]> cloud.milkyroute.net Git - dolphin.git/blob - src/infosidebarpage.h
* Starts to add Nepomuk supports to dolphin (currently, only annotations are supported)
[dolphin.git] / src / infosidebarpage.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef _INFOSIDEBARPAGE_H_
21 #define _INFOSIDEBARPAGE_H_
22
23 #include <sidebarpage.h>
24
25 #include <q3valuevector.h>
26 #include <qpushbutton.h>
27 //Added by qt3to4:
28 #include <QPixmap>
29 #include <QEvent>
30 #include <QLabel>
31 #include <Q3PtrList>
32
33 #include <kurl.h>
34 #include <kmimetype.h>
35 #include <kdedesktopmimetype.h>
36 #include <kvbox.h>
37
38 namespace KIO {
39 class Job;
40 }
41
42 class QPixmap;
43 class QIcon;
44 class QString;
45 class QPainter;
46 class KFileItem;
47 class QLabel;
48 class KVBox;
49 class Q3Grid;
50 class PixmapViewer;
51 class MetadataLoader;
52
53 /**
54 * @brief Prototype for a information sidebar.
55 *
56 * Will be exchanged in future releases by pluggable sidebar pages...
57 */
58 class InfoSidebarPage : public SidebarPage
59 {
60 Q_OBJECT
61
62 public:
63 explicit InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent=0);
64 virtual ~InfoSidebarPage();
65
66 protected:
67 /** @see SidebarPage::activeViewChanged() */
68 virtual void activeViewChanged();
69
70 private slots:
71 /**
72 * Does a delayed request of information for the item of the given Url and
73 * provides default actions.
74 *
75 * @see InfoSidebarPage::showItemInfo()
76 */
77 void requestDelayedItemInfo(const KUrl& url);
78
79 /**
80 * Does a request of information for the item of the given Url and
81 * provides default actions.
82 *
83 * @see InfoSidebarPage::showItemInfo()
84 */
85 void requestItemInfo(const KUrl& url);
86
87 /**
88 * Shows the information for the item of the Url which has been provided by
89 * InfoSidebarPage::requestItemInfo() and provides default actions.
90 */
91 void showItemInfo();
92
93 /**
94 * Triggered if the request for item information has timed out.
95 * @see InfoSidebarPage::requestDelayedItemInfo()
96 */
97 void slotTimeout();
98
99 /**
100 * Is invoked if no preview is available for the item. In this
101 * case the icon will be shown.
102 */
103 void slotPreviewFailed(const KFileItem* item);
104
105 /**
106 * Is invoked if a preview is available for the item. The preview
107 * \a pixmap is shown inside the info page.
108 */
109 void gotPreview(const KFileItem* item, const QPixmap& pixmap);
110
111 /**
112 * Starts the service of m_actionsVector with the index \index on
113 * the shown Url (or the selected items if available).
114 */
115 void startService(int index);
116
117 /**
118 * Opens a dialog to change the annotation of the currently selected
119 * file(s).
120 */
121 void changeAnnotation();
122
123 private:
124 /**
125 * Connects to signals from the currently active Dolphin view to get
126 * informed about highlighting changes.
127 */
128 void connectToActiveView();
129
130 /**
131 * Checks whether the current Url is repesented by a bookmark. If yes,
132 * then the bookmark icon and name are shown instead of a preview.
133 * @return True, if the Url represents exactly a bookmark.
134 */
135 bool applyBookmark();
136
137 /** Assures that any pending item information request is cancelled. */
138 void cancelRequest();
139
140 // TODO: the following methods are just a prototypes for meta
141 // info generation...
142 void createMetaInfo();
143 void addInfoLine(const QString& labelText,
144 const QString& infoText);
145 void beginInfoLines();
146 void endInfoLines();
147
148 /**
149 * Returns true, if the string \a key represents a meta information
150 * that should be shown.
151 */
152 bool showMetaInfo(const QString& key) const;
153
154 /**
155 * Inserts the available actions to the info page for the given item.
156 */
157 void insertActions();
158
159 /**
160 * Show the annotation of a file in the sidebar.
161 */
162 void showAnnotation(const KUrl& file);
163
164 /**
165 * Show the annotations of multiple files in the sidebar.
166 */
167 void showAnnotations(const KUrl::List& files);
168
169 bool m_multipleSelection;
170 bool m_pendingPreview;
171 QTimer* m_timer;
172 KUrl m_shownUrl;
173 KUrl m_urlCandidate;
174
175 PixmapViewer* m_preview;
176 QLabel* m_name;
177
178 QString m_infoLines;
179 QLabel* m_infos;
180
181 KVBox* m_actionBox;
182 Q3PtrList<QWidget> m_actionWidgets; // TODO: use children() from QObject instead
183 Q3ValueVector<KDEDesktopMimeType::Service> m_actionsVector;
184
185 QLabel* m_annotationLabel;
186 QPushButton* m_annotationButton;//Move to sthing sexy visually
187 MetadataLoader* m_metadata;
188 };
189
190 // TODO #1: move to SidebarPage?
191 // TODO #2: quite same button from the optical point of view as UrlNavigatorButton
192 // -> provide helper class or common base class
193 class ServiceButton : public QPushButton
194 {
195 Q_OBJECT
196
197 public:
198 ServiceButton(const QIcon& icon,
199 const QString& text,
200 QWidget* parent,
201 int index);
202 virtual ~ServiceButton();
203
204 signals:
205 void requestServiceStart(int index);
206
207 protected:
208 virtual void paintEvent(QPaintEvent* event);
209 virtual void enterEvent(QEvent* event);
210 virtual void leaveEvent(QEvent* event);
211
212 private slots:
213 void slotReleased();
214
215 private:
216 bool m_hover;
217 int m_index;
218 };
219
220 #endif // _INFOSIDEBARPAGE_H_