|
@@ -234,7 +234,7 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
clearThirdLevelMenu();
|
|
|
|
|
|
// **Home 界面逻辑**
|
|
|
- if (name == "Home")
|
|
|
+ if (name == "Home")
|
|
|
{
|
|
|
// 隐藏目录树和分隔线
|
|
|
m_pTreeViewDown->hide();
|
|
@@ -252,7 +252,7 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
updateButtonsVisibility(); // 将按钮隐藏
|
|
|
|
|
|
// 隐藏特定的分隔线 lineFrame1
|
|
|
- if (m_pLineFrame1)
|
|
|
+ if (m_pLineFrame1)
|
|
|
{
|
|
|
m_pLineFrame1->hide();
|
|
|
}
|
|
@@ -272,7 +272,7 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
st.multiTableName = "HomeProduct";
|
|
|
|
|
|
m_backStack.append(st);
|
|
|
- if(m_backStack.size() >= 2){
|
|
|
+ if (m_backStack.size() >= 2) {
|
|
|
buttonLeft->setIcon(QIcon(":/images/home_left.png"));
|
|
|
}
|
|
|
|
|
@@ -328,6 +328,10 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
|
|
|
m_thirdLevelFieldWnd->show();
|
|
|
|
|
|
+ }
|
|
|
+ else if (name == "Diagnosis")
|
|
|
+ {
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -393,7 +397,8 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
|
|
|
// 自动选中第一个根目录项并更新导航栏
|
|
|
QStandardItem *rootItem = m_pCModel->invisibleRootItem()->child(0);
|
|
|
- if (rootItem) {
|
|
|
+ if (rootItem)
|
|
|
+ {
|
|
|
QModelIndex rootIndex = m_pCModel->indexFromItem(rootItem);
|
|
|
m_pTreeViewDown->setCurrentIndex(rootIndex);
|
|
|
updateNavigationBar(rootIndex);
|
|
@@ -403,11 +408,14 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
bool isThirdLevel = false;
|
|
|
int directoryId = -1;
|
|
|
QString multiTableName = "";
|
|
|
- if (dataVar.canConvert<QJsonObject>()) {
|
|
|
+ if (dataVar.canConvert<QJsonObject>())
|
|
|
+ {
|
|
|
QJsonObject thirdLevelObj = dataVar.toJsonObject();
|
|
|
- if (thirdLevelObj.contains("IsThirdLevel") && thirdLevelObj["IsThirdLevel"].toBool()) {
|
|
|
+ if (thirdLevelObj.contains("IsThirdLevel") && thirdLevelObj["IsThirdLevel"].toBool())
|
|
|
+ {
|
|
|
isThirdLevel = true;
|
|
|
- if (thirdLevelObj.contains("Id")) {
|
|
|
+ if (thirdLevelObj.contains("Id"))
|
|
|
+ {
|
|
|
directoryId = thirdLevelObj["Id"].toInt();
|
|
|
}
|
|
|
if (thirdLevelObj.contains("TableName"))
|
|
@@ -416,8 +424,10 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (isThirdLevel) {
|
|
|
- if (directoryId == -1) {
|
|
|
+ if (isThirdLevel)
|
|
|
+ {
|
|
|
+ if (directoryId == -1)
|
|
|
+ {
|
|
|
// qWarning() << "无效的 DirectoryId,无法加载第三层目录内容。";
|
|
|
return;
|
|
|
}
|
|
@@ -444,12 +454,14 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
st.multiTableName = multiTableName;
|
|
|
|
|
|
m_backStack.append(st);
|
|
|
- if(m_backStack.size() >= 2){
|
|
|
-
|
|
|
+ if(m_backStack.size() >= 2)
|
|
|
+ {
|
|
|
buttonLeft->setIcon(QIcon(":/images/home_left.png"));
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
// qWarning() << "树形模型中没有根目录项。";
|
|
|
}
|
|
|
|
|
@@ -459,18 +471,21 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
// 自动找第一个三级目录
|
|
|
QStandardItem *rootItem1 = m_pCModel->invisibleRootItem();
|
|
|
QStandardItem *firstThirdItem = findFirstThirdLevelItemDFS(rootItem1);
|
|
|
- if (!firstThirdItem) {
|
|
|
+ if (!firstThirdItem)
|
|
|
+ {
|
|
|
// qDebug() << "[initializeTree] No third-level item found, do nothing.";
|
|
|
return;
|
|
|
}
|
|
|
// QStandardItem 里获取它的目录信息
|
|
|
QVariant dataVar = firstThirdItem->data(Qt::UserRole + 2);
|
|
|
- if (!dataVar.canConvert<QJsonObject>()) {
|
|
|
+ if (!dataVar.canConvert<QJsonObject>())
|
|
|
+ {
|
|
|
// qWarning() << "[initializeTree] firstThirdItem->data 无法转换为 QJsonObject";
|
|
|
return;
|
|
|
}
|
|
|
QJsonObject dirObj = dataVar.toJsonObject();
|
|
|
- if (!dirObj.contains("Id")) {
|
|
|
+ if (!dirObj.contains("Id"))
|
|
|
+ {
|
|
|
// qWarning() << "[initializeTree] 第一个三级目录无 Id 字段,无法加载";
|
|
|
return;
|
|
|
}
|
|
@@ -505,13 +520,8 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
// loadButtonConfigForThirdLevel 显示按钮
|
|
|
//loadButtonConfigForThirdLevel(data);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
// 从数据库加载目录 包含权限判断
|
|
|
void DbTreeViewManager::loadDirectories(int configId, const int &userPrivilege)
|
|
|
{
|
|
@@ -606,20 +616,24 @@ void DbTreeViewManager::buildTreeFromDirectories(const QList<QJsonObject> &direc
|
|
|
qDebug() << "child is nullptr";
|
|
|
}
|
|
|
|
|
|
- if (parentId == -1) {
|
|
|
+ if (parentId == -1)
|
|
|
+ {
|
|
|
// 说明这是一级目录
|
|
|
m_pCModel->invisibleRootItem()->appendRow(childItem);
|
|
|
qDebug() << " !!!!! first :" << "child : " << currentId;
|
|
|
|
|
|
|
|
|
// 如果一级目录的 "Separator" == 1,则为其创建一条分割线
|
|
|
- if (dir["Separator"].toInt() == 1) {
|
|
|
+ if (dir["Separator"].toInt() == 1)
|
|
|
+ {
|
|
|
QFrame *sep = createUnifiedSeparator(m_pOriginalWndMenuPage, 2);
|
|
|
sep->hide();
|
|
|
m_mapFirstLevelSeparators.insert(childItem, sep);
|
|
|
}
|
|
|
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
// 非一级目录 => 子目录
|
|
|
QStandardItem *parentItem = idItemMap.value(parentId);
|
|
|
if (parentItem)
|
|
@@ -628,7 +642,9 @@ void DbTreeViewManager::buildTreeFromDirectories(const QList<QJsonObject> &direc
|
|
|
qDebug() << "parent:" << parentId << "child : " << currentId;
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
qWarning() << "无法找到 ParentId:" << parentId << "的父目录项";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1074,7 +1090,8 @@ void DbTreeViewManager::updateButtonsVisibility()
|
|
|
buttonLeft->hide();
|
|
|
buttonRight->hide();
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
// 其他配置,显示所有按钮
|
|
|
ButtonBack->show();
|
|
|
buttonUp->show();
|
|
@@ -1083,6 +1100,7 @@ void DbTreeViewManager::updateButtonsVisibility()
|
|
|
buttonRight->show();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
QStandardItem* DbTreeViewManager::deepCopyItem(const QStandardItem *item){
|
|
|
if (!item) {
|
|
|
return nullptr;
|