Commit 69b378eb authored by Tobias Hunger's avatar Tobias Hunger Committed by Tim Jenssen
Browse files

ProjectExplorer: Expose sortByPath operator on project nodes



This is universally useful, so expose it.

Change-Id: I9cceee076397c7d690d8d34ef8ac815059e4454d
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent fdfe55c9
......@@ -186,6 +186,11 @@ SessionNode *Node::asSessionNode()
return nullptr;
}
bool Node::sortByPath(Node *a, Node *b)
{
return a->filePath() < b->filePath();
}
void Node::setParentFolderNode(FolderNode *parentFolder)
{
m_folderNode = parentFolder;
......@@ -371,24 +376,19 @@ FolderNode *FolderNode::findOrCreateSubFolderNode(const QString &directory)
return parent;
}
static bool sortNodesByPath(Node *a, Node *b)
{
return a->filePath() < b->filePath();
}
void FolderNode::buildTree(QList<FileNode *> &files)
{
// Gather old list
QList<ProjectExplorer::FileNode *> oldFiles = recursiveFileNodes();
Utils::sort(oldFiles, sortNodesByPath);
Utils::sort(files, sortNodesByPath);
Utils::sort(oldFiles, Node::sortByPath);
Utils::sort(files, Node::sortByPath);
QList<ProjectExplorer::FileNode *> added;
QList<ProjectExplorer::FileNode *> deleted;
ProjectExplorer::compareSortedLists(oldFiles, files, deleted, added, sortNodesByPath);
ProjectExplorer::compareSortedLists(oldFiles, files, deleted, added, Node::sortByPath);
qDeleteAll(ProjectExplorer::subtractSortedList(files, added, sortNodesByPath));
qDeleteAll(ProjectExplorer::subtractSortedList(files, added, Node::sortByPath));
QHash<ProjectExplorer::FolderNode *, QList<ProjectExplorer::FileNode *> > addedFolderMapping;
QHash<ProjectExplorer::FolderNode *, QList<ProjectExplorer::FileNode *> > deletedFolderMapping;
......
......@@ -129,6 +129,8 @@ public:
virtual ProjectNode *asProjectNode();
virtual SessionNode *asSessionNode();
static bool sortByPath(Node *a, Node *b);
protected:
Node(NodeType nodeType, const Utils::FileName &filePath, int line = -1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment