104 lines
2.8 KiB
C++
104 lines
2.8 KiB
C++
/*
|
|
QAD - Qt ADvanced
|
|
|
|
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef EVALSPINBOX_H
|
|
#define EVALSPINBOX_H
|
|
|
|
#include <QAbstractSpinBox>
|
|
#include <QMouseEvent>
|
|
#include "qpievaluator.h"
|
|
|
|
|
|
class QLabel;
|
|
|
|
class QAD_EXPORT EvalSpinBox: public QAbstractSpinBox
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true)
|
|
Q_PROPERTY(QString expression READ expression WRITE setExpression USER true)
|
|
Q_PROPERTY(QString defaultText READ defaultText WRITE setDefaultText)
|
|
Q_PROPERTY(bool clearButtonVisible READ isClearButtonVisible WRITE setClearButtonVisible)
|
|
Q_PROPERTY(int precision READ precision WRITE setPrecision)
|
|
|
|
public:
|
|
explicit EvalSpinBox(QWidget * parent = 0);
|
|
~EvalSpinBox();
|
|
|
|
double value() const;
|
|
const QString & expression() const;
|
|
const QString & defaultText() const {return dt;}
|
|
bool isClearButtonVisible() const {return cw_visible;}
|
|
bool isCleared() const;
|
|
int precision() const {return precision_;}
|
|
|
|
virtual void stepBy(int steps);
|
|
virtual void clear();
|
|
virtual QSize sizeHint() const;
|
|
|
|
protected:
|
|
QString text() const {return QAbstractSpinBox::text();}
|
|
|
|
virtual StepEnabled stepEnabled() const;
|
|
virtual void focusInEvent(QFocusEvent *event);
|
|
virtual void focusOutEvent(QFocusEvent *event);
|
|
virtual void wheelEvent(QWheelEvent *event);
|
|
|
|
void stepByDouble(double steps);
|
|
|
|
QWidget * status;
|
|
QWidget * cw;
|
|
QPIEvaluator eval;
|
|
QLabel * label;
|
|
QImage icon_ok;
|
|
QImage icon_fail;
|
|
QImage icon_calc;
|
|
QImage icon;
|
|
QImage clear_im;
|
|
QString dt;
|
|
bool cw_visible;
|
|
int precision_;
|
|
|
|
private:
|
|
bool eventFilter(QObject * o, QEvent * e);
|
|
void resizeEvent(QResizeEvent * );
|
|
void changeEvent(QEvent * e);
|
|
void statusPaintEvent();
|
|
void cwPaintEvent();
|
|
|
|
private slots:
|
|
void clearMouseRelease(QMouseEvent * e);
|
|
void textChanged_(const QString & text);
|
|
void setExpression_();
|
|
void resizeIcons();
|
|
|
|
public slots:
|
|
void setExpression(const QString & expr);
|
|
void setValue(double val);
|
|
void setDefaultText(const QString & t);
|
|
void setClearButtonVisible(bool visible);
|
|
void setPrecision(int precision) {precision_ = precision;}
|
|
|
|
signals:
|
|
void valueChanged(double val);
|
|
void cleared();
|
|
|
|
};
|
|
|
|
#endif // EVALSPINBOX_H
|