From: Frank Reininghaus Date: Thu, 27 Feb 2014 08:11:48 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/KDE/4.12' into KDE/4.13 X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/006f667ab14aff2d067373e7e88bde4800b2d9c2?hp=-c Merge remote-tracking branch 'origin/KDE/4.12' into KDE/4.13 --- 006f667ab14aff2d067373e7e88bde4800b2d9c2 diff --combined src/views/versioncontrol/versioncontrolobserver.cpp index 36345d986,769c290f9..6affe80d3 --- a/src/views/versioncontrol/versioncontrolobserver.cpp +++ b/src/views/versioncontrol/versioncontrolobserver.cpp @@@ -198,15 -198,20 +198,15 @@@ void VersionControlObserver::slotThread return; } - if (!thread->retrievedItems()) { - // Ignore m_silentUpdate for an error message - emit errorMessage(i18nc("@info:status", "Update of version information failed.")); - return; - } - const QMap >& itemStates = thread->itemStates(); - foreach (const QString& directory, itemStates.keys()) { - const QVector& items = itemStates.value(directory); + QMap >::const_iterator it = itemStates.constBegin(); + for (; it != itemStates.constEnd(); ++it) { + const QVector& items = it.value(); foreach (const ItemState& item, items) { QHash values; values.insert("version", QVariant(item.version)); - m_model->setData(item.index, values); + m_model->setData(m_model->index(item.item), values); } } @@@ -265,6 -270,7 +265,6 @@@ int VersionControlObserver::createItemS if (expansionLevel == currentExpansionLevel) { ItemState itemState; - itemState.index = index; itemState.item = m_model->fileItem(index); itemState.version = KVersionControlPlugin2::UnversionedVersion; @@@ -316,11 -322,18 +316,18 @@@ KVersionControlPlugin* VersionControlOb } } + // 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; } @@@ -333,18 -346,24 +340,24 @@@ 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