]> cloud.milkyroute.net Git - dolphin.git/commitdiff
provide a hover information in the statusbar if the mouse cursor enters an item
authorPeter Penz <peter.penz19@gmail.com>
Sat, 12 May 2007 10:22:01 +0000 (10:22 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 12 May 2007 10:22:01 +0000 (10:22 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=663779

src/dolphincolumnview.cpp
src/dolphincontroller.cpp
src/dolphincontroller.h
src/dolphindetailsview.cpp
src/dolphiniconsview.cpp
src/dolphinview.cpp
src/dolphinview.h

index 563f68f31c5f851633e37eaf4ba2da944f59efa8..dbed1304b936d603bc8c3f6159ced7eca2f0686b 100644 (file)
@@ -42,6 +42,7 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* control
     setDragDropMode(QAbstractItemView::DragDrop);
     setDropIndicatorShown(false);
 
+    setMouseTracking(true);
     viewport()->setAttribute(Qt::WA_Hover);
 
     if (KGlobalSettings::singleClick()) {
@@ -53,6 +54,10 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* control
     }
     connect(this, SIGNAL(activated(const QModelIndex&)),
             controller, SLOT(triggerItem(const QModelIndex&)));
+    connect(this, SIGNAL(entered(const QModelIndex&)),
+            controller, SLOT(emitItemEntered(const QModelIndex&)));
+    connect(this, SIGNAL(viewportEntered()),
+            controller, SLOT(emitViewportEntered()));
     connect(controller, SIGNAL(zoomIn()),
             this, SLOT(zoomIn()));
     connect(controller, SIGNAL(zoomOut()),
index 762526b3ce2149009f2143d4ae3b846da374c32b..4f8d8c96f07094404b25ac73738b2a9d5076b998 100644 (file)
@@ -92,6 +92,16 @@ void DolphinController::triggerItem(const QModelIndex& index)
     emit itemTriggered(index);
 }
 
+void DolphinController::emitItemEntered(const QModelIndex& index)
+{
+    emit itemEntered(index);
+}
+
+void DolphinController::emitViewportEntered()
+{
+    emit viewportEntered();
+}
+
 void DolphinController::indicateSelectionChange()
 {
     emit selectionChanged();
index b9431f3a79b86b71526b2ded5b7a21699f38ed51..1f277e133d632a815fd133d0797b222318d957a1 100644 (file)
@@ -84,7 +84,23 @@ public:
     inline bool isZoomOutPossible() const;
 
 public slots:
+    /**
+     * Emits the signal itemTriggered(). The method should be invoked by the
+     * controller parent whenever the user has triggered an item. */
     void triggerItem(const QModelIndex& index);
+
+    /**
+     * Emits the signal itemEntered(). The method should be invoked by
+     * the controller parent whenever the mouse cursor is above an item.
+     */
+    void emitItemEntered(const QModelIndex& index);
+
+    /**
+     * Emits the signal viewportEntered(). The method should be invoked by
+     * the controller parent whenever the mouse cursor is above the viewport.
+     */
+    void emitViewportEntered();
+
     void indicateSelectionChange();
 
 signals:
@@ -136,6 +152,17 @@ signals:
      */
     void itemTriggered(const QModelIndex& index);
 
+    /**
+     * Is emitted if the mouse cursor has entered the item
+     * given by \a index.
+     */
+    void itemEntered(const QModelIndex& index);
+
+    /**
+     * Is emitted if the mouse cursor has entered
+     * the viewport. */
+    void viewportEntered();
+
     /** Is emitted if the selection has been changed by the user. */
     void selectionChanged();
 
index 74963dc3dcfd61209e7f3519075517470cd25eff..df07fb9a52a1fa10966cd34c4408b27bfd7aed7d 100644 (file)
@@ -46,6 +46,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
     setDragDropMode(QAbstractItemView::DragDrop);
     setDropIndicatorShown(false);
 
+    setMouseTracking(true);
     viewport()->setAttribute(Qt::WA_Hover);
 
     const ViewProperties props(controller->url());
@@ -69,7 +70,10 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
     }
     connect(this, SIGNAL(activated(const QModelIndex&)),
             controller, SLOT(triggerItem(const QModelIndex&)));
-
+    connect(this, SIGNAL(entered(const QModelIndex&)),
+            controller, SLOT(emitItemEntered(const QModelIndex&)));
+    connect(this, SIGNAL(viewportEntered()),
+            controller, SLOT(emitViewportEntered()));
     connect(controller, SIGNAL(zoomIn()),
             this, SLOT(zoomIn()));
     connect(controller, SIGNAL(zoomOut()),
index c2262c1bcb295648f154e40108206762c1dc51bd..25776412b864bef2791b82b524726e81750bbd9d 100644 (file)
@@ -40,6 +40,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     setViewMode(QListView::IconMode);
     setResizeMode(QListView::Adjust);
 
+    setMouseTracking(true);
     viewport()->setAttribute(Qt::WA_Hover);
 
     if (KGlobalSettings::singleClick()) {
@@ -51,6 +52,10 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     }
     connect(this, SIGNAL(activated(const QModelIndex&)),
             controller, SLOT(triggerItem(const QModelIndex&)));
+    connect(this, SIGNAL(entered(const QModelIndex&)),
+            controller, SLOT(emitItemEntered(const QModelIndex&)));
+    connect(this, SIGNAL(viewportEntered()),
+            controller, SLOT(emitViewportEntered()));
     connect(controller, SIGNAL(showPreviewChanged(bool)),
             this, SLOT(slotShowPreviewChanged(bool)));
     connect(controller, SIGNAL(showAdditionalInfoChanged(bool)),
index 4188959f1e3e9dbc7a3f7715bea97e676755a210..8360f037d76d871ee5a6c164e995d3090a467f7a 100644 (file)
@@ -157,6 +157,10 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow,
             this, SLOT(emitSelectionChangedSignal()));
     connect(m_controller, SIGNAL(activated()),
             this, SLOT(requestActivation()));
+    connect(m_controller, SIGNAL(itemEntered(const QModelIndex&)),
+            this, SLOT(showHoverInformation(const QModelIndex&)));
+    connect(m_controller, SIGNAL(viewportEntered()),
+            this, SLOT(clearHoverInformation()));
 
     createView();
 
@@ -1179,6 +1183,25 @@ void DolphinView::updateCutItems()
     applyCutItemEffect();
 }
 
+void DolphinView::showHoverInformation(const QModelIndex& index)
+{
+    if (hasSelection()) {
+        return;
+    }
+
+    const KFileItem* item = fileItem(index);
+    if (item != 0) {
+        m_statusBar->setMessage(item->getStatusBarInfo(), DolphinStatusBar::Default);
+        emit requestItemInfo(item->url());
+    }
+}
+
+void DolphinView::clearHoverInformation()
+{
+    m_statusBar->clear();
+}
+
+
 void DolphinView::createView()
 {
     // delete current view
index b3b20600216b031182ed37e437d6dc47a27a3b49..96b4879619b8f4b0b061df08113aae4f1316088b 100644 (file)
@@ -528,6 +528,20 @@ private slots:
     /** Applies an item effect to all cut items of the clipboard. */
     void updateCutItems();
 
+    /**
+     * Updates the status bar to show hover information for the
+     * item with the index \a index. If currently other items are selected,
+     * no hover information is shown.
+     * @see DolphinView::clearHoverInformation()
+     */
+    void showHoverInformation(const QModelIndex& index);
+
+    /**
+     * Clears the hover information shown in the status bar.
+     * @see DolphinView::showHoverInformation().
+     */
+    void clearHoverInformation();
+
 private:
     void startDirLister(const KUrl& url, bool reload = false);