diff --git a/src/frontends/qt/TocWidget.cpp b/src/frontends/qt/TocWidget.cpp index c5c2ea4ee3..4cbcf96196 100644 --- a/src/frontends/qt/TocWidget.cpp +++ b/src/frontends/qt/TocWidget.cpp @@ -535,11 +535,8 @@ void TocWidget::finishUpdateView() } -void TocWidget::filterContents() +QModelIndexList TocWidget::getIndices() { - if (!tocTV->model()) - return; - QModelIndexList indices = tocTV->model()->match( tocTV->model()->index(0, 0), Qt::DisplayRole, ".*", -1, @@ -549,6 +546,16 @@ void TocWidget::filterContents() // deprecated in Qt 5.15. Qt::MatchFlags(Qt::MatchRegExp|Qt::MatchRecursive)); #endif + return indices; +} + + +void TocWidget::filterContents() +{ + if (!tocTV->model()) + return; + + QModelIndexList indices = getIndices(); bool const show_active = activeFilterCO->currentIndex() != 2; @@ -609,15 +616,7 @@ void TocWidget::collapseAllOthers(int const depth) if (!tocTV->model()) return; - QModelIndexList indices = tocTV->model()->match( - tocTV->model()->index(0, 0), - Qt::DisplayRole, ".*", -1, -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - Qt::MatchFlags(Qt::MatchRegularExpression|Qt::MatchRecursive)); -#else - // deprecated in Qt 5.15. - Qt::MatchFlags(Qt::MatchRegExp|Qt::MatchRecursive)); -#endif + QModelIndexList indices = getIndices(); int size = indices.size(); // collapse parents which are not in our ancestry line diff --git a/src/frontends/qt/TocWidget.h b/src/frontends/qt/TocWidget.h index 50c10893c3..c56d0ae051 100644 --- a/src/frontends/qt/TocWidget.h +++ b/src/frontends/qt/TocWidget.h @@ -102,6 +102,8 @@ private: /// bool isSortable() { return current_type_ != "tableofcontents"; } + /// + QModelIndexList getIndices(); /// \returns the top-most ancestor of \p descendant QModelIndex getAncestor(QModelIndex const & descendant) const; /// \returns \c true if \p ancestor is an ancestor (parent, grandparent, etc.) of \p descendant