|
@@ -1961,6 +1961,47 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
scrollLayout->setSpacing(10);
|
|
|
scrollLayout->setContentsMargins(10, 10, 10, 10);
|
|
|
|
|
|
+ QHBoxLayout* fieldLayout = new QHBoxLayout;
|
|
|
+ fieldLayout->setSpacing(5);
|
|
|
+
|
|
|
+ QPushButton* btnSave = new QPushButton(QStringLiteral("保存"));
|
|
|
+ btnSave->setFixedSize(80, 28);
|
|
|
+ btnSave->setStyleSheet(R"(
|
|
|
+ QPushButton {
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #BABBDC;
|
|
|
+ border-radius: 5px;
|
|
|
+ }
|
|
|
+ QPushButton:hover {
|
|
|
+ background-color: #F0F0F0;
|
|
|
+ }
|
|
|
+ )");
|
|
|
+ m_fieldWidgets.append(btnSave);
|
|
|
+
|
|
|
+ connect(btnSave, &QPushButton::clicked, this, [=]() {
|
|
|
+ if (modifiedLabels.isEmpty()) {
|
|
|
+ QMessageBox::information(this, "提示", "没有任何组件被修改!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int ret = QMessageBox::question(this, "保存确认", "检测到修改内容,是否保存?",
|
|
|
+ QMessageBox::Yes | QMessageBox::No);
|
|
|
+
|
|
|
+ if (ret == QMessageBox::Yes) {
|
|
|
+ emit saveClicked();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ fieldLayout->addWidget(btnSave);
|
|
|
+ scrollLayout->addLayout(fieldLayout);
|
|
|
+
|
|
|
+ QFrame* separator = createUnifiedSeparator(scrollWidget, 2);
|
|
|
+ QHBoxLayout* separatorLayout = new QHBoxLayout;
|
|
|
+ separatorLayout->setContentsMargins(0, 5, 0, 5);
|
|
|
+ separatorLayout->addWidget(separator);
|
|
|
+ scrollLayout->addLayout(separatorLayout);
|
|
|
+ separator->show();
|
|
|
+
|
|
|
//不同表格的全部插进来
|
|
|
int previousGroupId = -1;
|
|
|
QList<CONFIG_BASE_STRUCT> buttonControls;
|
|
@@ -1982,6 +2023,7 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
QString fieldDescribe = QString::fromStdString(control.strDescribe);
|
|
|
QString fieldType = QString::fromStdString(control.strType);
|
|
|
QString fieldValue = QString::fromStdString(control.strValue);
|
|
|
+ QString fieldDefult = QString::fromStdString(control.strDefult);
|
|
|
QString fieldUpLimit = QString::fromStdString(control.strUpperLimit);
|
|
|
QString fieldDownLimit = QString::fromStdString(control.strLowerLimit);
|
|
|
QString fieldUnits = QString::fromStdString(control.strUnit);
|
|
@@ -2095,51 +2137,142 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
m_fieldWidgets.append(unitLabel);
|
|
|
createdWidget = inputWidget;
|
|
|
// // 连接 textChanged 信号到 lambda 函数
|
|
|
- connect(lineEdit, &QLineEdit::textChanged, [this, lineEdit, fieldTableName, fieldName, fieldUpLimit, fieldDownLimit]() {
|
|
|
- if ((fieldUpLimit != "") && (fieldDownLimit != ""))
|
|
|
- {
|
|
|
- int uplimit = fieldUpLimit.toInt();
|
|
|
- int downlimit = fieldDownLimit.toInt();
|
|
|
- int inputvalue = (lineEdit->text()).toInt();
|
|
|
- if ((inputvalue <= uplimit) && (inputvalue >= downlimit))
|
|
|
- {
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
- //updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
- } else
|
|
|
- {
|
|
|
- lineEdit->setPlaceholderText(tr("超出设定范围,请重新输入"));
|
|
|
- }
|
|
|
- } else if (fieldDownLimit != "")
|
|
|
- {
|
|
|
- int downlimit = fieldDownLimit.toInt();
|
|
|
- int inputvalue = (lineEdit->text()).toInt();
|
|
|
- if (inputvalue >= downlimit)
|
|
|
- {
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
- //updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
- } else
|
|
|
- {
|
|
|
- lineEdit->setPlaceholderText(tr("超出设定范围,请重新输入"));
|
|
|
- }
|
|
|
- } else if (fieldUpLimit != "")
|
|
|
- {
|
|
|
- int uplimit = fieldUpLimit.toInt();
|
|
|
- int inputvalue = (lineEdit->text()).toInt();
|
|
|
- if (inputvalue <= uplimit)
|
|
|
- {
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
- //updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
- } else
|
|
|
- {
|
|
|
- lineEdit->setPlaceholderText(tr("超出设定范围,请重新输入"));
|
|
|
- }
|
|
|
- } else
|
|
|
- {
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
- //updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
+ //connect(lineEdit, &QLineEdit::textChanged, [this, lineEdit, fieldTableName, fieldName, fieldUpLimit, fieldDownLimit]() {
|
|
|
+ // if ((fieldUpLimit != "") && (fieldDownLimit != ""))
|
|
|
+ // {
|
|
|
+ // int uplimit = fieldUpLimit.toInt();
|
|
|
+ // int downlimit = fieldDownLimit.toInt();
|
|
|
+ // int inputvalue = (lineEdit->text()).toInt();
|
|
|
+ // if ((inputvalue <= uplimit) && (inputvalue >= downlimit))
|
|
|
+ // {
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
+ // //updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
+ // } else
|
|
|
+ // {
|
|
|
+ // lineEdit->setPlaceholderText(tr("超出设定范围,请重新输入"));
|
|
|
+ // }
|
|
|
+ // } else if (fieldDownLimit != "")
|
|
|
+ // {
|
|
|
+ // int downlimit = fieldDownLimit.toInt();
|
|
|
+ // int inputvalue = (lineEdit->text()).toInt();
|
|
|
+ // if (inputvalue >= downlimit)
|
|
|
+ // {
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
+ // //updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
+ // } else
|
|
|
+ // {
|
|
|
+ // lineEdit->setPlaceholderText(tr("超出设定范围,请重新输入"));
|
|
|
+ // }
|
|
|
+ // } else if (fieldUpLimit != "")
|
|
|
+ // {
|
|
|
+ // int uplimit = fieldUpLimit.toInt();
|
|
|
+ // int inputvalue = (lineEdit->text()).toInt();
|
|
|
+ // if (inputvalue <= uplimit)
|
|
|
+ // {
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
+ // //updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
+ // } else
|
|
|
+ // {
|
|
|
+ // lineEdit->setPlaceholderText(tr("超出设定范围,请重新输入"));
|
|
|
+ // }
|
|
|
+ // } else
|
|
|
+ // {
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
+ // //updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
+ // }
|
|
|
+
|
|
|
+ // });
|
|
|
+ connect(lineEdit, &QLineEdit::textChanged, [this, lineEdit, fieldUpLimit, fieldDownLimit, label]() {
|
|
|
+ if ((fieldUpLimit != "") && (fieldDownLimit != ""))
|
|
|
+ {
|
|
|
+ int uplimit = fieldUpLimit.toInt();
|
|
|
+ int downlimit = fieldDownLimit.toInt();
|
|
|
+ int inputvalue = (lineEdit->text()).toInt();
|
|
|
+ if ((inputvalue <= uplimit) && (inputvalue >= downlimit))
|
|
|
+ {
|
|
|
+ label->setProperty("value", lineEdit->text());
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
+ //updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lineEdit->setPlaceholderText(tr("超出设定范围,请重新输入"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (fieldDownLimit != "")
|
|
|
+ {
|
|
|
+ int downlimit = fieldDownLimit.toInt();
|
|
|
+ int inputvalue = (lineEdit->text()).toInt();
|
|
|
+ if (inputvalue >= downlimit)
|
|
|
+ {
|
|
|
+ label->setProperty("value", lineEdit->text());
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
+ //updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lineEdit->setPlaceholderText(tr("超出设定范围,请重新输入"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (fieldUpLimit != "")
|
|
|
+ {
|
|
|
+ int uplimit = fieldUpLimit.toInt();
|
|
|
+ int inputvalue = (lineEdit->text()).toInt();
|
|
|
+ if (inputvalue <= uplimit)
|
|
|
+ {
|
|
|
+ label->setProperty("value", lineEdit->text());
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
+ //updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lineEdit->setPlaceholderText(tr("超出设定范围,请重新输入"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ label->setProperty("value", lineEdit->text());
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
+ //updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
|
|
|
+ if (modifiedLabels.contains(label)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
|
|
|
+ label->setStyleSheet("color: black;");
|
|
|
+ modifiedLabels.remove(label);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
|
|
|
+ btnDefault->setFixedSize(60, 28);
|
|
|
+ btnDefault->setStyleSheet(R"(
|
|
|
+ QPushButton {
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #BABBDC;
|
|
|
+ border-radius: 5px;
|
|
|
}
|
|
|
-
|
|
|
- });
|
|
|
+ QPushButton:hover {
|
|
|
+ background-color: #F0F0F0;
|
|
|
+ }
|
|
|
+ )");
|
|
|
+ rightLayout->addWidget(btnDefault);
|
|
|
+
|
|
|
+ connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, lineEdit]() {
|
|
|
+ if (!fieldDefult.isEmpty()) {
|
|
|
+ lineEdit->setText(fieldDefult);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -2159,10 +2292,47 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
rightLayout->addWidget(lineEdit1);
|
|
|
createdWidget = lineEdit1;
|
|
|
// // 连接 textChanged 信号到 lambda 函数
|
|
|
- connect(lineEdit1, &QLineEdit::textChanged, [this, lineEdit1, fieldTableName, fieldName]() {
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit1->text());
|
|
|
+ //connect(lineEdit1, &QLineEdit::textChanged, [this, lineEdit1, fieldTableName, fieldName]() {
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit1->text());
|
|
|
+ // //updateDb(fieldTableName, fieldId, lineEdit1->text());
|
|
|
+ // loginput(fieldTableName, fieldName, lineEdit1->text());
|
|
|
+ // });
|
|
|
+ connect(lineEdit1, &QLineEdit::textChanged, [this, lineEdit1, label]() {
|
|
|
+ label->setProperty("value", lineEdit1->text());
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit1->text());
|
|
|
//updateDb(fieldTableName, fieldId, lineEdit1->text());
|
|
|
- loginput(fieldTableName, fieldName, lineEdit1->text());
|
|
|
+ // loginput(fieldTableName, fieldName, lineEdit1->text());
|
|
|
+ });
|
|
|
+
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
|
|
|
+ if (modifiedLabels.contains(label)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
|
|
|
+ loginput(fieldTableName, fieldName, label->property("value").toString());
|
|
|
+ label->setStyleSheet("color: black;");
|
|
|
+ modifiedLabels.remove(label);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
|
|
|
+ btnDefault->setFixedSize(60, 28);
|
|
|
+ btnDefault->setStyleSheet(R"(
|
|
|
+ QPushButton {
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #BABBDC;
|
|
|
+ border-radius: 5px;
|
|
|
+ }
|
|
|
+ QPushButton:hover {
|
|
|
+ background-color: #F0F0F0;
|
|
|
+ }
|
|
|
+ )");
|
|
|
+ rightLayout->addWidget(btnDefault);
|
|
|
+
|
|
|
+ connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, lineEdit1]() {
|
|
|
+ if (!fieldDefult.isEmpty()) {
|
|
|
+ lineEdit1->setText(fieldDefult);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -2187,15 +2357,60 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
}
|
|
|
}
|
|
|
// 使用Lambda函数连接 buttonToggled 信号
|
|
|
- connect(radioGroup, static_cast<void (QButtonGroup::*)(QAbstractButton*, bool)>(&QButtonGroup::buttonToggled), [this, fieldTableName, fieldName](QAbstractButton* button, bool checked) {
|
|
|
+ //connect(radioGroup, static_cast<void (QButtonGroup::*)(QAbstractButton*, bool)>(&QButtonGroup::buttonToggled), [this, fieldTableName, fieldName](QAbstractButton* button, bool checked) {
|
|
|
+ // if (checked)
|
|
|
+ // {
|
|
|
+ // // qDebug() << "Button toggled:" << button->text();
|
|
|
+ // // 在这里添加你想要执行的操作
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, button->text());
|
|
|
+ // //updateDb(fieldTableName, fieldId, button->text());
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ connect(radioGroup, static_cast<void (QButtonGroup::*)(QAbstractButton*, bool)>(&QButtonGroup::buttonToggled), [this, label](QAbstractButton* button, bool checked) {
|
|
|
if (checked)
|
|
|
{
|
|
|
+ label->setProperty("value", button->text());
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
// qDebug() << "Button toggled:" << button->text();
|
|
|
// 在这里添加你想要执行的操作
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, button->text());
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, button->text());
|
|
|
//updateDb(fieldTableName, fieldId, button->text());
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
|
|
|
+ if (modifiedLabels.contains(label)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
|
|
|
+ label->setStyleSheet("color: black;");
|
|
|
+ modifiedLabels.remove(label);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
|
|
|
+ btnDefault->setFixedSize(60, 28);
|
|
|
+ btnDefault->setStyleSheet(R"(
|
|
|
+ QPushButton {
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #BABBDC;
|
|
|
+ border-radius: 5px;
|
|
|
+ }
|
|
|
+ QPushButton:hover {
|
|
|
+ background-color: #F0F0F0;
|
|
|
+ }
|
|
|
+ )");
|
|
|
+ rightLayout->addWidget(btnDefault);
|
|
|
+
|
|
|
+ connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, radioGroup]() {
|
|
|
+ if (!fieldDefult.isEmpty()) {
|
|
|
+ for (QAbstractButton* button : radioGroup->buttons()) {
|
|
|
+ if (button->text() == fieldDefult) {
|
|
|
+ button->setChecked(true);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
rightLayout->addLayout(radioLayout);
|
|
|
}
|
|
|
else if (fieldType == "checkbox" || fieldType == "BOOL")
|
|
@@ -2230,28 +2445,93 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
)");
|
|
|
rightLayout->addWidget(checkBox);
|
|
|
createdWidget = checkBox;
|
|
|
- connect(checkBox, &QCheckBox::stateChanged, [this, fieldTableName, fieldName](int state) {
|
|
|
+ //connect(checkBox, &QCheckBox::stateChanged, [this, fieldTableName, fieldName](int state) {
|
|
|
+ // if (state == Qt::Checked)
|
|
|
+ // {
|
|
|
+ // // qDebug() << "CheckBox is checked"<<fieldId;
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, "1");
|
|
|
+ // //updateDb(fieldTableName, fieldId, "1");
|
|
|
+ // } else if (state == Qt::Unchecked)
|
|
|
+ // {
|
|
|
+ // // qDebug() << "CheckBox is unchecked"<<fieldId;
|
|
|
+ // // 在这里添加你想要执行的操作
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, "0");
|
|
|
+ // //updateDb(fieldTableName, fieldId, "0");
|
|
|
+ // } else if (state == Qt::PartiallyChecked)
|
|
|
+ // {
|
|
|
+ // qDebug() << "CheckBox is partially checked";
|
|
|
+ // // 在这里添加你想要执行的操作
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ connect(checkBox, &QCheckBox::stateChanged, [this, label](int state) {
|
|
|
if (state == Qt::Checked)
|
|
|
{
|
|
|
// qDebug() << "CheckBox is checked"<<fieldId;
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, "1");
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, "1");
|
|
|
//updateDb(fieldTableName, fieldId, "1");
|
|
|
- } else if (state == Qt::Unchecked)
|
|
|
+ label->setProperty("value", "1");
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
+ }
|
|
|
+ else if (state == Qt::Unchecked)
|
|
|
{
|
|
|
// qDebug() << "CheckBox is unchecked"<<fieldId;
|
|
|
// 在这里添加你想要执行的操作
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, "0");
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, "0");
|
|
|
//updateDb(fieldTableName, fieldId, "0");
|
|
|
- } else if (state == Qt::PartiallyChecked)
|
|
|
+ label->setProperty("value", "0");
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
+ }
|
|
|
+ else if (state == Qt::PartiallyChecked)
|
|
|
{
|
|
|
qDebug() << "CheckBox is partially checked";
|
|
|
// 在这里添加你想要执行的操作
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
|
|
|
+ if (modifiedLabels.contains(label)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
|
|
|
+ label->setStyleSheet("color: black;");
|
|
|
+ modifiedLabels.remove(label);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
|
|
|
+ btnDefault->setFixedSize(60, 28);
|
|
|
+ btnDefault->setStyleSheet(R"(
|
|
|
+ QPushButton {
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #BABBDC;
|
|
|
+ border-radius: 5px;
|
|
|
+ }
|
|
|
+ QPushButton:hover {
|
|
|
+ background-color: #F0F0F0;
|
|
|
+ }
|
|
|
+ )");
|
|
|
+ rightLayout->addWidget(btnDefault);
|
|
|
+
|
|
|
+ connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, checkBox]() {
|
|
|
+ if (!fieldDefult.isEmpty()) {
|
|
|
+ if (fieldDefult == "1") {
|
|
|
+ checkBox->setChecked(true);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ checkBox->setChecked(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
else if (fieldType == "ComboBox")
|
|
|
{
|
|
|
- QStringList optionList = fieldValue.split(QRegExp("[,,]"), Qt::SkipEmptyParts);
|
|
|
+ //QStringList optionList = fieldValue.split(QRegExp("[,,]"), Qt::SkipEmptyParts);
|
|
|
+ QJsonArray jsonArray;
|
|
|
+ QJsonParseError parseError;
|
|
|
+ QJsonDocument jsonDoc = QJsonDocument::fromJson(fieldUnits.toUtf8(), &parseError);
|
|
|
+ if (!jsonDoc.isNull() && jsonDoc.isArray()) {
|
|
|
+ jsonArray = jsonDoc.array();
|
|
|
+ }
|
|
|
QComboBox* comboBox = new QComboBox;
|
|
|
comboBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
comboBox->setFixedSize(140, 28);
|
|
@@ -2267,7 +2547,7 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
}
|
|
|
)");
|
|
|
// int newIndex = -1;
|
|
|
- for (const QString& opt : optionList)
|
|
|
+ /*for (const QString& opt : optionList)
|
|
|
{
|
|
|
QString trimmedOpt = opt.trimmed();
|
|
|
if (!trimmedOpt.isEmpty())
|
|
@@ -2279,17 +2559,91 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
} else
|
|
|
{
|
|
|
comboBox->setCurrentIndex(fieldValue.toInt());
|
|
|
+ }*/
|
|
|
+ int matchedIndex = -1;
|
|
|
+ int currentIndex = 0;
|
|
|
+
|
|
|
+ for (const QJsonValue& val : jsonArray) {
|
|
|
+ QJsonObject obj = val.toObject();
|
|
|
+ QString key = obj["key"].toString();
|
|
|
+ QString valueStr = QString::number(obj["value"].toInt()); // 统一转字符串对比
|
|
|
+
|
|
|
+ comboBox->addItem(key);
|
|
|
+
|
|
|
+ if (valueStr == fieldValue.trimmed()) {
|
|
|
+ matchedIndex = currentIndex;
|
|
|
+ }
|
|
|
+ currentIndex++;
|
|
|
}
|
|
|
+ comboBox->setCurrentIndex(matchedIndex != -1 ? matchedIndex : 0);
|
|
|
rightLayout->addWidget(comboBox);
|
|
|
createdWidget = comboBox;
|
|
|
// 使用Lambda函数连接 currentIndexChanged 信号
|
|
|
- connect(comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this, comboBox, fieldTableName, fieldName](int index) {
|
|
|
- QString selectedText = comboBox->itemText(index);
|
|
|
- QString indexString = QString::number(index);
|
|
|
- // qDebug() << "ComboBox index changed to:" << index << "Text:" << selectedText;
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, indexString);
|
|
|
- //updateDb(fieldTableName, fieldId, indexString);
|
|
|
- // 在这里添加你想要执行的操作
|
|
|
+ //connect(comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this, comboBox, fieldTableName, fieldName](int index) {
|
|
|
+ // QString selectedText = comboBox->itemText(index);
|
|
|
+ // QString indexString = QString::number(index);
|
|
|
+ // // qDebug() << "ComboBox index changed to:" << index << "Text:" << selectedText;
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, indexString);
|
|
|
+ // //updateDb(fieldTableName, fieldId, indexString);
|
|
|
+ // // 在这里添加你想要执行的操作
|
|
|
+ // });
|
|
|
+ connect(comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
|
+ [this, comboBox, jsonArray, label](int index) {
|
|
|
+ QString selectedText = comboBox->itemText(index);
|
|
|
+ QString valueString;
|
|
|
+ for (const QJsonValue& val : jsonArray) {
|
|
|
+ QJsonObject obj = val.toObject();
|
|
|
+ if (obj["key"].toString() == selectedText) {
|
|
|
+ valueString = QString::number(obj["value"].toInt());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, valueString);
|
|
|
+ label->setProperty("value", valueString);
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
+ });
|
|
|
+
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
|
|
|
+ if (modifiedLabels.contains(label)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
|
|
|
+ label->setStyleSheet("color: black;");
|
|
|
+ modifiedLabels.remove(label);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
|
|
|
+ btnDefault->setFixedSize(60, 28);
|
|
|
+ btnDefault->setStyleSheet(R"(
|
|
|
+ QPushButton {
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #BABBDC;
|
|
|
+ border-radius: 5px;
|
|
|
+ }
|
|
|
+ QPushButton:hover {
|
|
|
+ background-color: #F0F0F0;
|
|
|
+ }
|
|
|
+ )");
|
|
|
+ rightLayout->addWidget(btnDefault);
|
|
|
+
|
|
|
+ connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, comboBox, jsonArray]() {
|
|
|
+ if (!fieldDefult.isEmpty()) {
|
|
|
+ int matchedIndex = -1;
|
|
|
+ int currentIndex = 0;
|
|
|
+
|
|
|
+ for (const QJsonValue& val : jsonArray) {
|
|
|
+ QJsonObject obj = val.toObject();
|
|
|
+ QString key = obj["key"].toString();
|
|
|
+ QString valueStr = QString::number(obj["value"].toInt());
|
|
|
+
|
|
|
+ if (valueStr == fieldDefult.trimmed()) {
|
|
|
+ matchedIndex = currentIndex;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ currentIndex++;
|
|
|
+ }
|
|
|
+ comboBox->setCurrentIndex(matchedIndex != -1 ? matchedIndex : 0);
|
|
|
+ }
|
|
|
});
|
|
|
} else if (fieldType == "time")
|
|
|
{
|
|
@@ -2308,6 +2662,40 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
timeEdit->setTime(QTime::fromString(fieldValue, "HH:mm:ss"));
|
|
|
rightLayout->addWidget(timeEdit);
|
|
|
createdWidget = timeEdit;
|
|
|
+ connect(timeEdit, &QTimeEdit::timeChanged, [this, timeEdit, label]() {
|
|
|
+ QString timeString = timeEdit->time().toString("HH:mm:ss");
|
|
|
+ label->setProperty("value", timeString);
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
+ });
|
|
|
+
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
|
|
|
+ if (modifiedLabels.contains(label)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
|
|
|
+ label->setStyleSheet("color: black;");
|
|
|
+ modifiedLabels.remove(label);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
|
|
|
+ btnDefault->setFixedSize(60, 28);
|
|
|
+ btnDefault->setStyleSheet(R"(
|
|
|
+ QPushButton {
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #BABBDC;
|
|
|
+ border-radius: 5px;
|
|
|
+ }
|
|
|
+ QPushButton:hover {
|
|
|
+ background-color: #F0F0F0;
|
|
|
+ }
|
|
|
+ )");
|
|
|
+ rightLayout->addWidget(btnDefault);
|
|
|
+
|
|
|
+ connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, timeEdit]() {
|
|
|
+ if (!fieldDefult.isEmpty()) {
|
|
|
+ timeEdit->setTime(QTime::fromString(fieldDefult, "HH:mm:ss"));
|
|
|
+ }
|
|
|
+ });
|
|
|
} else if (fieldType == "switch")
|
|
|
{
|
|
|
QWidget* switchContainer = new QWidget;
|
|
@@ -2347,19 +2735,74 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
QLabel* switchLabel = new QLabel(switchBox->isChecked() ? tr("开") :tr("关"));
|
|
|
switchLabel->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
|
|
switchLabel->setStyleSheet("font-size: 14px;");
|
|
|
- connect(switchBox, &QCheckBox::stateChanged, [fieldTableName, fieldName, switchLabel, this](int state) {
|
|
|
+ //connect(switchBox, &QCheckBox::stateChanged, [fieldTableName, fieldName, switchLabel, this](int state) {
|
|
|
+ // if (state == Qt::Checked)
|
|
|
+ // {
|
|
|
+ // switchLabel->setText(tr("开"));
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, "on");
|
|
|
+ // //updateDb(fieldTableName, fieldId, "on");
|
|
|
+ // } else
|
|
|
+ // {
|
|
|
+ // switchLabel->setText(tr("关"));
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, "off");
|
|
|
+ // //updateDb(fieldTableName, fieldId, "off");
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ connect(switchBox, &QCheckBox::stateChanged, [switchLabel, this, label](int state) {
|
|
|
if (state == Qt::Checked)
|
|
|
{
|
|
|
switchLabel->setText(tr("开"));
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, "on");
|
|
|
+ label->setProperty("value", "on");
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, "on");
|
|
|
//updateDb(fieldTableName, fieldId, "on");
|
|
|
- } else
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
switchLabel->setText(tr("关"));
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, "off");
|
|
|
+ label->setProperty("value", "off");
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
+ // m_sqlOper->updateControlData(fieldTableName, fieldName, "off");
|
|
|
//updateDb(fieldTableName, fieldId, "off");
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
|
|
|
+ if (modifiedLabels.contains(label)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
|
|
|
+ label->setStyleSheet("color: black;");
|
|
|
+ modifiedLabels.remove(label);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
|
|
|
+ btnDefault->setFixedSize(60, 28);
|
|
|
+ btnDefault->setStyleSheet(R"(
|
|
|
+ QPushButton {
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #BABBDC;
|
|
|
+ border-radius: 5px;
|
|
|
+ }
|
|
|
+ QPushButton:hover {
|
|
|
+ background-color: #F0F0F0;
|
|
|
+ }
|
|
|
+ )");
|
|
|
+ rightLayout->addWidget(btnDefault);
|
|
|
+
|
|
|
+ connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, switchBox, switchLabel]() {
|
|
|
+ if (!fieldDefult.isEmpty()) {
|
|
|
+ if (fieldDefult == "on") {
|
|
|
+ switchBox->setChecked(true);
|
|
|
+ switchLabel->setText(tr("开"));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ switchBox->setChecked(false);
|
|
|
+ switchLabel->setText(tr("关"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
switchLayout->addWidget(switchBox);
|
|
|
switchLayout->addWidget(switchLabel);
|
|
|
rightLayout->addWidget(switchContainer);
|
|
@@ -2499,7 +2942,39 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
|
|
|
m_veCombinedCont.push_back(_a);
|
|
|
|
|
|
+ connect(comboInput, &QLineEdit::textChanged, [this, comboInput, label]() {
|
|
|
+ label->setProperty("value", comboInput->text());
|
|
|
+ label->setStyleSheet("color: #5c63be;");
|
|
|
+ modifiedLabels.insert(label);
|
|
|
+ });
|
|
|
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
|
|
|
+ if (modifiedLabels.contains(label)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
|
|
|
+ label->setStyleSheet("color: black;");
|
|
|
+ modifiedLabels.remove(label);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
|
|
|
+ btnDefault->setFixedSize(60, 28);
|
|
|
+ btnDefault->setStyleSheet(R"(
|
|
|
+ QPushButton {
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #BABBDC;
|
|
|
+ border-radius: 5px;
|
|
|
+ }
|
|
|
+ QPushButton:hover {
|
|
|
+ background-color: #F0F0F0;
|
|
|
+ }
|
|
|
+ )");
|
|
|
+ rightLayout->addWidget(btnDefault);
|
|
|
+
|
|
|
+ connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, comboInput]() {
|
|
|
+ if (!fieldDefult.isEmpty()) {
|
|
|
+ comboInput->setText(fieldDefult);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
} else if (fieldType == "Text")
|
|
|
{
|