/*! * Key press event handler. * Emit signals keyArrowLRPressed if press arrow left or arrow rigth. * \param e (in) - key press event. */ void aListBox::keyPressEvent(QKeyEvent *e) { if(e->key()==Qt::Key_Left || e->key()==Qt::Key_Right) { emit(keyArrowLRPressed()); emit(keyArrowLRPressed(currentText())); //printf("emit key pressed\n"); } if(e->key() == Qt::Key_Return) { //printf("enter !!!\n");// return; emit(keyArrowLRPressed()); emit(keyArrowLRPressed(currentText())); emit(keyEnterPressed()); //printf("enter !!!\n");// return; } if(e->key() == Qt::Key_Escape) { this->clearFocus(); // emit(lostFocus()); // printf("Esc!\n"); e->accept(); return; } e->accept(); QListBox::keyPressEvent(e); }
void aListBox::doubleClickHandler(QListBoxItem *i) { // printf("double click handler!\n"); emit(keyArrowLRPressed()); emit(keyArrowLRPressed(i->text())); emit(keyEnterPressed()); }
/*! Key press event handler. Emit signal keyArrowPressed(). * \param e (in) - key press event. */ void aLineEdit::keyPressEvent(QKeyEvent *e) { // timer->start(500,TRUE); if(e->key()==Qt::Key_Return)//Key_Enter) { e->accept(); emit(keyEnterPressed()); //e->ignore(); } if(e->key()==Qt::Key_Down) { emit(keyArrowPressed()); } e->ignore(); QLineEdit::keyPressEvent(e); }
/*! * Function create visual objects and connect slots. */ void CatalogForm::init() { ListView = new aListView(centralWidget(), "listView"); ListView->setGeometry(30,30,400,300); ListView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); LineEdit = new aLineEdit(centralWidget(), "lineEdit"); ListHint = new aListBox(centralWidget(), "listBox"); StatusFrame = new Q3Frame(centralWidget(), "statusFrame"); ListView->setRootIsDecorated( true ); StatusFrame->setGeometry( QRect( 0, 0, 50,5 ) ); StatusFrame->setFrameShape( Q3Frame::StyledPanel ); StatusFrame->setFrameShadow( Q3Frame::Raised ); StatusFrame->hide(); GridLayout = new Q3GridLayout(centralWidget(), 1, 1, 11, 6, "GridLayout"); GridLayout->addMultiCellWidget( ListView, 2,3, 0 , 0 ); GridLayout->addWidget( LineEdit, 1, 0 ); GridLayout->addWidget( bCancel, 3, 1 ); QLabel *lb = new QLabel(tr("Search"),centralWidget()); lb->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, lb->sizePolicy().hasHeightForWidth() ) ); GridLayout->addWidget( lb ,0,0); QSpacerItem* spacer = new QSpacerItem( 20, 390, QSizePolicy::Minimum, QSizePolicy::Expanding ); GridLayout->addMultiCell( spacer, 0,2,1, 1); QPixmap pix= rcIcon("cat.png"); if(pix.isNull()) { aLog::print(aLog::Info, tr("Catalog Form image cat.png not loaded")); } else { setIcon( pix ); } //setFocusPolicy(); // connect(this, SIGNAL (destoyed()), // this, SLOT (close()); connect(ListView, SIGNAL (newItemRequest(Q3ListViewItem*)), this, SLOT (new_item(Q3ListViewItem*))); connect(ListView, SIGNAL (newGroupRequest(Q3ListViewItem*)), this, SLOT (new_group(Q3ListViewItem*))); connect(ListView, SIGNAL (delItemRequest(Q3ListViewItem*)), this, SLOT (del_item(Q3ListViewItem*))); connect(ListView, SIGNAL (markDeletedRequest(Q3ListViewItem*)), this, SLOT (mark_deleted(Q3ListViewItem*))); connect(ListView, SIGNAL (undoMarkDeletedRequest(Q3ListViewItem*)), this, SLOT (undo_mark_deleted(Q3ListViewItem*))); connect(ListView, SIGNAL (editRequest(Q3ListViewItem*, int)), this, SLOT (edit(Q3ListViewItem*, int))); connect(ListView, SIGNAL (selectRequest(Q3ListViewItem*)), this, SLOT (select(Q3ListViewItem*))); connect(LineEdit, SIGNAL (delayTextChanged(const QString&)), this, SLOT (find(const QString&))); connect(LineEdit, SIGNAL (keyArrowPressed()), this, SLOT (pressArrow())); connect(LineEdit, SIGNAL (keyEnterPressed()), this, SLOT (go())); connect(ListView, SIGNAL (expanded ( Q3ListViewItem *)), this, SLOT (onLoadElements( Q3ListViewItem *))); connect(ListHint, SIGNAL (lostFocus()), LineEdit, SLOT (setFocus())); connect(ListHint, SIGNAL (lostFocus()), StatusFrame, SLOT (hide())); connect(ListHint, SIGNAL (lostFocus()), ListHint, SLOT (hide())); connect(ListHint, SIGNAL (keyArrowLRPressed()), LineEdit, SLOT (setFocus())); connect(ListHint, SIGNAL (keyArrowLRPressed(const QString&)), this, SLOT (setText(const QString&))); connect(ListHint, SIGNAL (keyEnterPressed()), this, SLOT (go())); connect(ListHint, SIGNAL (sendMessage(const QString &)), this->statusBar(), SLOT (message( const QString &))); connect(ListView, SIGNAL (sendMessage(const QString &)), this->statusBar(), SLOT (message( const QString &))); connect(LineEdit, SIGNAL (sendMessage(const QString &)), this->statusBar(), SLOT (message( const QString &))); LineEdit->setFocus(); }