本文整理汇总了C++中KeyPress::computer_id方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyPress::computer_id方法的具体用法?C++ KeyPress::computer_id怎么用?C++ KeyPress::computer_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyPress
的用法示例。
在下文中一共展示了KeyPress::computer_id方法的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);
}
}
}