]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/informationpanel.h
Build with QT_NO_KEYWORDS
[dolphin.git] / src / panels / information / informationpanel.h
1 /*
2 * SPDX-FileCopyrightText: 2006-2009 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef INFORMATIONPANEL_H
8 #define INFORMATIONPANEL_H
9
10 #include "panels/panel.h"
11
12 #include <KFileItem>
13
14 class InformationPanelContent;
15 namespace KIO
16 {
17 class Job;
18 }
19
20 /**
21 * @brief Panel for showing meta information of one ore more selected items.
22 */
23 class InformationPanel : public Panel
24 {
25 Q_OBJECT
26
27 public:
28 explicit InformationPanel(QWidget* parent = nullptr);
29 ~InformationPanel() override;
30
31 Q_SIGNALS:
32 void urlActivated(const QUrl& url);
33
34 public Q_SLOTS:
35 /**
36 * This is invoked to inform the panel that the user has selected a new
37 * set of items.
38 */
39 void setSelection(const KFileItemList& selection);
40
41 /**
42 * Does a delayed request of information for the item \a item.
43 * If within this delay InformationPanel::setUrl() or InformationPanel::setSelection()
44 * are invoked, then the request will be skipped. Requesting a delayed item information
45 * makes sense when hovering items.
46 */
47 void requestDelayedItemInfo(const KFileItem& item);
48
49 protected:
50 /** @see Panel::urlChanged() */
51 bool urlChanged() override;
52
53 /** @see QWidget::showEvent() */
54 void showEvent(QShowEvent* event) override;
55
56 /** @see QWidget::resizeEvent() */
57 void resizeEvent(QResizeEvent* event) override;
58
59 /** @see QWidget::contextMenuEvent() */
60 void contextMenuEvent(QContextMenuEvent* event) override;
61
62 private Q_SLOTS:
63 /**
64 * Shows the information for the item of the URL which has been provided by
65 * InformationPanel::requestDelayedItemInfo() and provides default actions.
66 */
67 void showItemInfo();
68
69 /**
70 * Shows the information for the currently displayed folder as a result from
71 * a stat job issued in showItemInfo().
72 */
73 void slotFolderStatFinished(KJob* job);
74
75 /**
76 * Triggered if the request for item information has timed out.
77 * @see InformationPanel::requestDelayedItemInfo()
78 */
79 void slotInfoTimeout();
80
81 /**
82 * Resets the information panel to show the current
83 * URL (InformationPanel::url()). Is called by
84 * DolphinInformationPanel::markUrlAsInvalid().
85 */
86 void reset();
87
88 void slotFileRenamed(const QString& source, const QString& dest);
89 void slotFilesAdded(const QString& directory);
90 void slotFilesChanged(const QStringList& files);
91 void slotFilesRemoved(const QStringList& files);
92 void slotEnteredDirectory(const QString& directory);
93 void slotLeftDirectory(const QString& directory);
94
95 private:
96 /** Assures that any pending item information request is cancelled. */
97 void cancelRequest();
98
99 /**
100 * Shows the meta information for the current shown item inside
101 * a label.
102 */
103 void showMetaInfo();
104
105 /**
106 * Returns true, if \a url is equal to the shown URL m_shownUrl.
107 */
108 bool isEqualToShownUrl(const QUrl& url) const;
109
110 /**
111 * Marks the URL as invalid and will reset the Information Panel
112 * after a short delay. The reset is not done synchronously to
113 * prevent expensive updates during temporary invalid URLs by
114 * e. g. changing the directory.
115 */
116 void markUrlAsInvalid();
117
118 /**
119 * Opens a menu which allows to configure which meta information
120 * should be shown.
121 */
122 void showContextMenu(const QPoint &point);
123
124 void init();
125
126 private:
127 bool m_initialized;
128 QTimer* m_infoTimer;
129 QTimer* m_urlChangedTimer;
130 QTimer* m_resetUrlTimer;
131
132 // URL that is currently shown in the Information Panel.
133 QUrl m_shownUrl;
134
135 // URL candidate that will replace m_shownURL after a delay.
136 // Used to remember URLs when hovering items.
137 QUrl m_urlCandidate;
138
139 // URL candidate that is marked as invalid (e. g. because the directory
140 // has been deleted or the shown item has been renamed). The Information
141 // Panel will be reset asynchronously to prevent unnecessary resets when
142 // a directory has been changed.
143 QUrl m_invalidUrlCandidate;
144
145 KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null)
146 KFileItemList m_selection;
147
148 KIO::Job* m_folderStatJob;
149
150 InformationPanelContent* m_content;
151 bool m_inConfigurationMode = false;
152 };
153
154 #endif // INFORMATIONPANEL_H