cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
pagination.h
1/*
2 * SPDX-FileCopyrightText: (C) 2015-2022 Daniel Nicoletti <dantti12@gmail.com>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef PAGINATION_H
6#define PAGINATION_H
7
8#include <Cutelyst/cutelyst_global.h>
9
10#include <QVariantMap>
11
12namespace Cutelyst {
13
25class CUTELYST_PLUGIN_UTILS_PAGINATION_EXPORT Pagination : public QVariantMap
26{
27 Q_GADGET
31 Q_PROPERTY(int limit READ limit CONSTANT)
35 Q_PROPERTY(int offset READ offset CONSTANT)
39 Q_PROPERTY(int currentPage READ currentPage CONSTANT)
43 Q_PROPERTY(int lastPage READ lastPage CONSTANT)
47 Q_PROPERTY(int numberOfItems READ numberOfItems CONSTANT)
51 Q_PROPERTY(bool enableFirst READ enableFirst CONSTANT)
55 Q_PROPERTY(bool enableLast READ enableLast CONSTANT)
59 Q_PROPERTY(QVector<int> pages READ pages CONSTANT)
60public:
61 Pagination() = default;
70 Pagination(int numberOfItems, int itemsPerPage, int currentPage, int pageLinks = 10);
71
75 virtual ~Pagination();
76
80 [[nodiscard]] int limit() const;
81
85 [[nodiscard]] int offset() const;
86
91 [[nodiscard]] static int offset(int itemsPerPage, int currentPage);
92
96 [[nodiscard]] int currentPage() const;
97
101 [[nodiscard]] int lastPage() const;
102
106 [[nodiscard]] int numberOfItems() const;
107
111 bool enableFirst() const;
112
116 bool enableLast() const;
117
121 [[nodiscard]] QVector<int> pages() const;
122};
123
124} // namespace Cutelyst
125Q_DECLARE_METATYPE(Cutelyst::Pagination)
126
127#endif // PAGINATION_H
Helper to calculate values for paginating result lists.
Definition pagination.h:26
The Cutelyst namespace holds all public Cutelyst API.