]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/infosidebarpage.h
replace QList<KFileItem> by KFileItemList, as KFileItemList is not QList<KFileItem...
[dolphin.git] / src / infosidebarpage.h
index 8d84512e992d139ac0efded5c0f871a9d0c2d71e..ef014b3163d696146a8b83546ca394b1a3de536a 100644 (file)
 #include <sidebarpage.h>
 
 #include <QtGui/QPushButton>
-#include <QPixmap>
-#include <QEvent>
-#include <QLabel>
-#include <QList>
+#include <QtGui/QPixmap>
+#include <QtCore/QEvent>
+#include <QtGui/QLabel>
+#include <QtCore/QList>
 
 #include <kurl.h>
 #include <kmimetype.h>
 #include <kdesktopfileactions.h>
 #include <kvbox.h>
 
-namespace KIO
-{
-    class Job;
-}
-
 class QPixmap;
-class QIcon;
 class QString;
-class QPainter;
 class KFileItem;
 class QLabel;
-class KVBox;
 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
 {
@@ -61,21 +51,34 @@ public:
     explicit InfoSidebarPage(QWidget* parent = 0);
     virtual ~InfoSidebarPage();
 
+    /** @see QWidget::sizeHint() */
+    virtual QSize sizeHint() const;
+
 public slots:
-    void setUrl(const KUrl& url);
-    void setSelection(const KFileItemList& selection);
+    /** @see SidebarPage::setUrl() */
+    virtual void setUrl(const KUrl& url);
+
+    /** @see SidebarPage::setSelection() */
+    virtual void setSelection(const KFileItemList& selection);
 
-private slots:
     /**
-     * Does a delayed 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 requestDelayedItemInfo(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
+     * Shows the information for the item of the URL which has been provided by
      * InfoSidebarPage::requestItemInfo() and provides default actions.
      */
     void showItemInfo();
@@ -99,44 +102,50 @@ private slots:
     void showPreview(const KFileItem& item, const QPixmap& pixmap);
 
 private:
+    enum { TimerDelay = 300 };
+
     /**
-     * Checks whether the an 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(const KUrl& url);
+    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,
+    /**
+     * 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,
                      const QString& infoText);
-    void beginInfoLines();
-    void endInfoLines();
 
     /**
+     * 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.
+     * that should be shown. If false is returned, \a text is not modified.
      */
-    bool showMetaInfo(const QString& key) const;
+    bool convertMetaInfo(const QString& key, QString& text) const;
 
 private:
-    bool m_multipleSelection;
     bool m_pendingPreview;
     QTimer* m_timer;
     KUrl m_shownUrl;
     KUrl m_urlCandidate;
-    KFileItemList m_currentSelection;
 
     PixmapViewer* m_preview;
-    QLabel* m_name;
+    QLabel* m_nameLabel;
 
-    QString m_infoLines;
-    QLabel* m_infos;
+    QLabel* m_infoLabel;
 
     MetaDataWidget* m_metadataWidget;
 };