]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/versioncontrol/versioncontrolobserver.cpp
Merge branch 'release/20.08' into master
[dolphin.git] / src / views / versioncontrol / versioncontrolobserver.cpp
index 2d801686e259099a249a301b613f49109d41ca03..7cf78c8aaa6914bf24fcb54b9a673199d9ffb32f 100644 (file)
@@ -1,21 +1,8 @@
-/***************************************************************************
- *   Copyright (C) 2009 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2009 Peter Penz <peter.penz19@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "versioncontrolobserver.h"
 
@@ -118,11 +105,19 @@ QList<QAction*> VersionControlObserver::actions(const KFileItemList& items) cons
         }
     }
 
-    if (!m_model || hasNullItems || !isVersioned()) {
+    if (!m_model || hasNullItems) {
         return {};
     }
 
-    return m_plugin->actions(items);
+    if (isVersionControlled()) {
+        return m_plugin->versionControlActions(items);
+    } else {
+        QList<QAction*> actions;
+        for (const auto &plugin : qAsConst(m_plugins)) {
+            actions << plugin.first->outOfVersionControlActions(items);
+        }
+        return actions;
+    }
 }
 
 void VersionControlObserver::delayedDirectoryVerification()
@@ -160,21 +155,8 @@ void VersionControlObserver::verifyDirectory()
         return;
     }
 
-    if (m_plugin) {
-        m_plugin->disconnect(this);
-    }
-
     m_plugin = searchPlugin(rootItem.url());
     if (m_plugin) {
-        connect(m_plugin, &KVersionControlPlugin::itemVersionsChanged,
-                this, &VersionControlObserver::silentDirectoryVerification);
-        connect(m_plugin, &KVersionControlPlugin::infoMessage,
-                this, &VersionControlObserver::infoMessage);
-        connect(m_plugin, &KVersionControlPlugin::errorMessage,
-                this, &VersionControlObserver::errorMessage);
-        connect(m_plugin, &KVersionControlPlugin::operationCompletedMessage,
-                this, &VersionControlObserver::operationCompletedMessage);
-
         if (!m_versionedDirectory) {
             m_versionedDirectory = true;
 
@@ -303,6 +285,15 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& director
             if (enabledPlugins.contains((*it)->name())) {
                 KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>(this);
                 if (plugin) {
+                    connect(plugin, &KVersionControlPlugin::itemVersionsChanged,
+                            this, &VersionControlObserver::silentDirectoryVerification);
+                    connect(plugin, &KVersionControlPlugin::infoMessage,
+                            this, &VersionControlObserver::infoMessage);
+                    connect(plugin, &KVersionControlPlugin::errorMessage,
+                            this, &VersionControlObserver::errorMessage);
+                    connect(plugin, &KVersionControlPlugin::operationCompletedMessage,
+                            this, &VersionControlObserver::operationCompletedMessage);
+
                     m_plugins.append( qMakePair(plugin, plugin->fileName()) );
                 }
             }
@@ -360,7 +351,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& director
     return bestPlugin;
 }
 
-bool VersionControlObserver::isVersioned() const
+bool VersionControlObserver::isVersionControlled() const
 {
     return m_versionedDirectory && m_plugin;
 }