|
|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
#include "trendswidget.h"
|
|
|
|
|
#include "ui_trendswidget.h"
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QTableWidgetItem>
|
|
|
|
|
#include <QColor>
|
|
|
|
|
|
|
|
|
|
TrendsWidget::TrendsWidget(QWidget *parent) :
|
|
|
|
|
QWidget(parent),
|
|
|
|
|
@ -8,8 +10,6 @@ TrendsWidget::TrendsWidget(QWidget *parent) :
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
m_UserData.SetManagerType(ManagerType::Ruoyi);
|
|
|
|
|
model = new QStandardItemModel;
|
|
|
|
|
ui->tableView->setModel(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TrendsWidget::~TrendsWidget()
|
|
|
|
|
@ -30,41 +30,66 @@ void TrendsWidget::SetUserInfo(UserInfo user)
|
|
|
|
|
void TrendsWidget::LoadTrendsData()
|
|
|
|
|
{
|
|
|
|
|
QList<QList<QString> > trends = m_UserData.GetTrends(QDate(),m_UserInfo.token);
|
|
|
|
|
// int rowCount = trends.count();
|
|
|
|
|
// int columnCount = 0;
|
|
|
|
|
// //更新到tableview中
|
|
|
|
|
// if(rowCount > 2)
|
|
|
|
|
// {
|
|
|
|
|
// model->insertRow(0);
|
|
|
|
|
// qDebug() << __FUNCTION__ << " trends[0]: " << trends[0];
|
|
|
|
|
// QList<QString> columns = trends[0];
|
|
|
|
|
// columnCount = columns.count();
|
|
|
|
|
// for (int column = 0; column < columnCount; ++column) {
|
|
|
|
|
// QStandardItem *item = new QStandardItem(columns[column]);
|
|
|
|
|
// model->setItem(0, column, item);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// qDebug() << __FUNCTION__ << " trends[1]: " <<trends[1];
|
|
|
|
|
// qDebug() << __FUNCTION__ << " trends[2]: " <<trends[2];
|
|
|
|
|
// qDebug() << __FUNCTION__ << " trends[3]: " <<trends[3];
|
|
|
|
|
// rowCount = trends[1].count();
|
|
|
|
|
// QList<QString> row1List = trends[1];
|
|
|
|
|
// qDebug() << __FUNCTION__ << trends[1];
|
|
|
|
|
// for(int row = 1 ; row < rowCount; row++)
|
|
|
|
|
// {
|
|
|
|
|
// qDebug() << __FUNCTION__ << row << trends[1][row];
|
|
|
|
|
// model->insertRow(row);
|
|
|
|
|
// QStandardItem *item = new QStandardItem(trends[1][row]);
|
|
|
|
|
// model->setItem(row, 0, item);
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// for(int row = 2 ; row < rowCount; row++)
|
|
|
|
|
// {
|
|
|
|
|
// for(int col = 0 ; col < columnCount; col++)
|
|
|
|
|
// {
|
|
|
|
|
// QStandardItem *item = new QStandardItem(trends[row][col]);
|
|
|
|
|
// model->setItem(row, col+1, item);
|
|
|
|
|
int rowCount = trends.count();
|
|
|
|
|
int columnCount = 0;
|
|
|
|
|
//更新到tableview中
|
|
|
|
|
if(rowCount > 2)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << __FUNCTION__ << " trends[0]: " << trends[0];
|
|
|
|
|
QStringList headText;
|
|
|
|
|
QList<QString> columns = trends[0];
|
|
|
|
|
QList<QString> rows0 = trends[1];
|
|
|
|
|
QList<QString> rows1 = trends[2];
|
|
|
|
|
qDebug() << __FUNCTION__ << " trends[1]: " << trends[1];
|
|
|
|
|
qDebug() << __FUNCTION__ << " trends[2]: " << trends[2];
|
|
|
|
|
columnCount = columns.count();
|
|
|
|
|
ui->tableWidget->setRowCount(trends[1].count());
|
|
|
|
|
ui->tableWidget->setColumnCount(columnCount);
|
|
|
|
|
for (int column = 0; column < columnCount; ++column) {
|
|
|
|
|
headText << columns[column];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
ui->tableWidget->setHorizontalHeaderLabels(headText);
|
|
|
|
|
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
|
ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
|
ui->tableWidget->setAlternatingRowColors(true);
|
|
|
|
|
ui->tableWidget->verticalHeader()->setVisible(false);
|
|
|
|
|
// ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置首列
|
|
|
|
|
int tableRows = trends[1].count();
|
|
|
|
|
for(int row = 0; row < tableRows; row++)
|
|
|
|
|
{
|
|
|
|
|
ui->tableWidget->setRowHeight(row, 24);
|
|
|
|
|
QTableWidgetItem *item = new QTableWidgetItem(trends[1][row]);
|
|
|
|
|
ui->tableWidget->setItem(row, 0, item);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
for(int datarow = 2, col = 1; datarow < rowCount; datarow++,col++)
|
|
|
|
|
{
|
|
|
|
|
for(int tablerow = 0 ; tablerow < tableRows; tablerow++)
|
|
|
|
|
{
|
|
|
|
|
QTableWidgetItem *item = new QTableWidgetItem(trends[datarow][tablerow]);
|
|
|
|
|
if(item->text().toInt() <= 3 && item->text().toInt() > 0)
|
|
|
|
|
{
|
|
|
|
|
item->setTextColor(Qt::white);
|
|
|
|
|
item->setBackground(QBrush(Qt::red));
|
|
|
|
|
}
|
|
|
|
|
else if(item->text().toInt() <= 6 && item->text().toInt() > 3)
|
|
|
|
|
{
|
|
|
|
|
item->setTextColor(Qt::white);
|
|
|
|
|
item->setBackground(QBrush(QColor(255,157,0)));
|
|
|
|
|
}
|
|
|
|
|
else if(item->text().toInt() <= 10 && item->text().toInt() > 6)
|
|
|
|
|
{
|
|
|
|
|
item->setTextColor(Qt::white);
|
|
|
|
|
item->setBackground(QBrush(QColor(255,208,0)));
|
|
|
|
|
}
|
|
|
|
|
ui->tableWidget->setItem(tablerow, col, item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|