summaryrefslogtreecommitdiffstats
path: root/logic/Env.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-02-02 01:09:28 +0100
committerPetr Mrázek <peterix@gmail.com>2015-04-12 20:57:17 +0200
commitd313e9ab09639346526b75c92498188753cb5b87 (patch)
tree1df78fb6150b77a705b48aa3af0a845131000309 /logic/Env.cpp
parent382ae78a0bf75892827321b052c6afbd195476bc (diff)
downloadMultiMC-d313e9ab09639346526b75c92498188753cb5b87.tar
MultiMC-d313e9ab09639346526b75c92498188753cb5b87.tar.gz
MultiMC-d313e9ab09639346526b75c92498188753cb5b87.tar.lz
MultiMC-d313e9ab09639346526b75c92498188753cb5b87.tar.xz
MultiMC-d313e9ab09639346526b75c92498188753cb5b87.zip
SCRATCH remove remaining references to MultiMC.h and fix legacy LWJGL
Diffstat (limited to 'logic/Env.cpp')
-rw-r--r--logic/Env.cpp92
1 files changed, 91 insertions, 1 deletions
diff --git a/logic/Env.cpp b/logic/Env.cpp
index f10f1951..7ca206f2 100644
--- a/logic/Env.cpp
+++ b/logic/Env.cpp
@@ -1,13 +1,19 @@
#include "Env.h"
#include "logic/net/HttpMetaCache.h"
#include "icons/IconList.h"
+#include "BaseVersion.h"
+#include "BaseVersionList.h"
#include <QDir>
#include <QNetworkProxy>
#include <QNetworkAccessManager>
#include "logger/QsLog.h"
-
+#include "logic/tasks/Task.h"
#include <QDebug>
+/*
+ * The *NEW* global rat nest of an object. Handle with care.
+ */
+
Env::Env()
{
m_qnam = std::make_shared<QNetworkAccessManager>();
@@ -17,6 +23,8 @@ void Env::destroy()
{
m_metacache.reset();
m_qnam.reset();
+ m_icons.reset();
+ m_versionLists.clear();
}
Env& Env::Env::getInstance()
@@ -41,6 +49,86 @@ std::shared_ptr<IconList> Env::icons()
Q_ASSERT(m_icons != nullptr);
return m_icons;
}
+/*
+class NullVersion : public BaseVersion
+{
+ Q_OBJECT
+public:
+ virtual QString name()
+ {
+ return "null";
+ }
+ virtual QString descriptor()
+ {
+ return "null";
+ }
+ virtual QString typeString() const
+ {
+ return "Null";
+ }
+};
+
+class NullTask: public Task
+{
+ Q_OBJECT
+public:
+ virtual void executeTask()
+ {
+ emitFailed(tr("Nothing to do."));
+ }
+};
+
+class NullVersionList: public BaseVersionList
+{
+ Q_OBJECT
+public:
+ virtual const BaseVersionPtr at(int i) const
+ {
+ return std::make_shared<NullVersion>();
+ }
+ virtual int count() const
+ {
+ return 0;
+ };
+ virtual Task* getLoadTask()
+ {
+ return new NullTask;
+ }
+ virtual bool isLoaded()
+ {
+ return false;
+ }
+ virtual void sort()
+ {
+ }
+ virtual void updateListData(QList< BaseVersionPtr >)
+ {
+ }
+};
+*/
+
+BaseVersionPtr Env::getVersion(QString component, QString version)
+{
+ auto list = getVersionList(component);
+ return list->findVersion(version);
+}
+
+std::shared_ptr< BaseVersionList > Env::getVersionList(QString component)
+{
+ auto iter = m_versionLists.find(component);
+ if(iter != m_versionLists.end())
+ {
+ return *iter;
+ }
+ //return std::make_shared<NullVersionList>();
+ return nullptr;
+}
+
+void Env::registerVersionList(QString name, std::shared_ptr< BaseVersionList > vlist)
+{
+ m_versionLists[name] = vlist;
+}
+
void Env::initHttpMetaCache(QString rootPath, QString staticDataPath)
{
@@ -121,3 +209,5 @@ void Env::updateProxySettings(QString proxyTypeStr, QString addr, int port, QStr
.arg(proxy.password());
QLOG_INFO() << proxyDesc;
}
+
+#include "Env.moc" \ No newline at end of file