2014-03-10 16:55:51 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vindividualmeasurements.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2014-03-10 16:55:51 +01:00
|
|
|
** @date 8 3, 2014
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2013 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "vindividualmeasurements.h"
|
2014-05-16 12:00:33 +02:00
|
|
|
#include "../widgets/vapplication.h"
|
2014-06-17 11:50:11 +02:00
|
|
|
#include <QDate>
|
2014-03-10 16:55:51 +01:00
|
|
|
|
2014-03-26 05:39:07 +01:00
|
|
|
const QString VIndividualMeasurements::TagFamily_name = QStringLiteral("family-name");
|
|
|
|
const QString VIndividualMeasurements::TagGiven_name = QStringLiteral("given-name");
|
|
|
|
const QString VIndividualMeasurements::TagBirth_date = QStringLiteral("birth-date");
|
|
|
|
const QString VIndividualMeasurements::TagSex = QStringLiteral("sex");
|
2014-05-16 12:00:33 +02:00
|
|
|
const QString VIndividualMeasurements::TagEmail = QStringLiteral("email");
|
2014-03-28 14:11:46 +01:00
|
|
|
const QString VIndividualMeasurements::SexMale = QStringLiteral("male");
|
|
|
|
const QString VIndividualMeasurements::SexFemale = QStringLiteral("female");
|
2014-03-21 11:08:29 +01:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-18 12:40:42 +02:00
|
|
|
VIndividualMeasurements::VIndividualMeasurements(VContainer *data)
|
|
|
|
:VAbstractMeasurements(data)
|
|
|
|
{
|
|
|
|
SCASSERT(data != nullptr)
|
|
|
|
}
|
2014-03-14 15:12:53 +01:00
|
|
|
|
2014-06-02 09:43:27 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VIndividualMeasurements::~VIndividualMeasurements()
|
|
|
|
{}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-12 09:22:29 +02:00
|
|
|
void VIndividualMeasurements::setUnit(const Unit &unit)
|
2014-03-26 05:39:07 +01:00
|
|
|
{
|
2014-03-28 14:11:46 +01:00
|
|
|
setTagText(TagUnit, UnitsToStr(unit));
|
2014-03-26 05:39:07 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-14 15:12:53 +01:00
|
|
|
void VIndividualMeasurements::Measurements()
|
|
|
|
{
|
2014-06-18 12:40:42 +02:00
|
|
|
VAbstractMeasurements::Measurements();
|
2014-03-14 15:12:53 +01:00
|
|
|
//heights
|
2014-05-16 13:17:25 +02:00
|
|
|
Measurement(height_M);
|
2014-05-16 12:00:33 +02:00
|
|
|
//extended
|
2014-05-16 13:17:25 +02:00
|
|
|
Measurement(size_M);
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-18 12:40:42 +02:00
|
|
|
void VIndividualMeasurements::ReadMeasurement(const QDomElement &domElement, const QString &tag)
|
2014-03-14 15:12:53 +01:00
|
|
|
{
|
2014-06-18 12:40:42 +02:00
|
|
|
qreal value = GetParametrDouble(domElement, AttrValue, "0.0");
|
2014-07-09 14:23:04 +02:00
|
|
|
value = UnitConvertor(value, MUnit(), qApp->patternUnit());
|
2014-07-29 13:28:18 +02:00
|
|
|
data->AddVariable(tag, new VMeasurement(tag, value, qApp->GuiText(tag), qApp->Description(tag), tag));
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-28 14:11:46 +01:00
|
|
|
QString VIndividualMeasurements::FamilyName() const
|
2014-03-14 15:12:53 +01:00
|
|
|
{
|
2014-03-26 05:39:07 +01:00
|
|
|
return UniqueTagText(TagFamily_name, "");
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-28 14:11:46 +01:00
|
|
|
void VIndividualMeasurements::setFamilyName(const QString &text)
|
|
|
|
{
|
|
|
|
setTagText(TagFamily_name, text);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-28 14:11:46 +01:00
|
|
|
QString VIndividualMeasurements::GivenName() const
|
2014-03-14 15:12:53 +01:00
|
|
|
{
|
2014-03-26 05:39:07 +01:00
|
|
|
return UniqueTagText(TagGiven_name, "");
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-28 14:11:46 +01:00
|
|
|
void VIndividualMeasurements::setGivenName(const QString &text)
|
|
|
|
{
|
|
|
|
setTagText(TagGiven_name, text);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-28 14:11:46 +01:00
|
|
|
QDate VIndividualMeasurements::BirthDate() const
|
2014-03-14 15:12:53 +01:00
|
|
|
{
|
2014-03-28 14:11:46 +01:00
|
|
|
const QString date = UniqueTagText(TagBirth_date, "1900-01-01");
|
|
|
|
return QDate::fromString(date, "yyyy-MM-dd");
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-28 14:11:46 +01:00
|
|
|
void VIndividualMeasurements::setBirthDate(const QDate &date)
|
2014-03-14 15:12:53 +01:00
|
|
|
{
|
2014-03-28 14:11:46 +01:00
|
|
|
setTagText(TagBirth_date, date.toString("yyyy-MM-dd"));
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-12 09:22:29 +02:00
|
|
|
SexType VIndividualMeasurements::Sex() const
|
2014-03-28 14:11:46 +01:00
|
|
|
{
|
|
|
|
return StrToGender(UniqueTagText(TagSex, ""));
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-12 09:22:29 +02:00
|
|
|
void VIndividualMeasurements::setSex(const SexType &sex)
|
2014-03-28 14:11:46 +01:00
|
|
|
{
|
|
|
|
setTagText(TagSex, GenderToStr(sex));
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-28 14:11:46 +01:00
|
|
|
QString VIndividualMeasurements::Mail() const
|
|
|
|
{
|
|
|
|
return UniqueTagText(TagEmail, "");
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-28 14:11:46 +01:00
|
|
|
void VIndividualMeasurements::setMail(const QString &text)
|
|
|
|
{
|
|
|
|
setTagText(TagEmail, text);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-12 09:22:29 +02:00
|
|
|
QString VIndividualMeasurements::GenderToStr(const SexType &sex)
|
2014-03-28 14:11:46 +01:00
|
|
|
{
|
|
|
|
switch (sex)
|
|
|
|
{
|
2014-06-12 09:22:29 +02:00
|
|
|
case SexType::Male:
|
2014-03-28 14:11:46 +01:00
|
|
|
return SexMale;
|
2014-06-12 09:22:29 +02:00
|
|
|
case SexType::Female:
|
2014-03-28 14:11:46 +01:00
|
|
|
return SexFemale;
|
|
|
|
default:
|
|
|
|
return SexMale;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-12 09:22:29 +02:00
|
|
|
SexType VIndividualMeasurements::StrToGender(const QString &sex)
|
2014-03-28 14:11:46 +01:00
|
|
|
{
|
2014-05-30 11:52:19 +02:00
|
|
|
QStringList genders{SexMale, SexFemale};
|
2014-03-28 14:11:46 +01:00
|
|
|
switch (genders.indexOf(sex))
|
|
|
|
{
|
|
|
|
case 0: // SexMale
|
2014-06-12 09:22:29 +02:00
|
|
|
return SexType::Male;
|
2014-03-28 14:11:46 +01:00
|
|
|
case 1: // SexFemale
|
2014-06-12 09:22:29 +02:00
|
|
|
return SexType::Female;
|
2014-03-28 14:11:46 +01:00
|
|
|
default:
|
2014-06-12 09:22:29 +02:00
|
|
|
return SexType::Male;
|
2014-03-28 14:11:46 +01:00
|
|
|
}
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|