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>
25 #include <QPushButton>
33 #include <kmimetype.h>
34 #include <kdesktopfileactions.h>
37 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
);
132 void slotPlayingStarted();
133 void slotPlayingStopped();
137 * Checks whether the an URL is repesented by a place. If yes,
138 * then the place icon and name are shown instead of a preview.
139 * @return True, if the URL represents exactly a place.
140 * @param url The url to check.
142 bool applyPlace(const KUrl
& url
);
144 /** Assures that any pending item information request is cancelled. */
145 void cancelRequest();
148 * Shows the meta information for the current shown item inside
154 * Returns the item for file where the preview and meta information
155 * should be received, if InformationPanel::showMultipleSelectionInfo()
158 KFileItem
fileItem() const;
161 * Returns true, if the meta information should be shown for
162 * the multiple selected items that are stored in
163 * m_selection. If true is returned, it is assured that
164 * m_selection.count() > 1. If false is returned, the meta
165 * information should be shown for the file
166 * InformationPanel::fileUrl();
168 bool showMultipleSelectionInfo() const;
171 * Returns true, if \a url is equal to the shown URL m_shownUrl.
173 bool isEqualToShownUrl(const KUrl
& url
) const;
176 * Sets the text for the label \a m_nameLabel and assures that the
177 * text is split in a way that it can be wrapped within the
178 * label width (QLabel::setWordWrap() does not work if the
179 * text represents one extremely long word).
181 void setNameLabelText(const QString
& text
);
184 * Resets the information panel to show the current
185 * URL (InformationPanel::url()).
190 * Assures that the settings for the meta information
191 * are initialized with proper default values.
193 void initMetaInfoSettings(KConfigGroup
& group
);
195 void updatePhononWidget();
198 * Temporary helper method for KDE 4.3 as we currently don't get
199 * translated labels for Nepmok literals: Replaces camelcase labels
200 * like "fileLocation" by "File Location:".
202 QString
tunedLabel(const QString
& label
) const;
208 bool m_pendingPreview
;
210 QTimer
* m_outdatedPreviewTimer
;
211 KUrl m_shownUrl
; // URL that is shown as info
212 KUrl m_urlCandidate
; // URL candidate that will replace m_shownURL after a delay
213 KFileItem m_fileItem
; // file item for m_shownUrl if available (otherwise null)
214 KFileItemList m_selection
;
217 PixmapViewer
* m_preview
;
218 KSeparator
* m_previewSeparator
;
219 PhononWidget
* m_phononWidget
;
220 MetaDataWidget
* m_metaDataWidget
;
221 KSeparator
* m_metaDataSeparator
;
223 QScrollArea
* m_metaTextArea
;
224 MetaTextLabel
* m_metaTextLabel
;
227 #endif // INFORMATIONPANEL_H