Cutelyst  2.13.0
pagination.h
1 /*
2  * Copyright (C) 2015-2017 Daniel Nicoletti <dantti12@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef PAGINATION_H
19 #define PAGINATION_H
20 
21 #include <QVariantMap>
22 #include <Cutelyst/cutelyst_global.h>
23 
24 namespace Cutelyst {
25 
26 class CUTELYST_PLUGIN_UTILS_PAGINATION_EXPORT Pagination : public QVariantMap
27 {
28  Q_GADGET
29  Q_PROPERTY(int limit READ limit CONSTANT)
30  Q_PROPERTY(int offset READ offset CONSTANT)
31  Q_PROPERTY(int currentPage READ currentPage CONSTANT)
32  Q_PROPERTY(int lastPage READ lastPage CONSTANT)
33  Q_PROPERTY(int numberOfItems READ numberOfItems CONSTANT)
34  Q_PROPERTY(bool enableFirst READ enableFirst CONSTANT)
35  Q_PROPERTY(bool enableLast READ enableLast CONSTANT)
36  Q_PROPERTY(QVector<int> pages READ pages CONSTANT)
37 public:
38  Pagination() = default;
46  Pagination(int numberOfItems, int itemsPerPage, int currentPage, int pageLinks = 10);
47  virtual ~Pagination();
48 
52  int limit() const;
53 
57  int offset() const;
58 
62  int currentPage() const;
63 
67  int lastPage() const;
68 
72  int numberOfItems() const;
73 
77  bool enableFirst() const;
78 
82  bool enableLast() const;
83 
87  QVector<int> pages() const;
88 };
89 
90 }
91 Q_DECLARE_METATYPE(Cutelyst::Pagination)
92 
93 #endif // PAGINATION_H
Cutelyst
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
Cutelyst::Pagination
Definition: pagination.h:26