]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Activate the DolphinView if the KItemListContainer gets focus
authorFrank Reininghaus <frank78ac@googlemail.com>
Fri, 14 Oct 2011 07:21:19 +0000 (09:21 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Fri, 14 Oct 2011 07:21:19 +0000 (09:21 +0200)
This is needed in the case that the view is split to make the
DolphinMainWindow aware of the view which is currently active.

src/views/dolphinview.cpp
src/views/dolphinview.h

index 441c7e276c38a431a10f3c6f4e93511b8e068f3d..f2f434f462fcdb68103685c53b375444493ab231 100644 (file)
@@ -164,6 +164,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
 
     m_container = new DolphinItemListContainer(m_dirLister, this);
     m_container->setVisibleRoles(QList<QByteArray>() << "name");
+    m_container->installEventFilter(this);
 
     KItemListController* controller = m_container->controller();
     controller->setSelectionBehavior(KItemListController::MultiSelection);
@@ -695,10 +696,20 @@ void DolphinView::setCategorizedSorting(bool categorized)
     emit categorizedSortingChanged(categorized);
 }
 
-void DolphinView::mouseReleaseEvent(QMouseEvent* event)
+bool DolphinView::eventFilter(QObject* watched, QEvent* event)
 {
-    QWidget::mouseReleaseEvent(event);
-    setActive(true);
+    switch (event->type()) {
+    case QEvent::FocusIn:
+        if (watched == m_container) {
+            setActive(true);
+        }
+        break;
+
+    default:
+        break;
+    }
+
+    return QWidget::eventFilter(watched, event);
 }
 
 void DolphinView::activate()
index 6ebd91c536fe835145844f2d2d9477d180ac12b9..c3981bef479b22a57115f1210227316c008b9aaa 100644 (file)
@@ -409,6 +409,9 @@ public slots:
      */
     void setCategorizedSorting(bool categorized);
 
+    /** Activates the view if the item list container gets focus. */
+    virtual bool eventFilter(QObject* watched, QEvent* event);
+
 signals:
     /**
      * Is emitted if the view has been activated by e. g. a mouse click.
@@ -550,9 +553,6 @@ signals:
      */
     void writeStateChanged(bool isFolderWritable);
 
-protected:
-    virtual void mouseReleaseEvent(QMouseEvent* event);
-
 private slots:
     /**
      * Marks the view as active (DolphinView:isActive() will return true)