//===================================== // XKeyboard get index of item text //------------------------------------- int XKeyboard::getItem ( QComboBox* widget, const QString& item ) { QListBox* list = widget -> listBox(); for (int i=0;i<widget->count();i++) { if (list->item(i)->text() == item ) { return (i); } } return (0); }
QListBoxItem * ListBoxDnd::itemAt( QPoint pos ) { QListBox * src = (QListBox *) this->src; QListBoxItem * result = src->itemAt( pos ); QListBoxItem * last = src->item( src->count() - 1 ); int i = src->index( result ); if ( result && ( pos.y() < (src->itemRect(result).top() + src->itemHeight(i)/2) ) ) result = result->prev(); else if ( !result && pos.y() > src->itemRect( last ).bottom() ) result = last; return result; }
bool KActionSelector::eventFilter(QObject *o, QEvent *e) { if(d->keyboardEnabled && e->type() == QEvent::KeyPress) { if((((QKeyEvent *)e)->state() & Qt::ControlButton)) { switch(((QKeyEvent *)e)->key()) { case Key_Right: buttonAddClicked(); break; case Key_Left: buttonRemoveClicked(); break; case Key_Up: buttonUpClicked(); break; case Key_Down: buttonDownClicked(); break; default: return QWidget::eventFilter(o, e); break; } return true; } else if(o->inherits("QListBox")) { switch(((QKeyEvent *)e)->key()) { case Key_Return: case Key_Enter: QListBox *lb = (QListBox *)o; int index = lb->currentItem(); if(index < 0) break; moveItem(lb->item(index)); return true; } } } return QWidget::eventFilter(o, e); }