Fix export increments and preview calculations.
Separate both types. First write increments then preview calculations. --HG-- branch : feature
This commit is contained in:
parent
661e71bad0
commit
4caab9a479
|
@ -1499,16 +1499,23 @@ void MainWindow::ExportToCSVData(const QString &fileName, const DialogExportToCS
|
||||||
}
|
}
|
||||||
|
|
||||||
const QMap<QString, QSharedPointer<VIncrement> > increments = pattern->DataIncrements();
|
const QMap<QString, QSharedPointer<VIncrement> > increments = pattern->DataIncrements();
|
||||||
|
|
||||||
|
qint32 currentRow = -1;
|
||||||
|
|
||||||
|
auto SavePreviewCalculation = [¤tRow, &csv, increments](bool save)
|
||||||
|
{
|
||||||
QMap<QString, QSharedPointer<VIncrement> >::const_iterator i;
|
QMap<QString, QSharedPointer<VIncrement> >::const_iterator i;
|
||||||
QMap<quint32, QString> map;
|
QMap<quint32, QString> map;
|
||||||
//Sorting QHash by id
|
//Sorting QHash by id
|
||||||
for (i = increments.constBegin(); i != increments.constEnd(); ++i)
|
for (i = increments.constBegin(); i != increments.constEnd(); ++i)
|
||||||
{
|
{
|
||||||
QSharedPointer<VIncrement> incr = i.value();
|
const QSharedPointer<VIncrement> incr = i.value();
|
||||||
|
if (incr->IsPreviewCalculation() == save)
|
||||||
|
{
|
||||||
map.insert(incr->getIndex(), i.key());
|
map.insert(incr->getIndex(), i.key());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qint32 currentRow = -1;
|
|
||||||
QMapIterator<quint32, QString> iMap(map);
|
QMapIterator<quint32, QString> iMap(map);
|
||||||
while (iMap.hasNext())
|
while (iMap.hasNext())
|
||||||
{
|
{
|
||||||
|
@ -1520,9 +1527,14 @@ void MainWindow::ExportToCSVData(const QString &fileName, const DialogExportToCS
|
||||||
csv.setText(currentRow, 0, incr->GetName()); // name
|
csv.setText(currentRow, 0, incr->GetName()); // name
|
||||||
csv.setText(currentRow, 1, qApp->LocaleToString(*incr->GetValue())); // calculated value
|
csv.setText(currentRow, 1, qApp->LocaleToString(*incr->GetValue())); // calculated value
|
||||||
|
|
||||||
QString formula = VTranslateVars::TryFormulaToUser(incr->GetFormula(), qApp->Settings()->GetOsSeparator());
|
QString formula = VTranslateVars::TryFormulaToUser(incr->GetFormula(),
|
||||||
|
qApp->Settings()->GetOsSeparator());
|
||||||
csv.setText(currentRow, 2, formula); // formula
|
csv.setText(currentRow, 2, formula); // formula
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SavePreviewCalculation(false);
|
||||||
|
SavePreviewCalculation(true);
|
||||||
|
|
||||||
csv.toCSV(fileName, dialog.WithHeader(), dialog.Separator(), QTextCodec::codecForMib(dialog.SelectedMib()));
|
csv.toCSV(fileName, dialog.WithHeader(), dialog.Separator(), QTextCodec::codecForMib(dialog.SelectedMib()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,8 @@ VIncrement::~VIncrement()
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief getIndex return index of row
|
* @brief getIndex return index of row. Row index for increments and preview calucalations is unique. Check type before
|
||||||
|
* using.
|
||||||
* @return index
|
* @return index
|
||||||
*/
|
*/
|
||||||
quint32 VIncrement::getIndex() const
|
quint32 VIncrement::getIndex() const
|
||||||
|
|
Loading…
Reference in New Issue
Block a user