Vidalia 0.3.1
Local8BitStringValidator.cpp
Go to the documentation of this file.
1/*
2** This file is part of Vidalia, and is subject to the license terms in the
3** LICENSE file, found in the top level directory of this distribution. If you
4** did not receive the LICENSE file with this file, you may obtain it from the
5** Vidalia source package distributed by the Vidalia Project at
6** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7** including this file, may be copied, modified, propagated, or distributed
8** except according to the terms described in the LICENSE file.
9*/
10
11/*
12** \file Local8BitStringValidator.cpp
13** \brief Validates that a given string contains only characters capable of
14** being represented in the current local 8-bit character encoding.
15*/
16
18
19
20/** Constructor. */
22 : QValidator(parent)
23{
24 _codec = QTextCodec::codecForLocale();
25}
26
27/** Validates the given input contains only valid nickname characters starting
28 * at the specified position. */
29QValidator::State
30Local8BitStringValidator::validate(QString &input, int &pos) const
31{
32 Q_UNUSED(pos);
33
34 if (_codec->canEncode(input))
35 return QValidator::Acceptable;
36 return QValidator::Invalid;
37}
38
39bool
41{
42 return QTextCodec::codecForLocale()->canEncode(input);
43}
static bool canEncode(const QString &input)
QValidator::State validate(QString &input, int &pos) const