diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index adca3763..09dd3fa9 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -488,7 +488,7 @@ void GraphController::createDummyGraphForTokenIds(const std::vector& tokenId { node->hasParent = false; - if (node->data->isType(NodeType::NODE_NAMESPACE | NodeType::NODE_PACKAGE)) + if (node->data->getType().isPackage()) { node->name = node->data->getFullName(); } @@ -546,7 +546,7 @@ std::vector> GraphController::createDummyNodeTopDown( m_dummyGraphNodes.emplace(result->data->getId(), result); nodes.push_back(result); - if (node->isType(NodeType::NODE_NAMESPACE)) + if (node->getType().isPackage()) { node->forEachChildNode( [&nodes, &ancestorId, this](Node* child) @@ -1197,6 +1197,7 @@ void GraphController::bundleNodesByType() LOG_ERROR("Nodes left after bundling for overview"); } + // crate a sub-bundle for anonymous namespaces for (const std::shared_ptr& bundleNode : m_dummyNodes) { if (!bundleNode->isBundleNode()) @@ -1300,7 +1301,7 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const if (node->isGraphNode()) { - margins = GraphViewStyle::getMarginsForNodeType(node->data->getType(), node->childVisible); + margins = GraphViewStyle::getMarginsForDataNode(node->data->getType().getNodeStyle(), node->data->getType().hasIcon(), node->childVisible); } else if (node->isAccessNode()) { @@ -1314,7 +1315,7 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const { if (node->bundledNodeType.getType() != NodeType::NODE_NON_INDEXED) { - margins = GraphViewStyle::getMarginsForNodeType(node->bundledNodeType, false); + margins = GraphViewStyle::getMarginsForDataNode(node->bundledNodeType.getNodeStyle(), node->bundledNodeType.hasIcon(), false); } else { diff --git a/src/lib/component/view/GraphViewStyle.cpp b/src/lib/component/view/GraphViewStyle.cpp index ab41e283..445670a0 100644 --- a/src/lib/component/view/GraphViewStyle.cpp +++ b/src/lib/component/view/GraphViewStyle.cpp @@ -11,8 +11,8 @@ int GraphViewStyle::s_gridCellSize = 5; int GraphViewStyle::s_gridCellPadding = 10; -std::unordered_map GraphViewStyle::s_charWidths; -std::unordered_map GraphViewStyle::s_charHeights; +std::unordered_map GraphViewStyle::s_charWidths; +std::unordered_map GraphViewStyle::s_charHeights; std::shared_ptr GraphViewStyle::s_impl; @@ -145,41 +145,19 @@ void GraphViewStyle::loadStyleSettings() s_edgeColors.clear(); s_screenMatchColors.clear(); - s_gridCellPadding = getImpl()->getCharHeightForNodeType(NodeType::NODE_TYPE) - 8; + s_gridCellPadding = getImpl()->getCharHeight(NodeType::STYLE_BIG_NODE) - 8; s_gridCellSize = s_gridCellPadding / 2; } -float GraphViewStyle::getCharWidthForNodeType(NodeType type) +size_t GraphViewStyle::getFontSizeForStyleType(NodeType::StyleType type) { - std::unordered_map::const_iterator it = s_charWidths.find(type.getReadableTypeString()); - - if (it != s_charWidths.end()) + switch (type) { - return it->second; + case NodeType::STYLE_PACKAGE: + case NodeType::STYLE_SMALL_NODE: + return s_fontSize - 3; } - - float charWidth = getImpl()->getCharWidthForNodeType(type); - s_charWidths.emplace(type.getReadableTypeString(), charWidth); - return charWidth; -} - -float GraphViewStyle::getCharHeightForNodeType(NodeType type) -{ - std::unordered_map::const_iterator it = s_charHeights.find(type.getReadableTypeString()); - - if (it != s_charHeights.end()) - { - return it->second; - } - - float charHeight = getImpl()->getCharHeightForNodeType(type); - s_charHeights.emplace(type.getReadableTypeString(), charHeight); - return charHeight; -} - -size_t GraphViewStyle::getFontSizeForNodeType(NodeType type) -{ - return s_fontSize + type.getFontSizeOffset(); + return s_fontSize; } size_t GraphViewStyle::getFontSizeOfAccessNode() @@ -227,35 +205,25 @@ std::string GraphViewStyle::getFontNameOfTextNode() return "Fira Sans"; } -GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(NodeType type, bool hasChildren) +GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForDataNode(NodeType::StyleType type, bool hasIcon, bool hasChildren) { NodeMargins margins; margins.spacingX = 6; margins.spacingY = 8; - switch (type.getType()) + switch (type) { - case NodeType::NODE_NAMESPACE: - case NodeType::NODE_PACKAGE: + case NodeType::STYLE_PACKAGE: margins.left = margins.right = 5; margins.top = margins.bottom = 3; margins.iconWidth = s_fontSize - 3; break; + case NodeType::STYLE_BIG_NODE: + if (hasIcon) + { + margins.iconWidth = s_fontSize + 11; + } - case NodeType::NODE_ENUM: - case NodeType::NODE_TYPEDEF: - case NodeType::NODE_FILE: - case NodeType::NODE_MACRO: - margins.iconWidth = s_fontSize + 11; - case NodeType::NODE_NON_INDEXED: - case NodeType::NODE_TYPE: - case NodeType::NODE_BUILTIN_TYPE: - case NodeType::NODE_STRUCT: - case NodeType::NODE_CLASS: - case NodeType::NODE_UNION: - case NodeType::NODE_INTERFACE: - case NodeType::NODE_TEMPLATE_PARAMETER_TYPE: - case NodeType::NODE_TYPE_PARAMETER: if (hasChildren) { margins.left = margins.right = 10; @@ -268,12 +236,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(NodeType type, margins.top = margins.bottom = 8; } break; - - case NodeType::NODE_FUNCTION: - case NodeType::NODE_METHOD: - case NodeType::NODE_GLOBAL_VARIABLE: - case NodeType::NODE_FIELD: - case NodeType::NODE_ENUM_CONSTANT: + case NodeType::STYLE_SMALL_NODE: if (hasChildren) { margins.top = margins.bottom = 5; @@ -289,8 +252,8 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(NodeType type, break; } - margins.charWidth = getCharWidthForNodeType(type); - margins.charHeight = getCharHeightForNodeType(type); + margins.charWidth = getCharWidth(type); + margins.charHeight = getCharHeight(type); return margins; } @@ -343,7 +306,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfExpandToggleNode() GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfBundleNode() { - return getMarginsForNodeType(NodeType::NODE_ENUM, false); + return getMarginsForDataNode(NodeType::STYLE_BIG_NODE, true, false); } GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfTextNode() @@ -359,13 +322,30 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfTextNode() GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType( NodeType type, bool defined, bool isActive, bool isFocused, bool hasChildren, bool hasQualifier +){ + return getStyleForNodeType( + type.getNodeStyle(), + type.getUnderscoredTypeString(), + type.getIconPath(), + defined, + isActive, + isFocused, + hasChildren, + hasQualifier + ); +} + +GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType( + NodeType::StyleType type, const std::string& underscoredTypeString, + const FilePath& iconPath, bool defined, bool isActive, bool isFocused, + bool hasChildren, bool hasQualifier ){ NodeStyle style; - style.color = getNodeColor(type.getUnderscoredTypeString(), isActive || isFocused); + style.color = getNodeColor(underscoredTypeString, isActive || isFocused); style.fontName = getFontNameForDataNode(); - style.fontSize = getFontSizeForNodeType(type); + style.fontSize = getFontSizeForStyleType(type); if (isActive || isFocused) { @@ -381,28 +361,15 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType( style.borderWidth = 1; } - switch (type.getType()) + switch (type) { - case NodeType::NODE_NAMESPACE: - case NodeType::NODE_PACKAGE: + case NodeType::STYLE_PACKAGE: style.cornerRadius = 0; style.textOffset.x = 5; style.textOffset.y = 3; break; - case NodeType::NODE_NON_INDEXED: - case NodeType::NODE_TYPE: - case NodeType::NODE_BUILTIN_TYPE: - case NodeType::NODE_STRUCT: - case NodeType::NODE_CLASS: - case NodeType::NODE_UNION: - case NodeType::NODE_INTERFACE: - case NodeType::NODE_ENUM: - case NodeType::NODE_TYPEDEF: - case NodeType::NODE_TEMPLATE_PARAMETER_TYPE: - case NodeType::NODE_TYPE_PARAMETER: - case NodeType::NODE_FILE: - case NodeType::NODE_MACRO: + case NodeType::STYLE_BIG_NODE: if (hasChildren) { style.cornerRadius = 20; @@ -417,11 +384,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType( } break; - case NodeType::NODE_FUNCTION: - case NodeType::NODE_METHOD: - case NodeType::NODE_GLOBAL_VARIABLE: - case NodeType::NODE_FIELD: - case NodeType::NODE_ENUM_CONSTANT: + case NodeType::STYLE_SMALL_NODE: style.cornerRadius = 8; style.textOffset.x = 5; style.textOffset.y = 3; @@ -430,11 +393,36 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType( style.hasHatching = !defined; - addIcon(type, hasChildren, &style); + if (!iconPath.empty()) + { + style.iconPath = iconPath; + if (type == NodeType::STYLE_PACKAGE) + { + style.iconSize = s_fontSize - 4; + style.iconOffset.x = -1; + style.iconOffset.y = 5; + } + else + { + style.iconSize = s_fontSize + 2; + + if (hasChildren) + { + style.iconOffset.x = 11; + style.textOffset.x = 6; + } + else + { + style.iconOffset.x = 9; + } + + style.iconOffset.y = 9; + } + } if (hasQualifier) { - if (style.iconPath.size()) + if (!style.iconPath.empty()) { style.iconOffset.x = style.iconOffset.x + 5; } @@ -493,14 +481,16 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfCountCircle() GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfBundleNode(bool isFocused) { - NodeStyle style = getStyleForNodeType(NodeType::NODE_CLASS, true, false, isFocused, false, false); - - style.color = getNodeColor("bundle", isFocused); - - addIcon(NodeType::NODE_ENUM, false, &style); - style.iconPath = ResourcePaths::getGuiPath().str() + "graph_view/images/bundle.png"; - - return style; + return getStyleForNodeType( + NodeType::STYLE_BIG_NODE, + "bundle", + ResourcePaths::getGuiPath().concat(FilePath("graph_view/images/bundle.png")), + true, + false, + isFocused, + false, + false + ); } GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfQualifier() @@ -710,45 +700,30 @@ const GraphViewStyle::NodeColor& GraphViewStyle::getScreenMatchColor(bool focus) return s_screenMatchColors.find(focus)->second; } -void GraphViewStyle::addIcon(NodeType type, bool hasChildren, NodeStyle* style) +float GraphViewStyle::getCharWidth(NodeType::StyleType type) { - switch (type.getType()) - { - case NodeType::NODE_NAMESPACE: - case NodeType::NODE_PACKAGE: - style->iconPath = ResourcePaths::getGuiPath().str() + "graph_view/images/namespace.png"; - style->iconSize = s_fontSize - 4; - style->iconOffset.x = -1; - style->iconOffset.y = 5; - return; + std::unordered_map::const_iterator it = s_charWidths.find(type); - case NodeType::NODE_ENUM: - style->iconPath = ResourcePaths::getGuiPath().str() + "graph_view/images/enum.png"; - break; - case NodeType::NODE_TYPEDEF: - style->iconPath = ResourcePaths::getGuiPath().str() + "graph_view/images/typedef.png"; - break; - case NodeType::NODE_MACRO: - style->iconPath = ResourcePaths::getGuiPath().str() + "graph_view/images/macro.png"; - break; - case NodeType::NODE_FILE: - style->iconPath = ResourcePaths::getGuiPath().str() + "graph_view/images/file.png"; - break; - default: - return; + if (it != s_charWidths.end()) + { + return it->second; } - style->iconSize = s_fontSize + 2; + float charWidth = getImpl()->getCharWidth(type); + s_charWidths.emplace(type, charWidth); + return charWidth; +} - if (hasChildren) - { - style->iconOffset.x = 11; - style->textOffset.x = 6; - } - else +float GraphViewStyle::getCharHeight(NodeType::StyleType type) +{ + std::unordered_map::const_iterator it = s_charHeights.find(type); + + if (it != s_charHeights.end()) { - style->iconOffset.x = 9; + return it->second; } - style->iconOffset.y = 9; + float charHeight = getImpl()->getCharHeight(type); + s_charHeights.emplace(type, charHeight); + return charHeight; } diff --git a/src/lib/component/view/GraphViewStyle.h b/src/lib/component/view/GraphViewStyle.h index 595bc251..32ecf895 100644 --- a/src/lib/component/view/GraphViewStyle.h +++ b/src/lib/component/view/GraphViewStyle.h @@ -65,7 +65,7 @@ public: Vec2i textOffset; - std::string iconPath; + FilePath iconPath; Vec2i iconOffset; size_t iconSize; @@ -99,10 +99,7 @@ public: static void loadStyleSettings(); - static float getCharWidthForNodeType(NodeType type); - static float getCharHeightForNodeType(NodeType type); - - static size_t getFontSizeForNodeType(NodeType type); + static size_t getFontSizeForStyleType(NodeType::StyleType type); static size_t getFontSizeOfAccessNode(); static size_t getFontSizeOfExpandToggleNode(); static size_t getFontSizeOfCountCircle(); @@ -114,7 +111,7 @@ public: static std::string getFontNameOfExpandToggleNode(); static std::string getFontNameOfTextNode(); - static NodeMargins getMarginsForNodeType(NodeType type, bool hasChildren); + static NodeMargins getMarginsForDataNode(NodeType::StyleType type, bool hasIcon, bool hasChildren); static NodeMargins getMarginsOfAccessNode(AccessKind access); static NodeMargins getMarginsOfExpandToggleNode(); static NodeMargins getMarginsOfBundleNode(); @@ -145,10 +142,16 @@ public: static int s_gridCellPadding; private: - static void addIcon(NodeType type, bool hasChildren, NodeStyle* style); + static NodeStyle getStyleForNodeType( + NodeType::StyleType type, const std::string& underscoredTypeString, + const FilePath& iconPath, bool defined, bool isActive, bool isFocused, + bool hasChildren, bool hasQualifier); - static std::unordered_map s_charWidths; - static std::unordered_map s_charHeights; + static float getCharWidth(NodeType::StyleType type); + static float getCharHeight(NodeType::StyleType type); + + static std::unordered_map s_charWidths; + static std::unordered_map s_charHeights; static std::shared_ptr s_impl; diff --git a/src/lib/component/view/GraphViewStyleImpl.h b/src/lib/component/view/GraphViewStyleImpl.h index 492948db..1e0219e0 100644 --- a/src/lib/component/view/GraphViewStyleImpl.h +++ b/src/lib/component/view/GraphViewStyleImpl.h @@ -7,8 +7,8 @@ class GraphViewStyleImpl { public: virtual ~GraphViewStyleImpl() { } - virtual float getCharWidthForNodeType(NodeType type) = 0; - virtual float getCharHeightForNodeType(NodeType type) = 0; + virtual float getCharWidth(NodeType::StyleType type) = 0; + virtual float getCharHeight(NodeType::StyleType type) = 0; virtual float getGraphViewZoomDifferenceForPlatform() = 0; }; diff --git a/src/lib/data/NodeType.cpp b/src/lib/data/NodeType.cpp index c2c62588..993e4ab0 100644 --- a/src/lib/data/NodeType.cpp +++ b/src/lib/data/NodeType.cpp @@ -1,5 +1,6 @@ #include "data/NodeType.h" +#include "utility/ResourcePaths.h" #include "utility/utilityString.h" NodeType::NodeType(Type type) @@ -24,6 +25,13 @@ bool NodeType::isFile() const return ((m_type & mask) > 0); } +bool NodeType::isNonIndexed() const +{ + const NodeType::TypeMask mask = + NodeType::NODE_NON_INDEXED; + return ((m_type & mask) > 0); +} + bool NodeType::isInheritable() const { // what about java enums? @@ -54,6 +62,14 @@ bool NodeType::isCallable() const return ((m_type & mask) > 0); } +bool NodeType::isVariable() const +{ + const NodeType::TypeMask mask = + NodeType::NODE_GLOBAL_VARIABLE | + NodeType::NODE_FIELD; + return ((m_type & mask) > 0); +} + bool NodeType::isUsable() const { const NodeType::TypeMask mask = @@ -102,14 +118,46 @@ bool NodeType::isVisibleAsParentInGraph() const return !isPackage(); } -int NodeType::getFontSizeOffset() const +FilePath NodeType::getIconPath() const { switch (m_type) { case NodeType::NODE_NAMESPACE: case NodeType::NODE_PACKAGE: - return - 3; + // package icon cannot be changed + return ResourcePaths::getGuiPath().concat(FilePath("graph_view/images/namespace.png")); + case NodeType::NODE_ENUM: + return ResourcePaths::getGuiPath().concat(FilePath("graph_view/images/enum.png")); + case NodeType::NODE_TYPEDEF: + return ResourcePaths::getGuiPath().concat(FilePath("graph_view/images/typedef.png")); + case NodeType::NODE_MACRO: + return ResourcePaths::getGuiPath().concat(FilePath("graph_view/images/macro.png")); + case NodeType::NODE_FILE: + return ResourcePaths::getGuiPath().concat(FilePath("graph_view/images/file.png")); + default: + return FilePath(); + } +} +bool NodeType::hasIcon() const +{ + const NodeType::TypeMask mask = + NodeType::NODE_NAMESPACE | + NodeType::NODE_PACKAGE | + NodeType::NODE_ENUM | + NodeType::NODE_TYPEDEF | + NodeType::NODE_FILE | + NodeType::NODE_MACRO; + return ((m_type & mask) > 0); +} + +NodeType::StyleType NodeType::getNodeStyle() const +{ + switch (m_type) + { + case NodeType::NODE_NAMESPACE: + case NodeType::NODE_PACKAGE: + return STYLE_PACKAGE; case NodeType::NODE_NON_INDEXED: case NodeType::NODE_TYPE: case NodeType::NODE_BUILTIN_TYPE: @@ -123,14 +171,13 @@ int NodeType::getFontSizeOffset() const case NodeType::NODE_TYPE_PARAMETER: case NodeType::NODE_FILE: case NodeType::NODE_MACRO: - return 0; - + return STYLE_BIG_NODE; case NodeType::NODE_FUNCTION: case NodeType::NODE_METHOD: case NodeType::NODE_GLOBAL_VARIABLE: case NodeType::NODE_FIELD: case NodeType::NODE_ENUM_CONSTANT: - return - 3; + return STYLE_SMALL_NODE; } } diff --git a/src/lib/data/NodeType.h b/src/lib/data/NodeType.h index 0cb9c8f8..2cd9d446 100644 --- a/src/lib/data/NodeType.h +++ b/src/lib/data/NodeType.h @@ -6,6 +6,7 @@ #include #include +#include "utility/file/FilePath.h" #include "utility/types.h" class NodeType @@ -41,6 +42,13 @@ public: NODE_MAX_VALUE = NODE_UNION }; + enum StyleType + { + STYLE_PACKAGE = 0, + STYLE_SMALL_NODE = 1, + STYLE_BIG_NODE = 2 + }; + NodeType(Type type); bool operator==(const NodeType& o) const; @@ -48,15 +56,19 @@ public: Type getType() const; bool isFile() const; + bool isNonIndexed() const; bool isInheritable() const; bool isPackage() const; bool isCallable() const; + bool isVariable() const; bool isUsable() const; bool isPotentialMember() const; bool isCollapsible() const; bool isVisibleAsParentInGraph() const; - - int getFontSizeOffset() const; + FilePath getIconPath() const; + + bool hasIcon() const; + StyleType getNodeStyle() const; std::string getUnderscoredTypeString() const; std::string getReadableTypeString() const; diff --git a/src/lib/data/access/StorageAccessProxy.cpp b/src/lib/data/access/StorageAccessProxy.cpp index ccb825ef..a3513a15 100644 --- a/src/lib/data/access/StorageAccessProxy.cpp +++ b/src/lib/data/access/StorageAccessProxy.cpp @@ -90,7 +90,7 @@ NodeType StorageAccessProxy::getNodeTypeForNodeWithId(Id id) const { return m_subject->getNodeTypeForNodeWithId(id); } - return NodeType::NODE_NON_INDEXED; + return NodeType(NodeType::NODE_NON_INDEXED); } Id StorageAccessProxy::getIdForEdge( diff --git a/src/lib/data/storage/PersistentStorage.cpp b/src/lib/data/storage/PersistentStorage.cpp index 078a6a92..6e257224 100644 --- a/src/lib/data/storage/PersistentStorage.cpp +++ b/src/lib/data/storage/PersistentStorage.cpp @@ -679,7 +679,7 @@ std::vector PersistentStorage::getAutocompletionSymbolMatches( match.searchType = SearchMatch::SEARCH_TOKEN; if (storageSymbolMap.find(firstNode->id) == storageSymbolMap.end() && - match.nodeType.getType() != NodeType::NODE_NON_INDEXED) + !match.nodeType.isNonIndexed()) { match.typeName = "non-indexed " + match.typeName; } diff --git a/src/lib_gui/qt/view/QtGraphViewStyleImpl.cpp b/src/lib_gui/qt/view/QtGraphViewStyleImpl.cpp index d32c2fb9..bfdc3446 100644 --- a/src/lib_gui/qt/view/QtGraphViewStyleImpl.cpp +++ b/src/lib_gui/qt/view/QtGraphViewStyleImpl.cpp @@ -9,14 +9,14 @@ QtGraphViewStyleImpl::~QtGraphViewStyleImpl() { } -float QtGraphViewStyleImpl::getCharWidthForNodeType(NodeType type) +float QtGraphViewStyleImpl::getCharWidth(NodeType::StyleType type) { - return QFontMetrics(QtGraphNode::getFontForNodeType(type)).width("QtGraphNode::QtGraphNode::QtGraphNode") / 37.0f; + return QFontMetrics(QtGraphNode::getFontForStyleType(type)).width("QtGraphNode::QtGraphNode::QtGraphNode") / 37.0f; } -float QtGraphViewStyleImpl::getCharHeightForNodeType(NodeType type) +float QtGraphViewStyleImpl::getCharHeight(NodeType::StyleType type) { - return QFontMetrics(QtGraphNode::getFontForNodeType(type)).height(); + return QFontMetrics(QtGraphNode::getFontForStyleType(type)).height(); } float QtGraphViewStyleImpl::getGraphViewZoomDifferenceForPlatform() diff --git a/src/lib_gui/qt/view/QtGraphViewStyleImpl.h b/src/lib_gui/qt/view/QtGraphViewStyleImpl.h index 78642cd7..3986a3bc 100644 --- a/src/lib_gui/qt/view/QtGraphViewStyleImpl.h +++ b/src/lib_gui/qt/view/QtGraphViewStyleImpl.h @@ -8,9 +8,9 @@ class QtGraphViewStyleImpl { public: virtual ~QtGraphViewStyleImpl(); - virtual float getCharWidthForNodeType(NodeType type); - virtual float getCharHeightForNodeType(NodeType type); - virtual float getGraphViewZoomDifferenceForPlatform(); + virtual float getCharWidth(NodeType::StyleType type) override; + virtual float getCharHeight(NodeType::StyleType type) override; + virtual float getGraphViewZoomDifferenceForPlatform() override; }; #endif // QT_GRAPH_VIEW_STYLE_IMPL_H diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNode.cpp b/src/lib_gui/qt/view/graphElements/QtGraphNode.cpp index 943077a3..8dda80fa 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNode.cpp +++ b/src/lib_gui/qt/view/graphElements/QtGraphNode.cpp @@ -34,10 +34,10 @@ void QtGraphNode::hideNode() this->hide(); } -QFont QtGraphNode::getFontForNodeType(NodeType type) +QFont QtGraphNode::getFontForStyleType(NodeType::StyleType type) { QFont font(GraphViewStyle::getFontNameForDataNode().c_str()); - font.setPixelSize(GraphViewStyle::getFontSizeForNodeType(type)); + font.setPixelSize(GraphViewStyle::getFontSizeForStyleType(type)); return font; } @@ -508,9 +508,9 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style) m_undefinedRect->show(); } - if (!m_icon && style.iconPath.size()) + if (!m_icon && !style.iconPath.empty()) { - QtDeviceScaledPixmap pixmap(QString::fromStdString(style.iconPath)); + QtDeviceScaledPixmap pixmap(QString::fromStdString(style.iconPath.str())); pixmap.scaleToHeight(style.iconSize); m_icon = new QGraphicsPixmapItem(utility::colorizePixmap(pixmap.pixmap(), style.color.icon.c_str()), this); diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNode.h b/src/lib_gui/qt/view/graphElements/QtGraphNode.h index 3326558b..3ce19a67 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNode.h +++ b/src/lib_gui/qt/view/graphElements/QtGraphNode.h @@ -31,7 +31,7 @@ public slots: void hideNode(); public: - static QFont getFontForNodeType(NodeType type); + static QFont getFontForStyleType(NodeType::StyleType type); QtGraphNode(); virtual ~QtGraphNode();