src: replaced references to NODE_FILE with call to isFile

This commit is contained in:
mlangkabel
2017-12-07 14:52:12 +01:00
parent b02596ddfa
commit 91b0c5d05f
9 changed files with 34 additions and 13 deletions
@@ -503,7 +503,7 @@ std::string BookmarkController::getNodeDisplayName(const Id nodeId) const
NodeType type = m_storageAccess->getNodeTypeForNodeWithId(nodeId); NodeType type = m_storageAccess->getNodeTypeForNodeWithId(nodeId);
NameHierarchy nameHierarchy = m_storageAccess->getNameHierarchyForNodeId(nodeId); NameHierarchy nameHierarchy = m_storageAccess->getNameHierarchyForNodeId(nodeId);
if (type.getType() == NodeType::NODE_FILE) if (type.isFile())
{ {
return FilePath(nameHierarchy.getQualifiedName()).fileName(); return FilePath(nameHierarchy.getQualifiedName()).fileName();
} }
@@ -979,7 +979,7 @@ void GraphController::bundleNodes()
bundleNodesAndEdgesMatching( bundleNodesAndEdgesMatching(
[](const DummyNode::BundleInfo& info, const Node* data) [](const DummyNode::BundleInfo& info, const Node* data)
{ {
return data->isType(NodeType::NODE_FILE); return data->getType().isFile();
}, },
1, 1,
false, false,
@@ -1009,7 +1009,7 @@ void GraphController::bundleNodes()
bundleNodesAndEdgesMatching( bundleNodesAndEdgesMatching(
[](const DummyNode::BundleInfo& info, const Node* data) [](const DummyNode::BundleInfo& info, const Node* data)
{ {
return info.isDefined && info.isReferenced && data->isType(NodeType::NODE_BUILTIN_TYPE); return info.isDefined && info.isReferenced && data->getType().isBuiltin();
}, },
3, 3,
false, false,
+18
View File
@@ -79,6 +79,24 @@ NodeTypeSet NodeTypeSet::getWithRemoved(const NodeTypeSet& typeSet) const
return ret; return ret;
} }
void NodeTypeSet::removeIf(const std::function<bool(const NodeType&)> condition)
{
for (const NodeType& type : s_allNodeTypes)
{
if (m_nodeTypeMask & nodeTypeToMask(type) && condition(type))
{
remove(type);
}
}
}
NodeTypeSet NodeTypeSet::getWithRemovedIf(const std::function<bool(const NodeType&)> condition) const
{
NodeTypeSet ret(*this);
ret.removeIf(condition);
return ret;
}
bool NodeTypeSet::isEmpty() const bool NodeTypeSet::isEmpty() const
{ {
return m_nodeTypeMask == 0; return m_nodeTypeMask == 0;
+3
View File
@@ -28,6 +28,9 @@ public:
void remove(const NodeTypeSet& typeSet); void remove(const NodeTypeSet& typeSet);
NodeTypeSet getWithRemoved(const NodeTypeSet& typeSet) const; NodeTypeSet getWithRemoved(const NodeTypeSet& typeSet) const;
void removeIf(const std::function<bool(const NodeType&)> condition);
NodeTypeSet getWithRemovedIf(const std::function<bool(const NodeType&)> condition) const;
bool isEmpty() const; bool isEmpty() const;
bool contains(const NodeType& type) const; bool contains(const NodeType& type) const;
bool intersectsWith(const NodeTypeSet& typeSet) const; bool intersectsWith(const NodeTypeSet& typeSet) const;
+1 -1
View File
@@ -219,7 +219,7 @@ void SearchMatch::print(std::ostream& ostream) const
std::string SearchMatch::getFullName() const std::string SearchMatch::getFullName() const
{ {
if (searchType == SEARCH_TOKEN && nodeType.getType() == NodeType::NODE_FILE) if (searchType == SEARCH_TOKEN && nodeType.isFile())
{ {
return text; return text;
} }
+6 -6
View File
@@ -576,12 +576,12 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionMatches(const std::
// create SearchMatches // create SearchMatches
std::vector<SearchMatch> matches; std::vector<SearchMatch> matches;
if (!acceptedNodeTypes.getWithRemoved(NodeType(NodeType::NODE_FILE)).isEmpty()) if (!acceptedNodeTypes.getWithRemovedIf([](const NodeType& type) { return type.isFile(); }).isEmpty())
{ {
utility::append(matches, getAutocompletionSymbolMatches(query, acceptedNodeTypes, maxResultsCount, maxBestScoredResultsLength)); utility::append(matches, getAutocompletionSymbolMatches(query, acceptedNodeTypes, maxResultsCount, maxBestScoredResultsLength));
} }
if (acceptedNodeTypes.contains(NodeType(NodeType::NODE_FILE))) if (!acceptedNodeTypes.getWithRemovedIf([](const NodeType& type) { return !type.isFile(); }).isEmpty())
{ {
utility::append(matches, getAutocompletionFileMatches(query, maxResultsCount)); utility::append(matches, getAutocompletionFileMatches(query, maxResultsCount));
} }
@@ -802,7 +802,7 @@ std::vector<SearchMatch> PersistentStorage::getSearchMatchesForTokenIds(const st
match.delimiter = nameHierarchy.getDelimiter(); match.delimiter = nameHierarchy.getDelimiter();
if (match.nodeType.getType() == NodeType::NODE_FILE) if (match.nodeType.isFile())
{ {
match.text = FilePath(match.text).fileName(); match.text = FilePath(match.text).fileName();
} }
@@ -1727,7 +1727,7 @@ TooltipInfo PersistentStorage::getTooltipInfoForTokenIds(const std::vector<Id>&
} }
} }
if (type.getType() == NodeType::NODE_FILE && m_fileNodePaths.find(node.id) != m_fileNodePaths.end()) if (type.isFile() && m_fileNodePaths.find(node.id) != m_fileNodePaths.end())
{ {
if (!getFileNodeComplete(node.id)) if (!getFileNodeComplete(node.id))
{ {
@@ -2174,7 +2174,7 @@ void PersistentStorage::addNodesToGraph(const std::vector<Id>& newNodeIds, Graph
for (const StorageNode& storageNode : m_sqliteIndexStorage.getAllByIds<StorageNode>(nodeIds)) for (const StorageNode& storageNode : m_sqliteIndexStorage.getAllByIds<StorageNode>(nodeIds))
{ {
const NodeType type(utility::intToType(storageNode.type)); const NodeType type(utility::intToType(storageNode.type));
if (type.getType() == NodeType::NODE_FILE) if (type.isFile())
{ {
const FilePath filePath(NameHierarchy::deserialize(storageNode.serializedName).getRawName()); const FilePath filePath(NameHierarchy::deserialize(storageNode.serializedName).getRawName());
@@ -2540,7 +2540,7 @@ void PersistentStorage::buildSearchIndex()
for (StorageNode& node : m_sqliteIndexStorage.getAll<StorageNode>()) for (StorageNode& node : m_sqliteIndexStorage.getAll<StorageNode>())
{ {
NodeType type = utility::intToType(node.type); NodeType type = utility::intToType(node.type);
if (type == NodeType::NODE_FILE) if (type.isFile())
{ {
auto it = m_fileNodePaths.find(node.id); auto it = m_fileNodePaths.find(node.id);
if (it != m_fileNodePaths.end()) if (it != m_fileNodePaths.end())
@@ -28,7 +28,7 @@ public:
for (size_t i = 0; i < m_matches.size(); i++) for (size_t i = 0; i < m_matches.size(); i++)
{ {
ss << '@'; ss << '@';
if (m_matches[i].nodeType.getType() == NodeType::NODE_FILE) if (m_matches[i].nodeType.isFile())
{ {
ss << m_matches[i].subtext; ss << m_matches[i].subtext;
} }
+1 -1
View File
@@ -22,7 +22,7 @@ QtHistoryItem::QtHistoryItem(const SearchMatch& match, size_t index, bool isCurr
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
layout->setAlignment(Qt::AlignTop); layout->setAlignment(Qt::AlignTop);
std::string name = utility::elide(match.nodeType.getType() == NodeType::NODE_FILE ? match.text : match.name, utility::ELIDE_RIGHT, 100); std::string name = utility::elide(match.nodeType.isFile() ? match.text : match.name, utility::ELIDE_RIGHT, 100);
m_name = new QLabel(name.c_str(), this); m_name = new QLabel(name.c_str(), this);
m_name->setAttribute(Qt::WA_MacShowFocusRect, 0); m_name->setAttribute(Qt::WA_MacShowFocusRect, 0);
+1 -1
View File
@@ -879,7 +879,7 @@ void QtMainWindow::setupHistoryMenu()
for (size_t i = 0; i < m_history.size(); i++) for (size_t i = 0; i < m_history.size(); i++)
{ {
SearchMatch& match = m_history[i]; SearchMatch& match = m_history[i];
std::string name = utility::elide(match.nodeType.getType() == NodeType::NODE_FILE ? match.text : match.name, utility::ELIDE_RIGHT, 50); std::string name = utility::elide(match.nodeType.isFile() ? match.text : match.name, utility::ELIDE_RIGHT, 50);
QAction* action = new QAction(); QAction* action = new QAction();
action->setText(name.c_str()); action->setText(name.c_str());