Don't use combobox instead return list of pattern pieces.
--HG-- branch : feature
This commit is contained in:
parent
34f9451460
commit
c03464144e
|
@ -90,7 +90,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
pattern = new VContainer();
|
||||
|
||||
doc = new VPattern(pattern, comboBoxDraws, &mode);
|
||||
doc = new VPattern(pattern, &mode, sceneDraw, sceneDetails);
|
||||
connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternWasModified);
|
||||
connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear);
|
||||
|
||||
|
@ -1884,20 +1884,9 @@ void MainWindow::LoadPattern(const QString &fileName)
|
|||
return;
|
||||
}
|
||||
|
||||
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &MainWindow::currentDrawChanged);
|
||||
try
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
#endif
|
||||
|
||||
doc->Parse(Document::FullParse, sceneDraw, sceneDetails);
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::restoreOverrideCursor();
|
||||
#endif
|
||||
ui->actionPattern_properties->setEnabled(true);
|
||||
}
|
||||
catch (const VExceptionObjectError &e)
|
||||
{
|
||||
|
@ -1948,8 +1937,15 @@ void MainWindow::LoadPattern(const QString &fileName)
|
|||
Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &MainWindow::currentDrawChanged);
|
||||
comboBoxDraws->clear();
|
||||
comboBoxDraws->addItems(doc->getPatternPieces());
|
||||
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &MainWindow::currentDrawChanged);
|
||||
ui->actionPattern_properties->setEnabled(true);
|
||||
|
||||
QString nameDraw = doc->GetNameActivDraw();
|
||||
qint32 index = comboBoxDraws->findText(nameDraw);
|
||||
if ( index != -1 )
|
||||
|
|
|
@ -70,10 +70,15 @@ const QString VPattern::IncrementKgrowth = QStringLiteral("kgrowth");
|
|||
const QString VPattern::IncrementDescription = QStringLiteral("description");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPattern::VPattern(VContainer *data, QComboBox *comboBoxDraws, Valentina::Draws *mode, QObject *parent)
|
||||
VPattern::VPattern(VContainer *data, Valentina::Draws *mode, VMainGraphicsScene *sceneDraw,
|
||||
VMainGraphicsScene *sceneDetail, QObject *parent)
|
||||
: QObject(parent), VDomDocument(data), nameActivDraw(QString()), tools(QHash<quint32, VDataTool*>()),
|
||||
history(QVector<VToolRecord>()), cursor(0), comboBoxDraws(comboBoxDraws), mode(mode), patternModified(false)
|
||||
{}
|
||||
history(QVector<VToolRecord>()), cursor(0), patternPieces(QStringList()), mode(mode), patternModified(false),
|
||||
sceneDraw(sceneDraw), sceneDetail(sceneDetail)
|
||||
{
|
||||
SCASSERT(sceneDraw != nullptr);
|
||||
SCASSERT(sceneDetail != nullptr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -237,6 +242,9 @@ bool VPattern::SetNameDraw(const QString &name)
|
|||
*/
|
||||
void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
#endif
|
||||
Q_CHECK_PTR(sceneDraw);
|
||||
Q_CHECK_PTR(sceneDetail);
|
||||
PrepareForParse(parse, sceneDraw, sceneDetail);
|
||||
|
@ -263,7 +271,7 @@ void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *scene
|
|||
{
|
||||
ChangeActivDraw(GetParametrString(domElement, AttrName));
|
||||
}
|
||||
comboBoxDraws->addItem(GetParametrString(domElement, AttrName));
|
||||
patternPieces << GetParametrString(domElement, AttrName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -292,6 +300,9 @@ void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *scene
|
|||
}
|
||||
domNode = domNode.nextSibling();
|
||||
}
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::restoreOverrideCursor();
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -331,15 +342,17 @@ void VPattern::setCursor(const quint32 &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setCurrentData set current data set.
|
||||
*
|
||||
* Each time after parsing need set correct data set for current pattern piece. After parsing it is always last.
|
||||
* Current data set for pattern pice it is data set for last object in pattern pice (point, arc, spline, spline path so
|
||||
* on).
|
||||
*/
|
||||
void VPattern::setCurrentData()
|
||||
{
|
||||
if (*mode == Valentina::Calculation)
|
||||
{
|
||||
const QString nameDraw = comboBoxDraws->itemText(comboBoxDraws->currentIndex());
|
||||
if (nameActivDraw != nameDraw)
|
||||
if (patternPieces.size() > 1)//don't need upadate data if we have only one pattern piece
|
||||
{
|
||||
nameActivDraw = nameDraw;
|
||||
quint32 id = 0;
|
||||
if (history.size() == 0)
|
||||
{
|
||||
|
@ -348,7 +361,7 @@ void VPattern::setCurrentData()
|
|||
for (qint32 i = 0; i < history.size(); ++i)
|
||||
{
|
||||
const VToolRecord tool = history.at(i);
|
||||
if (tool.getNameDraw() == nameDraw)
|
||||
if (tool.getNameDraw() == nameActivDraw)
|
||||
{
|
||||
id = tool.getId();
|
||||
}
|
||||
|
@ -737,6 +750,7 @@ void VPattern::ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable)
|
|||
emit ShowTool(id, color, enable);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ParseDrawElement parse draw tag.
|
||||
|
@ -1833,7 +1847,7 @@ void VPattern::PrepareForParse(const Document::Documents &parse, VMainGraphicsSc
|
|||
nameActivDraw.clear();
|
||||
sceneDraw->clear();
|
||||
sceneDetail->clear();
|
||||
comboBoxDraws->clear();
|
||||
patternPieces.clear();
|
||||
tools.clear();
|
||||
cursor = 0;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,8 @@ class VPattern : public QObject, public VDomDocument
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VPattern(VContainer *data, QComboBox *comboBoxDraws, Valentina::Draws *mode, QObject *parent = nullptr);
|
||||
VPattern(VContainer *data, Valentina::Draws *mode, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
||||
QObject *parent = nullptr);
|
||||
void CreateEmptyFile(const QString &tablePath);
|
||||
void ChangeActivDraw(const QString& name, const Document::Documents &parse = Document::FullParse);
|
||||
QString GetNameActivDraw() const;
|
||||
|
@ -115,6 +116,7 @@ public:
|
|||
static const QString IncrementKgrowth;
|
||||
static const QString IncrementDescription;
|
||||
virtual bool SaveDocument(const QString &fileName);
|
||||
QStringList getPatternPieces() const;
|
||||
signals:
|
||||
/**
|
||||
* @brief ChangedActivDraw change active pattern peace.
|
||||
|
@ -167,7 +169,7 @@ private:
|
|||
/** @brief cursor cursor keep id tool after which we will add new tool in file. */
|
||||
quint32 cursor;
|
||||
|
||||
QComboBox *comboBoxDraws;
|
||||
QStringList patternPieces;
|
||||
|
||||
/** @brief mode current draw mode. */
|
||||
Valentina::Draws *mode;
|
||||
|
@ -175,6 +177,9 @@ private:
|
|||
/** @brief fileModified true if exist change in file. */
|
||||
bool patternModified;
|
||||
|
||||
VMainGraphicsScene *sceneDraw;
|
||||
VMainGraphicsScene *sceneDetail;
|
||||
|
||||
bool CheckNameDraw(const QString& name) const;
|
||||
void SetActivDraw(const QString& name);
|
||||
void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
||||
|
@ -255,4 +260,10 @@ inline void VPattern::setPatternModified(bool value)
|
|||
patternModified = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline QStringList VPattern::getPatternPieces() const
|
||||
{
|
||||
return patternPieces;
|
||||
}
|
||||
|
||||
#endif // VPATTERN_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user