]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placespanel.h
[PlacesItemModelTest] Check whether Desktop and Download folders exist
[dolphin.git] / src / panels / places / placespanel.h
1 /***************************************************************************
2 * Copyright (C) 2008-2012 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2010 by Christian Muehlhaeuser <muesli@gmail.com> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #ifndef PLACESPANEL_H
22 #define PLACESPANEL_H
23
24 #include "panels/panel.h"
25
26 #include <QMimeData>
27 #include <QUrl>
28
29 class KItemListController;
30 class PlacesItem;
31 class PlacesItemModel;
32 class PlacesView;
33 class QGraphicsSceneDragDropEvent;
34 class KJob;
35 class QMenu;
36 /**
37 * @brief Combines bookmarks and mounted devices as list.
38 */
39 class PlacesPanel : public Panel
40 {
41 Q_OBJECT
42
43 public:
44 explicit PlacesPanel(QWidget* parent);
45 ~PlacesPanel() override;
46 void proceedWithTearDown();
47
48 signals:
49 void placeActivated(const QUrl& url);
50 void placeMiddleClicked(const QUrl& url);
51 void errorMessage(const QString& error);
52 void storageTearDownRequested(const QString& mountPath);
53 void storageTearDownExternallyRequested(const QString& mountPath);
54
55 protected:
56 bool urlChanged() override;
57 void showEvent(QShowEvent* event) override;
58
59 public slots:
60 void readSettings() override;
61
62 private slots:
63 void slotItemActivated(int index);
64 void slotItemMiddleClicked(int index);
65 void slotItemContextMenuRequested(int index, const QPointF& pos);
66 void slotViewContextMenuRequested(const QPointF& pos);
67 void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
68 void slotItemDropEventStorageSetupDone(int index, bool success);
69 void slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
70 void slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent);
71 void slotStorageSetupDone(int index, bool success);
72
73 private:
74 void addEntry();
75 void editEntry(int index);
76
77 /**
78 * Selects the item that has the closest URL for the URL set
79 * for the panel (see Panel::setUrl()).
80 */
81 void selectClosestItem();
82
83 void triggerItem(int index, Qt::MouseButton button);
84
85 QAction* buildGroupContextMenu(QMenu* menu, int index);
86
87 private:
88 KItemListController* m_controller;
89 PlacesItemModel* m_model;
90 PlacesView* m_view;
91
92 QUrl m_storageSetupFailedUrl;
93 Qt::MouseButton m_triggerStorageSetupButton;
94
95 int m_itemDropEventIndex;
96 QMimeData* m_itemDropEventMimeData;
97 QDropEvent* m_itemDropEvent;
98 };
99
100 #endif // PLACESPANEL_H