cutelyst  3.9.1
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 
12 namespace Cutelyst {
13 
14 class CUTELYST_PLUGIN_UTILS_PAGINATION_EXPORT Pagination : public QVariantMap
15 {
16  Q_GADGET
17  Q_PROPERTY(int limit READ limit CONSTANT)
18  Q_PROPERTY(int offset READ offset CONSTANT)
19  Q_PROPERTY(int currentPage READ currentPage CONSTANT)
20  Q_PROPERTY(int lastPage READ lastPage CONSTANT)
21  Q_PROPERTY(int numberOfItems READ numberOfItems CONSTANT)
22  Q_PROPERTY(bool enableFirst READ enableFirst CONSTANT)
23  Q_PROPERTY(bool enableLast READ enableLast CONSTANT)
24  Q_PROPERTY(QVector<int> pages READ pages CONSTANT)
25 public:
26  Pagination() = default;
35  Pagination(int numberOfItems, int itemsPerPage, int currentPage, int pageLinks = 10);
36  virtual ~Pagination();
37 
41  int limit() const;
42 
46  int offset() const;
47 
52  static int offset(int itemsPerPage, int currentPage);
53 
57  int currentPage() const;
58 
62  int lastPage() const;
63 
67  int numberOfItems() const;
68 
72  bool enableFirst() const;
73 
77  bool enableLast() const;
78 
82  QVector<int> pages() const;
83 };
84 
85 } // namespace Cutelyst
86 Q_DECLARE_METATYPE(Cutelyst::Pagination)
87 
88 #endif // PAGINATION_H
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7