#include <QIcon>
#include <QString>
+#include <QBrush>
+#define ACTIVE_COLOR QColor(0,72,140)
+#define PASSIVE_COLOR Qt::black
+
XGUI_DocumentDataModel::XGUI_DocumentDataModel(QObject* theParent)
: QAbstractItemModel(theParent), myActivePart(0)
{
// Create a top part of data tree model
myModel = new XGUI_TopDataModel(myDocument, this);
+ myModel->setItemsColor(ACTIVE_COLOR);
}
if (aUpdMsg->group().compare(PARTS_GROUP) == 0) { // Updsate only Parts group
int aStart = myPartModels.size();
removeSubModel(myPartModels.size() - 1);
- removeRow(aStart - 1, partFolderNode());
+ removeRow(aStart, partFolderNode());
} else { // Update top groups (other except parts
QModelIndex aIndex = myModel->findGroup(aUpdMsg->group());
int aStart = myModel->rowCount(aIndex);
aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
- removeRow(aStart - 1, aIndex);
+ removeRow(aStart, aIndex);
}
} else {
XGUI_PartModel* aPartModel = 0;
QModelIndex aIndex = aPartModel->findGroup(aUpdMsg->group());
int aStart = aPartModel->rowCount(aIndex);
aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
- removeRow(aStart - 1, aIndex);
+ removeRow(aStart, aIndex);
}
}
return QIcon(":pictures/constr_folder.png");
case Qt::ToolTipRole:
return tr("Parts folder");
+ case Qt::ForegroundRole:
+ if (myActivePart)
+ return QBrush(PASSIVE_COLOR);
+ else
+ return QBrush(ACTIVE_COLOR);
default:
return QVariant();
}
return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
case Qt::ToolTipRole:
return tr("Feature object");
+ case Qt::ForegroundRole:
+ if (myActivePart)
+ return QBrush(PASSIVE_COLOR);
+ else
+ return QBrush(ACTIVE_COLOR);
default:
return QVariant();
}
if (!isSubModel(aModel))
return 0;
- if (isPartSubModel(aModel)) {
+ /*if (isPartSubModel(aModel)) {
if (aModel != myActivePart)
return 0;
- }
+ }*/
return aModel->rowCount(*aParent);
}
if (isPartSubModel(aModel)) {
// if this is root node (Part item index)
if (!aIndex->parent().isValid()) {
- beginResetModel();
- myActivePart = (myActivePart == aModel)? 0 : (XGUI_PartModel*)aModel;
- endResetModel();
- return true;
+ if (myActivePart) myActivePart->setItemsColor(PASSIVE_COLOR);
+
+ if (myActivePart == aModel) {
+ myActivePart = 0;
+ myActivePartIndex = QModelIndex();
+ } else {
+ myActivePart = (XGUI_PartModel*)aModel;
+ myActivePartIndex = theIndex;
+ }
+
+ if (myActivePart) {
+ myActivePart->setItemsColor(ACTIVE_COLOR);
+ myModel->setItemsColor(PASSIVE_COLOR);
+ } else
+ myModel->setItemsColor(ACTIVE_COLOR);
+ return true;
}
}
return false;
if (myActivePart)
return myActivePart->part();
return FeaturePtr();
-}
\ No newline at end of file
+}
+
+void XGUI_DocumentDataModel::deactivatePart()
+{
+ if (myActivePart)
+ myActivePart->setItemsColor(PASSIVE_COLOR);
+ myActivePart = 0;
+ myModel->setItemsColor(ACTIVE_COLOR);
+}