DialogAlongLine - check if names of points don't equal.
--HG-- branch : develop
This commit is contained in:
parent
81f77054af
commit
0e3da0d902
|
@ -63,6 +63,10 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, QWidget *parent)
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogAlongLine::FormulaTextChanged);
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogAlongLine::FormulaTextChanged);
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogAlongLine::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogAlongLine::DeployFormulaTextEdit);
|
||||||
connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogTool::PutVal);
|
connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogTool::PutVal);
|
||||||
|
connect(ui->comboBoxFirstPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||||
|
this, &DialogAlongLine::PointChanged);
|
||||||
|
connect(ui->comboBoxSecondPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||||
|
this, &DialogAlongLine::PointChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -71,6 +75,24 @@ void DialogAlongLine::FormulaTextChanged()
|
||||||
this->FormulaChangedPlainText();
|
this->FormulaChangedPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogAlongLine::PointChanged()
|
||||||
|
{
|
||||||
|
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
|
||||||
|
{
|
||||||
|
flagError = false;
|
||||||
|
ChangeColor(ui->labelFirstPoint, Qt::red);
|
||||||
|
ChangeColor(ui->labelSecondPoint, Qt::red);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flagError = true;
|
||||||
|
ChangeColor(ui->labelFirstPoint, QColor(76, 76, 76));
|
||||||
|
ChangeColor(ui->labelSecondPoint, QColor(76, 76, 76));
|
||||||
|
}
|
||||||
|
CheckState();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogAlongLine::DeployFormulaTextEdit()
|
void DialogAlongLine::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,15 +65,16 @@ public slots:
|
||||||
/**
|
/**
|
||||||
* @brief DialogApply apply data and emit signal about applied dialog.
|
* @brief DialogApply apply data and emit signal about applied dialog.
|
||||||
*/
|
*/
|
||||||
virtual void DialogApply();
|
virtual void DialogApply();
|
||||||
/**
|
/**
|
||||||
* @brief DeployFormulaTextEdit grow or shrink formula input
|
* @brief DeployFormulaTextEdit grow or shrink formula input
|
||||||
*/
|
*/
|
||||||
void DeployFormulaTextEdit();
|
void DeployFormulaTextEdit();
|
||||||
/**
|
/**
|
||||||
* @brief FormulaTextChanged when formula text changes for validation and calc
|
* @brief FormulaTextChanged when formula text changes for validation and calc
|
||||||
*/
|
*/
|
||||||
void FormulaTextChanged();
|
void FormulaTextChanged();
|
||||||
|
void PointChanged();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogAlongLine)
|
Q_DISABLE_COPY(DialogAlongLine)
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,9 @@
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="go-down"/>
|
<iconset theme="go-down">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
|
@ -268,7 +270,7 @@
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="labelFirstPoint">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>First point</string>
|
<string>First point</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -286,7 +288,7 @@
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="labelSecondPoint">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Second point</string>
|
<string>Second point</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -59,9 +59,7 @@ DialogDetail::DialogDetail(const VContainer *data, QWidget *parent)
|
||||||
connect(bCansel, &QPushButton::clicked, this, &DialogTool::DialogRejected);
|
connect(bCansel, &QPushButton::clicked, this, &DialogTool::DialogRejected);
|
||||||
|
|
||||||
flagName = true;//We have default name of detail.
|
flagName = true;//We have default name of detail.
|
||||||
QPalette palette = labelEditNamePoint->palette();
|
ChangeColor(labelEditNamePoint, QColor(76, 76, 76));
|
||||||
palette.setColor(labelEditNamePoint->foregroundRole(), QColor(76, 76, 76));
|
|
||||||
labelEditNamePoint->setPalette(palette);
|
|
||||||
CheckState();
|
CheckState();
|
||||||
|
|
||||||
connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogDetail::ObjectChanged);
|
connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogDetail::ObjectChanged);
|
||||||
|
|
|
@ -57,8 +57,8 @@
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogTool::DialogTool(const VContainer *data, QWidget *parent)
|
DialogTool::DialogTool(const VContainer *data, QWidget *parent)
|
||||||
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(nullptr),
|
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), flagError(true),
|
||||||
bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), plainTextEditFormula(nullptr),
|
timerFormula(nullptr), bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), plainTextEditFormula(nullptr),
|
||||||
listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr),
|
listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr),
|
||||||
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
|
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
|
||||||
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
|
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
|
||||||
|
@ -401,9 +401,7 @@ void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer)
|
||||||
{
|
{
|
||||||
flag = false;
|
flag = false;
|
||||||
CheckState();
|
CheckState();
|
||||||
QPalette palette = labelEditFormula->palette();
|
ChangeColor(labelEditFormula, Qt::red);
|
||||||
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
|
||||||
labelEditFormula->setPalette(palette);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
timer->start(1000);
|
timer->start(1000);
|
||||||
|
@ -418,9 +416,7 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim
|
||||||
{
|
{
|
||||||
flag = false;
|
flag = false;
|
||||||
CheckState();
|
CheckState();
|
||||||
QPalette palette = labelEditFormula->palette();
|
ChangeColor(labelEditFormula, Qt::red);
|
||||||
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
|
||||||
labelEditFormula->setPalette(palette);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
timer->start(1000);
|
timer->start(1000);
|
||||||
|
@ -439,11 +435,10 @@ void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *la
|
||||||
SCASSERT(timer != nullptr);
|
SCASSERT(timer != nullptr);
|
||||||
SCASSERT(label != nullptr);
|
SCASSERT(label != nullptr);
|
||||||
SCASSERT(labelEditFormula != nullptr);
|
SCASSERT(labelEditFormula != nullptr);
|
||||||
QPalette palette = labelEditFormula->palette();
|
|
||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
{
|
{
|
||||||
flag = false;
|
flag = false;
|
||||||
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
ChangeColor(labelEditFormula, Qt::red);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -468,14 +463,14 @@ void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *la
|
||||||
label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
||||||
}
|
}
|
||||||
flag = true;
|
flag = true;
|
||||||
palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76));
|
ChangeColor(labelEditFormula, QColor(76, 76, 76));
|
||||||
emit ToolTip("");
|
emit ToolTip("");
|
||||||
}
|
}
|
||||||
catch (qmu::QmuParserError &e)
|
catch (qmu::QmuParserError &e)
|
||||||
{
|
{
|
||||||
label->setText(tr("Error"));
|
label->setText(tr("Error"));
|
||||||
flag = false;
|
flag = false;
|
||||||
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
ChangeColor(labelEditFormula, Qt::red);
|
||||||
emit ToolTip("Parser error: "+e.GetMsg());
|
emit ToolTip("Parser error: "+e.GetMsg());
|
||||||
qDebug() << "\nMath parser error:\n"
|
qDebug() << "\nMath parser error:\n"
|
||||||
<< "--------------------------------------\n"
|
<< "--------------------------------------\n"
|
||||||
|
@ -486,7 +481,6 @@ void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *la
|
||||||
}
|
}
|
||||||
CheckState();
|
CheckState();
|
||||||
timer->stop();
|
timer->stop();
|
||||||
labelEditFormula->setPalette(palette);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -636,11 +630,11 @@ void DialogTool::FillList(QComboBox *box, const QMap<QString, quint32> &list) co
|
||||||
void DialogTool::CheckState()
|
void DialogTool::CheckState()
|
||||||
{
|
{
|
||||||
SCASSERT(bOk != nullptr);
|
SCASSERT(bOk != nullptr);
|
||||||
bOk->setEnabled(flagFormula && flagName);
|
bOk->setEnabled(flagFormula && flagName && flagError);
|
||||||
// In case dialog hasn't apply button
|
// In case dialog hasn't apply button
|
||||||
if ( bApply != nullptr)
|
if ( bApply != nullptr)
|
||||||
{
|
{
|
||||||
bApply->setEnabled(flagFormula && flagName);
|
bApply->setEnabled(bOk->isEnabled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,21 +664,26 @@ void DialogTool::NamePointChanged()
|
||||||
if (name.isEmpty() || name.contains(" "))
|
if (name.isEmpty() || name.contains(" "))
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
QPalette palette = labelEditNamePoint->palette();
|
ChangeColor(labelEditNamePoint, Qt::red);
|
||||||
palette.setColor(labelEditNamePoint->foregroundRole(), Qt::red);
|
|
||||||
labelEditNamePoint->setPalette(palette);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagName = true;
|
flagName = true;
|
||||||
QPalette palette = labelEditNamePoint->palette();
|
ChangeColor(labelEditNamePoint, QColor(76, 76, 76));
|
||||||
palette.setColor(labelEditNamePoint->foregroundRole(), QColor(76, 76, 76));
|
|
||||||
labelEditNamePoint->setPalette(palette);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogTool::ChangeColor(QWidget *widget, const QColor &color)
|
||||||
|
{
|
||||||
|
SCASSERT(widget != nullptr);
|
||||||
|
QPalette palette = widget->palette();
|
||||||
|
palette.setColor(widget->foregroundRole(), color);
|
||||||
|
widget->setPalette(palette);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief DialogAccepted save data and emit signal about closed dialog.
|
* @brief DialogAccepted save data and emit signal about closed dialog.
|
||||||
|
|
|
@ -122,6 +122,13 @@ protected:
|
||||||
/** @brief flagFormula true if formula correct */
|
/** @brief flagFormula true if formula correct */
|
||||||
bool flagFormula;
|
bool flagFormula;
|
||||||
|
|
||||||
|
/** @brief flagError use this flag if for you do not enought @see flagName and @see flagFormula.
|
||||||
|
*
|
||||||
|
* In many cases you will need more flags fore checking if all data are valid.
|
||||||
|
* By default this flag is true.
|
||||||
|
*/
|
||||||
|
bool flagError;
|
||||||
|
|
||||||
/** @brief timerFormula timer for check formula */
|
/** @brief timerFormula timer for check formula */
|
||||||
QTimer *timerFormula;
|
QTimer *timerFormula;
|
||||||
|
|
||||||
|
@ -292,6 +299,7 @@ protected:
|
||||||
* @brief associatedTool vdrawtool associated with opened dialog.
|
* @brief associatedTool vdrawtool associated with opened dialog.
|
||||||
*/
|
*/
|
||||||
VAbstractTool* associatedTool;
|
VAbstractTool* associatedTool;
|
||||||
|
void ChangeColor(QWidget *widget, const QColor &color);
|
||||||
private:
|
private:
|
||||||
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user