1 /***************************************************************************
2 * Copyright (C) 2006 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>
24 #include <panels/information/informationpaneldialog.h>
26 #include <QPushButton>
34 #include <kmimetype.h>
35 #include <kdesktopfileactions.h>
38 class InformationPanelDialog
;
50 * @brief Panel for showing meta information of one ore more selected items.
52 class InformationPanel
: public Panel
57 explicit InformationPanel(QWidget
* parent
= 0);
58 virtual ~InformationPanel();
60 /** @see QWidget::sizeHint() */
61 virtual QSize
sizeHint() const;
64 /** @see Panel::setUrl() */
65 virtual void setUrl(const KUrl
& url
);
68 * This is invoked to inform the panel that the user has selected a new
71 void setSelection(const KFileItemList
& selection
);
74 * Does a delayed request of information for the item \a item.
75 * If within this delay InformationPanel::setUrl() or InformationPanel::setSelection()
76 * are invoked, then the request will be skipped. Requesting a delayed item information
77 * makes sense when hovering items.
79 void requestDelayedItemInfo(const KFileItem
& item
);
82 /** @see QWidget::showEvent() */
83 virtual void showEvent(QShowEvent
* event
);
85 /** @see QWidget::resizeEvent() */
86 virtual void resizeEvent(QResizeEvent
* event
);
88 /** @see QObject::eventFilter() */
89 virtual bool eventFilter(QObject
* obj
, QEvent
* event
);
91 /** @see QWidget::contextMenuEvent() */
92 virtual void contextMenuEvent(QContextMenuEvent
* event
);
96 * Shows the information for the item of the URL which has been provided by
97 * InformationPanel::requestItemInfo() and provides default actions.
102 * Triggered if the request for item information has timed out.
103 * @see InformationPanel::requestDelayedItemInfo()
105 void slotInfoTimeout();
108 * Marks the currently shown preview as outdated
109 * by greying the content.
111 void markOutdatedPreview();
114 * Is invoked if no preview is available for the item. In this
115 * case the icon will be shown.
117 void showIcon(const KFileItem
& item
);
120 * Is invoked if a preview is available for the item. The preview
121 * \a pixmap is shown inside the info page.
123 void showPreview(const KFileItem
& item
, const QPixmap
& pixmap
);
125 void slotFileRenamed(const QString
& source
, const QString
& dest
);
126 void slotFilesAdded(const QString
& directory
);
127 void slotFilesChanged(const QStringList
& files
);
128 void slotFilesRemoved(const QStringList
& files
);
129 void slotEnteredDirectory(const QString
& directory
);
130 void slotLeftDirectory(const QString
& directory
);
134 * Checks whether the an URL is repesented by a place. If yes,
135 * then the place icon and name are shown instead of a preview.
136 * @return True, if the URL represents exactly a place.
137 * @param url The url to check.
139 bool applyPlace(const KUrl
& url
);
141 /** Assures that any pending item information request is cancelled. */
142 void cancelRequest();
145 * Shows the meta information for the current shown item inside
151 * Returns the item for file where the preview and meta information
152 * should be received, if InformationPanel::showMultipleSelectionInfo()
155 KFileItem
fileItem() const;
158 * Returns true, if the meta information should be shown for
159 * the multiple selected items that are stored in
160 * m_selection. If true is returned, it is assured that
161 * m_selection.count() > 1. If false is returned, the meta
162 * information should be shown for the file
163 * InformationPanel::fileUrl();
165 bool showMultipleSelectionInfo() const;
168 * Returns true, if \a url is equal to the shown URL m_shownUrl.
170 bool isEqualToShownUrl(const KUrl
& url
) const;
173 * Sets the text for the label \a m_nameLabel and assures that the
174 * text is split in a way that it can be wrapped within the
175 * label width (QLabel::setWordWrap() does not work if the
176 * text represents one extremely long word).
178 void setNameLabelText(const QString
& text
);
181 * Resets the information panel to show the current
182 * URL (InformationPanel::url()).
190 bool m_pendingPreview
;
192 QTimer
* m_outdatedPreviewTimer
;
193 KUrl m_shownUrl
; // URL that is shown as info
194 KUrl m_urlCandidate
; // URL candidate that will replace m_shownURL after a delay
195 KFileItem m_fileItem
; // file item for m_shownUrl if available (otherwise null)
196 KFileItemList m_selection
;
199 PixmapViewer
* m_preview
;
200 PhononWidget
* m_phononWidget
;
201 MetaDataWidget
* m_metaDataWidget
;
203 QScrollArea
* m_metaTextArea
;
204 MetaTextLabel
* m_metaTextLabel
;
206 QPointer
<InformationPanelDialog
> m_dialog
;
209 #endif // INFORMATIONPANEL_H