NOISSUE reimplement package dependencies
It is now stored as a hashmap There is also a parentUid to limit depsolving by encapsulating by version
This commit is contained in:
parent
77f27a628f
commit
da4ae1bc1e
@ -426,8 +426,6 @@ set(META_SOURCES
|
|||||||
meta/Version.h
|
meta/Version.h
|
||||||
meta/Index.cpp
|
meta/Index.cpp
|
||||||
meta/Index.h
|
meta/Index.h
|
||||||
meta/Reference.cpp
|
|
||||||
meta/Reference.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_unit_test(Index
|
add_unit_test(Index
|
||||||
|
@ -48,20 +48,22 @@ static BaseEntity::Ptr parseIndexInternal(const QJsonObject &obj)
|
|||||||
// Version
|
// Version
|
||||||
static VersionPtr parseCommonVersion(const QString &uid, const QJsonObject &obj)
|
static VersionPtr parseCommonVersion(const QString &uid, const QJsonObject &obj)
|
||||||
{
|
{
|
||||||
const QVector<QJsonObject> requiresRaw = obj.contains("requires") ? requireIsArrayOf<QJsonObject>(obj, "requires") : QVector<QJsonObject>();
|
|
||||||
QVector<Reference> requires;
|
|
||||||
requires.reserve(requiresRaw.size());
|
|
||||||
std::transform(requiresRaw.begin(), requiresRaw.end(), std::back_inserter(requires), [](const QJsonObject &rObj)
|
|
||||||
{
|
|
||||||
Reference ref(requireString(rObj, "uid"));
|
|
||||||
ref.setVersion(ensureString(rObj, "version", QString()));
|
|
||||||
return ref;
|
|
||||||
});
|
|
||||||
|
|
||||||
VersionPtr version = std::make_shared<Version>(uid, requireString(obj, "version"));
|
VersionPtr version = std::make_shared<Version>(uid, requireString(obj, "version"));
|
||||||
version->setTime(QDateTime::fromString(requireString(obj, "releaseTime"), Qt::ISODate).toMSecsSinceEpoch() / 1000);
|
version->setTime(QDateTime::fromString(requireString(obj, "releaseTime"), Qt::ISODate).toMSecsSinceEpoch() / 1000);
|
||||||
version->setType(ensureString(obj, "type", QString()));
|
version->setType(ensureString(obj, "type", QString()));
|
||||||
version->setRequires(requires);
|
version->setParentUid(ensureString(obj, "parentUid", QString()));
|
||||||
|
if(obj.contains("requires"))
|
||||||
|
{
|
||||||
|
QHash<QString, QString> requires;
|
||||||
|
auto reqobj = requireObject(obj, "requires");
|
||||||
|
auto iter = reqobj.begin();
|
||||||
|
while(iter != reqobj.end())
|
||||||
|
{
|
||||||
|
requires[iter.key()] = requireString(iter.value());
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
version->setRequires(requires);
|
||||||
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +92,7 @@ static BaseEntity::Ptr parseVersionListInternal(const QJsonObject &obj)
|
|||||||
|
|
||||||
VersionListPtr list = std::make_shared<VersionList>(uid);
|
VersionListPtr list = std::make_shared<VersionList>(uid);
|
||||||
list->setName(ensureString(obj, "name", QString()));
|
list->setName(ensureString(obj, "name", QString()));
|
||||||
|
list->setParentUid(ensureString(obj, "parentUid", QString()));
|
||||||
list->setVersions(versions);
|
list->setVersions(versions);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
/* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Reference.h"
|
|
||||||
|
|
||||||
namespace Meta
|
|
||||||
{
|
|
||||||
Reference::Reference(const QString &uid)
|
|
||||||
: m_uid(uid)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Reference::uid() const
|
|
||||||
{
|
|
||||||
return m_uid;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Reference::version() const
|
|
||||||
{
|
|
||||||
return m_version;
|
|
||||||
}
|
|
||||||
void Reference::setVersion(const QString &version)
|
|
||||||
{
|
|
||||||
m_version = version;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Reference::operator==(const Reference &other) const
|
|
||||||
{
|
|
||||||
return m_uid == other.m_uid && m_version == other.m_version;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Reference::operator!=(const Reference &other) const
|
|
||||||
{
|
|
||||||
return m_uid != other.m_uid || m_version != other.m_version;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/* 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 <QString>
|
|
||||||
#include <QMetaType>
|
|
||||||
|
|
||||||
#include "multimc_logic_export.h"
|
|
||||||
|
|
||||||
namespace Meta
|
|
||||||
{
|
|
||||||
class MULTIMC_LOGIC_EXPORT Reference
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Reference() {}
|
|
||||||
explicit Reference(const QString &uid);
|
|
||||||
|
|
||||||
QString uid() const;
|
|
||||||
|
|
||||||
QString version() const;
|
|
||||||
void setVersion(const QString &version);
|
|
||||||
|
|
||||||
bool operator==(const Reference &other) const;
|
|
||||||
bool operator!=(const Reference &other) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_uid;
|
|
||||||
QString m_version;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Q_DECLARE_METATYPE(Meta::Reference)
|
|
@ -65,6 +65,10 @@ void Meta::Version::merge(const std::shared_ptr<BaseEntity> &other)
|
|||||||
{
|
{
|
||||||
setRequires(version->m_requires);
|
setRequires(version->m_requires);
|
||||||
}
|
}
|
||||||
|
if (m_parentUid != version->m_parentUid)
|
||||||
|
{
|
||||||
|
setParentUid(version->m_parentUid);
|
||||||
|
}
|
||||||
|
|
||||||
setData(version->m_data);
|
setData(version->m_data);
|
||||||
}
|
}
|
||||||
@ -74,21 +78,30 @@ QString Meta::Version::localFilename() const
|
|||||||
return m_uid + '/' + m_version + ".json";
|
return m_uid + '/' + m_version + ".json";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Meta::Version::setParentUid(const QString& parentUid)
|
||||||
|
{
|
||||||
|
m_parentUid = parentUid;
|
||||||
|
emit requiresChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void Meta::Version::setType(const QString &type)
|
void Meta::Version::setType(const QString &type)
|
||||||
{
|
{
|
||||||
m_type = type;
|
m_type = type;
|
||||||
emit typeChanged();
|
emit typeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Meta::Version::setTime(const qint64 time)
|
void Meta::Version::setTime(const qint64 time)
|
||||||
{
|
{
|
||||||
m_time = time;
|
m_time = time;
|
||||||
emit timeChanged();
|
emit timeChanged();
|
||||||
}
|
}
|
||||||
void Meta::Version::setRequires(const QVector<Reference> &requires)
|
|
||||||
|
void Meta::Version::setRequires(const QHash<QString, QString> &requires)
|
||||||
{
|
{
|
||||||
m_requires = requires;
|
m_requires = requires;
|
||||||
emit requiresChanged();
|
emit requiresChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Meta::Version::setData(const VersionFilePtr &data)
|
void Meta::Version::setData(const VersionFilePtr &data)
|
||||||
{
|
{
|
||||||
m_data = data;
|
m_data = data;
|
||||||
|
@ -17,15 +17,14 @@
|
|||||||
|
|
||||||
#include "BaseVersion.h"
|
#include "BaseVersion.h"
|
||||||
|
|
||||||
#include <QVector>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QVector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "minecraft/VersionFile.h"
|
#include "minecraft/VersionFile.h"
|
||||||
|
|
||||||
#include "BaseEntity.h"
|
#include "BaseEntity.h"
|
||||||
#include "Reference.h"
|
|
||||||
|
|
||||||
#include "multimc_logic_export.h"
|
#include "multimc_logic_export.h"
|
||||||
|
|
||||||
@ -37,10 +36,11 @@ class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString uid READ uid CONSTANT)
|
Q_PROPERTY(QString uid READ uid CONSTANT)
|
||||||
|
Q_PROPERTY(QString parentUid READ parentUid)
|
||||||
Q_PROPERTY(QString version READ version CONSTANT)
|
Q_PROPERTY(QString version READ version CONSTANT)
|
||||||
Q_PROPERTY(QString type READ type NOTIFY typeChanged)
|
Q_PROPERTY(QString type READ type NOTIFY typeChanged)
|
||||||
Q_PROPERTY(QDateTime time READ time NOTIFY timeChanged)
|
Q_PROPERTY(QDateTime time READ time NOTIFY timeChanged)
|
||||||
Q_PROPERTY(QVector<Reference> requires READ requires NOTIFY requiresChanged)
|
Q_PROPERTY(QHash<QString, QString> requires READ requires NOTIFY requiresChanged)
|
||||||
|
|
||||||
public: /* con/des */
|
public: /* con/des */
|
||||||
explicit Version(const QString &uid, const QString &version);
|
explicit Version(const QString &uid, const QString &version);
|
||||||
@ -49,13 +49,35 @@ public: /* con/des */
|
|||||||
QString name() override;
|
QString name() override;
|
||||||
QString typeString() const override;
|
QString typeString() const override;
|
||||||
|
|
||||||
QString uid() const { return m_uid; }
|
QString uid() const
|
||||||
QString version() const { return m_version; }
|
{
|
||||||
QString type() const { return m_type; }
|
return m_uid;
|
||||||
|
}
|
||||||
|
QString parentUid() const
|
||||||
|
{
|
||||||
|
return m_parentUid;
|
||||||
|
}
|
||||||
|
QString version() const
|
||||||
|
{
|
||||||
|
return m_version;
|
||||||
|
}
|
||||||
|
QString type() const
|
||||||
|
{
|
||||||
|
return m_type;
|
||||||
|
}
|
||||||
QDateTime time() const;
|
QDateTime time() const;
|
||||||
qint64 rawTime() const { return m_time; }
|
qint64 rawTime() const
|
||||||
QVector<Reference> requires() const { return m_requires; }
|
{
|
||||||
VersionFilePtr data() const { return m_data; }
|
return m_time;
|
||||||
|
}
|
||||||
|
const QHash<QString, QString> &requires() const
|
||||||
|
{
|
||||||
|
return m_requires;
|
||||||
|
}
|
||||||
|
VersionFilePtr data() const
|
||||||
|
{
|
||||||
|
return m_data;
|
||||||
|
}
|
||||||
|
|
||||||
void merge(const std::shared_ptr<BaseEntity> &other) override;
|
void merge(const std::shared_ptr<BaseEntity> &other) override;
|
||||||
void parse(const QJsonObject &obj) override;
|
void parse(const QJsonObject &obj) override;
|
||||||
@ -63,9 +85,10 @@ public: /* con/des */
|
|||||||
QString localFilename() const override;
|
QString localFilename() const override;
|
||||||
|
|
||||||
public: // for usage by format parsers only
|
public: // for usage by format parsers only
|
||||||
|
void setParentUid(const QString &parentUid);
|
||||||
void setType(const QString &type);
|
void setType(const QString &type);
|
||||||
void setTime(const qint64 time);
|
void setTime(const qint64 time);
|
||||||
void setRequires(const QVector<Reference> &requires);
|
void setRequires(const QHash<QString, QString> &requires);
|
||||||
void setData(const VersionFilePtr &data);
|
void setData(const VersionFilePtr &data);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -76,10 +99,11 @@ signals:
|
|||||||
private:
|
private:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_uid;
|
QString m_uid;
|
||||||
|
QString m_parentUid;
|
||||||
QString m_version;
|
QString m_version;
|
||||||
QString m_type;
|
QString m_type;
|
||||||
qint64 m_time;
|
qint64 m_time;
|
||||||
QVector<Reference> m_requires;
|
QHash<QString, QString> m_requires;
|
||||||
VersionFilePtr m_data;
|
VersionFilePtr m_data;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
#include "JsonFormat.h"
|
#include "JsonFormat.h"
|
||||||
#include "Reference.h"
|
|
||||||
|
|
||||||
namespace Meta
|
namespace Meta
|
||||||
{
|
{
|
||||||
@ -76,14 +75,17 @@ QVariant VersionList::data(const QModelIndex &index, int role) const
|
|||||||
return version->version();
|
return version->version();
|
||||||
case ParentGameVersionRole:
|
case ParentGameVersionRole:
|
||||||
{
|
{
|
||||||
const auto end = version->requires().end();
|
auto parentUid = this->parentUid();
|
||||||
const auto it = std::find_if(version->requires().begin(), end,
|
if(parentUid.isEmpty())
|
||||||
[](const Reference &ref) { return ref.uid() == "net.minecraft"; });
|
|
||||||
if (it != end)
|
|
||||||
{
|
{
|
||||||
return (*it).version();
|
return QVariant();
|
||||||
|
}
|
||||||
|
auto & reqs = version->requires();
|
||||||
|
auto iter = reqs.find(parentUid);
|
||||||
|
if (iter != reqs.end())
|
||||||
|
{
|
||||||
|
return iter.value();
|
||||||
}
|
}
|
||||||
return QVariant();
|
|
||||||
}
|
}
|
||||||
case TypeRole: return version->type();
|
case TypeRole: return version->type();
|
||||||
|
|
||||||
@ -175,6 +177,11 @@ void VersionList::merge(const BaseEntity::Ptr &other)
|
|||||||
setName(list->m_name);
|
setName(list->m_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(m_parentUid != list->m_parentUid)
|
||||||
|
{
|
||||||
|
setParentUid(list->m_parentUid);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_versions.isEmpty())
|
if (m_versions.isEmpty())
|
||||||
{
|
{
|
||||||
setVersions(list->m_versions);
|
setVersions(list->m_versions);
|
||||||
@ -228,5 +235,10 @@ BaseVersionPtr VersionList::getRecommended() const
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Meta::VersionList::setParentUid(const QString& parentUid)
|
||||||
|
{
|
||||||
|
m_parentUid = parentUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "VersionList.moc"
|
#include "VersionList.moc"
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BaseVersionList.h"
|
|
||||||
#include "BaseEntity.h"
|
#include "BaseEntity.h"
|
||||||
|
#include "BaseVersionList.h"
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -56,16 +56,30 @@ public:
|
|||||||
|
|
||||||
QString localFilename() const override;
|
QString localFilename() const override;
|
||||||
|
|
||||||
QString uid() const { return m_uid; }
|
QString parentUid() const
|
||||||
QString name() const { return m_name; }
|
{
|
||||||
|
return m_parentUid;
|
||||||
|
}
|
||||||
|
QString uid() const
|
||||||
|
{
|
||||||
|
return m_uid;
|
||||||
|
}
|
||||||
|
QString name() const
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
QString humanReadable() const;
|
QString humanReadable() const;
|
||||||
|
|
||||||
VersionPtr getVersion(const QString &version);
|
VersionPtr getVersion(const QString &version);
|
||||||
|
|
||||||
QVector<VersionPtr> versions() const { return m_versions; }
|
QVector<VersionPtr> versions() const
|
||||||
|
{
|
||||||
|
return m_versions;
|
||||||
|
}
|
||||||
|
|
||||||
public: // for usage only by parsers
|
public: // for usage only by parsers
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
void setParentUid(const QString &parentUid);
|
||||||
void setVersions(const QVector<VersionPtr> &versions);
|
void setVersions(const QVector<VersionPtr> &versions);
|
||||||
void merge(const BaseEntity::Ptr &other) override;
|
void merge(const BaseEntity::Ptr &other) override;
|
||||||
void parse(const QJsonObject &obj) override;
|
void parse(const QJsonObject &obj) override;
|
||||||
@ -74,12 +88,15 @@ signals:
|
|||||||
void nameChanged(const QString &name);
|
void nameChanged(const QString &name);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void updateListData(QList<BaseVersionPtr>) override {}
|
void updateListData(QList<BaseVersionPtr>) override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<VersionPtr> m_versions;
|
QVector<VersionPtr> m_versions;
|
||||||
QHash<QString, VersionPtr> m_lookup;
|
QHash<QString, VersionPtr> m_lookup;
|
||||||
QString m_uid;
|
QString m_uid;
|
||||||
|
QString m_parentUid;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
||||||
VersionPtr m_recommended;
|
VersionPtr m_recommended;
|
||||||
@ -87,6 +104,5 @@ private:
|
|||||||
|
|
||||||
void setupAddedVersion(const int row, const VersionPtr &version);
|
void setupAddedVersion(const int row, const VersionPtr &version);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
Q_DECLARE_METATYPE(Meta::VersionListPtr)
|
Q_DECLARE_METATYPE(Meta::VersionListPtr)
|
||||||
|
@ -43,6 +43,9 @@
|
|||||||
|
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
|
|
||||||
|
#include <meta/Index.h>
|
||||||
|
#include <meta/VersionList.h>
|
||||||
|
|
||||||
class IconProxy : public QIdentityProxyModel
|
class IconProxy : public QIdentityProxyModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -372,7 +375,7 @@ int VersionPage::doUpdate()
|
|||||||
|
|
||||||
void VersionPage::on_forgeBtn_clicked()
|
void VersionPage::on_forgeBtn_clicked()
|
||||||
{
|
{
|
||||||
auto vlist = ENV.getVersionList("net.minecraftforge");
|
auto vlist = ENV.metadataIndex()->get("net.minecraftforge");
|
||||||
if(!vlist)
|
if(!vlist)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -391,7 +394,7 @@ void VersionPage::on_forgeBtn_clicked()
|
|||||||
|
|
||||||
void VersionPage::on_liteloaderBtn_clicked()
|
void VersionPage::on_liteloaderBtn_clicked()
|
||||||
{
|
{
|
||||||
auto vlist = ENV.getVersionList("com.liteloader");
|
auto vlist = ENV.metadataIndex()->get("com.liteloader");
|
||||||
if(!vlist)
|
if(!vlist)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -34,17 +34,15 @@ using namespace Meta;
|
|||||||
static QString formatRequires(const VersionPtr &version)
|
static QString formatRequires(const VersionPtr &version)
|
||||||
{
|
{
|
||||||
QStringList lines;
|
QStringList lines;
|
||||||
for (const Reference &ref : version->requires())
|
auto & reqs = version->requires();
|
||||||
|
auto iter = reqs.begin();
|
||||||
|
while (iter != reqs.end())
|
||||||
{
|
{
|
||||||
const QString readable = ENV.metadataIndex()->hasUid(ref.uid()) ? ENV.metadataIndex()->get(ref.uid())->humanReadable() : ref.uid();
|
auto &uid = iter.key();
|
||||||
if (ref.version().isEmpty())
|
auto &version = iter.value();
|
||||||
{
|
const QString readable = ENV.metadataIndex()->hasUid(uid) ? ENV.metadataIndex()->get(uid)->humanReadable() : uid;
|
||||||
lines.append(readable);
|
lines.append(QString("%1 (%2)").arg(readable, version));
|
||||||
}
|
iter++;
|
||||||
else
|
|
||||||
{
|
|
||||||
lines.append(QString("%1 (%2)").arg(readable, ref.version()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user