X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/a47dc8edae84ae571ff364351d493cec0be9d3f3..c06e0666343722e272fcb9268359852bd460cdee:/src/versioncontrol/fileviewsvnplugin.cpp diff --git a/src/versioncontrol/fileviewsvnplugin.cpp b/src/versioncontrol/fileviewsvnplugin.cpp index 91a37a878..00bb373fe 100644 --- a/src/versioncontrol/fileviewsvnplugin.cpp +++ b/src/versioncontrol/fileviewsvnplugin.cpp @@ -43,8 +43,8 @@ K_EXPORT_PLUGIN(FileViewSvnPluginFactory("fileviewsvnplugin")) FileViewSvnPlugin::FileViewSvnPlugin(QObject* parent, const QList& args) : KVersionControlPlugin(parent), + m_pendingOperation(false), m_versionInfoHash(), - m_versionInfoKeys(), m_updateAction(0), m_showLocalChangesAction(0), m_commitAction(0), @@ -102,6 +102,16 @@ bool FileViewSvnPlugin::beginRetrieval(const QString& directory) { Q_ASSERT(directory.endsWith('/')); + // Clear all entries for this directory including the entries + // for sub directories + QMutableHashIterator it(m_versionInfoHash); + while (it.hasNext()) { + it.next(); + if (it.key().startsWith(directory)) { + it.remove(); + } + } + QStringList arguments; arguments << "status" << "--show-updates" << directory; @@ -126,16 +136,21 @@ bool FileViewSvnPlugin::beginRetrieval(const QString& directory) break; } - int pos = filePath.indexOf('/'); - const int length = filePath.length() - pos - 1; - filePath = filePath.mid(pos, length); - if (!filePath.isEmpty()) { - m_versionInfoHash.insert(filePath, state); + // Only values with a different state as 'NormalVersion' + // are added to the hash table. If a value is not in the + // hash table, it is automatically defined as 'NormalVersion' + // (see FileViewSvnPlugin::versionState()). + if (state != NormalVersion) { + int pos = filePath.indexOf('/'); + const int length = filePath.length() - pos - 1; + filePath = filePath.mid(pos, length); + if (!filePath.isEmpty()) { + m_versionInfoHash.insert(filePath, state); + } } } } - m_versionInfoKeys = m_versionInfoHash.keys(); return true; } @@ -159,13 +174,15 @@ KVersionControlPlugin::VersionState FileViewSvnPlugin::versionState(const KFileI // The item is a directory. Check whether an item listed by 'svn status' (= m_versionInfoHash) // is part of this directory. In this case a local modification should be indicated in the // directory already. - foreach (const QString& key, m_versionInfoKeys) { - if (key.startsWith(itemUrl)) { - const VersionState state = m_versionInfoHash.value(key); + QHash::const_iterator it = m_versionInfoHash.constBegin(); + while (it != m_versionInfoHash.constEnd()) { + if (it.key().startsWith(itemUrl)) { + const VersionState state = m_versionInfoHash.value(it.key()); if (state == LocallyModifiedVersion) { return LocallyModifiedVersion; } } + ++it; } return NormalVersion; @@ -213,7 +230,7 @@ QList FileViewSvnPlugin::contextMenuActions(const KFileItemList& items QList FileViewSvnPlugin::contextMenuActions(const QString& directory) { - const bool enabled = m_contextItems.isEmpty(); + const bool enabled = !m_pendingOperation; if (enabled) { m_contextDir = directory; } @@ -311,6 +328,8 @@ void FileViewSvnPlugin::removeFiles() void FileViewSvnPlugin::slotOperationCompleted(int exitCode, QProcess::ExitStatus exitStatus) { + m_pendingOperation = false; + if ((exitStatus != QProcess::NormalExit) || (exitCode != 0)) { emit errorMessage(m_errorMsg); } else if (m_contextItems.isEmpty()) { @@ -323,10 +342,11 @@ void FileViewSvnPlugin::slotOperationCompleted(int exitCode, QProcess::ExitStatu void FileViewSvnPlugin::slotOperationError() { - emit errorMessage(m_errorMsg); - // don't do any operation on other items anymore m_contextItems.clear(); + m_pendingOperation = false; + + emit errorMessage(m_errorMsg); } void FileViewSvnPlugin::execSvnCommand(const QString& svnCommand, @@ -345,6 +365,8 @@ void FileViewSvnPlugin::execSvnCommand(const QString& svnCommand, void FileViewSvnPlugin::startSvnCommandProcess() { + m_pendingOperation = true; + QProcess* process = new QProcess(this); connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotOperationCompleted(int, QProcess::ExitStatus)));