Init all pin comboboxes.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-02-15 15:32:48 +02:00
parent a3d27bf9db
commit ff2d9c28fe
3 changed files with 186 additions and 98 deletions

View File

@ -172,6 +172,8 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
NewPin(piece.GetPins().at(i));
}
InitAllPinComboboxes();
ui->comboBoxStartPoint->blockSignals(true);
ui->comboBoxStartPoint->clear();
ui->comboBoxStartPoint->blockSignals(false);
@ -194,8 +196,8 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
m_my = piece.GetMy();
ui->lineEditLetter->setText(piece.GetPatternPieceData().GetLetter());
ui->checkBoxDetail->setChecked(piece.GetPatternPieceData().IsVisible());
ui->checkBoxPattern->setChecked(piece.GetPatternInfo().IsVisible());
ui->groupBoxDetailLabel->setChecked(piece.GetPatternPieceData().IsVisible());
ui->groupBoxPatternLabel->setChecked(piece.GetPatternInfo().IsVisible());
m_conMCP.clear();
for (int i = 0; i < piece.GetPatternPieceData().GetMCPCount(); ++i)
@ -385,11 +387,7 @@ void DialogSeamAllowance::AddUpdate()
MaterialCutPlacement mcp;
QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials();
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
int i = ui->comboBoxMaterial->itemData(ui->comboBoxMaterial->currentIndex()).toInt();
#else
int i = ui->comboBoxMaterial->currentData().toInt();
#endif
const int i = CURRENT_DATA(ui->comboBoxMaterial).toInt();
QString qsMat = ui->comboBoxMaterial->currentText();
if (i < m_qslMaterials.count() && qsMat == m_qslMaterials[i])
{
@ -627,6 +625,7 @@ void DialogSeamAllowance::ShowPinsContextMenu(const QPoint &pos)
{
delete ui->listWidgetPins->item(row);
TabChanged(ui->tabWidget->currentIndex());
InitAllPinComboboxes();
}
}
@ -673,13 +672,8 @@ void DialogSeamAllowance::NodeChanged(int index)
if (index != -1)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const quint32 id = ui->comboBoxNodes->itemData(index).toUInt();
#else
const quint32 id = ui->comboBoxNodes->currentData().toUInt();
#endif
const VPiece piece = CreatePiece();
const int nodeIndex = piece.GetPath().indexOfNode(id);
const int nodeIndex = piece.GetPath().indexOfNode(CURRENT_DATA(ui->comboBoxNodes).toUInt());
if (nodeIndex != -1)
{
const VPieceNode &node = piece.GetPath().at(nodeIndex);
@ -733,71 +727,54 @@ void DialogSeamAllowance::NodeChanged(int index)
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::CSAStartPointChanged(int index)
{
Q_UNUSED(index);
const int row = ui->listWidgetCustomSA->currentRow();
if (ui->listWidgetCustomSA->count() == 0 || row == -1 || row >= ui->listWidgetCustomSA->count())
{
return;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const quint32 startPoint = ui->comboBoxStartPoint->itemData(index).toUInt();
#else
Q_UNUSED(index);
const quint32 startPoint = ui->comboBoxStartPoint->currentData().toUInt();
#endif
QListWidgetItem *rowItem = ui->listWidgetCustomSA->item(row);
SCASSERT(rowItem != nullptr);
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
record.startPoint = startPoint;
record.startPoint = CURRENT_DATA(ui->comboBoxStartPoint).toUInt();
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::CSAEndPointChanged(int index)
{
Q_UNUSED(index);
const int row = ui->listWidgetCustomSA->currentRow();
if (ui->listWidgetCustomSA->count() == 0 || row == -1 || row >= ui->listWidgetCustomSA->count())
{
return;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const quint32 endPoint = ui->comboBoxEndPoint->itemData(index).toUInt();
#else
Q_UNUSED(index);
const quint32 endPoint = ui->comboBoxEndPoint->currentData().toUInt();
#endif
QListWidgetItem *rowItem = ui->listWidgetCustomSA->item(row);
SCASSERT(rowItem != nullptr);
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
record.endPoint = endPoint;
record.endPoint = CURRENT_DATA(ui->comboBoxEndPoint).toUInt();
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::CSAIncludeTypeChanged(int index)
{
Q_UNUSED(index);
const int row = ui->listWidgetCustomSA->currentRow();
if (ui->listWidgetCustomSA->count() == 0 || row == -1 || row >= ui->listWidgetCustomSA->count())
{
return;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const PiecePathIncludeType type =
static_cast<PiecePathIncludeType>(ui->comboBoxIncludeType->itemData(index).toUInt());
#else
Q_UNUSED(index);
const PiecePathIncludeType type =
static_cast<PiecePathIncludeType>(ui->comboBoxIncludeType->currentData().toUInt());
#endif
QListWidgetItem *rowItem = ui->listWidgetCustomSA->item(row);
SCASSERT(rowItem != nullptr);
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
record.includeType = type;
record.includeType = static_cast<PiecePathIncludeType>(CURRENT_DATA(ui->comboBoxIncludeType).toUInt());
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
}
@ -807,23 +784,11 @@ void DialogSeamAllowance::NodeAngleChanged(int index)
const int i = ui->comboBoxNodes->currentIndex();
if (i != -1 && index != -1)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const quint32 id = ui->comboBoxNodes->itemData(i).toUInt();
#else
const quint32 id = ui->comboBoxNodes->currentData().toUInt();
#endif
QListWidgetItem *rowItem = GetItemById(id);
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(ui->comboBoxNodes).toUInt());
if (rowItem)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const PieceNodeAngle angle = static_cast<PieceNodeAngle>(ui->comboBoxAngle->itemData(index).toUInt());
#else
const PieceNodeAngle angle = static_cast<PieceNodeAngle>(ui->comboBoxAngle->currentData().toUInt());
#endif
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetAngleType(angle);
rowNode.SetAngleType(static_cast<PieceNodeAngle>(CURRENT_DATA(ui->comboBoxAngle).toUInt()));
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
ListChanged();
@ -1333,10 +1298,10 @@ VPiece DialogSeamAllowance::CreatePiece() const
piece.GetPatternPieceData().SetLabelHeight(m_oldData.GetLabelHeight());
piece.GetPatternPieceData().SetFontSize(m_oldData.GetFontSize());
piece.GetPatternPieceData().SetRotation(m_oldData.GetRotation());
piece.GetPatternPieceData().SetVisible(ui->checkBoxDetail->isChecked());
piece.GetPatternPieceData().SetVisible(ui->groupBoxDetailLabel->isChecked());
piece.GetPatternInfo() = m_oldGeom;
piece.GetPatternInfo().SetVisible(ui->checkBoxPattern->isChecked());
piece.GetPatternInfo().SetVisible(ui->groupBoxPatternLabel->isChecked());
piece.GetGrainlineGeometry() = m_oldGrainline;
piece.GetGrainlineGeometry().SetVisible(ui->checkBoxGrainline->isChecked());
@ -1480,20 +1445,16 @@ bool DialogSeamAllowance::MainPathIsClockwise() const
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitNodesList()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const quint32 id = ui->comboBoxNodes->itemData(ui->comboBoxNodes->currentIndex()).toUInt();
#else
const quint32 id = ui->comboBoxNodes->currentData().toUInt();
#endif
const quint32 id = CURRENT_DATA(ui->comboBoxNodes).toUInt();
ui->comboBoxNodes->blockSignals(true);
ui->comboBoxNodes->clear();
const VPiece piece = CreatePiece();
const QVector<VPieceNode> nodes = GetPieceInternals<VPieceNode>(ui->listWidgetMainPath);
for (int i = 0; i < piece.GetPath().CountNodes(); ++i)
for (int i = 0; i < nodes.size(); ++i)
{
const VPieceNode node = piece.GetPath().at(i);
const VPieceNode node = nodes.at(i);
if (node.GetTypeTool() == Tool::NodePoint)
{
const QString name = GetNodeName(node);
@ -1567,13 +1528,7 @@ void DialogSeamAllowance::UpdateNodeSABefore(const QString &formula)
const int index = ui->comboBoxNodes->currentIndex();
if (index != -1)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const quint32 id = ui->comboBoxNodes->itemData(index).toUInt();
#else
const quint32 id = ui->comboBoxNodes->currentData().toUInt();
#endif
QListWidgetItem *rowItem = GetItemById(id);
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(ui->comboBoxNodes).toUInt());
if (rowItem)
{
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
@ -1589,13 +1544,7 @@ void DialogSeamAllowance::UpdateNodeSAAfter(const QString &formula)
const int index = ui->comboBoxNodes->currentIndex();
if (index != -1)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const quint32 id = ui->comboBoxNodes->itemData(index).toUInt();
#else
const quint32 id = ui->comboBoxNodes->currentData().toUInt();
#endif
QListWidgetItem *rowItem = GetItemById(id);
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(ui->comboBoxNodes).toUInt());
if (rowItem)
{
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
@ -1689,11 +1638,11 @@ void DialogSeamAllowance::InitCSAPoint(QComboBox *box)
box->clear();
box->addItem(tr("Empty"), NULL_ID);
const VPiece piece = CreatePiece();
const QVector<VPieceNode> nodes = GetPieceInternals<VPieceNode>(ui->listWidgetMainPath);
for (int i = 0; i < piece.GetPath().CountNodes(); ++i)
for (int i = 0; i < nodes.size(); ++i)
{
const VPieceNode &node = piece.GetPath().at(i);
const VPieceNode &node = nodes.at(i);
if (node.GetTypeTool() == Tool::NodePoint)
{
const QString name = GetNodeName(node);
@ -1702,6 +1651,35 @@ void DialogSeamAllowance::InitCSAPoint(QComboBox *box)
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitPinPoint(QComboBox *box)
{
SCASSERT(box != nullptr);
quint32 currentId = NULL_ID;
if (box->count() > 0)
{
currentId = CURRENT_DATA(box).toUInt();
}
box->clear();
box->addItem(QLatin1String("<") + tr("no pin") + QLatin1String(">"), NULL_ID);
const QVector<quint32> pins = GetPieceInternals<quint32>(ui->listWidgetPins);
for (int i = 0; i < pins.size(); ++i)
{
const QSharedPointer<VGObject> pin = data->GetGObject(pins.at(i));
box->addItem(pin->name(), pins.at(i));
}
const int index = ui->comboBoxNodes->findData(currentId);
if (index != -1)
{
box->setCurrentIndex(index);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitSAIncludeType()
{
@ -1728,6 +1706,11 @@ void DialogSeamAllowance::InitPatternPieceDataTab()
ui->lineEditLetter->setClearButtonEnabled(true);
#endif
InitPinPoint(ui->comboBoxDetailLabelTopLeftPin);
InitPinPoint(ui->comboBoxDetailLabelBottomRightPin);
InitPinPoint(ui->comboBoxPatternLabelTopLeftPin);
InitPinPoint(ui->comboBoxPatternLabelBottomRightPin);
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogSeamAllowance::NameDetailChanged);
m_qslMaterials << QApplication::translate("Detail", "Fabric", 0)
@ -1779,6 +1762,9 @@ void DialogSeamAllowance::InitGrainlineTab()
m_iRotBaseHeight = ui->lineEditRotFormula->height();
m_iLenBaseHeight = ui->lineEditLenFormula->height();
InitPinPoint(ui->comboBoxGrainlineTopPin);
InitPinPoint(ui->comboBoxGrainlineBottomPin);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1789,6 +1775,18 @@ void DialogSeamAllowance::InitPinsTab()
&DialogSeamAllowance::ShowPinsContextMenu);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitAllPinComboboxes()
{
InitPinPoint(ui->comboBoxGrainlineTopPin);
InitPinPoint(ui->comboBoxGrainlineBottomPin);
InitPinPoint(ui->comboBoxDetailLabelTopLeftPin);
InitPinPoint(ui->comboBoxDetailLabelBottomRightPin);
InitPinPoint(ui->comboBoxPatternLabelTopLeftPin);
InitPinPoint(ui->comboBoxPatternLabelBottomRightPin);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogSeamAllowance::GetFormulaSAWidth() const
{

View File

@ -178,11 +178,13 @@ private:
void InitSeamAllowanceTab();
void InitNodesList();
void InitCSAPoint(QComboBox *box);
void InitPinPoint(QComboBox *box);
void InitSAIncludeType();
void InitInternalPathsTab();
void InitPatternPieceDataTab();
void InitGrainlineTab();
void InitPinsTab();
void InitAllPinComboboxes();
void SetFormulaSAWidth(const QString &formula);

View File

@ -911,7 +911,7 @@
<item>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
@ -1029,17 +1029,82 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QCheckBox" name="checkBoxDetail">
<property name="text">
<widget class="QGroupBox" name="groupBoxDetailLabel">
<property name="title">
<string>Detail label visible</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_4">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelDetailLabelTopLeftPin">
<property name="text">
<string>Top left pin:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxDetailLabelTopLeftPin"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelDetailLabelBottomRightPin">
<property name="text">
<string>Bottom right pin:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxDetailLabelBottomRightPin"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxPattern">
<property name="text">
<widget class="QGroupBox" name="groupBoxPatternLabel">
<property name="title">
<string>Pattern label visible</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_5">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelPatternLabelTopLeftPin">
<property name="text">
<string>Top left pin:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxPatternLabelTopLeftPin"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelPatternLabelBottomRightPin">
<property name="text">
<string>Bottom right pin:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxPatternLabelBottomRightPin"/>
</item>
</layout>
</widget>
</item>
</layout>
@ -1456,8 +1521,11 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelEditLen_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
@ -1507,24 +1575,44 @@
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxArrow"/>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="1" column="0">
<widget class="QLabel" name="labelGrainlineTopPin">
<property name="text">
<string>Top pin:</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelGrainlineBottomPin">
<property name="text">
<string>Bottom pin:</string>
</property>
</spacer>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxGrainlineTopPin"/>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxGrainlineBottomPin"/>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabPins">