15 if (itemsPerPage <= 0) {
16 qCWarning(C_PAGINATION) <<
"Invalid number of items per page:" << itemsPerPage
17 <<
"failing back to 1";
21 if (currentPage <= 0) {
22 qCWarning(C_PAGINATION) <<
"Invalid current page:" << currentPage <<
"failing back to 1";
27 qCWarning(C_PAGINATION) <<
"Invalid number of page links:" << pageLinks
28 <<
"failing back to 1";
32 insert(QStringLiteral(
"limit"), itemsPerPage);
33 insert(QStringLiteral(
"offset"), (currentPage - 1) * itemsPerPage);
34 insert(QStringLiteral(
"currentPage"), currentPage);
35 insert(QStringLiteral(
"current"), currentPage);
37 int lastPage = (numberOfItems - 1) / itemsPerPage + 1;
38 if (currentPage > lastPage) {
39 currentPage = lastPage;
42 int startPage = (currentPage < pageLinks + 1) ? 1 : currentPage - pageLinks;
43 int endPage = (pageLinks * 2) + startPage;
44 if (lastPage < endPage) {
49 for (
int i = startPage; i <= endPage; ++i) {
52 insert(QStringLiteral(
"enableFirst"), currentPage > 1);
53 insert(QStringLiteral(
"enableLast"), currentPage != lastPage);
55 insert(QStringLiteral(
"lastPage"), lastPage);
56 insert(QStringLiteral(
"numberOfItems"), numberOfItems);