File indexing completed on 2024-04-28 05:45:13

0001 /*
0002  * SPDX-FileCopyrightText: 2008-2012 Peter Penz <peter.penz19@gmail.com>
0003  * SPDX-FileCopyrightText: 2010 Christian Muehlhaeuser <muesli@gmail.com>
0004  * SPDX-FileCopyrightText: 2021 Kai Uwe Broulik <kde@broulik.de>
0005  *
0006  * SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 
0009 #ifndef PLACESPANEL_H
0010 #define PLACESPANEL_H
0011 
0012 #include "panels/panel.h"
0013 
0014 #include <KFilePlacesView>
0015 #include <QUrl>
0016 
0017 #include <Solid/SolidNamespace> // Solid::ErrorType
0018 
0019 class QTimer;
0020 namespace Solid
0021 {
0022 class StorageAccess;
0023 }
0024 
0025 /**
0026  * @brief Combines bookmarks and mounted devices as list.
0027  */
0028 class PlacesPanel : public KFilePlacesView
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     explicit PlacesPanel(QWidget *parent);
0034     ~PlacesPanel() override;
0035 
0036     void setUrl(const QUrl &url); // override
0037 
0038     // for compatibility with Panel, actions that are shown
0039     // on the view's context menu
0040     QList<QAction *> customContextMenuActions() const;
0041     void setCustomContextMenuActions(const QList<QAction *> &actions);
0042 
0043     void requestTearDown();
0044     void proceedWithTearDown();
0045 
0046 public Q_SLOTS:
0047     void readSettings();
0048 
0049 Q_SIGNALS:
0050     void errorMessage(const QString &error);
0051     void storageTearDownRequested(const QString &mountPath);
0052     void storageTearDownExternallyRequested(const QString &mountPath);
0053     void storageTearDownSuccessful();
0054     void openInSplitViewRequested(const QUrl &url);
0055 
0056 protected:
0057     void showEvent(QShowEvent *event) override;
0058     void dragMoveEvent(QDragMoveEvent *event) override;
0059 
0060 private Q_SLOTS:
0061     void slotConfigureTrash();
0062     void slotUrlsDropped(const QUrl &dest, QDropEvent *event, QWidget *parent);
0063     void slotContextMenuAboutToShow(const QModelIndex &index, QMenu *menu);
0064     void slotTearDownRequested(const QModelIndex &index);
0065     void slotTearDownRequestedExternally(const QString &udi);
0066     void slotTearDownDone(const QModelIndex &index, Solid::ErrorType error, const QVariant &errorData);
0067     void slotRowsInserted(const QModelIndex &parent, int first, int last);
0068     void slotRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
0069 
0070 private:
0071     void connectDeviceSignals(const QModelIndex &idx);
0072 
0073     QUrl m_url; // only used for initial setUrl
0074     QList<QAction *> m_customContextMenuActions;
0075 
0076     QPersistentModelIndex m_indexToTearDown;
0077 
0078     QAction *m_configureTrashAction;
0079     QAction *m_openInSplitView;
0080     QAction *m_lockPanelsAction;
0081 };
0082 
0083 #endif // PLACESPANEL_H