Salome HOME
Using mouse double click for history line change
[modules/shaper.git] / src / PartSet / PartSet_PartDataModel.cpp
index 1f30ed2b264a8b84f6a656392abfa4e30ea5bd06..ec4dabffaccfbcc66badffccf4f7229e11279f2f 100644 (file)
@@ -361,8 +361,11 @@ QVariant PartSet_PartDataModel::data(const QModelIndex& theIndex, int theRole) c
       // return Tooltip
       break;
     case Qt::ForegroundRole:
+      if (theIndex.internalId() == HistoryObject) {
+        if (theIndex.row() > lastHistoryRow())
+          return QBrush(Qt::lightGray);
+      }
       return QBrush(myItemsColor);
-      break;
   }
   return QVariant();
 }
@@ -571,3 +574,29 @@ int PartSet_PartDataModel::lastHistoryRow() const
 {
   return rowCount() - 1 - myHistoryBackOffset;
 }
+
+void PartSet_PartDataModel::setLastHistoryItem(const QModelIndex& theIndex)
+{
+  if (theIndex.internalId() == HistoryObject) {
+    myHistoryBackOffset = rowCount() - 1 - theIndex.row();
+  }
+}
+
+QModelIndex PartSet_PartDataModel::lastHistoryItem() const
+{
+  return index(lastHistoryRow(), 1);
+}
+
+Qt::ItemFlags PartSet_PartDataModel::flags(const QModelIndex& theIndex) const
+{
+  Qt::ItemFlags aFlags = Qt::ItemIsSelectable;
+  if (object(theIndex)) {
+    aFlags |= Qt::ItemIsEditable;
+  }
+  if (theIndex.internalId() == HistoryObject) {
+    if (theIndex.row() <= lastHistoryRow() || (theIndex.column() == 1))
+      aFlags |= Qt::ItemIsEnabled;
+  } else
+    aFlags |= Qt::ItemIsEnabled;
+  return aFlags;
+}