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,261 +572,307 @@
<attribute name="title"> <attribute name="title">
<string>Information</string> <string>Information</string>
</attribute> </attribute>
<layout class="QFormLayout" name="formLayout_2"> <layout class="QVBoxLayout" name="verticalLayout">
<item row="0" column="0"> <item>
<widget class="QLabel" name="label_21"> <layout class="QFormLayout" name="formLayout_2">
<property name="text"> <property name="fieldGrowthPolicy">
<string>Type:</string> <enum>QFormLayout::ExpandingFieldsGrow</enum>
</property> </property>
</widget> <item row="0" column="0">
</item> <widget class="QLabel" name="label_21">
<item row="0" column="1"> <property name="text">
<widget class="QLabel" name="labelMType"> <string>Type:</string>
<property name="text">
<string>Measurement type</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayoutPath">
<item>
<widget class="QLineEdit" name="lineEditPathToFile">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background: transparent;</string>
</property>
<property name="frame">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string notr="true">Path to the measurement file</string>
</property> </property>
</widget> </widget>
</item> </item>
<item alignment="Qt::AlignRight"> <item row="0" column="1">
<widget class="QPushButton" name="pushButtonShowInExplorer"> <widget class="QLabel" name="labelMType">
<property name="text">
<string>Measurement type</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayoutPath">
<item>
<widget class="QLineEdit" name="lineEditPathToFile">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background: transparent;</string>
</property>
<property name="frame">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string notr="true">Path to the measurement file</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QPushButton" name="pushButtonShowInExplorer">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Show in Explorer</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelPMSystem">
<property name="text">
<string>PM system:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxPMSystem">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelBaseValues">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Show in Explorer</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">
<widget class="QLabel" name="labelCustomerName">
<property name="text">
<string>Customer name:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditCustomerName">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>Customer's name</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="labelBirthDate">
<property name="text">
<string>Birth date:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDateEdit" name="dateEditBirthDate">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>124</width>
<height>0</height>
</size>
</property>
<property name="displayFormat">
<string notr="true">yyyy-MM-dd</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
<property name="currentSectionIndex">
<number>0</number>
</property>
<property name="date">
<date>
<year>1800</year>
<month>1</month>
<day>1</day>
</date>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelGender">
<property name="text">
<string>Gender:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="comboBoxGender">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="labelEmail">
<property name="text">
<string>Email:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="lineEditEmail">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>Customer's email address</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="labelNotes">
<property name="text">
<string>Notes:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="VPlainTextEdit" name="plainTextEditNotes">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
</widget>
</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> </layout>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="labelPMSystem">
<property name="text">
<string>PM system:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxPMSystem">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelBaseSize">
<property name="text">
<string>Base size:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="labelBaseSizeValue">
<property name="text">
<string>Base size value</string>
</property>
</widget>
</item>
<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">
<property name="text">
<string>Customer name:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditCustomerName">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>Customer's name</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelBirthDate">
<property name="text">
<string>Birth date:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QDateEdit" name="dateEditBirthDate">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>124</width>
<height>0</height>
</size>
</property>
<property name="displayFormat">
<string notr="true">yyyy-MM-dd</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
<property name="currentSectionIndex">
<number>0</number>
</property>
<property name="date">
<date>
<year>1800</year>
<month>1</month>
<day>1</day>
</date>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="labelGender">
<property name="text">
<string>Gender:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QComboBox" name="comboBoxGender">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="labelEmail">
<property name="text">
<string>Email:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="lineEditEmail">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>Customer's email address</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="labelNotes">
<property name="text">
<string>Notes:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="VPlainTextEdit" name="plainTextEditNotes">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
</widget>
</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">