-
Notifications
You must be signed in to change notification settings - Fork 0
/
olistview.cpp
42 lines (35 loc) · 1.39 KB
/
olistview.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "olistview.h"
#include <QDebug>
#include <QEvent>
#include <qevent.h>
OListView::OListView(QWidget *parent)
{
setSelectionMode(QAbstractItemView::ContiguousSelection);
setSelectionRectVisible(true);
setContextMenuPolicy(Qt::ActionsContextMenu);
}
bool OListView::event(QEvent *event){
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
//qDebug()<<keyEvent->key()<<" "<<keyEvent->modifiers()<<endl;
if ((keyEvent->key() == 16777235 || keyEvent->key() == 16777237) && keyEvent->modifiers()==0) { //up
emit(upDownKeyPressed());
}
else if (keyEvent->key() == 16777234 && keyEvent->modifiers()==0) { //left
emit(leftKeyPressed());
}
else if (keyEvent->key() == 16777236/*rightArrow*/ && keyEvent->modifiers()==67108864/*Ctrl*/) {
emit(rightKeyPressed());
}
else if (keyEvent->key() == 16777223 && keyEvent->modifiers()==0) {
emit(deletPressed());
}
else if (keyEvent->key() == 83 && keyEvent->modifiers()==67108864) {
emit(cntrlPlusSPressed());
}
else if (keyEvent->key() == 83 && keyEvent->modifiers()==201326592) {
emit(cntrlPlusAltPlusSPressed());
}
}
return QListView::event(event);
}