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