[LyX/master] Bit refactoring

Juergen Spitzmueller spitz at lyx.org
Mon Sep 18 04:55:26 UTC 2023


commit 63b99beedd995441c1dd78bce59c9ef53be3b160
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Mon Sep 18 08:13:23 2023 +0200

    Bit refactoring
---
 src/frontends/qt/TocWidget.cpp |   25 ++++++++++++-------------
 src/frontends/qt/TocWidget.h   |    2 ++
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/frontends/qt/TocWidget.cpp b/src/frontends/qt/TocWidget.cpp
index c5c2ea4..4cbcf96 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 50c1089..c56d0ae 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


More information about the lyx-cvs mailing list