Sort forge versions right. Do not spam the multimc log with mc server status stuff.

This commit is contained in:
Petr Mrázek 2014-01-16 23:06:07 +01:00
parent d85e820a07
commit 7b96d74d3b
4 changed files with 31 additions and 13 deletions

View File

@ -39,6 +39,15 @@ struct BaseVersion
* the kind of version this is (Stable, Beta, Snapshot, whatever)
*/
virtual QString typeString() const = 0;
virtual bool operator<(BaseVersion &a)
{
return name() < a.name();
};
virtual bool operator>(BaseVersion &a)
{
return name() > a.name();
};
};
typedef std::shared_ptr<BaseVersion> BaseVersionPtr;

View File

@ -404,12 +404,8 @@ void ForgeListLoadTask::listDownloaded()
{
return;
}
qSort(list.begin(), list.end(), [](const BaseVersionPtr & p1, const BaseVersionPtr & p2)
{
// TODO better comparison (takes major/minor/build number into account)
return p1->name() > p2->name();
});
std::sort(list.begin(), list.end(), [](const BaseVersionPtr & l, const BaseVersionPtr & r)
{ return (*l > *r); });
m_list->updateListData(list);

View File

@ -29,25 +29,38 @@ typedef std::shared_ptr<ForgeVersion> ForgeVersionPtr;
struct ForgeVersion : public BaseVersion
{
virtual QString descriptor()
virtual QString descriptor() override
{
return filename;
}
;
virtual QString name()
virtual QString name() override
{
return "Forge " + jobbuildver;
}
;
virtual QString typeString() const
virtual QString typeString() const override
{
if (installer_url.isEmpty())
return "Universal";
else
return "Installer";
}
;
virtual bool operator<(BaseVersion &a) override
{
ForgeVersion *pa = dynamic_cast<ForgeVersion *>(&a);
if(!pa)
return true;
return m_buildnr < pa->m_buildnr;
}
virtual bool operator>(BaseVersion &a) override
{
ForgeVersion *pa = dynamic_cast<ForgeVersion *>(&a);
if(!pa)
return false;
return m_buildnr > pa->m_buildnr;
}
int m_buildnr = 0;
QString universal_url;
QString changelog_url;

View File

@ -31,11 +31,11 @@ void StatusChecker::reloadStatus()
{
if (isLoadingStatus())
{
QLOG_INFO() << "Ignored request to reload status. Currently reloading already.";
// QLOG_INFO() << "Ignored request to reload status. Currently reloading already.";
return;
}
QLOG_INFO() << "Reloading status.";
// QLOG_INFO() << "Reloading status.";
NetJob* job = new NetJob("Status JSON");
job->addNetAction(ByteArrayDownload::make(URLConstants::MOJANG_STATUS_URL));
@ -85,7 +85,7 @@ void StatusChecker::statusDownloadFinished()
if(value.type() == QVariant::Type::String)
{
m_statusEntries.insert(key, value.toString());
QLOG_DEBUG() << "Status JSON object: " << key << m_statusEntries[key];
//QLOG_DEBUG() << "Status JSON object: " << key << m_statusEntries[key];
}
else
{