Save gradation options.
--HG-- branch : feature
This commit is contained in:
parent
a7b9637f5f
commit
83e3af90f8
|
@ -109,7 +109,7 @@ QStringList VMeasurement::ListHeights(QMap<GHeights, bool> heights)
|
|||
QMap<GHeights, bool>::const_iterator i = heights.constBegin();
|
||||
while (i != heights.constEnd())
|
||||
{
|
||||
if (i.value())
|
||||
if (i.value() && i.key() != GHeights::ALL)
|
||||
{
|
||||
ListValue(list, static_cast<int>(i.key()));
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ QStringList VMeasurement::ListSizes(QMap<GSizes, bool> sizes)
|
|||
QMap<GSizes, bool>::const_iterator i = sizes.constBegin();
|
||||
while (i != sizes.constEnd())
|
||||
{
|
||||
if (i.value())
|
||||
if (i.value() && i.key() != GSizes::ALL)
|
||||
{
|
||||
ListValue(list, static_cast<int>(i.key()));
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "dialogpatternproperties.h"
|
||||
#include "ui_dialogpatternproperties.h"
|
||||
#include <QSettings>
|
||||
#include <QPushButton>
|
||||
#include "../../xml/vpattern.h"
|
||||
#include "../../widgets/vapplication.h"
|
||||
|
@ -38,79 +37,47 @@
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogPatternProperties::DialogPatternProperties(VPattern *doc, QWidget *parent) :
|
||||
QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc), heightsChecked(MAX_HEIGHTS), sizesChecked(MAX_SIZES)
|
||||
QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc), heightsChecked(MAX_HEIGHTS),
|
||||
sizesChecked(MAX_SIZES), heights (QMap<GHeights, bool>()), sizes(QMap<GSizes, bool>()),
|
||||
data(QMap<QCheckBox *, int>()), descriptionChanged(false), gradationChanged(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
SCASSERT(doc != nullptr);
|
||||
|
||||
QSettings *settings = qApp->getSettings();
|
||||
SCASSERT(settings != nullptr);
|
||||
#ifdef Q_OS_WIN
|
||||
QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString();
|
||||
#else
|
||||
QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USER").constData())).toString();
|
||||
#endif
|
||||
ui->lineEditAuthor->setText(doc->GetAuthor());
|
||||
connect(ui->lineEditAuthor, &QLineEdit::editingFinished, this, &DialogPatternProperties::DescEdited);
|
||||
|
||||
ui->lineEditAuthor->setText(this->doc->UniqueTagText("author", user));
|
||||
ui->plainTextEditDescription->setPlainText(this->doc->UniqueTagText("description"));
|
||||
ui->plainTextEditTechNotes->setPlainText(this->doc->UniqueTagText("notes"));
|
||||
ui->plainTextEditDescription->setPlainText(doc->GetDescription());
|
||||
connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited);
|
||||
|
||||
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||
SCASSERT(bOk != nullptr);
|
||||
connect(bOk, &QPushButton::clicked, this, &DialogPatternProperties::Apply);
|
||||
ui->plainTextEditTechNotes->setPlainText(doc->GetNotes());
|
||||
connect(ui->plainTextEditTechNotes, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited);
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &DialogPatternProperties::Ok);
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this,
|
||||
&DialogPatternProperties::Apply);
|
||||
|
||||
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||||
SCASSERT(bCansel != nullptr);
|
||||
connect(bCansel, &QPushButton::clicked, this, &DialogPatternProperties::close);
|
||||
|
||||
connect(this, &DialogPatternProperties::haveChange, this->doc, &VPattern::haveLiteChange);
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
if (qApp->patternType() == MeasurementsType::Individual)
|
||||
{
|
||||
ui->tabWidget->setTabEnabled(1, false);
|
||||
}
|
||||
connect(ui->checkBoxAllHeights, &QCheckBox::stateChanged, this, &DialogPatternProperties::SelectAll);
|
||||
connect(ui->checkBoxAllSizes, &QCheckBox::stateChanged, this, &DialogPatternProperties::SelectAll);
|
||||
|
||||
connect(ui->checkBoxH92, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH98, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH104, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH110, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH116, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH122, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH128, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH134, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH140, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH146, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH152, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH158, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH164, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH170, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH176, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH182, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH188, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
connect(ui->checkBoxH194, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight);
|
||||
InitHeights();
|
||||
InitSizes();
|
||||
|
||||
connect(ui->checkBoxS22, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS24, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS26, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS28, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS30, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS32, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS34, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS36, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS38, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS40, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS42, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS44, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS46, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS48, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS50, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS52, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS54, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
connect(ui->checkBoxS56, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize);
|
||||
heights = doc->GetGradationHeights();
|
||||
sizes = doc->GetGradationSizes();
|
||||
|
||||
SetOptions(heights);
|
||||
SetOptions(sizes);
|
||||
|
||||
gradationChanged = false;//Set to default value after initialization
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -122,10 +89,36 @@ DialogPatternProperties::~DialogPatternProperties()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::Apply()
|
||||
{
|
||||
Write("notes", ui->plainTextEditTechNotes->document()->toPlainText());
|
||||
Write("description", ui->plainTextEditDescription->document()->toPlainText());
|
||||
Write("author", ui->lineEditAuthor->text());
|
||||
emit haveChange();
|
||||
switch (ui->tabWidget->currentIndex())
|
||||
{
|
||||
case 0:
|
||||
SaveDescription();
|
||||
descriptionChanged = false;
|
||||
break;
|
||||
case 1:
|
||||
SaveGradation();
|
||||
gradationChanged = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::Ok()
|
||||
{
|
||||
if (descriptionChanged)
|
||||
{
|
||||
SaveDescription();
|
||||
descriptionChanged = false;
|
||||
}
|
||||
|
||||
if (gradationChanged)
|
||||
{
|
||||
SaveGradation();
|
||||
gradationChanged = false;
|
||||
}
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
|
@ -139,30 +132,16 @@ void DialogPatternProperties::SelectAll(int state)
|
|||
{
|
||||
if (state == Qt::Checked)
|
||||
{
|
||||
ui->checkBoxH92->setChecked(true);
|
||||
ui->checkBoxH98->setChecked(true);
|
||||
ui->checkBoxH104->setChecked(true);
|
||||
ui->checkBoxH110->setChecked(true);
|
||||
ui->checkBoxH116->setChecked(true);
|
||||
ui->checkBoxH122->setChecked(true);
|
||||
ui->checkBoxH128->setChecked(true);
|
||||
ui->checkBoxH134->setChecked(true);
|
||||
ui->checkBoxH140->setChecked(true);
|
||||
ui->checkBoxH146->setChecked(true);
|
||||
ui->checkBoxH152->setChecked(true);
|
||||
ui->checkBoxH158->setChecked(true);
|
||||
ui->checkBoxH164->setChecked(true);
|
||||
ui->checkBoxH170->setChecked(true);
|
||||
ui->checkBoxH176->setChecked(true);
|
||||
ui->checkBoxH182->setChecked(true);
|
||||
ui->checkBoxH188->setChecked(true);
|
||||
ui->checkBoxH194->setChecked(true);
|
||||
|
||||
SetHeightsEnabled(false);
|
||||
SetHeightsChecked(true);
|
||||
}
|
||||
else if (state == Qt::Unchecked)
|
||||
{
|
||||
SetHeightsEnabled(true);
|
||||
SetHeightsChecked(false);
|
||||
}
|
||||
|
||||
if (data.contains(box))
|
||||
{
|
||||
heights.insert(static_cast<GHeights>(data.value(box)), box->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,181 +149,252 @@ void DialogPatternProperties::SelectAll(int state)
|
|||
{
|
||||
if (state == Qt::Checked)
|
||||
{
|
||||
ui->checkBoxS22->setChecked(true);
|
||||
ui->checkBoxS24->setChecked(true);
|
||||
ui->checkBoxS26->setChecked(true);
|
||||
ui->checkBoxS28->setChecked(true);
|
||||
ui->checkBoxS30->setChecked(true);
|
||||
ui->checkBoxS32->setChecked(true);
|
||||
ui->checkBoxS34->setChecked(true);
|
||||
ui->checkBoxS36->setChecked(true);
|
||||
ui->checkBoxS38->setChecked(true);
|
||||
ui->checkBoxS40->setChecked(true);
|
||||
ui->checkBoxS42->setChecked(true);
|
||||
ui->checkBoxS44->setChecked(true);
|
||||
ui->checkBoxS46->setChecked(true);
|
||||
ui->checkBoxS48->setChecked(true);
|
||||
ui->checkBoxS50->setChecked(true);
|
||||
ui->checkBoxS52->setChecked(true);
|
||||
ui->checkBoxS54->setChecked(true);
|
||||
ui->checkBoxS56->setChecked(true);
|
||||
|
||||
SetSizesEnabled(false);
|
||||
SetSizesChecked(true);
|
||||
}
|
||||
else if (state == Qt::Unchecked)
|
||||
{
|
||||
SetSizesEnabled(true);
|
||||
SetSizesChecked(false);
|
||||
}
|
||||
|
||||
if (data.contains(box))
|
||||
{
|
||||
sizes.insert(static_cast<GSizes>(data.value(box)), box->isChecked());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::UncheckHeight(int state)
|
||||
void DialogPatternProperties::CheckStateHeight(int state)
|
||||
{
|
||||
QCheckBox* box = qobject_cast<QCheckBox*>(sender());
|
||||
if (box)
|
||||
{
|
||||
if (box == ui->checkBoxH92 || box == ui->checkBoxH98 || box == ui->checkBoxH104 || box == ui->checkBoxH110 ||
|
||||
box == ui->checkBoxH116 || box == ui->checkBoxH122 || box == ui->checkBoxH128 || box == ui->checkBoxH134 ||
|
||||
box == ui->checkBoxH140 || box == ui->checkBoxH146 || box == ui->checkBoxH152 || box == ui->checkBoxH158 ||
|
||||
box == ui->checkBoxH164 || box == ui->checkBoxH170 || box == ui->checkBoxH176 || box == ui->checkBoxH182 ||
|
||||
box == ui->checkBoxH188 || box == ui->checkBoxH194)
|
||||
if (state == Qt::Checked)
|
||||
{
|
||||
if (state == Qt::Checked)
|
||||
++heightsChecked;
|
||||
if (heightsChecked == MAX_HEIGHTS)
|
||||
{
|
||||
++heightsChecked;
|
||||
}
|
||||
else if (state == Qt::Unchecked)
|
||||
{
|
||||
if (heightsChecked == 1)
|
||||
{
|
||||
box->setCheckState(Qt::Checked);//Will call this method again with Qt::Checked state
|
||||
--heightsChecked;// That's why we will increase.
|
||||
}
|
||||
else
|
||||
{
|
||||
--heightsChecked;
|
||||
}
|
||||
ui->checkBoxAllHeights->blockSignals(true);//don't touch anothers checkboxes
|
||||
ui->checkBoxAllHeights->setCheckState(Qt::Checked);
|
||||
heights.insert(GHeights::ALL, true);
|
||||
ui->checkBoxAllHeights->blockSignals(false);
|
||||
}
|
||||
}
|
||||
else if (state == Qt::Unchecked)
|
||||
{
|
||||
if (heightsChecked == MAX_HEIGHTS)
|
||||
{
|
||||
ui->checkBoxAllHeights->blockSignals(true);//don't touch anothers checkboxes
|
||||
ui->checkBoxAllHeights->setCheckState(Qt::Unchecked);
|
||||
heights.insert(GHeights::ALL, false);
|
||||
ui->checkBoxAllHeights->blockSignals(false);
|
||||
}
|
||||
--heightsChecked;
|
||||
}
|
||||
|
||||
if (data.contains(box))
|
||||
{
|
||||
heights.insert(static_cast<GHeights>(data.value(box)), box->isChecked());
|
||||
}
|
||||
|
||||
CheckApplyOk();
|
||||
gradationChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::UncheckSize(int state)
|
||||
void DialogPatternProperties::CheckStateSize(int state)
|
||||
{
|
||||
QCheckBox* box = qobject_cast<QCheckBox*>(sender());
|
||||
if (box)
|
||||
{
|
||||
if (box == ui->checkBoxS22 || box == ui->checkBoxS24 || box == ui->checkBoxS26 || box == ui->checkBoxS28 ||
|
||||
box == ui->checkBoxS30 || box == ui->checkBoxS32 || box == ui->checkBoxS34 || box == ui->checkBoxS36 ||
|
||||
box == ui->checkBoxS38 || box == ui->checkBoxS40 || box == ui->checkBoxS42 || box == ui->checkBoxS44 ||
|
||||
box == ui->checkBoxS46 || box == ui->checkBoxS48 || box == ui->checkBoxS50 || box == ui->checkBoxS52 ||
|
||||
box == ui->checkBoxS54 || box == ui->checkBoxS56)
|
||||
|
||||
if (state == Qt::Checked)
|
||||
{
|
||||
if (state == Qt::Checked)
|
||||
++sizesChecked;
|
||||
if (sizesChecked == MAX_SIZES)
|
||||
{
|
||||
++sizesChecked;
|
||||
ui->checkBoxAllSizes->blockSignals(true);//don't touch anothers checkboxes
|
||||
ui->checkBoxAllSizes->setCheckState(Qt::Checked);
|
||||
sizes.insert(GSizes::ALL, true);
|
||||
ui->checkBoxAllSizes->blockSignals(false);
|
||||
}
|
||||
else if (state == Qt::Unchecked)
|
||||
}
|
||||
else if (state == Qt::Unchecked)
|
||||
{
|
||||
if (sizesChecked == MAX_SIZES)
|
||||
{
|
||||
if (sizesChecked == 1)
|
||||
ui->checkBoxAllSizes->blockSignals(true);//don't touch anothers checkboxes
|
||||
ui->checkBoxAllSizes->setCheckState(Qt::Unchecked);
|
||||
sizes.insert(GSizes::ALL, false);
|
||||
ui->checkBoxAllSizes->blockSignals(false);
|
||||
}
|
||||
--sizesChecked;
|
||||
}
|
||||
|
||||
if (data.contains(box))
|
||||
{
|
||||
sizes.insert(static_cast<GSizes>(data.value(box)), box->isChecked());
|
||||
}
|
||||
|
||||
CheckApplyOk();
|
||||
gradationChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::DescEdited()
|
||||
{
|
||||
descriptionChanged = true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::SetHeightsChecked(bool enabled)
|
||||
{
|
||||
ui->checkBoxH92->setChecked(enabled);
|
||||
ui->checkBoxH98->setChecked(enabled);
|
||||
ui->checkBoxH104->setChecked(enabled);
|
||||
ui->checkBoxH110->setChecked(enabled);
|
||||
ui->checkBoxH116->setChecked(enabled);
|
||||
ui->checkBoxH122->setChecked(enabled);
|
||||
ui->checkBoxH128->setChecked(enabled);
|
||||
ui->checkBoxH134->setChecked(enabled);
|
||||
ui->checkBoxH140->setChecked(enabled);
|
||||
ui->checkBoxH146->setChecked(enabled);
|
||||
ui->checkBoxH152->setChecked(enabled);
|
||||
ui->checkBoxH158->setChecked(enabled);
|
||||
ui->checkBoxH164->setChecked(enabled);
|
||||
ui->checkBoxH170->setChecked(enabled);
|
||||
ui->checkBoxH176->setChecked(enabled);
|
||||
ui->checkBoxH182->setChecked(enabled);
|
||||
ui->checkBoxH188->setChecked(enabled);
|
||||
ui->checkBoxH194->setChecked(enabled);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::SetSizesChecked(bool enabled)
|
||||
{
|
||||
ui->checkBoxS22->setChecked(enabled);
|
||||
ui->checkBoxS24->setChecked(enabled);
|
||||
ui->checkBoxS26->setChecked(enabled);
|
||||
ui->checkBoxS28->setChecked(enabled);
|
||||
ui->checkBoxS30->setChecked(enabled);
|
||||
ui->checkBoxS32->setChecked(enabled);
|
||||
ui->checkBoxS34->setChecked(enabled);
|
||||
ui->checkBoxS36->setChecked(enabled);
|
||||
ui->checkBoxS38->setChecked(enabled);
|
||||
ui->checkBoxS40->setChecked(enabled);
|
||||
ui->checkBoxS42->setChecked(enabled);
|
||||
ui->checkBoxS44->setChecked(enabled);
|
||||
ui->checkBoxS46->setChecked(enabled);
|
||||
ui->checkBoxS48->setChecked(enabled);
|
||||
ui->checkBoxS50->setChecked(enabled);
|
||||
ui->checkBoxS52->setChecked(enabled);
|
||||
ui->checkBoxS54->setChecked(enabled);
|
||||
ui->checkBoxS56->setChecked(enabled);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::InitHeights()
|
||||
{
|
||||
Init(ui->checkBoxAllHeights, static_cast<int>(GHeights::ALL), &DialogPatternProperties::SelectAll);
|
||||
|
||||
Init(ui->checkBoxH92, static_cast<int>(GHeights::H92), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH98, static_cast<int>(GHeights::H98), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH104, static_cast<int>(GHeights::H104), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH110, static_cast<int>(GHeights::H110), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH116, static_cast<int>(GHeights::H116), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH122, static_cast<int>(GHeights::H122), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH128, static_cast<int>(GHeights::H128), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH134, static_cast<int>(GHeights::H134), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH140, static_cast<int>(GHeights::H140), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH146, static_cast<int>(GHeights::H146), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH152, static_cast<int>(GHeights::H152), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH158, static_cast<int>(GHeights::H158), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH164, static_cast<int>(GHeights::H164), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH170, static_cast<int>(GHeights::H170), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH176, static_cast<int>(GHeights::H176), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH182, static_cast<int>(GHeights::H182), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH188, static_cast<int>(GHeights::H188), &DialogPatternProperties::CheckStateHeight);
|
||||
Init(ui->checkBoxH194, static_cast<int>(GHeights::H194), &DialogPatternProperties::CheckStateHeight);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::InitSizes()
|
||||
{
|
||||
Init(ui->checkBoxAllSizes, static_cast<int>(GSizes::ALL), &DialogPatternProperties::SelectAll);
|
||||
|
||||
Init(ui->checkBoxS22, static_cast<int>(GSizes::S22), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS24, static_cast<int>(GSizes::S24), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS26, static_cast<int>(GSizes::S26), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS28, static_cast<int>(GSizes::S28), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS30, static_cast<int>(GSizes::S30), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS32, static_cast<int>(GSizes::S32), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS34, static_cast<int>(GSizes::S34), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS36, static_cast<int>(GSizes::S36), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS38, static_cast<int>(GSizes::S38), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS40, static_cast<int>(GSizes::S40), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS42, static_cast<int>(GSizes::S42), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS44, static_cast<int>(GSizes::S44), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS46, static_cast<int>(GSizes::S46), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS48, static_cast<int>(GSizes::S48), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS50, static_cast<int>(GSizes::S50), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS52, static_cast<int>(GSizes::S52), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS54, static_cast<int>(GSizes::S54), &DialogPatternProperties::CheckStateSize);
|
||||
Init(ui->checkBoxS56, static_cast<int>(GSizes::S56), &DialogPatternProperties::CheckStateSize);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::CheckApplyOk()
|
||||
{
|
||||
bool enable = !(heightsChecked == 0 || sizesChecked == 0);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enable);
|
||||
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(enable);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::SaveDescription()
|
||||
{
|
||||
doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText());
|
||||
doc->SetDescription(ui->plainTextEditTechNotes->document()->toPlainText());
|
||||
doc->SetAuthor(ui->lineEditAuthor->text());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::SaveGradation()
|
||||
{
|
||||
doc->SetGradationHeights(heights);
|
||||
doc->SetGradationSizes(sizes);
|
||||
emit UpdateGradation();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<typename Func>
|
||||
void DialogPatternProperties::Init(QCheckBox *check, int val, Func slot)
|
||||
{
|
||||
connect(check, &QCheckBox::stateChanged, this, slot);
|
||||
data.insert(check, val);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<typename GVal>
|
||||
void DialogPatternProperties::SetOptions(const QMap<GVal, bool> &option)
|
||||
{
|
||||
if (option.value(GVal::ALL) == false)
|
||||
{
|
||||
QMapIterator<GVal, bool> i(option);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value() == false && i.key() != GVal::ALL)
|
||||
{
|
||||
QCheckBox *box = data.key(static_cast<int>(i.key()));
|
||||
if (box != nullptr)
|
||||
{
|
||||
box->setCheckState(Qt::Checked);//Will call this method again with Qt::Checked state
|
||||
--sizesChecked; // That's why we will increase.
|
||||
}
|
||||
else
|
||||
{
|
||||
--sizesChecked;
|
||||
box->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::Write(const QString &tagName, const QString &text) const
|
||||
{
|
||||
QDomNodeList nodeList = doc->elementsByTagName(tagName);
|
||||
if (nodeList.isEmpty())
|
||||
{
|
||||
QDomElement pattern = doc->documentElement();
|
||||
|
||||
QDomElement tag = doc->createElement(tagName);
|
||||
QDomText domText = doc->createTextNode(text);
|
||||
tag.appendChild(domText);
|
||||
//The Old pattern file doesn't have comment. But here we try insert the tag after first child (comment).
|
||||
// <pattern>
|
||||
// <!--Valentina pattern format.-->
|
||||
// -->place for new tag<--
|
||||
// </pattern>
|
||||
if (pattern.firstChild().isComment())
|
||||
{
|
||||
pattern.insertAfter(tag, pattern.firstChild());
|
||||
}
|
||||
else
|
||||
{
|
||||
pattern.insertBefore(tag, pattern.firstChild());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QDomElement oldTag = nodeList.at(0).toElement();
|
||||
if (oldTag.isElement())
|
||||
{
|
||||
QDomElement newTag = doc->createElement(tagName);
|
||||
QDomText domText = doc->createTextNode(text);
|
||||
newTag.appendChild(domText);
|
||||
|
||||
QDomElement pattern = doc->documentElement();
|
||||
pattern.replaceChild(newTag, oldTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::SetHeightsEnabled(bool enabled)
|
||||
{
|
||||
ui->checkBoxH92->setEnabled(enabled);
|
||||
ui->checkBoxH98->setEnabled(enabled);
|
||||
ui->checkBoxH104->setEnabled(enabled);
|
||||
ui->checkBoxH110->setEnabled(enabled);
|
||||
ui->checkBoxH116->setEnabled(enabled);
|
||||
ui->checkBoxH122->setEnabled(enabled);
|
||||
ui->checkBoxH128->setEnabled(enabled);
|
||||
ui->checkBoxH134->setEnabled(enabled);
|
||||
ui->checkBoxH140->setEnabled(enabled);
|
||||
ui->checkBoxH146->setEnabled(enabled);
|
||||
ui->checkBoxH152->setEnabled(enabled);
|
||||
ui->checkBoxH158->setEnabled(enabled);
|
||||
ui->checkBoxH164->setEnabled(enabled);
|
||||
ui->checkBoxH170->setEnabled(enabled);
|
||||
ui->checkBoxH176->setEnabled(enabled);
|
||||
ui->checkBoxH182->setEnabled(enabled);
|
||||
ui->checkBoxH188->setEnabled(enabled);
|
||||
ui->checkBoxH194->setEnabled(enabled);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPatternProperties::SetSizesEnabled(bool enabled)
|
||||
{
|
||||
ui->checkBoxS22->setEnabled(enabled);
|
||||
ui->checkBoxS24->setEnabled(enabled);
|
||||
ui->checkBoxS26->setEnabled(enabled);
|
||||
ui->checkBoxS28->setEnabled(enabled);
|
||||
ui->checkBoxS30->setEnabled(enabled);
|
||||
ui->checkBoxS32->setEnabled(enabled);
|
||||
ui->checkBoxS34->setEnabled(enabled);
|
||||
ui->checkBoxS36->setEnabled(enabled);
|
||||
ui->checkBoxS38->setEnabled(enabled);
|
||||
ui->checkBoxS40->setEnabled(enabled);
|
||||
ui->checkBoxS42->setEnabled(enabled);
|
||||
ui->checkBoxS44->setEnabled(enabled);
|
||||
ui->checkBoxS46->setEnabled(enabled);
|
||||
ui->checkBoxS48->setEnabled(enabled);
|
||||
ui->checkBoxS50->setEnabled(enabled);
|
||||
ui->checkBoxS52->setEnabled(enabled);
|
||||
ui->checkBoxS54->setEnabled(enabled);
|
||||
ui->checkBoxS56->setEnabled(enabled);
|
||||
}
|
||||
|
|
|
@ -30,8 +30,10 @@
|
|||
#define DIALOGPATTERNPROPERTIES_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "../../options.h"
|
||||
|
||||
class VPattern;
|
||||
class QCheckBox;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -45,21 +47,37 @@ public:
|
|||
DialogPatternProperties(VPattern *doc, QWidget *parent = nullptr);
|
||||
virtual ~DialogPatternProperties();
|
||||
signals:
|
||||
void haveChange();
|
||||
void UpdateGradation();
|
||||
public slots:
|
||||
void Apply();
|
||||
void Ok();
|
||||
void SelectAll(int state);
|
||||
void UncheckHeight(int state);
|
||||
void UncheckSize(int state);
|
||||
void CheckStateHeight(int state);
|
||||
void CheckStateSize(int state);
|
||||
void DescEdited();
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogPatternProperties)
|
||||
Ui::DialogPatternProperties *ui;
|
||||
VPattern *doc;
|
||||
char heightsChecked;
|
||||
char sizesChecked;
|
||||
void Write(const QString &tagName, const QString &text) const;
|
||||
void SetHeightsEnabled(bool enabled);
|
||||
void SetSizesEnabled(bool enabled);
|
||||
VPattern *doc;
|
||||
char heightsChecked;
|
||||
char sizesChecked;
|
||||
QMap<GHeights, bool> heights;
|
||||
QMap<GSizes, bool> sizes;
|
||||
QMap<QCheckBox *, int> data;
|
||||
bool descriptionChanged;
|
||||
bool gradationChanged;
|
||||
|
||||
void SetHeightsChecked(bool enabled);
|
||||
void SetSizesChecked(bool enabled);
|
||||
void InitHeights();
|
||||
void InitSizes();
|
||||
template<typename Func>
|
||||
void Init(QCheckBox *check, int val, Func slot);
|
||||
template<typename GVal>
|
||||
void SetOptions(const QMap<GVal, bool> &option);
|
||||
void CheckApplyOk();
|
||||
void SaveDescription();
|
||||
void SaveGradation();
|
||||
};
|
||||
|
||||
#endif // DIALOGPATTERNPROPERTIES_H
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxH92">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -129,7 +129,7 @@
|
|||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxH146">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -148,7 +148,7 @@
|
|||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxH98">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -167,7 +167,7 @@
|
|||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxH152">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -186,7 +186,7 @@
|
|||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxH104">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -211,7 +211,7 @@
|
|||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxH158">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -230,7 +230,7 @@
|
|||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxH110">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -249,7 +249,7 @@
|
|||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxH164">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -268,7 +268,7 @@
|
|||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxH116">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -287,7 +287,7 @@
|
|||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxH170">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -306,7 +306,7 @@
|
|||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxH122">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -325,7 +325,7 @@
|
|||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxH176">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -344,7 +344,7 @@
|
|||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxH128">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -363,7 +363,7 @@
|
|||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxH182">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -382,7 +382,7 @@
|
|||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxH134">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -401,7 +401,7 @@
|
|||
<item row="7" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxH188">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -420,7 +420,7 @@
|
|||
<item row="8" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxH140">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -439,7 +439,7 @@
|
|||
<item row="8" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxH194">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -484,7 +484,7 @@
|
|||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxS22">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -503,7 +503,7 @@
|
|||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxS40">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -522,7 +522,7 @@
|
|||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxS24">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -541,7 +541,7 @@
|
|||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxS42">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -560,7 +560,7 @@
|
|||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxS26">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -579,7 +579,7 @@
|
|||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxS44">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -598,7 +598,7 @@
|
|||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxS28">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -617,7 +617,7 @@
|
|||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxS46">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -636,7 +636,7 @@
|
|||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxS30">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -655,7 +655,7 @@
|
|||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxS48">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -674,7 +674,7 @@
|
|||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxS32">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -693,7 +693,7 @@
|
|||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxS50">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -712,7 +712,7 @@
|
|||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxS34">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -731,7 +731,7 @@
|
|||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxS52">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -750,7 +750,7 @@
|
|||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxS36">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -769,7 +769,7 @@
|
|||
<item row="7" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxS54">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -788,7 +788,7 @@
|
|||
<item row="8" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxS38">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -807,7 +807,7 @@
|
|||
<item row="8" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxS56">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -840,7 +840,7 @@
|
|||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -1594,7 +1594,7 @@ void MainWindow::ActionLayout(bool checked)
|
|||
QPainterPath path = VEquidistant().ContourPath(idetail.key(), pattern);
|
||||
listDetails.append(new VItem(path, listDetails.size()));
|
||||
}
|
||||
QString description = doc->UniqueTagText("description");
|
||||
QString description = doc->GetDescription();
|
||||
emit ModelChosen(listDetails, curFile, description);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,11 +75,13 @@ enum class Draw : char { Calculation, Modeling };
|
|||
enum class Unit : char { Mm, Cm, Inch };
|
||||
enum class MeasurementsType : char { Standard, Individual };
|
||||
|
||||
enum class GHeights : unsigned char { H92=92, H98=98, H104=104, H110=110, H116=116, H122=122, H128=128, H134=134,
|
||||
enum class GHeights : unsigned char { ALL,
|
||||
H92=92, H98=98, H104=104, H110=110, H116=116, H122=122, H128=128, H134=134,
|
||||
H140=140, H146=146, H152=152, H158=158, H164=164, H170=170, H176=176, H182=182,
|
||||
H188=188, H194=194};
|
||||
|
||||
enum class GSizes : unsigned char { S22=22, S24=24, S26=26, S28=28, S30=30, S32=32, S34=34, S36=36, S38=38, S40=40,
|
||||
enum class GSizes : unsigned char { ALL,
|
||||
S22=22, S24=24, S26=26, S28=28, S30=30, S32=32, S34=34, S36=36, S38=38, S40=40,
|
||||
S42=42, S44=44, S46=46, S48=48, S50=50, S52=52, S54=54, S56=56 };
|
||||
|
||||
// measurements
|
||||
|
|
|
@ -87,11 +87,6 @@ public:
|
|||
* @param domElement element in xml tree.
|
||||
* @param name name of attribute.
|
||||
* @param value value of attribute.
|
||||
* @param parse parsing mode
|
||||
* @return list of tool pointers
|
||||
* @return list of history record lists
|
||||
* @return cursor
|
||||
* @throw VExceptionUniqueId
|
||||
*/
|
||||
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
|
||||
{
|
||||
|
@ -104,7 +99,7 @@ public:
|
|||
QString GetParametrString(const QDomElement& domElement, const QString &name,
|
||||
const QString &defValue = QString()) const;
|
||||
qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const;
|
||||
QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const;
|
||||
|
||||
static void ValidateXML(const QString &schema, const QString &fileName);
|
||||
void setContent(const QString &fileName);
|
||||
static Unit StrToUnits(const QString &unit);
|
||||
|
@ -118,7 +113,8 @@ protected:
|
|||
/** @brief data container with data. */
|
||||
VContainer *data;
|
||||
|
||||
void setTagText(const QString &tag, const QString &text);
|
||||
void setTagText(const QString &tag, const QString &text);
|
||||
QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const;
|
||||
private:
|
||||
Q_DISABLE_COPY(VDomDocument)
|
||||
/** @brief Map used for finding element by id. */
|
||||
|
@ -135,6 +131,22 @@ inline void VDomDocument::SetAttribute<QString>(QDomElement &domElement, const Q
|
|||
domElement.setAttribute(name, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <>
|
||||
inline void VDomDocument::SetAttribute<bool>(QDomElement &domElement, const QString &name, const bool &value) const
|
||||
{
|
||||
QString string;
|
||||
if (value)
|
||||
{
|
||||
string = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
string = "false";
|
||||
}
|
||||
domElement.setAttribute(name, string);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <>
|
||||
inline void VDomDocument::SetAttribute<MeasurementsType>(QDomElement &domElement, const QString &name,
|
||||
|
|
|
@ -1543,6 +1543,75 @@ void VPattern::ParseCurrentPP()
|
|||
emit CheckLayout();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::CheckTagExists(const QString &tag)
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(tag);
|
||||
if (list.size() == 0)
|
||||
{
|
||||
QStringList tags{TagVersion, TagAuthor, TagDescription, TagNotes, TagGradation};
|
||||
QDomElement pattern = documentElement();
|
||||
switch (tags.indexOf(tag))
|
||||
{
|
||||
case 0: //TagVersion
|
||||
break;// Mandatory tag
|
||||
case 1: //TagAuthor
|
||||
pattern.insertAfter(createElement(TagAuthor), elementsByTagName(TagVersion).at(0));
|
||||
SetVersion();
|
||||
break;
|
||||
case 2: //TagDescription
|
||||
{
|
||||
for (int i = tags.indexOf(tag)-1; i >= 0; --i)
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(tags.at(i));
|
||||
if (list.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pattern.insertAfter(createElement(TagDescription), list.at(0));
|
||||
}
|
||||
SetVersion();
|
||||
break;
|
||||
}
|
||||
case 3: //TagNotes
|
||||
{
|
||||
for (int i = tags.indexOf(tag)-1; i >= 0; --i)
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(tags.at(i));
|
||||
if (list.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pattern.insertAfter(createElement(TagNotes), list.at(0));
|
||||
}
|
||||
SetVersion();
|
||||
break;
|
||||
}
|
||||
case 4: //TagGradation
|
||||
{
|
||||
QDomElement gradation = createElement(TagGradation);
|
||||
gradation.appendChild(createElement(TagHeights));
|
||||
gradation.appendChild(createElement(TagSizes));
|
||||
|
||||
for (int i = tags.indexOf(tag)-1; i >= 0; --i)
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(tags.at(i));
|
||||
if (list.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pattern.insertAfter(gradation, list.at(0));
|
||||
break;
|
||||
}
|
||||
SetVersion();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ParseSplineElement parse spline tag.
|
||||
|
@ -1863,6 +1932,7 @@ quint32 VPattern::GetParametrId(const QDomElement &domElement) const
|
|||
QMap<GHeights, bool> VPattern::GetGradationHeights() const
|
||||
{
|
||||
QMap<GHeights, bool> map;
|
||||
map.insert(GHeights::ALL, true);
|
||||
map.insert(GHeights::H92, true);
|
||||
map.insert(GHeights::H98, true);
|
||||
map.insert(GHeights::H104, true);
|
||||
|
@ -1905,6 +1975,10 @@ QMap<GHeights, bool> VPattern::GetGradationHeights() const
|
|||
{
|
||||
return map;
|
||||
}
|
||||
else
|
||||
{
|
||||
map.insert(GHeights::ALL, false);
|
||||
}
|
||||
|
||||
map.insert(GHeights::H92, GetParametrBool(domElement, AttrH92, defValue));
|
||||
map.insert(GHeights::H98, GetParametrBool(domElement, AttrH98, defValue));
|
||||
|
@ -1938,10 +2012,68 @@ QMap<GHeights, bool> VPattern::GetGradationHeights() const
|
|||
return map;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::SetGradationHeights(const QMap<GHeights, bool> &options)
|
||||
{
|
||||
CheckTagExists(TagGradation);
|
||||
QDomNodeList tags = elementsByTagName(TagGradation);
|
||||
if (tags.size() == 0)
|
||||
{
|
||||
qDebug()<<"Can't save tag "<<TagGradation<<Q_FUNC_INFO;
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList gTags{TagHeights, TagSizes};
|
||||
QDomNode domNode = tags.at(0).firstChild();
|
||||
while (domNode.isNull() == false)
|
||||
{
|
||||
if (domNode.isElement())
|
||||
{
|
||||
QDomElement domElement = domNode.toElement();
|
||||
if (domElement.isNull() == false)
|
||||
{
|
||||
switch (gTags.indexOf(domElement.tagName()))
|
||||
{
|
||||
case 0: // TagHeights
|
||||
SetAttribute(domElement, AttrAll, options.value(GHeights::ALL));
|
||||
SetAttribute(domElement, AttrH92, options.value(GHeights::H92));
|
||||
SetAttribute(domElement, AttrH98, options.value(GHeights::H98));
|
||||
SetAttribute(domElement, AttrH104, options.value(GHeights::H104));
|
||||
SetAttribute(domElement, AttrH110, options.value(GHeights::H110));
|
||||
SetAttribute(domElement, AttrH116, options.value(GHeights::H116));
|
||||
SetAttribute(domElement, AttrH122, options.value(GHeights::H122));
|
||||
SetAttribute(domElement, AttrH128, options.value(GHeights::H128));
|
||||
SetAttribute(domElement, AttrH134, options.value(GHeights::H134));
|
||||
SetAttribute(domElement, AttrH140, options.value(GHeights::H140));
|
||||
SetAttribute(domElement, AttrH146, options.value(GHeights::H146));
|
||||
SetAttribute(domElement, AttrH152, options.value(GHeights::H152));
|
||||
SetAttribute(domElement, AttrH158, options.value(GHeights::H158));
|
||||
SetAttribute(domElement, AttrH164, options.value(GHeights::H164));
|
||||
SetAttribute(domElement, AttrH170, options.value(GHeights::H170));
|
||||
SetAttribute(domElement, AttrH176, options.value(GHeights::H176));
|
||||
SetAttribute(domElement, AttrH182, options.value(GHeights::H182));
|
||||
SetAttribute(domElement, AttrH188, options.value(GHeights::H188));
|
||||
SetAttribute(domElement, AttrH194, options.value(GHeights::H194));
|
||||
|
||||
emit patternChanged(false);
|
||||
return;
|
||||
break;
|
||||
case 1: // TagSizes
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
domNode = domNode.nextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QMap<GSizes, bool> VPattern::GetGradationSizes() const
|
||||
{
|
||||
QMap<GSizes, bool> map;
|
||||
map.insert(GSizes::ALL, true);
|
||||
map.insert(GSizes::S22, true);
|
||||
map.insert(GSizes::S24, true);
|
||||
map.insert(GSizes::S26, true);
|
||||
|
@ -1986,6 +2118,10 @@ QMap<GSizes, bool> VPattern::GetGradationSizes() const
|
|||
{
|
||||
return map;
|
||||
}
|
||||
else
|
||||
{
|
||||
map.insert(GSizes::ALL, false);
|
||||
}
|
||||
|
||||
map.insert(GSizes::S22, GetParametrBool(domElement, AttrS22, defValue));
|
||||
map.insert(GSizes::S24, GetParametrBool(domElement, AttrS24, defValue));
|
||||
|
@ -2017,6 +2153,126 @@ QMap<GSizes, bool> VPattern::GetGradationSizes() const
|
|||
return map;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::SetGradationSizes(const QMap<GSizes, bool> &options)
|
||||
{
|
||||
CheckTagExists(TagGradation);
|
||||
QDomNodeList tags = elementsByTagName(TagGradation);
|
||||
if (tags.size() == 0)
|
||||
{
|
||||
qDebug()<<"Can't save tag "<<TagGradation<<Q_FUNC_INFO;
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList gTags{TagHeights, TagSizes};
|
||||
QDomNode domNode = tags.at(0).firstChild();
|
||||
while (domNode.isNull() == false)
|
||||
{
|
||||
if (domNode.isElement())
|
||||
{
|
||||
QDomElement domElement = domNode.toElement();
|
||||
if (domElement.isNull() == false)
|
||||
{
|
||||
switch (gTags.indexOf(domElement.tagName()))
|
||||
{
|
||||
case 0: // TagHeights
|
||||
break;
|
||||
case 1: // TagSizes
|
||||
SetAttribute(domElement, AttrAll, options.value(GSizes::ALL));
|
||||
SetAttribute(domElement, AttrS22, options.value(GSizes::S22));
|
||||
SetAttribute(domElement, AttrS24, options.value(GSizes::S24));
|
||||
SetAttribute(domElement, AttrS26, options.value(GSizes::S26));
|
||||
SetAttribute(domElement, AttrS28, options.value(GSizes::S28));
|
||||
SetAttribute(domElement, AttrS30, options.value(GSizes::S30));
|
||||
SetAttribute(domElement, AttrS32, options.value(GSizes::S32));
|
||||
SetAttribute(domElement, AttrS34, options.value(GSizes::S34));
|
||||
SetAttribute(domElement, AttrS36, options.value(GSizes::S36));
|
||||
SetAttribute(domElement, AttrS38, options.value(GSizes::S38));
|
||||
SetAttribute(domElement, AttrS40, options.value(GSizes::S40));
|
||||
SetAttribute(domElement, AttrS42, options.value(GSizes::S42));
|
||||
SetAttribute(domElement, AttrS44, options.value(GSizes::S44));
|
||||
SetAttribute(domElement, AttrS46, options.value(GSizes::S46));
|
||||
SetAttribute(domElement, AttrS48, options.value(GSizes::S48));
|
||||
SetAttribute(domElement, AttrS50, options.value(GSizes::S50));
|
||||
SetAttribute(domElement, AttrS52, options.value(GSizes::S52));
|
||||
SetAttribute(domElement, AttrS54, options.value(GSizes::S54));
|
||||
SetAttribute(domElement, AttrS56, options.value(GSizes::S56));
|
||||
|
||||
emit patternChanged(false);
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
domNode = domNode.nextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPattern::GetAuthor() const
|
||||
{
|
||||
QSettings *settings = qApp->getSettings();
|
||||
SCASSERT(settings != nullptr);
|
||||
#ifdef Q_OS_WIN
|
||||
QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString();
|
||||
#else
|
||||
QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USER").constData())).toString();
|
||||
#endif
|
||||
|
||||
return UniqueTagText(TagAuthor, user);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::SetAuthor(const QString &text)
|
||||
{
|
||||
CheckTagExists(TagAuthor);
|
||||
setTagText(TagAuthor, text);
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPattern::GetDescription() const
|
||||
{
|
||||
return UniqueTagText(TagDescription);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::SetDescription(const QString &text)
|
||||
{
|
||||
CheckTagExists(TagDescription);
|
||||
setTagText(TagDescription, text);
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPattern::GetNotes() const
|
||||
{
|
||||
return UniqueTagText(TagNotes);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::SetNotes(const QString &text)
|
||||
{
|
||||
CheckTagExists(TagNotes);
|
||||
setTagText(TagNotes, text);
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPattern::GetVersion() const
|
||||
{
|
||||
return UniqueTagText(TagVersion, VAL_STR_VERSION);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::SetVersion()
|
||||
{
|
||||
setTagText(TagVersion, VAL_STR_VERSION);
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief CollectId recursive function, try find id attribute in file. Throw exclusion if find not unique.
|
||||
|
|
|
@ -163,7 +163,22 @@ public:
|
|||
quint32 GetParametrId(const QDomElement& domElement) const;
|
||||
|
||||
QMap<GHeights, bool> GetGradationHeights() const;
|
||||
void SetGradationHeights(const QMap<GHeights, bool> &options);
|
||||
|
||||
QMap<GSizes, bool> GetGradationSizes() const;
|
||||
void SetGradationSizes(const QMap<GSizes, bool> &options);
|
||||
|
||||
QString GetAuthor() const;
|
||||
void SetAuthor(const QString &text);
|
||||
|
||||
QString GetDescription() const;
|
||||
void SetDescription(const QString &text);
|
||||
|
||||
QString GetNotes() const;
|
||||
void SetNotes(const QString &text);
|
||||
|
||||
QString GetVersion() const;
|
||||
void SetVersion();
|
||||
signals:
|
||||
/**
|
||||
* @brief ChangedActivDraw change active pattern peace.
|
||||
|
@ -264,6 +279,7 @@ private:
|
|||
template <typename T>
|
||||
QRectF ToolBoundingRect(const QRectF &rec, const quint32 &id) const;
|
||||
void ParseCurrentPP();
|
||||
void CheckTagExists(const QString &tag);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user