From 39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 Mon Sep 17 00:00:00 2001 From: pohly Date: Thu, 05 May 2005 14:39:33 +0000 Subject: new opie-reader sources with support for ArriereGo, Reb input and flite output plugins --- (limited to 'noncore/apps/opie-reader/cbkmkselector.h') 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 @@ -3,6 +3,16 @@ #include #include +class CBkmkSelectorItem : public QListBoxText +{ + int m_ref; + public: + CBkmkSelectorItem(const QString& _t, int ref) : QListBoxText(_t), m_ref(ref) + { + } + int reference() { return m_ref; } +}; + class CBkmkSelector : public QWidget { @@ -10,14 +20,40 @@ class CBkmkSelector : public QWidget QListBox* bkmkselector; QPushButton* exitButton; - + /* + void keyPressEvent ( QKeyEvent * e ) + { + if ((e->key() == Key_Return) || (e->key() == Key_Space)) + { + emit selected(reinterpret_cast(bkmkselector->item(bkmkselector->currentItem()))->reference()); + e->accept(); + } + else + { + e->ignore(); + } + } + */ signals: void selected(int i); void cancelled(); private slots: - void slotSelected(QListBoxItem* t) { emit selected(bkmkselector->index(t)); } - void slotSelected(int t) { emit selected(t); } + void slotSelected(QListBoxItem* t) + { + if (t != NULL) + { + emit selected(reinterpret_cast(t)->reference()); + } + } +//void slotSelected(int t) { emit selected(t); } void slotCancel() { emit cancelled(); } + void slotSort() + { + bkmkselector->sort(); +#ifdef USEQPE + setCurrentItem(bkmkselector->currentItem()); +#endif + } public: CBkmkSelector( QWidget *parent=0, const char *name=0, WFlags f = 0) : QWidget(parent, name, f) @@ -27,17 +63,27 @@ public: // setFont( f ); QVBoxLayout* grid = new QVBoxLayout(this); - bkmkselector = new QListBox(this, "Bookmarks"); - exitButton = new QPushButton("Cancel", this); - connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( slotSelected(int) ) ); + QHBoxLayout* hgrid = new QHBoxLayout(); + bkmkselector = new QListBox(this, tr("Bookmarks")); + QPushButton* _sort = new QPushButton(tr("Sort"), this); + connect(_sort, SIGNAL(clicked()), this, SLOT( slotSort() ) ); + exitButton = new QPushButton(tr("Cancel"), this); + // connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( slotSelected(int) ) ); connect(bkmkselector, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); + connect(bkmkselector, SIGNAL( returnPressed(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) ); grid->addWidget(bkmkselector,1); - grid->addWidget(exitButton); + grid->addLayout(hgrid); + hgrid->addWidget(_sort); + hgrid->addWidget(exitButton); } void clear() { bkmkselector->clear(); } - void insertItem(const QString& item) { bkmkselector->insertItem(item); } + void insertItem(const QString& _item, int ref) + { + CBkmkSelectorItem* item = new CBkmkSelectorItem(_item, ref); + bkmkselector->insertItem(item); + } QString text(int index) const { return bkmkselector->text(index); } void setText(const QString& _l) { exitButton->setText(_l); } + void setCurrentItem(int _i) { bkmkselector->setCurrentItem(_i); } }; - -- cgit v0.9.0.2