]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1438: Provide editing cells with tab
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 22 Apr 2016 14:48:15 +0000 (17:48 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 22 Apr 2016 14:48:30 +0000 (17:48 +0300)
src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp
src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.h

index 6d1aa48141432f3c9efeca9b0bb8c237415856c6..2f1e3a6a3638057ff35ea9f72587db55c877774d 100644 (file)
@@ -49,11 +49,16 @@ public:
     const QStyleOptionViewItem& option, 
     const QModelIndex& index ) const;
   
-  //virtual QWidget* createEditor(QWidget* parent, 
-  //                              const QStyleOptionViewItem& option, 
-  //                              const QModelIndex& index) const;
+  virtual QWidget* createEditor(QWidget* parent, 
+                                const QStyleOptionViewItem& option, 
+                                const QModelIndex& index) const;
 
   bool isEditable(const QModelIndex& theIndex) const;
+
+  QModelIndex editIndex() const { return myEditingIdx; }
+
+private:
+  mutable QModelIndex myEditingIdx;
 };
 
 bool ParametersPlugin_ItemDelegate::isEditable(const QModelIndex& theIndex) const
@@ -84,6 +89,14 @@ void ParametersPlugin_ItemDelegate::paint(QPainter* painter,
   painter->setBrush(aBrush);
 }
 
+QWidget* ParametersPlugin_ItemDelegate::createEditor(QWidget* parent, 
+                                                     const QStyleOptionViewItem& option, 
+                                                     const QModelIndex& index) const
+{
+  myEditingIdx = index;
+  return QStyledItemDelegate::createEditor(parent, option, index);
+}
+
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -299,16 +312,15 @@ void ParametersPlugin_WidgetParamsMgr::onDoubleClick(const QModelIndex& theIndex
 {
   if (myDelegate->isEditable(theIndex)) {
     myTable->edit(theIndex);
-    myEditingIndex = theIndex;
   }
 }
 
 void ParametersPlugin_WidgetParamsMgr::onCloseEditor(QWidget* theEditor, 
                                                      QAbstractItemDelegate::EndEditHint theHint)
 {
-  FeaturePtr aFeature = myParametersList.at(myEditingIndex.row());
-  QTreeWidgetItem* aItem = myParameters->child(myEditingIndex.row());
-  int aColumn = myEditingIndex.column();
+  FeaturePtr aFeature = myParametersList.at(myDelegate->editIndex().row());
+  QTreeWidgetItem* aItem = myParameters->child(myDelegate->editIndex().row());
+  int aColumn = myDelegate->editIndex().column();
   QString aText = aItem->text(aColumn);
   bool isModified = false;
 
@@ -355,7 +367,9 @@ void ParametersPlugin_WidgetParamsMgr::onCloseEditor(QWidget* theEditor,
   if (!isModified)
     return;
   Events_Loop* aLoop = Events_Loop::loop();
+  aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
   aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+  aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 
   ResultParameterPtr aResult = 
     std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aFeature->firstResult());
@@ -364,8 +378,6 @@ void ParametersPlugin_WidgetParamsMgr::onCloseEditor(QWidget* theEditor,
       aResult->data()->real(ModelAPI_ResultParameter::VALUE());
     aItem->setText(Col_Result, QString::number(aValueAttribute->value()));
   }
-  myEditingIndex = QModelIndex();
-
   if (aColumn == Col_Equation)
     updateParametersPart();
   updateFeaturesPart();
@@ -387,7 +399,8 @@ void ParametersPlugin_WidgetParamsMgr::updateItem(QTreeWidgetItem* theItem,
   foreach(QStringList aFeature, theFeaturesList) {
     int aCol = 0;
     foreach(QString aText, aFeature) {
-      theItem->child(i)->setText(aCol, aText);
+      if (aText.length() > 0)
+        theItem->child(i)->setText(aCol, aText);
       aCol++;
     }
     i++;
index f722402afefa349b91dcb6813a34cc6a0be26bce..eb3903e03c3861cbebb82b37c45b749f6c3a2462 100644 (file)
@@ -107,7 +107,6 @@ private:
   QTreeWidgetItem* myFeatures;
   QTreeWidgetItem* myParameters;
   ParametersPlugin_ItemDelegate* myDelegate;
-  QModelIndex myEditingIndex;
 
   QList<FeaturePtr> myParametersList;