From e861e849d16f1c0a32e17b37ed1bf0f9d7e59e9a Mon Sep 17 00:00:00 2001 From: nkv Date: Mon, 30 May 2005 09:38:19 +0000 Subject: [PATCH] Restriction of the number of labels (no more than 25) --- src/VISUGUI/VisuGUI_CubeAxesDlg.cxx | 13 +++++++++++++ src/VISUGUI/VisuGUI_CubeAxesDlg.h | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/VISUGUI/VisuGUI_CubeAxesDlg.cxx b/src/VISUGUI/VisuGUI_CubeAxesDlg.cxx index e0589924..0b93cb0d 100755 --- a/src/VISUGUI/VisuGUI_CubeAxesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CubeAxesDlg.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -86,6 +87,8 @@ VisuGUI_AxisWg::VisuGUI_AxisWg( QWidget* theParent ) aHBox->setSpacing( 5 ); aLabel = new QLabel( tr( "NUMBER" ), aHBox ); myLabelNumber = new QLineEdit( aHBox ); + myLabelNumber->setValidator(new QIntValidator(0, 25, this)); + myLabelNumber->installEventFilter(this); aLabels.append( aLabel ); aHBox = new QHBox( myLabelsGrp ); @@ -149,6 +152,16 @@ void VisuGUI_AxisWg::updateControlState() onTicksChecked(); } +bool VisuGUI_AxisWg::eventFilter(QObject* o, QEvent* e) +{ + if (e->type() == QEvent::FocusOut) { + bool isOK = false; + int k = myLabelNumber->text().toInt(&isOK); + if (isOK && k > 25) myLabelNumber->setText("25"); + } + return false; +} + //======================================================================= // name : VisuGUI_AxisWg::onNameChecked // Purpose : diff --git a/src/VISUGUI/VisuGUI_CubeAxesDlg.h b/src/VISUGUI/VisuGUI_CubeAxesDlg.h index 73e9ec6a..e77f1948 100755 --- a/src/VISUGUI/VisuGUI_CubeAxesDlg.h +++ b/src/VISUGUI/VisuGUI_CubeAxesDlg.h @@ -106,7 +106,10 @@ public: const bool ); bool ReadData( vtkAxisActor2D* ); bool Apply( vtkAxisActor2D* ); - + + + protected: + bool eventFilter(QObject*, QEvent*); private slots: -- 2.39.2