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