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


C++ WTable::rowAt方法代码示例

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


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

示例1: update

void HighScoresWidget::update()
{
  clear();
  
  new WText("<h2>Hall of fame</h2>", this);
  
  int ranking = session_->findRanking();
  
  std::string yourScore;
  if (ranking == 1)
    yourScore = "Congratulations! You are currently leading the pack.";
  else {
    yourScore = "You are currently ranked number "
      + boost::lexical_cast<std::string>(ranking)
      + ". Almost there !";
  }

  WText *score = new WText("<p>" + yourScore + "</p>", this);
  score->addStyleClass("score");
  
  std::vector<User> top = session_->topUsers(20);

  WTable *table = new WTable(this);

  new WText("Rank", table->elementAt(0, 0));
  new WText("User", table->elementAt(0, 1));
  new WText("Games", table->elementAt(0, 2));
  new WText("Score", table->elementAt(0, 3));
  new WText("Last game", table->elementAt(0, 4));
  table->setHeaderCount(1);

  int formerScore = -1;
  int rank = 0;
  for (unsigned i = 0; i < top.size(); i++) {
    User u = top[i];

    if (u.score != formerScore) {
      formerScore = u.score;
      ++rank;
    }
    
    int row = table->rowCount();
    new WText(boost::lexical_cast<std::string>(rank),
	      table->elementAt(row, 0));
    new WText(u.name, table->elementAt(row, 1));
    new WText(boost::lexical_cast<std::string>(u.gamesPlayed),
	      table->elementAt(row, 2));
    new WText(boost::lexical_cast<std::string>(u.score),
	      table->elementAt(row, 3));
    if (!u.lastGame.isNull())
      new WText(u.lastGame.timeTo(WDateTime::currentDateTime())
		+ " ago", table->elementAt(row, 4));
    else
      new WText("---", table->elementAt(row, 4));
    
    if (session_->login().loggedIn() && session_->userName() == u.name)
      table->rowAt(row)->setId("self");
  }

  WText *fineprint = new WText(tr("highscore.info"), this);
  fineprint->addStyleClass("fineprint");
}
开发者ID:913862627,项目名称:wt,代码行数:62,代码来源:HighScoresWidget.C


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