Clearing old code.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-08-18 14:22:31 +03:00
parent 96df1db48e
commit f07fd426dd
9 changed files with 40 additions and 183 deletions

View File

@ -914,21 +914,6 @@ void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail)
ppData.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR));
ppData.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR));
ppData.SetLabelTemplate(GetLabelTemplate(domElement));
QDomNodeList nodeListMCP = domElement.childNodes();
for (int iMCP = 0; iMCP < nodeListMCP.count(); ++iMCP)
{
MaterialCutPlacement mcp;
QDomElement domMCP = nodeListMCP.at(iMCP).toElement();
mcp.m_eMaterial = MaterialType(GetParametrUInt(domMCP, AttrMaterial, 0));
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
mcp.m_qsMaterialUserDef = GetParametrString(domMCP, AttrUserDefined, "");
}
mcp.m_iCutNumber = static_cast<int>(GetParametrUInt(domMCP, AttrCutNumber, 0));
mcp.m_ePlacement = PlacementType(GetParametrUInt(domMCP, AttrPlacement, 0));
ppData.Append(mcp);
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -81,7 +81,6 @@ const QString VAbstractPattern::TagHeights = QStringLiteral("heights");
const QString VAbstractPattern::TagSizes = QStringLiteral("sizes");
const QString VAbstractPattern::TagData = QStringLiteral("data");
const QString VAbstractPattern::TagPatternInfo = QStringLiteral("patternInfo");
const QString VAbstractPattern::TagMCP = QStringLiteral("mcp");
const QString VAbstractPattern::TagPatternName = QStringLiteral("patternName");
const QString VAbstractPattern::TagPatternNum = QStringLiteral("patternNumber");
const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer");
@ -100,10 +99,6 @@ const QString VAbstractPattern::AttrType = QStringLiteral("type");
const QString VAbstractPattern::AttrLetter = QStringLiteral("letter");
const QString VAbstractPattern::AttrQuantity = QStringLiteral("quantity");
const QString VAbstractPattern::AttrOnFold = QStringLiteral("onFold");
const QString VAbstractPattern::AttrMaterial = QStringLiteral("material");
const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef");
const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber");
const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement");
const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows");
const QString VAbstractPattern::AttrNodeReverse = QStringLiteral("reverse");
const QString VAbstractPattern::AttrNodeExcluded = QStringLiteral("excluded");

View File

@ -203,7 +203,6 @@ public:
static const QString TagSizes;
static const QString TagData;
static const QString TagPatternInfo;
static const QString TagMCP;
static const QString TagPatternName;
static const QString TagPatternNum;
static const QString TagCompanyName;
@ -222,10 +221,6 @@ public:
static const QString AttrLetter;
static const QString AttrQuantity;
static const QString AttrOnFold;
static const QString AttrMaterial;
static const QString AttrUserDefined;
static const QString AttrCutNumber;
static const QString AttrPlacement;
static const QString AttrArrows;
static const QString AttrNodeReverse;
static const QString AttrNodeExcluded;

View File

