|
@@ -221,7 +221,7 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
|
|
|
// 清空已有模型数据和相关记录
|
|
|
m_pCModel->clear();
|
|
|
- firstLevelSeparators.clear();
|
|
|
+ m_mapFirstLevelSeparators.clear();
|
|
|
expandedPaths.clear();
|
|
|
|
|
|
// 清理并隐藏三级目录窗口
|
|
@@ -232,7 +232,7 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
{
|
|
|
// 隐藏目录树和分隔线
|
|
|
m_pTreeViewDown->hide();
|
|
|
- for (auto separator : firstLevelSeparators)
|
|
|
+ for (auto separator : m_mapFirstLevelSeparators)
|
|
|
{
|
|
|
if (separator)
|
|
|
{
|
|
@@ -252,7 +252,7 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
}
|
|
|
|
|
|
// 从 BondHead 和 Buttons 表中加载 DirectoryId = 1 的数据
|
|
|
- QList<Table_Control_Data> tableControlDatas;
|
|
|
+ QList<ST_TABLE_CONTROL_DATA> tableControlDatas;
|
|
|
bool allChangeFlag = false;
|
|
|
m_sqlOper->GetThirdDirControlData("HomeProduct", userPrivilege, tableControlDatas, allChangeFlag);
|
|
|
//QJsonObject data = fetchThirdLevelData(1, userPrivilege);
|
|
@@ -276,7 +276,7 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
m_pTreeViewDown->setGeometry(16, 106, m_pOriginalWndMenuPage->width() - 16, m_pOriginalWndMenuPage->height() - 106);
|
|
|
// 显示目录树和分隔线
|
|
|
m_pTreeViewDown->show();
|
|
|
- for (auto separator : firstLevelSeparators) {
|
|
|
+ for (auto separator : m_mapFirstLevelSeparators) {
|
|
|
if (separator)
|
|
|
separator->show();
|
|
|
}
|
|
@@ -349,7 +349,7 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
}
|
|
|
// userPrivilege 同样传递
|
|
|
//QJsonObject data = fetchThirdLevelData(directoryId, userPrivilege);
|
|
|
- QList<Table_Control_Data> tableControlDatas;
|
|
|
+ QList<ST_TABLE_CONTROL_DATA> tableControlDatas;
|
|
|
bool allChangeFlag = false;
|
|
|
m_sqlOper->GetThirdDirControlData(multiTableName, userPrivilege, tableControlDatas, allChangeFlag);
|
|
|
//QJsonObject data = fetchThirdLevelData(1, userPrivilege);
|
|
@@ -534,7 +534,7 @@ void DbTreeViewManager::buildTreeFromDirectories(const QList<QJsonObject> &direc
|
|
|
if (dir["Separator"].toInt() == 1) {
|
|
|
QFrame *sep = createUnifiedSeparator(m_pOriginalWndMenuPage, 2);
|
|
|
sep->hide();
|
|
|
- firstLevelSeparators.insert(childItem, sep);
|
|
|
+ m_mapFirstLevelSeparators.insert(childItem, sep);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
@@ -1040,17 +1040,20 @@ void DbTreeViewManager::onTreeViewClicked(const QModelIndex &index)
|
|
|
int dirId = -1;
|
|
|
QString strModuleType; // 模组
|
|
|
|
|
|
- //QString dirTableName = "";
|
|
|
QString mutliTableName = "";
|
|
|
QVariant dataVar = item->data(Qt::UserRole + 2);
|
|
|
- if (dataVar.canConvert<QJsonObject>()) {
|
|
|
+ if (dataVar.canConvert<QJsonObject>())
|
|
|
+ {
|
|
|
QJsonObject obj = dataVar.toJsonObject();
|
|
|
qDebug() << " AAkey :" << obj;
|
|
|
- if (obj.contains("IsThirdLevel") && obj["IsThirdLevel"].toBool()) {
|
|
|
+ if (obj.contains("IsThirdLevel") && obj["IsThirdLevel"].toBool())
|
|
|
+ {
|
|
|
isThird = true;
|
|
|
- if (obj.contains("Id")) {
|
|
|
+ if (obj.contains("Id"))
|
|
|
+ {
|
|
|
dirId = obj["Id"].toInt();
|
|
|
}
|
|
|
+
|
|
|
if (obj.contains("TableName"))
|
|
|
{
|
|
|
mutliTableName = obj["TableName"].toString();
|
|
@@ -1058,10 +1061,8 @@ void DbTreeViewManager::onTreeViewClicked(const QModelIndex &index)
|
|
|
|
|
|
if (obj.contains("ModuleType"))
|
|
|
{
|
|
|
- strModuleType = obj["ModuleType"].toString();
|
|
|
- m_strModuleTypeAAA = strModuleType;
|
|
|
+ m_str2DirModuleType = obj["ModuleType"].toString();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1079,7 +1080,7 @@ void DbTreeViewManager::onTreeViewClicked(const QModelIndex &index)
|
|
|
qWarning() << "无效directoryId";
|
|
|
return;
|
|
|
}
|
|
|
- QList<Table_Control_Data> tableControlDatas;
|
|
|
+ QList<ST_TABLE_CONTROL_DATA> tableControlDatas;
|
|
|
bool allChangeFlag = false;
|
|
|
m_sqlOper->GetThirdDirControlData(mutliTableName, userPrivilege, tableControlDatas, allChangeFlag);
|
|
|
displayThirdLevelFields(tableControlDatas, allChangeFlag, false); // 传递参数表示 Home 界面
|
|
@@ -1167,7 +1168,7 @@ void DbTreeViewManager::onTreeViewClicked_updown(const QModelIndex &index){
|
|
|
qWarning() << "无效multiTableName";
|
|
|
return;
|
|
|
}
|
|
|
- QList<Table_Control_Data> tableControlDatas;
|
|
|
+ QList<ST_TABLE_CONTROL_DATA> tableControlDatas;
|
|
|
bool allChangeFlag = false;
|
|
|
m_sqlOper->GetThirdDirControlData(multiTableName, userPrivilege, tableControlDatas, allChangeFlag);
|
|
|
displayThirdLevelFields(tableControlDatas, allChangeFlag, false); // 传递参数表示 Home 界面
|
|
@@ -1281,16 +1282,16 @@ void DbTreeViewManager::updateNavigationBar(const QModelIndex &index)
|
|
|
|
|
|
void DbTreeViewManager::clearAllSeparators()
|
|
|
{
|
|
|
- // 遍历 firstLevelSeparators 中所有 QFrame,
|
|
|
+ // 遍历 m_mapFirstLevelSeparators 中所有 QFrame,
|
|
|
// 隐藏后调用 deleteLater()
|
|
|
- for (auto separator : firstLevelSeparators.values()) {
|
|
|
+ for (auto separator : m_mapFirstLevelSeparators.values()) {
|
|
|
if(separator) {
|
|
|
separator->hide();
|
|
|
separator->deleteLater();
|
|
|
}
|
|
|
}
|
|
|
// 清空映射
|
|
|
- firstLevelSeparators.clear();
|
|
|
+ m_mapFirstLevelSeparators.clear();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1299,7 +1300,7 @@ void DbTreeViewManager::updateSeparatorLine()
|
|
|
{
|
|
|
// 如果目录树被隐藏,就把分割线都藏起来
|
|
|
if (!m_pTreeViewDown->isVisible()) {
|
|
|
- for (auto it = firstLevelSeparators.begin(); it != firstLevelSeparators.end(); ++it) {
|
|
|
+ for (auto it = m_mapFirstLevelSeparators.begin(); it != m_mapFirstLevelSeparators.end(); ++it) {
|
|
|
QFrame *sep = it.value();
|
|
|
if (sep) sep->hide();
|
|
|
}
|
|
@@ -1307,7 +1308,7 @@ void DbTreeViewManager::updateSeparatorLine()
|
|
|
}
|
|
|
|
|
|
// 遍历所有“一级目录”与其分隔线
|
|
|
- for (auto it = firstLevelSeparators.begin(); it != firstLevelSeparators.end(); ++it) {
|
|
|
+ for (auto it = m_mapFirstLevelSeparators.begin(); it != m_mapFirstLevelSeparators.end(); ++it) {
|
|
|
QStandardItem *firstLevelItem = it.key();
|
|
|
QFrame *separator = it.value();
|
|
|
if (!firstLevelItem || !separator) continue;
|
|
@@ -1409,7 +1410,7 @@ QModelIndex DbTreeViewManager::findLastVisibleChild(const QModelIndex &parentInd
|
|
|
//
|
|
|
// // 隐藏目录树及所有分隔线
|
|
|
// treeViewDown->hide();
|
|
|
-// for (auto separator : firstLevelSeparators) {
|
|
|
+// for (auto separator : m_mapFirstLevelSeparators) {
|
|
|
// if (separator)
|
|
|
// separator->hide();
|
|
|
// }
|
|
@@ -1892,7 +1893,7 @@ QString extractBeforeComma(const QString& input)
|
|
|
return input;
|
|
|
}
|
|
|
|
|
|
-void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>& data, bool allChangeFlag, bool isHome)
|
|
|
+void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DATA>& data, bool allChangeFlag, bool isHome)
|
|
|
{
|
|
|
if (data.isEmpty())
|
|
|
{
|
|
@@ -1919,14 +1920,15 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
currentItem->setCheckState(allChangeFlag ? Qt::Checked : Qt::Unchecked);
|
|
|
qDebug() << "设置当前目录项复选框状态为:" << (allChangeFlag ? "Checked" : "Unchecked");
|
|
|
}
|
|
|
- } else
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
qWarning() << "当前没有选中的目录项";
|
|
|
}
|
|
|
|
|
|
// 隐藏目录树及所有分隔线
|
|
|
m_pTreeViewDown->hide();
|
|
|
- for (auto separator : firstLevelSeparators)
|
|
|
+ for (auto separator : m_mapFirstLevelSeparators)
|
|
|
{
|
|
|
if (separator)
|
|
|
separator->hide();
|
|
@@ -1937,13 +1939,14 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
|
|
|
// 创建新的 "字段展示" 窗口,并赋值给 m_thirdLevelFieldWnd
|
|
|
m_thirdLevelFieldWnd = new QWidget(m_pOriginalWndMenuPage);
|
|
|
- m_thirdLevelFieldWnd->setWindowTitle("字段展示");
|
|
|
+ m_thirdLevelFieldWnd->setWindowTitle(m_strShowName);
|
|
|
m_thirdLevelFieldWnd->setStyleSheet("background-color: transparent;");
|
|
|
if (isHome)
|
|
|
{
|
|
|
// Home 界面,填满 widget2
|
|
|
m_thirdLevelFieldWnd->setGeometry(0, 0, m_pOriginalWndMenuPage->width(), m_pOriginalWndMenuPage->height());
|
|
|
- } else
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
// 其他配置界面,设置与 treeViewDown 相同的几何位置
|
|
|
m_thirdLevelFieldWnd->setGeometry(m_pTreeViewDown->geometry());
|
|
@@ -1961,39 +1964,7 @@ 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);
|
|
|
+ Level3MenuAllSaveBut(scrollLayout);
|
|
|
|
|
|
QFrame* separator = createUnifiedSeparator(scrollWidget, 2);
|
|
|
QHBoxLayout* separatorLayout = new QHBoxLayout;
|
|
@@ -2005,7 +1976,7 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
//不同表格的全部插进来
|
|
|
int previousGroupId = -1;
|
|
|
QList<CONFIG_BASE_STRUCT> buttonControls;
|
|
|
- for (const Table_Control_Data& tableData : data)
|
|
|
+ for (const ST_TABLE_CONTROL_DATA& tableData : data)
|
|
|
{
|
|
|
//遍历控件list
|
|
|
for (const CONFIG_BASE_STRUCT& control : tableData.controlDataList)
|
|
@@ -2028,7 +1999,7 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
QString fieldDownLimit = QString::fromStdString(control.strLowerLimit);
|
|
|
QString fieldUnits = QString::fromStdString(control.strUnit);
|
|
|
QString strAxisType = QString::fromStdString(control.strAxisType);
|
|
|
- QString strstrModuleType = m_strModuleTypeAAA;
|
|
|
+ QString strstrModuleType = m_str2DirModuleType;
|
|
|
int groupId = control.iGroupId;
|
|
|
|
|
|
QString fieldTableName = extractBeforeComma(tableData.tableName);
|
|
@@ -3077,7 +3048,7 @@ void DbTreeViewManager::onButtonBackClicked()
|
|
|
|
|
|
// 显示目录树和分隔线
|
|
|
m_pTreeViewDown->show();
|
|
|
- for (auto separator : firstLevelSeparators) {
|
|
|
+ for (auto separator : m_mapFirstLevelSeparators) {
|
|
|
if (separator)
|
|
|
separator->show();
|
|
|
}
|
|
@@ -3162,7 +3133,7 @@ void DbTreeViewManager::onButtonBackClicked()
|
|
|
|
|
|
int userPrivilege = 0x1; // 当前用户的权限等级
|
|
|
|
|
|
- QList<Table_Control_Data> tableControlDatas;
|
|
|
+ QList<ST_TABLE_CONTROL_DATA> tableControlDatas;
|
|
|
bool allChangeFlag = false;
|
|
|
m_sqlOper->GetThirdDirControlData(multiTableName, userPrivilege, tableControlDatas, allChangeFlag);
|
|
|
displayThirdLevelFields(tableControlDatas, allChangeFlag, false); // 传递参数表示 Home 界面
|
|
@@ -3174,7 +3145,7 @@ void DbTreeViewManager::onButtonBackClicked()
|
|
|
} else {
|
|
|
// 父目录不是第三层目录,确保目录树和分隔线可见
|
|
|
m_pTreeViewDown->show();
|
|
|
- for (auto separator : firstLevelSeparators) {
|
|
|
+ for (auto separator : m_mapFirstLevelSeparators) {
|
|
|
if (separator)
|
|
|
separator->show();
|
|
|
}
|
|
@@ -3242,7 +3213,7 @@ void DbTreeViewManager::onButtonBackClicked()
|
|
|
}
|
|
|
|
|
|
int userPrivilege = 0x1; // 根据实际情况获取当前用户的权限等级
|
|
|
- QList<Table_Control_Data> tableControlDatas;
|
|
|
+ QList<ST_TABLE_CONTROL_DATA> tableControlDatas;
|
|
|
bool allChangeFlag = false;
|
|
|
m_sqlOper->GetThirdDirControlData(multiTableName, userPrivilege, tableControlDatas, allChangeFlag);
|
|
|
displayThirdLevelFields(tableControlDatas, allChangeFlag, false); // 传递参数表示 Home 界面
|
|
@@ -3899,22 +3870,23 @@ void DbTreeViewManager::displayThirdLevelButtons(const QList<CONFIG_BASE_STRUCT>
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-// 清理并隐藏三级目录菜单内容
|
|
|
void DbTreeViewManager::clearThirdLevelMenu()
|
|
|
{
|
|
|
// 遍历所有子控件,找到标题为 "字段展示" 的窗口并关闭
|
|
|
- foreach (QObject *child, m_pOriginalWndMenuPage->children()) {
|
|
|
+ foreach (QObject *child, m_pOriginalWndMenuPage->children())
|
|
|
+ {
|
|
|
QWidget *childWidget = qobject_cast<QWidget*>(child);
|
|
|
- if (childWidget && childWidget->windowTitle() == "字段展示") {
|
|
|
- qDebug() << "关闭现有的字段展示窗口";
|
|
|
+ if (childWidget && childWidget->windowTitle() == m_strShowName)
|
|
|
+ {
|
|
|
+ JLogAllOutput::cmd_debug("关闭现有的字段展示窗口");
|
|
|
childWidget->close();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 显示主目录树和分隔线
|
|
|
m_pTreeViewDown->show();
|
|
|
- for (auto separator : firstLevelSeparators) {
|
|
|
+ for (auto separator : m_mapFirstLevelSeparators)
|
|
|
+ {
|
|
|
separator->show();
|
|
|
}
|
|
|
}
|
|
@@ -4073,6 +4045,44 @@ void DbTreeViewManager::loadExpandedPaths()
|
|
|
}
|
|
|
|
|
|
|
|
|
+void DbTreeViewManager::Level3MenuAllSaveBut(QVBoxLayout* pVBox)
|
|
|
+{
|
|
|
+ QHBoxLayout* fieldLayout = new QHBoxLayout;
|
|
|
+ fieldLayout->setSpacing(5);
|
|
|
+
|
|
|
+ QPushButton* pSaveBut = new QPushButton(tr("Save", "保存"));
|
|
|
+ pSaveBut->setFixedSize(80, 28);
|
|
|
+ pSaveBut->setStyleSheet(R"(
|
|
|
+ QPushButton {
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #BABBDC;
|
|
|
+ border-radius: 5px;
|
|
|
+ }
|
|
|
+ QPushButton:hover {
|
|
|
+ background-color: #F0F0F0;
|
|
|
+ }
|
|
|
+ )");
|
|
|
+ m_fieldWidgets.append(pSaveBut);
|
|
|
+
|
|
|
+ connect(pSaveBut, &QPushButton::clicked, this, [=]()
|
|
|
+ {
|
|
|
+ if (modifiedLabels.isEmpty())
|
|
|
+ {
|
|
|
+ JMessageTip::Message_information(tr("No components were modified!", "没有任何组件被修改!"), this);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (JMessageTip::Message_question(tr("Modifications detected, do you want to save?", "检测到修改内容,是否保存?"), this) == QMessageBox::Yes)
|
|
|
+ {
|
|
|
+ emit saveClicked();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ fieldLayout->addWidget(pSaveBut);
|
|
|
+ pVBox->addLayout(fieldLayout);
|
|
|
+}
|
|
|
+
|
|
|
// 清空历史
|
|
|
void DbTreeViewManager::clearHistory()
|
|
|
{
|
|
@@ -4163,7 +4173,7 @@ void DbTreeViewManager::loadPageState(const PageState &st, bool isByHistoryNav)
|
|
|
}
|
|
|
|
|
|
int userPrivilege = 0x1;
|
|
|
- QList<Table_Control_Data> tableControlDatas;
|
|
|
+ QList<ST_TABLE_CONTROL_DATA> tableControlDatas;
|
|
|
bool allChangeFlag = false;
|
|
|
m_sqlOper->GetThirdDirControlData(st.multiTableName, userPrivilege, tableControlDatas, allChangeFlag);
|
|
|
displayThirdLevelFields(tableControlDatas, allChangeFlag, false); // 传递参数表示 Home 界面
|
|
@@ -4177,7 +4187,7 @@ void DbTreeViewManager::loadPageState(const PageState &st, bool isByHistoryNav)
|
|
|
m_thirdLevelFieldWnd = nullptr;
|
|
|
}
|
|
|
m_pTreeViewDown->show();
|
|
|
- for (auto sep : firstLevelSeparators) {
|
|
|
+ for (auto sep : m_mapFirstLevelSeparators) {
|
|
|
if (sep) sep->show();
|
|
|
}
|
|
|
}
|