Allow insertion of multiple nodes by setting their number. Closes #88. Ref #80

This commit is contained in:
Roman Telezhynskyi 2021-01-23 21:11:21 +02:00
parent 8123c67e7c
commit c47664d86c
4 changed files with 67 additions and 3 deletions

View File

@ -11,6 +11,7 @@
- Improve multisize measurements format. Allow excluding combinations inside min/max range. - Improve multisize measurements format. Allow excluding combinations inside min/max range.
- New warning. Grainline is not valid. - New warning. Grainline is not valid.
- [smart-pattern/valentina#87] Add support for TIFF format. - [smart-pattern/valentina#87] Add support for TIFF format.
- [smart-pattern/valentina#88] Allow insertion of multiple nodes by setting their number.
# Version 0.7.41 Dec 4, 2020 # Version 0.7.41 Dec 4, 2020
- Bug fixes. - Bug fixes.

View File

@ -48,6 +48,9 @@ DialogInsertNode::DialogInsertNode(const VContainer *data, quint32 toolId, QWidg
}); });
connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogInsertNode::ShowContextMenu); connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogInsertNode::ShowContextMenu);
connect(ui->listWidget, &QListWidget::itemSelectionChanged, this, &DialogInsertNode::NodeSelected);
connect(ui->spinBoxNodeNumber, QOverload<int>::of(&QSpinBox::valueChanged), this,
&DialogInsertNode::NodeNumberChanged);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -101,7 +104,11 @@ QVector<VPieceNode> DialogInsertNode::GetNodes() const
QVector<VPieceNode> nodes; QVector<VPieceNode> nodes;
for (qint32 i = 0; i < ui->listWidget->count(); ++i) for (qint32 i = 0; i < ui->listWidget->count(); ++i)
{ {
nodes.append(qvariant_cast<VPieceNode>(ui->listWidget->item(i)->data(Qt::UserRole))); VPieceNode node = qvariant_cast<VPieceNode>(ui->listWidget->item(i)->data(Qt::UserRole));
for(int n = 1; n <= nodeNumbers.value(node.GetId(), 1); ++n)
{
nodes.append(node);
}
} }
return nodes; return nodes;
} }
@ -224,6 +231,41 @@ void DialogInsertNode::ShowContextMenu(const QPoint &pos)
CheckNodes(); CheckNodes();
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogInsertNode::NodeSelected()
{
QListWidgetItem *item = ui->listWidget->currentItem();
if (item == nullptr)
{
ui->spinBoxNodeNumber->setDisabled(true);
ui->spinBoxNodeNumber->blockSignals(true);
ui->spinBoxNodeNumber->setValue(1);
ui->spinBoxNodeNumber->blockSignals(false);
return;
}
VPieceNode node = qvariant_cast<VPieceNode>(item->data(Qt::UserRole));
ui->spinBoxNodeNumber->setEnabled(true);
ui->spinBoxNodeNumber->blockSignals(true);
ui->spinBoxNodeNumber->setValue(nodeNumbers.value(node.GetId(), 1));
ui->spinBoxNodeNumber->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogInsertNode::NodeNumberChanged(int val)
{
QListWidgetItem *item = ui->listWidget->currentItem();
if (item == nullptr)
{
return;
}
VPieceNode node = qvariant_cast<VPieceNode>(item->data(Qt::UserRole));
nodeNumbers[node.GetId()] = val;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogInsertNode::CheckPieces() void DialogInsertNode::CheckPieces()
{ {

View File

@ -62,6 +62,8 @@ protected:
private slots: private slots:
void ShowContextMenu(const QPoint &pos); void ShowContextMenu(const QPoint &pos);
void NodeSelected();
void NodeNumberChanged(int val);
private: private:
Q_DISABLE_COPY(DialogInsertNode) Q_DISABLE_COPY(DialogInsertNode)
@ -71,6 +73,8 @@ private:
bool m_flagNodes{false}; bool m_flagNodes{false};
bool m_flagError{false}; bool m_flagError{false};
QMap<quint32, int> nodeNumbers{};
void CheckPieces(); void CheckPieces();
void CheckNodes(); void CheckNodes();
}; };

View File

@ -26,16 +26,33 @@
<property name="fieldGrowthPolicy"> <property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum> <enum>QFormLayout::ExpandingFieldsGrow</enum>
</property> </property>
<item row="0" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelPiece"> <widget class="QLabel" name="labelPiece">
<property name="text"> <property name="text">
<string>Piece:</string> <string>Piece:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="comboBoxPiece"/> <widget class="QComboBox" name="comboBoxPiece"/>
</item> </item>
<item row="0" column="0">
<widget class="QLabel" name="labelNumber">
<property name="text">
<string>Number:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBoxNodeNumber">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>50</number>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>