1
git-svn-id: svn://db.shs.com.ru/libs@1 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
43
qad_widgets/clineedit.h
Normal file
43
qad_widgets/clineedit.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef CLINEEDIT_H
|
||||
#define CLINEEDIT_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLineEdit>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
class CLineEdit: public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString defaultText READ defaultText WRITE setDefaultText)
|
||||
|
||||
public:
|
||||
explicit CLineEdit(QWidget * parent = 0);
|
||||
~CLineEdit() {delete cw;}
|
||||
|
||||
inline QString defaultText() const {return dt;}
|
||||
|
||||
protected:
|
||||
QWidget * cw;
|
||||
QString dt;
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
void resizeEvent(QResizeEvent * );
|
||||
void changeEvent(QEvent * e);
|
||||
|
||||
private slots:
|
||||
void clearMouseRelease(QMouseEvent * e) {if (cw->rect().contains(e->pos())) clearClick();}
|
||||
void textChanged_(QString text) {cw->setVisible(text != dt);}
|
||||
|
||||
public slots:
|
||||
void clearClick() {if (!isEnabled()) return; setText(dt); emit cleared(); emit textEdited(dt);}
|
||||
void setDefaultText(const QString & t, bool set_text = false);
|
||||
|
||||
signals:
|
||||
void cleared();
|
||||
|
||||
};
|
||||
|
||||
#endif // CLINEEDIT_H
|
||||
Reference in New Issue
Block a user