|
@@ -271,7 +271,7 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
CustomizeWndCall(m_pProgrammPage);
|
|
|
|
|
|
}
|
|
|
- else if (name == "Diagnosis")
|
|
|
+ else if (name == "Diagnosis") //TODO:yang 推荐后续定制页面都使用我这个
|
|
|
{
|
|
|
m_pDiagnosisPage = new DiagnosisPage();
|
|
|
CustomizeWndCall(m_pDiagnosisPage);
|
|
@@ -3064,6 +3064,7 @@ void DbTreeViewManager::onButtonBackClicked()
|
|
|
}
|
|
|
}
|
|
|
// 关闭并销毁字段展示窗口
|
|
|
+
|
|
|
m_thirdLevelFieldWnd->close();
|
|
|
m_thirdLevelFieldWnd->deleteLater();
|
|
|
m_thirdLevelFieldWnd = nullptr;
|
|
@@ -3893,8 +3894,6 @@ void DbTreeViewManager::displayThirdLevelButtons(const QList<CONFIG_BASE_STRUCT>
|
|
|
m_fieldWidgets.append(textLabel);
|
|
|
m_fieldWidgets.append(fLabel);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
void DbTreeViewManager::clearThirdLevelMenu()
|
|
@@ -3945,7 +3944,8 @@ void DbTreeViewManager::saveCheckedPaths()
|
|
|
// 加载选中路径
|
|
|
void DbTreeViewManager::loadCheckedPaths()
|
|
|
{
|
|
|
- if (m_currentConfigName == "") {
|
|
|
+ if (m_currentConfigName == "")
|
|
|
+ {
|
|
|
//qWarning() << "当前配置ID无效,无法加载复选框状态。";
|
|
|
return;
|
|
|
}
|
|
@@ -3970,30 +3970,39 @@ void DbTreeViewManager::loadCheckedPaths()
|
|
|
m_blockItemChanged = false;
|
|
|
|
|
|
// 更新导航栏
|
|
|
- if (!loadedChecked.isEmpty()) {
|
|
|
+ if (!loadedChecked.isEmpty())
|
|
|
+ {
|
|
|
QString lastPathStr = loadedChecked.last();
|
|
|
QStringList lastPath = lastPathStr.split("/");
|
|
|
QModelIndex lastIdx = findItemByPath(lastPath);
|
|
|
- if (lastIdx.isValid()) {
|
|
|
+ if (lastIdx.isValid())
|
|
|
+ {
|
|
|
m_pTreeViewDown->setCurrentIndex(lastIdx);
|
|
|
updateNavigationBar(lastIdx);
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
// 如果没有加载到任何路径,自动选择第一个目录
|
|
|
QStandardItem *rootItem = m_pCModel->invisibleRootItem();
|
|
|
- if (rootItem->rowCount() > 0) {
|
|
|
+ if (rootItem->rowCount() > 0)
|
|
|
+ {
|
|
|
QModelIndex firstIndex = m_pCModel->index(0, 0, QModelIndex());
|
|
|
- if (firstIndex.isValid()) {
|
|
|
+ if (firstIndex.isValid())
|
|
|
+ {
|
|
|
m_pTreeViewDown->setCurrentIndex(firstIndex);
|
|
|
m_pTreeViewDown->expand(firstIndex); // 展开第一个目录
|
|
|
|
|
|
QStandardItem *firstItem = m_pCModel->itemFromIndex(firstIndex);
|
|
|
QVariant data = firstItem->data(Qt::UserRole + 2);
|
|
|
- if (data.canConvert<QJsonObject>()) {
|
|
|
+ if (data.canConvert<QJsonObject>())
|
|
|
+ {
|
|
|
QJsonObject thirdLevelObj = data.toJsonObject();
|
|
|
- if (thirdLevelObj.contains("IsThirdLevel") && thirdLevelObj["IsThirdLevel"].toBool()) {
|
|
|
+ if (thirdLevelObj.contains("IsThirdLevel") && thirdLevelObj["IsThirdLevel"].toBool())
|
|
|
+ {
|
|
|
QString multiTableName = "";
|
|
|
- if (thirdLevelObj.contains("TableName")) {
|
|
|
+ if (thirdLevelObj.contains("TableName"))
|
|
|
+ {
|
|
|
multiTableName = thirdLevelObj["TableName"].toString();
|
|
|
}
|
|
|
QList<CONFIG_BASE_STRUCT> buttons;
|
|
@@ -4012,7 +4021,8 @@ void DbTreeViewManager::loadCheckedPaths()
|
|
|
// 保存展开路径
|
|
|
void DbTreeViewManager::saveExpandedPaths()
|
|
|
{
|
|
|
- if (m_currentConfigName == "") {
|
|
|
+ if (m_currentConfigName == "")
|
|
|
+ {
|
|
|
qWarning() << "当前配置ID无效,无法保存展开路径。";
|
|
|
return;
|
|
|
}
|
|
@@ -4159,40 +4169,49 @@ DbTreeViewManager::PageState DbTreeViewManager::getCurrentPageState()
|
|
|
st.directoryId = -1;
|
|
|
|
|
|
// 判断是否在第三层窗口中
|
|
|
- if (m_thirdLevelFieldWnd && m_thirdLevelFieldWnd->isVisible()) {
|
|
|
+ if (m_thirdLevelFieldWnd && m_thirdLevelFieldWnd->isVisible())
|
|
|
+ {
|
|
|
// 如果此时是在第三层界面,则用当前导航栏 or 目录树的 “选中项” 来获取路径
|
|
|
QModelIndex curIndex = m_pTreeViewDown->currentIndex();
|
|
|
- if (!curIndex.isValid()) {
|
|
|
-
|
|
|
+ if (!curIndex.isValid())
|
|
|
+ {
|
|
|
st.path << "未知目录";
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
QStandardItem* item = m_pCModel->itemFromIndex(curIndex);
|
|
|
st.path = buildItemPath(item);
|
|
|
}
|
|
|
|
|
|
// 如果能拿到 DirectoryId,则置为第三层
|
|
|
QVariant dataVar = m_pCModel->itemFromIndex(m_pTreeViewDown->currentIndex())->data(Qt::UserRole + 2);
|
|
|
- if (dataVar.canConvert<QJsonObject>()) {
|
|
|
+ if (dataVar.canConvert<QJsonObject>())
|
|
|
+ {
|
|
|
QJsonObject obj = dataVar.toJsonObject();
|
|
|
- if (obj.contains("IsThirdLevel") && obj["IsThirdLevel"].toBool()) {
|
|
|
+ if (obj.contains("IsThirdLevel") && obj["IsThirdLevel"].toBool())
|
|
|
+ {
|
|
|
st.isThirdLevel = true;
|
|
|
st.directoryId = obj.value("Id").toInt(-1);
|
|
|
st.multiTableName = obj.value("TableName").toString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
// 当前是目录树界面,就看 treeView 选中项
|
|
|
QModelIndex curIndex = m_pTreeViewDown->currentIndex();
|
|
|
- if (curIndex.isValid()) {
|
|
|
+ if (curIndex.isValid())
|
|
|
+ {
|
|
|
QStandardItem* item = m_pCModel->itemFromIndex(curIndex);
|
|
|
st.path = buildItemPath(item);
|
|
|
|
|
|
// 检查是否第三层
|
|
|
QVariant dataVar = item->data(Qt::UserRole + 2);
|
|
|
- if (dataVar.canConvert<QJsonObject>()) {
|
|
|
+ if (dataVar.canConvert<QJsonObject>())
|
|
|
+ {
|
|
|
QJsonObject obj = dataVar.toJsonObject();
|
|
|
- if (obj.contains("IsThirdLevel") && obj["IsThirdLevel"].toBool()) {
|
|
|
+ if (obj.contains("IsThirdLevel") && obj["IsThirdLevel"].toBool())
|
|
|
+ {
|
|
|
st.isThirdLevel = true;
|
|
|
st.directoryId = obj.value("Id").toInt(-1);
|
|
|
st.multiTableName = obj.value("TableName").toString();
|
|
@@ -4210,7 +4229,8 @@ void DbTreeViewManager::loadPageState(const PageState &st, bool isByHistoryNav)
|
|
|
{
|
|
|
// 先根据 st.path 找到对应的节点
|
|
|
QModelIndex idx = findItemByPath(st.path);
|
|
|
- if (!idx.isValid()) {
|
|
|
+ if (!idx.isValid())
|
|
|
+ {
|
|
|
qWarning() << "[loadPageState] 未找到路径" << st.path;
|
|
|
return;
|
|
|
}
|
|
@@ -4222,15 +4242,11 @@ void DbTreeViewManager::loadPageState(const PageState &st, bool isByHistoryNav)
|
|
|
// 更新导航栏
|
|
|
updateNavigationBar(idx);
|
|
|
|
|
|
- // 如果是第三层,就加载对应的数据窗口
|
|
|
- if (st.isThirdLevel && st.directoryId != -1) {
|
|
|
- // 如果当前已在一个第三层窗口,先关闭它
|
|
|
- if (m_thirdLevelFieldWnd) {
|
|
|
- m_thirdLevelFieldWnd->close();
|
|
|
- m_thirdLevelFieldWnd->deleteLater();
|
|
|
- m_thirdLevelFieldWnd = nullptr;
|
|
|
- }
|
|
|
+ DelMemoryWnd(m_thirdLevelFieldWnd);
|
|
|
|
|
|
+ // 如果是第三层,就加载对应的数据窗口
|
|
|
+ if (st.isThirdLevel && st.directoryId != -1)
|
|
|
+ {
|
|
|
int userPrivilege = 0x1;
|
|
|
QList<ST_TABLE_CONTROL_DATA> tableControlDatas;
|
|
|
bool allChangeFlag = false;
|
|
@@ -4238,25 +4254,28 @@ void DbTreeViewManager::loadPageState(const PageState &st, bool isByHistoryNav)
|
|
|
displayThirdLevelFields(tableControlDatas, allChangeFlag, false); // 传递参数表示 Home 界面
|
|
|
//QJsonObject data = fetchThirdLevelData(st.directoryId, userPrivilege);
|
|
|
//displayThirdLevelFields(data, (m_currentConfigName == "Home"));
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
// 否则,显示目录树
|
|
|
- if (m_thirdLevelFieldWnd) {
|
|
|
- m_thirdLevelFieldWnd->close();
|
|
|
- m_thirdLevelFieldWnd->deleteLater();
|
|
|
- m_thirdLevelFieldWnd = nullptr;
|
|
|
- }
|
|
|
m_pTreeViewDown->show();
|
|
|
- for (auto sep : m_mapFirstLevelSeparators) {
|
|
|
- if (sep) sep->show();
|
|
|
+ for (auto sep : m_mapFirstLevelSeparators)
|
|
|
+ {
|
|
|
+ if (sep)
|
|
|
+ {
|
|
|
+ sep->show();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!isByHistoryNav) {
|
|
|
+ if (!isByHistoryNav)
|
|
|
+ {
|
|
|
m_forwardStack.clear();
|
|
|
buttonRight->setIcon(QIcon(":/images/home_right.png"));
|
|
|
// 把新状态压入后退栈
|
|
|
m_backStack.append(st);
|
|
|
- if(m_backStack.size() >= 2){
|
|
|
+ if(m_backStack.size() >= 2)
|
|
|
+ {
|
|
|
buttonLeft->setIcon(QIcon(":/images/home_left.png"));
|
|
|
}
|
|
|
}
|
|
@@ -4270,10 +4289,12 @@ void DbTreeViewManager::loginput(const QString& fieldTableName, const QString& f
|
|
|
writeLogToFile(logMessage,pathoflog);
|
|
|
}
|
|
|
|
|
|
-void DbTreeViewManager::writeLogToFile(const QString& logMessage, const QString& filePath) {
|
|
|
+void DbTreeViewManager::writeLogToFile(const QString& logMessage, const QString& filePath)
|
|
|
+{
|
|
|
QFile logFile(filePath);
|
|
|
|
|
|
- if (!logFile.open(QIODevice::Append | QIODevice::Text)) {
|
|
|
+ if (!logFile.open(QIODevice::Append | QIODevice::Text))
|
|
|
+ {
|
|
|
qWarning() << "Cannot open file for writing:" << filePath;
|
|
|
return;
|
|
|
}
|