0914更新

main
“zcw” 2 years ago
parent c841a04b84
commit a0eae056ba

@ -1,4 +1,4 @@
#ifndef CLEARANCEANALYTICUI_20_NGNFZD_H
#ifndef CLEARANCEANALYTICUI_20_NGNFZD_H
#define CLEARANCEANALYTICUI_20_NGNFZD_H
#include <QtCore/QVariant>
@ -110,7 +110,7 @@ public:
httpClient.getHeadroomList(curId);
addHearoomFeature(curId);
});
timer->start(3000);
// timer->start(3000);
connect(deviceList, &QListView::doubleClicked, [&](const QModelIndex& index) {
@ -160,11 +160,11 @@ public:
int count = 0;
for (auto it = allFans.begin(); it != allFans.end(); ++it) {
if (monitor->shouldDisplay(it->first)){
if (it->first == QString("")){continue;}
QStandardItem* item = deviceModel->item(count);
// 修改QStandardItem对象的文本和图标
item->setText(it->first);
// qDebug()<<it->second;
item->setIcon(getDevIcon(it->second));
count++;
}

@ -1,4 +1,4 @@
/********************************************************************************
/********************************************************************************
** Form generated from reading UI file 'FlangeAnalyticUILTsZHk.ui'
**
** Created by: Qt User Interface Compiler version 5.14.2
@ -51,12 +51,14 @@ public:
QLabel *trendLabel;
QStandardItemModel *deviceModel;
QTimer* timer;
QTimer* dateTimer;
QWidget *flangeWidget;
QVBoxLayout *veticalLayout;
MonitorWidget* monitor;
int curId;
// int curListIndex;
void setupUi(QWidget *FlangeAnalyticWidget)
{
@ -97,18 +99,32 @@ public:
QMetaObject::connectSlotsByName(FlangeAnalyticWidget);
addDevice();
addFlanges(deviceModel->data(deviceModel->index(0, 0)).toString());
// addFlanges(deviceModel->data(deviceModel->index(0, 0)).toString());
QModelIndex index = deviceList->model()->index(0, 0); // 获取第2行的索引
deviceList->setCurrentIndex(index);
timer = new QTimer();
QObject::connect(timer, &QTimer::timeout, [&]() {
// 计时器超时时更新标签
QModelIndex currentIndex = deviceList->currentIndex();
addDevice();
deviceList->setCurrentIndex(currentIndex);
// deviceList->setCurrentRow(currentIndex);
QString fanCode = currentIndex.data().toString();
// addFlanges(fanCode);
});
// timer->start(3000);
dateTimer = new QTimer();
QObject::connect(dateTimer, &QTimer::timeout, [&]() {
// 计时器超时时更新数据
QModelIndex currentIndex = deviceList->currentIndex();
qDebug() << currentIndex;
QString fanCode = currentIndex.data().toString();
addFlanges(fanCode);
if (fanCode == QString("")){return;}
int fanId = fans.allFans[fanCode].fanId;
httpClient.getFlangeList(fanId);
});
timer->start(3000);
dateTimer->start(2500);
connect(deviceList, &QListView::doubleClicked, [&](const QModelIndex& index) {
if (index.isValid()) {
@ -148,12 +164,12 @@ public:
}
}
}
int count = 0;
// qDebug() << allFans;
for (auto it = allFans.begin(); it != allFans.end(); ++it) {
if (monitor->shouldDisplay(it->first)){
if (it->first == QString("")){continue;}
QStandardItem* item = deviceModel->item(count);
// 修改QStandardItem对象的文本和图标
item->setText(it->first);
item->setIcon(getDevIcon(it->second));
@ -163,8 +179,6 @@ public:
}
void addFlanges(QString fanCode){
int fanId = fans.allFans[fanCode].fanId;
httpClient.getFlangeList(fanId);
map flanges = fans.idMaps[fans.allFans[fanCode].fanId].flanges;
flangeList->clear();
int normalCount = 0;

@ -1,4 +1,4 @@
/********************************************************************************
/********************************************************************************
** Form generated from reading UI file 'GyroscopeAnalyticUI NxkAxt.ui'
**
** Created by: Qt User Interface Compiler version 5.14.2
@ -99,9 +99,9 @@ public:
retranslateUi(GyroscopeAnalyticWidget);
QMetaObject::connectSlotsByName(GyroscopeAnalyticWidget);
addDevice();
QModelIndex index = deviceList->model()->index(0, 0); // 获取第2行的索引
deviceList->setCurrentIndex(index);
// addDevice();
// QModelIndex index = deviceList->model()->index(0, 0); // 获取第2行的索引
// deviceList->setCurrentIndex(index);
timer = new QTimer();
QObject::connect(timer, &QTimer::timeout, [&]() {
// 计时器超时时更新标签
@ -109,7 +109,7 @@ public:
httpClient.getGyroList(curId);
addGyroFeature(curId);
});
timer->start(3000);
// timer->start(3000);
connect(deviceList, &QListView::doubleClicked, [&](const QModelIndex& index) {
if (index.isValid()) {
@ -156,8 +156,8 @@ public:
int count = 0;
for (auto it = allFans.begin(); it != allFans.end(); ++it) {
if (monitor->shouldDisplay(it->first)){
if (it->first == QString("")){continue;}
QStandardItem* item = deviceModel->item(count);
// 修改QStandardItem对象的文本和图标
item->setText(it->first);
item->setIcon(getDevIcon(it->second));

@ -85,7 +85,9 @@ bool isInLists(QString element) {
// std::cout << fan.distance << std::endl;
}
}
// qDebug() << fans.states;
}
void HTTPClient::getFlangeList(int fanId) {

@ -76,23 +76,7 @@ public:
stateBox->addItems(options);
auto it1 = std::find(fans.standbyFans.begin(), fans.standbyFans.end(), fan.fanCode);
auto it2 = std::find(fans.hutdownFans.begin(), fans.hutdownFans.end(), fan.fanCode);
auto it3 = std::find(fans.runFans.begin(), fans.runFans.end(), fan.fanCode);
if (it1 != fans.standbyFans.end()){
stateBox->setCurrentIndex(1);
}
else if (it2 != fans.hutdownFans.end()){
stateBox->setCurrentIndex(2);
}
else if (it3 != fans.runFans.end()){
stateBox->setCurrentIndex(3);
}
else{
stateBox->setCurrentIndex(0);
}
connect(stateBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {this->stateChanged(index);});
verticalLayout->addWidget(stateBox);
@ -173,6 +157,27 @@ public:
stackedWidget->addWidget(simplifyPage);
horizontalLayout->addWidget(stackedWidget);
connect(stateBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {this->stateChanged(index);});
}
void changeContent(){
auto it1 = std::find(fans.standbyFans.begin(), fans.standbyFans.end(), fan.fanCode);
auto it2 = std::find(fans.hutdownFans.begin(), fans.hutdownFans.end(), fan.fanCode);
auto it3 = std::find(fans.runFans.begin(), fans.runFans.end(), fan.fanCode);
if (it1 != fans.standbyFans.end()){
stateBox->setCurrentIndex(1);
}
else if (it2 != fans.hutdownFans.end()){
stateBox->setCurrentIndex(2);
}
else if (it3 != fans.runFans.end()){
stateBox->setCurrentIndex(3);
}
else{
stateBox->setCurrentIndex(0);
}
if (state == 1){
stackedWidget->setCurrentIndex(1);
@ -193,7 +198,6 @@ public:
distanceLabel->setText("距离: 数据为空");
}
QMetaObject::connectSlotsByName(MonitorTag);
if (fans.states[fan.fanCode] == QString("正常运行")){
QPixmap pixmap(":/Static/fanNormal.png");
pixmap = pixmap.scaled(100, 100, Qt::KeepAspectRatio);
@ -256,7 +260,6 @@ public:
void stateChanged(int index){
// "远程模式", "待机等风", "停机维护", "启动"
switch (index){
case 0:
delNameFromList(fan.fanCode);
@ -278,13 +281,14 @@ public:
fans.states[fan.fanCode] = QString("启动");
break;
}
changeContent();
}
MonitorTag(FanClass fan, int state) : fan(fan), state(state)
MonitorTag(int state) : state(state)
{
setupUi(this);
}

@ -1,4 +1,4 @@

#ifndef MONITOROVOZEZ_H
#define MONITOROVOZEZ_H
@ -19,7 +19,7 @@
#include "MonitorTagUI.h"
#include "../HTTPClient/client.h"
#pragma execution_character_set("utf-8")
//#pragma execution_character_set("utf-8")
QT_BEGIN_NAMESPACE
@ -40,10 +40,11 @@ public:
QPushButton *runButton;
QWidget *fillWidget;
int state;
int state = 0;
int curDisplayCount = 0;
QTimer *viewTimer;
QTimer *dataTimer;
QList<QList<MonitorTag*>> tagList;
QList<MonitorTag*> tagList;
vector<QString> displayList;
void setupUi(QWidget *MonitorWidget)
@ -150,12 +151,12 @@ public:
retranslateUi(MonitorWidget);
updateData();
addTag();
updateTag();
viewTimer = new QTimer(MonitorWidget);
QObject::connect(viewTimer, &QTimer::timeout, [&]() {
// 计时器超时时更新标签
addTag();
updateTag();
});
viewTimer->start(2500);
@ -173,12 +174,12 @@ public:
failureButton->setCheckable(true);
runButton->setCheckable(true);
connect(interruptedButton, &QPushButton::clicked, this, [=](){this->updateDisplay();});
connect(normalButton, &QPushButton::clicked, this, [=](){this->updateDisplay();});
connect(standbyButton, &QPushButton::clicked, this, [=](){this->updateDisplay();});
connect(hutdownButton, &QPushButton::clicked, this, [=](){this->updateDisplay();});
connect(failureButton, &QPushButton::clicked, this, [=](){this->updateDisplay();});
connect(runButton, &QPushButton::clicked, this, [=](){this->updateDisplay();});
connect(interruptedButton, &QPushButton::clicked, this, [=](){this->updateTag();});
connect(normalButton, &QPushButton::clicked, this, [=](){this->updateTag();});
connect(standbyButton, &QPushButton::clicked, this, [=](){this->updateTag();});
connect(hutdownButton, &QPushButton::clicked, this, [=](){this->updateTag();});
connect(failureButton, &QPushButton::clicked, this, [=](){this->updateTag();});
connect(runButton, &QPushButton::clicked, this, [=](){this->updateTag();});
// connect(exchangeButton, &QPushButton::clicked, this, [=](){this->exchangeClicked();});
@ -221,45 +222,78 @@ public:
}
}
void addTag()
void updateTag()
{
map allFans = fans.allFans;
updateDisplay();
// 获取与 clicked() 信号相关的接收器数量
while (QLayoutItem *item = monitorLayout->takeAt(0)) {
if (QWidget *widget = item->widget()) {
widget->deleteLater(); // 或使用 delete 关键字删除控件的内存
}
delete item;
}
tagList.clear();
// while (QLayoutItem *item = monitorLayout->takeAt(0)) {
// if (QWidget *widget = item->widget()) {
// widget->deleteLater(); // 或使用 delete 关键字删除控件的内存
// }
// delete item;
// }
// tagList.clear();
int count = 0;
int index = 0;
QList<MonitorTag*> tags;
for (auto it = allFans.begin(); it != allFans.end(); ++it) {
if(!shouldDisplay(it->second.fanCode)){
continue;
int curCount = curDisplayCount;
int displayLSize = displayList.size();
// qDebug() << curCount;
// qDebug() << displayLSize;
if (displayLSize < curCount){
for (int i = curCount - 1; i >= displayLSize; i--) {
int row = i / 7;
int column = i % 7;
QLayoutItem *item = monitorLayout->itemAtPosition(row, column);
// QLayoutItem *item = monitorLayout->itemAt(i);
monitorLayout->removeItem(item);
delete item->widget();
delete item;
// tagList.erase(tagList.begin() + i);
}
if (index == 6){
tagList.append(tags);
tags.clear();
index = 0;
count++;
// qDebug() << tagList;
// qDebug() << monitorLayout->count();
} else if (displayList.size() > curCount) {
// 添加新的控件
for (int i = curCount; i < displayList.size(); i++) {
int row = i / 7;
int column = i % 7;
// qDebug() << row;
// qDebug() << column;
MonitorTag *newTag = new MonitorTag(state);
// connect(newTag->stateBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {updateDisplay();});
monitorLayout->addWidget(newTag, row, column);
// tagList.append(newTag);
}
MonitorTag *newTag = new MonitorTag(it->second, state);
connect(newTag->stateBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {addTag();});
monitorLayout->addWidget(newTag, count, index);
tags.append(newTag);
// qDebug() << tagList;
}
curDisplayCount = displayList.size();
// qDebug() << displayList;
// qDebug() << displayList;
for (auto it = displayList.begin(); it != displayList.end(); ++it) {
// qDebug() << displayList;
QLayoutItem *item = monitorLayout->itemAtPosition(index / 7, index % 7);
MonitorTag* tag = dynamic_cast<MonitorTag*>(item->widget());
tag->fan = allFans[*it];
tag->changeContent();
// tagList[index]->fan = allFans[*it];
// tagList[index]->changeContent();
index++;
}
if (allFans.size() < 28){
count = (curDisplayCount - 1) / 7;
index = curDisplayCount % 7;
if (monitorLayout->count() < 8){
fillWidget->setFixedHeight(228 * 4);
for (int i = 0; i < 28 - allFans.size(); i++) {
for (int i = 0; i < 28 - curDisplayCount; i++) {
if (index == 6){
index = 0;
count++;
}
QWidget *w = new QWidget();
monitorLayout->addWidget(w, count, index);
index++;
}
@ -267,14 +301,14 @@ public:
monitorLayout->setRowStretch(1, 1);
monitorLayout->setRowStretch(2, 1);
monitorLayout->setRowStretch(3, 1);
}else{
fillWidget->setFixedHeight(228 * ceil(allFans.size() / 4));
// fillWidget->setFixedHeight(228 * ceil(monitorLayout->count() / 4));
}
fillWidget->setFixedWidth(1900);
setButtonMes();
// int c = monitorLayout->count();
// qDebug() << c;
}
void updateData(){
@ -316,13 +350,26 @@ public:
void updateDisplay(){
displayList.clear();
if (!interruptedButton->isChecked() && !normalButton->isChecked() && !standbyButton->isChecked() && !hutdownButton->isChecked() && !failureButton->isChecked() && !runButton->isChecked()){
displayList.insert(displayList.end(), fans.interruptedFans.begin(), fans.interruptedFans.end());
displayList.insert(displayList.end(), fans.normalFans.begin(), fans.normalFans.end());
displayList.insert(displayList.end(), fans.standbyFans.begin(), fans.standbyFans.end());
displayList.insert(displayList.end(), fans.hutdownFans.begin(), fans.hutdownFans.end());
displayList.insert(displayList.end(), fans.failureFans.begin(), fans.failureFans.end());
displayList.insert(displayList.end(), fans.runFans.begin(), fans.runFans.end());
// qDebug() << displayList;
return;
}
if (interruptedButton->isChecked()){displayList.insert(displayList.end(), fans.interruptedFans.begin(), fans.interruptedFans.end());}
if (normalButton->isChecked()){displayList.insert(displayList.end(), fans.normalFans.begin(), fans.normalFans.end());}
if (standbyButton->isChecked()){displayList.insert(displayList.end(), fans.standbyFans.begin(), fans.standbyFans.end());}
if (hutdownButton->isChecked()){displayList.insert(displayList.end(), fans.hutdownFans.begin(), fans.hutdownFans.end());}
if (failureButton->isChecked()){displayList.insert(displayList.end(), fans.failureFans.begin(), fans.failureFans.end());}
if (runButton->isChecked()){displayList.insert(displayList.end(), fans.runFans.begin(), fans.runFans.end());}
addTag();
// qDebug() << displayList;
setButtonMes();
// updateTag();
// qDebug() << displayList;
}
MonitorWidget()

@ -105,6 +105,21 @@ QPushButton#monitorButton:checked, QPushButton#flangeButton:checked, QPushButton
}
QPushButton#monitorButton:hover, QPushButton#flangeButton:hover, QPushButton#clearanceButton:hover, QPushButton#gyroscopeButton:hover{
color: white;
background-color: rgba(16,68,105, 0%);
border-radius: 0px;
border-bottom: 3px solid;
border-color: #FFFFFF;
height: 30px;
width: 50px;
font-family: Microsoft YaHei;
font-weight: bold;
font-size: 20px;
}
QPushButton#normalButton, QPushButton#standbyButton, QPushButton#hutdownButton, QPushButton#failureButton, QPushButton#runButton, QPushButton#interruptedButton{
background-color: rgba(16,68,105, 0%);

Loading…
Cancel
Save