fix save bug

This commit is contained in:
baiYue 2026-06-10 20:04:51 +08:00
parent c3c73e2153
commit ccb362defb
9 changed files with 275 additions and 222 deletions

View File

@ -1,7 +1,7 @@
#ifndef BASEDRAWINGPANEL_H #ifndef BASEDRAWINGPANEL_H
#define BASEDRAWINGPANEL_H #define BASEDRAWINGPANEL_H
/****************工程模和运行时panel的基类*****************/ /****************组态panel的基类*****************/
#include <QWidget> #include <QWidget>
#include <QHBoxLayout> #include <QHBoxLayout>

View File

@ -33,7 +33,6 @@ private:
void updateShowLabel(QStringList lst); void updateShowLabel(QStringList lst);
void updateLables(); void updateLables();
void deleteRowWithReindex(int row); void deleteRowWithReindex(int row);
void reorderMapAndUpdateIndices(int startRow);
private: private:
Ui::ctExtraInfoDlg *ui; Ui::ctExtraInfoDlg *ui;
QMap<QString,CtExtraInfo> _mapCT; QMap<QString,CtExtraInfo> _mapCT;

View File

@ -31,7 +31,6 @@ protected:
void addTableRow(QString sRatioRange,QString sAccuracy,QString sVolume,QString sStar,double dRatio,bool bPolarity,int index = -1); void addTableRow(QString sRatioRange,QString sAccuracy,QString sVolume,QString sStar,double dRatio,bool bPolarity,int index = -1);
private: private:
void deleteRowWithReindex(int row); void deleteRowWithReindex(int row);
void reorderMapAndUpdateIndices(int startRow);
private: private:
Ui::ptExtraInfoDlg *ui; Ui::ptExtraInfoDlg *ui;
QMap<QString,PtExtraInfo> _mapPT; QMap<QString,PtExtraInfo> _mapPT;

View File

