diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index dc13983e..94568584 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -155,7 +155,7 @@ void lcPartSelectionListModel::SetCategory(int CategoryIndex) mParts.resize(SingleParts.GetSize()); for (int PartIdx = 0; PartIdx < SingleParts.GetSize(); PartIdx++) - mParts[PartIdx] = QPair(SingleParts[PartIdx], QPixmap()); + mParts[PartIdx] = std::pair(SingleParts[PartIdx], QPixmap()); endResetModel(); @@ -178,9 +178,16 @@ void lcPartSelectionListModel::SetModelsCategory() lcModel* Model = Models[ModelIdx]; if (!Model->IncludesModel(ActiveModel)) - mParts.emplace_back(QPair(Model->GetPieceInfo(), QPixmap())); + mParts.emplace_back(std::pair(Model->GetPieceInfo(), QPixmap())); } + auto lcPartSortFunc = [](const std::pair& a, const std::pair& b) + { + return strcmp(a.first->m_strDescription, b.first->m_strDescription) < 0; + }; + + std::sort(mParts.begin(), mParts.end(), lcPartSortFunc); + endResetModel(); SetFilter(mFilter); @@ -208,7 +215,7 @@ void lcPartSelectionListModel::SetPaletteCategory(int SetIndex) mParts.reserve(PartsList.size()); for (PieceInfo* Favorite : PartsList) - mParts.emplace_back(QPair(Favorite, QPixmap())); + mParts.emplace_back(std::pair(Favorite, QPixmap())); endResetModel(); @@ -228,7 +235,14 @@ void lcPartSelectionListModel::SetCurrentModelCategory() ActiveModel->GetPartsList(gDefaultColor, true, PartsList); for (const auto& PartIt : PartsList) - mParts.emplace_back(QPair((PieceInfo*)PartIt.first, QPixmap())); + mParts.emplace_back(std::pair((PieceInfo*)PartIt.first, QPixmap())); + + auto lcPartSortFunc = [](const std::pair& a, const std::pair& b) + { + return strcmp(a.first->m_strDescription, b.first->m_strDescription) < 0; + }; + + std::sort(mParts.begin(), mParts.end(), lcPartSortFunc); endResetModel(); diff --git a/common/lc_partselectionwidget.h b/common/lc_partselectionwidget.h index b5d890f6..fe9c7900 100644 --- a/common/lc_partselectionwidget.h +++ b/common/lc_partselectionwidget.h @@ -121,7 +121,7 @@ protected: void DrawPreview(int InfoIndex); lcPartSelectionListView* mListView; - std::vector> mParts; + std::vector> mParts; std::vector mRequestedPreviews; int mIconSize; bool mColorLocked;