NOISSUE stuff and things happened. Maybe.

This commit is contained in:
Petr Mrázek
2017-03-19 23:58:54 +01:00
parent 2660418d58
commit f557c13679
23 changed files with 210 additions and 212 deletions

View File

@ -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);

View File

@ -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()

View File

@ -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
{

View File

@ -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;

View File

@ -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

View File

@ -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;