Add initial sorting function

This commit is contained in:
MrMelon 2022-06-06 18:12:50 +01:00
parent db1c804812
commit 1c60e9b4fc
No known key found for this signature in database
GPG Key ID: B0ADD5395BCDAAB6
2 changed files with 29 additions and 0 deletions

View File

@ -56,6 +56,32 @@ IconList::IconList(const QStringList &builtinPaths, QString path, QObject *paren
emit iconUpdated({});
}
void IconList::sortIconList()
{
qDebug() << "Sorting icon list...";
QVector<MMCIcon> newIcons = QVector<MMCIcon>();
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();
}
void IconList::directoryChanged(const QString &path)
{
QDir new_dir (path);
@ -141,6 +167,8 @@ void IconList::directoryChanged(const QString &path)
emit iconUpdated(key);
}
}
sortIconList();
}
void IconList::fileChanged(const QString &path)

View File

@ -71,6 +71,7 @@ private:
// hide assign op
IconList &operator=(const IconList &) = delete;
void reindex();
void sortIconList();
public slots:
void directoryChanged(const QString &path);