summaryrefslogtreecommitdiffstats
path: root/api/logic/modplatform/ftb/FtbPackDownloader.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2018-03-19 02:36:12 +0100
committerPetr Mrázek <peterix@gmail.com>2018-03-27 09:25:36 +0200
commit8e44ab2338f4ca63d58de4b3329c384df9d6c053 (patch)
tree60b915ec620221656d1c3a42f40124b15e9e69f0 /api/logic/modplatform/ftb/FtbPackDownloader.cpp
parent4c7ea0f99a23f73fd3cae87f7dfaab89922a2311 (diff)
downloadMultiMC-8e44ab2338f4ca63d58de4b3329c384df9d6c053.tar
MultiMC-8e44ab2338f4ca63d58de4b3329c384df9d6c053.tar.gz
MultiMC-8e44ab2338f4ca63d58de4b3329c384df9d6c053.tar.lz
MultiMC-8e44ab2338f4ca63d58de4b3329c384df9d6c053.tar.xz
MultiMC-8e44ab2338f4ca63d58de4b3329c384df9d6c053.zip
NOISSUE redo new instance dialog
Diffstat (limited to 'api/logic/modplatform/ftb/FtbPackDownloader.cpp')
-rw-r--r--api/logic/modplatform/ftb/FtbPackDownloader.cpp84
1 files changed, 16 insertions, 68 deletions
diff --git a/api/logic/modplatform/ftb/FtbPackDownloader.cpp b/api/logic/modplatform/ftb/FtbPackDownloader.cpp
index caadd4ae..3e274c9e 100644
--- a/api/logic/modplatform/ftb/FtbPackDownloader.cpp
+++ b/api/logic/modplatform/ftb/FtbPackDownloader.cpp
@@ -3,36 +3,25 @@
#include "FtbPackFetchTask.h"
#include "Env.h"
-FtbPackDownloader::FtbPackDownloader() {
+FtbPackDownloader::FtbPackDownloader()
+{
done = false;
fetching = false;
}
-FtbPackDownloader::~FtbPackDownloader(){
-}
-
-bool FtbPackDownloader::isValidPackSelected(){
- FtbModpack dummy;
- dummy.name = "__INVALID__";
-
- FtbModpack other = fetchedPacks.value(selected.name, dummy);
- if(other.name == "__INVALID__") {
- return false;
- }
-
- return other.oldVersions.contains(selectedVersion) && !other.broken;
-}
-
-QString FtbPackDownloader::getSuggestedInstanceName() {
- return selected.name;
+FtbPackDownloader::~FtbPackDownloader()
+{
}
-FtbModpackList FtbPackDownloader::getModpacks() {
+FtbModpackList FtbPackDownloader::getModpacks()
+{
return static_cast<FtbModpackList>(fetchedPacks.values());
}
-void FtbPackDownloader::fetchModpacks(bool force = false){
- if(fetching || (!force && done)) {
+void FtbPackDownloader::fetchModpacks(bool force = false)
+{
+ if(fetching || (!force && done))
+ {
qDebug() << "Skipping modpack refetch because done or already fetching [done =>" << done << "| fetching =>" << fetching << "]";
return;
}
@@ -46,8 +35,10 @@ void FtbPackDownloader::fetchModpacks(bool force = false){
}
-void FtbPackDownloader::fetchSuccess(FtbModpackList modpacks) {
- for(int i = 0; i < modpacks.size(); i++) {
+void FtbPackDownloader::fetchSuccess(FtbModpackList modpacks)
+{
+ for(int i = 0; i < modpacks.size(); i++)
+ {
fetchedPacks.insert(modpacks.at(i).name, modpacks.at(i));
}
@@ -57,53 +48,10 @@ void FtbPackDownloader::fetchSuccess(FtbModpackList modpacks) {
fetchTask->deleteLater();
}
-void FtbPackDownloader::fetchFailed(QString reason) {
+void FtbPackDownloader::fetchFailed(QString reason)
+{
qWarning() << "Failed to fetch FtbData" << reason;
fetching = false;
emit packFetchFailed();
fetchTask->deleteLater();
}
-
-void FtbPackDownloader::selectPack(FtbModpack modpack, QString version) {
- selected = modpack;
- selectedVersion = version;
-}
-
-FtbModpack FtbPackDownloader::getSelectedPack() {
- return selected;
-}
-
-void FtbPackDownloader::downloadSelected(MetaEntryPtr cache) {
- NetJob *job = new NetJob("Downlad FTB Pack");
-
- cache->setStale(true);
- QString url = QString("http://ftb.cursecdn.com/FTB2/modpacks/%1/%2/%3").arg(selected.dir, selectedVersion.replace(".", "_"), selected.file);
- job->addNetAction(Net::Download::makeCached(url, cache));
- downloadPath = cache->getFullPath();
-
- netJobContainer.reset(job);
-
- connect(job, &NetJob::succeeded, this, &FtbPackDownloader::_downloadSucceeded);
- connect(job, &NetJob::failed, this, &FtbPackDownloader::_downloadFailed);
- connect(job, &NetJob::progress, this, &FtbPackDownloader::_downloadProgress);
- job->start();
-}
-
-void FtbPackDownloader::_downloadSucceeded() {
- netJobContainer.reset();
- emit downloadSucceded(downloadPath);
-}
-
-void FtbPackDownloader::_downloadProgress(qint64 current, qint64 total) {
- emit downloadProgress(current, total);
-}
-
-void FtbPackDownloader::_downloadFailed(QString reason) {
- netJobContainer.reset();
- emit downloadFailed(reason);
-}
-
-NetJobPtr FtbPackDownloader::getNetJob()
-{
- return netJobContainer;
-}