addAction("RENAME_CMD", aAction);
connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRename()));
- aAction = new QAction(QIcon(":pictures/move.png"), tr("Move to the end"), this);
+ aAction = new QAction(QIcon(":pictures/move.png"), XGUI_Workshop::MOVE_TO_END_COMMAND, this);
addAction("MOVE_CMD", aAction);
aAction = new QAction(QIcon(":pictures/color.png"), tr("Color..."), this);
aParent = createIndex(folderId(aGroup, aDoc.get()), 0, aDoc.get());
}
int aChildNb = rowCount(aParent);
- rebuildBranch(aStartId, aChildNb - aStartId);
+ rebuildBranch(aStartId, aChildNb - aStartId, aParent);
} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
DocumentPtr aDoc = ModelAPI_Session::get()->activeDocument();
if (aDoc != aRootDoc) {
}
}
+//***************************************************
+QModelIndexList XGUI_ObjectsBrowser::expandedItems(const QModelIndex& theParent) const
+{
+ QModelIndexList aIndexes;
+ QModelIndex aIndex;
+ for (int i = 0; i < myDocModel->rowCount(); i++) {
+ aIndex = myDocModel->index(i, 0, theParent);
+ if (myDocModel->hasChildren(aIndex)) {
+ if (myTreeView->isExpanded(aIndex)) {
+ aIndexes.append(aIndex);
+ QModelIndexList aSubIndexes = expandedItems(aIndex);
+ if (!aSubIndexes.isEmpty())
+ aIndexes.append(aSubIndexes);
+ }
+ }
+ }
+ return aIndexes;
+}
+
//***************************************************
void XGUI_ObjectsBrowser::rebuildDataTree()
{
+ QModelIndexList aIndexList = expandedItems();
myDocModel->rebuildDataTree();
+ foreach(QModelIndex aIndex, aIndexList) {
+ myTreeView->setExpanded(aIndex, true);
+ }
update();
}
void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
private:
+ QModelIndexList expandedItems(const QModelIndex& theParent = QModelIndex()) const;
//! Internal model
XGUI_DataModel* myDocModel;
#include <dlfcn.h>
#endif
+
+QString XGUI_Workshop::MOVE_TO_END_COMMAND = QObject::tr("Move to the end");
+
//#define DEBUG_DELETE
XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
{
objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
SessionPtr aMgr = ModelAPI_Session::get();
+ std::list<std::string> aUndoList = aMgr->undoList();
if (aMgr->isOperation()) {
/// this is important for nested operations
/// when sketch operation is active, this condition is false and
/// the sketch operation is not aborted
operationMgr()->onAbortOperation();
}
- for (int i = 0; i < theTimes; ++i) {
+ std::list<std::string>::const_iterator aIt = aUndoList.cbegin();
+ for (int i = 0; (i < theTimes) && (aIt != aUndoList.cend()); ++i, ++aIt) {
aMgr->undo();
+ if (QString((*aIt).c_str()) == MOVE_TO_END_COMMAND)
+ myObjectBrowser->rebuildDataTree();
}
operationMgr()->updateApplyOfOperations();
objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
SessionPtr aMgr = ModelAPI_Session::get();
+ std::list<std::string> aRedoList = aMgr->redoList();
if (aMgr->isOperation()) {
/// this is important for nested operations
/// when sketch operation is active, this condition is false and
/// the sketch operation is not aborted
operationMgr()->onAbortOperation();
}
- for (int i = 0; i < theTimes; ++i) {
+ std::list<std::string>::const_iterator aIt = aRedoList.cbegin();
+ for (int i = 0; (i < theTimes) && (aIt != aRedoList.cend()); ++i, ++aIt) {
aMgr->redo();
+ if (QString((*aIt).c_str()) == MOVE_TO_END_COMMAND)
+ myObjectBrowser->rebuildDataTree();
}
operationMgr()->updateApplyOfOperations();
updateCommandStatus();
class QAction;
+
/**\class XGUI_Workshop
* \ingroup GUI
* \brief Class which defines a configuration of the application (Workshop) and launches it.
/// \param theUpdateViewer update viewer flag
void synchronizeGroupInViewer(const DocumentPtr& theDoc, const std::string& theGroup, bool theUpdateViewer);
+ /// A constant string used for "Move to end" command definition
+ /// It is used for specific processing of Undo/Redo for this command.
+ static QString MOVE_TO_END_COMMAND;
+
signals:
/// Emitted when selection happens in Salome viewer
void salomeViewerSelection();