Add initial sorting function
This commit is contained in:
parent
db1c804812
commit
1c60e9b4fc
@ -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)
|
||||
|
@ -71,6 +71,7 @@ private:
|
||||
// hide assign op
|
||||
IconList &operator=(const IconList &) = delete;
|
||||
void reindex();
|
||||
void sortIconList();
|
||||
|
||||
public slots:
|
||||
void directoryChanged(const QString &path);
|
||||
|
Loading…
Reference in New Issue
Block a user