From: vsv Date: Tue, 27 Jun 2017 13:16:32 +0000 (+0300) Subject: Issue #2210: Object Browser : new show / hide button X-Git-Tag: V_2.9.0~23^2~34 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6fb5a58743556b877d64129002572de4116abd96;p=modules%2Fshaper.git Issue #2210: Object Browser : new show / hide button --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index bd8880387..a9845e2a5 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1263,7 +1263,7 @@ void PartSet_Module::processEvent(const std::shared_ptr& theMess aTreeView->setExpanded(myActivePartIndex, false); XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel(); - myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc); + myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc, 0); bool needUpdate = false; if (myActivePartIndex.isValid()) { needUpdate = aTreeView->isExpanded(myActivePartIndex); @@ -1335,7 +1335,7 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex) //aMgr->setActiveDocument(aMgr->moduleDocument()); return; } - if (theIndex.column() != 0) // Use only first column + if (theIndex.column() != 1) // Use only first column return; XGUI_Workshop* aWorkshop = getWorkshop(); diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 47c1be475..e7f6c5f55 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -724,7 +724,7 @@ void XGUI_ContextMenuMgr::addFeatures(QMenu* theMenu) const bool aIsRoot = false; foreach(QModelIndex aIdx, aSelectedIndexes) { // Process only first column - if (aIdx.column() == 0) { + if (aIdx.column() == 1) { aIsRoot = !aIdx.parent().isValid(); // Exit if the selected index belongs to non active document if (aIsRoot && (aActiveDoc != aMgr->moduleDocument())) diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 30cf4e574..196957cc5 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -19,6 +19,9 @@ // #include "XGUI_DataModel.h" +#include "XGUI_Workshop.h" +#include "XGUI_ObjectsBrowser.h" +#include "XGUI_Displayer.h" #include @@ -81,6 +84,9 @@ ModelAPI_Document* getSubDocument(void* theObj) XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParent)//, //myIsEventsProcessingBlocked(false) { + XGUI_ObjectsBrowser* aOB = qobject_cast(theParent); + myWorkshop = aOB->workshop(); + Events_Loop* aLoop = Events_Loop::loop(); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); @@ -136,7 +142,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess } else { int aFolderId = myXMLReader->rootFolderId(aObjType); if (aFolderId != -1) { - insertRow(aRow, createIndex(aFolderId, 0, (void*)Q_NULLPTR)); + insertRow(aRow, createIndex(aFolderId, 1, (void*)Q_NULLPTR)); } } } @@ -162,7 +168,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess if (aRow != -1) { int aFolderId = folderId(aObjType, aDoc.get()); if (aFolderId != -1) { - QModelIndex aParentFolder = createIndex(aFolderId, 0, aDoc.get()); + QModelIndex aParentFolder = createIndex(aFolderId, 1, aDoc.get()); insertRow(aRow, aParentFolder); emit dataChanged(aParentFolder, aParentFolder); } @@ -210,7 +216,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess // Process root sub-folder int aFolderId = myXMLReader->rootFolderId(aGroup); if (aFolderId != -1) { - QModelIndex aFolderIndex = createIndex(aFolderId, 0, (void*)Q_NULLPTR); + QModelIndex aFolderIndex = createIndex(aFolderId, 1, (void*)Q_NULLPTR); removeRow(aRow, aFolderIndex); //rebuildBranch(0, aRow); } @@ -239,7 +245,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess // List of objects under a folder int aFolderId = folderId(aGroup, aDoc.get()); if (aFolderId != -1) { - QModelIndex aFolderRoot = createIndex(aFolderId, 0, aDoc.get()); + QModelIndex aFolderRoot = createIndex(aFolderId, 1, aDoc.get()); removeRow(aRow, aFolderRoot); //rebuildBranch(0, aRow, aFolderRoot); } @@ -303,7 +309,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess if (aGroup == myXMLReader->rootType()) // Update objects under root aStartId = foldersCount(); else // Update objects in folder under root - aParent = createIndex(folderId(aGroup), 0, (void*)Q_NULLPTR); + aParent = createIndex(folderId(aGroup), 1, (void*)Q_NULLPTR); } else { // Update a sub-document if (aGroup == myXMLReader->subType()) { @@ -312,7 +318,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess aStartId = foldersCount(aDoc.get()); } else // update folder in sub-document - aParent = createIndex(folderId(aGroup, aDoc.get()), 0, aDoc.get()); + aParent = createIndex(folderId(aGroup, aDoc.get()), 1, aDoc.get()); } int aChildNb = rowCount(aParent); rebuildBranch(aStartId, aChildNb - aStartId, aParent); @@ -363,7 +369,7 @@ ObjectPtr XGUI_DataModel::object(const QModelIndex& theIndex) const } //****************************************************** -QModelIndex XGUI_DataModel::objectIndex(const ObjectPtr theObject) const +QModelIndex XGUI_DataModel::objectIndex(const ObjectPtr theObject, int theColumn) const { std::string aType = theObject->groupName(); DocumentPtr aDoc = theObject->document(); @@ -398,7 +404,7 @@ QModelIndex XGUI_DataModel::objectIndex(const ObjectPtr theObject) const if (aRow == -1) return QModelIndex(); else - return createIndex(aRow, 0, theObject.get()); + return createIndex(aRow, theColumn, theObject.get()); } SessionPtr aSession = ModelAPI_Session::get(); DocumentPtr aRootDoc = aSession->moduleDocument(); @@ -409,7 +415,7 @@ QModelIndex XGUI_DataModel::objectIndex(const ObjectPtr theObject) const // The object from sub document aRow += foldersCount(aDoc.get()); } - return createIndex(aRow, 0, theObject.get()); + return createIndex(aRow, theColumn, theObject.get()); } //****************************************************** @@ -420,10 +426,26 @@ QVariant XGUI_DataModel::data(const QModelIndex& theIndex, int theRole) const int aNbFolders = foldersCount(); int theIndexRow = theIndex.row(); - if ((theRole == Qt::DecorationRole) && (theIndex == lastHistoryIndex())) - return QIcon(":pictures/arrow.png"); + if (theRole == Qt::DecorationRole) { + if (theIndex == lastHistoryIndex()) + return QIcon(":pictures/arrow.png"); + else if (theIndex.column() == 0) { + VisibilityState aState = getVisibilityState(theIndex); + switch (aState) { + case NoneState: + return QIcon(); + case Visible: + return QIcon(":pictures/eyeopen.png"); + case SemiVisible: + return QIcon(":pictures/eyemiclosed.png"); + case Hidden: + return QIcon(":pictures/eyeclosed.png"); + } + } + } - if (theIndex.column() == 1) + //if (theIndex.column() == 1) + if (theIndex.column() != 1) return QVariant(); quintptr aParentId = theIndex.internalId(); @@ -596,7 +618,7 @@ int XGUI_DataModel::rowCount(const QModelIndex& theParent) const //****************************************************** int XGUI_DataModel::columnCount(const QModelIndex& theParent) const { - return 2; + return 3; } //****************************************************** @@ -616,7 +638,7 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex & int aObjId = theRow - aNbFolders; if (aObjId < aRootDoc->size(aType)) { ObjectPtr aObj = aRootDoc->object(aType, aObjId); - aIndex = objectIndex(aObj); + aIndex = objectIndex(aObj, theColumn); } } } else { @@ -626,7 +648,7 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex & std::string aType = myXMLReader->rootFolderType(aParentPos); if (theRow < aRootDoc->size(aType)) { ObjectPtr aObj = aRootDoc->object(aType, theRow); - aIndex = objectIndex(aObj); + aIndex = objectIndex(aObj, theColumn); } } else { // It is an object which could have children @@ -641,7 +663,7 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex & std::string aType = myXMLReader->subFolderType(aParentRow); if (theRow < aDoc->size(aType)) { ObjectPtr aObj = aDoc->object(aType, theRow); - aIndex = objectIndex(aObj); + aIndex = objectIndex(aObj, theColumn); } } } else { @@ -659,24 +681,24 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex & // this is an object under sub document root std::string aType = myXMLReader->subType(); ObjectPtr aObj = aSubDoc->object(aType, theRow - aNbSubFolders); - aIndex = objectIndex(aObj); + aIndex = objectIndex(aObj, theColumn); } } else { // Check for composite object ModelAPI_CompositeFeature* aCompFeature = dynamic_cast(aParentObj); if (aCompFeature) { - aIndex = objectIndex(aCompFeature->subFeature(theRow)); + aIndex = objectIndex(aCompFeature->subFeature(theRow), theColumn); } else { ModelAPI_ResultCompSolid* aCompRes = dynamic_cast(aParentObj); if (aCompRes) - aIndex = objectIndex(aCompRes->subResult(theRow)); + aIndex = objectIndex(aCompRes->subResult(theRow), theColumn); else { ModelAPI_ResultField* aFieldRes = dynamic_cast(aParentObj); if (aFieldRes) { - aIndex = createIndex(theRow, 0, aFieldRes->step(theRow)); + aIndex = createIndex(theRow, theColumn, aFieldRes->step(theRow)); } } } @@ -684,8 +706,6 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex & } } } - if (theColumn != 0) - return createIndex(aIndex.row(), theColumn, aIndex.internalPointer()); return aIndex; } @@ -754,7 +774,7 @@ QModelIndex XGUI_DataModel::parent(const QModelIndex& theIndex) const // return first level of folder index int aFolderId = myXMLReader->rootFolderId(aType); // Items in a one row must have the same parent - return createIndex(aFolderId, 0, (void*)Q_NULLPTR); + return createIndex(aFolderId, 1, (void*)Q_NULLPTR); } } else { if (aType == myXMLReader->subType()) @@ -763,7 +783,7 @@ QModelIndex XGUI_DataModel::parent(const QModelIndex& theIndex) const // return first level of folder index int aFolderId = folderId(aType, aSubDoc.get()); // Items in a one row must have the same parent - return createIndex(aFolderId, 0, aSubDoc.get()); + return createIndex(aFolderId, 1, aSubDoc.get()); } } } @@ -821,15 +841,15 @@ Qt::ItemFlags XGUI_DataModel::flags(const QModelIndex& theIndex) const if (aObj) { // An object if (aObj->isDisabled()) - return theIndex.column() == 1? Qt::ItemIsSelectable : aNullFlag; + return theIndex.column() == 2? Qt::ItemIsSelectable : aNullFlag; if (aSession->moduleDocument() != aObj->document()) if (aActiveDoc != aObj->document()) - return theIndex.column() == 1? Qt::ItemIsSelectable : aNullFlag; + return theIndex.column() == 2? Qt::ItemIsSelectable : aNullFlag; bool isCompositeSub = false; - // An object which is sub-object of a composite object can not be accessible in column 1 - if (theIndex.column() == 1) { + // An object which is sub-object of a composite object can not be accessible in column 2 + if (theIndex.column() == 2) { ObjectPtr aObjPtr = aObj->data()->owner(); FeaturePtr aFeature = std::dynamic_pointer_cast(aObjPtr); if (aFeature.get()) { @@ -866,7 +886,7 @@ Qt::ItemFlags XGUI_DataModel::flags(const QModelIndex& theIndex) const } //****************************************************** -QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDoc) const +QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDoc, int aColumn) const { SessionPtr aSession = ModelAPI_Session::get(); DocumentPtr aRootDoc = aSession->moduleDocument(); @@ -882,7 +902,7 @@ QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDo if (myXMLReader->rootType() == ModelAPI_Feature::group()) { aRow += foldersCount(); } - return createIndex(aRow, 0, aObj.get()); + return createIndex(aRow, aColumn, aObj.get()); } } } else { // If document is attached to feature @@ -896,7 +916,7 @@ QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDo int aRow = i; if (myXMLReader->rootType() == ModelAPI_Feature::group()) aRow += foldersCount(); - return createIndex(aRow, 0, aObj.get()); + return createIndex(aRow, aColumn, aObj.get()); } } } @@ -904,14 +924,14 @@ QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDo } //****************************************************** -QModelIndex XGUI_DataModel::documentRootIndex(DocumentPtr theDoc) const +QModelIndex XGUI_DataModel::documentRootIndex(DocumentPtr theDoc, int theColumn) const { SessionPtr aSession = ModelAPI_Session::get(); DocumentPtr aRootDoc = aSession->moduleDocument(); if (theDoc == aRootDoc) return QModelIndex(); else - return findDocumentRootIndex(theDoc.get()); + return findDocumentRootIndex(theDoc.get(), theColumn); } //****************************************************** @@ -994,12 +1014,12 @@ QModelIndex XGUI_DataModel::lastHistoryIndex() const FeaturePtr aFeature = aCurDoc->currentFeature(true); if (aFeature.get()) { QModelIndex aInd = objectIndex(aFeature); - return createIndex(aInd.row(), 1, aInd.internalPointer()); + return createIndex(aInd.row(), 2, aInd.internalPointer()); } else { if (aCurDoc == aSession->moduleDocument()) - return createIndex(foldersCount() - 1, 1, -1); + return createIndex(foldersCount() - 1, 2, -1); else - return createIndex(foldersCount(aCurDoc.get()) - 1, 1, aCurDoc.get()); + return createIndex(foldersCount(aCurDoc.get()) - 1, 2, aCurDoc.get()); } } @@ -1052,3 +1072,37 @@ void XGUI_DataModel::rebuildBranch(int theRow, int theCount, const QModelIndex& // myIsEventsProcessingBlocked = theState; // return aPreviousState; //} + +//****************************************************** +XGUI_DataModel::VisibilityState + XGUI_DataModel::getVisibilityState(const QModelIndex& theIndex) const +{ + ObjectPtr aObj = object(theIndex); + if (aObj.get()) { + ResultPtr aResObj = std::dynamic_pointer_cast(aObj); + if (aResObj.get()) { + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast(aResObj); + if (aCompRes.get()) { + VisibilityState aState = NoneState; + for (int i = 0; i < aCompRes->numberOfSubs(true); i++) { + ResultPtr aSubRes = aCompRes->subResult(i, true); + VisibilityState aS = aDisplayer->isVisible(aSubRes)? Visible : Hidden; + if (aState == NoneState) + aState = aS; + else if (aState != aS) { + aState = SemiVisible; + break; + } + } + return aState; + } else { + if (aDisplayer->isVisible(aResObj)) + return Visible; + else + return Hidden; + } + } + } + return NoneState; +} diff --git a/src/XGUI/XGUI_DataModel.h b/src/XGUI/XGUI_DataModel.h index 39cbd3dc4..cbcb030da 100644 --- a/src/XGUI/XGUI_DataModel.h +++ b/src/XGUI/XGUI_DataModel.h @@ -30,6 +30,7 @@ #include class Config_DataModelReader; +class XGUI_Workshop; /**\class XGUI_DataModel * \ingroup GUI @@ -63,7 +64,7 @@ public: //! Returns index of the object //! \param theObject object to find - virtual QModelIndex objectIndex(const ObjectPtr theObject) const; + virtual QModelIndex objectIndex(const ObjectPtr theObject, int theColumn = 1) const; //! Clear internal data virtual void clear(); @@ -130,7 +131,7 @@ public: /// Returns an index which is root of the given document /// \param theDoc a document - QModelIndex documentRootIndex(DocumentPtr theDoc) const; + QModelIndex documentRootIndex(DocumentPtr theDoc, int theColumn = 1) const; /// Returns last history object index virtual QModelIndex lastHistoryIndex() const; @@ -146,9 +147,15 @@ signals: void treeRebuilt(); private: + enum VisibilityState { + NoneState, + Visible, + SemiVisible, + Hidden }; + /// Find a root index which contains objects of the given document /// \param theDoc the document object - QModelIndex findDocumentRootIndex(const ModelAPI_Document* theDoc) const; + QModelIndex findDocumentRootIndex(const ModelAPI_Document* theDoc, int aColumn = 1) const; /// Returns number of folders in document. /// Considered folders which has to be shown only if they are not empty. @@ -171,13 +178,15 @@ private: /// \param theParent - index of parent folder void rebuildBranch(int theRow, int theCount, const QModelIndex& theParent = QModelIndex()); - /// Returns list of folders types which can not be shown empty /// \param fromRoot - root document flag QStringList listOfShowNotEmptyFolders(bool fromRoot = true) const; + VisibilityState getVisibilityState(const QModelIndex& theIndex) const; + Config_DataModelReader* myXMLReader; + XGUI_Workshop* myWorkshop; //bool myIsEventsProcessingBlocked; }; diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 101ab27fb..5b86c1c03 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -38,8 +38,12 @@ #include #include +#ifdef DEBUG_INDXES +#include +#endif /// Width of second column (minimum acceptable = 27) +#define FIRST_COL_WIDTH 30 #define SECOND_COL_WIDTH 30 @@ -81,11 +85,12 @@ XGUI_DataTree::XGUI_DataTree(QWidget* theParent) : QTreeView(theParent) { setHeaderHidden(true); + setTreePosition(1); setEditTriggers(QAbstractItemView::NoEditTriggers); setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionMode(QAbstractItemView::ExtendedSelection); - setItemDelegateForColumn(0, new XGUI_TreeViewItemDelegate(this)); + setItemDelegateForColumn(1, new XGUI_TreeViewItemDelegate(this)); connect(this, SIGNAL(doubleClicked(const QModelIndex&)), SLOT(onDoubleClick(const QModelIndex&))); @@ -141,15 +146,44 @@ void XGUI_DataTree::resizeEvent(QResizeEvent* theEvent) QTreeView::resizeEvent(theEvent); QSize aSize = theEvent->size(); if (aSize.isValid()) { - setColumnWidth(0, aSize.width() - SECOND_COL_WIDTH - 7); - setColumnWidth(1, SECOND_COL_WIDTH); + setColumnWidth(0, FIRST_COL_WIDTH); + setColumnWidth(1, aSize.width() - SECOND_COL_WIDTH - FIRST_COL_WIDTH - 12); + setColumnWidth(2, SECOND_COL_WIDTH); } } -void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex) +#ifdef DEBUG_INDXES +void XGUI_DataTree::mousePressEvent(QMouseEvent* theEvent) { - if (theIndex.column() != 1) + QTreeView::mousePressEvent(theEvent); + if (theEvent->button() != Qt::MidButton) return; + QModelIndex aInd = indexAt(theEvent->pos()); + QString aTxt = QString("r=%1 c=%2 p=%3").arg(aInd.row()).arg(aInd.column()).arg((long)aInd.internalPointer()); + + QModelIndex aPar = aInd.parent(); + QString aTxt1 = QString("r=%1 c=%2 p=%3").arg(aPar.row()).arg(aPar.column()).arg((long)aPar.internalPointer()); + QToolTip::showText(theEvent->globalPos(), aTxt + '\n' + aTxt1); +} +#endif + +void XGUI_DataTree::mouseReleaseEvent(QMouseEvent* theEvent) +{ + QTreeView::mouseReleaseEvent(theEvent); +#ifdef DEBUG_INDXES + if (theEvent->button() != Qt::MidButton) + return; + QToolTip::hideText(); +#endif + if (theEvent->button() == Qt::LeftButton) { + QModelIndex aInd = indexAt(theEvent->pos()); + if (aInd.column() == 0) + processEyeClick(aInd); + } +} + +void XGUI_DataTree::processHistoryChange(const QModelIndex& theIndex) +{ SessionPtr aMgr = ModelAPI_Session::get(); // When operation is opened then we can not change history if (aMgr->isOperation()) @@ -187,6 +221,35 @@ void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex) for (int i = 0; i < aSize; i++) { update(aModel->index(i, 0, aParent)); update(aModel->index(i, 1, aParent)); + update(aModel->index(i, 2, aParent)); + } +} + +void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex) +{ + XGUI_DataModel* aModel = dataModel(); + ObjectPtr aObj = aModel->object(theIndex); + if (aObj.get()) { + ResultPtr aResObj = std::dynamic_pointer_cast(aObj); + if (aResObj.get()) { + aResObj->setDisplayed(!aResObj->isDisplayed()); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + update(theIndex); + } + // Update list of selected objects because this event happens after selection event in object browser + XGUI_ObjectsBrowser* aObjBrowser = qobject_cast(parent()); + if (aObjBrowser) { + aObjBrowser->onSelectionChanged(); + } + } +} + +void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex) +{ + switch (theIndex.column()) { + case 2: + processHistoryChange(theIndex); + break; } } @@ -289,8 +352,8 @@ void XGUI_ActiveDocLbl::unselect() //******************************************************************** //******************************************************************** //******************************************************************** -XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) - : QWidget(theParent), myDocModel(0) +XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent, XGUI_Workshop* theWorkshop) + : QWidget(theParent), myDocModel(0), myWorkshop(theWorkshop) { QVBoxLayout* aLayout = new QVBoxLayout(this); ModuleBase_Tools::zeroMargins(aLayout); @@ -473,12 +536,20 @@ void XGUI_ObjectsBrowser::clearContent() myTreeView->clear(); } +//*************************************************** void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected) +{ + onSelectionChanged(); +} + +//*************************************************** +void XGUI_ObjectsBrowser::onSelectionChanged() { emit selectionChanged(); } +//*************************************************** QObjectPtrList XGUI_ObjectsBrowser::selectedObjects(QModelIndexList* theIndexes) const { QObjectPtrList aList; @@ -486,7 +557,7 @@ QObjectPtrList XGUI_ObjectsBrowser::selectedObjects(QModelIndexList* theIndexes) XGUI_DataModel* aModel = dataModel(); QModelIndexList::const_iterator aIt; for (aIt = aIndexes.constBegin(); aIt != aIndexes.constEnd(); ++aIt) { - if ((*aIt).column() == 0) { + if ((*aIt).column() == 1) { ObjectPtr aObject = aModel->object(*aIt); if (aObject) { aList.append(aObject); @@ -517,7 +588,7 @@ std::list XGUI_ObjectsBrowser::getStateForDoc(DocumentPtr theDoc) const QModelIndex aRootIdx = aModel->documentRootIndex(theDoc); int aNbChild = aModel->rowCount(aRootIdx); for (int i = 0; i < aNbChild; i++) { - QModelIndex aIdx = aModel->index(i, 0, aRootIdx); + QModelIndex aIdx = aModel->index(i, 1, aRootIdx); aStates.push_back(myTreeView->isExpanded(aIdx)); } return aStates; diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index c1a9527bd..fd522c61a 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -34,6 +34,9 @@ class ModuleBase_IDocumentDataModel; class XGUI_DataModel; class Config_DataModelReader; +class XGUI_Workshop; + +//#define DEBUG_INDXES /** * \ingroup GUI @@ -118,6 +121,22 @@ public slots: /// Redefinition of virtual method virtual void resizeEvent(QResizeEvent* theEvent); + + /// Redefinition of virtual method + virtual void mouseReleaseEvent(QMouseEvent* theEvent); + +#ifdef DEBUG_INDXES + virtual void mousePressEvent(QMouseEvent* theEvent); +#endif + +private: + /// Process a history change request + /// \param theIndex a clicked data index + void processHistoryChange(const QModelIndex& theIndex); + + /// Process a visibility change request + /// \param theIndex a clicked data index + void processEyeClick(const QModelIndex& theIndex); }; /**\class XGUI_ObjectsBrowser @@ -130,7 +149,7 @@ Q_OBJECT public: /// Constructor /// \param theParent a parent widget - XGUI_ObjectsBrowser(QWidget* theParent); + XGUI_ObjectsBrowser(QWidget* theParent, XGUI_Workshop* theWorkshop); virtual ~XGUI_ObjectsBrowser(); //! Returns Model which provides access to data objects @@ -182,6 +201,12 @@ Q_OBJECT /// \param theStates list of booleans with state expanded or not void setStateForDoc(DocumentPtr theDoc, const std::list& theStates); + /// Returns current workshop + XGUI_Workshop* workshop() const { return myWorkshop; } + + void onSelectionChanged(); + + public slots: //! Called on Edit command request void onEditItem(); @@ -219,6 +244,7 @@ signals: XGUI_DataModel* myDocModel; XGUI_ActiveDocLbl* myActiveDocLbl; XGUI_DataTree* myTreeView; + XGUI_Workshop* myWorkshop; /// A field to store expanded items before model reset QModelIndexList myExpandedItems; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 462359e09..2dee78840 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1228,7 +1228,7 @@ QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent) aObjDock->setWindowTitle(tr("Object browser")); aObjDock->setStyleSheet( "::title { position: relative; padding-left: 5px; text-align: left center }"); - myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock); + myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock, this); myObjectBrowser->setXMLReader(myDataModelXMLReader); myModule->customizeObjectBrowser(myObjectBrowser); aObjDock->setWidget(myObjectBrowser); diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index 86cc1b28f..222dfd208 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -56,5 +56,9 @@ pictures/wire.png pictures/result.png pictures/find_result.png + + pictures/eyeclosed.png + pictures/eyemiclosed.png + pictures/eyeopen.png diff --git a/src/XGUI/pictures/eyeclosed.png b/src/XGUI/pictures/eyeclosed.png new file mode 100644 index 000000000..df57123b2 Binary files /dev/null and b/src/XGUI/pictures/eyeclosed.png differ diff --git a/src/XGUI/pictures/eyemiclosed.png b/src/XGUI/pictures/eyemiclosed.png new file mode 100644 index 000000000..e05e411fb Binary files /dev/null and b/src/XGUI/pictures/eyemiclosed.png differ diff --git a/src/XGUI/pictures/eyeopen.png b/src/XGUI/pictures/eyeopen.png new file mode 100644 index 000000000..e578fe6d2 Binary files /dev/null and b/src/XGUI/pictures/eyeopen.png differ