]> cloud.milkyroute.net Git - dolphin.git/commitdiff
information sidebar fixes:
authorPeter Penz <peter.penz19@gmail.com>
Thu, 17 May 2007 14:51:54 +0000 (14:51 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 17 May 2007 14:51:54 +0000 (14:51 +0000)
- provide meta information when hovering items
- don't increase the sidebar width, if the item name is longer than the available width

svn path=/trunk/KDE/kdebase/apps/; revision=665646

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/infosidebarpage.cpp
src/infosidebarpage.h

index 5b7fde6ce24caa77e8a60e25728458d787763416..43b699ee2b226e52af6c891f905e323f45744c2a 100644 (file)
@@ -353,6 +353,11 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
     emit selectionChanged(selection);
 }
 
+void DolphinMainWindow::slotRequestItemInfo(const KUrl& url)
+{
+    emit requestItemInfo(url);
+}
+
 void DolphinMainWindow::slotHistoryChanged()
 {
     updateHistory();
@@ -1247,6 +1252,8 @@ void DolphinMainWindow::setupDockWidgets()
             infoWidget, SLOT(setUrl(KUrl)));
     connect(this, SIGNAL(selectionChanged(KFileItemList)),
             infoWidget, SLOT(setSelection(KFileItemList)));
+    connect(this, SIGNAL(requestItemInfo(KUrl)),
+            infoWidget, SLOT(requestDelayedItemInfo(KUrl)));
 
     // setup "Tree View"
     QDockWidget* treeViewDock = new QDockWidget(i18n("Folders"));
@@ -1461,6 +1468,8 @@ void DolphinMainWindow::connectViewSignals(int viewIndex)
             this, SLOT(slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation)));
     connect(view, SIGNAL(selectionChanged(KFileItemList)),
             this, SLOT(slotSelectionChanged(KFileItemList)));
+    connect(view, SIGNAL(requestItemInfo(KUrl)),
+            this, SLOT(slotRequestItemInfo(KUrl)));
     connect(view, SIGNAL(showFilterBarChanged(bool)),
             this, SLOT(updateFilterBarAction(bool)));
     connect(view, SIGNAL(urlChanged(KUrl)),
index 35b1b5267866d81a213b26d62362d14a5ce67c09..8d44a10862ae233094410351f8334d976ace3a0c 100644 (file)
@@ -143,6 +143,12 @@ signals:
      */
     void urlChanged(const KUrl& url);
 
+    /**
+     * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
+     * It the URL is empty, no item information request is pending.
+     */
+    void requestItemInfo(const KUrl& url);
+
 protected:
     /** @see QMainWindow::closeEvent */
     virtual void closeEvent(QCloseEvent* event);
@@ -379,9 +385,15 @@ private slots:
     /** Updates the state of the 'Additional Information' actions. */
     void slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info);
 
-    /** Updates the state of the 'Edit' menu actions. */
+    /**
+     * Updates the state of the 'Edit' menu actions and emits
+     * the signal selectionChanged().
+     */
     void slotSelectionChanged(const KFileItemList& selection);
 
