//! Returns index of the object
//! \param theObject object to find
- virtual QModelIndex objectIndex(const ObjectPtr theObject, int theColumn = 1) const;
+ virtual QModelIndex objectIndex(const ObjectPtr theObject, int theColumn = 0) const;
//! Clear internal data
virtual void clear();
/// Returns an index which is root of the given document
/// \param theDoc a document
- QModelIndex documentRootIndex(DocumentPtr theDoc, int theColumn = 1) const;
+ QModelIndex documentRootIndex(DocumentPtr theDoc, int theColumn = 0) const;
/// Returns last history object index
virtual QModelIndex lastHistoryIndex() const;
QModelIndex aRootIdx = aModel->documentRootIndex(theDoc);
int aNbChild = aModel->rowCount(aRootIdx);
for (int i = 0; i < aNbChild; i++) {
- QModelIndex aIdx = aModel->index(i, 1, aRootIdx);
+ QModelIndex aIdx = aModel->index(i, 0, aRootIdx);
aStates.push_back(myTreeView->isExpanded(aIdx));
}
return aStates;
}
}
}
+
+QMap<ObjectPtr, bool> XGUI_ObjectsBrowser::getFoldersState(DocumentPtr theDoc) const
+{
+ QMap<ObjectPtr, bool> aMap;
+
+ int aNb = theDoc->size(ModelAPI_Folder::group());
+ ObjectPtr aObj;
+ for (int i = 0; i < aNb; i++) {
+ aObj = theDoc->object(ModelAPI_Folder::group(), i);
+ QModelIndex aIdx = myDocModel->objectIndex(aObj);
+ aMap[aObj] = myTreeView->isExpanded(aIdx);
+ }
+ return aMap;
+}
+
+void XGUI_ObjectsBrowser::setFoldersState(const QMap<ObjectPtr, bool>& theStates)
+{
+ QMap<ObjectPtr, bool>::const_iterator aIt;
+ for (aIt = theStates.constBegin(); aIt != theStates.constEnd(); aIt++) {
+ QModelIndex aIdx = myDocModel->objectIndex(aIt.key());
+ myTreeView->setExpanded(aIdx, aIt.value());
+ }
+}
#include <ModelAPI_Object.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_Folder.h>
#include <QWidget>
#include <QTreeView>
#include <QLabel>
+#include <QMap>
class ModuleBase_IDocumentDataModel;
class XGUI_DataModel;
/// \param theParent - a parent item (by default from root)
void updateAllIndexes(int theColumn = 0, const QModelIndex& theParent = QModelIndex());
+ QMap<ObjectPtr, bool> getFoldersState(DocumentPtr theDoc) const;
+
+ void setFoldersState(const QMap<ObjectPtr, bool>& theStates);
+
public slots:
//! Called on Edit command request
void onEditItem();
QString aDescription = contextMenuMgr()->action(
isBefore ? "ADD_TO_FOLDER_BEFORE_CMD" : "ADD_TO_FOLDER_AFTER_CMD")->text();
+ QMap<ObjectPtr, bool> aStates = myObjectBrowser->getFoldersState(aDoc);
+
aMgr->startOperation(aDescription.toStdString());
aDoc->moveToFolder(aFeatures, aFolder);
aMgr->finishOperation();
+ myObjectBrowser->setFoldersState(aStates);
+
updateCommandStatus();
}
SessionPtr aMgr = ModelAPI_Session::get();
DocumentPtr aDoc = aMgr->activeDocument();
-
QString aDescription = contextMenuMgr()->action(
isBefore ? "ADD_OUT_FOLDER_BEFORE_CMD" : "ADD_OUT_FOLDER_AFTER_CMD")->text();
+ QMap<ObjectPtr, bool> aStates = myObjectBrowser->getFoldersState(aDoc);
+
aMgr->startOperation(aDescription.toStdString());
aDoc->removeFromFolder(aFeatures, isBefore);
aMgr->finishOperation();
+ myObjectBrowser->setFoldersState(aStates);
+
updateCommandStatus();
}