mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-10 15:39:02 +00:00
26 lines
647 B
C++
26 lines
647 B
C++
|
|
#include "idvalidator.hpp"
|
|
|
|
bool CSVWorld::IdValidator::isValid (const QChar& c, bool first) const
|
|
{
|
|
if (c.isLetter() || c=='_')
|
|
return true;
|
|
|
|
if (!first && (c.isDigit() || c.isSpace()))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
CSVWorld::IdValidator::IdValidator (QObject *parent) : QValidator (parent) {}
|
|
|
|
QValidator::State CSVWorld::IdValidator::validate (QString& input, int& pos) const
|
|
{
|
|
bool first = true;
|
|
|
|
for (QString::const_iterator iter (input.begin()); iter!=input.end(); ++iter, first = false)
|
|
if (!isValid (*iter, first))
|
|
return QValidator::Invalid;
|
|
|
|
return QValidator::Acceptable;
|
|
} |