diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-09-18 22:53:37 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-09-18 22:53:37 +0200 |
commit | 69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91 (patch) | |
tree | a22a80b987212490371294f53e1f8bd698f1dad5 /api/dead/src/handlers | |
parent | eb747e08b78d8630413b9bdb3a96108ccfcc2ac8 (diff) | |
download | MultiMC-69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91.tar MultiMC-69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91.tar.gz MultiMC-69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91.tar.lz MultiMC-69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91.tar.xz MultiMC-69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91.zip |
NOISSUE delete dead code
Diffstat (limited to 'api/dead/src/handlers')
-rw-r--r-- | api/dead/src/handlers/IconResourceHandler.cpp | 37 | ||||
-rw-r--r-- | api/dead/src/handlers/IconResourceHandler.h | 23 | ||||
-rw-r--r-- | api/dead/src/handlers/WebResourceHandler.cpp | 68 | ||||
-rw-r--r-- | api/dead/src/handlers/WebResourceHandler.h | 23 |
4 files changed, 0 insertions, 151 deletions
diff --git a/api/dead/src/handlers/IconResourceHandler.cpp b/api/dead/src/handlers/IconResourceHandler.cpp deleted file mode 100644 index b03553fd..00000000 --- a/api/dead/src/handlers/IconResourceHandler.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "IconResourceHandler.h" -#include <xdgicon.h> - -#include <QDir> -#include <QDebug> - -QList<std::weak_ptr<IconResourceHandler>> IconResourceHandler::m_iconHandlers; - -IconResourceHandler::IconResourceHandler(const QString &key) - : m_key(key) -{ -} - -void IconResourceHandler::setTheme(const QString &theme) -{ - // notify everyone - for (auto handler : m_iconHandlers) - { - std::shared_ptr<IconResourceHandler> ptr = handler.lock(); - if (ptr) - { - ptr->setResult(ptr->get()); - } - } -} - -void IconResourceHandler::init(std::shared_ptr<ResourceHandler> &ptr) -{ - m_iconHandlers.append(std::dynamic_pointer_cast<IconResourceHandler>(ptr)); - // we always have a result, so lets report it now! - setResult(get()); -} - -QVariant IconResourceHandler::get() const -{ - return XdgIcon::fromTheme(m_key); -} diff --git a/api/dead/src/handlers/IconResourceHandler.h b/api/dead/src/handlers/IconResourceHandler.h deleted file mode 100644 index 0cc4de4f..00000000 --- a/api/dead/src/handlers/IconResourceHandler.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include <memory> -#include <resources/ResourceHandler.h> - -class IconResourceHandler : public ResourceHandler -{ -public: - explicit IconResourceHandler(const QString &key); - - /// Sets the current theme and notifies all IconResourceHandlers of the change - static void setTheme(const QString &theme); - -private: - // we need to keep track of all IconResourceHandlers so that we can update them if the theme changes - void init(std::shared_ptr<ResourceHandler> &ptr) override; - static QList<std::weak_ptr<IconResourceHandler>> m_iconHandlers; - - QString m_key; - - // the workhorse, returns QVariantMap (filename => size) for m_key/m_theme - QVariant get() const; -}; diff --git a/api/dead/src/handlers/WebResourceHandler.cpp b/api/dead/src/handlers/WebResourceHandler.cpp deleted file mode 100644 index e4fd74fa..00000000 --- a/api/dead/src/handlers/WebResourceHandler.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "WebResourceHandler.h" - -#include "net/Download.h" -#include "net/HttpMetaCache.h" -#include "net/NetJob.h" -#include "FileSystem.h" -#include "Env.h" - -//FIXME: wrong. needs to be done elsewhere. -QMap<QString, NetJob *> WebResourceHandler::m_activeDownloads; - -WebResourceHandler::WebResourceHandler(const QString &url) - : QObject(), m_url(url) -{ - MetaEntryPtr entry = ENV.metacache()->resolveEntry("icons", url); - if (!entry->isStale()) - { - setResultFromFile(entry->getFullPath()); - } - else if (m_activeDownloads.contains(url)) - { - NetJob *job = m_activeDownloads.value(url); - connect(job, &NetJob::succeeded, this, &WebResourceHandler::succeeded); - connect(job, &NetJob::failed, this, [job, this]() {setFailure(job->failReason());}); - connect(job, &NetJob::progress, this, &WebResourceHandler::progress); - } - else - { - NetJob *job = new NetJob("Icon download"); - job->addNetAction(Download::make(QUrl(url), entry)); - connect(job, &NetJob::succeeded, this, &WebResourceHandler::succeeded); - connect(job, &NetJob::failed, this, [job, this]() {setFailure(job->failReason());}); - connect(job, &NetJob::progress, this, &WebResourceHandler::progress); - connect(job, &NetJob::finished, job, [job](){m_activeDownloads.remove(m_activeDownloads.key(job));job->deleteLater();}); - m_activeDownloads.insert(url, job); - job->start(); - } -} - -void WebResourceHandler::succeeded() -{ - MetaEntryPtr entry = ENV.metacache()->resolveEntry("icons", m_url); - setResultFromFile(entry->getFullPath()); - m_activeDownloads.remove(m_activeDownloads.key(qobject_cast<NetJob *>(sender()))); -} -void WebResourceHandler::progress(qint64 current, qint64 total) -{ - if (total == 0) - { - setProgress(101); - } - else - { - setProgress(current / total); - } -} - -void WebResourceHandler::setResultFromFile(const QString &file) -{ - try - { - setResult(FS::read(file)); - } - catch (Exception &e) - { - setFailure(e.cause()); - } -} diff --git a/api/dead/src/handlers/WebResourceHandler.h b/api/dead/src/handlers/WebResourceHandler.h deleted file mode 100644 index 54bef6a1..00000000 --- a/api/dead/src/handlers/WebResourceHandler.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include <QObject> -#include <resources/ResourceHandler.h> - -class NetJob; - -class WebResourceHandler : public QObject, public ResourceHandler -{ -public: - explicit WebResourceHandler(const QString &url); - -private slots: - void succeeded(); - void progress(qint64 current, qint64 total); - -private: - static QMap<QString, NetJob *> m_activeDownloads; - - QString m_url; - - void setResultFromFile(const QString &file); -}; |