2006-11-21 06:02:05 +00:00
|
|
|
/***************************************************************************
|
2007-03-11 14:41:09 +00:00
|
|
|
* Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
|
2006-11-21 06:02:05 +00:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
2006-12-08 21:24:08 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
2006-11-21 06:02:05 +00:00
|
|
|
***************************************************************************/
|
|
|
|
|
2007-03-02 18:59:09 +00:00
|
|
|
#ifndef INFOSIDEBARPAGE_H
|
|
|
|
#define INFOSIDEBARPAGE_H
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
#include <sidebarpage.h>
|
|
|
|
|
2007-04-12 13:02:58 +00:00
|
|
|
#include <QtGui/QPushButton>
|
2007-05-09 22:23:52 +00:00
|
|
|
#include <QtGui/QPixmap>
|
|
|
|
#include <QtCore/QEvent>
|
|
|
|
#include <QtGui/QLabel>
|
|
|
|
#include <QtCore/QList>
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
#include <kurl.h>
|
|
|
|
#include <kmimetype.h>
|
2007-03-26 08:24:06 +00:00
|
|
|
#include <kdesktopfileactions.h>
|
2006-11-23 07:54:24 +00:00
|
|
|
#include <kvbox.h>
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
class QPixmap;
|
|
|
|
class QString;
|
|
|
|
class KFileItem;
|
|
|
|
class QLabel;
|
|
|
|
class PixmapViewer;
|
2007-03-20 09:01:22 +00:00
|
|
|
class MetaDataWidget;
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
/**
|
2007-05-06 17:25:50 +00:00
|
|
|
* @brief Sidebar for showing meta information of one ore more selected items.
|
2006-11-21 06:02:05 +00:00
|
|
|
*/
|
|
|
|
class InfoSidebarPage : public SidebarPage
|
|
|
|
{
|
2007-04-09 19:12:54 +00:00
|
|
|
Q_OBJECT
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
public:
|
2007-03-25 06:44:28 +00:00
|
|
|
explicit InfoSidebarPage(QWidget* parent = 0);
|
2006-11-21 06:02:05 +00:00
|
|
|
virtual ~InfoSidebarPage();
|
|
|
|
|
2007-03-25 06:44:28 +00:00
|
|
|
public slots:
|
2007-05-17 14:51:54 +00:00
|
|
|
/** @see SidebarPage::setUrl() */
|
2007-05-06 17:25:50 +00:00
|
|
|
virtual void setUrl(const KUrl& url);
|
2007-05-17 14:51:54 +00:00
|
|
|
|
|
|
|
/** @see SidebarPage::setSelection() */
|
2007-05-06 17:25:50 +00:00
|
|
|
virtual void setSelection(const KFileItemList& selection);
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-05-17 14:51:54 +00:00
|
|
|
/**
|
|
|
|
* Does a delayed request of information for the item of the given URL.
|
|
|
|
* If within this delay InfoSidebarPage::setUrl() or InfoSidebarPage::setSelection()
|
|
|
|
* are invoked, then the request will be skipped. Requesting a delayed item information
|
|
|
|
* makes sense when hovering items.
|
|
|
|
*/
|
|
|
|
void requestDelayedItemInfo(const KUrl& url);
|
|
|
|
|
2007-05-06 20:46:01 +00:00
|
|
|
protected:
|
|
|
|
/** @see QWidget::showEvent() */
|
|
|
|
virtual void showEvent(QShowEvent* event);
|
|
|
|
|
2007-05-17 14:51:54 +00:00
|
|
|
/** @see QWidget::resizeEvent() */
|
|
|
|
virtual void resizeEvent(QResizeEvent* event);
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-05-17 14:51:54 +00:00
|
|
|
private slots:
|
2006-11-21 06:02:05 +00:00
|
|
|
/**
|
2007-05-17 14:51:54 +00:00
|
|
|
* Shows the information for the item of the URL which has been provided by
|
2006-11-21 06:02:05 +00:00
|
|
|
* InfoSidebarPage::requestItemInfo() and provides default actions.
|
|
|
|
*/
|
|
|
|
void showItemInfo();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggered if the request for item information has timed out.
|
|
|
|
* @see InfoSidebarPage::requestDelayedItemInfo()
|
|
|
|
*/
|
|
|
|
void slotTimeout();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is invoked if no preview is available for the item. In this
|
|
|
|
* case the icon will be shown.
|
|
|
|
*/
|
2007-05-03 05:52:54 +00:00
|
|
|
void showIcon(const KFileItem& item);
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Is invoked if a preview is available for the item. The preview
|
|
|
|
* \a pixmap is shown inside the info page.
|
|
|
|
*/
|
2007-05-03 05:52:54 +00:00
|
|
|
void showPreview(const KFileItem& item, const QPixmap& pixmap);
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
private:
|
2007-05-19 14:42:11 +00:00
|
|
|
enum { TimerDelay = 300 };
|
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
/**
|
2007-05-17 14:51:54 +00:00
|
|
|
* Checks whether the an URL is repesented by a bookmark. If yes,
|
2006-11-21 06:02:05 +00:00
|
|
|
* then the bookmark icon and name are shown instead of a preview.
|
2007-05-17 14:51:54 +00:00
|
|
|
* @return True, if the URL represents exactly a bookmark.
|
2007-02-23 02:28:27 +00:00
|
|
|
* @param url The url to check.
|
2006-11-21 06:02:05 +00:00
|
|
|
*/
|
2007-02-23 02:28:27 +00:00
|
|
|
bool applyBookmark(const KUrl& url);
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
/** Assures that any pending item information request is cancelled. */
|
|
|
|
void cancelRequest();
|
|
|
|
|
2007-05-19 17:23:35 +00:00
|
|
|
/**
|
|
|
|
* Shows the meta information for the current shown item inside
|
|
|
|
* a label.
|
|
|
|
*/
|
|
|
|
void showMetaInfo();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the texts \a labelText and \a infoText as one formated line
|
|
|
|
* to text.
|
|
|
|
*/
|
|
|
|
void addInfoLine(QString& text,
|
|
|
|
const QString& labelText,
|
2006-11-21 06:02:05 +00:00
|
|
|
const QString& infoText);
|
|
|
|
|
|
|
|
/**
|
2007-05-19 17:23:35 +00:00
|
|
|
* Converts the meta key \a key to a readable format into \a text.
|
2006-11-21 06:02:05 +00:00
|
|
|
* Returns true, if the string \a key represents a meta information
|
2007-05-19 17:23:35 +00:00
|
|
|
* that should be shown. If false is returned, \a text is not modified.
|
2006-11-21 06:02:05 +00:00
|
|
|
*/
|
2007-05-19 17:23:35 +00:00
|
|
|
bool convertMetaInfo(const QString& key, QString& text) const;
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-05-03 05:52:54 +00:00
|
|
|
private:
|
2006-11-21 06:02:05 +00:00
|
|
|
bool m_pendingPreview;
|
|
|
|
QTimer* m_timer;
|
2006-11-22 17:13:11 +00:00
|
|
|
KUrl m_shownUrl;
|
2006-11-22 08:22:45 +00:00
|
|
|
KUrl m_urlCandidate;
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
PixmapViewer* m_preview;
|
2007-05-19 17:53:12 +00:00
|
|
|
QLabel* m_nameLabel;
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-05-19 17:23:35 +00:00
|
|
|
QLabel* m_infoLabel;
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-03-20 09:01:22 +00:00
|
|
|
MetaDataWidget* m_metadataWidget;
|
2006-11-21 06:02:05 +00:00
|
|
|
};
|
|
|
|
|
2007-03-02 18:59:09 +00:00
|
|
|
#endif // INFOSIDEBARPAGE_H
|