aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@digia.com>2014-08-05 16:08:45 +0200
committerEike Ziller <eike.ziller@digia.com>2014-08-15 13:10:27 +0200
commit1c6394b8cd9cf2df010bdbb06245fc8da323db96 (patch)
tree603bfec2598055aaf2ffa88cdcac59aac44a331d
parentf6dab5c0e3f5589da78f9df72c24d33444ae7e4a (diff)
New File Dialog: Tweak default node on Projct Page
The case from the bug report is: / --> project.pro --> src --> foo.qrc --> folder --> file added here Since the .qrc file is nearer then the .pro file, it was selected as the default node. This patch makes the priority for the .qrc node -1 if it's a unmatched mime type. That means a .qrc node will only be the default if it's either a image, a .qml or a .js file. Task-number: QTCREATORBUG-12793 Change-Id: I7328fd6359cc2e1959ab0bda831bd77de117baff Reviewed-by: Eike Ziller <eike.ziller@digia.com>
-rw-r--r--src/plugins/projectexplorer/projectfilewizardextension.cpp6
-rw-r--r--src/plugins/resourceeditor/resourcenode.cpp18
2 files changed, 14 insertions, 10 deletions
diff --git a/src/plugins/projectexplorer/projectfilewizardextension.cpp b/src/plugins/projectexplorer/projectfilewizardextension.cpp
index 5a9e3e03c1..58a0a76f69 100644
--- a/src/plugins/projectexplorer/projectfilewizardextension.cpp
+++ b/src/plugins/projectexplorer/projectfilewizardextension.cpp
@@ -136,8 +136,10 @@ void BestNodeSelector::inspect(AddNewTree *tree)
const int projectDirectorySize = projectDirectory.size();
if (!m_commonDirectory.startsWith(projectDirectory))
return;
- bool betterMatch = projectDirectorySize > m_bestMatchLength
- || (projectDirectorySize == m_bestMatchLength && tree->priority() > m_bestMatchPriority);
+ bool betterMatch = tree->priority() > 0
+ && (projectDirectorySize > m_bestMatchLength
+ || (projectDirectorySize == m_bestMatchLength && tree->priority() > m_bestMatchPriority));
+
if (betterMatch) {
m_bestMatchPriority = tree->priority();
m_bestMatchLength = projectDirectorySize;
diff --git a/src/plugins/resourceeditor/resourcenode.cpp b/src/plugins/resourceeditor/resourcenode.cpp
index 552a628132..aea6099880 100644
--- a/src/plugins/resourceeditor/resourcenode.cpp
+++ b/src/plugins/resourceeditor/resourcenode.cpp
@@ -256,10 +256,11 @@ ProjectExplorer::FolderNode::AddNewInformation ResourceTopLevelNode::addNewInfor
.arg(QFileInfo(path()).fileName())
.arg(QLatin1String("/"));
- int p = 80;
- if (priority(files)) {
- if (context == 0 || context == this)
- p = 125;
+ int p = -1;
+ if (priority(files)) { // images/* and qml/js mimetypes
+ p = 110;
+ if (context == this)
+ p = 120;
else if (projectNode() == context)
p = 150; // steal from our project node
// The ResourceFolderNode '/' defers to us, as otherwise
@@ -267,7 +268,7 @@ ProjectExplorer::FolderNode::AddNewInformation ResourceTopLevelNode::addNewInfor
// Thus also return a high priority for it
if (ResourceFolderNode *rfn = qobject_cast<ResourceFolderNode *>(context))
if (rfn->prefix() == QLatin1String("/") && rfn->parentFolderNode() == this)
- p = 150;
+ p = 120;
}
return AddNewInformation(name, p);
@@ -389,9 +390,10 @@ ProjectExplorer::FolderNode::AddNewInformation ResourceFolderNode::addNewInforma
.arg(QFileInfo(m_topLevelNode->path()).fileName())
.arg(displayName());
- int p = 80;
- if (priority(files)) {
- if (context == 0 || context == this)
+ int p = -1; // never the default
+ if (priority(files)) { // image/* and qml/js mimetypes
+ p = 105; // prefer against .pro and .pri files
+ if (context == this)
p = 120;
}