removeSubModel(aDelPartModel);
removeRow(aStart, partFolderNode(0));
}
+ } if (aGroup == ModelAPI_Feature::group()) { // Update History node
+ int aRow = historyOffset() + aRootDoc->size(ModelAPI_Feature::group());
+ removeRow(aRow);
} else { // Update top groups (other except parts
QModelIndex aIndex = myModel->findGroup(aGroup);
int aStart = myModel->rowCount(aIndex);
}
if (aPartModel) {
QModelIndex aIndex = aPartModel->findGroup(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);
+ }
}
}
}
int PartSet_DocumentDataModel::rowCount(const QModelIndex& theParent) const
{
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
+ SessionPtr aSession = ModelAPI_Session::get();
+ if (!aSession->hasModuleDocument())
+ return 0;
+ DocumentPtr aRootDoc = aSession->moduleDocument();
if (!theParent.isValid()) {
// Size of external models
int aVal = historyOffset();
foreach (PartSet_PartModel* aPart, myPartModels)
delete aPart;
myPartModels.clear();
+ myActivePartModel = 0;
}
ObjectPtr PartSet_DocumentDataModel::object(const QModelIndex& theIndex) const
myIndexes.removeAt(aId);
aToRemove.removeLast();
}
- delete theModel;
+ if (theModel == myActivePartModel)
+ myActivePartModel = 0;
myPartModels.removeAll(theModel);
+ delete theModel;
}
{
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
} else {
QModelIndex* aIndex = toSourceModelIndex(theIndex);
const QAbstractItemModel* aModel = aIndex->model();
- return aModel->flags(*aIndex);
+ Qt::ItemFlags aFlags = aModel->flags(*aIndex);
+ if (aModel == myModel) {
+ if (myModel->object(*aIndex).get())
+ aFlags |= Qt::ItemIsEditable;
+ }
+ return aFlags;
}
}