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
23 // File : SMESHGUI_IdValidator.h
24 // Author : Edward AGAPOV
26 // $Header: /dn05/salome/PAL/SMESH/SMESH_SRC/src/SMESHGUI/SMESHGUI_IdValidator.h
28 #ifndef SMESHGUI_IdValidator_HeaderFile
29 #define SMESHGUI_IdValidator_HeaderFile
31 #include "SMESH_SMESHGUI.hxx"
33 #include <qvalidator.h>
35 // validator for manual input of Ids
37 class SMESHGUI_EXPORT SMESHGUI_IdValidator: public QValidator
41 SMESHGUI_IdValidator(QWidget * parent, const char * name = 0, const int maxNbId = 0):
42 QValidator(parent,name), myMaxNbId(maxNbId) {}
44 State validate ( QString & text, int & pos) const
46 text.replace( QRegExp(" *[^0-9]+ *"), " " );
47 if ( myMaxNbId && text.length() > myMaxNbId) { // truncate extra ids
48 int ind = 0, nbId = 0;
49 while ( ind < text.length() ) {
50 if ( text.at( ind ) != ' ' ) {
51 if ( ++nbId > myMaxNbId ) {
55 ind = text.find( ' ', ind );
61 if ( pos > text.length() )