Improve context menu in dialog piece path.

This menu should povide exclude option. Also Passmark option should be available
only when a piece path included as main path.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2018-09-24 14:40:02 +03:00
parent f0fdb7d8b9
commit 56e05ab953

View file

@ -313,7 +313,8 @@ void DialogPiecePath::ShowContextMenu(const QPoint &pos)
} }
else else
{ {
if (m_showMode && GetType() == PiecePathType::CustomSeamAllowance) if (m_showMode && GetType() == PiecePathType::CustomSeamAllowance
&& ui->tabWidget->indexOf(ui->tabPassmarks) != -1)
{ {
actionPassmark = menu->addAction(tr("Passmark")); actionPassmark = menu->addAction(tr("Passmark"));
actionPassmark->setCheckable(true); actionPassmark->setCheckable(true);
@ -325,6 +326,10 @@ void DialogPiecePath::ShowContextMenu(const QPoint &pos)
actionUniqueness->setChecked(rowNode.IsCheckUniqueness()); actionUniqueness->setChecked(rowNode.IsCheckUniqueness());
} }
QAction *actionExcluded = menu->addAction(tr("Excluded"));
actionExcluded->setCheckable(true);
actionExcluded->setChecked(rowNode.IsExcluded());
QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
QAction *selectedAction = menu->exec(ui->listWidget->viewport()->mapToGlobal(pos)); QAction *selectedAction = menu->exec(ui->listWidget->viewport()->mapToGlobal(pos));
@ -338,13 +343,22 @@ void DialogPiecePath::ShowContextMenu(const QPoint &pos)
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
rowItem->setText(GetNodeName(rowNode, IsShowNotch())); rowItem->setText(GetNodeName(rowNode, IsShowNotch()));
} }
else if (m_showMode && selectedAction == actionPassmark && GetType() == PiecePathType::CustomSeamAllowance) else if (m_showMode && rowNode.GetTypeTool() == Tool::NodePoint && selectedAction == actionPassmark
&& GetType() == PiecePathType::CustomSeamAllowance
&& ui->tabWidget->indexOf(ui->tabPassmarks) != -1)
{ {
rowNode.SetPassmark(not rowNode.IsPassmark()); rowNode.SetPassmark(not rowNode.IsPassmark());
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
rowItem->setText(GetNodeName(rowNode, IsShowNotch())); rowItem->setText(GetNodeName(rowNode, IsShowNotch()));
} }
else if (selectedAction == actionUniqueness) else if (selectedAction == actionExcluded)
{
rowNode.SetExcluded(not rowNode.IsExcluded());
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
rowItem->setText(GetNodeName(rowNode, true));
rowItem->setFont(NodeFont(rowItem->font(), rowNode.IsExcluded()));
}
else if (rowNode.GetTypeTool() == Tool::NodePoint && selectedAction == actionUniqueness)
{ {
rowNode.SetCheckUniqueness(not rowNode.IsCheckUniqueness()); rowNode.SetCheckUniqueness(not rowNode.IsCheckUniqueness());
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));