From ab868df50eb6f9f3958bdc0a7ab9199dcdf46b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 11 Mar 2017 01:39:45 +0100 Subject: NOISSUE Wonko is the new Meta And then Wonko was the Meta. --- api/logic/meta/Index.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 api/logic/meta/Index.h (limited to 'api/logic/meta/Index.h') diff --git a/api/logic/meta/Index.h b/api/logic/meta/Index.h new file mode 100644 index 00000000..16e95d5a --- /dev/null +++ b/api/logic/meta/Index.h @@ -0,0 +1,72 @@ +/* Copyright 2015-2017 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 + * + * 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 +#include + +#include "BaseEntity.h" + +#include "multimc_logic_export.h" + +class Task; + +namespace Meta +{ +using VersionListPtr = std::shared_ptr; + +class MULTIMC_LOGIC_EXPORT Index : public QAbstractListModel, public BaseEntity +{ + Q_OBJECT +public: + explicit Index(QObject *parent = nullptr); + explicit Index(const QVector &lists, QObject *parent = nullptr); + + enum + { + UidRole = Qt::UserRole, + NameRole, + ListPtrRole + }; + + QVariant data(const QModelIndex &index, int role) const override; + int rowCount(const QModelIndex &parent) const override; + int columnCount(const QModelIndex &parent) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + + std::unique_ptr remoteUpdateTask() override; + std::unique_ptr localUpdateTask() override; + + QString localFilename() const override { return "index.json"; } + QJsonObject serialized() const override; + + // queries + bool hasUid(const QString &uid) const; + VersionListPtr getList(const QString &uid) const; + VersionListPtr getListGuaranteed(const QString &uid) const; + + QVector lists() const { return m_lists; } + +public: // for usage by parsers only + void merge(const BaseEntity::Ptr &other) override; + +private: + QVector m_lists; + QHash m_uids; + + void connectVersionList(const int row, const VersionListPtr &list); +}; +} -- cgit v1.2.3 From 0060b506257b906d40ef53d1e23404dba76afcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 17 Mar 2017 01:48:54 +0100 Subject: NOISSUE simplify. --- api/logic/meta/Index.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'api/logic/meta/Index.h') diff --git a/api/logic/meta/Index.h b/api/logic/meta/Index.h index 16e95d5a..37341656 100644 --- a/api/logic/meta/Index.h +++ b/api/logic/meta/Index.h @@ -27,6 +27,7 @@ class Task; namespace Meta { using VersionListPtr = std::shared_ptr; +using VersionPtr = std::shared_ptr; class MULTIMC_LOGIC_EXPORT Index : public QAbstractListModel, public BaseEntity { @@ -51,17 +52,21 @@ public: std::unique_ptr localUpdateTask() override; QString localFilename() const override { return "index.json"; } - QJsonObject serialized() const override; // queries + VersionListPtr get(const QString &uid); + VersionPtr get(const QString &uid, const QString &version); bool hasUid(const QString &uid) const; + /* VersionListPtr getList(const QString &uid) const; VersionListPtr getListGuaranteed(const QString &uid) const; + */ QVector lists() const { return m_lists; } public: // for usage by parsers only void merge(const BaseEntity::Ptr &other) override; + void parse(const QJsonObject &obj) override; private: QVector m_lists; -- cgit v1.2.3 From e46aba9da584338db8d8a1a8a487bdcc6cf84343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 18 Mar 2017 02:22:36 +0100 Subject: NOISSUE sanitize loading and downloading of metadata files --- api/logic/meta/Index.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'api/logic/meta/Index.h') diff --git a/api/logic/meta/Index.h b/api/logic/meta/Index.h index 37341656..544a8b96 100644 --- a/api/logic/meta/Index.h +++ b/api/logic/meta/Index.h @@ -48,19 +48,12 @@ public: int columnCount(const QModelIndex &parent) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - std::unique_ptr remoteUpdateTask() override; - std::unique_ptr localUpdateTask() override; - QString localFilename() const override { return "index.json"; } // queries VersionListPtr get(const QString &uid); VersionPtr get(const QString &uid, const QString &version); bool hasUid(const QString &uid) const; - /* - VersionListPtr getList(const QString &uid) const; - VersionListPtr getListGuaranteed(const QString &uid) const; - */ QVector lists() const { return m_lists; } -- cgit v1.2.3 From 2660418d58efb33cd3a0ab8ed9d48c359c076905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 19 Mar 2017 02:13:49 +0100 Subject: NOISSUE hack it together enough to get launching back Meta index will now always return valid objects. They just might never load if they don't exist on the server. --- api/logic/meta/Index.h | 1 + 1 file changed, 1 insertion(+) (limited to 'api/logic/meta/Index.h') diff --git a/api/logic/meta/Index.h b/api/logic/meta/Index.h index 544a8b96..9811e152 100644 --- a/api/logic/meta/Index.h +++ b/api/logic/meta/Index.h @@ -68,3 +68,4 @@ private: void connectVersionList(const int row, const VersionListPtr &list); }; } + -- cgit v1.2.3