git-svn-id: svn://db.shs.com.ru/libs@541 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <QDebug>
|
||||
#include <QRegExp>
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
#include <QStyle>
|
||||
#include <QStyleOptionSpinBox>
|
||||
#include "qad_types.h"
|
||||
@@ -67,10 +68,15 @@ void EvalSpinBox::resizeIcons() {
|
||||
QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &so, lineEdit());
|
||||
int m0, m1, m2, m3;
|
||||
lineEdit()->getTextMargins(&m0, &m1, &m2, &m3);
|
||||
label->setGeometry(m0 + r.x() + 2, m1 + 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);
|
||||
//label->setGeometry(m0 + r.x() + 2, m1 + 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);
|
||||
int lwh = label->sizeHint().width();
|
||||
label->setGeometry(lineEdit()->width() - m0 - lwh + r.x() - 2,
|
||||
m1 + r.y() + (r.height() - fontMetrics().height() + 1) / 2,
|
||||
lwh,// - 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);
|
||||
lineEdit()->setTextMargins(m0, m1, (is * 1.2) * ((status->isVisible() ? 1 : 0) + (cw->isVisible() ? 1 : 0)), m3);
|
||||
}
|
||||
|
||||
|
||||
@@ -158,19 +164,24 @@ void EvalSpinBox::setExpression_() {
|
||||
// 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());
|
||||
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->setText("<html><head/><body><p><span style=\"color:#005500;\">-> " + QString::number(value(), 'G', 10) + "</span></p></body></html>");
|
||||
else
|
||||
label->setText("");
|
||||
lineEdit()->blockSignals(true);
|
||||
if (!eval.isCorrect()) {
|
||||
lineEdit()->setStyleSheet("color: darkred;");
|
||||
status->show();
|
||||
} else {
|
||||
lineEdit()->setStyleSheet("color: black;");
|
||||
lineEdit()->setStyleSheet("");
|
||||
status->hide();
|
||||
}
|
||||
// lineEdit()->setText(eval.expression() + " -> " + QString::number(value(), 'G', 10));
|
||||
lineEdit()->setText("");
|
||||
//lineEdit()->setText("");
|
||||
lineEdit()->blockSignals(false);
|
||||
}
|
||||
|
||||
@@ -213,7 +224,7 @@ double EvalSpinBox::value() const {
|
||||
if (eval.isCorrect()) {
|
||||
return eval.lastResult().real();
|
||||
}
|
||||
return 0;
|
||||
return 0.;
|
||||
}
|
||||
|
||||
|
||||
@@ -244,8 +255,8 @@ void EvalSpinBox::focusInEvent(QFocusEvent * event) {
|
||||
label->hide();
|
||||
status->show();
|
||||
lineEdit()->blockSignals(true);
|
||||
lineEdit()->setStyleSheet("color: black;");
|
||||
if (eval.expression() != "0") lineEdit()->setText(eval.expression());
|
||||
lineEdit()->setStyleSheet("");
|
||||
//if (eval.expression() != "0") lineEdit()->setText(eval.expression());
|
||||
lineEdit()->blockSignals(false);
|
||||
QAbstractSpinBox::focusInEvent(event);
|
||||
resizeIcons();
|
||||
@@ -255,15 +266,20 @@ void EvalSpinBox::focusInEvent(QFocusEvent * event) {
|
||||
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());
|
||||
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->setText("<html><head/><body><p><span style=\"color:#005500;\">-> " + QString::number(value(), 'G', 10) + "</span></p></body></html>");
|
||||
else
|
||||
label->setText("");
|
||||
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()->clear();
|
||||
lineEdit()->blockSignals(false);
|
||||
resizeIcons();
|
||||
}
|
||||
|
||||
@@ -63,12 +63,12 @@ private:
|
||||
void changeEvent(QEvent * e);
|
||||
void statusPaintEvent();
|
||||
void cwPaintEvent();
|
||||
void resizeIcons();
|
||||
|
||||
private slots:
|
||||
void clearMouseRelease(QMouseEvent * e);
|
||||
void textChanged_(const QString & text);
|
||||
void setExpression_();
|
||||
void resizeIcons();
|
||||
|
||||
signals:
|
||||
void valueChanged(double val);
|
||||
|
||||
Reference in New Issue
Block a user