]> cloud.milkyroute.net Git - dolphin.git/blob - src/infosidebarpage.h
include cleanup
[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 <QtGui/QPushButton>
26 #include <QtGui/QPixmap>
27 #include <QtCore/QEvent>
28 #include <QtGui/QLabel>
29 #include <QtCore/QList>
30
31 #include <kurl.h>
32 #include <kmimetype.h>
33 #include <kdesktopfileactions.h>
34 #include <kvbox.h>
35
36 namespace KIO
37 {
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 KVBox;
48 class PixmapViewer;
49 class MetaDataWidget;
50
51 /**
52 * @brief Sidebar for showing meta information of one ore more selected items.
53 */
54 class InfoSidebarPage : public SidebarPage
55 {
56 Q_OBJECT
57
58 public:
59 explicit InfoSidebarPage(QWidget* parent = 0);
60 virtual ~InfoSidebarPage();
61
62 public slots:
63 virtual void setUrl(const KUrl& url);
64 virtual void setSelection(const KFileItemList& selection);
65
66 protected:
67 /** @see QWidget::showEvent() */
68 virtual void showEvent(QShowEvent* event);
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 * Shows the information for the item of the Url which has been provided by
81 * InfoSidebarPage::requestItemInfo() and provides default actions.
82 */
83 void showItemInfo();
84
85 /**
86 * Triggered if the request for item information has timed out.
87 * @see InfoSidebarPage::requestDelayedItemInfo()
88 */
89 void slotTimeout();
90
91 /**
92 * Is invoked if no preview is available for the item. In this
93 * case the icon will be shown.
94 */
95 void showIcon(const KFileItem& item);
96
97 /**
98 * Is invoked if a preview is available for the item. The preview
99 * \a pixmap is shown inside the info page.
100 */
101 void showPreview(const KFileItem& item, const QPixmap& pixmap);
102
103 private:
104 /**
105 * Checks whether the an Url is repesented by a bookmark. If yes,
106 * then the bookmark icon and name are shown instead of a preview.
107 * @return True, if the Url represents exactly a bookmark.
108 * @param url The url to check.
109 */
110 bool applyBookmark(const KUrl& url);
111
112 /** Assures that any pending item information request is cancelled. */
113 void cancelRequest();
114
115 // TODO: the following methods are just a prototypes for meta
116 // info generation...
117 void createMetaInfo();
118 void addInfoLine(const QString& labelText,
119 const QString& infoText);
120 void beginInfoLines();
121 void endInfoLines();
122
123 /**
124 * Returns true, if the string \a key represents a meta information
125 * that should be shown.
126 */
127 bool showMetaInfo(const QString& key) const;
128
129 private:
130 bool m_multipleSelection;
131 bool m_pendingPreview;
132 QTimer* m_timer;
133 KUrl m_shownUrl;
134 KUrl m_urlCandidate;
135
136 PixmapViewer* m_preview;
137 QLabel* m_name;
138
139 QString m_infoLines;
140 QLabel* m_infos;
141
142 MetaDataWidget* m_metadataWidget;
143 };
144
145 #endif // INFOSIDEBARPAGE_H