MatchResDialog::MatchResDialog( Match match, QWidget* parent )
    : QDialog( parent ),
      _match( match ),
      _okButton( new QPushButton( tr( "Save" ) ) )
{
    setWindowTitle( tr( "Match score" ) );

    _okButton->setEnabled( false );

    QGridLayout* l = new QGridLayout( this );

    QLabel* playerA = new QLabel( match.playerA().name(), this );
    QLabel* playerB = new QLabel( match.playerB().name(), this );

    l->addWidget( playerA, 0, 0, Qt::AlignJustify );
    l->addWidget( playerB, 0, 1, Qt::AlignJustify );

    unsigned int games = match.games_const().count();
    for ( unsigned int i = 0; i < match.maxGames(); i ++ ) {
        QLineEdit* ballsA = new QLineEdit( this );
        QLineEdit* ballsB = new QLineEdit( this );

        if ( i < games ) {
            // this should be done before connecting of lineedits to textChanged
            // slot
            ballsA->setText( QString::number( match.games_const().at( i ).aBalls ) );
            ballsB->setText( QString::number( match.games_const().at( i ).bBalls ) );
        }

        connect( ballsA, SIGNAL( textChanged( const QString& ) ),
                 this, SLOT( textChanged( ) ) );
        connect( ballsB, SIGNAL( textChanged( const QString& ) ),
                 this, SLOT( textChanged( ) ) );

        l->addWidget( ballsA, i + 1, 0 );
        l->addWidget( ballsB, i + 1, 1 );
    }

    if ( games ) {
        textChanged();
    }

    l->addWidget( _okButton, l->rowCount(), 0, 1, 2 );

    connect( _okButton, SIGNAL( clicked() ), this, SLOT( okButtonClicked() ) );
}
Beispiel #2
0
void Group::setMatchResults( Match m )
{
  setMatchResults( m.playerA(), m.playerB(), m.games_const() );
}