@ -82,9 +82,9 @@ QMap<QString,PropertyStateInfo> CtExtraInfoDlg::getPropertyValue(BaseProperty* p
else if(info.name == "相数" || info.tagName == "phase_num") else if(info.name == "相数" || info.tagName == "phase_num")
{ {
if(ui->rb_tpt_ct->isChecked()) if(ui->rb_tpt_ct->isChecked())
info.defaultValue = 1; info.defaultValue = QVariant(1);
else else
info.defaultValue = 0; info.defaultValue = QVariant(0);
} }
else if(info.name == "CT绕组" || info.tagName == "ct_winding") else if(info.name == "CT绕组" || info.tagName == "ct_winding")
{ {
@ -211,7 +211,7 @@ void CtExtraInfoDlg::onTableCustomContextMenuRequested(const QPoint &pos) {
} }
void CtExtraInfoDlg::addTableRow(QString sRatioRange,QString sAccuracy,QString sVolume,double dRatio,bool bPolarity,int index) void CtExtraInfoDlg::addTableRow(QString sRatioRange,QString sAccuracy,QString sVolume,double dRatio,bool bPolarity,int index)
{ {
if(_mapCT.contains(QString::number(index))) /*if(_mapCT.contains(QString::number(index)))
{ {
return; return;
} }
@ -255,13 +255,49 @@ void CtExtraInfoDlg::addTableRow(QString sRatioRange,QString sAccuracy,QString s
info.polarity = bPolarity? 1 : -1; info.polarity = bPolarity? 1 : -1;
_mapCT.insert(QString::number(info.index),info); _mapCT.insert(QString::number(info.index),info);
updateLables();*/
if (index != -1) {
if (_mapCT.contains(QString::number(index)))
return;
}
int row = ui->tb_ct->rowCount();
ui->tb_ct->insertRow(row);
// index 永远等于 row + 1
int newIndex = row + 1;
CtExtraInfo info;
info.index = newIndex;
info.scope = sRatioRange;
info.accuracy = sAccuracy;
info.volume = sVolume;
info.ratio = dRatio;
info.polarity = bPolarity ? 1 : -1;
// 表格显示
auto* idItem = new QTableWidgetItem(QString::number(newIndex));
idItem->setData(Qt::UserRole, newIndex);
ui->tb_ct->setItem(row, 0, idItem);
ui->tb_ct->setItem(row, 1, new QTableWidgetItem(sRatioRange));
ui->tb_ct->setItem(row, 2, new QTableWidgetItem(sAccuracy));
ui->tb_ct->setItem(row, 3, new QTableWidgetItem(sVolume));
ui->tb_ct->setItem(row, 4, new QTableWidgetItem(QString::number(dRatio)));
ui->tb_ct->setItem(row, 5, new QTableWidgetItem(QString::number(info.polarity)));
// map 同步
_mapCT.insert(QString::number(newIndex), info);
updateLables(); updateLables();
} }
void CtExtraInfoDlg::updateShowLabel(QStringList lst) void CtExtraInfoDlg::updateShowLabel(QStringList lst)
{ {
_curLabels = lst; _curLabels = lst;
ui->label_title_ct->setText(_curLabels.join(" ")); ui->label_title_ct->setText(_curLabels.join("\n"));
int h = ui->label_title_ct->heightForWidth(ui->label_title_ct->width());
ui->label_title_ct->setFixedHeight(h);
} }
void CtExtraInfoDlg::updateLables() void CtExtraInfoDlg::updateLables()
@ -276,7 +312,7 @@ void CtExtraInfoDlg::updateLables()
void CtExtraInfoDlg::deleteRowWithReindex(int row) { void CtExtraInfoDlg::deleteRowWithReindex(int row) {
// 1. 获取要删除的ID // 1. 获取要删除的ID
QTableWidgetItem* pFirstItem = ui->tb_ct->item(row, 0); /*QTableWidgetItem* pFirstItem = ui->tb_ct->item(row, 0);
if (!pFirstItem) return; if (!pFirstItem) return;
int deletedId = pFirstItem->data(Qt::UserRole).toInt(); int deletedId = pFirstItem->data(Qt::UserRole).toInt();
@ -291,39 +327,42 @@ void CtExtraInfoDlg::deleteRowWithReindex(int row) {
} }
// 4. 重新排序和更新index // 4. 重新排序和更新index
reorderMapAndUpdateIndices(row); reorderMapAndUpdateIndices(row);*/
} if (row < 0 || row >= ui->tb_ct->rowCount())
return;
void CtExtraInfoDlg::reorderMapAndUpdateIndices(int startRow) { // 1. 删除行
ui->tb_ct->removeRow(row);
// 2. 清空旧数据
_mapCT.clear();
// 3. 按当前表格顺序重建 index 和 map
int totalRows = ui->tb_ct->rowCount(); int totalRows = ui->tb_ct->rowCount();
for (int r = 0; r < totalRows; ++r)
{
int newIndex = r + 1;
// 遍历从startRow开始的所有行 CtExtraInfo info;
for (int row = startRow; row < totalRows; ++row) { info.index = newIndex;
QTableWidgetItem* idItem = ui->tb_ct->item(row, 0); info.scope = ui->tb_ct->item(r, 1)->text();
if (!idItem) continue; info.accuracy = ui->tb_ct->item(r, 2)->text();
info.volume = ui->tb_ct->item(r, 3)->text();
info.ratio = ui->tb_ct->item(r, 4)->text().toDouble();
info.polarity = (ui->tb_ct->item(r, 5)->text().toInt() > 0);
int currentId = idItem->data(Qt::UserRole).toInt(); QString key = QString::number(newIndex);
QString currentKey = QString::number(currentId);
// 计算新的ID和索引 _mapCT[key] = info;
int newId = row + 1; // 新的ID
int newIndex = row + 1; // 新的索引
if (_mapCT.contains(currentKey)) { // 更新显示
// 获取并更新数据 auto* idItem = ui->tb_ct->item(r, 0);
CtExtraInfo info = _mapCT[currentKey]; if (idItem) {
info.index = newIndex; idItem->setText(key);
idItem->setData(Qt::UserRole, newIndex);
// 从旧位置移除
_mapCT.remove(currentKey);
// 添加到新位置
QString newKey = QString::number(newId);
_mapCT[newKey] = info;
// 更新表格显示
idItem->setText(QString::number(newId));
idItem->setData(Qt::UserRole, newId);
} }
} }
updateLables();
} }

View File

@ -1186,7 +1186,6 @@ void FixedPortsModel::saveNode(int nPageId)
} }
QMap<QUuid,GraphicsProjectModelItem*> mapItems = allItems(); QMap<QUuid,GraphicsProjectModelItem*> mapItems = allItems();
bool updated = false;
for(auto& pItem:mapItems) for(auto& pItem:mapItems)
{ {
BaseProperty* pData = dynamic_cast<BaseProperty*>(pItem->getProperty()); BaseProperty* pData = dynamic_cast<BaseProperty*>(pItem->getProperty());
@ -1216,10 +1215,7 @@ void FixedPortsModel::saveNode(int nPageId)
VariableProperty* pVariable = dynamic_cast<VariableProperty*>(pData); VariableProperty* pVariable = dynamic_cast<VariableProperty*>(pData);
if(pVariable) if(pVariable)
{ {
bool useCatch = updated?true:false; ModelDataInfo& dataInfo = pVariable->getPropertyValue(true);
ModelDataInfo& dataInfo = pVariable->getPropertyValue(useCatch);
if(updated == false)
updated = true;
QString tempTag = pData->tag()+"-"+_pageName+pData->getBay(); //tag后加工程名使得全局唯一 QString tempTag = pData->tag()+"-"+_pageName+pData->getBay(); //tag后加工程名使得全局唯一
if(exist) //已存在更新 if(exist) //已存在更新
{ {
@ -1516,6 +1512,7 @@ void FixedPortsModel::saveNode(int nPageId)
} }
} }
} }
int a = 1;
} }
void FixedPortsModel::onSignal_ifExits(QUuid id,const QString& str,int type,GraphicsProjectModelItem* pitem) void FixedPortsModel::onSignal_ifExits(QUuid id,const QString& str,int type,GraphicsProjectModelItem* pitem)
@ -2055,7 +2052,7 @@ void FixedPortsModel::updateItemLinePort(QUuid uid,ModelFunctionType type)
void FixedPortsModel::showModelDlg(const QString& sName,QUuid uuid,GraphicsProjectModelItem* pItem) void FixedPortsModel::showModelDlg(const QString& sName,QUuid uuid,GraphicsProjectModelItem* pItem)
{ {
ModelStateInfo stateInfo = _modelStateInfo[sName]; ModelStateInfo stateInfo = _modelStateInfo[sName];
ModelDataMap mapData = DataManager::instance().modelData(); ModelDataMap mapData = DataManager::instance().modelData(true);
ItemPropertyDlg* pDlg = dynamic_cast<ItemPropertyDlg*>(stateInfo._PropertyDlg); ItemPropertyDlg* pDlg = dynamic_cast<ItemPropertyDlg*>(stateInfo._PropertyDlg);
if(pDlg) if(pDlg)
{ {

View File

@ -208,7 +208,7 @@ void PtExtraInfoDlg::onTableCustomContextMenuRequested(const QPoint &pos) {
void PtExtraInfoDlg::addTableRow(QString sRatioRange,QString sAccuracy,QString sVolume,QString sStar,double dRatio,bool bPolarity,int index) void PtExtraInfoDlg::addTableRow(QString sRatioRange,QString sAccuracy,QString sVolume,QString sStar,double dRatio,bool bPolarity,int index)
{ {
if(_mapPT.contains(QString::number(index))) /*if(_mapPT.contains(QString::number(index)))
{ {
return; return;
} }
@ -254,12 +254,44 @@ void PtExtraInfoDlg::addTableRow(QString sRatioRange,QString sAccuracy,QString s
info.star = sStar; info.star = sStar;
info.ratio = dRatio; info.ratio = dRatio;
info.polarity = bPolarity? 1 : -1; info.polarity = bPolarity? 1 : -1;
_mapPT.insert(QString::number(info.index),info); _mapPT.insert(QString::number(info.index),info);*/
if (index != -1) {
if (_mapPT.contains(QString::number(index)))
return;
}
int row = ui->tb_pt->rowCount();
ui->tb_pt->insertRow(row);
int newIndex = row + 1;
PtExtraInfo info;
info.index = newIndex;
info.scope = sRatioRange;
info.accuracy = sAccuracy;
info.volume = sVolume;
info.star = sStar;
info.ratio = dRatio;
info.polarity = bPolarity ? 1 : -1;
// index 列
auto* idItem = new QTableWidgetItem(QString::number(newIndex));
idItem->setData(Qt::UserRole, newIndex);
ui->tb_pt->setItem(row, 0, idItem);
ui->tb_pt->setItem(row, 1, new QTableWidgetItem(sRatioRange));
ui->tb_pt->setItem(row, 2, new QTableWidgetItem(sAccuracy));
ui->tb_pt->setItem(row, 3, new QTableWidgetItem(sVolume));
ui->tb_pt->setItem(row, 4, new QTableWidgetItem(QString::number(dRatio)));
ui->tb_pt->setItem(row, 5, new QTableWidgetItem(QString::number(info.polarity)));
ui->tb_pt->setItem(row, 6, new QTableWidgetItem(sStar));
_mapPT.insert(QString::number(newIndex), info);
} }
void PtExtraInfoDlg::deleteRowWithReindex(int row) { void PtExtraInfoDlg::deleteRowWithReindex(int row) {
// 1. 获取要删除的ID // 1. 获取要删除的ID
QTableWidgetItem* pFirstItem = ui->tb_pt->item(row, 0); /*QTableWidgetItem* pFirstItem = ui->tb_pt->item(row, 0);
if (!pFirstItem) return; if (!pFirstItem) return;
int deletedId = pFirstItem->data(Qt::UserRole).toInt(); int deletedId = pFirstItem->data(Qt::UserRole).toInt();
@ -274,39 +306,40 @@ void PtExtraInfoDlg::deleteRowWithReindex(int row) {
} }
// 4. 重新排序和更新index // 4. 重新排序和更新index
reorderMapAndUpdateIndices(row); reorderMapAndUpdateIndices(row);*/
} if (row < 0 || row >= ui->tb_pt->rowCount())
return;
void PtExtraInfoDlg::reorderMapAndUpdateIndices(int startRow) { // 1. 删除行
ui->tb_pt->removeRow(row);
// 2. 清空旧 map
_mapPT.clear();
// 3. 按表格顺序重建
int totalRows = ui->tb_pt->rowCount(); int totalRows = ui->tb_pt->rowCount();
for (int r = 0; r < totalRows; ++r)
{
int newIndex = r + 1;
// 遍历从startRow开始的所有行 PtExtraInfo info;
for (int row = startRow; row < totalRows; ++row) { info.index = newIndex;
QTableWidgetItem* idItem = ui->tb_pt->item(row, 0); info.scope = ui->tb_pt->item(r, 1)->text();
if (!idItem) continue; info.accuracy = ui->tb_pt->item(r, 2)->text();
info.volume = ui->tb_pt->item(r, 3)->text();
info.ratio = ui->tb_pt->item(r, 4)->text().toDouble();
info.polarity = (ui->tb_pt->item(r, 5)->text().toInt() > 0);
info.star = ui->tb_pt->item(r, 6)->text();
int currentId = idItem->data(Qt::UserRole).toInt(); QString key = QString::number(newIndex);
QString currentKey = QString::number(currentId); _mapPT[key] = info;
// 计算新的ID和索引 // 更新显示
int newId = row + 1; // 新的ID auto* idItem = ui->tb_pt->item(r, 0);
int newIndex = row + 1; // 新的索引 if (idItem) {
idItem->setText(key);
if (_mapPT.contains(currentKey)) { idItem->setData(Qt::UserRole, newIndex);
// 获取并更新数据
PtExtraInfo info = _mapPT[currentKey];
info.index = newIndex;
// 从旧位置移除
_mapPT.remove(currentKey);
// 添加到新位置
QString newKey = QString::number(newId);
_mapPT[newKey] = info;
// 更新表格显示
idItem->setText(QString::number(newId));
idItem->setData(Qt::UserRole, newId);
} }
} }
} }

View File

@ -24,6 +24,12 @@
</property> </property>
<item row="0" column="0" colspan="17"> <item row="0" column="0" colspan="17">
<widget class="QLabel" name="label_title_ct"> <widget class="QLabel" name="label_title_ct">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
@ -45,6 +51,9 @@
<property name="alignment"> <property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set> <set>Qt::AlignmentFlag::AlignCenter</set>
</property> </property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">

View File

@ -321,7 +321,7 @@ bool DataBase::updateComponent(QUuid uuid,QString tag,QString name,QJsonObject c
QJsonDocument contextDoc(context); QJsonDocument contextDoc(context);
QString strCon = contextDoc.toJson(QJsonDocument::Compact); QString strCon = contextDoc.toJson(QJsonDocument::Compact);
qry.prepare("UPDATE component SET tag=?, name=?, context=?, ts=? ,in_service=?,state=?,status=?WHERE global_uuid=?"); qry.prepare("UPDATE component SET tag=?, name=?, context=?, ts=? ,in_service=?,state=?,status=? WHERE global_uuid=?");
qry.bindValue(0,tag); qry.bindValue(0,tag);
qry.bindValue(1,name); qry.bindValue(1,name);
qry.bindValue(2,strCon); qry.bindValue(2,strCon);
@ -3028,171 +3028,144 @@ PropertyValueInfo DataBase::selectGroupPropertyByValue(const QString& tableName,
QList<MeasureAttributeType> DataBase::getMeasureAttributeTypes() //暂时调换获取的name与tag QList<MeasureAttributeType> DataBase::getMeasureAttributeTypes() //暂时调换获取的name与tag
{ {
QList<MeasureAttributeType> lst; QList<MeasureAttributeType> lst;
QString strSQL = "SELECT attribute,attribute_name FROM basic.attribute WHERE is_visible = ?";
QVariantList params; const QString strSQL =
params.append(2); "SELECT attribute, attribute_name FROM basic.attribute WHERE is_visible = ?";
QVariantList params{2};
try try
{ {
QSqlQuery query = executeSQL(strSQL,false,params); QSqlQuery query = executeSQL(strSQL, false, params);
while (query.next()) while (query.next())
{ {
QString attName = query.value(0).toString(); QString attName = query.value(0).toString();
QString attTag = query.value(1).toString(); QString attTag = query.value(1).toString();
if(attName.contains("$")){ //包含$ const QChar firstChar = attName.isEmpty() ? QChar() : attName.at(0);
QStringList lst_dollar; const bool hasDollar = attName.contains("$");
lst_dollar<<"s1"<<"s2"<<"s3"; const bool hasUnderDollar = attName.contains("_$");
if(attName.contains("sn")){ //同时包含$与sn,9个分支 const bool hasSn = attName.contains("sn");
QStringList lst_sn;
lst_sn<<"s1"<<"s2"<<"s3";
if(attName.contains("_$")){ //包含_$,特殊处理 /* ========== 规则 1_$ ========== */
if(attName.first(1) == "I"){ //头字母为I if (hasUnderDollar)
QStringList lst_I; {
lst_I<<"a"<<"b"<<"c"; QStringList underDollarValues;
for(auto &i:lst_I) if (firstChar == 'I')
{
QString tn1 = attName;
QString tt1 = attTag;
QString name = tn1.replace("_$",i);
QString tag = tt1.replace("_$",i);
for(auto &sn:lst_sn)
{
QString tn2 = name;
QString tt2 = tag;
MeasureAttributeType measure;
measure.tag = tn2.replace("sn",sn);
measure.name = tt2.replace("sn",sn);
lst.append(measure);
}
}
}
else{ //头字母为U
QStringList lst_U;
lst_U<<"AB"<<"BC"<<"CA";
for(auto &u:lst_U)
{
QString tn1 = attName;
QString tt1 = attTag;
QString name = tn1.replace("_$",u);
QString tag = tt1.replace("_$",u);
for(auto &sn:lst_sn)
{
QString tn2 = name;
QString tt2 = tag;
MeasureAttributeType measure;
measure.tag = tn2.replace("sn",sn);
measure.name = tt2.replace("sn",sn);
lst.append(measure);
}
}
}
}
else{ //只包含$与sn
for(auto &dor:lst_dollar)
{
QString tn1 = attName;
QString tt1 = attTag;
QString name = tn1.replace("$",dor);
QString tag = tt1.replace("$",dor);
for(auto &sn:lst_sn)
{
QString tn2 = name;
QString tt2 = tag;
MeasureAttributeType measure;
measure.tag = tn2.replace("sn",sn);
measure.name = tt2.replace("sn",sn);
lst.append(measure);
}
}
}
}
else{ //不包含sn,3种分支
if(attName.contains("_$")){ //包含_$
if(attName.first(1) == "I"){ //头字母为I
QStringList lst_I;
lst_I<<"a"<<"b"<<"c";
for(auto &i:lst_I)
{
QString name = attName;
QString tag = attTag;
MeasureAttributeType measure;
measure.tag = name.replace("_$",i);
measure.name = tag.replace("_$",i);
lst.append(measure);
}
}
else{ //头字母为U
QStringList lst_U;
lst_U<<"AB"<<"BC"<<"CA";
for(auto &u:lst_U)
{
QString name = attName;
QString tag = attTag;
MeasureAttributeType measure;
measure.tag = name.replace("_$",u);
measure.name = tag.replace("_$",u);
lst.append(measure);
}
}
}
else{ //不包含_$
QStringList lst_dollar;
lst_dollar<<"s1"<<"s2"<<"s3";
for(auto &dor:lst_dollar)
{
QString name = attName;
QString tag = attTag;
MeasureAttributeType measure;
measure.tag = name.replace("$",dor);
measure.name = tag.replace("$",dor);
lst.append(measure);
}
}
}
}
else if(attName.contains("sn")){ //只包含sn3种分支
QStringList lst_sn;
lst_sn<<"s1"<<"s2"<<"s3";
for(auto &sn:lst_sn)
{ {
QString name = attName; underDollarValues = QStringList{"a", "b", "c"};
QString tag = attTag; }
else // U
{
underDollarValues = QStringList{"ab", "bc", "ca"}; // ✅ 已修正
}
MeasureAttributeType measure; if (hasSn)
measure.tag = name.replace("sn",sn); {
measure.name = tag.replace("sn",sn); for (const QString& u : underDollarValues)
lst.append(measure); {
QString tmpName = attName;
QString tmpTag = attTag;
tmpName.replace("_$", u);
tmpTag.replace("_$", u);
for (const QString& sn : {"s1","s2","s3"})
{
MeasureAttributeType m;
m.tag = tmpName;
m.name = tmpTag;
m.tag.replace("sn", sn);
m.name.replace("sn", sn);
lst.append(m);
}
}
}
else
{
for (const QString& u : underDollarValues)
{
MeasureAttributeType m;
m.tag = attName;
m.name = attTag;
m.tag.replace("_$", u);
m.name.replace("_$", u);
lst.append(m);
}
} }
} }
else{ //没有分支 /* ========== 规则 2$ ========== */
MeasureAttributeType measure; else if (hasDollar)
measure.tag = attName; {
measure.name = attTag; QStringList dollarValues =
lst.append(measure); (firstChar == 'I') ? QStringList{"A","B","C"}
: QStringList{"AB","BC","CA"};
if (hasSn)
{
for (const QString& d : dollarValues)
{
QString tmpName = attName;
QString tmpTag = attTag;
tmpName.replace("$", d);
tmpTag.replace("$", d);
for (const QString& sn : {"s1","s2","s3"})
{
MeasureAttributeType m;
m.tag = tmpName;
m.name = tmpTag;
m.tag.replace("sn", sn);
m.name.replace("sn", sn);
lst.append(m);
}
}
}
else
{
for (const QString& d : dollarValues)
{
MeasureAttributeType m;
m.tag = attName;
m.name = attTag;
m.tag.replace("$", d);
m.name.replace("$", d);
lst.append(m);
}
}
}
/* ========== 规则 3仅 sn ========== */
else if (hasSn)
{
for (const QString& sn : {"s1","s2","s3"})
{
MeasureAttributeType m;
m.tag = attName;
m.name = attTag;
m.tag.replace("sn", sn);
m.name.replace("sn", sn);
lst.append(m);
}
}
/* ========== 规则 4无占位符 ========== */
else
{
MeasureAttributeType m;
m.tag = attName;
m.name = attTag;
lst.append(m);
} }
} }
query.clear(); query.clear();
return lst; return lst;
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
LOG_ERROR("DB", QString("Select measureAttributeType fail")); LOG_ERROR("DB", QString("Select measureAttributeType fail: %1").arg(e.what()));
return lst;
} }
return lst;
} }
/************************************运行模式*********************************************/ /************************************运行模式*********************************************/

View File

@ -202,13 +202,17 @@ void DiagramView::onItemClicked(const QModelIndex &index)
void DiagramView::onPageSaved(const QString sPage,int id) void DiagramView::onPageSaved(const QString sPage,int id)
{ {
for (int row = 0; row < _pModel->rowCount(); ++row) { for (int row = 0; row < _pModel->rowCount(); ++row) {
QStandardItem *item = _pModel->item(row, 0); QStandardItem* item = _pModel->item(row, 0);
if (item && item->data(Qt::DisplayRole) == sPage) { if (item && item->text() == sPage) {
QStandardItem* pItem = new QStandardItem(sPage); item->setData(id, Qt::UserRole);
pItem->setData(id,Qt::UserRole); return; // 已处理,直接返回
_pModel->appendRow(pItem);
} }
} }
// 不存在则新增
QStandardItem* pItem = new QStandardItem(sPage);
pItem->setData(id, Qt::UserRole);
_pModel->appendRow(pItem);
} }
void DiagramView::onEditorRbtnClicked(const QPoint &pos) void DiagramView::onEditorRbtnClicked(const QPoint &pos)