//******************************************************************
//******************************************************************
PartSet_PartDataModel::PartSet_PartDataModel(QObject* theParent)
- : PartSet_PartModel(theParent), myHistoryBackOffset(0)
+ : PartSet_PartModel(theParent)
{
}
DocumentPtr aActiveDoc = ModelAPI_Session::get()->activeDocument();
QModelIndex aParent = theIndex.parent();
if (aActiveDoc == aPartDoc) {
- if ((theIndex.internalId() == HistoryObject) && (!aParent.isValid())) {
+ if (!aParent.isValid()) {
switch (theRole) {
case Qt::DecorationRole:
if (theIndex.row() == lastHistoryRow())
int PartSet_PartDataModel::lastHistoryRow() const
{
- return rowCount() - 1 - myHistoryBackOffset;
+ DocumentPtr aDoc = partDocument();
+ FeaturePtr aFeature = aDoc->currentFeature();
+ if (aFeature.get())
+ return getRowsNumber() + aDoc->index(aFeature);
+ else
+ return getRowsNumber() - 1;
}
void PartSet_PartDataModel::setLastHistoryItem(const QModelIndex& theIndex)
{
+ SessionPtr aMgr = ModelAPI_Session::get();
+ DocumentPtr aDoc = partDocument();
+ std::string aOpName = tr("History change").toStdString();
if (theIndex.internalId() == HistoryObject) {
- myHistoryBackOffset = rowCount() - 1 - theIndex.row();
+ ObjectPtr aObject = object(theIndex);
+ aMgr->startOperation(aOpName);
+ aDoc->setCurrentFeature(std::dynamic_pointer_cast<ModelAPI_Feature>(aObject));
+ aMgr->finishOperation();
+ } else {
+ aMgr->startOperation(aOpName);
+ aDoc->setCurrentFeature(FeaturePtr());
+ aMgr->finishOperation();
}
}