You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.8 KiB

#include "trendswidget.h"
#include "ui_trendswidget.h"
#include <QDebug>
TrendsWidget::TrendsWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::TrendsWidget)
{
ui->setupUi(this);
m_UserData.SetManagerType(ManagerType::Ruoyi);
model = new QStandardItemModel;
ui->tableView->setModel(model);
}
TrendsWidget::~TrendsWidget()
{
delete ui;
}
void TrendsWidget::SetUserData()
{
}
void TrendsWidget::SetUserInfo(UserInfo user)
{
m_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);
}
}
}