FileViewSvnPlugin::FileViewSvnPlugin(QObject* parent, const QList<QVariant>& args) :
KVersionControlPlugin(parent),
+ m_pendingOperation(false),
m_versionInfoHash(),
- m_versionInfoKeys(),
m_updateAction(0),
m_showLocalChangesAction(0),
m_commitAction(0),
{
Q_ASSERT(directory.endsWith('/'));
+ // Clear all entries for this directory including the entries
+ // for sub directories
+ QMutableHashIterator<QString, VersionState> it(m_versionInfoHash);
+ while (it.hasNext()) {
+ it.next();
+ if (it.key().startsWith(directory)) {
+ it.remove();
+ }
+ }
+
QStringList arguments;
arguments << "status" << "--show-updates" << 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;
}
// 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<QString, VersionState>::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;
QList<QAction*> FileViewSvnPlugin::contextMenuActions(const QString& directory)
{
- const bool enabled = m_contextItems.isEmpty();
+ const bool enabled = !m_pendingOperation;
if (enabled) {
m_contextDir = directory;
}
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()) {
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,
void FileViewSvnPlugin::startSvnCommandProcess()
{
+ m_pendingOperation = true;
+
QProcess* process = new QProcess(this);
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(slotOperationCompleted(int, QProcess::ExitStatus)));