|
|
@@ -1,6 +1,7 @@
|
|
|
#include "thresholdlistwidget.h"
|
|
|
#include "ui_thresholdlistwidget.h"
|
|
|
#include "pdu_ctrl.h"
|
|
|
+#include <QScroller>
|
|
|
ThresholdListWidget::ThresholdListWidget(QWidget *parent) :
|
|
|
QWidget(parent),
|
|
|
ui(new Ui::ThresholdListWidget)
|
|
|
@@ -16,7 +17,7 @@ ThresholdListWidget::~ThresholdListWidget()
|
|
|
|
|
|
void ThresholdListWidget::UpdateTreshold()
|
|
|
{
|
|
|
- ReadSqlData();
|
|
|
+ //ReadSqlData();
|
|
|
updateTablewidget();
|
|
|
}
|
|
|
|
|
|
@@ -63,6 +64,7 @@ void ThresholdListWidget::updateTablewidget()
|
|
|
// 初始化表格内容
|
|
|
auto overMG=pdu_Ctrl::instance()->getOverMG();
|
|
|
for(auto iters= overMG.begin(); iters!= overMG.end(); iters++) {
|
|
|
+ if(iters== overMG.begin()) continue;
|
|
|
for(auto iter=iters.value().begin();iter!=iters.value().end();iter++)
|
|
|
{
|
|
|
// 初始化阈值列(带两位小数格式)
|
|
|
@@ -70,11 +72,9 @@ void ThresholdListWidget::updateTablewidget()
|
|
|
auto pWarningData=pdu_Ctrl::instance()->getWarningData(iter.value().nAddrID,iter.value().nAddrCHID);
|
|
|
if (pWarningData)
|
|
|
{
|
|
|
- checkThresholds(nRow,pWarningData);
|
|
|
+ checkThresholds(nRow+1,pWarningData);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -84,6 +84,11 @@ void ThresholdListWidget::InitUI()
|
|
|
"电流上限(A)", "功率上限(W)", "电量上限(Wh)"};
|
|
|
ui->tableWidget->setColumnCount(6);
|
|
|
ui->tableWidget->setHorizontalHeaderLabels(headers);
|
|
|
+ QScroller::grabGesture(ui->tableWidget->viewport(), QScroller::TouchGesture);
|
|
|
+ QScrollerProperties properties = QScroller::scroller(ui->tableWidget)->scrollerProperties();
|
|
|
+ properties.setScrollMetric(QScrollerProperties::DragVelocitySmoothingFactor, 0.6); // 惯性系数
|
|
|
+ properties.setScrollMetric(QScrollerProperties::SnapPositionRatio, 0.2); // 弹性效果
|
|
|
+ ui->tableWidget->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); // 启用触控事件
|
|
|
// 设置自动调整列宽
|
|
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
ui->tableWidget->verticalHeader()->setVisible(false);
|
|
|
@@ -100,6 +105,11 @@ int ThresholdListWidget::AddRowData(int nChID,QString strName,GlobalOverManager*
|
|
|
ui->tableWidget->setItem(nMaxRow, 0, channelItem);
|
|
|
|
|
|
// 初始化阈值列
|
|
|
+ /*if(pData->product_vol_upper_threshold!=0
|
|
|
+ ||pData->product_vol_lower_threshold!=0
|
|
|
+ ||pData->product_cur_upper_threshold!=0
|
|
|
+ ||pData->product_pwr_upper_threshold!=0
|
|
|
+ ||pData->product_pwrcon_upper_threshold!=0){qDebug()<<"HaveData "<< nMaxRow; }*/
|
|
|
ui->tableWidget->setItem(nMaxRow, 1, new QTableWidgetItem(QString::number(pData->product_vol_upper_threshold,'f',2)));
|
|
|
ui->tableWidget->setItem(nMaxRow, 2, new QTableWidgetItem(QString::number(pData->product_vol_lower_threshold,'f',2)));
|
|
|
ui->tableWidget->setItem(nMaxRow, 3, new QTableWidgetItem(QString::number(pData->product_cur_upper_threshold,'f',2)));
|
|
|
@@ -126,10 +136,10 @@ void ThresholdListWidget::checkThresholds(int nRow,PowerWarningInfo* pWarning) {
|
|
|
}
|
|
|
// 电压检测
|
|
|
if(pWarning->w_voltage_up) {
|
|
|
- color = Qt::red;
|
|
|
+ color = Qt::blue;//
|
|
|
ui->tableWidget->item(nRow,1)->setForeground(color);
|
|
|
} else if(pWarning->w_voltage_down) {
|
|
|
- color = Qt::red;
|
|
|
+ color = Qt::blue;
|
|
|
ui->tableWidget->item(nRow,2)->setForeground(color);
|
|
|
}else
|
|
|
{
|
|
|
@@ -140,7 +150,7 @@ void ThresholdListWidget::checkThresholds(int nRow,PowerWarningInfo* pWarning) {
|
|
|
|
|
|
// 电流检测
|
|
|
if(pWarning->w_current) {
|
|
|
- color = Qt::red;
|
|
|
+ color = Qt::blue;
|
|
|
}else
|
|
|
{
|
|
|
color = Qt::green;
|
|
|
@@ -149,7 +159,7 @@ void ThresholdListWidget::checkThresholds(int nRow,PowerWarningInfo* pWarning) {
|
|
|
|
|
|
// 功率检测
|
|
|
if(pWarning->w_power) {
|
|
|
- color = Qt::red;
|
|
|
+ color = Qt::blue;
|
|
|
}else
|
|
|
{
|
|
|
color = Qt::green;
|
|
|
@@ -157,7 +167,7 @@ void ThresholdListWidget::checkThresholds(int nRow,PowerWarningInfo* pWarning) {
|
|
|
ui->tableWidget->item(nRow,4)->setForeground(color);
|
|
|
// 电量检测
|
|
|
if(pWarning->w_consumption) {
|
|
|
- color = Qt::red;
|
|
|
+ color = Qt::blue;
|
|
|
}else
|
|
|
{
|
|
|
color = Qt::green;
|