Skip to content

Commit 5b6bf88

Browse files
committed
sort fix
1 parent 59001db commit 5b6bf88

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

QtCellLifeSimulationApp/GenerationSettingsWidget.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -184,28 +184,27 @@ void GenerationSettingsWidget::selecter_setupGenerationAmont()
184184

185185
void GenerationSettingsWidget::selecter_setOptionsList(std::vector<CellFactory::GenerateOption> options)
186186
{
187-
QStringList typesList;
188-
189-
ui.selectTypeIDComboBox->clear();
190-
187+
std::vector<int> typesList;
191188
for (auto option : options) {
192-
QString typeID_Str = QString::number(option.typeID);
193189
bool wasAdded = false;
194190
for (auto type : typesList) {
195-
if (type == typeID_Str)wasAdded = true;
191+
if (type == option.typeID) wasAdded = true;
196192
}
197193
if (!wasAdded) {
198-
typesList.push_back(typeID_Str);
194+
typesList.push_back(option.typeID);
199195
}
200196
}
201-
typesList.sort();
202-
typesList.push_front(ANY_STR);
197+
std::sort(typesList.begin(), typesList.end());
203198

204-
ui.selectTypeIDComboBox->addItems(typesList);
205-
206-
QString currentTypeStr = QString::number(factory->getGenerationType());
207-
bool isContained = typesList.contains(currentTypeStr);
208-
int findindex = !isContained ? 0 : typesList.indexOf(currentTypeStr);
199+
int currentType = factory->getGenerationType();
200+
bool isContained = false;
201+
ui.selectTypeIDComboBox->clear();
202+
ui.selectTypeIDComboBox->addItem(ANY_STR);
203+
for (int item : typesList) {
204+
ui.selectTypeIDComboBox->addItem(QString::number(item));
205+
if (item = currentType)isContained = true;
206+
}
207+
int findindex = !isContained ? 0 : ui.selectTypeIDComboBox->findText(QString::number(currentType));
209208
ui.selectTypeIDComboBox->setCurrentIndex(findindex);
210209
}
211210

0 commit comments

Comments
 (0)