/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>
+ * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
* *
* 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 *
* 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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#ifndef _INFOSIDEBARPAGE_H_
-#define _INFOSIDEBARPAGE_H_
+#ifndef INFOSIDEBARPAGE_H
+#define INFOSIDEBARPAGE_H
#include <sidebarpage.h>
-#include <q3valuevector.h>
-#include <qpushbutton.h>
-//Added by qt3to4:
-#include <QPixmap>
-#include <QEvent>
-#include <QLabel>
-#include <Q3PtrList>
+#include <QtGui/QPushButton>
+#include <QtGui/QPixmap>
+#include <QtCore/QEvent>
+#include <QtGui/QLabel>
+#include <QtCore/QList>
#include <kurl.h>
#include <kmimetype.h>
-#include <kdedesktopmimetype.h>
-
-namespace KIO {
- class Job;
-};
+#include <kdesktopfileactions.h>
+#include <kvbox.h>
class QPixmap;
-class QIcon;
class QString;
-class QPainter;
class KFileItem;
class QLabel;
-class Q3VBox;
-class Q3Grid;
class PixmapViewer;
+class MetaDataWidget;
/**
- * @brief Prototype for a information sidebar.
- *
- * Will be exchanged in future releases by pluggable sidebar pages...
+ * @brief Sidebar for showing meta information of one ore more selected items.
*/
class InfoSidebarPage : public SidebarPage
{
- Q_OBJECT
+ Q_OBJECT
public:
- InfoSidebarPage(QWidget* parent);
+ explicit InfoSidebarPage(QWidget* parent = 0);
virtual ~InfoSidebarPage();
-protected:
- /** @see SidebarPage::activeViewChanged() */
- virtual void activeViewChanged();
+ /** @see QWidget::sizeHint() */
+ virtual QSize sizeHint() const;
-private slots:
- /**
- * Does a delayed request of information for the item of the given URL and
- * provides default actions.
- *
- * @see InfoSidebarPage::showItemInfo()
- */
- void requestDelayedItemInfo(const KUrl& url);
+public slots:
+ /** @see SidebarPage::setUrl() */
+ virtual void setUrl(const KUrl& url);
+
+ /** @see SidebarPage::setSelection() */
+ virtual void setSelection(const KFileItemList& selection);
/**
- * Does a request of information for the item of the given URL and
- * provides default actions.
- *
- * @see InfoSidebarPage::showItemInfo()
+ * Does a delayed request of information for the item \a item.
+ * 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 requestItemInfo(const KUrl& url);
+ void requestDelayedItemInfo(const KFileItem& item);
+
+protected:
+ /** @see QWidget::showEvent() */
+ virtual void showEvent(QShowEvent* event);
+ /** @see QWidget::resizeEvent() */
+ virtual void resizeEvent(QResizeEvent* event);
+
+private slots:
/**
* Shows the information for the item of the URL which has been provided by
* InfoSidebarPage::requestItemInfo() and provides default actions.
* Is invoked if no preview is available for the item. In this
* case the icon will be shown.
*/
- void slotPreviewFailed(const KFileItem* item);
+ void showIcon(const KFileItem& item);
/**
* Is invoked if a preview is available for the item. The preview
* \a pixmap is shown inside the info page.
*/
- void gotPreview(const KFileItem* item, const QPixmap& pixmap);
-
- /**
- * Starts the service of m_actionsVector with the index \index on
- * the shown URL (or the selected items if available).
- */
- void startService(int index);
+ void showPreview(const KFileItem& item, const QPixmap& pixmap);
private:
- /**
- * Connects to signals from the currently active Dolphin view to get
- * informed about highlighting changes.
- */
- void connectToActiveView();
+ enum { TimerDelay = 300 };
/**
- * Checks whether the current URL is repesented by a bookmark. If yes,
- * then the bookmark icon and name are shown instead of a preview.
- * @return True, if the URL represents exactly a bookmark.
+ * Checks whether the an URL is repesented by a place. If yes,
+ * then the place icon and name are shown instead of a preview.
+ * @return True, if the URL represents exactly a place.
+ * @param url The url to check.
*/
- bool applyBookmark();
+ bool applyPlace(const KUrl& url);
/** Assures that any pending item information request is cancelled. */
void cancelRequest();
- // TODO: the following methods are just a prototypes for meta
- // info generation...
- void createMetaInfo();
- void addInfoLine(const QString& labelText,
- const QString& infoText);
- void beginInfoLines();
- void endInfoLines();
+ /**
+ * Shows the meta information for the current shown item inside
+ * a label.
+ */
+ void showMetaInfo();
/**
- * Returns true, if the string \a key represents a meta information
- * that should be shown.
+ * Adds the texts \a labelText and \a infoText as one formated line
+ * to text.
*/
- bool showMetaInfo(const QString& key) const;
+ void addInfoLine(QString& text,
+ const QString& labelText,
+ const QString& infoText);
/**
- * Inserts the available actions to the info page for the given item.
+ * Converts the meta key \a key to a readable format into \a text.
+ * Returns true, if the string \a key represents a meta information
+ * that should be shown. If false is returned, \a text is not modified.
*/
- void insertActions();
+ bool convertMetaInfo(const QString& key, QString& text) const;
- bool m_multipleSelection;
+private:
bool m_pendingPreview;
QTimer* m_timer;
- KUrl m_shownURL;
- KUrl m_urlCandidate;
+ KUrl m_shownUrl; // URL that is shown as info
+ KUrl m_urlCandidate; // URL candidate that will replace m_shownURL after a delay
+ KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null)
PixmapViewer* m_preview;
- QLabel* m_name;
-
- int m_currInfoLineIdx;
- Q3Grid* m_infoGrid;
- Q3PtrList<QLabel> m_infoWidgets; // TODO: use children() from QObject instead
-
- Q3VBox* m_actionBox;
- Q3PtrList<QWidget> m_actionWidgets; // TODO: use children() from QObject instead
- Q3ValueVector<KDEDesktopMimeType::Service> m_actionsVector;
-};
-
-// TODO #1: move to SidebarPage?
-// TODO #2: quite same button from the optical point of view as URLNavigatorButton
-// -> provide helper class or common base class
-class ServiceButton : public QPushButton
-{
- Q_OBJECT
+ QLabel* m_nameLabel;
-public:
- ServiceButton(const QIcon& icon,
- const QString& text,
- QWidget* parent,
- int index);
- virtual ~ServiceButton();
+ QLabel* m_infoLabel;
-signals:
- void requestServiceStart(int index);
-
-protected:
- virtual void drawButton(QPainter* painter);
- virtual void enterEvent(QEvent* event);
- virtual void leaveEvent(QEvent* event);
-
-private slots:
- void slotReleased();
-
-private:
- bool m_hover;
- int m_index;
+ MetaDataWidget* m_metadataWidget;
};
-#endif // _INFOSIDEBARPAGE_H_
+#endif // INFOSIDEBARPAGE_H