Simplify sorting logic to a single std::sort call
This commit is contained in:
parent
1c60e9b4fc
commit
89d4405563
@ -59,26 +59,9 @@ IconList::IconList(const QStringList &builtinPaths, QString path, QObject *paren
|
|||||||
void IconList::sortIconList()
|
void IconList::sortIconList()
|
||||||
{
|
{
|
||||||
qDebug() << "Sorting icon list...";
|
qDebug() << "Sorting icon list...";
|
||||||
|
std::sort(icons.begin(), icons.end(), [](const MMCIcon& a, const MMCIcon& b) {
|
||||||
QVector<MMCIcon> newIcons = QVector<MMCIcon>();
|
return a.m_key.compare(b.m_key) < 0;
|
||||||
QVectorIterator<MMCIcon> iconIter(icons);
|
});
|
||||||
|
|
||||||
iconLoop:
|
|
||||||
while(iconIter.hasNext())
|
|
||||||
{
|
|
||||||
MMCIcon a = iconIter.next();
|
|
||||||
for(int i=0;i<newIcons.size();i++)
|
|
||||||
{
|
|
||||||
if(a.m_key.compare(newIcons[i].m_key) < 0)
|
|
||||||
{
|
|
||||||
newIcons.insert(i,a);
|
|
||||||
goto iconLoop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newIcons.append(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
icons = newIcons;
|
|
||||||
reindex();
|
reindex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user