From 794911106c265c8691689f601e4aed0862aff0b8 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 12 May 2007 10:22:01 +0000 Subject: [PATCH] provide a hover information in the statusbar if the mouse cursor enters an item svn path=/trunk/KDE/kdebase/apps/; revision=663779 --- src/dolphincolumnview.cpp | 5 +++++ src/dolphincontroller.cpp | 10 ++++++++++ src/dolphincontroller.h | 27 +++++++++++++++++++++++++++ src/dolphindetailsview.cpp | 6 +++++- src/dolphiniconsview.cpp | 5 +++++ src/dolphinview.cpp | 23 +++++++++++++++++++++++ src/dolphinview.h | 14 ++++++++++++++ 7 files changed, 89 insertions(+), 1 deletion(-) diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp index 563f68f31c..dbed1304b9 100644 --- a/src/dolphincolumnview.cpp +++ b/src/dolphincolumnview.cpp @@ -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()), diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp index 762526b3ce..4f8d8c96f0 100644 --- a/src/dolphincontroller.cpp +++ b/src/dolphincontroller.cpp @@ -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(); diff --git a/src/dolphincontroller.h b/src/dolphincontroller.h index b9431f3a79..1f277e133d 100644 --- a/src/dolphincontroller.h +++ b/src/dolphincontroller.h @@ -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(); diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 74963dc3dc..df07fb9a52 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -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()), diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index c2262c1bcb..25776412b8 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -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)), diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 4188959f1e..8360f037d7 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -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 diff --git a/src/dolphinview.h b/src/dolphinview.h index b3b2060021..96b4879619 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -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);