┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistcontainer.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2011-08-10 14:30:32 +0200
committerFrank Reininghaus <[email protected]>2011-08-10 14:30:32 +0200
commit6d6fe76dcf46ae71e31d730981118cdcddb16f8b (patch)
treef70ce739ecf9fb35b22f561f9f745b9ec62e5964 /src/kitemviews/kitemlistcontainer.cpp
parent2e3b7e6dd3b051b3d9cb9799e1dd22f8376d2957 (diff)
Make sure that key presses are handled in KItemListController
Key press events are forwarded from KItemListContainer to KItemListController. Right now, only the 'Home' and 'End' keys are handled (arrow keys require some more work because their action depends on the view mode). Note: 1. Before key presses are handled, the view has to be clicked with the mouse. It seems that the view does not have the keyboard focus initially. 2. The view does not scroll to the new current item yet.
Diffstat (limited to 'src/kitemviews/kitemlistcontainer.cpp')
-rw-r--r--src/kitemviews/kitemlistcontainer.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/kitemviews/kitemlistcontainer.cpp b/src/kitemviews/kitemlistcontainer.cpp
index e247df0c7..906f44640 100644
--- a/src/kitemviews/kitemlistcontainer.cpp
+++ b/src/kitemviews/kitemlistcontainer.cpp
@@ -26,6 +26,7 @@
#include "kitemlistview.h"
#include "kitemmodelbase.h"
+#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QPropertyAnimation>
@@ -82,6 +83,20 @@ KItemListController* KItemListContainer::controller() const
return m_controller;
}
+void KItemListContainer::keyPressEvent(QKeyEvent* event)
+{
+ // TODO: We should find a better way to handle the key press events in the view.
+ // The reasons why we need this hack are:
+ // 1. Without reimplementing keyPressEvent() here, the event would not reach the QGraphicsView.
+ // 2. By default, the KItemListView does not have the keyboard focus in the QGraphicsScene, so
+ // simply sending the event to the QGraphicsView which is the KItemListContainer's viewport
+ // does not work.
+ KItemListView* view = m_controller->view();
+ if (view) {
+ QApplication::sendEvent(view, event);
+ }
+}
+
void KItemListContainer::showEvent(QShowEvent* event)
{
QAbstractScrollArea::showEvent(event);