1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 CEA
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : SMESHGUI_IdValidator.h
22 // Author : Edward AGAPOV, Open CASCADE S.A.S.
25 #ifndef SMESHGUI_IDVALIDATOR_H
26 #define SMESHGUI_IDVALIDATOR_H
29 #include "SMESH_SMESHGUI.hxx"
34 // validator for manual input of Ids
36 class SMESHGUI_EXPORT SMESHGUI_IdValidator : public QValidator
39 SMESHGUI_IdValidator( QWidget* parent, const int maxNbId = 0 ) :
40 QValidator( parent ), myMaxNbId( maxNbId ) {}
42 State validate( QString& input, int& pos ) const
44 input.replace( QRegExp(" *[^0-9]+ *"), " " );
45 if ( myMaxNbId && input.length() > myMaxNbId ) {
47 int ind = 0, nbId = 0;
48 while ( ind < input.length() ) {
49 if ( input.at( ind ) != ' ' ) {
50 if ( ++nbId > myMaxNbId ) {
51 input.truncate( ind );
54 ind = input.indexOf( ' ', ind );
60 if ( pos > input.length() )
69 #endif // SMESHGUI_IDVALIDATOR_H