diff --git a/mainwindow.cpp b/mainwindow.cpp index 3a53ebe..3a05ece 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -28,12 +28,12 @@ MainWindow::~MainWindow() void MainWindow::SetUserInfo(UserInfo user) { m_UserInfo = user; - ui->trends->SetUserInfo(user); + ui->trendsPage->SetUserInfo(user); } void MainWindow::LoadTrendsData() { - ui->trends->LoadTrendsData(); + ui->trendsPage->LoadTrendsData(); } void MainWindow::Init() @@ -71,7 +71,7 @@ void MainWindow::Init() connect(btn, SIGNAL(clicked()), this, SLOT(buttonClick())); } - ui->btnMain->click(); + ui->tradeRecordBtn->click(); } void MainWindow::InitStyle() @@ -141,15 +141,15 @@ void MainWindow::getQssColor(const QString &qss, const QString &flag, QString &c //qDebug() << TIMEMS << flag << color; } -bool MainWindow::eventFilter(QObject *watched, QEvent *event) -{ - if (watched == ui->widgetTitle) { - if (event->type() == QEvent::MouseButtonDblClick) { - on_btnMenu_Max_clicked(); - } - } - return QWidget::eventFilter(watched, event); -} +//bool MainWindow::eventFilter(QObject *watched, QEvent *event) +//{ +// if (watched == ui->widgetTitle) { +// if (event->type() == QEvent::MouseButtonDblClick) { +// on_btnMenu_Max_clicked(); +// } +// } +// return QWidget::eventFilter(watched, event); +//} void MainWindow::getQssColor(const QString &qss, QString &textColor, QString &panelColor, QString &borderColor, QString &normalColorStart, QString &normalColorEnd, @@ -168,22 +168,27 @@ void MainWindow::getQssColor(const QString &qss, QString &textColor, QString &pa void MainWindow::buttonClick() { QAbstractButton *b = (QAbstractButton *)sender(); - QString name = b->text(); + QString name = b->objectName(); QList tbtns = ui->widgetTop->findChildren(); foreach (QAbstractButton *btn, tbtns) { btn->setChecked(btn == b); } - if (name == "交易记录") { - ui->stackedWidget->setCurrentIndex(0); - } else if (name == "动量趋势") { - ui->stackedWidget->setCurrentIndex(1); - } else if (name == "ddd") { + if (name == "tradeRecordBtn") + { ui->stackedWidget->setCurrentIndex(0); - } else if (name == "vvv") { + } else if (name == "trendsBtn") + { ui->stackedWidget->setCurrentIndex(1); - } else if (name == "aaa") { + } else if (name == "limitBtn") + { + ui->stackedWidget->setCurrentIndex(2); + } else if (name == "newRecordBtn") + { + ui->stackedWidget->setCurrentIndex(3); + } else if (name == "logouBtn") + { exit(0); } } @@ -214,3 +219,40 @@ void MainWindow::on_btnMenu_Close_clicked() close(); } +bool MainWindow::eventFilter(QObject *watched, QEvent *event) +{ + QWidget *w = (QWidget *)watched; + if(w->property("form") != "title") + { + return QObject::eventFilter(watched, event); + } + if (!w->property("canMove").toBool()) + { + return QObject::eventFilter(watched, event); + } + + static QPoint mousePoint; + static bool mousePressed = false; + + QMouseEvent *mouseEvent = static_cast(event); + if (mouseEvent->type() == QEvent::MouseButtonPress) { + if (mouseEvent->button() == Qt::LeftButton) { + mousePressed = true; + mousePoint = mouseEvent->globalPos() - this->pos(); + } + } else if (mouseEvent->type() == QEvent::MouseButtonRelease) { + mousePressed = false; + } else if (mouseEvent->type() == QEvent::MouseMove) { + if (mousePressed) { + this->move(mouseEvent->globalPos() - mousePoint); + return true; + } + } + else if (event->type() == QEvent::MouseButtonDblClick) { + on_btnMenu_Max_clicked(); + } + + return QObject::eventFilter(watched, event); +} + + diff --git a/mainwindow.ui b/mainwindow.ui index 13cc482..373bdbd 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -14,437 +14,441 @@ MainWindow - - - - 0 - 0 - 1440 - 65 - + + + 0 - - - 0 - 0 - + + 0 - - - 10 - - - 10 - - - 0 - - - 0 - - - 0 - - - - - + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 10 - - Qt::AlignCenter + + 10 - - - - - - + + 0 - - + + 0 - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + 0 - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - 交易记录 - - - - :/image/main_main.png:/image/main_main.png - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 0 - 0 - - - - 动量趋势 - - - - :/image/main_config.png:/image/main_config.png - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 0 - 0 - - - - 涨跌停板 - - - - :/image/main_data.png:/image/main_data.png - - - false - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 0 - 0 - - - - - - - 新高新低 - - - - :/image/main_person.png:/image/main_person.png - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 0 - 0 - - - - - - - 用户退出 - - - - :/image/main_exit.png:/image/main_exit.png - - - Qt::ToolButtonTextUnderIcon - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - ArrowCursor - - - Qt::NoFocus - - - 最小化 - - - - - - - - - - - 0 - 0 - - - - ArrowCursor - - - Qt::NoFocus - - - 关闭 - - - - - - - - - - - 0 - 0 - - - - Qt::NoFocus - - - - - - - - - - - - - - - 0 - 70 - 1440 - 830 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 所有日期 + + + + + + + Qt::AlignCenter + + + + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 - - - - - + + + + 0 + 0 + + - 自定 + 交易记录 + + + + :/image/main_main.png:/image/main_main.png + + + Qt::ToolButtonTextUnderIcon - + + + + 0 + 0 + + + + 动量趋势 + + + + :/image/main_config.png:/image/main_config.png + + + Qt::ToolButtonTextUnderIcon + + - + + + + 0 + 0 + + - + 涨跌停板 + + + + :/image/main_data.png:/image/main_data.png + + + false + + + Qt::ToolButtonTextUnderIcon - + + + + 0 + 0 + + + + + + + 新高新低 + + + + :/image/main_person.png:/image/main_person.png + + + Qt::ToolButtonTextUnderIcon + + - + + + + 0 + 0 + + + + + - 确定 + 用户退出 + + + + :/image/main_exit.png:/image/main_exit.png + + + Qt::ToolButtonTextUnderIcon - + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + ArrowCursor + + + Qt::NoFocus + + + 最小化 + + + + + + + + + + + 0 + 0 + + + + ArrowCursor + + + Qt::NoFocus + + + 关闭 + + + + + + + + + + + 0 + 0 + + + + Qt::NoFocus + + + + + + + + + + + + + + + + - + - + - 当前日期区间 + - + - 20231209-20231209 + - - - Qt::Horizontal + + + - - - 40 - 20 - + + + + + + - + - + - 添加记录 + 所有日期 + + + + + + 自定 + + + + + + + + + + + + + + + + + + + + 确定 + + + + + + + + + + + 当前日期区间 + + + + + + + 20231209-20231209 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 添加记录 + + + + + + + + - - - - - - - - + + + + + + + diff --git a/qss/blacksoft.css b/qss/blacksoft.css index 6780634..593d3fe 100644 --- a/qss/blacksoft.css +++ b/qss/blacksoft.css @@ -462,7 +462,7 @@ QTreeView,QListView,QTableView,QSplitter::handle,QTreeView::branch{ background:#444444; } -QTableView::item:selected,QListView::item:selected,QTreeView::item:selected{ +/*QTableView::item:selected,QListView::item:selected,QTreeView::item:selected{ color:#DCDCDC; background:#383838; } @@ -476,7 +476,7 @@ QTableView::item,QListView::item,QTreeView::item{ padding:1px; margin:0px; border:0px; -} +}*/ QHeaderView::section,QTableCornerButton:section{ padding:3px; @@ -691,4 +691,4 @@ background:none; /*NormalColorEnd:#383838*/ /*DarkColorStart:#646464*/ /*DarkColorEnd:#525252*/ -/*HighColor:#AAAAAA*/ \ No newline at end of file +/*HighColor:#AAAAAA*/ diff --git a/widget/trendswidget.cpp b/widget/trendswidget.cpp index 72fcbee..17e7eaa 100644 --- a/widget/trendswidget.cpp +++ b/widget/trendswidget.cpp @@ -1,6 +1,8 @@ #include "trendswidget.h" #include "ui_trendswidget.h" #include +#include +#include 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 > 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 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]: " < 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 columns = trends[0]; + QList rows0 = trends[1]; + QList 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); + } + } } diff --git a/widget/trendswidget.h b/widget/trendswidget.h index 3b3d42f..7b37bcd 100644 --- a/widget/trendswidget.h +++ b/widget/trendswidget.h @@ -25,7 +25,6 @@ private: Ui::TrendsWidget *ui; UserData m_UserData; UserInfo m_UserInfo; - QStandardItemModel* model; }; #endif // TRENDSWIDGET_H diff --git a/widget/trendswidget.ui b/widget/trendswidget.ui index 9327cd5..e85f81c 100644 --- a/widget/trendswidget.ui +++ b/widget/trendswidget.ui @@ -6,16 +6,37 @@ 0 0 - 983 + 1440 647 Form - + - + + + + 16777215 + 16777215 + + + + + + + + + Tab 1 + + + + + Tab 2 + + +