1 /***************************************************************************
2 * Copyright (C) 2006-2009 by Peter Penz <peter.penz19@gmail.com> *
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>
24 #include <KFileItemList>
25 class InformationPanelContent
;
32 * @brief Panel for showing meta information of one ore more selected items.
34 class InformationPanel
: public Panel
39 explicit InformationPanel(QWidget
* parent
= 0);
40 virtual ~InformationPanel();
43 void urlActivated(const QUrl
& url
);
47 * This is invoked to inform the panel that the user has selected a new
50 void setSelection(const KFileItemList
& selection
);
53 * Does a delayed request of information for the item \a item.
54 * If within this delay InformationPanel::setUrl() or InformationPanel::setSelection()
55 * are invoked, then the request will be skipped. Requesting a delayed item information
56 * makes sense when hovering items.
58 void requestDelayedItemInfo(const KFileItem
& item
);
61 /** @see Panel::urlChanged() */
62 virtual bool urlChanged() Q_DECL_OVERRIDE
;
64 /** @see QWidget::showEvent() */
65 virtual void showEvent(QShowEvent
* event
) Q_DECL_OVERRIDE
;
67 /** @see QWidget::resizeEvent() */
68 virtual void resizeEvent(QResizeEvent
* event
) Q_DECL_OVERRIDE
;
70 /** @see QWidget::contextMenuEvent() */
71 virtual void contextMenuEvent(QContextMenuEvent
* event
) Q_DECL_OVERRIDE
;
75 * Shows the information for the item of the URL which has been provided by
76 * InformationPanel::requestItemInfo() and provides default actions.
81 * Shows the information for the currently displayed folder as a result from
82 * a stat job issued in showItemInfo().
84 void slotFolderStatFinished(KJob
* job
);
87 * Triggered if the request for item information has timed out.
88 * @see InformationPanel::requestDelayedItemInfo()
90 void slotInfoTimeout();
93 * Resets the information panel to show the current
94 * URL (InformationPanel::url()). Is called by
95 * DolphinInformationPanel::markUrlAsInvalid().
99 void slotFileRenamed(const QString
& source
, const QString
& dest
);
100 void slotFilesAdded(const QString
& directory
);
101 void slotFilesChanged(const QStringList
& files
);
102 void slotFilesRemoved(const QStringList
& files
);
103 void slotEnteredDirectory(const QString
& directory
);
104 void slotLeftDirectory(const QString
& directory
);
107 /** Assures that any pending item information request is cancelled. */
108 void cancelRequest();
111 * Shows the meta information for the current shown item inside
117 * Returns true, if \a url is equal to the shown URL m_shownUrl.
119 bool isEqualToShownUrl(const QUrl
& url
) const;
122 * Marks the URL as invalid and will reset the Information Panel
123 * after a short delay. The reset is not done synchronously to
124 * prevent expensive updates during temporary invalid URLs by
125 * e. g. changing the directory.
127 void markUrlAsInvalid();
133 bool m_pendingPreview
;
135 QTimer
* m_urlChangedTimer
;
136 QTimer
* m_resetUrlTimer
;
138 // URL that is currently shown in the Information Panel.
141 // URL candidate that will replace m_shownURL after a delay.
142 // Used to remember URLs when hovering items.
145 // URL candidate that is marked as invalid (e. g. because the directory
146 // has been deleted or the shown item has been renamed). The Information
147 // Panel will be reset asynchronously to prevent unnecessary resets when
148 // a directory has been changed.
149 QUrl m_invalidUrlCandidate
;
151 KFileItem m_fileItem
; // file item for m_shownUrl if available (otherwise null)
152 KFileItemList m_selection
;
154 KIO::Job
* m_folderStatJob
;
156 InformationPanelContent
* m_content
;
159 #endif // INFORMATIONPANEL_H