]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/informationpanel.h
fix padding in places view
[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 * Returns true, if \a url is equal to the shown URL m_shownUrl.
101 */
102 bool isEqualToShownUrl(const QUrl& url) const;
103
104 /**
105 * Marks the URL as invalid and will reset the Information Panel
106 * after a short delay. The reset is not done synchronously to
107 * prevent expensive updates during temporary invalid URLs by
108 * e. g. changing the directory.
109 */
110 void markUrlAsInvalid();
111
112 /**
113 * Opens a menu which allows to configure which meta information
114 * should be shown.
115 */
116 void showContextMenu(const QPoint &point);
117
118 void init();
119
120 private:
121 bool m_initialized;
122 QTimer* m_infoTimer;
123 QTimer* m_urlChangedTimer;
124 QTimer* m_resetUrlTimer;
125
126 // URL that is currently shown in the Information Panel.
127 QUrl m_shownUrl;
128
129 // URL candidate that will replace m_shownURL after a delay.
130 // Used to remember URLs when hovering items.
131 QUrl m_urlCandidate;
132
133 // URL candidate that is marked as invalid (e. g. because the directory
134 // has been deleted or the shown item has been renamed). The Information
135 // Panel will be reset asynchronously to prevent unnecessary resets when
136 // a directory has been changed.
137 QUrl m_invalidUrlCandidate;
138
139 KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null)
140 KFileItemList m_selection;
141
142 KIO::Job* m_folderStatJob;
143
144 InformationPanelContent* m_content;
145 bool m_inConfigurationMode = false;
146 };
147
148 #endif // INFORMATIONPANEL_H