diff options
author | Janrupf <werbung.janrupf@t-online.de> | 2018-04-01 20:24:28 +0200 |
---|---|---|
committer | Janrupf <werbung.janrupf@t-online.de> | 2018-04-02 23:02:33 +0200 |
commit | bbd523acb8bf846d27a7859d1d79f28ea92de245 (patch) | |
tree | b8cb693f9558b99e27f730840ca1764da08495d2 /application/pages/modplatform/FTBPage.cpp | |
parent | 67d2f283da3bf9538e6a31de3759cd959010b36c (diff) | |
download | MultiMC-bbd523acb8bf846d27a7859d1d79f28ea92de245.tar MultiMC-bbd523acb8bf846d27a7859d1d79f28ea92de245.tar.gz MultiMC-bbd523acb8bf846d27a7859d1d79f28ea92de245.tar.lz MultiMC-bbd523acb8bf846d27a7859d1d79f28ea92de245.tar.xz MultiMC-bbd523acb8bf846d27a7859d1d79f28ea92de245.zip |
NOISSUE Added FTB Pack logos to chooser and fixed some missing includes
Diffstat (limited to 'application/pages/modplatform/FTBPage.cpp')
-rw-r--r-- | application/pages/modplatform/FTBPage.cpp | 81 |
1 files changed, 51 insertions, 30 deletions
diff --git a/application/pages/modplatform/FTBPage.cpp b/application/pages/modplatform/FTBPage.cpp index 26b1e30b..3b808799 100644 --- a/application/pages/modplatform/FTBPage.cpp +++ b/application/pages/modplatform/FTBPage.cpp @@ -5,41 +5,53 @@ #include "FolderInstanceProvider.h" #include "dialogs/CustomMessageBox.h" #include "dialogs/NewInstanceDialog.h" -#include "modplatform/ftb/FtbPackDownloader.h" +#include "modplatform/ftb/FtbPackFetchTask.h" #include "modplatform/ftb/FtbPackInstallTask.h" #include <FtbListModel.h> FTBPage::FTBPage(NewInstanceDialog* dialog, QWidget *parent) : QWidget(parent), dialog(dialog), ui(new Ui::FTBPage) { + ftbFetchTask = new FtbPackFetchTask(); + ui->setupUi(this); ui->tabWidget->tabBar()->hide(); - ftbPackDownloader = new FtbPackDownloader(); - connect(ftbPackDownloader, &FtbPackDownloader::ready, this, &FTBPage::ftbPackDataDownloadSuccessfully); - connect(ftbPackDownloader, &FtbPackDownloader::packFetchFailed, this, &FTBPage::ftbPackDataDownloadFailed); + { + publicFilterModel = new FtbFilterModel(this); + publicListModel = new FtbListModel(this); + publicFilterModel->setSourceModel(publicListModel); - filterModel = new FtbFilterModel(this); - listModel = new FtbListModel(this); - filterModel->setSourceModel(listModel); + ui->publicPackList->setModel(publicFilterModel); + ui->publicPackList->setSortingEnabled(true); + ui->publicPackList->header()->hide(); + ui->publicPackList->setIndentation(0); - ui->packList->setModel(filterModel); - ui->packList->setSortingEnabled(true); - ui->packList->header()->hide(); - ui->packList->setIndentation(0); + for(int i = 0; i < publicFilterModel->getAvailableSortings().size(); i++) + { + ui->sortByBox->addItem(publicFilterModel->getAvailableSortings().keys().at(i)); + } - filterModel->setSorting(FtbFilterModel::Sorting::ByName); + ui->sortByBox->setCurrentText(publicFilterModel->translateCurrentSorting()); + } - for(int i = 0; i < filterModel->getAvailableSortings().size(); i++) { - ui->sortByBox->addItem(filterModel->getAvailableSortings().keys().at(i)); + thirdPartyFilterModel = new FtbFilterModel(this); + thirdPartyModel = new FtbListModel(this); + thirdPartyFilterModel->setSourceModel(thirdPartyModel); + + ui->thirdPartyPackList->setModel(thirdPartyFilterModel); + ui->thirdPartyPackList->setSortingEnabled(true); + ui->thirdPartyPackList->header()->hide(); + ui->thirdPartyPackList->setIndentation(0); + thirdPartyFilterModel->setSorting(publicFilterModel->getCurrentSorting()); } - ui->sortByBox->setCurrentText(filterModel->getAvailableSortings().key(filterModel->getCurrentSorting())); - connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &FTBPage::onSortingSelectionChanged); connect(ui->packVersionSelection, &QComboBox::currentTextChanged, this, &FTBPage::onVersionSelectionItemChanged); - connect(ui->packList->selectionModel(), &QItemSelectionModel::currentChanged, this, &FTBPage::onPackSelectionChanged); + + connect(ui->publicPackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &FTBPage::onPublicPackSelectionChanged); + connect(ui->thirdPartyPackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &FTBPage::onThirdPartyPackSelectionChanged); ui->modpackInfo->setOpenExternalLinks(true); } @@ -47,9 +59,8 @@ FTBPage::FTBPage(NewInstanceDialog* dialog, QWidget *parent) FTBPage::~FTBPage() { delete ui; - if(ftbPackDownloader) - { - ftbPackDownloader->deleteLater(); + if(ftbFetchTask) { + ftbFetchTask->deleteLater(); } } @@ -62,7 +73,9 @@ void FTBPage::openedImpl() { if(!initialized) { - ftbPackDownloader->fetchModpacks(false); + connect(ftbFetchTask, &FtbPackFetchTask::finished, this, &FTBPage::ftbPackDataDownloadSuccessfully); + connect(ftbFetchTask, &FtbPackFetchTask::failed, this, &FTBPage::ftbPackDataDownloadFailed); + ftbFetchTask->fetch(); initialized = true; } suggestCurrent(); @@ -83,25 +96,31 @@ void FTBPage::suggestCurrent() } } -FtbPackDownloader *FTBPage::getFtbPackDownloader() +void FTBPage::ftbPackDataDownloadSuccessfully(FtbModpackList publicPacks, FtbModpackList thirdPartyPacks) +{ + publicListModel->fill(publicPacks); + thirdPartyModel->fill(thirdPartyPacks); +} + +void FTBPage::ftbPackDataDownloadFailed(QString reason) { - return ftbPackDownloader; + //TODO: Display the error } -void FTBPage::ftbPackDataDownloadSuccessfully() +void FTBPage::onPublicPackSelectionChanged(QModelIndex first, QModelIndex second) { - listModel->fill(ftbPackDownloader->getModpacks()); + onPackSelectionChanged(first, second, publicFilterModel); } -void FTBPage::ftbPackDataDownloadFailed() +void FTBPage::onThirdPartyPackSelectionChanged(QModelIndex first, QModelIndex second) { - qDebug() << "Stuff went missing while grabbing FTB pack list or something..."; + onPackSelectionChanged(first, second, thirdPartyFilterModel); } -void FTBPage::onPackSelectionChanged(QModelIndex now, QModelIndex prev) +void FTBPage::onPackSelectionChanged(QModelIndex now, QModelIndex prev, FtbFilterModel *model) { ui->packVersionSelection->clear(); - FtbModpack selectedPack = filterModel->data(now, Qt::UserRole).value<FtbModpack>(); + FtbModpack selectedPack = model->data(now, Qt::UserRole).value<FtbModpack>(); ui->modpackInfo->setHtml("Pack by <b>" + selectedPack.author + "</b>" + "<br>Minecraft " + selectedPack.mcVersion + "<br>" "<br>" + selectedPack.description + "<ul><li>" + selectedPack.mods.replace(";", "</li><li>") + "</li></ul>"); @@ -149,5 +168,7 @@ QString FTBPage::getSelectedVersion() void FTBPage::onSortingSelectionChanged(QString data) { - filterModel->setSorting(filterModel->getAvailableSortings().value(data)); + FtbFilterModel::Sorting toSet = publicFilterModel->getAvailableSortings().value(data); + publicFilterModel->setSorting(toSet); + thirdPartyFilterModel->setSorting(toSet); } |