2013-09-16 04:24:39 +05:30
|
|
|
/* Copyright 2013 MultiMC Contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2013-09-22 07:51:36 +05:30
|
|
|
*
|
2013-09-16 04:24:39 +05:30
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <QUrl>
|
|
|
|
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include "BaseVersionList.h"
|
|
|
|
#include "logic/tasks/Task.h"
|
2013-10-26 23:25:48 +05:30
|
|
|
#include "logic/net/NetJob.h"
|
2013-09-16 04:24:39 +05:30
|
|
|
|
|
|
|
class ForgeVersion;
|
2013-10-06 04:43:40 +05:30
|
|
|
typedef std::shared_ptr<ForgeVersion> ForgeVersionPtr;
|
2013-09-16 04:24:39 +05:30
|
|
|
|
|
|
|
struct ForgeVersion : public BaseVersion
|
|
|
|
{
|
|
|
|
virtual QString descriptor()
|
|
|
|
{
|
|
|
|
return filename;
|
2013-09-22 07:51:36 +05:30
|
|
|
}
|
|
|
|
;
|
2013-09-16 04:24:39 +05:30
|
|
|
virtual QString name()
|
|
|
|
{
|
2013-09-18 03:30:35 +05:30
|
|
|
return "Forge " + jobbuildver;
|
2013-09-22 07:51:36 +05:30
|
|
|
}
|
|
|
|
;
|
2013-09-16 04:24:39 +05:30
|
|
|
virtual QString typeString() const
|
|
|
|
{
|
2013-09-22 07:51:36 +05:30
|
|
|
if (installer_url.isEmpty())
|
2013-09-16 04:24:39 +05:30
|
|
|
return "Universal";
|
|
|
|
else
|
|
|
|
return "Installer";
|
2013-09-22 07:51:36 +05:30
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2013-09-16 04:24:39 +05:30
|
|
|
int m_buildnr = 0;
|
|
|
|
QString universal_url;
|
|
|
|
QString changelog_url;
|
|
|
|
QString installer_url;
|
|
|
|
QString jobbuildver;
|
|
|
|
QString mcver;
|
|
|
|
QString filename;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ForgeVersionList : public BaseVersionList
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
friend class ForgeListLoadTask;
|
2013-09-22 07:51:36 +05:30
|
|
|
|
2013-09-16 04:24:39 +05:30
|
|
|
explicit ForgeVersionList(QObject *parent = 0);
|
2013-09-22 07:51:36 +05:30
|
|
|
|
2013-09-16 04:24:39 +05:30
|
|
|
virtual Task *getLoadTask();
|
|
|
|
virtual bool isLoaded();
|
|
|
|
virtual const BaseVersionPtr at(int i) const;
|
|
|
|
virtual int count() const;
|
|
|
|
virtual void sort();
|
2013-09-22 07:51:36 +05:30
|
|
|
|
2013-09-16 04:24:39 +05:30
|
|
|
virtual BaseVersionPtr getLatestStable() const;
|
2013-09-22 07:51:36 +05:30
|
|
|
|
|
|
|
virtual QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
virtual QVariant headerData(int section, Qt::Orientation orientation,
|
|
|
|
int role) const;
|
|
|
|
virtual int columnCount(const QModelIndex &parent) const;
|
|
|
|
|
2013-09-16 04:24:39 +05:30
|
|
|
protected:
|
2013-09-18 03:30:35 +05:30
|
|
|
QList<BaseVersionPtr> m_vlist;
|
2013-09-22 07:51:36 +05:30
|
|
|
|
2013-09-16 04:24:39 +05:30
|
|
|
bool m_loaded;
|
2013-09-22 07:51:36 +05:30
|
|
|
|
|
|
|
protected
|
|
|
|
slots:
|
|
|
|
virtual void updateListData(QList<BaseVersionPtr> versions);
|
2013-09-16 04:24:39 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
class ForgeListLoadTask : public Task
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2013-09-22 07:51:36 +05:30
|
|
|
|
2013-09-16 04:24:39 +05:30
|
|
|
public:
|
|
|
|
explicit ForgeListLoadTask(ForgeVersionList *vlist);
|
2013-09-22 07:51:36 +05:30
|
|
|
|
2013-09-16 04:24:39 +05:30
|
|
|
virtual void executeTask();
|
2013-09-22 07:51:36 +05:30
|
|
|
|
|
|
|
protected
|
|
|
|
slots:
|
2013-09-16 04:24:39 +05:30
|
|
|
void list_downloaded();
|
2013-10-03 03:05:45 +05:30
|
|
|
void list_failed();
|
2013-09-22 07:51:36 +05:30
|
|
|
|
2013-09-16 04:24:39 +05:30
|
|
|
protected:
|
2013-10-26 23:25:48 +05:30
|
|
|
NetJobPtr listJob;
|
2013-09-16 04:24:39 +05:30
|
|
|
ForgeVersionList *m_list;
|
|
|
|
};
|