]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/informationpanelcontent.h
Merge branch 'Applications/19.04'
[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 QString;
36 class QLabel;
37 class QScrollArea;
38
39 namespace KIO {
40 class PreviewJob;
41 }
42
43 namespace Baloo {
44 class FileMetaDataWidget;
45 }
46
47 /**
48 * @brief Manages the widgets that display the meta information
49 * for file items of the Information Panel.
50 */
51 class InformationPanelContent : public QWidget
52 {
53 Q_OBJECT
54
55 public:
56 explicit InformationPanelContent(QWidget* parent = nullptr);
57 ~InformationPanelContent() override;
58
59 /**
60 * Shows the meta information for the item \p item.
61 * The preview of the item is generated asynchronously,
62 * the other meta information are fetched synchronously.
63 */
64 void showItem(const KFileItem& item);
65
66 /**
67 * Shows the meta information for the items \p items and its preview
68 */
69 void showItems(const KFileItemList& items);
70
71 KFileItemList items();
72
73 /**
74 * Refreshes the preview display, hiding it if needed
75 */
76 void refreshPreview();
77
78 signals:
79 void urlActivated( const QUrl& url );
80
81 public slots:
82 /**
83 * Is invoked after the file meta data configuration dialog has been
84 * closed and refreshes the displayed meta data by the panel.
85 */
86 void refreshMetaData();
87
88 protected:
89 /** @see QObject::eventFilter() */
90 bool eventFilter(QObject* obj, QEvent* event) override;
91
92 private slots:
93 /**
94 * Is invoked if no preview is available for the item. In this
95 * case the icon will be shown.
96 */
97 void showIcon(const KFileItem& item);
98
99 /**
100 * Is invoked if a preview is available for the item. The preview
101 * \a pixmap is shown inside the info page.
102 */
103 void showPreview(const KFileItem& item, const QPixmap& pixmap);
104
105 /**
106 * Marks the currently shown preview as outdated
107 * by greying the content.
108 */
109 void markOutdatedPreview();
110
111 void slotHasVideoChanged(bool hasVideo);
112
113 private:
114 /**
115 * Sets the text for the label \a m_nameLabel and assures that the
116 * text is split in a way that it can be wrapped within the
117 * label width (QLabel::setWordWrap() does not work if the
118 * text represents one extremely long word).
119 */
120 void setNameLabelText(const QString& text);
121
122 /**
123 * Adjusts the sizes of the widgets dependent on the available
124 * width given by \p width.
125 */
126 void adjustWidgetSizes(int width);
127
128 private:
129 KFileItem m_item;
130
131 QPointer<KIO::PreviewJob> m_previewJob;
132 QTimer* m_outdatedPreviewTimer;
133
134 PixmapViewer* m_preview;
135 PhononWidget* m_phononWidget;
136 QLabel* m_nameLabel;
137 Baloo::FileMetaDataWidget* m_metaDataWidget;
138 QScrollArea* m_metaDataArea;
139
140 PlacesItemModel* m_placesItemModel;
141 };
142
143 #endif // INFORMATIONPANELCONTENT_H