┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorTirtha Chatterjee <[email protected]>2011-08-29 21:13:36 +0530
committerTirtha Chatterjee <[email protected]>2011-08-29 21:13:36 +0530
commit6e6b4ce75cf3f01bad2fad34baa9ecf15a5516af (patch)
tree77a8189afa012a6d0bc38452495201243b506a6b /src/kitemviews
parentd8ce0bfe56e4df252198818db6ca2e0286ba1547 (diff)
Added the functionality to activate items by pressing 'enter' or 'return' key on them, equivalent to a mouse click.
REVIEW: 102450
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kitemlistcontroller.cpp35
-rw-r--r--src/kitemviews/kitemlistcontroller.h5
2 files changed, 26 insertions, 14 deletions
diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp
index 207535ce1..615cc9c6d 100644
--- a/src/kitemviews/kitemlistcontroller.cpp
+++ b/src/kitemviews/kitemlistcontroller.cpp
@@ -200,6 +200,11 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
}
break;
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ emit itemActivated(index);
+ break;
+
case Qt::Key_Space:
if (controlPressed) {
m_selectionManager->endAnchoredSelection();
@@ -240,7 +245,7 @@ void KItemListController::slotKeyboardActivationRequested(const QString& text, b
const int currentIndex = m_selectionManager->currentItem();
int index;
if (searchFromNextItem) {
- index = m_model->indexForKeyboardSearch(text, (currentIndex + 1) % m_model->count());
+ index = m_model->indexForKeyboardSearch(text, (currentIndex + 1) % m_model->count());
}
else {
index = m_model->indexForKeyboardSearch(text, currentIndex);
@@ -411,18 +416,24 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
m_selectionManager->setSelectedItems(QSet<int>() << index);
}
- bool emitItemClicked = true;
if (event->button() & Qt::LeftButton) {
+ bool emitItemActivated = true;
if (m_view->isAboveExpansionToggle(index, pos)) {
emit itemExpansionToggleClicked(index);
- emitItemClicked = false;
- } else if (shiftOrControlPressed || !KGlobalSettings::singleClick()) {
- emitItemClicked = false;
+ emitItemActivated = false;
+ } else if (shiftOrControlPressed) {
+ // The mouse click should only update the selection, not trigger the item
+ emitItemActivated = false;
+ } else if (!KGlobalSettings::singleClick()) {
+ emitItemActivated = false;
}
- }
-
- if (emitItemClicked) {
- emit itemClicked(index, event->button());
+ if (emitItemActivated) {
+ emit itemActivated(index);
+ }
+ } else if (event->button() & Qt::MidButton) {
+ emit itemMiddleClicked(index);
+ } else if (event->button() & Qt::RightButton) {
+ emit contextMenuRequested(index, QPointF(event->pos()));
}
} else if (clearSelection) {
m_selectionManager->clearSelection();
@@ -439,11 +450,11 @@ bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event,
const QPointF pos = transform.map(event->pos());
const int index = m_view->itemAt(pos);
- bool emitItemClicked = !KGlobalSettings::singleClick() &&
+ bool emitItemActivated = !KGlobalSettings::singleClick() &&
(event->button() & Qt::LeftButton) &&
index >= 0 && index < m_model->count();
- if (emitItemClicked) {
- emit itemClicked(index, event->button());
+ if (emitItemActivated) {
+ emit itemActivated(index);
}
return false;
}
diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h
index 04d49854e..2e33948aa 100644
--- a/src/kitemviews/kitemlistcontroller.h
+++ b/src/kitemviews/kitemlistcontroller.h
@@ -105,13 +105,14 @@ public:
virtual bool processEvent(QEvent* event, const QTransform& transform);
signals:
- void itemClicked(int index, Qt::MouseButton button);
+ void itemActivated(int index);
+ void itemMiddleClicked(int index);
+ void contextMenuRequested(int index, const QPointF& pos);
/**
* Is emitted if the item with the index \p index gets hovered.
*/
void itemHovered(int index);
-
/**
* Is emitted if the item with the index \p index gets unhovered.
* It is assured that the signal itemHovered() for this index