2015-02-02 22:25:30 +00:00
|
|
|
/* Copyright 2013-2015 MultiMC Contributors
|
2013-09-15 23:54:39 +01:00
|
|
|
*
|
|
|
|
* 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 03:21:36 +01:00
|
|
|
*
|
2013-09-15 23:54:39 +01:00
|
|
|
* 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 <QUrl>
|
|
|
|
#include <QNetworkReply>
|
2014-04-23 01:27:40 +01:00
|
|
|
|
2014-05-08 20:20:10 +01:00
|
|
|
#include "logic/BaseVersionList.h"
|
2013-09-15 23:54:39 +01:00
|
|
|
#include "logic/tasks/Task.h"
|
2013-10-26 18:55:48 +01:00
|
|
|
#include "logic/net/NetJob.h"
|
2014-04-23 01:27:40 +01:00
|
|
|
#include "logic/forge/ForgeVersion.h"
|
2013-09-15 23:54:39 +01:00
|
|
|
|
|
|
|
class ForgeVersionList : public BaseVersionList
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
friend class ForgeListLoadTask;
|
2013-09-22 03:21:36 +01:00
|
|
|
|
2013-09-15 23:54:39 +01:00
|
|
|
explicit ForgeVersionList(QObject *parent = 0);
|
2013-09-22 03:21:36 +01:00
|
|
|
|
2013-09-15 23:54:39 +01:00
|
|
|
virtual Task *getLoadTask();
|
|
|
|
virtual bool isLoaded();
|
|
|
|
virtual const BaseVersionPtr at(int i) const;
|
|
|
|
virtual int count() const;
|
|
|
|
virtual void sort();
|
2013-09-22 03:21:36 +01:00
|
|
|
|
2013-09-15 23:54:39 +01:00
|
|
|
virtual BaseVersionPtr getLatestStable() const;
|
2013-09-22 03:21:36 +01:00
|
|
|
|
2014-05-04 23:10:59 +01:00
|
|
|
ForgeVersionPtr findVersionByVersionNr(QString version);
|
|
|
|
|
2013-09-22 03:21:36 +01:00
|
|
|
virtual QVariant data(const QModelIndex &index, int role) const;
|
2013-11-04 01:53:05 +00:00
|
|
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
2013-09-22 03:21:36 +01:00
|
|
|
virtual int columnCount(const QModelIndex &parent) const;
|
|
|
|
|
2013-09-15 23:54:39 +01:00
|
|
|
protected:
|
2013-09-17 23:00:35 +01:00
|
|
|
QList<BaseVersionPtr> m_vlist;
|
2013-09-22 03:21:36 +01:00
|
|
|
|
2013-12-22 04:47:10 +00:00
|
|
|
bool m_loaded = false;
|
2013-09-22 03:21:36 +01:00
|
|
|
|
|
|
|
protected
|
|
|
|
slots:
|
|
|
|
virtual void updateListData(QList<BaseVersionPtr> versions);
|
2013-09-15 23:54:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class ForgeListLoadTask : public Task
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2013-09-22 03:21:36 +01:00
|
|
|
|
2013-09-15 23:54:39 +01:00
|
|
|
public:
|
|
|
|
explicit ForgeListLoadTask(ForgeVersionList *vlist);
|
2013-09-22 03:21:36 +01:00
|
|
|
|
2013-09-15 23:54:39 +01:00
|
|
|
virtual void executeTask();
|
2013-09-22 03:21:36 +01:00
|
|
|
|
|
|
|
protected
|
|
|
|
slots:
|
2013-12-22 23:12:03 +00:00
|
|
|
void listDownloaded();
|
|
|
|
void listFailed();
|
|
|
|
void gradleListFailed();
|
2013-09-22 03:21:36 +01:00
|
|
|
|
2013-09-15 23:54:39 +01:00
|
|
|
protected:
|
2013-10-26 18:55:48 +01:00
|
|
|
NetJobPtr listJob;
|
2013-09-15 23:54:39 +01:00
|
|
|
ForgeVersionList *m_list;
|
2013-12-22 23:12:03 +00:00
|
|
|
|
|
|
|
CacheDownloadPtr listDownload;
|
|
|
|
CacheDownloadPtr gradleListDownload;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool parseForgeList(QList<BaseVersionPtr> &out);
|
|
|
|
bool parseForgeGradleList(QList<BaseVersionPtr> &out);
|
2013-09-15 23:54:39 +01:00
|
|
|
};
|