]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/informationpanel.h
Update e-mail address from peter.penz@gmx.at to peter.penz19@gmail.com
[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 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 signals:
39 void urlActivated(const KUrl& url);
40
41 public slots:
42 /**
43 * This is invoked to inform the panel that the user has selected a new
44 * set of items.
45 */
46 void setSelection(const KFileItemList& selection);
47
48 /**
49 * Does a delayed request of information for the item \a item.
50 * If within this delay InformationPanel::setUrl() or InformationPanel::setSelection()
51 * are invoked, then the request will be skipped. Requesting a delayed item information
52 * makes sense when hovering items.
53 */
54 void requestDelayedItemInfo(const KFileItem& item);
55
56 protected:
57 /** @see Panel::urlChanged() */
58 virtual bool urlChanged();
59
60 /** @see QWidget::showEvent() */
61 virtual void showEvent(QShowEvent* event);
62
63 /** @see QWidget::resizeEvent() */
64 virtual void resizeEvent(QResizeEvent* event);
65
66 /** @see QWidget::contextMenuEvent() */
67 virtual void contextMenuEvent(QContextMenuEvent* event);
68
69 private slots:
70 /**
71 * Shows the information for the item of the URL which has been provided by
72 * InformationPanel::requestItemInfo() and provides default actions.
73 */
74 void showItemInfo();
75
76 /**
77 * Shows the information for the currently displayed folder as a result from
78 * a stat job issued in showItemInfo().
79 */
80 void slotFolderStatFinished(KJob* job);
81
82 /**
83 * Triggered if the request for item information has timed out.
84 * @see InformationPanel::requestDelayedItemInfo()
85 */
86 void slotInfoTimeout();
87
88 /**
89 * Resets the information panel to show the current
90 * URL (InformationPanel::url()). Is called by
91 * DolphinInformationPanel::markUrlAsInvalid().
92 */
93 void reset();
94
95 void slotFileRenamed(const QString& source, const QString& dest);
96 void slotFilesAdded(const QString& directory);
97 void slotFilesChanged(const QStringList& files);
98 void slotFilesRemoved(const QStringList& files);
99 void slotEnteredDirectory(const QString& directory);
100 void slotLeftDirectory(const QString& directory);
101
102 private:
103 /** Assures that any pending item information request is cancelled. */
104 void cancelRequest();
105
106 /**
107 * Shows the meta information for the current shown item inside
108 * a label.
109 */
110 void showMetaInfo();
111
112 /**
113 * Returns true, if \a url is equal to the shown URL m_shownUrl.
114 */
115 bool isEqualToShownUrl(const KUrl& url) const;
116
117 /**
118 * Marks the URL as invalid and will reset the Information Panel
119 * after a short delay. The reset is not done synchronously to
120 * prevent expensive updates during temporary invalid URLs by
121 * e. g. changing the directory.
122 */
123 void markUrlAsInvalid();
124
125 void init();
126
127 private:
128 bool m_initialized;
129 bool m_pendingPreview;
130 QTimer* m_infoTimer;
131 QTimer* m_urlChangedTimer;
132 QTimer* m_resetUrlTimer;
133
134 // URL that is currently shown in the Information Panel.
135 KUrl m_shownUrl;
136
137 // URL candidate that will replace m_shownURL after a delay.
138 // Used to remember URLs when hovering items.
139 KUrl m_urlCandidate;
140
141 // URL candidate that is marked as invalid (e. g. because the directory
142 // has been deleted or the shown item has been renamed). The Information
143 // Panel will be reset asynchronously to prevent unnecessary resets when
144 // a directory has been changed.
145 KUrl m_invalidUrlCandidate;
146
147 KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null)
148 KFileItemList m_selection;
149
150 KJob* m_folderStatJob;
151
152 InformationPanelContent* m_content;
153 };
154
155 #endif // INFORMATIONPANEL_H