]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/informationpanelcontent.h
[Information Panel] Remove unused PlacesItemModel
[dolphin.git] / src / panels / information / informationpanelcontent.h
1 /*
2 * SPDX-FileCopyrightText: 2009-2010 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef INFORMATIONPANELCONTENT_H
8 #define INFORMATIONPANELCONTENT_H
9
10 #include <KFileItem>
11 #include <config-baloo.h>
12
13 #include <QPointer>
14 #include <QUrl>
15 #include <QWidget>
16
17 class KFileItemList;
18 class PhononWidget;
19 class PixmapViewer;
20 class QPixmap;
21 class QDialogButtonBox;
22 class QString;
23 class QLabel;
24 class QScrollArea;
25 class QGestureEvent;
26
27 namespace KIO {
28 class PreviewJob;
29 }
30
31 namespace Baloo {
32 class FileMetaDataWidget;
33 }
34
35 /**
36 * @brief Manages the widgets that display the meta information
37 * for file items of the Information Panel.
38 */
39 class InformationPanelContent : public QWidget
40 {
41 Q_OBJECT
42
43 public:
44 explicit InformationPanelContent(QWidget* parent = nullptr);
45 ~InformationPanelContent() override;
46
47 /**
48 * Shows the meta information for the item \p item.
49 * The preview of the item is generated asynchronously,
50 * the other meta information are fetched synchronously.
51 */
52 void showItem(const KFileItem& item);
53
54 /**
55 * Shows the meta information for the items \p items and its preview
56 */
57 void showItems(const KFileItemList& items);
58
59 KFileItemList items();
60
61 /**
62 * Refreshes the preview display, hiding it if needed
63 */
64 void refreshPreview();
65
66 /**
67 * Switch the metadatawidget into configuration mode
68 */
69 void configureShownProperties();
70
71 /*
72 * Set the auto play media mode for the file previewed
73 * Eventually starting media playback when turning it on
74 * But not stopping it when turning it off
75 */
76 void setPreviewAutoPlay(bool autoPlay);
77
78 Q_SIGNALS:
79 void urlActivated( const QUrl& url );
80 void configurationFinished();
81 void contextMenuRequested(const QPoint& pos);
82
83 public Q_SLOTS:
84 /**
85 * Is invoked after the file meta data configuration dialog has been
86 * closed and refreshes the displayed meta data by the panel.
87 */
88 void refreshMetaData();
89
90 protected:
91 /** @see QObject::eventFilter() */
92 bool eventFilter(QObject* obj, QEvent* event) override;
93
94 bool event(QEvent * event) override;
95
96 private Q_SLOTS:
97 /**
98 * Is invoked if no preview is available for the item. In this
99 * case the icon will be shown.
100 */
101 void showIcon(const KFileItem& item);
102
103 /**
104 * Is invoked if a preview is available for the item. The preview
105 * \a pixmap is shown inside the info page.
106 */
107 void showPreview(const KFileItem& item, const QPixmap& pixmap);
108
109 /**
110 * Marks the currently shown preview as outdated
111 * by greying the content.
112 */
113 void markOutdatedPreview();
114
115 void slotHasVideoChanged(bool hasVideo);
116
117 private:
118 /**
119 * Sets the text for the label \a m_nameLabel and assures that the
120 * text is split in a way that it can be wrapped within the
121 * label width (QLabel::setWordWrap() does not work if the
122 * text represents one extremely long word).
123 */
124 void setNameLabelText(const QString& text);
125
126 /**
127 * Adjusts the sizes of the widgets dependent on the available
128 * width given by \p width.
129 */
130 void adjustWidgetSizes(int width);
131
132 /**
133 * Refreshes the image in the PixmapViewer
134 */
135 void refreshPixmapView();
136
137 bool gestureEvent(QGestureEvent* event);
138
139 private:
140 KFileItem m_item;
141
142 QPointer<KIO::PreviewJob> m_previewJob;
143 QTimer* m_outdatedPreviewTimer;
144
145 PixmapViewer* m_preview;
146 PhononWidget* m_phononWidget;
147 QLabel* m_nameLabel;
148 Baloo::FileMetaDataWidget* m_metaDataWidget;
149 QScrollArea* m_metaDataArea;
150 QLabel* m_configureLabel;
151 QDialogButtonBox* m_configureButtons;
152
153 bool m_isVideo;
154 };
155
156 #endif // INFORMATIONPANELCONTENT_H