TreeFrogFramework  1.18
Public Member Functions | Protected Member Functions | List of all members
TPaginator Class Reference

#include <tpaginator.h>

Public Member Functions

 TPaginator (int itemsTotal=0, int itemsPerPage=10, int midRange=5)
 
 TPaginator (const TPaginator &other)
 
virtual ~TPaginator ()
 
TPaginatoroperator= (const TPaginator &other)
 
void setItemTotalCount (int total)
 
void setItemCountPerPage (int count)
 
void setMidRange (int range)
 
void setCurrentPage (int page)
 
int itemTotalCount () const
 
int numPages () const
 
int itemCountPerPage ()
 
int offset () const
 
int midRange () const
 
virtual QList< int > range () const
 
int currentPage () const
 
int firstPage () const
 
int previousPage () const
 
int nextPage () const
 
int lastPage () const
 
bool hasPrevious () const
 
bool hasNext () const
 
bool hasPage (int page) const
 

Protected Member Functions

void calculateNumPages ()
 

Detailed Description

The TPaginator class provides simple functionality for a pagination bar.

Constructor & Destructor Documentation

TPaginator::TPaginator ( int  itemsTotal = 0,
int  itemsPerPage = 10,
int  midRange = 5 
)

Constructs a TPaginator object using the parameters.

itemsTotal specifies the total number of items. itemsPerPage specifies the maximum number of items to be shown per page. midRange specifies the number of pages to show ‘around’ the current page on a pagination bar, and should be an odd number.

TPaginator::TPaginator ( const TPaginator other)

Copy constructor.

virtual TPaginator::~TPaginator ( )
inlinevirtual

Member Function Documentation

void TPaginator::calculateNumPages ( )
protected

Calculates the total number of pages.

Internal use only.

int TPaginator::currentPage ( ) const
inline

Returns the current page number.

int TPaginator::firstPage ( ) const
inline

Returns the first page number, always 1.

bool TPaginator::hasNext ( ) const
inline

Returns true if there is at least one page after the current page; otherwise returns false.

bool TPaginator::hasPage ( int  page) const
inline

Returns true if page is a valid page; otherwise returns false.

bool TPaginator::hasPrevious ( ) const
inline

Returns true if there is at least one page before the current page; otherwise returns false.

int TPaginator::itemCountPerPage ( )
inline

Returns the maximum number of items to be shown per page.

int TPaginator::itemTotalCount ( ) const
inline

Returns the total number of items.

int TPaginator::lastPage ( ) const
inline

Returns the last page number.

int TPaginator::midRange ( ) const
inline

Returns the number of page numbers to be shown on a pagination bar.

int TPaginator::nextPage ( ) const
inline

Returns the page number after the current page.

int TPaginator::numPages ( ) const
inline

Returns the total number of pages.

int TPaginator::offset ( ) const

Returns the number of items before the first item of the current page.

TPaginator & TPaginator::operator= ( const TPaginator other)

Assignment operator.

int TPaginator::previousPage ( ) const
inline

Returns the page number before the current page.

QList< int > TPaginator::range ( ) const
virtual

Returns a list of page numbers to be shown on a pagination bar.

void TPaginator::setCurrentPage ( int  page)

Sets the current page to page and recalculates other parameters.

void TPaginator::setItemCountPerPage ( int  count)

Sets the maximum number of items to be shown per page to count, and recalculates other parameters.

void TPaginator::setItemTotalCount ( int  total)

Sets the total number of items to total and recalculates other parameters.

void TPaginator::setMidRange ( int  range)

Sets the number of page numbers to range and recalculates other parameters.


The documentation for this class was generated from the following files: