refactoring qad widgets part 1
c++ cast, nullptr, forward declaration, agregate ui, connect to member functions, order and clear includes
This commit is contained in:
@@ -20,46 +20,40 @@
|
||||
#ifndef CLINEEDIT_H
|
||||
#define CLINEEDIT_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLineEdit>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include "qad_widgets_export.h"
|
||||
#include <QLineEdit>
|
||||
|
||||
|
||||
class QAD_WIDGETS_EXPORT CLineEdit: public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString defaultText READ defaultText WRITE setDefaultText)
|
||||
|
||||
public:
|
||||
explicit CLineEdit(QWidget * parent = 0);
|
||||
~CLineEdit() {delete cw;}
|
||||
explicit CLineEdit(QWidget * parent = nullptr);
|
||||
~CLineEdit() override;
|
||||
|
||||
const QString & defaultText() const {return dt;}
|
||||
|
||||
protected:
|
||||
QWidget * cw;
|
||||
QString dt;
|
||||
QImage clear_im;
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
void resizeEvent(QResizeEvent * );
|
||||
void changeEvent(QEvent * e);
|
||||
void cwPaintEvent();
|
||||
|
||||
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();
|
||||
|
||||
|
||||
private slots:
|
||||
void clearMouseRelease(QMouseEvent *e);
|
||||
void textChangedSlot(QString text);
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject * o, QEvent * e) override;
|
||||
void resizeEvent(QResizeEvent *) override;
|
||||
void changeEvent(QEvent * e) override;
|
||||
void cwPaintEvent();
|
||||
|
||||
QWidget * cw;
|
||||
QString dt;
|
||||
QImage clear_im;
|
||||
};
|
||||
|
||||
#endif // CLINEEDIT_H
|
||||
|
||||
Reference in New Issue
Block a user