Fixed few bugs: label position is preserved after editing detail, buttons for add/update/remove MCP are handled correcty. Added style to VTextGraphicsItem lines

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-06-26 14:21:06 +02:00
parent 21debaf249
commit e68fa3a0f3
5 changed files with 21 additions and 6 deletions

View File

@ -346,6 +346,8 @@ VDetail DialogDetail::CreateDetail() const
detail.GetPatternPieceData().Append(m_conMCP[i]); detail.GetPatternPieceData().Append(m_conMCP[i]);
} }
detail.GetPatternPieceData().SetPos(m_ptPos);
return detail; return detail;
} }
@ -404,6 +406,7 @@ void DialogDetail::setDetail(const VDetail &value)
} }
UpdateList(); UpdateList();
m_ptPos = detail.GetPatternPieceData().GetPos();
ValidObjects(DetailIsValid()); ValidObjects(DetailIsValid());
} }
@ -692,7 +695,7 @@ void DialogDetail::SetEditMode()
{ {
int iR = ui.listWidgetMCP->currentRow(); int iR = ui.listWidgetMCP->currentRow();
// this method can be called by clicking on item or by update. In the latter case there is nothing else to do! // this method can be called by clicking on item or by update. In the latter case there is nothing else to do!
if (iR < 0 || iR >= detail.GetPatternPieceData().GetMCPCount()) if (iR < 0 || iR >= m_conMCP.count())
{ {
return; return;
} }
@ -701,7 +704,7 @@ void DialogDetail::SetEditMode()
ui.pushButtonCancel->show(); ui.pushButtonCancel->show();
ui.pushButtonRemove->show(); ui.pushButtonRemove->show();
MaterialCutPlacement mcp = detail.GetPatternPieceData().GetMCP(iR); MaterialCutPlacement mcp = m_conMCP.at(iR);
ui.comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef); ui.comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef);
ui.spinBoxCutNumber->setValue(mcp.m_iCutNumber); ui.spinBoxCutNumber->setValue(mcp.m_iCutNumber);
ui.comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement)); ui.comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement));

View File

@ -100,6 +100,7 @@ private:
QStringList m_qslPlacements; QStringList m_qslPlacements;
// temporary container for Material/Cut/Placement 3-tuples // temporary container for Material/Cut/Placement 3-tuples
MCPContainer m_conMCP; MCPContainer m_conMCP;
QPointF m_ptPos;
void ClearFields(); void ClearFields();

View File

@ -80,6 +80,7 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
iH = tl.m_iHeight; iH = tl.m_iHeight;
fnt.setPixelSize(m_font.pixelSize() + tl.m_iFontSize); fnt.setPixelSize(m_font.pixelSize() + tl.m_iFontSize);
fnt.setWeight(tl.m_eFontWeight); fnt.setWeight(tl.m_eFontWeight);
fnt.setStyle(tl.m_eStyle);
painter->setFont(fnt); painter->setFont(fnt);
painter->drawText(0, iY, boundingRect().width(), iH, tl.m_eAlign, tl.m_qsText); painter->drawText(0, iY, boundingRect().width(), iH, tl.m_eAlign, tl.m_qsText);
iY += iH + SPACING; iY += iH + SPACING;
@ -186,6 +187,14 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
{ {
if (m_eMode == mMove)
{
emit SignalMoved(pos());
}
else
{
emit SignalResized(m_rectBoundingBox.width(), m_font.pixelSize());
}
m_eMode = mActivated; m_eMode = mActivated;
Update(); Update();
} }
@ -229,9 +238,9 @@ bool VTextGraphicsItem::IsBigEnough(qreal fW, qreal fH, int iFontSize)
QFontMetrics fm(fnt); QFontMetrics fm(fnt);
tlOut.m_iHeight = fm.height(); tlOut.m_iHeight = fm.height();
QStringList qslLines = SplitString(tlOut.m_qsText, fW, fm); QStringList qslLines = SplitString(tlOut.m_qsText, fW, fm);
for (int i = 0; i < qslLines.count(); ++i) for (int iL = 0; iL < qslLines.count(); ++iL)
{ {
tlOut.m_qsText = qslLines[i]; tlOut.m_qsText = qslLines[iL];
m_liOutput << tlOut; m_liOutput << tlOut;
iY += tlOut.m_iHeight + SPACING; iY += tlOut.m_iHeight + SPACING;
} }

View File

@ -38,6 +38,7 @@ struct TextLine
QString m_qsText; QString m_qsText;
int m_iFontSize; // 0 means default int m_iFontSize; // 0 means default
QFont::Weight m_eFontWeight; QFont::Weight m_eFontWeight;
QFont::Style m_eStyle;
Qt::Alignment m_eAlign; Qt::Alignment m_eAlign;
int m_iHeight; int m_iHeight;
}; };

View File

@ -311,6 +311,7 @@ void VToolDetail::FullUpdateFromGuiOk(int result)
VDetail newDet = dialogTool->getDetail(); VDetail newDet = dialogTool->getDetail();
VDetail oldDet = VAbstractTool::data.GetDetail(id); VDetail oldDet = VAbstractTool::data.GetDetail(id);
qDebug() << "VToolDetail Position" << newDet.GetPatternPieceData().GetPos();
SaveDetailOptions *saveCommand = new SaveDetailOptions(oldDet, newDet, doc, id, this->scene()); SaveDetailOptions *saveCommand = new SaveDetailOptions(oldDet, newDet, doc, id, this->scene());
connect(saveCommand, &SaveDetailOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); connect(saveCommand, &SaveDetailOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(saveCommand); qApp->getUndoStack()->push(saveCommand);
@ -653,14 +654,14 @@ void VToolDetail::UpdateLabel()
tl.m_qsText = data.GetLetter(); tl.m_qsText = data.GetLetter();
tl.m_eAlign = Qt::AlignCenter; tl.m_eAlign = Qt::AlignCenter;
tl.m_eFontWeight = QFont::Bold; tl.m_eFontWeight = QFont::Bold;
tl.m_iFontSize = 4; tl.m_eStyle = QFont::StyleNormal;
tl.m_iFontSize = 6;
dataLabel->AddLine(tl); dataLabel->AddLine(tl);
tl.m_qsText = data.GetName(); tl.m_qsText = data.GetName();
tl.m_eAlign = Qt::AlignCenter; tl.m_eAlign = Qt::AlignCenter;
tl.m_eFontWeight = QFont::DemiBold; tl.m_eFontWeight = QFont::DemiBold;
tl.m_iFontSize = 2; tl.m_iFontSize = 2;
dataLabel->AddLine(tl); dataLabel->AddLine(tl);
// MCP // MCP
tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter; tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter;
tl.m_eFontWeight = QFont::Normal; tl.m_eFontWeight = QFont::Normal;