fix save bug
This commit is contained in:
parent
c3c73e2153
commit
ccb362defb
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef BASEDRAWINGPANEL_H
|
||||
#define BASEDRAWINGPANEL_H
|
||||
|
||||
/****************工程模和运行时panel的基类*****************/
|
||||
/****************组态panel的基类*****************/
|
||||
|
||||
#include <QWidget>
|
||||
#include <QHBoxLayout>
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ private:
|
|||
void updateShowLabel(QStringList lst);
|
||||
void updateLables();
|
||||
void deleteRowWithReindex(int row);
|
||||
void reorderMapAndUpdateIndices(int startRow);
|
||||
private:
|
||||
Ui::ctExtraInfoDlg *ui;
|
||||
QMap<QString,CtExtraInfo> _mapCT;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ protected:
|
|||
void addTableRow(QString sRatioRange,QString sAccuracy,QString sVolume,QString sStar,double dRatio,bool bPolarity,int index = -1);
|
||||
private:
|
||||
void deleteRowWithReindex(int row);
|
||||
void reorderMapAndUpdateIndices(int startRow);
|
||||
private:
|
||||
Ui::ptExtraInfoDlg *ui;
|
||||
QMap<QString,PtExtraInfo> _mapPT;
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ QMap<QString,PropertyStateInfo> CtExtraInfoDlg::getPropertyValue(BaseProperty* p
|
|||
else if(info.name == "相数" || info.tagName == "phase_num")
|
||||
{
|
||||
if(ui->rb_tpt_ct->isChecked())
|
||||
info.defaultValue = 1;
|
||||
info.defaultValue = QVariant(1);
|
||||
else
|
||||
info.defaultValue = 0;
|
||||
info.defaultValue = QVariant(0);
|
||||
}
|
||||
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)
|
||||
{
|
||||
if(_mapCT.contains(QString::number(index)))
|
||||
/*if(_mapCT.contains(QString::number(index)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -255,13 +255,49 @@ void CtExtraInfoDlg::addTableRow(QString sRatioRange,QString sAccuracy,QString s
|
|||
info.polarity = bPolarity? 1 : -1;
|
||||
_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();
|
||||
}
|
||||
|
||||
void CtExtraInfoDlg::updateShowLabel(QStringList 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()
|
||||
|
|
@ -276,7 +312,7 @@ void CtExtraInfoDlg::updateLables()
|
|||
|
||||
void CtExtraInfoDlg::deleteRowWithReindex(int row) {
|
||||
// 1. 获取要删除的ID
|
||||
QTableWidgetItem* pFirstItem = ui->tb_ct->item(row, 0);
|
||||
/*QTableWidgetItem* pFirstItem = ui->tb_ct->item(row, 0);
|
||||
if (!pFirstItem) return;
|
||||
|
||||
int deletedId = pFirstItem->data(Qt::UserRole).toInt();
|
||||
|
|
@ -291,39 +327,42 @@ void CtExtraInfoDlg::deleteRowWithReindex(int row) {
|
|||
}
|
||||
|
||||
// 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();
|
||||
for (int r = 0; r < totalRows; ++r)
|
||||
{
|
||||
int newIndex = r + 1;
|
||||
|
||||
// 遍历从startRow开始的所有行
|
||||
for (int row = startRow; row < totalRows; ++row) {
|
||||
QTableWidgetItem* idItem = ui->tb_ct->item(row, 0);
|
||||
if (!idItem) continue;
|
||||
CtExtraInfo info;
|
||||
info.index = newIndex;
|
||||
info.scope = ui->tb_ct->item(r, 1)->text();
|
||||
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 currentKey = QString::number(currentId);
|
||||
QString key = QString::number(newIndex);
|
||||
|
||||
// 计算新的ID和索引
|
||||
int newId = row + 1; // 新的ID
|
||||
int newIndex = row + 1; // 新的索引
|
||||
_mapCT[key] = info;
|
||||
|
||||
if (_mapCT.contains(currentKey)) {
|
||||
// 获取并更新数据
|
||||
CtExtraInfo info = _mapCT[currentKey];
|
||||
info.index = newIndex;
|
||||
|
||||
// 从旧位置移除
|
||||
_mapCT.remove(currentKey);
|
||||
|
||||
// 添加到新位置
|
||||
QString newKey = QString::number(newId);
|
||||
_mapCT[newKey] = info;
|
||||
|
||||
// 更新表格显示
|
||||
idItem->setText(QString::number(newId));
|
||||
idItem->setData(Qt::UserRole, newId);
|
||||
// 更新显示
|
||||
auto* idItem = ui->tb_ct->item(r, 0);
|
||||
if (idItem) {
|
||||
idItem->setText(key);
|
||||
idItem->setData(Qt::UserRole, newIndex);
|
||||
}
|
||||
}
|
||||
|
||||
updateLables();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1186,7 +1186,6 @@ void FixedPortsModel::saveNode(int nPageId)
|
|||
}
|
||||
|
||||
QMap<QUuid,GraphicsProjectModelItem*> mapItems = allItems();
|
||||
bool updated = false;
|
||||
for(auto& pItem:mapItems)
|
||||
{
|
||||
BaseProperty* pData = dynamic_cast<BaseProperty*>(pItem->getProperty());
|
||||
|
|
@ -1216,10 +1215,7 @@ void FixedPortsModel::saveNode(int nPageId)
|
|||
VariableProperty* pVariable = dynamic_cast<VariableProperty*>(pData);
|
||||
if(pVariable)
|
||||
{
|
||||
bool useCatch = updated?true:false;
|
||||
ModelDataInfo& dataInfo = pVariable->getPropertyValue(useCatch);
|
||||
if(updated == false)
|
||||
updated = true;
|
||||
ModelDataInfo& dataInfo = pVariable->getPropertyValue(true);
|
||||
QString tempTag = pData->tag()+"-"+_pageName+pData->getBay(); //tag后加工程名使得全局唯一
|
||||
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)
|
||||
|
|
@ -2055,7 +2052,7 @@ void FixedPortsModel::updateItemLinePort(QUuid uid,ModelFunctionType type)
|
|||
void FixedPortsModel::showModelDlg(const QString& sName,QUuid uuid,GraphicsProjectModelItem* pItem)
|
||||
{
|
||||
ModelStateInfo stateInfo = _modelStateInfo[sName];
|
||||
ModelDataMap mapData = DataManager::instance().modelData();
|
||||
ModelDataMap mapData = DataManager::instance().modelData(true);
|
||||
ItemPropertyDlg* pDlg = dynamic_cast<ItemPropertyDlg*>(stateInfo._PropertyDlg);
|
||||
if(pDlg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
if(_mapPT.contains(QString::number(index)))
|
||||
/*if(_mapPT.contains(QString::number(index)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -254,12 +254,44 @@ void PtExtraInfoDlg::addTableRow(QString sRatioRange,QString sAccuracy,QString s
|
|||
info.star = sStar;
|
||||
info.ratio = dRatio;
|
||||
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) {
|
||||
// 1. 获取要删除的ID
|
||||
QTableWidgetItem* pFirstItem = ui->tb_pt->item(row, 0);
|
||||
/*QTableWidgetItem* pFirstItem = ui->tb_pt->item(row, 0);
|
||||
if (!pFirstItem) return;
|
||||
|
||||
int deletedId = pFirstItem->data(Qt::UserRole).toInt();
|
||||
|
|
@ -274,39 +306,40 @@ void PtExtraInfoDlg::deleteRowWithReindex(int row) {
|
|||
}
|
||||
|
||||
// 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();
|
||||
for (int r = 0; r < totalRows; ++r)
|
||||
{
|
||||
int newIndex = r + 1;
|
||||
|
||||
// 遍历从startRow开始的所有行
|
||||
for (int row = startRow; row < totalRows; ++row) {
|
||||
QTableWidgetItem* idItem = ui->tb_pt->item(row, 0);
|
||||
if (!idItem) continue;
|
||||
PtExtraInfo info;
|
||||
info.index = newIndex;
|
||||
info.scope = ui->tb_pt->item(r, 1)->text();
|
||||
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 currentKey = QString::number(currentId);
|
||||
QString key = QString::number(newIndex);
|
||||
_mapPT[key] = info;
|
||||
|
||||
// 计算新的ID和索引
|
||||
int newId = row + 1; // 新的ID
|
||||
int newIndex = row + 1; // 新的索引
|
||||
|
||||
if (_mapPT.contains(currentKey)) {
|
||||
// 获取并更新数据
|
||||
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);
|
||||
// 更新显示
|
||||
auto* idItem = ui->tb_pt->item(r, 0);
|
||||
if (idItem) {
|
||||
idItem->setText(key);
|
||||
idItem->setData(Qt::UserRole, newIndex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@
|
|||
</property>
|
||||
<item row="0" column="0" colspan="17">
|
||||
<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">
|
||||
<size>
|
||||
<width>0</width>
|
||||
|
|
@ -45,6 +51,9 @@
|
|||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ bool DataBase::updateComponent(QUuid uuid,QString tag,QString name,QJsonObject c
|
|||
QJsonDocument contextDoc(context);
|
||||
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(1,name);
|
||||
qry.bindValue(2,strCon);
|
||||
|
|
@ -3028,171 +3028,144 @@ PropertyValueInfo DataBase::selectGroupPropertyByValue(const QString& tableName,
|
|||
QList<MeasureAttributeType> DataBase::getMeasureAttributeTypes() //暂时调换获取的name与tag
|
||||
{
|
||||
QList<MeasureAttributeType> lst;
|
||||
QString strSQL = "SELECT attribute,attribute_name FROM basic.attribute WHERE is_visible = ?";
|
||||
QVariantList params;
|
||||
params.append(2);
|
||||
|
||||
const QString strSQL =
|
||||
"SELECT attribute, attribute_name FROM basic.attribute WHERE is_visible = ?";
|
||||
|
||||
QVariantList params{2};
|
||||
|
||||
try
|
||||
{
|
||||
QSqlQuery query = executeSQL(strSQL,false,params);
|
||||
QSqlQuery query = executeSQL(strSQL, false, params);
|
||||
|
||||
while (query.next())
|
||||
{
|
||||
QString attName = query.value(0).toString();
|
||||
QString attTag = query.value(1).toString();
|
||||
QString attTag = query.value(1).toString();
|
||||
|
||||
if(attName.contains("$")){ //包含$
|
||||
QStringList lst_dollar;
|
||||
lst_dollar<<"s1"<<"s2"<<"s3";
|
||||
if(attName.contains("sn")){ //同时包含$与sn,9个分支
|
||||
QStringList lst_sn;
|
||||
lst_sn<<"s1"<<"s2"<<"s3";
|
||||
const QChar firstChar = attName.isEmpty() ? QChar() : attName.at(0);
|
||||
const bool hasDollar = attName.contains("$");
|
||||
const bool hasUnderDollar = attName.contains("_$");
|
||||
const bool hasSn = attName.contains("sn");
|
||||
|
||||
if(attName.contains("_$")){ //包含_$,特殊处理
|
||||
if(attName.first(1) == "I"){ //头字母为I
|
||||
QStringList lst_I;
|
||||
lst_I<<"a"<<"b"<<"c";
|
||||
/* ========== 规则 1:_$ ========== */
|
||||
if (hasUnderDollar)
|
||||
{
|
||||
QStringList underDollarValues;
|
||||
|
||||
for(auto &i:lst_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")){ //只包含sn,3种分支
|
||||
QStringList lst_sn;
|
||||
lst_sn<<"s1"<<"s2"<<"s3";
|
||||
|
||||
for(auto &sn:lst_sn)
|
||||
if (firstChar == 'I')
|
||||
{
|
||||
QString name = attName;
|
||||
QString tag = attTag;
|
||||
underDollarValues = QStringList{"a", "b", "c"};
|
||||
}
|
||||
else // U
|
||||
{
|
||||
underDollarValues = QStringList{"ab", "bc", "ca"}; // ✅ 已修正
|
||||
}
|
||||
|
||||
MeasureAttributeType measure;
|
||||
measure.tag = name.replace("sn",sn);
|
||||
measure.name = tag.replace("sn",sn);
|
||||
lst.append(measure);
|
||||
if (hasSn)
|
||||
{
|
||||
for (const QString& u : underDollarValues)
|
||||
{
|
||||
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{ //没有分支
|
||||
MeasureAttributeType measure;
|
||||
measure.tag = attName;
|
||||
measure.name = attTag;
|
||||
lst.append(measure);
|
||||
/* ========== 规则 2:$ ========== */
|
||||
else if (hasDollar)
|
||||
{
|
||||
QStringList dollarValues =
|
||||
(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();
|
||||
return lst;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/************************************运行模式*********************************************/
|
||||
|
|
|
|||
|
|
@ -202,13 +202,17 @@ void DiagramView::onItemClicked(const QModelIndex &index)
|
|||
void DiagramView::onPageSaved(const QString sPage,int id)
|
||||
{
|
||||
for (int row = 0; row < _pModel->rowCount(); ++row) {
|
||||
QStandardItem *item = _pModel->item(row, 0);
|
||||
if (item && item->data(Qt::DisplayRole) == sPage) {
|
||||
QStandardItem* pItem = new QStandardItem(sPage);
|
||||
pItem->setData(id,Qt::UserRole);
|
||||
_pModel->appendRow(pItem);
|
||||
QStandardItem* item = _pModel->item(row, 0);
|
||||
if (item && item->text() == sPage) {
|
||||
item->setData(id, Qt::UserRole);
|
||||
return; // 已处理,直接返回
|
||||
}
|
||||
}
|
||||
|
||||
// 不存在则新增
|
||||
QStandardItem* pItem = new QStandardItem(sPage);
|
||||
pItem->setData(id, Qt::UserRole);
|
||||
_pModel->appendRow(pItem);
|
||||
}
|
||||
|
||||
void DiagramView::onEditorRbtnClicked(const QPoint &pos)
|
||||
|
|
|
|||
Loading…
Reference in New Issue