Refactoring method PointNameChanged.

--HG--
branch : develop
This commit is contained in:
dismine 2014-07-14 19:28:41 +03:00
parent 84050f042b
commit 9563604d67
14 changed files with 70 additions and 64 deletions

View File

@ -78,18 +78,19 @@ void DialogAlongLine::FormulaTextChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogAlongLine::PointChanged()
{
QColor color = okColor;
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
{
flagError = false;
ChangeColor(ui->labelFirstPoint, Qt::red);
ChangeColor(ui->labelSecondPoint, Qt::red);
color = errorColor;
}
else
{
flagError = true;
ChangeColor(ui->labelFirstPoint, QColor(76, 76, 76));
ChangeColor(ui->labelSecondPoint, QColor(76, 76, 76));
color = okColor;
}
ChangeColor(ui->labelFirstPoint, color);
ChangeColor(ui->labelSecondPoint, color);
CheckState();
}

View File

@ -88,20 +88,20 @@ void DialogBisector::PointNameChanged()
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
set.insert(getCurrentObjectId(ui->comboBoxThirdPoint));
QColor color = okColor;
if (set.size() != 3)
{
flagError = false;
ChangeColor(ui->labelFirstPoint, Qt::red);
ChangeColor(ui->labelSecondPoint, Qt::red);
ChangeColor(ui->labelThirdPoint, Qt::red);
color = errorColor;
}
else
{
flagError = true;
ChangeColor(ui->labelFirstPoint, QColor(76, 76, 76));
ChangeColor(ui->labelSecondPoint, QColor(76, 76, 76));
ChangeColor(ui->labelThirdPoint, QColor(76, 76, 76));
color = okColor;
}
ChangeColor(ui->labelFirstPoint, color);
ChangeColor(ui->labelSecondPoint, color);
ChangeColor(ui->labelThirdPoint, color);
CheckState();
}

View File

@ -59,7 +59,7 @@ DialogDetail::DialogDetail(const VContainer *data, QWidget *parent)
connect(bCansel, &QPushButton::clicked, this, &DialogTool::DialogRejected);
flagName = true;//We have default name of detail.
ChangeColor(labelEditNamePoint, QColor(76, 76, 76));
ChangeColor(labelEditNamePoint, okColor);
CheckState();
connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogDetail::ObjectChanged);

View File

@ -193,20 +193,20 @@ void DialogHeight::PointNameChanged()
const VPointF *p1Line = data->GeometricObject<const VPointF *>(p1LineId);
const VPointF *p2Line = data->GeometricObject<const VPointF *>(p2LineId);
QColor color = okColor;
if (set.size() != 3 || VAbstractTool::ClosestPoint(QLineF(p1Line->toQPointF(), p2Line->toQPointF()),
basePoint->toQPointF()) == QPointF())
{
flagError = false;
ChangeColor(ui->labelBasePoint, Qt::red);
ChangeColor(ui->labelFirstLinePoint, Qt::red);
ChangeColor(ui->labelSecondLinePoint, Qt::red);
color = errorColor;
}
else
{
flagError = true;
ChangeColor(ui->labelBasePoint, QColor(76, 76, 76));
ChangeColor(ui->labelFirstLinePoint, QColor(76, 76, 76));
ChangeColor(ui->labelSecondLinePoint, QColor(76, 76, 76));
color = okColor;
}
ChangeColor(ui->labelBasePoint, color);
ChangeColor(ui->labelFirstLinePoint, color);
ChangeColor(ui->labelSecondLinePoint, color);
CheckState();
}

View File

@ -111,18 +111,19 @@ void DialogLine::DialogAccepted()
//---------------------------------------------------------------------------------------------------------------------
void DialogLine::PointNameChanged()
{
QColor color = okColor;
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
{
flagError = false;
ChangeColor(ui->labelFirstPoint, Qt::red);
ChangeColor(ui->labelSecondPoint, Qt::red);
color = errorColor;
}
else
{
flagError = true;
ChangeColor(ui->labelFirstPoint, QColor(76, 76, 76));
ChangeColor(ui->labelSecondPoint, QColor(76, 76, 76));
color = okColor;
}
ChangeColor(ui->labelFirstPoint, color);
ChangeColor(ui->labelSecondPoint, color);
CheckState();
}

