From b02902a0efd231b4f7b1aa06d91184df5f3deee5 Mon Sep 17 00:00:00 2001 From: duanshengchao <519970194@qq.com> Date: Mon, 4 Aug 2025 10:57:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8DdataPanle=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=97=B6=EF=BC=8C=E9=80=89=E6=8B=A9=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=BA=90(=E5=A4=9A=E6=9D=A1=E6=9B=B2?= =?UTF-8?q?=E7=BA=BF)=E9=80=A0=E6=88=90=E7=9A=84=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=B4=A9=E6=BA=83(=E7=94=B1=E4=BA=8E=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E4=BA=86=E5=B1=80=E9=83=A8=E5=8F=98=E9=87=8F=E7=9A=84=E5=9C=B0?= =?UTF-8?q?=E5=9D=80)=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataPanel/dpBaseChart.h | 9 ++++++++- dataPanel/dpConfigurationDialog.cpp | 10 +++++++++- dataPanel/dpLineChart.cpp | 5 ++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dataPanel/dpBaseChart.h b/dataPanel/dpBaseChart.h index 72923e6..41c73c5 100644 --- a/dataPanel/dpBaseChart.h +++ b/dataPanel/dpBaseChart.h @@ -99,11 +99,18 @@ protected: { QColor color; RealTimeDataType dataType; - //QCPGraph* qGraph = nullptr; + //QCPGraph* qGraph; QPointer qGraph; QString dataID; QString synchronizeTagging; //同步配置数据时的标记,new、update两种,没有的就是要被删除 + + Graph() + { + dataID = ""; + //qGraph = nullptr; + synchronizeTagging = "noTagging"; + } }; }; diff --git a/dataPanel/dpConfigurationDialog.cpp b/dataPanel/dpConfigurationDialog.cpp index ce51ac2..ebefb61 100644 --- a/dataPanel/dpConfigurationDialog.cpp +++ b/dataPanel/dpConfigurationDialog.cpp @@ -145,9 +145,16 @@ void dpConfigurationDialog::copyModelData(QStandardItemModel* sourceModel, QStan if(item) { QStandardItem* newItem = new QStandardItem(item->text()); - newItem->setData(item->data(Qt::DecorationRole), Qt::DecorationRole); + QString strTag = item->data(Qt::UserRole + itemRole_tag).toString(); RealTimeDataType dataType = (RealTimeDataType)item->data(Qt::UserRole + itemRole_dataType).toInt(); newItem->setData(dataType, Qt::UserRole + itemRole_dataType); + if(strTag == "point") + { + newItem->setData(item->data(Qt::DecorationRole), Qt::DecorationRole); + newItem->setData(item->data(Qt::UserRole + itemRole_stationID), Qt::UserRole + itemRole_stationID); + newItem->setData(item->data(Qt::UserRole + itemRole_componentID), Qt::UserRole + itemRole_componentID); + newItem->setData(item->data(Qt::UserRole + itemRole_pointID), Qt::UserRole + itemRole_pointID); + } itemList.push_back(newItem); } } @@ -521,6 +528,7 @@ void dpConfigurationDialog::onItemClicked_dataSource(const QModelIndex& index) { QStandardItem* newItem = new QStandardItem(strText); newItem->setEditable(false); + newItem->setData(item->data(Qt::UserRole + itemRole_tag), Qt::UserRole + itemRole_tag); newItem->setData(item->data(Qt::UserRole + itemRole_stationID), Qt::UserRole + itemRole_stationID); newItem->setData(item->data(Qt::UserRole + itemRole_componentID), Qt::UserRole + itemRole_componentID); newItem->setData(item->data(Qt::UserRole + itemRole_pointID), Qt::UserRole + itemRole_pointID); diff --git a/dataPanel/dpLineChart.cpp b/dataPanel/dpLineChart.cpp index 1ecdd9d..2aa5d0c 100644 --- a/dataPanel/dpLineChart.cpp +++ b/dataPanel/dpLineChart.cpp @@ -355,7 +355,7 @@ void dpLineChart::synchronizeConfigData(const configurationResults& cfg) axis.setQCPAxis(pAxis, false); } m_axes.append(axis); - axesMap.insert(axis._cfg.dataType, &axis); //临时变量axesMap通过做更新 + axesMap.insert(axis._cfg.dataType, &m_axes.last()); //临时变量axesMap通过做更新,此处不要直接使用&axis,因为axis是局部变量,地址会被自动释放,造成堆错误 #endif } } @@ -370,6 +370,7 @@ void dpLineChart::synchronizeConfigData(const configurationResults& cfg) QString stationID = cfg.m_pModel_dataSource->item(i, 0)->data(Qt::UserRole + itemRole_stationID).toString(); QString compoentID = cfg.m_pModel_dataSource->item(i, 0)->data(Qt::UserRole + itemRole_componentID).toString(); QString pointID = cfg.m_pModel_dataSource->item(i, 0)->data(Qt::UserRole + itemRole_pointID).toString(); + QString graphID = stationID + "-" + compoentID + "-" + pointID; if(!m_graphs.contains(graphID)) //新增数据 { @@ -416,6 +417,8 @@ void dpLineChart::synchronizeConfigData(const configurationResults& cfg) qWarning() << "Failed to remove graph:" << key; } + qDebug() << m_graphs.count(); + m_updateData = true; }