QString min;
if ( !myDicItem.IsNull() && myDicItem->HasData( DDS_DicItem::MinValue ) )
- min = format( format(), type(), myDicItem->GetMinValue() );
+ min = formatValue( (double)myDicItem->GetMinValue() );
return min;
}
QString max;
if ( !myDicItem.IsNull() && myDicItem->HasData( DDS_DicItem::MaxValue ) )
- max = format( format(), type(), myDicItem->GetMaxValue() );
+ max = formatValue( myDicItem->GetMaxValue() );
return max;
}
initDatum();
mySourceValue = defaultValue();
- setString( format( ( myFlags & NotFormat ) ? (QString) "" : format(), type(), mySourceValue ) );
+ setString( formatValue( mySourceValue ) );
invalidateCache();
onParamChanged();
initDatum();
mySourceValue = txt;
- QString aStr = format( ( flags() & NotFormat ) ? (QString) "" : format(), type(), txt );
+ QString aStr = formatValue( txt );
setString( aStr );
myTargetValue = aStr;
if ( !myDicItem.IsNull() && !( flags() & NotConvert ) )
val = myDicItem->FromSI( val );
- QString aStr = format( ( flags() & NotFormat ) ? (QString) "" : format(), type(), val );
+ QString aStr = formatValue( val );
setString( aStr );
myTargetValue = aStr;
if ( !myDicItem.IsNull() && !( flags() & NotConvert ) )
val = myDicItem->FromSI( val );
- QString aStr = format( ( flags() & NotFormat ) ? (QString) "" : format(), type(), val );
+ QString aStr = formatValue( val );
setString( aStr );
myTargetValue = aStr;
parent()->removeEventFilter( (QObject*)this );
}
+/*!
+ \brief Format integer value according to datum formatting and type.
+ \internal
+ \param theValue the value being formatted.
+ \return formatted string value.
+*/
+QString QDS_Datum::formatValue( const int theValue ) const
+{
+ return format( flags() & NotFormat ? "" : format(), type(), theValue );
+}
+
+/*!
+ \brief Format double value according to datum formatting and type.
+ \internal
+ \param theValue the value being formatted.
+ \return formatted string value.
+*/
+QString QDS_Datum::formatValue( const double theValue ) const
+{
+ return format( flags() & NotFormat ? "" : format(), type(), theValue );
+}
+
+/*!
+ \brief Format string value according to datum formatting and type.
+ \internal
+ \param theValue the value being formatted.
+ \return formatted string value.
+*/
+QString QDS_Datum::formatValue( const QString& theValue ) const
+{
+ return format( flags() & NotFormat ? "" : format(), type(), theValue );
+}
+
/*!
\brief Get wrapper for specified subwidget.
\internal
#include <QLineEdit>
#include <QValidator>
-/*!
- \class QDS_LineEdit::Editor
- \internal
- \brief Improved version of QLineEdit.
-*/
-
-class QDS_LineEdit::Editor : public QLineEdit
-{
-public:
- Editor( QWidget* parent = 0 ) : QLineEdit( parent ), myNumber( 2 ) {};
- virtual ~Editor() {};
-
- void setNumber( const int num ) { myNumber = num; };
-
- virtual QSize minimumSizeHint() const
- {
- return QLineEdit::minimumSizeHint().
- expandedTo( QSize( fontMetrics().width( "0" ) * myNumber, 0 ) );
- }
-
- virtual QSize sizeHint() const
- {
- return minimumSizeHint();
- }
-
-private:
- int myNumber;
-};
-
/*
\class QDS_LineEdit
num += aLen.toInt();
}
- int zeroLen = format( format(), type(), 0 ).length();
- int minLen = format( format(), type(), minValue() ).length();
- int maxLen = format( format(), type(), maxValue() ).length();
+ int zeroLen = formatValue( 0 ).length();
+ int minLen = formatValue( minValue() ).length();
+ int maxLen = formatValue( maxValue() ).length();
num = qMax( qMax( num, zeroLen ), qMax( minLen, maxLen ) );
((Editor*)le)->setNumber( num );
#include "QDS_Datum.h"
-class QLineEdit;
+#include <QLineEdit>
class QDS_EXPORT QDS_LineEdit : public QDS_Datum
{
Q_PROPERTY( bool Selection READ hasSelection WRITE setSelection )
-protected:
+public:
class Editor;
public:
virtual void unitSystemChanged( const QString& );
};
+class QDS_LineEdit::Editor : public QLineEdit
+{
+public:
+ Editor( QWidget* parent = 0 ) : QLineEdit( parent ), myNumber( 2 ) {};
+ virtual ~Editor() {};
+
+ void setNumber( const int num ) { myNumber = num; };
+
+ virtual QSize minimumSizeHint() const
+ {
+ return QLineEdit::minimumSizeHint().
+ expandedTo( QSize( fontMetrics().width( "0" ) * myNumber, 0 ) );
+ }
+
+ virtual QSize sizeHint() const
+ {
+ return minimumSizeHint();
+ }
+
+private:
+ int myNumber;
+};
+
#endif