#include <ModelAPI_Document.h>
#include <QAbstractItemModel>
+#include <QColor>
/**\class XGUI_FeaturesModel
* \ingroup GUI
{
public:
XGUI_FeaturesModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
- QAbstractItemModel(theParent), myDocument(theDocument) {}
+ QAbstractItemModel(theParent), myDocument(theDocument), myItemsColor(Qt::black) {}
//! Returns Feature object by the given Model index.
//! Returns 0 if the given index is not index of a feature
//! Returns index corresponded to the group
virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
+ void setItemsColor(const QColor& theColor) { myItemsColor = theColor; }
+
+ QColor itemsColor() const { return myItemsColor; }
+
protected:
boost::shared_ptr<ModelAPI_Document> myDocument;
+ QColor myItemsColor;
};
#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);
}
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();
+ if (myActivePart) myActivePart->setItemsColor(PASSIVE_COLOR);
myActivePart = (myActivePart == aModel)? 0 : (XGUI_PartModel*)aModel;
- endResetModel();
- return true;
+ if (myActivePart) {
+ myActivePart->setItemsColor(ACTIVE_COLOR);
+ myModel->setItemsColor(PASSIVE_COLOR);
+ } else
+ myModel->setItemsColor(ACTIVE_COLOR);
+ return true;
}
}
return false;
bool isChanged = myDocModel->activatedIndex(aIndex);
QTreeView::mouseDoubleClickEvent(theEvent);
if (isChanged) {
- setExpanded(aIndex.parent(), true);
- setExpanded(aIndex, myDocModel->hasChildren(aIndex));
emit activePartChanged(myDocModel->activePart());
}
}
#include <ModelAPI_AttributeDocRef.h>
#include <QIcon>
+#include <QBrush>
XGUI_TopDataModel::XGUI_TopDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent)
: XGUI_FeaturesModel(theDocument, theParent)
case Qt::ToolTipRole:
// return Tooltip
break;
+ case Qt::ForegroundRole:
+ return QBrush(myItemsColor);
+ break;
}
return QVariant();
}
case Qt::ToolTipRole:
// return Tooltip
break;
+ case Qt::ForegroundRole:
+ return QBrush(myItemsColor);
+ break;
}
return QVariant();
}