|
@@ -5,63 +5,48 @@
|
|
|
#include <QTextStream>
|
|
|
#include <QDateTime>
|
|
|
#include "Src/common/JMessageTip.h"
|
|
|
+#include "Src/common/JLogAllOutput.h"
|
|
|
#include "CViewInterface.h"
|
|
|
|
|
|
// 构造函数
|
|
|
-DbTreeViewManager::DbTreeViewManager(OriginalWnd* originalWnd, QWidget* widget2, QWidget* parent)
|
|
|
+DbTreeViewManager::DbTreeViewManager(QWidget* pOriginalWndMenuPage, QWidget* parent)
|
|
|
: QWidget(parent),
|
|
|
- m_originalWnd(originalWnd),
|
|
|
- widget2(widget2),
|
|
|
- treeViewDown(new QTreeView(this)),
|
|
|
- model(new QStandardItemModel(this)),
|
|
|
- restoring(false),
|
|
|
- m_blockItemChanged(false)
|
|
|
-
|
|
|
+ m_pOriginalWndMenuPage(pOriginalWndMenuPage)
|
|
|
{
|
|
|
- if (!widget2) {
|
|
|
- // qWarning() << "DbTreeViewManager: widget2 未初始化";
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //设置样式
|
|
|
-
|
|
|
-
|
|
|
- //创建数据库对象
|
|
|
- m_sqlOper = &SqlOperation::GetInstance();
|
|
|
-
|
|
|
+ m_originalWnd = dynamic_cast<OriginalWnd*>(parent);
|
|
|
+ Init();
|
|
|
|
|
|
// 设置模型
|
|
|
- treeViewDown->setModel(model);
|
|
|
- treeViewDown->setHeaderHidden(true);
|
|
|
- treeViewDown->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
+ m_pTreeViewDown->setModel(m_pCModel);
|
|
|
+ m_pTreeViewDown->setHeaderHidden(true);
|
|
|
+ m_pTreeViewDown->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
|
// 设置树视图的几何位置
|
|
|
- treeViewDown->setGeometry(16, 106, widget2->width() - 16, widget2->height() - 106);
|
|
|
+ m_pTreeViewDown->setGeometry(16, 106, m_pOriginalWndMenuPage->width() - 16, m_pOriginalWndMenuPage->height() - 106);
|
|
|
|
|
|
// 安装事件过滤器以自定义绘制虚线
|
|
|
- treeViewDown->viewport()->installEventFilter(this);
|
|
|
+ m_pTreeViewDown->viewport()->installEventFilter(this);
|
|
|
|
|
|
// 创建统一分隔线
|
|
|
- lineFrame1 = createUnifiedSeparator(widget2, 2);
|
|
|
- lineFrame1->setGeometry(16, 100, 460, 2);
|
|
|
+ m_pLineFrame1 = createUnifiedSeparator(m_pOriginalWndMenuPage, 2);
|
|
|
+ m_pLineFrame1->setGeometry(16, 100, 460, 2);
|
|
|
|
|
|
// 创建按钮并设置布局
|
|
|
setupButton();
|
|
|
|
|
|
// 创建导航栏
|
|
|
- navigationWidget = new QWidget(widget2);
|
|
|
- navigationWidget->setGeometry(15, 15, 300, 74);
|
|
|
+ m_pNavigationWidget = new QWidget(m_pOriginalWndMenuPage);
|
|
|
+ m_pNavigationWidget->setGeometry(15, 15, 300, 74);
|
|
|
|
|
|
// 连接目录前的复选框信号与槽
|
|
|
- connect(model, &QStandardItemModel::itemChanged, this, &DbTreeViewManager::onItemChanged);
|
|
|
+ connect(m_pCModel, &QStandardItemModel::itemChanged, this, &DbTreeViewManager::onItemChanged);
|
|
|
|
|
|
// 目录树连接点击信号
|
|
|
- connect(treeViewDown, &QTreeView::clicked, this, &DbTreeViewManager::onTreeViewClicked);
|
|
|
+ connect(m_pTreeViewDown, &QTreeView::clicked, this, &DbTreeViewManager::onTreeViewClicked);
|
|
|
|
|
|
// 连接目录 expanded 和 collapsed 信号
|
|
|
- connect(treeViewDown, &QTreeView::expanded, this, [=](const QModelIndex &index) {
|
|
|
- QStandardItem *item = model->itemFromIndex(index);
|
|
|
+ connect(m_pTreeViewDown, &QTreeView::expanded, this, [=](const QModelIndex &index) {
|
|
|
+ QStandardItem *item = m_pCModel->itemFromIndex(index);
|
|
|
if (!item) return;
|
|
|
|
|
|
QStringList path = buildItemPath(item);
|
|
@@ -72,8 +57,8 @@ DbTreeViewManager::DbTreeViewManager(OriginalWnd* originalWnd, QWidget* widget2,
|
|
|
saveExpandedPaths();
|
|
|
});
|
|
|
|
|
|
- connect(treeViewDown, &QTreeView::collapsed, this, [=](const QModelIndex &index) {
|
|
|
- QStandardItem *item = model->itemFromIndex(index);
|
|
|
+ connect(m_pTreeViewDown, &QTreeView::collapsed, this, [=](const QModelIndex &index) {
|
|
|
+ QStandardItem *item = m_pCModel->itemFromIndex(index);
|
|
|
if (!item) return;
|
|
|
|
|
|
QStringList path = buildItemPath(item);
|
|
@@ -88,7 +73,7 @@ DbTreeViewManager::DbTreeViewManager(OriginalWnd* originalWnd, QWidget* widget2,
|
|
|
|
|
|
// 所有展开操作完成后更新分隔线
|
|
|
QTimer::singleShot(0, this, [=]() {
|
|
|
- QStandardItem *rootItem = model->invisibleRootItem();
|
|
|
+ QStandardItem *rootItem = m_pCModel->invisibleRootItem();
|
|
|
QStandardItem *thirdItem = findFirstThirdLevelItemDFS(rootItem);
|
|
|
if (thirdItem)
|
|
|
{
|
|
@@ -110,7 +95,7 @@ DbTreeViewManager::DbTreeViewManager(OriginalWnd* originalWnd, QWidget* widget2,
|
|
|
});
|
|
|
|
|
|
// 应用自定义只读复选框委托
|
|
|
- treeViewDown->setItemDelegate(new NonInteractiveCheckDelegate(treeViewDown));
|
|
|
+ m_pTreeViewDown->setItemDelegate(new NonInteractiveCheckDelegate(m_pTreeViewDown));
|
|
|
menuArray[0] = {2, false,-1};
|
|
|
menuArray[1] = {5, false,-1};
|
|
|
menuArray[2] = {3, false,-1};
|
|
@@ -124,6 +109,14 @@ DbTreeViewManager::~DbTreeViewManager()
|
|
|
|
|
|
}
|
|
|
|
|
|
+void DbTreeViewManager::Init()
|
|
|
+{
|
|
|
+ m_pTreeViewDown = new QTreeView(this);
|
|
|
+ m_pCModel = new QStandardItemModel(this);
|
|
|
+
|
|
|
+ m_sqlOper = &SqlOperation::GetInstance();
|
|
|
+}
|
|
|
+
|
|
|
// 创建横线样式
|
|
|
QFrame* DbTreeViewManager::createUnifiedSeparator(QWidget *parent, int height)
|
|
|
{
|
|
@@ -137,7 +130,7 @@ QFrame* DbTreeViewManager::createUnifiedSeparator(QWidget *parent, int height)
|
|
|
|
|
|
// 目录树样式
|
|
|
void DbTreeViewManager::applyCustomStyles() {
|
|
|
- treeViewDown->setStyleSheet(R"(
|
|
|
+ m_pTreeViewDown->setStyleSheet(R"(
|
|
|
/* 设置分支图标 */
|
|
|
QTreeView::branch:closed:has-children {
|
|
|
border-image: none;
|
|
@@ -208,7 +201,11 @@ bool DbTreeViewManager::hasPrivilege(const int &UserGrade, const int &userPrivil
|
|
|
|
|
|
void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
{
|
|
|
- qDebug() << "Initializing tree with configId:" << name << "and userPrivilege:" << userPrivilege;
|
|
|
+ QString strLog = "Initializing tree with configId:";
|
|
|
+ strLog += name;
|
|
|
+ strLog += "and userPrivilege:";
|
|
|
+ strLog += userPrivilege;
|
|
|
+ JLogAllOutput::cmd_debug(strLog.toStdString());
|
|
|
|
|
|
m_currentConfigName = name; // 设置当前配置ID
|
|
|
// 先清空历史
|
|
@@ -216,13 +213,13 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
|
|
|
// 保存之前的选中/展开状态
|
|
|
m_blockItemChanged = true;
|
|
|
- restoring = true;
|
|
|
+ m_isRestoring = true;
|
|
|
|
|
|
// 清理当前的分隔线
|
|
|
clearAllSeparators();
|
|
|
|
|
|
// 清空已有模型数据和相关记录
|
|
|
- model->clear();
|
|
|
+ m_pCModel->clear();
|
|
|
firstLevelSeparators.clear();
|
|
|
expandedPaths.clear();
|
|
|
|
|
@@ -230,30 +227,30 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
clearThirdLevelMenu();
|
|
|
|
|
|
// **Home 界面逻辑**
|
|
|
- if (name == "Home") {
|
|
|
-
|
|
|
+ if (name == "Home")
|
|
|
+ {
|
|
|
// 隐藏目录树和分隔线
|
|
|
- treeViewDown->hide();
|
|
|
-
|
|
|
- for (auto separator : firstLevelSeparators) {
|
|
|
+ m_pTreeViewDown->hide();
|
|
|
+ for (auto separator : firstLevelSeparators)
|
|
|
+ {
|
|
|
if (separator)
|
|
|
+ {
|
|
|
separator->hide();
|
|
|
+ }
|
|
|
}
|
|
|
// 隐藏导航栏
|
|
|
- navigationWidget->hide();
|
|
|
+ m_pNavigationWidget->hide();
|
|
|
|
|
|
// 隐藏按钮
|
|
|
updateButtonsVisibility(); // 将按钮隐藏
|
|
|
|
|
|
// 隐藏特定的分隔线 lineFrame1
|
|
|
- if (lineFrame1) {
|
|
|
- lineFrame1->hide();
|
|
|
+ if (m_pLineFrame1)
|
|
|
+ {
|
|
|
+ m_pLineFrame1->hide();
|
|
|
}
|
|
|
|
|
|
// 从 BondHead 和 Buttons 表中加载 DirectoryId = 1 的数据
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
QList<Table_Control_Data> tableControlDatas;
|
|
|
bool allChangeFlag = false;
|
|
|
m_sqlOper->GetThirdDirControlData("HomeProduct", userPrivilege, tableControlDatas, allChangeFlag);
|
|
@@ -275,9 +272,9 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
} else {
|
|
|
// **其他配置逻辑**
|
|
|
// 设置 treeViewDown 的几何位置
|
|
|
- treeViewDown->setGeometry(16, 106, widget2->width() - 16, widget2->height() - 106);
|
|
|
+ m_pTreeViewDown->setGeometry(16, 106, m_pOriginalWndMenuPage->width() - 16, m_pOriginalWndMenuPage->height() - 106);
|
|
|
// 显示目录树和分隔线
|
|
|
- treeViewDown->show();
|
|
|
+ m_pTreeViewDown->show();
|
|
|
for (auto separator : firstLevelSeparators) {
|
|
|
if (separator)
|
|
|
separator->show();
|
|
@@ -286,14 +283,14 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
applyCustomStyles();
|
|
|
|
|
|
// 显示导航栏
|
|
|
- navigationWidget->show();
|
|
|
+ m_pNavigationWidget->show();
|
|
|
|
|
|
// 显示按钮
|
|
|
updateButtonsVisibility();
|
|
|
|
|
|
// 显示特定的分隔线 lineFrame1
|
|
|
- if (lineFrame1) {
|
|
|
- lineFrame1->show();
|
|
|
+ if (m_pLineFrame1) {
|
|
|
+ m_pLineFrame1->show();
|
|
|
}
|
|
|
|
|
|
// 加载目录数据 并进行权限判断
|
|
@@ -309,7 +306,7 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
|
|
|
m_blockItemChanged = false;
|
|
|
|
|
|
- restoring = false;
|
|
|
+ m_isRestoring = false;
|
|
|
|
|
|
// qDebug() << "Tree initialization completed.";
|
|
|
|
|
@@ -320,10 +317,10 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
loadCheckedPaths();
|
|
|
|
|
|
// 自动选中第一个根目录项并更新导航栏
|
|
|
- QStandardItem *rootItem = model->invisibleRootItem()->child(0);
|
|
|
+ QStandardItem *rootItem = m_pCModel->invisibleRootItem()->child(0);
|
|
|
if (rootItem) {
|
|
|
- QModelIndex rootIndex = model->indexFromItem(rootItem);
|
|
|
- treeViewDown->setCurrentIndex(rootIndex);
|
|
|
+ QModelIndex rootIndex = m_pCModel->indexFromItem(rootItem);
|
|
|
+ m_pTreeViewDown->setCurrentIndex(rootIndex);
|
|
|
updateNavigationBar(rootIndex);
|
|
|
|
|
|
// 如果当前根目录是三级目录,则加载其字段内容
|
|
@@ -385,7 +382,7 @@ void DbTreeViewManager::initializeTree(QString name, const int &userPrivilege)
|
|
|
//寻找第一个三级目录,显示第一个三级目录的按钮
|
|
|
|
|
|
// 自动找第一个三级目录
|
|
|
- QStandardItem *rootItem1 = model->invisibleRootItem();
|
|
|
+ QStandardItem *rootItem1 = m_pCModel->invisibleRootItem();
|
|
|
QStandardItem *firstThirdItem = findFirstThirdLevelItemDFS(rootItem1);
|
|
|
if (!firstThirdItem) {
|
|
|
// qDebug() << "[initializeTree] No third-level item found, do nothing.";
|
|
@@ -528,13 +525,13 @@ void DbTreeViewManager::buildTreeFromDirectories(const QList<QJsonObject> &direc
|
|
|
|
|
|
if (parentId == -1) {
|
|
|
// 说明这是一级目录
|
|
|
- model->invisibleRootItem()->appendRow(childItem);
|
|
|
+ m_pCModel->invisibleRootItem()->appendRow(childItem);
|
|
|
qDebug() << " !!!!! first :" << "child : " << currentId;
|
|
|
|
|
|
|
|
|
// 如果一级目录的 "Separator" == 1,则为其创建一条分割线
|
|
|
if (dir["Separator"].toInt() == 1) {
|
|
|
- QFrame *sep = createUnifiedSeparator(widget2, 2);
|
|
|
+ QFrame *sep = createUnifiedSeparator(m_pOriginalWndMenuPage, 2);
|
|
|
sep->hide();
|
|
|
firstLevelSeparators.insert(childItem, sep);
|
|
|
}
|
|
@@ -696,13 +693,13 @@ void DbTreeViewManager::buildTreeFromDirectories(const QList<QJsonObject> &direc
|
|
|
bool DbTreeViewManager::eventFilter(QObject *watched, QEvent *event)
|
|
|
{
|
|
|
// 拦截 Paint 事件
|
|
|
- if (watched == treeViewDown->viewport() && event->type() == QEvent::Paint)
|
|
|
+ if (watched == m_pTreeViewDown->viewport() && event->type() == QEvent::Paint)
|
|
|
{
|
|
|
// 进行默认绘制
|
|
|
bool handled = QWidget::eventFilter(watched, event);
|
|
|
|
|
|
// 使用 QPainter 叠加画“拐角线”
|
|
|
- QPainter painter(treeViewDown->viewport());
|
|
|
+ QPainter painter(m_pTreeViewDown->viewport());
|
|
|
if (!painter.isActive()) {
|
|
|
qWarning() << "Painter not active";
|
|
|
return handled;
|
|
@@ -725,11 +722,11 @@ bool DbTreeViewManager::eventFilter(QObject *watched, QEvent *event)
|
|
|
// 递归绘制所有分支
|
|
|
void DbTreeViewManager::paintAllBranches(const QModelIndex &parentIndex, QPainter &painter)
|
|
|
{
|
|
|
- int rowCount = model->rowCount(parentIndex);
|
|
|
+ int rowCount = m_pCModel->rowCount(parentIndex);
|
|
|
for(int i = 0; i < rowCount; ++i)
|
|
|
{
|
|
|
// 当前子节点
|
|
|
- QModelIndex childIndex = model->index(i, 0, parentIndex);
|
|
|
+ QModelIndex childIndex = m_pCModel->index(i, 0, parentIndex);
|
|
|
if (!childIndex.isValid()) continue;
|
|
|
|
|
|
// 1) 父->子拐角线
|
|
@@ -751,12 +748,12 @@ void DbTreeViewManager::drawParentChildLine(const QModelIndex &childIndex, QPain
|
|
|
QModelIndex parentIndex = childIndex.parent();
|
|
|
if (!parentIndex.isValid()) {
|
|
|
// “顶层节点”定义一个固定的起点 (rootX, rootY)
|
|
|
- int indent = treeViewDown->indentation();
|
|
|
+ int indent = m_pTreeViewDown->indentation();
|
|
|
int depth = 0; // 顶层节点深度为0
|
|
|
int branchX = (depth + 1) * indent - indent / 2; // 计算 branchX 基于缩进和深度
|
|
|
|
|
|
// 定义 rootY 为节点中心 Y
|
|
|
- QRect childRect = treeViewDown->visualRect(childIndex);
|
|
|
+ QRect childRect = m_pTreeViewDown->visualRect(childIndex);
|
|
|
if (!childRect.isValid())
|
|
|
return;
|
|
|
|
|
@@ -778,8 +775,8 @@ void DbTreeViewManager::drawParentChildLine(const QModelIndex &childIndex, QPain
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- QRect parentRect = treeViewDown->visualRect(parentIndex);
|
|
|
- QRect childRect = treeViewDown->visualRect(childIndex);
|
|
|
+ QRect parentRect = m_pTreeViewDown->visualRect(parentIndex);
|
|
|
+ QRect childRect = m_pTreeViewDown->visualRect(childIndex);
|
|
|
if (!parentRect.isValid() || !childRect.isValid()) {
|
|
|
// 父或子超出可视区域
|
|
|
return;
|
|
@@ -796,7 +793,7 @@ void DbTreeViewManager::drawParentChildLine(const QModelIndex &childIndex, QPain
|
|
|
p = p.parent();
|
|
|
}
|
|
|
|
|
|
- int indent = treeViewDown->indentation();
|
|
|
+ int indent = m_pTreeViewDown->indentation();
|
|
|
int branchX = depth * indent - indent / 2;
|
|
|
|
|
|
// branchX 不超出视图范围
|
|
@@ -825,14 +822,14 @@ void DbTreeViewManager::drawSiblingLine(const QModelIndex &childIndex, QPainter
|
|
|
|
|
|
// 下一个兄弟
|
|
|
int row = childIndex.row();
|
|
|
- int lastRow = model->rowCount(parentIndex) - 1;
|
|
|
+ int lastRow = m_pCModel->rowCount(parentIndex) - 1;
|
|
|
if (row >= lastRow) {
|
|
|
return; // 说明是最后一个兄弟,不用画延伸线
|
|
|
}
|
|
|
|
|
|
- QModelIndex nextSibling = model->index(row + 1, 0, parentIndex);
|
|
|
- QRect currRect = treeViewDown->visualRect(childIndex);
|
|
|
- QRect nextRect = treeViewDown->visualRect(nextSibling);
|
|
|
+ QModelIndex nextSibling = m_pCModel->index(row + 1, 0, parentIndex);
|
|
|
+ QRect currRect = m_pTreeViewDown->visualRect(childIndex);
|
|
|
+ QRect nextRect = m_pTreeViewDown->visualRect(nextSibling);
|
|
|
if (!currRect.isValid() || !nextRect.isValid()) {
|
|
|
return;
|
|
|
}
|
|
@@ -845,7 +842,7 @@ void DbTreeViewManager::drawSiblingLine(const QModelIndex &childIndex, QPainter
|
|
|
p = p.parent();
|
|
|
}
|
|
|
|
|
|
- int indent = treeViewDown->indentation();
|
|
|
+ int indent = m_pTreeViewDown->indentation();
|
|
|
int branchX = depth * indent - indent / 2;
|
|
|
|
|
|
// 确保 branchX 不超出视图范围
|
|
@@ -892,7 +889,7 @@ QStandardItem* DbTreeViewManager::findFirstThirdLevelItemDFS(QStandardItem *pare
|
|
|
|
|
|
void DbTreeViewManager::onItemChanged(QStandardItem *item)
|
|
|
{
|
|
|
- if (m_blockItemChanged || restoring) {
|
|
|
+ if (m_blockItemChanged || m_isRestoring) {
|
|
|
return; // 防止递归和恢复期间触发
|
|
|
}
|
|
|
|
|
@@ -913,7 +910,7 @@ void DbTreeViewManager::onItemChanged(QStandardItem *item)
|
|
|
// 更新所有父项的复选框状态
|
|
|
QModelIndex parentIndex = item->index().parent();
|
|
|
while (parentIndex.isValid()) {
|
|
|
- QStandardItem *parentItem = model->itemFromIndex(parentIndex);
|
|
|
+ QStandardItem *parentItem = m_pCModel->itemFromIndex(parentIndex);
|
|
|
if (!parentItem) break;
|
|
|
|
|
|
int checkedCount = 0;
|
|
@@ -1035,7 +1032,7 @@ void DbTreeViewManager::loadpage(const int &configId){
|
|
|
|
|
|
void DbTreeViewManager::onTreeViewClicked(const QModelIndex &index)
|
|
|
{
|
|
|
- QStandardItem *item = model->itemFromIndex(index);
|
|
|
+ QStandardItem *item = m_pCModel->itemFromIndex(index);
|
|
|
if (!item) return;
|
|
|
// 是否第三层,提取第三层的目录ID及目录表格名字
|
|
|
bool isThird = false;
|
|
@@ -1126,7 +1123,7 @@ void DbTreeViewManager::onTreeViewClicked(const QModelIndex &index)
|
|
|
}
|
|
|
|
|
|
void DbTreeViewManager::onTreeViewClicked_updown(const QModelIndex &index){
|
|
|
- QStandardItem *item = model->itemFromIndex(index);
|
|
|
+ QStandardItem *item = m_pCModel->itemFromIndex(index);
|
|
|
if (!item) return;
|
|
|
// 是否第三层
|
|
|
bool isThird = false;
|
|
@@ -1211,22 +1208,22 @@ void DbTreeViewManager::onTreeViewClicked_updown(const QModelIndex &index){
|
|
|
|
|
|
void DbTreeViewManager::updateNavigationBar(const QModelIndex &index)
|
|
|
{
|
|
|
- QStandardItem *item = model->itemFromIndex(index);
|
|
|
+ QStandardItem *item = m_pCModel->itemFromIndex(index);
|
|
|
if (!item) {
|
|
|
qWarning() << "导航栏更新失败:未找到对应项";
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 清理现有布局
|
|
|
- if (navigationWidget->layout()) {
|
|
|
+ if (m_pNavigationWidget->layout()) {
|
|
|
QLayoutItem *child;
|
|
|
- while ((child = navigationWidget->layout()->takeAt(0)) != nullptr) {
|
|
|
+ while ((child = m_pNavigationWidget->layout()->takeAt(0)) != nullptr) {
|
|
|
if (child->widget()) {
|
|
|
child->widget()->deleteLater();
|
|
|
}
|
|
|
delete child;
|
|
|
}
|
|
|
- delete navigationWidget->layout();
|
|
|
+ delete m_pNavigationWidget->layout();
|
|
|
}
|
|
|
|
|
|
// 构建路径列表,从当前项回溯到根节点
|
|
@@ -1260,14 +1257,14 @@ void DbTreeViewManager::updateNavigationBar(const QModelIndex &index)
|
|
|
font.setBold(true); // 设置文字为粗体
|
|
|
font.setLetterSpacing(QFont::PercentageSpacing,105); // 设置字间距100%为默认
|
|
|
label->setFont(font);
|
|
|
- label->setFixedHeight(navigationWidget->height() / 3);
|
|
|
+ label->setFixedHeight(m_pNavigationWidget->height() / 3);
|
|
|
|
|
|
newLayout->addWidget(label);
|
|
|
}
|
|
|
|
|
|
// 设置布局并更新导航栏
|
|
|
- navigationWidget->setLayout(newLayout);
|
|
|
- navigationWidget->update();
|
|
|
+ m_pNavigationWidget->setLayout(newLayout);
|
|
|
+ m_pNavigationWidget->update();
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1291,7 +1288,7 @@ void DbTreeViewManager::clearAllSeparators()
|
|
|
void DbTreeViewManager::updateSeparatorLine()
|
|
|
{
|
|
|
// 如果目录树被隐藏,就把分割线都藏起来
|
|
|
- if (!treeViewDown->isVisible()) {
|
|
|
+ if (!m_pTreeViewDown->isVisible()) {
|
|
|
for (auto it = firstLevelSeparators.begin(); it != firstLevelSeparators.end(); ++it) {
|
|
|
QFrame *sep = it.value();
|
|
|
if (sep) sep->hide();
|
|
@@ -1306,8 +1303,8 @@ void DbTreeViewManager::updateSeparatorLine()
|
|
|
if (!firstLevelItem || !separator) continue;
|
|
|
|
|
|
// 拿到可视区域
|
|
|
- QModelIndex firstLevelIndex = model->indexFromItem(firstLevelItem);
|
|
|
- QRect firstLevelRect = treeViewDown->visualRect(firstLevelIndex);
|
|
|
+ QModelIndex firstLevelIndex = m_pCModel->indexFromItem(firstLevelItem);
|
|
|
+ QRect firstLevelRect = m_pTreeViewDown->visualRect(firstLevelIndex);
|
|
|
|
|
|
// 如果这个一级目录滚动到看不见了,就把分割线也藏起来
|
|
|
if (!firstLevelRect.isValid()) {
|
|
@@ -1316,13 +1313,13 @@ void DbTreeViewManager::updateSeparatorLine()
|
|
|
}
|
|
|
|
|
|
// 如果展开并且它有子节点,就找“最后一个可见子项”
|
|
|
- if (treeViewDown->isExpanded(firstLevelIndex) && firstLevelItem->hasChildren()) {
|
|
|
+ if (m_pTreeViewDown->isExpanded(firstLevelIndex) && firstLevelItem->hasChildren()) {
|
|
|
QModelIndex lastVisibleChild = findLastVisibleChild(firstLevelIndex);
|
|
|
if (lastVisibleChild.isValid()) {
|
|
|
- QRect lastChildRect = treeViewDown->visualRect(lastVisibleChild);
|
|
|
+ QRect lastChildRect = m_pTreeViewDown->visualRect(lastVisibleChild);
|
|
|
if (lastChildRect.isValid()) {
|
|
|
// 将分割线放在最后一个子项下面
|
|
|
- separator->setGeometry(16,lastChildRect.bottom() + 115,widget2->width() - 40,1);
|
|
|
+ separator->setGeometry(16,lastChildRect.bottom() + 115, m_pOriginalWndMenuPage->width() - 40,1);
|
|
|
separator->show();
|
|
|
continue;
|
|
|
}
|
|
@@ -1330,7 +1327,7 @@ void DbTreeViewManager::updateSeparatorLine()
|
|
|
}
|
|
|
|
|
|
// 如果收起或找不到可见子项,就放在本一级目录下面
|
|
|
- separator->setGeometry(16,firstLevelRect.bottom() + 115,widget2->width() - 40,1);
|
|
|
+ separator->setGeometry(16,firstLevelRect.bottom() + 115, m_pOriginalWndMenuPage->width() - 40,1);
|
|
|
separator->show();
|
|
|
}
|
|
|
}
|
|
@@ -1339,13 +1336,13 @@ void DbTreeViewManager::updateSeparatorLine()
|
|
|
QModelIndex DbTreeViewManager::findLastVisibleChild(const QModelIndex &parentIndex) {
|
|
|
if (!parentIndex.isValid()) return QModelIndex();
|
|
|
|
|
|
- int childCount = model->rowCount(parentIndex);
|
|
|
+ int childCount = m_pCModel->rowCount(parentIndex);
|
|
|
QModelIndex lastVisible;
|
|
|
|
|
|
for (int i = childCount - 1; i >= 0; --i) {
|
|
|
- QModelIndex childIndex = model->index(i, 0, parentIndex);
|
|
|
- if (!treeViewDown->isRowHidden(i, parentIndex)) {
|
|
|
- if (treeViewDown->isExpanded(childIndex) && model->rowCount(childIndex) > 0) {
|
|
|
+ QModelIndex childIndex = m_pCModel->index(i, 0, parentIndex);
|
|
|
+ if (!m_pTreeViewDown->isRowHidden(i, parentIndex)) {
|
|
|
+ if (m_pTreeViewDown->isExpanded(childIndex) && m_pCModel->rowCount(childIndex) > 0) {
|
|
|
QModelIndex deeper = findLastVisibleChild(childIndex);
|
|
|
if (deeper.isValid()) {
|
|
|
return deeper;
|
|
@@ -1893,10 +1890,10 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
}
|
|
|
|
|
|
// 获取当前选中的目录项,设置状态
|
|
|
- QModelIndex currentIndex = treeViewDown->currentIndex();
|
|
|
+ QModelIndex currentIndex = m_pTreeViewDown->currentIndex();
|
|
|
if (currentIndex.isValid())
|
|
|
{
|
|
|
- QStandardItem* currentItem = model->itemFromIndex(currentIndex);
|
|
|
+ QStandardItem* currentItem = m_pCModel->itemFromIndex(currentIndex);
|
|
|
if (currentItem)
|
|
|
{
|
|
|
currentItem->setCheckState(allChangeFlag ? Qt::Checked : Qt::Unchecked);
|
|
@@ -1908,7 +1905,7 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
}
|
|
|
|
|
|
// 隐藏目录树及所有分隔线
|
|
|
- treeViewDown->hide();
|
|
|
+ m_pTreeViewDown->hide();
|
|
|
for (auto separator : firstLevelSeparators)
|
|
|
{
|
|
|
if (separator)
|
|
@@ -1919,17 +1916,17 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<Table_Control_Data>&
|
|
|
m_fieldWidgets.clear();
|
|
|
|
|
|
// 创建新的 "字段展示" 窗口,并赋值给 m_thirdLevelFieldWnd
|
|
|
- m_thirdLevelFieldWnd = new QWidget(widget2);
|
|
|
+ m_thirdLevelFieldWnd = new QWidget(m_pOriginalWndMenuPage);
|
|
|
m_thirdLevelFieldWnd->setWindowTitle("字段展示");
|
|
|
m_thirdLevelFieldWnd->setStyleSheet("background-color: transparent;");
|
|
|
if (isHome)
|
|
|
{
|
|
|
// Home 界面,填满 widget2
|
|
|
- m_thirdLevelFieldWnd->setGeometry(0, 0, widget2->width(), widget2->height());
|
|
|
+ m_thirdLevelFieldWnd->setGeometry(0, 0, m_pOriginalWndMenuPage->width(), m_pOriginalWndMenuPage->height());
|
|
|
} else
|
|
|
{
|
|
|
// 其他配置界面,设置与 treeViewDown 相同的几何位置
|
|
|
- m_thirdLevelFieldWnd->setGeometry(treeViewDown->geometry());
|
|
|
+ m_thirdLevelFieldWnd->setGeometry(m_pTreeViewDown->geometry());
|
|
|
}
|
|
|
|
|
|
// 创建滚动区域
|
|
@@ -2502,7 +2499,7 @@ void DbTreeViewManager::onButtonBackClicked()
|
|
|
m_thirdLevelFieldWnd = nullptr;
|
|
|
|
|
|
// 显示目录树和分隔线
|
|
|
- treeViewDown->show();
|
|
|
+ m_pTreeViewDown->show();
|
|
|
for (auto separator : firstLevelSeparators) {
|
|
|
if (separator)
|
|
|
separator->show();
|
|
@@ -2510,7 +2507,7 @@ void DbTreeViewManager::onButtonBackClicked()
|
|
|
|
|
|
// 获取当前导航路径
|
|
|
QStringList path;
|
|
|
- QLayout* layout = navigationWidget->layout();
|
|
|
+ QLayout* layout = m_pNavigationWidget->layout();
|
|
|
if (!layout) {
|
|
|
qWarning() << "导航栏没有布局,无法获取路径。";
|
|
|
return;
|
|
@@ -2549,14 +2546,14 @@ void DbTreeViewManager::onButtonBackClicked()
|
|
|
}
|
|
|
|
|
|
// 选中父目录项
|
|
|
- treeViewDown->setCurrentIndex(parentIndex);
|
|
|
- treeViewDown->scrollTo(parentIndex);
|
|
|
+ m_pTreeViewDown->setCurrentIndex(parentIndex);
|
|
|
+ m_pTreeViewDown->scrollTo(parentIndex);
|
|
|
|
|
|
// 更新导航栏
|
|
|
updateNavigationBar(parentIndex);
|
|
|
|
|
|
// 检查父目录是否为第三层目录
|
|
|
- QStandardItem* parentItem = model->itemFromIndex(parentIndex);
|
|
|
+ QStandardItem* parentItem = m_pCModel->itemFromIndex(parentIndex);
|
|
|
if (!parentItem) {
|
|
|
qWarning() << "父目录项无效。";
|
|
|
return;
|
|
@@ -2599,7 +2596,7 @@ void DbTreeViewManager::onButtonBackClicked()
|
|
|
//displayThirdLevelFields(data, false); // 传递参数表示非 Home 界面
|
|
|
} else {
|
|
|
// 父目录不是第三层目录,确保目录树和分隔线可见
|
|
|
- treeViewDown->show();
|
|
|
+ m_pTreeViewDown->show();
|
|
|
for (auto separator : firstLevelSeparators) {
|
|
|
if (separator)
|
|
|
separator->show();
|
|
@@ -2611,13 +2608,13 @@ void DbTreeViewManager::onButtonBackClicked()
|
|
|
// 如果不在第三层目录,则在目录树中返回上一层
|
|
|
qDebug() << "当前不在第三层目录,尝试在目录树中返回上一层。";
|
|
|
|
|
|
- QModelIndex currentIndex = treeViewDown->currentIndex();
|
|
|
+ QModelIndex currentIndex = m_pTreeViewDown->currentIndex();
|
|
|
if (!currentIndex.isValid()) {
|
|
|
qWarning() << "当前没有选中的目录项,无法返回。";
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- QStandardItem* currentItem = model->itemFromIndex(currentIndex);
|
|
|
+ QStandardItem* currentItem = m_pCModel->itemFromIndex(currentIndex);
|
|
|
if (!currentItem) {
|
|
|
qWarning() << "当前选中的目录项无效。";
|
|
|
return;
|
|
@@ -2629,15 +2626,15 @@ void DbTreeViewManager::onButtonBackClicked()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- QModelIndex parentIndex = model->indexFromItem(parentItem);
|
|
|
+ QModelIndex parentIndex = m_pCModel->indexFromItem(parentItem);
|
|
|
if (!parentIndex.isValid()) {
|
|
|
qWarning() << "父目录的 QModelIndex 无效。";
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 选中父目录项
|
|
|
- treeViewDown->setCurrentIndex(parentIndex);
|
|
|
- treeViewDown->scrollTo(parentIndex);
|
|
|
+ m_pTreeViewDown->setCurrentIndex(parentIndex);
|
|
|
+ m_pTreeViewDown->scrollTo(parentIndex);
|
|
|
|
|
|
// 更新导航栏
|
|
|
updateNavigationBar(parentIndex);
|
|
@@ -2682,7 +2679,7 @@ QList<QStandardItem*> DbTreeViewManager::collectAllThirdLevelItems()
|
|
|
{
|
|
|
QList<QStandardItem*> result;
|
|
|
// 从根节点开始递归搜集
|
|
|
- QStandardItem *root = model->invisibleRootItem();
|
|
|
+ QStandardItem *root = m_pCModel->invisibleRootItem();
|
|
|
if (!root) return result;
|
|
|
|
|
|
std::function<void(QStandardItem*)> dfsCollectThirdLevel;
|
|
@@ -2723,13 +2720,13 @@ void DbTreeViewManager::onButtonDownClicked()
|
|
|
}
|
|
|
|
|
|
// 2) 找到 当前选中的节点 在 thirdLevelList 里的索引
|
|
|
- QModelIndex curIndex = treeViewDown->currentIndex();
|
|
|
+ QModelIndex curIndex = m_pTreeViewDown->currentIndex();
|
|
|
if (!curIndex.isValid()) {
|
|
|
qDebug() << "[onButtonDownClicked] 当前没有选中节点,默认跳到第一个三级目录。";
|
|
|
// 如果想默认跳到第一个
|
|
|
QStandardItem *firstItem = thirdLevelList.first();
|
|
|
- QModelIndex idx = model->indexFromItem(firstItem);
|
|
|
- treeViewDown->setCurrentIndex(idx);
|
|
|
+ QModelIndex idx = m_pCModel->indexFromItem(firstItem);
|
|
|
+ m_pTreeViewDown->setCurrentIndex(idx);
|
|
|
// 模拟点击一下
|
|
|
onTreeViewClicked_updown(idx);
|
|
|
// 保存复选框状态
|
|
@@ -2739,7 +2736,7 @@ void DbTreeViewManager::onButtonDownClicked()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- QStandardItem *curItem = model->itemFromIndex(curIndex);
|
|
|
+ QStandardItem *curItem = m_pCModel->itemFromIndex(curIndex);
|
|
|
if (!curItem) {
|
|
|
qWarning() << "[onButtonDownClicked] currentItem 无效。";
|
|
|
return;
|
|
@@ -2765,8 +2762,8 @@ void DbTreeViewManager::onButtonDownClicked()
|
|
|
if (currentPos < 0) {
|
|
|
qDebug() << "还是找不到,说明当前目录不属于任何三级目录,直接跳到第一个";
|
|
|
QStandardItem *firstItem = thirdLevelList.first();
|
|
|
- QModelIndex idx = model->indexFromItem(firstItem);
|
|
|
- treeViewDown->setCurrentIndex(idx);
|
|
|
+ QModelIndex idx = m_pCModel->indexFromItem(firstItem);
|
|
|
+ m_pTreeViewDown->setCurrentIndex(idx);
|
|
|
onTreeViewClicked_updown(idx);
|
|
|
// 保存复选框状态
|
|
|
saveCheckedPaths();
|
|
@@ -2786,8 +2783,8 @@ void DbTreeViewManager::onButtonDownClicked()
|
|
|
|
|
|
// 跳到下一个
|
|
|
QStandardItem *nextItem = thirdLevelList[nextPos];
|
|
|
- QModelIndex nextIndex = model->indexFromItem(nextItem);
|
|
|
- treeViewDown->setCurrentIndex(nextIndex);
|
|
|
+ QModelIndex nextIndex = m_pCModel->indexFromItem(nextItem);
|
|
|
+ m_pTreeViewDown->setCurrentIndex(nextIndex);
|
|
|
// 相当于模拟点击
|
|
|
onTreeViewClicked_updown(nextIndex);
|
|
|
// 保存复选框状态
|
|
@@ -2806,13 +2803,13 @@ void DbTreeViewManager::onButtonUpClicked()
|
|
|
}
|
|
|
|
|
|
// 2) 找到 当前选中的节点
|
|
|
- QModelIndex curIndex = treeViewDown->currentIndex();
|
|
|
+ QModelIndex curIndex = m_pTreeViewDown->currentIndex();
|
|
|
if (!curIndex.isValid()) {
|
|
|
qDebug() << "[onButtonUpClicked] 当前无选中节点,默认跳到最后一个三级目录。";
|
|
|
// 跳到最后一个
|
|
|
QStandardItem *lastItem = thirdLevelList.last();
|
|
|
- QModelIndex idx = model->indexFromItem(lastItem);
|
|
|
- treeViewDown->setCurrentIndex(idx);
|
|
|
+ QModelIndex idx = m_pCModel->indexFromItem(lastItem);
|
|
|
+ m_pTreeViewDown->setCurrentIndex(idx);
|
|
|
// 模拟点击
|
|
|
onTreeViewClicked_updown(idx);
|
|
|
// 保存复选框状态
|
|
@@ -2822,7 +2819,7 @@ void DbTreeViewManager::onButtonUpClicked()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- QStandardItem *curItem = model->itemFromIndex(curIndex);
|
|
|
+ QStandardItem *curItem = m_pCModel->itemFromIndex(curIndex);
|
|
|
if (!curItem) {
|
|
|
qWarning() << "[onButtonUpClicked] currentItem 无效。";
|
|
|
return;
|
|
@@ -2844,8 +2841,8 @@ void DbTreeViewManager::onButtonUpClicked()
|
|
|
if (currentPos < 0) {
|
|
|
qDebug() << "找不到任何三级目录,直接跳到最后一个。";
|
|
|
QStandardItem *lastItem = thirdLevelList.last();
|
|
|
- QModelIndex idx = model->indexFromItem(lastItem);
|
|
|
- treeViewDown->setCurrentIndex(idx);
|
|
|
+ QModelIndex idx = m_pCModel->indexFromItem(lastItem);
|
|
|
+ m_pTreeViewDown->setCurrentIndex(idx);
|
|
|
onTreeViewClicked_updown(idx);
|
|
|
// 保存复选框状态
|
|
|
saveCheckedPaths();
|
|
@@ -2864,8 +2861,8 @@ void DbTreeViewManager::onButtonUpClicked()
|
|
|
|
|
|
// 跳到上一个
|
|
|
QStandardItem *prevItem = thirdLevelList[prevPos];
|
|
|
- QModelIndex prevIndex = model->indexFromItem(prevItem);
|
|
|
- treeViewDown->setCurrentIndex(prevIndex);
|
|
|
+ QModelIndex prevIndex = m_pCModel->indexFromItem(prevItem);
|
|
|
+ m_pTreeViewDown->setCurrentIndex(prevIndex);
|
|
|
// 模拟点击
|
|
|
onTreeViewClicked_updown(prevIndex);
|
|
|
// 保存复选框状态
|
|
@@ -2942,7 +2939,7 @@ QModelIndex DbTreeViewManager::findItemByPath(const QStringList &path)
|
|
|
{
|
|
|
if (path.isEmpty()) return QModelIndex();
|
|
|
|
|
|
- QStandardItem *currentItem = model->invisibleRootItem();
|
|
|
+ QStandardItem *currentItem = m_pCModel->invisibleRootItem();
|
|
|
QModelIndex currentIndex;
|
|
|
|
|
|
for (const QString &part : path) {
|
|
@@ -2954,7 +2951,7 @@ QModelIndex DbTreeViewManager::findItemByPath(const QStringList &path)
|
|
|
qDebug() << "child is nullptr";
|
|
|
}
|
|
|
if (child->text() == part) {
|
|
|
- currentIndex = model->indexFromItem(child);
|
|
|
+ currentIndex = m_pCModel->indexFromItem(child);
|
|
|
currentItem = child;
|
|
|
found = true;
|
|
|
qDebug() << "找到路径部分:" << part;
|
|
@@ -2980,7 +2977,7 @@ void DbTreeViewManager::setCheckedPaths(const QStringList &checkedPathsList)
|
|
|
QStringList path = pathStr.split("/");
|
|
|
QModelIndex idx = findItemByPath(path);
|
|
|
if (idx.isValid()) {
|
|
|
- QStandardItem *item = model->itemFromIndex(idx);
|
|
|
+ QStandardItem *item = m_pCModel->itemFromIndex(idx);
|
|
|
if (item) {
|
|
|
item->setCheckState(Qt::Checked);
|
|
|
qDebug() << " Setting item:" << item->text() << "to Checked";
|
|
@@ -3000,7 +2997,7 @@ QStringList DbTreeViewManager::collectCheckedPathsRecursive(QStandardItem *item,
|
|
|
{
|
|
|
QStringList checkedList;
|
|
|
if (!item) {
|
|
|
- item = model->invisibleRootItem();
|
|
|
+ item = m_pCModel->invisibleRootItem();
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < item->rowCount(); ++i) {
|
|
@@ -3024,7 +3021,7 @@ QStringList DbTreeViewManager::collectCheckedPathsRecursive(QStandardItem *item,
|
|
|
// 收集所有被选中的复选框路径
|
|
|
QStringList DbTreeViewManager::collectCheckedPaths()
|
|
|
{
|
|
|
- return collectCheckedPathsRecursive(model->invisibleRootItem(), QStringList());
|
|
|
+ return collectCheckedPathsRecursive(m_pCModel->invisibleRootItem(), QStringList());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -3330,7 +3327,7 @@ void DbTreeViewManager::displayThirdLevelButtons(const QList<CONFIG_BASE_STRUCT>
|
|
|
void DbTreeViewManager::clearThirdLevelMenu()
|
|
|
{
|
|
|
// 遍历所有子控件,找到标题为 "字段展示" 的窗口并关闭
|
|
|
- foreach (QObject *child, widget2->children()) {
|
|
|
+ foreach (QObject *child, m_pOriginalWndMenuPage->children()) {
|
|
|
QWidget *childWidget = qobject_cast<QWidget*>(child);
|
|
|
if (childWidget && childWidget->windowTitle() == "字段展示") {
|
|
|
qDebug() << "关闭现有的字段展示窗口";
|
|
@@ -3339,7 +3336,7 @@ void DbTreeViewManager::clearThirdLevelMenu()
|
|
|
}
|
|
|
|
|
|
// 显示主目录树和分隔线
|
|
|
- treeViewDown->show();
|
|
|
+ m_pTreeViewDown->show();
|
|
|
for (auto separator : firstLevelSeparators) {
|
|
|
separator->show();
|
|
|
}
|
|
@@ -3402,19 +3399,19 @@ void DbTreeViewManager::loadCheckedPaths()
|
|
|
QStringList lastPath = lastPathStr.split("/");
|
|
|
QModelIndex lastIdx = findItemByPath(lastPath);
|
|
|
if (lastIdx.isValid()) {
|
|
|
- treeViewDown->setCurrentIndex(lastIdx);
|
|
|
+ m_pTreeViewDown->setCurrentIndex(lastIdx);
|
|
|
updateNavigationBar(lastIdx);
|
|
|
}
|
|
|
} else {
|
|
|
// 如果没有加载到任何路径,自动选择第一个目录
|
|
|
- QStandardItem *rootItem = model->invisibleRootItem();
|
|
|
+ QStandardItem *rootItem = m_pCModel->invisibleRootItem();
|
|
|
if (rootItem->rowCount() > 0) {
|
|
|
- QModelIndex firstIndex = model->index(0, 0, QModelIndex());
|
|
|
+ QModelIndex firstIndex = m_pCModel->index(0, 0, QModelIndex());
|
|
|
if (firstIndex.isValid()) {
|
|
|
- treeViewDown->setCurrentIndex(firstIndex);
|
|
|
- treeViewDown->expand(firstIndex); // 展开第一个目录
|
|
|
+ m_pTreeViewDown->setCurrentIndex(firstIndex);
|
|
|
+ m_pTreeViewDown->expand(firstIndex); // 展开第一个目录
|
|
|
|
|
|
- QStandardItem *firstItem = model->itemFromIndex(firstIndex);
|
|
|
+ QStandardItem *firstItem = m_pCModel->itemFromIndex(firstIndex);
|
|
|
QVariant data = firstItem->data(Qt::UserRole + 2);
|
|
|
if (data.canConvert<QJsonObject>()) {
|
|
|
QJsonObject thirdLevelObj = data.toJsonObject();
|
|
@@ -3487,7 +3484,7 @@ void DbTreeViewManager::loadExpandedPaths()
|
|
|
QStringList path = p.split("/");
|
|
|
QModelIndex idx = findItemByPath(path);
|
|
|
if (idx.isValid()) {
|
|
|
- treeViewDown->expand(idx);
|
|
|
+ m_pTreeViewDown->expand(idx);
|
|
|
expandedPaths.insert(p);
|
|
|
qDebug() << "成功恢复展开路径:" << p;
|
|
|
} else {
|
|
@@ -3518,17 +3515,17 @@ DbTreeViewManager::PageState DbTreeViewManager::getCurrentPageState()
|
|
|
// 判断是否在第三层窗口中
|
|
|
if (m_thirdLevelFieldWnd && m_thirdLevelFieldWnd->isVisible()) {
|
|
|
// 如果此时是在第三层界面,则用当前导航栏 or 目录树的 “选中项” 来获取路径
|
|
|
- QModelIndex curIndex = treeViewDown->currentIndex();
|
|
|
+ QModelIndex curIndex = m_pTreeViewDown->currentIndex();
|
|
|
if (!curIndex.isValid()) {
|
|
|
|
|
|
st.path << "未知目录";
|
|
|
} else {
|
|
|
- QStandardItem* item = model->itemFromIndex(curIndex);
|
|
|
+ QStandardItem* item = m_pCModel->itemFromIndex(curIndex);
|
|
|
st.path = buildItemPath(item);
|
|
|
}
|
|
|
|
|
|
// 如果能拿到 DirectoryId,则置为第三层
|
|
|
- QVariant dataVar = model->itemFromIndex(treeViewDown->currentIndex())->data(Qt::UserRole + 2);
|
|
|
+ QVariant dataVar = m_pCModel->itemFromIndex(m_pTreeViewDown->currentIndex())->data(Qt::UserRole + 2);
|
|
|
if (dataVar.canConvert<QJsonObject>()) {
|
|
|
QJsonObject obj = dataVar.toJsonObject();
|
|
|
if (obj.contains("IsThirdLevel") && obj["IsThirdLevel"].toBool()) {
|
|
@@ -3540,9 +3537,9 @@ DbTreeViewManager::PageState DbTreeViewManager::getCurrentPageState()
|
|
|
}
|
|
|
else {
|
|
|
// 当前是目录树界面,就看 treeView 选中项
|
|
|
- QModelIndex curIndex = treeViewDown->currentIndex();
|
|
|
+ QModelIndex curIndex = m_pTreeViewDown->currentIndex();
|
|
|
if (curIndex.isValid()) {
|
|
|
- QStandardItem* item = model->itemFromIndex(curIndex);
|
|
|
+ QStandardItem* item = m_pCModel->itemFromIndex(curIndex);
|
|
|
st.path = buildItemPath(item);
|
|
|
|
|
|
// 检查是否第三层
|
|
@@ -3573,8 +3570,8 @@ void DbTreeViewManager::loadPageState(const PageState &st, bool isByHistoryNav)
|
|
|
}
|
|
|
|
|
|
// 选中该节点
|
|
|
- treeViewDown->setCurrentIndex(idx);
|
|
|
- treeViewDown->scrollTo(idx);
|
|
|
+ m_pTreeViewDown->setCurrentIndex(idx);
|
|
|
+ m_pTreeViewDown->scrollTo(idx);
|
|
|
|
|
|
// 更新导航栏
|
|
|
updateNavigationBar(idx);
|
|
@@ -3602,7 +3599,7 @@ void DbTreeViewManager::loadPageState(const PageState &st, bool isByHistoryNav)
|
|
|
m_thirdLevelFieldWnd->deleteLater();
|
|
|
m_thirdLevelFieldWnd = nullptr;
|
|
|
}
|
|
|
- treeViewDown->show();
|
|
|
+ m_pTreeViewDown->show();
|
|
|
for (auto sep : firstLevelSeparators) {
|
|
|
if (sep) sep->show();
|
|
|
}
|