Updated detail dialog with pattern piece data editing

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-06-18 22:14:35 +02:00
parent 1899abc39e
commit 8140647242
8 changed files with 746 additions and 746 deletions

View File

@ -51,7 +51,8 @@ public:
{}
VDetailData(const VDetailData &detail)
:QSharedData(detail), _id(NULL_ID), nodes(detail.nodes), mx(detail.mx), my(detail.my)
:QSharedData(detail), _id(NULL_ID), nodes(detail.nodes), mx(detail.mx), my(detail.my),
m_ppData(detail.m_ppData)
{}
~VDetailData() {}

View File

@ -38,8 +38,7 @@ HEADERS += \
$$PWD/tools/dialogcubicbezier.h \
$$PWD/tools/dialogcubicbezierpath.h \
$$PWD/tools/dialoggroup.h \
$$PWD/tools/dialogrotation.h \
$$PWD/tools/dialogpatternpiecedata.h
$$PWD/tools/dialogrotation.h
SOURCES += \
@ -78,8 +77,7 @@ SOURCES += \
$$PWD/tools/dialogcubicbezier.cpp \
$$PWD/tools/dialogcubicbezierpath.cpp \
$$PWD/tools/dialoggroup.cpp \
$$PWD/tools/dialogrotation.cpp \
$$PWD/tools/dialogpatternpiecedata.cpp
$$PWD/tools/dialogrotation.cpp
FORMS += \
$$PWD/tools/dialogalongline.ui \

View File

