src: converted NodeType to a class
NodeType internally still uses the Type enum
This commit is contained in:
@@ -64,7 +64,7 @@ QVariant QtAutocompletionModel::data(const QModelIndex &index, int role) const
|
||||
return indices;
|
||||
}
|
||||
case 5:
|
||||
return match.nodeType;
|
||||
return match.nodeType.getType();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@@ -140,7 +140,7 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt
|
||||
QString subtext = index.sibling(index.row(), index.column() + 2).data().toString();
|
||||
QString type = index.sibling(index.row(), index.column() + 3).data().toString();
|
||||
QList<QVariant> indices = index.sibling(index.row(), index.column() + 4).data().toList();
|
||||
Node::NodeType nodeType = static_cast<Node::NodeType>(index.sibling(index.row(), index.column() + 5).data().toInt());
|
||||
NodeType nodeType = utility::intToType(index.sibling(index.row(), index.column() + 5).data().toInt());
|
||||
|
||||
// define highlight colors
|
||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||
@@ -149,7 +149,7 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt
|
||||
|
||||
if (type.size() && type != "command" && type != "filter")
|
||||
{
|
||||
const GraphViewStyle::NodeColor& nodeColor = GraphViewStyle::getNodeColor(Node::getUnderscoredTypeString(nodeType), false);
|
||||
const GraphViewStyle::NodeColor& nodeColor = GraphViewStyle::getNodeColor(nodeType.getUnderscoredTypeString(), false);
|
||||
fillColor = QColor(nodeColor.fill.c_str());
|
||||
textColor = QColor(nodeColor.text.c_str());
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ QtHistoryItem::QtHistoryItem(const SearchMatch& match, size_t index, bool isCurr
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
|
||||
std::string name = utility::elide(match.nodeType == Node::NODE_FILE ? match.text : match.name, utility::ELIDE_RIGHT, 100);
|
||||
std::string name = utility::elide(match.nodeType.getType() == NodeType::NODE_FILE ? match.text : match.name, utility::ELIDE_RIGHT, 100);
|
||||
|
||||
m_name = new QLabel(name.c_str(), this);
|
||||
m_name->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||
@@ -43,8 +43,8 @@ QtHistoryItem::QtHistoryItem(const SearchMatch& match, size_t index, bool isCurr
|
||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||
if (match.searchType == SearchMatch::SEARCH_TOKEN)
|
||||
{
|
||||
m_indicatorColor = GraphViewStyle::getNodeColor(Node::getUnderscoredTypeString(match.nodeType), false).fill;
|
||||
m_indicatorHoverColor = GraphViewStyle::getNodeColor(Node::getUnderscoredTypeString(match.nodeType), true).fill;
|
||||
m_indicatorColor = GraphViewStyle::getNodeColor(match.nodeType.getUnderscoredTypeString(), false).fill;
|
||||
m_indicatorHoverColor = GraphViewStyle::getNodeColor(match.nodeType.getUnderscoredTypeString(), true).fill;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -807,10 +807,10 @@ void QtSmartSearchBox::updateElements()
|
||||
|
||||
if (match.searchType == SearchMatch::SEARCH_TOKEN)
|
||||
{
|
||||
color = GraphViewStyle::getNodeColor(Node::getUnderscoredTypeString(match.nodeType), false).fill;
|
||||
hoverColor = GraphViewStyle::getNodeColor(Node::getUnderscoredTypeString(match.nodeType), true).fill;
|
||||
textColor = GraphViewStyle::getNodeColor(Node::getUnderscoredTypeString(match.nodeType), false).text;
|
||||
textHoverColor = GraphViewStyle::getNodeColor(Node::getUnderscoredTypeString(match.nodeType), true).text;
|
||||
color = GraphViewStyle::getNodeColor(match.nodeType.getUnderscoredTypeString(), false).fill;
|
||||
hoverColor = GraphViewStyle::getNodeColor(match.nodeType.getUnderscoredTypeString(), true).fill;
|
||||
textColor = GraphViewStyle::getNodeColor(match.nodeType.getUnderscoredTypeString(), false).text;
|
||||
textHoverColor = GraphViewStyle::getNodeColor(match.nodeType.getUnderscoredTypeString(), true).text;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1040,15 +1040,15 @@ std::deque<SearchMatch> QtSmartSearchBox::getMatchesForInput(const std::string&
|
||||
return matches;
|
||||
}
|
||||
|
||||
Node::NodeTypeMask QtSmartSearchBox::getMatchFilter() const
|
||||
NodeType::TypeMask QtSmartSearchBox::getMatchFilter() const
|
||||
{
|
||||
Node::NodeTypeMask filter = 0;
|
||||
NodeType::TypeMask filter = 0;
|
||||
|
||||
for (const SearchMatch& match : m_matches)
|
||||
{
|
||||
if (match.isFilterCommand())
|
||||
{
|
||||
filter |= match.nodeType;
|
||||
filter |= match.nodeType.getType();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -99,7 +99,7 @@ private:
|
||||
|
||||
std::deque<SearchMatch> getMatchesForInput(const std::string& text) const;
|
||||
|
||||
Node::NodeTypeMask getMatchFilter() const;
|
||||
NodeType::TypeMask getMatchFilter() const;
|
||||
bool lastMatchIsNoFilter() const;
|
||||
|
||||
bool m_allowTextChange;
|
||||
|
||||
@@ -661,27 +661,27 @@ MessageActivateTrail QtGraphView::getMessageActivateTrail(bool forward)
|
||||
QtGraphNodeData* node = nullptr;
|
||||
if (m_oldActiveNode && (node = dynamic_cast<QtGraphNodeData*>(m_oldActiveNode)))
|
||||
{
|
||||
Edge::EdgeTypeMask trailType;
|
||||
Edge::TypeMask trailType;
|
||||
bool horizontalLayout = true;
|
||||
|
||||
switch (node->getData()->getType())
|
||||
switch (node->getData()->getType().getType())
|
||||
{
|
||||
case Node::NODE_NON_INDEXED:
|
||||
case Node::NODE_CLASS:
|
||||
case Node::NODE_STRUCT:
|
||||
case Node::NODE_INTERFACE:
|
||||
case NodeType::NODE_NON_INDEXED:
|
||||
case NodeType::NODE_CLASS:
|
||||
case NodeType::NODE_STRUCT:
|
||||
case NodeType::NODE_INTERFACE:
|
||||
trailType = Edge::EDGE_INHERITANCE;
|
||||
horizontalLayout = false;
|
||||
break;
|
||||
|
||||
case Node::NODE_FUNCTION:
|
||||
case Node::NODE_METHOD:
|
||||
case NodeType::NODE_FUNCTION:
|
||||
case NodeType::NODE_METHOD:
|
||||
trailType = Edge::EDGE_CALL | Edge::EDGE_OVERRIDE |
|
||||
Edge::EDGE_TEMPLATE_SPECIALIZATION | Edge::EDGE_TEMPLATE_MEMBER_SPECIALIZATION;
|
||||
horizontalLayout = true;
|
||||
break;
|
||||
|
||||
case Node::NODE_FILE:
|
||||
case NodeType::NODE_FILE:
|
||||
trailType = Edge::EDGE_INCLUDE;
|
||||
horizontalLayout = true;
|
||||
break;
|
||||
|
||||
@@ -9,12 +9,12 @@ QtGraphViewStyleImpl::~QtGraphViewStyleImpl()
|
||||
{
|
||||
}
|
||||
|
||||
float QtGraphViewStyleImpl::getCharWidthForNodeType(Node::NodeType type)
|
||||
float QtGraphViewStyleImpl::getCharWidthForNodeType(NodeType type)
|
||||
{
|
||||
return QFontMetrics(QtGraphNode::getFontForNodeType(type)).width("QtGraphNode::QtGraphNode::QtGraphNode") / 37.0f;
|
||||
}
|
||||
|
||||
float QtGraphViewStyleImpl::getCharHeightForNodeType(Node::NodeType type)
|
||||
float QtGraphViewStyleImpl::getCharHeightForNodeType(NodeType type)
|
||||
{
|
||||
return QFontMetrics(QtGraphNode::getFontForNodeType(type)).height();
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ class QtGraphViewStyleImpl
|
||||
{
|
||||
public:
|
||||
virtual ~QtGraphViewStyleImpl();
|
||||
virtual float getCharWidthForNodeType(Node::NodeType type);
|
||||
virtual float getCharHeightForNodeType(Node::NodeType type);
|
||||
virtual float getCharWidthForNodeType(NodeType type);
|
||||
virtual float getCharHeightForNodeType(NodeType type);
|
||||
virtual float getGraphViewZoomDifferenceForPlatform();
|
||||
};
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ void QtGraphNode::hideNode()
|
||||
this->hide();
|
||||
}
|
||||
|
||||
QFont QtGraphNode::getFontForNodeType(Node::NodeType type)
|
||||
QFont QtGraphNode::getFontForNodeType(NodeType type)
|
||||
{
|
||||
QFont font(GraphViewStyle::getFontNameForNodeType(type).c_str());
|
||||
QFont font(GraphViewStyle::getFontNameForDataNode().c_str());
|
||||
font.setPixelSize(GraphViewStyle::getFontSizeForNodeType(type));
|
||||
return font;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public slots:
|
||||
void hideNode();
|
||||
|
||||
public:
|
||||
static QFont getFontForNodeType(Node::NodeType type);
|
||||
static QFont getFontForNodeType(NodeType type);
|
||||
|
||||
QtGraphNode();
|
||||
virtual ~QtGraphNode();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "qt/graphics/QtCountCircleItem.h"
|
||||
|
||||
QtGraphNodeBundle::QtGraphNodeBundle(Id tokenId, size_t nodeCount, Node::NodeType type, std::string name)
|
||||
QtGraphNodeBundle::QtGraphNodeBundle(Id tokenId, size_t nodeCount, NodeType type, std::string name)
|
||||
: QtGraphNode()
|
||||
, m_tokenId(tokenId)
|
||||
, m_type(type)
|
||||
@@ -42,8 +42,8 @@ void QtGraphNodeBundle::onClick()
|
||||
{
|
||||
MessageGraphNodeBundleSplit(
|
||||
m_tokenId,
|
||||
m_type != Node::NODE_NON_INDEXED && getName() != "Anonymous Namespaces",
|
||||
m_type != Node::NODE_NON_INDEXED
|
||||
m_type.getType() != NodeType::NODE_NON_INDEXED && getName() != "Anonymous Namespaces",
|
||||
m_type.getType() != NodeType::NODE_NON_INDEXED
|
||||
).dispatch();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ void QtGraphNodeBundle::moved(const Vec2i& oldPosition)
|
||||
void QtGraphNodeBundle::updateStyle()
|
||||
{
|
||||
GraphViewStyle::NodeStyle style;
|
||||
if (m_type != Node::NODE_NON_INDEXED)
|
||||
if (m_type.getType() != NodeType::NODE_NON_INDEXED)
|
||||
{
|
||||
style = GraphViewStyle::getStyleForNodeType(m_type, true, false, m_isHovering, false, false);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class QtGraphNodeBundle
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtGraphNodeBundle(Id tokenId, size_t nodeCount, Node::NodeType type, std::string name);
|
||||
QtGraphNodeBundle(Id tokenId, size_t nodeCount, NodeType type, std::string name);
|
||||
virtual ~QtGraphNodeBundle();
|
||||
|
||||
// QtGraphNode implementation
|
||||
@@ -29,7 +29,7 @@ protected:
|
||||
private:
|
||||
QtCountCircleItem* m_circle;
|
||||
Id m_tokenId;
|
||||
Node::NodeType m_type;
|
||||
NodeType m_type;
|
||||
};
|
||||
|
||||
#endif // QT_GRAPH_NODE_BUNDLE_H
|
||||
|
||||
@@ -30,7 +30,7 @@ const Node* QtGraphNodeData::getData() const
|
||||
|
||||
FilePath QtGraphNodeData::getFilePath() const
|
||||
{
|
||||
if (m_data->isType(Node::NODE_FILE))
|
||||
if (m_data->getType().isFile())
|
||||
{
|
||||
return m_data->getComponent<TokenComponentFilePath>()->getFilePath();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ QtGraphNodeQualifier::QtGraphNodeQualifier(const NameHierarchy& name)
|
||||
m_rightArrowSmall = new QGraphicsPolygonItem(this);
|
||||
|
||||
QFont font;
|
||||
font.setFamily(GraphViewStyle::getFontNameForNodeType(Node::NODE_NON_INDEXED).c_str());
|
||||
font.setFamily(GraphViewStyle::getFontNameForDataNode().c_str());
|
||||
font.setPixelSize(GraphViewStyle::getFontSizeOfQualifier());
|
||||
font.setWeight(QFont::Normal);
|
||||
|
||||
|
||||
@@ -867,7 +867,7 @@ void QtMainWindow::setupHistoryMenu()
|
||||
for (size_t i = 0; i < m_history.size(); i++)
|
||||
{
|
||||
SearchMatch& match = m_history[i];
|
||||
std::string name = utility::elide(match.nodeType == Node::NODE_FILE ? match.text : match.name, utility::ELIDE_RIGHT, 50);
|
||||
std::string name = utility::elide(match.nodeType.getType() == NodeType::NODE_FILE ? match.text : match.name, utility::ELIDE_RIGHT, 50);
|
||||
|
||||
QAction* action = new QAction();
|
||||
action->setText(name.c_str());
|
||||
|
||||
Reference in New Issue
Block a user