File indexing completed on 2024-06-16 07:42:24

0001 /*
0002     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "k3bcdtextvalidator.h"
0007 
0008 K3b::CdTextValidator::CdTextValidator(QObject *parent)
0009     : K3b::Latin1Validator(parent)
0010 {
0011 }
0012 
0013 
0014 K3b::CdTextValidator::~CdTextValidator()
0015 {
0016 }
0017 
0018 
0019 QValidator::State K3b::CdTextValidator::validate( QString& input, int& pos ) const
0020 {
0021     if( input.length() > 160 )
0022         return Invalid;
0023 
0024     // forbid some characters that might introduce problems
0025     for( int i = 0; i < input.length(); ++i ) {
0026         if( input[i] == '/' || input[i] == '"' || input[i] == '\\' )
0027             return Invalid;
0028     }
0029 
0030     return K3b::Latin1Validator::validate( input, pos );
0031 }