summaryrefslogtreecommitdiffstats
path: root/api/logic/meta
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-03-19 23:58:54 +0100
committerPetr Mrázek <peterix@gmail.com>2017-04-07 00:20:02 +0200
commitf557c1367994a61935fa0e8d0b1b67688d2692d0 (patch)
tree8eff9809b158cd1e65ba0eadc2b1c140b78c4e8b /api/logic/meta
parent2660418d58efb33cd3a0ab8ed9d48c359c076905 (diff)
downloadMultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.tar
MultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.tar.gz
MultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.tar.lz
MultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.tar.xz
MultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.zip
NOISSUE stuff and things happened. Maybe.
Diffstat (limited to 'api/logic/meta')
-rw-r--r--api/logic/meta/BaseEntity.cpp8
-rw-r--r--api/logic/meta/Index_test.cpp2
-rw-r--r--api/logic/meta/Version.cpp12
-rw-r--r--api/logic/meta/Version.h82
-rw-r--r--api/logic/meta/VersionList.cpp8
-rw-r--r--api/logic/meta/VersionList.h2
6 files changed, 17 insertions, 97 deletions
diff --git a/api/logic/meta/BaseEntity.cpp b/api/logic/meta/BaseEntity.cpp
index 809f88cb..633afab2 100644
--- a/api/logic/meta/BaseEntity.cpp
+++ b/api/logic/meta/BaseEntity.cpp
@@ -101,16 +101,20 @@ bool Meta::BaseEntity::loadLocalFile()
void Meta::BaseEntity::load()
{
+ // load local file if nothing is loaded yet
if(!isLoaded())
{
- loadLocalFile();
+ if(loadLocalFile())
+ {
+ m_loadStatus = LoadStatus::Local;
+ }
}
+ // if we need remote update, run the update task
if(!shouldStartRemoteUpdate())
{
return;
}
NetJob *job = new NetJob(QObject::tr("Download of meta file %1").arg(localFilename()));
-
auto url = this->url();
auto entry = ENV.metacache()->resolveEntry("meta", localFilename());
entry->setStale(true);
diff --git a/api/logic/meta/Index_test.cpp b/api/logic/meta/Index_test.cpp
index d4343c37..1c5face2 100644
--- a/api/logic/meta/Index_test.cpp
+++ b/api/logic/meta/Index_test.cpp
@@ -23,7 +23,7 @@ slots:
QVERIFY(!windex.hasUid("asdf"));
QVERIFY(windex.get("list2") != nullptr);
QCOMPARE(windex.get("list2")->uid(), QString("list2"));
- QVERIFY(windex.get("adsf") == nullptr);
+ QVERIFY(windex.get("adsf") != nullptr);
}
void test_merge()
diff --git a/api/logic/meta/Version.cpp b/api/logic/meta/Version.cpp
index 2790b2f3..fee7d049 100644
--- a/api/logic/meta/Version.cpp
+++ b/api/logic/meta/Version.cpp
@@ -20,14 +20,6 @@
#include "JsonFormat.h"
#include "minecraft/MinecraftProfile.h"
-void Meta::Version::applyTo(MinecraftProfile* profile)
-{
- if(m_data)
- {
- m_data->applyTo(profile);
- }
-}
-
Meta::Version::Version(const QString &uid, const QString &version)
: BaseVersion(), m_uid(uid), m_version(version)
{
@@ -39,7 +31,9 @@ QString Meta::Version::descriptor()
}
QString Meta::Version::name()
{
- return m_version;
+ if(m_data)
+ return m_data->getName();
+ return m_uid;
}
QString Meta::Version::typeString() const
{
diff --git a/api/logic/meta/Version.h b/api/logic/meta/Version.h
index b8ea7e44..b3943f47 100644
--- a/api/logic/meta/Version.h
+++ b/api/logic/meta/Version.h
@@ -33,7 +33,7 @@ namespace Meta
{
using VersionPtr = std::shared_ptr<class Version>;
-class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public BaseEntity, public ProfilePatch
+class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public BaseEntity
{
Q_OBJECT
Q_PROPERTY(QString uid READ uid CONSTANT)
@@ -45,85 +45,6 @@ class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public
public: /* con/des */
explicit Version(const QString &uid, const QString &version);
-// FIXME: none of this belongs here...
-public: /* ProfilePatch overrides */
- QString getFilename() override
- {
- return QString();
- }
- QString getID() override
- {
- return m_uid;
- }
- QList<JarmodPtr> getJarMods() override
- {
- return {};
- }
- QString getName() override
- {
- return name();
- }
- QDateTime getReleaseDateTime() override
- {
- return time();
- }
- QString getVersion() override
- {
- return m_version;
- }
- std::shared_ptr<class VersionFile> getVersionFile() override
- {
- return m_data;
- }
- int getOrder() override
- {
- return 0;
- }
- VersionSource getVersionSource() override
- {
- return VersionSource::Local;
- }
- bool isVersionChangeable() override
- {
- return true;
- }
- bool isRevertible() override
- {
- return false;
- }
- bool isRemovable() override
- {
- return true;
- }
- bool isCustom() override
- {
- return false;
- }
- bool isCustomizable() override
- {
- return true;
- }
- bool isMoveable() override
- {
- return true;
- }
- bool isEditable() override
- {
- return false;
- }
- void setOrder(int) override
- {
- }
- bool hasJarMods() override
- {
- return false;
- }
- bool isMinecraftVersion() override
- {
- return m_uid == "net.minecraft";
- }
- void applyTo(MinecraftProfile * profile) override;
-
QString descriptor() override;
QString name() override;
QString typeString() const override;
@@ -153,6 +74,7 @@ signals:
void requiresChanged();
private:
+ QString m_name;
QString m_uid;
QString m_version;
QString m_type;
diff --git a/api/logic/meta/VersionList.cpp b/api/logic/meta/VersionList.cpp
index d6bbf70f..28d9dd26 100644
--- a/api/logic/meta/VersionList.cpp
+++ b/api/logic/meta/VersionList.cpp
@@ -29,15 +29,15 @@ VersionList::VersionList(const QString &uid, QObject *parent)
setObjectName("Version list: " + uid);
}
-Task *VersionList::getLoadTask()
+shared_qobject_ptr<Task> VersionList::getLoadTask()
{
- // TODO: create a wrapper task that will chain from root to here.
- return nullptr;
+ load();
+ return getCurrentTask();
}
bool VersionList::isLoaded()
{
- return isLoaded();
+ return BaseEntity::isLoaded();
}
const BaseVersionPtr VersionList::at(int i) const
diff --git a/api/logic/meta/VersionList.h b/api/logic/meta/VersionList.h
index 26fa6c5a..08d71230 100644
--- a/api/logic/meta/VersionList.h
+++ b/api/logic/meta/VersionList.h
@@ -41,7 +41,7 @@ public:
VersionPtrRole
};
- Task *getLoadTask() override;
+ shared_qobject_ptr<Task> getLoadTask() override;
bool isLoaded() override;
const BaseVersionPtr at(int i) const override;
int count() const override;