From c07aa84f63abed90dec431269c5fcc385b456bfa Mon Sep 17 00:00:00 2001 From: Yari Polla Date: Wed, 1 Mar 2023 01:38:09 +0100 Subject: [PATCH] quicksettings: fix PaginateModel --- components/mobileshell/quicksettings/paginatemodel.cpp | 5 ++++- components/mobileshell/quicksettings/paginatemodel.h | 5 +---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/mobileshell/quicksettings/paginatemodel.cpp b/components/mobileshell/quicksettings/paginatemodel.cpp index 874ff48f..fd17d813 100644 --- a/components/mobileshell/quicksettings/paginatemodel.cpp +++ b/components/mobileshell/quicksettings/paginatemodel.cpp @@ -170,12 +170,15 @@ void PaginateModel::previousPage() int PaginateModel::currentPage() const { + if (d->m_pageSize == 0) + return 0; + return d->m_firstItem / d->m_pageSize; } int PaginateModel::pageCount() const { - if (!d->m_sourceModel) + if (!d->m_sourceModel || d->m_pageSize == 0) return 0; const int rc = d->m_sourceModel->rowCount(); const int r = (rc % d->m_pageSize == 0) ? 1 : 0; diff --git a/components/mobileshell/quicksettings/paginatemodel.h b/components/mobileshell/quicksettings/paginatemodel.h index b8c99b15..0602e44e 100644 --- a/components/mobileshell/quicksettings/paginatemodel.h +++ b/components/mobileshell/quicksettings/paginatemodel.h @@ -4,8 +4,7 @@ * SPDX-License-Identifier: LGPL-2.0-or-later */ -#ifndef PAGINATEMODEL_H -#define PAGINATEMODEL_H +#pragma once #include @@ -118,5 +117,3 @@ private: class PaginateModelPrivate; QScopedPointer d; }; - -#endif