X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_DocumentDataModel.cpp;h=84ac7a1697ea1820628022c43d0111c696a38c67;hb=857b1f72d9703c46c6c8c9bb239821d314344c86;hp=c4f24582188fc90e13937eb837db889eea873041;hpb=c83f12f16a84be5881402a01e4c1345dd454be10;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_DocumentDataModel.cpp b/src/PartSet/PartSet_DocumentDataModel.cpp index c4f245821..84ac7a169 100644 --- a/src/PartSet/PartSet_DocumentDataModel.cpp +++ b/src/PartSet/PartSet_DocumentDataModel.cpp @@ -2,6 +2,7 @@ #include "PartSet_DocumentDataModel.h" #include "PartSet_PartDataModel.h" +#include "PartSet_TopDataModel.h" #include "PartSet_Module.h" //#include "XGUI_Tools.h" @@ -136,6 +137,9 @@ void PartSet_DocumentDataModel::processEvent(const std::shared_ptrsize(ModelAPI_Feature::group()); + removeRow(aRow); } else { // Update top groups (other except parts QModelIndex aIndex = myModel->findGroup(aGroup); int aStart = myModel->rowCount(aIndex); @@ -152,9 +156,15 @@ void PartSet_DocumentDataModel::processEvent(const std::shared_ptrfindGroup(aGroup); - int aStart = aPartModel->rowCount(aIndex); - aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex)); - removeRow(aStart, aIndex); + if (aIndex.isValid()) { + int aStart = aPartModel->rowCount(aIndex); + aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex)); + removeRow(aStart, aIndex); + } else { + int aRow = aPartModel->rowCount(); + aIndex = createIndex(aPartModel->position() + historyOffset(), 0, HistoryNode); + removeRow(aRow, aIndex); + } } } } @@ -279,7 +289,20 @@ QVariant PartSet_DocumentDataModel::data(const QModelIndex& theIndex, int theRol case Qt::DecorationRole: return featureIcon(aFeature); case Qt::ToolTipRole: - return tr("Feature object"); + { + ResultPtr aResult = aFeature->firstResult(); + bool isResultAndNotLoaded = false; + if( aResult.get() ) + { + ResultPartPtr aResultPart = std::dynamic_pointer_cast( aResult ); + if( aResultPart.get() ) + isResultAndNotLoaded = !aResultPart->isActivated(); + } + if( isResultAndNotLoaded ) + return tr( "The part should be activated before the user may edit it" ); + else + return tr( "Feature object" ); + } case Qt::ForegroundRole: if (theIndex.row() > lastHistoryRow()) return QBrush(Qt::lightGray); @@ -483,6 +506,7 @@ void PartSet_DocumentDataModel::clearSubModels() foreach (PartSet_PartModel* aPart, myPartModels) delete aPart; myPartModels.clear(); + myActivePartModel = 0; } ObjectPtr PartSet_DocumentDataModel::object(const QModelIndex& theIndex) const @@ -546,8 +570,10 @@ void PartSet_DocumentDataModel::removeSubModel(PartSet_PartModel* theModel) myIndexes.removeAt(aId); aToRemove.removeLast(); } - delete theModel; + if (theModel == myActivePartModel) + myActivePartModel = 0; myPartModels.removeAll(theModel); + delete theModel; } @@ -630,7 +656,7 @@ Qt::ItemFlags PartSet_DocumentDataModel::flags(const QModelIndex& theIndex) cons { if ((theIndex.internalId() >= PartsFolder) && (theIndex.internalId() <= PartResult)) { Qt::ItemFlags aFlags = Qt::ItemIsSelectable; - if (object(theIndex)) { + if (object(theIndex).get()) { aFlags |= Qt::ItemIsEditable; } // Disable items which are below of last history row @@ -646,7 +672,7 @@ Qt::ItemFlags PartSet_DocumentDataModel::flags(const QModelIndex& theIndex) cons const QAbstractItemModel* aModel = aIndex->model(); Qt::ItemFlags aFlags = aModel->flags(*aIndex); if (aModel == myModel) { - if (myModel->object(*aIndex)) + if (myModel->object(*aIndex).get()) aFlags |= Qt::ItemIsEditable; } return aFlags; @@ -789,6 +815,8 @@ void PartSet_DocumentDataModel::onMouseDoubleClick(const QModelIndex& theIndex) { if (theIndex.column() != 1) return; + if (flags(theIndex) == 0) + return; QTreeView* aTreeView = dynamic_cast(sender()); if ((theIndex.internalId() >= PartsFolder) && (theIndex.internalId() <= PartResult)) { if (myActivePartModel)