Back to index

salome-gui  6.5.0
Classes | Functions
QtxPagePrefMgr.cxx File Reference
#include "QtxPagePrefMgr.h"
#include "QtxGridBox.h"
#include "QtxFontEdit.h"
#include "QtxGroupBox.h"
#include "QtxComboBox.h"
#include "QtxIntSpinBox.h"
#include "QtxColorButton.h"
#include "QtxBiColorTool.h"
#include "QtxDoubleSpinBox.h"
#include "QtxShortcutEdit.h"
#include "QtxBackgroundTool.h"
#include "QtxResourceMgr.h"
#include <QEvent>
#include <QLayout>
#include <QToolBox>
#include <QLineEdit>
#include <QTextEdit>
#include <QCheckBox>
#include <QSplitter>
#include <QTabWidget>
#include <QListWidget>
#include <QApplication>
#include <QDateTimeEdit>
#include <QStackedWidget>
#include <QSlider>
#include <stdio.h>

Go to the source code of this file.

Classes

class  QtxPagePrefItem::Listener

Functions

static void fixupAndSet (QLineEdit *le, const QString &txt)

Function Documentation

static void fixupAndSet ( QLineEdit *  le,
const QString &  txt 
) [static]

Definition at line 2058 of file QtxPagePrefMgr.cxx.

{
  if ( le ) {
    QString val = txt;
    if ( le->validator() ) {
      const QDoubleValidator* de = dynamic_cast<const QDoubleValidator*>( le->validator() );
      if ( de ) {
       int dec = de->decimals();
       int idx = val.lastIndexOf( QRegExp( QString("[.|%1]").arg( le->locale().decimalPoint () ) ) );
       if ( idx >= 0 ) {
         QString tmp = val.mid( idx+1 );
         QString exp;
         val = val.left( idx+1 );
         idx = tmp.indexOf( QRegExp( QString("[e|E]") ) );
         if ( idx >= 0 ) {
           exp = tmp.mid( idx );
           tmp = tmp.left( idx );
         }
         tmp.truncate( dec );
         val = val + tmp + exp;
       }
      }
      int pos = 0;
      if ( le->validator()->validate( val, pos ) == QValidator::Invalid )
       val.clear();
    }
    le->setText( val );
  }
}