Salome HOME
Make Table of parameters view according to proposal of DBC
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 29 Apr 2016 10:03:25 +0000 (13:03 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 29 Apr 2016 10:03:39 +0000 (13:03 +0300)
src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp
src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.h

index 526850d6326bf71cde31d668cee2de89a248b408..6dc416d93fd384f99d047b41375cc86e8d3f74e1 100644 (file)
@@ -80,10 +80,11 @@ void ParametersPlugin_ItemDelegate::paint(QPainter* painter,
 {
   QBrush aBrush = painter->brush();
   QPen aPen = painter->pen();
-  if (!isEditable(index))
+//  if (!isEditable(index))
+  if (!index.parent().isValid())
     painter->setBrush(Qt::lightGray);
 
-  painter->setPen(Qt::darkGray);
+  painter->setPen(Qt::lightGray);
   painter->drawRect(option.rect);
   painter->setPen(aPen);
 
@@ -168,11 +169,13 @@ ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theP
   QStringList aNames;
   aNames<<tr("Parameters");
   myParameters = new QTreeWidgetItem(aNames);
+  myParameters->setFlags(Qt::ItemIsEnabled);
   myTable->addTopLevelItem(myParameters);
 
   aNames.clear();
   aNames<<tr("Features");
   myFeatures = new QTreeWidgetItem(aNames);
+  myFeatures->setFlags(Qt::ItemIsEnabled);
   myTable->addTopLevelItem(myFeatures);
 
   QHBoxLayout* aBtnLayout = new QHBoxLayout(this);
@@ -392,6 +395,9 @@ void ParametersPlugin_WidgetParamsMgr::onCloseEditor(QWidget* theEditor,
     {
       AttributeStringPtr aStringAttr = aFeature->string(ParametersPlugin_Parameter::VARIABLE_ID());
       if (!aText.isEmpty()) {
+        while (aText.indexOf(" ") != -1) {
+          aText.replace(" ", "");
+        }
         if (hasName(aText)) {
           myMessage = tr("Name %1 already exists.").arg(aText);
           QTimer::singleShot(50, this, SLOT(sendWarning()));
@@ -441,7 +447,7 @@ void ParametersPlugin_WidgetParamsMgr::updateItem(QTreeWidgetItem* theItem,
   if (theFeaturesList.count() != theItem->childCount()) {
     if (theItem->childCount()  < theFeaturesList.count()) {
       while (theItem->childCount() != theFeaturesList.count()) 
-        theItem->addChild(createNewItem());
+        theItem->addChild(createNewItem(theItem));
     } else {
       while (theItem->childCount() != theFeaturesList.count()) 
         theItem->removeChild(theItem->child(theItem->childCount() - 1));
@@ -475,14 +481,17 @@ FeaturePtr ParametersPlugin_WidgetParamsMgr::createParameter() const
 }
 
 
-QTreeWidgetItem* ParametersPlugin_WidgetParamsMgr::createNewItem() const
+QTreeWidgetItem* ParametersPlugin_WidgetParamsMgr::createNewItem(QTreeWidgetItem* theParent) const
 {
   QStringList aValues;
   aValues << NoName;
   aValues << NoValue;
 
   QTreeWidgetItem* aItem = new QTreeWidgetItem(aValues);
-  aItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
+  if (theParent == myParameters)
+    aItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
+  else 
+    aItem->setFlags(Qt::NoItemFlags);
   return aItem;
 }
 
index 7f2b493ebc0448446e8b9f8afa32088ab93032d6..9762385768bc638a93dc6a822f0dad77bf46564e 100644 (file)
@@ -95,7 +95,7 @@ private:
   FeaturePtr createParameter() const;
 
   /// Creates a new item
-  QTreeWidgetItem* createNewItem() const;
+  QTreeWidgetItem* createNewItem(QTreeWidgetItem* theParent) const;
 
   /// Returns currently selected item
   QTreeWidgetItem* selectedItem() const;