worldlist now sorted case insensetive
Dieser Commit ist enthalten in:
Ursprung
db50f112b8
Commit
8e655f7c2e
@ -3,7 +3,7 @@
|
||||
*
|
||||
* This file is part of the traintastic source code.
|
||||
*
|
||||
* Copyright (C) 2019-2020,2022-2023 Reinder Feenstra
|
||||
* Copyright (C) 2019-2020,2022-2024 Reinder Feenstra
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -98,7 +98,7 @@ void WorldList::buildIndex()
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(m_items.begin(), m_items.end(), [](const WorldInfo& a, const WorldInfo& b) -> bool { return a > b; });
|
||||
sort();
|
||||
|
||||
//for(auto& model : m_models)
|
||||
// model->setRowCount(m_items.size());
|
||||
@ -138,3 +138,12 @@ bool WorldList::readInfo(const json& world, WorldInfo& info)
|
||||
|
||||
return !info.uuid.is_nil();
|
||||
}
|
||||
|
||||
void WorldList::sort()
|
||||
{
|
||||
std::sort(m_items.begin(), m_items.end(),
|
||||
[](const WorldInfo& a, const WorldInfo& b) -> bool
|
||||
{
|
||||
return a > b;
|
||||
});
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
*
|
||||
* This file is part of the traintastic source code.
|
||||
*
|
||||
* Copyright (C) 2019-2020,2023 Reinder Feenstra
|
||||
* Copyright (C) 2019-2020,2023-2024 Reinder Feenstra
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -45,10 +45,13 @@ class WorldList : public Object, public Table
|
||||
|
||||
bool operator >(const WorldInfo& that) const
|
||||
{
|
||||
return name.compare(that.name) > 0;
|
||||
return strcasecmp(name.c_str(), that.name.c_str()) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
void sort();
|
||||
|
||||
protected:
|
||||
static bool readInfo(const nlohmann::json& world, WorldInfo& info);
|
||||
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren