qwwlineedit.cpp

00001 //
00002 // C++ Implementation: %{MODULE}
00003 //
00004 // Description:
00005 //
00006 //
00007 // Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR}
00008 //
00009 // Copyright: See COPYING file that comes with this distribution
00010 //
00011 //
00012 
00013 #ifndef WW_NO_LINEEDIT
00014 
00015 #include "qwwlineedit.h"
00016 #include <QRegExpValidator>
00017 
00022 QwwLineEdit::QwwLineEdit(QWidget *parent)
00023         : QLineEdit(parent) {}
00024 
00025 
00031 QwwLineEdit::QwwLineEdit(const QString & contents, QWidget * parent)
00032         : QLineEdit(contents, parent) {}
00033 
00037 QwwLineEdit::~QwwLineEdit() {}
00038 
00039 
00044 QString QwwLineEdit::regExp() const {
00045     const QRegExpValidator *rxvalid = qobject_cast<const QRegExpValidator*>(validator());
00046     if (!rxvalid) return ".*";
00047     return rxvalid->regExp().pattern();
00048 }
00049 
00054 void QwwLineEdit::setRegExp(const QString &v) {
00055     QValidator *valid = const_cast<QValidator*>(validator());
00056     QRegExpValidator *rxvalid = qobject_cast<QRegExpValidator*>(valid);
00057     if (rxvalid && rxvalid->regExp().pattern()==v) {
00058         return;
00059     }
00060     QRegExp rx(v);
00061     if (v==".*" || v.isEmpty()) {
00062         setValidator(0);
00063         emit validatorChanged(".*");
00064         return;
00065     }
00066     if (rxvalid) {
00067         rxvalid->setRegExp(rx);
00068     } else {
00069         setValidator(new QRegExpValidator(rx, this));
00070     }
00071     emit validatorChanged(v);
00072 }
00073 
00078 void QwwLineEdit::setRegExp(const QRegExp &rx) {
00079     QValidator *valid = const_cast<QValidator*>(validator());
00080     QRegExpValidator *rxvalid = qobject_cast<QRegExpValidator*>(valid);
00081     if (rxvalid && rxvalid->regExp()==rx) {
00082         return;
00083     }
00084     if (rx.pattern()==".*") {
00085         setValidator(0);
00086         emit validatorChanged(".*");
00087         return;
00088     }
00089     if (rxvalid) {
00090         rxvalid->setRegExp(rx);
00091     } else {
00092         setValidator(new QRegExpValidator(rx, this));
00093     }
00094     emit validatorChanged(rx.pattern());
00095 }
00096 
00097 #endif

Generated on Sat Apr 21 21:54:35 2007 for wwWidgets by  doxygen 1.5.1