Resolved issue #734. Optimization. Stop increments/variables table from
updating immediately. --HG-- branch : develop
This commit is contained in:
parent
51f89c9799
commit
a6bafb77e1
|
@ -11,6 +11,7 @@
|
|||
- [#669] Improve export: export labels as text in DXF.
|
||||
- [#716] Command line option to create *tiled* export.
|
||||
- [#660] New export: Export details without layout.
|
||||
- [#734] Optimization. Stop increments/variables table from updating immediately.
|
||||
|
||||
# Version 0.5.1
|
||||
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.
|
||||
|
|
|
@ -59,7 +59,8 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
|||
data(data),
|
||||
doc(doc),
|
||||
formulaBaseHeight(0),
|
||||
search()
|
||||
search(),
|
||||
hasChanges(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
@ -87,7 +88,6 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
|||
FillRadiusesArcs();
|
||||
FillAnglesCurves();
|
||||
|
||||
connect(this, &DialogIncrements::FullUpdateTree, this->doc, &VPattern::LiteParseTree);
|
||||
connect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile);
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
|
@ -109,6 +109,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
|||
connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term){search->Find(term);});
|
||||
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this](){search->FindPrevious();});
|
||||
connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this](){search->FindNext();});
|
||||
connect(ui->pushButtonRefresh, &QPushButton::clicked, this, &DialogIncrements::RefreshPattern);
|
||||
|
||||
connect(search.data(), &VTableSearch::HasResult, this, [this] (bool state)
|
||||
{
|
||||
|
@ -378,7 +379,10 @@ void DialogIncrements::Controls()
|
|||
{
|
||||
if (ui->tableWidgetIncrement->rowCount() > 0)
|
||||
{
|
||||
ui->toolButtonRemove->setEnabled(true);
|
||||
const QTableWidgetItem *nameField = ui->tableWidgetIncrement->item(ui->tableWidgetIncrement->currentRow(), 0);
|
||||
SCASSERT(nameField != nullptr)
|
||||
|
||||
ui->toolButtonRemove->setEnabled(not IncrementUsed(nameField->text()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -451,10 +455,15 @@ void DialogIncrements::EnableDetails(bool enabled)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief FullUpdateFromFile update information in tables form file
|
||||
*/
|
||||
void DialogIncrements::FullUpdateFromFile()
|
||||
void DialogIncrements::LocalUpdateTree()
|
||||
{
|
||||
doc->LiteParseIncrements();
|
||||
|
||||
UpdateTree();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogIncrements::UpdateTree()
|
||||
{
|
||||
ui->tableWidgetLines->clearContents();
|
||||
ui->tableWidgetSplines->clearContents();
|
||||
|
@ -473,6 +482,49 @@ void DialogIncrements::FullUpdateFromFile()
|
|||
search->RefreshList(ui->lineEditFind->text());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogIncrements::IncrementUsed(const QString &name) const
|
||||
{
|
||||
const QStringList expressions = doc->ListExpressions();
|
||||
|
||||
for(int i = 0; i < expressions.size(); ++i)
|
||||
{
|
||||
if (expressions.at(i).indexOf(name) != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief FullUpdateFromFile update information in tables form file
|
||||
*/
|
||||
void DialogIncrements::FullUpdateFromFile()
|
||||
{
|
||||
hasChanges = false;
|
||||
|
||||
UpdateTree();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogIncrements::RefreshPattern()
|
||||
{
|
||||
if (hasChanges)
|
||||
{
|
||||
const int row = ui->tableWidgetIncrement->currentRow();
|
||||
|
||||
doc->LiteParseTree(Document::LiteParse);
|
||||
|
||||
ui->tableWidgetIncrement->blockSignals(true);
|
||||
ui->tableWidgetIncrement->selectRow(row);
|
||||
ui->tableWidgetIncrement->blockSignals(false);
|
||||
|
||||
hasChanges = false;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief clickedToolButtonAdd create new row in table
|
||||
|
@ -496,7 +548,9 @@ void DialogIncrements::AddIncrement()
|
|||
doc->AddEmptyIncrementAfter(nameField->text(), name);
|
||||
}
|
||||
|
||||
FullUpdateTree(Document::LiteParse);
|
||||
hasChanges = true;
|
||||
LocalUpdateTree();
|
||||
|
||||
ui->tableWidgetIncrement->selectRow(currentRow);
|
||||
}
|
||||
|
||||
|
@ -516,7 +570,8 @@ void DialogIncrements::RemoveIncrement()
|
|||
const QTableWidgetItem *nameField = ui->tableWidgetIncrement->item(row, 0);
|
||||
doc->RemoveIncrement(nameField->text());
|
||||
|
||||
FullUpdateTree(Document::LiteParse);
|
||||
hasChanges = true;
|
||||
LocalUpdateTree();
|
||||
|
||||
if (ui->tableWidgetIncrement->rowCount() > 0)
|
||||
{
|
||||
|
@ -540,7 +595,10 @@ void DialogIncrements::MoveUp()
|
|||
|
||||
const QTableWidgetItem *nameField = ui->tableWidgetIncrement->item(row, 0);
|
||||
doc->MoveUpIncrement(nameField->text());
|
||||
FullUpdateTree(Document::LiteParse);
|
||||
|
||||
hasChanges = true;
|
||||
LocalUpdateTree();
|
||||
|
||||
ui->tableWidgetIncrement->selectRow(row-1);
|
||||
}
|
||||
|
||||
|
@ -556,7 +614,10 @@ void DialogIncrements::MoveDown()
|
|||
|
||||
const QTableWidgetItem *nameField = ui->tableWidgetIncrement->item(row, 0);
|
||||
doc->MoveDownIncrement(nameField->text());
|
||||
FullUpdateTree(Document::LiteParse);
|
||||
|
||||
hasChanges = true;
|
||||
LocalUpdateTree();
|
||||
|
||||
ui->tableWidgetIncrement->selectRow(row+1);
|
||||
}
|
||||
|
||||
|
@ -587,7 +648,10 @@ void DialogIncrements::SaveIncrName(const QString &text)
|
|||
}
|
||||
|
||||
doc->SetIncrementName(nameField->text(), newName);
|
||||
FullUpdateTree(Document::LiteParse);
|
||||
|
||||
hasChanges = true;
|
||||
LocalUpdateTree();
|
||||
|
||||
ui->tableWidgetIncrement->blockSignals(true);
|
||||
ui->tableWidgetIncrement->selectRow(row);
|
||||
ui->tableWidgetIncrement->blockSignals(false);
|
||||
|
@ -606,7 +670,7 @@ void DialogIncrements::SaveIncrDescription()
|
|||
const QTableWidgetItem *nameField = ui->tableWidgetIncrement->item(row, 0);
|
||||
doc->SetIncrementDescription(nameField->text(), ui->plainTextEditDescription->toPlainText());
|
||||
|
||||
FullUpdateTree(Document::LiteParse);
|
||||
LocalUpdateTree();
|
||||
|
||||
const QTextCursor cursor = ui->plainTextEditDescription->textCursor();
|
||||
ui->tableWidgetIncrement->blockSignals(true);
|
||||
|
@ -666,7 +730,8 @@ void DialogIncrements::SaveIncrFormula()
|
|||
return;
|
||||
}
|
||||
|
||||
FullUpdateTree(Document::LiteParse);
|
||||
hasChanges = true;
|
||||
LocalUpdateTree();
|
||||
|
||||
const QTextCursor cursor = ui->plainTextEditFormula->textCursor();
|
||||
ui->tableWidgetIncrement->blockSignals(true);
|
||||
|
@ -734,7 +799,10 @@ void DialogIncrements::Fx()
|
|||
// Because of the bug need to take QTableWidgetItem twice time. Previous update "killed" the pointer.
|
||||
const QTableWidgetItem *nameField = ui->tableWidgetIncrement->item(row, 0);
|
||||
doc->SetIncrementFormula(nameField->text(), dialog->GetFormula());
|
||||
FullUpdateTree(Document::LiteParse);
|
||||
|
||||
hasChanges = true;
|
||||
LocalUpdateTree();
|
||||
|
||||
ui->tableWidgetIncrement->selectRow(row);
|
||||
}
|
||||
delete dialog;
|
||||
|
@ -743,6 +811,8 @@ void DialogIncrements::Fx()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogIncrements::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
RefreshPattern();
|
||||
|
||||
ui->plainTextEditFormula->blockSignals(true);
|
||||
ui->lineEditName->blockSignals(true);
|
||||
ui->plainTextEditDescription->blockSignals(true);
|
||||
|
@ -819,6 +889,7 @@ void DialogIncrements::ShowIncrementDetails()
|
|||
ui->lineEditName->blockSignals(true);
|
||||
ui->lineEditName->setText(ClearIncrementName(incr->GetName()));
|
||||
ui->lineEditName->blockSignals(false);
|
||||
ui->lineEditName->setReadOnly(IncrementUsed(incr->GetName()));
|
||||
|
||||
ui->plainTextEditDescription->blockSignals(true);
|
||||
ui->plainTextEditDescription->setPlainText(incr->GetDescription());
|
||||
|
|
|
@ -50,12 +50,6 @@ public:
|
|||
DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent = nullptr);
|
||||
virtual ~DialogIncrements() Q_DECL_OVERRIDE;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief FullUpdateTree signal update data for dom document
|
||||
*/
|
||||
void FullUpdateTree(const Document &parse);
|
||||
|
||||
protected:
|
||||
virtual void closeEvent ( QCloseEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void changeEvent ( QEvent * event) Q_DECL_OVERRIDE;
|
||||
|
@ -72,6 +66,7 @@ private slots:
|
|||
void DeployFormula();
|
||||
void Fx();
|
||||
void FullUpdateFromFile();
|
||||
void RefreshPattern();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogIncrements)
|
||||
|
@ -89,6 +84,8 @@ private:
|
|||
|
||||
QSharedPointer<VTableSearch> search;
|
||||
|
||||
bool hasChanges;
|
||||
|
||||
template <typename T>
|
||||
void FillTable(const QMap<QString, T> &varTable, QTableWidget *table);
|
||||
|
||||
|
@ -111,6 +108,11 @@ private:
|
|||
bool EvalIncrementFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label);
|
||||
void Controls();
|
||||
void EnableDetails(bool enabled);
|
||||
|
||||
void LocalUpdateTree();
|
||||
void UpdateTree();
|
||||
|
||||
bool IncrementUsed(const QString &name) const;
|
||||
};
|
||||
|
||||
#endif // DIALOGINCREMENTS_H
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>979</width>
|
||||
<height>680</height>
|
||||
<height>729</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
|
@ -188,9 +188,6 @@
|
|||
<string>Details</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item alignment="Qt::AlignLeft">
|
||||
|
@ -427,14 +424,14 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QPlainTextEdit" name="plainTextEditDescription">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
|
@ -447,6 +444,33 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<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>
|
||||
<widget class="QPushButton" name="pushButtonRefresh">
|
||||
<property name="toolTip">
|
||||
<string>Refresh a pattern with all changes you made</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
|
@ -417,6 +417,77 @@ bool VPattern::SaveDocument(const QString &fileName, QString &error)
|
|||
return saved;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::LiteParseIncrements()
|
||||
{
|
||||
try
|
||||
{
|
||||
emit SetEnabledGUI(true);
|
||||
|
||||
VContainer::ClearUniqueIncrementNames();
|
||||
data->ClearVariables(VarType::Increment);
|
||||
|
||||
const QDomNodeList tags = elementsByTagName(TagIncrements);
|
||||
if (not tags.isEmpty())
|
||||
{
|
||||
const QDomNode domElement = tags.at(0);
|
||||
if (not domElement.isNull())
|
||||
{
|
||||
ParseIncrementsElement(domElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const VExceptionUndo &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
/* If user want undo last operation before undo we need finish broken redo operation. For those we post event
|
||||
* myself. Later in method customEvent call undo.*/
|
||||
QApplication::postEvent(this, new UndoEvent());
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionObjectError &e)
|
||||
{
|
||||
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), //-V807
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
emit SetEnabledGUI(false);
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionConversionError &e)
|
||||
{
|
||||
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value.")),
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
emit SetEnabledGUI(false);
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionEmptyParameter &e)
|
||||
{
|
||||
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")),
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
emit SetEnabledGUI(false);
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionWrongId &e)
|
||||
{
|
||||
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")),
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
emit SetEnabledGUI(false);
|
||||
return;
|
||||
}
|
||||
catch (VException &e)
|
||||
{
|
||||
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")),
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
emit SetEnabledGUI(false);
|
||||
return;
|
||||
}
|
||||
catch (const std::bad_alloc &)
|
||||
{
|
||||
qCCritical(vXML, "%s", qUtf8Printable(tr("Error parsing file (std::bad_alloc).")));
|
||||
emit SetEnabledGUI(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief LiteParseTree lite parse file.
|
||||
|
|
|
@ -94,6 +94,8 @@ public:
|
|||
bool IsReadOnly() const;
|
||||
void SetReadOnly(bool rOnly);
|
||||
|
||||
void LiteParseIncrements();
|
||||
|
||||
static const QString AttrReadOnly;
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -68,6 +68,7 @@ public:
|
|||
virtual ~VAbstractPattern() Q_DECL_EQ_DEFAULT;
|
||||
|
||||
QStringList ListMeasurements() const;
|
||||
QStringList ListExpressions() const;
|
||||
|
||||
virtual void CreateEmptyFile()=0;
|
||||
|
||||
|
@ -387,7 +388,6 @@ private:
|
|||
Q_DISABLE_COPY(VAbstractPattern)
|
||||
|
||||
QStringList ListIncrements() const;
|
||||
QStringList ListExpressions() const;
|
||||
QStringList ListPointExpressions() const;
|
||||
QStringList ListArcExpressions() const;
|
||||
QStringList ListElArcExpressions() const;
|
||||
|
|
|
@ -693,6 +693,21 @@ void VContainer::ClearUniqueNames()
|
|||
uniqueNames.clear();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VContainer::ClearUniqueIncrementNames()
|
||||
{
|
||||
const QList<QString> list = uniqueNames.toList();
|
||||
ClearUniqueNames();
|
||||
|
||||
for(int i = 0; i < list.size(); ++i)
|
||||
{
|
||||
if (not list.at(i).startsWith('#'))
|
||||
{
|
||||
uniqueNames.insert(list.at(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SetSize set value of size
|
||||
|
|
|
@ -170,6 +170,7 @@ public:
|
|||
void ClearCalculationGObjects();
|
||||
void ClearVariables(const VarType &type = VarType::Unknown);
|
||||
static void ClearUniqueNames();
|
||||
static void ClearUniqueIncrementNames();
|
||||
|
||||
static void SetSize(qreal size);
|
||||
static void SetHeight(qreal height);
|
||||
|
|
Loading…
Reference in New Issue
Block a user