Files
qad/libs/piqt_widgets/pivariant_edit_widgets.h
2022-11-29 18:08:39 +03:00

88 lines
2.3 KiB
C++

/*
PIQt Utils - Qt utilites for PIP
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 pivariant_edit_widgets_H
#define pivariant_edit_widgets_H
#include "pivariant_edit.h"
#include <QCheckBox>
#include <QSpinBox>
#include <QDoubleSpinBox>
class QAD_PIQT_UTILS_EXPORT PIVariantEditorBool: public PIVariantEditorBase {
public:
PIVariantEditorBool() {
createBoxLayout();
widget = new QCheckBox();
layout()->addWidget(widget);
}
void setValue(const PIVariant & v) override {widget->setChecked(v.toBool());}
PIVariant value() const override {return widget->isChecked();}
private:
QCheckBox * widget;
};
class QAD_PIQT_UTILS_EXPORT PIVariantEditorInt: public PIVariantEditorBase {
public:
PIVariantEditorInt() {
createBoxLayout();
widget = new QSpinBox();
layout()->addWidget(widget);
}
void setValue(const PIVariant & v) override {widget->setValue(v.toInt());}
PIVariant value() const override {return widget->value();}
PIVariantMap defaultAttributes() const override;
private:
void applyAttributes(const PIVariantMap & a) override;
QSpinBox * widget;
};
class QAD_PIQT_UTILS_EXPORT PIVariantEditorDouble: public PIVariantEditorBase {
public:
PIVariantEditorDouble() {
createBoxLayout();
widget = new QDoubleSpinBox();
widget->setRange(-std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
layout()->addWidget(widget);
}
void setValue(const PIVariant & v) override {widget->setValue(v.toDouble());}
PIVariant value() const override {return widget->value();}
PIVariantMap defaultAttributes() const override;
private:
void applyAttributes(const PIVariantMap & a) override;
QDoubleSpinBox * widget;
};
#endif