]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/informationpanelcontent.h
[InformationPanel] Use the new inline configuration mode
[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 <KFileItem>
24 #include <config-baloo.h>
25
26 #include <QPointer>
27 #include <QUrl>
28 #include <QWidget>
29
30 class KFileItemList;
31 class PhononWidget;
32 class PixmapViewer;
33 class PlacesItemModel;
34 class QPixmap;
35 class QDialogButtonBox;
36 class QString;
37 class QLabel;
38 class QScrollArea;
39
40 namespace KIO {
41 class PreviewJob;
42 }
43
44 namespace Baloo {
45 class FileMetaDataWidget;
46 }
47
48 /**
49 * @brief Manages the widgets that display the meta information
50 * for file items of the Information Panel.
51 */
52 class InformationPanelContent : public QWidget
53 {
54 Q_OBJECT
55
56 public:
57 explicit InformationPanelContent(QWidget* parent = nullptr);
58 ~InformationPanelContent() override;
59
60 /**
61 * Shows the meta information for the item \p item.
62 * The preview of the item is generated asynchronously,
63 * the other meta information are fetched synchronously.
64 */
65 void showItem(const KFileItem& item);
66
67 /**
68 * Shows the meta information for the items \p items and its preview
69 */
70 void showItems(const KFileItemList& items);
71
72 KFileItemList items();
73
74 /**
75 * Refreshes the preview display, hiding it if needed
76 */
77 void refreshPreview();
78
79 /**
80 * Switch the metadatawidget into configuration mode
81 */
82 void configureShownProperties();
83
84 signals:
85 void urlActivated( const QUrl& url );
86 void configurationFinished();
87
88 public slots:
89 /**
90 * Is invoked after the file meta data configuration dialog has been
91 * closed and refreshes the displayed meta data by the panel.
92 */
93 void refreshMetaData();
94
95 protected:
96 /** @see QObject::eventFilter() */
97 bool eventFilter(QObject* obj, QEvent* event) override;
98
99 private slots:
100 /**
101 * Is invoked if no preview is available for the item. In this
102 * case the icon will be shown.
103 */
104 void showIcon(const KFileItem& item);
105
106 /**
107 * Is invoked if a preview is available for the item. The preview
108 * \a pixmap is shown inside the info page.
109 */
110 void showPreview(const KFileItem& item, const QPixmap& pixmap);
111
112 /**
113 * Marks the currently shown preview as outdated
114 * by greying the content.
115 */
116 void markOutdatedPreview();
117
118 void slotHasVideoChanged(bool hasVideo);
119
120 private:
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 QPointer<KIO::PreviewJob> m_previewJob;
139 QTimer* m_outdatedPreviewTimer;
140
141 PixmapViewer* m_preview;
142 PhononWidget* m_phononWidget;
143 QLabel* m_nameLabel;
144 Baloo::FileMetaDataWidget* m_metaDataWidget;
145 QScrollArea* m_metaDataArea;
146 QLabel* m_configureLabel;
147 QDialogButtonBox* m_configureButtons;
148
149 PlacesItemModel* m_placesItemModel;
150 };
151
152 #endif // INFORMATIONPANELCONTENT_H