void AMenu::selectPrevious() { auto iter = findSelectedItem(); if ( iter != _items.end() ) { (*iter)->deselect(); iter = (iter == _items.begin() ) ? _items.end() - 1 : std::prev(iter); (*iter)->select(); } else { selectFirst(); } }
void AMenu::selectNext() { auto iter = findSelectedItem(); if ( iter != _items.end() ) { (*iter)->deselect(); iter = ( iter == _items.end() - 1 ) ? _items.begin() : std::next(iter); (*iter)->select(); } else { selectFirst(); } }
void PreviewBoard::keyPressEvent ( QKeyEvent * event ) { // std::cout << event->key() << std::endl; if (event->key() == Qt::Key_Left) { selectBack(); } if (event->key() == Qt::Key_Right) { selectForward(); } if (event->key() == Qt::Key_Up) { selectBackTen(); } if (event->key() == Qt::Key_Down) { selectForwardTen(); } if (event->key() == Qt::Key_Home) { selectFirst(); } if (event->key() == Qt::Key_End) { selectLast(); } }
SectionLord::SectionLord( QWidget * parent, const char * name ) : GenericSection( parent, name ) { setTitle( tr( "Lord" ) ); QVBoxLayout * layout = new QVBoxLayout( _mainWidget ); layout->setMargin( 5 ); layout->setSpacing( 5 ); _bigPix = new AskPixmap( true, "", tr( "Photo: " ), _mainWidget ); layout->addWidget( _bigPix ); _smallPix = new AskPixmap( true, "", tr( "Icon: " ), _mainWidget ); layout->addWidget( _smallPix ); _name = new AskString( tr( "Name : " ), _mainWidget ); layout->addWidget( _name ); _category = new AskCombo( tr( "Category : " ), _mainWidget ); layout->addWidget( _category ); _attack = new AskInt( tr( "Attack : " ), _mainWidget ); _defense = new AskInt( tr( "Defense : " ), _mainWidget ); _movemax = new AskInt( tr( "MaxMoves : " ), _mainWidget ); _movemax->setMaxValue( 9000 ); _vision = new AskInt( tr( "Vision : " ), _mainWidget ); QWidget * widg = new QWidget(this); QGridLayout * glayout = new QGridLayout( widg ); glayout->setColumnStretch( 0, 1 ); glayout->setColumnStretch( 1, 1 ); glayout->addWidget( _attack, 0, 0,Qt::AlignLeft ); glayout->addWidget( _defense, 0, 1 ,Qt::AlignLeft ); glayout->addWidget( _movemax, 1, 0 ,Qt::AlignLeft ); glayout->addWidget( _vision, 1, 1 ,Qt::AlignLeft ); glayout->setRowStretch( 2, 1 ); glayout->setMargin( 0 ); widg->setFixedWidth( 450 ); layout->addWidget( widg ); _cost = new AskCost( tr( "Cost: " ), _mainWidget ); layout->addWidget( _cost ); _troops = new DisplayTroops( _mainWidget ); layout->addWidget( _troops ); layout->addStretch( 1 ); layout->activate(); if( DataTheme.lords.count() > 1 ) { _idLord = 1; } else { _idLord = 0; } updateData(); selectFirst(); }