@ -65,6 +65,7 @@ QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc)
QMap<QString, QString> placeholders;
// Pattern tags
QLocale locale(qApp->Settings()->GetLocale());
placeholders.insert(pl_date, locale.toString(QDate::currentDate()));
placeholders.insert(pl_time, locale.toString(QTime::currentTime()));
@ -94,9 +95,33 @@ QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc)
placeholders.insert(pl_height, curHeight);
placeholders.insert(pl_mExt, mExt);
// Piece tags
placeholders.insert(pl_pLetter, "");
placeholders.insert(pl_pName, "");
placeholders.insert(pl_pQuantity, "");
placeholders.insert(pl_wOnFold, "");
placeholders.insert(pl_mFabric, QObject::tr("Fabric"));
placeholders.insert(pl_mLining, QObject::tr("Lining"));
placeholders.insert(pl_mInterfacing, QObject::tr("Interfacing"));
placeholders.insert(pl_mInterlining, QObject::tr("Interlining"));
placeholders.insert(pl_wCut, QObject::tr("Cut"));
return placeholders;
}
//---------------------------------------------------------------------------------------------------------------------
void InitPiecePlaceholders(QMap<QString, QString> &placeholders, const QString &name, const VPieceLabelData& data)
{
placeholders[pl_pLetter] = data.GetLetter();
placeholders[pl_pName] = name;
placeholders[pl_pQuantity] = QString::number(data.GetQuantity());
if (data.IsOnFold())
{
placeholders[pl_wOnFold] = QObject::tr("on fold");
}
}
//---------------------------------------------------------------------------------------------------------------------
QString ReplacePlaceholders(const QMap<QString, QString> &placeholders, QString line)
{
@ -298,56 +323,17 @@ void VTextManager::Update(const QString& qsName, const VPieceLabelData& data)
{
m_liLines.clear();
TextLine tl;
// all text must be centered and normal style!
tl.m_eAlign = Qt::AlignCenter;
QMap<QString, QString> placeholders = PreparePlaceholders(qApp->getCurrentDocument());
InitPiecePlaceholders(placeholders, qsName, data);
// letter
tl.m_qsText = data.GetLetter();
if (tl.m_qsText.isEmpty() == false)
QVector<VLabelTemplateLine> lines = data.GetLabelTemplate();
for (int i=0; i<lines.size(); ++i)
{
tl.bold = true;
tl.m_iFontSize = 6;
m_liLines << tl;
}
// name
tl.m_qsText = qsName;
if (tl.m_qsText.isEmpty() == false)
{
tl.bold = true;
tl.m_iFontSize = 2;
m_liLines << tl;
}
// MCP
QStringList qslMaterials;
qslMaterials << QApplication::translate("Detail", "Fabric", nullptr)
<< QApplication::translate("Detail", "Lining", nullptr)
<< QApplication::translate("Detail", "Interfacing", nullptr)
<< QApplication::translate("Detail", "Interlining", nullptr);
QString qsText = QLatin1String("%1, ") + tr("cut") + QLatin1String(" %2%3");
QStringList qslPlace;
qslPlace << "" << QLatin1String(" ") + tr("on fold");
tl.bold = false;
tl.m_iFontSize = 0;
for (int i = 0; i < data.GetMCPCount(); ++i)
{
MaterialCutPlacement mcp = data.GetMCP(i);
if (mcp.m_iCutNumber > 0)//Not gonna happen because min value is 1 now, but decided to left
{
QString qsMat;
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
qsMat = mcp.m_qsMaterialUserDef;
}
else
{
qsMat = qslMaterials[int(mcp.m_eMaterial)];
}
tl.m_qsText = qsText.arg(qsMat).arg(mcp.m_iCutNumber).
arg(qslPlace[int(mcp.m_ePlacement)]);
m_liLines << tl;
}
lines[i].line = ReplacePlaceholders(placeholders, lines.at(i).line);
}
m_liLines = PrepareLines(lines);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -40,40 +40,5 @@ enum class ArrowType : char
atRear
};
enum class MaterialType : char
{
mtFabric = 0,
mtLining = 1,
mtInterfacing = 2,
mtInterlining = 3,
mtUserDefined = 4
};
enum class PlacementType : char
{
ptNone = 0,
ptCutOnFold = 1
};
/**
* @brief The MaterialCutPlacement struct used to hold a material, cut number and placement 3-tuple
*/
struct MaterialCutPlacement
{
MaterialType m_eMaterial;
QString m_qsMaterialUserDef;
int m_iCutNumber;
PlacementType m_ePlacement;
MaterialCutPlacement()
: m_eMaterial(MaterialType::mtFabric),
m_qsMaterialUserDef(),
m_iCutNumber(0),
m_ePlacement(PlacementType::ptNone)
{}
};
typedef QList<MaterialCutPlacement> MCPContainer;
#endif // FLOATITEMDEF_H

View File

