Moving, resizing and editing both labels now works
--HG-- branch : feature
This commit is contained in:
parent
1c7c962dc3
commit
80fcf30776
|
@ -138,7 +138,7 @@ void VPattern::Parse(const Document &parse)
|
||||||
QStringList tags = QStringList() << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes
|
QStringList tags = QStringList() << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes
|
||||||
<< TagMeasurements << TagVersion << TagGradation << TagImage << TagUnit
|
<< TagMeasurements << TagVersion << TagGradation << TagImage << TagUnit
|
||||||
<< TagPatternName << TagPatternNum << TagCompanyName << TagCustomerName
|
<< TagPatternName << TagPatternNum << TagCompanyName << TagCustomerName
|
||||||
<< TagCreationDate;
|
<< TagCreationDate << TagLabelPos << TagLabelWidth << TagLabelFont;
|
||||||
PrepareForParse(parse);
|
PrepareForParse(parse);
|
||||||
QDomNode domNode = documentElement().firstChild();
|
QDomNode domNode = documentElement().firstChild();
|
||||||
while (domNode.isNull() == false)
|
while (domNode.isNull() == false)
|
||||||
|
@ -213,6 +213,15 @@ void VPattern::Parse(const Document &parse)
|
||||||
case 14: // TagCreationDate
|
case 14: // TagCreationDate
|
||||||
qCDebug(vXML, "Creation date.");
|
qCDebug(vXML, "Creation date.");
|
||||||
break;
|
break;
|
||||||
|
case 15: // TagLabelPos
|
||||||
|
qCDebug(vXML, "Label position.");
|
||||||
|
break;
|
||||||
|
case 16: // TagLabelWidth
|
||||||
|
qCDebug(vXML, "Label width.");
|
||||||
|
break;
|
||||||
|
case 17: // TagLabelFont
|
||||||
|
qCDebug(vXML, "Label font size.");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qCDebug(vXML, "Wrong tag name %s", qUtf8Printable(domElement.tagName()));
|
qCDebug(vXML, "Wrong tag name %s", qUtf8Printable(domElement.tagName()));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -67,7 +67,9 @@ const QString VAbstractPattern::TagPatternNum = QStringLiteral("patternNumber"
|
||||||
const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer");
|
const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer");
|
||||||
const QString VAbstractPattern::TagCompanyName = QStringLiteral("company");
|
const QString VAbstractPattern::TagCompanyName = QStringLiteral("company");
|
||||||
const QString VAbstractPattern::TagCreationDate = QStringLiteral("created");
|
const QString VAbstractPattern::TagCreationDate = QStringLiteral("created");
|
||||||
const QString VAbstractPattern::TagPatternLabel = QStringLiteral("patternLabel");
|
const QString VAbstractPattern::TagLabelPos = QStringLiteral("labelPosition");
|
||||||
|
const QString VAbstractPattern::TagLabelWidth = QStringLiteral("labelWidth");
|
||||||
|
const QString VAbstractPattern::TagLabelFont = QStringLiteral("fontSize");
|
||||||
|
|
||||||
const QString VAbstractPattern::AttrName = QStringLiteral("name");
|
const QString VAbstractPattern::AttrName = QStringLiteral("name");
|
||||||
const QString VAbstractPattern::AttrVisible = QStringLiteral("visible");
|
const QString VAbstractPattern::AttrVisible = QStringLiteral("visible");
|
||||||
|
@ -79,8 +81,6 @@ const QString VAbstractPattern::AttrMaterial = QStringLiteral("material");
|
||||||
const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef");
|
const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef");
|
||||||
const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber");
|
const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber");
|
||||||
const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement");
|
const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement");
|
||||||
const QString VAbstractPattern::AttrWidth = QStringLiteral("width");
|
|
||||||
const QString VAbstractPattern::AttrFont = QStringLiteral("font");
|
|
||||||
|
|
||||||
const QString VAbstractPattern::AttrAll = QStringLiteral("all");
|
const QString VAbstractPattern::AttrAll = QStringLiteral("all");
|
||||||
|
|
||||||
|
@ -1081,21 +1081,19 @@ QDate VAbstractPattern::GetCreationDate() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPointF VAbstractPattern::GetLabelPosition() const
|
QPointF VAbstractPattern::GetLabelPosition() const
|
||||||
{
|
{
|
||||||
QPointF ptPos(0.0, 0.0);
|
QStringList qsl = UniqueTagText(TagLabelPos).split(",");
|
||||||
QDomNodeList li = elementsByTagName(TagPatternLabel);
|
QPointF ptPos(0, 0);
|
||||||
if (li.count() == 0)
|
if (qsl.count() == 2)
|
||||||
{
|
{
|
||||||
return ptPos;
|
bool bOKX;
|
||||||
}
|
bool bOKY;
|
||||||
|
double fX = qsl[0].toDouble(&bOKX);
|
||||||
QDomNamedNodeMap attr = li.at(0).attributes();
|
double fY = qsl[1].toDouble(&bOKY);
|
||||||
if (attr.contains(AttrMx) == true)
|
if (bOKX == true && bOKY == true)
|
||||||
{
|
{
|
||||||
ptPos.setX(attr.namedItem(AttrMx).nodeValue().toDouble());
|
ptPos.setX(fX);
|
||||||
}
|
ptPos.setY(fY);
|
||||||
if (attr.contains(AttrMy) == true)
|
}
|
||||||
{
|
|
||||||
ptPos.setY(attr.namedItem(AttrMy).nodeValue().toDouble());
|
|
||||||
}
|
}
|
||||||
return ptPos;
|
return ptPos;
|
||||||
}
|
}
|
||||||
|
@ -1103,28 +1101,20 @@ QPointF VAbstractPattern::GetLabelPosition() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractPattern::SetLabelPosition(const QPointF& ptPos)
|
void VAbstractPattern::SetLabelPosition(const QPointF& ptPos)
|
||||||
{
|
{
|
||||||
CheckTagExists(TagPatternLabel);
|
CheckTagExists(TagLabelPos);
|
||||||
QDomNode node = elementsByTagName(TagPatternLabel).at(0);
|
setTagText(TagLabelPos, QString::number(ptPos.x(), 'f', 3) + "," + QString::number(ptPos.y(), 'f', 3));
|
||||||
node.toElement().setAttribute(AttrMx, ptPos.x());
|
modified = true;
|
||||||
node.toElement().setAttribute(AttrMy, ptPos.y());
|
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
|
|
||||||
qDebug() << "LABEL POSITION" << GetLabelPosition();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
qreal VAbstractPattern::GetLabelWidth() const
|
qreal VAbstractPattern::GetLabelWidth() const
|
||||||
{
|
{
|
||||||
qreal fW = 0.0;
|
bool bOK;
|
||||||
QDomNodeList li = elementsByTagName(TagPatternLabel);
|
qreal fW = UniqueTagText(TagLabelWidth).toDouble(&bOK);
|
||||||
if (li.count() == 0)
|
if (bOK == false)
|
||||||
{
|
{
|
||||||
return fW;
|
fW = 0;
|
||||||
}
|
|
||||||
QDomNamedNodeMap attr = li.at(0).attributes();
|
|
||||||
if (attr.contains(AttrWidth) == true)
|
|
||||||
{
|
|
||||||
fW = attr.namedItem(AttrWidth).nodeName().toDouble();
|
|
||||||
}
|
}
|
||||||
return fW;
|
return fW;
|
||||||
}
|
}
|
||||||
|
@ -1132,25 +1122,20 @@ qreal VAbstractPattern::GetLabelWidth() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractPattern::SetLabelWidth(qreal fW)
|
void VAbstractPattern::SetLabelWidth(qreal fW)
|
||||||
{
|
{
|
||||||
CheckTagExists(TagPatternLabel);
|
CheckTagExists(TagLabelWidth);
|
||||||
QDomNode node = elementsByTagName(TagPatternLabel).at(0);
|
setTagText(TagLabelWidth, QString::number(fW, 'f', 3));
|
||||||
node.toElement().setAttribute(AttrWidth, fW);
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
int VAbstractPattern::GetFontSize() const
|
int VAbstractPattern::GetFontSize() const
|
||||||
{
|
{
|
||||||
int iFS = 0;
|
bool bOK;
|
||||||
QDomNodeList li = elementsByTagName(TagPatternLabel);
|
int iFS = UniqueTagText(TagLabelFont).toInt(&bOK);
|
||||||
if (li.count() == 0)
|
if (bOK == false)
|
||||||
{
|
{
|
||||||
return iFS;
|
iFS = 0;
|
||||||
}
|
|
||||||
QDomNamedNodeMap attr = li.at(0).attributes();
|
|
||||||
if (attr.contains(AttrFont) == true)
|
|
||||||
{
|
|
||||||
iFS = attr.namedItem(AttrFont).nodeName().toInt();
|
|
||||||
}
|
}
|
||||||
return iFS;
|
return iFS;
|
||||||
}
|
}
|
||||||
|
@ -1158,9 +1143,9 @@ int VAbstractPattern::GetFontSize() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractPattern::SetFontSize(int iFS)
|
void VAbstractPattern::SetFontSize(int iFS)
|
||||||
{
|
{
|
||||||
CheckTagExists(TagPatternLabel);
|
CheckTagExists(TagLabelFont);
|
||||||
QDomNode node = elementsByTagName(TagPatternLabel).at(0);
|
setTagText(TagLabelFont, QString::number(iFS));
|
||||||
node.toElement().setAttribute(AttrWidth, iFS);
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1289,7 +1274,8 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
|
||||||
{
|
{
|
||||||
const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes
|
const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes
|
||||||
<< TagGradation << TagPatternName << TagPatternNum << TagCompanyName
|
<< TagGradation << TagPatternName << TagPatternNum << TagCompanyName
|
||||||
<< TagCustomerName << TagCreationDate << TagPatternLabel;
|
<< TagCustomerName << TagCreationDate << TagLabelPos << TagLabelWidth
|
||||||
|
<< TagLabelFont;
|
||||||
switch (tags.indexOf(tag))
|
switch (tags.indexOf(tag))
|
||||||
{
|
{
|
||||||
case 0: //TagUnit
|
case 0: //TagUnit
|
||||||
|
@ -1357,7 +1343,17 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
|
||||||
}
|
}
|
||||||
case 11:
|
case 11:
|
||||||
{
|
{
|
||||||
element = createElement(TagPatternLabel);
|
element = createElement(TagLabelPos);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 12:
|
||||||
|
{
|
||||||
|
element = createElement(TagLabelWidth);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 13:
|
||||||
|
{
|
||||||
|
element = createElement(TagLabelFont);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,9 @@ public:
|
||||||
static const QString TagCompanyName;
|
static const QString TagCompanyName;
|
||||||
static const QString TagCustomerName;
|
static const QString TagCustomerName;
|
||||||
static const QString TagCreationDate;
|
static const QString TagCreationDate;
|
||||||
static const QString TagPatternLabel;
|
static const QString TagLabelPos;
|
||||||
|
static const QString TagLabelWidth;
|
||||||
|
static const QString TagLabelFont;
|
||||||
|
|
||||||
static const QString AttrName;
|
static const QString AttrName;
|
||||||
static const QString AttrVisible;
|
static const QString AttrVisible;
|
||||||
|
@ -191,8 +193,6 @@ public:
|
||||||
static const QString AttrUserDefined;
|
static const QString AttrUserDefined;
|
||||||
static const QString AttrCutNumber;
|
static const QString AttrCutNumber;
|
||||||
static const QString AttrPlacement;
|
static const QString AttrPlacement;
|
||||||
static const QString AttrWidth;
|
|
||||||
static const QString AttrFont;
|
|
||||||
|
|
||||||
static const QString AttrAll;
|
static const QString AttrAll;
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,7 @@ void VTextGraphicsItem::Reset()
|
||||||
{
|
{
|
||||||
m_eMode = mNormal;
|
m_eMode = mNormal;
|
||||||
UpdateFont();
|
UpdateFont();
|
||||||
|
setZValue(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -174,6 +175,7 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
|
||||||
{
|
{
|
||||||
m_eMode = mMove;
|
m_eMode = mMove;
|
||||||
}
|
}
|
||||||
|
setZValue(3);
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
|
|
||||||
connect(scene, &VMainGraphicsScene::EnableToolMove, this, &VToolDetail::EnableToolMove);
|
connect(scene, &VMainGraphicsScene::EnableToolMove, this, &VToolDetail::EnableToolMove);
|
||||||
connect(scene, &VMainGraphicsScene::MouseLeftPressed, this, &VToolDetail::ResetChild);
|
connect(scene, &VMainGraphicsScene::MouseLeftPressed, this, &VToolDetail::ResetChildren);
|
||||||
if (typeCreation == Source::FromGui || typeCreation == Source::FromTool)
|
if (typeCreation == Source::FromGui || typeCreation == Source::FromTool)
|
||||||
{
|
{
|
||||||
AddToFile();
|
AddToFile();
|
||||||
|
@ -942,9 +942,10 @@ void VToolDetail::AllowSelecting(bool enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolDetail::ResetChild()
|
void VToolDetail::ResetChildren()
|
||||||
{
|
{
|
||||||
dataLabel->Reset();
|
dataLabel->Reset();
|
||||||
|
patternInfo->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -91,7 +91,7 @@ public slots:
|
||||||
void EnableToolMove(bool move);
|
void EnableToolMove(bool move);
|
||||||
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
||||||
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
|
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
|
||||||
virtual void ResetChild();
|
virtual void ResetChildren();
|
||||||
virtual void UpdateAll();
|
virtual void UpdateAll();
|
||||||
protected:
|
protected:
|
||||||
virtual void AddToFile () Q_DECL_OVERRIDE;
|
virtual void AddToFile () Q_DECL_OVERRIDE;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user