@ -36,6 +36,7 @@
#include "../../../vgeometry/vsplinepath.h"
#include "../../../vpatterndb/vcontainer.h"
#include "../../../ifc/xml/vdomdocument.h"
#include "vpatternpiecedata.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -90,6 +91,19 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
connect(ui.toolButtonDelete, &QToolButton::clicked, this, &DialogDetail::DeleteItem);
connect(ui.toolButtonUp, &QToolButton::clicked, this, &DialogDetail::ScrollUp);
connect(ui.toolButtonDown, &QToolButton::clicked, this, &DialogDetail::ScrollDown);
m_qslMaterials << tr("Fabric") << tr("Lining") << tr("Interfacing") << tr("Interlining");
ui.comboBoxMaterial->addItems(m_qslMaterials);
m_qslPlacements << tr("None") << tr("Cut on fold");
ui.comboBoxPlacement->addItems(m_qslPlacements);
connect(ui.pushButtonAdd, &QPushButton::clicked, this, &DialogDetail::AddUpdate);
connect(ui.pushButtonCancel, &QPushButton::clicked, this, &DialogDetail::Cancel);
connect(ui.pushButtonRemove, &QPushButton::clicked, this, &DialogDetail::Remove);
connect(ui.listWidgetMCP, &QListWidget::itemClicked, this, &DialogDetail::SetEditMode);
SetAddMode();
ui.tabWidget->setCurrentIndex(0);
}
//---------------------------------------------------------------------------------------------------------------------
@ -153,6 +167,74 @@ void DialogDetail::CheckState()
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::UpdateList()
{
ui.listWidgetMCP->clear();
for (int i = 0; i < detail.GetPatternPieceData().GetMCPCount(); ++i)
{
MaterialCutPlacement mcp = detail.GetPatternPieceData().GetMCP(i);
QString qsText = tr("Cut %1 of %2%3");
qsText = qsText.arg(mcp.m_iCutNumber);
if (mcp.m_eMaterial < MaterialType::mtUserDefined)
qsText = qsText.arg(m_qslMaterials[int(mcp.m_eMaterial)]);
else
qsText = qsText.arg(mcp.m_qsMaterialUserDef);
if (mcp.m_ePlacement == PlacementType::ptCutOnFold)
qsText = qsText.arg(tr(" on Fold"));
else
qsText = qsText.arg("");
ui.listWidgetMCP->addItem(qsText);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::AddUpdate()
{
MaterialCutPlacement mcp;
mcp.m_qsMaterialUserDef = ui.comboBoxMaterial->currentText();
mcp.m_eMaterial = MaterialType::mtUserDefined;
for (int i = 0; i < m_qslMaterials.count(); ++i)
if (mcp.m_qsMaterialUserDef == m_qslMaterials[i])
mcp.m_eMaterial = MaterialType(i);
mcp.m_iCutNumber = ui.spinBoxCutNumber->value();
mcp.m_ePlacement = PlacementType(ui.comboBoxPlacement->currentIndex());
if (m_bAddMode == true)
{
detail.GetPatternPieceData().Append(mcp);
}
else
{
int iR = ui.listWidgetMCP->currentRow();
SCASSERT(iR >= 0);
detail.GetPatternPieceData().Set(iR, mcp);
SetAddMode();
}
UpdateList();
ClearFields();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::Cancel()
{
ClearFields();
SetAddMode();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::Remove()
{
int iR = ui.listWidgetMCP->currentRow();
SCASSERT(iR >= 0);
detail.GetPatternPieceData().RemoveMCP(iR);
UpdateList();
ClearFields();
SetAddMode();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief NewItem add new object (point, arc, spline or spline path) to list
@ -245,6 +327,14 @@ VDetail DialogDetail::CreateDetail() const
detail.setName(ui.lineEditNameDetail->text());
detail.setSeamAllowance(supplement);
detail.setClosed(closed);
detail.GetPatternPieceData().SetLetter(ui.lineEditLetter->text());
detail.GetPatternPieceData().SetName(ui.lineEditName->text());
qDebug() << "DD" << detail.GetPatternPieceData().GetLetter()
<< detail.GetPatternPieceData().GetName()
<< detail.GetPatternPieceData().GetMCPCount();
return detail;
}
@ -292,6 +382,11 @@ void DialogDetail::setDetail(const VDetail &value)
ui.listWidget->setCurrentRow(0);
ui.listWidget->setFocus(Qt::OtherFocusReason);
ui.toolButtonDelete->setEnabled(true);
ui.lineEditLetter->setText(detail.GetPatternPieceData().GetLetter());
ui.lineEditName->setText(detail.GetPatternPieceData().GetName());
UpdateList();
ValidObjects(DetailIsValid());
}
@ -555,3 +650,41 @@ bool DialogDetail::DetailIsClockwise() const
}
return false;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::ClearFields()
{
ui.comboBoxMaterial->setCurrentIndex(0);
ui.spinBoxCutNumber->setValue(0);
ui.comboBoxPlacement->setCurrentIndex(0);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::SetAddMode()
{
ui.pushButtonAdd->setText(tr("Add"));
ui.pushButtonCancel->hide();
ui.pushButtonRemove->hide();
ui.listWidgetMCP->setCurrentRow(-1);
m_bAddMode = true;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::SetEditMode()
{
int iR = ui.listWidgetMCP->currentRow();
// this method can be called by clicking on item or by update. In the latter case there is nothing else to do!
if (iR < 0 || iR >= detail.GetPatternPieceData().GetMCPCount())
return;
ui.pushButtonAdd->setText(tr("Update"));
ui.pushButtonCancel->show();
ui.pushButtonRemove->show();
MaterialCutPlacement mcp = detail.GetPatternPieceData().GetMCP(iR);
ui.comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef);
ui.spinBoxCutNumber->setValue(mcp.m_iCutNumber);
ui.comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement));
m_bAddMode = false;
}

View File

@ -62,6 +62,13 @@ protected:
*/
virtual void SaveData() Q_DECL_OVERRIDE;
virtual void CheckState() Q_DECL_OVERRIDE;
protected slots:
void UpdateList();
void AddUpdate();
void Cancel();
void Remove();
private:
/** @brief ui keeps information about user interface */
@ -85,6 +92,18 @@ private:
VDetail CreateDetail() const;
void ValidObjects(bool value);
void EnableObjectGUI(bool value);
bool m_bAddMode;
QStringList m_qslMaterials;
QStringList m_qslPlacements;
void ClearFields();
private slots:
void SetAddMode();
void SetEditMode();
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>522</width>
<height>425</height>
<height>481</height>
</rect>
</property>
<property name="windowTitle">
@ -20,11 +20,422 @@
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>General</string>
</attribute>
<widget class="QLabel" name="helpLabel">
<property name="geometry">
<rect>
<x>59</x>
<y>468</y>
<width>504</width>
<height>15</height>
</rect>
</property>
<property name="text">
<string>Ready!</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>50</x>
<y>40</y>
<width>367</width>
<height>34</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7"/>
</widget>
<widget class="QWidget" name="layoutWidget_2">
<property name="geometry">
<rect>
<x>0</x>
<y>30</y>
<width>561</width>
<height>361</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Bias X:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxBiasX">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-900.990000000000009</double>
</property>
<property name="maximum">
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelUnitX">
<property name="text">
<string>cm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Bias Y:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxBiasY">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-900.990000000000009</double>
</property>
<property name="maximum">
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelUnitY">
<property name="text">
<string>cm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QCheckBox" name="checkBoxReverse">
<property name="text">
<string>Reverse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="labelEditNameDetail">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Name of detail:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNameDetail">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Detail</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxSeams">
<property name="text">
<string>Seam allowance</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelEditWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSeams">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelUnit">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>cm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxClosed">
<property name="text">
<string>Closed</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item alignment="Qt::AlignLeft">
<widget class="QToolButton" name="toolButtonDelete">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonDown">
<property name="toolTip">
<string>Scroll down the list</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonUp">
<property name="toolTip">
<string>Scroll up the list</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-up">
<normaloff/>
</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>50</x>
<y>0</y>
<width>327</width>
<height>32</height>
</rect>
</property>
<property name="text">
<string>All objects in path should follow in clockwise direction.</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -38,376 +449,160 @@
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/32x32/clockwise.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>All objects in path should follow in clockwise direction.</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Bias X:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxBiasX">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-900.990000000000009</double>
</property>
<property name="maximum">
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelUnitX">
<property name="text">
<string>cm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Bias Y:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxBiasY">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-900.990000000000009</double>
</property>
<property name="maximum">
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelUnitY">
<property name="text">
<string>cm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QCheckBox" name="checkBoxReverse">
<property name="text">
<string>Reverse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="labelEditNameDetail">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Name of detail:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNameDetail">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Detail</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxSeams">
<property name="text">
<string>Seam allowance</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelEditWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSeams">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelUnit">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>cm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxClosed">
<property name="text">
<string>Closed</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item alignment="Qt::AlignLeft">
<widget class="QToolButton" name="toolButtonDelete">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonDown">
<property name="toolTip">
<string>Scroll down the list</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonUp">
<property name="toolTip">
<string>Scroll up the list</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-up">
<normaloff/>
</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Pattern piece data</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>9</x>
<y>38</y>
<width>40</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Name:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName">
<property name="geometry">
<rect>
<x>55</x>
<y>38</y>
<width>125</width>
<height>23</height>
</rect>
</property>
<property name="maxLength">
<number>15</number>
</property>
</widget>
<widget class="QListWidget" name="listWidgetMCP">
<property name="geometry">
<rect>
<x>280</x>
<y>0</y>
<width>201</width>
<height>381</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>0</x>
<y>70</y>
<width>271</width>
<height>153</height>
</rect>
</property>
<property name="title">
<string>Material/Cut number/Placement</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Material type:</string>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<widget class="QComboBox" name="comboBoxMaterial">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Cut number:</string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<widget class="QSpinBox" name="spinBoxCutNumber">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Placement:</string>
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<widget class="QComboBox" name="comboBoxPlacement"/>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButtonAdd">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QPushButton" name="pushButtonCancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="pushButtonRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>40</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Letter:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditLetter">
<property name="geometry">
<rect>
<x>55</x>
<y>9</y>
<width>125</width>
<height>23</height>
</rect>
</property>
<property name="maxLength">
<number>3</number>
</property>
</widget>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="helpLabel">
<property name="text">
<string>Ready!</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -420,14 +615,28 @@
</layout>
</widget>
<tabstops>
<tabstop>lineEditLetter</tabstop>
<tabstop>lineEditName</tabstop>
<tabstop>comboBoxMaterial</tabstop>
<tabstop>spinBoxCutNumber</tabstop>
<tabstop>comboBoxPlacement</tabstop>
<tabstop>pushButtonAdd</tabstop>
<tabstop>pushButtonCancel</tabstop>
<tabstop>pushButtonRemove</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>listWidgetMCP</tabstop>
<tabstop>buttonBox</tabstop>
<tabstop>toolButtonUp</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>checkBoxClosed</tabstop>
<tabstop>toolButtonDelete</tabstop>
<tabstop>doubleSpinBoxBiasX</tabstop>
<tabstop>doubleSpinBoxBiasY</tabstop>
<tabstop>checkBoxReverse</tabstop>
<tabstop>lineEditNameDetail</tabstop>
<tabstop>checkBoxSeams</tabstop>
<tabstop>doubleSpinBoxSeams</tabstop>
<tabstop>checkBoxClosed</tabstop>
<tabstop>buttonBox</tabstop>
<tabstop>toolButtonDown</tabstop>
</tabstops>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>

View File

@ -1,250 +0,0 @@
/************************************************************************
**
** @file vpatternconverter.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 11 12, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFormLayout>
#include <QGridLayout>
#include <QLabel>
#include <QGroupBox>
#include "vpatternpiecedata.h"
#include "dialogpatternpiecedata.h"
//---------------------------------------------------------------------------------------------------------------------
DialogPatternPieceData::DialogPatternPieceData(const VContainer *data, const quint32 &toolId, QWidget *parent) :
DialogTool(data, toolId, parent)
{
// main dialog layout
QVBoxLayout* pLayout = new QVBoxLayout(this);
// widgets layout
QHBoxLayout* pWidgetsLayout = new QHBoxLayout;
setWindowTitle(tr("Pattern piece data"));
QFormLayout* pFormLayout = new QFormLayout;
QLabel* plb;
plb = new QLabel(tr("Letter") + ":");
m_pleLetter = new QLineEdit;
m_pleLetter->setMaxLength(3);
pFormLayout->addRow(plb, m_pleLetter);
plb = new QLabel(tr("Name") + ":");
m_pleName = new QLineEdit;
m_pleName->setMaxLength(15);
pFormLayout->addRow(plb, m_pleName);
pWidgetsLayout->addLayout(pFormLayout);
QGroupBox* pgb = new QGroupBox(tr("Material/Cut number/Placement"));
QGridLayout* pLayoutGB = new QGridLayout(pgb);
pFormLayout = new QFormLayout;
plb = new QLabel(tr("Material type") + ":");
m_pcbMaterial = new QComboBox;
m_pcbMaterial->setFixedWidth(200);
m_qslMaterials << tr("Fabric") << tr("Lining") << tr("Interfacing") << tr("Interlining");
m_pcbMaterial->addItems(m_qslMaterials);
m_pcbMaterial->setEditable(true);
pFormLayout->addRow(plb, m_pcbMaterial);
plb = new QLabel(tr("Cut number") + ":");
m_psbCutNumber = new QSpinBox;
m_psbCutNumber->setRange(0, 1000);
pFormLayout->addRow(plb, m_psbCutNumber);
plb = new QLabel(tr("Placement type") + ":");
m_pcbPlacement = new QComboBox;
m_qslPlacements << tr("None") << tr("Cut on fold");
m_pcbPlacement->addItems(m_qslPlacements);
pFormLayout->addRow(plb, m_pcbPlacement);
pLayoutGB->addLayout(pFormLayout, 0, 0);
QHBoxLayout* pMCPButtonLayout = new QHBoxLayout;
m_pbOpAddUpdate = new QPushButton;
connect(m_pbOpAddUpdate, &QPushButton::clicked, this, &DialogPatternPieceData::AddUpdate);
pMCPButtonLayout->addStretch(1);
pMCPButtonLayout->addWidget(m_pbOpAddUpdate);
m_pbOpCancel = new QPushButton(tr("Cancel"));
connect(m_pbOpCancel, &QPushButton::clicked, this, &DialogPatternPieceData::Cancel);
pMCPButtonLayout->addWidget(m_pbOpCancel);
m_pbOpRemove = new QPushButton(tr("Remove"));
connect(m_pbOpRemove, &QPushButton::clicked, this, &DialogPatternPieceData::Remove);
pMCPButtonLayout->addWidget(m_pbOpRemove);
pLayoutGB->addLayout(pMCPButtonLayout, 1, 0);
m_plwMCP = new QListWidget;
connect(m_plwMCP, &QListWidget::itemClicked, this, &DialogPatternPieceData::SetEditMode);
pLayoutGB->addWidget(m_plwMCP, 0, 1, 3, 1);
pLayoutGB->setRowStretch(2, 1);
pLayoutGB->setColumnStretch(2, 1);
pWidgetsLayout->addWidget(pgb);
pWidgetsLayout->setStretch(2, 1);
pLayout->addLayout(pWidgetsLayout);
QHBoxLayout* pButtonsLayout = new QHBoxLayout;
pButtonsLayout->addStretch(0);
bOk = new QPushButton(tr("OK"));
connect(bOk, &QPushButton::clicked, this, &DialogTool::DialogAccepted);
QPushButton* pbCancel = new QPushButton(tr("Cancel"));
connect(pbCancel, &QPushButton::clicked, this, &DialogTool::DialogRejected);
pButtonsLayout->addWidget(bOk);
pButtonsLayout->addWidget(pbCancel);
pLayout->addLayout(pButtonsLayout);
pLayout->setStretch(0, 1);
SetAddMode();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternPieceData::SetDetail(const VDetail& rDetail)
{
m_detail = rDetail;
m_pleLetter->setText(m_detail.GetPatternPieceData().GetLetter());
m_pleName->setText(m_detail.GetPatternPieceData().GetName());
UpdateList();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternPieceData::SaveData()
{
m_detail.GetPatternPieceData().SetLetter(m_pleLetter->text());
m_detail.GetPatternPieceData().SetName(m_pleName->text());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternPieceData::UpdateList()
{
m_plwMCP->clear();
for (int i = 0; i < m_detail.GetPatternPieceData().GetMCPCount(); ++i)
{
MaterialCutPlacement mcp = m_detail.GetPatternPieceData().GetMCP(i);
QString qsText = tr("Cut %1 of %2%3");
qsText = qsText.arg(mcp.m_iCutNumber);
if (mcp.m_eMaterial < MaterialType::mtUserDefined)
qsText = qsText.arg(m_qslMaterials[int(mcp.m_eMaterial)]);
else
qsText = qsText.arg(mcp.m_qsMaterialUserDef);
if (mcp.m_ePlacement == PlacementType::ptCutOnFold)
qsText = qsText.arg(tr(" on Fold"));
else
qsText = qsText.arg("");
m_plwMCP->addItem(qsText);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternPieceData::AddUpdate()
{
MaterialCutPlacement mcp;
mcp.m_qsMaterialUserDef = m_pcbMaterial->currentText();
mcp.m_eMaterial = MaterialType::mtUserDefined;
for (int i = 0; i < m_qslMaterials.count(); ++i)
if (mcp.m_qsMaterialUserDef == m_qslMaterials[i])
mcp.m_eMaterial = MaterialType(i);
mcp.m_iCutNumber = m_psbCutNumber->value();
mcp.m_ePlacement = PlacementType(m_pcbPlacement->currentIndex());
if (m_bAddMode == true)
{
m_detail.GetPatternPieceData().Append(mcp);
}
else
{
int iR = m_plwMCP->currentRow();
SCASSERT(iR >= 0);
m_detail.GetPatternPieceData().Set(iR, mcp);
SetAddMode();
}
UpdateList();
ClearFields();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternPieceData::Cancel()
{
ClearFields();
SetAddMode();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternPieceData::Remove()
{
int iR = m_plwMCP->currentRow();
SCASSERT(iR >= 0);
m_detail.GetPatternPieceData().RemoveMCP(iR);
UpdateList();
ClearFields();
SetAddMode();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternPieceData::ClearFields()
{
m_pcbMaterial->setCurrentIndex(0);
m_psbCutNumber->setValue(0);
m_pcbPlacement->setCurrentIndex(0);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternPieceData::SetAddMode()
{
m_pbOpAddUpdate->setText(tr("Add"));
m_pbOpCancel->hide();
m_pbOpRemove->hide();
m_plwMCP->setCurrentRow(-1);
m_bAddMode = true;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternPieceData::SetEditMode()
{
int iR = m_plwMCP->currentRow();
// this method can be called by clicking on item or by update. In the latter case there is nothing else to do!
if (iR < 0 || iR >= m_detail.GetPatternPieceData().GetMCPCount())
return;
m_pbOpAddUpdate->setText(tr("Update"));
m_pbOpCancel->show();
m_pbOpRemove->show();
MaterialCutPlacement mcp = m_detail.GetPatternPieceData().GetMCP(iR);
m_pcbMaterial->setCurrentText(mcp.m_qsMaterialUserDef);
m_psbCutNumber->setValue(mcp.m_iCutNumber);
m_pcbPlacement->setCurrentIndex(int(mcp.m_ePlacement));
m_bAddMode = false;
}

View File

@ -1,94 +0,0 @@
/************************************************************************
**
** @file vpatternconverter.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 11 12, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef DIALOGPATTERNPIECEDATA_H
#define DIALOGPATTERNPIECEDATA_H
#include <QLineEdit>
#include <QComboBox>
#include <QSpinBox>
#include <QPushButton>
#include <QListWidget>
#include "vdetail.h"
#include "dialogtool.h"
/**
* @brief This dialog allows user to edit pattern piece meta data
*/
class DialogPatternPieceData : public DialogTool
{
Q_OBJECT
public:
DialogPatternPieceData(const VContainer* data, const quint32& toolId, QWidget* parent = nullptr);
VDetail GetDetail() const;
void SetDetail(const VDetail& rDetail);
void SaveData();
protected slots:
void UpdateList();
void AddUpdate();
void Cancel();
void Remove();
private:
VDetail m_detail;
QLineEdit* m_pleName;
QLineEdit* m_pleLetter;
QComboBox* m_pcbMaterial;
QSpinBox* m_psbCutNumber;
QComboBox* m_pcbPlacement;
QPushButton* m_pbOpAddUpdate;
QPushButton* m_pbOpCancel;
QPushButton* m_pbOpRemove;
QListWidget* m_plwMCP;
QStringList m_qslMaterials;
QStringList m_qslPlacements;
bool m_bAddMode;
void ClearFields();
private slots:
void SetAddMode();
void SetEditMode();
};
inline VDetail DialogPatternPieceData::GetDetail() const
{
return m_detail;
}
#endif // DIALOGPATTERNPIECEDATA_H

View File

@ -36,7 +36,6 @@
#include "../vwidgets/vmaingraphicsview.h"
#include "../dialogs/tools/dialogtool.h"
#include "../dialogs/tools/dialogdetail.h"
#include "../dialogs/tools/dialogpatternpiecedata.h"
#include "../undocommands/savedetailoptions.h"
#include "../undocommands/movedetail.h"
#include "../undocommands/adddet.h"
@ -295,21 +294,17 @@ void VToolDetail::FullUpdateFromGuiOk(int result)
if (result == QDialog::Accepted)
{
SCASSERT(dialog != nullptr);
VDetail newDet;
VDetail oldDet = VAbstractTool::data.GetDetail(id);
DialogDetail *dialogTool = qobject_cast<DialogDetail*>(dialog);
//SCASSERT(dialogTool != nullptr);
SCASSERT(dialogTool != nullptr);
VDetail newDet = dialogTool->getDetail();
VDetail oldDet = VAbstractTool::data.GetDetail(id);
qDebug() << "VTOOL" << newDet.GetPatternPieceData().GetLetter()
<< newDet.GetPatternPieceData().GetName()
<< newDet.GetPatternPieceData().GetMCPCount()
<< dialogTool->getDetail().GetPatternPieceData().GetName();
if (dialogTool != nullptr)
{
newDet = dialogTool->getDetail();
}
else
{
DialogPatternPieceData* dialogPPD = qobject_cast<DialogPatternPieceData*>(dialog);
SCASSERT(dialogPPD != nullptr);
newDet = dialogPPD->GetDetail();
}
SaveDetailOptions *saveCommand = new SaveDetailOptions(oldDet, newDet, doc, id, this->scene());
connect(saveCommand, &SaveDetailOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
@ -551,7 +546,6 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
QMenu menu;
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
QAction* actionData = menu.addAction(tr("Details info"));
QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
if (_referens > 1)
{
@ -572,16 +566,6 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
setDialog();
dialog->show();
}
else if (selectedAction == actionData)
{
dialog = new DialogPatternPieceData(getData(), id, qApp->getMainWindow());
dialog->setModal(true);
connect(dialog, &DialogTool::DialogClosed, this, &VToolDetail::FullUpdateFromGuiOk);
VDetail detail = VAbstractTool::data.GetDetail(id);
qobject_cast<DialogPatternPieceData*>(dialog)->SetDetail(detail);
dialog->show();
}
else if (selectedAction == actionRemove)
{
try