@ -59,65 +59,20 @@ VPieceLabelData &VPieceLabelData::operator=(const VPieceLabelData &data)
VPieceLabelData::~VPieceLabelData()
{}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::Append(const MaterialCutPlacement& rMCP)
{
d->m_conMCP.append(rMCP);
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::Insert(int i, const MaterialCutPlacement& rMCP)
{
Q_ASSERT(i >= 0);
Q_ASSERT(i <= GetMCPCount());
d->m_conMCP.insert(i, rMCP);
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::Set(int i, const MaterialCutPlacement& rMCP)
{
Q_ASSERT(i >= 0);
Q_ASSERT(i < GetMCPCount());
d->m_conMCP[i] = rMCP;
}
//---------------------------------------------------------------------------------------------------------------------
int VPieceLabelData::GetMCPCount() const
{
return d->m_conMCP.count();
}
//---------------------------------------------------------------------------------------------------------------------
const MaterialCutPlacement& VPieceLabelData::GetMCP(int i) const
{
Q_ASSERT(i >= 0);
Q_ASSERT(i < GetMCPCount());
return d->m_conMCP.at(i);
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::RemoveMCP(int i)
{
Q_ASSERT(i >= 0);
Q_ASSERT(i < GetMCPCount());
d->m_conMCP.removeAt(i);
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::Clear()
{
d->m_qsLetter.clear();
d->m_conMCP.clear();
}
//---------------------------------------------------------------------------------------------------------------------
const QString& VPieceLabelData::GetLetter() const
QString VPieceLabelData::GetLetter() const
{
return d->m_qsLetter;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetLetter(QString qsLetter)
void VPieceLabelData::SetLetter(const QString &qsLetter)
{
d->m_qsLetter = qsLetter.left(3);
}

View File

@ -57,18 +57,11 @@ public:
void Swap(VPieceLabelData &data) Q_DECL_NOTHROW
{ VPatternLabelData::Swap(data); std::swap(d, data.d); }
// methods, which operate on MaterialCutPlacement container
void Append(const MaterialCutPlacement& rMCP);
void Insert(int i, const MaterialCutPlacement& rMCP);
void Set(int i, const MaterialCutPlacement& rMCP);
int GetMCPCount() const;
const MaterialCutPlacement& GetMCP(int i) const;
void RemoveMCP(int i);
void Clear();
void Clear();
// methods, which operate on other members
const QString& GetLetter() const;
void SetLetter(QString qsLetter);
QString GetLetter() const;
void SetLetter(const QString &qsLetter);
int GetQuantity() const;
void SetQuantity(int val);

View File

@ -46,7 +46,6 @@ class VPieceLabelDataPrivate : public QSharedData
public:
VPieceLabelDataPrivate()
: m_qsLetter(),
m_conMCP(),
m_quantity(1),
m_onFold(false),
m_lines()
@ -55,7 +54,6 @@ public:
VPieceLabelDataPrivate(const VPieceLabelDataPrivate &data)
: QSharedData(data),
m_qsLetter(data.m_qsLetter),
m_conMCP(data.m_conMCP),
m_quantity(data.m_quantity),
m_onFold(data.m_onFold),
m_lines(data.m_lines)
@ -65,8 +63,6 @@ public:
/** @brief m_qsLetter Detail letter (should be no more than 3 characters) */
QString m_qsLetter;
/** @brief m_conMCP List of material, cut, placement tuples */
MCPContainer m_conMCP;
int m_quantity;
bool m_onFold;

View File

@ -341,19 +341,6 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement
doc->SetLabelTemplate(domData, data.GetLabelTemplate());
for (int i = 0; i < data.GetMCPCount(); ++i)
{
const MaterialCutPlacement mcp = data.GetMCP(i);
QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP);
doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial));
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef);
}
doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber);
doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement));
domData.appendChild(domMCP);
}
domElement.appendChild(domData);
}
@ -362,7 +349,7 @@ void VToolSeamAllowance::AddPatternInfo(VAbstractPattern *doc, QDomElement &domE
{
QDomElement domData = doc->createElement(VAbstractPattern::TagPatternInfo);
const VPatternLabelData& geom = piece.GetPatternInfo();
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, geom.IsVisible() == true ? trueStr : falseStr);
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, geom.IsVisible());
doc->SetAttribute(domData, AttrMx, geom.GetPos().x());
doc->SetAttribute(domData, AttrMy, geom.GetPos().y());
doc->SetAttribute(domData, VAbstractPattern::AttrWidth, geom.GetLabelWidth());
@ -406,7 +393,7 @@ void VToolSeamAllowance::AddGrainline(VAbstractPattern *doc, QDomElement &domEle
// grainline
QDomElement domData = doc->createElement(VAbstractPattern::TagGrainline);
const VGrainlineData& glGeom = piece.GetGrainlineGeometry();
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, glGeom.IsVisible() == true ? trueStr : falseStr);
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, glGeom.IsVisible());
doc->SetAttribute(domData, AttrMx, glGeom.GetPos().x());
doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y());
doc->SetAttribute(domData, AttrLength, glGeom.GetLength());