Prepare base values.

This commit is contained in:
Roman Telezhynskyi 2020-10-01 16:56:44 +03:00
parent ac72a6cfa9
commit 4db0f3a420
3 changed files with 424 additions and 256 deletions

View File

@ -562,10 +562,8 @@ void TMainWindow::changeEvent(QEvent *event)
if (mType == MeasurementsType::Multisize) if (mType == MeasurementsType::Multisize)
{ {
ui->labelMType->setText(tr("Multisize measurements")); ui->labelMType->setText(tr("Multisize measurements"));
ui->labelBaseSizeValue->setText(QString().setNum(m->DimensionABase()) + QChar(QChar::Space) +
UnitsToStr(m->MUnit(), true)); RetranslateDimensionBaseValues();
ui->labelBaseHeightValue->setText(QString().setNum(m->DimensionBBase()) + QChar(QChar::Space) +
UnitsToStr(m->MUnit(), true));
labelGradationHeights->setText(tr("Height (%1):").arg(UnitsToStr(mUnit))); labelGradationHeights->setText(tr("Height (%1):").arg(UnitsToStr(mUnit)));
labelGradationSizes->setText(tr("Size (%1):").arg(UnitsToStr(mUnit))); labelGradationSizes->setText(tr("Size (%1):").arg(UnitsToStr(mUnit)));
@ -2017,7 +2015,7 @@ void TMainWindow::InitWindow()
SCASSERT(m != nullptr) SCASSERT(m != nullptr)
ui->labelToolTip->setVisible(false); ui->labelToolTip->setVisible(false);
ui->tabWidget->setVisible(true); ui->tabWidget->setVisible(true);
ui->tabWidget->setCurrentIndex(0); ui->tabWidget->setCurrentIndex(0); // measurements
ui->plainTextEditNotes->setEnabled(true); ui->plainTextEditNotes->setEnabled(true);
ui->toolBarGradation->setVisible(true); ui->toolBarGradation->setVisible(true);
@ -2025,10 +2023,8 @@ void TMainWindow::InitWindow()
if (mType == MeasurementsType::Multisize) if (mType == MeasurementsType::Multisize)
{ {
ui->labelMType->setText(tr("Multisize measurements")); ui->labelMType->setText(tr("Multisize measurements"));
ui->labelBaseSizeValue->setText(QString().setNum(m->DimensionABase()) + QChar(QChar::Space) +
UnitsToStr(m->MUnit(), true)); InitDimensionsBaseValue();
ui->labelBaseHeightValue->setText(QString().setNum(m->DimensionBBase()) + QChar(QChar::Space) +
UnitsToStr(m->MUnit(), true));
// Because Qt Designer doesn't know about our deleting we will create empty objects for correct // Because Qt Designer doesn't know about our deleting we will create empty objects for correct
// working the retranslation UI // working the retranslation UI
@ -2091,10 +2087,14 @@ void TMainWindow::InitWindow()
HackWidget(&ui->labelInHeights); HackWidget(&ui->labelInHeights);
// Tab Information // Tab Information
HackWidget(&ui->labelBaseSize); HackWidget(&ui->labelDimensionA);
HackWidget(&ui->labelBaseSizeValue); HackWidget(&ui->labelDimensionABase);
HackWidget(&ui->labelBaseHeight); HackWidget(&ui->labelDimensionB);
HackWidget(&ui->labelBaseHeightValue); HackWidget(&ui->labelDimensionBBase);
HackWidget(&ui->labelDimensionC);
HackWidget(&ui->labelDimensionCBase);
HackWidget(&ui->frameBaseValue);
HackWidget(&ui->labelBaseValues);
ui->lineEditCustomerName->setText(m->Customer()); ui->lineEditCustomerName->setText(m->Customer());
@ -2179,6 +2179,44 @@ void TMainWindow::InitWindow()
InitTable(); InitTable();
} }
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::InitDimensionsBaseValue()
{
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
const QString unit = UnitsToStr(m->MUnit(), true);
auto DimensionsBaseValue = [this, dimensions, unit](int index, QLabel *name, QLabel *base)
{
SCASSERT(name != nullptr)
SCASSERT(base != nullptr)
if (dimensions.size() > index)
{
MeasurementDimension_p dimension = dimensions.at(index);
name->setText(DimensionName(dimension->Type())+QChar(':'));
name->setToolTip(DimensionToolTip(dimension->Type(), dimension->IsCircumference()));
if (dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X)
{
base->setText(QString("%1 %2").arg(dimension->BaseValue()).arg(unit));
}
else
{
base->setText(QString::number(dimension->BaseValue()));
}
}
else
{
HackWidget(&name);
HackWidget(&base);
}
};
DimensionsBaseValue(0, ui->labelDimensionA, ui->labelDimensionABase);
DimensionsBaseValue(1, ui->labelDimensionB, ui->labelDimensionBBase);
DimensionsBaseValue(2, ui->labelDimensionC, ui->labelDimensionCBase);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::InitTable() void TMainWindow::InitTable()
{ {
@ -3306,6 +3344,84 @@ void TMainWindow::SetCurrentPatternUnit()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString TMainWindow::DimensionName(MeasurementDimension type)
{
switch(type)
{
case MeasurementDimension::X:
return tr("Height");
case MeasurementDimension::Y:
return tr("Size");
case MeasurementDimension::W:
return tr("Hip");
case MeasurementDimension::Z:
return tr("Waist");
default:
return QString();
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::RetranslateDimensionBaseValues()
{
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
const QString unit = UnitsToStr(m->MUnit(), true);
auto DimensionsBaseValue = [this, dimensions, unit](int index, QLabel *name, QLabel *base)
{
SCASSERT(name != nullptr)
SCASSERT(base != nullptr)
if (dimensions.size() > index)
{
MeasurementDimension_p dimension = dimensions.at(index);
name->setText(DimensionName(dimension->Type())+QChar(':'));
name->setToolTip(DimensionToolTip(dimension->Type(), dimension->IsCircumference()));
if (dimension->IsCircumference())
{
base->setText(QString("%1 %2").arg(dimension->BaseValue()).arg(unit));
}
else
{
base->setText(QString::number(dimension->BaseValue()));
}
}
};
DimensionsBaseValue(0, ui->labelDimensionA, ui->labelDimensionABase);
DimensionsBaseValue(1, ui->labelDimensionC, ui->labelDimensionCBase);
DimensionsBaseValue(2, ui->labelDimensionB, ui->labelDimensionBBase);
}
//---------------------------------------------------------------------------------------------------------------------
QString TMainWindow::DimensionToolTip(MeasurementDimension type, bool circumference)
{
const bool fc = m->IsFullCircumference();
switch(type)
{
case MeasurementDimension::X:
return tr("Height");
case MeasurementDimension::Y:
if (circumference)
{
return fc ? tr("Chest full circumference") : tr("Chest half circumference");
}
else
{
return tr("Size");
}
return circumference ? tr("Chest circumference") : tr("Size");
case MeasurementDimension::W:
return fc ? tr("Hip full circumference") : tr("Hip half circumference");
case MeasurementDimension::Z:
return fc ? tr("Waist full circumference") : tr("Waist half circumference");
default:
return QString();
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SetDecimals() void TMainWindow::SetDecimals()
{ {

View File

@ -155,6 +155,7 @@ private:
void SetupMenu(); void SetupMenu();
void InitWindow(); void InitWindow();
void InitDimensionsBaseValue();
void InitTable(); void InitTable();
void SetDecimals(); void SetDecimals();
void InitUnits(); void InitUnits();
@ -218,6 +219,11 @@ private:
void ImportMultisizeMeasurements(const QxtCsvModel &csv); void ImportMultisizeMeasurements(const QxtCsvModel &csv);
void SetCurrentPatternUnit(); void SetCurrentPatternUnit();
QString DimensionName(MeasurementDimension type);
QString DimensionToolTip(MeasurementDimension type, bool circumference);
void RetranslateDimensionBaseValues();
}; };
#endif // TMAINWINDOW_H #endif // TMAINWINDOW_H

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>835</width> <width>1034</width>
<height>726</height> <height>896</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -24,7 +24,7 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QLabel" name="labelToolTip"> <widget class="QLabel" name="labelToolTip">
<property name="sizePolicy"> <property name="sizePolicy">
@ -47,7 +47,7 @@
<string/> <string/>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tabMeasurements"> <widget class="QWidget" name="tabMeasurements">
<attribute name="icon"> <attribute name="icon">
@ -572,7 +572,12 @@
<attribute name="title"> <attribute name="title">
<string>Information</string> <string>Information</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout_2"> <layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_21"> <widget class="QLabel" name="label_21">
<property name="text"> <property name="text">
@ -666,41 +671,29 @@
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="labelBaseSize"> <widget class="QLabel" name="labelBaseValues">
<property name="text"> <property name="sizePolicy">
<string>Base size:</string> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="labelBaseSizeValue">
<property name="text"> <property name="text">
<string>Base size value</string> <string>Base Values:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="labelBaseHeight">
<property name="text">
<string>Base height:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="labelBaseHeightValue">
<property name="text">
<string>Base height value</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="labelCustomerName"> <widget class="QLabel" name="labelCustomerName">
<property name="text"> <property name="text">
<string>Customer name:</string> <string>Customer name:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="4" column="1">
<widget class="QLineEdit" name="lineEditCustomerName"> <widget class="QLineEdit" name="lineEditCustomerName">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -716,20 +709,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="5" column="0">
<widget class="QLabel" name="labelBirthDate"> <widget class="QLabel" name="labelBirthDate">
<property name="text"> <property name="text">
<string>Birth date:</string> <string>Birth date:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="5" column="1">
<widget class="QDateEdit" name="dateEditBirthDate"> <widget class="QDateEdit" name="dateEditBirthDate">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -758,14 +751,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="6" column="0">
<widget class="QLabel" name="labelGender"> <widget class="QLabel" name="labelGender">
<property name="text"> <property name="text">
<string>Gender:</string> <string>Gender:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="6" column="1">
<widget class="QComboBox" name="comboBoxGender"> <widget class="QComboBox" name="comboBoxGender">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -776,22 +769,16 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget> </widget>
</item> </item>
<item row="8" column="0"> <item row="7" column="0">
<widget class="QLabel" name="labelEmail"> <widget class="QLabel" name="labelEmail">
<property name="text"> <property name="text">
<string>Email:</string> <string>Email:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="7" column="1">
<widget class="QLineEdit" name="lineEditEmail"> <widget class="QLineEdit" name="lineEditEmail">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -807,14 +794,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0"> <item row="8" column="0">
<widget class="QLabel" name="labelNotes"> <widget class="QLabel" name="labelNotes">
<property name="text"> <property name="text">
<string>Notes:</string> <string>Notes:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="8" column="1">
<widget class="VPlainTextEdit" name="plainTextEditNotes"> <widget class="VPlainTextEdit" name="plainTextEditNotes">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -827,6 +814,65 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1">
<widget class="QFrame" name="frameBaseValue">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<layout class="QFormLayout" name="formLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="labelDimensionA">
<property name="text">
<string notr="true">A</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelDimensionABase">
<property name="text">
<string notr="true">Base</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelDimensionB">
<property name="text">
<string notr="true">B</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelDimensionBBase">
<property name="text">
<string notr="true">Base</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelDimensionC">
<property name="text">
<string notr="true">C</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="labelDimensionCBase">
<property name="text">
<string notr="true">Base</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
@ -838,8 +884,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>835</width> <width>1034</width>
<height>22</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">