2021-01-18 08:28:54 +01:00
|
|
|
/* Copyright 2013-2021 MultiMC Contributors
|
2013-10-14 02:59:21 +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
|
|
|
|
|
*
|
|
|
|
|
* 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 <QAbstractListModel>
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
2015-02-09 01:51:14 +01:00
|
|
|
#include "BaseVersionList.h"
|
2024-01-24 18:26:43 +02:00
|
|
|
#include "java/JavaChecker.h"
|
2015-02-09 01:51:14 +01:00
|
|
|
#include "tasks/Task.h"
|
2016-01-02 00:35:54 +01:00
|
|
|
|
|
|
|
|
#include "JavaInstall.h"
|
2013-10-14 02:59:21 +01:00
|
|
|
|
2019-04-07 23:59:04 +02:00
|
|
|
#include "QObjectPtr.h"
|
|
|
|
|
|
2013-10-14 02:59:21 +01:00
|
|
|
class JavaListLoadTask;
|
|
|
|
|
|
2021-07-25 19:11:59 +02:00
|
|
|
class JavaInstallList : public BaseVersionList {
|
2013-10-14 02:59:21 +01:00
|
|
|
Q_OBJECT
|
2017-04-18 16:45:58 +02:00
|
|
|
enum class Status { NotDone, InProgress, Done };
|
2023-08-02 18:35:35 +02:00
|
|
|
|
2013-10-14 02:59:21 +01:00
|
|
|
public:
|
2024-02-09 22:47:39 +02:00
|
|
|
explicit JavaInstallList(QObject* parent = 0, bool onlyManagedVersions = false);
|
2013-10-14 02:59:21 +01:00
|
|
|
|
2026-04-10 02:00:02 +02:00
|
|
|
Task::Ptr getLoadTask(bool forceReload = false) override;
|
2017-03-19 23:58:54 +01:00
|
|
|
bool isLoaded() override;
|
2022-11-01 19:48:26 -03:00
|
|
|
const BaseVersion::Ptr at(int i) const override;
|
2017-03-19 23:58:54 +01:00
|
|
|
int count() const override;
|
|
|
|
|
void sortVersions() override;
|
2013-10-14 02:59:21 +01:00
|
|
|
|
2017-03-19 23:58:54 +01:00
|
|
|
QVariant data(const QModelIndex& index, int role) const override;
|
|
|
|
|
RoleList providesRoles() const override;
|
2013-10-14 02:59:21 +01:00
|
|
|
|
2015-04-28 09:01:37 +02:00
|
|
|
public slots:
|
2022-11-01 19:48:26 -03:00
|
|
|
void updateListData(QList<BaseVersion::Ptr> versions) override;
|
2013-10-14 02:59:21 +01:00
|
|
|
|
|
|
|
|
protected:
|
2017-04-18 16:45:58 +02:00
|
|
|
void load();
|
2021-11-21 23:36:55 +01:00
|
|
|
Task::Ptr getCurrentTask();
|
2013-10-14 02:59:21 +01:00
|
|
|
|
2017-04-18 16:45:58 +02:00
|
|
|
protected:
|
|
|
|
|
Status m_status = Status::NotDone;
|
2024-01-24 18:26:43 +02:00
|
|
|
shared_qobject_ptr<JavaListLoadTask> m_load_task;
|
2022-11-01 19:48:26 -03:00
|
|
|
QList<BaseVersion::Ptr> m_vlist;
|
2024-02-09 22:47:39 +02:00
|
|
|
bool m_only_managed_versions;
|
2013-10-14 02:59:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class JavaListLoadTask : public Task {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2024-02-09 22:47:39 +02:00
|
|
|
explicit JavaListLoadTask(JavaInstallList* vlist, bool onlyManagedVersions = false);
|
2024-01-24 18:26:43 +02:00
|
|
|
virtual ~JavaListLoadTask() = default;
|
2013-10-14 02:59:21 +01:00
|
|
|
|
2024-01-24 18:26:43 +02:00
|
|
|
protected:
|
2017-03-19 23:58:54 +01:00
|
|
|
void executeTask() override;
|
2013-12-11 03:54:39 +00:00
|
|
|
public slots:
|
2017-06-27 04:32:53 +02:00
|
|
|
void javaCheckerFinished();
|
2013-10-14 02:59:21 +01:00
|
|
|
|
|
|
|
|
protected:
|
2024-01-24 18:26:43 +02:00
|
|
|
Task::Ptr m_job;
|
2016-01-02 00:35:54 +01:00
|
|
|
JavaInstallList* m_list;
|
2024-01-24 18:26:43 +02:00
|
|
|
JavaInstall* m_current_recommended;
|
|
|
|
|
QList<JavaChecker::Result> m_results;
|
2024-02-09 22:47:39 +02:00
|
|
|
bool m_only_managed_versions;
|
2013-10-14 02:59:21 +01:00
|
|
|
};
|