Fixed broken feature 'Default height and size'.
--HG-- branch : develop
This commit is contained in:
parent
fa410de76d
commit
65bf17fcf9
|
@ -88,12 +88,10 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
|
|||
InitComboBox(ui->comboBoxHeight, heights);
|
||||
InitComboBox(ui->comboBoxSize, sizes);
|
||||
|
||||
const QString height = QString().setNum(static_cast<int>(UnitConvertor(doc->GetDefCustomHeight(),
|
||||
*pattern->GetPatternUnit(), Unit::Cm)));
|
||||
const QString height = QString().setNum(doc->GetDefCustomHeight());
|
||||
SetDefaultHeight(height);
|
||||
|
||||
const QString size = QString().setNum(static_cast<int>(UnitConvertor(doc->GetDefCustomSize(),
|
||||
*pattern->GetPatternUnit(), Unit::Cm)));
|
||||
const QString size = QString().setNum(doc->GetDefCustomSize());
|
||||
SetDefaultSize(size);
|
||||
|
||||
connect(ui->radioButtonDefFromP, &QRadioButton::toggled, this, &DialogPatternProperties::ToggleComboBox);
|
||||
|
@ -454,18 +452,12 @@ void DialogPatternProperties::SaveDefValues()
|
|||
if (ui->radioButtonDefFromM->isChecked())
|
||||
{
|
||||
doc->SetDefCustom(false);
|
||||
doc->SetDefCustomHeight(0);
|
||||
doc->SetDefCustomSize(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
doc->SetDefCustom(true);
|
||||
const int height = static_cast<int>(UnitConvertor(ui->comboBoxHeight->currentText().toInt(),
|
||||
Unit::Cm, *pattern->GetPatternUnit()));
|
||||
doc->SetDefCustomHeight(height);
|
||||
const int size = static_cast<int>(UnitConvertor(ui->comboBoxSize->currentText().toInt(),
|
||||
Unit::Cm, *pattern->GetPatternUnit()));
|
||||
doc->SetDefCustomSize(size);
|
||||
doc->SetDefCustomHeight(ui->comboBoxHeight->currentText().toInt());
|
||||
doc->SetDefCustomSize(ui->comboBoxSize->currentText().toInt());
|
||||
}
|
||||
defaultChanged = false;
|
||||
}
|
||||
|
@ -481,7 +473,7 @@ void DialogPatternProperties::SetDefaultHeight(const QString &def)
|
|||
}
|
||||
else
|
||||
{
|
||||
const int height = static_cast<int>(UnitConvertor(pattern->height(), *pattern->GetPatternUnit(), Unit::Cm));
|
||||
const int height = static_cast<int>(pattern->height());
|
||||
index = ui->comboBoxHeight->findText(QString().setNum(height));
|
||||
if (index != -1)
|
||||
{
|
||||
|
@ -502,7 +494,7 @@ void DialogPatternProperties::SetDefaultSize(const QString &def)
|
|||
}
|
||||
else
|
||||
{
|
||||
const int size = static_cast<int>(UnitConvertor(pattern->size(), *pattern->GetPatternUnit(), Unit::Cm));
|
||||
const int size = static_cast<int>(pattern->size());
|
||||
index = ui->comboBoxSize->findText(QString().setNum(size));
|
||||
if (index != -1)
|
||||
{
|
||||
|
@ -572,7 +564,8 @@ void DialogPatternProperties::InitComboBox(QComboBox *box, const QMap<GVal, bool
|
|||
i.next();
|
||||
if (i.value() && i.key() != GVal::ALL)
|
||||
{
|
||||
box->addItem(QString().setNum(static_cast<int>(i.key())));
|
||||
box->addItem(QString().setNum(static_cast<int>(UnitConvertor(static_cast<int>(i.key()), Unit::Cm,
|
||||
*pattern->GetPatternUnit()))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2693,8 +2693,7 @@ void MainWindow::ChangedHeight(const QString &text)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::SetDefaultHeight()
|
||||
{
|
||||
const QString defHeight = QString().setNum(static_cast<int>(UnitConvertor(doc->GetDefCustomHeight(),
|
||||
*pattern->GetPatternUnit(), Unit::Cm)));
|
||||
const QString defHeight = QString().setNum(doc->GetDefCustomHeight());
|
||||
int index = gradationHeights->findText(defHeight);
|
||||
if (index != -1)
|
||||
{
|
||||
|
@ -2707,18 +2706,14 @@ void MainWindow::SetDefaultHeight()
|
|||
{
|
||||
gradationHeights->setCurrentIndex(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
pattern->SetHeight(gradationHeights->currentText().toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::SetDefaultSize()
|
||||
{
|
||||
const QString defSize = QString().setNum(static_cast<int>(UnitConvertor(doc->GetDefCustomSize(),
|
||||
*pattern->GetPatternUnit(), Unit::Cm)));
|
||||
const QString defSize = QString().setNum(doc->GetDefCustomSize());
|
||||
int index = gradationSizes->findText(defSize);
|
||||
if (index != -1)
|
||||
{
|
||||
|
@ -2731,11 +2726,8 @@ void MainWindow::SetDefaultSize()
|
|||
{
|
||||
gradationSizes->setCurrentIndex(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
pattern->SetSize(gradationSizes->currentText().toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -2546,8 +2546,17 @@ void VPattern::SetDefCustom(bool value)
|
|||
QDomNode domNode = tags.at(0);
|
||||
QDomElement domElement = domNode.toElement();
|
||||
if (domElement.isNull() == false)
|
||||
{
|
||||
if (value == false)
|
||||
{
|
||||
domElement.removeAttribute(AttrDefHeight);
|
||||
SetDefCustomHeight(0);
|
||||
SetDefCustomSize(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAttribute(domElement, AttrCustom, value);
|
||||
}
|
||||
modified = true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -654,6 +654,29 @@ void VAbstractPattern::SetGradationHeights(const QMap<GHeights, bool> &options)
|
|||
{
|
||||
case 0: // TagHeights
|
||||
SetAttribute(domElement, AttrAll, options.value(GHeights::ALL));
|
||||
if (options.value(GHeights::ALL))
|
||||
{
|
||||
domElement.removeAttribute(AttrH92);
|
||||
domElement.removeAttribute(AttrH98);
|
||||
domElement.removeAttribute(AttrH104);
|
||||
domElement.removeAttribute(AttrH110);
|
||||
domElement.removeAttribute(AttrH116);
|
||||
domElement.removeAttribute(AttrH122);
|
||||
domElement.removeAttribute(AttrH128);
|
||||
domElement.removeAttribute(AttrH134);
|
||||
domElement.removeAttribute(AttrH140);
|
||||
domElement.removeAttribute(AttrH146);
|
||||
domElement.removeAttribute(AttrH152);
|
||||
domElement.removeAttribute(AttrH158);
|
||||
domElement.removeAttribute(AttrH164);
|
||||
domElement.removeAttribute(AttrH170);
|
||||
domElement.removeAttribute(AttrH176);
|
||||
domElement.removeAttribute(AttrH182);
|
||||
domElement.removeAttribute(AttrH188);
|
||||
domElement.removeAttribute(AttrH194);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAttribute(domElement, AttrH92, options.value(GHeights::H92));
|
||||
SetAttribute(domElement, AttrH98, options.value(GHeights::H98));
|
||||
SetAttribute(domElement, AttrH104, options.value(GHeights::H104));
|
||||
|
@ -672,6 +695,7 @@ void VAbstractPattern::SetGradationHeights(const QMap<GHeights, bool> &options)
|
|||
SetAttribute(domElement, AttrH182, options.value(GHeights::H182));
|
||||
SetAttribute(domElement, AttrH188, options.value(GHeights::H188));
|
||||
SetAttribute(domElement, AttrH194, options.value(GHeights::H194));
|
||||
}
|
||||
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
|
@ -798,6 +822,29 @@ void VAbstractPattern::SetGradationSizes(const QMap<GSizes, bool> &options)
|
|||
break;
|
||||
case 1: // TagSizes
|
||||
SetAttribute(domElement, AttrAll, options.value(GSizes::ALL));
|
||||
if (options.value(GSizes::ALL))
|
||||
{
|
||||
domElement.removeAttribute(AttrS22);
|
||||
domElement.removeAttribute(AttrS24);
|
||||
domElement.removeAttribute(AttrS26);
|
||||
domElement.removeAttribute(AttrS28);
|
||||
domElement.removeAttribute(AttrS30);
|
||||
domElement.removeAttribute(AttrS32);
|
||||
domElement.removeAttribute(AttrS34);
|
||||
domElement.removeAttribute(AttrS36);
|
||||
domElement.removeAttribute(AttrS38);
|
||||
domElement.removeAttribute(AttrS40);
|
||||
domElement.removeAttribute(AttrS42);
|
||||
domElement.removeAttribute(AttrS44);
|
||||
domElement.removeAttribute(AttrS46);
|
||||
domElement.removeAttribute(AttrS48);
|
||||
domElement.removeAttribute(AttrS50);
|
||||
domElement.removeAttribute(AttrS52);
|
||||
domElement.removeAttribute(AttrS54);
|
||||
domElement.removeAttribute(AttrS56);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAttribute(domElement, AttrS22, options.value(GSizes::S22));
|
||||
SetAttribute(domElement, AttrS24, options.value(GSizes::S24));
|
||||
SetAttribute(domElement, AttrS26, options.value(GSizes::S26));
|
||||
|
@ -816,6 +863,7 @@ void VAbstractPattern::SetGradationSizes(const QMap<GSizes, bool> &options)
|
|||
SetAttribute(domElement, AttrS52, options.value(GSizes::S52));
|
||||
SetAttribute(domElement, AttrS54, options.value(GSizes::S54));
|
||||
SetAttribute(domElement, AttrS56, options.value(GSizes::S56));
|
||||
}
|
||||
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
|
@ -973,8 +1021,14 @@ void VAbstractPattern::CheckTagExists(const QString &tag)
|
|||
case 4: //TagGradation
|
||||
{
|
||||
QDomElement gradation = createElement(TagGradation);
|
||||
gradation.appendChild(createElement(TagHeights));
|
||||
gradation.appendChild(createElement(TagSizes));
|
||||
|
||||
QDomElement heights = createElement(TagHeights);
|
||||
heights.setAttribute(AttrAll, QLatin1Literal("true"));
|
||||
gradation.appendChild(heights);
|
||||
|
||||
QDomElement sizes = createElement(TagSizes);
|
||||
sizes.setAttribute(AttrAll, QLatin1Literal("true"));
|
||||
gradation.appendChild(sizes);
|
||||
|
||||
for (int i = tags.indexOf(tag)-1; i >= 0; --i)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user