From: Peter Penz Date: Thu, 21 Feb 2008 14:01:40 +0000 (+0000) Subject: * Install an event-filter for the view implementations. Whenever a view implementatio... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/518372394da1f58da8e69acbb981a97db375e739?ds=sidebyside * Install an event-filter for the view implementations. Whenever a view implementation gets the focus, it should request it's activation. * Let the metadata widget only get the focus by clicking. * Tried to install a similar filter for the wheel-event code duplication in the view-implementations, but the event filter is invoked _after_ the view implementation gets the wheel event... -> added a note the the 3 implementations as hint. svn path=/trunk/KDE/kdebase/apps/; revision=777757 --- diff --git a/src/dolphincolumnwidget.cpp b/src/dolphincolumnwidget.cpp index ca4db00c7..b1050afda 100644 --- a/src/dolphincolumnwidget.cpp +++ b/src/dolphincolumnwidget.cpp @@ -346,7 +346,7 @@ void DolphinColumnWidget::mousePressEvent(QMouseEvent* event) void DolphinColumnWidget::keyPressEvent(QKeyEvent* event) { QListView::keyPressEvent(event); - Q_ASSERT(m_view->m_controller->itemView() == this); + requestActivation(); m_view->m_controller->handleKeyPressEvent(event); } @@ -373,7 +373,8 @@ void DolphinColumnWidget::contextMenuEvent(QContextMenuEvent* event) void DolphinColumnWidget::wheelEvent(QWheelEvent* event) { // let Ctrl+wheel events propagate to the DolphinView for icon zooming - if ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) { + // (installing an event filter does not work, as the wheel event is handled first) + if (event->modifiers() & Qt::ControlModifier) { event->ignore(); return; } diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index b17164d8b..c8c419f02 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -386,9 +386,10 @@ void DolphinDetailsView::resizeEvent(QResizeEvent* event) void DolphinDetailsView::wheelEvent(QWheelEvent* event) { // let Ctrl+wheel events propagate to the DolphinView for icon zooming - if ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) { + // (installing an event filter does not work, as the wheel event is handled first) + if (event->modifiers() & Qt::ControlModifier) { event->ignore(); - return; + return; } QTreeView::wheelEvent(event); } diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index bb3d242b9..9f3114182 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -297,7 +297,8 @@ void DolphinIconsView::keyPressEvent(QKeyEvent* event) void DolphinIconsView::wheelEvent(QWheelEvent* event) { // let Ctrl+wheel events propagate to the DolphinView for icon zooming - if ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) { + // (installing an event filter does not work, as the wheel event is handled first) + if (event->modifiers() & Qt::ControlModifier) { event->ignore(); return; } diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 6f351e63b..d6c5f6c25 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -537,17 +537,26 @@ void DolphinView::mouseReleaseEvent(QMouseEvent* event) void DolphinView::wheelEvent(QWheelEvent* event) { - if ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) { - int d = event->delta(); - if (d > 0 && isZoomInPossible()) { + if (event->modifiers() & Qt::ControlModifier) { + const int delta = event->delta(); + if ((delta > 0) && isZoomInPossible()) { zoomIn(); - } else if (d < 0 && isZoomOutPossible()) { + } else if ((delta < 0) && isZoomOutPossible()) { zoomOut(); } - event->accept(); + event->accept(); } } +bool DolphinView::eventFilter(QObject* watched, QEvent* event) +{ + if ((watched == itemView()) && (event->type() == QEvent::FocusIn)) { + m_controller->requestActivation(); + } + + return QWidget::eventFilter(watched, event); +} + void DolphinView::activate() { setActive(true); @@ -897,6 +906,8 @@ void DolphinView::createView() } Q_ASSERT(view != 0); + view->installEventFilter(this); + m_controller->setItemView(view); m_fileItemDelegate = new KFileItemDelegate(view); diff --git a/src/dolphinview.h b/src/dolphinview.h index af0dd62a2..4f2964761 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -75,11 +75,11 @@ class LIBDOLPHINPRIVATE_EXPORT DolphinView : public QWidget public: /** - * Defines the view mode for a directory. The view mode - * can be defined when constructing a DolphinView. The - * view mode is automatically updated if the directory itself - * defines a view mode (see class ViewProperties for details). - */ + * Defines the view mode for a directory. The view mode + * can be defined when constructing a DolphinView. The + * view mode is automatically updated if the directory itself + * defines a view mode (see class ViewProperties for details). + */ enum Mode { /** @@ -489,6 +489,7 @@ protected: /** @see QWidget::mouseReleaseEvent */ virtual void mouseReleaseEvent(QMouseEvent* event); virtual void wheelEvent(QWheelEvent* event); + virtual bool eventFilter(QObject* watched, QEvent* event); private slots: /** diff --git a/src/metadatawidget.cpp b/src/metadatawidget.cpp index 8db305e93..4e3aa66dd 100644 --- a/src/metadatawidget.cpp +++ b/src/metadatawidget.cpp @@ -85,6 +85,7 @@ MetaDataWidget::MetaDataWidget(QWidget* parent) : #ifdef HAVE_NEPOMUK d = new Private; d->editComment = new QTextEdit(this); + d->editComment->setFocusPolicy(Qt::ClickFocus); d->ratingWidget = new KRatingWidget(this); d->tagWidget = new Nepomuk::TagWidget(this); connect(d->ratingWidget, SIGNAL(ratingChanged(unsigned int)), this, SLOT(slotRatingChanged(unsigned int)));