From 0603e18cd4e36b988196a99810f2e3e803fe3125 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Thu, 16 Dec 2021 19:29:22 +0100 Subject: Port back to KFilePlacesView This removes the custom-view engine version of the places panel and replaces it with the upstream `KFilePlacesView` from KIO. --- src/panels/places/placespanel.h | 98 +++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 57 deletions(-) (limited to 'src/panels/places/placespanel.h') diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h index e19447cbf..fd6661c76 100644 --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -1,6 +1,7 @@ /* * SPDX-FileCopyrightText: 2008-2012 Peter Penz * SPDX-FileCopyrightText: 2010 Christian Muehlhaeuser + * SPDX-FileCopyrightText: 2021 Kai Uwe Broulik * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -8,95 +9,78 @@ #ifndef PLACESPANEL_H #define PLACESPANEL_H -#include - #include "panels/panel.h" #include -#include - -class KItemListController; -class PlacesItemModel; -class PlacesView; -class QGraphicsSceneDragDropEvent; -class QMenu; -class QMimeData; +#include + +#include // 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(QWidget* parent); ~PlacesPanel() override; + + void setUrl(const QUrl &url); // override + + // for compatibility with Panel, actions that are shown + // on the view's context menu + QList customContextMenuActions() const; + void setCustomContextMenuActions(const QList& actions); + + void requestTearDown(); void proceedWithTearDown(); - bool eventFilter(QObject *obj, QEvent *event) override; +public Q_SLOTS: + void readSettings(); Q_SIGNALS: - void placeActivated(const QUrl& url); - void placeActivatedInNewTab(const QUrl &url); - void placeActivatedInNewActiveTab(const QUrl &url); void errorMessage(const QString& error); void storageTearDownRequested(const QString& mountPath); void storageTearDownExternallyRequested(const QString& mountPath); - void showHiddenEntriesChanged(bool shown); void storageTearDownSuccessful(); protected: - bool urlChanged() override; void showEvent(QShowEvent* event) override; - -public Q_SLOTS: - void readSettings() override; - void showHiddenEntries(bool shown); - int hiddenListCount(); + void dragMoveEvent(QDragMoveEvent *event) override; + void dragLeaveEvent(QDragLeaveEvent *event) override; private Q_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 slotConfigureTrash(); + void slotDragActivationTimeout(); void slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent); - void slotStorageSetupDone(int index, bool success); - void slotShowTooltip(); + 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: - enum class TriggerItemModifier { None, ToNewTab, ToNewActiveTab, ToNewWindow }; + void connectDeviceSignals(const QModelIndex &idx); -private: - void addEntry(); - void editEntry(int index); - - /** - * Selects the item that matches the URL set - * for the panel (see Panel::setUrl()). - */ - void selectItem(); + QUrl m_url; // only used for initial setUrl + QList m_customContextMenuActions; - void triggerItem(int index, TriggerItemModifier modifier); + QTimer *m_dragActivationTimer = nullptr; + QPersistentModelIndex m_pendingDragActivation; - QAction* buildGroupContextMenu(QMenu* menu, int index); + Solid::StorageAccess *m_deviceToTearDown = nullptr; -private: - KItemListController* m_controller; - PlacesItemModel* m_model; - PlacesView* m_view; - - QUrl m_storageSetupFailedUrl; - TriggerItemModifier m_triggerStorageSetupModifier; - - int m_itemDropEventIndex; - QMimeData* m_itemDropEventMimeData; - QDropEvent* m_itemDropEvent; - QTimer m_tooltipTimer; - std::optional m_hoveredIndex; - QPoint m_hoverPos; + QAction *m_configureTrashAction; + QAction *m_lockPanelsAction; }; #endif // PLACESPANEL_H -- cgit v1.3.1