Refactoring. Move method to class DialogEditWrongFormula.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-04-30 14:08:54 +03:00
parent 225c1b219b
commit 9fb1e972c5
4 changed files with 265 additions and 348 deletions

View File

@ -28,6 +28,7 @@
#include "dialogeditwrongformula.h" #include "dialogeditwrongformula.h"
#include "ui_dialogeditwrongformula.h" #include "ui_dialogeditwrongformula.h"
#include "../../container/vcontainer.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent)
@ -35,7 +36,7 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui
checkZero(false), postfix(QString()), restoreCursor(false) checkZero(false), postfix(QString()), restoreCursor(false)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables();
InitFormulaUI(ui); InitFormulaUI(ui);
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this); ui->plainTextEditFormula->installEventFilter(this);
@ -105,6 +106,195 @@ void DialogEditWrongFormula::EvalFormula()
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, checkZero); Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, checkZero);
} }
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ValChenged show description when current variable changed
* @param row number of row
*/
void DialogEditWrongFormula::ValChenged(int row)
{
if (ui->listWidget->count() == 0)
{
ui->labelDescription->setText("");
return;
}
QListWidgetItem *item = ui->listWidget->item( row );
if (ui->radioButtonSizeGrowth->isChecked())
{
if (item->text()==data->HeightName())
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->height()).arg(tr("Height"));
ui->labelDescription->setText(desc);
}
if (item->text()==data->SizeName())
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size"));
ui->labelDescription->setText(desc);
}
return;
}
if (ui->radioButtonStandardTable->isChecked())
{
QString name = qApp->VarFromUser(item->text());
QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name);
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(name))
.arg(stable->GetGuiText());
ui->labelDescription->setText(desc);
return;
}
if (ui->radioButtonIncrements->isChecked())
{
QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(item->text());
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(item->text()))
.arg(incr->GetDescription());
ui->labelDescription->setText(desc);
return;
}
if (ui->radioButtonLengthLine->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VLengthLine>(qApp->VarFromUser(item->text()))->GetValue())
.arg(tr("Line length"));
ui->labelDescription->setText(desc);
return;
}
if (ui->radioButtonLengthArc->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VArcLength>(qApp->VarFromUser(item->text()))->GetValue())
.arg(tr("Arc length"));
ui->labelDescription->setText(desc);
return;
}
if (ui->radioButtonLengthSpline->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VSplineLength>(qApp->VarFromUser(item->text()))->GetValue())
.arg(tr("Curve length"));
ui->labelDescription->setText(desc);
return;
}
if (ui->radioButtonAngleLine->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VLineAngle>(qApp->VarFromUser(item->text()))->GetValue())
.arg(tr("Line Angle"));
ui->labelDescription->setText(desc);
return;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SizeHeight show in list base variables
*/
void DialogEditWrongFormula::SizeHeight()
{
ui->checkBoxHideEmpty->setEnabled(false);
ui->listWidget->blockSignals(true);
ui->listWidget->clear();
{
QListWidgetItem *item = new QListWidgetItem(data->HeightName());
item->setFont(QFont("Times", 12, QFont::Bold));
ui->listWidget->addItem(item);
}
QListWidgetItem *item = new QListWidgetItem(data->SizeName());
item->setFont(QFont("Times", 12, QFont::Bold));
ui->listWidget->addItem(item);
ui->listWidget->blockSignals(false);
ui->listWidget->setCurrentRow (0);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PutHere put variable into edit
*/
void DialogEditWrongFormula::PutHere()
{
const QListWidgetItem *item = ui->listWidget->currentItem();
if (item != nullptr)
{
QTextCursor cursor = ui->plainTextEditFormula->textCursor();
cursor.insertText(item->text());
ui->plainTextEditFormula->setTextCursor(cursor);
ui->plainTextEditFormula->setFocus();
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PutVal put variable into edit
* @param item chosen item of list widget
*/
void DialogEditWrongFormula::PutVal(QListWidgetItem *item)
{
SCASSERT(item != nullptr);
QTextCursor cursor = ui->plainTextEditFormula->textCursor();
cursor.insertText(item->text());
ui->plainTextEditFormula->setTextCursor(cursor);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Measurements show in list measurements
*/
void DialogEditWrongFormula::Measurements()
{
ui->checkBoxHideEmpty->setEnabled(true);
ShowVariable(data->DataMeasurements());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief LengthLines show in list lengths of lines variables
*/
void DialogEditWrongFormula::LengthLines()
{
ui->checkBoxHideEmpty->setEnabled(false);
ShowVariable(data->DataLengthLines());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief LengthArcs show in list lengths of arcs variables
*/
void DialogEditWrongFormula::LengthArcs()
{
ui->checkBoxHideEmpty->setEnabled(false);
ShowVariable(data->DataLengthArcs());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief LengthCurves show in list lengths of curves variables
*/
void DialogEditWrongFormula::LengthCurves()
{
ui->checkBoxHideEmpty->setEnabled(false);
ShowVariable(data->DataLengthSplines());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::AngleLines()
{
ui->checkBoxHideEmpty->setEnabled(false);
ShowVariable(data->DataAngleLines());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Increments show in list increment variables
*/
void DialogEditWrongFormula::Increments()
{
ui->checkBoxHideEmpty->setEnabled(false);
ShowVariable(data->DataIncrements());
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::CheckState() void DialogEditWrongFormula::CheckState()
{ {
@ -150,3 +340,59 @@ QString DialogEditWrongFormula::GetFormula() const
{ {
return qApp->FormulaFromUser(formula); return qApp->FormulaFromUser(formula);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::InitVariables()
{
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogEditWrongFormula::ValChenged);
if (qApp->patternType() == MeasurementsType::Standard)
{
SizeHeight();
connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogEditWrongFormula::SizeHeight);
}
else
{
ui->radioButtonSizeGrowth->setEnabled(false);
ui->radioButtonStandardTable->setChecked(true);
Measurements();
}
connect(ui->radioButtonStandardTable, &QRadioButton::clicked, this, &DialogEditWrongFormula::Measurements);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogEditWrongFormula::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogEditWrongFormula::LengthLines);
connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogEditWrongFormula::LengthArcs);
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogEditWrongFormula::LengthCurves);
connect(ui->radioButtonAngleLine, &QRadioButton::clicked, this, &DialogEditWrongFormula::AngleLines);
connect(ui->checkBoxHideEmpty, &QCheckBox::stateChanged, this, &DialogEditWrongFormula::Measurements);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowVariable show variables in list
* @param var container with variables
*/
template <class key, class val>
void DialogEditWrongFormula::ShowVariable(const QMap<key, val> var)
{
ui->listWidget->blockSignals(true);
ui->listWidget->clear();
ui->labelDescription->setText("");
QMapIterator<key, val> iMap(var);
while (iMap.hasNext())
{
iMap.next();
if (ui->checkBoxHideEmpty->isEnabled() && ui->checkBoxHideEmpty->isChecked() && iMap.value()->IsNotUsed())
{
continue; //skip this measurement
}
if (iMap.value()->Filter(toolId) == false)
{// If we create this variable don't show
QListWidgetItem *item = new QListWidgetItem(iMap.key());
item->setFont(QFont("Times", 12, QFont::Bold));
ui->listWidget->addItem(item);
}
}
ui->listWidget->blockSignals(false);
ui->listWidget->setCurrentRow (0);
}

View File

@ -63,6 +63,17 @@ public slots:
*/ */
void DeployFormulaTextEdit(); void DeployFormulaTextEdit();
virtual void EvalFormula(); virtual void EvalFormula();
void ValChenged(int row);
void SizeHeight();
void PutHere();
void PutVal(QListWidgetItem * item);
void Measurements();
void LengthLines();
void LengthArcs();
void LengthCurves();
void AngleLines();
void Increments();
protected: protected:
virtual void CheckState(); virtual void CheckState();
virtual void closeEvent(QCloseEvent *event); virtual void closeEvent(QCloseEvent *event);
@ -79,6 +90,11 @@ private:
bool checkZero; bool checkZero;
QString postfix; QString postfix;
bool restoreCursor; bool restoreCursor;
void InitVariables();
template <class key, class val>
void ShowVariable(const QMap<key, val> var);
}; };

View File

@ -60,10 +60,7 @@ Q_LOGGING_CATEGORY(vDialog, "v.dialog")
DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *parent)
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), flagError(true), :QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), flagError(true),
timerFormula(nullptr), 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), labelResultCalculation(nullptr), labelEditNamePoint(nullptr), labelEditFormula(nullptr),
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), checkBoxHideEmpty(nullptr),
okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr),
toolId(toolId), prepare(false), pointName(QString()), number(0) toolId(toolId), prepare(false), pointName(QString()), number(0)
{ {
@ -348,41 +345,6 @@ void DialogTool::ChangeCurrentData(QComboBox *box, const QVariant &value) const
} }
} }
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PutValHere put variable into line edit from list
* @param lineEdit lineEdit
* @param listWidget listWidget
*/
void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget)
{
SCASSERT(lineEdit != nullptr);
SCASSERT(listWidget != nullptr);
QListWidgetItem *item = listWidget->currentItem();
if (item != nullptr)
{
int pos = lineEdit->cursorPosition();
lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text()));
lineEdit->setFocus();
lineEdit->setCursorPosition(pos + item->text().size());
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget)
{
SCASSERT(plainTextEdit != nullptr);
SCASSERT(listWidget != nullptr);
QListWidgetItem *item = listWidget->currentItem();
if (item != nullptr)
{
QTextCursor cursor = plainTextEdit->textCursor();
cursor.insertText(item->text());
plainTextEdit->setTextCursor(cursor);
plainTextEdit->setFocus();
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTool::MoveCursorToEnd(QPlainTextEdit *plainTextEdit) void DialogTool::MoveCursorToEnd(QPlainTextEdit *plainTextEdit)
{ {
@ -884,205 +846,6 @@ void DialogTool::EvalFormula()
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, false); Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, false);
} }
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SizeHeight show in list base variables
*/
void DialogTool::SizeHeight()
{
SCASSERT(checkBoxHideEmpty != nullptr);
checkBoxHideEmpty->setEnabled(false);
SCASSERT(listWidget != nullptr);
listWidget->blockSignals(true);
listWidget->clear();
{
QListWidgetItem *item = new QListWidgetItem(data->HeightName());
item->setFont(QFont("Times", 12, QFont::Bold));
listWidget->addItem(item);
}
QListWidgetItem *item = new QListWidgetItem(data->SizeName());
item->setFont(QFont("Times", 12, QFont::Bold));
listWidget->addItem(item);
listWidget->blockSignals(false);
listWidget->setCurrentRow (0);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Measurements show in list measurements
*/
void DialogTool::Measurements()
{
SCASSERT(checkBoxHideEmpty != nullptr);
checkBoxHideEmpty->setEnabled(true);
ShowVariable(data->DataMeasurements());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief LengthLines show in list lengths of lines variables
*/
void DialogTool::LengthLines()
{
SCASSERT(checkBoxHideEmpty != nullptr);
checkBoxHideEmpty->setEnabled(false);
ShowVariable(data->DataLengthLines());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief LengthArcs show in list lengths of arcs variables
*/
void DialogTool::LengthArcs()
{
SCASSERT(checkBoxHideEmpty != nullptr);
checkBoxHideEmpty->setEnabled(false);
ShowVariable(data->DataLengthArcs());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief LengthCurves show in list lengths of curves variables
*/
void DialogTool::LengthCurves()
{
SCASSERT(checkBoxHideEmpty != nullptr);
checkBoxHideEmpty->setEnabled(false);
ShowVariable(data->DataLengthSplines());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::AngleLines()
{
SCASSERT(checkBoxHideEmpty != nullptr);
checkBoxHideEmpty->setEnabled(false);
ShowVariable(data->DataAngleLines());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Increments show in list increment variables
*/
void DialogTool::Increments()
{
SCASSERT(checkBoxHideEmpty != nullptr);
checkBoxHideEmpty->setEnabled(false);
ShowVariable(data->DataIncrements());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PutHere put variable into edit
*/
void DialogTool::PutHere()
{
PutValHere(plainTextEditFormula, listWidget);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PutVal put variable into edit
* @param item chosen item of list widget
*/
void DialogTool::PutVal(QListWidgetItem *item)
{
SCASSERT(plainTextEditFormula != nullptr);
SCASSERT(item != nullptr);
QTextCursor cursor = plainTextEditFormula->textCursor();
cursor.insertText(item->text());
plainTextEditFormula->setTextCursor(cursor);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ValChenged show description when current variable changed
* @param row number of row
*/
void DialogTool::ValChenged(int row)
{
SCASSERT(listWidget != nullptr);
SCASSERT(labelDescription != nullptr);
SCASSERT(radioButtonSizeGrowth != nullptr);
SCASSERT(radioButtonStandardTable != nullptr);
SCASSERT(radioButtonIncrements != nullptr);
SCASSERT(radioButtonLengthLine != nullptr);
SCASSERT(radioButtonLengthArc != nullptr);
SCASSERT(radioButtonLengthCurve != nullptr);
if (listWidget->count() == 0)
{
labelDescription->setText("");
return;
}
QListWidgetItem *item = listWidget->item( row );
if (radioButtonSizeGrowth->isChecked())
{
if (item->text()==data->HeightName())
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->height()).arg(tr("Height"));
labelDescription->setText(desc);
}
if (item->text()==data->SizeName())
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size"));
labelDescription->setText(desc);
}
return;
}
if (radioButtonStandardTable->isChecked())
{
QString name = qApp->VarFromUser(item->text());
QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name);
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(name))
.arg(stable->GetGuiText());
labelDescription->setText(desc);
return;
}
if (radioButtonIncrements->isChecked())
{
QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(item->text());
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(item->text()))
.arg(incr->GetDescription());
labelDescription->setText(desc);
return;
}
if (radioButtonLengthLine->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VLengthLine>(qApp->VarFromUser(item->text()))->GetValue())
.arg(tr("Line length"));
labelDescription->setText(desc);
return;
}
if (radioButtonLengthArc->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VArcLength>(qApp->VarFromUser(item->text()))->GetValue())
.arg(tr("Arc length"));
labelDescription->setText(desc);
return;
}
if (radioButtonLengthCurve->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VSplineLength>(qApp->VarFromUser(item->text()))->GetValue())
.arg(tr("Curve length"));
labelDescription->setText(desc);
return;
}
if (radioButtonAngleLine->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VLineAngle>(qApp->VarFromUser(item->text()))->GetValue())
.arg(tr("Line Angle"));
labelDescription->setText(desc);
return;
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
quint32 DialogTool::GetToolId() const quint32 DialogTool::GetToolId() const
@ -1102,39 +865,6 @@ QString DialogTool::getPointName() const
return pointName; return pointName;
} }
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowVariable show variables in list
* @param var container with variables
*/
template <class key, class val>
void DialogTool::ShowVariable(const QMap<key, val> var)
{
SCASSERT(listWidget != nullptr);
SCASSERT(checkBoxHideEmpty != nullptr);
listWidget->blockSignals(true);
listWidget->clear();
labelDescription->setText("");
QMapIterator<key, val> iMap(var);
while (iMap.hasNext())
{
iMap.next();
if (checkBoxHideEmpty->isEnabled() && checkBoxHideEmpty->isChecked() && iMap.value()->IsNotUsed())
{
continue; //skip this measurement
}
if (iMap.value()->Filter(toolId) == false)
{// If we create this variable don't show
QListWidgetItem *item = new QListWidgetItem(iMap.key());
item->setFont(QFont("Times", 12, QFont::Bold));
listWidget->addItem(item);
}
}
listWidget->blockSignals(false);
listWidget->setCurrentRow (0);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTool::ShowVisToolTip(const QString &toolTip) void DialogTool::ShowVisToolTip(const QString &toolTip)
{ {

View File

@ -111,16 +111,7 @@ public slots:
void ArrowRightUp(); void ArrowRightUp();
void ArrowRightDown(); void ArrowRightDown();
virtual void EvalFormula(); virtual void EvalFormula();
void SizeHeight();
void Measurements();
void LengthLines();
void LengthArcs();
void LengthCurves();
void AngleLines();
void Increments();
void PutHere();
void PutVal(QListWidgetItem * item);
virtual void ValChenged(int row);
virtual void PointNameChanged(){} virtual void PointNameChanged(){}
protected: protected:
Q_DISABLE_COPY(DialogTool) Q_DISABLE_COPY(DialogTool)
@ -159,43 +150,16 @@ protected:
/** @brief plainTextEditFormula formula */ /** @brief plainTextEditFormula formula */
QPlainTextEdit *plainTextEditFormula; QPlainTextEdit *plainTextEditFormula;
/** @brief listWidget listWidget with variables */
QListWidget *listWidget;
/** @brief labelResultCalculation label with result of calculation */ /** @brief labelResultCalculation label with result of calculation */
QLabel *labelResultCalculation; QLabel *labelResultCalculation;
/** @brief labelDescription description of variable */
QLabel *labelDescription;
/** @brief labelEditNamePoint label used when need show wrong name of point */ /** @brief labelEditNamePoint label used when need show wrong name of point */
QLabel *labelEditNamePoint; QLabel *labelEditNamePoint;
/** @brief labelEditFormula label used when need show wrong formula */ /** @brief labelEditFormula label used when need show wrong formula */
QLabel *labelEditFormula; QLabel *labelEditFormula;
/** @brief radioButtonSizeGrowth radio button for base variables */
QRadioButton *radioButtonSizeGrowth;
/** @brief radioButtonStandardTable radio button for standard table variables */
QRadioButton *radioButtonStandardTable;
/** @brief radioButtonIncrements radio button for increments variables */
QRadioButton *radioButtonIncrements;
/** @brief radioButtonLengthLine radio button for lengths od lines variables */
QRadioButton *radioButtonLengthLine;
/** @brief radioButtonLengthArc radio button for lengths of arcs variables */
QRadioButton *radioButtonLengthArc;
/** @brief radioButtonLengthCurve radio button for lengths of curves variables */
QRadioButton *radioButtonLengthCurve;
QRadioButton *radioButtonAngleLine;
QCheckBox *checkBoxHideEmpty;
const QColor okColor; const QColor okColor;
const QColor errorColor; const QColor errorColor;
/** /**
@ -227,11 +191,7 @@ protected:
virtual void CheckState(); virtual void CheckState();
QString GetComboBoxCurrentData(const QComboBox *box)const; QString GetComboBoxCurrentData(const QComboBox *box)const;
template <class key, class val>
void ShowVariable(const QMap<key, val> var);
void ChangeCurrentData(QComboBox *box, const QVariant &value) const; void ChangeCurrentData(QComboBox *box, const QVariant &value) const;
void PutValHere(QLineEdit *lineEdit, QListWidget *listWidget);
void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget);
void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer); void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer);
void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer); void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer);
qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix, qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix,
@ -262,41 +222,6 @@ protected:
connect(ui->toolButtonArrowRightDown, &QPushButton::clicked, this, &DialogTool::ArrowRightDown); connect(ui->toolButtonArrowRightDown, &QPushButton::clicked, this, &DialogTool::ArrowRightDown);
} }
template <typename T> template <typename T>
void InitVariables(T *ui)
{
listWidget = ui->listWidget;
labelDescription = ui->labelDescription;
radioButtonSizeGrowth = ui->radioButtonSizeGrowth;
radioButtonStandardTable = ui->radioButtonStandardTable;
radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
radioButtonAngleLine = ui->radioButtonAngleLine;
checkBoxHideEmpty = ui->checkBoxHideEmpty;
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
if (qApp->patternType() == MeasurementsType::Standard)
{
SizeHeight();
connect(radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeHeight);
}
else
{
radioButtonSizeGrowth->setEnabled(false);
radioButtonStandardTable->setChecked(true);
Measurements();
}
connect(radioButtonStandardTable, &QRadioButton::clicked, this, &DialogTool::Measurements);
connect(radioButtonIncrements, &QRadioButton::clicked, this, &DialogTool::Increments);
connect(radioButtonLengthLine, &QRadioButton::clicked, this, &DialogTool::LengthLines);
connect(radioButtonLengthArc, &QRadioButton::clicked, this, &DialogTool::LengthArcs);
connect(radioButtonLengthCurve, &QRadioButton::clicked, this, &DialogTool::LengthCurves);
connect(radioButtonAngleLine, &QRadioButton::clicked, this, &DialogTool::AngleLines);
connect(checkBoxHideEmpty, &QCheckBox::stateChanged, this, &DialogTool::Measurements);
}
template <typename T>
/** /**
* @brief InitOkCancelApply initialise OK / Cancel and Apply buttons * @brief InitOkCancelApply initialise OK / Cancel and Apply buttons
* @param ui Dialog container * @param ui Dialog container