Dialog Seam allowance tool. Show pins in a list.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-02-14 15:11:54 +02:00
parent 71ac49a221
commit fc86069f7c
3 changed files with 76 additions and 1 deletions

View File

@ -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<quint32> pins;
for (qint32 i = 0; i < ui->listWidgetPins->count(); ++i)
{
QListWidgetItem *item = ui->listWidgetPins->item(i);
pins.append(qvariant_cast<quint32>(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<VGObject> 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
{

View File

@ -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);
};

View File

@ -21,7 +21,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabMainPath">
<attribute name="title">
@ -1527,6 +1527,20 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tabPins">
<attribute name="title">
<string>Pins</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QListWidget" name="listWidgetPins">
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>