/usr/include/qgis/qgslonglongvalidator.h is in libqgis-dev 2.8.6+dfsg-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | /***************************************************************************
qgslonglongvalidator.h - description
-------------------
begin : August 2010
copyright : (C) 2010 by Jürgen E. Fischer
email : jef@norbit.de
adapted version of QIntValidator for qint64
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLONGLONGVALIDATOR_H
#define QGSLONGLONGVALIDATOR_H
#include <limits>
#include <QValidator>
#include <QLocale>
class GUI_EXPORT QgsLongLongValidator : public QValidator
{
Q_OBJECT
public:
explicit QgsLongLongValidator( QObject *parent )
: QValidator( parent )
, b( std::numeric_limits<qint64>::min() )
, t( std::numeric_limits<qint64>::max() )
{}
QgsLongLongValidator( qint64 bottom, qint64 top, QObject *parent )
: QValidator( parent )
, b( bottom )
, t( top )
{}
~QgsLongLongValidator()
{}
QValidator::State validate( QString &input, int& ) const override
{
if ( input.isEmpty() )
return Intermediate;
if ( b >= 0 && input.startsWith( '-' ) )
return Invalid;
if ( t < 0 && input.startsWith( '+' ) )
return Invalid;
if ( input == "-" || input == "+" )
return Intermediate;
bool ok;
qlonglong entered = input.toLongLong( &ok );
if ( !ok )
return Invalid;
if ( entered >= b && entered <= t )
return Acceptable;
if ( entered >= 0 )
{
// the -entered < b condition is necessary to allow people to type
// the minus last (e.g. for right-to-left languages)
return ( entered > t && -entered < b ) ? Invalid : Intermediate;
}
else
{
return ( entered < b ) ? Invalid : Intermediate;
}
}
void setBottom( qint64 bottom ) { b = bottom; }
void setTop( qint64 top ) { t = top; }
virtual void setRange( qint64 bottom, qint64 top )
{
b = bottom;
t = top;
}
qint64 bottom() const { return b; }
qint64 top() const { return t; }
private:
Q_DISABLE_COPY( QgsLongLongValidator )
qint64 b;
qint64 t;
};
#endif // QGSLONGLONGVALIDATOR_H
|