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