]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/places/placespanel.h
Add clang-format and format code as in Frameworks
[dolphin.git] / src / panels / places / placespanel.h
index 8a84e00a0baeb012f974bcca66ca7e7f9b5cea69..2eb309483103462c8eee4fc4bbd38750b4330475 100644 (file)
@@ -1,85 +1,81 @@
-/***************************************************************************
- *   Copyright (C) 2008-2012 by Peter Penz <peter.penz19@gmail.com>        *
- *   Copyright (C) 2010 by Christian Muehlhaeuser <muesli@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: 2008-2012 Peter Penz <peter.penz19@gmail.com>
+ * SPDX-FileCopyrightText: 2010 Christian Muehlhaeuser <muesli@gmail.com>
+ * SPDX-FileCopyrightText: 2021 Kai Uwe Broulik <kde@broulik.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #ifndef PLACESPANEL_H
 #define PLACESPANEL_H
 
-#include <KUrl>
-#include <panels/panel.h>
+#include "panels/panel.h"
+
+#include <KFilePlacesView>
+#include <QUrl>
+
+#include <Solid/SolidNamespace> // Solid::ErrorType
 
-class KItemListController;
-class PlacesItemEditDialog;
-class PlacesItem;
-class PlacesItemModel;
-class QGraphicsSceneDragDropEvent;
+class QTimer;
+namespace Solid
+{
+class StorageAccess;
+}
 
 /**
  * @brief Combines bookmarks and mounted devices as list.
  */
-class PlacesPanel : public Panel
+class PlacesPanel : public KFilePlacesView
 {
     Q_OBJECT
 
 public:
-    PlacesPanel(QWidget* parent);
-    virtual ~PlacesPanel();
+    explicit PlacesPanel(QWidget *parent);
+    ~PlacesPanel() override;
 
-signals:
-    void placeActivated(const KUrl& url);
-    void placeMiddleClicked(const KUrl& url);
-    void errorMessage(const QString& error);
+    void setUrl(const QUrl &url); // override
 
-protected:
-    virtual bool urlChanged();
-    virtual void showEvent(QShowEvent* event);
-
-private slots:
-    void slotItemActivated(int index);
-    void slotItemMiddleClicked(int index);
-    void slotItemContextMenuRequested(int index, const QPointF& pos);
-    void slotViewContextMenuRequested(const QPointF& pos);
-    void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
-    void slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
-    void slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent);
-    void slotTrashUpdated(KJob* job);
-    void slotStorageSetupDone(int index, bool success);
+    // for compatibility with Panel, actions that are shown
+    // on the view's context menu
+    QList<QAction *> customContextMenuActions() const;
+    void setCustomContextMenuActions(const QList<QAction *> &actions);
 
-private:
-    void emptyTrash();
-    void addEntry();
-    void editEntry(int index);
+    void requestTearDown();
+    void proceedWithTearDown();
 
-    /**
-     * Selects the item that has the closest URL for the URL set
-     * for the panel (see Panel::setUrl()).
-     */
-    void selectClosestItem();
+public Q_SLOTS:
+    void readSettings();
 
-    void triggerItem(int index, Qt::MouseButton button);
+Q_SIGNALS:
+    void errorMessage(const QString &error);
+    void storageTearDownRequested(const QString &mountPath);
+    void storageTearDownExternallyRequested(const QString &mountPath);
+    void storageTearDownSuccessful();
+
+protected:
+    void showEvent(QShowEvent *event) override;
+    void dragMoveEvent(QDragMoveEvent *event) override;
+
+private Q_SLOTS:
+    void slotConfigureTrash();
+    void slotUrlsDropped(const QUrl &dest, QDropEvent *event, QWidget *parent);
+    void slotContextMenuAboutToShow(const QModelIndex &index, QMenu *menu);
+    void slotTearDownRequested(const QModelIndex &index);
+    void slotTearDownRequestedExternally(const QString &udi);
+    void slotTearDownDone(const QModelIndex &index, Solid::ErrorType error, const QVariant &errorData);
+    void slotRowsInserted(const QModelIndex &parent, int first, int last);
+    void slotRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
 
 private:
-    KItemListController* m_controller;
-    PlacesItemModel* m_model;
+    void connectDeviceSignals(const QModelIndex &idx);
+
+    QUrl m_url; // only used for initial setUrl
+    QList<QAction *> m_customContextMenuActions;
+
+    QPersistentModelIndex m_indexToTearDown;
 
-    KUrl m_storageSetupFailedUrl;
-    Qt::MouseButton m_triggerStorageSetupButton;
+    QAction *m_configureTrashAction;
+    QAction *m_lockPanelsAction;
 };
 
 #endif // PLACESPANEL_H