Merged dismine/valentina into develop

--HG--
branch : develop
This commit is contained in:
Ronan Le Tiec 2018-04-06 21:58:09 +02:00
commit a56c41589c
110 changed files with 846 additions and 668 deletions

View File

@ -41,6 +41,8 @@ win32 {
../../../dist/win/msvcr120.dll ../../../dist/win/msvcr120.dll
} }
DEFINES += QT_NO_FOREACH
macx{ macx{
# QTBUG-31034 qmake doesn't allow override QMAKE_CXX # QTBUG-31034 qmake doesn't allow override QMAKE_CXX
CONFIG+=no_ccache CONFIG+=no_ccache

View File

@ -438,9 +438,9 @@ void DialogMDataBase::InitGroup(QTreeWidgetItem **group, const QString &groupNam
const QStringList &list) const QStringList &list)
{ {
*group = AddGroup(groupName); *group = AddGroup(groupName);
for (int i=0; i < mList.size(); ++i) for (auto &m : mList)
{ {
AddMeasurement(*group, mList.at(i), list); AddMeasurement(*group, m, list);
} }
} }

View File

@ -252,11 +252,7 @@ MApplication::MApplication(int &argc, char **argv)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MApplication::~MApplication() MApplication::~MApplication()
{ {
for (int i = 0; i < mainWindows.size(); ++i) qDeleteAll(mainWindows);
{
TMainWindow *window = mainWindows.at(i);
delete window;
}
delete trVars; delete trVars;
if (not dataBase.isNull()) if (not dataBase.isNull())
@ -368,9 +364,9 @@ QList<TMainWindow *> MApplication::MainWindows()
{ {
Clean(); Clean();
QList<TMainWindow*> list; QList<TMainWindow*> list;
for (int i = 0; i < mainWindows.count(); ++i) for (auto &w : mainWindows)
{ {
list.append(mainWindows.at(i)); list.append(w);
} }
return list; return list;
} }
@ -536,10 +532,10 @@ void MApplication::RetranslateGroups()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MApplication::RetranslateTables() void MApplication::RetranslateTables()
{ {
QList<TMainWindow*> list = MainWindows(); const QList<TMainWindow*> list = MainWindows();
for (int i=0; i < list.size(); ++i) for (auto w : list)
{ {
list.at(i)->RetranslateTable(); w->RetranslateTable();
} }
} }
@ -689,10 +685,10 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
parser.showHelp(V_EX_USAGE); parser.showHelp(V_EX_USAGE);
} }
for (int i = 0; i < args.size(); ++i) for (auto &arg : args)
{ {
NewMainWindow(); NewMainWindow();
if (not MainWindow()->LoadFile(args.at(i))) if (not MainWindow()->LoadFile(arg))
{ {
if (testMode) if (testMode)
{ {

View File

@ -226,12 +226,12 @@ bool TMainWindow::LoadFile(const QString &path)
} }
// Check if file already opened // Check if file already opened
QList<TMainWindow*>list = qApp->MainWindows(); const QList<TMainWindow*> list = qApp->MainWindows();
for (int i = 0; i < list.size(); ++i) for (auto w : list)
{ {
if (list.at(i)->CurrentFile() == path) if (w->CurrentFile() == path)
{ {
list.at(i)->activateWindow(); w->activateWindow();
close(); close();
return false; return false;
} }
@ -526,6 +526,15 @@ void TMainWindow::ToolBarStyles()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::closeEvent(QCloseEvent *event) void TMainWindow::closeEvent(QCloseEvent *event)
{ {
#if defined(Q_OS_MAC)
// Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344
static int numCalled = 0;
if (numCalled++ >= 1)
{
return;
}
#endif
if (MaybeSave()) if (MaybeSave())
{ {
WriteSettings(); WriteSettings();
@ -970,8 +979,11 @@ void TMainWindow::ImportDataFromCSV()
const QString filters = tr("Comma-Separated Values") + QLatin1String(" (*.csv)"); const QString filters = tr("Comma-Separated Values") + QLatin1String(" (*.csv)");
const QString suffix("csv"); const QString suffix("csv");
QString fileName = QFileDialog::getOpenFileName(this, tr("Import from CSV"), QDir::homePath(), filters, nullptr, QString fileName = QFileDialog::getOpenFileName(this, tr("Import from CSV"), QDir::homePath(), filters, nullptr
QFileDialog::DontUseNativeDialog); #ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
@ -1354,15 +1366,15 @@ void TMainWindow::AddKnown()
if (ui->tableWidget->currentRow() == -1) if (ui->tableWidget->currentRow() == -1)
{ {
currentRow = ui->tableWidget->rowCount() + list.size() - 1; currentRow = ui->tableWidget->rowCount() + list.size() - 1;
for (int i = 0; i < list.size(); ++i) for (auto &name : list)
{ {
if (mType == MeasurementsType::Individual) if (mType == MeasurementsType::Individual)
{ {
m->AddEmpty(list.at(i), qApp->TrVars()->MFormula(list.at(i))); m->AddEmpty(name, qApp->TrVars()->MFormula(name));
} }
else else
{ {
m->AddEmpty(list.at(i)); m->AddEmpty(name);
} }
search->AddRow(currentRow); search->AddRow(currentRow);
@ -1373,18 +1385,18 @@ void TMainWindow::AddKnown()
currentRow = ui->tableWidget->currentRow() + list.size(); currentRow = ui->tableWidget->currentRow() + list.size();
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
QString after = nameField->data(Qt::UserRole).toString(); QString after = nameField->data(Qt::UserRole).toString();
for (int i = 0; i < list.size(); ++i) for (auto &name : list)
{ {
if (mType == MeasurementsType::Individual) if (mType == MeasurementsType::Individual)
{ {
m->AddEmptyAfter(after, list.at(i), qApp->TrVars()->MFormula(list.at(i))); m->AddEmptyAfter(after, name, qApp->TrVars()->MFormula(name));
} }
else else
{ {
m->AddEmptyAfter(after, list.at(i)); m->AddEmptyAfter(after, name);
} }
search->AddRow(currentRow); search->AddRow(currentRow);
after = list.at(i); after = name;
} }
} }
@ -1448,9 +1460,9 @@ void TMainWindow::ImportFromPattern()
if (ui->tableWidget->currentRow() == -1) if (ui->tableWidget->currentRow() == -1)
{ {
currentRow = ui->tableWidget->rowCount() + measurements.size() - 1; currentRow = ui->tableWidget->rowCount() + measurements.size() - 1;
for (int i = 0; i < measurements.size(); ++i) for (auto &mName : measurements)
{ {
m->AddEmpty(measurements.at(i)); m->AddEmpty(mName);
} }
} }
else else
@ -1458,10 +1470,10 @@ void TMainWindow::ImportFromPattern()
currentRow = ui->tableWidget->currentRow() + measurements.size(); currentRow = ui->tableWidget->currentRow() + measurements.size();
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
QString after = nameField->data(Qt::UserRole).toString(); QString after = nameField->data(Qt::UserRole).toString();
for (int i = 0; i < measurements.size(); ++i) for (auto &mName : measurements)
{ {
m->AddEmptyAfter(after, measurements.at(i)); m->AddEmptyAfter(after, mName);
after = measurements.at(i); after = mName;
} }
} }
@ -2843,12 +2855,12 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
} }
// Check if file already opened // Check if file already opened
QList<TMainWindow*>list = qApp->MainWindows(); const QList<TMainWindow*> list = qApp->MainWindows();
for (int i = 0; i < list.size(); ++i) for (auto w : list)
{ {
if (list.at(i)->CurrentFile() == path) if (w->CurrentFile() == path)
{ {
list.at(i)->activateWindow(); w->activateWindow();
close(); close();
return false; return false;
} }
@ -2984,7 +2996,7 @@ void TMainWindow::CreateWindowMenu(QMenu *menu)
SCASSERT(menu != nullptr) SCASSERT(menu != nullptr)
QAction *action = menu->addAction(tr("&New Window")); QAction *action = menu->addAction(tr("&New Window"));
connect(action, &QAction::triggered, this, [this]() connect(action, &QAction::triggered, this, []()
{ {
qApp->NewMainWindow(); qApp->NewMainWindow();
qApp->MainWindow()->activateWindow(); qApp->MainWindow()->activateWindow();
@ -3214,18 +3226,18 @@ void TMainWindow::ImportIndividualMeasurements(const QxtCsvModel &csv)
} }
} }
for(int i=0; i < measurements.size(); ++i) for(auto im : qAsConst(measurements))
{ {
m->AddEmpty(measurements.at(i).name, measurements.at(i).value); m->AddEmpty(im.name, im.value);
if (not measurements.at(i).fullName.isEmpty()) if (not im.fullName.isEmpty())
{ {
m->SetMFullName(measurements.at(i).name, measurements.at(i).fullName); m->SetMFullName(im.name, im.fullName);
} }
if (not measurements.at(i).description.isEmpty()) if (not im.description.isEmpty())
{ {
m->SetMDescription(measurements.at(i).name, measurements.at(i).description); m->SetMDescription(im.name, im.description);
} }
} }
@ -3244,7 +3256,7 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv)
return; return;
} }
auto ConverToDouble = [this](QString text, const QString &error) auto ConverToDouble = [](QString text, const QString &error)
{ {
text = VTranslateVars::TryFormulaFromUser(text, qApp->Settings()->GetOsSeparator()); text = VTranslateVars::TryFormulaFromUser(text, qApp->Settings()->GetOsSeparator());
bool ok = false; bool ok = false;
@ -3324,21 +3336,21 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv)
} }
} }
for(int i=0; i < measurements.size(); ++i) for(auto mm : qAsConst(measurements))
{ {
m->AddEmpty(measurements.at(i).name); m->AddEmpty(mm.name);
m->SetMBaseValue(measurements.at(i).name, measurements.at(i).base); m->SetMBaseValue(mm.name, mm.base);
m->SetMSizeIncrease(measurements.at(i).name, measurements.at(i).sizeIncrease); m->SetMSizeIncrease(mm.name, mm.sizeIncrease);
m->SetMHeightIncrease(measurements.at(i).name, measurements.at(i).heightIncrease); m->SetMHeightIncrease(mm.name, mm.heightIncrease);
if (not measurements.at(i).fullName.isEmpty()) if (not mm.fullName.isEmpty())
{ {
m->SetMFullName(measurements.at(i).name, measurements.at(i).fullName); m->SetMFullName(mm.name, mm.fullName);
} }
if (not measurements.at(i).description.isEmpty()) if (not mm.description.isEmpty())
{ {
m->SetMDescription(measurements.at(i).name, measurements.at(i).description); m->SetMDescription(mm.name, mm.description);
} }
} }

View File

@ -513,9 +513,8 @@ void VApplication::ClearOldLogs() const
if (allFiles.isEmpty() == false) if (allFiles.isEmpty() == false)
{ {
qCDebug(vApp, "Clearing old logs"); qCDebug(vApp, "Clearing old logs");
for (int i = 0, sz = allFiles.size(); i < sz; ++i) for (auto &fn : allFiles)
{ {
auto fn = allFiles.at(i);
QFileInfo info(fn); QFileInfo info(fn);
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
const QDateTime created = info.birthTime(); const QDateTime created = info.birthTime();

View File

@ -139,8 +139,8 @@ VPE::VProperty *VFormulaProperty::clone(bool include_children, VProperty *contai
if (!include_children) if (!include_children)
{ {
QList<VProperty*> tmpChildren = container->getChildren(); const QList<VProperty*> tmpChildren = container->getChildren();
foreach (VProperty* tmpChild, tmpChildren) for (auto tmpChild : tmpChildren)
{ {
container->removeChild(tmpChild); container->removeChild(tmpChild);
delete tmpChild; delete tmpChild;

View File

@ -35,6 +35,7 @@
#include <QColorDialog> #include <QColorDialog>
#include <QDebug> #include <QDebug>
#include <QRegularExpression> #include <QRegularExpression>
#include <QSpacerItem>
#include "../vpropertyexplorer/vproperty.h" #include "../vpropertyexplorer/vproperty.h"
#include "../vtools/dialogs/support/dialogeditwrongformula.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h"
@ -42,7 +43,7 @@
// VFormulaPropertyEditor // VFormulaPropertyEditor
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent) VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent)
: QWidget(parent), formula(VFormula()), ToolButton(nullptr), TextLabel(nullptr), Spacer(nullptr) : QWidget(parent), formula(VFormula()), ToolButton(nullptr), TextLabel(nullptr)
{ {
setAutoFillBackground(true); setAutoFillBackground(true);
@ -61,15 +62,13 @@ VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent)
TextLabel = new QLabel(this); TextLabel = new QLabel(this);
TextLabel->setText(formula.getStringValue()); TextLabel->setText(formula.getStringValue());
// Spacer (this is needed for proper display of the label and button)
Spacer = new QSpacerItem(1, 0, QSizePolicy::Expanding, QSizePolicy::Ignored);
// The layout (a horizontal layout) // The layout (a horizontal layout)
QHBoxLayout* layout = new QHBoxLayout(this); QHBoxLayout* layout = new QHBoxLayout(this);
layout->setSpacing(3); layout->setSpacing(3);
layout->setMargin(0); layout->setMargin(0);
layout->addWidget(TextLabel); layout->addWidget(TextLabel);
layout->addItem(Spacer); // Spacer (this is needed for proper display of the label and button)
layout->addSpacerItem(new QSpacerItem(1000000000, 0, QSizePolicy::Expanding, QSizePolicy::Expanding));
layout->addWidget(ToolButton); layout->addWidget(ToolButton);
} }

View File

@ -33,7 +33,6 @@
#include <QToolButton> #include <QToolButton>
#include <QLineEdit> #include <QLineEdit>
#include <QLabel> #include <QLabel>
#include <QSpacerItem>
#include "../vpatterndb/vformula.h" #include "../vpatterndb/vformula.h"
@ -72,7 +71,6 @@ private:
VFormula formula; VFormula formula;
QToolButton* ToolButton; QToolButton* ToolButton;
QLabel* TextLabel; QLabel* TextLabel;
QSpacerItem* Spacer;
}; };

View File

@ -765,9 +765,9 @@ void VToolOptionsPropertyBrowser::SetOperationSuffix(const QString &suffix)
QRegularExpression rx(NameRegExp()); QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = VContainer::AllUniqueNames(); const QStringList uniqueNames = VContainer::AllUniqueNames();
for (int i=0; i < uniqueNames.size(); ++i) for (auto &uniqueName : uniqueNames)
{ {
const QString name = uniqueNames.at(i) + suffix; const QString name = uniqueName + suffix;
if (not rx.match(name).hasMatch() || not VContainer::IsUnique(name)) if (not rx.match(name).hasMatch() || not VContainer::IsUnique(name))
{ {
idToProperty[AttrSuffix]->setValue(item->Suffix()); idToProperty[AttrSuffix]->setValue(item->Suffix());

View File

@ -179,10 +179,9 @@ void PreferencesConfigurationPage::changeEvent(QEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::SetLabelComboBox(const QStringList &list) void PreferencesConfigurationPage::SetLabelComboBox(const QStringList &list)
{ {
for (int i = 0; i < list.size(); ++i) for (auto &name : list)
{ {
QLocale loc = QLocale(list.at(i)); ui->labelCombo->addItem(QLocale(name).nativeLanguageName(), name);
ui->labelCombo->addItem(loc.nativeLanguageName(), list.at(i));
} }
} }

View File

@ -148,7 +148,10 @@ void PreferencesPathPage::EditPath()
const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path, const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path,
QFileDialog::ShowDirsOnly QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks | QFileDialog::DontResolveSymlinks
| QFileDialog::DontUseNativeDialog); #ifdef Q_OS_LINUX
| QFileDialog::DontUseNativeDialog
#endif
);
if (dir.isEmpty()) if (dir.isEmpty())
{ {
if (usedNotExistedDir) if (usedNotExistedDir)

View File

@ -61,7 +61,7 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) :
ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR)); ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR));
connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, [this]() connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []()
{ {
if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false) if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false)
{ {

View File

@ -165,14 +165,14 @@ void DialogDateTimeFormats::SetFormatLines(const QStringList &predefined, const
int row = -1; int row = -1;
for (int i=0; i<predefined.size(); ++i) for (auto &item : predefined)
{ {
ui->listWidget->insertItem(++row, AddListLine(predefined.at(i))); ui->listWidget->insertItem(++row, AddListLine(item));
} }
for (int i=0; i<userDefined.size(); ++i) for (auto &item : userDefined)
{ {
ui->listWidget->insertItem(++row, AddListLine(userDefined.at(i))); ui->listWidget->insertItem(++row, AddListLine(item));
} }
ui->listWidget->blockSignals(false); ui->listWidget->blockSignals(false);

View File

@ -585,15 +585,14 @@ bool DialogIncrements::IncrementUsed(const QString &name) const
{ {
const QVector<VFormulaField> expressions = doc->ListExpressions(); const QVector<VFormulaField> expressions = doc->ListExpressions();
for(int i = 0; i < expressions.size(); ++i) for(auto field : expressions)
{ {
if (expressions.at(i).expression.indexOf(name) != -1) if (field.expression.indexOf(name) != -1)
{ {
// Eval formula // Eval formula
try try
{ {
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(expressions.at(i).expression, false, QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(field.expression, false, false));
false));
// Tokens (variables, measurements) // Tokens (variables, measurements)
if (cal->GetTokens().values().contains(name)) if (cal->GetTokens().values().contains(name))
@ -728,9 +727,9 @@ void DialogIncrements::RefreshPattern()
if (hasChanges) if (hasChanges)
{ {
QVector<VFormulaField> expressions = doc->ListExpressions(); QVector<VFormulaField> expressions = doc->ListExpressions();
for (int i = 0; i < renameList.size(); ++i) for (auto &item : renameList)
{ {
doc->ReplaceNameInFormula(expressions, renameList.at(i).first, renameList.at(i).second); doc->ReplaceNameInFormula(expressions, item.first, item.second);
} }
renameList.clear(); renameList.clear();

View File

@ -62,12 +62,11 @@ void DialogKnownMaterials::SetList(const QStringList &list)
int row = -1; int row = -1;
for (int i=0; i<list.size(); ++i) for (auto &m : list)
{ {
if (not list.at(i).isEmpty()) if (not m.isEmpty())
{ {
QListWidgetItem *item = new QListWidgetItem(list.at(i)); ui->listWidget->insertItem(++row, new QListWidgetItem(m));
ui->listWidget->insertItem(++row, item);
} }
} }

View File

@ -746,9 +746,9 @@ void DialogLayoutSettings::InitPrinter()
QStringList printerNames; QStringList printerNames;
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
const QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters(); const QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
for(int i = 0; i < printers.size(); ++i) for(auto printer : printers)
{ {
const QString name = printers.at(i).printerName(); const QString name = printer.printerName();
if (not name.isEmpty()) if (not name.isEmpty())
{ {
printerNames.append(name); printerNames.append(name);

View File

@ -44,11 +44,11 @@ QStringList PrepareKnowMaterials(const QStringList &patternMaterials, bool remem
if (rememberPM) if (rememberPM)
{ {
for(int i=0; i < patternMaterials.size(); ++i) for(auto &patternMaterial : patternMaterials)
{ {
if (not patternMaterials.at(i).isEmpty() && not knownMaterials.contains(patternMaterials.at(i))) if (not patternMaterial.isEmpty() && not knownMaterials.contains(patternMaterial))
{ {
knownMaterials.append(patternMaterials.at(i)); knownMaterials.append(patternMaterial);
} }
} }
} }

View File

@ -100,7 +100,7 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
} }
ui->lineEditPathToFile->setCursorPosition(0); ui->lineEditPathToFile->setCursorPosition(0);
connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, [this]() connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, []()
{ {
ShowInGraphicalShell(qApp->GetPPath()); ShowInGraphicalShell(qApp->GetPPath());
}); });
@ -837,8 +837,11 @@ void DialogPatternProperties::InitImage()
void DialogPatternProperties::ChangeImage() void DialogPatternProperties::ChangeImage()
{ {
const QString filter = tr("Images") + QLatin1String(" (*.png *.jpg *.jpeg *.bmp)"); const QString filter = tr("Images") + QLatin1String(" (*.png *.jpg *.jpeg *.bmp)");
const QString fileName = QFileDialog::getOpenFileName(this, tr("Image for pattern"), QString(), filter, nullptr, const QString fileName = QFileDialog::getOpenFileName(this, tr("Image for pattern"), QString(), filter, nullptr
QFileDialog::DontUseNativeDialog); #ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
if (not fileName.isEmpty()) if (not fileName.isEmpty())
{ {
QImage image; QImage image;
@ -879,8 +882,11 @@ void DialogPatternProperties::SaveImage()
QByteArray ba = QByteArray::fromBase64(byteArray); QByteArray ba = QByteArray::fromBase64(byteArray);
const QString extension = QLatin1String(".") + doc->GetImageExtension(); const QString extension = QLatin1String(".") + doc->GetImageExtension();
QString filter = tr("Images") + QLatin1String(" (*") + extension + QLatin1String(")"); QString filter = tr("Images") + QLatin1String(" (*") + extension + QLatin1String(")");
QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), tr("untitled"), filter, &filter, QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), tr("untitled"), filter, &filter
QFileDialog::DontUseNativeDialog); #ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
if (not filename.isEmpty()) if (not filename.isEmpty())
{ {
if (not filename.endsWith(extension.toUpper())) if (not filename.endsWith(extension.toUpper()))

View File

@ -95,7 +95,7 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
} }
} }
foreach (auto& v, InitFormats()) for (auto &v : InitFormats())
{ {
ui->comboBoxFormat->addItem(v.first, QVariant(static_cast<int>(v.second))); ui->comboBoxFormat->addItem(v.first, QVariant(static_cast<int>(v.second)));
} }
@ -129,7 +129,10 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder"), dirPath, const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder"), dirPath,
QFileDialog::ShowDirsOnly QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks | QFileDialog::DontResolveSymlinks
| QFileDialog::DontUseNativeDialog); #ifdef Q_OS_LINUX
| QFileDialog::DontUseNativeDialog
#endif
);
if (not dir.isEmpty()) if (not dir.isEmpty())
{// If paths equal the signal will not be called, we will do this manually {// If paths equal the signal will not be called, we will do this manually
dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir); dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir);

View File

@ -62,7 +62,7 @@ void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates)
const QString pdi = QString("(%1ppi)").arg(PrintDPI); const QString pdi = QString("(%1ppi)").arg(PrintDPI);
auto cntr = static_cast<VIndexType>(PaperSizeTemplate::A0); auto cntr = static_cast<VIndexType>(PaperSizeTemplate::A0);
foreach(const auto& v, pageFormatNames) for(const auto& v : pageFormatNames)
{ {
if (cntr <= static_cast<int>(PaperSizeTemplate::Legal)) if (cntr <= static_cast<int>(PaperSizeTemplate::Legal))
{ {

View File

@ -1518,6 +1518,15 @@ void MainWindow::changeEvent(QEvent *event)
*/ */
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
#if defined(Q_OS_MAC)
// Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344
static int numCalled = 0;
if (numCalled++ >= 1)
{
return;
}
#endif
qCDebug(vMainWindow, "Closing main window"); qCDebug(vMainWindow, "Closing main window");
if (MaybeSave()) if (MaybeSave())
{ {
@ -1660,8 +1669,11 @@ void MainWindow::LoadIndividual()
usedNotExistedDir = directory.mkpath("."); usedNotExistedDir = directory.mkpath(".");
} }
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr, const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr
QFileDialog::DontUseNativeDialog); #ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
if (not mPath.isEmpty()) if (not mPath.isEmpty())
{ {
@ -1698,8 +1710,11 @@ void MainWindow::LoadMultisize()
//Use standard path to multisize measurements //Use standard path to multisize measurements
QString path = qApp->ValentinaSettings()->GetPathMultisizeMeasurements(); QString path = qApp->ValentinaSettings()->GetPathMultisizeMeasurements();
path = VCommonSettings::PrepareMultisizeTables(path); path = VCommonSettings::PrepareMultisizeTables(path);
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr, const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr
QFileDialog::DontUseNativeDialog); #ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
if (not mPath.isEmpty()) if (not mPath.isEmpty())
{ {
@ -2745,7 +2760,11 @@ bool MainWindow::SaveAs()
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
dir + QLatin1String("/") + tr("pattern") + QLatin1String(".val"), dir + QLatin1String("/") + tr("pattern") + QLatin1String(".val"),
filters, nullptr, QFileDialog::DontUseNativeDialog); filters, nullptr
#ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
auto RemoveTempDir = [usedNotExistedDir, dir]() auto RemoveTempDir = [usedNotExistedDir, dir]()
{ {
@ -2936,8 +2955,11 @@ void MainWindow::Open()
dir = QFileInfo(files.first()).absolutePath(); dir = QFileInfo(files.first()).absolutePath();
} }
qCDebug(vMainWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); qCDebug(vMainWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir));
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr, const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr
QFileDialog::DontUseNativeDialog); #ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
if (filePath.isEmpty()) if (filePath.isEmpty())
{ {
return; return;
@ -4270,19 +4292,19 @@ void MainWindow::CreateActions()
connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close); connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close);
connect(ui->actionPreferences, &QAction::triggered, this, &MainWindow::Preferences); connect(ui->actionPreferences, &QAction::triggered, this, &MainWindow::Preferences);
connect(ui->actionReportBug, &QAction::triggered, this, [this]() connect(ui->actionReportBug, &QAction::triggered, this, []()
{ {
qCDebug(vMainWindow, "Reporting bug"); qCDebug(vMainWindow, "Reporting bug");
QDesktopServices::openUrl(QUrl(QStringLiteral("https://bitbucket.org/dismine/valentina/issues/new"))); QDesktopServices::openUrl(QUrl(QStringLiteral("https://bitbucket.org/dismine/valentina/issues/new")));
}); });
connect(ui->actionWiki, &QAction::triggered, this, [this]() connect(ui->actionWiki, &QAction::triggered, this, []()
{ {
qCDebug(vMainWindow, "Showing online help"); qCDebug(vMainWindow, "Showing online help");
QDesktopServices::openUrl(QUrl(QStringLiteral("https://wiki.valentinaproject.org/wiki/Main_Page"))); QDesktopServices::openUrl(QUrl(QStringLiteral("https://wiki.valentinaproject.org/wiki/Main_Page")));
}); });
connect(ui->actionForum, &QAction::triggered, this, [this]() connect(ui->actionForum, &QAction::triggered, this, []()
{ {
qCDebug(vMainWindow, "Opening forum"); qCDebug(vMainWindow, "Opening forum");
QDesktopServices::openUrl(QUrl(QStringLiteral("http://valentinaproject.forumotion.me/"))); QDesktopServices::openUrl(QUrl(QStringLiteral("http://valentinaproject.forumotion.me/")));
@ -4635,29 +4657,29 @@ QStringList MainWindow::GetUnlokedRestoreFileList() const
QStringList files = qApp->ValentinaSettings()->GetRestoreFileList(); QStringList files = qApp->ValentinaSettings()->GetRestoreFileList();
if (files.size() > 0) if (files.size() > 0)
{ {
for (int i = 0; i < files.size(); ++i) for (auto &file : files)
{ {
// Seeking file that realy need reopen // Seeking file that realy need reopen
VLockGuard<char> tmp(files.at(i)); VLockGuard<char> tmp(file);
if (tmp.IsLocked()) if (tmp.IsLocked())
{ {
restoreFiles.append(files.at(i)); restoreFiles.append(file);
} }
} }
// Clearing list after filtering // Clearing list after filtering
for (int i = 0; i < restoreFiles.size(); ++i) for (auto &file : restoreFiles)
{ {
files.removeAll(restoreFiles.at(i)); files.removeAll(file);
} }
// Clear all files that do not exist. // Clear all files that do not exist.
QStringList filtered; QStringList filtered;
for (int i = 0; i < files.size(); ++i) for (auto &file : files)
{ {
if (QFileInfo::exists(files.at(i))) if (QFileInfo::exists(file))
{ {
filtered.append(files.at(i)); filtered.append(file);
} }
} }
@ -4863,21 +4885,21 @@ void MainWindow::ReopenFilesAfterCrash(QStringList &args)
{ {
qCDebug(vMainWindow, "User said Yes."); qCDebug(vMainWindow, "User said Yes.");
for (int i = 0; i < restoreFiles.size(); ++i) for (auto &file : restoreFiles)
{ {
QString error; QString error;
if (VDomDocument::SafeCopy(restoreFiles.at(i) + *autosavePrefix, restoreFiles.at(i), error)) if (VDomDocument::SafeCopy(file + *autosavePrefix, file, error))
{ {
QFile autoFile(restoreFiles.at(i) + *autosavePrefix); QFile autoFile(file + *autosavePrefix);
autoFile.remove(); autoFile.remove();
LoadPattern(restoreFiles.at(i)); LoadPattern(file);
args.removeAll(restoreFiles.at(i));// Do not open file twice after we restore him. args.removeAll(file);// Do not open file twice after we restore him.
} }
else else
{ {
qCDebug(vMainWindow, "Could not copy %s%s to %s %s", qCDebug(vMainWindow, "Could not copy %s%s to %s %s",
qUtf8Printable(restoreFiles.at(i)), qUtf8Printable(*autosavePrefix), qUtf8Printable(file), qUtf8Printable(*autosavePrefix),
qUtf8Printable(restoreFiles.at(i)), qUtf8Printable(error)); qUtf8Printable(file), qUtf8Printable(error));
} }
} }
} }
@ -5380,9 +5402,9 @@ void MainWindow::ProcessCMD()
{ {
ReopenFilesAfterCrash(args); ReopenFilesAfterCrash(args);
for (int i=0, sz = args.size(); i < sz; ++i) for (auto &arg : args)
{ {
LoadPattern(args.at(i)); LoadPattern(arg);
} }
} }
else else

View File

@ -372,9 +372,8 @@ void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const QVector<VLayoutPiece> &li
QScopedPointer<QGraphicsScene> scene(new QGraphicsScene()); QScopedPointer<QGraphicsScene> scene(new QGraphicsScene());
QList<QGraphicsItem *> list; QList<QGraphicsItem *> list;
for (int i=0; i < listDetails.count(); ++i) for (auto piece : listDetails)
{ {
VLayoutPiece piece = listDetails.at(i);
QGraphicsItem *item = piece.GetItem(m_dialogSaveLayout->IsTextAsPaths()); QGraphicsItem *item = piece.GetItem(m_dialogSaveLayout->IsTextAsPaths());
qreal diff = 0; qreal diff = 0;
if (piece.IsForceFlipping()) if (piece.IsForceFlipping())
@ -396,9 +395,9 @@ void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const QVector<VLayoutPiece> &li
list.append(item); list.append(item);
} }
for (int i=0; i < list.size(); ++i) for (auto item : list)
{ {
scene->addItem(list.at(i)); scene->addItem(item);
} }
QList<QGraphicsItem *> papers;// Blank sheets QList<QGraphicsItem *> papers;// Blank sheets
@ -410,9 +409,9 @@ void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const QVector<VLayoutPiece> &li
QTransform matrix; QTransform matrix;
matrix = matrix.translate(-mx, -my); matrix = matrix.translate(-mx, -my);
for (int i=0; i < list.size(); ++i) for (auto item : list)
{ {
list.at(i)->setTransform(matrix); item->setTransform(matrix);
} }
rect = scene->itemsBoundingRect().toRect(); rect = scene->itemsBoundingRect().toRect();
@ -537,9 +536,9 @@ void MainWindowsNoGUI::ExportDetailsAsApparelLayout(QVector<VLayoutPiece> listDe
list.append(item); list.append(item);
} }
for (int i=0; i < list.size(); ++i) for (auto item : list)
{ {
scene->addItem(list.at(i)); scene->addItem(item);
} }
QRect rect = scene->itemsBoundingRect().toRect(); QRect rect = scene->itemsBoundingRect().toRect();
@ -550,9 +549,9 @@ void MainWindowsNoGUI::ExportDetailsAsApparelLayout(QVector<VLayoutPiece> listDe
QTransform matrix; QTransform matrix;
matrix = matrix.translate(-mx, -my); matrix = matrix.translate(-mx, -my);
for (int i=0; i < list.size(); ++i) for (auto item : list)
{ {
list.at(i)->setTransform(matrix); item->setTransform(matrix);
} }
rect = scene->itemsBoundingRect().toRect(); rect = scene->itemsBoundingRect().toRect();
@ -853,11 +852,10 @@ QList<QGraphicsItem *> MainWindowsNoGUI::CreateShadows(const QList<QGraphicsItem
{ {
QList<QGraphicsItem *> shadows; QList<QGraphicsItem *> shadows;
for (int i=0; i< papers.size(); ++i) for (auto paper : papers)
{ {
qreal x1=0, y1=0, x2=0, y2=0; qreal x1=0, y1=0, x2=0, y2=0;
QGraphicsRectItem *item = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i)); if (QGraphicsRectItem *item = qgraphicsitem_cast<QGraphicsRectItem *>(paper))
if (item)
{ {
item->rect().getCoords(&x1, &y1, &x2, &y2); item->rect().getCoords(&x1, &y1, &x2, &y2);
QGraphicsRectItem *shadowPaper = new QGraphicsRectItem(QRectF(x1+4, y1+4, x2+4, y2+4)); QGraphicsRectItem *shadowPaper = new QGraphicsRectItem(QRectF(x1+4, y1+4, x2+4, y2+4));
@ -886,10 +884,10 @@ QList<QGraphicsScene *> MainWindowsNoGUI::CreateScenes(const QList<QGraphicsItem
scene->addItem(shadows.at(i)); scene->addItem(shadows.at(i));
scene->addItem(papers.at(i)); scene->addItem(papers.at(i));
QList<QGraphicsItem *> paperDetails = details.at(i); const QList<QGraphicsItem *> paperDetails = details.at(i);
for (int i=0; i < paperDetails.size(); ++i) for (auto &detail : paperDetails)
{ {
scene->addItem(paperDetails.at(i)); scene->addItem(detail);
} }
scenes.append(scene); scenes.append(scene);
@ -1182,18 +1180,16 @@ void MainWindowsNoGUI::RestorePaper(int index) const
void MainWindowsNoGUI::PrepareTextForDXF(const QString &placeholder, void MainWindowsNoGUI::PrepareTextForDXF(const QString &placeholder,
const QList<QList<QGraphicsItem *> > &details) const const QList<QList<QGraphicsItem *> > &details) const
{ {
for (int i = 0; i < details.size(); ++i) for (auto &paperItems : details)
{ {
const QList<QGraphicsItem *> &paperItems = details.at(i); for (auto item : paperItems)
for (int j = 0; j < paperItems.size(); ++j)
{ {
QList<QGraphicsItem *> pieceChildren = paperItems.at(j)->childItems(); QList<QGraphicsItem *> pieceChildren = item->childItems();
for (int k = 0; k < pieceChildren.size(); ++k) for (auto child : pieceChildren)
{ {
QGraphicsItem *item = pieceChildren.at(k); if (child->type() == QGraphicsSimpleTextItem::Type)
if (item->type() == QGraphicsSimpleTextItem::Type)
{ {
if(QGraphicsSimpleTextItem *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(item)) if(QGraphicsSimpleTextItem *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
{ {
textItem->setText(textItem->text() + placeholder); textItem->setText(textItem->text() + placeholder);
} }
@ -1215,18 +1211,16 @@ void MainWindowsNoGUI::PrepareTextForDXF(const QString &placeholder,
void MainWindowsNoGUI::RestoreTextAfterDXF(const QString &placeholder, void MainWindowsNoGUI::RestoreTextAfterDXF(const QString &placeholder,
const QList<QList<QGraphicsItem *> > &details) const const QList<QList<QGraphicsItem *> > &details) const
{ {
for (int i = 0; i < details.size(); ++i) for (auto &paperItems : details)
{ {
const QList<QGraphicsItem *> &paperItems = details.at(i); for (auto item : paperItems)
for (int j = 0; j < paperItems.size(); ++j)
{ {
QList<QGraphicsItem *> pieceChildren = paperItems.at(i)->childItems(); QList<QGraphicsItem *> pieceChildren = item->childItems();
for (int k = 0; k < pieceChildren.size(); ++k) for (auto child : pieceChildren)
{ {
QGraphicsItem *item = pieceChildren.at(k); if (child->type() == QGraphicsSimpleTextItem::Type)
if (item->type() == QGraphicsSimpleTextItem::Type)
{ {
if(QGraphicsSimpleTextItem *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(item)) if(QGraphicsSimpleTextItem *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
{ {
QString text = textItem->text(); QString text = textItem->text();
text.replace(placeholder, QString()); text.replace(placeholder, QString());
@ -1432,8 +1426,7 @@ bool MainWindowsNoGUI::IsLayoutGrayscale() const
for (int i=0; i < scenes.size(); ++i) for (int i=0; i < scenes.size(); ++i)
{ {
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i)); if (auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i)))
if (paper)
{ {
// Hide shadow and paper border // Hide shadow and paper border
PreparePaper(i); PreparePaper(i);
@ -1513,9 +1506,9 @@ bool MainWindowsNoGUI::isPagesUniform() const
{ {
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(0)); auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(0));
SCASSERT(paper != nullptr) SCASSERT(paper != nullptr)
for (int i=1; i < papers.size(); ++i) for (auto paperItem : papers)
{ {
auto *p = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i)); auto *p = qgraphicsitem_cast<QGraphicsRectItem *>(paperItem);
SCASSERT(p != nullptr) SCASSERT(p != nullptr)
if (paper->rect() != p->rect()) if (paper->rect() != p->rect())
{ {

View File

@ -209,9 +209,9 @@ QMap<QString, QIcon> LineStylesPics()
QMap<QString, QIcon> map; QMap<QString, QIcon> map;
const QStringList styles = StylesList(); const QStringList styles = StylesList();
for (int i=0; i < styles.size(); ++i) for (auto &s : styles)
{ {
const Qt::PenStyle style = LineStyleToPenStyle(styles.at(i)); const Qt::PenStyle style = LineStyleToPenStyle(s);
QPixmap pix(80, 14); QPixmap pix(80, 14);
pix.fill(Qt::white); pix.fill(Qt::white);
@ -222,7 +222,7 @@ QMap<QString, QIcon> LineStylesPics()
painter.setPen(pen); painter.setPen(pen);
painter.drawLine(2, 7, 78, 7); painter.drawLine(2, 7, 78, 7);
map.insert(styles.at(i), QIcon(pix)); map.insert(s, QIcon(pix));
} }
return map; return map;
} }

View File

@ -260,7 +260,7 @@ QStringList VAbstractPattern::ListMeasurements() const
QSet<QString> measurements; QSet<QString> measurements;
QSet<QString> others = futureIncrements.result().toSet(); QSet<QString> others = futureIncrements.result().toSet();
foreach (const QString &token, tokens) for (const auto &token : tokens)
{ {
if (token == QChar('-') || measurements.contains(token) || others.contains(token)) if (token == QChar('-') || measurements.contains(token) || others.contains(token))
{ {
@ -2023,13 +2023,13 @@ QVector<VFormulaField> VAbstractPattern::ListFinalMeasurementsExpressions() cons
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstractPattern::IsVariable(const QString &token) const bool VAbstractPattern::IsVariable(const QString &token) const
{ {
for (int i = 0; i < builInVariables.size(); ++i) for (auto &var : builInVariables)
{ {
if (token.indexOf( builInVariables.at(i) ) == 0) if (token.indexOf( var ) == 0)
{ {
if (builInVariables.at(i) == currentLength || builInVariables.at(i) == currentSeamAllowance) if (var == currentLength || var == currentSeamAllowance)
{ {
return token == builInVariables.at(i); return token == var;
} }
else else
{ {
@ -2049,9 +2049,9 @@ bool VAbstractPattern::IsVariable(const QString &token) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstractPattern::IsFunction(const QString &token) const bool VAbstractPattern::IsFunction(const QString &token) const
{ {
for (int i = 0; i < builInFunctions.size(); ++i) for (auto &fn : builInFunctions)
{ {
if (token.indexOf( builInFunctions.at(i) ) == 0) if (token.indexOf(fn) == 0)
{ {
return true; return true;
} }
@ -2176,13 +2176,13 @@ void VAbstractPattern::SetFMeasurements(QDomElement &element, const QVector<VFin
{ {
if (not element.isNull()) if (not element.isNull())
{ {
for (int i=0; i < measurements.size(); ++i) for (auto &m : measurements)
{ {
QDomElement tagFMeasurement = createElement(TagFMeasurement); QDomElement tagFMeasurement = createElement(TagFMeasurement);
SetAttribute(tagFMeasurement, AttrName, measurements.at(i).name); SetAttribute(tagFMeasurement, AttrName, m.name);
SetAttribute(tagFMeasurement, AttrFormula, measurements.at(i).formula); SetAttribute(tagFMeasurement, AttrFormula, m.formula);
SetAttribute(tagFMeasurement, AttrDescription, measurements.at(i).description); SetAttribute(tagFMeasurement, AttrDescription, m.description);
element.appendChild(tagFMeasurement); element.appendChild(tagFMeasurement);
} }

View File

@ -972,15 +972,15 @@ void VDomDocument::SetLabelTemplate(QDomElement &element, const QVector<VLabelTe
{ {
if (not element.isNull()) if (not element.isNull())
{ {
for (int i=0; i < lines.size(); ++i) for (auto &line : lines)
{ {
QDomElement tagLine = createElement(TagLine); QDomElement tagLine = createElement(TagLine);
SetAttribute(tagLine, AttrText, lines.at(i).line); SetAttribute(tagLine, AttrText, line.line);
SetAttribute(tagLine, AttrBold, lines.at(i).bold); SetAttribute(tagLine, AttrBold, line.bold);
SetAttribute(tagLine, AttrItalic, lines.at(i).italic); SetAttribute(tagLine, AttrItalic, line.italic);
SetAttribute(tagLine, AttrAlignment, lines.at(i).alignment); SetAttribute(tagLine, AttrAlignment, line.alignment);
SetAttribute(tagLine, AttrFSIncrement, lines.at(i).fontSizeIncrement); SetAttribute(tagLine, AttrFSIncrement, line.fontSizeIncrement);
element.appendChild(tagLine); element.appendChild(tagLine);
} }

View File

@ -1677,10 +1677,10 @@ void VPatternConverter::SaveChildrenToolUnionToV0_2_4(quint32 id, const QVector<
QDomElement tagChildren = createElement(*strChildren); QDomElement tagChildren = createElement(*strChildren);
for (int i=0; i<children.size(); ++i) for (auto child : children)
{ {
QDomElement tagChild = createElement(*strChild); QDomElement tagChild = createElement(*strChild);
tagChild.appendChild(createTextNode(QString().setNum(children.at(i)))); tagChild.appendChild(createTextNode(QString().setNum(child)));
tagChildren.appendChild(tagChild); tagChildren.appendChild(tagChild);
} }
@ -2581,10 +2581,10 @@ void VPatternConverter::TagUnionDetailsToV0_4_0()
RemoveAllChildren(toolDOM); RemoveAllChildren(toolDOM);
for (int i = 0; i < nodes.size(); ++i) for (auto &node : nodes)
{ {
QDomElement tagDet = createElement(*strDet); QDomElement tagDet = createElement(*strDet);
tagDet.appendChild(nodes.at(i)); tagDet.appendChild(node);
toolDOM.appendChild(tagDet); toolDOM.appendChild(tagDet);
} }
toolDOM.appendChild(tagChildrenNodes); toolDOM.appendChild(tagChildrenNodes);

View File

@ -201,13 +201,13 @@ void VVITConverter::ConvertMeasurementsToV0_3_0()
const QMultiMap<QString, QString> names = OldNamesToNewNames_InV0_3_0(); const QMultiMap<QString, QString> names = OldNamesToNewNames_InV0_3_0();
const QList<QString> keys = names.uniqueKeys(); const QList<QString> keys = names.uniqueKeys();
for (int i = 0; i < keys.size(); ++i) for (auto &key : keys)
{ {
qreal resValue = 0; qreal resValue = 0;
// This has the same effect as a .values(), just isn't as elegant // This has the same effect as a .values(), just isn't as elegant
const QList<QString> list = names.values( keys.at(i) ); const QList<QString> list = names.values( key );
foreach(const QString &val, list ) for(const auto &val : list)
{ {
const QDomNodeList nodeList = this->elementsByTagName(val); const QDomNodeList nodeList = this->elementsByTagName(val);
if (nodeList.isEmpty()) if (nodeList.isEmpty())
@ -223,7 +223,7 @@ void VVITConverter::ConvertMeasurementsToV0_3_0()
} }
} }
bm.appendChild(AddMV0_3_0(keys.at(i), resValue)); bm.appendChild(AddMV0_3_0(key, resValue));
} }
QDomElement rootElement = this->documentElement(); QDomElement rootElement = this->documentElement();

View File

@ -214,15 +214,15 @@ void VVSTConverter::ConvertMeasurementsToV0_4_0()
const QMultiMap<QString, QString> names = OldNamesToNewNames_InV0_3_0(); const QMultiMap<QString, QString> names = OldNamesToNewNames_InV0_3_0();
const QList<QString> keys = names.uniqueKeys(); const QList<QString> keys = names.uniqueKeys();
for (int i = 0; i < keys.size(); ++i) for (auto &key : keys)
{ {
qreal resValue = 0; qreal resValue = 0;
qreal resSizeIncrease = 0; qreal resSizeIncrease = 0;
qreal resHeightIncrease = 0; qreal resHeightIncrease = 0;
// This has the same effect as a .values(), just isn't as elegant // This has the same effect as a .values(), just isn't as elegant
const QList<QString> list = names.values( keys.at(i) ); const QList<QString> list = names.values( key );
foreach(const QString &val, list ) for(const auto &val : list)
{ {
const QDomNodeList nodeList = this->elementsByTagName(val); const QDomNodeList nodeList = this->elementsByTagName(val);
if (nodeList.isEmpty()) if (nodeList.isEmpty())
@ -243,7 +243,7 @@ void VVSTConverter::ConvertMeasurementsToV0_4_0()
} }
} }
bm.appendChild(AddMV0_4_0(keys.at(i), resValue, resSizeIncrease, resHeightIncrease)); bm.appendChild(AddMV0_4_0(key, resValue, resSizeIncrease, resHeightIncrease));
} }
QDomElement rootElement = this->documentElement(); QDomElement rootElement = this->documentElement();

View File

@ -292,26 +292,26 @@ QString NameRegExp()
QString decimalPoints; QString decimalPoints;
QString groupSeparators; QString groupSeparators;
for(int i = 0; i < allLocales.size(); ++i) for(auto &locale : allLocales)
{ {
if (not positiveSigns.contains(allLocales.at(i).positiveSign())) if (not positiveSigns.contains(locale.positiveSign()))
{ {
positiveSigns.append(allLocales.at(i).positiveSign()); positiveSigns.append(locale.positiveSign());
} }
if (not negativeSigns.contains(allLocales.at(i).negativeSign())) if (not negativeSigns.contains(locale.negativeSign()))
{ {
negativeSigns.append(allLocales.at(i).negativeSign()); negativeSigns.append(locale.negativeSign());
} }
if (not decimalPoints.contains(allLocales.at(i).decimalPoint())) if (not decimalPoints.contains(locale.decimalPoint()))
{ {
decimalPoints.append(allLocales.at(i).decimalPoint()); decimalPoints.append(locale.decimalPoint());
} }
if (not groupSeparators.contains(allLocales.at(i).groupSeparator())) if (not groupSeparators.contains(locale.groupSeparator()))
{ {
groupSeparators.append(allLocales.at(i).groupSeparator()); groupSeparators.append(locale.groupSeparator());
} }
} }

View File

@ -145,9 +145,9 @@ void QmuFormulaBase::SetSepForEval()
void QmuFormulaBase::RemoveAll(QMap<int, QString> &map, const QString &val) void QmuFormulaBase::RemoveAll(QMap<int, QString> &map, const QString &val)
{ {
const QList<int> listKeys = map.keys(val);//Take all keys that contain token. const QList<int> listKeys = map.keys(val);//Take all keys that contain token.
for (int i = 0; i < listKeys.size(); ++i) for (auto key : listKeys)
{ {
map.remove(listKeys.at(i)); map.remove(key);
} }
} }

View File

@ -143,9 +143,8 @@ void VDxfEngine::drawPath(const QPainterPath &path)
{ {
const QList<QPolygonF> subpaths = path.toSubpathPolygons(matrix); const QList<QPolygonF> subpaths = path.toSubpathPolygons(matrix);
for (int j=0; j < subpaths.size(); ++j) for (auto polygon : subpaths)
{ {
const QPolygonF polygon = subpaths.at(j);
if (polygon.isEmpty()) if (polygon.isEmpty())
{ {
continue; continue;
@ -166,10 +165,10 @@ void VDxfEngine::drawPath(const QPainterPath &path)
poly->flags |= 0x80; // plinegen poly->flags |= 0x80; // plinegen
for (int i=0; i < polygon.count(); ++i) for (auto p : polygon)
{ {
poly->addVertex(DRW_Vertex2D(FromPixel(polygon.at(i).x(), varInsunits), poly->addVertex(DRW_Vertex2D(FromPixel(p.x(), varInsunits),
FromPixel(getSize().height() - polygon.at(i).y(), varInsunits), 0)); FromPixel(getSize().height() - p.y(), varInsunits), 0));
} }
input->AddEntity(poly); input->AddEntity(poly);
@ -188,10 +187,10 @@ void VDxfEngine::drawPath(const QPainterPath &path)
poly->flags |= 0x80; // plinegen poly->flags |= 0x80; // plinegen
for (int i=0; i < polygon.count(); ++i) for (auto p : polygon)
{ {
poly->addVertex(DRW_Vertex(FromPixel(polygon.at(i).x(), varInsunits), poly->addVertex(DRW_Vertex(FromPixel(p.x(), varInsunits),
FromPixel(getSize().height() - polygon.at(i).y(), varInsunits), 0, 0)); FromPixel(getSize().height() - p.y(), varInsunits), 0, 0));
} }
input->AddEntity(poly); input->AddEntity(poly);
@ -622,10 +621,8 @@ bool VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details)
ExportAAMAGlobalText(input, details); ExportAAMAGlobalText(input, details);
for(int i = 0; i < details.size(); ++i) for(auto &detail : details)
{ {
const VLayoutPiece &detail = details.at(i);
dx_ifaceBlock *detailBlock = new dx_ifaceBlock(); dx_ifaceBlock *detailBlock = new dx_ifaceBlock();
QString blockName = detail.GetName(); QString blockName = detail.GetName();
@ -683,32 +680,29 @@ void VDxfEngine::ExportAAMADraw(dx_ifaceBlock *detailBlock, const VLayoutPiece &
if (not detail.IsHideMainPath()) if (not detail.IsHideMainPath())
{ {
QVector<QPointF> poly = detail.GetContourPoints(); QVector<QPointF> poly = detail.GetContourPoints();
DRW_Entity *e = AAMAPolygon(poly, "8", true); if (DRW_Entity *e = AAMAPolygon(poly, "8", true))
if (e)
{ {
detailBlock->ent.push_back(e); detailBlock->ent.push_back(e);
} }
} }
QVector<QVector<QPointF>> drawIntCut = detail.InternalPathsForCut(false); const QVector<QVector<QPointF>> drawIntCut = detail.InternalPathsForCut(false);
for(int j = 0; j < drawIntCut.size(); ++j) for(auto &intCut : drawIntCut)
{ {
DRW_Entity *e = AAMAPolygon(drawIntCut.at(j), "8", false); if (DRW_Entity *e = AAMAPolygon(intCut, "8", false))
if (e)
{ {
detailBlock->ent.push_back(e); detailBlock->ent.push_back(e);
} }
} }
const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels(); const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels();
foreach(const VLayoutPlaceLabel &label, labels) for(auto &label : labels)
{ {
if (label.type != PlaceLabelType::Doubletree && label.type != PlaceLabelType::Button) if (label.type != PlaceLabelType::Doubletree && label.type != PlaceLabelType::Button)
{ {
foreach(const QPolygonF &p, label.shape) for(auto &p : qAsConst(label.shape))
{ {
DRW_Entity *e = AAMAPolygon(p, "8", false); if (DRW_Entity *e = AAMAPolygon(p, "8", false))
if (e)
{ {
detailBlock->ent.push_back(e); detailBlock->ent.push_back(e);
} }
@ -721,10 +715,9 @@ void VDxfEngine::ExportAAMADraw(dx_ifaceBlock *detailBlock, const VLayoutPiece &
void VDxfEngine::ExportAAMAIntcut(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) void VDxfEngine::ExportAAMAIntcut(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
{ {
QVector<QVector<QPointF>> drawIntCut = detail.InternalPathsForCut(true); QVector<QVector<QPointF>> drawIntCut = detail.InternalPathsForCut(true);
for(int j = 0; j < drawIntCut.size(); ++j) for(auto &intCut : drawIntCut)
{ {
DRW_Entity *e = AAMAPolygon(drawIntCut.at(j), "11", false); if (DRW_Entity *e = AAMAPolygon(intCut, "11", false))
if (e)
{ {
detailBlock->ent.push_back(e); detailBlock->ent.push_back(e);
} }
@ -736,11 +729,10 @@ void VDxfEngine::ExportAAMANotch(dx_ifaceBlock *detailBlock, const VLayoutPiece
{ {
if (detail.IsSeamAllowance()) if (detail.IsSeamAllowance())
{ {
QVector<QLineF> passmarks = detail.GetPassmarks(); const QVector<QLineF> passmarks = detail.GetPassmarks();
for(int i = 0; i < passmarks.size(); ++i) for(auto passmark : passmarks)
{ {
DRW_Entity *e = AAMALine(passmarks.at(i), "4"); if (DRW_Entity *e = AAMALine(passmark, "4"))
if (e)
{ {
detailBlock->ent.push_back(e); detailBlock->ent.push_back(e);
} }
@ -754,8 +746,7 @@ void VDxfEngine::ExportAAMAGrainline(dx_ifaceBlock *detailBlock, const VLayoutPi
const QVector<QPointF> grainline = detail.GetGrainline(); const QVector<QPointF> grainline = detail.GetGrainline();
if (grainline.count() > 1) if (grainline.count() > 1)
{ {
DRW_Entity *e = AAMALine(QLineF(grainline.first(), grainline.last()), "7"); if (DRW_Entity *e = AAMALine(QLineF(grainline.first(), grainline.last()), "7"))
if (e)
{ {
detailBlock->ent.push_back(e); detailBlock->ent.push_back(e);
} }
@ -778,9 +769,9 @@ void VDxfEngine::ExportAAMAText(dx_ifaceBlock *detailBlock, const VLayoutPiece &
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::ExportAAMAGlobalText(const QSharedPointer<dx_iface> &input, const QVector<VLayoutPiece> &details) void VDxfEngine::ExportAAMAGlobalText(const QSharedPointer<dx_iface> &input, const QVector<VLayoutPiece> &details)
{ {
for(int i = 0; i < details.size(); ++i) for(auto &detail : details)
{ {
const QStringList strings = details.at(i).GetPatternText(); const QStringList strings = detail.GetPatternText();
if (not strings.isEmpty()) if (not strings.isEmpty())
{ {
for (int j = 0; j < strings.size(); ++j) for (int j = 0; j < strings.size(); ++j)
@ -798,7 +789,7 @@ void VDxfEngine::ExportAAMADrill(dx_ifaceBlock *detailBlock, const VLayoutPiece
{ {
const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels(); const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels();
foreach(const VLayoutPlaceLabel &label, labels) for(auto &label : labels)
{ {
if (label.type == PlaceLabelType::Doubletree || label.type == PlaceLabelType::Button) if (label.type == PlaceLabelType::Doubletree || label.type == PlaceLabelType::Button)
{ {
@ -878,10 +869,10 @@ P *VDxfEngine::CreateAAMAPolygon(const QVector<QPointF> &polygon, const QString
} }
} }
for (int i=0; i < polygon.count(); ++i) for (auto p : polygon)
{ {
poly->addVertex(V(FromPixel(polygon.at(i).x(), varInsunits), poly->addVertex(V(FromPixel(p.x(), varInsunits),
FromPixel(getSize().height() - polygon.at(i).y(), varInsunits))); FromPixel(getSize().height() - p.y(), varInsunits)));
} }
return poly; return poly;

View File

@ -658,13 +658,13 @@ bool VMeasurements::IsDefinedKnownNamesValid() const
QStringList names = AllGroupNames(); QStringList names = AllGroupNames();
QSet<QString> set; QSet<QString> set;
foreach (const QString &var, names) for (const auto &var : names)
{ {
set.insert(var); set.insert(var);
} }
names = ListKnown(); names = ListKnown();
foreach (const QString &var, names) for (const auto &var : qAsConst(names))
{ {
if (not set.contains(var)) if (not set.contains(var))
{ {

View File

@ -376,9 +376,8 @@ QPainterPath VAbstractCurve::ShowDirection(const QVector<DirectionArrow> &arrows
{ {
QPainterPath path; QPainterPath path;
for (int i = 0; i < arrows.size(); ++i) for (auto arrow : arrows)
{ {
const DirectionArrow arrow = arrows.at(i);
if (not arrow.first.isNull() && not arrow.second.isNull()) if (not arrow.first.isNull() && not arrow.second.isNull())
{ {
QPainterPath arrowPath; QPainterPath arrowPath;

View File

@ -83,9 +83,9 @@ VCubicBezierPath VCubicBezierPath::Rotate(const QPointF &originPoint, qreal degr
{ {
const QVector<VPointF> points = GetCubicPath(); const QVector<VPointF> points = GetCubicPath();
VCubicBezierPath curve; VCubicBezierPath curve;
for(int i=0; i < points.size(); ++i) for(auto &point : points)
{ {
curve.append(points.at(i).Rotate(originPoint, degrees)); curve.append(point.Rotate(originPoint, degrees));
} }
curve.setName(name() + prefix); curve.setName(name() + prefix);
curve.SetColor(GetColor()); curve.SetColor(GetColor());
@ -99,9 +99,9 @@ VCubicBezierPath VCubicBezierPath::Flip(const QLineF &axis, const QString &prefi
{ {
const QVector<VPointF> points = GetCubicPath(); const QVector<VPointF> points = GetCubicPath();
VCubicBezierPath curve; VCubicBezierPath curve;
for(int i=0; i < points.size(); ++i) for(auto &point : points)
{ {
curve.append(points.at(i).Flip(axis)); curve.append(point.Flip(axis));
} }
curve.setName(name() + prefix); curve.setName(name() + prefix);
curve.SetColor(GetColor()); curve.SetColor(GetColor());
@ -115,9 +115,9 @@ VCubicBezierPath VCubicBezierPath::Move(qreal length, qreal angle, const QString
{ {
const QVector<VPointF> points = GetCubicPath(); const QVector<VPointF> points = GetCubicPath();
VCubicBezierPath curve; VCubicBezierPath curve;
for(int i=0; i < points.size(); ++i) for(auto &point : points)
{ {
curve.append(points.at(i).Move(length, angle)); curve.append(point.Move(length, angle));
} }
curve.setName(name() + prefix); curve.setName(name() + prefix);
curve.SetColor(GetColor()); curve.SetColor(GetColor());

View File

@ -527,9 +527,8 @@ qreal VSpline::ParamT (const QPointF &pBt) const
// In morst case we will have 6 result in interval [0; 1]. // In morst case we will have 6 result in interval [0; 1].
// Here we try find closest to our point. // Here we try find closest to our point.
for (int i=0; i< ts.size(); ++i) for (auto t : qAsConst(ts))
{ {
const qreal t = ts.at(i);
const QPointF p0 = static_cast<QPointF>(GetP1()); const QPointF p0 = static_cast<QPointF>(GetP1());
const QPointF p1 = static_cast<QPointF>(GetP2()); const QPointF p1 = static_cast<QPointF>(GetP2());
const QPointF p2 = static_cast<QPointF>(GetP3()); const QPointF p2 = static_cast<QPointF>(GetP3());

View File

@ -1017,7 +1017,7 @@ bool VAbstractPiece::IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &pr
QPainterPath VAbstractPiece::PlaceLabelImgPath(const PlaceLabelImg &img) QPainterPath VAbstractPiece::PlaceLabelImgPath(const PlaceLabelImg &img)
{ {
QPainterPath path; QPainterPath path;
foreach(const QPolygonF &p, img) for (auto &p : img)
{ {
if (not p.isEmpty()) if (not p.isEmpty())
{ {

View File

@ -208,9 +208,9 @@ LayoutErrors VLayoutGenerator::State() const
QList<QGraphicsItem *> VLayoutGenerator::GetPapersItems() const QList<QGraphicsItem *> VLayoutGenerator::GetPapersItems() const
{ {
QList<QGraphicsItem *> list; QList<QGraphicsItem *> list;
for (int i=0; i < papers.count(); ++i) for (auto &paper : papers)
{ {
list.append(papers.at(i).GetPaperItem(autoCrop, IsTestAsPaths())); list.append(paper.GetPaperItem(autoCrop, IsTestAsPaths()));
} }
return list; return list;
} }
@ -219,9 +219,9 @@ QList<QGraphicsItem *> VLayoutGenerator::GetPapersItems() const
QList<QList<QGraphicsItem *> > VLayoutGenerator::GetAllDetailsItems() const QList<QList<QGraphicsItem *> > VLayoutGenerator::GetAllDetailsItems() const
{ {
QList<QList<QGraphicsItem *> > list; QList<QList<QGraphicsItem *> > list;
for (int i=0; i < papers.count(); ++i) for (auto &paper : papers)
{ {
list.append(papers.at(i).GetItemDetails(IsTestAsPaths())); list.append(paper.GetItemDetails(IsTestAsPaths()));
} }
return list; return list;
} }
@ -230,9 +230,9 @@ QList<QList<QGraphicsItem *> > VLayoutGenerator::GetAllDetailsItems() const
QVector<QVector<VLayoutPiece> > VLayoutGenerator::GetAllDetails() const QVector<QVector<VLayoutPiece> > VLayoutGenerator::GetAllDetails() const
{ {
QVector<QVector<VLayoutPiece> > list; QVector<QVector<VLayoutPiece> > list;
for (int i=0; i < papers.count(); ++i) for (auto &paper : papers)
{ {
list.append(papers.at(i).GetDetails()); list.append(paper.GetDetails());
} }
return list; return list;
} }
@ -458,9 +458,8 @@ QList<VLayoutPiece> VLayoutGenerator::MoveDetails(qreal length, const QVector<VL
} }
QList<VLayoutPiece> newDetails; QList<VLayoutPiece> newDetails;
for (int i = 0; i < details.size(); ++i) for (auto d : details)
{ {
VLayoutPiece d = details.at(i);
d.Translate(0, length); d.Translate(0, length);
newDetails.append(d); newDetails.append(d);
} }

View File

@ -275,9 +275,9 @@ bool VLayoutPaper::AddToSheet(const VLayoutPiece &detail, std::atomic_bool &stop
return false; return false;
} }
for (int i=0; i < threads.size(); ++i) for (auto thread : threads)
{ {
bestResult.NewResult(threads.at(i)->getBestResult()); bestResult.NewResult(thread->getBestResult());
} }
qDeleteAll(threads.begin(), threads.end()); qDeleteAll(threads.begin(), threads.end());
@ -322,9 +322,9 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop, bool textAsPaths) c
{ {
QScopedPointer<QGraphicsScene> scene(new QGraphicsScene()); QScopedPointer<QGraphicsScene> scene(new QGraphicsScene());
QList<QGraphicsItem *> list = GetItemDetails(textAsPaths); QList<QGraphicsItem *> list = GetItemDetails(textAsPaths);
for (int i=0; i < list.size(); ++i) for (auto item : list)
{ {
scene->addItem(list.at(i)); scene->addItem(item);
} }
const int height = scene->itemsBoundingRect().toRect().height(); const int height = scene->itemsBoundingRect().toRect().height();
if (d->globalContour.GetHeight() > height) //-V807 if (d->globalContour.GetHeight() > height) //-V807
@ -349,9 +349,9 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop, bool textAsPaths) c
QList<QGraphicsItem *> VLayoutPaper::GetItemDetails(bool textAsPaths) const QList<QGraphicsItem *> VLayoutPaper::GetItemDetails(bool textAsPaths) const
{ {
QList<QGraphicsItem *> list; QList<QGraphicsItem *> list;
for (int i=0; i < d->details.count(); ++i) for (auto &detail : d->details)
{ {
list.append(d->details.at(i).GetItem(textAsPaths)); list.append(detail.GetItem(textAsPaths));
} }
return list; return list;
} }
@ -372,9 +372,9 @@ void VLayoutPaper::SetDetails(const QList<VLayoutPiece> &details)
QRectF VLayoutPaper::DetailsBoundingRect() const QRectF VLayoutPaper::DetailsBoundingRect() const
{ {
QRectF rec; QRectF rec;
for (int i=0; i < d->details.count(); ++i) for (auto &detail : d->details)
{ {
rec = rec.united(d->details.at(i).DetailBoundingRect()); rec = rec.united(detail.DetailBoundingRect());
} }
return rec; return rec;

View File

@ -66,9 +66,9 @@ QVector<VLayoutPiecePath> ConvertInternalPaths(const VPiece &piece, const VConta
QVector<VLayoutPiecePath> paths; QVector<VLayoutPiecePath> paths;
const QVector<quint32> pathsId = piece.GetInternalPaths(); const QVector<quint32> pathsId = piece.GetInternalPaths();
for (int i = 0; i < pathsId.size(); ++i) for (auto id : pathsId)
{ {
const VPiecePath path = pattern->GetPiecePath(pathsId.at(i)); const VPiecePath path = pattern->GetPiecePath(id);
if (path.GetType() == PiecePathType::InternalPath && path.IsVisible(pattern->DataVariables())) if (path.GetType() == PiecePathType::InternalPath && path.IsVisible(pattern->DataVariables()))
{ {
paths.append(VLayoutPiecePath(path.PathPoints(pattern), path.IsCutPath(), path.GetPenType())); paths.append(VLayoutPiecePath(path.PathPoints(pattern), path.IsCutPath(), path.GetPenType()));
@ -246,28 +246,28 @@ bool IsItemContained(const QRectF &parentBoundingRect, const QVector<QPointF> &s
// single point differences // single point differences
bool bInside = true; bool bInside = true;
for (int i = 0; i < shape.size(); ++i) for (auto p : shape)
{ {
qreal dPtX = 0; qreal dPtX = 0;
qreal dPtY = 0; qreal dPtY = 0;
if (not parentBoundingRect.contains(shape.at(i))) if (not parentBoundingRect.contains(p))
{ {
if (shape.at(i).x() < parentBoundingRect.left()) if (p.x() < parentBoundingRect.left())
{ {
dPtX = parentBoundingRect.left() - shape.at(i).x(); dPtX = parentBoundingRect.left() - p.x();
} }
else if (shape.at(i).x() > parentBoundingRect.right()) else if (p.x() > parentBoundingRect.right())
{ {
dPtX = parentBoundingRect.right() - shape.at(i).x(); dPtX = parentBoundingRect.right() - p.x();
} }
if (shape.at(i).y() < parentBoundingRect.top()) if (p.y() < parentBoundingRect.top())
{ {
dPtY = parentBoundingRect.top() - shape.at(i).y(); dPtY = parentBoundingRect.top() - p.y();
} }
else if (shape.at(i).y() > parentBoundingRect.bottom()) else if (p.y() > parentBoundingRect.bottom())
{ {
dPtY = parentBoundingRect.bottom() - shape.at(i).y(); dPtY = parentBoundingRect.bottom() - p.y();
} }
if (fabs(dPtX) > fabs(dX)) if (fabs(dPtX) > fabs(dX))
@ -305,9 +305,9 @@ QVector<QPointF> CorrectPosition(const QRectF &parentBoundingRect, QVector<QPoin
QVector<VSAPoint> PrepareAllowance(const QVector<QPointF> &points) QVector<VSAPoint> PrepareAllowance(const QVector<QPointF> &points)
{ {
QVector<VSAPoint> allowancePoints; QVector<VSAPoint> allowancePoints;
for(int i = 0; i < points.size(); ++i) for(auto point : points)
{ {
allowancePoints.append(VSAPoint(points.at(i))); allowancePoints.append(VSAPoint(point));
} }
return allowancePoints; return allowancePoints;
} }
@ -348,9 +348,10 @@ QStringList PieceLabelText(const QVector<QPointF> &labelShape, const VTextManage
QVector<VLayoutPlaceLabel> ConvertPlaceLabels(const VPiece &piece, const VContainer *pattern) QVector<VLayoutPlaceLabel> ConvertPlaceLabels(const VPiece &piece, const VContainer *pattern)
{ {
QVector<VLayoutPlaceLabel> labels; QVector<VLayoutPlaceLabel> labels;
for(int i=0; i < piece.GetPlaceLabels().size(); ++i) const QVector<quint32> placeLabels = piece.GetPlaceLabels();
for(auto placeLabel : placeLabels)
{ {
const auto label = pattern->GeometricObject<VPlaceLabelItem>(piece.GetPlaceLabels().at(i)); const auto label = pattern->GeometricObject<VPlaceLabelItem>(placeLabel);
VLayoutPlaceLabel layoutLabel; VLayoutPlaceLabel layoutLabel;
layoutLabel.shape = label->LabelShape(); layoutLabel.shape = label->LabelShape();
layoutLabel.center = label->toQPointF(); layoutLabel.center = label->toQPointF();
@ -447,9 +448,9 @@ template <class T>
QVector<T> VLayoutPiece::Map(const QVector<T> &points) const QVector<T> VLayoutPiece::Map(const QVector<T> &points) const
{ {
QVector<T> p; QVector<T> p;
for (int i = 0; i < points.size(); ++i) for (auto point : points)
{ {
p.append(d->matrix.map(points.at(i))); p.append(d->matrix.map(point));
} }
if (d->mirror) if (d->mirror)
@ -469,12 +470,12 @@ template <>
QVector<VLayoutPlaceLabel> VLayoutPiece::Map<VLayoutPlaceLabel>(const QVector<VLayoutPlaceLabel> &points) const QVector<VLayoutPlaceLabel> VLayoutPiece::Map<VLayoutPlaceLabel>(const QVector<VLayoutPlaceLabel> &points) const
{ {
QVector<VLayoutPlaceLabel> p; QVector<VLayoutPlaceLabel> p;
foreach (const VLayoutPlaceLabel &label, points) for (auto &label : points)
{ {
VLayoutPlaceLabel mappedLabel; VLayoutPlaceLabel mappedLabel;
mappedLabel.type = label.type; mappedLabel.type = label.type;
mappedLabel.center = d->matrix.map(label.center); mappedLabel.center = d->matrix.map(label.center);
foreach (const QPolygonF &p, label.shape) for (const auto &p : label.shape)
{ {
mappedLabel.shape.append(d->matrix.map(p)); mappedLabel.shape.append(d->matrix.map(p));
} }
@ -948,11 +949,11 @@ QVector<QVector<QPointF> > VLayoutPiece::InternalPathsForCut(bool cut) const
{ {
QVector<QVector<QPointF> > paths; QVector<QVector<QPointF> > paths;
for (int i=0;i < d->m_internalPaths.count(); ++i) for (auto &path : d->m_internalPaths)
{ {
if (d->m_internalPaths.at(i).IsCutPath() == cut) if (path.IsCutPath() == cut)
{ {
paths.append(Map(d->m_internalPaths.at(i).Points())); paths.append(Map(path.Points()));
} }
} }
@ -1050,20 +1051,20 @@ QGraphicsItem *VLayoutPiece::GetItem(bool textAsPaths) const
{ {
QGraphicsPathItem *item = GetMainItem(); QGraphicsPathItem *item = GetMainItem();
for (int i = 0; i < d->m_internalPaths.count(); ++i) for (auto &path : d->m_internalPaths)
{ {
QGraphicsPathItem* pathItem = new QGraphicsPathItem(item); QGraphicsPathItem* pathItem = new QGraphicsPathItem(item);
pathItem->setPath(d->matrix.map(d->m_internalPaths.at(i).GetPainterPath())); pathItem->setPath(d->matrix.map(path.GetPainterPath()));
QPen pen = pathItem->pen(); QPen pen = pathItem->pen();
pen.setStyle(d->m_internalPaths.at(i).PenStyle()); pen.setStyle(path.PenStyle());
pathItem->setPen(pen); pathItem->setPen(pen);
} }
for (int i = 0; i < d->m_placeLabels.count(); ++i) for (auto &label : d->m_placeLabels)
{ {
QGraphicsPathItem* pathItem = new QGraphicsPathItem(item); QGraphicsPathItem* pathItem = new QGraphicsPathItem(item);
pathItem->setPath(d->matrix.map(PlaceLabelImgPath(d->m_placeLabels.at(i).shape))); pathItem->setPath(d->matrix.map(PlaceLabelImgPath(label.shape)));
} }
CreateLabelStrings(item, d->detailLabel, d->m_tmDetail, textAsPaths); CreateLabelStrings(item, d->detailLabel, d->m_tmDetail, textAsPaths);
@ -1198,9 +1199,9 @@ void VLayoutPiece::CreateGrainlineItem(QGraphicsItem *parent) const
QVector<QPointF> gPoints = GetGrainline(); QVector<QPointF> gPoints = GetGrainline();
path.moveTo(gPoints.at(0)); path.moveTo(gPoints.at(0));
for (int i = 1; i < gPoints.count(); ++i) for (auto p : gPoints)
{ {
path.lineTo(gPoints.at(i)); path.lineTo(p);
} }
item->setPath(path); item->setPath(path);
} }

View File

@ -571,9 +571,9 @@ QPainterPath VPosition::DrawDetails(const QVector<VLayoutPiece> &details)
path.setFillRule(Qt::WindingFill); path.setFillRule(Qt::WindingFill);
if (details.count() > 0) if (details.count() > 0)
{ {
for (int i = 0; i < details.size(); ++i) for (auto &detail : details)
{ {
path.addPath(details.at(i).ContourPath()); path.addPath(detail.ContourPath());
} }
} }
return path; return path;

View File

@ -180,16 +180,16 @@ QList<TextLine> PrepareLines(const QVector<VLabelTemplateLine> &lines)
{ {
QList<TextLine> textLines; QList<TextLine> textLines;
for (int i=0; i < lines.size(); ++i) for (auto &line : lines)
{ {
if (not lines.at(i).line.isEmpty()) if (not line.line.isEmpty())
{ {
TextLine tl; TextLine tl;
tl.m_qsText = lines.at(i).line; tl.m_qsText = line.line;
tl.m_eAlign = static_cast<Qt::Alignment>(lines.at(i).alignment); tl.m_eAlign = static_cast<Qt::Alignment>(line.alignment);
tl.m_iFontSize = lines.at(i).fontSizeIncrement; tl.m_iFontSize = line.fontSizeIncrement;
tl.bold = lines.at(i).bold; tl.bold = line.bold;
tl.italic = lines.at(i).italic; tl.italic = line.italic;
textLines << tl; textLines << tl;
} }

View File

@ -817,11 +817,9 @@ void InitLanguages(QComboBox *combobox)
bool englishUS = false; bool englishUS = false;
const QString en_US = QStringLiteral("en_US"); const QString en_US = QStringLiteral("en_US");
for (int i = 0; i < fileNames.size(); ++i) for (auto locale : fileNames)
{ {
// get locale extracted by filename // get locale extracted by filename "valentina_de_De.qm"
QString locale;
locale = fileNames.at(i); // "valentina_de_De.qm"
locale.truncate(locale.lastIndexOf('.')); // "valentina_de_De" locale.truncate(locale.lastIndexOf('.')); // "valentina_de_De"
locale.remove(0, locale.indexOf('_') + 1); // "de_De" locale.remove(0, locale.indexOf('_') + 1); // "de_De"

View File

@ -46,7 +46,8 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
foreach (int mib, QTextCodec::availableMibs()) const QList<int> mibs = QTextCodec::availableMibs();
for (auto mib : mibs)
{ {
ui->comboBoxCodec->addItem(QTextCodec::codecForMib(mib)->name(), mib); ui->comboBoxCodec->addItem(QTextCodec::codecForMib(mib)->name(), mib);
} }

View File

@ -105,9 +105,9 @@ qreal lineWidthCached = 0;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats) QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats)
{ {
for (int i = 0; i < predefinedFormats.size(); ++i) for (auto &f : predefinedFormats)
{ {
formats.removeAll(predefinedFormats.at(i)); formats.removeAll(f);
} }
return formats; return formats;
} }
@ -550,11 +550,11 @@ QStringList VCommonSettings::GetRecentFileList() const
const QStringList files = value(*settingGeneralRecentFileList).toStringList(); const QStringList files = value(*settingGeneralRecentFileList).toStringList();
QStringList cleared; QStringList cleared;
for (int i = 0; i < files.size(); ++i) for (auto &f : files)
{ {
if (QFileInfo::exists(files.at(i))) if (QFileInfo::exists(f))
{ {
cleared.append(files.at(i)); cleared.append(f);
} }
} }

View File

@ -105,7 +105,7 @@ void VTableSearch::Find(const QString &term)
if (not searchList.isEmpty()) if (not searchList.isEmpty())
{ {
foreach(QTableWidgetItem *item, searchList) for (auto item : qAsConst(searchList))
{ {
item->setBackground(Qt::yellow); item->setBackground(Qt::yellow);
} }
@ -158,7 +158,7 @@ void VTableSearch::RemoveRow(int row)
if (row <= indexRow) if (row <= indexRow)
{ {
foreach(QTableWidgetItem *item, searchList) for (auto item : qAsConst(searchList))
{ {
if (item->row() == row) if (item->row() == row)
{ {
@ -180,7 +180,7 @@ void VTableSearch::AddRow(int row)
if (row <= indexRow) if (row <= indexRow)
{ {
foreach(QTableWidgetItem *item, searchList) for (auto item : qAsConst(searchList))
{ {
if (item->row() == row) if (item->row() == row)
{ {
@ -202,7 +202,7 @@ void VTableSearch::RefreshList(const QString &term)
searchList = table->findItems(term, Qt::MatchContains); searchList = table->findItems(term, Qt::MatchContains);
foreach(QTableWidgetItem *item, searchList) for (auto item : qAsConst(searchList))
{ {
item->setBackground(Qt::yellow); item->setBackground(Qt::yellow);
} }

View File

@ -172,12 +172,12 @@ void VObjEngine::drawPath(const QPainterPath &path)
quint32 num_points = 0; quint32 num_points = 0;
for (int i=0; i < polygon.count(); i++) for (auto &p : polygon)
{ {
if ( num_points < MAX_POINTS ) if ( num_points < MAX_POINTS )
{ {
points[num_points].x = polygon.at(i).x(); points[num_points].x = p.x();
points[num_points].y = polygon.at(i).y(); points[num_points].y = p.y();
num_points++; num_points++;
} }
} }
@ -326,12 +326,12 @@ QPolygonF VObjEngine::MakePointsUnique(const QPolygonF &polygon) const
{ {
QVector<QPointF> set; QVector<QPointF> set;
QPolygonF uniquePolygon; QPolygonF uniquePolygon;
for (int i=0; i < polygon.count(); i++) for (auto p : polygon)
{ {
if (set.contains(polygon.at(i)) == false) if (set.contains(p) == false)
{ {
set.append(polygon.at(i)); set.append(p);
uniquePolygon.append(polygon.at(i)); uniquePolygon.append(p);
} }
} }
return uniquePolygon; return uniquePolygon;

View File

@ -671,9 +671,9 @@ QStringList ListNumbers(const VTranslateMeasurements *trM, const QStringList &li
SCASSERT(trM != nullptr) SCASSERT(trM != nullptr)
QStringList numbers; QStringList numbers;
for (int i=0; i < listMeasurements.size(); ++i) for (auto &m : listMeasurements)
{ {
numbers.append(trM->MNumber(listMeasurements.at(i))); numbers.append(trM->MNumber(m));
} }
return numbers; return numbers;
} }

View File

@ -159,9 +159,9 @@ void InitPMSystems(QComboBox *systemCombo)
{ {
const QStringList listSystems = ListPMSystems(); const QStringList listSystems = ListPMSystems();
QMap<QString, QString> systems; QMap<QString, QString> systems;
for (int i = 0; i < listSystems.size()-1; ++i) for (auto &sys : listSystems)
{ {
systems.insert(qApp->TrVars()->PMSystemName(listSystems.at(i)) + " ("+listSystems.at(i)+")", listSystems.at(i)); systems.insert(qApp->TrVars()->PMSystemName(sys) + QLatin1String(" (") + sys + QLatin1String(")"), sys);
} }
// * The default option (blank field or 'None') should appear at the top of the list. // * The default option (blank field or 'None') should appear at the top of the list.

View File

@ -591,11 +591,11 @@ void VContainer::ClearUniqueIncrementNames()
const QList<QString> list = uniqueNames.toList(); const QList<QString> list = uniqueNames.toList();
ClearUniqueNames(); ClearUniqueNames();
for(int i = 0; i < list.size(); ++i) for(auto &name : list)
{ {
if (not list.at(i).startsWith('#')) if (not name.startsWith('#'))
{ {
uniqueNames.insert(list.at(i)); uniqueNames.insert(name);
} }
} }
} }

View File

@ -224,9 +224,8 @@ QVector<VPieceNode> VNodeDetail::Convert(const VContainer *data, const QVector<V
} }
VPiecePath path; VPiecePath path;
for (int i = 0; i < nodes.size(); ++i) for (auto &node : nodes)
{ {
const VNodeDetail &node = nodes.at(i);
path.Append(VPieceNode(node.getId(), node.getTypeTool(), node.getReverse())); path.Append(VPieceNode(node.getId(), node.getTypeTool(), node.getReverse()));
} }

View File

@ -256,9 +256,8 @@ bool IsPassmarksPossible(const QVector<VPieceNode> &path)
int countPointNodes = 0; int countPointNodes = 0;
int countOthers = 0; int countOthers = 0;
for (int i = 0; i< path.size(); ++i) for (auto &node : path)
{ {
const VPieceNode &node = path.at(i);
if (node.IsExcluded()) if (node.IsExcluded())
{ {
continue;// skip node continue;// skip node
@ -448,11 +447,11 @@ QVector<QLineF> VPiece::PassmarksLines(const VContainer *data, const QVector<QPo
QVector<PlaceLabelImg> VPiece::PlaceLabelPoints(const VContainer *data) const QVector<PlaceLabelImg> VPiece::PlaceLabelPoints(const VContainer *data) const
{ {
QVector<PlaceLabelImg> points; QVector<PlaceLabelImg> points;
for(int i=0; i < d->m_placeLabels.size(); ++i) for(auto placeLabel : d->m_placeLabels)
{ {
try try
{ {
const auto label = data->GeometricObject<VPlaceLabelItem>(d->m_placeLabels.at(i)); const auto label = data->GeometricObject<VPlaceLabelItem>(placeLabel);
points.append(label->LabelShape()); points.append(label->LabelShape());
} }
catch (const VExceptionBadId &e) catch (const VExceptionBadId &e)
@ -463,10 +462,21 @@ QVector<PlaceLabelImg> VPiece::PlaceLabelPoints(const VContainer *data) const
return points; return points;
} }
//---------------------------------------------------------------------------------------------------------------------
QVector<QPainterPath> VPiece::CurvesPainterPath(const VContainer *data) const
{
return GetPath().CurvesPainterPath(data);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPainterPath VPiece::MainPathPath(const VContainer *data) const QPainterPath VPiece::MainPathPath(const VContainer *data) const
{ {
const QVector<QPointF> points = MainPathPoints(data); return VPiece::MainPathPath(MainPathPoints(data));
}
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VPiece::MainPathPath(const QVector<QPointF> &points)
{
QPainterPath path; QPainterPath path;
if (not points.isEmpty()) if (not points.isEmpty())
@ -670,22 +680,22 @@ QList<quint32> VPiece::Dependencies() const
{ {
QList<quint32> list = d->m_path.Dependencies(); QList<quint32> list = d->m_path.Dependencies();
foreach (const CustomSARecord &record, d->m_customSARecords) for (auto &record : d->m_customSARecords)
{ {
list.append(record.path); list.append(record.path);
} }
foreach (const quint32 &value, d->m_internalPaths) for (auto &value : d->m_internalPaths)
{ {
list.append(value); list.append(value);
} }
foreach (const quint32 &value, d->m_pins) for (auto &value : d->m_pins)
{ {
list.append(value); list.append(value);
} }
foreach (const quint32 &value, d->m_placeLabels) for (auto &value : d->m_placeLabels)
{ {
list.append(value); list.append(value);
} }
@ -884,9 +894,8 @@ QVector<VPieceNode> VPiece::GetUnitedPath(const VContainer *data) const
QVector<CustomSARecord> VPiece::GetValidRecords() const QVector<CustomSARecord> VPiece::GetValidRecords() const
{ {
QVector<CustomSARecord> records; QVector<CustomSARecord> records;
for (int i = 0; i < d->m_customSARecords.size(); ++i) for (auto &record : d->m_customSARecords)
{ {
const CustomSARecord &record = d->m_customSARecords.at(i);
const int indexStartPoint = d->m_path.indexOfNode(record.startPoint); const int indexStartPoint = d->m_path.indexOfNode(record.startPoint);
const int indexEndPoint = d->m_path.indexOfNode(record.endPoint); const int indexEndPoint = d->m_path.indexOfNode(record.endPoint);
@ -937,13 +946,13 @@ QVector<CustomSARecord> VPiece::FilterRecords(QVector<CustomSARecord> records) c
records.remove(startIndex); records.remove(startIndex);
QVector<CustomSARecord> secondRound; QVector<CustomSARecord> secondRound;
for (int i = 0; i < records.size(); ++i) for (auto &record : records)
{ {
const int indexStartPoint = d->m_path.indexOfNode(records.at(i).startPoint); const int indexStartPoint = d->m_path.indexOfNode(record.startPoint);
const int indexEndPoint = d->m_path.indexOfNode(filter.endPoint); const int indexEndPoint = d->m_path.indexOfNode(filter.endPoint);
if (indexStartPoint > indexEndPoint) if (indexStartPoint > indexEndPoint)
{ {
secondRound.append(records.at(i)); secondRound.append(record);
} }
} }
@ -1138,12 +1147,12 @@ bool VPiece::IsPassmarkVisible(const QVector<VPieceNode> &path, int passmarkInde
return true; return true;
} }
for (int i = 0; i < records.size(); ++i) for (auto &record : records)
{ {
if (records.at(i).includeType == PiecePathIncludeType::AsCustomSA) if (record.includeType == PiecePathIncludeType::AsCustomSA)
{ {
const int indexStartPoint = VPiecePath::indexOfNode(path, records.at(i).startPoint); const int indexStartPoint = VPiecePath::indexOfNode(path, record.startPoint);
const int indexEndPoint = VPiecePath::indexOfNode(path, records.at(i).endPoint); const int indexEndPoint = VPiecePath::indexOfNode(path, record.endPoint);
if (passmarkIndex > indexStartPoint && passmarkIndex < indexEndPoint) if (passmarkIndex > indexStartPoint && passmarkIndex < indexEndPoint)
{ {
return false; return false;

View File

@ -74,7 +74,11 @@ public:
const QVector<QPointF> &seamAllowance = QVector<QPointF>()) const; const QVector<QPointF> &seamAllowance = QVector<QPointF>()) const;
QVector<PlaceLabelImg> PlaceLabelPoints(const VContainer *data) const; QVector<PlaceLabelImg> PlaceLabelPoints(const VContainer *data) const;
QPainterPath MainPathPath(const VContainer *data) const; QVector<QPainterPath> CurvesPainterPath(const VContainer *data) const;
QPainterPath MainPathPath(const VContainer *data) const;
static QPainterPath MainPathPath(const QVector<QPointF> &points);
QPainterPath SeamAllowancePath(const VContainer *data) const; QPainterPath SeamAllowancePath(const VContainer *data) const;
QPainterPath SeamAllowancePath(const QVector<QPointF> &points) const; QPainterPath SeamAllowancePath(const QVector<QPointF> &points) const;
QPainterPath PassmarksPath(const VContainer *data, QPainterPath PassmarksPath(const VContainer *data,

View File

@ -128,6 +128,20 @@ int IndexOfNode(const QVector<VPieceNode> &list, quint32 id)
qDebug()<<"Can't find node."; qDebug()<<"Can't find node.";
return -1; return -1;
} }
//---------------------------------------------------------------------------------------------------------------------
QPainterPath MakePainterPath(const QVector<QPointF> &points)
{
QPainterPath path;
if (not points.isEmpty())
{
path.addPolygon(QPolygonF(points));
path.setFillRule(Qt::WindingFill);
}
return path;
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -332,6 +346,41 @@ QVector<VPointF> VPiecePath::PathNodePoints(const VContainer *data, bool showExc
return points; return points;
} }
//---------------------------------------------------------------------------------------------------------------------
QVector<QVector<QPointF> > VPiecePath::PathCurvePoints(const VContainer *data) const
{
QVector<QVector<QPointF> > curves;
for (int i = 0; i < CountNodes(); ++i)
{
if (at(i).IsExcluded())
{
continue;// skip excluded node
}
switch (at(i).GetTypeTool())
{
case (Tool::NodeArc):
case (Tool::NodeElArc):
case (Tool::NodeSpline):
case (Tool::NodeSplinePath):
{
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).GetId());
const QPointF begin = StartSegment(data, i, at(i).GetReverse());
const QPointF end = EndSegment(data, i, at(i).GetReverse());
curves.append(curve->GetSegmentPoints(begin, end, at(i).GetReverse()));
break;
}
case (Tool::NodePoint):
default:
break;
}
}
return curves;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<VSAPoint> VPiecePath::SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const QVector<VSAPoint> VPiecePath::SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const
{ {
@ -374,16 +423,20 @@ QVector<VSAPoint> VPiecePath::SeamAllowancePoints(const VContainer *data, qreal
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPainterPath VPiecePath::PainterPath(const VContainer *data) const QPainterPath VPiecePath::PainterPath(const VContainer *data) const
{ {
const QVector<QPointF> points = PathPoints(data); return MakePainterPath(PathPoints(data));
QPainterPath path; }
if (not points.isEmpty()) //---------------------------------------------------------------------------------------------------------------------
QVector<QPainterPath> VPiecePath::CurvesPainterPath(const VContainer *data) const
{
const QVector<QVector<QPointF> > curves = PathCurvePoints(data);
QVector<QPainterPath> paths(curves.size());
for(auto &curve : curves)
{ {
path.addPolygon(QPolygonF(points)); paths.append(MakePainterPath(curve));
path.setFillRule(Qt::WindingFill);
} }
return paths;
return path;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -452,7 +505,7 @@ VSAPoint VPiecePath::EndSegment(const VContainer *data, const QVector<VPieceNode
QList<quint32> VPiecePath::Dependencies() const QList<quint32> VPiecePath::Dependencies() const
{ {
QList<quint32> list; QList<quint32> list;
foreach (const VPieceNode &node, d->m_nodes) for (auto &node : d->m_nodes)
{ {
list.append(node.GetId()); list.append(node.GetId());
} }
@ -528,9 +581,9 @@ void VPiecePath::NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPiecePath::Contains(quint32 id) const bool VPiecePath::Contains(quint32 id) const
{ {
for (int i = 0; i < d->m_nodes.size(); ++i) for (auto &node : d->m_nodes)
{ {
if (d->m_nodes.at(i).GetId() == id) if (node.GetId() == id)
{ {
return true; return true;
} }
@ -623,11 +676,11 @@ int VPiecePath::Edge(quint32 p1, quint32 p2) const
QVector<VPieceNode> VPiecePath::ListNodePoint() const QVector<VPieceNode> VPiecePath::ListNodePoint() const
{ {
QVector<VPieceNode> list; QVector<VPieceNode> list;
for (int i = 0; i < d->m_nodes.size(); ++i) //-V807 for (auto &node : d->m_nodes) //-V807
{ {
if (d->m_nodes.at(i).GetTypeTool() == Tool::NodePoint) if (node.GetTypeTool() == Tool::NodePoint)
{ {
list.append(d->m_nodes.at(i)); list.append(node);
} }
} }
return list; return list;
@ -942,9 +995,9 @@ QVector<VSAPoint> VPiecePath::CurveSeamAllowanceSegment(const VContainer *data,
qreal w2 = end.GetSABefore(); qreal w2 = end.GetSABefore();
if (w1 < 0 && w2 < 0) if (w1 < 0 && w2 < 0)
{// no local widths {// no local widths
for(int i = 0; i < points.size(); ++i) for(auto point : points)
{ {
VSAPoint p(points.at(i)); VSAPoint p(point);
if (i == 0) if (i == 0)
{ // first point { // first point
p.SetSAAfter(begin.GetSAAfter()); p.SetSAAfter(begin.GetSAAfter());
@ -983,9 +1036,9 @@ QVector<VSAPoint> VPiecePath::CurveSeamAllowanceSegment(const VContainer *data,
qreal length = 0; // how much we handle qreal length = 0; // how much we handle
for(int i = 1; i < points.size(); ++i) for(auto point : points)
{ {
p = VSAPoint(points.at(i)); p = VSAPoint(point);
if (i == points.size() - 1) if (i == points.size() - 1)
{// last point {// last point

View File

@ -85,11 +85,13 @@ public:
QString GetVisibilityTrigger() const; QString GetVisibilityTrigger() const;
void SetVisibilityTrigger(const QString &formula); void SetVisibilityTrigger(const QString &formula);
QVector<QPointF> PathPoints(const VContainer *data) const; QVector<QPointF> PathPoints(const VContainer *data) const;
QVector<VPointF> PathNodePoints(const VContainer *data, bool showExcluded = true) const; QVector<VPointF> PathNodePoints(const VContainer *data, bool showExcluded = true) const;
QVector<VSAPoint> SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const; QVector<QVector<QPointF> > PathCurvePoints(const VContainer *data) const;
QVector<VSAPoint> SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const;
QPainterPath PainterPath(const VContainer *data) const; QPainterPath PainterPath(const VContainer *data) const;
QVector<QPainterPath> CurvesPainterPath(const VContainer *data) const;
QList<quint32> Dependencies() const; QList<quint32> Dependencies() const;
QVector<quint32> MissingNodes(const VPiecePath &path) const; QVector<quint32> MissingNodes(const VPiecePath &path) const;

View File

@ -222,7 +222,9 @@ QPushButton *CheckableMessageBox::addButton(const QString &text, QDialogButtonBo
QDialogButtonBox::StandardButton CheckableMessageBox::defaultButton() const QDialogButtonBox::StandardButton CheckableMessageBox::defaultButton() const
{ {
foreach (QAbstractButton *b, d->buttonBox->buttons()) const QList<QAbstractButton *> buttons = d->buttonBox->buttons();
for (auto b : buttons)
{
if (QPushButton *pb = qobject_cast<QPushButton *>(b)) if (QPushButton *pb = qobject_cast<QPushButton *>(b))
{ {
if (pb->isDefault()) if (pb->isDefault())
@ -230,6 +232,7 @@ QDialogButtonBox::StandardButton CheckableMessageBox::defaultButton() const
return d->buttonBox->standardButton(pb); return d->buttonBox->standardButton(pb);
} }
} }
}
return QDialogButtonBox::NoButton; return QDialogButtonBox::NoButton;
} }
@ -429,7 +432,7 @@ bool CheckableMessageBox::hasSuppressedQuestions(QSettings *settings)
//Q_ASSERT(settings, return false); //Q_ASSERT(settings, return false);
bool hasSuppressed = false; bool hasSuppressed = false;
settings->beginGroup(QLatin1String(kDoNotAskAgainKey)); settings->beginGroup(QLatin1String(kDoNotAskAgainKey));
foreach (const QString &subKey, settings->childKeys()) for (auto &subKey : settings->childKeys())
{ {
if (settings->value(subKey, false).toBool()) if (settings->value(subKey, false).toBool())
{ {

View File

@ -115,8 +115,8 @@ VPE::VProperty* VPE::QVector3DProperty::clone(bool include_children, VProperty*
if (!include_children) if (!include_children)
{ {
QList<VProperty*> tmpChildren = container->getChildren(); const QList<VProperty*> &tmpChildren = container->getChildren();
foreach (VProperty* tmpChild, tmpChildren) for (auto tmpChild : tmpChildren)
{ {
container->removeChild(tmpChild); container->removeChild(tmpChild);
delete tmpChild; delete tmpChild;

View File

@ -113,10 +113,16 @@ void VPE::VFileEditWidget::onToolButtonClicked()
{ {
QString filepath = (Directory ? QFileDialog::getExistingDirectory(nullptr, tr("Directory"), CurrentFilePath, QString filepath = (Directory ? QFileDialog::getExistingDirectory(nullptr, tr("Directory"), CurrentFilePath,
QFileDialog::ShowDirsOnly QFileDialog::ShowDirsOnly
| QFileDialog::DontUseNativeDialog) #ifdef Q_OS_LINUX
| QFileDialog::DontUseNativeDialog
#endif
)
: QFileDialog::getOpenFileName(nullptr, tr("Open File"), CurrentFilePath, : QFileDialog::getOpenFileName(nullptr, tr("Open File"), CurrentFilePath,
FileDialogFilter, nullptr, FileDialogFilter, nullptr
QFileDialog::DontUseNativeDialog)); #ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
));
if (filepath.isNull() == false) if (filepath.isNull() == false)
{ {
setFile(filepath, true); setFile(filepath, true);
@ -245,7 +251,7 @@ bool VPE::VFileEditWidget::checkFileFilter(const QString& file) const
return false; return false;
} }
foreach(QString tmpFilter, FilterList) for (auto &tmpFilter : FilterList)
{ {
QRegExp tmpRegExpFilter(tmpFilter, Qt::CaseInsensitive, QRegExp::Wildcard); QRegExp tmpRegExpFilter(tmpFilter, Qt::CaseInsensitive, QRegExp::Wildcard);
if (tmpRegExpFilter.exactMatch(file)) if (tmpRegExpFilter.exactMatch(file))

View File

@ -114,8 +114,8 @@ VPE::VProperty *VPE::VPointFProperty::clone(bool include_children, VProperty *co
if (!include_children) if (!include_children)
{ {
QList<VProperty*> tmpChildren = container->getChildren(); const QList<VProperty*> &tmpChildren = container->getChildren();
foreach(VProperty* tmpChild, tmpChildren) for(auto tmpChild : tmpChildren)
{ {
container->removeChild(tmpChild); container->removeChild(tmpChild);
delete tmpChild; delete tmpChild;

View File

@ -350,9 +350,11 @@ QMap<QString, QVariant> VPE::VProperty::getSettings() const
{ {
QMap<QString, QVariant> tmpResult; QMap<QString, QVariant> tmpResult;
QStringList tmpKeyList = getSettingKeys(); const QStringList tmpKeyList = getSettingKeys();
foreach(const QString& tmpKey, tmpKeyList) for(auto &tmpKey : tmpKeyList)
{
tmpResult.insert(tmpKey, getSetting(tmpKey)); tmpResult.insert(tmpKey, getSetting(tmpKey));
}
return tmpResult; return tmpResult;
} }
@ -392,8 +394,11 @@ VPE::VProperty* VPE::VProperty::clone(bool include_children, VProperty* containe
if (include_children) if (include_children)
{ {
foreach(VProperty* tmpChild, d_ptr->Children) const QList<VProperty*> children = d_ptr->Children;
for (auto tmpChild : children)
{
container->addChild(tmpChild->clone(true)); container->addChild(tmpChild->clone(true));
}
} }
return container; return container;

View File

@ -213,9 +213,9 @@ void VPE::VPropertyFormView::connectPropertyFormWidget(VPropertyFormWidget *widg
connect(widget, &VPropertyFormWidget::propertyDataSubmitted, this, &VPropertyFormView::dataSubmitted, connect(widget, &VPropertyFormWidget::propertyDataSubmitted, this, &VPropertyFormView::dataSubmitted,
Qt::UniqueConnection); Qt::UniqueConnection);
QList<VPropertyFormWidget*> tmpList = widget->getChildPropertyFormWidgets(); const QList<VPropertyFormWidget*> tmpList = widget->getChildPropertyFormWidgets();
foreach(VPropertyFormWidget* tmpEditorWidget, tmpList) for (auto tmpEditorWidget : tmpList)
{ {
connectPropertyFormWidget(tmpEditorWidget); connectPropertyFormWidget(tmpEditorWidget);
} }

View File

@ -103,6 +103,7 @@ void VPE::VPropertyFormWidget::build()
} }
QFormLayout* tmpFormLayout = new QFormLayout(this); QFormLayout* tmpFormLayout = new QFormLayout(this);
tmpFormLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
setLayout(tmpFormLayout); setLayout(tmpFormLayout);
for (int i = 0; i < d_ptr->Properties.count(); ++i) for (int i = 0; i < d_ptr->Properties.count(); ++i)
@ -123,9 +124,11 @@ void VPE::VPropertyFormWidget::build()
tmpFormLayout->addRow(group); tmpFormLayout->addRow(group);
QFormLayout* subFormLayout = new QFormLayout(group); QFormLayout* subFormLayout = new QFormLayout(group);
subFormLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
QMargins margins = subFormLayout->contentsMargins(); QMargins margins = subFormLayout->contentsMargins();
margins.setTop(0); margins.setTop(0);
margins.setLeft(14); margins.setLeft(18);
margins.setRight(0);
subFormLayout->setContentsMargins(margins); subFormLayout->setContentsMargins(margins);
group->setLayout(subFormLayout); group->setLayout(subFormLayout);
@ -268,8 +271,8 @@ void VPE::VPropertyFormWidget::setCommitBehaviour(bool auto_commit)
{ {
d_ptr->UpdateEditors = auto_commit; d_ptr->UpdateEditors = auto_commit;
QList<VPropertyFormWidget*> tmpChildFormWidgets = getChildPropertyFormWidgets(); const QList<VPropertyFormWidget*> tmpChildFormWidgets = getChildPropertyFormWidgets();
foreach(VPropertyFormWidget* tmpChild, tmpChildFormWidgets) for (auto tmpChild : tmpChildFormWidgets)
{ {
if (tmpChild) if (tmpChild)
{ {
@ -281,7 +284,7 @@ void VPE::VPropertyFormWidget::setCommitBehaviour(bool auto_commit)
QList<VPE::VPropertyFormWidget *> VPE::VPropertyFormWidget::getChildPropertyFormWidgets() const QList<VPE::VPropertyFormWidget *> VPE::VPropertyFormWidget::getChildPropertyFormWidgets() const
{ {
QList<VPropertyFormWidget *> tmpResult; QList<VPropertyFormWidget *> tmpResult;
foreach(const VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget, d_ptr->EditorWidgets) for (auto &tmpEditorWidget : d_ptr->EditorWidgets)
{ {
if (tmpEditorWidget.FormWidget) if (tmpEditorWidget.FormWidget)
{ {

View File

@ -204,9 +204,11 @@ VPE::VPropertySet* VPE::VPropertySet::clone() const
{ {
VPropertySet* tmpResult = new VPropertySet(); VPropertySet* tmpResult = new VPropertySet();
foreach(VProperty* tmpProperty, d_ptr->RootProperties) const QList<VProperty*> rootProperties = d_ptr->RootProperties;
for (auto tmpProperty : rootProperties)
{
cloneProperty(tmpProperty, nullptr, tmpResult); cloneProperty(tmpProperty, nullptr, tmpResult);
}
return tmpResult; return tmpResult;
} }
@ -219,7 +221,7 @@ bool VPE::VPropertySet::hasProperty(VProperty *property, VProperty *parent) cons
} }
const QList<VProperty*>& tmpChildrenList = (parent != nullptr ? parent->getChildren() : d_ptr->RootProperties); const QList<VProperty*>& tmpChildrenList = (parent != nullptr ? parent->getChildren() : d_ptr->RootProperties);
foreach(VProperty* tmpProp, tmpChildrenList) for(auto tmpProp : tmpChildrenList)
{ {
if (tmpProp && (tmpProp == property || hasProperty(property, tmpProp))) if (tmpProp && (tmpProp == property || hasProperty(property, tmpProp)))
{ {
@ -253,13 +255,17 @@ void VPE::VPropertySet::cloneProperty(VProperty* property_to_clone, VProperty *p
void VPE::VPropertySet::removePropertyFromSet(VProperty *prop) void VPE::VPropertySet::removePropertyFromSet(VProperty *prop)
{ {
// Remove all the children // Remove all the children
foreach(VProperty* tmpChild, prop->getChildren()) const QList<VPE::VProperty*>& children = prop->getChildren();
for (auto tmpChild : children)
{
removeProperty(tmpChild); removeProperty(tmpChild);
}
const QList<QString> tmpKeys = d_ptr->Properties.keys(prop);
QList<QString> tmpKeys = d_ptr->Properties.keys(prop); for (auto &tmpID : tmpKeys)
foreach(const QString& tmpID, tmpKeys) {
d_ptr->Properties.remove(tmpID); d_ptr->Properties.remove(tmpID);
}
// Remove from list // Remove from list
d_ptr->RootProperties.removeAll(prop); d_ptr->RootProperties.removeAll(prop);

View File

@ -61,7 +61,7 @@ void VPE::VSerializedProperty::initChildren(const VProperty *property, const VPr
if (property && set) if (property && set)
{ {
const QList<VProperty*>& tmpChildren = property->getChildren(); const QList<VProperty*>& tmpChildren = property->getChildren();
foreach(const VProperty* tmpChild, tmpChildren) for (auto tmpChild : tmpChildren)
{ {
QString tmpChildID = set->getPropertyID(property); QString tmpChildID = set->getPropertyID(property);
Children.append(VSerializedProperty(tmpChild, tmpChildID, set)); Children.append(VSerializedProperty(tmpChild, tmpChildID, set));

View File

@ -163,9 +163,9 @@ bool AbstractTest::CopyRecursively(const QString &srcFilePath, const QString &tg
return false; return false;
} }
QDir sourceDir(srcFilePath); QDir sourceDir(srcFilePath);
QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | const QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot |
QDir::System); QDir::Hidden | QDir::System);
foreach (const QString &fileName, fileNames) for (auto &fileName : fileNames)
{ {
const QString newSrcFilePath = srcFilePath + QDir::separator() + fileName; const QString newSrcFilePath = srcFilePath + QDir::separator() + fileName;
const QString newTgtFilePath = tgtFilePath + QDir::separator() + fileName; const QString newTgtFilePath = tgtFilePath + QDir::separator() + fileName;

View File

@ -291,7 +291,11 @@ void DialogEditLabel::ExportTemplate()
QString fileName = QFileDialog::getSaveFileName(this, tr("Export label template"), QString fileName = QFileDialog::getSaveFileName(this, tr("Export label template"),
path + QLatin1String("/") + tr("template") + QLatin1String(".xml"), path + QLatin1String("/") + tr("template") + QLatin1String(".xml"),
filters, nullptr, QFileDialog::DontUseNativeDialog); filters, nullptr
#ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
@ -340,8 +344,11 @@ void DialogEditLabel::ImportTemplate()
QString filter(tr("Label template") + QLatin1String(" (*.xml)")); QString filter(tr("Label template") + QLatin1String(" (*.xml)"));
//Use standard path to label templates //Use standard path to label templates
const QString path = VCommonSettings::PrepareLabelTemplates(qApp->Settings()->GetPathLabelTemplate()); const QString path = VCommonSettings::PrepareLabelTemplates(qApp->Settings()->GetPathLabelTemplate());
const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"), path, filter, nullptr, const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"), path, filter, nullptr
QFileDialog::DontUseNativeDialog); #ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
return; return;
@ -574,16 +581,16 @@ void DialogEditLabel::SetTemplate(const QVector<VLabelTemplateLine> &lines)
int row = -1; int row = -1;
for (int i=0; i<lines.size(); ++i) for (auto &line : lines)
{ {
QListWidgetItem *item = new QListWidgetItem(qApp->TrVars()->PlaceholderToUserText(lines.at(i).line)); QListWidgetItem *item = new QListWidgetItem(qApp->TrVars()->PlaceholderToUserText(line.line));
item->setTextAlignment(lines.at(i).alignment); item->setTextAlignment(line.alignment);
item->setData(Qt::UserRole, lines.at(i).fontSizeIncrement); item->setData(Qt::UserRole, line.fontSizeIncrement);
QFont font = item->font(); QFont font = item->font();
font.setBold(lines.at(i).bold); font.setBold(line.bold);
font.setItalic(lines.at(i).italic); font.setItalic(line.italic);
font.setPointSize(font.pointSize() + lines.at(i).fontSizeIncrement); font.setPointSize(font.pointSize() + line.fontSizeIncrement);
item->setFont(font); item->setFont(font);
ui->listWidgetEdit->insertItem(++row, item); ui->listWidgetEdit->insertItem(++row, item);
@ -622,16 +629,16 @@ void DialogEditLabel::InitPreviewLines(const QVector<VLabelTemplateLine> &lines)
int row = -1; int row = -1;
for (int i=0; i<lines.size(); ++i) for (auto &line : lines)
{ {
QListWidgetItem *item = new QListWidgetItem(ReplacePlaceholders(lines.at(i).line)); QListWidgetItem *item = new QListWidgetItem(ReplacePlaceholders(line.line));
item->setTextAlignment(lines.at(i).alignment); item->setTextAlignment(line.alignment);
item->setData(Qt::UserRole, lines.at(i).fontSizeIncrement); item->setData(Qt::UserRole, line.fontSizeIncrement);
QFont font = item->font(); QFont font = item->font();
font.setBold(lines.at(i).bold); font.setBold(line.bold);
font.setItalic(lines.at(i).italic); font.setItalic(line.italic);
font.setPointSize(font.pointSize() + lines.at(i).fontSizeIncrement); font.setPointSize(font.pointSize() + line.fontSizeIncrement);
item->setFont(font); item->setFont(font);
ui->listWidgetPreview->insertItem(++row, item); ui->listWidgetPreview->insertItem(++row, item);

View File

@ -254,9 +254,9 @@ void DialogFlippingByAxis::SuffixChanged()
{ {
QRegularExpression rx(NameRegExp()); QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = VContainer::AllUniqueNames(); const QStringList uniqueNames = VContainer::AllUniqueNames();
for (int i=0; i < uniqueNames.size(); ++i) for (auto &uniqueName : uniqueNames)
{ {
const QString name = uniqueNames.at(i) + suffix; const QString name = uniqueName + suffix;
if (not rx.match(name).hasMatch() || not data->IsUnique(name)) if (not rx.match(name).hasMatch() || not data->IsUnique(name))
{ {
flagName = false; flagName = false;

View File

@ -281,9 +281,9 @@ void DialogFlippingByLine::SuffixChanged()
{ {
QRegularExpression rx(NameRegExp()); QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = VContainer::AllUniqueNames(); const QStringList uniqueNames = VContainer::AllUniqueNames();
for (int i=0; i < uniqueNames.size(); ++i) for (auto &uniqueName : uniqueNames)
{ {
const QString name = uniqueNames.at(i) + suffix; const QString name = uniqueName + suffix;
if (not rx.match(name).hasMatch() || not data->IsUnique(name)) if (not rx.match(name).hasMatch() || not data->IsUnique(name))
{ {
flagName = false; flagName = false;

View File

@ -474,9 +474,9 @@ void DialogMove::SuffixChanged()
{ {
QRegularExpression rx(NameRegExp()); QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = VContainer::AllUniqueNames(); const QStringList uniqueNames = VContainer::AllUniqueNames();
for (int i=0; i < uniqueNames.size(); ++i) for (auto &uniqueName : uniqueNames)
{ {
const QString name = uniqueNames.at(i) + suffix; const QString name = uniqueName + suffix;
if (not rx.match(name).hasMatch() || not data->IsUnique(name)) if (not rx.match(name).hasMatch() || not data->IsUnique(name))
{ {
flagName = false; flagName = false;

View File

@ -336,9 +336,9 @@ void DialogRotation::SuffixChanged()
{ {
QRegularExpression rx(NameRegExp()); QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = VContainer::AllUniqueNames(); const QStringList uniqueNames = VContainer::AllUniqueNames();
for (int i=0; i < uniqueNames.size(); ++i) for (auto &uniqueName : uniqueNames)
{ {
const QString name = uniqueNames.at(i) + suffix; const QString name = uniqueName + suffix;
if (not rx.match(name).hasMatch() || not data->IsUnique(name)) if (not rx.match(name).hasMatch() || not data->IsUnique(name))
{ {
flagName = false; flagName = false;

View File

@ -218,9 +218,9 @@ void DialogTool::FillComboBoxPiecesList(QComboBox *box, const QVector<quint32> &
SCASSERT(box != nullptr) SCASSERT(box != nullptr)
box->blockSignals(true); box->blockSignals(true);
box->clear(); box->clear();
for (int i=0; i < list.size(); ++i) for (auto id : list)
{ {
box->addItem(data->GetPiece(list.at(i)).GetName(), list.at(i)); box->addItem(data->GetPiece(id).GetName(), id);
} }
box->blockSignals(false); box->blockSignals(false);
box->setCurrentIndex(-1); // Force a user to choose box->setCurrentIndex(-1); // Force a user to choose

View File

@ -1022,9 +1022,8 @@ void DialogPiecePath::InitPassmarksList()
const QVector<VPieceNode> nodes = GetListInternals<VPieceNode>(ui->listWidget); const QVector<VPieceNode> nodes = GetListInternals<VPieceNode>(ui->listWidget);
for (int i = 0; i < nodes.size(); ++i) for (auto &node : nodes)
{ {
const VPieceNode node = nodes.at(i);
if (node.GetTypeTool() == Tool::NodePoint && node.IsPassmark()) if (node.GetTypeTool() == Tool::NodePoint && node.IsPassmark())
{ {
const QString name = GetNodeName(node); const QString name = GetNodeName(node);

View File

@ -163,11 +163,6 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
flagMainPathIsValid = MainPathIsValid(); flagMainPathIsValid = MainPathIsValid();
CheckState(); CheckState();
if (not applyAllowed)
{
vis = new VisToolPiece(data);
}
m_ftb->SetCurrentIndex(TabOrder::Paths);// Show always first tab active on start. m_ftb->SetCurrentIndex(TabOrder::Paths);// Show always first tab active on start.
} }
@ -203,6 +198,11 @@ void DialogSeamAllowance::EnableApply(bool enable)
m_ftb->SetTabEnabled(TabOrder::Grainline, applyAllowed); m_ftb->SetTabEnabled(TabOrder::Grainline, applyAllowed);
m_ftb->SetTabEnabled(TabOrder::Passmarks, applyAllowed); m_ftb->SetTabEnabled(TabOrder::Passmarks, applyAllowed);
m_ftb->SetTabEnabled(TabOrder::PlaceLabels, applyAllowed); m_ftb->SetTabEnabled(TabOrder::PlaceLabels, applyAllowed);
if (not applyAllowed && vis.isNull())
{
vis = new VisToolPiece(data);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -223,9 +223,9 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
uiTabPaths->checkBoxHideMainPath->setChecked(piece.IsHideMainPath()); uiTabPaths->checkBoxHideMainPath->setChecked(piece.IsHideMainPath());
uiTabPaths->listWidgetCustomSA->blockSignals(true); uiTabPaths->listWidgetCustomSA->blockSignals(true);
uiTabPaths->listWidgetCustomSA->clear(); uiTabPaths->listWidgetCustomSA->clear();
for (int i = 0; i < piece.GetCustomSARecords().size(); ++i) QVector<CustomSARecord> records = piece.GetCustomSARecords();
for (auto record : records)
{ {
const CustomSARecord &record = piece.GetCustomSARecords().at(i);
if (record.path > NULL_ID) if (record.path > NULL_ID)
{ {
const QString name = GetPathName(record.path, record.reverse); const QString name = GetPathName(record.path, record.reverse);
@ -240,9 +240,9 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
uiTabPaths->listWidgetCustomSA->blockSignals(false); uiTabPaths->listWidgetCustomSA->blockSignals(false);
uiTabPaths->listWidgetInternalPaths->clear(); uiTabPaths->listWidgetInternalPaths->clear();
for (int i = 0; i < piece.GetInternalPaths().size(); ++i) const QVector<quint32> paths = piece.GetInternalPaths();
for (auto path : paths)
{ {
const quint32 path = piece.GetInternalPaths().at(i);
if (path > NULL_ID) if (path > NULL_ID)
{ {
const QString name = GetPathName(path); const QString name = GetPathName(path);
@ -277,17 +277,19 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
}; };
uiTabPins->listWidgetPins->clear(); uiTabPins->listWidgetPins->clear();
for (int i = 0; i < piece.GetPins().size(); ++i) const QVector<quint32> pins = piece.GetPins();
for (auto pin : pins)
{ {
NewSpecialPoint(uiTabPins->listWidgetPins, piece.GetPins().at(i)); NewSpecialPoint(uiTabPins->listWidgetPins, pin);
} }
InitAllPinComboboxes(); InitAllPinComboboxes();
uiTabPlaceLabels->listWidgetPlaceLabels->clear(); uiTabPlaceLabels->listWidgetPlaceLabels->clear();
for (int i = 0; i < piece.GetPlaceLabels().size(); ++i) const QVector<quint32> labels = piece.GetPlaceLabels();
for (auto label : labels)
{ {
NewSpecialPoint(uiTabPlaceLabels->listWidgetPlaceLabels, piece.GetPlaceLabels().at(i)); NewSpecialPoint(uiTabPlaceLabels->listWidgetPlaceLabels, label);
} }
if (piece.GetPlaceLabels().size() > 0) if (piece.GetPlaceLabels().size() > 0)
@ -2471,9 +2473,8 @@ void DialogSeamAllowance::InitNodesList()
const QVector<VPieceNode> nodes = GetListInternals<VPieceNode>(uiTabPaths->listWidgetMainPath); const QVector<VPieceNode> nodes = GetListInternals<VPieceNode>(uiTabPaths->listWidgetMainPath);
for (int i = 0; i < nodes.size(); ++i) for (auto &node : nodes)
{ {
const VPieceNode node = nodes.at(i);
if (node.GetTypeTool() == Tool::NodePoint && not node.IsExcluded()) if (node.GetTypeTool() == Tool::NodePoint && not node.IsExcluded())
{ {
const QString name = GetNodeName(node); const QString name = GetNodeName(node);
@ -2505,9 +2506,8 @@ void DialogSeamAllowance::InitPassmarksList()
const QVector<VPieceNode> nodes = GetListInternals<VPieceNode>(uiTabPaths->listWidgetMainPath); const QVector<VPieceNode> nodes = GetListInternals<VPieceNode>(uiTabPaths->listWidgetMainPath);
for (int i = 0; i < nodes.size(); ++i) for (auto &node : nodes)
{ {
const VPieceNode node = nodes.at(i);
if (node.GetTypeTool() == Tool::NodePoint && node.IsPassmark()) if (node.GetTypeTool() == Tool::NodePoint && node.IsPassmark())
{ {
const QString name = GetNodeName(node); const QString name = GetNodeName(node);
@ -2775,9 +2775,8 @@ void DialogSeamAllowance::InitCSAPoint(QComboBox *box)
const QVector<VPieceNode> nodes = GetListInternals<VPieceNode>(uiTabPaths->listWidgetMainPath); const QVector<VPieceNode> nodes = GetListInternals<VPieceNode>(uiTabPaths->listWidgetMainPath);
for (int i = 0; i < nodes.size(); ++i) for (auto &node : nodes)
{ {
const VPieceNode &node = nodes.at(i);
if (node.GetTypeTool() == Tool::NodePoint && not node.IsExcluded()) if (node.GetTypeTool() == Tool::NodePoint && not node.IsExcluded())
{ {
const QString name = GetNodeName(node); const QString name = GetNodeName(node);
@ -2802,10 +2801,9 @@ void DialogSeamAllowance::InitPinPoint(QComboBox *box)
const QVector<quint32> pins = GetListInternals<quint32>(uiTabPins->listWidgetPins); const QVector<quint32> pins = GetListInternals<quint32>(uiTabPins->listWidgetPins);
for (int i = 0; i < pins.size(); ++i) for (auto pin : pins)
{ {
const QSharedPointer<VGObject> pin = data->GetGObject(pins.at(i)); box->addItem(data->GetGObject(pin)->name(), pin);
box->addItem(pin->name(), pins.at(i));
} }
const int index = uiTabPaths->comboBoxNodes->findData(currentId); const int index = uiTabPaths->comboBoxNodes->findData(currentId);
@ -3028,10 +3026,13 @@ void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula)
} }
uiTabPaths->plainTextEditFormulaWidth->setPlainText(width); uiTabPaths->plainTextEditFormulaWidth->setPlainText(width);
VisToolPiece *path = qobject_cast<VisToolPiece *>(vis); if (not applyAllowed)
SCASSERT(path != nullptr) {
const VPiece p = CreatePiece(); VisToolPiece *path = qobject_cast<VisToolPiece *>(vis);
path->SetPiece(p); SCASSERT(path != nullptr)
const VPiece p = CreatePiece();
path->SetPiece(p);
}
MoveCursorToEnd(uiTabPaths->plainTextEditFormulaWidth); MoveCursorToEnd(uiTabPaths->plainTextEditFormulaWidth);
} }
@ -3298,9 +3299,9 @@ QString DialogSeamAllowance::GetDefaultPieceName() const
QList<VPiece> pieces = data->DataPieces()->values(); QList<VPiece> pieces = data->DataPieces()->values();
QSet<QString> names; QSet<QString> names;
for (int i = 0; i < pieces.size(); ++i) for (auto &piece : pieces)
{ {
names.insert(pieces.at(i).GetName()); names.insert(piece.GetName());
} }
const QString defName = tr("Detail"); const QString defName = tr("Detail");

View File

@ -55,9 +55,8 @@ void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData,
initData.id = VContainer::getNextId();//Just reserve id for tool initData.id = VContainer::getNextId();//Just reserve id for tool
for (int i = 0; i < initData.source.size(); ++i) for (auto idObject : qAsConst(initData.source))
{ {
const quint32 idObject = initData.source.at(i);
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject); const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
// This check helps to find missed objects in the switch // This check helps to find missed objects in the switch

View File

@ -130,9 +130,9 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData ini
InitOperationToolConnections(initData.scene, tool); InitOperationToolConnections(initData.scene, tool);
VAbstractPattern::AddTool(initData.id, tool); VAbstractPattern::AddTool(initData.id, tool);
initData.doc->IncrementReferens(originPoint.getIdTool()); initData.doc->IncrementReferens(originPoint.getIdTool());
for (int i = 0; i < initData.source.size(); ++i) for (auto idObject : qAsConst(initData.source))
{ {
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool()); initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
} }
return tool; return tool;
} }

View File

@ -124,9 +124,9 @@ VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData ini
VAbstractPattern::AddTool(initData.id, tool); VAbstractPattern::AddTool(initData.id, tool);
initData.doc->IncrementReferens(firstPoint.getIdTool()); initData.doc->IncrementReferens(firstPoint.getIdTool());
initData.doc->IncrementReferens(secondPoint.getIdTool()); initData.doc->IncrementReferens(secondPoint.getIdTool());
for (int i = 0; i < initData.source.size(); ++i) for (auto idObject : qAsConst(initData.source))
{ {
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool()); initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
} }
return tool; return tool;
} }

View File

@ -519,26 +519,26 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
doc->RemoveAllChildren(tag); doc->RemoveAllChildren(tag);
QDomElement tagObjects = doc->createElement(TagSource); QDomElement tagObjects = doc->createElement(TagSource);
for (int i = 0; i < source.size(); ++i) for (auto id : qAsConst(source))
{ {
QDomElement item = doc->createElement(TagItem); QDomElement item = doc->createElement(TagItem);
doc->SetAttribute(item, AttrIdObject, source.at(i)); doc->SetAttribute(item, AttrIdObject, id);
tagObjects.appendChild(item); tagObjects.appendChild(item);
} }
tag.appendChild(tagObjects); tag.appendChild(tagObjects);
tagObjects = doc->createElement(TagDestination); tagObjects = doc->createElement(TagDestination);
for (int i = 0; i < destination.size(); ++i) for (auto dItem : qAsConst(destination))
{ {
QDomElement item = doc->createElement(TagItem); QDomElement item = doc->createElement(TagItem);
doc->SetAttribute(item, AttrIdObject, destination.at(i).id); doc->SetAttribute(item, AttrIdObject, dItem.id);
if (not VFuzzyComparePossibleNulls(destination.at(i).mx, INT_MAX) && if (not VFuzzyComparePossibleNulls(dItem.mx, INT_MAX) &&
not VFuzzyComparePossibleNulls(destination.at(i).my, INT_MAX)) not VFuzzyComparePossibleNulls(dItem.my, INT_MAX))
{ {
doc->SetAttribute(item, AttrMx, qApp->fromPixel(destination.at(i).mx)); doc->SetAttribute(item, AttrMx, qApp->fromPixel(dItem.mx));
doc->SetAttribute(item, AttrMy, qApp->fromPixel(destination.at(i).my)); doc->SetAttribute(item, AttrMy, qApp->fromPixel(dItem.my));
doc->SetAttribute<bool>(item, AttrShowLabel, destination.at(i).showLabel); doc->SetAttribute<bool>(item, AttrShowLabel, dItem.showLabel);
} }
tagObjects.appendChild(item); tagObjects.appendChild(item);
@ -609,9 +609,8 @@ void VAbstractOperation::AllowCurveSelecting(bool enabled, GOType type)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::InitOperatedObjects() void VAbstractOperation::InitOperatedObjects()
{ {
for (int i = 0; i < destination.size(); ++i) for (auto object : qAsConst(destination))
{ {
const DestinationItem object = destination.at(i);
const QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(object.id); const QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(object.id);
// This check helps to find missed objects in the switch // This check helps to find missed objects in the switch

View File

@ -82,9 +82,8 @@ QPointF GetOriginPoint(const QVector<quint32> objects, const VContainer *data, q
{ {
QPolygonF originObjects; QPolygonF originObjects;
for (int i = 0; i < objects.size(); ++i) for (auto id : objects)
{ {
const quint32 id = objects.at(i);
const QSharedPointer<VGObject> obj = data->GetGObject(id); const QSharedPointer<VGObject> obj = data->GetGObject(id);
// This check helps to find missed objects in the switch // This check helps to find missed objects in the switch
@ -106,7 +105,7 @@ QPointF GetOriginPoint(const QVector<quint32> objects, const VContainer *data, q
originObjects.append(data->GeometricObject<VAbstractCurve>(id)->GetPoints()); originObjects.append(data->GeometricObject<VAbstractCurve>(id)->GetPoints());
#else #else
const QVector<QPointF> points = data->GeometricObject<VAbstractCurve>(id)->GetPoints(); const QVector<QPointF> points = data->GeometricObject<VAbstractCurve>(id)->GetPoints();
foreach (const QPointF &point, points) for (auto &point : points)
{ {
originObjects.append(point); originObjects.append(point);
} }
@ -200,9 +199,8 @@ VToolMove *VToolMove::Create(VToolMoveInitData &initData)
initData.id = VContainer::getNextId();//Just reserve id for tool initData.id = VContainer::getNextId();//Just reserve id for tool
for (int i = 0; i < initData.source.size(); ++i) for (auto idObject : qAsConst(initData.source))
{ {
const quint32 idObject = initData.source.at(i);
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject); const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
// This check helps to find missed objects in the switch // This check helps to find missed objects in the switch
@ -332,9 +330,9 @@ QT_WARNING_POP
initData.doc->IncrementReferens(originPoint->getIdTool()); initData.doc->IncrementReferens(originPoint->getIdTool());
} }
for (int i = 0; i < initData.source.size(); ++i) for (auto idObject : qAsConst(initData.source))
{ {
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool()); initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
} }
return tool; return tool;
} }

View File

@ -144,9 +144,8 @@ VToolRotation *VToolRotation::Create(VToolRotationInitData &initData)
initData.id = VContainer::getNextId();//Just reserve id for tool initData.id = VContainer::getNextId();//Just reserve id for tool
for (int i = 0; i < initData.source.size(); ++i) for (auto idObject : qAsConst(initData.source))
{ {
const quint32 idObject = initData.source.at(i);
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject); const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
// This check helps to find missed objects in the switch // This check helps to find missed objects in the switch
@ -259,9 +258,9 @@ QT_WARNING_POP
InitOperationToolConnections(initData.scene, tool); InitOperationToolConnections(initData.scene, tool);
VAbstractPattern::AddTool(initData.id, tool); VAbstractPattern::AddTool(initData.id, tool);
initData.doc->IncrementReferens(originPoint.getIdTool()); initData.doc->IncrementReferens(originPoint.getIdTool());
for (int i = 0; i < initData.source.size(); ++i) for (auto idObject : qAsConst(initData.source))
{ {
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool()); initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
} }
return tool; return tool;
} }

View File

@ -174,7 +174,7 @@ void VAbstractSpline::AllowHover(bool enabled)
// Manually handle hover events. Need for setting cursor for not selectable paths. // Manually handle hover events. Need for setting cursor for not selectable paths.
m_acceptHoverEvents = enabled; m_acceptHoverEvents = enabled;
foreach (auto *point, controlPoints) for (auto point : qAsConst(controlPoints))
{ {
point->setAcceptHoverEvents(enabled); point->setAcceptHoverEvents(enabled);
} }
@ -185,7 +185,7 @@ void VAbstractSpline::AllowSelecting(bool enabled)
{ {
setFlag(QGraphicsItem::ItemIsSelectable, enabled); setFlag(QGraphicsItem::ItemIsSelectable, enabled);
foreach (auto *point, controlPoints) for (auto point : qAsConst(controlPoints))
{ {
point->setFlag(QGraphicsItem::ItemIsSelectable, enabled); point->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
} }
@ -424,7 +424,7 @@ void VAbstractSpline::CurveSelected(bool selected)
{ {
setSelected(selected); setSelected(selected);
foreach (auto *point, controlPoints) for (auto point : qAsConst(controlPoints))
{ {
point->blockSignals(true); point->blockSignals(true);
point->setSelected(selected); point->setSelected(selected);
@ -442,9 +442,9 @@ void VAbstractSpline::InitDefShape()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::ShowHandles(bool show) void VAbstractSpline::ShowHandles(bool show)
{ {
for (int i = 0; i < controlPoints.size(); ++i) for (auto point : qAsConst(controlPoints))
{ {
controlPoints.at(i)->setVisible(show); point->setVisible(show);
} }
update();// Show direction update();// Show direction
} }

View File

@ -294,7 +294,7 @@ void VToolSpline::EnableToolMove(bool move)
{ {
this->setFlag(QGraphicsItem::ItemIsMovable, move); this->setFlag(QGraphicsItem::ItemIsMovable, move);
foreach (auto *point, controlPoints) for (auto point : qAsConst(controlPoints))
{ {
point->setFlag(QGraphicsItem::ItemIsMovable, move); point->setFlag(QGraphicsItem::ItemIsMovable, move);
} }
@ -562,7 +562,7 @@ bool VToolSpline::IsMovable() const
void VToolSpline::RefreshCtrlPoints() void VToolSpline::RefreshCtrlPoints()
{ {
// Very important to disable control points. Without it the pogram can't move the curve. // Very important to disable control points. Without it the pogram can't move the curve.
foreach (auto *point, controlPoints) for (auto point : qAsConst(controlPoints))
{ {
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
} }
@ -595,7 +595,7 @@ void VToolSpline::RefreshCtrlPoints()
controlPoints[0]->blockSignals(false); controlPoints[0]->blockSignals(false);
controlPoints[1]->blockSignals(false); controlPoints[1]->blockSignals(false);
foreach (auto *point, controlPoints) for (auto point : qAsConst(controlPoints))
{ {
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
} }

View File

@ -293,7 +293,7 @@ void VToolSplinePath::EnableToolMove(bool move)
{ {
this->setFlag(QGraphicsItem::ItemIsMovable, move); this->setFlag(QGraphicsItem::ItemIsMovable, move);
foreach (auto *point, controlPoints) for (auto point : qAsConst(controlPoints))
{ {
point->setFlag(QGraphicsItem::ItemIsMovable, move); point->setFlag(QGraphicsItem::ItemIsMovable, move);
} }
@ -727,7 +727,7 @@ bool VToolSplinePath::IsMovable(int index) const
void VToolSplinePath::RefreshCtrlPoints() void VToolSplinePath::RefreshCtrlPoints()
{ {
// Very important to disable control points. Without it the pogram can't move the curve. // Very important to disable control points. Without it the pogram can't move the curve.
foreach (auto *point, controlPoints) for (auto point : qAsConst(controlPoints))
{ {
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
} }
@ -765,7 +765,7 @@ void VToolSplinePath::RefreshCtrlPoints()
controlPoints[j-1]->blockSignals(false); controlPoints[j-1]->blockSignals(false);
} }
foreach (auto *point, controlPoints) for (auto point : qAsConst(controlPoints))
{ {
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
} }

View File

@ -411,12 +411,12 @@ void VAbstractTool::ToolCreation(const Source &typeCreation)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VToolRecord VAbstractTool::GetRecord(const quint32 id, const Tool &toolType, VAbstractPattern *doc) VToolRecord VAbstractTool::GetRecord(const quint32 id, const Tool &toolType, VAbstractPattern *doc)
{ {
QVector<VToolRecord> *history = doc->getHistory(); const QVector<VToolRecord> *history = doc->getHistory();
for(int i = 0; i < history->size(); ++i) for(auto &record : *history)
{ {
if (history->at(i).getId() == id && history->at(i).getTypeTool() == toolType) if (record.getId() == id && record.getTypeTool() == toolType)
{ {
return history->at(i); return record;
} }
} }
return VToolRecord(); return VToolRecord();

View File

@ -300,9 +300,9 @@ void VToolSeamAllowance::AddCSARecords(VAbstractPattern *doc, QDomElement &domEl
if (records.size() > 0) if (records.size() > 0)
{ {
QDomElement csaRecordsElement = doc->createElement(VToolSeamAllowance::TagCSA); QDomElement csaRecordsElement = doc->createElement(VToolSeamAllowance::TagCSA);
for (int i = 0; i < records.size(); ++i) for (auto record : records)
{ {
AddCSARecord(doc, csaRecordsElement, records.at(i)); AddCSARecord(doc, csaRecordsElement, record);
} }
domElement.appendChild(csaRecordsElement); domElement.appendChild(csaRecordsElement);
} }
@ -314,10 +314,10 @@ void VToolSeamAllowance::AddInternalPaths(VAbstractPattern *doc, QDomElement &do
if (paths.size() > 0) if (paths.size() > 0)
{ {
QDomElement iPathsElement = doc->createElement(VToolSeamAllowance::TagIPaths); QDomElement iPathsElement = doc->createElement(VToolSeamAllowance::TagIPaths);
for (int i = 0; i < paths.size(); ++i) for (auto path : paths)
{ {
QDomElement recordNode = doc->createElement(VToolSeamAllowance::TagRecord); QDomElement recordNode = doc->createElement(VToolSeamAllowance::TagRecord);
doc->SetAttribute(recordNode, VAbstractPattern::AttrPath, paths.at(i)); doc->SetAttribute(recordNode, VAbstractPattern::AttrPath, path);
iPathsElement.appendChild(recordNode); iPathsElement.appendChild(recordNode);
} }
domElement.appendChild(iPathsElement); domElement.appendChild(iPathsElement);
@ -1240,9 +1240,9 @@ void VToolSeamAllowance::keyReleaseEvent(QKeyEvent *event)
{ {
qApp->getUndoStack()->beginMacro(tr("multi deletion")); qApp->getUndoStack()->beginMacro(tr("multi deletion"));
for(int i=0; i < toolList.size(); ++i) for(auto tool : toolList)
{ {
toolList.at(i)->RemoveWithConfirm(false); tool->RemoveWithConfirm(false);
} }
} }
DeleteToolWithConfirm(false); DeleteToolWithConfirm(false);
@ -1332,12 +1332,12 @@ void VToolSeamAllowance::UpdateExcludeState()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::UpdateInternalPaths() void VToolSeamAllowance::UpdateInternalPaths()
{ {
const VPiece detail = VAbstractTool::data.GetPiece(m_id); const QVector<quint32> paths = VAbstractTool::data.GetPiece(m_id).GetInternalPaths();
for (int i = 0; i < detail.GetInternalPaths().size(); ++i) for (auto path : paths)
{ {
try try
{ {
if (auto *tool = qobject_cast<VToolPiecePath*>(VAbstractPattern::getTool(detail.GetInternalPaths().at(i)))) if (auto *tool = qobject_cast<VToolPiecePath*>(VAbstractPattern::getTool(path)))
{ {
tool->RefreshGeometry(); tool->RefreshGeometry();
} }
@ -1355,7 +1355,9 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren)
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
const VPiece detail = VAbstractTool::data.GetPiece(m_id); const VPiece detail = VAbstractTool::data.GetPiece(m_id);
QFuture<QPainterPath > futurePath = QtConcurrent::run(detail, &VPiece::MainPathPath, this->getData()); QFuture<QPainterPath > futurePath = QtConcurrent::run(detail,
QOverload<const VContainer *>::of(&VPiece::MainPathPath),
this->getData());
QFuture<QVector<QPointF> > futureSeamAllowance; QFuture<QVector<QPointF> > futureSeamAllowance;
if (detail.IsSeamAllowance()) if (detail.IsSeamAllowance())
@ -1440,7 +1442,7 @@ void VToolSeamAllowance::SaveDialogChange(const QString &undoText)
{ {
qApp->getUndoStack()->beginMacro(undoText.isEmpty() ? saveCommand->text(): undoText); qApp->getUndoStack()->beginMacro(undoText.isEmpty() ? saveCommand->text(): undoText);
foreach (QUndoCommand* command, undocommands) for (auto command : undocommands)
{ {
qApp->getUndoStack()->push(command); qApp->getUndoStack()->push(command);
} }
@ -1764,18 +1766,20 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::InitCSAPaths(const VPiece &detail) const void VToolSeamAllowance::InitCSAPaths(const VPiece &detail) const
{ {
for (int i = 0; i < detail.GetCustomSARecords().size(); ++i) const QVector<CustomSARecord> records = detail.GetCustomSARecords();
for (auto record : records)
{ {
doc->IncrementReferens(detail.GetCustomSARecords().at(i).path); doc->IncrementReferens(record.path);
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::InitInternalPaths(const VPiece &detail) void VToolSeamAllowance::InitInternalPaths(const VPiece &detail)
{ {
for (int i = 0; i < detail.GetInternalPaths().size(); ++i) const QVector<quint32> paths = detail.GetInternalPaths();
for (auto path : paths)
{ {
auto *tool = qobject_cast<VToolPiecePath*>(VAbstractPattern::getTool(detail.GetInternalPaths().at(i))); auto *tool = qobject_cast<VToolPiecePath*>(VAbstractPattern::getTool(path));
SCASSERT(tool != nullptr); SCASSERT(tool != nullptr);
if (tool->parent() != this) if (tool->parent() != this)
@ -1784,16 +1788,16 @@ void VToolSeamAllowance::InitInternalPaths(const VPiece &detail)
tool->SetParentType(ParentType::Item); tool->SetParentType(ParentType::Item);
} }
tool->show(); tool->show();
doc->IncrementReferens(detail.GetInternalPaths().at(i)); doc->IncrementReferens(path);
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::InitSpecialPoints(const QVector<quint32> &points) const void VToolSeamAllowance::InitSpecialPoints(const QVector<quint32> &points) const
{ {
for (int i = 0; i < points.size(); ++i) for (auto point : points)
{ {
doc->IncrementReferens(points.at(i)); doc->IncrementReferens(point);
} }
} }
@ -1890,9 +1894,9 @@ QList<VToolSeamAllowance *> VToolSeamAllowance::SelectedTools() const
if (not list.isEmpty()) if (not list.isEmpty())
{ {
for(int i=0; i < list.size(); ++i) for(auto item : list)
{ {
VToolSeamAllowance *tool = qgraphicsitem_cast<VToolSeamAllowance *>(list.at(i)); VToolSeamAllowance *tool = qgraphicsitem_cast<VToolSeamAllowance *>(item);
if (tool != nullptr && tool->getId() != m_id) if (tool != nullptr && tool->getId() != m_id)
{ {
tools.append(tool); tools.append(tool);
@ -1911,10 +1915,10 @@ void VToolSeamAllowance::AddPointRecords(VAbstractPattern *doc, QDomElement &dom
if (records.size() > 0) if (records.size() > 0)
{ {
QDomElement pinsElement = doc->createElement(tag); QDomElement pinsElement = doc->createElement(tag);
for (int i = 0; i < records.size(); ++i) for (auto record : records)
{ {
QDomElement recordNode = doc->createElement(VToolSeamAllowance::TagRecord); QDomElement recordNode = doc->createElement(VToolSeamAllowance::TagRecord);
recordNode.appendChild(doc->createTextNode(QString().setNum(records.at(i)))); recordNode.appendChild(doc->createTextNode(QString().setNum(record)));
pinsElement.appendChild(recordNode); pinsElement.appendChild(recordNode);
} }
domElement.appendChild(pinsElement); domElement.appendChild(pinsElement);
@ -2009,9 +2013,8 @@ QVector<CustomSARecord> VToolSeamAllowance::DuplicateCustomSARecords(const QVect
const QMap<quint32, quint32> &replacements) const QMap<quint32, quint32> &replacements)
{ {
QVector<CustomSARecord> newRecords; QVector<CustomSARecord> newRecords;
for(int i=0; i < records.size(); ++i) for(auto record : records)
{ {
CustomSARecord record = records.at(i);
record.path = DuplicatePiecePath(record.path, initData); record.path = DuplicatePiecePath(record.path, initData);
record.startPoint = replacements.value(record.startPoint, NULL_ID); record.startPoint = replacements.value(record.startPoint, NULL_ID);
record.endPoint = replacements.value(record.endPoint, NULL_ID); record.endPoint = replacements.value(record.endPoint, NULL_ID);
@ -2025,9 +2028,9 @@ QVector<quint32> VToolSeamAllowance::DuplicateInternalPaths(const QVector<quint3
const VToolSeamAllowanceInitData &initData) const VToolSeamAllowanceInitData &initData)
{ {
QVector<quint32> newPaths; QVector<quint32> newPaths;
for(int i=0; i < iPaths.size(); ++i) for(auto iPath : iPaths)
{ {
newPaths.append(DuplicatePiecePath(iPaths.at(i), initData)); newPaths.append(DuplicatePiecePath(iPath, initData));
} }
return newPaths; return newPaths;
} }
@ -2037,11 +2040,11 @@ QVector<quint32> VToolSeamAllowance::DuplicatePins(const QVector<quint32> &pins,
const VToolSeamAllowanceInitData &initData) const VToolSeamAllowanceInitData &initData)
{ {
QVector<quint32> newPins; QVector<quint32> newPins;
for(int i=0; i < pins.size(); ++i) for(auto p : pins)
{ {
QSharedPointer<VPointF> pin = initData.data->GeometricObject<VPointF>(pins.at(i)); QSharedPointer<VPointF> pin = initData.data->GeometricObject<VPointF>(p);
VAbstractNode *tool = qobject_cast<VAbstractNode *>(VAbstractPattern::getTool(pins.at(i))); VAbstractNode *tool = qobject_cast<VAbstractNode *>(VAbstractPattern::getTool(p));
SCASSERT(tool != nullptr) SCASSERT(tool != nullptr)
VToolPinInitData initNodeData; VToolPinInitData initNodeData;
@ -2066,10 +2069,10 @@ QVector<quint32> VToolSeamAllowance::DuplicatePlaceLabels(const QVector<quint32>
const VToolSeamAllowanceInitData &initData) const VToolSeamAllowanceInitData &initData)
{ {
QVector<quint32> newPlaceLabels; QVector<quint32> newPlaceLabels;
for(int i=0; i < placeLabels.size(); ++i) for(auto placeLabel : placeLabels)
{ {
QSharedPointer<VPlaceLabelItem> label = initData.data->GeometricObject<VPlaceLabelItem>(placeLabels.at(i)); QSharedPointer<VPlaceLabelItem> label = initData.data->GeometricObject<VPlaceLabelItem>(placeLabel);
VAbstractNode *tool = qobject_cast<VAbstractNode *>(VAbstractPattern::getTool(placeLabels.at(i))); VAbstractNode *tool = qobject_cast<VAbstractNode *>(VAbstractPattern::getTool(placeLabel));
SCASSERT(tool != nullptr) SCASSERT(tool != nullptr)
VToolPlaceLabelInitData initNodeData; VToolPlaceLabelInitData initNodeData;

View File

@ -813,10 +813,10 @@ void SaveChildren(VAbstractPattern *doc, quint32 id, QDomElement section, const
{ {
if (children.size() > 0) if (children.size() > 0)
{ {
for (int i=0; i<children.size(); ++i) for (auto child : children)
{ {
QDomElement tagChild = doc->createElement(VToolUnionDetails::TagChild); QDomElement tagChild = doc->createElement(VToolUnionDetails::TagChild);
tagChild.appendChild(doc->createTextNode(QString().setNum(children.at(i)))); tagChild.appendChild(doc->createTextNode(QString().setNum(child)));
section.appendChild(tagChild); section.appendChild(tagChild);
} }
@ -1131,21 +1131,20 @@ void CreateUnitedNodes(VPiece &newDetail, const VPiece &d1, const VPiece &d2, co
const VPiecePath d1Path = d1.GetPath().RemoveEdge(initData.indexD1); const VPiecePath d1Path = d1.GetPath().RemoveEdge(initData.indexD1);
const VPiecePath d2Path = d2.GetPath().RemoveEdge(initData.indexD2); const VPiecePath d2Path = d2.GetPath().RemoveEdge(initData.indexD2);
const QVector<QPair<bool, VPieceNode> > unitedPath = VToolUnionDetails::CalcUnitedPath(d1Path, d2Path, const auto unitedPath = VToolUnionDetails::CalcUnitedPath(d1Path, d2Path, initData.indexD2, pRotate);
initData.indexD2, pRotate);
QVector<quint32> children; QVector<quint32> children;
VPiecePath newPath; VPiecePath newPath;
for (int i=0; i < unitedPath.size(); ++i) for (auto &path : unitedPath)
{ {
if (unitedPath.at(i).first) if (path.first)
{// first piece {// first piece
AddNodeToNewPath(initData, newPath, unitedPath.at(i).second, children, drawName); AddNodeToNewPath(initData, newPath, path.second, children, drawName);
} }
else else
{// second piece {// second piece
AddNodeToNewPath(initData, newPath, unitedPath.at(i).second, children, drawName, dx, dy, pRotate, angle); AddNodeToNewPath(initData, newPath, path.second, children, drawName, dx, dy, pRotate, angle);
} }
} }
@ -1161,9 +1160,9 @@ void CreateUnitedDetailCSA(VPiece &newDetail, const VPiece &d, QVector<quint32>
quint32 pRotate, qreal angle) quint32 pRotate, qreal angle)
{ {
QVector<quint32> nodeChildren; QVector<quint32> nodeChildren;
for(int i=0; i < d.GetCustomSARecords().size(); ++i) const QVector<CustomSARecord> records = d.GetCustomSARecords();
for(auto record : records)
{ {
CustomSARecord record = d.GetCustomSARecords().at(i);
const VPiecePath path = initData.data->GetPiecePath(record.path); const VPiecePath path = initData.data->GetPiecePath(record.path);
VPiecePath newPath = path; VPiecePath newPath = path;
newPath.Clear();//Clear nodes newPath.Clear();//Clear nodes
@ -1204,9 +1203,10 @@ void CreateUnitedDetailCSA(VPiece &newDetail, const VPiece &d, QVector<quint32>
void CreateUnitedCSA(VPiece &newDetail, const VPiece &d1, const VPiece &d2, const QString &drawName, void CreateUnitedCSA(VPiece &newDetail, const VPiece &d1, const VPiece &d2, const QString &drawName,
const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle) const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle)
{ {
for (int i = 0; i < d1.GetCustomSARecords().size(); ++i) const QVector<CustomSARecord> records = d1.GetCustomSARecords();
for (auto record : records)
{ {
newDetail.GetCustomSARecords().append(d1.GetCustomSARecords().at(i)); newDetail.GetCustomSARecords().append(record);
} }
QVector<quint32> children; QVector<quint32> children;
@ -1220,9 +1220,10 @@ void CreateUnitedDetailInternalPaths(VPiece &newDetail, const VPiece &d, QVector
qreal dy, quint32 pRotate, qreal angle) qreal dy, quint32 pRotate, qreal angle)
{ {
QVector<quint32> nodeChildren; QVector<quint32> nodeChildren;
for(int i=0; i < d.GetInternalPaths().size(); ++i) const QVector<quint32> internalPaths = d.GetInternalPaths();
for(auto iPath : internalPaths)
{ {
const VPiecePath path = initData.data->GetPiecePath(d.GetInternalPaths().at(i)); const VPiecePath path = initData.data->GetPiecePath(iPath);
VPiecePath newPath = path; VPiecePath newPath = path;
newPath.Clear();//Clear nodes newPath.Clear();//Clear nodes
@ -1263,9 +1264,10 @@ void CreateUnitedInternalPaths(VPiece &newDetail, const VPiece &d1, const VPiece
const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate,
qreal angle) qreal angle)
{ {
for (int i = 0; i < d1.GetInternalPaths().size(); ++i) const QVector<quint32> paths = d1.GetInternalPaths();
for (auto path : paths)
{ {
newDetail.GetInternalPaths().append(d1.GetInternalPaths().at(i)); newDetail.GetInternalPaths().append(path);
} }
QVector<quint32> children; QVector<quint32> children;
@ -1280,9 +1282,10 @@ void CreateUnitedDetailPins(VPiece &newDetail, const VPiece &d, QVector<quint32>
quint32 pRotate, qreal angle) quint32 pRotate, qreal angle)
{ {
QVector<quint32> nodeChildren; QVector<quint32> nodeChildren;
for(int i=0; i < d.GetPins().size(); ++i) const QVector<quint32> pins = d.GetPins();
for(auto pin : pins)
{ {
const quint32 id = AddPin(d.GetPins().at(i), initData, children, drawName, dx, dy, pRotate, angle); const quint32 id = AddPin(pin, initData, children, drawName, dx, dy, pRotate, angle);
newDetail.GetPins().append(id); newDetail.GetPins().append(id);
} }
children += nodeChildren; children += nodeChildren;
@ -1294,10 +1297,10 @@ void CreateUnitedDetailPlaceLabels(VPiece &newDetail, const VPiece &d, QVector<q
qreal dy, quint32 pRotate, qreal angle) qreal dy, quint32 pRotate, qreal angle)
{ {
QVector<quint32> nodeChildren; QVector<quint32> nodeChildren;
for(int i=0; i < d.GetPlaceLabels().size(); ++i) const QVector<quint32> placeLabels = d.GetPlaceLabels();
for(auto placeLabel : placeLabels)
{ {
const quint32 id = AddPlaceLabel(d.GetPlaceLabels().at(i), initData, children, drawName, dx, dy, pRotate, const quint32 id = AddPlaceLabel(placeLabel, initData, children, drawName, dx, dy, pRotate, angle);
angle);
newDetail.GetPlaceLabels().append(id); newDetail.GetPlaceLabels().append(id);
} }
children += nodeChildren; children += nodeChildren;
@ -1307,9 +1310,10 @@ void CreateUnitedDetailPlaceLabels(VPiece &newDetail, const VPiece &d, QVector<q
void CreateUnitedPins(VPiece &newDetail, const VPiece &d1, const VPiece &d2, const QString &drawName, void CreateUnitedPins(VPiece &newDetail, const VPiece &d1, const VPiece &d2, const QString &drawName,
const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle) const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle)
{ {
for (int i = 0; i < d1.GetPins().size(); ++i) const auto pins = d1.GetPins();
for (auto pin : pins)
{ {
newDetail.GetPins().append(d1.GetPins().at(i)); newDetail.GetPins().append(pin);
} }
QVector<quint32> children; QVector<quint32> children;
@ -1322,9 +1326,10 @@ void CreateUnitedPlaceLabels(VPiece &newDetail, const VPiece &d1, const VPiece &
const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate,
qreal angle) qreal angle)
{ {
for (int i = 0; i < d1.GetPlaceLabels().size(); ++i) const auto labels = d1.GetPlaceLabels();
for (auto label : labels)
{ {
newDetail.GetPlaceLabels().append(d1.GetPlaceLabels().at(i)); newDetail.GetPlaceLabels().append(label);
} }
QVector<quint32> children; QVector<quint32> children;
@ -1350,19 +1355,17 @@ void UpdateUnitedNodes(const VToolUnionDetailsInitData &initData, qreal dx, qrea
"Time to refactor the code."); "Time to refactor the code.");
if (children.size() == countNodeD1 + countNodeD2-1) if (children.size() == countNodeD1 + countNodeD2-1)
{ {
const QVector<QPair<bool, VPieceNode> > unitedPath = VToolUnionDetails::CalcUnitedPath(d1REPath, d2REPath, const auto unitedPath = VToolUnionDetails::CalcUnitedPath(d1REPath, d2REPath, initData.indexD2, pRotate);
initData.indexD2,
pRotate);
for (int i=0; i < unitedPath.size(); ++i) for (auto path : unitedPath)
{ {
if (unitedPath.at(i).first) if (path.first)
{// first piece {// first piece
UpdatePathNode(initData.data, unitedPath.at(i).second, children); UpdatePathNode(initData.data, path.second, children);
} }
else else
{// second piece {// second piece
UpdatePathNode(initData.data, unitedPath.at(i).second, children, dx, dy, pRotate, angle); UpdatePathNode(initData.data, path.second, children, dx, dy, pRotate, angle);
} }
} }
} }
@ -1400,9 +1403,9 @@ void UpdateUnitedNodes(const VToolUnionDetailsInitData &initData, qreal dx, qrea
void UpdateUnitedDetailPaths(const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, void UpdateUnitedDetailPaths(const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate,
qreal angle, const QVector<quint32> &records, QVector<quint32> children) qreal angle, const QVector<quint32> &records, QVector<quint32> children)
{ {
for (int i=0; i < records.size(); ++i) for (auto record : records)
{ {
const VPiecePath path = initData.data->GetPiecePath(records.at(i)); const VPiecePath path = initData.data->GetPiecePath(record);
if (initData.version == 1) if (initData.version == 1)
{ {
@ -1442,9 +1445,9 @@ void UpdateUnitedDetailCSA(const VToolUnionDetailsInitData &initData, qreal dx,
qreal angle, const QVector<CustomSARecord> &records) qreal angle, const QVector<CustomSARecord> &records)
{ {
QVector<quint32> idRecords; QVector<quint32> idRecords;
for (int i = 0; i < records.size(); ++i) for (auto record : records)
{ {
idRecords.append(records.at(i).path); idRecords.append(record.path);
} }
UpdateUnitedDetailPaths(initData, dx, dy, pRotate, angle, idRecords, GetCSAChildren(initData.doc, initData.id)); UpdateUnitedDetailPaths(initData, dx, dy, pRotate, angle, idRecords, GetCSAChildren(initData.doc, initData.id));
} }
@ -1463,9 +1466,9 @@ void UpdateUnitedDetailPins(const VToolUnionDetailsInitData &initData, qreal dx,
{ {
QVector<quint32> children = GetPinChildren(initData.doc, initData.id); QVector<quint32> children = GetPinChildren(initData.doc, initData.id);
for (int i = 0; i < records.size(); ++i) for (auto record : records)
{ {
QScopedPointer<VPointF> point(new VPointF(*initData.data->GeometricObject<VPointF>(records.at(i)))); QScopedPointer<VPointF> point(new VPointF(*initData.data->GeometricObject<VPointF>(record)));
point->setMode(Draw::Modeling); point->setMode(Draw::Modeling);
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
{ {
@ -1482,9 +1485,9 @@ void UpdateUnitedDetailPlaceLabels(const VToolUnionDetailsInitData &initData, qr
{ {
QVector<quint32> children = GetPlaceLabelChildren(initData.doc, initData.id); QVector<quint32> children = GetPlaceLabelChildren(initData.doc, initData.id);
for (int i = 0; i < records.size(); ++i) for (auto record : records)
{ {
QSharedPointer<VPlaceLabelItem> parentLabel = initData.data->GeometricObject<VPlaceLabelItem>(records.at(i)); QSharedPointer<VPlaceLabelItem> parentLabel = initData.data->GeometricObject<VPlaceLabelItem>(record);
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
{ {
BiasRotatePoint(parentLabel.data(), dx, dy, BiasRotatePoint(parentLabel.data(), dx, dy,
@ -1645,9 +1648,9 @@ void VToolUnionDetails::incrementReferens()
if (_referens == 1) if (_referens == 1)
{ {
const QVector<quint32> objects = GetReferenceObjects(); const QVector<quint32> objects = GetReferenceObjects();
for(int i = 0; i < objects.size(); ++i) for(auto object : objects)
{ {
doc->IncrementReferens(objects.at(i)); doc->IncrementReferens(object);
} }
QDomElement domElement = doc->elementById(m_id, getTagName()); QDomElement domElement = doc->elementById(m_id, getTagName());
@ -1665,9 +1668,9 @@ void VToolUnionDetails::decrementReferens()
if (_referens == 0) if (_referens == 0)
{ {
const QVector<quint32> objects = GetReferenceObjects(); const QVector<quint32> objects = GetReferenceObjects();
for(int i = 0; i < objects.size(); ++i) for(auto object : objects)
{ {
doc->DecrementReferens(objects.at(i)); doc->DecrementReferens(object);
} }
QDomElement domElement = doc->elementById(m_id, getTagName()); QDomElement domElement = doc->elementById(m_id, getTagName());

View File

@ -104,9 +104,8 @@ void VisOperation::RefreshFlippedObjects(const QPointF &firstPoint, const QPoint
{ {
int iPoint = -1; int iPoint = -1;
int iCurve = -1; int iCurve = -1;
for (int i = 0; i < objects.size(); ++i) for (auto id : qAsConst(objects))
{ {
const quint32 id = objects.at(i);
const QSharedPointer<VGObject> obj = Visualization::data->GetGObject(id); const QSharedPointer<VGObject> obj = Visualization::data->GetGObject(id);
// This check helps to find missed objects in the switch // This check helps to find missed objects in the switch

View File

@ -271,9 +271,8 @@ int VisToolMove::AddMovedRotatedCurve(qreal angle, qreal length, quint32 id, int
QPointF VisToolMove::GetOriginPoint(const QVector<QGraphicsItem *> &objects) QPointF VisToolMove::GetOriginPoint(const QVector<QGraphicsItem *> &objects)
{ {
QRectF boundingRect; QRectF boundingRect;
for (int i=0; i < objects.size(); ++i) for (auto object : qAsConst(objects))
{ {
QGraphicsItem *object = objects.at(i);
if (object) if (object)
{ {
QRectF childrenRect = object->childrenBoundingRect(); QRectF childrenRect = object->childrenBoundingRect();
@ -300,9 +299,8 @@ QVector<QGraphicsItem *> VisToolMove::CreateOriginObjects(int &iPoint, int &iCur
{ {
QVector<QGraphicsItem *> originObjects; QVector<QGraphicsItem *> originObjects;
for (int i = 0; i < objects.size(); ++i) for (auto id : qAsConst(objects))
{ {
const quint32 id = objects.at(i);
const QSharedPointer<VGObject> obj = Visualization::data->GetGObject(id); const QSharedPointer<VGObject> obj = Visualization::data->GetGObject(id);
// This check helps to find missed objects in the switch // This check helps to find missed objects in the switch
@ -358,9 +356,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
void VisToolMove::CreateMovedRotatedObjects(int &iPoint, int &iCurve, qreal length, qreal angle, qreal rotationAngle, void VisToolMove::CreateMovedRotatedObjects(int &iPoint, int &iCurve, qreal length, qreal angle, qreal rotationAngle,
const QPointF &rotationOrigin) const QPointF &rotationOrigin)
{ {
for (int i = 0; i < objects.size(); ++i) for (auto id : qAsConst(objects))
{ {
const quint32 id = objects.at(i);
const QSharedPointer<VGObject> obj = Visualization::data->GetGObject(id); const QSharedPointer<VGObject> obj = Visualization::data->GetGObject(id);
// This check helps to find missed objects in the switch // This check helps to find missed objects in the switch

View File

@ -125,9 +125,8 @@ void VisToolRotation::RefreshGeometry()
int iPoint = -1; int iPoint = -1;
int iCurve = -1; int iCurve = -1;
for (int i = 0; i < objects.size(); ++i) for (auto id : qAsConst(objects))
{ {
const quint32 id = objects.at(i);
const QSharedPointer<VGObject> obj = Visualization::data->GetGObject(id); const QSharedPointer<VGObject> obj = Visualization::data->GetGObject(id);
// This check helps to find missed objects in the switch // This check helps to find missed objects in the switch

View File

@ -87,9 +87,9 @@ VSimplePoint *VisPieceSpecialPoints::GetPoint(quint32 i, const QColor &color)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisPieceSpecialPoints::HideAllItems() void VisPieceSpecialPoints::HideAllItems()
{ {
for (int i=0; i < m_points.size(); ++i) for (auto item : qAsConst(m_points))
{ {
if (QGraphicsEllipseItem *item = m_points.at(i)) if (item)
{ {
item->setVisible(false); item->setVisible(false);
} }

View File

@ -35,13 +35,15 @@
VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent) VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
: VisPath(data, parent), : VisPath(data, parent),
m_points(), m_points(),
m_curves(),
m_line1(nullptr), m_line1(nullptr),
m_line2(nullptr), m_line2(nullptr),
m_piece(), m_piece(),
m_pieceCached(false), m_pieceCached(false),
m_cachedMainPath(), m_cachedMainPath(),
m_cachedNodes(), m_cachedNodes(),
m_cachedMainPathPoints() m_cachedMainPathPoints(),
m_cachedCurvesPath()
{ {
m_line1 = InitItem<VScaledLine>(supportColor, this); m_line1 = InitItem<VScaledLine>(supportColor, this);
m_line2 = InitItem<VScaledLine>(supportColor, this); m_line2 = InitItem<VScaledLine>(supportColor, this);
@ -56,11 +58,16 @@ void VisToolPiece::RefreshGeometry()
{ {
if (not m_pieceCached) if (not m_pieceCached)
{ {
m_cachedMainPath = m_piece.MainPathPath(Visualization::data);
m_cachedNodes = m_piece.MainPathNodePoints(Visualization::data); m_cachedNodes = m_piece.MainPathNodePoints(Visualization::data);
if (mode == Mode::Creation) if (mode == Mode::Creation)
{ {
m_cachedCurvesPath = m_piece.CurvesPainterPath(Visualization::data);
m_cachedMainPathPoints = m_piece.MainPathPoints(Visualization::data); m_cachedMainPathPoints = m_piece.MainPathPoints(Visualization::data);
m_cachedMainPath = VPiece::MainPathPath(m_cachedMainPathPoints);
}
else
{
m_cachedMainPath = m_piece.MainPathPath(Visualization::data);
} }
m_pieceCached = true; m_pieceCached = true;
} }
@ -75,6 +82,12 @@ void VisToolPiece::RefreshGeometry()
if (mode == Mode::Creation) if (mode == Mode::Creation)
{ {
for (int i = 0; i < m_cachedCurvesPath.size(); ++i)
{
VCurvePathItem *path = GetCurve(static_cast<quint32>(i), supportColor);
DrawPath(path, m_cachedCurvesPath.at(i), supportColor);
}
DrawLine(m_line1, QLineF(m_cachedMainPathPoints.first(), Visualization::scenePos), supportColor, DrawLine(m_line1, QLineF(m_cachedMainPathPoints.first(), Visualization::scenePos), supportColor,
Qt::DashLine); Qt::DashLine);
@ -100,6 +113,12 @@ VScaledEllipse *VisToolPiece::GetPoint(quint32 i, const QColor &color)
return GetPointItem(m_points, i, color, this); return GetPointItem(m_points, i, color, this);
} }
//---------------------------------------------------------------------------------------------------------------------
VCurvePathItem *VisToolPiece::GetCurve(quint32 i, const QColor &color)
{
return GetCurveItem(m_curves, i, color, this);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolPiece::HideAllItems() void VisToolPiece::HideAllItems()
{ {
@ -113,9 +132,17 @@ void VisToolPiece::HideAllItems()
m_line2->setVisible(false); m_line2->setVisible(false);
} }
for (int i=0; i < m_points.size(); ++i) for(QGraphicsEllipseItem *item : qAsConst(m_points))
{ {
if (QGraphicsEllipseItem *item = m_points.at(i)) if (item)
{
item->setVisible(false);
}
}
for(QGraphicsPathItem *item : qAsConst(m_curves))
{
if (item)
{ {
item->setVisible(false); item->setVisible(false);
} }

View File

@ -50,6 +50,7 @@ public:
private: private:
Q_DISABLE_COPY(VisToolPiece) Q_DISABLE_COPY(VisToolPiece)
QVector<VScaledEllipse *> m_points; QVector<VScaledEllipse *> m_points;
QVector<VCurvePathItem *> m_curves;
VScaledLine *m_line1; VScaledLine *m_line1;
VScaledLine *m_line2; VScaledLine *m_line2;
@ -58,8 +59,10 @@ private:
QPainterPath m_cachedMainPath; QPainterPath m_cachedMainPath;
QVector<VPointF> m_cachedNodes; QVector<VPointF> m_cachedNodes;
QVector<QPointF> m_cachedMainPathPoints; QVector<QPointF> m_cachedMainPathPoints;
QVector<QPainterPath> m_cachedCurvesPath;
VScaledEllipse* GetPoint(quint32 i, const QColor &color); VScaledEllipse* GetPoint(quint32 i, const QColor &color);
VCurvePathItem *GetCurve(quint32 i, const QColor &color);
void HideAllItems(); void HideAllItems();
}; };

View File

@ -99,9 +99,9 @@ void VisToolPiecePath::HideAllItems()
m_line->setVisible(false); m_line->setVisible(false);
} }
for (int i=0; i < m_points.size(); ++i) for (auto item : qAsConst(m_points))
{ {
if (QGraphicsEllipseItem *item = m_points.at(i)) if (item)
{ {
item->setVisible(false); item->setVisible(false);
} }

View File

@ -59,6 +59,44 @@ template <class K, class V> class QHash;
Q_LOGGING_CATEGORY(vVis, "v.visualization") Q_LOGGING_CATEGORY(vVis, "v.visualization")
namespace
{
//---------------------------------------------------------------------------------------------------------------------
VScaledEllipse *InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z = 0)
{
VScaledEllipse *point = new VScaledEllipse(parent);
point->setZValue(1);
point->setBrush(QBrush(Qt::NoBrush));
QPen visPen = point->pen();
visPen.setColor(color);
point->setPen(visPen);
point->setRect(PointRect(ScaledRadius(SceneScale(qApp->getCurrentScene()))));
point->setPos(QPointF());
point->setFlags(QGraphicsItem::ItemStacksBehindParent);
point->setZValue(z);
point->setVisible(false);
return point;
}
//---------------------------------------------------------------------------------------------------------------------
VCurvePathItem *InitCurveItem(const QColor &color, QGraphicsItem *parent, qreal z = 0)
{
VCurvePathItem *curve = new VCurvePathItem(parent);
curve->setBrush(QBrush(Qt::NoBrush));
QPen visPen = curve->pen();
visPen.setColor(color);
curve->setPen(visPen);
curve->setFlags(QGraphicsItem::ItemStacksBehindParent);
curve->setZValue(z);
curve->setVisible(false);
return curve;
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Visualization::Visualization(const VContainer *data) Visualization::Visualization(const VContainer *data)
:QObject(), :QObject(),
@ -261,22 +299,19 @@ VScaledEllipse *Visualization::GetPointItem(QVector<VScaledEllipse *> &points, q
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VScaledEllipse *Visualization::InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z) VCurvePathItem *Visualization::GetCurveItem(QVector<VCurvePathItem *> &curves, quint32 i, const QColor &color,
QGraphicsItem *parent)
{ {
VScaledEllipse *point = new VScaledEllipse(parent); if (not curves.isEmpty() && static_cast<quint32>(curves.size() - 1) >= i)
point->setZValue(1); {
point->setBrush(QBrush(Qt::NoBrush)); return curves.at(static_cast<int>(i));
}
QPen visPen = point->pen(); else
visPen.setColor(color); {
auto point = InitCurveItem(color, parent);
point->setPen(visPen); curves.append(point);
point->setRect(PointRect(ScaledRadius(SceneScale(qApp->getCurrentScene())))); return point;
point->setPos(QPointF()); }
point->setFlags(QGraphicsItem::ItemStacksBehindParent);
point->setZValue(z);
point->setVisible(false);
return point;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -114,10 +114,10 @@ protected:
static VScaledEllipse *GetPointItem(QVector<VScaledEllipse *> &points, quint32 i, const QColor &color, static VScaledEllipse *GetPointItem(QVector<VScaledEllipse *> &points, quint32 i, const QColor &color,
QGraphicsItem *parent); QGraphicsItem *parent);
static VCurvePathItem *GetCurveItem(QVector<VCurvePathItem *> &curves, quint32 i, const QColor &color,
QGraphicsItem *parent);
private: private:
Q_DISABLE_COPY(Visualization) Q_DISABLE_COPY(Visualization)
static VScaledEllipse* InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z = 0);
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -88,7 +88,7 @@ QSize FancyTabBar::TabSizeHint(bool minimum) const
if (words.size() > 1) if (words.size() > 1)
{ {
QString sentence; QString sentence;
foreach(const QString & word, words) for (auto &word : words)
{ {
sentence = sentence.isEmpty() ? sentence = word : sentence + QLatin1Char(' ') + word; sentence = sentence.isEmpty() ? sentence = word : sentence + QLatin1Char(' ') + word;

View File

@ -114,7 +114,8 @@ void StyleHelper::setBaseColor(const QColor &newcolor)
if (color.isValid() && color != m_baseColor) if (color.isValid() && color != m_baseColor)
{ {
m_baseColor = color; m_baseColor = color;
foreach (QWidget *w, QApplication::topLevelWidgets()) const QWidgetList widgets = QApplication::topLevelWidgets();
for (auto w : widgets)
{ {
w->update(); w->update();
} }

View File

@ -106,8 +106,11 @@ QString VAbstractMainWindow::CSVFilePath()
const QString suffix("csv"); const QString suffix("csv");
const QString path = QDir::homePath() + QLatin1String("/") + tr("values") + QLatin1String(".") + suffix; const QString path = QDir::homePath() + QLatin1String("/") + tr("values") + QLatin1String(".") + suffix;
QString fileName = QFileDialog::getSaveFileName(this, tr("Export to CSV"), path, filters, nullptr, QString fileName = QFileDialog::getSaveFileName(this, tr("Export to CSV"), path, filters, nullptr
QFileDialog::DontUseNativeDialog); #ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {

View File

@ -209,7 +209,7 @@ void VMainGraphicsScene::InitOrigins()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::SetOriginsVisible(bool visible) void VMainGraphicsScene::SetOriginsVisible(bool visible)
{ {
foreach (QGraphicsItem *item, origins) for (auto item : qAsConst(origins))
{ {
item->setVisible(visible); item->setVisible(visible);
} }
@ -225,7 +225,8 @@ QPointF VMainGraphicsScene::getScenePos() const
QRectF VMainGraphicsScene::VisibleItemsBoundingRect() const QRectF VMainGraphicsScene::VisibleItemsBoundingRect() const
{ {
QRectF rect; QRectF rect;
foreach(QGraphicsItem *item, items()) const QList<QGraphicsItem *> qItems = items();
for (auto item : qItems)
{ {
if(not item->isVisible()) if(not item->isVisible())
{ {

View File

@ -486,14 +486,13 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *event)
emit itemClicked(nullptr); emit itemClicked(nullptr);
break; break;
} }
for (int i = 0; i < list.size(); ++i) for (auto item : list)
{ {
if (this->scene()->items().contains(list.at(i))) if (this->scene()->items().contains(item))
{ {
if (list.at(i)->type() > QGraphicsItem::UserType && if (item->type() > QGraphicsItem::UserType && item->type() <= VSimpleCurve::Type)
list.at(i)->type() <= VSimpleCurve::Type)
{ {
emit itemClicked(list.at(i)); emit itemClicked(item);
break; break;
} }
else else
@ -692,7 +691,8 @@ void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QG
else else
{ {
QRectF rect = item->sceneBoundingRect(); QRectF rect = item->sceneBoundingRect();
foreach(QGraphicsItem *child, item->childItems()) const QList<QGraphicsItem *> children = item->childItems();
for (auto child : children)
{ {
if(child->isVisible()) if(child->isVisible())
{ {

View File

@ -51,16 +51,16 @@ int main(int argc, char** argv)
ASSERT_TEST(new TST_TSTranslation()); ASSERT_TEST(new TST_TSTranslation());
const QStringList locales = SupportedLocales(); const QStringList locales = SupportedLocales();
for(int l = 0, sz = locales.size(); l < sz; ++l) for(auto &locale : locales)
{ {
for(quint32 s = 0; s < TST_MeasurementRegExp::systemCounts; ++s) for(quint32 s = 0; s < TST_MeasurementRegExp::systemCounts; ++s)
{ {
ASSERT_TEST(new TST_MeasurementRegExp(s, locales.at(l))); ASSERT_TEST(new TST_MeasurementRegExp(s, locale));
} }
ASSERT_TEST(new TST_TSLocaleTranslation(locales.at(l))); ASSERT_TEST(new TST_TSLocaleTranslation(locale));
ASSERT_TEST(new TST_BuitInRegExp(locales.at(l))); ASSERT_TEST(new TST_BuitInRegExp(locale));
ASSERT_TEST(new TST_QmuParserErrorMsg(locales.at(l))); ASSERT_TEST(new TST_QmuParserErrorMsg(locale));
} }
return status; return status;

View File

@ -183,11 +183,11 @@ void TST_BuitInRegExp::TestCheckInternalVaribleRegExp_data()
QTest::addColumn<QString>("var"); QTest::addColumn<QString>("var");
QTest::addColumn<QString>("originalName"); QTest::addColumn<QString>("originalName");
foreach(const QString &var, builInVariables) for (auto &var : qAsConst(builInVariables))
{ {
const QString tag = QString("Locale: '%1'. Var '%2'").arg(m_locale, var); const QString tag = QString("Locale: '%1'. Var '%2'").arg(m_locale, var);
const QStringList originalNames = AllNames(); const QStringList originalNames = AllNames();
foreach(const QString &str, originalNames) for (auto &str : originalNames)
{ {
QTest::newRow(qUtf8Printable(tag)) << var << str; QTest::newRow(qUtf8Printable(tag)) << var << str;
} }
@ -231,10 +231,10 @@ void TST_BuitInRegExp::TestTemplatePlaceholders()
QSet<QString> originals; QSet<QString> originals;
QSet<QString> translations; QSet<QString> translations;
for (int i = 0; i < labelTemplatePlaceholders.size(); ++i) for (auto &placeholder : labelTemplatePlaceholders)
{ {
originals.insert(labelTemplatePlaceholders.at(i)); originals.insert(placeholder);
translations.insert(m_trMs->PlaceholderToUser(labelTemplatePlaceholders.at(i))); translations.insert(m_trMs->PlaceholderToUser(placeholder));
} }
QCOMPARE(originals.size(), labelTemplatePlaceholders.size()); // All tags are unique QCOMPARE(originals.size(), labelTemplatePlaceholders.size()); // All tags are unique
@ -254,7 +254,7 @@ void TST_BuitInRegExp::PrepareData()
QTest::addColumn<QString>("originalName"); QTest::addColumn<QString>("originalName");
foreach(const QString &str, originalNames) for (auto &str : originalNames)
{ {
const QString tag = QString("Locale: '%1'. Name '%2'").arg(m_locale, str); const QString tag = QString("Locale: '%1'. Name '%2'").arg(m_locale, str);
QTest::newRow(qUtf8Printable(tag)) << str; QTest::newRow(qUtf8Printable(tag)) << str;

Some files were not shown because too many files have changed in this diff Show More