当前位置: 首页>>代码示例>>C++>>正文


C++ PlayerList::count方法代码示例

本文整理汇总了C++中PlayerList::count方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerList::count方法的具体用法?C++ PlayerList::count怎么用?C++ PlayerList::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlayerList的用法示例。


在下文中一共展示了PlayerList::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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 );
}
开发者ID:yapavelkurochkin,项目名称:tournament,代码行数:42,代码来源:ratingstable.cpp

示例2: updateMatchCells

/** calls updateMatchCell for each match cell ;)
 */
void RatingsTable::updateMatchCells( )
{
  PlayerList players = _group->const_validPlayers();

  int plCnt = players.count();

  for ( int i = 1; i < rowCount(); i ++ ) {
    for ( int j = 1; j < plCnt + 1; j ++ ) {
      if ( i != j ) {
        updateMatchCell( i, j );
      }
    }
  }
}
开发者ID:yapavelkurochkin,项目名称:tournament,代码行数:16,代码来源:ratingstable.cpp

示例3: mouseDoubleClickEvent

/**
 * Asks user to select a file with players in a plain text format:
 * Player, rating\nPlayer2, rating\n etc...
 */
void PlayerTable::mouseDoubleClickEvent( QMouseEvent * )
{
  QString fName = QFileDialog::getOpenFileName(this,
                  tr("Open players list file"), QDir::homePath(), 
                  tr("Txt Files (*.txt)"));

  if ( !fName.isNull() ) {
    PlayerList players = loadPlayerList( fName );
    if ( players.count() > 0 ) {
      setPlayerList( players );
    } else {
      QMessageBox msg;
      msg.setText( tr( "I cannot find any player in '" ) + fName + "'" );
      msg.exec();
    } 
  }
}
开发者ID:kiff20072008,项目名称:tournament,代码行数:21,代码来源:playertable.cpp

示例4: 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 );
  }
}
开发者ID:yapavelkurochkin,项目名称:tournament,代码行数:48,代码来源:ratingstable.cpp

示例5: 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 ); 
  }
}
开发者ID:yapavelkurochkin,项目名称:tournament,代码行数:21,代码来源:ratingstable.cpp


注:本文中的PlayerList::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。