From cf135bcbc51faf1b160cb56b2aba0641ef7d9c99 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Mon, 27 May 2019 16:22:49 -0700 Subject: [PATCH] Fixed compiler warnings. --- common/lc_array.h | 2 +- common/lc_partselectionwidget.cpp | 20 +++++++++++++------- common/lc_partselectionwidget.h | 4 ++-- qt/lc_qpropertiesdialog.cpp | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/common/lc_array.h b/common/lc_array.h index dcc91b86..e572951c 100644 --- a/common/lc_array.h +++ b/common/lc_array.h @@ -111,7 +111,7 @@ public: if (NewSize > mAlloc) AllocGrow(NewSize - mLength); - mLength = NewSize; + mLength = (int)NewSize; } void SetGrow(int Grow) diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index ebb6eb72..fbf8e464 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -175,7 +175,7 @@ void lcPartSelectionListModel::SetModelsCategory() lcModel* Model = Models[ModelIdx]; if (!Model->IncludesModel(ActiveModel)) - mParts.append(QPair(Model->GetPieceInfo(), QPixmap())); + mParts.emplace_back(QPair(Model->GetPieceInfo(), QPixmap())); } endResetModel(); @@ -196,7 +196,7 @@ void lcPartSelectionListModel::SetCurrentModelCategory() ActiveModel->GetPartsList(gDefaultColor, true, PartsList); for (const auto& PartIt : PartsList) - mParts.append(QPair((PieceInfo*)PartIt.first, QPixmap())); + mParts.emplace_back(QPair((PieceInfo*)PartIt.first, QPixmap())); endResetModel(); @@ -246,7 +246,7 @@ int lcPartSelectionListModel::rowCount(const QModelIndex& Parent) const { Q_UNUSED(Parent); - return mParts.size(); + return (int)mParts.size(); } QVariant lcPartSelectionListModel::data(const QModelIndex& Index, int Role) const @@ -304,7 +304,7 @@ void lcPartSelectionListModel::RequestPreview(int InfoIndex) if (!mIconSize || !mParts[InfoIndex].second.isNull()) return; - if (mRequestedPreviews.indexOf(InfoIndex) != -1) + if (std::find(mRequestedPreviews.begin(), mRequestedPreviews.end(), InfoIndex) != mRequestedPreviews.end()) return; PieceInfo* Info = mParts[InfoIndex].first; @@ -313,7 +313,7 @@ void lcPartSelectionListModel::RequestPreview(int InfoIndex) if (Info->mState == LC_PIECEINFO_LOADED) DrawPreview(InfoIndex); else - mRequestedPreviews.append(InfoIndex); + mRequestedPreviews.push_back(InfoIndex); } void lcPartSelectionListModel::PartLoaded(PieceInfo* Info) @@ -322,8 +322,12 @@ void lcPartSelectionListModel::PartLoaded(PieceInfo* Info) { if (mParts[PartIdx].first == Info) { - if (mRequestedPreviews.removeOne(PartIdx)) + auto PreviewIt = std::find(mRequestedPreviews.begin(), mRequestedPreviews.end(), PartIdx); + if (PreviewIt != mRequestedPreviews.end()) + { + mRequestedPreviews.erase(PreviewIt); DrawPreview(PartIdx); + } break; } } @@ -385,7 +389,9 @@ void lcPartSelectionListModel::DrawPreview(int InfoIndex) Context->ClearResources(); #if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)) - emit dataChanged(index(InfoIndex, 0), index(InfoIndex, 0), QVector() << Qt::DecorationRole); + QVector Roles; + Roles.append(Qt::DecorationRole); + emit dataChanged(index(InfoIndex, 0), index(InfoIndex, 0), Roles); #else emit dataChanged(index(InfoIndex, 0), index(InfoIndex, 0)); #endif diff --git a/common/lc_partselectionwidget.h b/common/lc_partselectionwidget.h index f05e739d..5b649cba 100644 --- a/common/lc_partselectionwidget.h +++ b/common/lc_partselectionwidget.h @@ -91,8 +91,8 @@ protected: void DrawPreview(int InfoIndex); lcPartSelectionListView* mListView; - QVector> mParts; - QList mRequestedPreviews; + std::vector> mParts; + std::vector mRequestedPreviews; int mIconSize; bool mColorLocked; int mColorIndex; diff --git a/qt/lc_qpropertiesdialog.cpp b/qt/lc_qpropertiesdialog.cpp index 5de39a7b..0b0dd54d 100644 --- a/qt/lc_qpropertiesdialog.cpp +++ b/qt/lc_qpropertiesdialog.cpp @@ -82,7 +82,7 @@ lcQPropertiesDialog::lcQPropertiesDialog(QWidget *parent, void *data) : std::vector InfoTotals(PartsList.size()); std::vector ColorTotals(NumColors); - size_t Row = 0, Total = 0; + int Row = 0, Total = 0; for (const auto& PartIt : PartsList) {