- break;
-
- case Qt::ToolTipRole:
- // return Tooltip
- break;
- case Qt::ForegroundRole:
- return QBrush(myItemsColor);
- break;
- }
- return QVariant();
-}
-
-QVariant PartSet_TopDataModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- return QVariant();
-}
-
-int PartSet_TopDataModel::rowCount(const QModelIndex& theParent) const
-{
- if (!theParent.isValid())
- return 2; // In case of groups using it has to be +1
-
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- if (theParent.internalId() == ParamsFolder)
- return aRootDoc->size(ModelAPI_ResultParameter::group());
-
- if (theParent.internalId() == ConstructFolder)
- return aRootDoc->size(ModelAPI_ResultConstruction::group());
-
- //if (theParent.internalId() == GroupsFolder)
- // return aRootDoc->size(ModelAPI_ResultGroup::group());
-
- return 0;
-}
-
-int PartSet_TopDataModel::columnCount(const QModelIndex &parent) const
-{
- return 1;
-}
-
-QModelIndex PartSet_TopDataModel::index(int theRow, int theColumn, const QModelIndex& theParent) const
-{
- if (!theParent.isValid()) {
- switch (theRow) {
- case 0:
- return createIndex(theRow, theColumn, (qint32) ParamsFolder);
- case 1:
- return createIndex(theRow, theColumn, (qint32) ConstructFolder);
- //case 2:
- // return createIndex(theRow, theColumn, (qint32) GroupsFolder);
- }
- } else {
- if (theParent.internalId() == ParamsFolder)
- return createIndex(theRow, theColumn, (qint32) ParamObject);
-
- if (theParent.internalId() == ConstructFolder)
- return createIndex(theRow, theColumn, (qint32) ConstructObject);
-
- //if (theParent.internalId() == GroupsFolder)
- // return createIndex(theRow, theColumn, (qint32) GroupObject);
- }
- return QModelIndex();
-}
-
-QModelIndex PartSet_TopDataModel::parent(const QModelIndex& theIndex) const
-{
- int aId = (int) theIndex.internalId();
- switch (aId) {
- case ParamsFolder:
- case ConstructFolder:
- //case GroupsFolder:
- return QModelIndex();
- case ParamObject:
- return createIndex(0, 0, (qint32) ParamsFolder);
- case ConstructObject:
- return createIndex(1, 0, (qint32) ConstructFolder);
- //case GroupObject:
- // return createIndex(2, 0, (qint32) GroupsFolder);
- }
- return QModelIndex();
-}
-
-bool PartSet_TopDataModel::hasChildren(const QModelIndex& theParent) const
-{
- return rowCount(theParent) > 0;
-}
-
-ObjectPtr PartSet_TopDataModel::object(const QModelIndex& theIndex) const
-{
- switch (theIndex.internalId()) {
- case ParamsFolder:
- case ConstructFolder:
- return ObjectPtr();
- case ParamObject: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- return aRootDoc->object(ModelAPI_ResultParameter::group(), theIndex.row());