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