git-svn-id: svn://db.shs.com.ru/libs@334 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -35,6 +35,7 @@ if (DEBUG)
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
|
||||||
endif ()
|
endif ()
|
||||||
|
include(SDKMacros.cmake)
|
||||||
|
|
||||||
set(PIP_LIBRARY pip)
|
set(PIP_LIBRARY pip)
|
||||||
set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io" "console" "math" "code" "geo" "resources" "opencl")
|
set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io" "console" "math" "code" "geo" "resources" "opencl")
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY})
|
|||||||
add_executable(cdutilstest "cdutilstest.cpp" "cdtest.h")
|
add_executable(cdutilstest "cdutilstest.cpp" "cdtest.h")
|
||||||
target_link_libraries(cdutilstest ${PIP_LIBRARY} ${PROJECT_NAME})
|
target_link_libraries(cdutilstest ${PIP_LIBRARY} ${PROJECT_NAME})
|
||||||
message(STATUS "Building ${PROJECT_NAME}")
|
message(STATUS "Building ${PROJECT_NAME}")
|
||||||
#if (LIBPROJECT)
|
|
||||||
# include(SDKMacros)
|
|
||||||
# sdk_install("" "${PROJECT_NAME}" "${HDRS_UTILS}")
|
|
||||||
#else()
|
|
||||||
if(LIB)
|
if(LIB)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
|
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
|
||||||
@@ -52,4 +48,3 @@ message(STATUS "Building ${PROJECT_NAME}")
|
|||||||
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||||
#message(STATUS "Install ${PROJECT_NAME} to local \"bin\"")
|
#message(STATUS "Install ${PROJECT_NAME} to local \"bin\"")
|
||||||
endif()
|
endif()
|
||||||
#endif()
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ qt_add_library(${PROJECT_NAME} SHARED out_CPP)
|
|||||||
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets)
|
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets)
|
||||||
message(STATUS "Building ${PROJECT_NAME}")
|
message(STATUS "Building ${PROJECT_NAME}")
|
||||||
if(LIBPROJECT)
|
if(LIBPROJECT)
|
||||||
include(SDKMacros)
|
|
||||||
sdk_install("pip" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}")
|
sdk_install("pip" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}")
|
||||||
else()
|
else()
|
||||||
if(LIB)
|
if(LIB)
|
||||||
|
|||||||
@@ -13,34 +13,6 @@
|
|||||||
__GraphicRegistrator__ __graphic_registrator__;
|
__GraphicRegistrator__ __graphic_registrator__;
|
||||||
|
|
||||||
|
|
||||||
ELineEdit::ELineEdit(QWidget * parent): CLineEdit(parent) {
|
|
||||||
last_ret = complexd_0;
|
|
||||||
is_auto = false;
|
|
||||||
is_reset = true;
|
|
||||||
connect(this, SIGNAL(editingFinished()), this, SLOT(calculate()));
|
|
||||||
connect(this, SIGNAL(cleared()), this, SLOT(toDefaultClicked()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ELineEdit::wheelEvent(QWheelEvent * e) {
|
|
||||||
double mul = 1.1;
|
|
||||||
if (e->delta() < 0) mul = 0.9;
|
|
||||||
CLineEdit::setText(QString::number(last_ret.real() * mul).toUpper());
|
|
||||||
calculate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ELineEdit::calculate() {
|
|
||||||
evaluator.check(text().replace(",", "."));
|
|
||||||
if (!evaluator.isCorrect()) return;
|
|
||||||
is_reset = false;
|
|
||||||
last_ret = evaluator.evaluate();
|
|
||||||
CLineEdit::setText(QString::number(last_ret.real()).toUpper());
|
|
||||||
emit valueChanged(last_ret.real());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Graphic::Graphic(QWidget * parent): QFrame(parent), line_x_min(this), line_x_max(this), line_y_min(this), line_y_max(this) {
|
Graphic::Graphic(QWidget * parent): QFrame(parent), line_x_min(this), line_x_max(this), line_y_min(this), line_y_max(this) {
|
||||||
QTranslator * trans = new QTranslator();
|
QTranslator * trans = new QTranslator();
|
||||||
trans->load(":/lang/qad_graphic_" + QLocale::system().name().left(2));
|
trans->load(":/lang/qad_graphic_" + QLocale::system().name().left(2));
|
||||||
@@ -66,6 +38,10 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), line_x_min(this), line_x_max
|
|||||||
LN2 = qLn(2.);
|
LN2 = qLn(2.);
|
||||||
LN5 = qLn(5.);
|
LN5 = qLn(5.);
|
||||||
LN10 = qLn(10.);
|
LN10 = qLn(10.);
|
||||||
|
line_x_min.setClearButtonVisible(true);
|
||||||
|
line_x_max.setClearButtonVisible(true);
|
||||||
|
line_y_min.setClearButtonVisible(true);
|
||||||
|
line_y_max.setClearButtonVisible(true);
|
||||||
connect(&line_x_min, SIGNAL(valueChanged(double)), this, SLOT(lineXMinChanged(double)));
|
connect(&line_x_min, SIGNAL(valueChanged(double)), this, SLOT(lineXMinChanged(double)));
|
||||||
connect(&line_x_max, SIGNAL(valueChanged(double)), this, SLOT(lineXMaxChanged(double)));
|
connect(&line_x_max, SIGNAL(valueChanged(double)), this, SLOT(lineXMaxChanged(double)));
|
||||||
connect(&line_y_min, SIGNAL(valueChanged(double)), this, SLOT(lineYMinChanged(double)));
|
connect(&line_y_min, SIGNAL(valueChanged(double)), this, SLOT(lineYMinChanged(double)));
|
||||||
@@ -1249,26 +1225,44 @@ void Graphic::swapToBuffer() {
|
|||||||
|
|
||||||
void Graphic::setRectToLines() {
|
void Graphic::setRectToLines() {
|
||||||
is_lines_update = true;
|
is_lines_update = true;
|
||||||
line_x_min.is_auto = line_x_max.is_auto = line_y_min.is_auto = line_y_max.is_auto = true;
|
//line_x_min.is_auto = line_x_max.is_auto = line_y_min.is_auto = line_y_max.is_auto = true;
|
||||||
//qDebug() << "set to lines" << selrect;
|
//qDebug() << "set to lines" << selrect;
|
||||||
line_x_min.is_reset = line_x_max.is_reset = line_y_min.is_reset = line_y_max.is_reset = isFit;
|
//line_x_min.is_reset = line_x_max.is_reset = line_y_min.is_reset = line_y_max.is_reset = isFit;
|
||||||
if (!line_x_min.hasFocus()) line_x_min.setValue(selrect.left());
|
if (line_x_min.isVisible() && line_x_max.isVisible() && line_y_min.isVisible() && line_y_max.isVisible()) {
|
||||||
if (!line_x_max.hasFocus()) line_x_max.setValue(selrect.right());
|
line_x_min.blockSignals(true); line_x_max.blockSignals(true); line_y_min.blockSignals(true); line_y_max.blockSignals(true);
|
||||||
if (!line_y_min.hasFocus()) line_y_min.setValue(selrect.bottom());
|
if (!line_x_min.hasFocus()) {
|
||||||
if (!line_y_max.hasFocus()) line_y_max.setValue(selrect.top());
|
if (isFit) line_x_min.setValue(grect.left());
|
||||||
if (!isFit) {
|
else line_x_min.setValue(selrect.left());
|
||||||
|
}
|
||||||
|
if (!line_x_max.hasFocus()) {
|
||||||
|
if(isFit) line_x_max.setValue(grect.right());
|
||||||
|
else line_x_max.setValue(selrect.right());
|
||||||
|
}
|
||||||
|
if (!line_y_min.hasFocus()) {
|
||||||
|
if(isFit) line_y_min.setValue(grect.bottom());
|
||||||
|
else line_y_min.setValue(selrect.bottom());
|
||||||
|
}
|
||||||
|
if (!line_y_max.hasFocus()) {
|
||||||
|
if(isFit) line_y_max.setValue(grect.top());
|
||||||
|
else line_y_max.setValue(selrect.top());
|
||||||
|
}
|
||||||
line_x_min.setDefaultText(QString::number(grect.left()).toUpper());
|
line_x_min.setDefaultText(QString::number(grect.left()).toUpper());
|
||||||
line_x_max.setDefaultText(QString::number(grect.right()).toUpper());
|
line_x_max.setDefaultText(QString::number(grect.right()).toUpper());
|
||||||
line_y_min.setDefaultText(QString::number(grect.bottom()).toUpper());
|
line_y_min.setDefaultText(QString::number(grect.bottom()).toUpper());
|
||||||
line_y_max.setDefaultText(QString::number(grect.top()).toUpper());
|
line_y_max.setDefaultText(QString::number(grect.top()).toUpper());
|
||||||
|
line_x_min.blockSignals(false); line_x_max.blockSignals(false); line_y_min.blockSignals(false); line_y_max.blockSignals(false);
|
||||||
|
// if(isFit) {
|
||||||
|
// line_y_min.setValue(grect.left());
|
||||||
|
// line_y_max.setValue(grect.left());
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
line_x_min.is_auto = line_x_max.is_auto = line_y_min.is_auto = line_y_max.is_auto = false;
|
//line_x_min.is_auto = line_x_max.is_auto = line_y_min.is_auto = line_y_max.is_auto = false;
|
||||||
is_lines_update = false;
|
is_lines_update = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Graphic::checkLines() {
|
void Graphic::checkLines() {
|
||||||
isFit = (line_x_min.isDefault() && line_x_max.isDefault() && line_y_min.isDefault() && line_y_max.isDefault());
|
isFit = (line_x_min.isCleared() && line_x_max.isCleared() && line_y_min.isCleared() && line_y_max.isCleared());
|
||||||
update(true);
|
update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1549,6 +1543,7 @@ void Graphic::setBorderInputsVisible(bool visible) {
|
|||||||
ui->widgetLX->setVisible(visible);
|
ui->widgetLX->setVisible(visible);
|
||||||
ui->widgetLY->setVisible(visible);
|
ui->widgetLY->setVisible(visible);
|
||||||
ui->checkBorderInputs->setChecked(visible);
|
ui->checkBorderInputs->setChecked(visible);
|
||||||
|
if (visible) setRectToLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,34 +16,12 @@
|
|||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include "graphic_conf.h"
|
#include "graphic_conf.h"
|
||||||
#include "clineedit.h"
|
#include "evalspinbox.h"
|
||||||
#include "qpievaluator.h"
|
|
||||||
|
|
||||||
QT_BEGIN_HEADER
|
QT_BEGIN_HEADER
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class ELineEdit: public CLineEdit {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit ELineEdit(QWidget * parent = 0);
|
|
||||||
//void setText(const QString & v) {if (!is_auto) is_reset = false; CLineEdit::setText(v); setDefaultText(v, is_reset); last_ret = complexd(v.toDouble(), 0.); emit valueChanged(last_ret.real());}
|
|
||||||
void setValue(const int & v) {if (is_reset) setDefaultText(QString::number(v).toUpper(), is_reset); else setText(QString::number(v).toUpper()); last_ret = complexd(v, 0.); if (!is_auto) emit valueChanged(last_ret.real());}
|
|
||||||
void setValue(const double & v) {if (is_reset) setDefaultText(QString::number(v).toUpper(), is_reset); else setText(QString::number(v).toUpper()); last_ret = complexd(v, 0.); if (!is_auto) emit valueChanged(last_ret.real());}
|
|
||||||
double value() const {return last_ret.real();}
|
|
||||||
bool isDefault() const {return !cw->isVisible();}
|
|
||||||
bool is_reset, is_auto;
|
|
||||||
protected:
|
|
||||||
void wheelEvent(QWheelEvent * e);
|
|
||||||
QPIEvaluator evaluator;
|
|
||||||
complexd last_ret;
|
|
||||||
private slots:
|
|
||||||
void toDefaultClicked() {is_reset = true; calculate();}
|
|
||||||
void calculate();
|
|
||||||
signals:
|
|
||||||
void valueChanged(double value);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class Graphic;
|
class Graphic;
|
||||||
@@ -381,7 +359,7 @@ protected:
|
|||||||
Graphic::Buttons buttons_;
|
Graphic::Buttons buttons_;
|
||||||
Graphic::Alignment align;
|
Graphic::Alignment align;
|
||||||
GraphicConf * conf;
|
GraphicConf * conf;
|
||||||
ELineEdit line_x_min, line_x_max, line_y_min, line_y_max;
|
EvalSpinBox line_x_min, line_x_max, line_y_min, line_y_max;
|
||||||
QTime tm;
|
QTime tm;
|
||||||
QIcon icon_exp_x, icon_exp_y, icon_exp_sx, icon_exp_sy;
|
QIcon icon_exp_x, icon_exp_y, icon_exp_sx, icon_exp_sy;
|
||||||
QImage icon_pause_b, icon_pause_f;
|
QImage icon_pause_b, icon_pause_f;
|
||||||
|
|||||||
@@ -193,6 +193,9 @@
|
|||||||
<property name="decimals">
|
<property name="decimals">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>999.990000000000009</double>
|
||||||
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<double>1.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
@@ -265,22 +268,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
|
||||||
<widget class="QDoubleSpinBox" name="spinGridStepX">
|
|
||||||
<property name="decimals">
|
|
||||||
<number>3</number>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<double>0.001000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<double>9999999.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>50.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="label_8">
|
<widget class="QLabel" name="label_8">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -295,22 +282,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1">
|
|
||||||
<widget class="QDoubleSpinBox" name="spinGridStepY">
|
|
||||||
<property name="decimals">
|
|
||||||
<number>3</number>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<double>0.001000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<double>9999999.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>30.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="checkGridAutoX">
|
<widget class="QCheckBox" name="checkGridAutoX">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -331,6 +302,32 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="EvalSpinBox" name="spinGridStepY">
|
||||||
|
<property name="expression">
|
||||||
|
<string>30</string>
|
||||||
|
</property>
|
||||||
|
<property name="defaultText">
|
||||||
|
<string>30</string>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonVisible">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="EvalSpinBox" name="spinGridStepX">
|
||||||
|
<property name="expression">
|
||||||
|
<string>50</string>
|
||||||
|
</property>
|
||||||
|
<property name="defaultText">
|
||||||
|
<string>50</string>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonVisible">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -474,6 +471,11 @@
|
|||||||
<signal>colorChanged(QColor)</signal>
|
<signal>colorChanged(QColor)</signal>
|
||||||
</slots>
|
</slots>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>EvalSpinBox</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>evalspinbox.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>checkAAlias</tabstop>
|
<tabstop>checkAAlias</tabstop>
|
||||||
|
|||||||
BIN
qad/icons/dialog-warning.png
Normal file
BIN
qad/icons/dialog-warning.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
BIN
qad/icons/evalspinbox.png
Normal file
BIN
qad/icons/evalspinbox.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
@@ -16,7 +16,7 @@ public:
|
|||||||
explicit CLineEdit(QWidget * parent = 0);
|
explicit CLineEdit(QWidget * parent = 0);
|
||||||
~CLineEdit() {delete cw;}
|
~CLineEdit() {delete cw;}
|
||||||
|
|
||||||
inline QString defaultText() const {return dt;}
|
const QString & defaultText() const {return dt;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QWidget * cw;
|
QWidget * cw;
|
||||||
|
|||||||
303
qad/widgets/evalspinbox.cpp
Normal file
303
qad/widgets/evalspinbox.cpp
Normal file
@@ -0,0 +1,303 @@
|
|||||||
|
#include "evalspinbox.h"
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QRegExp>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyle>
|
||||||
|
#include <QStyleOptionSpinBox>
|
||||||
|
#include "qad_types.h"
|
||||||
|
|
||||||
|
|
||||||
|
EvalSpinBox::EvalSpinBox(QWidget * parent): QAbstractSpinBox(parent) {
|
||||||
|
status = new QWidget(lineEdit());
|
||||||
|
cw = new QWidget(lineEdit());
|
||||||
|
label = new QLabel(lineEdit());
|
||||||
|
// label->hide();
|
||||||
|
clear_im.load(":/icons/edit-clear-locationbar-rtl.png");
|
||||||
|
icon_ok.load(":/icons/dialog-ok-apply.png");
|
||||||
|
icon_fail.load(":/icons/dialog-warning.png");
|
||||||
|
icon_calc.load(":/icons/tools-wizard.png");
|
||||||
|
icon = icon_ok;
|
||||||
|
status->setCursor(Qt::ArrowCursor);
|
||||||
|
status->setToolTip("OK -> 0");
|
||||||
|
status->hide();
|
||||||
|
cw->setCursor(Qt::ArrowCursor);
|
||||||
|
cw->setToolTip(tr("Clear"));
|
||||||
|
cw->hide();
|
||||||
|
cw_visible = false;
|
||||||
|
//lineEdit()->setStyleSheet("color: darkgreen;");
|
||||||
|
//lineEdit()->setText(eval.expression() + " -> " + QString::number(value(), 'G', 10));
|
||||||
|
cw->installEventFilter(this);
|
||||||
|
status->installEventFilter(this);
|
||||||
|
connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(textChanged_(QString)));
|
||||||
|
connect(this, SIGNAL(editingFinished()), this, SLOT(setExpression_()));
|
||||||
|
label->setText("0");
|
||||||
|
//connect(cw, SIGNAL(mouseReleaseEvent(QMouseEvent * )), this, SLOT(clearMouseRelease(QMouseEvent * )));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EvalSpinBox::~EvalSpinBox() {
|
||||||
|
delete cw;
|
||||||
|
delete status;
|
||||||
|
delete label;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool EvalSpinBox::eventFilter(QObject * o, QEvent * e) {
|
||||||
|
switch (e->type()) {
|
||||||
|
case QEvent::MouseButtonRelease:
|
||||||
|
if (o == cw) clearMouseRelease((QMouseEvent * )e);
|
||||||
|
break;
|
||||||
|
case QEvent::Paint:
|
||||||
|
if (o == status) statusPaintEvent();
|
||||||
|
if (o == cw) cwPaintEvent();
|
||||||
|
break;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
return QAbstractSpinBox::eventFilter(o, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::resizeIcons() {
|
||||||
|
int is = fontHeight();
|
||||||
|
int tm = (lineEdit()->height() - is + 1) / 2;
|
||||||
|
QStyleOptionFrame so;
|
||||||
|
so.initFrom(lineEdit());
|
||||||
|
QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &so, lineEdit());
|
||||||
|
label->setGeometry(r.x() + 2, r.y() + (r.height() - fontMetrics().height() + 1) / 2, lineEdit()->width() - 2*tm - (is * 1.2) * ((status->isVisible() ? 1 : 0) + (cw->isVisible() ? 1 : 0)), lineEdit()->height() - 2*tm);
|
||||||
|
status->setGeometry(lineEdit()->width() - (is + tm) * (cw->isVisible() ? 2 : 1), tm, is, is);
|
||||||
|
cw->setGeometry(lineEdit()->width() - (is + tm) * 1, tm, is, is);
|
||||||
|
lineEdit()->setTextMargins(0, 0, (is * 1.2) * ((status->isVisible() ? 1 : 0) + (cw->isVisible() ? 1 : 0)), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::resizeEvent(QResizeEvent * e) {
|
||||||
|
QAbstractSpinBox::resizeEvent(e);
|
||||||
|
resizeIcons();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::changeEvent(QEvent * e) {
|
||||||
|
if (e->type() == QEvent::LanguageChange) {
|
||||||
|
cw->setToolTip(tr("Clear"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QAbstractSpinBox::changeEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::cwPaintEvent() {
|
||||||
|
QPainter p(cw);
|
||||||
|
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
p.drawImage(cw->rect(), clear_im);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::statusPaintEvent() {
|
||||||
|
QPainter p(status);
|
||||||
|
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
p.drawImage(status->rect(), icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::clearMouseRelease(QMouseEvent * e) {
|
||||||
|
if (cw->rect().contains(e->pos())) clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::textChanged_(const QString & text) {
|
||||||
|
double pv = value();
|
||||||
|
QString t = text;
|
||||||
|
cw->setVisible(text != dt && cw_visible);
|
||||||
|
bool td = false;
|
||||||
|
if (t.endsWith('=')) {
|
||||||
|
td = true;
|
||||||
|
t.chop(1);
|
||||||
|
}
|
||||||
|
bool ok = eval.check(t);
|
||||||
|
if (ok) {
|
||||||
|
eval.evaluate();
|
||||||
|
if (td) {
|
||||||
|
icon = icon_calc;
|
||||||
|
status->setToolTip("Enter to calc -> "+QString::number(value(), 'G', 10));
|
||||||
|
} else {
|
||||||
|
icon = icon_ok;
|
||||||
|
status->setToolTip("OK -> "+QString::number(value(), 'G', 10));
|
||||||
|
}
|
||||||
|
// qDebug() << "value =" << value();
|
||||||
|
if (pv != value()) emit valueChanged(value());
|
||||||
|
} else {
|
||||||
|
icon = icon_fail;
|
||||||
|
status->setToolTip(eval.error());
|
||||||
|
}
|
||||||
|
resizeIcons();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::setExpression_() {
|
||||||
|
bool td = false;
|
||||||
|
double pv = value();
|
||||||
|
QString t = text();
|
||||||
|
if (t.endsWith('=')) {
|
||||||
|
td = true;
|
||||||
|
t.chop(1);
|
||||||
|
}
|
||||||
|
if (eval.check(t)) {
|
||||||
|
if (eval.expression() == "0") lineEdit()->clear();
|
||||||
|
else lineEdit()->setText(eval.expression());
|
||||||
|
eval.evaluate();
|
||||||
|
if (td) lineEdit()->setText(QString::number(value(), 'G', 10));
|
||||||
|
status->setToolTip("OK -> " + QString::number(value(), 'G', 10));
|
||||||
|
icon = icon_ok;
|
||||||
|
} else {
|
||||||
|
icon = icon_fail;
|
||||||
|
status->setToolTip(eval.error());
|
||||||
|
// qDebug() << eval.expression();
|
||||||
|
}
|
||||||
|
if (!label->isHidden()) {
|
||||||
|
if (eval.expression() != QString::number(value(), 'G', 10) && eval.expression() != QString::number(value(), 'G', 11) && eval.isCorrect())
|
||||||
|
label->setText("<html><head/><body><p>" + eval.expression() + " <span style=\"color:#005500;\">-> " + QString::number(value(), 'G', 10) + "</span></p></body></html>");
|
||||||
|
else label->setText(eval.expression());
|
||||||
|
lineEdit()->blockSignals(true);
|
||||||
|
if (!eval.isCorrect()) {
|
||||||
|
lineEdit()->setStyleSheet("color: darkred;");
|
||||||
|
status->show();
|
||||||
|
} else {
|
||||||
|
lineEdit()->setStyleSheet("color: black;");
|
||||||
|
status->hide();
|
||||||
|
}
|
||||||
|
// lineEdit()->setText(eval.expression() + " -> " + QString::number(value(), 'G', 10));
|
||||||
|
lineEdit()->setText("");
|
||||||
|
lineEdit()->blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// qDebug() << "value =" << value();
|
||||||
|
if (pv != value()) emit valueChanged(value());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::setExpression(const QString & expr) {
|
||||||
|
lineEdit()->setText(expr);
|
||||||
|
//if (eval.expression() == "0") lineEdit()->clear();
|
||||||
|
cw->setVisible(text() != dt && cw_visible);
|
||||||
|
setExpression_();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::setValue(double val) {
|
||||||
|
lineEdit()->setText(QString::number(val));
|
||||||
|
//if (val == 0) lineEdit()->clear();
|
||||||
|
cw->setVisible(text() != dt && cw_visible);
|
||||||
|
setExpression_();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::stepBy(int steps) {
|
||||||
|
QString t = text();
|
||||||
|
if (eval.check(t)) {
|
||||||
|
t = eval.expression();
|
||||||
|
QRegExp re("(\\-?\\d+)");
|
||||||
|
int pos = 0;
|
||||||
|
if ((pos = re.indexIn(t)) != -1) {
|
||||||
|
double v = t.mid(pos, re.matchedLength()).toDouble();
|
||||||
|
v += steps;
|
||||||
|
t.remove(pos, re.matchedLength());
|
||||||
|
t.insert(pos, QString::number(v));
|
||||||
|
} else {
|
||||||
|
double v = steps;
|
||||||
|
t = QString::number(v) + t;
|
||||||
|
}
|
||||||
|
eval.check(t);
|
||||||
|
lineEdit()->setText(eval.expression());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::clear() {
|
||||||
|
lineEdit()->setText(dt);
|
||||||
|
setExpression_();
|
||||||
|
cw->hide();
|
||||||
|
resizeIcons();
|
||||||
|
emit cleared();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double EvalSpinBox::value() const {
|
||||||
|
if (eval.isCorrect()) {
|
||||||
|
return eval.lastResult().real();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QString & EvalSpinBox::expression() const {
|
||||||
|
return eval.expression();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool EvalSpinBox::isCleared() const {
|
||||||
|
return (dt == eval.expression() || (value() == 0 && dt.isEmpty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QSize EvalSpinBox::sizeHint() const {
|
||||||
|
QSize s = QAbstractSpinBox::sizeHint();
|
||||||
|
s.setWidth(120);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QAbstractSpinBox::StepEnabled EvalSpinBox::stepEnabled() const {
|
||||||
|
return StepUpEnabled | StepDownEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::focusInEvent(QFocusEvent * event) {
|
||||||
|
// qDebug() << "focus_in";
|
||||||
|
label->hide();
|
||||||
|
status->show();
|
||||||
|
lineEdit()->blockSignals(true);
|
||||||
|
lineEdit()->setStyleSheet("color: black;");
|
||||||
|
if (eval.expression() != "0") lineEdit()->setText(eval.expression());
|
||||||
|
lineEdit()->blockSignals(false);
|
||||||
|
QAbstractSpinBox::focusInEvent(event);
|
||||||
|
resizeIcons();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::focusOutEvent(QFocusEvent * event) {
|
||||||
|
QAbstractSpinBox::focusOutEvent(event);
|
||||||
|
// qDebug() << eval.expression() << QString::number(value(), 'G', 10);
|
||||||
|
if (eval.expression() != QString::number(value(), 'G', 10) && eval.expression() != QString::number(value(), 'G', 11) && eval.isCorrect())
|
||||||
|
label->setText("<html><head/><body><p>" + eval.expression() + " <span style=\"color:#005500;\">-> " + QString::number(value(), 'G', 10) + "</span></p></body></html>");
|
||||||
|
else label->setText(eval.expression());
|
||||||
|
label->show();
|
||||||
|
lineEdit()->blockSignals(true);
|
||||||
|
if (!eval.isCorrect()) lineEdit()->setStyleSheet("color: darkred;");
|
||||||
|
else status->hide();
|
||||||
|
// lineEdit()->setText(eval.expression() + " -> " + QString::number(value(), 'G', 10));
|
||||||
|
lineEdit()->clear();
|
||||||
|
lineEdit()->blockSignals(false);
|
||||||
|
resizeIcons();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::setDefaultText(const QString & t) {
|
||||||
|
// bool def = (!cw->isHidden());
|
||||||
|
dt = t;
|
||||||
|
// if (def) {
|
||||||
|
// lineEdit()->setText(dt);
|
||||||
|
// setExpression_();
|
||||||
|
// }
|
||||||
|
//if (t == eval.expression() || (value() == 0 && t.isEmpty())) clear();
|
||||||
|
cw->setVisible((eval.expression() != dt || (dt.isEmpty() && eval.expression() == "0")) && cw_visible);
|
||||||
|
resizeIcons();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBox::setClearButtonVisible(bool visible) {
|
||||||
|
cw_visible = visible;
|
||||||
|
cw->setVisible((eval.expression() != dt || (dt.isEmpty() && eval.expression() == "0")) && cw_visible);
|
||||||
|
resizeIcons();
|
||||||
|
}
|
||||||
77
qad/widgets/evalspinbox.h
Normal file
77
qad/widgets/evalspinbox.h
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#ifndef EVALSPINBOX_H
|
||||||
|
#define EVALSPINBOX_H
|
||||||
|
|
||||||
|
#include <QAbstractSpinBox>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include "qpievaluator.h"
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
|
class 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)
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
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;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool eventFilter(QObject * o, QEvent * e);
|
||||||
|
void resizeEvent(QResizeEvent * );
|
||||||
|
void changeEvent(QEvent * e);
|
||||||
|
void statusPaintEvent();
|
||||||
|
void cwPaintEvent();
|
||||||
|
void resizeIcons();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void clearMouseRelease(QMouseEvent * e);
|
||||||
|
void textChanged_(const QString & text);
|
||||||
|
void setExpression_();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setExpression(const QString & expr);
|
||||||
|
void setValue(double val);
|
||||||
|
void setDefaultText(const QString & t);
|
||||||
|
void setClearButtonVisible(bool visible);
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void stepBy(int steps);
|
||||||
|
virtual void clear();
|
||||||
|
virtual QSize sizeHint() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual StepEnabled stepEnabled() const;
|
||||||
|
virtual void focusInEvent(QFocusEvent *event);
|
||||||
|
virtual void focusOutEvent(QFocusEvent *event);
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void valueChanged(double val);
|
||||||
|
void cleared();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EVALSPINBOX_H
|
||||||
69
qad/widgets/plugin/evalspinboxplugin.cpp
Normal file
69
qad/widgets/plugin/evalspinboxplugin.cpp
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#include "evalspinbox.h"
|
||||||
|
#include "evalspinboxplugin.h"
|
||||||
|
#include <QtCore/QtPlugin>
|
||||||
|
|
||||||
|
|
||||||
|
EvalSpinBoxPlugin::EvalSpinBoxPlugin(QObject * parent): QObject(parent) {
|
||||||
|
m_initialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalSpinBoxPlugin::initialize(QDesignerFormEditorInterface * /* core */) {
|
||||||
|
if (m_initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Add extension registrations, etc. here
|
||||||
|
|
||||||
|
m_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool EvalSpinBoxPlugin::isInitialized() const {
|
||||||
|
return m_initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QWidget * EvalSpinBoxPlugin::createWidget(QWidget * parent) {
|
||||||
|
return new EvalSpinBox(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString EvalSpinBoxPlugin::name() const {
|
||||||
|
return QLatin1String("EvalSpinBox");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString EvalSpinBoxPlugin::group() const {
|
||||||
|
return QLatin1String("Input Widgets");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QIcon EvalSpinBoxPlugin::icon() const {
|
||||||
|
return QIcon(":/icons/evalspinbox.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString EvalSpinBoxPlugin::toolTip() const {
|
||||||
|
return QLatin1String("Evaluation double SpinBox");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString EvalSpinBoxPlugin::whatsThis() const {
|
||||||
|
return QLatin1String("Evaluation double SpinBox");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool EvalSpinBoxPlugin::isContainer() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString EvalSpinBoxPlugin::domXml() const {
|
||||||
|
return QLatin1String("<widget class=\"EvalSpinBox\" name=\"evalSpin\">\n</widget>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString EvalSpinBoxPlugin::includeFile() const {
|
||||||
|
return QLatin1String("evalspinbox.h");
|
||||||
|
}
|
||||||
|
|
||||||
36
qad/widgets/plugin/evalspinboxplugin.h
Normal file
36
qad/widgets/plugin/evalspinboxplugin.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#ifndef EVALSPINBOXPLUGIN_H
|
||||||
|
#define EVALSPINBOXPLUGIN_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
# include <QtUiPlugin/QDesignerCustomWidgetInterface>
|
||||||
|
#else
|
||||||
|
# include <QDesignerCustomWidgetInterface>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class EvalSpinBoxPlugin: public QObject, public QDesignerCustomWidgetInterface
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(QDesignerCustomWidgetInterface)
|
||||||
|
|
||||||
|
public:
|
||||||
|
EvalSpinBoxPlugin(QObject * parent = 0);
|
||||||
|
|
||||||
|
bool isContainer() const;
|
||||||
|
bool isInitialized() const;
|
||||||
|
QIcon icon() const;
|
||||||
|
QString domXml() const;
|
||||||
|
QString group() const;
|
||||||
|
QString includeFile() const;
|
||||||
|
QString name() const;
|
||||||
|
QString toolTip() const;
|
||||||
|
QString whatsThis() const;
|
||||||
|
QWidget * createWidget(QWidget * parent);
|
||||||
|
void initialize(QDesignerFormEditorInterface * core);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_initialized;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EVALSPINBOXPLUGIN_H
|
||||||
@@ -13,9 +13,10 @@
|
|||||||
#include "qcodeeditplugin.h"
|
#include "qcodeeditplugin.h"
|
||||||
#include "qvarianteditplugin.h"
|
#include "qvarianteditplugin.h"
|
||||||
#include "qpiconfigplugin.h"
|
#include "qpiconfigplugin.h"
|
||||||
|
#include "evalspinboxplugin.h"
|
||||||
|
|
||||||
QADWidgets::QADWidgets(QObject * parent): QObject(parent)
|
|
||||||
{
|
QADWidgets::QADWidgets(QObject * parent): QObject(parent) {
|
||||||
m_widgets.append(new SpinSliderPlugin(this));
|
m_widgets.append(new SpinSliderPlugin(this));
|
||||||
m_widgets.append(new ColorButtonPlugin(this));
|
m_widgets.append(new ColorButtonPlugin(this));
|
||||||
m_widgets.append(new CharDialogPlugin(this));
|
m_widgets.append(new CharDialogPlugin(this));
|
||||||
@@ -30,6 +31,7 @@ QADWidgets::QADWidgets(QObject * parent): QObject(parent)
|
|||||||
m_widgets.append(new QCodeEditPlugin(this));
|
m_widgets.append(new QCodeEditPlugin(this));
|
||||||
m_widgets.append(new QVariantEditPlugin(this));
|
m_widgets.append(new QVariantEditPlugin(this));
|
||||||
m_widgets.append(new QPIConfigPlugin(this));
|
m_widgets.append(new QPIConfigPlugin(this));
|
||||||
|
m_widgets.append(new EvalSpinBoxPlugin(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,5 +36,9 @@
|
|||||||
<file>../icons/qvariantedit.png</file>
|
<file>../icons/qvariantedit.png</file>
|
||||||
<file>../icons/code-word.png</file>
|
<file>../icons/code-word.png</file>
|
||||||
<file>../icons/f1.png</file>
|
<file>../icons/f1.png</file>
|
||||||
|
<file>../icons/dialog-ok-apply.png</file>
|
||||||
|
<file>../icons/dialog-warning.png</file>
|
||||||
|
<file>../icons/tools-wizard.png</file>
|
||||||
|
<file>../icons/evalspinbox.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ QVariantEdit::QVariantEdit(QWidget * parent): QWidget(parent) {
|
|||||||
_list = 0;
|
_list = 0;
|
||||||
_date = 0;
|
_date = 0;
|
||||||
_spin = 0;
|
_spin = 0;
|
||||||
|
_espin = 0;
|
||||||
_rect = 0;
|
_rect = 0;
|
||||||
_point = 0;
|
_point = 0;
|
||||||
_path = 0;
|
_path = 0;
|
||||||
@@ -222,11 +223,11 @@ void QVariantEdit::_recreate(const QVariant & new_value) {
|
|||||||
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
case QVariant::Double:
|
case QVariant::Double:
|
||||||
_spin = new QDoubleSpinBox(this);
|
_espin = new EvalSpinBox(this);
|
||||||
_spin->setDecimals(5);
|
//_spin->setDecimals(5);
|
||||||
_spin->setRange(-1E+199, 1E+199);
|
//_spin->setRange(-1E+199, 1E+199);
|
||||||
_cur_edit = _spin;
|
_cur_edit = _espin;
|
||||||
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
connect(_espin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
case QVariant::Color:
|
case QVariant::Color:
|
||||||
_color = new ColorButton(this);
|
_color = new ColorButton(this);
|
||||||
@@ -321,7 +322,7 @@ QVariant QVariantEdit::value() const {
|
|||||||
case QVariant::UInt: return (unsigned int)(_spin->value());
|
case QVariant::UInt: return (unsigned int)(_spin->value());
|
||||||
case QVariant::LongLong: return qlonglong(_spin->value());
|
case QVariant::LongLong: return qlonglong(_spin->value());
|
||||||
case QVariant::ULongLong: return qulonglong(_spin->value());
|
case QVariant::ULongLong: return qulonglong(_spin->value());
|
||||||
case QVariant::Double: return double(_spin->value());
|
case QVariant::Double: return _espin->value();
|
||||||
case QVariant::Color: return _color->color();
|
case QVariant::Color: return _color->color();
|
||||||
case QVariant::String: return _line->text();
|
case QVariant::String: return _line->text();
|
||||||
case QVariant::StringList: return _list->value();
|
case QVariant::StringList: return _list->value();
|
||||||
@@ -372,6 +373,7 @@ void QVariantEdit::setValue(const QVariant & v) {
|
|||||||
if (_list) {_list->setValue(v.toStringList());}
|
if (_list) {_list->setValue(v.toStringList());}
|
||||||
if (_date) {_date->setDateTime(v.toDateTime());}
|
if (_date) {_date->setDateTime(v.toDateTime());}
|
||||||
if (_spin) {_spin->setValue(v.toDouble());}
|
if (_spin) {_spin->setValue(v.toDouble());}
|
||||||
|
if (_espin) {_espin->setValue(v.toDouble());}
|
||||||
if (_rect) {_rect->setValue(v.toRectF());}
|
if (_rect) {_rect->setValue(v.toRectF());}
|
||||||
if (_point) {_point->setValue(v.toPointF());}
|
if (_point) {_point->setValue(v.toPointF());}
|
||||||
if (_path) {
|
if (_path) {
|
||||||
@@ -394,6 +396,7 @@ void QVariantEdit::_delete() {
|
|||||||
_list = 0;
|
_list = 0;
|
||||||
_date = 0;
|
_date = 0;
|
||||||
_spin = 0;
|
_spin = 0;
|
||||||
|
_espin = 0;
|
||||||
_rect = 0;
|
_rect = 0;
|
||||||
_point = 0;
|
_point = 0;
|
||||||
_path = 0;
|
_path = 0;
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
#ifndef QVARIANTEDIT_H
|
#ifndef QVARIANTEDIT_H
|
||||||
#define QVARIANTEDIT_H
|
#define QVARIANTEDIT_H
|
||||||
|
|
||||||
|
#include "qad_types.h"
|
||||||
#include "clineedit.h"
|
#include "clineedit.h"
|
||||||
#include "ecombobox.h"
|
#include "ecombobox.h"
|
||||||
#include "colorbutton.h"
|
#include "colorbutton.h"
|
||||||
#include "qrectedit.h"
|
#include "qrectedit.h"
|
||||||
#include "qpointedit.h"
|
#include "qpointedit.h"
|
||||||
#include "qad_types.h"
|
#include "evalspinbox.h"
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
|
|
||||||
@@ -108,6 +109,7 @@ protected:
|
|||||||
StringListEdit * _list;
|
StringListEdit * _list;
|
||||||
QDateTimeEdit * _date;
|
QDateTimeEdit * _date;
|
||||||
QDoubleSpinBox * _spin;
|
QDoubleSpinBox * _spin;
|
||||||
|
EvalSpinBox * _espin;
|
||||||
QRectEdit * _rect;
|
QRectEdit * _rect;
|
||||||
QPointEdit * _point;
|
QPointEdit * _point;
|
||||||
PathEdit * _path;
|
PathEdit * _path;
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ qt_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM)
|
|||||||
qt_add_library(${PROJECT_NAME} SHARED out_CPP)
|
qt_add_library(${PROJECT_NAME} SHARED out_CPP)
|
||||||
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets cd_utils piqt)
|
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets cd_utils piqt)
|
||||||
message(STATUS "Building ${PROJECT_NAME}")
|
message(STATUS "Building ${PROJECT_NAME}")
|
||||||
|
|
||||||
|
add_subdirectory(pult)
|
||||||
|
|
||||||
if(LIBPROJECT)
|
if(LIBPROJECT)
|
||||||
#sdk_install("" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}")
|
#sdk_install("" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}")
|
||||||
else()
|
else()
|
||||||
@@ -46,5 +49,3 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(pult)
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "qcd_core.h"
|
#include "qcd_core.h"
|
||||||
#include "qcd_kmodel.h"
|
#include "qcd_kmodel.h"
|
||||||
#include "pifile.h"
|
#include "pifile.h"
|
||||||
|
#include "evalspinbox.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace CDUtils;
|
using namespace CDUtils;
|
||||||
@@ -116,6 +117,9 @@ Form::Form(QWidget *parent) : QWidget(parent), ui(new Ui::Form) {
|
|||||||
CDCore::instance()->initPult();
|
CDCore::instance()->initPult();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->treeView->setKFile("");
|
ui->treeView->setKFile("");
|
||||||
|
EvalSpinBox * ev = new EvalSpinBox();
|
||||||
|
ev->setValue(2);
|
||||||
|
ui->groupBox->layout()->addWidget(ev);
|
||||||
|
|
||||||
PIFile f;
|
PIFile f;
|
||||||
piCout << f.open("test.kh", PIIODevice::ReadOnly);
|
piCout << f.open("test.kh", PIIODevice::ReadOnly);
|
||||||
|
|||||||
@@ -13,21 +13,14 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QPushButton" name="buttonRefresh">
|
|
||||||
<property name="text">
|
|
||||||
<string>Refresh</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QPushButton" name="pushButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Send</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QPushButton" name="pushButton_3">
|
<widget class="QPushButton" name="pushButton_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -35,16 +28,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" colspan="2">
|
|
||||||
<widget class="CDKView" name="treeView"/>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QPushButton" name="buttonCalc">
|
|
||||||
<property name="text">
|
|
||||||
<string>Calculate</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QPushButton" name="pushButton_4">
|
<widget class="QPushButton" name="pushButton_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -52,17 +35,10 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="1" column="0">
|
||||||
<widget class="QPushButton" name="pushButton_5">
|
<widget class="QPushButton" name="pushButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Clear</string>
|
<string>Send</string>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QPushButton" name="pushButton_6">
|
|
||||||
<property name="text">
|
|
||||||
<string>update from KDescription</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -73,7 +49,39 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2" rowspan="5">
|
<item row="2" column="0">
|
||||||
|
<widget class="QPushButton" name="pushButton_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>update from KDescription</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QPushButton" name="pushButton_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Clear</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QPushButton" name="buttonCalc">
|
||||||
|
<property name="text">
|
||||||
|
<string>Calculate</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonRefresh">
|
||||||
|
<property name="text">
|
||||||
|
<string>Refresh</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="2">
|
||||||
|
<widget class="CDKView" name="treeView"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
@@ -113,6 +121,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
Reference in New Issue
Block a user