Diffstat (limited to 'noncore/apps/opie-reader/cbkmkselector.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/cbkmkselector.h | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/noncore/apps/opie-reader/cbkmkselector.h b/noncore/apps/opie-reader/cbkmkselector.h index 42951e5..ec0c6e8 100644 --- a/noncore/apps/opie-reader/cbkmkselector.h +++ b/noncore/apps/opie-reader/cbkmkselector.h | |||
@@ -1,43 +1,89 @@ | |||
1 | #include <qwidget.h> | 1 | #include <qwidget.h> |
2 | #include <qlistbox.h> | 2 | #include <qlistbox.h> |
3 | #include <qpushbutton.h> | 3 | #include <qpushbutton.h> |
4 | #include <qlayout.h> | 4 | #include <qlayout.h> |
5 | 5 | ||
6 | class CBkmkSelectorItem : public QListBoxText | ||
7 | { | ||
8 | int m_ref; | ||
9 | public: | ||
10 | CBkmkSelectorItem(const QString& _t, int ref) : QListBoxText(_t), m_ref(ref) | ||
11 | { | ||
12 | } | ||
13 | int reference() { return m_ref; } | ||
14 | }; | ||
15 | |||
6 | class CBkmkSelector : public QWidget | 16 | class CBkmkSelector : public QWidget |
7 | { | 17 | { |
8 | 18 | ||
9 | Q_OBJECT | 19 | Q_OBJECT |
10 | 20 | ||
11 | QListBox* bkmkselector; | 21 | QListBox* bkmkselector; |
12 | QPushButton* exitButton; | 22 | QPushButton* exitButton; |
13 | 23 | /* | |
24 | void keyPressEvent ( QKeyEvent * e ) | ||
25 | { | ||
26 | if ((e->key() == Key_Return) || (e->key() == Key_Space)) | ||
27 | { | ||
28 | emit selected(reinterpret_cast<CBkmkSelectorItem*>(bkmkselector->item(bkmkselector->currentItem()))->reference()); | ||
29 | e->accept(); | ||
30 | } | ||
31 | else | ||
32 | { | ||
33 | e->ignore(); | ||
34 | } | ||
35 | } | ||
36 | */ | ||
14 | signals: | 37 | signals: |
15 | void selected(int i); | 38 | void selected(int i); |
16 | void cancelled(); | 39 | void cancelled(); |
17 | private slots: | 40 | private slots: |
18 | void slotSelected(QListBoxItem* t) { emit selected(bkmkselector->index(t)); } | 41 | void slotSelected(QListBoxItem* t) |
19 | void slotSelected(int t) { emit selected(t); } | 42 | { |
43 | if (t != NULL) | ||
44 | { | ||
45 | emit selected(reinterpret_cast<CBkmkSelectorItem*>(t)->reference()); | ||
46 | } | ||
47 | } | ||
48 | //void slotSelected(int t) { emit selected(t); } | ||
20 | void slotCancel() { emit cancelled(); } | 49 | void slotCancel() { emit cancelled(); } |
50 | void slotSort() | ||
51 | { | ||
52 | bkmkselector->sort(); | ||
53 | #ifdef USEQPE | ||
54 | setCurrentItem(bkmkselector->currentItem()); | ||
55 | #endif | ||
56 | } | ||
21 | public: | 57 | public: |
22 | CBkmkSelector( QWidget *parent=0, const char *name=0, WFlags f = 0) : | 58 | CBkmkSelector( QWidget *parent=0, const char *name=0, WFlags f = 0) : |
23 | QWidget(parent, name, f) | 59 | QWidget(parent, name, f) |
24 | { | 60 | { |
25 | 61 | ||
26 | // QFont f("unifont", 16); | 62 | // QFont f("unifont", 16); |
27 | // setFont( f ); | 63 | // setFont( f ); |
28 | 64 | ||
29 | QVBoxLayout* grid = new QVBoxLayout(this); | 65 | QVBoxLayout* grid = new QVBoxLayout(this); |
30 | bkmkselector = new QListBox(this, "Bookmarks"); | 66 | QHBoxLayout* hgrid = new QHBoxLayout(); |
31 | exitButton = new QPushButton("Cancel", this); | 67 | bkmkselector = new QListBox(this, tr("Bookmarks")); |
32 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( slotSelected(int) ) ); | 68 | QPushButton* _sort = new QPushButton(tr("Sort"), this); |
69 | connect(_sort, SIGNAL(clicked()), this, SLOT( slotSort() ) ); | ||
70 | exitButton = new QPushButton(tr("Cancel"), this); | ||
71 | // connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( slotSelected(int) ) ); | ||
33 | connect(bkmkselector, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); | 72 | connect(bkmkselector, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); |
73 | connect(bkmkselector, SIGNAL( returnPressed(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); | ||
34 | connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) ); | 74 | connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) ); |
35 | grid->addWidget(bkmkselector,1); | 75 | grid->addWidget(bkmkselector,1); |
36 | grid->addWidget(exitButton); | 76 | grid->addLayout(hgrid); |
77 | hgrid->addWidget(_sort); | ||
78 | hgrid->addWidget(exitButton); | ||
37 | } | 79 | } |
38 | void clear() { bkmkselector->clear(); } | 80 | void clear() { bkmkselector->clear(); } |
39 | void insertItem(const QString& item) { bkmkselector->insertItem(item); } | 81 | void insertItem(const QString& _item, int ref) |
82 | { | ||
83 | CBkmkSelectorItem* item = new CBkmkSelectorItem(_item, ref); | ||
84 | bkmkselector->insertItem(item); | ||
85 | } | ||
40 | QString text(int index) const { return bkmkselector->text(index); } | 86 | QString text(int index) const { return bkmkselector->text(index); } |
41 | void setText(const QString& _l) { exitButton->setText(_l); } | 87 | void setText(const QString& _l) { exitButton->setText(_l); } |
88 | void setCurrentItem(int _i) { bkmkselector->setCurrentItem(_i); } | ||
42 | }; | 89 | }; |
43 | |||