┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/versioncontrol/versioncontrolobserver.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2014-05-13 18:42:05 +0200
committerFrank Reininghaus <[email protected]>2014-05-13 18:42:05 +0200
commit4cf04b91dd8804f2536fc31ae2f1b486bfc8cf9c (patch)
tree75aee505fe55fabedf33fa202cc4b4e4f6481a71 /src/views/versioncontrol/versioncontrolobserver.cpp
parent7e92abb4ea2c2b269d21973bc9f2e76da5fb9114 (diff)
parent5780fab172e02c3dd44082aa10d37cd87a98e29b (diff)
Merge remote-tracking branch 'origin/master' into frameworks
Since the master branch had never been merged into frameworks since the creation of the frameworks branch, I had to fix a couple of merge conflicts and make another change in order to make it build - I hope I did not get anything wrong. We should probably merge master into frameworks on a regular basis from now on. CCMAIL:[email protected] Conflicts: dolphin/src/dolphinmainwindow.cpp dolphin/src/search/dolphinfacetswidget.cpp dolphin/src/statusbar/dolphinstatusbar.cpp dolphin/src/views/dolphinview.cpp
Diffstat (limited to 'src/views/versioncontrol/versioncontrolobserver.cpp')
-rw-r--r--src/views/versioncontrol/versioncontrolobserver.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp
index 2c966e186..9033e19da 100644
--- a/src/views/versioncontrol/versioncontrolobserver.cpp
+++ b/src/views/versioncontrol/versioncontrolobserver.cpp
@@ -317,11 +317,18 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
}
}
+ // We use the number of upUrl() calls to find the best matching plugin
+ // for the given directory. The smaller value, the better it is (0 is best).
+ KVersionControlPlugin* bestPlugin = 0;
+ int bestScore = INT_MAX;
+
// Verify whether the current directory contains revision information
// like .svn, .git, ...
foreach (KVersionControlPlugin* plugin, plugins) {
const QString fileName = directory.path(KUrl::AddTrailingSlash) + plugin->fileName();
if (QFile::exists(fileName)) {
+ // The score of this plugin is 0 (best), so we can just return this plugin,
+ // instead of going through the plugin scoring procedure, we can't find a better one ;)
return plugin;
}
@@ -334,18 +341,24 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
if (m_versionedDirectory) {
KUrl dirUrl(directory);
KUrl upUrl = dirUrl.upUrl();
- while (upUrl != dirUrl) {
+ int upUrlCounter = 1;
+ while ((upUrlCounter < bestScore) && (upUrl != dirUrl)) {
const QString fileName = dirUrl.path(KUrl::AddTrailingSlash) + plugin->fileName();
if (QFile::exists(fileName)) {
- return plugin;
+ if (upUrlCounter < bestScore) {
+ bestPlugin = plugin;
+ bestScore = upUrlCounter;
+ }
+ break;
}
dirUrl = upUrl;
upUrl = dirUrl.upUrl();
+ ++upUrlCounter;
}
}
}
- return 0;
+ return bestPlugin;
}
bool VersionControlObserver::isVersioned() const