OSDN Git Service

Ver0.12
[gefu/Gefu.git] / searchbox.cpp
1 #include "common.h"
2 #include "mainwindow.h"
3 #include "searchbox.h"
4
5 #include <QAction>
6 #include <QDebug>
7 #include <QKeyEvent>
8 #include <QApplication>
9
10 SearchBox::SearchBox(QWidget *parent) :
11     QLineEdit(parent)
12 {
13 }
14
15 void SearchBox::itemFound()
16 {
17     QPalette palette = this->palette();
18     palette.setColor(QPalette::Text, Qt::black);
19     setPalette(palette);
20 }
21
22 void SearchBox::itemNotFound()
23 {
24     QPalette palette = this->palette();
25     palette.setColor(QPalette::Text, Qt::red);
26     setPalette(palette);
27 }
28
29 void SearchBox::keyPressEvent(QKeyEvent *event)
30 {
31 #if 0
32     QString ksq = KeyEventToSequence(event);
33
34     if (ksq == "/") {
35         QAction *action = getMainWnd()->findChild<QAction*>("action_Search");
36         action->toggle();
37         event->accept();
38         return;
39     }
40
41     QString textBefore = text();
42     QLineEdit::keyPressEvent(event);
43
44
45     if (ksq == "Shift+Return"){
46         qDebug() << ksq;
47         emit getMainWnd()->findChild<QAction*>("action_SearchPrev")->triggered();
48     }
49     else if (ksq.indexOf("Return") != -1) {
50         qDebug() << ksq;
51         emit getMainWnd()->findChild<QAction*>("action_SearchNext")->triggered();
52     }
53     else if (textBefore != text()) {
54         emit searchItem(text());
55     }
56     else {
57         qDebug() << ksq;
58     }
59 #endif
60
61     QLineEdit::keyPressEvent(event);
62
63 }