]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placespanel.h
Merge branch 'release/20.08'
[dolphin.git] / src / panels / places / placespanel.h
1 /*
2 * SPDX-FileCopyrightText: 2008-2012 Peter Penz <peter.penz19@gmail.com>
3 * SPDX-FileCopyrightText: 2010 Christian Muehlhaeuser <muesli@gmail.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8 #ifndef PLACESPANEL_H
9 #define PLACESPANEL_H
10
11 #include "panels/panel.h"
12
13 #include <QUrl>
14
15 class KItemListController;
16 class PlacesItemModel;
17 class PlacesView;
18 class QGraphicsSceneDragDropEvent;
19 class QMenu;
20 class QMimeData;
21 /**
22 * @brief Combines bookmarks and mounted devices as list.
23 */
24 class PlacesPanel : public Panel
25 {
26 Q_OBJECT
27
28 public:
29 explicit PlacesPanel(QWidget* parent);
30 ~PlacesPanel() override;
31 void proceedWithTearDown();
32
33 signals:
34 void placeActivated(const QUrl& url);
35 void placeMiddleClicked(const QUrl& url);
36 void errorMessage(const QString& error);
37 void storageTearDownRequested(const QString& mountPath);
38 void storageTearDownExternallyRequested(const QString& mountPath);
39 void showHiddenEntriesChanged(bool shown);
40
41 protected:
42 bool urlChanged() override;
43 void showEvent(QShowEvent* event) override;
44
45 public slots:
46 void readSettings() override;
47 void showHiddenEntries(bool shown);
48 int hiddenListCount();
49
50 private slots:
51 void slotItemActivated(int index);
52 void slotItemMiddleClicked(int index);
53 void slotItemContextMenuRequested(int index, const QPointF& pos);
54 void slotViewContextMenuRequested(const QPointF& pos);
55 void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
56 void slotItemDropEventStorageSetupDone(int index, bool success);
57 void slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
58 void slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent);
59 void slotStorageSetupDone(int index, bool success);
60
61 private:
62 void addEntry();
63 void editEntry(int index);
64
65 /**
66 * Selects the item that has the closest URL for the URL set
67 * for the panel (see Panel::setUrl()).
68 */
69 void selectClosestItem();
70
71 void triggerItem(int index, Qt::MouseButton button);
72
73 QAction* buildGroupContextMenu(QMenu* menu, int index);
74
75 private:
76 KItemListController* m_controller;
77 PlacesItemModel* m_model;
78 PlacesView* m_view;
79
80 QUrl m_storageSetupFailedUrl;
81 Qt::MouseButton m_triggerStorageSetupButton;
82
83 int m_itemDropEventIndex;
84 QMimeData* m_itemDropEventMimeData;
85 QDropEvent* m_itemDropEvent;
86 };
87
88 #endif // PLACESPANEL_H