2006-06-29 21:12:47 +00:00
|
|
|
// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*-
|
|
|
|
//
|
|
|
|
// pageNumber.h
|
|
|
|
//
|
|
|
|
// Part of KVIEWSHELL - A framework for multipage text/gfx viewers
|
|
|
|
//
|
2021-05-24 07:25:56 +00:00
|
|
|
// SPDX-FileCopyrightText: 2004 Stefan Kebekus
|
2021-05-24 12:00:50 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2006-06-29 21:12:47 +00:00
|
|
|
|
|
|
|
#ifndef PAGENUMBER_H
|
|
|
|
#define PAGENUMBER_H
|
|
|
|
|
|
|
|
#include <QGlobalStatic>
|
|
|
|
|
|
|
|
/** \brief Class to represent a page number
|
|
|
|
|
|
|
|
The class PageNumber is really nothing but an alias for quint16, and
|
|
|
|
can be casted to and from quint16. It is used in kviewshell to remind
|
|
|
|
the programmer of the convention that page numbers start at '1' (for
|
|
|
|
'first page'), and that the value '0' means 'illegal page number' or
|
|
|
|
'no page number'. Accordingly, the value '0' is also named
|
|
|
|
PageNumber::invalidPage, and there is a trivial method isInvalid()
|
|
|
|
that checks if the page number is 0.
|
|
|
|
|
|
|
|
@author Stefan Kebekus <kebekus@kde.org>
|
|
|
|
@version 1.0 0
|
|
|
|
*/
|
|
|
|
|
|
|
|
class PageNumber
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum pageNums {
|
|
|
|
invalidPage = 0 /*! Invalid page number */
|
|
|
|
};
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2006-06-29 21:12:47 +00:00
|
|
|
/** The default constructor sets the page number to 'invalidPage' */
|
|
|
|
PageNumber()
|
|
|
|
{
|
|
|
|
pgNum = invalidPage;
|
|
|
|
}
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2006-06-29 21:12:47 +00:00
|
|
|
/** \brief Constructor that sets the page number
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2006-06-29 21:12:47 +00:00
|
|
|
@param num page number that is set initially
|
|
|
|
*/
|
2021-08-21 23:14:34 +00:00
|
|
|
explicit PageNumber(quint16 num)
|
2006-06-29 21:12:47 +00:00
|
|
|
{
|
|
|
|
pgNum = num;
|
|
|
|
}
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2006-06-29 21:12:47 +00:00
|
|
|
/** \brief this method implements typecasts from quint16 */
|
|
|
|
PageNumber &operator=(const quint16 p)
|
|
|
|
{
|
|
|
|
pgNum = p;
|
|
|
|
return *this;
|
|
|
|
}
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2006-06-29 21:12:47 +00:00
|
|
|
/** \brief This method implements typecasts to quint16 */
|
2021-08-21 23:14:34 +00:00
|
|
|
explicit operator quint16() const
|
2006-06-29 21:12:47 +00:00
|
|
|
{
|
|
|
|
return pgNum;
|
|
|
|
}
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2021-08-21 23:14:34 +00:00
|
|
|
bool operator>(const PageNumber other) const
|
|
|
|
{
|
|
|
|
return pgNum > other.pgNum;
|
|
|
|
}
|
|
|
|
|
2006-06-29 21:12:47 +00:00
|
|
|
/** \brief Checks if the page number is invalid
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2006-06-29 21:12:47 +00:00
|
|
|
@returns true, if pgNum != invalidPage, i.e., does not equal 0
|
|
|
|
*/
|
|
|
|
bool isValid() const
|
|
|
|
{
|
|
|
|
return (pgNum != invalidPage);
|
|
|
|
}
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2006-06-29 21:12:47 +00:00
|
|
|
private:
|
|
|
|
/** \brief Single number that represents the page number */
|
|
|
|
quint16 pgNum;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|