]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/places/placesitemmodel.cpp
Add Flatpak patches to Dolphin depending on CMake definition
[dolphin.git] / src / panels / places / placesitemmodel.cpp
index 4a91ec6d8bb1ba7777de1d006af64d17787d8c54..3da6f7e1f88595723006b485b0d31ca6de765e27 100644 (file)
@@ -1,25 +1,12 @@
-/***************************************************************************
- *   Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   Based on KFilePlacesModel from kdelibs:                               *
- *   Copyright (C) 2007 Kevin Ottens <ervin@kde.org>                       *
- *   Copyright (C) 2007 David Faure <faure@kde.org>                        *
- *                                                                         *
- *   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: 2012 Peter Penz <peter.penz19@gmail.com>
+ *
+ * Based on KFilePlacesModel from kdelibs:
+ * SPDX-FileCopyrightText: 2007 Kevin Ottens <ervin@kde.org>
+ * SPDX-FileCopyrightText: 2007 David Faure <faure@kde.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "placesitemmodel.h"
 
@@ -250,7 +237,7 @@ void PlacesItemModel::requestEject(int index)
         } else {
             const QString label = item->text();
             const QString message = i18nc("@info", "The device '%1' is not a disk and cannot be ejected.", label);
-            emit errorMessage(message);
+            Q_EMIT errorMessage(message);
         }
     }
 }
@@ -267,7 +254,7 @@ void PlacesItemModel::requestTearDown(int index)
             // after we have emitted PlacesItemModel::storageTearDownRequested
             disconnect(tmp, &Solid::StorageAccess::teardownRequested,
                        item->signalHandler(), &PlacesItemSignalHandler::onTearDownRequested);
-            emit storageTearDownRequested(tmp->filePath());
+            Q_EMIT storageTearDownRequested(tmp->filePath());
         }
     }
 }
@@ -480,12 +467,15 @@ void PlacesItemModel::slotStorageTearDownDone(Solid::ErrorType error, const QVar
                             "One or more files on this device are opened in following applications: <application>%2</application>.",
                             blockingApps.count(), blockingApps.join(i18nc("separator in list of apps blocking device unmount", ", ")));
                 }
-                emit errorMessage(errorString);
+                Q_EMIT errorMessage(errorString);
             });
             listOpenFilesJob->start();
         } else {
-            emit errorMessage(errorData.toString());
+            Q_EMIT errorMessage(errorData.toString());
         }
+    } else {
+        // No error; it must have been unmounted successfully
+        Q_EMIT storageTearDownSuccessful();
     }
     disconnect(m_deviceToTearDown, &Solid::StorageAccess::teardownDone,
                this, &PlacesItemModel::slotStorageTearDownDone);
@@ -496,7 +486,7 @@ void PlacesItemModel::slotStorageSetupDone(Solid::ErrorType error,
                                            const QVariant& errorData,
                                            const QString& udi)
 {
-    Q_UNUSED(udi);
+    Q_UNUSED(udi)
 
     const int index = m_storageSetupInProgress.take(sender());
     const PlacesItem*  item = placesItem(index);
@@ -506,16 +496,16 @@ void PlacesItemModel::slotStorageSetupDone(Solid::ErrorType error,
 
     if (error != Solid::NoError) {
         if (errorData.isValid()) {
-            emit errorMessage(i18nc("@info", "An error occurred while accessing '%1', the system responded: %2",
+            Q_EMIT errorMessage(i18nc("@info", "An error occurred while accessing '%1', the system responded: %2",
                                     item->text(),
                                     errorData.toString()));
         } else {
-            emit errorMessage(i18nc("@info", "An error occurred while accessing '%1'",
+            Q_EMIT errorMessage(i18nc("@info", "An error occurred while accessing '%1'",
                                     item->text()));
         }
-        emit storageSetupDone(index, false);
+        Q_EMIT storageSetupDone(index, false);
     } else {
-        emit storageSetupDone(index, true);
+        Q_EMIT storageSetupDone(index, true);
     }
 }
 
@@ -540,8 +530,8 @@ void PlacesItemModel::onSourceModelRowsAboutToBeRemoved(const QModelIndex &paren
 
 void PlacesItemModel::onSourceModelRowsAboutToBeMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
 {
-    Q_UNUSED(destination);
-    Q_UNUSED(row);
+    Q_UNUSED(destination)
+    Q_UNUSED(row)
 
     for(int r = start; r <= end; r++) {
         const QModelIndex sourceIndex = m_sourceModel->index(r, 0, parent);
@@ -552,8 +542,8 @@ void PlacesItemModel::onSourceModelRowsAboutToBeMoved(const QModelIndex &parent,
 
 void PlacesItemModel::onSourceModelRowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
 {
-    Q_UNUSED(destination);
-    Q_UNUSED(parent);
+    Q_UNUSED(destination)
+    Q_UNUSED(parent)
 
     const int blockSize = (end - start) + 1;
 
@@ -568,7 +558,7 @@ void PlacesItemModel::onSourceModelRowsMoved(const QModelIndex &parent, int star
 
 void PlacesItemModel::onSourceModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
 {
-    Q_UNUSED(roles);
+    Q_UNUSED(roles)
 
     for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
         const QModelIndex sourceIndex = m_sourceModel->index(r, 0);
@@ -588,11 +578,6 @@ void PlacesItemModel::onSourceModelDataChanged(const QModelIndex &topLeft, const
         }
 
         if (placeItem && !m_sourceModel->isDevice(sourceIndex)) {
-            placeItem->setText(bookmark.text());
-            placeItem->setIcon(sourceIndex.data(KFilePlacesModel::IconNameRole).toString());
-            placeItem->setUrl(m_sourceModel->url(sourceIndex));
-            placeItem->bookmark().setMetaDataItem(QStringLiteral("OnlyInApp"),
-                                                  bookmark.metaDataItem(QStringLiteral("OnlyInApp")));
             // must update the bookmark object
             placeItem->setBookmark(bookmark);
         }
@@ -760,7 +745,7 @@ int PlacesItemModel::mapFromSource(const QModelIndex &index) const
 
 bool PlacesItemModel::isDir(int index) const
 {
-    Q_UNUSED(index);
+    Q_UNUSED(index)
     return true;
 }