]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/places/placespanel.h
Merge branch 'release/21.12'
[dolphin.git] / src / panels / places / placespanel.h
index 0c8b5f7f23b746a218eb013e1a676d87a450a507..97be1f735016ccd05bd1523e01b941ab4caf8601 100644 (file)
@@ -1,95 +1,80 @@
-/***************************************************************************
- *   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 "panels/panel.h"
+
 #include <QUrl>
-#include <QMimeData>
-#include <panels/panel.h>
-
-class KItemListController;
-class PlacesItem;
-class PlacesItemModel;
-class PlacesView;
-class QGraphicsSceneDragDropEvent;
-class KJob;
+#include <KFilePlacesView>
+
+#include <Solid/SolidNamespace> // Solid::ErrorType
+
+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;
+
+    void setUrl(const QUrl &url); // override
 
-signals:
-    void placeActivated(const QUrl& url);
-    void placeMiddleClicked(const QUrl& url);
+    // for compatibility with Panel, actions that are shown
+    // on the view's context menu
+    QList<QAction*> customContextMenuActions() const;
+    void setCustomContextMenuActions(const QList<QAction*>& actions);
+
+    void requestTearDown();
+    void proceedWithTearDown();
+
+public Q_SLOTS:
+    void readSettings();
+
+Q_SIGNALS:
     void errorMessage(const QString& error);
+    void storageTearDownRequested(const QString& mountPath);
+    void storageTearDownExternallyRequested(const QString& mountPath);
+    void storageTearDownSuccessful();
 
 protected:
-    virtual bool urlChanged() Q_DECL_OVERRIDE;
-    virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
-
-public slots:
-    virtual void readSettings() Q_DECL_OVERRIDE;
-
-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 slotItemDropEventStorageSetupDone(int index, bool success);
-    void slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
+    void showEvent(QShowEvent* event) override;
+
+private Q_SLOTS:
+    void slotConfigureTrash();
     void slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent);
-    void slotTrashUpdated(KJob* job);
-    void slotStorageSetupDone(int index, bool success);
+    void slotContextMenuAboutToShow(const QModelIndex &index, QMenu *menu);
+    void slotTearDownRequested(const QModelIndex &index);
+    void slotTearDownRequestedExternally(const QString &udi);
+    void slotTearDownDone(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:
-    void emptyTrash();
-    void addEntry();
-    void editEntry(int index);
+    void connectDeviceSignals(const QModelIndex &idx);
 
-    /**
-     * Selects the item that has the closest URL for the URL set
-     * for the panel (see Panel::setUrl()).
-     */
-    void selectClosestItem();
-
-    void triggerItem(int index, Qt::MouseButton button);
-
-private:
-    KItemListController* m_controller;
-    PlacesItemModel* m_model;
-    PlacesView* m_view;
+    QUrl m_url; // only used for initial setUrl
+    QList<QAction*> m_customContextMenuActions;
 
-    QUrl m_storageSetupFailedUrl;
-    Qt::MouseButton m_triggerStorageSetupButton;
+    Solid::StorageAccess *m_deviceToTearDown = nullptr;
 
-    int m_itemDropEventIndex;
-    QMimeData* m_itemDropEventMimeData;
-    QDropEvent* m_itemDropEvent;
+    QAction *m_configureTrashAction;
+    QAction *m_lockPanelsAction;
 };
 
 #endif // PLACESPANEL_H