+    /** Emits the signal requestItemInfo(). */
+    void slotRequestItemInfo(const KUrl& url);
+
     /**
      * Updates the state of the 'Back' and 'Forward' menu
      * actions corresponding the the current history.
index 8d99ddecef2cce05809b7b7ae496a91ecf32ee82..07887e2bdcac69df07e6a0078d0a18698c87b2b3 100644 (file)
 
 #include "infosidebarpage.h"
 
-#include <QtGui/QLayout>
-#include <QtGui/QPixmap>
-#include <QtGui/QLabel>
-#include <QtCore/QTimer>
-#include <QtGui/QPushButton>
-#include <QtGui/QMenu>
-#include <QtGui/QPainter>
-#include <QtGui/QFontMetrics>
-#include <QtCore/QEvent>
-#include <QtGui/QInputDialog>
-#include <QtCore/QDir>
+#include <QDir>
+#include <QEvent>
+#include <QFontMetrics>
+#include <QInputDialog>
+#include <QLabel>
+#include <QLayout>
+#include <QMenu>
+#include <QPainter>
+#include <QPixmap>
+#include <QPushButton>
+#include <QResizeEvent>
+#include <QTimer>
 
 #include <kfileplacesmodel.h>
 #include <klocale.h>
@@ -77,19 +78,13 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
     m_name = new QLabel(this);
     m_name->setTextFormat(Qt::RichText);
     m_name->setAlignment(m_name->alignment() | Qt::AlignHCenter);
-    QFontMetrics fontMetrics(m_name->font());
-    m_name->setMinimumHeight(fontMetrics.height() * 3);
-    m_name->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
-
-    KSeparator* sep1 = new KSeparator(this);
+    m_name->setWordWrap(true);
 
     // general information
     m_infos = new QLabel(this);
     m_infos->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     m_infos->setTextFormat(Qt::RichText);
 
-    KSeparator* sep2 = new KSeparator(this);
-
     if (MetaDataWidget::metaDataAvailable()) {
         m_metadataWidget = new MetaDataWidget(this);
     }
@@ -97,9 +92,9 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
     layout->addItem(new QSpacerItem(spacing, spacing, QSizePolicy::Preferred, QSizePolicy::Fixed));
     layout->addWidget(m_preview);
     layout->addWidget(m_name);
-    layout->addWidget(sep1);
+    layout->addWidget(new KSeparator(this));
     layout->addWidget(m_infos);
-    layout->addWidget(sep2);
+    layout->addWidget(new KSeparator(this));
     if (m_metadataWidget) {
         layout->addWidget(m_metadataWidget);
         layout->addWidget(new KSeparator(this));
@@ -130,12 +125,6 @@ void InfoSidebarPage::setSelection(const KFileItemList& selection)
     showItemInfo();
 }
 
-void InfoSidebarPage::showEvent(QShowEvent* event)
-{
-    SidebarPage::showEvent(event);
-    showItemInfo();
-}
-
 void InfoSidebarPage::requestDelayedItemInfo(const KUrl& url)
 {
     cancelRequest();
@@ -147,6 +136,22 @@ void InfoSidebarPage::requestDelayedItemInfo(const KUrl& url)
     }
 }
 
+void InfoSidebarPage::showEvent(QShowEvent* event)
+{
+    SidebarPage::showEvent(event);
+    showItemInfo();
+}
+
+void InfoSidebarPage::resizeEvent(QResizeEvent* event)
+{
+    // If the item name cannot get wrapped, the maximum width of
+    // the label is increased, so that the width of the information sidebar
+    // gets increased. To prevent this, the maximum width is adjusted to
+    // the current width of the sidebar.
+    m_name->setMaximumWidth(event->size().width() - KDialog::spacingHint() * 4);
+    SidebarPage::resizeEvent(event);
+}
+
 void InfoSidebarPage::showItemInfo()
 {
     if (!isVisible()) {
index 5aa4f5d07c7e47a1612b3d08d56148e0f76eae4b..9fcf449be3149fac5677a772d1a2f12b508e8a20 100644 (file)
@@ -60,24 +60,30 @@ public:
     virtual ~InfoSidebarPage();
 
 public slots:
+    /** @see SidebarPage::setUrl() */
     virtual void setUrl(const KUrl& url);
+
+    /** @see SidebarPage::setSelection() */
     virtual void setSelection(const KFileItemList& selection);
 
+    /**
+     * 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);
+
 protected:
     /** @see QWidget::showEvent() */
     virtual void showEvent(QShowEvent* event);
 
-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);
+    /** @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();
@@ -102,9 +108,9 @@ private slots:
 
 private:
     /**
-     * Checks whether the an Url is repesented by a bookmark. If yes,
+     * 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.
+     * @return True, if the URL represents exactly a bookmark.
      * @param url The url to check.
      */
     bool applyBookmark(const KUrl& url);