From 902204236031dedffc6047802524c93dcc14fa45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 9 Feb 2014 11:00:34 +0100 Subject: Only load instance list twice. --- logic/lists/MinecraftVersionList.cpp | 10 +++++++--- logic/lists/MinecraftVersionList.h | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'logic') diff --git a/logic/lists/MinecraftVersionList.cpp b/logic/lists/MinecraftVersionList.cpp index 91f86df0..ece31e3d 100644 --- a/logic/lists/MinecraftVersionList.cpp +++ b/logic/lists/MinecraftVersionList.cpp @@ -60,10 +60,15 @@ bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second) return left->timestamp > right->timestamp; } +void MinecraftVersionList::sortInternal() +{ + qSort(m_vlist.begin(), m_vlist.end(), cmpVersions); +} + void MinecraftVersionList::sort() { beginResetModel(); - qSort(m_vlist.begin(), m_vlist.end(), cmpVersions); + sortInternal(); endResetModel(); } @@ -85,9 +90,8 @@ void MinecraftVersionList::updateListData(QList versions) beginResetModel(); m_vlist = versions; m_loaded = true; + sortInternal(); endResetModel(); - // NOW SORT!! - sort(); } inline QDomElement getDomElementByTagName(QDomElement parent, QString tagname) diff --git a/logic/lists/MinecraftVersionList.h b/logic/lists/MinecraftVersionList.h index 82af1009..167f4d11 100644 --- a/logic/lists/MinecraftVersionList.h +++ b/logic/lists/MinecraftVersionList.h @@ -29,6 +29,8 @@ class QNetworkReply; class MinecraftVersionList : public BaseVersionList { Q_OBJECT +private: + void sortInternal(); public: friend class MCVListLoadTask; -- cgit v1.2.3