<rect>
<x>0</x>
<y>0</y>
- <width>478</width>
- <height>475</height>
+ <width>488</width>
+ <height>490</height>
</rect>
</property>
<property name="caption">
</widget>
<widget class="QCheckBox">
<property name="name">
- <cstring>VdcheckBox</cstring>
+ <cstring>efVd</cstring>
</property>
<property name="text">
<string>Vd</string>
<cstring>textLabel3</cstring>
</property>
<property name="text">
- <string><font size="-1"><u>Example:</u> RegEx <b><i>[A-C]\d{5}[W-Z]</b></i> for string <i><b>A12345Z</b></i></font></string>
+ <string><u>Example:</u> RegExp <b><i>[A-C]\d{5}[W-Z]</b></i> for string <i><b>A12345Z</b></i></string>
</property>
- <property name="alignment">
- <set>WordBreak|AlignCenter</set>
+ <property name="textFormat">
+ <enum>AutoText</enum>
</property>
</widget>
</grid>
<slot>tNotBound_stateChanged(int)</slot>
</connection>
<connection>
- <sender>VdcheckBox</sender>
+ <sender>efVd</sender>
<signal>stateChanged(int)</signal>
<receiver>dEditField</receiver>
- <slot>VdcheckBox_stateChanged(int)</slot>
+ <slot>efVd_stateChanged(int)</slot>
</connection>
<connection>
<sender>VdRegEx</sender>
<slot>tNotBound_stateChanged( int )</slot>
<slot>aUsersList_clicked( QListViewItem * )</slot>
<slot>setExample()</slot>
- <slot>VdcheckBox_stateChanged( int )</slot>
+ <slot>efVd_stateChanged( int )</slot>
<slot>VdRegEx_textChanged( const QString & )</slot>
<slot>Testline_textChanged( const QString & )</slot>
</slots>
#include <qdatetime.h>
#include <qvaluelist.h>
#include <qlistview.h>
-#include <qvalidator.h>
+#include <qvalidator.h>
#include "alog.h"
#include "acfg.h"
#include "acfgrc.h"
eType->clear();
otypes.append(" ");
lzcheckBox->setText(tr("Add leading zeros"));
- VdcheckBox->setText(tr("Validate"));
+ efVd->setText(tr("Validate"));
eType->insertItem(tr("Unknown"), 0);
}
else efPlus->setChecked( false );
if( md->attr( obj, mda_nz ) == "1" ) efNZ->setChecked( true );
else efNZ->setChecked( false );
+ if( md->attr( obj, mda_vd ) == "1" ) efVd->setChecked( true );
+ else efVd->setChecked( false );
+
+ VdRegEx->setText( md->attr( obj, mda_validator ) );
+
efSum->setChecked(md->attr( obj, mda_sum ) == "1");
QStringList tlist;
else md->setAttr( obj, mda_plus, "0" );
if( efNZ->isChecked() ) md->setAttr( obj, mda_nz, "1" );
else md->setAttr( obj, mda_nz, "0" );
+ if( efVd->isChecked() ) md->setAttr( obj, mda_vd, "1" );
+ else md->setAttr( obj, mda_vd, "0" );
+ if (VdRegEx->text() )md->setAttr( obj, mda_validator, VdRegEx->text().stripWhiteSpace() );
if( efSum->isChecked() )
md->setAttr( obj, mda_sum, "1" );
else
tSepTriads->show();
comboBox2->setEnabled(false);
comboBox2->hide();
- VdcheckBox->show();
+ efVd->show();
ValidateGroupBox->show();
DateMask->hide();
saldoTextLabel->hide();
lzcheckBox->hide();
tNotBound->show();
DateMask->show();
- VdcheckBox->show();
+ efVd->show();
ValidateGroupBox->show();
efSum->setChecked(false);
comboBox2->setEnabled(false);
efSum->hide();
tNotBound->hide();
tSepTriads->hide();
- VdcheckBox->hide();
+ efVd->hide();
ValidateGroupBox->hide();
//
Num_Label->hide();
efSum->hide();
tNotBound->hide();
tSepTriads->hide();
- VdcheckBox->hide();
+ efVd->hide();
DateMask->hide();
ValidateGroupBox->hide();
//
-void dEditField::VdcheckBox_stateChanged( int )
+void dEditField::efVd_stateChanged( int )
{
- if (VdcheckBox->isChecked() )
+ if (efVd->isChecked() )
{
ValidateGroupBox->show();
} else {
if(v.validate(s, pos ) == QValidator::Acceptable)
{
pal.setColor(QColorGroup::Highlight, Qt::green);
- Testline->setPalette(pal);
+ Testline->setPalette(pal);
}
}
#define mda_format "format"
#define mda_stdf "stdf"
#define mda_rights "rights"
+#define mda_vd "vd"
+#define mda_validator "validator"
+
/*!
Actions types
}else{
wField::SetNonZero(false);
}
+ if ( md->attr(o,mda_vd) == "1" && md->attr(o,mda_validator) != "")
+ {
+ wField::SetValidator( md->attr(o,mda_validator) );
+ }
+
+
//aObject* obj = new aObject(o,adb);
//tableInsert( aDatabase::tableDbName( *md, o ), o );
// debug_message("init dbfield \n");
{
// set default validator for string
lineEdit->setMaxLength(20);
- }
- else
- {
+ }else{
// set validator for string
lineEdit->setMaxLength(n1);
}
connect( lineEdit, SIGNAL( textChanged( const QString & ) ),
- this, SLOT( setValue( const QString & ) ) );
+ this, SLOT( setValue( const QString & ) ) );
connect( lineEdit, SIGNAL( lostFocus() ), this, SLOT( focusOutEvent()) );
setFocusProxy(lineEdit);
void
wField::setValue(const QDate& newDate)
{
-//CHECK_POINT
+ //CHECK_POINT
vValue = newDate.toString(Qt::ISODate);
- vValue+="T00:00:00"; //for correct converting to date-time
+ vValue+="T00:00:00";//for correct converting to date-time
emit valueChanged(vValue);
emit valueChanged(QVariant(vValue));
}
+/*!
+ * \en Validate value and paint LineEdit frame. \_en
+ * \ru Проверяет значение и рисует рамку поля ввода.\_ru
+ */
+void
+wField::Validate(const QString &test)
+{
+ int p = 0;
+ QString s = test;
+ QPalette pal = lineEdit->palette();
+ switch ( v->validate(s, p) )
+ {
+ case QValidator::Invalid:
+ pal.setColor(QColorGroup::Highlight, Qt::red);
+ lineEdit->setPalette(pal);
+ emit inputInvalid();
+ break;
+ case QValidator::Intermediate:
+ pal.setColor(QColorGroup::Highlight, Qt::yellow);
+ lineEdit->setPalette(pal);
+ setValue( test );
+ break;
+ case QValidator::Acceptable:
+ pal.setColor(QColorGroup::Highlight, Qt::green);
+ lineEdit->setPalette(pal);
+ setValue( test );
+ break;
+ }
+}
+
+/*!
+ * \en Set validaror and connect LineEdit to Validator.
+ * \_en
+ * \ru Устанавливает валидатор и соединяет LineEdit с Validator.
+ * \_ru
+ * \param QString Validator - \en RegExp for QRegExpValidator \_en \ru значение RegExp для установки QRegExpValidator\_ru
+ */
+void
+wField::SetValidator(QString Validator)
+{
+ QRegExp rx( Validator );
+ v = new QRegExpValidator( rx, 0 );
+ connect( lineEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( Validate( const QString & ) ) );
+}
/*!
* \en Sets value. \_en
}
-
/*!
* \en Gets value. \_en
* \ru Возвращает значение виджета. \_ru
}
-
/*!
* \en Gets text value. \_en
* \ru Возвращает текстовое значение виджета. \_ru
}
}
-
-
-
/*!
* \en Handler signal lostFocus. \_en
* \ru Обработчик сигнала lostFocus. \ru
#include "adatabase.h"
#include "ananas.h"
#include "acalendar.h"
+#include <qvalidator.h>
class wCatButton;
class wCheckBox;
signals:
void valueChanged( const QString & );
void valueChanged( const QVariant & );
+ void inputInvalid();
void lostFocus();
public slots:
virtual QString value() const;
QString text() const;
virtual void setValue( const QString &fn );
+ virtual void Validate( const QString &fn );
void setValue( const QDate& d);
virtual QString textValue() {return text();};
void setFieldType( QString n );
void selectAll();
virtual void SetReadOnly(bool);
virtual void SetNonZero(bool);
+ virtual void SetValidator(QString Validator);
private slots:
void on_selected( Q_ULLONG uid );
QLabel *nzLabel;
wCatButton *objButton;
wCheckBox *checkBox;
+ QValidator *v;
tEditorType vEditorType;
QString vFieldType;
QString vValue;