]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/versioncontrol/versioncontrolobserver.cpp
operator+/- is disabled for QFlags in qt6
[dolphin.git] / src / views / versioncontrol / versioncontrolobserver.cpp
index f6c74fb5fe4de9eee2e1b8560142b4cab93a1ecb..c66c639c87fbdd86b92aec1edf01966d546c6fbb 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"
 
@@ -110,7 +97,7 @@ DolphinView* VersionControlObserver::view() const
 QList<QAction*> VersionControlObserver::actions(const KFileItemList& items) const
 {
     bool hasNullItems = false;
-    foreach (const KFileItem& item, items) {
+    for (const KFileItem& item : items) {
         if (item.isNull()) {
             qCWarning(DolphinDebug) << "Requesting version-control-actions for empty items";
             hasNullItems = true;
@@ -168,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;
 
@@ -215,7 +189,7 @@ void VersionControlObserver::slotThreadFinished()
     for (; it != itemStates.constEnd(); ++it) {
         const QVector<ItemState>& items = it.value();
 
-        foreach (const ItemState& item, items) {
+        for (const ItemState& item : items) {
             const KFileItem& fileItem = item.first;
             const KVersionControlPlugin::ItemVersion version = item.second;
             QHash<QByteArray, QVariant> values;
@@ -228,7 +202,7 @@ void VersionControlObserver::slotThreadFinished()
         // Using an empty message results in clearing the previously shown information message and showing
         // the default status bar information. This is useful as the user already gets feedback that the
         // operation has been completed because of the icon emblems.
-        emit operationCompletedMessage(QString());
+        Q_EMIT operationCompletedMessage(QString());
     }
 
     if (m_pendingItemStatesUpdate) {
@@ -252,7 +226,7 @@ void VersionControlObserver::updateItemStates()
 
     if (!itemStates.isEmpty()) {
         if (!m_silentUpdate) {
-            emit infoMessage(i18nc("@info:status", "Updating version information..."));
+            Q_EMIT infoMessage(i18nc("@info:status", "Updating version information..."));
         }
         m_updateItemStatesThread = new UpdateItemStatesThread(m_plugin, itemStates);
         connect(m_updateItemStatesThread, &UpdateItemStatesThread::finished,
@@ -311,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()) );
                 }
             }