|
@@ -2071,7 +2071,7 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
scrollLayout->addLayout(separatorLayout);
|
|
|
separator->show();
|
|
|
|
|
|
- languageValue = gen_if.getLanguageValue();
|
|
|
+ m_nLanguageSwitch = gen_if.getLanguageValue();
|
|
|
|
|
|
//不同表格的全部插进来
|
|
|
int previousGroupId = -1;
|
|
@@ -2120,34 +2120,15 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
}
|
|
|
previousGroupId = groupId;
|
|
|
|
|
|
- // 每个字段一行
|
|
|
+ // 每个控件的行
|
|
|
QHBoxLayout* fieldLayout = new QHBoxLayout;
|
|
|
fieldLayout->setSpacing(5);
|
|
|
+ QLabel* pFieldDescribeLabel = JIoMapPage::JCreateName0(fieldDescribe, fieldDescribe_Eng,m_nLanguageSwitch);
|
|
|
|
|
|
- QLabel* label = new QLabel();
|
|
|
- if (languageValue == 0)
|
|
|
- {
|
|
|
- label->setText(fieldDescribe_Eng);
|
|
|
- if (fieldDescribe_Eng.isEmpty())
|
|
|
- {
|
|
|
- label->setText(fieldDescribe);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- label->setText(fieldDescribe);
|
|
|
- if (fieldDescribe.isEmpty())
|
|
|
- {
|
|
|
- label->setText(fieldDescribe_Eng);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
|
|
- label->setFixedHeight(24);
|
|
|
- label->setMinimumWidth(120);
|
|
|
- fieldLayout->addWidget(label);
|
|
|
+ fieldLayout->addWidget(pFieldDescribeLabel);
|
|
|
fieldLayout->addStretch(1);
|
|
|
|
|
|
+ //这个是侧边的小部件
|
|
|
QWidget* rightWidget = new QWidget;
|
|
|
QHBoxLayout* rightLayout = new QHBoxLayout(rightWidget);
|
|
|
rightLayout->setContentsMargins(0, 0, 20, 0);
|
|
@@ -2167,50 +2148,53 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
|
|
|
// 创建 QLineEdit 显示左边文本
|
|
|
QLineEdit* lineEdit = new QLineEdit();
|
|
|
- if ((fieldUpLimit == "") && (fieldDownLimit == ""))
|
|
|
+ // 1.空值判断
|
|
|
+ if (fieldValue == "")
|
|
|
{
|
|
|
- lineEdit->setText(fieldValue);
|
|
|
- lineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
- lineEdit->setFixedSize(105, 28);
|
|
|
- lineEdit->setAlignment(Qt::AlignLeft);
|
|
|
- //!!!提到前面
|
|
|
- /*lineEdit->setStyleSheet(R"(
|
|
|
- QLineEdit {
|
|
|
- background: #FFFFFF;
|
|
|
- border: 1px solid #BABBDC;
|
|
|
- border-radius: 6px;
|
|
|
- padding: 2px 5px;
|
|
|
+ lineEdit->setPlaceholderText(tr("Please input number", "请输入数字"));
|
|
|
}
|
|
|
- QLineEdit:disabled {
|
|
|
- background: #eeeeee;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lineEdit->setText(fieldValue);
|
|
|
}
|
|
|
- )");*/
|
|
|
- } else
|
|
|
- {//上下限至少设置了一个值
|
|
|
- if (fieldValue == "")
|
|
|
- {
|
|
|
- lineEdit->setPlaceholderText(tr("Please input number","请输入数字"));
|
|
|
- } else
|
|
|
- {
|
|
|
- lineEdit->setText(fieldValue);
|
|
|
- }
|
|
|
+ lineEdit->setFixedSize(105, 28);
|
|
|
+ lineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
|
|
|
|
- lineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
- lineEdit->setFixedSize(105, 28);
|
|
|
- lineEdit->setAlignment(Qt::AlignLeft);
|
|
|
- /*lineEdit->setStyleSheet(R"(
|
|
|
- QLineEdit {
|
|
|
- background: #FFFFFF;
|
|
|
- border: 1px solid #BABBDC;
|
|
|
- border-radius: 6px;
|
|
|
- padding: 2px 5px;
|
|
|
+ // 限制范围
|
|
|
+ int nMin = -1000;
|
|
|
+ int nMax = 1000;
|
|
|
+ double doMin = -1000.0;
|
|
|
+ double doMan = 1000.0;
|
|
|
+ if ((fieldUpLimit == "") || (fieldDownLimit == ""))
|
|
|
+ {
|
|
|
}
|
|
|
- QLineEdit:disabled {
|
|
|
- background: #eeeeee;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ nMin = fieldUpLimit.toInt();
|
|
|
+ nMax = fieldDownLimit.toInt();
|
|
|
+
|
|
|
+ doMin = fieldUpLimit.toDouble();
|
|
|
+ doMan = fieldDownLimit.toDouble();
|
|
|
}
|
|
|
- )");*/
|
|
|
+
|
|
|
+ if (fieldType == "input")
|
|
|
+ {
|
|
|
+ //int 类型
|
|
|
+ QIntValidator* validator = new QIntValidator(nMin, nMax, lineEdit);
|
|
|
+ lineEdit->setValidator(validator);
|
|
|
}
|
|
|
+ else if (fieldType == "LONG")
|
|
|
+ {
|
|
|
+ QDoubleValidator* validator = new QDoubleValidator(doMin, doMan, 4, lineEdit);
|
|
|
+ validator->setNotation(QDoubleValidator::StandardNotation);
|
|
|
+ lineEdit->setValidator(validator);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ lineEdit->setAlignment(Qt::AlignLeft);
|
|
|
+
|
|
|
|
|
|
// 创建 QLabel 显示右边文本(比如 "分钟")
|
|
|
QLabel* unitLabel = new QLabel(fieldUnits);
|
|
@@ -2280,7 +2264,7 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
- connect(lineEdit, &QLineEdit::textChanged, [this, lineEdit, fieldUpLimit, fieldDownLimit, label]() {
|
|
|
+ connect(lineEdit, &QLineEdit::textChanged, [this, lineEdit, fieldUpLimit, fieldDownLimit, pFieldDescribeLabel]() {
|
|
|
if ((fieldUpLimit != "") && (fieldDownLimit != ""))
|
|
|
{
|
|
|
int uplimit = fieldUpLimit.toInt();
|
|
@@ -2288,10 +2272,10 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
int inputvalue = (lineEdit->text()).toInt();
|
|
|
if ((inputvalue <= uplimit) && (inputvalue >= downlimit))
|
|
|
{
|
|
|
- label->setProperty("value", lineEdit->text());
|
|
|
- label->setDisabled(true);
|
|
|
+ pFieldDescribeLabel->setProperty("value", lineEdit->text());
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
// m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
//updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
}
|
|
@@ -2306,10 +2290,10 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
int inputvalue = (lineEdit->text()).toInt();
|
|
|
if (inputvalue >= downlimit)
|
|
|
{
|
|
|
- label->setProperty("value", lineEdit->text());
|
|
|
- label->setDisabled(true);
|
|
|
+ pFieldDescribeLabel->setProperty("value", lineEdit->text());
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
// m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
//updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
}
|
|
@@ -2324,10 +2308,10 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
int inputvalue = (lineEdit->text()).toInt();
|
|
|
if (inputvalue <= uplimit)
|
|
|
{
|
|
|
- label->setProperty("value", lineEdit->text());
|
|
|
- label->setDisabled(true);
|
|
|
+ pFieldDescribeLabel->setProperty("value", lineEdit->text());
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
// m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
|
|
|
//updateDb(fieldTableName, fieldId, lineEdit->text());
|
|
|
}
|
|
@@ -2338,52 +2322,29 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- label->setProperty("value", lineEdit->text());
|
|
|
- label->setDisabled(true);
|
|
|
+ pFieldDescribeLabel->setProperty("value", lineEdit->text());
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
// 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->setDisabled(false);
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
|
|
|
+ if (modifiedLabels.contains(pFieldDescribeLabel)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
|
|
|
+ pFieldDescribeLabel->setDisabled(false);
|
|
|
//label->setStyleSheet("color: black;");
|
|
|
- modifiedLabels.remove(label);
|
|
|
+ modifiedLabels.remove(pFieldDescribeLabel);
|
|
|
}
|
|
|
});
|
|
|
+ JIoMapPage::JCreateMenu(rightWidget, { fieldDefult ,lineEdit ,privilege ,fieldUserGrade });
|
|
|
|
|
|
- QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
|
|
|
- btnDefault->setFixedSize(60, 28);
|
|
|
- btnDefault->setProperty("type", "default");
|
|
|
- /*btnDefault->setStyleSheet(R"(
|
|
|
- QPushButton {
|
|
|
- background: #FFFFFF;
|
|
|
- border: 1px solid #BABBDC;
|
|
|
- border-radius: 5px;
|
|
|
- }
|
|
|
- QPushButton:hover {
|
|
|
- background-color: #F0F0F0;
|
|
|
- }
|
|
|
- QPushButton:disabled {
|
|
|
- background-color: #cccccc;
|
|
|
- }
|
|
|
- )");*/
|
|
|
- rightLayout->addWidget(btnDefault);
|
|
|
-
|
|
|
- connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, lineEdit]() {
|
|
|
- if (!fieldDefult.isEmpty()) {
|
|
|
- lineEdit->setText(fieldDefult);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- if ((privilege &fieldUserGrade) == 1) {
|
|
|
+ if ((privilege &fieldUserGrade) == 1)
|
|
|
+ {
|
|
|
lineEdit->setEnabled(false);
|
|
|
- btnDefault->setEnabled(false);
|
|
|
}
|
|
|
|
|
|
ST_INPUT_CONT _a;
|
|
@@ -2420,23 +2381,23 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
// //updateDb(fieldTableName, fieldId, lineEdit1->text());
|
|
|
// loginput(fieldTableName, fieldName, lineEdit1->text());
|
|
|
// });
|
|
|
- connect(lineEdit1, &QLineEdit::textChanged, [this, lineEdit1, label]() {
|
|
|
- label->setProperty("value", lineEdit1->text());
|
|
|
- label->setDisabled(true);
|
|
|
+ connect(lineEdit1, &QLineEdit::textChanged, [this, lineEdit1, pFieldDescribeLabel]() {
|
|
|
+ pFieldDescribeLabel->setProperty("value", lineEdit1->text());
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
// m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit1->text());
|
|
|
//updateDb(fieldTableName, fieldId, 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->setDisabled(false);
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
|
|
|
+ if (modifiedLabels.contains(pFieldDescribeLabel)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
|
|
|
+ loginput(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
|
|
|
+ pFieldDescribeLabel->setDisabled(false);
|
|
|
//label->setStyleSheet("color: black;");
|
|
|
- modifiedLabels.remove(label);
|
|
|
+ modifiedLabels.remove(pFieldDescribeLabel);
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -2478,7 +2439,7 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
m_veInputCont.push_back(_a);
|
|
|
}
|
|
|
}
|
|
|
- else if (fieldType == "radio")
|
|
|
+ else if (fieldType == "JRadio")
|
|
|
{
|
|
|
// 用逗号分隔的选项
|
|
|
QStringList optionList = fieldUnits.split(QRegExp("[,,]"), Qt::SkipEmptyParts);
|
|
@@ -2488,7 +2449,10 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
for (const QString& optionText : optionList)
|
|
|
{
|
|
|
QString trimmedOpt = optionText.trimmed();
|
|
|
- if (trimmedOpt.isEmpty()) continue;
|
|
|
+ if (trimmedOpt.isEmpty())
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
QRadioButton* radioButton = new QRadioButton(trimmedOpt);
|
|
|
radioGroup->addButton(radioButton);
|
|
|
radioLayout->addWidget(radioButton);
|
|
@@ -2508,13 +2472,13 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
// //updateDb(fieldTableName, fieldId, button->text());
|
|
|
// }
|
|
|
// });
|
|
|
- connect(radioGroup, static_cast<void (QButtonGroup::*)(QAbstractButton*, bool)>(&QButtonGroup::buttonToggled), [this, label](QAbstractButton* button, bool checked) {
|
|
|
+ connect(radioGroup, static_cast<void (QButtonGroup::*)(QAbstractButton*, bool)>(&QButtonGroup::buttonToggled), [this, pFieldDescribeLabel](QAbstractButton* button, bool checked) {
|
|
|
if (checked)
|
|
|
{
|
|
|
- label->setProperty("value", button->text());
|
|
|
- label->setDisabled(true);
|
|
|
+ pFieldDescribeLabel->setProperty("value", button->text());
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
// qDebug() << "Button toggled:" << button->text();
|
|
|
// 在这里添加你想要执行的操作
|
|
|
// m_sqlOper->updateControlData(fieldTableName, fieldName, button->text());
|
|
@@ -2522,50 +2486,38 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
|
|
|
- if (modifiedLabels.contains(label)) {
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
|
|
|
- label->setDisabled(false);
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
|
|
|
+ if (modifiedLabels.contains(pFieldDescribeLabel)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
|
|
|
+ pFieldDescribeLabel->setDisabled(false);
|
|
|
//label->setStyleSheet("color: black;");
|
|
|
- modifiedLabels.remove(label);
|
|
|
+ modifiedLabels.remove(pFieldDescribeLabel);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
rightLayout->addLayout(radioLayout);
|
|
|
-
|
|
|
- QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
|
|
|
- btnDefault->setFixedSize(60, 28);
|
|
|
- btnDefault->setProperty("type", "default");
|
|
|
- /*btnDefault->setStyleSheet(R"(
|
|
|
- QPushButton {
|
|
|
- background: #FFFFFF;
|
|
|
- border: 1px solid #BABBDC;
|
|
|
- border-radius: 5px;
|
|
|
- }
|
|
|
- QPushButton:hover {
|
|
|
- background-color: #F0F0F0;
|
|
|
- }
|
|
|
- QPushButton:disabled {
|
|
|
- background-color: #cccccc;
|
|
|
- }
|
|
|
- )");*/
|
|
|
- rightLayout->addWidget(btnDefault);
|
|
|
-
|
|
|
- connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, radioGroup]() {
|
|
|
- if (!fieldDefult.isEmpty()) {
|
|
|
- for (QAbstractButton* button : radioGroup->buttons()) {
|
|
|
- if (button->text() == fieldDefult) {
|
|
|
+ JIoMapPage::JCreateMenuReDefault(rightWidget, [this, fieldDefult, radioGroup]()
|
|
|
+ {
|
|
|
+ if (!fieldDefult.isEmpty())
|
|
|
+ {
|
|
|
+ for (QAbstractButton* button : radioGroup->buttons())
|
|
|
+ {
|
|
|
+ // 这个选中逻辑需要重新做
|
|
|
+ if (button->text() == fieldDefult)
|
|
|
+ {
|
|
|
button->setChecked(true);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- if ((privilege &fieldUserGrade) == 1) {
|
|
|
- for (QAbstractButton* btn : radioGroup->buttons()) {
|
|
|
+
|
|
|
+ if ((privilege &fieldUserGrade) == 1)
|
|
|
+ {
|
|
|
+ for (QAbstractButton* btn : radioGroup->buttons())
|
|
|
+ {
|
|
|
btn->setEnabled(false);
|
|
|
}
|
|
|
- btnDefault->setEnabled(false);
|
|
|
}
|
|
|
|
|
|
ST_RADIO_CONT _a;
|
|
@@ -2576,13 +2528,14 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
|
|
|
m_veRadioCont.push_back(_a);
|
|
|
}
|
|
|
- else if (fieldType == "checkbox" || fieldType == "BOOL")
|
|
|
+ else if (fieldType == "BOOL")
|
|
|
{
|
|
|
bool isChecked;
|
|
|
if (fieldValue == "")
|
|
|
{
|
|
|
isChecked = (fieldValue == "1");
|
|
|
- } else
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
isChecked = (fieldValue == "1");
|
|
|
}
|
|
@@ -2612,94 +2565,63 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
)");*/
|
|
|
rightLayout->addWidget(checkBox);
|
|
|
createdWidget = checkBox;
|
|
|
- //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) {
|
|
|
+ connect(checkBox, &QCheckBox::stateChanged, [this, pFieldDescribeLabel](int state)
|
|
|
+ {
|
|
|
if (state == Qt::Checked)
|
|
|
{
|
|
|
- // qDebug() << "CheckBox is checked"<<fieldId;
|
|
|
// m_sqlOper->updateControlData(fieldTableName, fieldName, "1");
|
|
|
//updateDb(fieldTableName, fieldId, "1");
|
|
|
- label->setProperty("value", "1");
|
|
|
- label->setDisabled(true);
|
|
|
+ pFieldDescribeLabel->setProperty("value", "1");
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
}
|
|
|
else if (state == Qt::Unchecked)
|
|
|
{
|
|
|
- // qDebug() << "CheckBox is unchecked"<<fieldId;
|
|
|
// 在这里添加你想要执行的操作
|
|
|
// m_sqlOper->updateControlData(fieldTableName, fieldName, "0");
|
|
|
//updateDb(fieldTableName, fieldId, "0");
|
|
|
- label->setProperty("value", "0");
|
|
|
- label->setDisabled(true);
|
|
|
+ pFieldDescribeLabel->setProperty("value", "0");
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
}
|
|
|
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->setDisabled(false);
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
|
|
|
+ if (modifiedLabels.contains(pFieldDescribeLabel))
|
|
|
+ {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
|
|
|
+ pFieldDescribeLabel->setDisabled(false);
|
|
|
//label->setStyleSheet("color: black;");
|
|
|
- modifiedLabels.remove(label);
|
|
|
+ modifiedLabels.remove(pFieldDescribeLabel);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
|
|
|
- btnDefault->setFixedSize(60, 28);
|
|
|
- btnDefault->setProperty("type", "default");
|
|
|
- /*btnDefault->setStyleSheet(R"(
|
|
|
- QPushButton {
|
|
|
- background: #FFFFFF;
|
|
|
- border: 1px solid #BABBDC;
|
|
|
- border-radius: 5px;
|
|
|
- }
|
|
|
- QPushButton:hover {
|
|
|
- background-color: #F0F0F0;
|
|
|
- }
|
|
|
- QPushButton:disabled {
|
|
|
- background-color: #cccccc;
|
|
|
- }
|
|
|
- )");*/
|
|
|
- rightLayout->addWidget(btnDefault);
|
|
|
-
|
|
|
- connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, checkBox]() {
|
|
|
- if (!fieldDefult.isEmpty()) {
|
|
|
- if (fieldDefult == "1") {
|
|
|
- checkBox->setChecked(true);
|
|
|
- }
|
|
|
- else {
|
|
|
- checkBox->setChecked(false);
|
|
|
+ JIoMapPage::JCreateMenuReDefault(rightWidget, [this, fieldDefult, checkBox]()
|
|
|
+ {
|
|
|
+ if (!fieldDefult.isEmpty())
|
|
|
+ {
|
|
|
+ if (fieldDefult == "1")
|
|
|
+ {
|
|
|
+ checkBox->setChecked(true);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ checkBox->setChecked(false);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
});
|
|
|
|
|
|
- if ((privilege &fieldUserGrade) == 1) {
|
|
|
+
|
|
|
+ if ((privilege & fieldUserGrade) == 1)
|
|
|
+ {
|
|
|
checkBox->setEnabled(false);
|
|
|
- btnDefault->setEnabled(false);
|
|
|
}
|
|
|
|
|
|
ST_CHECKBOX_CONT _a;
|
|
@@ -2710,6 +2632,16 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
|
|
|
m_veCheckBoxCont.push_back(_a);
|
|
|
}
|
|
|
+ else if (fieldType == "JCheckBox")
|
|
|
+ {
|
|
|
+ QList<ST_DATA_ITEM> dataList = JIoMapPage::parseJsonToDataList(fieldUnits);
|
|
|
+
|
|
|
+ // 创建 CheckBoxWidget , 将数据绑定
|
|
|
+ JCheckBoxCont* window = new JCheckBoxCont(dataList);
|
|
|
+ rightLayout->addWidget(window);
|
|
|
+ createdWidget = window;
|
|
|
+
|
|
|
+ }
|
|
|
else if (fieldType == "ComboBox")
|
|
|
{
|
|
|
//QStringList optionList = fieldValue.split(QRegExp("[,,]"), Qt::SkipEmptyParts);
|
|
@@ -2753,14 +2685,16 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
int matchedIndex = -1;
|
|
|
int currentIndex = 0;
|
|
|
|
|
|
- for (const QJsonValue& val : jsonArray) {
|
|
|
+ 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()) {
|
|
|
+ if (valueStr == fieldValue.trimmed())
|
|
|
+ {
|
|
|
matchedIndex = currentIndex;
|
|
|
}
|
|
|
currentIndex++;
|
|
@@ -2778,61 +2712,52 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
// // 在这里添加你想要执行的操作
|
|
|
// });
|
|
|
connect(comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
|
- [this, comboBox, jsonArray, label](int index) {
|
|
|
+ [this, comboBox, jsonArray, pFieldDescribeLabel](int index)
|
|
|
+ {
|
|
|
QString selectedText = comboBox->itemText(index);
|
|
|
QString valueString;
|
|
|
- for (const QJsonValue& val : jsonArray) {
|
|
|
+ for (const QJsonValue& val : jsonArray)
|
|
|
+ {
|
|
|
QJsonObject obj = val.toObject();
|
|
|
- if (obj["key"].toString() == selectedText) {
|
|
|
+ if (obj["key"].toString() == selectedText)
|
|
|
+ {
|
|
|
valueString = QString::number(obj["value"].toInt());
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
// m_sqlOper->updateControlData(fieldTableName, fieldName, valueString);
|
|
|
- label->setProperty("value", valueString);
|
|
|
- label->setDisabled(true);
|
|
|
+ pFieldDescribeLabel->setProperty("value", valueString);
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
});
|
|
|
|
|
|
- connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
|
|
|
- if (modifiedLabels.contains(label)) {
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
|
|
|
- label->setDisabled(false);
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
|
|
|
+ if (modifiedLabels.contains(pFieldDescribeLabel))
|
|
|
+ {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
|
|
|
+ pFieldDescribeLabel->setDisabled(false);
|
|
|
//label->setStyleSheet("color: black;");
|
|
|
- modifiedLabels.remove(label);
|
|
|
+ modifiedLabels.remove(pFieldDescribeLabel);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
|
|
|
- btnDefault->setFixedSize(60, 28);
|
|
|
- btnDefault->setProperty("type", "default");
|
|
|
- /*btnDefault->setStyleSheet(R"(
|
|
|
- QPushButton {
|
|
|
- background: #FFFFFF;
|
|
|
- border: 1px solid #BABBDC;
|
|
|
- border-radius: 5px;
|
|
|
- }
|
|
|
- QPushButton:hover {
|
|
|
- background-color: #F0F0F0;
|
|
|
- }
|
|
|
- QPushButton:disabled {
|
|
|
- background-color: #cccccc;
|
|
|
- }
|
|
|
- )");*/
|
|
|
- rightLayout->addWidget(btnDefault);
|
|
|
|
|
|
- connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, comboBox, jsonArray]() {
|
|
|
- if (!fieldDefult.isEmpty()) {
|
|
|
+ JIoMapPage::JCreateMenuReDefault(rightWidget, [this, fieldDefult, comboBox, jsonArray]()
|
|
|
+ {
|
|
|
+ if (!fieldDefult.isEmpty())
|
|
|
+ {
|
|
|
int matchedIndex = -1;
|
|
|
int currentIndex = 0;
|
|
|
|
|
|
- for (const QJsonValue& val : jsonArray) {
|
|
|
+ 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()) {
|
|
|
+ if (valueStr == fieldDefult.trimmed())
|
|
|
+ {
|
|
|
matchedIndex = currentIndex;
|
|
|
break;
|
|
|
}
|
|
@@ -2842,9 +2767,9 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- if ((privilege &fieldUserGrade) == 1) {
|
|
|
+ if ((privilege &fieldUserGrade) == 1)
|
|
|
+ {
|
|
|
comboBox->setEnabled(false);
|
|
|
- btnDefault->setEnabled(false);
|
|
|
}
|
|
|
|
|
|
ST_COMBOBOX_CONT _a;
|
|
@@ -2854,7 +2779,8 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
_a.strfieldDescribe = fieldDescribe;
|
|
|
|
|
|
m_veComboBoxCont.push_back(_a);
|
|
|
- } else if (fieldType == "time")
|
|
|
+ }
|
|
|
+ else if (fieldType == "time")
|
|
|
{
|
|
|
QTimeEdit* timeEdit = new QTimeEdit;
|
|
|
timeEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
@@ -2874,20 +2800,20 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
timeEdit->setTime(QTime::fromString(fieldValue, "HH:mm:ss"));
|
|
|
rightLayout->addWidget(timeEdit);
|
|
|
createdWidget = timeEdit;
|
|
|
- connect(timeEdit, &QTimeEdit::timeChanged, [this, timeEdit, label]() {
|
|
|
+ connect(timeEdit, &QTimeEdit::timeChanged, [this, timeEdit, pFieldDescribeLabel]() {
|
|
|
QString timeString = timeEdit->time().toString("HH:mm:ss");
|
|
|
- label->setProperty("value", timeString);
|
|
|
- label->setDisabled(true);
|
|
|
+ pFieldDescribeLabel->setProperty("value", timeString);
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
});
|
|
|
|
|
|
- connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
|
|
|
- if (modifiedLabels.contains(label)) {
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
|
|
|
- label->setDisabled(false);
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
|
|
|
+ if (modifiedLabels.contains(pFieldDescribeLabel)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
|
|
|
+ pFieldDescribeLabel->setDisabled(false);
|
|
|
//label->setStyleSheet("color: black;");
|
|
|
- modifiedLabels.remove(label);
|
|
|
+ modifiedLabels.remove(pFieldDescribeLabel);
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -2927,7 +2853,8 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
_a.strfieldDescribe = fieldDescribe;
|
|
|
|
|
|
m_veTimeCont.push_back(_a);
|
|
|
- } else if (fieldType == "switch")
|
|
|
+ }
|
|
|
+ else if (fieldType == "switch")
|
|
|
{
|
|
|
QWidget* switchContainer = new QWidget;
|
|
|
QHBoxLayout* switchLayout = new QHBoxLayout(switchContainer);
|
|
@@ -2983,35 +2910,35 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
// //updateDb(fieldTableName, fieldId, "off");
|
|
|
// }
|
|
|
// });
|
|
|
- connect(switchBox, &QCheckBox::stateChanged, [switchLabel, this, label](int state) {
|
|
|
+ connect(switchBox, &QCheckBox::stateChanged, [switchLabel, this, pFieldDescribeLabel](int state) {
|
|
|
if (state == Qt::Checked)
|
|
|
{
|
|
|
switchLabel->setText(tr("Open","开"));
|
|
|
- label->setProperty("value", "on");
|
|
|
- label->setDisabled(true);
|
|
|
+ pFieldDescribeLabel->setProperty("value", "on");
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
// m_sqlOper->updateControlData(fieldTableName, fieldName, "on");
|
|
|
//updateDb(fieldTableName, fieldId, "on");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
switchLabel->setText(tr("Close","关"));
|
|
|
- label->setProperty("value", "off");
|
|
|
- label->setDisabled(true);
|
|
|
+ pFieldDescribeLabel->setProperty("value", "off");
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
// 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->setDisabled(false);
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
|
|
|
+ if (modifiedLabels.contains(pFieldDescribeLabel)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
|
|
|
+ pFieldDescribeLabel->setDisabled(false);
|
|
|
//label->setStyleSheet("color: black;");
|
|
|
- modifiedLabels.remove(label);
|
|
|
+ modifiedLabels.remove(pFieldDescribeLabel);
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -3209,19 +3136,19 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
|
|
|
m_veCombinedCont.push_back(_a);
|
|
|
|
|
|
- connect(comboInput, &QLineEdit::textChanged, [this, comboInput, label]() {
|
|
|
- label->setProperty("value", comboInput->text());
|
|
|
- label->setDisabled(true);
|
|
|
+ connect(comboInput, &QLineEdit::textChanged, [this, comboInput, pFieldDescribeLabel]() {
|
|
|
+ pFieldDescribeLabel->setProperty("value", comboInput->text());
|
|
|
+ pFieldDescribeLabel->setDisabled(true);
|
|
|
//label->setStyleSheet("color: #5c63be;");
|
|
|
- modifiedLabels.insert(label);
|
|
|
+ modifiedLabels.insert(pFieldDescribeLabel);
|
|
|
});
|
|
|
|
|
|
- connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
|
|
|
- if (modifiedLabels.contains(label)) {
|
|
|
- m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
|
|
|
- label->setDisabled(false);
|
|
|
+ connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
|
|
|
+ if (modifiedLabels.contains(pFieldDescribeLabel)) {
|
|
|
+ m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
|
|
|
+ pFieldDescribeLabel->setDisabled(false);
|
|
|
//label->setStyleSheet("color: black;");
|
|
|
- modifiedLabels.remove(label);
|
|
|
+ modifiedLabels.remove(pFieldDescribeLabel);
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -3259,13 +3186,8 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
|
|
|
}
|
|
|
else if (fieldType == "Text")
|
|
|
{
|
|
|
- QLabel* label = new QLabel();
|
|
|
- label->setText(fieldValue);
|
|
|
- label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
|
|
- label->setFixedHeight(24);
|
|
|
- label->setMinimumWidth(120);
|
|
|
- rightLayout->addWidget(label);
|
|
|
-
|
|
|
+ rightLayout->addWidget(JIoMapPage::JCreateJText(fieldValue));
|
|
|
+ rightLayout->addWidget(JIoMapPage::JCreateJText(fieldUnits));
|
|
|
}
|
|
|
else if (fieldType == "IoPage")
|
|
|
{
|