comparison widgets/TypingSelectWidget.h @ 41:a42493a3baf8

* Make the typing select widget more useful (with working menu!)
author Chris Cannam
date Fri, 09 Apr 2010 16:19:50 +0100
parents 94cdfacc4910
children
comparison
equal deleted inserted replaced
40:40e3f0049c00 41:a42493a3baf8
3 #ifndef _TYPING_SELECT_WIDGET_H_ 3 #ifndef _TYPING_SELECT_WIDGET_H_
4 #define _TYPING_SELECT_WIDGET_H_ 4 #define _TYPING_SELECT_WIDGET_H_
5 5
6 #include <QWidget> 6 #include <QWidget>
7 #include <QList> 7 #include <QList>
8 #include <QLabel>
9 #include <QMenu>
10 #include <QMouseEvent>
11 #include <QShortcut>
8 12
9 class QLineEdit; 13 class QLineEdit;
10 class QListWidget; 14 class QListWidget;
11 class QGridLayout; 15 class QGridLayout;
12 class QFrame; 16 class QFrame;
13 17
18
14 namespace ClassicalData 19 namespace ClassicalData
15 { 20 {
16 21
17 class Matcher; 22 class Matcher;
23 class TypingSelectListEntry;
24 class TypingSelectListMenu;
18 25
19 class TypingSelectWidget : public QWidget 26 class TypingSelectWidget : public QWidget
20 { 27 {
21 Q_OBJECT 28 Q_OBJECT
22 29
25 32
26 void addMatcher(Matcher *m) { m_matchers.push_back(m); } 33 void addMatcher(Matcher *m) { m_matchers.push_back(m); }
27 34
28 private slots: 35 private slots:
29 void textEdited(const QString &); 36 void textEdited(const QString &);
37 void menuKeyPressed(QKeyEvent *);
38 void menuItemSelected(QString);
30 39
31 private: 40 private:
32 QList<Matcher *> m_matchers; 41 QList<Matcher *> m_matchers;
33 QLineEdit *m_editor; 42 QLineEdit *m_editor;
34 QFrame *m_list; 43 TypingSelectListMenu *m_menu;
35 QGridLayout *m_listLayout; 44 QList<TypingSelectListEntry *> m_listEntries;
36 QList<QWidget *> m_listEntries;
37 }; 45 };
46
47 class TypingSelectListMenu : public QMenu
48 {
49 Q_OBJECT
50
51 public:
52 TypingSelectListMenu(QWidget *parent = 0) : QMenu(parent) { }
53
54 signals:
55 void keyPressed(QKeyEvent *e);
56 void itemSelected(QString);
57
58 protected:
59 void keyPressEvent(QKeyEvent *e);
60 void keyReleaseEvent(QKeyEvent *e);
61 };
62
38 63
39 } 64 }
40 65
41 #endif 66 #endif
42 67