Make the FTB packs a set instead of a list.

This commit is contained in:
Petr Mrázek 2014-07-08 08:42:48 +02:00
parent 19278c853b
commit 9b3ae29a36
2 changed files with 13 additions and 4 deletions

View File

@ -283,9 +283,9 @@ void InstanceList::loadGroupList(QMap<QString, QString> &groupMap)
}
}
QList<FTBRecord> InstanceList::discoverFTBInstances()
QSet<FTBRecord> InstanceList::discoverFTBInstances()
{
QList<FTBRecord> records;
QSet<FTBRecord> records;
QDir dir = QDir(MMC->settings()->get("FTBLauncherDataRoot").toString());
QDir dataDir = QDir(MMC->settings()->get("FTBRoot").toString());
if (!dataDir.exists())
@ -333,7 +333,7 @@ QList<FTBRecord> InstanceList::discoverFTBInstances()
record.logo = attrs.value("logo").toString();
record.mcVersion = attrs.value("mcVersion").toString();
record.description = attrs.value("description").toString();
records.append(record);
records.insert(record);
}
break;
}

View File

@ -36,14 +36,23 @@ struct FTBRecord
QString description;
QString instanceDir;
QString templateDir;
bool operator ==(const FTBRecord other) const
{
return instanceDir == other.instanceDir;
}
};
inline uint qHash(FTBRecord record)
{
return qHash(record.instanceDir);
}
class InstanceList : public QAbstractListModel
{
Q_OBJECT
private:
void loadGroupList(QMap<QString, QString> &groupList);
QList<FTBRecord> discoverFTBInstances();
QSet<FTBRecord> discoverFTBInstances();
void loadFTBInstances(QMap<QString, QString> &groupMap, QList<InstancePtr> & tempList);
private