]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/informationpanel.h
* No need to reload all tags when one is deleted.
[dolphin.git] / src / panels / information / informationpanel.h
1 /***************************************************************************
2 * Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at> *
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 class InformationPanelContent;
26
27 /**
28 * @brief Panel for showing meta information of one ore more selected items.
29 */
30 class InformationPanel : public Panel
31 {
32 Q_OBJECT
33
34 public:
35 explicit InformationPanel(QWidget* parent = 0);
36 virtual ~InformationPanel();
37
38 /** @see QWidget::sizeHint() */
39 virtual QSize sizeHint() const;
40
41 signals:
42 void urlActivated(const KUrl& url);
43
44 public slots:
45 /** @see Panel::setUrl() */
46 virtual void setUrl(const KUrl& url);
47
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 QWidget::showEvent() */
64 virtual void showEvent(QShowEvent* event);
65
66 /** @see QWidget::resizeEvent() */
67 virtual void resizeEvent(QResizeEvent* event);
68
69 /** @see QWidget::contextMenuEvent() */
70 virtual void contextMenuEvent(QContextMenuEvent* event);
71
72 private slots:
73 /**
74 * Shows the information for the item of the URL which has been provided by
75 * InformationPanel::requestItemInfo() and provides default actions.
76 */
77 void showItemInfo();
78
79 /**
80 * Triggered if the request for item information has timed out.
81 * @see InformationPanel::requestDelayedItemInfo()
82 */
83 void slotInfoTimeout();
84
85 /**
86 * Resets the information panel to show the current
87 * URL (InformationPanel::url()). Is called by
88 * DolphinInformationPanel::markUrlAsInvalid().
89 */
90 void reset();
91
92 void slotFileRenamed(const QString& source, const QString& dest);
93 void slotFilesAdded(const QString& directory);
94 void slotFilesChanged(const QStringList& files);
95 void slotFilesRemoved(const QStringList& files);
96 void slotEnteredDirectory(const QString& directory);
97 void slotLeftDirectory(const QString& directory);
98
99 private:
100 /** Assures that any pending item information request is cancelled. */
101 void cancelRequest();
102
103 /**
104 * Shows the meta information for the current shown item inside
105 * a label.
106 */
107 void showMetaInfo();
108
109 /**
110 * Returns true, if the meta information should be shown for
111 * the multiple selected items that are stored in
112 * m_selection. If true is returned, it is assured that
113 * m_selection.count() > 1. If false is returned, the meta
114 * information should be shown for the file
115 * InformationPanel::fileUrl();
116 */
117 bool showMultipleSelectionInfo() const;
118
119 /**
120 * Returns true, if \a url is equal to the shown URL m_shownUrl.
121 */
122 bool isEqualToShownUrl(const KUrl& url) const;
123
124 /**
125 * Marks the URL as invalid and will reset the Information Panel
126 * after a short delay. The reset is not done synchronously to
127 * prevent expensive updates during temporary invalid URLs by
128 * e. g. changing the directory.
129 */
130 void markUrlAsInvalid();
131
132 void init();
133
134 private:
135 bool m_initialized;
136 bool m_pendingPreview;
137 QTimer* m_infoTimer;
138 QTimer* m_urlChangedTimer;
139 QTimer* m_resetUrlTimer;
140
141 // URL that is currently shown in the Information Panel.
142 KUrl m_shownUrl;
143
144 // URL candidate that will replace m_shownURL after a delay.
145 // Used to remember URLs when hovering items.
146 KUrl m_urlCandidate;
147
148 // URL candidate that is marked as invalid (e. g. because the directory
149 // has been deleted or the shown item has been renamed). The Information
150 // Panel will be reset asynchronously to prevent unnecessary resets when
151 // a directory has been changed.
152 KUrl m_invalidUrlCandidate;
153
154 KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null)
155 KFileItemList m_selection;
156
157 InformationPanelContent* m_content;
158 };
159
160 #endif // INFORMATIONPANEL_H