2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file vincrementtablerow.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2013-11-15 13:41:26 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
2014-03-19 19:27:11 +01:00
|
|
|
#include "vincrement.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../vmisc/def.h"
|
2014-08-20 18:31:15 +02:00
|
|
|
#include "vincrement_p.h"
|
2023-07-15 09:58:28 +02:00
|
|
|
#include "vvariable.h"
|
2013-07-17 13:38:11 +02:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-01 09:35:13 +02:00
|
|
|
/**
|
|
|
|
* @brief VIncrement create enpty increment
|
|
|
|
*/
|
2014-03-19 19:27:11 +01:00
|
|
|
VIncrement::VIncrement()
|
2023-07-15 09:58:28 +02:00
|
|
|
: VVariable(),
|
|
|
|
d(new VIncrementData)
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2014-08-20 17:58:10 +02:00
|
|
|
SetType(VarType::Increment);
|
2014-07-29 13:28:18 +02:00
|
|
|
}
|
2013-07-17 13:38:11 +02:00
|
|
|
|
2014-06-01 09:35:13 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief VIncrementTableRow create increment
|
2014-07-29 13:28:18 +02:00
|
|
|
* @param name increment's name
|
2014-06-01 09:35:13 +02:00
|
|
|
*/
|
2019-01-16 15:24:41 +01:00
|
|
|
VIncrement::VIncrement(VContainer *data, const QString &name, IncrementType incrType)
|
2023-07-15 09:58:28 +02:00
|
|
|
: VVariable(name, QString()),
|
|
|
|
d(new VIncrementData(data, incrType))
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2019-01-16 15:24:41 +01:00
|
|
|
incrType == IncrementType::Separator ? SetType(VarType::IncrementSeparator) : SetType(VarType::Increment);
|
2014-07-29 13:28:18 +02:00
|
|
|
}
|
2014-03-19 19:27:11 +01:00
|
|
|
|
2014-06-04 13:50:13 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-07-15 09:58:28 +02:00
|
|
|
COPY_CONSTRUCTOR_IMPL_2(VIncrement, VVariable)
|
2014-06-04 13:50:13 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VIncrement::operator=(const VIncrement &incr) -> VIncrement &
|
2014-06-04 13:50:13 +02:00
|
|
|
{
|
2023-07-15 09:58:28 +02:00
|
|
|
if (&incr == this)
|
2014-07-27 14:30:28 +02:00
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
2014-07-09 14:23:04 +02:00
|
|
|
VVariable::operator=(incr);
|
2014-08-20 18:31:15 +02:00
|
|
|
d = incr.d;
|
2014-06-04 13:50:13 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2019-12-30 12:00:57 +01:00
|
|
|
#ifdef Q_COMPILER_RVALUE_REFS
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-07-13 16:49:20 +02:00
|
|
|
VIncrement::VIncrement(VIncrement &&incr) noexcept
|
2023-07-15 09:58:28 +02:00
|
|
|
: VVariable(std::move(incr)),
|
|
|
|
d(std::move(incr.d))
|
|
|
|
{
|
|
|
|
}
|
2019-12-30 12:00:57 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-07-15 09:58:28 +02:00
|
|
|
auto VIncrement::operator=(VIncrement &&incr) noexcept -> VIncrement &
|
2019-12-30 12:00:57 +01:00
|
|
|
{
|
2019-12-30 16:13:18 +01:00
|
|
|
VVariable::operator=(incr);
|
2019-12-30 12:00:57 +01:00
|
|
|
std::swap(d, incr.d);
|
2019-12-30 16:13:18 +01:00
|
|
|
return *this;
|
2019-12-30 12:00:57 +01:00
|
|
|
}
|
2019-12-30 16:13:18 +01:00
|
|
|
#endif
|
2019-12-30 12:00:57 +01:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-07-15 09:58:28 +02:00
|
|
|
VIncrement::~VIncrement() = default;
|
2014-08-20 18:31:15 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
2017-09-27 10:53:17 +02:00
|
|
|
* @brief getIndex return index of row. Row index for increments and preview calucalations is unique. Check type before
|
|
|
|
* using.
|
2015-08-25 12:35:50 +02:00
|
|
|
* @return index
|
2014-08-20 18:31:15 +02:00
|
|
|
*/
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VIncrement::GetIndex() const -> quint32
|
2014-08-20 18:31:15 +02:00
|
|
|
{
|
2015-08-25 12:35:50 +02:00
|
|
|
return d->index;
|
2014-08-20 18:31:15 +02:00
|
|
|
}
|
|
|
|
|
2019-01-16 15:24:41 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VIncrement::SetFormula(qreal base, const QString &formula, bool ok)
|
|
|
|
{
|
|
|
|
VInternalVariable::SetValue(base);
|
|
|
|
d->formula = formula;
|
|
|
|
d->formulaOk = ok;
|
|
|
|
}
|
|
|
|
|
2014-08-20 18:31:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VIncrement::GetFormula() const -> QString
|
2015-08-25 12:35:50 +02:00
|
|
|
{
|
|
|
|
return d->formula;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VIncrement::IsFormulaOk() const -> bool
|
2015-08-25 12:35:50 +02:00
|
|
|
{
|
|
|
|
return d->formulaOk;
|
|
|
|
}
|
|
|
|
|
2019-01-16 15:24:41 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VIncrement::SetIndex(quint32 index)
|
|
|
|
{
|
|
|
|
d->index = index;
|
|
|
|
}
|
|
|
|
|
2015-08-25 12:35:50 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VIncrement::GetData() -> VContainer *
|
2014-08-20 18:31:15 +02:00
|
|
|
{
|
2018-09-18 15:38:16 +02:00
|
|
|
return d->data.data();
|
2014-08-20 18:31:15 +02:00
|
|
|
}
|
2017-09-02 13:47:44 +02:00
|
|
|
|
2019-01-16 15:24:41 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VIncrement::GetIncrementType() const -> IncrementType
|
2019-01-16 15:24:41 +01:00
|
|
|
{
|
|
|
|
return d->incrType;
|
|
|
|
}
|
|
|
|
|
2017-09-02 13:47:44 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VIncrement::IsPreviewCalculation() const -> bool
|
2017-09-02 13:47:44 +02:00
|
|
|
{
|
|
|
|
return d->previewCalculation;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VIncrement::SetPreviewCalculation(bool value)
|
|
|
|
{
|
|
|
|
d->previewCalculation = value;
|
|
|
|
}
|
2022-08-03 19:05:09 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VIncrement::IsSpecialUnits() const -> bool
|
2022-08-03 19:05:09 +02:00
|
|
|
{
|
|
|
|
return d->specialUnits;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VIncrement::SetSpecialUnits(bool special)
|
|
|
|
{
|
|
|
|
d->specialUnits = special;
|
|
|
|
}
|