|
@@ -0,0 +1,572 @@
|
|
|
+#include "treeviewmanager.h"
|
|
|
+
|
|
|
+
|
|
|
+TreeViewManager::TreeViewManager(QWidget *parent, QWidget *widget2)
|
|
|
+ : QWidget(parent),
|
|
|
+ widget2(widget2),
|
|
|
+ treeViewDown(new QTreeView(widget2)),
|
|
|
+ navigationWidget(nullptr),
|
|
|
+ buttonOpenFile(nullptr),
|
|
|
+ buttonUp(nullptr),
|
|
|
+ buttonDown(nullptr),
|
|
|
+ buttonLeft(nullptr),
|
|
|
+ buttonRight(nullptr) {
|
|
|
+ if (!widget2) {
|
|
|
+ qWarning() << "TreeViewManager: widget2 未初始化";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ downModel = new QStandardItemModel(this);
|
|
|
+ treeViewDown->setModel(downModel);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ applyCustomStyles();
|
|
|
+
|
|
|
+ treeViewDown->setHeaderHidden(true);
|
|
|
+
|
|
|
+ treeViewDown->setGeometry(16, 106, widget2->width()-16, widget2->height() - 106);
|
|
|
+ treeViewDown->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
+ treeViewDown->show();
|
|
|
+
|
|
|
+ qDebug() << "widget2 geometry:" << widget2->geometry();
|
|
|
+ qDebug() << "treeViewDown geometry:" << treeViewDown->geometry();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ loadJsonFromFile(":/config/menu_config.json");
|
|
|
+
|
|
|
+
|
|
|
+ setupButton();
|
|
|
+
|
|
|
+
|
|
|
+ navigationWidget = new QWidget(widget2);
|
|
|
+ navigationWidget->setGeometry(15, 15, 300, 74);
|
|
|
+ navigationLayout = new QVBoxLayout(navigationWidget);
|
|
|
+ navigationLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
+ navigationLayout->setSpacing(0);
|
|
|
+ navigationWidget->show();
|
|
|
+
|
|
|
+
|
|
|
+ updateNavigationWidgetGeometry();
|
|
|
+
|
|
|
+ connect(treeViewDown, &QTreeView::clicked, this, [=](const QModelIndex &index) {
|
|
|
+ QStandardItem *item = downModel->itemFromIndex(index);
|
|
|
+ if (!item) return;
|
|
|
+
|
|
|
+ QVariant data = item->data(Qt::UserRole);
|
|
|
+ if (data.canConvert<QJsonObject>()) {
|
|
|
+ QJsonObject fields = data.toJsonObject();
|
|
|
+ displayThirdLevelFields(fields);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ connect(treeViewDown, &QTreeView::clicked, this, [=](const QModelIndex &index) {
|
|
|
+ if (!index.isValid()) {
|
|
|
+ qWarning() << "点击事件:索引无效";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ QStandardItem *item = downModel->itemFromIndex(index);
|
|
|
+ if (!item) {
|
|
|
+ qWarning() << "点击事件:未找到对应项";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ QVariant data = item->data(Qt::UserRole);
|
|
|
+ if (data.canConvert<QJsonObject>()) {
|
|
|
+ QJsonObject fields = data.toJsonObject();
|
|
|
+ if (fields.contains("isThirdLevel") && fields["isThirdLevel"].toBool()) {
|
|
|
+ qDebug() << "加载三级目录字段内容:" << fields;
|
|
|
+
|
|
|
+
|
|
|
+ updateNavigationBar(index);
|
|
|
+
|
|
|
+
|
|
|
+ displayThirdLevelFields(fields);
|
|
|
+ treeViewDown->hide();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ updateNavigationBar(index);
|
|
|
+ qDebug() << "更新导航栏,目录项:" << item->text();
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ connect(buttonOpenFile, &QPushButton::clicked, this, &TreeViewManager::onButtonOpenFileClicked);
|
|
|
+ connect(buttonUp, &QPushButton::clicked, this, &TreeViewManager::onButtonUpClicked);
|
|
|
+ connect(buttonDown, &QPushButton::clicked, this, &TreeViewManager::onButtonDownClicked);
|
|
|
+ connect(buttonLeft, &QPushButton::clicked, this, &TreeViewManager::onButtonLeftClicked);
|
|
|
+ connect(buttonRight, &QPushButton::clicked, this, &TreeViewManager::onButtonRightClicked);
|
|
|
+}
|
|
|
+
|
|
|
+void TreeViewManager::loadJsonFromFile(const QString &filePath)
|
|
|
+{
|
|
|
+ QFile jsonFile(filePath);
|
|
|
+ if (!jsonFile.exists()) {
|
|
|
+ qWarning() << "JSON 文件不存在:" << filePath;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!jsonFile.open(QIODevice::ReadOnly)) {
|
|
|
+ qWarning() << "无法打开 JSON 文件:" << filePath;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ QByteArray fileData = jsonFile.readAll();
|
|
|
+ jsonFile.close();
|
|
|
+
|
|
|
+ QJsonDocument jsonDoc = QJsonDocument::fromJson(fileData);
|
|
|
+ if (jsonDoc.isNull() || !jsonDoc.isObject()) {
|
|
|
+ qWarning() << "JSON 文件格式错误:" << filePath;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ loadTreeData(jsonDoc);
|
|
|
+ qDebug() << "JSON 数据加载完成";
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void TreeViewManager::applyCustomStyles() {
|
|
|
+ treeViewDown->setStyleSheet(R"(
|
|
|
+
|
|
|
+ QTreeView::branch:closed:has-children {
|
|
|
+ border-image: none;
|
|
|
+ image: url(:/images/home_add.png);
|
|
|
+ }
|
|
|
+ QTreeView::branch:open:has-children {
|
|
|
+ border-image: none;
|
|
|
+ image: url(:/images/home_minus.png);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ QTreeView::indicator:unchecked {
|
|
|
+ image: url(:/images/home_up.png);
|
|
|
+ }
|
|
|
+ QTreeView::indicator:checked {
|
|
|
+ image: url(:/images/home_down.png);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ QTreeView {
|
|
|
+ background: transparent;
|
|
|
+ border: none;
|
|
|
+ }
|
|
|
+ )");
|
|
|
+}
|
|
|
+
|
|
|
+void TreeViewManager::loadTreeData(const QJsonDocument &doc)
|
|
|
+{
|
|
|
+ if (!doc.isObject()) {
|
|
|
+ qWarning() << "无效的 JSON 结构";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ buildTree(doc.object(), downModel->invisibleRootItem());
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void TreeViewManager::buildTree(const QJsonObject &jsonObj, QStandardItem *parent)
|
|
|
+{
|
|
|
+ for (auto it = jsonObj.begin(); it != jsonObj.end(); ++it) {
|
|
|
+ if (it.key() == "isThirdLevel") {
|
|
|
+ qDebug() << "跳过 'isThirdLevel' 字段:" << it.key();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ QStandardItem *item = new QStandardItem(it.key());
|
|
|
+ item->setCheckable(true);
|
|
|
+ parent->appendRow(item);
|
|
|
+
|
|
|
+ if (it.value().isObject()) {
|
|
|
+ QJsonObject childObj = it.value().toObject();
|
|
|
+
|
|
|
+ if (childObj.contains("isThirdLevel") && childObj["isThirdLevel"].toBool()) {
|
|
|
+
|
|
|
+ item->setData(childObj, Qt::UserRole);
|
|
|
+ qDebug() << "识别为三级目录:" << it.key();
|
|
|
+ } else {
|
|
|
+
|
|
|
+ buildTree(childObj, item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void TreeViewManager::updateNavigationWidgetGeometry()
|
|
|
+{
|
|
|
+
|
|
|
+ int navWidth = 300;
|
|
|
+ int navHeight = 74;
|
|
|
+
|
|
|
+
|
|
|
+ int navLeft = 15;
|
|
|
+ int navTop = 15;
|
|
|
+
|
|
|
+
|
|
|
+ navigationWidget->setGeometry(navLeft, navTop, navWidth, navHeight);
|
|
|
+
|
|
|
+
|
|
|
+ navigationWidget->update();
|
|
|
+
|
|
|
+ qDebug() << "Updated navigationWidget geometry:"
|
|
|
+ << navigationWidget->geometry();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void TreeViewManager::updateNavigationBar(const QModelIndex &index)
|
|
|
+{
|
|
|
+ if (!index.isValid()) {
|
|
|
+ qWarning() << "导航栏更新失败:索引无效";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ QStandardItem *item = downModel->itemFromIndex(index);
|
|
|
+ if (!item) {
|
|
|
+ qWarning() << "导航栏更新失败:未找到对应项";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ qDebug() << "导航栏更新,目录项:" << item->text();
|
|
|
+
|
|
|
+
|
|
|
+ if (navigationWidget->layout()) {
|
|
|
+ QLayoutItem *child;
|
|
|
+ while ((child = navigationWidget->layout()->takeAt(0)) != nullptr) {
|
|
|
+ if (child->widget()) {
|
|
|
+ child->widget()->deleteLater();
|
|
|
+ }
|
|
|
+ delete child;
|
|
|
+ }
|
|
|
+ delete navigationWidget->layout();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ QList<QStandardItem *> path;
|
|
|
+ while (item) {
|
|
|
+ if (item->text() != "isThirdLevel") {
|
|
|
+ path.prepend(item);
|
|
|
+ }
|
|
|
+ item = item->parent();
|
|
|
+ }
|
|
|
+
|
|
|
+ qDebug() << "导航路径:" << [path]() {
|
|
|
+ QStringList pathNames;
|
|
|
+ for (QStandardItem *p : path) {
|
|
|
+ pathNames.append(p->text());
|
|
|
+ }
|
|
|
+ return pathNames.join(" -> ");
|
|
|
+ }();
|
|
|
+
|
|
|
+
|
|
|
+ QVBoxLayout *newLayout = new QVBoxLayout;
|
|
|
+ newLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
+ newLayout->setSpacing(0);
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < 3; ++i) {
|
|
|
+ QLabel *label = new QLabel;
|
|
|
+
|
|
|
+ if (i < path.size()) {
|
|
|
+ QString text = path[i]->text();
|
|
|
+ if (i == 1) text = " " + text;
|
|
|
+ if (i == 2) text = " " + text;
|
|
|
+ label->setText(text);
|
|
|
+ } else {
|
|
|
+ label->setText("");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ QFont font = label->font();
|
|
|
+ font.setPointSize(12);
|
|
|
+ label->setFont(font);
|
|
|
+ label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
|
|
+ label->setFixedHeight(navigationWidget->height() / 3);
|
|
|
+
|
|
|
+ newLayout->addWidget(label);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ navigationWidget->setLayout(newLayout);
|
|
|
+ navigationWidget->update();
|
|
|
+ qDebug() << "导航栏更新完成:" << path.size() << "项";
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void TreeViewManager::displayThirdLevelFields(const QJsonObject &fields)
|
|
|
+{
|
|
|
+ if (fields.isEmpty()) {
|
|
|
+ qWarning() << "字段数据为空,无法显示";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ qDebug() << "显示的字段数据:" << fields;
|
|
|
+
|
|
|
+
|
|
|
+ foreach (QObject *child, widget2->children()) {
|
|
|
+ QWidget *childWidget = qobject_cast<QWidget *>(child);
|
|
|
+ if (childWidget && childWidget->windowTitle() == "字段展示") {
|
|
|
+ qDebug() << "字段窗口已存在,关闭旧窗口";
|
|
|
+ childWidget->close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QWidget *fieldWindow = new QWidget(widget2);
|
|
|
+ fieldWindow->setWindowTitle("字段展示");
|
|
|
+ fieldWindow->setGeometry(treeViewDown->geometry());
|
|
|
+
|
|
|
+ QVBoxLayout *layout = new QVBoxLayout(fieldWindow);
|
|
|
+
|
|
|
+ for (auto it = fields.begin(); it != fields.end(); ++it) {
|
|
|
+ QString fieldName = it.key();
|
|
|
+ if (fieldName == "isThirdLevel") {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ QJsonObject fieldConfig = it.value().toObject();
|
|
|
+ QHBoxLayout *fieldLayout = new QHBoxLayout;
|
|
|
+ QLabel *label = new QLabel(fieldName);
|
|
|
+ label->setFixedWidth(150);
|
|
|
+ fieldLayout->addWidget(label);
|
|
|
+
|
|
|
+ if (fieldConfig["type"].toString() == "input") {
|
|
|
+ QLineEdit *lineEdit = new QLineEdit(fieldConfig["value"].toString());
|
|
|
+ fieldLayout->addWidget(lineEdit);
|
|
|
+ qDebug() << "创建输入控件:" << fieldName << ", 默认值:" << fieldConfig["value"].toString();
|
|
|
+ } else if (fieldConfig["type"].toString() == "dropdown") {
|
|
|
+ QComboBox *comboBox = new QComboBox;
|
|
|
+ QJsonArray options = fieldConfig["options"].toArray();
|
|
|
+ for (const QJsonValue &option : options) {
|
|
|
+ comboBox->addItem(option.toString());
|
|
|
+ }
|
|
|
+ comboBox->setCurrentText(fieldConfig["value"].toString());
|
|
|
+ fieldLayout->addWidget(comboBox);
|
|
|
+ qDebug() << "创建下拉框:" << fieldName << ", 选项:" << options << ", 默认值:" << fieldConfig["value"].toString();
|
|
|
+ } else if (fieldConfig["type"].toString() == "checkbox") {
|
|
|
+ QCheckBox *checkBox = new QCheckBox;
|
|
|
+ checkBox->setChecked(fieldConfig["value"].toString() == "true");
|
|
|
+ fieldLayout->addWidget(checkBox);
|
|
|
+ qDebug() << "创建复选框:" << fieldName << ", 默认值:" << fieldConfig["value"].toString();
|
|
|
+ } else {
|
|
|
+ qWarning() << "未知字段类型:" << fieldConfig["type"].toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ layout->addLayout(fieldLayout);
|
|
|
+ }
|
|
|
+
|
|
|
+ fieldWindow->setLayout(layout);
|
|
|
+ fieldWindow->adjustSize();
|
|
|
+ fieldWindow->show();
|
|
|
+
|
|
|
+ qDebug() << "三级目录字段窗口已打开";
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void TreeViewManager::setupButton()
|
|
|
+{
|
|
|
+ buttonOpenFile = new QPushButton(widget2);
|
|
|
+ buttonUp = new QPushButton(widget2);
|
|
|
+ buttonDown = new QPushButton(widget2);
|
|
|
+ buttonLeft = new QPushButton(widget2);
|
|
|
+ buttonRight = new QPushButton(widget2);
|
|
|
+
|
|
|
+
|
|
|
+ buttonOpenFile->setParent(widget2);
|
|
|
+ buttonOpenFile->setMaximumSize(76, 30);
|
|
|
+ buttonOpenFile->setIcon(QIcon(":/images/home_openFile.png"));
|
|
|
+ buttonOpenFile->setText("");
|
|
|
+ buttonOpenFile->setGeometry(328, 16, 76, 30);
|
|
|
+
|
|
|
+
|
|
|
+ buttonUp->setParent(widget2);
|
|
|
+ buttonUp->setMaximumSize(36, 30);
|
|
|
+ buttonUp->setIcon(QIcon(":/images/home_up.png"));
|
|
|
+ buttonUp->setText("");
|
|
|
+ buttonUp->setGeometry(408, 16, 36, 30);
|
|
|
+
|
|
|
+ buttonDown->setParent(widget2);
|
|
|
+ buttonDown->setMaximumSize(36, 30);
|
|
|
+ buttonDown->setIcon(QIcon(":/images/home_down.png"));
|
|
|
+ buttonDown->setText("");
|
|
|
+ buttonDown->setGeometry(408, 50, 36, 30);
|
|
|
+
|
|
|
+ buttonLeft->setParent(widget2);
|
|
|
+ buttonLeft->setMaximumSize(36, 30);
|
|
|
+ buttonLeft->setIcon(QIcon(":/images/home_left.png"));
|
|
|
+ buttonLeft->setText("");
|
|
|
+ buttonLeft->setGeometry(328, 50, 36, 30);
|
|
|
+
|
|
|
+ buttonRight->setParent(widget2);
|
|
|
+ buttonRight->setMaximumSize(36, 30);
|
|
|
+ buttonRight->setIcon(QIcon(":/images/home_right.png"));
|
|
|
+ buttonRight->setText("");
|
|
|
+ buttonRight->setGeometry(368, 50, 36, 30);
|
|
|
+
|
|
|
+
|
|
|
+ buttonOpenFile->show();
|
|
|
+ buttonUp->show();
|
|
|
+ buttonDown->show();
|
|
|
+ buttonLeft->show();
|
|
|
+ buttonRight->show();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void TreeViewManager::onButtonOpenFileClicked()
|
|
|
+{
|
|
|
+ foreach (QObject *child, widget2->children()) {
|
|
|
+ QWidget *childWidget = qobject_cast<QWidget *>(child);
|
|
|
+ if (childWidget && childWidget->windowTitle() == "字段展示") {
|
|
|
+ qDebug() << "关闭字段窗口:" << childWidget;
|
|
|
+ childWidget->close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ treeViewDown->show();
|
|
|
+ treeViewDown->collapseAll();
|
|
|
+ treeViewDown->clearSelection();
|
|
|
+
|
|
|
+
|
|
|
+ QStandardItem *rootItem = downModel->invisibleRootItem();
|
|
|
+ if (rootItem) {
|
|
|
+ for (int i = 0; i < rootItem->rowCount(); ++i) {
|
|
|
+ QStandardItem *childItem = rootItem->child(i);
|
|
|
+ if (childItem) {
|
|
|
+ treeViewDown->expand(downModel->indexFromItem(childItem));
|
|
|
+ qDebug() << "展开一级目录:" << childItem->text();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ updateNavigationBar(QModelIndex());
|
|
|
+ qDebug() << "成功返回到一级菜单";
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void TreeViewManager::onButtonUpClicked()
|
|
|
+{
|
|
|
+ qDebug() << "TreeViewManager: 遍历导航向上";
|
|
|
+
|
|
|
+
|
|
|
+ QModelIndex currentIndex = treeViewDown->currentIndex();
|
|
|
+ if (!currentIndex.isValid()) {
|
|
|
+ qDebug() << "没有选中的索引,无法向上遍历";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ QModelIndex parentIndex = currentIndex.parent();
|
|
|
+ if (!parentIndex.isValid()) {
|
|
|
+ qDebug() << "当前已在顶级目录,无法向上遍历";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ treeViewDown->setCurrentIndex(parentIndex);
|
|
|
+
|
|
|
+
|
|
|
+ QStandardItem *parentItem = downModel->itemFromIndex(parentIndex);
|
|
|
+ if (!parentItem) {
|
|
|
+ qWarning() << "父项未找到,无法遍历";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ QVariant parentData = parentItem->data(Qt::UserRole);
|
|
|
+ if (parentData.canConvert<QJsonObject>()) {
|
|
|
+ QJsonObject fields = parentData.toJsonObject();
|
|
|
+
|
|
|
+
|
|
|
+ if (fields.contains("type") && fields["type"].toString() == "三级菜单") {
|
|
|
+ qDebug() << "跳过三级菜单的内容:" << parentItem->text();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ qDebug() << "成功遍历到上一级菜单:" << parentItem->text();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void TreeViewManager::onButtonDownClicked()
|
|
|
+{
|
|
|
+ qDebug() << "TreeViewManager: 遍历导航向下";
|
|
|
+
|
|
|
+ QModelIndex currentIndex = treeViewDown->currentIndex();
|
|
|
+ if (!currentIndex.isValid()) {
|
|
|
+ currentIndex = downModel->index(0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ QModelIndex nextIndex = getNextIndex(currentIndex);
|
|
|
+ while (nextIndex.isValid()) {
|
|
|
+ QStandardItem *item = downModel->itemFromIndex(nextIndex);
|
|
|
+ if (item && !item->data(Qt::UserRole).isValid()) {
|
|
|
+
|
|
|
+ treeViewDown->setCurrentIndex(nextIndex);
|
|
|
+ updateNavigationBar(nextIndex);
|
|
|
+ qDebug() << "成功导航到下一个目录:" << item->text();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ nextIndex = getNextIndex(nextIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ qDebug() << "已到达目录底部,无法继续向下遍历";
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+QModelIndex TreeViewManager::getNextIndex(const QModelIndex ¤tIndex)
|
|
|
+{
|
|
|
+
|
|
|
+ QModelIndex nextIndex = currentIndex.sibling(currentIndex.row() + 1, 0);
|
|
|
+ if (nextIndex.isValid()) {
|
|
|
+ return nextIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ QModelIndex parentIndex = currentIndex.parent();
|
|
|
+ while (parentIndex.isValid()) {
|
|
|
+ QModelIndex nextParentSibling = parentIndex.sibling(parentIndex.row() + 1, 0);
|
|
|
+ if (nextParentSibling.isValid()) {
|
|
|
+ return nextParentSibling;
|
|
|
+ }
|
|
|
+ parentIndex = parentIndex.parent();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return QModelIndex();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void TreeViewManager::onButtonLeftClicked()
|
|
|
+{
|
|
|
+ qDebug() << "TreeViewManager: 进入下一级目录";
|
|
|
+}
|
|
|
+
|
|
|
+void TreeViewManager::onButtonRightClicked()
|
|
|
+{
|
|
|
+ qDebug() << "TreeViewManager: 返回上一级目录";
|
|
|
+}
|