]> cloud.milkyroute.net Git - dolphin.git/blob - src/infosidebarpage.h
commited initial version of Dolphin
[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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 <ksortablevaluelist.h>
35 #include <kmimetype.h>
36
37 namespace KIO {
38 class Job;
39 };
40
41 class QPixmap;
42 class QIcon;
43 class QString;
44 class QPainter;
45 class KFileItem;
46 class QLabel;
47 class Q3VBox;
48 class Q3Grid;
49 class PixmapViewer;
50
51 /**
52 * @brief Prototype for a information sidebar.
53 *
54 * Will be exchanged in future releases by pluggable sidebar pages...
55 */
56 class InfoSidebarPage : public SidebarPage
57 {
58 Q_OBJECT
59
60 public:
61 InfoSidebarPage(QWidget* parent);
62 virtual ~InfoSidebarPage();
63
64 protected:
65 /** @see SidebarPage::activeViewChanged() */
66 virtual void activeViewChanged();
67
68 private slots:
69 /**
70 * Does a delayed request of information for the item of the given URL and
71 * provides default actions.
72 *
73 * @see InfoSidebarPage::showItemInfo()
74 */
75 void requestDelayedItemInfo(const KURL& url);
76
77 /**
78 * Does a request of information for the item of the given URL and
79 * provides default actions.
80 *
81 * @see InfoSidebarPage::showItemInfo()
82 */
83 void requestItemInfo(const KURL& url);
84
85 /**
86 * Shows the information for the item of the URL which has been provided by
87 * InfoSidebarPage::requestItemInfo() and provides default actions.
88 */
89 void showItemInfo();
90
91 /**
92 * Triggered if the request for item information has timed out.
93 * @see InfoSidebarPage::requestDelayedItemInfo()
94 */
95 void slotTimeout();
96
97 /**
98 * Is invoked if no preview is available for the item. In this
99 * case the icon will be shown.
100 */
101 void slotPreviewFailed(const KFileItem* item);
102
103 /**
104 * Is invoked if a preview is available for the item. The preview
105 * \a pixmap is shown inside the info page.
106 */
107 void gotPreview(const KFileItem* item, const QPixmap& pixmap);
108
109 /**
110 * Starts the service of m_actionsVector with the index \index on
111 * the shown URL (or the selected items if available).
112 */
113 void startService(int index);
114
115 private:
116 /**
117 * Connects to signals from the currently active Dolphin view to get
118 * informed about highlighting changes.
119 */
120 void connectToActiveView();
121
122 /**
123 * Checks whether the current URL is repesented by a bookmark. If yes,
124 * then the bookmark icon and name are shown instead of a preview.
125 * @return True, if the URL represents exactly a bookmark.
126 */
127 bool applyBookmark();
128
129 /** Assures that any pending item information request is cancelled. */
130 void cancelRequest();
131
132 // TODO: the following methods are just a prototypes for meta
133 // info generation...
134 void createMetaInfo();
135 void addInfoLine(const QString& labelText,
136 const QString& infoText);
137 void beginInfoLines();
138 void endInfoLines();
139
140 /**
141 * Returns true, if the string \a key represents a meta information
142 * that should be shown.
143 */
144 bool showMetaInfo(const QString& key) const;
145
146 /**
147 * Inserts the available actions to the info page for the given item.
148 */
149 void insertActions();
150
151 bool m_multipleSelection;
152 bool m_pendingPreview;
153 QTimer* m_timer;
154 KURL m_shownURL;
155 KURL m_urlCandidate;
156
157 PixmapViewer* m_preview;
158 QLabel* m_name;
159
160 int m_currInfoLineIdx;
161 Q3Grid* m_infoGrid;
162 Q3PtrList<QLabel> m_infoWidgets; // TODO: use children() from QObject instead
163
164 Q3VBox* m_actionBox;
165 Q3PtrList<QWidget> m_actionWidgets; // TODO: use children() from QObject instead
166 Q3ValueVector<KDEDesktopMimeType::Service> m_actionsVector;
167 };
168
169 // TODO #1: move to SidebarPage?
170 // TODO #2: quite same button from the optical point of view as URLNavigatorButton
171 // -> provide helper class or common base class
172 class ServiceButton : public QPushButton
173 {
174 Q_OBJECT
175
176 public:
177 ServiceButton(const QIcon& icon,
178 const QString& text,
179 QWidget* parent,
180 int index);
181 virtual ~ServiceButton();
182
183 signals:
184 void requestServiceStart(int index);
185
186 protected:
187 virtual void drawButton(QPainter* painter);
188 virtual void enterEvent(QEvent* event);
189 virtual void leaveEvent(QEvent* event);
190
191 private slots:
192 void slotReleased();
193
194 private:
195 bool m_hover;
196 int m_index;
197 };
198
199 #endif // _INFOSIDEBARPAGE_H_