本文整理汇总了C++中PlayerList::at方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerList::at方法的具体用法?C++ PlayerList::at怎么用?C++ PlayerList::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerList
的用法示例。
在下文中一共展示了PlayerList::at方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupCells
/** should be called in constructor for basic setup of
* table cells.
*/
void RatingsTable::setupCells()
{
PlayerList players = _group->const_validPlayers();
int plCnt = players.count();
setRowCount( plCnt + 1 );
setColumnCount( plCnt + 1 + 1 ); // 1 column for total rating results
for ( int i = 0; i < rowCount(); i ++ ) {
for ( int j = 0; j < plCnt + 1; j ++ ) {
QTableWidgetItem *item = new QTableWidgetItem( );
QString text;
if ( i == j ) {
item->setBackground( palette().brush( QPalette::Disabled,
QPalette::Background ) );
if ( i == 0 ) {
text = _group->name();
}
item->setFlags( Qt::NoItemFlags );
} else if ( i == 0 ) { // 0th row
text = players.at( j - 1 ).name();
item->setFlags( Qt::NoItemFlags );
} else if ( j == 0 ) { // 0th column
Player p = players.at( i - 1 );
text = p.name();
text += " (" + QString::number( p.rating(), 'f', 1 ) + ")";
item->setFlags( Qt::NoItemFlags );
} else {
item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
}
item->setText( text );
setItem( i, j, item );
}
QTableWidgetItem *item = new QTableWidgetItem( );
if ( i == 0 ) {
item->setText( tr( "New rating" ) );
}
item->setFlags( Qt::NoItemFlags );
setItem( i, plCnt + 1, item );
}
}
示例2: updateTotalRatings
/** Update total rating for each player
*/
void RatingsTable::updateTotalRatings()
{
PlayerList players = _group->const_validPlayers();
int plCnt = players.count();
int col = plCnt + 1;
for ( int i = 1; i < rowCount(); i ++ ) {
Player p = players.at( i - 1 );
double earned = _group->earnedRating( p );
double total = p.rating() + earned;
QString text;
text += QString().setNum( total, 'f', 1 );
text += " (+" + QString().setNum( earned, 'f', 1 ) + ")";
item( i, col )->setText( text );
item( i, col )->setBackground( SPRING_GREEN1 );
}
}
示例3: updateMatchCell
/** Writes match result and earned rating into specified cell.
*/
void RatingsTable::updateMatchCell( int row, int col )
{
int aIndex = row - 1;
int bIndex = col - 1;
PlayerList players = _group->const_validPlayers();
if ( aIndex >= players.count() || bIndex >= players.count() ) {
qCritical() << __FUNCTION__ << "invalid row&col indexes: " << row << col;
return;
}
Player a = players.at( aIndex );
Player b = players.at( bIndex );
MatchList matches = _group->matchList( a, b );
QString text = item( row, col )->text();
QString toolTip = item( row, col )->toolTip();
foreach( Match m, matches ) {
if ( m.played() ) {
if ( !text.isEmpty() ) {
text += " ";
}
text += m.toString();
text += " (+" + QString().setNum( m.earnedRating( a ), 'g', 2 ) + ")";
item( row, col )->setBackground( SPRING_GREEN1 );
if ( !toolTip.isEmpty() ) {
toolTip += "\n\n";
}
toolTip += m.gamesToString();
} else {
item( row, col )->setBackground( palette().color( QPalette::Normal, QPalette::Base ) );
}
}
item( row, col )->setToolTip( toolTip );
item( row, col )->setText( text );
}