View File

@ -236,22 +236,21 @@ void DialogLineIntersect::PointNameChanged()
QPointF fPoint;
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
QColor color = okColor;
if (set.size() < 3 || intersect == QLineF::NoIntersection)
{
flagError = false;
ChangeColor(ui->labelP1Line1, Qt::red);
ChangeColor(ui->labelP2Line1, Qt::red);
ChangeColor(ui->labelP1Line2, Qt::red);
ChangeColor(ui->labelP2Line2, Qt::red);
color = errorColor;
}
else
{
flagError = true;
ChangeColor(ui->labelP1Line1, QColor(76, 76, 76));
ChangeColor(ui->labelP2Line1, QColor(76, 76, 76));
ChangeColor(ui->labelP1Line2, QColor(76, 76, 76));
ChangeColor(ui->labelP2Line2, QColor(76, 76, 76));
color = okColor;
}
ChangeColor(ui->labelP1Line1, color);
ChangeColor(ui->labelP2Line1, color);
ChangeColor(ui->labelP1Line2, color);
ChangeColor(ui->labelP2Line2, color);
CheckState();
}

View File

@ -78,18 +78,19 @@ void DialogNormal::FormulaTextChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogNormal::PointNameChanged()
{
QColor color = okColor;
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
{
flagError = false;
ChangeColor(ui->labelFirstPoint, Qt::red);
ChangeColor(ui->labelSecondPoint, Qt::red);
color = errorColor;
}
else
{
flagError = true;
ChangeColor(ui->labelFirstPoint, QColor(76, 76, 76));
ChangeColor(ui->labelSecondPoint, QColor(76, 76, 76));
color = okColor;
}
ChangeColor(ui->labelFirstPoint, color);
ChangeColor(ui->labelSecondPoint, color);
CheckState();
}

View File

@ -101,20 +101,20 @@ void DialogPointOfContact::PointNameChanged()
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
set.insert(getCurrentObjectId(ui->comboBoxCenter));
QColor color = okColor;
if (set.size() != 3)
{
flagError = false;
ChangeColor(ui->labelFirstPoint, Qt::red);
ChangeColor(ui->labelSecondPoint, Qt::red);
ChangeColor(ui->labelArcCenter, Qt::red);
color = errorColor;
}
else
{
flagError = true;
ChangeColor(ui->labelFirstPoint, QColor(76, 76, 76));
ChangeColor(ui->labelSecondPoint, QColor(76, 76, 76));
ChangeColor(ui->labelArcCenter, QColor(76, 76, 76));
color = okColor;
}
ChangeColor(ui->labelFirstPoint, color);
ChangeColor(ui->labelSecondPoint, color);
ChangeColor(ui->labelArcCenter, color);
CheckState();
}

View File

@ -131,18 +131,19 @@ void DialogPointOfIntersection::DialogAccepted()
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersection::PointNameChanged()
{
QColor color = okColor;
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
{
flagError = false;
ChangeColor(ui->labelFirstPoint, Qt::red);
ChangeColor(ui->labelSecondPoint, Qt::red);
color = errorColor;
}
else
{
flagError = true;
ChangeColor(ui->labelFirstPoint, QColor(76, 76, 76));
ChangeColor(ui->labelSecondPoint, QColor(76, 76, 76));
color = okColor;
}
ChangeColor(ui->labelFirstPoint, color);
ChangeColor(ui->labelSecondPoint, color);
CheckState();
}

View File

