]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placespanel.h
Enable Ctrl/Shift-Click to open folder in a new tab/window
[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 #include <QTimer>
15
16 class KItemListController;
17 class PlacesItemModel;
18 class PlacesView;
19 class QGraphicsSceneDragDropEvent;
20 class QMenu;
21 class QMimeData;
22 /**
23 * @brief Combines bookmarks and mounted devices as list.
24 */
25 class PlacesPanel : public Panel
26 {
27 Q_OBJECT
28
29 public:
30 explicit PlacesPanel(QWidget* parent);
31 ~PlacesPanel() override;
32 void proceedWithTearDown();
33
34 bool eventFilter(QObject *obj, QEvent *event) override;
35
36 Q_SIGNALS:
37 void placeActivated(const QUrl& url);
38 void placeActivatedInNewTab(const QUrl &url);
39 void placeActivatedInNewActiveTab(const QUrl &url);
40 void errorMessage(const QString& error);
41 void storageTearDownRequested(const QString& mountPath);
42 void storageTearDownExternallyRequested(const QString& mountPath);
43 void showHiddenEntriesChanged(bool shown);
44 void storageTearDownSuccessful();
45
46 protected:
47 bool urlChanged() override;
48 void showEvent(QShowEvent* event) override;
49
50 public Q_SLOTS:
51 void readSettings() override;
52 void showHiddenEntries(bool shown);
53 int hiddenListCount();
54
55 private Q_SLOTS:
56 void slotItemActivated(int index);
57 void slotItemMiddleClicked(int index);
58 void slotItemContextMenuRequested(int index, const QPointF& pos);
59 void slotViewContextMenuRequested(const QPointF& pos);
60 void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
61 void slotItemDropEventStorageSetupDone(int index, bool success);
62 void slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
63 void slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent);
64 void slotStorageSetupDone(int index, bool success);
65 void slotShowTooltip();
66
67 private:
68 enum class TriggerItemModifier { None, ToNewTab, ToNewActiveTab, ToNewWindow };
69
70 private:
71 void addEntry();
72 void editEntry(int index);
73
74 /**
75 * Selects the item that matches the URL set
76 * for the panel (see Panel::setUrl()).
77 */
78 void selectItem();
79
80 void triggerItem(int index, TriggerItemModifier modifier);
81
82 QAction* buildGroupContextMenu(QMenu* menu, int index);
83
84 private:
85 KItemListController* m_controller;
86 PlacesItemModel* m_model;
87 PlacesView* m_view;
88
89 QUrl m_storageSetupFailedUrl;
90 TriggerItemModifier m_triggerStorageSetupModifier;
91
92 int m_itemDropEventIndex;
93 QMimeData* m_itemDropEventMimeData;
94 QDropEvent* m_itemDropEvent;
95 QTimer m_tooltipTimer;
96 int m_hoveredIndex;
97 QPoint m_hoverPos;
98 };
99
100 #endif // PLACESPANEL_H