cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
|
Helper to calculate values for paginating result lists. More...
#include <Cutelyst/Plugins/Utils/Pagination>
Public Member Functions | |
Pagination (int numberOfItems, int itemsPerPage, int currentPage, int pageLinks=10) | |
virtual | ~Pagination () |
int | currentPage () const |
bool | enableFirst () const |
bool | enableLast () const |
int | lastPage () const |
int | limit () const |
int | numberOfItems () const |
int | offset () const |
QVector< int > | pages () const |
Static Public Member Functions | |
static int | offset (int itemsPerPage, int currentPage) |
Properties | |
int | currentPage |
bool | enableFirst |
bool | enableLast |
int | lastPage |
int | limit |
int | numberOfItems |
int | offset |
QVector< int > | pages |
The Pagination plugin is a little helper class to calculate different values for paginating result lists from for example database queries. If you have a result set of for example 123 records and want to show 10 per page, you can use this class to calculate the pagination.
Definition at line 25 of file pagination.h.
Pagination::Pagination | ( | int | numberOfItems, |
int | itemsPerPage, | ||
int | currentPage, | ||
int | pageLinks = 10 |
||
) |
Contructs a new Pagination object with the given parameters.
numberOfItems | should be set to the total of items to be displayed |
itemsPerPage | the desired number of items per page |
currentPage | the current 1 indexed page (first page is 1) usually from the query url |
pageLinks | the number of page links that should be generated, for example 3 -> 11, 12, 13 |
Definition at line 13 of file pagination.cpp.
References QList::append(), and QVariant::fromValue().
|
virtual |
Destroys the Pagination object.
Definition at line 59 of file pagination.cpp.
int Pagination::currentPage | ( | ) | const |
Returns the current page number.
Definition at line 87 of file pagination.cpp.
bool Pagination::enableFirst | ( | ) | const |
Returns true
if the first page link should be enabled.
Definition at line 102 of file pagination.cpp.
bool Pagination::enableLast | ( | ) | const |
Returns true
if the last page link should be enabled.
Definition at line 107 of file pagination.cpp.
int Pagination::lastPage | ( | ) | const |
Returns the number of the last page.
Definition at line 92 of file pagination.cpp.
int Pagination::limit | ( | ) | const |
Returns the number os items per page.
Definition at line 63 of file pagination.cpp.
int Pagination::numberOfItems | ( | ) | const |
Returns the total number of items.
Definition at line 97 of file pagination.cpp.
int Pagination::offset | ( | ) | const |
Returns the current page offset for use in SQL.
Definition at line 68 of file pagination.cpp.
|
static |
Returns the current page offset for use in SQL taking the number of items per page and the current page.
Definition at line 73 of file pagination.cpp.
References currentPage.
QVector< int > Pagination::pages | ( | ) | const |
Returns the list of pages, with each page number as the integer.
Definition at line 112 of file pagination.cpp.
|
read |
Returns the current page number.
Definition at line 39 of file pagination.h.
Referenced by offset().
|
read |
Returns true
if the first page link should be enabled.
Definition at line 51 of file pagination.h.
|
read |
Returns true
if the last page link should be enabled.
Definition at line 55 of file pagination.h.
|
read |
Returns the number of the last page.
Definition at line 43 of file pagination.h.
|
read |
Returns the number os items per page.
Definition at line 31 of file pagination.h.
|
read |
Returns the total number of items.
Definition at line 47 of file pagination.h.
|
read |
Returns the current page offset for use in SQL.
Definition at line 35 of file pagination.h.
|
read |
Returns the list of pages, with each page number as the integer.
Definition at line 59 of file pagination.h.