From: vsv Date: Fri, 11 Apr 2014 09:03:50 +0000 (+0400) Subject: Update just modified part tree in object browser X-Git-Tag: V_0.1~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7949d72fa59228ccd233f482b6883f254e544f8d;p=modules%2Fshaper.git Update just modified part tree in object browser --- diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index b7f65b746..1e53953f7 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -12,6 +12,7 @@ #include +#include XGUI_DocumentDataModel::XGUI_DocumentDataModel(QObject* theParent) @@ -38,21 +39,32 @@ XGUI_DocumentDataModel::~XGUI_DocumentDataModel() void XGUI_DocumentDataModel::processEvent(const Event_Message* theMessage) { - beginResetModel(); - int aNbParts = myDocument->featuresIterator(PARTS_GROUP)->numIterationsLeft(); - if (myPartModels.size() != aNbParts) { // resize internal models - while (myPartModels.size() > aNbParts) { - delete myPartModels.last(); - myPartModels.removeLast(); - } - while (myPartModels.size() < aNbParts) { - myPartModels.append(new XGUI_PartDataModel(myDocument, this)); + if (QString(theMessage->eventID().eventText()) == EVENT_FEATURE_CREATED) { + // Add a new part + int aStart = myModel->rowCount(QModelIndex()) + myPartModels.size(); + beginInsertRows(QModelIndex(), aStart, aStart + 1); + XGUI_PartDataModel* aModel = new XGUI_PartDataModel(myDocument, this); + aModel->setPartId(myPartModels.count()); + myPartModels.append(aModel); + endInsertRows(); + } else { + // Reset whole tree + beginResetModel(); + int aNbParts = myDocument->featuresIterator(PARTS_GROUP)->numIterationsLeft(); + if (myPartModels.size() != aNbParts) { // resize internal models + while (myPartModels.size() > aNbParts) { + delete myPartModels.last(); + myPartModels.removeLast(); + } + while (myPartModels.size() < aNbParts) { + myPartModels.append(new XGUI_PartDataModel(myDocument, this)); + } + for (int i = 0; i < myPartModels.size(); i++) + myPartModels.at(i)->setPartId(i); } - for (int i = 0; i < myPartModels.size(); i++) - myPartModels.at(i)->setPartId(i); + clearModelIndexes(); + endResetModel(); } - clearModelIndexes(); - endResetModel(); } QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole) const