diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp index 60e895416..54074d27c 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp @@ -99,6 +99,7 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & InitInternalPathsTab(); InitPatternPieceDataTab(); InitGrainlineTab(); + InitPinsTab(); flagName = true;//We have default name of piece. ChangeColor(ui->labelEditName, okColor); @@ -129,6 +130,7 @@ void DialogSeamAllowance::EnableApply(bool enable) ui->tabInternalPaths->setEnabled(applyAllowed); ui->tabPatternPieceData->setEnabled(applyAllowed); ui->tabGrainline->setEnabled(applyAllowed); + ui->tabPins->setEnabled(applyAllowed); } //--------------------------------------------------------------------------------------------------------------------- @@ -160,6 +162,12 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) NewInternalPath(piece.GetInternalPaths().at(i)); } + ui->listWidgetPins->clear(); + for (int i = 0; i < piece.GetPins().size(); ++i) + { + NewPin(piece.GetPins().at(i)); + } + ui->comboBoxStartPoint->blockSignals(true); ui->comboBoxStartPoint->clear(); ui->comboBoxStartPoint->blockSignals(false); @@ -598,6 +606,25 @@ void DialogSeamAllowance::ShowInternalPathsContextMenu(const QPoint &pos) } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::ShowPinsContextMenu(const QPoint &pos) +{ + const int row = ui->listWidgetPins->currentRow(); + if (ui->listWidgetPins->count() == 0 || row == -1 || row >= ui->listWidgetPins->count()) + { + return; + } + + QMenu *menu = new QMenu(this); + QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); + + QAction *selectedAction = menu->exec(ui->listWidgetPins->viewport()->mapToGlobal(pos)); + if (selectedAction == actionDelete) + { + delete ui->listWidgetPins->item(row); + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::ListChanged() { @@ -1271,6 +1298,14 @@ VPiece DialogSeamAllowance::CreatePiece() const } piece.SetInternalPaths(iPaths); + QVector pins; + for (qint32 i = 0; i < ui->listWidgetPins->count(); ++i) + { + QListWidgetItem *item = ui->listWidgetPins->item(i); + pins.append(qvariant_cast(item->data(Qt::UserRole))); + } + piece.SetPins(pins); + piece.SetForbidFlipping(ui->checkBoxForbidFlipping->isChecked()); piece.SetSeamAllowance(ui->checkBoxSeams->isChecked()); piece.SetName(ui->lineEditName->text()); @@ -1344,6 +1379,21 @@ void DialogSeamAllowance::NewInternalPath(quint32 path) } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::NewPin(quint32 pinPoint) +{ + if (pinPoint > NULL_ID) + { + const QSharedPointer pin = data->GetGObject(pinPoint); + + QListWidgetItem *item = new QListWidgetItem(pin->name()); + item->setFont(QFont("Times", 12, QFont::Bold)); + item->setData(Qt::UserRole, QVariant::fromValue(pinPoint)); + ui->listWidgetPins->addItem(item); + ui->listWidgetPins->setCurrentRow(ui->listWidgetPins->count()-1); + } +} + //--------------------------------------------------------------------------------------------------------------------- QString DialogSeamAllowance::GetPathName(quint32 path, bool reverse) const { @@ -1727,6 +1777,14 @@ void DialogSeamAllowance::InitGrainlineTab() m_iLenBaseHeight = ui->lineEditLenFormula->height(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::InitPinsTab() +{ + ui->listWidgetPins->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui->listWidgetPins, &QListWidget::customContextMenuRequested, this, + &DialogSeamAllowance::ShowPinsContextMenu); +} + //--------------------------------------------------------------------------------------------------------------------- QString DialogSeamAllowance::GetFormulaSAWidth() const { diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/dialogseamallowance.h index 94a8b8530..04bda4583 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.h @@ -77,6 +77,7 @@ private slots: void ShowMainPathContextMenu(const QPoint &pos); void ShowCustomSAContextMenu(const QPoint &pos); void ShowInternalPathsContextMenu(const QPoint &pos); + void ShowPinsContextMenu(const QPoint &pos); void ListChanged(); void EnableSeamAllowance(bool enable); @@ -150,6 +151,7 @@ private: void NewMainPathItem(const VPieceNode &node); void NewCustomSA(const CustomSARecord &record); void NewInternalPath(quint32 path); + void NewPin(quint32 pinPoint); QString GetPathName(quint32 path, bool reverse = false) const; bool MainPathIsValid() const; void ValidObjects(bool value); @@ -176,6 +178,7 @@ private: void InitInternalPathsTab(); void InitPatternPieceDataTab(); void InitGrainlineTab(); + void InitPinsTab(); void SetFormulaSAWidth(const QString &formula); }; diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.ui b/src/libs/vtools/dialogs/tools/dialogseamallowance.ui index 315098dc5..73d9c4118 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.ui +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.ui @@ -21,7 +21,7 @@ - 1 + 0 @@ -1527,6 +1527,20 @@ + + + Pins + + + + + + QAbstractItemView::InternalMove + + + + +