forked from engor/Jentos.Code
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlistwidgetcomplete.cpp
executable file
·66 lines (53 loc) · 1.42 KB
/
listwidgetcomplete.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
Jentos IDE.
Copyright 2014, Evgeniy Goroshkin.
See LICENSE.TXT for licensing terms.
*/
#include "listwidgetcomplete.h"
ListWidgetComplete::ListWidgetComplete(QWidget *parent) :
QListWidget(parent)
{
_isForInheritance = false;
}
void ListWidgetComplete::keyPressEvent(QKeyEvent *event) {
int key = event->key();
if( key == Qt::Key_Escape ) {
emit focusOut();
}
else if( key == Qt::Key_Return || key == Qt::Key_Tab ) {
emit itemActivated( currentItem() );
//emit activated(_codeItem);
}
else {
QListWidget::keyPressEvent(event);
}
event->accept();
}
void ListWidgetComplete::focusOutEvent(QFocusEvent* event) {
emit focusOut();
}
void ListWidgetComplete::mouseDoubleClickEvent(QMouseEvent *event) {
emit itemActivated( currentItem() );
}
void ListWidgetComplete::selectNear(int dir) {
int cnt = count();
if(cnt <= 1)
return;
int row = currentRow();
if(dir == -1) {
--row;
if(row < 0)
row = cnt-1;
setCurrentRow(row);
}
else if(dir == 1) {
++row;
if(row >= cnt)
row = 0;
setCurrentRow(row);
}
}
//----------------------------------------------------------------------
ListWidgetCompleteItem::ListWidgetCompleteItem(const QIcon &icon, const QString &text, CodeItem *code, QListWidget *parent)
: QListWidgetItem(icon,text,parent), _codeItem(code) {
}