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