Deploy formula.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-07-21 19:24:47 +03:00
parent 2cb4b18491
commit f6ec3ecb95
2 changed files with 36 additions and 1 deletions

View File

@ -38,6 +38,8 @@
#include <QMessageBox> #include <QMessageBox>
#include <QComboBox> #include <QComboBox>
#define DIALOG_MAX_FORMULA_HEIGHT 64
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
TMainWindow::TMainWindow(QWidget *parent) TMainWindow::TMainWindow(QWidget *parent)
:QMainWindow(parent), :QMainWindow(parent),
@ -48,7 +50,8 @@ TMainWindow::TMainWindow(QWidget *parent)
mType(MeasurementsType::Individual), mType(MeasurementsType::Individual),
curFile(), curFile(),
gradationHeights(nullptr), gradationHeights(nullptr),
gradationSizes(nullptr) gradationSizes(nullptr),
formulaBaseHeight(0)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->tabWidget->setVisible(false); ui->tabWidget->setVisible(false);
@ -457,6 +460,7 @@ void TMainWindow::ShowMData()
} }
else else
{ {
this->formulaBaseHeight = ui->plainTextEditFormula->height();
EvalFormula(meash->GetFormula(), meash->GetData(), ui->labelCalculatedValue); EvalFormula(meash->GetFormula(), meash->GetData(), ui->labelCalculatedValue);
ui->plainTextEditFormula->setPlainText(qApp->TrVars()->FormulaToUser(meash->GetFormula())); ui->plainTextEditFormula->setPlainText(qApp->TrVars()->FormulaToUser(meash->GetFormula()));
} }
@ -477,6 +481,33 @@ void TMainWindow::ShowMData()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::DeployFormula()
{
SCASSERT(ui->plainTextEditFormula != nullptr);
SCASSERT(ui->pushButtonGrow != nullptr)
if (ui->plainTextEditFormula->height() < DIALOG_MAX_FORMULA_HEIGHT)
{
ui->plainTextEditFormula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrow->setIcon(QIcon::fromTheme("go-next",
QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png")));
}
else
{
ui->plainTextEditFormula->setFixedHeight(formulaBaseHeight);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrow->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png")));
}
// I found that after change size of formula field, it was filed for angle formula, field for formula became black.
// This code prevent this.
setUpdatesEnabled(false);
repaint();
setUpdatesEnabled(true);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SetupMenu() void TMainWindow::SetupMenu()
{ {
@ -604,6 +635,7 @@ void TMainWindow::InitWindow()
&TMainWindow::SaveSex); &TMainWindow::SaveSex);
connect(ui->dateEditBirthDate, &QDateEdit::dateChanged, this, &TMainWindow::SaveBirthDate); connect(ui->dateEditBirthDate, &QDateEdit::dateChanged, this, &TMainWindow::SaveBirthDate);
connect(ui->plainTextEditNotes, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveNotes); connect(ui->plainTextEditNotes, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveNotes);
connect(ui->pushButtonGrow, &QPushButton::clicked, this, &TMainWindow::DeployFormula);
} }
ui->actionAddCustom->setEnabled(true); ui->actionAddCustom->setEnabled(true);

View File

@ -78,6 +78,8 @@ private slots:
void ShowMData(); void ShowMData();
void DeployFormula();
private: private:
Q_DISABLE_COPY(TMainWindow) Q_DISABLE_COPY(TMainWindow)
Ui::TMainWindow *ui; Ui::TMainWindow *ui;
@ -88,6 +90,7 @@ private:
QString curFile; QString curFile;
QComboBox *gradationHeights; QComboBox *gradationHeights;
QComboBox *gradationSizes; QComboBox *gradationSizes;
int formulaBaseHeight;
void SetupMenu(); void SetupMenu();
void InitWindow(); void InitWindow();