Fixed some code style errors and checking label position at resizing

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-07-14 02:59:42 +02:00
parent 634d8773de
commit ea9cdd46b2
7 changed files with 28 additions and 18 deletions

View file

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<pattern>
<!--Valentina pattern format.-->
<version>0.3.2</version>
<version>0.2.4</version>
<unit>cm</unit>
<author/>
<description/>

View file

@ -90,9 +90,13 @@ int VPatternInfoGeometry::GetFontSize() const
void VPatternInfoGeometry::SetFontSize(int iSize)
{
if (iSize >= MIN_FONT_SIZE)
{
m_iFontSize = iSize;
}
else
{
m_iFontSize = MIN_FONT_SIZE;
}
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -152,9 +152,13 @@ int VPatternPieceData::GetFontSize() const
void VPatternPieceData::SetFontSize(int iSize)
{
if (iSize >= MIN_FONT_SIZE)
{
m_iFontSize = iSize;
}
else
{
m_iFontSize = MIN_FONT_SIZE;
}
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -175,7 +175,9 @@ void VTextGraphicsItem::SetSize(qreal fW, qreal fH)
{
// don't allow resize under specific size
if (fW < MIN_W || fH < m_iMinH)
{
return;
}
m_rectBoundingBox.setTopLeft(QPointF(0, 0));
m_rectBoundingBox.setWidth(fW);
@ -293,16 +295,14 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
{
QPointF pt = m_ptStartPos;
rectBB.setTopLeft(pt);
QSize sz(m_szStart.width() + ptDiff.x(), m_szStart.height() + ptDiff.y());
QSizeF sz(m_szStart.width() + ptDiff.x(), m_szStart.height() + ptDiff.y());
rectBB.setSize(sz);
if (IsContained(rectBB, rotation(), dX, dY) == false) {
sz.setWidth(sz.width() + dX);
sz.setHeight(sz.height() + dY);
if (IsContained(rectBB, rotation(), dX, dY) == true)
{
SetSize(sz.width(), sz.height());
Update();
emit SignalShrink();
}
SetSize(sz.width(), sz.height());
Update();
emit SignalShrink();
}
else if (m_eMode == mRotate)
{
@ -429,7 +429,7 @@ bool VTextGraphicsItem::IsBigEnough(qreal fW, qreal fH, int iFontSize)
//---------------------------------------------------------------------------------------------------------------------
QStringList VTextGraphicsItem::SplitString(const QString &qs, qreal fW, const QFontMetrics &fm)
{
QRegExp reg("\\s+");
QRegularExpression reg("\\s+");
QStringList qslWords = qs.split(reg);
QStringList qslLines;
QString qsCurrent;
@ -437,7 +437,7 @@ QStringList VTextGraphicsItem::SplitString(const QString &qs, qreal fW, const QF
{
if (qsCurrent.length() > 0)
{
qsCurrent += " ";
qsCurrent += QLatin1Literal(" ");
}
if (fm.width(qsCurrent + qslWords[i]) > fW)
{
@ -460,9 +460,13 @@ double VTextGraphicsItem::GetAngle(QPointF pt) const
double dY = pt.y() - m_ptRotCenter.y();
if (fabs(dX) < 1 && fabs(dY) < 1)
{
return 0;
}
else
{
return atan2(dY, dX);
}
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -85,7 +85,7 @@ protected:
double GetAngle(QPointF pt) const;
signals:
void SignalMoved(QPointF ptPos);
void SignalMoved(const QPointF& ptPos);
void SignalResized(qreal iTW, int iFontSize);
void SignalRotated(qreal dAng);
void SignalShrink();

View file

@ -134,12 +134,10 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
connect(dataLabel, &VTextGraphicsItem::SignalMoved, this, &VToolDetail::SaveMoveDetail);
connect(dataLabel, &VTextGraphicsItem::SignalResized, this, &VToolDetail::SaveResizeDetail);
connect(dataLabel, &VTextGraphicsItem::SignalRotated, this, &VToolDetail::SaveRotationDetail);
//connect(dataLabel, &VTextGraphicsItem::SignalShrink, this, &VToolDetail::UpdateAll);
connect(patternInfo, &VTextGraphicsItem::SignalMoved, this, &VToolDetail::SaveMovePattern);
connect(patternInfo, &VTextGraphicsItem::SignalResized, this, &VToolDetail::SaveResizePattern);
connect(patternInfo, &VTextGraphicsItem::SignalRotated, this, &VToolDetail::SaveRotationPattern);
//connect(patternInfo, &VTextGraphicsItem::SignalShrink, this, &VToolDetail::UpdateAll);
connect(doc, &VAbstractPattern::patternChanged, this, &VToolDetail::UpdatePatternInfo);
connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdateLabel);
@ -820,7 +818,7 @@ void VToolDetail::UpdatePatternInfo()
/**
* @brief SaveMoveDetail saves the move detail operation to the undo stack
*/
void VToolDetail::SaveMoveDetail(QPointF ptPos)
void VToolDetail::SaveMoveDetail(const QPointF& ptPos)
{
VDetail oldDet = VAbstractTool::data.GetDetail(id);
VDetail newDet = oldDet;
@ -879,7 +877,7 @@ void VToolDetail::SaveRotationDetail(qreal dRot)
/**
* @brief SaveMovePattern saves the pattern label position
*/
void VToolDetail::SaveMovePattern(QPointF ptPos)
void VToolDetail::SaveMovePattern(const QPointF &ptPos)
{
VDetail oldDet = VAbstractTool::data.GetDetail(id);
VDetail newDet = oldDet;

View file

@ -111,10 +111,10 @@ protected:
protected slots:
virtual void UpdateLabel();
virtual void UpdatePatternInfo();
virtual void SaveMoveDetail(QPointF ptPos);
virtual void SaveMoveDetail(const QPointF &ptPos);
virtual void SaveResizeDetail(qreal dLabelW, int iFontSize);
virtual void SaveRotationDetail(qreal dRot);
virtual void SaveMovePattern(QPointF ptPos);
virtual void SaveMovePattern(const QPointF& ptPos);
virtual void SaveResizePattern(qreal dLabelW, int iFontSize);
virtual void SaveRotationPattern(qreal dRot);