Bit refactoring

This commit is contained in:
Juergen Spitzmueller 2023-09-18 08:13:23 +02:00
parent 9119671ee6
commit 63b99beedd
2 changed files with 14 additions and 13 deletions

View File

@ -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

View File

@ -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