]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/informationpanelcontent.h
Merge remote-tracking branch 'origin/KDE/4.12'
[dolphin.git] / src / panels / information / informationpanelcontent.h
1 /***************************************************************************
2 * Copyright (C) 2009-2010 by Peter Penz <peter.penz19@gmail.com> *
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 INFORMATIONPANELCONTENT_H
21 #define INFORMATIONPANELCONTENT_H
22
23 #include "config-baloo.h"
24 #include <KConfig>
25 #include <KFileItem>
26 #include <KUrl>
27 #include <KVBox>
28
29 #include <QPointer>
30
31 class KFileItemList;
32 class PhononWidget;
33 class PixmapViewer;
34 class PlacesItemModel;
35 class QPixmap;
36 class QString;
37 class QLabel;
38 class QScrollArea;
39
40 namespace KIO {
41 class PreviewJob;
42 }
43
44 #ifndef HAVE_BALOO
45 class KFileMetaDataWidget;
46 #else
47 namespace Baloo {
48 class FileMetaDataWidget;
49 }
50 #endif
51
52 /**
53 * @brief Manages the widgets that display the meta information
54 * for file items of the Information Panel.
55 */
56 class InformationPanelContent : public QWidget
57 {
58 Q_OBJECT
59
60 public:
61 explicit InformationPanelContent(QWidget* parent = 0);
62 virtual ~InformationPanelContent();
63
64 /**
65 * Shows the meta information for the item \p item.
66 * The preview of the item is generated asynchronously,
67 * the other meta information are fetched synchronously.
68 */
69 void showItem(const KFileItem& item);
70
71 /**
72 * Shows the meta information for the items \p items.
73 */
74 void showItems(const KFileItemList& items);
75
76 /**
77 * Opens a menu which allows to configure which meta information
78 * should be shown.
79 *
80 * TODO: Move this code to the class InformationPanel
81 */
82 void configureSettings(const QList<QAction*>& customContextMenuActions);
83
84 signals:
85 void urlActivated( const KUrl& url );
86
87 protected:
88 /** @see QObject::eventFilter() */
89 virtual bool eventFilter(QObject* obj, QEvent* event);
90
91 private slots:
92 /**
93 * Is invoked if no preview is available for the item. In this
94 * case the icon will be shown.
95 */
96 void showIcon(const KFileItem& item);
97
98 /**
99 * Is invoked if a preview is available for the item. The preview
100 * \a pixmap is shown inside the info page.
101 */
102 void showPreview(const KFileItem& item, const QPixmap& pixmap);
103
104 /**
105 * Marks the currently shown preview as outdated
106 * by greying the content.
107 */
108 void markOutdatedPreview();
109
110 void slotHasVideoChanged(bool hasVideo);
111
112 /**
113 * Is invoked after the file meta data configuration dialog has been
114 * closed and refreshes the visibility of the meta data.
115 */
116 void refreshMetaData();
117
118 private:
119 /**
120 * Checks whether the an URL is repesented by a place. If yes,
121 * then the place icon and name are shown instead of a preview.
122 * @return True, if the URL represents exactly a place.
123 * @param url The url to check.
124 */
125 bool applyPlace(const KUrl& url);
126
127 /**
128 * Sets the text for the label \a m_nameLabel and assures that the
129 * text is split in a way that it can be wrapped within the
130 * label width (QLabel::setWordWrap() does not work if the
131 * text represents one extremely long word).
132 */
133 void setNameLabelText(const QString& text);
134
135 /**
136 * Adjusts the sizes of the widgets dependent on the available
137 * width given by \p width.
138 */
139 void adjustWidgetSizes(int width);
140
141 private:
142 KFileItem m_item;
143
144 QPointer<KIO::PreviewJob> m_previewJob;
145 QTimer* m_outdatedPreviewTimer;
146
147 PixmapViewer* m_preview;
148 PhononWidget* m_phononWidget;
149 QLabel* m_nameLabel;
150 #ifndef HAVE_BALOO
151 KFileMetaDataWidget* m_metaDataWidget;
152 #else
153 Baloo::FileMetaDataWidget* m_metaDataWidget;
154 #endif
155 QScrollArea* m_metaDataArea;
156
157 PlacesItemModel* m_placesItemModel;
158 };
159
160 #endif // INFORMATIONPANELCONTENT_H