diff options
| author | Kai Uwe Broulik <[email protected]> | 2021-12-16 19:29:22 +0100 |
|---|---|---|
| committer | Kai Uwe Broulik <[email protected]> | 2022-01-09 18:09:10 +0100 |
| commit | 0603e18cd4e36b988196a99810f2e3e803fe3125 (patch) | |
| tree | 6d70829efea053cb36c9e6618d8feadd45569a91 /src/panels/places/placespanel.h | |
| parent | 3abc4cfcd49df45c856e1b5f01da8de8f970ccb2 (diff) | |
Port back to KFilePlacesView
This removes the custom-view engine version of the places panel
and replaces it with the upstream `KFilePlacesView` from KIO.
Diffstat (limited to 'src/panels/places/placespanel.h')
| -rw-r--r-- | src/panels/places/placespanel.h | 96 |
1 files changed, 40 insertions, 56 deletions
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 <[email protected]> * SPDX-FileCopyrightText: 2010 Christian Muehlhaeuser <[email protected]> + * SPDX-FileCopyrightText: 2021 Kai Uwe Broulik <[email protected]> * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -8,95 +9,78 @@ #ifndef PLACESPANEL_H #define PLACESPANEL_H -#include <optional> - #include "panels/panel.h" #include <QUrl> -#include <QTimer> +#include <KFilePlacesView> + +#include <Solid/SolidNamespace> // Solid::ErrorType + +class QTimer; +namespace Solid +{ +class StorageAccess; +} -class KItemListController; -class PlacesItemModel; -class PlacesView; -class QGraphicsSceneDragDropEvent; -class QMenu; -class QMimeData; /** * @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<QAction*> customContextMenuActions() const; + void setCustomContextMenuActions(const QList<QAction*>& 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(); - -private: - enum class TriggerItemModifier { None, ToNewTab, ToNewActiveTab, ToNewWindow }; + 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 addEntry(); - void editEntry(int index); + void connectDeviceSignals(const QModelIndex &idx); - /** - * 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<QAction*> m_customContextMenuActions; - void triggerItem(int index, TriggerItemModifier modifier); - - QAction* buildGroupContextMenu(QMenu* menu, int index); - -private: - KItemListController* m_controller; - PlacesItemModel* m_model; - PlacesView* m_view; + QTimer *m_dragActivationTimer = nullptr; + QPersistentModelIndex m_pendingDragActivation; - QUrl m_storageSetupFailedUrl; - TriggerItemModifier m_triggerStorageSetupModifier; + Solid::StorageAccess *m_deviceToTearDown = nullptr; - int m_itemDropEventIndex; - QMimeData* m_itemDropEventMimeData; - QDropEvent* m_itemDropEvent; - QTimer m_tooltipTimer; - std::optional<int> m_hoveredIndex; - QPoint m_hoverPos; + QAction *m_configureTrashAction; + QAction *m_lockPanelsAction; }; #endif // PLACESPANEL_H |
