compatibility for qt 5.12

This commit is contained in:
Roy Qu 2022-10-19 00:55:59 +00:00
parent eed7fdcf56
commit 4caeeb3a78
2 changed files with 10 additions and 1 deletions

View File

@ -6135,7 +6135,11 @@ void MainWindow::on_actionAdd_to_project_triggered()
QModelIndex parentIndex = mProject->model()->getParentIndex(newUnit->node().get()); QModelIndex parentIndex = mProject->model()->getParentIndex(newUnit->node().get());
parentIndex = mProjectProxyModel->mapFromSource(parentIndex); parentIndex = mProjectProxyModel->mapFromSource(parentIndex);
if (parentIndex.isValid()) { if (parentIndex.isValid()) {
ui->projectView->expandRecursively(index); #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
ui->projectView->expandRecursively(parentIndex);
#else
ui->projectView->expand(parentIndex);
#endif
} }
if (index.isValid()) { if (index.isValid()) {
ui->projectView->setCurrentIndex(index); ui->projectView->setCurrentIndex(index);
@ -6532,7 +6536,11 @@ void MainWindow::setProjectViewCurrentNode(PProjectModelNode node)
QModelIndex parentIndex = mProject->model()->getParentIndex(node.get()); QModelIndex parentIndex = mProject->model()->getParentIndex(node.get());
parentIndex = mProjectProxyModel->mapFromSource(parentIndex); parentIndex = mProjectProxyModel->mapFromSource(parentIndex);
if (parentIndex.isValid()) { if (parentIndex.isValid()) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
ui->projectView->expandRecursively(parentIndex); ui->projectView->expandRecursively(parentIndex);
#else
ui->projectView->expand(parentIndex);
#endif
} }
QModelIndex index = mProject->model()->getNodeIndex(node.get()); QModelIndex index = mProject->model()->getNodeIndex(node.get());
index = mProjectProxyModel->mapFromSource(index); index = mProjectProxyModel->mapFromSource(index);

View File

@ -25,6 +25,7 @@
#include <QJsonObject> #include <QJsonObject>
#include <QJsonParseError> #include <QJsonParseError>
#include <QSet> #include <QSet>
#include <QDateTime>
#include "../utils.h" #include "../utils.h"
BookmarkModel::BookmarkModel(QObject* parent):QAbstractTableModel(parent), BookmarkModel::BookmarkModel(QObject* parent):QAbstractTableModel(parent),