1 /***************************************************************************
2 * Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at> *
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. *
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. *
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 ***************************************************************************/
20 #ifndef INFORMATIONPANEL_H
21 #define INFORMATIONPANEL_H
23 #include <panels/panel.h>
25 class InformationPanelContent
;
28 * @brief Panel for showing meta information of one ore more selected items.
30 class InformationPanel
: public Panel
35 explicit InformationPanel(QWidget
* parent
= 0);
36 virtual ~InformationPanel();
38 /** @see QWidget::sizeHint() */
39 virtual QSize
sizeHint() const;
42 void urlActivated(const KUrl
& url
);
46 * This is invoked to inform the panel that the user has selected a new
49 void setSelection(const KFileItemList
& selection
);
52 * Does a delayed request of information for the item \a item.
53 * If within this delay InformationPanel::setUrl() or InformationPanel::setSelection()
54 * are invoked, then the request will be skipped. Requesting a delayed item information
55 * makes sense when hovering items.
57 void requestDelayedItemInfo(const KFileItem
& item
);
60 /** @see Panel::urlChanged() */
61 virtual bool urlChanged();
63 /** @see QWidget::showEvent() */
64 virtual void showEvent(QShowEvent
* event
);
66 /** @see QWidget::resizeEvent() */
67 virtual void resizeEvent(QResizeEvent
* event
);
69 /** @see QWidget::contextMenuEvent() */
70 virtual void contextMenuEvent(QContextMenuEvent
* event
);
74 * Shows the information for the item of the URL which has been provided by
75 * InformationPanel::requestItemInfo() and provides default actions.
80 * Shows the information for the currently displayed folder as a result from
81 * a stat job issued in showItemInfo().
83 void slotFolderStatFinished(KJob
* job
);
86 * Triggered if the request for item information has timed out.
87 * @see InformationPanel::requestDelayedItemInfo()
89 void slotInfoTimeout();
92 * Resets the information panel to show the current
93 * URL (InformationPanel::url()). Is called by
94 * DolphinInformationPanel::markUrlAsInvalid().
98 void slotFileRenamed(const QString
& source
, const QString
& dest
);
99 void slotFilesAdded(const QString
& directory
);
100 void slotFilesChanged(const QStringList
& files
);
101 void slotFilesRemoved(const QStringList
& files
);
102 void slotEnteredDirectory(const QString
& directory
);
103 void slotLeftDirectory(const QString
& directory
);
106 /** Assures that any pending item information request is cancelled. */
107 void cancelRequest();
110 * Shows the meta information for the current shown item inside
116 * Returns true, if \a url is equal to the shown URL m_shownUrl.
118 bool isEqualToShownUrl(const KUrl
& url
) const;
121 * Marks the URL as invalid and will reset the Information Panel
122 * after a short delay. The reset is not done synchronously to
123 * prevent expensive updates during temporary invalid URLs by
124 * e. g. changing the directory.
126 void markUrlAsInvalid();
132 bool m_pendingPreview
;
134 QTimer
* m_urlChangedTimer
;
135 QTimer
* m_resetUrlTimer
;
137 // URL that is currently shown in the Information Panel.
140 // URL candidate that will replace m_shownURL after a delay.
141 // Used to remember URLs when hovering items.
144 // URL candidate that is marked as invalid (e. g. because the directory
145 // has been deleted or the shown item has been renamed). The Information
146 // Panel will be reset asynchronously to prevent unnecessary resets when
147 // a directory has been changed.
148 KUrl m_invalidUrlCandidate
;
150 KFileItem m_fileItem
; // file item for m_shownUrl if available (otherwise null)
151 KFileItemList m_selection
;
153 KJob
* m_folderStatJob
;
155 InformationPanelContent
* m_content
;
158 #endif // INFORMATIONPANEL_H