@ -86,20 +86,20 @@ void DialogShoulderPoint::PointNameChanged()
set.insert(getCurrentObjectId(ui->comboBoxP2Line));
set.insert(getCurrentObjectId(ui->comboBoxPShoulder));
QColor color = okColor;
if (set.size() != 3)
{
flagError = false;
ChangeColor(ui->labelFirstPoint, Qt::red);
ChangeColor(ui->labelSecondPoint, Qt::red);
ChangeColor(ui->labelPointShoulder, Qt::red);
color = errorColor;
}
else
{
flagError = true;
ChangeColor(ui->labelFirstPoint, QColor(76, 76, 76));
ChangeColor(ui->labelSecondPoint, QColor(76, 76, 76));
ChangeColor(ui->labelPointShoulder, QColor(76, 76, 76));
color = okColor;
}
ChangeColor(ui->labelFirstPoint, color);
ChangeColor(ui->labelSecondPoint, color);
ChangeColor(ui->labelPointShoulder, color);
CheckState();
}

View File

@ -140,18 +140,19 @@ void DialogSpline::PointNameChanged()
set.insert(getCurrentObjectId(ui->comboBoxP1));
set.insert(getCurrentObjectId(ui->comboBoxP4));
QColor color = okColor;
if (getCurrentObjectId(ui->comboBoxP1) == getCurrentObjectId(ui->comboBoxP4))
{
flagError = false;
ChangeColor(ui->labelFirstPoint, Qt::red);
ChangeColor(ui->labelSecondPoint, Qt::red);
color = errorColor;
}
else
{
flagError = true;
ChangeColor(ui->labelFirstPoint, QColor(76, 76, 76));
ChangeColor(ui->labelSecondPoint, QColor(76, 76, 76));
color = okColor;
}
ChangeColor(ui->labelFirstPoint, color);
ChangeColor(ui->labelSecondPoint, color);
CheckState();
}

View File

@ -62,7 +62,8 @@ DialogTool::DialogTool(const VContainer *data, QWidget *parent)
listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr),
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
radioButtonLengthCurve(nullptr), lineStyles(QStringList()), associatedTool(nullptr)
radioButtonLengthCurve(nullptr), lineStyles(QStringList()), okColor(QColor(76, 76, 76)), errorColor(Qt::red),
associatedTool(nullptr)
{
SCASSERT(data != nullptr);
timerFormula = new QTimer(this);
@ -463,7 +464,7 @@ void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *la
label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true));
}
flag = true;
ChangeColor(labelEditFormula, QColor(76, 76, 76));
ChangeColor(labelEditFormula, okColor);
emit ToolTip("");
}
catch (qmu::QmuParserError &e)
@ -669,7 +670,7 @@ void DialogTool::NamePointChanged()
else
{
flagName = true;
ChangeColor(labelEditNamePoint, QColor(76, 76, 76));
ChangeColor(labelEditNamePoint, okColor);
}
}
CheckState();

View File

@ -179,6 +179,8 @@ protected:
/** @brief lineStyles list supported line styles. */
QStringList lineStyles;
const QColor okColor;
const QColor errorColor;
virtual void closeEvent ( QCloseEvent * event );
virtual void showEvent( QShowEvent *event );

View File

@ -137,22 +137,21 @@ void DialogTriangle::PointNameChanged()
set.insert(getCurrentObjectId(ui->comboBoxAxisP1));
set.insert(getCurrentObjectId(ui->comboBoxAxisP2));
QColor color = okColor;
if (set.size() != 4)
{
flagError = false;
ChangeColor(ui->labelFirstPoint, Qt::red);
ChangeColor(ui->labelSecondPoint, Qt::red);
ChangeColor(ui->labelAxisP1, Qt::red);
ChangeColor(ui->labelAxisP2, Qt::red);
color = errorColor;
}
else
{
flagError = true;
ChangeColor(ui->labelFirstPoint, QColor(76, 76, 76));
ChangeColor(ui->labelSecondPoint, QColor(76, 76, 76));
ChangeColor(ui->labelAxisP1, QColor(76, 76, 76));
ChangeColor(ui->labelAxisP2, QColor(76, 76, 76));
color = okColor;
}
ChangeColor(ui->labelFirstPoint, color);
ChangeColor(ui->labelSecondPoint, color);
ChangeColor(ui->labelAxisP1, color);
ChangeColor(ui->labelAxisP2, color);
CheckState();
}