Commit e0a12e9e authored by con's avatar con
Browse files

Show native file paths in category sub-folder nodes.

Correctly show
* Headers
   * C:\foo
instead of
* Headers
   * C:/foo
parent 00404240
...@@ -245,7 +245,7 @@ struct InternalNode ...@@ -245,7 +245,7 @@ struct InternalNode
QMap<QString, InternalNode*> subnodes; QMap<QString, InternalNode*> subnodes;
QStringList files; QStringList files;
ProjectExplorer::FileType type; ProjectExplorer::FileType type;
QString fullName; QString fullPath;
QIcon icon; QIcon icon;
InternalNode() InternalNode()
...@@ -269,6 +269,13 @@ struct InternalNode ...@@ -269,6 +269,13 @@ struct InternalNode
// * file2 // * file2
// * path2 // * path2
// * file1 // * file1
// The method first creates a tree that looks like the directory structure, i.e.
// * /
// * absolute
// * path
// ...
// and afterwards calls compress() which merges directory nodes with single children, i.e. to
// * /absolute/path
void create(const QString &projectDir, const QStringList &newFilePaths, ProjectExplorer::FileType type) void create(const QString &projectDir, const QStringList &newFilePaths, ProjectExplorer::FileType type)
{ {
static const QChar separator = QChar('/'); static const QChar separator = QChar('/');
...@@ -299,7 +306,7 @@ struct InternalNode ...@@ -299,7 +306,7 @@ struct InternalNode
if (!currentNode->subnodes.contains(key)) { if (!currentNode->subnodes.contains(key)) {
InternalNode *val = new InternalNode; InternalNode *val = new InternalNode;
val->type = type; val->type = type;
val->fullName = path; val->fullPath = path;
currentNode->subnodes.insert(key, val); currentNode->subnodes.insert(key, val);
currentNode = val; currentNode = val;
} else { } else {
...@@ -317,7 +324,7 @@ struct InternalNode ...@@ -317,7 +324,7 @@ struct InternalNode
// Removes folder nodes with only a single sub folder in it // Removes folder nodes with only a single sub folder in it
void compress() void compress()
{ {
static const QChar separator = QChar('/'); static const QChar separator = QDir::separator(); // it is used for the *keys* which will become display name
QMap<QString, InternalNode*> newSubnodes; QMap<QString, InternalNode*> newSubnodes;
QMapIterator<QString, InternalNode*> i(subnodes); QMapIterator<QString, InternalNode*> i(subnodes);
while (i.hasNext()) { while (i.hasNext()) {
...@@ -363,7 +370,7 @@ struct InternalNode ...@@ -363,7 +370,7 @@ struct InternalNode
foldersToRemove << *existingNodeIter; foldersToRemove << *existingNodeIter;
++existingNodeIter; ++existingNodeIter;
} else if ((*existingNodeIter)->displayName() > newNodeIter.key()) { } else if ((*existingNodeIter)->displayName() > newNodeIter.key()) {
FolderNode *newNode = new FolderNode(newNodeIter.value()->fullName); FolderNode *newNode = new FolderNode(newNodeIter.value()->fullPath);
newNode->setDisplayName(newNodeIter.key()); newNode->setDisplayName(newNodeIter.key());
if (!newNodeIter.value()->icon.isNull()) if (!newNodeIter.value()->icon.isNull())
newNode->setIcon(newNodeIter.value()->icon); newNode->setIcon(newNodeIter.value()->icon);
...@@ -382,7 +389,7 @@ struct InternalNode ...@@ -382,7 +389,7 @@ struct InternalNode
++existingNodeIter; ++existingNodeIter;
} }
while (newNodeIter != subnodes.constEnd()) { while (newNodeIter != subnodes.constEnd()) {
FolderNode *newNode = new FolderNode(newNodeIter.value()->fullName); FolderNode *newNode = new FolderNode(newNodeIter.value()->fullPath);
newNode->setDisplayName(newNodeIter.key()); newNode->setDisplayName(newNodeIter.key());
if (!newNodeIter.value()->icon.isNull()) if (!newNodeIter.value()->icon.isNull())
newNode->setIcon(newNodeIter.value()->icon); newNode->setIcon(newNodeIter.value()->icon);
...@@ -489,7 +496,7 @@ void Qt4PriFileNode::update(ProFile *includeFile, ProFileReader *reader) ...@@ -489,7 +496,7 @@ void Qt4PriFileNode::update(ProFile *includeFile, ProFileReader *reader)
InternalNode *subfolder = new InternalNode; InternalNode *subfolder = new InternalNode;
subfolder->type = type; subfolder->type = type;
subfolder->icon = fileTypes.at(i).icon; subfolder->icon = fileTypes.at(i).icon;
subfolder->fullName = m_projectDir + '#' + fileTypes.at(i).typeName; subfolder->fullPath = m_projectDir + '#' + fileTypes.at(i).typeName;
contents.subnodes.insert(fileTypes.at(i).typeName, subfolder); contents.subnodes.insert(fileTypes.at(i).typeName, subfolder);
// create the hierarchy with subdirectories // create the hierarchy with subdirectories
subfolder->create(m_projectDir, newFilePaths, type); subfolder->create(m_projectDir, newFilePaths, type);
......
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