- QLineEdit* aEditor = dynamic_cast<QLineEdit*>(theEditor);
- if (aEditor) {
- QString aRes = aEditor->text();
- ObjectPtr aFeature = mySelectedData.first();
- PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
- aMgr->rootDocument()->startOperation();
- aFeature->data()->setName(qPrintable(aRes));
- aMgr->rootDocument()->finishOperation();
+ QSize aSize = theEvent->size();
+ if (aSize.isValid()) {
+ setColumnWidth(0, aSize.width() - SECOND_COL_WIDTH);
+ setColumnWidth(1, SECOND_COL_WIDTH);
+ }
+}
+
+void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
+{
+ if (theIndex.column() != 1)
+ return;
+ SessionPtr aMgr = ModelAPI_Session::get();
+ // When operation is opened then we can not change history
+ if (aMgr->isOperation())
+ return;
+ ModuleBase_IDocumentDataModel* aModel = dataModel();
+ if (aModel->flags(theIndex) == 0)
+ return;
+ ObjectPtr aObj = aModel->object(theIndex);
+
+ DocumentPtr aDoc = aMgr->activeDocument();
+
+ std::string aOpName = tr("History change").toStdString();
+ if (aObj.get()) {
+ if (aObj->document() != aDoc)
+ return;
+ aMgr->startOperation(aOpName);
+ aDoc->setCurrentFeature(std::dynamic_pointer_cast<ModelAPI_Feature>(aObj), true);
+ aMgr->finishOperation();
+ } else {
+ // Ignore clicks on folders outside current document
+ if ((theIndex.internalId() == -1) && (aDoc != aMgr->moduleDocument()))
+ // Clicked folder under root but active document is another
+ return;
+ if ((theIndex.internalId() != -1) && (aDoc.get() != theIndex.internalPointer()))
+ // Cliced not on active document folder
+ return;
+
+ aMgr->startOperation(aOpName);
+ aDoc->setCurrentFeature(FeaturePtr(), true);
+ aMgr->finishOperation();
+ }
+ QModelIndex aNewIndex = aModel->lastHistoryIndex();
+ QModelIndex aParent = theIndex.parent();
+ int aSize = aModel->rowCount(aParent);
+ for (int i = 0; i < aSize; i++) {
+ update(aModel->index(i, 0, aParent));