]> cloud.milkyroute.net Git - dolphin.git/blob - src/infosidebarpage.h
There are some extractable strings in subdirs too.
[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 class QPixmap;
37 class QString;
38 class KFileItem;
39 class QLabel;
40 class PixmapViewer;
41 class MetaDataWidget;
42 class MetaTextLabel;
43
44 /**
45 * @brief Sidebar for showing meta information of one ore more selected items.
46 */
47 class InfoSidebarPage : public SidebarPage
48 {
49 Q_OBJECT
50
51 public:
52 explicit InfoSidebarPage(QWidget* parent = 0);
53 virtual ~InfoSidebarPage();
54
55 /** @see QWidget::sizeHint() */
56 virtual QSize sizeHint() const;
57
58 public slots:
59 /** @see SidebarPage::setUrl() */
60 virtual void setUrl(const KUrl& url);
61
62 /**
63 * This is invoked to inform the sidebar that the user has selected a new
64 * set of items.
65 */
66 void setSelection(const KFileItemList& selection);
67
68 /**
69 * Does a delayed request of information for the item \a item.
70 * If within this delay InfoSidebarPage::setUrl() or InfoSidebarPage::setSelection()
71 * are invoked, then the request will be skipped. Requesting a delayed item information
72 * makes sense when hovering items.
73 */
74 void requestDelayedItemInfo(const KFileItem& item);
75
76 protected:
77 /** @see QWidget::showEvent() */
78 virtual void showEvent(QShowEvent* event);
79
80 /** @see QWidget::resizeEvent() */
81 virtual void resizeEvent(QResizeEvent* event);
82
83 private slots:
84 /**
85 * Shows the information for the item of the URL which has been provided by
86 * InfoSidebarPage::requestItemInfo() and provides default actions.
87 */
88 void showItemInfo();
89
90 /**
91 * Triggered if the request for item information has timed out.
92 * @see InfoSidebarPage::requestDelayedItemInfo()
93 */
94 void slotTimeout();
95
96 /**
97 * Is invoked if no preview is available for the item. In this
98 * case the icon will be shown.
99 */
100 void showIcon(const KFileItem& item);
101
102 /**
103 * Is invoked if a preview is available for the item. The preview
104 * \a pixmap is shown inside the info page.
105 */
106 void showPreview(const KFileItem& item, const QPixmap& pixmap);
107
108 private:
109 enum { TimerDelay = 300 };
110
111 /**
112 * Checks whether the an URL is repesented by a place. If yes,
113 * then the place icon and name are shown instead of a preview.
114 * @return True, if the URL represents exactly a place.
115 * @param url The url to check.
116 */
117 bool applyPlace(const KUrl& url);
118
119 /** Assures that any pending item information request is cancelled. */
120 void cancelRequest();
121
122 /**
123 * Shows the meta information for the current shown item inside
124 * a label.
125 */
126 void showMetaInfo();
127
128 /**
129 * Converts the meta key \a key to a readable format into \a text.
130 * Returns true, if the string \a key represents a meta information
131 * that should be shown. If false is returned, \a text is not modified.
132 */
133 bool convertMetaInfo(const QString& key, QString& text) const;
134
135 private:
136 bool m_pendingPreview;
137 QTimer* m_timer;
138 KUrl m_shownUrl; // URL that is shown as info
139 KUrl m_urlCandidate; // URL candidate that will replace m_shownURL after a delay
140 KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null)
141 KFileItemList m_selection;
142
143 QLabel* m_nameLabel;
144 PixmapViewer* m_preview;
145 MetaDataWidget* m_metaDataWidget;
146 MetaTextLabel* m_metaTextLabel;
147 };
148
149 #endif // INFOSIDEBARPAGE_H