From 171b3be090c4784047886c79c8c0e24e5b534015 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 9 Feb 2023 17:23:11 +0200 Subject: [PATCH] Backward compatibility for type qsizetype. --- .../dialogs/dialogpuzzlepreferences.cpp | 2 +- .../puzzle/dialogs/dialogsavemanuallayout.cpp | 3 +- .../puzzle/dialogs/dialogsavemanuallayout.h | 4 +- .../undocommands/vpundopiecezvaluemove.cpp | 6 +- src/app/puzzle/vpapplication.cpp | 2 +- src/app/puzzle/vpcommandline.cpp | 2 +- src/app/puzzle/vpmainwindow.cpp | 20 +++--- src/app/puzzle/vpmainwindow.h | 2 +- .../dialogs/dialogdimensioncustomnames.cpp | 2 +- .../tape/dialogs/dialogdimensionlabels.cpp | 2 +- .../dialogs/dialogmeasurementscsvcolumns.cpp | 4 +- .../tape/dialogs/dialogrestrictdimension.cpp | 4 +- .../tape/dialogs/dialogtapepreferences.cpp | 2 +- src/app/tape/mapplication.cpp | 2 +- src/app/tape/tmainwindow.cpp | 38 +++++----- src/app/tape/tmainwindow.h | 2 +- .../core/vtooloptionspropertybrowser.cpp | 60 ++++++++-------- .../dialogs/dialogfinalmeasurements.cpp | 2 +- src/app/valentina/dialogs/dialoghistory.cpp | 2 +- .../valentina/dialogs/dialogincrements.cpp | 6 +- .../valentina/dialogs/dialogpreferences.cpp | 2 +- .../dialogs/vwidgetbackgroundimages.cpp | 2 +- src/app/valentina/dialogs/vwidgetdetails.cpp | 2 +- src/app/valentina/dialogs/vwidgetgroups.cpp | 2 +- src/app/valentina/mainwindow.cpp | 7 +- src/app/valentina/mainwindowsnogui.cpp | 4 +- src/app/valentina/xml/vpattern.cpp | 8 +-- src/libs/ifc/xml/vabstractconverter.cpp | 13 ++-- src/libs/ifc/xml/vabstractconverter.h | 7 +- src/libs/ifc/xml/vabstractpattern.cpp | 2 +- src/libs/ifc/xml/vpatternconverter.cpp | 16 ++--- src/libs/qmuparser/qmudef.cpp | 7 +- src/libs/qmuparser/qmudef.h | 6 +- src/libs/qmuparser/qmuformulabase.cpp | 4 +- src/libs/qmuparser/qmuformulabase.h | 2 +- src/libs/qmuparser/qmuparser.cpp | 15 ++-- src/libs/qmuparser/qmuparser.h | 14 ++-- src/libs/qmuparser/qmuparserbase.cpp | 20 +++--- src/libs/qmuparser/qmuparserbase.h | 16 ++--- src/libs/qmuparser/qmuparserbytecode.cpp | 16 ++--- src/libs/qmuparser/qmuparserbytecode.h | 20 +++--- src/libs/qmuparser/qmuparserdef.h | 15 ++-- src/libs/qmuparser/qmuparsererror.cpp | 2 +- src/libs/qmuparser/qmuparsererror.h | 8 +-- src/libs/qmuparser/qmuparsertest.cpp | 4 +- src/libs/qmuparser/qmuparsertest.h | 10 +-- src/libs/qmuparser/qmuparsertoken.h | 8 +-- src/libs/qmuparser/qmuparsertokenreader.cpp | 35 ++++----- src/libs/qmuparser/qmuparsertokenreader.h | 12 ++-- src/libs/vdxf/vdxfengine.cpp | 7 +- src/libs/vformat/vmeasurements.cpp | 2 +- src/libs/vgeometry/vabstractcubicbezierpath.h | 6 +- src/libs/vgeometry/vcubicbezierpath.cpp | 30 ++++---- src/libs/vgeometry/vcubicbezierpath.h | 16 ++--- src/libs/vgeometry/vsplinepath.cpp | 12 ++-- src/libs/vgeometry/vsplinepath.h | 10 +-- src/libs/vlayout/vabstractpiece.cpp | 10 +-- src/libs/vlayout/vabstractpiece.h | 4 +- src/libs/vlayout/vbank.cpp | 10 +-- src/libs/vlayout/vbank.h | 6 +- src/libs/vlayout/vcontour.cpp | 14 ++-- src/libs/vlayout/vcontour.h | 3 +- src/libs/vlayout/vcontour_p.h | 2 +- src/libs/vlayout/vlayoutgenerator.cpp | 8 ++- src/libs/vlayout/vlayoutgenerator.h | 4 +- src/libs/vlayout/vlayoutpaper.cpp | 2 +- src/libs/vlayout/vlayoutpaper.h | 4 +- src/libs/vlayout/vlayoutpiece.cpp | 10 +-- src/libs/vlayout/vlayoutpiece.h | 4 +- src/libs/vlayout/vposition.cpp | 2 +- src/libs/vlayout/vposter.cpp | 4 +- src/libs/vlayout/vposter.h | 4 +- src/libs/vlayout/vprintlayout.cpp | 16 ++--- src/libs/vlayout/vprintlayout.h | 4 +- src/libs/vlayout/vrawlayout.cpp | 4 +- src/libs/vlayout/vtextmanager.cpp | 8 +-- src/libs/vlayout/vtextmanager.h | 4 +- src/libs/vmisc/compatibility.h | 4 +- src/libs/vmisc/defglobal.h | 6 ++ src/libs/vmisc/qxtcsvmodel.cpp | 8 +-- src/libs/vmisc/vtablesearch.cpp | 12 ++-- src/libs/vmisc/vtablesearch.h | 10 +-- src/libs/vobj/vobjengine.cpp | 2 +- src/libs/vpatterndb/vpassmark.h | 2 +- src/libs/vpatterndb/vpiece.cpp | 30 ++++---- src/libs/vpatterndb/vpiece.h | 21 +++--- src/libs/vpatterndb/vpiecepath.cpp | 32 ++++----- src/libs/vpatterndb/vpiecepath.h | 20 +++--- .../vpatterndb/vtranslatemeasurements.cpp | 4 +- src/libs/vpatterndb/vtranslatemeasurements.h | 2 +- src/libs/vpatterndb/vtranslatevars.cpp | 71 ++++++++++--------- src/libs/vpatterndb/vtranslatevars.h | 27 ++++--- .../plugins/vlinecolorproperty.cpp | 2 +- .../plugins/vlinecolorproperty.h | 2 +- .../plugins/vlinetypeproperty.cpp | 2 +- .../plugins/vlinetypeproperty.h | 2 +- src/libs/vpropertyexplorer/vproperty.cpp | 6 +- src/libs/vpropertyexplorer/vproperty.h | 6 +- src/libs/vpropertyexplorer/vpropertydef.h | 38 ++++++++++ .../vpropertyexplorer/vpropertyexplorer.qbs | 1 + src/libs/vpropertyexplorer/vpropertymodel.cpp | 24 ++++--- src/libs/vpropertyexplorer/vpropertyset.cpp | 4 +- src/libs/vpropertyexplorer/vpropertyset.h | 4 +- .../dialogs/tools/dialogcubicbezierpath.cpp | 6 +- .../dialogs/tools/dialoguniondetails.cpp | 2 +- .../vtools/dialogs/tools/dialoguniondetails.h | 14 ++-- src/libs/vtools/tools/vtooluniondetails.cpp | 12 ++-- .../path/vistoolcubicbezierpath.cpp | 32 ++++----- .../path/vistoolcubicbezierpath.h | 2 +- .../visualization/path/vistoolsplinepath.cpp | 19 ++--- .../visualization/path/vistoolsplinepath.h | 6 +- src/libs/vwidgets/fancytabbar/fancytabbar.cpp | 14 ++-- src/libs/vwidgets/fancytabbar/fancytabbar.h | 2 +- src/libs/vwidgets/qtcolorpicker.cpp | 4 +- src/libs/vwidgets/vabstractmainwindow.cpp | 2 +- src/libs/vwidgets/vcontrolpointspline.cpp | 7 +- src/libs/vwidgets/vcontrolpointspline.h | 10 +-- src/libs/vwidgets/vhighlighter.cpp | 4 +- src/libs/vwidgets/vhighlighter.h | 4 +- src/libs/vwidgets/vlineedit.cpp | 6 +- src/libs/vwidgets/vplaintextedit.cpp | 15 ++-- src/libs/vwidgets/vtextgraphicsitem.cpp | 2 +- src/libs/vwidgets/vtextgraphicsitem.h | 2 +- .../TranslationsTest/tst_abstractregexp.cpp | 2 +- .../tst_measurementregexp.cpp | 2 +- .../tst_tslocaletranslation.cpp | 4 +- src/test/ValentinaTest/tst_qmutokenparser.cpp | 4 +- src/test/ValentinaTest/tst_readval.cpp | 4 +- src/test/ValentinaTest/tst_readval.h | 2 +- .../ValentinaTest/tst_vcubicbezierpath.cpp | 6 +- 130 files changed, 641 insertions(+), 546 deletions(-) create mode 100644 src/libs/vpropertyexplorer/vpropertydef.h diff --git a/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp b/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp index deb8c4a5f..09928fcec 100644 --- a/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp +++ b/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp @@ -136,7 +136,7 @@ void DialogPuzzlePreferences::Apply() if (not preferences.isEmpty()) { const QString text = tr("Followed %n option(s) require restart to take effect: %1.", "", - preferences.size()).arg(preferences.join(QStringLiteral(", "))); + static_cast(preferences.size())).arg(preferences.join(QStringLiteral(", "))); QMessageBox::information(this, QCoreApplication::applicationName(), text); } diff --git a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp index 31a2fc722..0ec51c6f6 100644 --- a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp +++ b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp @@ -45,7 +45,8 @@ #endif //--------------------------------------------------------------------------------------------------------------------- -DialogSaveManualLayout::DialogSaveManualLayout(int count, bool consoleExport, const QString &fileName, QWidget *parent) +DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExport, const QString &fileName, + QWidget *parent) : VAbstractLayoutDialog(parent), ui(new Ui::DialogSaveManualLayout), m_count(count), diff --git a/src/app/puzzle/dialogs/dialogsavemanuallayout.h b/src/app/puzzle/dialogs/dialogsavemanuallayout.h index 62dcbc99c..116100a4f 100644 --- a/src/app/puzzle/dialogs/dialogsavemanuallayout.h +++ b/src/app/puzzle/dialogs/dialogsavemanuallayout.h @@ -41,7 +41,7 @@ class DialogSaveManualLayout : public VAbstractLayoutDialog Q_OBJECT // NOLINT public: - explicit DialogSaveManualLayout(int count, bool consoleExport, const QString &fileName = QString(), + explicit DialogSaveManualLayout(vsizetype count, bool consoleExport, const QString &fileName = QString(), QWidget *parent = nullptr); ~DialogSaveManualLayout() override; @@ -77,7 +77,7 @@ private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DialogSaveManualLayout) // NOLINT Ui::DialogSaveManualLayout *ui; - int m_count; + vsizetype m_count; bool m_isInitialized{false}; bool m_scaleConnected{true}; bool m_consoleExport; diff --git a/src/app/puzzle/undocommands/vpundopiecezvaluemove.cpp b/src/app/puzzle/undocommands/vpundopiecezvaluemove.cpp index bd9cea733..ccb91cf07 100644 --- a/src/app/puzzle/undocommands/vpundopiecezvaluemove.cpp +++ b/src/app/puzzle/undocommands/vpundopiecezvaluemove.cpp @@ -41,7 +41,7 @@ auto CorrectedZValues(const QList> &order) -> QHash(order.size()); } for (int i = 0; i < order.size(); ++i) @@ -266,7 +266,7 @@ auto VPUndoPieceZValueMove::LevelStep(const QList &pieces) const -> return 0; } - return 1.0/levels.size(); + return 1.0 / static_cast(levels.size()); } //--------------------------------------------------------------------------------------------------------------------- @@ -509,5 +509,5 @@ auto VPUndoPiecesZValueMove::LevelStep(const QList &pieces) -> qreal return 0; } - return 1.0/levels.size(); + return 1.0 / static_cast(levels.size()); } diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index e6fdb75ae..e3679737b 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -620,7 +620,7 @@ void VPApplication::SetPreferencesDialog(const QSharedPointer= 0; --i) + for (vsizetype i = m_mainWindows.count() - 1; i >= 0; --i) { if (m_mainWindows.at(i).isNull()) { diff --git a/src/app/puzzle/vpcommandline.cpp b/src/app/puzzle/vpcommandline.cpp index 040d46463..9cbabe54f 100644 --- a/src/app/puzzle/vpcommandline.cpp +++ b/src/app/puzzle/vpcommandline.cpp @@ -39,7 +39,7 @@ std::shared_ptr VPCommandLine::instance = nullptr; // NOLINT(cppc auto VPCommandLine::IsExportEnabled() const -> bool { const bool result = IsOptionSet(LONG_OPTION_EXPORT_FILE); - int argSize = parser.positionalArguments().size(); + auto argSize = parser.positionalArguments().size(); if (result && argSize != 1) { qCritical() << translate("Puzzle", "Export options can be used with single input file only.") << "/n"; diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 44e6d5dbd..374b419bc 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -1592,7 +1592,7 @@ void VPMainWindow::UpdateWindowTitle() } else { - int index = VPApplication::VApp()->MainWindows().indexOf(this); + vsizetype index = VPApplication::VApp()->MainWindows().indexOf(this); if (index != -1) { showName = tr("untitled %1.vlt").arg(index+1); @@ -1745,7 +1745,7 @@ void VPMainWindow::CreateWindowMenu(QMenu *menu) VPMainWindow *window = windows.at(i); QString title = QStringLiteral("%1. %2").arg(i+1).arg(window->windowTitle()); - const int index = title.lastIndexOf(QLatin1String("[*]")); + const vsizetype index = title.lastIndexOf(QLatin1String("[*]")); if (index != -1) { window->isWindowModified() ? title.replace(index, 3, QChar('*')) : title.replace(index, 3, QString()); @@ -2915,13 +2915,13 @@ void VPMainWindow::PrintLayoutSheets(QPrinter *printer, const QList firstPageNumber = 0; } - int lastPageNumber = printer->toPage() - 1; + vsizetype lastPageNumber = printer->toPage() - 1; if (lastPageNumber == -1 || lastPageNumber >= sheets.count()) { lastPageNumber = sheets.count() - 1; } - const int numPages = lastPageNumber - firstPageNumber + 1; + const vsizetype numPages = lastPageNumber - firstPageNumber + 1; int copyCount = 1; if (not printer->supportsMultipleCopies()) { @@ -2946,7 +2946,8 @@ void VPMainWindow::PrintLayoutSheets(QPrinter *printer, const QList { for (int j = 0; j < numPages; ++j) { - int index = printer->pageOrder() == QPrinter::FirstPageFirst ? firstPageNumber + j : lastPageNumber - j; + vsizetype index = printer->pageOrder() == QPrinter::FirstPageFirst ? firstPageNumber + j + : lastPageNumber - j; const VPSheetPtr& sheet = sheets.at(index); if (sheet.isNull()) @@ -3013,13 +3014,13 @@ void VPMainWindow::PrintLayoutTiledSheets(QPrinter *printer, const QListtoPage() - 1; + vsizetype lastPageNumber = printer->toPage() - 1; if (lastPageNumber == -1 || lastPageNumber >= pages.count()) { lastPageNumber = pages.count() - 1; } - const int numPages = lastPageNumber - firstPageNumber + 1; + const vsizetype numPages = lastPageNumber - firstPageNumber + 1; int copyCount = 1; if (not printer->supportsMultipleCopies()) { @@ -3036,7 +3037,8 @@ void VPMainWindow::PrintLayoutTiledSheets(QPrinter *printer, const QListpageOrder() == QPrinter::FirstPageFirst ? firstPageNumber + j : lastPageNumber - j; + vsizetype index = printer->pageOrder() == QPrinter::FirstPageFirst ? firstPageNumber + j + : lastPageNumber - j; const VPLayoutPrinterPage &page = pages.at(index); if (not PrintLayoutTiledSheetPage(printer, painter, page, firstPage)) @@ -3287,7 +3289,7 @@ void VPMainWindow::TranslatePieces() } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::TranslatePieceRelatively(const VPPiecePtr &piece, const QRectF &rect, int selectedPiecesCount, +void VPMainWindow::TranslatePieceRelatively(const VPPiecePtr &piece, const QRectF &rect, vsizetype selectedPiecesCount, qreal dx, qreal dy) { if (not piece.isNull()) diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index 993cdc462..b41ad5d79 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -506,7 +506,7 @@ private: auto AddLayoutPieces(const QVector &pieces) -> bool; void TranslatePieces(); - void TranslatePieceRelatively(const VPPiecePtr &piece, const QRectF &rect, int selectedPiecesCount, qreal dx, + void TranslatePieceRelatively(const VPPiecePtr &piece, const QRectF &rect, vsizetype selectedPiecesCount, qreal dx, qreal dy); void RotatePieces(); }; diff --git a/src/app/tape/dialogs/dialogdimensioncustomnames.cpp b/src/app/tape/dialogs/dialogdimensioncustomnames.cpp index bf873c616..72804aead 100644 --- a/src/app/tape/dialogs/dialogdimensioncustomnames.cpp +++ b/src/app/tape/dialogs/dialogdimensioncustomnames.cpp @@ -69,7 +69,7 @@ void DialogDimensionCustomNames::InitTable(const QMaptableWidget->blockSignals(true); ui->tableWidget->clearContents(); - ui->tableWidget->setRowCount(dimensions.size()); + ui->tableWidget->setRowCount(static_cast(dimensions.size())); int row = 0; QMap::const_iterator i = dimensions.constBegin(); diff --git a/src/app/tape/dialogs/dialogdimensionlabels.cpp b/src/app/tape/dialogs/dialogdimensionlabels.cpp index 675930a68..837607d67 100644 --- a/src/app/tape/dialogs/dialogdimensionlabels.cpp +++ b/src/app/tape/dialogs/dialogdimensionlabels.cpp @@ -162,7 +162,7 @@ void DialogDimensionLabels::InitTable() const QVector bases = dimension->ValidBases(); - ui->tableWidget->setRowCount(bases.size()); + ui->tableWidget->setRowCount(static_cast(bases.size())); const DimesionLabels labels = m_labels.value(type); diff --git a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp index f4199f094..3dff6a0de 100644 --- a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp +++ b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp @@ -217,7 +217,7 @@ auto DialogMeasurementsCSVColumns::ColumnMandatory(int column) const -> bool if (m_dimensions.size() > 1) { - mandatory += qMin(m_dimensions.size(), 2); + mandatory += qMin(static_cast(m_dimensions.size()), 2); } return static_cast(column) < mandatory; @@ -315,7 +315,7 @@ auto DialogMeasurementsCSVColumns::MinimumColumns() const -> int if (m_dimensions.size() > 1) { - mandatory += qMin(m_dimensions.size(), 2); + mandatory += qMin(static_cast(m_dimensions.size()), 2); } return mandatory; diff --git a/src/app/tape/dialogs/dialogrestrictdimension.cpp b/src/app/tape/dialogs/dialogrestrictdimension.cpp index 5ea0bec52..bda648491 100644 --- a/src/app/tape/dialogs/dialogrestrictdimension.cpp +++ b/src/app/tape/dialogs/dialogrestrictdimension.cpp @@ -523,7 +523,7 @@ void DialogRestrictDimension::InitTable() { MeasurementDimension_p dimension = m_dimensions.at(index); const QVector bases = dimension->ValidBases(); - ui->tableWidget->setRowCount(bases.size()); + ui->tableWidget->setRowCount(static_cast(bases.size())); ui->tableWidget->setVerticalHeaderLabels(DimensionLabels(bases, dimension)); } }; @@ -534,7 +534,7 @@ void DialogRestrictDimension::InitTable() { MeasurementDimension_p dimension = m_dimensions.at(index); const QVector bases = dimension->ValidBases(); - ui->tableWidget->setColumnCount(bases.size()); + ui->tableWidget->setColumnCount(static_cast(bases.size())); ui->tableWidget->setHorizontalHeaderLabels(DimensionLabels(bases, dimension)); } }; diff --git a/src/app/tape/dialogs/dialogtapepreferences.cpp b/src/app/tape/dialogs/dialogtapepreferences.cpp index f1350f802..e08a7d3de 100644 --- a/src/app/tape/dialogs/dialogtapepreferences.cpp +++ b/src/app/tape/dialogs/dialogtapepreferences.cpp @@ -132,7 +132,7 @@ void DialogTapePreferences::Apply() if (not preferences.isEmpty()) { const QString text = tr("Followed %n option(s) require restart to take effect: %1.", "", - preferences.size()).arg(preferences.join(QStringLiteral(", "))); + static_cast(preferences.size())).arg(preferences.join(QStringLiteral(", "))); QMessageBox::information(this, QCoreApplication::applicationName(), text); } diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index c4769c312..9c8d46821 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -743,7 +743,7 @@ void MApplication::NewLocalSocketConnection() void MApplication::Clean() { // cleanup any deleted main windows first - for (int i = m_mainWindows.count() - 1; i >= 0; --i) + for (vsizetype i = m_mainWindows.count() - 1; i >= 0; --i) { if (m_mainWindows.at(i).isNull()) { diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 16c675bb5..bf2a59014 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -1471,7 +1471,7 @@ void TMainWindow::AddKnown() QScopedPointer dialog (new DialogMDataBase(m_m->ListKnown(), this)); if (dialog->exec() == QDialog::Accepted) { - qint32 currentRow; + vsizetype currentRow; const QStringList list = dialog->GetNewNames(); if (ui->tableWidget->currentRow() == -1) @@ -1514,7 +1514,7 @@ void TMainWindow::AddKnown() RefreshData(); m_search->RefreshList(ui->lineEditFind->text()); - ui->tableWidget->selectRow(currentRow); + ui->tableWidget->selectRow(static_cast(currentRow)); ui->actionExportToCSV->setEnabled(true); @@ -1596,7 +1596,7 @@ void TMainWindow::ImportFromPattern() measurements = FilterMeasurements(measurements, m_m->ListAll()); - qint32 currentRow; + vsizetype currentRow; if (ui->tableWidget->currentRow() == -1) { @@ -1622,7 +1622,7 @@ void TMainWindow::ImportFromPattern() m_search->RefreshList(ui->lineEditFind->text()); - ui->tableWidget->selectRow(currentRow); + ui->tableWidget->selectRow(static_cast(currentRow)); MeasurementsWereSaved(false); } @@ -3020,7 +3020,7 @@ void TMainWindow::ShowHeaderUnits(QTableWidget *table, int column, const QString SCASSERT(table != nullptr) QString header = table->horizontalHeaderItem(column)->text(); - const int index = header.indexOf(QLatin1String("(")); + const auto index = header.indexOf(QLatin1String("(")); if (index != -1) { header.remove(index-1, 100); @@ -3187,7 +3187,7 @@ void TMainWindow::RefreshTable(bool freshCall) const QMap > orderedTable = OrderedMeasurments(); qint32 currentRow = -1; - ui->tableWidget->setRowCount ( orderedTable.size() ); + ui->tableWidget->setRowCount ( static_cast(orderedTable.size()) ); for (auto iMap = orderedTable.constBegin(); iMap != orderedTable.constEnd(); ++iMap) { const QSharedPointer &meash = iMap.value(); @@ -3432,7 +3432,7 @@ void TMainWindow::UpdateWindowTitle() } else { - int index = MApplication::VApp()->MainWindows().indexOf(this); + auto index = MApplication::VApp()->MainWindows().indexOf(this); if (index != -1) { showName = tr("untitled %1").arg(index+1); @@ -3483,7 +3483,7 @@ void TMainWindow::UpdateWindowTitle() auto TMainWindow::ClearCustomName(const QString &name) -> QString { QString clear = name; - const int index = clear.indexOf(CustomMSign); + const auto index = clear.indexOf(CustomMSign); if (index == 0) { clear.remove(0, 1); @@ -3798,7 +3798,7 @@ void TMainWindow::CreateWindowMenu(QMenu *menu) TMainWindow *window = windows.at(i); QString title = QStringLiteral("%1. %2").arg(i+1).arg(window->windowTitle()); - const int index = title.lastIndexOf(QLatin1String("[*]")); + const auto index = title.lastIndexOf(QLatin1String("[*]")); if (index != -1) { window->isWindowModified() ? title.replace(index, 3, QChar('*')) : title.replace(index, 3, QString()); @@ -4093,11 +4093,11 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVec } //--------------------------------------------------------------------------------------------------------------------- -auto TMainWindow::ImportMultisizeMeasurement( - const QxtCsvModel &csv, int i, const QVector &map,int dimensionsCount, - QSet &importedNames) -> TMainWindow::MultisizeMeasurement +auto TMainWindow::ImportMultisizeMeasurement(const QxtCsvModel &csv, int i, const QVector &map, + vsizetype dimensionsCount, + QSet &importedNames) -> TMainWindow::MultisizeMeasurement { - const int nameColumn = map.at(static_cast(MultisizeMeasurementsColumns::Name)); + const auto nameColumn = map.at(static_cast(MultisizeMeasurementsColumns::Name)); const QString name = csv.text(i, nameColumn).simplified(); if (name.isEmpty()) { @@ -4110,18 +4110,18 @@ auto TMainWindow::ImportMultisizeMeasurement( importedNames.insert(mName); measurement.name = mName; - const int baseValueColumn = map.at(static_cast(MultisizeMeasurementsColumns::BaseValue)); + const auto baseValueColumn = map.at(static_cast(MultisizeMeasurementsColumns::BaseValue)); measurement.base = ConverToDouble(csv.text(i, baseValueColumn), tr("Cannot convert base value to double in column 2.")); - const int shiftAColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftA)); + const auto shiftAColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftA)); measurement.shiftA = ConverToDouble(csv.text(i, shiftAColumn), tr("Cannot convert shift value to double in column %1.") .arg(shiftAColumn)); if (dimensionsCount > 1) { - const int shiftBColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftB)); + const auto shiftBColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftB)); measurement.shiftB = ConverToDouble(csv.text(i, shiftBColumn), tr("Cannot convert shift value to double in column %1.") .arg(shiftBColumn)); @@ -4129,7 +4129,7 @@ auto TMainWindow::ImportMultisizeMeasurement( if (dimensionsCount > 2) { - const int shiftCColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftC)); + const auto shiftCColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftC)); measurement.shiftC = ConverToDouble(csv.text(i, shiftCColumn), tr("Cannot convert shift value to double in column %1.") .arg(shiftCColumn)); @@ -4139,7 +4139,7 @@ auto TMainWindow::ImportMultisizeMeasurement( const bool custom = name.startsWith(CustomMSign); if (columns > 4 && custom) { - const int fullNameColumn = map.at(static_cast(MultisizeMeasurementsColumns::FullName)); + const auto fullNameColumn = map.at(static_cast(MultisizeMeasurementsColumns::FullName)); if (fullNameColumn >= 0) { measurement.fullName = csv.text(i, fullNameColumn).simplified(); @@ -4148,7 +4148,7 @@ auto TMainWindow::ImportMultisizeMeasurement( if (columns > 5 && custom) { - const int descriptionColumn = map.at(static_cast(MultisizeMeasurementsColumns::Description)); + const auto descriptionColumn = map.at(static_cast(MultisizeMeasurementsColumns::Description)); if (descriptionColumn >= 0) { measurement.description = csv.text(i, descriptionColumn).simplified(); diff --git a/src/app/tape/tmainwindow.h b/src/app/tape/tmainwindow.h index daf856c48..1fc7887ec 100644 --- a/src/app/tape/tmainwindow.h +++ b/src/app/tape/tmainwindow.h @@ -266,7 +266,7 @@ private: void ImportIndividualMeasurements(const QxtCsvModel &csv, const QVector &map, bool withHeader); void ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVector &map, bool withHeader); auto ImportMultisizeMeasurement(const QxtCsvModel &csv, int i, const QVector &map, - int dimensionsCount, QSet &importedNames) -> MultisizeMeasurement; + vsizetype dimensionsCount, QSet &importedNames) -> MultisizeMeasurement; void SetCurrentPatternUnit(); diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 1c85657b1..6960978e3 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -737,7 +737,7 @@ void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &pr { auto *lineTypeProperty = new VPE::VLineTypeProperty(propertyName); lineTypeProperty->setStyles(styles); - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(styles, i->getLineType()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(styles, i->getLineType()); if (index == -1) { qWarning()<<"Can't find line style" << i->getLineType()<<"in list"; @@ -753,7 +753,7 @@ void VToolOptionsPropertyBrowser::AddPropertyCurvePenStyle(Tool *i, const QStrin { auto *penStyleProperty = new VPE::VLineTypeProperty(propertyName); penStyleProperty->setStyles(styles); - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(styles, i->GetPenStyle()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(styles, i->GetPenStyle()); if (index == -1) { qWarning()<<"Can't find pen style" << i->getLineType()<<"in list"; @@ -769,7 +769,7 @@ void VToolOptionsPropertyBrowser::AddPropertyLineColor(Tool *i, const QString &p { auto *lineColorProperty = new VPE::VLineColorProperty(propertyName); lineColorProperty->setColors(colors); - const qint32 index = VPE::VLineColorProperty::IndexOfColor(colors, i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(colors, i->GetLineColor()); if (index == -1) { qWarning()<<"Can't find line style" << i->GetLineColor()<<"in list"; @@ -3348,12 +3348,12 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolEndLine() m_idToProperty[AttrName]->setValue(i->name()); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); m_idToProperty[AttrTypeLine]->setValue(index); } { - const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); m_idToProperty[AttrLineColor]->setValue(index); } @@ -3379,12 +3379,12 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolAlongLine() m_idToProperty[AttrName]->setValue(i->name()); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); m_idToProperty[AttrTypeLine]->setValue(index); } { - const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); m_idToProperty[AttrLineColor]->setValue(index); } @@ -3423,12 +3423,12 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArc() m_idToProperty[AttrAngle2]->setValue(valueSecondAngle); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); m_idToProperty[AttrPenStyle]->setValue(index); } { - const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); m_idToProperty[AttrColor]->setValue(index); } @@ -3465,12 +3465,12 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArcWithLength() m_idToProperty[AttrLength]->setValue(valueLength); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); m_idToProperty[AttrPenStyle]->setValue(index); } { - const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); m_idToProperty[AttrColor]->setValue(index); } @@ -3499,12 +3499,12 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolBisector() m_idToProperty[AttrLength]->setValue(valueFormula); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); m_idToProperty[AttrTypeLine]->setValue(index); } { - const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); m_idToProperty[AttrLineColor]->setValue(index); } @@ -3625,12 +3625,12 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolHeight() m_idToProperty[AttrName]->setValue(i->name()); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); m_idToProperty[AttrTypeLine]->setValue(index); } { - const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); m_idToProperty[AttrLineColor]->setValue(index); } @@ -3655,12 +3655,12 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolLine() auto *i = qgraphicsitem_cast(m_currentItem); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); m_idToProperty[AttrTypeLine]->setValue(index); } { - const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); m_idToProperty[AttrLineColor]->setValue(index); } @@ -3715,12 +3715,12 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolNormal() m_idToProperty[AttrAngle]->setValue( i->GetAngle()); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); m_idToProperty[AttrTypeLine]->setValue(index); } { - const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); m_idToProperty[AttrLineColor]->setValue(index); } @@ -3899,12 +3899,12 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint() m_idToProperty[AttrName]->setValue(i->name()); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); m_idToProperty[AttrTypeLine]->setValue(index); } { - const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); m_idToProperty[AttrLineColor]->setValue(index); } @@ -3968,7 +3968,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() m_idToProperty[AttrLength2]->setValue(length2); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); m_idToProperty[AttrPenStyle]->setValue(index); } @@ -3992,7 +3992,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCubicBezier() m_idToProperty[AttrName]->setValue(i->name()); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); m_idToProperty[AttrPenStyle]->setValue(index); } @@ -4032,7 +4032,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSplinePath() m_idToProperty[AttrName]->setValue(i->name()); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); m_idToProperty[AttrPenStyle]->setValue(index); } @@ -4056,7 +4056,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCubicBezierPath() m_idToProperty[AttrName]->setValue(i->name()); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); m_idToProperty[AttrPenStyle]->setValue(index); } @@ -4105,12 +4105,12 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolLineIntersectAxis() m_idToProperty[AttrName]->setValue(i->name()); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); m_idToProperty[AttrTypeLine]->setValue(index); } { - const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); m_idToProperty[AttrLineColor]->setValue(index); } @@ -4140,12 +4140,12 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCurveIntersectAxis() m_idToProperty[AttrName]->setValue(i->name()); { - const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); m_idToProperty[AttrTypeLine]->setValue(index); } { - const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); m_idToProperty[AttrLineColor]->setValue(index); } @@ -4264,7 +4264,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolEllipticalArc() valueFormulaRotationAngle.setValue(i->GetFormulaRotationAngle()); m_idToProperty[AttrRotationAngle]->setValue(valueFormulaRotationAngle); - const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); m_idToProperty[AttrColor]->setValue(index); QVariant valueCenterPoint; diff --git a/src/app/valentina/dialogs/dialogfinalmeasurements.cpp b/src/app/valentina/dialogs/dialogfinalmeasurements.cpp index adcc8a596..91c699491 100644 --- a/src/app/valentina/dialogs/dialogfinalmeasurements.cpp +++ b/src/app/valentina/dialogs/dialogfinalmeasurements.cpp @@ -483,7 +483,7 @@ void DialogFinalMeasurements::FillFinalMeasurements(bool freshCall) ui->tableWidget->blockSignals(true); ui->tableWidget->clearContents(); - ui->tableWidget->setRowCount(m_measurements.size()); + ui->tableWidget->setRowCount(static_cast(m_measurements.size())); for (int i=0; i < m_measurements.size(); ++i) { const VFinalMeasurement &m = m_measurements.at(i); diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index 7fcf2e877..8e70caa5f 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -177,7 +177,7 @@ void DialogHistory::FillTable() QVector history = m_doc->getLocalHistory(); qint32 currentRow = -1; qint32 count = 0; - ui->tableWidget->setRowCount(history.size());//Make row count max possible number + ui->tableWidget->setRowCount(static_cast(history.size()));//Make row count max possible number std::function CreateRecord = [this](const VToolRecord &tool) { diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index d23391b85..0a84293eb 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -203,7 +203,7 @@ void DialogIncrements::FillTable(const QMap &varTable, QTableWidget i.next(); qreal length = *i.value()->GetValue(); currentRow++; - table->setRowCount ( varTable.size() ); + table->setRowCount ( static_cast(varTable.size()) ); auto *item = new QTableWidgetItem(i.key()); item->setTextAlignment(Qt::AlignLeft); @@ -349,7 +349,7 @@ auto DialogIncrements::GetCustomName() const -> QString auto DialogIncrements::ClearIncrementName(const QString &name) -> QString { QString clear = name; - const int index = clear.indexOf(CustomIncrSign); + const auto index = clear.indexOf(CustomIncrSign); if (index == 0) { clear.remove(0, 1); @@ -1315,7 +1315,7 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table, qint32 currentRow = -1; QMapIterator iMap(map); - table->setRowCount ( map.size() ); + table->setRowCount ( static_cast(map.size()) ); while (iMap.hasNext()) { iMap.next(); diff --git a/src/app/valentina/dialogs/dialogpreferences.cpp b/src/app/valentina/dialogs/dialogpreferences.cpp index ad5640120..fd79d9661 100644 --- a/src/app/valentina/dialogs/dialogpreferences.cpp +++ b/src/app/valentina/dialogs/dialogpreferences.cpp @@ -148,7 +148,7 @@ void DialogPreferences::Apply() if (not preferences.isEmpty()) { const QString text = tr("Followed %n option(s) require restart to take effect: %1.", "", - preferences.size()).arg(preferences.join(QStringLiteral(", "))); + static_cast(preferences.size())).arg(preferences.join(QStringLiteral(", "))); QMessageBox::information(this, QCoreApplication::applicationName(), text); } diff --git a/src/app/valentina/dialogs/vwidgetbackgroundimages.cpp b/src/app/valentina/dialogs/vwidgetbackgroundimages.cpp index 1432a0ec9..7622c89bf 100644 --- a/src/app/valentina/dialogs/vwidgetbackgroundimages.cpp +++ b/src/app/valentina/dialogs/vwidgetbackgroundimages.cpp @@ -732,7 +732,7 @@ void VWidgetBackgroundImages::FillTable(const QVector & ui->tableWidget->clear(); ui->tableWidget->setColumnCount(3); - ui->tableWidget->setRowCount(images.size()); + ui->tableWidget->setRowCount(static_cast(images.size())); qint32 currentRow = -1; auto ReadOnly = [](QTableWidgetItem *item) diff --git a/src/app/valentina/dialogs/vwidgetdetails.cpp b/src/app/valentina/dialogs/vwidgetdetails.cpp index e472eba11..0946d23e0 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.cpp +++ b/src/app/valentina/dialogs/vwidgetdetails.cpp @@ -173,7 +173,7 @@ void VWidgetDetails::FillTable(const QHash *details) ui->tableWidget->clearContents(); ui->tableWidget->setColumnCount(2); - ui->tableWidget->setRowCount(details->size()); + ui->tableWidget->setRowCount(static_cast(details->size())); qint32 currentRow = -1; auto i = details->constBegin(); while (i != details->constEnd()) diff --git a/src/app/valentina/dialogs/vwidgetgroups.cpp b/src/app/valentina/dialogs/vwidgetgroups.cpp index 6354eb2ce..7fcef6168 100644 --- a/src/app/valentina/dialogs/vwidgetgroups.cpp +++ b/src/app/valentina/dialogs/vwidgetgroups.cpp @@ -338,7 +338,7 @@ void VWidgetGroups::FillTable(QMap groups) ui->tableWidget->clear(); ui->tableWidget->setColumnCount(2); - ui->tableWidget->setRowCount(groups.size()); + ui->tableWidget->setRowCount(static_cast(groups.size())); qint32 currentRow = -1; auto i = groups.constBegin(); while (i != groups.constEnd()) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 68b4c12f3..d22883a61 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -6202,7 +6202,8 @@ void MainWindow::ExportLayoutAs() try { m_dialogSaveLayout = QSharedPointer( - new DialogSaveLayout(m_layoutSettings->LayoutScenes().size(), Draw::Layout, FileName(), this)); + new DialogSaveLayout(static_cast(m_layoutSettings->LayoutScenes().size()), Draw::Layout, FileName(), + this)); if (m_dialogSaveLayout->exec() == QDialog::Rejected) { @@ -6615,8 +6616,8 @@ auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool try { m_dialogSaveLayout = QSharedPointer( - new DialogSaveLayout(m_layoutSettings->LayoutScenes().size(), - Draw::Layout, expParams->OptBaseName(), this)); + new DialogSaveLayout(static_cast(m_layoutSettings->LayoutScenes().size()), + Draw::Layout, expParams->OptBaseName(), this)); m_dialogSaveLayout->SetDestinationPath(expParams->OptDestinationPath()); m_dialogSaveLayout->SelectFormat(static_cast(expParams->OptExportType())); m_dialogSaveLayout->SetBinaryDXFFormat(expParams->IsBinaryDXF()); diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 403566b4c..dab8c1c91 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -249,7 +249,7 @@ bool MainWindowsNoGUI::GenerateLayout(VLayoutGenerator& lGenerator) int rotatate = 1; lGenerator.SetShift(-1); // Trigger first shift calulation lGenerator.SetRotate(false); - int papersCount = INT_MAX; + vsizetype papersCount = INT_MAX; qreal efficiency = 0; bool hasResult = false; @@ -913,7 +913,7 @@ QVector MainWindowsNoGUI::PrepareDetailsForLayout(const QVectorgetData()); }; - QProgressDialog progress(tr("Preparing details for layout"), QString(), 0, details.size()); + QProgressDialog progress(tr("Preparing details for layout"), QString(), 0, static_cast(details.size())); progress.setWindowModality(Qt::ApplicationModal); QFutureWatcher futureWatcher; diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 85ebbac39..b8e7e42bb 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -1537,7 +1537,7 @@ QString VPattern::GetLabelBase(quint32 index) const QString base; const int count = qFloor(index/static_cast(alphabet.size())); - const int number = static_cast(index) - alphabet.size() * count; + const int number = static_cast(index) - static_cast(alphabet.size()) * count; int i = 0; do { @@ -4229,13 +4229,13 @@ void VPattern::SetIncrementSpecialUnits(const QString &name, bool special) //--------------------------------------------------------------------------------------------------------------------- void VPattern::ReplaceNameInFormula(QVector &expressions, const QString &name, const QString &newName) { - const int bias = name.length() - newName.length(); + const auto bias = name.length() - newName.length(); for(int i = 0; i < expressions.size(); ++i) { if (expressions.at(i).expression.indexOf(name) != -1) { - QMap tokens; + QMap tokens; // Eval formula try @@ -4256,7 +4256,7 @@ void VPattern::ReplaceNameInFormula(QVector &expressions, const Q continue; } - QList tKeys = tokens.keys();// Take all tokens positions + QList tKeys = tokens.keys();// Take all tokens positions QString newFormula = expressions.at(i).expression; for (int i = 0; i < tKeys.size(); ++i) diff --git a/src/libs/ifc/xml/vabstractconverter.cpp b/src/libs/ifc/xml/vabstractconverter.cpp index c2e5bf237..9c2e48028 100644 --- a/src/libs/ifc/xml/vabstractconverter.cpp +++ b/src/libs/ifc/xml/vabstractconverter.cpp @@ -175,15 +175,16 @@ void VAbstractConverter::ReserveFile() const } //--------------------------------------------------------------------------------------------------------------------- -void VAbstractConverter::Replace(QString &formula, const QString &newName, int position, const QString &token, - int &bias) const +void VAbstractConverter::Replace(QString &formula, const QString &newName, vsizetype position, const QString &token, + vsizetype &bias) const { formula.replace(position, token.length(), newName); bias = token.length() - newName.length(); } //--------------------------------------------------------------------------------------------------------------------- -void VAbstractConverter::CorrectionsPositions(int position, int bias, QMap &tokens) const +void VAbstractConverter::CorrectionsPositions(vsizetype position, vsizetype bias, + QMap &tokens) const { if (bias == 0) { @@ -194,10 +195,10 @@ void VAbstractConverter::CorrectionsPositions(int position, int bias, QMap &tokens) +void VAbstractConverter::BiasTokens(vsizetype position, vsizetype bias, QMap &tokens) { - QMap newTokens; - QMap::const_iterator i = tokens.constBegin(); + QMap newTokens; + QMap::const_iterator i = tokens.constBegin(); while (i != tokens.constEnd()) { if (i.key()<= position) diff --git a/src/libs/ifc/xml/vabstractconverter.h b/src/libs/ifc/xml/vabstractconverter.h index 36ae8d69d..f89f84e82 100644 --- a/src/libs/ifc/xml/vabstractconverter.h +++ b/src/libs/ifc/xml/vabstractconverter.h @@ -75,9 +75,10 @@ protected: virtual bool IsReadOnly() const =0; - void Replace(QString &formula, const QString &newName, int position, const QString &token, int &bias) const; - void CorrectionsPositions(int position, int bias, QMap &tokens) const; - static void BiasTokens(int position, int bias, QMap &tokens); + void Replace(QString &formula, const QString &newName, vsizetype position, const QString &token, + vsizetype &bias) const; + void CorrectionsPositions(vsizetype position, vsizetype bias, QMap &tokens) const; + static void BiasTokens(vsizetype position, vsizetype bias, QMap &tokens); void ValidateXML(const QString &schema) const; diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index bc1441f6c..dbc63e477 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1658,7 +1658,7 @@ auto VAbstractPattern::CheckTagExists(const QString &tag) -> QDomElement void VAbstractPattern::InsertTag(const QStringList &tags, const QDomElement &element) { QDomElement pattern = documentElement(); - for (int i = tags.indexOf(element.tagName())-1; i >= 0; --i) + for (vsizetype i = tags.indexOf(element.tagName())-1; i >= 0; --i) { const QDomNodeList list = elementsByTagName(tags.at(i)); if (not list.isEmpty()) diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 074be2890..16cb23506 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -1001,10 +1001,10 @@ QString VPatternConverter::FixMeasurementInFormulaToV0_2_0(const QString &formul "Time to refactor the code."); QScopedPointer cal(new qmu::QmuTokenParser(formula, false, false));// Eval formula - QMap tokens = cal->GetTokens();// Tokens (variables, measurements) + QMap tokens = cal->GetTokens();// Tokens (variables, measurements) delete cal.take(); - QList tKeys = tokens.keys();// Take all tokens positions + QList tKeys = tokens.keys();// Take all tokens positions QList tValues = tokens.values(); QString newFormula = formula;// Local copy for making changes @@ -1015,7 +1015,7 @@ QString VPatternConverter::FixMeasurementInFormulaToV0_2_0(const QString &formul continue; } - int bias = 0; + vsizetype bias = 0; Replace(newFormula, names.value(tValues.at(i)), tKeys.at(i), tValues.at(i), bias); if (bias != 0) {// Translated token has different length than original. Position next tokens need to be corrected. @@ -1035,21 +1035,21 @@ QString VPatternConverter::FixIncrementInFormulaToV0_2_0(const QString &formula, "Time to refactor the code."); qmu::QmuTokenParser *cal = new qmu::QmuTokenParser(formula, false, false);// Eval formula - QMap tokens = cal->GetTokens();// Tokens (variables, measurements) + QMap tokens = cal->GetTokens();// Tokens (variables, measurements) delete cal; - QList tKeys = tokens.keys();// Take all tokens positions + QList tKeys = tokens.keys();// Take all tokens positions QList tValues = tokens.values(); QString newFormula = formula;// Local copy for making changes - for (int i = 0; i < tValues.size(); ++i) + for (vsizetype i = 0; i < tValues.size(); ++i) { if (not names.contains(tValues.at(i))) { continue; } - int bias = 0; + vsizetype bias = 0; Replace(newFormula, "#"+tValues.at(i), tKeys.at(i), tValues.at(i), bias); if (bias != 0) {// Translated token has different length than original. Position next tokens need to be corrected. @@ -1870,7 +1870,7 @@ QDomElement VPatternConverter::AddTagPatternLabelV0_5_1() QDomElement element = createElement(*strPatternLabel); QDomElement pattern = documentElement(); - for (int i = tags.indexOf(element.tagName())-1; i >= 0; --i) + for (vsizetype i = tags.indexOf(element.tagName())-1; i >= 0; --i) { const QDomNodeList list = elementsByTagName(tags.at(i)); if (not list.isEmpty()) diff --git a/src/libs/qmuparser/qmudef.cpp b/src/libs/qmuparser/qmudef.cpp index 7bc8a9f6c..f97309c4d 100644 --- a/src/libs/qmuparser/qmudef.cpp +++ b/src/libs/qmuparser/qmudef.cpp @@ -167,7 +167,8 @@ static int CheckChar(QChar &c, const QLocale &locale, const QChar &decimal, cons } //--------------------------------------------------------------------------------------------------------------------- -int ReadVal(const QString &formula, qreal &val, const QLocale &locale, const QChar &decimal, const QChar &thousand) +qmusizetype ReadVal(const QString &formula, qreal &val, const QLocale &locale, const QChar &decimal, + const QChar &thousand) { // Must not be equal if (decimal == thousand || formula.isEmpty()) @@ -335,9 +336,9 @@ QString NameRegExp() } //--------------------------------------------------------------------------------------------------------------------- -int FindFirstNotOf(const QString &string, const QString &chars, int pos) +qmusizetype FindFirstNotOf(const QString &string, const QString &chars, qmusizetype pos) { - int chPos = pos; + qmusizetype chPos = pos; QString::const_iterator it = string.constBegin() + pos; QString::const_iterator end = string.constEnd(); while (it != end) diff --git a/src/libs/qmuparser/qmudef.h b/src/libs/qmuparser/qmudef.h index 1217b4420..19a3e7f93 100644 --- a/src/libs/qmuparser/qmudef.h +++ b/src/libs/qmuparser/qmudef.h @@ -144,9 +144,9 @@ static inline bool QmuFuzzyComparePossibleNulls(double p1, double p2) } } -QMUPARSERSHARED_EXPORT int ReadVal(const QString &formula, qreal &val, const QLocale &locale, const QChar &decimal, - const QChar &thousand); +QMUPARSERSHARED_EXPORT qmusizetype ReadVal(const QString &formula, qreal &val, const QLocale &locale, + const QChar &decimal, const QChar &thousand); -QMUPARSERSHARED_EXPORT int FindFirstNotOf(const QString &string, const QString &chars, int pos = 0); +QMUPARSERSHARED_EXPORT qmusizetype FindFirstNotOf(const QString &string, const QString &chars, qmusizetype pos = 0); #endif // QMUDEF_H diff --git a/src/libs/qmuparser/qmuformulabase.cpp b/src/libs/qmuparser/qmuformulabase.cpp index 566227e7c..872ed396f 100644 --- a/src/libs/qmuparser/qmuformulabase.cpp +++ b/src/libs/qmuparser/qmuformulabase.cpp @@ -177,9 +177,9 @@ void QmuFormulaBase::SetSepForEval() * @param map map with tokens * @param val token that need delete */ -void QmuFormulaBase::RemoveAll(QMap &map, const QString &val) +void QmuFormulaBase::RemoveAll(QMap &map, const QString &val) { - const QList listKeys = map.keys(val);//Take all keys that contain token. + const QList listKeys = map.keys(val);//Take all keys that contain token. for (auto key : listKeys) { map.remove(key); diff --git a/src/libs/qmuparser/qmuformulabase.h b/src/libs/qmuparser/qmuformulabase.h index d8d2061be..bbcc43a13 100644 --- a/src/libs/qmuparser/qmuformulabase.h +++ b/src/libs/qmuparser/qmuformulabase.h @@ -45,7 +45,7 @@ public: void SetSepForTr(bool osSeparator, bool fromUser); - static void RemoveAll(QMap &map, const QString &val); + static void RemoveAll(QMap &map, const QString &val); protected: static qreal* AddVariable(const QString &a_szName, void *a_pUserData); diff --git a/src/libs/qmuparser/qmuparser.cpp b/src/libs/qmuparser/qmuparser.cpp index 373ce39c0..b678f1044 100644 --- a/src/libs/qmuparser/qmuparser.cpp +++ b/src/libs/qmuparser/qmuparser.cpp @@ -299,7 +299,7 @@ qreal QmuParser::FMod(qreal number, qreal denom) * @param [in] a_afArg Vector with the function arguments * @param [in] a_iArgc The size of a_afArg */ -qreal QmuParser::Sum(const qreal *a_afArg, int a_iArgc) +qreal QmuParser::Sum(const qreal *a_afArg, qmusizetype a_iArgc) { if (a_iArgc == 0) { @@ -320,7 +320,7 @@ qreal QmuParser::Sum(const qreal *a_afArg, int a_iArgc) * @param [in] a_afArg Vector with the function arguments * @param [in] a_iArgc The size of a_afArg */ -qreal QmuParser::Avg(const qreal *a_afArg, int a_iArgc) +qreal QmuParser::Avg(const qreal *a_afArg, qmusizetype a_iArgc) { if (a_iArgc == 0) { @@ -341,7 +341,7 @@ qreal QmuParser::Avg(const qreal *a_afArg, int a_iArgc) * @param [in] a_afArg Vector with the function arguments * @param [in] a_iArgc The size of a_afArg */ -qreal QmuParser::Min(const qreal *a_afArg, int a_iArgc) +qreal QmuParser::Min(const qreal *a_afArg, qmusizetype a_iArgc) { if (a_iArgc == 0) { @@ -362,7 +362,7 @@ qreal QmuParser::Min(const qreal *a_afArg, int a_iArgc) * @param [in] a_afArg Vector with the function arguments * @param [in] a_iArgc The size of a_afArg */ -qreal QmuParser::Max(const qreal *a_afArg, int a_iArgc) +qreal QmuParser::Max(const qreal *a_afArg, qmusizetype a_iArgc) { if (a_iArgc == 0) { @@ -385,12 +385,13 @@ qreal QmuParser::Max(const qreal *a_afArg, int a_iArgc) * @param [out] a_fVal Pointer where the value should be stored in case one is found. * @return 1 if a value was found 0 otherwise. */ -int QmuParser::IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal, const QLocale &locale, bool cNumbers, +int QmuParser::IsVal(const QString &a_szExpr, qmusizetype *a_iPos, qreal *a_fVal, const QLocale &locale, bool cNumbers, const QChar &decimal, const QChar &thousand) { qreal fVal(0); - int pos = ReadVal(a_szExpr, fVal, locale != QLocale::c() && cNumbers ? QLocale::c() : locale, decimal, thousand); + qmusizetype pos = ReadVal(a_szExpr, fVal, locale != QLocale::c() && cNumbers ? QLocale::c() : locale, decimal, + thousand); if (pos == -1) { @@ -510,7 +511,7 @@ void QmuParser::InitOprt() } //--------------------------------------------------------------------------------------------------------------------- -void QmuParser::OnDetectVar(const QString &pExpr, int &nStart, int &nEnd) +void QmuParser::OnDetectVar(const QString &pExpr, qmusizetype &nStart, qmusizetype &nEnd) { Q_UNUSED(pExpr) Q_UNUSED(nStart) diff --git a/src/libs/qmuparser/qmuparser.h b/src/libs/qmuparser/qmuparser.h index c91974df5..5da818713 100644 --- a/src/libs/qmuparser/qmuparser.h +++ b/src/libs/qmuparser/qmuparser.h @@ -58,11 +58,11 @@ namespace qmu virtual void InitFun() override; virtual void InitConst() override; virtual void InitOprt() override; - virtual void OnDetectVar(const QString &pExpr, int &nStart, int &nEnd) override; + virtual void OnDetectVar(const QString &pExpr, qmusizetype &nStart, qmusizetype &nEnd) override; qreal Diff(qreal *a_Var, qreal a_fPos, qreal a_fEpsilon = 0) const; protected: - static int IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal, const QLocale &locale, bool cNumbers, - const QChar &decimal, const QChar &thousand); + static int IsVal(const QString &a_szExpr, qmusizetype *a_iPos, qreal *a_fVal, const QLocale &locale, + bool cNumbers, const QChar &decimal, const QChar &thousand); // hyperbolic functions static qreal Sinh(qreal); static qreal Cosh(qreal); @@ -96,10 +96,10 @@ namespace qmu // !!! Unary Minus is a MUST if you want to use negative signs !!! static qreal UnaryMinus(qreal v); // Functions with variable number of arguments - static qreal Sum(const qreal*, int); // sum - static qreal Avg(const qreal*, int); // mean value - static qreal Min(const qreal*, int); // minimum - static qreal Max(const qreal*, int); // maximum + static qreal Sum(const qreal*, qmusizetype); // sum + static qreal Avg(const qreal*, qmusizetype); // mean value + static qreal Min(const qreal*, qmusizetype); // minimum + static qreal Max(const qreal*, qmusizetype); // maximum }; QT_WARNING_POP diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index bc61fa601..3417354c4 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -85,8 +85,8 @@ QmuParserBase::QmuParserBase() m_nIfElseCounter(0), m_vStackBuffer(), m_nFinalResultIdx(0), - m_Tokens(QMap()), - m_Numbers(QMap()), + m_Tokens(QMap()), + m_Numbers(QMap()), allowSubexpressions(true) { InitTokenReader(); @@ -121,8 +121,8 @@ QmuParserBase::QmuParserBase(const QmuParserBase &a_Parser) m_nIfElseCounter(0), m_vStackBuffer(), m_nFinalResultIdx(0), - m_Tokens(QMap()), - m_Numbers(QMap()), + m_Tokens(QMap()), + m_Numbers(QMap()), allowSubexpressions(true) { m_pTokenReader.reset(new token_reader_type(this)); @@ -229,7 +229,7 @@ void QmuParserBase::ReInit() const } //--------------------------------------------------------------------------------------------------------------------- -void QmuParserBase::OnDetectVar(const QString &pExpr, int &nStart, int &nEnd) +void QmuParserBase::OnDetectVar(const QString &pExpr, qmusizetype &nStart, qmusizetype &nEnd) { Q_UNUSED(pExpr) Q_UNUSED(nStart) @@ -1023,7 +1023,7 @@ qreal QmuParserBase::ParseCmdCodeBulk(int nOffset, int nThreadID) const qreal *Stack = ((nOffset==0) && (nThreadID==0)) ? &m_vStackBuffer[0] : &m_vStackBuffer[nThreadID * (m_vStackBuffer.size() / s_MaxNumOpenMPThreads)]; qreal buf; - int sidx(0); + qmusizetype sidx(0); for (const SToken *pTok = m_vRPN.GetBase(); pTok->Cmd!=cmEND ; ++pTok) { switch (pTok->Cmd) @@ -1143,7 +1143,7 @@ QT_WARNING_POP // Next is treatment of numeric functions case cmFUNC: { - int iArgCount = pTok->Fun.argc; + qmusizetype iArgCount = pTok->Fun.argc; QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wcast-function-type") @@ -1224,7 +1224,7 @@ QT_WARNING_DISABLE_MSVC(4191) sidx -= pTok->Fun.argc -1; // The index of the string argument in the string table - int iIdxStack = pTok->Fun.idx; + qmusizetype iIdxStack = pTok->Fun.idx; Q_ASSERT( iIdxStack>=0 && iIdxStackFun.argc) // switch according to argument count @@ -1248,7 +1248,7 @@ QT_WARNING_DISABLE_MSVC(4191) } case cmFUNC_BULK: { - int iArgCount = pTok->Fun.argc; + qmusizetype iArgCount = pTok->Fun.argc; // switch according to argument count switch (iArgCount) @@ -1648,7 +1648,7 @@ qreal QmuParserBase::ParseString() const * @param a_sTok [in] The token string representation associated with the error. * @throw ParserException always throws thats the only purpose of this function. */ -void Q_NORETURN QmuParserBase::Error(EErrorCodes a_iErrc, int a_iPos, const QString &a_sTok) const +void Q_NORETURN QmuParserBase::Error(EErrorCodes a_iErrc, qmusizetype a_iPos, const QString &a_sTok) const { throw qmu::QmuParserError (a_iErrc, a_sTok, m_pTokenReader->GetExpr(), a_iPos); } diff --git a/src/libs/qmuparser/qmuparserbase.h b/src/libs/qmuparser/qmuparserbase.h index 42903db66..4dace385d 100644 --- a/src/libs/qmuparser/qmuparserbase.h +++ b/src/libs/qmuparser/qmuparserbase.h @@ -111,8 +111,8 @@ public: const funmap_type& GetFunDef() const; static QString GetVersion(EParserVersionInfo eInfo = pviFULL); static const QStringList& GetOprtDef(); - QMap GetTokens() const; - QMap GetNumbers() const; + QMap GetTokens() const; + QMap GetNumbers() const; void DefineNameChars(const QString &a_szCharset); void DefineOprtChars(const QString &a_szCharset); void DefineInfixOprtChars(const QString &a_szCharset); @@ -121,7 +121,7 @@ public: const QString& ValidInfixOprtChars() const; void SetArgSep(char_type cArgSep); QChar GetArgSep() const; - void Q_NORETURN Error(EErrorCodes a_iErrc, int a_iPos = -1, const QString &a_sTok = QString() ) const; + void Q_NORETURN Error(EErrorCodes a_iErrc, qmusizetype a_iPos = -1, const QString &a_sTok = QString() ) const; template void DefineFun(const QString &a_strName, T a_pFun, bool a_bAllowOpt = true); @@ -162,7 +162,7 @@ protected: virtual void InitFun() = 0; virtual void InitConst() = 0; virtual void InitOprt() = 0; - virtual void OnDetectVar(const QString &pExpr, int &nStart, int &nEnd); + virtual void OnDetectVar(const QString &pExpr, qmusizetype &nStart, qmusizetype &nEnd); /** * @brief A facet class used to change decimal and thousands separator. */ @@ -256,8 +256,8 @@ private: // items merely used for caching state information mutable valbuf_type m_vStackBuffer; ///< This is merely a buffer used for the stack in the cmd parsing routine mutable int m_nFinalResultIdx; - mutable QMap m_Tokens;///< Keep all tokens that we can translate - mutable QMap m_Numbers;///< Keep all numbers what exist in formula + mutable QMap m_Tokens;///< Keep all tokens that we can translate + mutable QMap m_Numbers;///< Keep all numbers what exist in formula bool allowSubexpressions; @@ -337,13 +337,13 @@ inline const QStringList &QmuParserBase::GetOprtDef() } //--------------------------------------------------------------------------------------------------------------------- -inline QMap QmuParserBase::GetTokens() const +inline QMap QmuParserBase::GetTokens() const { return m_Tokens; } //--------------------------------------------------------------------------------------------------------------------- -inline QMap QmuParserBase::GetNumbers() const +inline QMap QmuParserBase::GetNumbers() const { return m_Numbers; } diff --git a/src/libs/qmuparser/qmuparserbytecode.cpp b/src/libs/qmuparser/qmuparserbytecode.cpp index 1123e3a9f..e727ad25a 100644 --- a/src/libs/qmuparser/qmuparserbytecode.cpp +++ b/src/libs/qmuparser/qmuparserbytecode.cpp @@ -139,7 +139,7 @@ void QmuParserByteCode::AddVal(qreal a_fVal) //--------------------------------------------------------------------------------------------------------------------- void QmuParserByteCode::ConstantFolding(ECmdCode a_Oprt) { - int sz = m_vRPN.size(); + qmusizetype sz = m_vRPN.size(); qreal &x = m_vRPN[sz-2].Val.data2, &y = m_vRPN[sz-1].Val.data2; switch (a_Oprt) @@ -216,7 +216,7 @@ void QmuParserByteCode::ConstantFolding(ECmdCode a_Oprt) } //--------------------------------------------------------------------------------------------------------------------- -void QmuParserByteCode::OpPOW(int sz, bool &bOptimized) +void QmuParserByteCode::OpPOW(qmusizetype sz, bool &bOptimized) { if (m_vRPN.at(sz-2).Cmd == cmVAR && m_vRPN.at(sz-1).Cmd == cmVAL) //-V807 { @@ -242,7 +242,7 @@ void QmuParserByteCode::OpPOW(int sz, bool &bOptimized) } //--------------------------------------------------------------------------------------------------------------------- -void QmuParserByteCode::OpSUBADD(ECmdCode a_Oprt, int sz, bool &bOptimized) +void QmuParserByteCode::OpSUBADD(ECmdCode a_Oprt, qmusizetype sz, bool &bOptimized) { if ( (m_vRPN.at(sz-1).Cmd == cmVAR && m_vRPN.at(sz-2).Cmd == cmVAL) || (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVAR) || @@ -273,7 +273,7 @@ void QmuParserByteCode::OpSUBADD(ECmdCode a_Oprt, int sz, bool &bOptimized) } //--------------------------------------------------------------------------------------------------------------------- -void QmuParserByteCode::OpMUL(int sz, bool &bOptimized) +void QmuParserByteCode::OpMUL(qmusizetype sz, bool &bOptimized) { if ( (m_vRPN.at(sz-1).Cmd == cmVAR && m_vRPN.at(sz-2).Cmd == cmVAL) || (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVAR) ) @@ -319,7 +319,7 @@ void QmuParserByteCode::OpMUL(int sz, bool &bOptimized) } //--------------------------------------------------------------------------------------------------------------------- -void QmuParserByteCode::OpDIV(int sz, bool &bOptimized) +void QmuParserByteCode::OpDIV(qmusizetype sz, bool &bOptimized) { if (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVARMUL && not qFuzzyIsNull(m_vRPN.at(sz-1).Val.data2)) @@ -370,7 +370,7 @@ void QmuParserByteCode::AddOp(ECmdCode a_Oprt) return; } - int sz = m_vRPN.size(); + qmusizetype sz = m_vRPN.size(); // Check for foldable constants like: // cmVAL cmVAL cmADD @@ -477,7 +477,7 @@ void QmuParserByteCode::AddFun(generic_fun_type a_pFun, int a_iArgc) * @param a_iArgc Number of arguments, negative numbers indicate multiarg functions. * @param a_pFun Pointer to function callback. */ -void QmuParserByteCode::AddBulkFun(generic_fun_type a_pFun, int a_iArgc) +void QmuParserByteCode::AddBulkFun(generic_fun_type a_pFun, qmusizetype a_iArgc) { m_iStackPos = static_cast(static_cast(m_iStackPos) - a_iArgc + 1); m_iMaxStackSize = qMax(m_iMaxStackSize, m_iStackPos); @@ -497,7 +497,7 @@ void QmuParserByteCode::AddBulkFun(generic_fun_type a_pFun, int a_iArgc) * A string function entry consists of the stack position of the return value, followed by a cmSTRFUNC code, the * function pointer and an index into the string buffer maintained by the parser. */ -void QmuParserByteCode::AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx) +void QmuParserByteCode::AddStrFun(generic_fun_type a_pFun, int a_iArgc, qmusizetype a_iIdx) { m_iStackPos = static_cast(static_cast(m_iStackPos) - a_iArgc + 1); diff --git a/src/libs/qmuparser/qmuparserbytecode.h b/src/libs/qmuparser/qmuparserbytecode.h index 694643c42..9fc0a15ce 100644 --- a/src/libs/qmuparser/qmuparserbytecode.h +++ b/src/libs/qmuparser/qmuparserbytecode.h @@ -58,8 +58,8 @@ struct SToken // pointer due to constraints in the ANSI standard which allows // data pointers and function pointers to differ in size. generic_fun_type ptr; - int argc; - int idx; + qmusizetype argc; + qmusizetype idx; } Fun; struct //SOprtData @@ -98,13 +98,13 @@ public: void AddIfElse(ECmdCode a_Oprt); void AddAssignOp(qreal *a_pVar); void AddFun(generic_fun_type a_pFun, int a_iArgc); - void AddBulkFun(generic_fun_type a_pFun, int a_iArgc); - void AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx); + void AddBulkFun(generic_fun_type a_pFun, qmusizetype a_iArgc); + void AddStrFun(generic_fun_type a_pFun, int a_iArgc, qmusizetype a_iIdx); void EnableOptimizer(bool bStat); void Finalize(); void clear(); auto GetMaxStackSize() const -> int; - auto GetSize() const -> int; + auto GetSize() const -> qmusizetype; auto GetBase() const -> const SToken*; void AsciiDump(); private: @@ -127,10 +127,10 @@ private: void ConstantFolding(ECmdCode a_Oprt); - void OpPOW(int sz, bool &bOptimized); - void OpSUBADD(ECmdCode a_Oprt, int sz, bool &bOptimized); - void OpMUL(int sz, bool &bOptimized); - void OpDIV(int sz, bool &bOptimized); + void OpPOW(qmusizetype sz, bool &bOptimized); + void OpSUBADD(ECmdCode a_Oprt, qmusizetype sz, bool &bOptimized); + void OpMUL(qmusizetype sz, bool &bOptimized); + void OpDIV(qmusizetype sz, bool &bOptimized); }; //--------------------------------------------------------------------------------------------------------------------- @@ -150,7 +150,7 @@ inline auto QmuParserByteCode::GetMaxStackSize() const -> int * @brief Returns the number of entries in the bytecode. */ // cppcheck-suppress unusedFunction -inline auto QmuParserByteCode::GetSize() const -> int +inline auto QmuParserByteCode::GetSize() const -> qmusizetype { return m_vRPN.size(); } diff --git a/src/libs/qmuparser/qmuparserdef.h b/src/libs/qmuparser/qmuparserdef.h index a5bda09a4..7387497df 100644 --- a/src/libs/qmuparser/qmuparserdef.h +++ b/src/libs/qmuparser/qmuparserdef.h @@ -26,6 +26,7 @@ #include #include #include +#include #include "qmuparserfixes.h" @@ -99,6 +100,12 @@ class QLocale; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +using qmusizetype = qsizetype; +#else +using qmusizetype = int; +#endif + namespace qmu { //------------------------------------------------------------------------------ @@ -224,7 +231,7 @@ typedef std::map varmap_type; typedef std::map valmap_type; /** @brief Type for assigning a string name to an index in the internal string table. */ -typedef std::map strmap_type; +typedef std::map strmap_type; // Parser callbacks @@ -298,7 +305,7 @@ typedef qreal ( *bulkfun_type9 ) ( int, int, qreal, qreal, qreal, qreal, qreal, typedef qreal ( *bulkfun_type10 ) ( int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); /** @brief Callback type used for functions with a variable argument list. */ -typedef qreal ( *multfun_type ) ( const qreal*, int ); +typedef qreal ( *multfun_type ) ( const qreal*, qmusizetype ); /** @brief Callback type used for functions taking a string as an argument. */ typedef qreal ( *strfun_type1 ) ( const QString & ); @@ -310,8 +317,8 @@ typedef qreal ( *strfun_type2 ) ( const QString &, qreal ); typedef qreal ( *strfun_type3 ) ( const QString &, qreal, qreal ); /** @brief Callback used for functions that identify values in a string. */ -typedef int ( *identfun_type ) ( const QString &sExpr, int *nPos, qreal *fVal, const QLocale &locale, bool cNumbers, - const QChar &decimal, const QChar &thousand ); +typedef int ( *identfun_type ) ( const QString &sExpr, qmusizetype *nPos, qreal *fVal, const QLocale &locale, + bool cNumbers, const QChar &decimal, const QChar &thousand ); /** @brief Callback used for variable creation factory functions. */ typedef qreal* ( *facfun_type ) ( const QString &, void* ); diff --git a/src/libs/qmuparser/qmuparsererror.cpp b/src/libs/qmuparser/qmuparsererror.cpp index 987a09c4b..54dad5f2e 100644 --- a/src/libs/qmuparser/qmuparsererror.cpp +++ b/src/libs/qmuparser/qmuparsererror.cpp @@ -203,7 +203,7 @@ QmuParserError::QmuParserError ( const QString &sMsg ) * @param [in] sExpr The expression related to the error. * @param [in] iPos the position in the expression where the error occured. */ -QmuParserError::QmuParserError ( EErrorCodes iErrc, const QString &sTok, const QString &sExpr, int iPos ) +QmuParserError::QmuParserError (EErrorCodes iErrc, const QString &sTok, const QString &sExpr, qmusizetype iPos ) : QException(), m_sMsg(), m_sExpr ( sExpr ), m_sTok ( sTok ), m_iPos ( iPos ), m_iErrc ( iErrc ), m_ErrMsg ( QmuParserErrorMsg::Instance() ) { diff --git a/src/libs/qmuparser/qmuparsererror.h b/src/libs/qmuparser/qmuparsererror.h index 9a85cd40c..5017473c2 100644 --- a/src/libs/qmuparser/qmuparsererror.h +++ b/src/libs/qmuparser/qmuparsererror.h @@ -170,7 +170,7 @@ public: QmuParserError(); explicit QmuParserError ( EErrorCodes a_iErrc ); explicit QmuParserError ( const QString &sMsg ); - QmuParserError ( EErrorCodes a_iErrc, const QString &sTok, const QString &sFormula = QString(), int a_iPos = -1 ); + QmuParserError ( EErrorCodes a_iErrc, const QString &sTok, const QString &sFormula = QString(), qmusizetype a_iPos = -1 ); QmuParserError ( EErrorCodes a_iErrc, int a_iPos, const QString &sTok ); QmuParserError ( const QString &szMsg, int iPos, const QString &sTok = QString() ); QmuParserError ( const QmuParserError &a_Obj ); @@ -180,7 +180,7 @@ public: void SetFormula ( const QString &a_strFormula ); const QString& GetExpr() const; const QString& GetMsg() const; - int GetPos() const; + qmusizetype GetPos() const; const QString& GetToken() const; EErrorCodes GetCode() const; Q_NORETURN virtual void raise() const override; @@ -189,7 +189,7 @@ private: QString m_sMsg; ///< The message string QString m_sExpr; ///< Formula string QString m_sTok; ///< Token related with the error - int m_iPos; ///< Formula position related to the error + qmusizetype m_iPos; ///< Formula position related to the error EErrorCodes m_iErrc; ///< Error code const QmuParserErrorMsg &m_ErrMsg; void Reset(); @@ -228,7 +228,7 @@ inline const QString& QmuParserError::GetMsg() const * * If the error is not related to a distinct position this will return -1 */ -inline int QmuParserError::GetPos() const +inline qmusizetype QmuParserError::GetPos() const { return m_iPos; } diff --git a/src/libs/qmuparser/qmuparsertest.cpp b/src/libs/qmuparser/qmuparsertest.cpp index a090a5eb2..c87f8b21d 100644 --- a/src/libs/qmuparser/qmuparsertest.cpp +++ b/src/libs/qmuparser/qmuparsertest.cpp @@ -74,7 +74,7 @@ QmuParserTester::QmuParserTester(QObject *parent) } //--------------------------------------------------------------------------------------------------------------------- -int QmuParserTester::IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_fVal, const QLocale &locale, +int QmuParserTester::IsHexVal ( const QString &a_szExpr, qmusizetype *a_iPos, qreal *a_fVal, const QLocale &locale, bool cNumbers, const QChar &decimal, const QChar &thousand ) { Q_UNUSED(locale) @@ -102,7 +102,7 @@ int QmuParserTester::IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_f return 1; } - *a_iPos += static_cast(2 + nPos); + *a_iPos += static_cast(2 + nPos); *a_fVal = static_cast(iVal); return 1; } diff --git a/src/libs/qmuparser/qmuparsertest.h b/src/libs/qmuparser/qmuparsertest.h index 66db9d8e1..908f05f1c 100644 --- a/src/libs/qmuparser/qmuparsertest.h +++ b/src/libs/qmuparser/qmuparsertest.h @@ -201,7 +201,7 @@ private: return static_cast( v1 ) & static_cast( v2 ); } - static qreal FirstArg ( const qreal* a_afArg, int a_iArgc ) + static qreal FirstArg ( const qreal* a_afArg, qmusizetype a_iArgc ) { if ( a_iArgc == 0) { @@ -211,7 +211,7 @@ private: return a_afArg[0]; } - static qreal LastArg ( const qreal* a_afArg, int a_iArgc ) + static qreal LastArg ( const qreal* a_afArg, qmusizetype a_iArgc ) { if ( a_iArgc == 0) { @@ -221,7 +221,7 @@ private: return a_afArg[a_iArgc - 1]; } - static qreal Sum ( const qreal* a_afArg, int a_iArgc ) + static qreal Sum ( const qreal* a_afArg, qmusizetype a_iArgc ) { if ( a_iArgc == 0) { @@ -307,8 +307,8 @@ private: } // Custom value recognition - static int IsHexVal (const QString &a_szExpr, int *a_iPos, qreal *a_fVal, const QLocale &locale, bool cNumbers, - const QChar &decimal, const QChar &thousand); + static int IsHexVal (const QString &a_szExpr, qmusizetype *a_iPos, qreal *a_fVal, const QLocale &locale, + bool cNumbers, const QChar &decimal, const QChar &thousand); int TestNames(); int TestSyntax(); diff --git a/src/libs/qmuparser/qmuparsertoken.h b/src/libs/qmuparser/qmuparsertoken.h index 630878c65..82640576b 100644 --- a/src/libs/qmuparser/qmuparsertoken.h +++ b/src/libs/qmuparser/qmuparsertoken.h @@ -215,7 +215,7 @@ public: * Member variables not necessary for variable tokens will be invalidated. * @throw nothrow */ - auto SetString ( const TString &a_strTok, int a_iSize ) -> QmuParserToken& + auto SetString ( const TString &a_strTok, qmusizetype a_iSize ) -> QmuParserToken& { m_iCode = cmSTRING; m_iType = tpSTR; @@ -235,7 +235,7 @@ public: * @param a_iIdx The index the string function result will take in the bytecode parser. * @throw QmuParserError if #a_iIdx<0 or #m_iType!=cmSTRING */ - void SetIdx ( int a_iIdx ) + void SetIdx ( qmusizetype a_iIdx ) { if ( m_iCode != cmSTRING || a_iIdx < 0 ) { @@ -254,7 +254,7 @@ public: * @throw QmuParserError if #m_iIdx<0 or #m_iType!=cmSTRING * @return The index the result will take in the Bytecode calculatin array (#m_iIdx). */ - auto GetIdx() const -> int + auto GetIdx() const -> qmusizetype { if ( m_iIdx < 0 || m_iCode != cmSTRING ) { @@ -465,7 +465,7 @@ private: ECmdCode m_iCode{cmUNKNOWN}; ///< Type of the token; The token type is a constant of type #ECmdCode. ETypeCode m_iType{tpVOID}; void *m_pTok{nullptr}; ///< Stores Token pointer; not applicable for all tokens - int m_iIdx{-1}; ///< An otional index to an external buffer storing the token data + qmusizetype m_iIdx{-1}; ///< An otional index to an external buffer storing the token data TString m_strTok{}; ///< Token string TString m_strVal{}; ///< Value for string variables qreal m_fVal{}; ///< the value diff --git a/src/libs/qmuparser/qmuparsertokenreader.cpp b/src/libs/qmuparser/qmuparsertokenreader.cpp index f854079be..bbc3afb9b 100644 --- a/src/libs/qmuparser/qmuparsertokenreader.cpp +++ b/src/libs/qmuparser/qmuparsertokenreader.cpp @@ -283,7 +283,7 @@ auto QmuParserTokenReader::ReadNextToken(const QLocale &locale, bool cNumbers, c // !!! From this point on there is no exit without an exception possible... // QString strTok; - int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); + qmusizetype iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); if ( iEnd != m_iPos ) { Error ( ecUNASSIGNABLE_TOKEN, m_iPos, strTok ); @@ -318,9 +318,10 @@ void QmuParserTokenReader::SetParent ( QmuParserBase *a_pParent ) */ QT_WARNING_PUSH QT_WARNING_DISABLE_MSVC(4309) -auto QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_sTok, int a_iPos ) const -> int +auto QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_sTok, + qmusizetype a_iPos ) const -> qmusizetype { - int iEnd = FindFirstNotOf(m_strFormula, a_szCharSet, a_iPos); + qmusizetype iEnd = FindFirstNotOf(m_strFormula, a_szCharSet, a_iPos); if (iEnd == -1) { @@ -344,9 +345,9 @@ auto QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a * alphabetic characters are allowed in operator tokens. To avoid this this function checks specifically * for operator tokens. */ -auto QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, int a_iPos ) const -> int +auto QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, qmusizetype a_iPos ) const -> qmusizetype { - int iEnd = FindFirstNotOf(m_strFormula, m_pParser->ValidOprtChars(), a_iPos); + qmusizetype iEnd = FindFirstNotOf(m_strFormula, m_pParser->ValidOprtChars(), a_iPos); if ( iEnd == -1 ) { @@ -380,7 +381,7 @@ auto QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok ) -> bool // check string for operator/function for ( int i = 0; i < pOprtDef.size(); ++i ) { - int len = pOprtDef.at ( i ).length(); + qmusizetype len = pOprtDef.at ( i ).length(); if ( pOprtDef.at ( i ) == m_strFormula.mid ( m_iPos, len ) ) { if (i >= cmLE && i <= cmASSIGN) @@ -549,7 +550,7 @@ auto QmuParserTokenReader::IsEOF ( token_type &a_Tok ) -> bool auto QmuParserTokenReader::IsInfixOpTok ( token_type &a_Tok ) -> bool { QString sTok; - int iEnd = ExtractToken ( m_pParser->ValidInfixOprtChars(), sTok, m_iPos ); + qmusizetype iEnd = ExtractToken ( m_pParser->ValidInfixOprtChars(), sTok, m_iPos ); if ( iEnd == m_iPos ) { return false; @@ -588,7 +589,7 @@ auto QmuParserTokenReader::IsInfixOpTok ( token_type &a_Tok ) -> bool auto QmuParserTokenReader::IsFunTok ( token_type &a_Tok ) -> bool { QString strTok; - int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); + qmusizetype iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); if ( iEnd == m_iPos ) { return false; @@ -628,7 +629,7 @@ auto QmuParserTokenReader::IsOprt ( token_type &a_Tok ) -> bool { QString strTok; - int iEnd = ExtractOperatorToken ( strTok, m_iPos ); + qmusizetype iEnd = ExtractOperatorToken ( strTok, m_iPos ); if ( iEnd == m_iPos ) { return false; @@ -718,7 +719,7 @@ auto QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok ) -> bool // Test if there could be a postfix operator QString sTok; - int iEnd = ExtractToken ( m_pParser->ValidOprtChars(), sTok, m_iPos ); + qmusizetype iEnd = ExtractToken ( m_pParser->ValidOprtChars(), sTok, m_iPos ); if ( iEnd == m_iPos ) { return false; @@ -758,7 +759,7 @@ auto QmuParserTokenReader::IsValTok ( token_type &a_Tok, const QLocale &locale, QString strTok; qreal fVal ( 0 ); - int iEnd ( 0 ); + qmusizetype iEnd ( 0 ); // 2.) Check for user defined constant // Read everything that could be a constant name @@ -786,7 +787,7 @@ auto QmuParserTokenReader::IsValTok ( token_type &a_Tok, const QLocale &locale, auto item = m_vIdentFun.begin(); for ( item = m_vIdentFun.begin(); item != m_vIdentFun.end(); ++item ) { - int iStart = m_iPos; + qmusizetype iStart = m_iPos; if ( ( *item ) ( m_strFormula.mid ( m_iPos ), &m_iPos, &fVal, locale, cNumbers, decimal, thousand ) == 1 ) { // 2013-11-27 Issue 2: https://code.google.com/p/muparser/issues/detail?id=2 @@ -819,7 +820,7 @@ auto QmuParserTokenReader::IsVarTok ( token_type &a_Tok ) -> bool } QString strTok; - int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); + qmusizetype iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); if ( iEnd == m_iPos ) { return false; @@ -858,7 +859,7 @@ auto QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok ) -> bool } QString strTok; - int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); + qmusizetype iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); if ( iEnd == m_iPos ) { return false; @@ -899,7 +900,7 @@ auto QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok ) -> bool auto QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) -> bool { QString strTok; - int iEnd ( ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ) ); + qmusizetype iEnd ( ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ) ); if ( iEnd == m_iPos ) { return false; @@ -966,7 +967,7 @@ auto QmuParserTokenReader::IsString ( token_type &a_Tok ) -> bool } QString strBuf (m_strFormula.mid(m_iPos + 1)); - int iEnd ( 0 ), iSkip ( 0 ); + qmusizetype iEnd ( 0 ), iSkip ( 0 ); // parser over escaped '\"' end replace them with '"' for ( iEnd = strBuf.indexOf ( "\"" ); iEnd != 0 && iEnd != -1; iEnd = strBuf.indexOf ( "\"", iEnd ) ) @@ -1011,7 +1012,7 @@ auto QmuParserTokenReader::IsString ( token_type &a_Tok ) -> bool * @param a_sTok [in] The token string representation associated with the error. * @throw ParserException always throws thats the only purpose of this function. */ -void Q_NORETURN QmuParserTokenReader::Error ( EErrorCodes a_iErrc, int a_iPos, const QString &a_sTok ) const +void Q_NORETURN QmuParserTokenReader::Error ( EErrorCodes a_iErrc, qmusizetype a_iPos, const QString &a_sTok ) const { m_pParser->Error ( a_iErrc, a_iPos, a_sTok ); } diff --git a/src/libs/qmuparser/qmuparsertokenreader.h b/src/libs/qmuparser/qmuparsertokenreader.h index 3abfbd940..efd3c4233 100644 --- a/src/libs/qmuparser/qmuparsertokenreader.h +++ b/src/libs/qmuparser/qmuparsertokenreader.h @@ -62,7 +62,7 @@ public: void SetVarCreator(facfun_type a_pFactory, void *pUserData); void SetFormula(const QString &a_strFormula); void SetArgSep(char_type cArgSep); - auto GetPos() const -> int; + auto GetPos() const -> qmusizetype; auto GetExpr() const -> const QString&; auto GetUsedVar() -> varmap_type&; auto GetArgSep() const -> QChar; @@ -100,7 +100,7 @@ private: QmuParserBase *m_pParser; QString m_strFormula{}; - int m_iPos{0}; + qmusizetype m_iPos{0}; int m_iSynFlags{0}; bool m_bIgnoreUndefVar{false}; @@ -126,8 +126,8 @@ private: void Assign(const QmuParserTokenReader &a_Reader); void SetParent(QmuParserBase *a_pParent); - auto ExtractToken(const QString &a_szCharSet, QString &a_strTok, int a_iPos) const -> int; - auto ExtractOperatorToken(QString &a_sTok, int a_iPos) const -> int; + auto ExtractToken(const QString &a_szCharSet, QString &a_strTok, qmusizetype a_iPos) const -> qmusizetype; + auto ExtractOperatorToken(QString &a_sTok, qmusizetype a_iPos) const -> qmusizetype; auto IsBuiltIn(token_type &a_Tok) -> bool; auto IsArgSep(token_type &a_Tok) -> bool; @@ -142,7 +142,7 @@ private: auto IsStrVarTok(token_type &a_Tok) -> bool; auto IsUndefVarTok(token_type &a_Tok) -> bool; auto IsString(token_type &a_Tok) -> bool; - void Q_NORETURN Error(EErrorCodes a_iErrc, int a_iPos = -1, const QString &a_sTok = QString() ) const; + void Q_NORETURN Error(EErrorCodes a_iErrc, qmusizetype a_iPos = -1, const QString &a_sTok = QString() ) const; auto SaveBeforeReturn(const token_type &tok) -> token_type&; }; @@ -154,7 +154,7 @@ private: * @return #m_iPos * @throw nothrow */ -inline auto QmuParserTokenReader::GetPos() const -> int +inline auto QmuParserTokenReader::GetPos() const -> qmusizetype { return m_iPos; } diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index e5cf85746..da9e04d00 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -860,7 +860,8 @@ void VDxfEngine::ExportPieceText(const QSharedPointer &detailBloc for (int i = 0; i < list.size(); ++i) { - QPointF pos(startPos.x(), startPos.y() - ToPixel(AAMATextHeight * m_yscale, m_varInsunits)*(list.size() - i-1)); + const qreal height = ToPixel(AAMATextHeight * m_yscale, m_varInsunits); + QPointF pos(startPos.x(), startPos.y() - height * (static_cast(list.size()) - i-1)); detailBlock->ent.push_back(AAMAText(pos, list.at(i), *layer1)); } } @@ -875,8 +876,8 @@ void VDxfEngine::ExportStyleSystemText(const QSharedPointer &input, co { for (int j = 0; j < strings.size(); ++j) { - QPointF pos(0, GetSize().height() - - ToPixel(AAMATextHeight * m_yscale, m_varInsunits)*(strings.size() - j-1)); + const qreal height = ToPixel(AAMATextHeight * m_yscale, m_varInsunits); + QPointF pos(0, GetSize().height() - height * (static_cast(strings.size()) - j-1)); input->AddEntity(AAMAText(pos, strings.at(j), *layer1)); } return; diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index c6d2538cc..3e0467283 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -1464,7 +1464,7 @@ qreal VMeasurements::EvalFormula(VContainer *data, const QString &formula, bool QString VMeasurements::ClearPMCode(const QString &code) const { QString clear = code; - const int index = clear.indexOf(QLatin1Char('p')); + const vsizetype index = clear.indexOf(QLatin1Char('p')); if (index == 0) { clear.remove(0, 1); diff --git a/src/libs/vgeometry/vabstractcubicbezierpath.h b/src/libs/vgeometry/vabstractcubicbezierpath.h index b2d3be9f3..2ac105e48 100644 --- a/src/libs/vgeometry/vabstractcubicbezierpath.h +++ b/src/libs/vgeometry/vabstractcubicbezierpath.h @@ -57,10 +57,10 @@ public: auto operator= (const VAbstractCubicBezierPath &curve) -> VAbstractCubicBezierPath&; ~VAbstractCubicBezierPath() override; - virtual auto CountSubSpl() const -> qint32 =0; - virtual auto CountPoints() const -> qint32 =0; + virtual auto CountSubSpl() const -> vsizetype =0; + virtual auto CountPoints() const -> vsizetype =0; virtual void Clear() =0; - virtual auto GetSpline(qint32 index) const -> VSpline =0; + virtual auto GetSpline(vsizetype index) const -> VSpline =0; virtual auto GetSplinePath() const -> QVector =0; auto GetPath() const -> QPainterPath override; diff --git a/src/libs/vgeometry/vcubicbezierpath.cpp b/src/libs/vgeometry/vcubicbezierpath.cpp index a162430e3..9adf27b2e 100644 --- a/src/libs/vgeometry/vcubicbezierpath.cpp +++ b/src/libs/vgeometry/vcubicbezierpath.cpp @@ -167,13 +167,13 @@ VCubicBezierPath::~VCubicBezierPath() } //--------------------------------------------------------------------------------------------------------------------- -VPointF &VCubicBezierPath::operator[](int indx) +VPointF &VCubicBezierPath::operator[](vsizetype indx) { return d->path[indx]; } //--------------------------------------------------------------------------------------------------------------------- -const VPointF &VCubicBezierPath::at(int indx) const +const VPointF &VCubicBezierPath::at(vsizetype indx) const { return d->path[indx]; } @@ -186,13 +186,13 @@ void VCubicBezierPath::append(const VPointF &point) } //--------------------------------------------------------------------------------------------------------------------- -qint32 VCubicBezierPath::CountSubSpl() const +vsizetype VCubicBezierPath::CountSubSpl() const { return CountSubSpl(d->path.size()); } //--------------------------------------------------------------------------------------------------------------------- -qint32 VCubicBezierPath::CountPoints() const +vsizetype VCubicBezierPath::CountPoints() const { return d->path.size(); } @@ -205,7 +205,7 @@ void VCubicBezierPath::Clear() } //--------------------------------------------------------------------------------------------------------------------- -VSpline VCubicBezierPath::GetSpline(qint32 index) const +VSpline VCubicBezierPath::GetSpline(vsizetype index) const { if (CountPoints() < 4) { @@ -217,7 +217,7 @@ VSpline VCubicBezierPath::GetSpline(qint32 index) const throw VException(tr("This spline does not exist.")); } - const qint32 base = SubSplOffset(index); + const vsizetype base = SubSplOffset(index); // Correction the first control point of each next spline curve except for the first. QPointF p2 = static_cast(d->path.at(base + 1)); @@ -252,7 +252,7 @@ qreal VCubicBezierPath::GetStartAngle() const //--------------------------------------------------------------------------------------------------------------------- qreal VCubicBezierPath::GetEndAngle() const { - const qint32 count = CountSubSpl(); + const vsizetype count = CountSubSpl(); if (count > 0) { return GetSpline(count).GetEndAngle(); @@ -279,7 +279,7 @@ qreal VCubicBezierPath::GetC1Length() const //--------------------------------------------------------------------------------------------------------------------- qreal VCubicBezierPath::GetC2Length() const { - const qint32 count = CountSubSpl(); + const vsizetype count = CountSubSpl(); if (count > 0) { return GetSpline(count).GetC2Length(); @@ -293,7 +293,7 @@ qreal VCubicBezierPath::GetC2Length() const //--------------------------------------------------------------------------------------------------------------------- QVector VCubicBezierPath::GetSplinePath() const { - const int size = CountSubSpl(); + const vsizetype size = CountSubSpl(); QVector splPoints(size+1); for (qint32 i = 1; i <= size; ++i) @@ -326,17 +326,21 @@ QVector VCubicBezierPath::GetCubicPath() const } //--------------------------------------------------------------------------------------------------------------------- -qint32 VCubicBezierPath::CountSubSpl(qint32 size) +vsizetype VCubicBezierPath::CountSubSpl(vsizetype size) { if (size <= 0) { return 0; } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return qFloor(qAbs((size - 4) / 3.0L + 1)); +#else return qFloor(qAbs((size - 4) / 3.0 + 1)); +#endif } //--------------------------------------------------------------------------------------------------------------------- -qint32 VCubicBezierPath::SubSplOffset(qint32 subSplIndex) +vsizetype VCubicBezierPath::SubSplOffset(vsizetype subSplIndex) { if (subSplIndex <= 0) { @@ -347,7 +351,7 @@ qint32 VCubicBezierPath::SubSplOffset(qint32 subSplIndex) } //--------------------------------------------------------------------------------------------------------------------- -qint32 VCubicBezierPath::SubSplPointsCount(qint32 countSubSpl) +vsizetype VCubicBezierPath::SubSplPointsCount(vsizetype countSubSpl) { if (countSubSpl <= 0) { @@ -373,7 +377,7 @@ VPointF VCubicBezierPath::FirstPoint() const //--------------------------------------------------------------------------------------------------------------------- VPointF VCubicBezierPath::LastPoint() const { - const qint32 count = CountSubSpl(); + const vsizetype count = CountSubSpl(); if (count >= 1) { return d->path.at(SubSplOffset(count) + 3);// Take last point of the last real spline diff --git a/src/libs/vgeometry/vcubicbezierpath.h b/src/libs/vgeometry/vcubicbezierpath.h index aa797fa79..5b92d930d 100644 --- a/src/libs/vgeometry/vcubicbezierpath.h +++ b/src/libs/vgeometry/vcubicbezierpath.h @@ -62,16 +62,16 @@ public: VCubicBezierPath &operator=(VCubicBezierPath &&curve) Q_DECL_NOTHROW; #endif - VPointF &operator[](int indx); + VPointF &operator[](vsizetype indx); - const VPointF &at(int indx) const; + const VPointF &at(vsizetype indx) const; void append(const VPointF &point); - virtual qint32 CountSubSpl() const override; - virtual qint32 CountPoints() const override; + virtual vsizetype CountSubSpl() const override; + virtual vsizetype CountPoints() const override; virtual void Clear() override; - virtual VSpline GetSpline(qint32 index) const override; + virtual VSpline GetSpline(vsizetype index) const override; virtual qreal GetStartAngle () const override; virtual qreal GetEndAngle () const override; @@ -81,9 +81,9 @@ public: virtual QVector GetSplinePath() const override; QVector GetCubicPath() const; - static qint32 CountSubSpl(qint32 size); - static qint32 SubSplOffset(qint32 subSplIndex); - static qint32 SubSplPointsCount(qint32 countSubSpl); + static vsizetype CountSubSpl(vsizetype size); + static vsizetype SubSplOffset(vsizetype subSplIndex); + static vsizetype SubSplPointsCount(vsizetype countSubSpl); protected: virtual VPointF FirstPoint() const override; virtual VPointF LastPoint() const override; diff --git a/src/libs/vgeometry/vsplinepath.cpp b/src/libs/vgeometry/vsplinepath.cpp index f13b55f43..2f6ad9198 100644 --- a/src/libs/vgeometry/vsplinepath.cpp +++ b/src/libs/vgeometry/vsplinepath.cpp @@ -216,7 +216,7 @@ void VSplinePath::append(const VSplinePoint &point) * @brief CountSubSpl return count of simple splines. * @return count. */ -qint32 VSplinePath::CountSubSpl() const +vsizetype VSplinePath::CountSubSpl() const { if (d->path.isEmpty()) { @@ -232,7 +232,7 @@ qint32 VSplinePath::CountSubSpl() const * @param index index spline in spline path. * @return spline */ -VSpline VSplinePath::GetSpline(qint32 index) const +VSpline VSplinePath::GetSpline(vsizetype index) const { if (CountPoints()<1) { @@ -337,7 +337,7 @@ VSplinePath &VSplinePath::operator=(VSplinePath &&path) Q_DECL_NOTHROW * @param indx index in list. * @return spline point. */ -VSplinePoint & VSplinePath::operator[](int indx) +VSplinePoint & VSplinePath::operator[](vsizetype indx) { return d->path[indx]; } @@ -348,7 +348,7 @@ VSplinePoint & VSplinePath::operator[](int indx) * @param indx index in list. * @return spline point. */ -const VSplinePoint &VSplinePath::at(int indx) const +const VSplinePoint &VSplinePath::at(vsizetype indx) const { return d->path[indx]; } @@ -409,7 +409,7 @@ VPointF VSplinePath::FirstPoint() const //--------------------------------------------------------------------------------------------------------------------- VPointF VSplinePath::LastPoint() const { - const qint32 count = CountSubSpl(); + const vsizetype count = CountSubSpl(); return count >= 1 ? d->path.at(count).P() :// Take last point of the last real spline VPointF(); } @@ -419,7 +419,7 @@ VPointF VSplinePath::LastPoint() const * @brief CountPoints return count of points. * @return count. */ -qint32 VSplinePath::CountPoints() const +vsizetype VSplinePath::CountPoints() const { return d->path.size(); } diff --git a/src/libs/vgeometry/vsplinepath.h b/src/libs/vgeometry/vsplinepath.h index d87137b2f..7ef1e4be2 100644 --- a/src/libs/vgeometry/vsplinepath.h +++ b/src/libs/vgeometry/vsplinepath.h @@ -64,7 +64,7 @@ public: VSplinePath Move(qreal length, qreal angle, const QString &prefix = QString()) const; virtual ~VSplinePath() override; - VSplinePoint &operator[](int indx); + VSplinePoint &operator[](vsizetype indx); VSplinePath &operator=(const VSplinePath &path); #ifdef Q_COMPILER_RVALUE_REFS VSplinePath(VSplinePath&& splPath) Q_DECL_NOTHROW; @@ -73,10 +73,10 @@ public: void append(const VSplinePoint &point); - virtual qint32 CountSubSpl() const override; - virtual qint32 CountPoints() const override; + virtual vsizetype CountSubSpl() const override; + virtual vsizetype CountPoints() const override; virtual void Clear() override; - virtual VSpline GetSpline(qint32 index) const override; + virtual VSpline GetSpline(vsizetype index) const override; virtual QVector GetSplinePath() const override; QVector GetFSplinePath() const; @@ -90,7 +90,7 @@ public: void UpdatePoint(qint32 indexSpline, const SplinePointPosition &pos, const VSplinePoint &point); VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) const; - const VSplinePoint &at(int indx) const; + const VSplinePoint &at(vsizetype indx) const; virtual QJsonObject ToJson() const override; diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 671051032..6138f9dc8 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -597,7 +597,7 @@ auto AngleBySecondRightAngle(QVector points, QPointF p1, QPointF p2 // Because artificial loop can lead to wrong clipping we must rollback current seam allowance points bool success = false; - const int countBefore = points.size(); + const auto countBefore = points.size(); QVector temp = points; temp.append(VRawSAPoint(bigLine1.p2(), p.CurvePoint(), p.TurnPoint())); temp = VAbstractPiece::RollbackSeamAllowance(temp, edge, &success); @@ -705,7 +705,7 @@ auto CorrectPathDistortion(QVector path) -> QVector return path; } - int prev = -1; + vsizetype prev = -1; for (qint32 i = 0; i < path.size(); ++i) { if (prev == -1) @@ -1159,7 +1159,7 @@ auto VAbstractPiece::SumTrapezoids(const QVector &points) -> qreal { // Calculation a polygon area through the sum of the areas of trapezoids qreal s, res = 0; - const int n = points.size(); + const auto n = points.size(); if(n > 2) { @@ -1564,7 +1564,7 @@ auto VAbstractPiece::RollbackSeamAllowance(QVector points, const QL *success = false; QVector clipped; clipped.reserve(points.count()+1); - for (int i = points.count()-1; i > 0; --i) + for (auto i = points.count()-1; i > 0; --i) { QLineF segment(points.at(i), points.at(i-1)); QPointF crosPoint; @@ -1575,7 +1575,7 @@ auto VAbstractPiece::RollbackSeamAllowance(QVector points, const QL && IsSameDirection(cuttingEdge.p2(), cuttingEdge.p1(), crosPoint)) { clipped.append(VRawSAPoint(crosPoint, points.at(i).CurvePoint(), points.at(i).TurnPoint())); - for (int j=i-1; j>=0; --j) + for (auto j=i-1; j>=0; --j) { clipped.append(points.at(j)); } diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 1254c9981..2c3fc52fc 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -229,8 +229,8 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector &points, b return buf1; } - int prev = -1; - int next = -1; + vsizetype prev = -1; + vsizetype next = -1; QVector buf2; //Remove point on line diff --git a/src/libs/vlayout/vbank.cpp b/src/libs/vlayout/vbank.cpp index 20dfe72b4..bc3b63815 100644 --- a/src/libs/vlayout/vbank.cpp +++ b/src/libs/vlayout/vbank.cpp @@ -80,9 +80,9 @@ void Insert(QMap> &container, uint key, int valKey, qin //--------------------------------------------------------------------------------------------------------------------- template -int CountDetails(const T &container) +vsizetype CountDetails(const T &container) { - int count = 0; + vsizetype count = 0; auto i = container.constBegin(); while (i != container.constEnd()) { @@ -424,19 +424,19 @@ void VBank::SetCaseType(Cases caseType) } //--------------------------------------------------------------------------------------------------------------------- -int VBank::AllDetailsCount() const +vsizetype VBank::AllDetailsCount() const { return CountDetails(unsorted) + CountDetails(big) + CountDetails(middle) + CountDetails(small) + CountDetails(desc); } //--------------------------------------------------------------------------------------------------------------------- -int VBank::LeftToArrange() const +vsizetype VBank::LeftToArrange() const { return CountDetails(big) + CountDetails(middle) + CountDetails(small) + CountDetails(desc); } //--------------------------------------------------------------------------------------------------------------------- -int VBank::FailedToArrange() const +vsizetype VBank::FailedToArrange() const { return CountDetails(unsorted); } diff --git a/src/libs/vlayout/vbank.h b/src/libs/vlayout/vbank.h index 960f46179..3145f6a6c 100644 --- a/src/libs/vlayout/vbank.h +++ b/src/libs/vlayout/vbank.h @@ -77,9 +77,9 @@ public: void Reset(); void SetCaseType(Cases caseType); - int AllDetailsCount() const; - int LeftToArrange() const; - int FailedToArrange() const; + vsizetype AllDetailsCount() const; + vsizetype LeftToArrange() const; + vsizetype FailedToArrange() const; qreal GetBiggestDiagonal() const; diff --git a/src/libs/vlayout/vcontour.cpp b/src/libs/vlayout/vcontour.cpp index e0728841c..1d18a802c 100644 --- a/src/libs/vlayout/vcontour.cpp +++ b/src/libs/vlayout/vcontour.cpp @@ -71,9 +71,9 @@ QVector OptimizeCombining(const QVector &contour, const QPoint QPointF withdrawFirst = ConstLast(contour); bool optimize = false; int count = 0; - int cutIndex = -1; + vsizetype cutIndex = -1; - for (int i = contour.size() - 2; i >= 0; --i) + for (auto i = contour.size() - 2; i >= 0; --i) { if (not VGObject::IsPointOnLineSegment(contour.at(i), withdrawFirst, withdrawEnd, accuracyPointOnLine*2)) { @@ -259,7 +259,7 @@ QVector VContour::UniteWithContour(const VLayoutPiece &detail, int glob } //--------------------------------------------------------------------------------------------------------------------- -int VContour::GlobalEdgesCount() const +vsizetype VContour::GlobalEdgesCount() const { return d->m_emptySheetEdgesCount; } @@ -277,7 +277,7 @@ QLineF VContour::GlobalEdge(int i) const } const QLineF emptyEdge = EmptySheetEdge(); - const qreal nShift = emptyEdge.length()/GlobalEdgesCount(); + const qreal nShift = emptyEdge.length() / static_cast(GlobalEdgesCount()); edge = IsPortrait() ? QLineF(nShift*(i-1) + emptyEdge.x1(), emptyEdge.y1(), nShift*i + emptyEdge.x1(), emptyEdge.y2()) : QLineF(emptyEdge.x1(), nShift*(i-1) + emptyEdge.y1(), @@ -339,7 +339,7 @@ QVector VContour::CutEdge(const QLineF &edge) const QVector VContour::CutEmptySheetEdge() const { QVector points; - const qreal nShift = EmptySheetEdge().length()/GlobalEdgesCount(); + const qreal nShift = EmptySheetEdge().length() / static_cast(GlobalEdgesCount()); for (int i = 1; i <= GlobalEdgesCount()+1; ++i) { QLineF l1 = EmptySheetEdge(); @@ -359,7 +359,7 @@ const QPointF &VContour::at(int i) const void VContour::AppendWhole(QVector &contour, const VLayoutPiece &detail, int detJ) const { int processedEdges = 0; - const int nD = detail.LayoutEdgesCount(); + const auto nD = detail.LayoutEdgesCount(); int j = detJ; contour = OptimizeCombining(contour, detail.LayoutEdge(j).p2()); @@ -385,7 +385,7 @@ void VContour::AppendWhole(QVector &contour, const VLayoutPiece &detail void VContour::InsertDetail(QVector &contour, const VLayoutPiece &detail, int detJ) const { int processedEdges = 0; - const int nD = detail.LayoutEdgesCount(); + const auto nD = detail.LayoutEdgesCount(); int j = detJ; contour = OptimizeCombining(contour, detail.LayoutEdge(j).p2()); diff --git a/src/libs/vlayout/vcontour.h b/src/libs/vlayout/vcontour.h index 58cb1ee65..2c511f860 100644 --- a/src/libs/vlayout/vcontour.h +++ b/src/libs/vlayout/vcontour.h @@ -36,6 +36,7 @@ #include #include "vlayoutdef.h" +#include "../vmisc/defglobal.h" class VContourData; class QPointF; @@ -80,7 +81,7 @@ public: QVector UniteWithContour(const VLayoutPiece &detail, int globalI, int detJ, BestFrom type) const; QLineF EmptySheetEdge() const; - int GlobalEdgesCount() const; + vsizetype GlobalEdgesCount() const; QLineF GlobalEdge(int i) const; QVector CutEdge(const QLineF &edge) const; QVector CutEmptySheetEdge() const; diff --git a/src/libs/vlayout/vcontour_p.h b/src/libs/vlayout/vcontour_p.h index 00f9a243c..2f068cab4 100644 --- a/src/libs/vlayout/vcontour_p.h +++ b/src/libs/vlayout/vcontour_p.h @@ -81,7 +81,7 @@ public: qreal layoutWidth{0}; - int m_emptySheetEdgesCount{0}; + vsizetype m_emptySheetEdgesCount{0}; private: Q_DISABLE_ASSIGN(VContourData) diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp index 68492af0b..557cd6620 100644 --- a/src/libs/vlayout/vlayoutgenerator.cpp +++ b/src/libs/vlayout/vlayoutgenerator.cpp @@ -96,7 +96,7 @@ void VLayoutGenerator::SetCaseType(Cases caseType) //--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction -int VLayoutGenerator::DetailsCount() +vsizetype VLayoutGenerator::DetailsCount() { return bank->AllDetailsCount(); } @@ -296,6 +296,12 @@ LayoutErrors VLayoutGenerator::State() const return state; } +//--------------------------------------------------------------------------------------------------------------------- +vsizetype VLayoutGenerator::PapersCount() const +{ + return papers.size(); +} + //--------------------------------------------------------------------------------------------------------------------- QList VLayoutGenerator::GetPapersItems() const { diff --git a/src/libs/vlayout/vlayoutgenerator.h b/src/libs/vlayout/vlayoutgenerator.h index fc4b16509..9df2f8442 100644 --- a/src/libs/vlayout/vlayoutgenerator.h +++ b/src/libs/vlayout/vlayoutgenerator.h @@ -57,7 +57,7 @@ public: void SetDetails(const QVector &details); void SetLayoutWidth(qreal width); void SetCaseType(Cases caseType); - int DetailsCount(); + vsizetype DetailsCount(); qreal GetPaperHeight() const; void SetPaperHeight(qreal value); @@ -85,7 +85,7 @@ public: LayoutErrors State() const; - int PapersCount() const {return papers.size();} + vsizetype PapersCount() const; Q_REQUIRED_RESULT QList GetPapersItems() const; Q_REQUIRED_RESULT QList GetGlobalContours() const; diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index 6ecf2157b..2f02c672a 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -269,7 +269,7 @@ bool VLayoutPaper::ArrangeDetail(const VLayoutPiece &detail, std::atomic_bool &s } //--------------------------------------------------------------------------------------------------------------------- -int VLayoutPaper::Count() const +vsizetype VLayoutPaper::Count() const { return d->details.count(); } diff --git a/src/libs/vlayout/vlayoutpaper.h b/src/libs/vlayout/vlayoutpaper.h index a1cad1ade..c2e79a24d 100644 --- a/src/libs/vlayout/vlayoutpaper.h +++ b/src/libs/vlayout/vlayoutpaper.h @@ -36,7 +36,7 @@ #include #include -#include "vlayoutdef.h" +#include "../vmisc/defglobal.h" class VBestSquare; class VLayoutPaperData; @@ -93,7 +93,7 @@ public: void SetOriginPaperPortrait(bool portrait); bool ArrangeDetail(const VLayoutPiece &detail, std::atomic_bool &stop); - int Count() const; + vsizetype Count() const; Q_REQUIRED_RESULT QGraphicsRectItem *GetPaperItem(bool autoCropLength, bool autoCropWidth, bool textAsPaths) const; Q_REQUIRED_RESULT QGraphicsPathItem *GetGlobalContour() const; Q_REQUIRED_RESULT QList GetItemDetails(bool textAsPaths) const; diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 611c6e315..190a64387 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -194,7 +194,7 @@ auto PieceLabelText(const QVector &labelShape, const VTextManager &tm) QStringList text; if (labelShape.count() > 2) { - int sourceCount = tm.GetSourceLinesCount(); + auto sourceCount = tm.GetSourceLinesCount(); text.reserve(sourceCount); for (int i = 0; i < sourceCount; ++i) { @@ -1174,15 +1174,15 @@ void VLayoutPiece::Mirror() } //--------------------------------------------------------------------------------------------------------------------- -auto VLayoutPiece::DetailEdgesCount() const -> int +auto VLayoutPiece::DetailEdgesCount() const -> vsizetype { return DetailPath().count(); } //--------------------------------------------------------------------------------------------------------------------- -auto VLayoutPiece::LayoutEdgesCount() const -> int +auto VLayoutPiece::LayoutEdgesCount() const -> vsizetype { - const int count = d->m_layoutAllowance.count(); + const auto count = d->m_layoutAllowance.count(); return count > 2 ? count : 0; } @@ -1768,7 +1768,7 @@ auto VLayoutPiece::Edge(const QVector &path, int i) const -> QLineF return {}; } - int i1, i2; + vsizetype i1, i2; if (i < path.count()) { i1 = i-1; diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index 0ddd29ab8..02c8c4b91 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -161,8 +161,8 @@ public: void Mirror(const QLineF &edge); void Mirror(); - auto DetailEdgesCount() const -> int; - auto LayoutEdgesCount() const -> int; + auto DetailEdgesCount() const -> vsizetype; + auto LayoutEdgesCount() const -> vsizetype; auto LayoutEdge(int i) const -> QLineF; auto LayoutEdgeByPoint(const QPointF &p1) const -> EdgeIndex; diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index 07e748e4c..adb6e2b31 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -210,7 +210,7 @@ auto VPosition::ArrangeDetail(const VPositionData &data, std::atomic_bool *stop, } const VLayoutPiece detail = data.detail; - const int detailEdgesCount = detail.LayoutEdgesCount(); + const auto detailEdgesCount = detail.LayoutEdgesCount(); if (detailEdgesCount < 3 || detail.DetailEdgesCount() < 3) { return bestResult;//Not enough edges diff --git a/src/libs/vlayout/vposter.cpp b/src/libs/vlayout/vposter.cpp index 4f0155b7b..71ff270a8 100644 --- a/src/libs/vlayout/vposter.cpp +++ b/src/libs/vlayout/vposter.cpp @@ -153,7 +153,7 @@ QVector VPoster::Calc(const QSize &imageRect, int page, PageOrientat } //--------------------------------------------------------------------------------------------------------------------- -QVector VPoster::Tile(QGraphicsItem *parent, const PosterData &img, int sheets, +QVector VPoster::Tile(QGraphicsItem *parent, const PosterData &img, vsizetype sheets, const VWatermarkData &watermarkData, const QString &watermarkPath) const { QVector data; @@ -180,7 +180,7 @@ QVector VPoster::Tile(QGraphicsItem *parent, const PosterData & } //--------------------------------------------------------------------------------------------------------------------- -QVector VPoster::Borders(QGraphicsItem *parent, const PosterData &img, int sheets) const +QVector VPoster::Borders(QGraphicsItem *parent, const PosterData &img, vsizetype sheets) const { SCASSERT(parent != nullptr) diff --git a/src/libs/vlayout/vposter.h b/src/libs/vlayout/vposter.h index 8ad8da402..6bfc50020 100644 --- a/src/libs/vlayout/vposter.h +++ b/src/libs/vlayout/vposter.h @@ -69,7 +69,7 @@ public: QVector Calc(const QSize &imageRect, int page, PageOrientation orientation) const; - QVector Tile(QGraphicsItem *parent, const PosterData &img, int sheets, + QVector Tile(QGraphicsItem *parent, const PosterData &img, vsizetype sheets, const VWatermarkData &watermarkData, const QString &watermarkPath) const; private: @@ -89,7 +89,7 @@ private: void Ruler(QVector &data, QGraphicsItem *parent, QRect rec) const; - QVector Borders(QGraphicsItem *parent, const PosterData &img, int sheets) const; + QVector Borders(QGraphicsItem *parent, const PosterData &img, vsizetype sheets) const; QVector TextWatermark(QGraphicsItem *parent, const PosterData &img, const VWatermarkData &watermarkData) const; diff --git a/src/libs/vlayout/vprintlayout.cpp b/src/libs/vlayout/vprintlayout.cpp index 5611b9034..aaeac7acd 100644 --- a/src/libs/vlayout/vprintlayout.cpp +++ b/src/libs/vlayout/vprintlayout.cpp @@ -326,7 +326,7 @@ void VPrintLayout::PrintPages(QPrinter *printer) Qt::RoundCap, Qt::RoundJoin)); painter.setBrush ( QBrush ( Qt::NoBrush ) ); - int count = 0; + vsizetype count = 0; QSharedPointer> poster; QSharedPointer posterazor; @@ -363,7 +363,7 @@ void VPrintLayout::PrintPages(QPrinter *printer) } // Handle the fromPage(), toPage(), supportsMultipleCopies(), and numCopies() values from QPrinter. - int firstPage = printer->fromPage() - 1; + vsizetype firstPage = printer->fromPage() - 1; if (firstPage >= count) { return; @@ -373,13 +373,13 @@ void VPrintLayout::PrintPages(QPrinter *printer) firstPage = 0; } - int lastPage = printer->toPage() - 1; + vsizetype lastPage = printer->toPage() - 1; if (lastPage == -1 || lastPage >= count) { lastPage = count - 1; } - const int numPages = lastPage - firstPage + 1; + const vsizetype numPages = lastPage - firstPage + 1; int copyCount = 1; if (not printer->supportsMultipleCopies()) { @@ -400,7 +400,7 @@ void VPrintLayout::PrintPages(QPrinter *printer) return; } } - int index; + vsizetype index; if (printer->pageOrder() == QPrinter::FirstPageFirst) { index = firstPage + j; @@ -410,7 +410,7 @@ void VPrintLayout::PrintPages(QPrinter *printer) index = lastPage - j; } - int paperIndex = -1; + vsizetype paperIndex = -1; m_isTiled ? paperIndex = static_cast(poster->at(index).index) : paperIndex = index; auto *paper = qgraphicsitem_cast(m_layoutPapers.at(paperIndex)); @@ -610,7 +610,7 @@ auto VPrintLayout::DocName() const -> QString } //--------------------------------------------------------------------------------------------------------------------- -void VPrintLayout::PreparePaper(int index) const +void VPrintLayout::PreparePaper(vsizetype index) const { auto *paper = qgraphicsitem_cast(m_layoutPapers.at(index)); if (paper != nullptr) @@ -635,7 +635,7 @@ void VPrintLayout::PreparePaper(int index) const } //--------------------------------------------------------------------------------------------------------------------- -void VPrintLayout::RestorePaper(int index) const +void VPrintLayout::RestorePaper(vsizetype index) const { auto *paper = qgraphicsitem_cast(m_layoutPapers.at(index)); if (paper != nullptr) diff --git a/src/libs/vlayout/vprintlayout.h b/src/libs/vlayout/vprintlayout.h index 0a650961c..f09421c96 100644 --- a/src/libs/vlayout/vprintlayout.h +++ b/src/libs/vlayout/vprintlayout.h @@ -166,8 +166,8 @@ private: QString DocName() const; - void PreparePaper(int index) const; - void RestorePaper(int index) const; + void PreparePaper(vsizetype index) const; + void RestorePaper(vsizetype index) const; bool IsPagesUniform() const; bool IsPagesFit(QSizeF printPaper) const; diff --git a/src/libs/vlayout/vrawlayout.cpp b/src/libs/vlayout/vrawlayout.cpp index 681fc32e6..0d1970e40 100644 --- a/src/libs/vlayout/vrawlayout.cpp +++ b/src/libs/vlayout/vrawlayout.cpp @@ -114,7 +114,7 @@ bool VRawLayout::WriteFile(QIODevice *ioDevice, const VRawLayoutData &data) dataStream.setVersion(QDataStream::Qt_5_4); // Don't use the << operator for QByteArray. See the note in ReadFile() below. - dataStream.writeRawData(fileHeaderByteArray.constData(), fileHeaderByteArray.size()); + dataStream.writeRawData(fileHeaderByteArray.constData(), static_cast(fileHeaderByteArray.size())); dataStream << fileVersion; dataStream << data; @@ -158,7 +158,7 @@ bool VRawLayout::ReadFile(QIODevice *ioDevice, VRawLayoutData &data) // bytes of the stream will be the size of the array, we might end up attempting to allocate // a large amount of memory if the wrong file type was read. Instead, we'll just read the // same number of bytes that are in the array we are comparing it to. No size was written. - const int len = fileHeaderByteArray.size(); + const int len = static_cast(fileHeaderByteArray.size()); QByteArray actualFileHeaderByteArray( len, '\0' ); dataStream.readRawData( actualFileHeaderByteArray.data(), len ); diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index 15f6208bb..e6d2f3602 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -492,7 +492,7 @@ void VTextManager::SetAllSourceLines(const QVector &lines) * @brief VTextManager::GetSourceLinesCount returns the number of input text lines * @return number of text lines that were added to the list by calling AddLine */ -auto VTextManager::GetSourceLinesCount() const -> int +auto VTextManager::GetSourceLinesCount() const -> vsizetype { return m_liLines.count(); } @@ -503,7 +503,7 @@ auto VTextManager::GetSourceLinesCount() const -> int * @param i index of the requested line * @return reference to the requested TextLine object */ -auto VTextManager::GetSourceLine(int i) const -> const TextLine& +auto VTextManager::GetSourceLine(vsizetype i) const -> const TextLine& { Q_ASSERT(i >= 0); Q_ASSERT(i < m_liLines.count()); @@ -550,7 +550,7 @@ void VTextManager::FitFontSize(qreal fW, qreal fH) int iFS = 0; if (GetSourceLinesCount() > 0) {//division by zero - iFS = 3*qFloor(fH/GetSourceLinesCount())/4; + iFS = 3*qFloor(fH/static_cast(GetSourceLinesCount()))/4; } if (iFS < MIN_FONT_SIZE) @@ -563,7 +563,7 @@ void VTextManager::FitFontSize(qreal fW, qreal fH) int iMaxLen = 0; TextLine maxLine; QFont fnt; - for (int i = 0; i < GetSourceLinesCount(); ++i) + for (vsizetype i = 0; i < GetSourceLinesCount(); ++i) { const TextLine& tl = GetSourceLine(i); fnt = m_font; diff --git a/src/libs/vlayout/vtextmanager.h b/src/libs/vlayout/vtextmanager.h index 47cb75415..36ee0075f 100644 --- a/src/libs/vlayout/vtextmanager.h +++ b/src/libs/vlayout/vtextmanager.h @@ -92,8 +92,8 @@ public: auto GetAllSourceLines() const -> QVector; void SetAllSourceLines(const QVector &lines); - auto GetSourceLinesCount() const -> int; - auto GetSourceLine(int i) const -> const TextLine&; + auto GetSourceLinesCount() const -> vsizetype; + auto GetSourceLine(vsizetype i) const -> const TextLine&; auto MaxLineWidth(int width) const -> int; diff --git a/src/libs/vmisc/compatibility.h b/src/libs/vmisc/compatibility.h index 4aaeaa7c0..5f18c5cd4 100644 --- a/src/libs/vmisc/compatibility.h +++ b/src/libs/vmisc/compatibility.h @@ -205,8 +205,8 @@ inline auto Reverse(const QVector &container) -> QVector return container; } QVector reversed(container.size()); - qint32 j = 0; - for (qint32 i = container.size() - 1; i >= 0; --i) + vsizetype j = 0; + for (vsizetype i = container.size() - 1; i >= 0; --i) { reversed.replace(j, container.at(i)); ++j; diff --git a/src/libs/vmisc/defglobal.h b/src/libs/vmisc/defglobal.h index d2c99ae47..44b7e5939 100644 --- a/src/libs/vmisc/defglobal.h +++ b/src/libs/vmisc/defglobal.h @@ -119,4 +119,10 @@ void qAsConst(const T &&) Q_DECL_EQ_DELETE; #endif // QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) #endif // (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +using vsizetype = qsizetype; +#else +using vsizetype = int; +#endif + #endif // DEFGLOBAL_H diff --git a/src/libs/vmisc/qxtcsvmodel.cpp b/src/libs/vmisc/qxtcsvmodel.cpp index 76d4dc082..720e8e747 100644 --- a/src/libs/vmisc/qxtcsvmodel.cpp +++ b/src/libs/vmisc/qxtcsvmodel.cpp @@ -55,7 +55,7 @@ public: QList csvData; QStringList header; - int maxColumn; + vsizetype maxColumn; QxtCsvModel::QuoteMode quoteMode; private: @@ -117,7 +117,7 @@ int QxtCsvModel::rowCount(const QModelIndex& parent) const { return 0; } - return qxt_d().csvData.count(); + return static_cast(qxt_d().csvData.count()); } /*! @@ -129,7 +129,7 @@ int QxtCsvModel::columnCount(const QModelIndex& parent) const { return 0; } - return qxt_d().maxColumn; + return static_cast(qxt_d().maxColumn); } /*! @@ -325,7 +325,7 @@ void QxtCsvModel::setSource(QIODevice *file, bool withHeader, QChar separator, Q void QxtCsvModel::setHeaderData(const QStringList& data) { qxt_d().header = data; - emit headerDataChanged(Qt::Horizontal, 0, data.count()); + emit headerDataChanged(Qt::Horizontal, 0, static_cast(data.count())); } /*! diff --git a/src/libs/vmisc/vtablesearch.cpp b/src/libs/vmisc/vtablesearch.cpp index 8d01bcf05..2a9ec417d 100644 --- a/src/libs/vmisc/vtablesearch.cpp +++ b/src/libs/vmisc/vtablesearch.cpp @@ -76,7 +76,7 @@ void VTableSearch::Clear() } //--------------------------------------------------------------------------------------------------------------------- -void VTableSearch::ShowNext(int newIndex) +void VTableSearch::ShowNext(vsizetype newIndex) { if (not searchList.isEmpty()) { @@ -210,7 +210,7 @@ void VTableSearch::Find(const QString &term) //--------------------------------------------------------------------------------------------------------------------- void VTableSearch::FindPrevious() { - int newIndex = searchIndex - 1; + vsizetype newIndex = searchIndex - 1; if (newIndex < 0) { @@ -223,7 +223,7 @@ void VTableSearch::FindPrevious() //--------------------------------------------------------------------------------------------------------------------- void VTableSearch::FindNext() { - int newIndex = searchIndex + 1; + vsizetype newIndex = searchIndex + 1; if (newIndex >= searchList.size()) { @@ -256,7 +256,7 @@ void VTableSearch::RemoveRow(int row) } //--------------------------------------------------------------------------------------------------------------------- -void VTableSearch::AddRow(int row) +void VTableSearch::AddRow(vsizetype row) { if (searchIndex < 0 || searchIndex >= searchList.size()) { @@ -367,13 +367,13 @@ auto VTableSearch::IsUseUnicodePreperties() const -> bool } //--------------------------------------------------------------------------------------------------------------------- -auto VTableSearch::MatchIndex() const -> int +auto VTableSearch::MatchIndex() const -> vsizetype { return searchIndex; } //--------------------------------------------------------------------------------------------------------------------- -auto VTableSearch::MatchCount() const -> int +auto VTableSearch::MatchCount() const -> vsizetype { return searchList.size(); } diff --git a/src/libs/vmisc/vtablesearch.h b/src/libs/vmisc/vtablesearch.h index f931e93d1..53187888e 100644 --- a/src/libs/vmisc/vtablesearch.h +++ b/src/libs/vmisc/vtablesearch.h @@ -47,7 +47,7 @@ public: void FindPrevious(); void FindNext(); void RemoveRow(int row); - void AddRow(int row); + void AddRow(vsizetype row); void RefreshList(const QString &term); void SetMatchCase(bool value); @@ -62,8 +62,8 @@ public: void SetUseUnicodePreperties(bool value); auto IsUseUnicodePreperties() const -> bool; - auto MatchIndex() const -> int; - auto MatchCount() const -> int; + auto MatchIndex() const -> vsizetype; + auto MatchCount() const -> vsizetype; auto SearchPlaceholder() const -> QString; @@ -77,7 +77,7 @@ private: Q_DISABLE_COPY_MOVE(VTableSearch) // NOLINT QTableWidget *table; - int searchIndex{-1}; + vsizetype searchIndex{-1}; QList searchList{}; bool m_matchCase{false}; @@ -86,7 +86,7 @@ private: bool m_useUnicodePreperties{false}; void Clear(); - void ShowNext(int newIndex); + void ShowNext(vsizetype newIndex); auto FindTableItems(QString term) -> QList; auto FindCurrentMatchIndex() const -> int; }; diff --git a/src/libs/vobj/vobjengine.cpp b/src/libs/vobj/vobjengine.cpp index 6a8ba4b8f..858af6e7d 100644 --- a/src/libs/vobj/vobjengine.cpp +++ b/src/libs/vobj/vobjengine.cpp @@ -368,7 +368,7 @@ qint64 VObjEngine::Square(const QPolygonF &poly) const QVector x; QVector y; - int n = poly.count(); + vsizetype n = poly.count(); qreal s, res = 0; qint64 sq = 0; diff --git a/src/libs/vpatterndb/vpassmark.h b/src/libs/vpatterndb/vpassmark.h index 709fb82aa..ff3174c29 100644 --- a/src/libs/vpatterndb/vpassmark.h +++ b/src/libs/vpatterndb/vpassmark.h @@ -59,7 +59,7 @@ struct VPiecePassmarkData PassmarkAngleType passmarkAngleType{PassmarkAngleType::Straightforward}; bool isMainPathNode{true}; bool isShowSecondPassmark{true}; - int passmarkIndex{-1}; + vsizetype passmarkIndex{-1}; vidtype id{NULL_ID}; qreal globalPassmarkLength{0}; diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 7b813d244..247767219 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -103,7 +103,7 @@ bool IsPassmarksPossible(const QVector &path) } //--------------------------------------------------------------------------------------------------------------------- -QVector RotatePath(const QVector &path, int index) +QVector RotatePath(const QVector &path, vsizetype index) { if (index < 0 || index >= path.size()) { @@ -257,8 +257,8 @@ QVector VPiece::Passmarks(const VContainer *data) const continue;// skip node } - const int previousIndex = VPiecePath::FindInLoopNotExcludedUp(i, unitedPath); - const int nextIndex = VPiecePath::FindInLoopNotExcludedDown(i, unitedPath); + const vsizetype previousIndex = VPiecePath::FindInLoopNotExcludedUp(i, unitedPath); + const vsizetype nextIndex = VPiecePath::FindInLoopNotExcludedDown(i, unitedPath); passmarks += CreatePassmark(unitedPath, previousIndex, i, nextIndex, data); } @@ -649,7 +649,7 @@ const VGrainlineData &VPiece::GetGrainlineGeometry() const } //--------------------------------------------------------------------------------------------------------------------- -QVector VPiece::SeamAllowancePointsWithRotation(const VContainer *data, int makeFirst) const +QVector VPiece::SeamAllowancePointsWithRotation(const VContainer *data, vsizetype makeFirst) const { SCASSERT(data != nullptr); @@ -881,7 +881,8 @@ QVector VPiece::FilterRecords(QVector records) c } //--------------------------------------------------------------------------------------------------------------------- -QVector VPiece::GetNodeSAPoints(const QVector &path, int index, const VContainer *data) const +QVector VPiece::GetNodeSAPoints(const QVector &path, vsizetype index, + const VContainer *data) const { SCASSERT(data != nullptr) @@ -908,7 +909,7 @@ QVector VPiece::GetNodeSAPoints(const QVector &path, int i } //--------------------------------------------------------------------------------------------------------------------- -bool VPiece::GetPassmarkSAPoint(const QVector &path, int index, const VContainer *data, +bool VPiece::GetPassmarkSAPoint(const QVector &path, vsizetype index, const VContainer *data, VSAPoint &point) const { SCASSERT(data != nullptr) @@ -925,8 +926,9 @@ bool VPiece::GetPassmarkSAPoint(const QVector &path, int index, cons } //--------------------------------------------------------------------------------------------------------------------- -bool VPiece::GetPassmarkPreviousSAPoints(const QVector &path, int index, const VSAPoint &passmarkSAPoint, - const VContainer *data, VSAPoint &point, int passmarkIndex) const +bool VPiece::GetPassmarkPreviousSAPoints(const QVector &path, vsizetype index, + const VSAPoint &passmarkSAPoint, const VContainer *data, VSAPoint &point, + vsizetype passmarkIndex) const { SCASSERT(data != nullptr) @@ -942,7 +944,7 @@ bool VPiece::GetPassmarkPreviousSAPoints(const QVector &path, int in } bool found = false; - int nodeIndex = points.size()-1; + auto nodeIndex = points.size()-1; do { const VSAPoint previous = points.at(nodeIndex); @@ -964,8 +966,8 @@ bool VPiece::GetPassmarkPreviousSAPoints(const QVector &path, int in } //--------------------------------------------------------------------------------------------------------------------- -bool VPiece::GetPassmarkNextSAPoints(const QVector &path, int index, const VSAPoint &passmarkSAPoint, - const VContainer *data, VSAPoint &point, int passmarkIndex) const +bool VPiece::GetPassmarkNextSAPoints(const QVector &path, vsizetype index, const VSAPoint &passmarkSAPoint, + const VContainer *data, VSAPoint &point, vsizetype passmarkIndex) const { SCASSERT(data != nullptr) @@ -1004,7 +1006,7 @@ bool VPiece::GetPassmarkNextSAPoints(const QVector &path, int index, } //--------------------------------------------------------------------------------------------------------------------- -bool VPiece::IsPassmarkVisible(const QVector &path, int passmarkIndex) const +bool VPiece::IsPassmarkVisible(const QVector &path, vsizetype passmarkIndex) const { if (passmarkIndex < 0 || passmarkIndex >= path.size()) { @@ -1044,8 +1046,8 @@ bool VPiece::IsPassmarkVisible(const QVector &path, int passmarkInde } //--------------------------------------------------------------------------------------------------------------------- -VPassmark VPiece::CreatePassmark(const QVector &path, int previousIndex, int passmarkIndex, int nextIndex, - const VContainer *data) const +VPassmark VPiece::CreatePassmark(const QVector &path, vsizetype previousIndex, vsizetype passmarkIndex, + vsizetype nextIndex, const VContainer *data) const { SCASSERT(data != nullptr); diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 156c29042..c12fb857c 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -135,7 +135,7 @@ public: QVector GetUnitedPath(const VContainer *data) const; - QVector SeamAllowancePointsWithRotation(const VContainer *data, int makeFirst) const; + QVector SeamAllowancePointsWithRotation(const VContainer *data, vsizetype makeFirst) const; void SetGradationLabel(const QString &label); auto GetGradationLabel() const -> QString; @@ -153,18 +153,19 @@ private: QVector GetValidRecords() const; QVector FilterRecords(QVector records) const; - QVector GetNodeSAPoints(const QVector &path, int index, const VContainer *data) const; + QVector GetNodeSAPoints(const QVector &path, vsizetype index, const VContainer *data) const; - bool GetPassmarkSAPoint(const QVector &path, int index, const VContainer *data, VSAPoint &point) const; - bool GetPassmarkPreviousSAPoints(const QVector &path, int index, const VSAPoint &passmarkSAPoint, - const VContainer *data, VSAPoint &point, int passmarkIndex) const; - bool GetPassmarkNextSAPoints(const QVector &path, int index, const VSAPoint &passmarkSAPoint, - const VContainer *data, VSAPoint &point, int passmarkIndex) const; + bool GetPassmarkSAPoint(const QVector &path, vsizetype index, const VContainer *data, + VSAPoint &point) const; + bool GetPassmarkPreviousSAPoints(const QVector &path, vsizetype index, const VSAPoint &passmarkSAPoint, + const VContainer *data, VSAPoint &point, vsizetype passmarkIndex) const; + bool GetPassmarkNextSAPoints(const QVector &path, vsizetype index, const VSAPoint &passmarkSAPoint, + const VContainer *data, VSAPoint &point, vsizetype passmarkIndex) const; - bool IsPassmarkVisible(const QVector &path, int passmarkIndex) const; + bool IsPassmarkVisible(const QVector &path, vsizetype passmarkIndex) const; - VPassmark CreatePassmark(const QVector &path, int previousIndex, int passmarkIndex, int nextIndex, - const VContainer *data) const; + VPassmark CreatePassmark(const QVector &path, vsizetype previousIndex, vsizetype passmarkIndex, + vsizetype nextIndex, const VContainer *data) const; static int IsCSAStart(const QVector &records, quint32 id); diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index a1779d89f..ac7b52831 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -300,19 +300,19 @@ void VPiecePath::Clear() } //--------------------------------------------------------------------------------------------------------------------- -qint32 VPiecePath::CountNodes() const +vsizetype VPiecePath::CountNodes() const { return d->m_nodes.size(); } //--------------------------------------------------------------------------------------------------------------------- -VPieceNode &VPiecePath::operator[](int indx) +VPieceNode &VPiecePath::operator[](vsizetype indx) { return d->m_nodes[indx]; } //--------------------------------------------------------------------------------------------------------------------- -const VPieceNode &VPiecePath::at(int indx) const +const VPieceNode &VPiecePath::at(vsizetype indx) const { return d->m_nodes.at(indx); } @@ -591,7 +591,7 @@ QVector VPiecePath::CurvesPainterPath(const VContainer *data) cons } //--------------------------------------------------------------------------------------------------------------------- -VSAPoint VPiecePath::StartSegment(const VContainer *data, const QVector &nodes, int i) +VSAPoint VPiecePath::StartSegment(const VContainer *data, const QVector &nodes, vsizetype i) { if (i < 0 || i > nodes.size()-1) { @@ -615,7 +615,7 @@ VSAPoint VPiecePath::StartSegment(const VContainer *data, const QVector 1) { - const int index = FindInLoopNotExcludedUp(i, nodes); + const vsizetype index = FindInLoopNotExcludedUp(i, nodes); if (index != i && index != -1) { @@ -626,7 +626,7 @@ VSAPoint VPiecePath::StartSegment(const VContainer *data, const QVector &nodes, int i) +VSAPoint VPiecePath::EndSegment(const VContainer *data, const QVector &nodes, vsizetype i) { if (i < 0 || i > nodes.size()-1) { @@ -650,7 +650,7 @@ VSAPoint VPiecePath::EndSegment(const VContainer *data, const QVector 2) { - const int index = FindInLoopNotExcludedDown(i, nodes); + const vsizetype index = FindInLoopNotExcludedDown(i, nodes); if (index != i && index != -1) { @@ -775,7 +775,7 @@ bool VPiecePath::OnEdge(quint32 p1, quint32 p2) const return false; } int i = IndexOfNode(list, p1); - int j1 = 0, j2 = 0; + vsizetype j1 = 0, j2 = 0; if (i == list.size() - 1) { @@ -811,7 +811,7 @@ bool VPiecePath::OnEdge(quint32 p1, quint32 p2) const * @param p2 id second point. * @return edge index or -1 if points don't located on edge */ -int VPiecePath::Edge(quint32 p1, quint32 p2) const +vsizetype VPiecePath::Edge(quint32 p1, quint32 p2) const { if (OnEdge(p1, p2) == false) { @@ -920,7 +920,7 @@ QPointF VPiecePath::NodePreviousPoint(const VContainer *data, int i) const if (d->m_nodes.size() > 1) { - int index = 0; + vsizetype index = 0; if (i == 0) { index = d->m_nodes.size()-1; @@ -1056,14 +1056,14 @@ int VPiecePath::indexOfNode(const QVector &nodes, quint32 id) } //--------------------------------------------------------------------------------------------------------------------- -int VPiecePath::FindInLoopNotExcludedUp(int start, const QVector &nodes) +vsizetype VPiecePath::FindInLoopNotExcludedUp(vsizetype start, const QVector &nodes) { if (start < 0 || start >= nodes.size()) { return -1; } - int i = (start == 0) ? nodes.size()-1 : start-1; + vsizetype i = (start == 0) ? nodes.size()-1 : start-1; if (i < 0 || i >= nodes.size()) { @@ -1092,14 +1092,14 @@ int VPiecePath::FindInLoopNotExcludedUp(int start, const QVector &no } //--------------------------------------------------------------------------------------------------------------------- -int VPiecePath::FindInLoopNotExcludedDown(int start, const QVector &nodes) +vsizetype VPiecePath::FindInLoopNotExcludedDown(vsizetype start, const QVector &nodes) { if (start < 0 || start >= nodes.size()) { return -1; } - int i = (start == nodes.size()-1) ? 0 : start+1; + vsizetype i = (start == nodes.size()-1) ? 0 : start+1; if (i < 0 || i >= nodes.size()) { @@ -1147,7 +1147,7 @@ VSAPoint VPiecePath::PreparePointEkv(const VPieceNode &node, const VContainer *d //--------------------------------------------------------------------------------------------------------------------- QVector VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, const QVector &nodes, - const QSharedPointer &curve, int i, + const QSharedPointer &curve, vsizetype i, bool reverse, qreal width, const QString &piece) { const VSAPoint begin = StartSegment(data, nodes, i); @@ -1245,7 +1245,7 @@ QVector VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, } //--------------------------------------------------------------------------------------------------------------------- -QString VPiecePath::NodeName(const QVector &nodes, int nodeIndex, const VContainer *data) +QString VPiecePath::NodeName(const QVector &nodes, vsizetype nodeIndex, const VContainer *data) { if (not nodes.isEmpty() && (nodeIndex < 0 || nodeIndex >= nodes.size())) { diff --git a/src/libs/vpatterndb/vpiecepath.h b/src/libs/vpatterndb/vpiecepath.h index d2693e472..02656e52a 100644 --- a/src/libs/vpatterndb/vpiecepath.h +++ b/src/libs/vpatterndb/vpiecepath.h @@ -61,10 +61,10 @@ public: void Append(const VPieceNode &node); void Clear(); - qint32 CountNodes() const; + vsizetype CountNodes() const; - VPieceNode & operator[](int indx); - const VPieceNode & at ( int indx ) const; + VPieceNode & operator[](vsizetype indx); + const VPieceNode & at (vsizetype indx ) const; QVector GetNodes() const; void SetNodes(const QVector &nodes); @@ -108,7 +108,7 @@ public: void NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const; bool Contains(quint32 id) const; bool OnEdge(quint32 p1, quint32 p2) const; - int Edge(quint32 p1, quint32 p2) const; + vsizetype Edge(quint32 p1, quint32 p2) const; QVector ListNodePoint() const; @@ -124,20 +124,20 @@ public: static int indexOfNode(const QVector &nodes, quint32 id); - static int FindInLoopNotExcludedUp(int start, const QVector &nodes); - static int FindInLoopNotExcludedDown(int start, const QVector &nodes); + static vsizetype FindInLoopNotExcludedUp(vsizetype start, const QVector &nodes); + static vsizetype FindInLoopNotExcludedDown(vsizetype start, const QVector &nodes); - static VSAPoint StartSegment(const VContainer *data, const QVector &nodes, int i); - static VSAPoint EndSegment(const VContainer *data, const QVector &nodes, int i); + static VSAPoint StartSegment(const VContainer *data, const QVector &nodes, vsizetype i); + static VSAPoint EndSegment(const VContainer *data, const QVector &nodes, vsizetype i); static VSAPoint PreparePointEkv(const VPieceNode &node, const VContainer *data); static QVector CurveSeamAllowanceSegment(const VContainer *data, const QVector &nodes, const QSharedPointer &curve, - int i, bool reverse, qreal width, + vsizetype i, bool reverse, qreal width, const QString &piece = QString()); - static QString NodeName(const QVector &nodes, int nodeIndex, const VContainer *data); + static QString NodeName(const QVector &nodes, vsizetype nodeIndex, const VContainer *data); static QVector NodesToPoints(const VContainer *data, const QVector &nodes, const QString &piece = QString()); diff --git a/src/libs/vpatterndb/vtranslatemeasurements.cpp b/src/libs/vpatterndb/vtranslatemeasurements.cpp index 05e086a99..fedff7b62 100644 --- a/src/libs/vpatterndb/vtranslatemeasurements.cpp +++ b/src/libs/vpatterndb/vtranslatemeasurements.cpp @@ -56,8 +56,8 @@ VTranslateMeasurements::~VTranslateMeasurements() * @param bias hold change of length between translated and origin token string * @return true if was found measurement with same name. */ -bool VTranslateMeasurements::MeasurementsFromUser(QString &newFormula, int position, const QString &token, - int &bias) const +bool VTranslateMeasurements::MeasurementsFromUser(QString &newFormula, vsizetype position, const QString &token, + vsizetype &bias) const { QMap::const_iterator i = measurements.constBegin(); while (i != measurements.constEnd()) diff --git a/src/libs/vpatterndb/vtranslatemeasurements.h b/src/libs/vpatterndb/vtranslatemeasurements.h index 665e5d2f4..3ab83a698 100644 --- a/src/libs/vpatterndb/vtranslatemeasurements.h +++ b/src/libs/vpatterndb/vtranslatemeasurements.h @@ -42,7 +42,7 @@ public: VTranslateMeasurements(); virtual ~VTranslateMeasurements(); - bool MeasurementsFromUser(QString &newFormula, int position, const QString &token, int &bias) const; + bool MeasurementsFromUser(QString &newFormula, vsizetype position, const QString &token, vsizetype &bias) const; QString MFromUser(const QString &measurement) const; QString MToUser(const QString &measurement) const; diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index 51ebff020..c97d95d0b 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -623,8 +623,8 @@ void VTranslateVars::InitSystem(const QString &code, const qmu::QmuTranslation & * @param tokens all tokens * @param numbers all numbers */ -void VTranslateVars::CorrectionsPositions(int position, int bias, QMap &tokens, - QMap &numbers) +void VTranslateVars::CorrectionsPositions(vsizetype position, vsizetype bias, QMap &tokens, + QMap &numbers) { if (bias == 0) { @@ -636,14 +636,14 @@ void VTranslateVars::CorrectionsPositions(int position, int bias, QMap &tokens, - QMap &numbers) const +void VTranslateVars::TranslateVarsFromUser(QString &newFormula, QMap &tokens, + QMap &numbers) const { - QList tKeys = tokens.keys();// Take all tokens positions + QList tKeys = tokens.keys();// Take all tokens positions QList tValues = tokens.values(); - for (int i = 0; i < tKeys.size(); ++i) + for (vsizetype i = 0; i < tKeys.size(); ++i) { - int bias = 0; + vsizetype bias = 0; if (MeasurementsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) { if (bias != 0) @@ -685,13 +685,13 @@ void VTranslateVars::TranslateVarsFromUser(QString &newFormula, QMap &tokens, - QMap &numbers, bool osSeparator) +void VTranslateVars::TranslateNumbersFromUser(QString &newFormula, QMap &tokens, + QMap &numbers, bool osSeparator) { QLocale loc = QLocale(); // User locale if (loc != QLocale::c() && osSeparator) {// User want use Os separator - QList nKeys = numbers.keys();// Positions for all numbers in expression + QList nKeys = numbers.keys();// Positions for all numbers in expression QList nValues = numbers.values(); for (int i = 0; i < nKeys.size(); ++i) { @@ -707,7 +707,7 @@ void VTranslateVars::TranslateNumbersFromUser(QString &newFormula, QMap &tokens, - QMap &numbers) const +void VTranslateVars::TranslateVarsToUser(QString &newFormula, QMap &tokens, + QMap &numbers) const { - QList tKeys = tokens.keys(); + QList tKeys = tokens.keys(); QList tValues = tokens.values(); - for (int i = 0; i < tKeys.size(); ++i) + for (vsizetype i = 0; i < tKeys.size(); ++i) { if (measurements.contains(tValues.at(i))) { newFormula.replace(tKeys.at(i), tValues.at(i).length(), measurements.value(tValues.at(i)) .translate(VAbstractApplication::VApp()->Settings()->GetLocale())); - int bias = tValues.at(i).length() - + auto bias = tValues.at(i).length() - measurements.value(tValues.at(i)) .translate(VAbstractApplication::VApp()->Settings()->GetLocale()).length(); if (bias != 0) @@ -748,7 +748,7 @@ void VTranslateVars::TranslateVarsToUser(QString &newFormula, QMap newFormula.replace(tKeys.at(i), tValues.at(i).length(), functions.value(tValues.at(i)) .translate(VAbstractApplication::VApp()->Settings()->GetLocale())); - int bias = tValues.at(i).length() - + auto bias = tValues.at(i).length() - functions.value(tValues.at(i)) .translate(VAbstractApplication::VApp()->Settings()->GetLocale()).length(); if (bias != 0) @@ -760,7 +760,7 @@ void VTranslateVars::TranslateVarsToUser(QString &newFormula, QMap continue; } - int bias = 0; + vsizetype bias = 0; if (VariablesToUser(newFormula, tKeys.at(i), tValues.at(i), bias)) { if (bias != 0) @@ -780,13 +780,13 @@ void VTranslateVars::TranslateVarsToUser(QString &newFormula, QMap } //--------------------------------------------------------------------------------------------------------------------- -void VTranslateVars::TranslateNumbersToUser(QString &newFormula, QMap &tokens, - QMap &numbers, bool osSeparator) +void VTranslateVars::TranslateNumbersToUser(QString &newFormula, QMap &tokens, + QMap &numbers, bool osSeparator) { QLocale loc = QLocale();// User locale if (loc != QLocale::C && osSeparator) {// User want use Os separator - QList nKeys = numbers.keys();// Positions for all numbers in expression + QList nKeys = numbers.keys();// Positions for all numbers in expression QList nValues = numbers.values(); for (int i = 0; i < nKeys.size(); ++i) { @@ -806,7 +806,7 @@ void VTranslateVars::TranslateNumbersToUser(QString &newFormula, QMap &tokens) +void VTranslateVars::BiasTokens(vsizetype position, vsizetype bias, QMap &tokens) { - QMap newTokens; - QMap::const_iterator i = tokens.constBegin(); + QMap newTokens; + QMap::const_iterator i = tokens.constBegin(); while (i != tokens.constEnd()) { if (i.key()<= position) @@ -854,7 +854,8 @@ void VTranslateVars::BiasTokens(int position, int bias, QMap &toke * @param bias hold change of length between translated and origin token string * @return true if was found variable with same name. */ -auto VTranslateVars::VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const -> bool +auto VTranslateVars::VariablesFromUser(QString &newFormula, vsizetype position, const QString &token, + vsizetype &bias) const -> bool { const QString currentLengthTr = variables.value(currentLength).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); @@ -895,7 +896,8 @@ auto VTranslateVars::VariablesFromUser(QString &newFormula, int position, const * @param bias hold change of length between translated and origin token string * @return true if was found function with same name. */ -auto VTranslateVars::FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const -> bool +auto VTranslateVars::FunctionsFromUser(QString &newFormula, vsizetype position, const QString &token, + vsizetype &bias) const -> bool { QMap::const_iterator i = functions.constBegin(); while (i != functions.constEnd()) @@ -920,7 +922,8 @@ auto VTranslateVars::FunctionsFromUser(QString &newFormula, int position, const * @param bias hold change of length between translated and origin token string * @return true if was found variable with same name. */ -auto VTranslateVars::VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const -> bool +auto VTranslateVars::VariablesToUser(QString &newFormula, vsizetype position, const QString &token, + vsizetype &bias) const -> bool { QMap::const_iterator i = variables.constBegin(); while (i != variables.constEnd()) @@ -951,7 +954,7 @@ auto VTranslateVars::VariablesToUser(QString &newFormula, int position, const QS auto VTranslateVars::InternalVarToUser(const QString &var) const -> QString { QString newVar = var; - int bias = 0; + vsizetype bias = 0; if (VariablesToUser(newVar, 0, var, bias)) { return newVar; @@ -990,7 +993,7 @@ auto VTranslateVars::VarFromUser(const QString &var) const -> QString } QString newVar = var; - int bias = 0; + vsizetype bias = 0; if (MeasurementsFromUser(newVar, 0, var, bias)) { return newVar; @@ -1044,8 +1047,8 @@ auto VTranslateVars::FormulaFromUser(const QString &formula, bool osSeparator) c // Eval formula QScopedPointer cal( new qmu::QmuTokenParser(formula, osSeparator, true, GetTranslatedFunctions())); - QMap tokens = cal->GetTokens();// Tokens (variables, measurements) - QMap numbers = cal->GetNumbers();// All numbers in expression for changing decimal separator + QMap tokens = cal->GetTokens();// Tokens (variables, measurements) + QMap numbers = cal->GetNumbers();// All numbers in expression for changing decimal separator delete cal.take(); QString newFormula = formula;// Local copy for making changes @@ -1087,8 +1090,8 @@ auto VTranslateVars::FormulaToUser(const QString &formula, bool osSeparator) con QString newFormula = formula;// Local copy for making changes - QMap tokens; - QMap numbers; + QMap tokens; + QMap numbers; try { QScopedPointer cal(new qmu::QmuTokenParser(formula, false, false));// Eval formula diff --git a/src/libs/vpatterndb/vtranslatevars.h b/src/libs/vpatterndb/vtranslatevars.h index 8d45c6730..0f47ef44c 100644 --- a/src/libs/vpatterndb/vtranslatevars.h +++ b/src/libs/vpatterndb/vtranslatevars.h @@ -41,9 +41,11 @@ public: explicit VTranslateVars(); ~VTranslateVars() override = default; - auto VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const -> bool; - auto FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const -> bool; - auto VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const -> bool; + auto VariablesFromUser(QString &newFormula, vsizetype position, const QString &token, + vsizetype &bias) const -> bool; + auto FunctionsFromUser(QString &newFormula, vsizetype position, const QString &token, + vsizetype &bias) const -> bool; + auto VariablesToUser(QString &newFormula, vsizetype position, const QString &token, vsizetype &bias) const -> bool; auto InternalVarToUser(const QString &var) const -> QString; @@ -67,7 +69,7 @@ public: auto GetFunctionsDescriptions() const -> QMap; auto GetFunctionsArguments() const -> QMap; - static void BiasTokens(int position, int bias, QMap &tokens); + static void BiasTokens(vsizetype position, vsizetype bias, QMap &tokens); private: // cppcheck-suppress unknownMacro @@ -91,15 +93,18 @@ private: void InitSystem(const QString &code, const qmu::QmuTranslation &name, const qmu::QmuTranslation &author, const qmu::QmuTranslation &book); - static void CorrectionsPositions(int position, int bias, QMap &tokens, QMap &numbers); + static void CorrectionsPositions(vsizetype position, vsizetype bias, QMap &tokens, + QMap &numbers); - void TranslateVarsFromUser(QString &newFormula, QMap &tokens, QMap &numbers) const; - static void TranslateNumbersFromUser(QString &newFormula, QMap &tokens, QMap &numbers, - bool osSeparator); + void TranslateVarsFromUser(QString &newFormula, QMap &tokens, + QMap &numbers) const; + static void TranslateNumbersFromUser(QString &newFormula, QMap &tokens, + QMap &numbers, bool osSeparator); - void TranslateVarsToUser(QString &newFormula, QMap &tokens, QMap &numbers) const; - static void TranslateNumbersToUser(QString &newFormula, QMap &tokens, QMap &numbers, - bool osSeparator); + void TranslateVarsToUser(QString &newFormula, QMap &tokens, + QMap &numbers) const; + static void TranslateNumbersToUser(QString &newFormula, QMap &tokens, + QMap &numbers, bool osSeparator); }; #endif // VTRANSLATEVARS_H diff --git a/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp index 9d40b9f75..57f543b4d 100644 --- a/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp @@ -162,7 +162,7 @@ VPE::VProperty *VPE::VLineColorProperty::clone(bool include_children, VProperty return VProperty::clone(include_children, container ? container : new VLineColorProperty(getName())); } -int VPE::VLineColorProperty::IndexOfColor(const QMap &colors, const QString &color) +vpesizetype VPE::VLineColorProperty::IndexOfColor(const QMap &colors, const QString &color) { QVector indexList; QMap::const_iterator i = colors.constBegin(); diff --git a/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.h b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.h index cc1e42722..f751d01f2 100644 --- a/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.h @@ -90,7 +90,7 @@ public: Q_REQUIRED_RESULT virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const override; - static int IndexOfColor(const QMap &colors, const QString &color); + static vpesizetype IndexOfColor(const QMap &colors, const QString &color); public slots: void currentIndexChanged(int index); diff --git a/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp index 2978feb3d..48ae5b724 100644 --- a/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp @@ -155,7 +155,7 @@ VPE::VProperty *VPE::VLineTypeProperty::clone(bool include_children, VProperty * return VProperty::clone(include_children, container ? container : new VLineTypeProperty(getName())); } -int VPE::VLineTypeProperty::IndexOfStyle(const QMap &styles, const QString &style) +vpesizetype VPE::VLineTypeProperty::IndexOfStyle(const QMap &styles, const QString &style) { QVector indexList; QMap::const_iterator i = styles.constBegin(); diff --git a/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.h b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.h index 2c59b7c4a..d21542a09 100644 --- a/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.h @@ -91,7 +91,7 @@ public: Q_REQUIRED_RESULT virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const override; - static int IndexOfStyle(const QMap &styles, const QString &style); + static vpesizetype IndexOfStyle(const QMap &styles, const QString &style); public slots: void currentIndexChanged(int index); diff --git a/src/libs/vpropertyexplorer/vproperty.cpp b/src/libs/vpropertyexplorer/vproperty.cpp index 14c6e98a4..b74cc5da0 100644 --- a/src/libs/vpropertyexplorer/vproperty.cpp +++ b/src/libs/vpropertyexplorer/vproperty.cpp @@ -249,7 +249,7 @@ VPE::VProperty* VPE::VProperty::getChild(int row) const } //! Gets the number of children -int VPE::VProperty::getRowCount() const +vpesizetype VPE::VProperty::getRowCount() const { return d_ptr->Children.count(); } @@ -282,7 +282,7 @@ void VPE::VProperty::setParent(VProperty* parent) } } -int VPE::VProperty::addChild(VProperty *child) +vpesizetype VPE::VProperty::addChild(VProperty *child) { if (child && child->getParent() != this) { @@ -312,7 +312,7 @@ void VPE::VProperty::removeChild(VProperty* child) } //! Returns the row the child has -int VPE::VProperty::getChildRow(VProperty* child) const +vpesizetype VPE::VProperty::getChildRow(VProperty* child) const { return d_ptr->Children.indexOf(child); } diff --git a/src/libs/vpropertyexplorer/vproperty.h b/src/libs/vpropertyexplorer/vproperty.h index 9b2cafd4e..a4488d549 100644 --- a/src/libs/vpropertyexplorer/vproperty.h +++ b/src/libs/vpropertyexplorer/vproperty.h @@ -152,7 +152,7 @@ public: virtual QString getDescription() const; //! Adds a child to this property - virtual int addChild(VProperty* child); + virtual vpesizetype addChild(VProperty* child); //! Returns a reference to the list of children virtual QList& getChildren(); @@ -164,7 +164,7 @@ public: virtual VProperty* getChild(int row) const; //! Gets the number of children - virtual int getRowCount() const; + virtual vpesizetype getRowCount() const; //! Gets the parent of this property virtual VProperty* getParent() const; @@ -176,7 +176,7 @@ public: virtual void removeChild(VProperty* child); //! Returns the row the child has - virtual int getChildRow(VProperty* child) const; + virtual vpesizetype getChildRow(VProperty* child) const; //! Returns whether the views have to update the parent of this property if it changes virtual bool getUpdateParent() const; diff --git a/src/libs/vpropertyexplorer/vpropertydef.h b/src/libs/vpropertyexplorer/vpropertydef.h new file mode 100644 index 000000000..e27a91351 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertydef.h @@ -0,0 +1,38 @@ +/************************************************************************ + ** + ** @file vpropertydef.h + ** @author Roman Telezhynskyi + ** @date 1 2, 2023 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2023 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ +#ifndef VPROPERTYDEF_H +#define VPROPERTYDEF_H + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +using vpesizetype = qsizetype; +#else +using vpesizetype = int; +#endif + +#endif // VPROPERTYDEF_H diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer.qbs b/src/libs/vpropertyexplorer/vpropertyexplorer.qbs index da96a56b5..f6b569156 100644 --- a/src/libs/vpropertyexplorer/vpropertyexplorer.qbs +++ b/src/libs/vpropertyexplorer/vpropertyexplorer.qbs @@ -7,6 +7,7 @@ VDynamicLib { version: "1.0.0" files: [ "vproperty.cpp", + "vpropertydef.h", "vpropertydelegate.cpp", "vpropertyfactorymanager.cpp", "vpropertyformview.cpp", diff --git a/src/libs/vpropertyexplorer/vpropertymodel.cpp b/src/libs/vpropertyexplorer/vpropertymodel.cpp index e9792dbdf..7d4197275 100644 --- a/src/libs/vpropertyexplorer/vpropertymodel.cpp +++ b/src/libs/vpropertyexplorer/vpropertymodel.cpp @@ -24,6 +24,7 @@ #include "vproperty.h" #include "vpropertyset.h" +#include "vpropertydef.h" #include "vpropertymodel_p.h" @@ -60,8 +61,10 @@ bool VPE::VPropertyModel::addProperty(VProperty* property, const QString& id, co if (emitsignals) { VProperty* tmpParent = getProperty(parentid); - int tmpRow = tmpParent != nullptr ? tmpParent->getRowCount() : d_ptr->Properties->getRootPropertyCount(); - beginInsertRows((tmpParent != nullptr ? getIndexFromProperty(tmpParent) : QModelIndex()), tmpRow, tmpRow); + vpesizetype tmpRow = tmpParent != nullptr ? tmpParent->getRowCount() + : d_ptr->Properties->getRootPropertyCount(); + beginInsertRows((tmpParent != nullptr ? getIndexFromProperty(tmpParent) : QModelIndex()), + static_cast(tmpRow), static_cast(tmpRow)); } d_ptr->Properties->addProperty(property, id, parentid); @@ -139,12 +142,13 @@ QModelIndex VPE::VPropertyModel::parent ( const QModelIndex & index ) const if (parentItem) { VProperty* grandParentItem = parentItem->getParent(); - int parents_row = grandParentItem != nullptr ? grandParentItem->getChildRow(parentItem) - : d_ptr->Properties->getRootProperties().indexOf(parentItem); + vpesizetype parents_row = + grandParentItem != nullptr ? grandParentItem->getChildRow(parentItem) + : d_ptr->Properties->getRootProperties().indexOf(parentItem); if (parents_row >= 0) { - return createIndex(parents_row, 0, parentItem); + return createIndex(static_cast(parents_row), 0, parentItem); } } } @@ -225,21 +229,21 @@ QVariant VPE::VPropertyModel::headerData (int section, Qt::Orientation orientati //! Returns the number of rows -int VPE::VPropertyModel::rowCount ( const QModelIndex & parent ) const +int VPE::VPropertyModel::rowCount( const QModelIndex & parent ) const { if (parent.isValid()) { VProperty* tmpParent = getProperty(parent); if (tmpParent) { - return tmpParent->getRowCount(); + return static_cast(tmpParent->getRowCount()); } } // Return the root property count if (d_ptr->Properties) { - return d_ptr->Properties->getRootPropertyCount(); + return static_cast(d_ptr->Properties->getRootPropertyCount()); } return 0; @@ -282,14 +286,14 @@ QModelIndex VPE::VPropertyModel::getIndexFromProperty(VProperty* property, int c } VProperty* parentItem = property->getParent(); - int row = 0; + vpesizetype row = 0; if (parentItem) { row = parentItem->getChildRow(property); } - return createIndex(row, column, property); + return createIndex(static_cast(row), column, property); } diff --git a/src/libs/vpropertyexplorer/vpropertyset.cpp b/src/libs/vpropertyexplorer/vpropertyset.cpp index c950c1f3a..03985374e 100644 --- a/src/libs/vpropertyexplorer/vpropertyset.cpp +++ b/src/libs/vpropertyexplorer/vpropertyset.cpp @@ -135,7 +135,7 @@ void VPE::VPropertySet::removeProperty(VProperty* prop, bool delete_property) } } -int VPE::VPropertySet::count() const +vpesizetype VPE::VPropertySet::count() const { return d_ptr->Properties.count(); } @@ -197,7 +197,7 @@ VPE::VProperty *VPE::VPropertySet::getRootProperty(int row) const return d_ptr->RootProperties.value(row, nullptr); } -int VPE::VPropertySet::getRootPropertyCount() const +vpesizetype VPE::VPropertySet::getRootPropertyCount() const { return d_ptr->RootProperties.count(); } diff --git a/src/libs/vpropertyexplorer/vpropertyset.h b/src/libs/vpropertyexplorer/vpropertyset.h index e47867f78..e881be71a 100644 --- a/src/libs/vpropertyexplorer/vpropertyset.h +++ b/src/libs/vpropertyexplorer/vpropertyset.h @@ -93,7 +93,7 @@ public: virtual void removeProperty(VProperty* prop, bool delete_property = true); //! Returns the number of properties with in ID that are directly accessable by getProperty() - virtual int count() const; + virtual vpesizetype count() const; //! Clears the set and (optionally) deletes all properties //! \param delete_properties Set this to false, if you don't want the properties to get deleted. @@ -118,7 +118,7 @@ public: VProperty* getRootProperty(int row) const; //! Returns the number of independent properties - int getRootPropertyCount() const; + vpesizetype getRootPropertyCount() const; //! Clones the property set Q_REQUIRED_RESULT VPropertySet* clone() const; diff --git a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp index 7076cddcc..5b0dcd29a 100644 --- a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp @@ -175,7 +175,7 @@ void DialogCubicBezierPath::ShowDialog(bool click) { if (click == false) { - const int size = path.CountPoints(); + const auto size = path.CountPoints(); if (size >= 7) { if (size - VCubicBezierPath::SubSplPointsCount(path.CountSubSpl()) == 0) @@ -320,10 +320,10 @@ QSet DialogCubicBezierPath::AllPathBackboneIds() const } QSet ids; - const qint32 count = VCubicBezierPath::CountSubSpl(points.size());// Count subpaths + const auto count = VCubicBezierPath::CountSubSpl(points.size());// Count subpaths for (qint32 i = 1; i <= count; ++i) { - const qint32 base = VCubicBezierPath::SubSplOffset(i); + const auto base = VCubicBezierPath::SubSplOffset(i); ids.insert(points.at(base));// The first subpath's point ids.insert(points.at(base + 3));// The last subpath's point } diff --git a/src/libs/vtools/dialogs/tools/dialoguniondetails.cpp b/src/libs/vtools/dialogs/tools/dialoguniondetails.cpp index 553be18e1..263ec458d 100644 --- a/src/libs/vtools/dialogs/tools/dialoguniondetails.cpp +++ b/src/libs/vtools/dialogs/tools/dialoguniondetails.cpp @@ -134,7 +134,7 @@ bool DialogUnionDetails::CheckDetail(const quint32 &idDetail) const * @param index index of edge */ void DialogUnionDetails::ChoosedDetail(const quint32 &id, const SceneObject &type, quint32 &idDetail, - int &index) + vsizetype &index) { if (idDetail == NULL_ID) { diff --git a/src/libs/vtools/dialogs/tools/dialoguniondetails.h b/src/libs/vtools/dialogs/tools/dialoguniondetails.h index 5578a2f1b..1c8ff5055 100644 --- a/src/libs/vtools/dialogs/tools/dialoguniondetails.h +++ b/src/libs/vtools/dialogs/tools/dialoguniondetails.h @@ -55,8 +55,8 @@ public: quint32 getD1() const; quint32 getD2() const; - int getIndexD1() const; - int getIndexD2() const; + vsizetype getIndexD1() const; + vsizetype getIndexD2() const; bool RetainPieces() const; public slots: @@ -70,10 +70,10 @@ private: Ui::DialogUnionDetails *ui; /** @brief indexD1 index edge first detail */ - int indexD1; + vsizetype indexD1; /** @brief indexD2 index edge second detail */ - int indexD2; + vsizetype indexD2; /** @brief d1 id first detail */ quint32 d1; @@ -97,7 +97,7 @@ private: bool CheckDetail(const quint32 &idDetail) const; void ChoosedDetail(const quint32 &id, const SceneObject &type, quint32 &idDetail, - int &index); + vsizetype &index); }; //--------------------------------------------------------------------------------------------------------------------- @@ -125,7 +125,7 @@ inline quint32 DialogUnionDetails::getD2() const * @brief getIndexD1 return index edge first detail * @return index */ -inline int DialogUnionDetails::getIndexD1() const +inline vsizetype DialogUnionDetails::getIndexD1() const { return indexD1; } @@ -135,7 +135,7 @@ inline int DialogUnionDetails::getIndexD1() const * @brief getIndexD2 return index edge second detail * @return index */ -inline int DialogUnionDetails::getIndexD2() const +inline vsizetype DialogUnionDetails::getIndexD2() const { return indexD2; } diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index 20a731f9c..5234cc84d 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -1325,8 +1325,8 @@ void UpdateUnitedNodes(const VToolUnionDetailsInitData &initData, qreal dx, qrea const VPiecePath d1REPath = GetPiece1MainPath(initData.doc, initData.id).RemoveEdge(initData.indexD1); const VPiecePath d2REPath = GetPiece2MainPath(initData.doc, initData.id).RemoveEdge(initData.indexD2); - const qint32 countNodeD1 = d1REPath.CountNodes(); - const qint32 countNodeD2 = d2REPath.CountNodes(); + const vsizetype countNodeD1 = d1REPath.CountNodes(); + const vsizetype countNodeD2 = d2REPath.CountNodes(); QVector children = GetNodesChildren(initData.doc, initData.id); if (not children.isEmpty()) @@ -1361,7 +1361,7 @@ void UpdateUnitedNodes(const VToolUnionDetailsInitData &initData, qreal dx, qrea ++i; if (i > indexOfNode) { - const int childrenCount = children.size(); + const vsizetype childrenCount = children.size(); qint32 j = 0; FindIndexJ(pointsD2, d2REPath, initData.indexD2, j); do @@ -1402,7 +1402,7 @@ QVector FixChildren(QVector records, QVector children QVector fixedChildren; while(not records.isEmpty()) { - const qint32 childrenIndex = records.size()-1; + const vsizetype childrenIndex = records.size()-1; if (children.size() > childrenIndex) { fixedChildren.append(children.takeAt(childrenIndex)); @@ -1959,8 +1959,8 @@ QVector > VToolUnionDetails::CalcUnitedPath(const VPiece { QVector > path; - const qint32 countNodeD1 = d1Path.CountNodes(); - const qint32 countNodeD2 = d2Path.CountNodes(); + const vsizetype countNodeD1 = d1Path.CountNodes(); + const vsizetype countNodeD2 = d2Path.CountNodes(); qint32 pointsD2 = 0; //Keeps number points the second detail, that we have already added. qint32 i = 0; diff --git a/src/libs/vtools/visualization/path/vistoolcubicbezierpath.cpp b/src/libs/vtools/visualization/path/vistoolcubicbezierpath.cpp index 15198149d..00a5e63dc 100644 --- a/src/libs/vtools/visualization/path/vistoolcubicbezierpath.cpp +++ b/src/libs/vtools/visualization/path/vistoolcubicbezierpath.cpp @@ -66,12 +66,12 @@ VisToolCubicBezierPath::~VisToolCubicBezierPath() void VisToolCubicBezierPath::RefreshGeometry() { const QVector pathPoints = path.GetCubicPath(); - const int size = pathPoints.size(); + const vsizetype size = pathPoints.size(); if (size > 0) { - const int countSubSpl = VCubicBezierPath::CountSubSpl(size); + const vsizetype countSubSpl = VCubicBezierPath::CountSubSpl(size); - for (int i = 0; i < size; ++i) + for (vsizetype i = 0; i < size; ++i) { VScaledEllipse *point = this->GetPoint(mainPoints, static_cast(i), 1/*zValue*/); DrawPoint(point, static_cast(pathPoints.at(i)), Color(VColor::SupportColor)); @@ -85,7 +85,7 @@ void VisToolCubicBezierPath::RefreshGeometry() } else { - const qint32 last = VCubicBezierPath::SubSplOffset(countSubSpl) + 3; + const vsizetype last = VCubicBezierPath::SubSplOffset(countSubSpl) + 3; Creating(pathPoints, size-1-last); } } @@ -94,10 +94,10 @@ void VisToolCubicBezierPath::RefreshGeometry() { DrawPath(this, path.GetPath(), path.DirectionArrows(), Color(VColor::MainColor), LineStyle(), Qt::RoundCap); - for (qint32 i = 1; i<=countSubSpl; ++i) + for (vsizetype i = 1; i<=countSubSpl; ++i) { - const int preLastPoint = (countSubSpl - 1) * 2; - const int lastPoint = preLastPoint + 1; + const vsizetype preLastPoint = (countSubSpl - 1) * 2; + const vsizetype lastPoint = preLastPoint + 1; const VSpline spl = path.GetSpline(i); @@ -163,16 +163,16 @@ auto VisToolCubicBezierPath::GetLine(quint32 i) -> VScaledLine * } //--------------------------------------------------------------------------------------------------------------------- -void VisToolCubicBezierPath::Creating(const QVector &pathPoints, int pointsLeft) +void VisToolCubicBezierPath::Creating(const QVector &pathPoints, vsizetype pointsLeft) { - const int size = pathPoints.size(); + const vsizetype size = pathPoints.size(); if (pathPoints.isEmpty() || size+1 < pointsLeft) { return; } - int subSplPoints = 0; - const int subSplCount = VCubicBezierPath::CountSubSpl(size); + vsizetype subSplPoints = 0; + const vsizetype subSplCount = VCubicBezierPath::CountSubSpl(size); if (subSplCount >= 1) { subSplPoints = VCubicBezierPath::SubSplPointsCount(subSplCount)-1; @@ -196,7 +196,7 @@ void VisToolCubicBezierPath::Creating(const QVector &pathPoints, int po DrawLine(helpLine1, p1p2, Color(VColor::MainColor), Qt::DashLine); - const int preLastPoint = subSplCount * 2; + const vsizetype preLastPoint = subSplCount * 2; VScaledEllipse *p2Ctrl = this->GetPoint(ctrlPoints, static_cast(preLastPoint)); DrawPoint(p2Ctrl, p2, Qt::green); } @@ -226,7 +226,7 @@ void VisToolCubicBezierPath::Creating(const QVector &pathPoints, int po VSpline spline(p1, p2, ScenePos(), VPointF(ScenePos())); DrawPath(newCurveSegment, spline.GetPath(), Color(VColor::MainColor), Qt::SolidLine, Qt::RoundCap); - const int preLastPoint = subSplCount * 2; + const vsizetype preLastPoint = subSplCount * 2; VScaledEllipse *p2Ctrl = this->GetPoint(ctrlPoints, static_cast(preLastPoint)); DrawPoint(p2Ctrl, p2, Qt::green); break; @@ -252,7 +252,7 @@ void VisToolCubicBezierPath::Creating(const QVector &pathPoints, int po VSpline spline(p1, p2, p3, VPointF(ScenePos())); DrawPath(newCurveSegment, spline.GetPath(), Color(VColor::MainColor), Qt::SolidLine, Qt::RoundCap); - const int preLastPoint = subSplCount * 2; + const vsizetype preLastPoint = subSplCount * 2; VScaledEllipse *p2Ctrl = this->GetPoint(ctrlPoints, static_cast(preLastPoint)); DrawPoint(p2Ctrl, p2, Qt::green); break; @@ -265,10 +265,10 @@ void VisToolCubicBezierPath::Creating(const QVector &pathPoints, int po //--------------------------------------------------------------------------------------------------------------------- void VisToolCubicBezierPath::RefreshToolTip() { - const int size = path.CountPoints(); + const vsizetype size = path.CountPoints(); if (size > 0) { - const int countSubSpl = VCubicBezierPath::CountSubSpl(size); + const vsizetype countSubSpl = VCubicBezierPath::CountSubSpl(size); if (size < 7) { diff --git a/src/libs/vtools/visualization/path/vistoolcubicbezierpath.h b/src/libs/vtools/visualization/path/vistoolcubicbezierpath.h index 98c27cdf5..95556ddfb 100644 --- a/src/libs/vtools/visualization/path/vistoolcubicbezierpath.h +++ b/src/libs/vtools/visualization/path/vistoolcubicbezierpath.h @@ -68,7 +68,7 @@ private: auto GetPoint(QVector &points, quint32 i, qreal z = 0) -> VScaledEllipse *; auto GetLine(quint32 i) -> VScaledLine *; - void Creating(const QVector &pathPoints , int pointsLeft); + void Creating(const QVector &pathPoints , vsizetype pointsLeft); void RefreshToolTip(); }; diff --git a/src/libs/vtools/visualization/path/vistoolsplinepath.cpp b/src/libs/vtools/visualization/path/vistoolsplinepath.cpp index 6a6cb4525..be3821467 100644 --- a/src/libs/vtools/visualization/path/vistoolsplinepath.cpp +++ b/src/libs/vtools/visualization/path/vistoolsplinepath.cpp @@ -78,7 +78,7 @@ void VisToolSplinePath::RefreshGeometry() } const QVector pathPoints = m_path.GetSplinePath(); - const int size = pathPoints.size(); + const auto size = pathPoints.size(); for (int i = 0; i < size; ++i) { @@ -90,10 +90,10 @@ void VisToolSplinePath::RefreshGeometry() { if (size > 1) { - for (qint32 i = 1; i<=m_path.CountSubSpl(); ++i) + for (vsizetype i = 1; i<=m_path.CountSubSpl(); ++i) { - const int preLastPoint = (m_path.CountSubSpl() - 1) * 2; - const int lastPoint = preLastPoint + 1; + const auto preLastPoint = (m_path.CountSubSpl() - 1) * 2; + const auto lastPoint = preLastPoint + 1; VSpline spl = m_path.GetSpline(i); @@ -196,7 +196,8 @@ auto VisToolSplinePath::GetPoint(quint32 i) -> VScaledEllipse * } //--------------------------------------------------------------------------------------------------------------------- -void VisToolSplinePath::DragControlPoint(int lastPoint, int preLastPoint, const QPointF &pSpl, int size) +void VisToolSplinePath::DragControlPoint(vsizetype lastPoint, vsizetype preLastPoint, const QPointF &pSpl, + vsizetype size) { if (not m_ctrlPoints.at(lastPoint)->isVisible()) { @@ -261,7 +262,7 @@ void VisToolSplinePath::DragControlPoint(int lastPoint, int preLastPoint, const } //--------------------------------------------------------------------------------------------------------------------- -void VisToolSplinePath::NewCurveSegment(const VSpline &spline, const QPointF &pSpl, int size) +void VisToolSplinePath::NewCurveSegment(const VSpline &spline, const QPointF &pSpl, vsizetype size) { m_path[size-1].SetAngle2(spline.GetStartAngle(), spline.GetStartAngleFormula()); @@ -277,10 +278,10 @@ void VisToolSplinePath::NewCurveSegment(const VSpline &spline, const QPointF &pS } //--------------------------------------------------------------------------------------------------------------------- -void VisToolSplinePath::Creating(const QPointF &pSpl, int size) +void VisToolSplinePath::Creating(const QPointF &pSpl, vsizetype size) { - int lastPoint = 0; - int preLastPoint = 0; + vsizetype lastPoint = 0; + vsizetype preLastPoint = 0; if (size > 1) { diff --git a/src/libs/vtools/visualization/path/vistoolsplinepath.h b/src/libs/vtools/visualization/path/vistoolsplinepath.h index 1ea846e63..2908485a6 100644 --- a/src/libs/vtools/visualization/path/vistoolsplinepath.h +++ b/src/libs/vtools/visualization/path/vistoolsplinepath.h @@ -83,9 +83,9 @@ private: QPointF m_ctrlPoint{}; auto GetPoint(quint32 i) -> VScaledEllipse*; - void DragControlPoint(int lastPoint, int preLastPoint, const QPointF &pSpl, int size); - void NewCurveSegment(const VSpline &spline, const QPointF &pSpl, int size); - void Creating(const QPointF &pSpl, int size); + void DragControlPoint(vsizetype lastPoint, vsizetype preLastPoint, const QPointF &pSpl, vsizetype size); + void NewCurveSegment(const VSpline &spline, const QPointF &pSpl, vsizetype size); + void Creating(const QPointF &pSpl, vsizetype size); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vwidgets/fancytabbar/fancytabbar.cpp b/src/libs/vwidgets/fancytabbar/fancytabbar.cpp index af213af15..b44dc61dd 100644 --- a/src/libs/vwidgets/fancytabbar/fancytabbar.cpp +++ b/src/libs/vwidgets/fancytabbar/fancytabbar.cpp @@ -378,11 +378,11 @@ QSize FancyTabBar::sizeHint() const if (m_position == Above || m_position == Below) { - return QSize(sh.width() * m_attachedTabs.count(), sh.height()); + return QSize(sh.width() * static_cast(m_attachedTabs.count()), sh.height()); } else { - return QSize(sh.width(), sh.height() * m_attachedTabs.count()); + return QSize(sh.width(), sh.height() * static_cast(m_attachedTabs.count())); } } @@ -394,11 +394,11 @@ QSize FancyTabBar::minimumSizeHint() const if(m_position == Above || m_position == Below) { - return QSize(sh.width() * m_attachedTabs.count(), sh.height()); + return QSize(sh.width() * static_cast(m_attachedTabs.count()), sh.height()); } else { - return QSize(sh.width(), sh.height() * m_attachedTabs.count()); + return QSize(sh.width(), sh.height() * static_cast(m_attachedTabs.count())); } } @@ -411,7 +411,7 @@ QRect FancyTabBar::TabRect(int index) const { if (sh.width() * m_attachedTabs.count() > width()) { - sh.setWidth(width() / m_attachedTabs.count()); + sh.setWidth(width() / static_cast(m_attachedTabs.count())); } return QRect(index * sh.width(), 0, sh.width(), sh.height()); @@ -420,7 +420,7 @@ QRect FancyTabBar::TabRect(int index) const { if (sh.height() * m_attachedTabs.count() > height()) { - sh.setHeight(height() / m_attachedTabs.count()); + sh.setHeight(height() / static_cast(m_attachedTabs.count())); } return QRect(0, index * sh.height(), sh.width(), sh.height()); @@ -629,7 +629,7 @@ void FancyTabBar::SetTabText(int index, const QString &text) } //--------------------------------------------------------------------------------------------------------------------- -int FancyTabBar::Count() const +vsizetype FancyTabBar::Count() const { return m_attachedTabs.count(); } diff --git a/src/libs/vwidgets/fancytabbar/fancytabbar.h b/src/libs/vwidgets/fancytabbar/fancytabbar.h index 2cc44e7d1..b427bf8b3 100644 --- a/src/libs/vwidgets/fancytabbar/fancytabbar.h +++ b/src/libs/vwidgets/fancytabbar/fancytabbar.h @@ -77,7 +77,7 @@ public: QString TabText(int index) const; void SetTabText(int index, const QString &text); - int Count() const; + vsizetype Count() const; QRect TabRect(int index) const; signals: diff --git a/src/libs/vwidgets/qtcolorpicker.cpp b/src/libs/vwidgets/qtcolorpicker.cpp index be52abcd6..1be456be9 100644 --- a/src/libs/vwidgets/qtcolorpicker.cpp +++ b/src/libs/vwidgets/qtcolorpicker.cpp @@ -207,7 +207,7 @@ public: QWidget *parent = nullptr); ~ColorPickerPopup(); - void insertColor(const QColor &col, const QString &text, int index); + void insertColor(const QColor &col, const QString &text, vsizetype index); void exec(); void setExecFlag(); @@ -618,7 +618,7 @@ auto ColorPickerPopup::find(const QColor &col) const -> ColorPickerItem * Adds \a item to the grid. The items are added from top-left to bottom-right. */ -void ColorPickerPopup::insertColor(const QColor &col, const QString &text, int index) +void ColorPickerPopup::insertColor(const QColor &col, const QString &text, vsizetype index) { // Don't add colors that we have already. ColorPickerItem *existingItem = find(col); diff --git a/src/libs/vwidgets/vabstractmainwindow.cpp b/src/libs/vwidgets/vabstractmainwindow.cpp index 99bd8292d..2bbade844 100644 --- a/src/libs/vwidgets/vabstractmainwindow.cpp +++ b/src/libs/vwidgets/vabstractmainwindow.cpp @@ -236,7 +236,7 @@ void VAbstractMainWindow::UpdateRecentFileActions() { const QStringList files = RecentFileList(); const QStringList recentFiles = RecentFiles(files); - const int numRecentFiles = qMin(files.size(), static_cast(MaxRecentFiles)); + const int numRecentFiles = qMin(static_cast(files.size()), static_cast(MaxRecentFiles)); for (int i = 0; i < numRecentFiles; ++i) { diff --git a/src/libs/vwidgets/vcontrolpointspline.cpp b/src/libs/vwidgets/vcontrolpointspline.cpp index 523d0c9e2..48b70fa5b 100644 --- a/src/libs/vwidgets/vcontrolpointspline.cpp +++ b/src/libs/vwidgets/vcontrolpointspline.cpp @@ -53,7 +53,8 @@ #include "scalesceneitems.h" //--------------------------------------------------------------------------------------------------------------------- -VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, QGraphicsItem *parent) +VControlPointSpline::VControlPointSpline(const vsizetype &indexSpline, SplinePointPosition position, + QGraphicsItem *parent) : VScenePoint(parent), controlLine(nullptr), indexSpline(indexSpline), @@ -72,7 +73,7 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP * @param controlPoint control point. * @param parent parent object. */ -VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, +VControlPointSpline::VControlPointSpline(const vsizetype &indexSpline, SplinePointPosition position, const QPointF &controlPoint, bool freeAngle, bool freeLength, QGraphicsItem *parent) : VScenePoint(parent), @@ -276,7 +277,7 @@ void VControlPointSpline::SetCtrlLine(const QPointF &controlPoint, const QPointF * @param controlPoint control point. * @param splinePoint spline point. */ -void VControlPointSpline::RefreshCtrlPoint(const qint32 &indexSpline, SplinePointPosition pos, +void VControlPointSpline::RefreshCtrlPoint(const vsizetype &indexSpline, SplinePointPosition pos, const QPointF &controlPoint, const QPointF &splinePoint, bool freeAngle, bool freeLength) { diff --git a/src/libs/vwidgets/vcontrolpointspline.h b/src/libs/vwidgets/vcontrolpointspline.h index a8b669f0d..c8b9efc08 100644 --- a/src/libs/vwidgets/vcontrolpointspline.h +++ b/src/libs/vwidgets/vcontrolpointspline.h @@ -50,8 +50,8 @@ class VControlPointSpline : public QObject, public VScenePoint { Q_OBJECT // NOLINT public: - VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, QGraphicsItem * parent = nullptr); - VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, const QPointF &controlPoint, + VControlPointSpline(const vsizetype &indexSpline, SplinePointPosition position, QGraphicsItem * parent = nullptr); + VControlPointSpline(const vsizetype &indexSpline, SplinePointPosition position, const QPointF &controlPoint, bool freeAngle, bool freeLength, QGraphicsItem * parent = nullptr); virtual ~VControlPointSpline() =default; @@ -67,7 +67,7 @@ signals: * @param position position point in spline. * @param pos new posotion. */ - void ControlPointChangePosition(const qint32 &indexSpline, SplinePointPosition position, + void ControlPointChangePosition(const vsizetype &indexSpline, SplinePointPosition position, const QPointF &pos); /** * @brief ShowContextMenu emit when need show tool's context menu. @@ -77,7 +77,7 @@ signals: void Released(); void Selected(bool selected); public slots: - void RefreshCtrlPoint(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint, + void RefreshCtrlPoint(const vsizetype &indexSpline, SplinePointPosition pos, const QPointF &controlPoint, const QPointF &splinePoint, bool freeAngle = true, bool freeLength = true); void setEnabledPoint(bool enable); protected: @@ -92,7 +92,7 @@ protected: private: Q_DISABLE_COPY_MOVE(VControlPointSpline) // NOLINT /** @brief indexSpline index spline in list.. */ - qint32 indexSpline; + vsizetype indexSpline; /** @brief position position point in spline. */ SplinePointPosition position; diff --git a/src/libs/vwidgets/vhighlighter.cpp b/src/libs/vwidgets/vhighlighter.cpp index 4ba8cf224..02184cc16 100644 --- a/src/libs/vwidgets/vhighlighter.cpp +++ b/src/libs/vwidgets/vhighlighter.cpp @@ -63,7 +63,7 @@ void VHighlighter::highlightBlock(const QString &text) { QScopedPointer data(new VTextBlockData); - int leftPos = text.indexOf('('); + vsizetype leftPos = text.indexOf('('); while (leftPos != -1) { QScopedPointer info(new ParenthesisInfo); @@ -74,7 +74,7 @@ void VHighlighter::highlightBlock(const QString &text) leftPos = text.indexOf('(', leftPos + 1); } - int rightPos = text.indexOf(')'); + vsizetype rightPos = text.indexOf(')'); while (rightPos != -1) { QScopedPointer info(new ParenthesisInfo); diff --git a/src/libs/vwidgets/vhighlighter.h b/src/libs/vwidgets/vhighlighter.h index 313fd6899..f4b1df5f6 100644 --- a/src/libs/vwidgets/vhighlighter.h +++ b/src/libs/vwidgets/vhighlighter.h @@ -31,13 +31,15 @@ #include #include +#include "../vmisc/defglobal.h" + class QString; class QTextDocument; struct ParenthesisInfo { char character; - int position; + vsizetype position; }; class VTextBlockData final : public QTextBlockUserData diff --git a/src/libs/vwidgets/vlineedit.cpp b/src/libs/vwidgets/vlineedit.cpp index 084479161..58c16eb91 100644 --- a/src/libs/vwidgets/vlineedit.cpp +++ b/src/libs/vwidgets/vlineedit.cpp @@ -75,7 +75,7 @@ QString MultiSelectCompleter::pathFromIndex(const QModelIndex& index) const QString text = static_cast(widget())->text(); - int pos = text.lastIndexOf(','); + vsizetype pos = text.lastIndexOf(','); if (pos >= 0) { path = text.left(pos) + ", " + path; @@ -87,7 +87,7 @@ QString MultiSelectCompleter::pathFromIndex(const QModelIndex& index) const //--------------------------------------------------------------------------------------------------------------------- QStringList MultiSelectCompleter::splitPath( const QString& path ) const { - int pos = path.lastIndexOf(',') + 1; + vsizetype pos = path.lastIndexOf(',') + 1; while (pos < path.length() && path.at(pos) == QLatin1Char(' ')) { @@ -122,7 +122,7 @@ void VLineEdit::focusInEvent(QFocusEvent *e) void VLineEdit::focusOutEvent(QFocusEvent *e) { const int start = selectionStart(); - const int selectionLength = selectedText().length(); + const int selectionLength = static_cast(selectedText().length()); const bool wasTextSelected = hasSelectedText(); QLineEdit::focusOutEvent(e); diff --git a/src/libs/vwidgets/vplaintextedit.cpp b/src/libs/vwidgets/vplaintextedit.cpp index 0e06af2d7..f97e1a40a 100644 --- a/src/libs/vwidgets/vplaintextedit.cpp +++ b/src/libs/vwidgets/vplaintextedit.cpp @@ -86,7 +86,7 @@ void VPlainTextEdit::appendPlainText(const QString &text) else { m_allLines.append(text); - const int diff = m_allLines.size() - maximumBlockCount(); + const vsizetype diff = m_allLines.size() - maximumBlockCount(); if (diff > 0) { m_allLines = m_allLines.mid(diff); @@ -115,12 +115,15 @@ void VPlainTextEdit::MatchParentheses() int curPos = textCursor().position() - textCursor().block().position(); if ((info->position == curPos - 1 || info->position == curPos) && info->character == '(') { - CreateParenthesisSelection(pos + info->position, MatchLeftParenthesis(textCursor().block(), i + 1, 0)); + CreateParenthesisSelection(pos + static_cast(info->position), + MatchLeftParenthesis(textCursor().block(), i + 1, 0)); return; } - else if ((info->position == curPos - 1 || info->position == curPos) && info->character == ')') + + if ((info->position == curPos - 1 || info->position == curPos) && info->character == ')') { - CreateParenthesisSelection(pos + info->position, MatchRightParenthesis(textCursor().block(), i - 1, 0)); + CreateParenthesisSelection(pos + static_cast(info->position), + MatchRightParenthesis(textCursor().block(), i - 1, 0)); return; } } @@ -146,7 +149,7 @@ bool VPlainTextEdit::MatchLeftParenthesis(QTextBlock currentBlock, int i, int nu if (info->character == ')' && numLeftParentheses == 0) { - CreateParenthesisSelection(docPos + info->position); + CreateParenthesisSelection(docPos + static_cast(info->position)); return true; } else @@ -182,7 +185,7 @@ bool VPlainTextEdit::MatchRightParenthesis(QTextBlock currentBlock, int i, int n if (info->character == '(' && numRightParentheses == 0) { - CreateParenthesisSelection(docPos + info->position); + CreateParenthesisSelection(docPos + static_cast(info->position)); return true; } else diff --git a/src/libs/vwidgets/vtextgraphicsitem.cpp b/src/libs/vwidgets/vtextgraphicsitem.cpp index e251a5c58..3f699d99e 100644 --- a/src/libs/vwidgets/vtextgraphicsitem.cpp +++ b/src/libs/vwidgets/vtextgraphicsitem.cpp @@ -335,7 +335,7 @@ void VTextGraphicsItem::UpdateData(VAbstractPattern* pDoc, const VContainer *pat * @brief VTextGraphicsItem::GetTextLines returns the number of lines of text to show * @return number of lines of text */ -int VTextGraphicsItem::GetTextLines() const +vsizetype VTextGraphicsItem::GetTextLines() const { return m_tm.GetSourceLinesCount(); } diff --git a/src/libs/vwidgets/vtextgraphicsitem.h b/src/libs/vwidgets/vtextgraphicsitem.h index 072e83a52..4d6967d3b 100644 --- a/src/libs/vwidgets/vtextgraphicsitem.h +++ b/src/libs/vwidgets/vtextgraphicsitem.h @@ -67,7 +67,7 @@ public: bool IsContained(QRectF rectBB, qreal dRot, qreal& dX, qreal& dY) const; void UpdateData(const QString& qsName, const VPieceLabelData& data, const VContainer *pattern); void UpdateData(VAbstractPattern* pDoc, const VContainer *pattern); - int GetTextLines() const; + vsizetype GetTextLines() const; protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent* pME) override; diff --git a/src/test/TranslationsTest/tst_abstractregexp.cpp b/src/test/TranslationsTest/tst_abstractregexp.cpp index 0bfbd113f..6777af9de 100644 --- a/src/test/TranslationsTest/tst_abstractregexp.cpp +++ b/src/test/TranslationsTest/tst_abstractregexp.cpp @@ -199,7 +199,7 @@ void TST_AbstractRegExp::CallTestForValidCharacters() } const QString translated = m_trMs->VarToUser(originalName); - const int pos = FindFirstNotOf(translated, validNameChars); + const vsizetype pos = FindFirstNotOf(translated, validNameChars); if (pos != -1) { const QString message = QStringLiteral("Translated string '%1' contains invalid character '%2' at " diff --git a/src/test/TranslationsTest/tst_measurementregexp.cpp b/src/test/TranslationsTest/tst_measurementregexp.cpp index 3c29d4004..9c504606a 100644 --- a/src/test/TranslationsTest/tst_measurementregexp.cpp +++ b/src/test/TranslationsTest/tst_measurementregexp.cpp @@ -196,7 +196,7 @@ void TST_MeasurementRegExp::cleanupTestCase() //--------------------------------------------------------------------------------------------------------------------- void TST_MeasurementRegExp::TestCombinations(int systemCounts, const QStringList &locales) const { - const int combinations = systemCounts * locales.size(); + const vsizetype combinations = systemCounts * locales.size(); QDir dir(TranslationsPath()); const QStringList fileNames = dir.entryList(QStringList("measurements_p*_*.qm")); diff --git a/src/test/TranslationsTest/tst_tslocaletranslation.cpp b/src/test/TranslationsTest/tst_tslocaletranslation.cpp index af4f23cdf..3870e12ca 100644 --- a/src/test/TranslationsTest/tst_tslocaletranslation.cpp +++ b/src/test/TranslationsTest/tst_tslocaletranslation.cpp @@ -334,10 +334,10 @@ void TST_TSLocaleTranslation::TestHTMLTags() QRegularExpression::DotMatchesEverythingOption); if (source.contains(openRegex)) { - const int countOpenTag = source.count(openRegex); + const auto countOpenTag = source.count(openRegex); const QRegularExpression closeRegex(QLatin1String("'. ").arg(tag) + diff --git a/src/test/ValentinaTest/tst_qmutokenparser.cpp b/src/test/ValentinaTest/tst_qmutokenparser.cpp index 1dac89e0e..bc759dcb1 100644 --- a/src/test/ValentinaTest/tst_qmutokenparser.cpp +++ b/src/test/ValentinaTest/tst_qmutokenparser.cpp @@ -137,8 +137,8 @@ bool TST_QmuTokenParser::IsSingleFromUser(const QString &formula) return false;// if don't know say no } - QMap tokens; - QMap numbers; + QMap tokens; + QMap numbers; try { diff --git a/src/test/ValentinaTest/tst_readval.cpp b/src/test/ValentinaTest/tst_readval.cpp index 8e1bed040..507dfa99e 100644 --- a/src/test/ValentinaTest/tst_readval.cpp +++ b/src/test/ValentinaTest/tst_readval.cpp @@ -121,7 +121,7 @@ void TST_ReadVal::PrepareVal(qreal val, const QLocale &locale) } //--------------------------------------------------------------------------------------------------------------------- -void TST_ReadVal::PrepareString(const QString &str, const QLocale &locale, qreal val, int count) +void TST_ReadVal::PrepareString(const QString &str, const QLocale &locale, qreal val, vsizetype count) { const QString tag = QStringLiteral("%1. String '%2'").arg(locale.name(), str); QTest::newRow(qUtf8Printable(tag)) << str << count << val << locale; @@ -138,7 +138,7 @@ void TST_ReadVal::TestVal() qreal resVal = 0; QLocale::setDefault(locale); - const int resCount = ReadVal(formula, resVal, locale, locale.decimalPoint(), locale.groupSeparator()); + const vsizetype resCount = ReadVal(formula, resVal, locale, locale.decimalPoint(), locale.groupSeparator()); // cppcheck-suppress unreadVariable QString errorMsg = QStringLiteral("Conversion failed. Locale: '%1'.").arg(locale.name()); diff --git a/src/test/ValentinaTest/tst_readval.h b/src/test/ValentinaTest/tst_readval.h index f80aef25b..69f29e1fd 100644 --- a/src/test/ValentinaTest/tst_readval.h +++ b/src/test/ValentinaTest/tst_readval.h @@ -53,7 +53,7 @@ private: QLocale m_systemLocale; void PrepareVal(qreal val, const QLocale &locale); - void PrepareString(const QString &str, const QLocale &locale, qreal val=0, int count=-1); + void PrepareString(const QString &str, const QLocale &locale, qreal val=0, vsizetype count=-1); void TestVal(); }; diff --git a/src/test/ValentinaTest/tst_vcubicbezierpath.cpp b/src/test/ValentinaTest/tst_vcubicbezierpath.cpp index 8e830c4fb..71e1a8b96 100644 --- a/src/test/ValentinaTest/tst_vcubicbezierpath.cpp +++ b/src/test/ValentinaTest/tst_vcubicbezierpath.cpp @@ -65,7 +65,7 @@ void TST_VCubicBezierPath::TestCountSubSpl() const QFETCH(qint32, points); QFETCH(qint32, countSubSpl); - const qint32 res = VCubicBezierPath::CountSubSpl(points); + const auto res = VCubicBezierPath::CountSubSpl(points); QCOMPARE(res, countSubSpl); } @@ -91,7 +91,7 @@ void TST_VCubicBezierPath::TestSubSplOffset() const QFETCH(qint32, subSplIndex); QFETCH(qint32, offset); - const qint32 res = VCubicBezierPath::SubSplOffset(subSplIndex); + const auto res = VCubicBezierPath::SubSplOffset(subSplIndex); QCOMPARE(res, offset); } @@ -117,6 +117,6 @@ void TST_VCubicBezierPath::TestSubSplPointsCount() const QFETCH(qint32, countSubSpl); QFETCH(qint32, points); - const qint32 res = VCubicBezierPath::SubSplPointsCount(countSubSpl); + const auto res = VCubicBezierPath::SubSplPointsCount(countSubSpl); QCOMPARE(res, points); }