]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placespanel.h
4156cfea09d966f36b701990dd8c5612a18819c8
[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 <config-nepomuk.h>
25
26 #include <KUrl>
27 #include <panels/panel.h>
28
29 class KItemListController;
30 class PlacesItemEditDialog;
31 class PlacesItem;
32 class PlacesItemModel;
33
34 #ifdef HAVE_NEPOMUK
35 namespace Nepomuk
36 {
37 namespace Query
38 {
39 class Term;
40 }
41 }
42 #endif
43
44 /**
45 * @brief Combines bookmarks and mounted devices as list.
46 */
47 class PlacesPanel : public Panel
48 {
49 Q_OBJECT
50
51 public:
52 PlacesPanel(QWidget* parent);
53 virtual ~PlacesPanel();
54
55 signals:
56 void placeActivated(const KUrl& url);
57 void placeMiddleClicked(const KUrl& url);
58 void errorMessage(const QString& error);
59
60 protected:
61 virtual bool urlChanged();
62 virtual void showEvent(QShowEvent* event);
63
64 private slots:
65 void slotItemActivated(int index);
66 void slotItemMiddleClicked(int index);
67 void slotItemContextMenuRequested(int index, const QPointF& pos);
68 void slotViewContextMenuRequested(const QPointF& pos);
69 void slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent);
70 void slotTrashUpdated(KJob* job);
71
72 private:
73 void emptyTrash();
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 /**
84 * @return Converts the URL, which contains "virtual" URLs for system-items like
85 * "search:/documents" into a Nepomuk-Query-URL that will be handled by
86 * the corresponding IO-slave. Virtual URLs for bookmarks are used to
87 * be independent from internal format changes.
88 */
89 static KUrl convertedUrl(const KUrl& url);
90
91 /**
92 * @return URL using the timeline-protocol for searching (see convertedUrl()).
93 */
94 static KUrl createTimelineUrl(const KUrl& url);
95
96 /**
97 * Helper method for createTimelineUrl().
98 * @return String that represents a date-path in the format that
99 * the timeline-protocol expects.
100 */
101 static QString timelineDateString(int year, int month, int day = 0);
102
103 /**
104 * @return URL that can be listed by KIO and results in searching
105 * for a given term. The URL \a url represents a places-internal
106 * URL like e.g. "search:/documents" (see convertedUrl()).
107 */
108 static KUrl createSearchUrl(const KUrl& url);
109
110 #ifdef HAVE_NEPOMUK
111 /**
112 * Helper method for createSearchUrl().
113 * @return URL that can be listed by KIO and results in searching
114 * for the given term.
115 */
116 static KUrl searchUrlForTerm(const Nepomuk::Query::Term& term);
117 #endif
118
119 private:
120 KItemListController* m_controller;
121 PlacesItemModel* m_model;
122 };
123
124 #endif // PLACESPANEL_H