| | |
| | | |
| | | } |
| | | |
| | | void SeparateAnalysis::calcWindowRank() |
| | | { |
| | | // 滑动窗口排名,6个要2+的前100 |
| | | QVector<int> ranks; |
| | | for(int i=0;i<m_model->rowCount();++i){ |
| | | ranks.append(m_model->item(i,9)->text().toInt()); |
| | | if(i >= 6){ |
| | | // 先统计排名计数 |
| | | int cntBig=0, cntSmall=0; |
| | | for(int j=0;j<ranks.size();++j){ |
| | | if(ranks.at(j) > 100){ |
| | | cntBig++; |
| | | }else{ |
| | | cntSmall++; |
| | | } |
| | | } |
| | | // 统计对比 |
| | | if(cntSmall == 2 && ranks.back() <= 100){ |
| | | // 将当前6个元素定为符合的窗口,背景色设置为紫色 |
| | | for(int k=0;k<6;++k){ |
| | | m_model->item(i-k,9)->setData(QColor("red"),Qt::BackgroundColorRole); |
| | | } |
| | | } |
| | | |
| | | // 清除窗口第一个元素 |
| | | ranks.pop_front(); |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | void SeparateAnalysis::initMySQL() |
| | | { |
| | | //添加一个数据库 |
| | |
| | | qint64 need = QDateTime::currentMSecsSinceEpoch()-tt; |
| | | ui->label_status->setText(QString("耗时:%1 毫秒,查询完成.条数: %2").arg(QString::number(need)).arg(QString::number(rows))); |
| | | ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); |
| | | // 滑动窗口统计 |
| | | calcWindowRank(); |
| | | |
| | | } |
| | | |