-// Copyright (C) 2014-2020 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2024 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <QBrush>
#include <QMap>
+#include <QPalette>
#define ACTIVE_COLOR QColor(Qt::black)
return QBrush(DISABLED_COLOR);
if (!aFlags.testFlag(Qt::ItemIsEditable))
return QBrush(SELECTABLE_COLOR);
- return ACTIVE_COLOR;
+ return activeItemColor();
}
return ModuleBase_ITreeNode::data(theColumn, theRole);
}
+QColor PartSet_TreeNode::activeItemColor() const
+{
+ // instead of ACTIVE_COLOR (black),
+ // use the color text of the current theme (white or black or other)
+ // to make it readable in dark theme (and light theme as well)
+ QColor color = QPalette().text().color() ;
+ return color;
+}
+
//////////////////////////////////////////////////////////////////////////////////
QVariant PartSet_ObjectNode::data(int theColumn, int theRole) const
AttributeDoublePtr aValueAttribute =
aParam->data()->real(ModelAPI_ResultParameter::VALUE());
QString aVal = QString::number(aValueAttribute->value());
- QString aTitle = QString(myObject->data()->name().c_str());
+ QString aTitle = QString::fromStdWString(myObject->data()->name());
return aTitle + " = " + aVal;
}
- return myObject->data()->name().c_str();
+ return QString::fromStdWString(myObject->data()->name());
}
break;
case Qt::DecorationRole:
else
return QIcon();
}
- case Qt::ForegroundRole:
- if (myObject->groupName() == ModelAPI_Feature::group()) {
- std::vector<int> aColor =
- Config_PropManager::color("Visualization", "feature_objectbrowser_color");
- return QColor(aColor[0], aColor[1], aColor[2]);
- }
- break;
}
return PartSet_TreeNode::data(theColumn, theRole);
}
+QColor PartSet_ObjectNode::activeItemColor() const
+{
+ if (myObject.get() && myObject->groupName() == ModelAPI_Feature::group()) {
+ std::vector<int> aColor =
+ Config_PropManager::color("Visualization", "feature_objectbrowser_color");
+ return QColor(aColor[0], aColor[1], aColor[2]);
+ }
+ return PartSet_TreeNode::activeItemColor();
+}
+
+
Qt::ItemFlags PartSet_ObjectNode::flags(int theColumn) const
{
if (myObject->isDisabled()) {
} else {
DocumentPtr aDoc = myObject->document();
SessionPtr aSession = ModelAPI_Session::get();
+
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(myObject);
+ if (aFeature.get() && aFeature->getKind() == "Group")
+ {
+ std::shared_ptr<ModelAPI_CompositeFeature> anOwner =
+ ModelAPI_Tools::compositeOwner (aFeature);
+
+ if (anOwner.get() && anOwner->getKind() == "ImportResult")
+ return aDefaultFlag;
+ }
+
if (aSession->activeDocument() == aDoc)
return aEditingFlag;
}
ResultPartPtr aPartRes = getPartResult(myObject);
if (aPartRes.get()) {
if (aPartRes->partDoc().get() == NULL)
- return QString(myObject->data()->name().c_str()) + " (Not loaded)";
+ return QString::fromStdWString(myObject->data()->name()) + " (Not loaded)";
}
- return QString(myObject->data()->name().c_str());
+ return QString::fromStdWString(myObject->data()->name());
}
case Qt::DecorationRole:
return ModuleBase_IconFactory::get()->getIcon(myObject);
QVariant PartSet_ObjectFolderNode::data(int theColumn, int theRole) const
{
if (theRole == Qt::ForegroundRole) {
- std::vector<int> aColor =
- Config_PropManager::color("Visualization", "feature_objectbrowser_color");
- return QColor(aColor[0], aColor[1], aColor[2]);
+ if (!myObject->isDisabled()) {
+ std::vector<int> aColor =
+ Config_PropManager::color("Visualization", "feature_objectbrowser_color");
+ return QColor(aColor[0], aColor[1], aColor[2]);
+ }
}
return PartSet_ObjectNode::data(theColumn, theRole);