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


C++ KeyPress::duration方法代码示例

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


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

示例1: renderData

void StatisticsWidget::renderData() {
  FUNCTION

  QString view = ui->viewCB->currentText();
  QString groupBy = ui->groupByCB->currentText();
  QDateTime fromDT = ui->fromDTE->dateTime();
  QDateTime toDT = ui->toDTE->dateTime();

  QList<KeyPress*> keyPressesAll = DesktopService::_instance->server->getKeyPresses(_user);
  QList<KeyPress*> kpqs;
  for(qint32 i = 0; i < keyPressesAll.size(); ++i) {
    KeyPress* keyPress = keyPressesAll.at(i);
    if((keyPress->start() >= fromDT) && (keyPress->start() <= toDT))
      kpqs.push_back(keyPress);
  }

  if(view == "All") {
    ui->groupByCB->setVisible(false);
    ui->statisticsTW->setColumnCount(5);
    ui->statisticsTW->setHorizontalHeaderLabels(QStringList() << "Computer" << "Application" << "Start" << "Duration" << "Keys");    ui->statisticsTW->setRowCount(kpqs.size());
    for(qint32 i = 0; i < kpqs.size(); ++i) {
      KeyPress* keyPress = kpqs.at(i);
      Computer* computer = QDjangoQuerySet<Computer>().get(QDjangoWhere("id", QDjangoWhere::Equals, keyPress->computer_id()));
      QTableWidgetItem* item0 = new QTableWidgetItem(computer->ip());
      QTableWidgetItem* item1 = new QTableWidgetItem(keyPress->application());
      QTableWidgetItem* item2 = new QTableWidgetItem(keyPress->start().toString());
      QTableWidgetItem* item3 = new QTableWidgetItem(QString::number(keyPress->duration()));
      QTableWidgetItem* item4 = new QTableWidgetItem(keyPress->keys().join(" "));

      ui->statisticsTW->setItem(i, 0, item0);
      ui->statisticsTW->setItem(i, 1, item1);
      ui->statisticsTW->setItem(i, 2, item2);
      ui->statisticsTW->setItem(i, 3, item3);
      ui->statisticsTW->setItem(i, 4, item4);
    }
  } else {
    ui->groupByCB->setVisible(true);
    ui->statisticsTW->setColumnCount(2);
    ui->statisticsTW->setHorizontalHeaderLabels(QStringList() << groupBy << "Total duration");
    QMap<QString, qint32> groups;
    for(qint32 i = 0; i < kpqs.size(); ++i) {
      KeyPress* keyPress = kpqs.at(i);
      if(groupBy == "Computer") {
        Computer* computer = QDjangoQuerySet<Computer>().get(QDjangoWhere("id", QDjangoWhere::Equals, keyPress->computer_id()));
        groups[computer->ip()] += keyPress->duration();
      } else if(groupBy == "Application") {
        groups[keyPress->application()] += keyPress->duration();
      }
    }

    QList<QString> keys = groups.keys();
    ui->statisticsTW->setRowCount(keys.size());
    for(qint32 i = 0; i < keys.size(); ++i) {
      QString key = keys.at(i);
      QTableWidgetItem* item0 = new QTableWidgetItem(key);
      QTableWidgetItem* item1 = new QTableWidgetItem(QString::number(groups.value(key)));

      ui->statisticsTW->setItem(i, 0, item0);
      ui->statisticsTW->setItem(i, 1, item1);
    }
  }
}
开发者ID:EPecherkin,项目名称:diplom,代码行数:62,代码来源:statisticswidget.cpp


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