]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/places/placespanel.h
Add explicit moc includes to sources for moc-covered headers
[dolphin.git] / src / panels / places / placespanel.h
index 8ea4d0831f6be24120b2d9caa557611f1a8ac220..2eb309483103462c8eee4fc4bbd38750b4330475 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * 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
  */
 
 #include "panels/panel.h"
 
+#include <KFilePlacesView>
 #include <QUrl>
 
-class KItemListController;
-class PlacesItemModel;
-class PlacesView;
-class QGraphicsSceneDragDropEvent;
-class QMenu;
-class QMimeData;
+#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:
-    explicit PlacesPanel(QWidgetparent);
+    explicit PlacesPanel(QWidget *parent);
     ~PlacesPanel() override;
-    void proceedWithTearDown();
 
-signals:
-    void placeActivated(const QUrl& url);
-    void placeMiddleClicked(const QUrl& url);
-    void errorMessage(const QString& error);
-    void storageTearDownRequested(const QString& mountPath);
-    void storageTearDownExternallyRequested(const QString& mountPath);
-    void showHiddenEntriesChanged(bool shown);
+    void setUrl(const QUrl &url); // override
 
-protected:
-    bool urlChanged() override;
-    void showEvent(QShowEvent* event) override;
-
-public slots:
-    void readSettings() override;
-    void showHiddenEntries(bool shown);
-    int hiddenListCount();
-
-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 slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent);
-    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 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();
 
-    QAction* buildGroupContextMenu(QMenu* menu, int index);
+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;
-    PlacesView* m_view;
+    void connectDeviceSignals(const QModelIndex &idx);
+
+    QUrl m_url; // only used for initial setUrl
+    QList<QAction *> m_customContextMenuActions;
 
-    QUrl m_storageSetupFailedUrl;
-    Qt::MouseButton m_triggerStorageSetupButton;
+    QPersistentModelIndex m_indexToTearDown;
 
-    int m_itemDropEventIndex;
-    QMimeData* m_itemDropEventMimeData;
-    QDropEvent* m_itemDropEvent;
+    QAction *m_configureTrashAction;
+    QAction *m_lockPanelsAction;
 };
 
 #endif // PLACESPANEL_H