Vidalia
0.2.15
|
00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 00007 ** including this file, may be copied, modified, propagated, or distributed 00008 ** except according to the terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file Local8BitStringValidator.cpp 00013 ** \brief Validates that a given string contains only characters capable of 00014 ** being represented in the current local 8-bit character encoding. 00015 */ 00016 00017 #include "Local8BitStringValidator.h" 00018 00019 00020 /** Constructor. */ 00021 Local8BitStringValidator::Local8BitStringValidator(QObject *parent) 00022 : QValidator(parent) 00023 { 00024 _codec = QTextCodec::codecForLocale(); 00025 } 00026 00027 /** Validates the given input contains only valid nickname characters starting 00028 * at the specified position. */ 00029 QValidator::State 00030 Local8BitStringValidator::validate(QString &input, int &pos) const 00031 { 00032 Q_UNUSED(pos); 00033 00034 if (_codec->canEncode(input)) 00035 return QValidator::Acceptable; 00036 return QValidator::Invalid; 00037 } 00038 00039 bool 00040 Local8BitStringValidator::canEncode(const QString &input) 00041 { 00042 return QTextCodec::codecForLocale()->canEncode(input); 00043 }