summaryrefslogtreecommitdiffstats
path: root/application/pages
diff options
context:
space:
mode:
authorJanrupf <werbung.janrupf@t-online.de>2018-04-01 20:24:28 +0200
committerJanrupf <werbung.janrupf@t-online.de>2018-04-02 23:02:33 +0200
commitbbd523acb8bf846d27a7859d1d79f28ea92de245 (patch)
treeb8cb693f9558b99e27f730840ca1764da08495d2 /application/pages
parent67d2f283da3bf9538e6a31de3759cd959010b36c (diff)
downloadMultiMC-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')
-rw-r--r--application/pages/modplatform/FTBPage.cpp81
-rw-r--r--application/pages/modplatform/FTBPage.h24
-rw-r--r--application/pages/modplatform/FTBPage.ui79
3 files changed, 133 insertions, 51 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);
}
diff --git a/application/pages/modplatform/FTBPage.h b/application/pages/modplatform/FTBPage.h
index f7d6ca8b..ba8dd299 100644
--- a/application/pages/modplatform/FTBPage.h
+++ b/application/pages/modplatform/FTBPage.h
@@ -21,6 +21,7 @@
#include <MultiMC.h>
#include "tasks/Task.h"
#include "modplatform/ftb/PackHelpers.h"
+#include "modplatform/ftb/FtbPackFetchTask.h"
namespace Ui
{
@@ -29,7 +30,6 @@ class FTBPage;
class FtbListModel;
class FtbFilterModel;
-class FtbPackDownloader;
class NewInstanceDialog;
class FTBPage : public QWidget, public BasePage
@@ -58,28 +58,36 @@ public:
bool shouldDisplay() const override;
void openedImpl() override;
- FtbPackDownloader* getFtbPackDownloader();
FtbModpack getSelectedModpack();
QString getSelectedVersion();
private:
void suggestCurrent();
+ void onPackSelectionChanged(QModelIndex first, QModelIndex second, FtbFilterModel *model);
private slots:
- void ftbPackDataDownloadSuccessfully();
- void ftbPackDataDownloadFailed();
+ void ftbPackDataDownloadSuccessfully(FtbModpackList publicPacks, FtbModpackList thirdPartyPacks);
+ void ftbPackDataDownloadFailed(QString reason);
+
void onSortingSelectionChanged(QString data);
void onVersionSelectionItemChanged(QString data);
- void onPackSelectionChanged(QModelIndex first, QModelIndex second);
+
+ void onPublicPackSelectionChanged(QModelIndex first, QModelIndex second);
+ void onThirdPartyPackSelectionChanged(QModelIndex first, QModelIndex second);
private:
bool initialized = false;
- FtbPackDownloader* ftbPackDownloader = nullptr;
FtbModpack selectedPack;
FtbModpack selected;
QString selectedVersion;
- FtbListModel* listModel = nullptr;
- FtbFilterModel* filterModel = nullptr;
+
+ FtbListModel* publicListModel = nullptr;
+ FtbFilterModel* publicFilterModel = nullptr;
+
+ FtbListModel *thirdPartyModel = nullptr;
+ FtbFilterModel *thirdPartyFilterModel = nullptr;
+
+ FtbPackFetchTask *ftbFetchTask;
NewInstanceDialog* dialog = nullptr;
Ui::FTBPage *ui = nullptr;
diff --git a/application/pages/modplatform/FTBPage.ui b/application/pages/modplatform/FTBPage.ui
index a64c9606..ee91f1f5 100644
--- a/application/pages/modplatform/FTBPage.ui
+++ b/application/pages/modplatform/FTBPage.ui
@@ -10,7 +10,7 @@
<height>602</height>
</rect>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
@@ -23,7 +23,7 @@
<property name="bottomMargin">
<number>0</number>
</property>
- <item>
+ <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
@@ -32,17 +32,15 @@
<attribute name="title">
<string notr="true"/>
</attribute>
- <layout class="QGridLayout" name="gridLayout" columnstretch="0,0,4,4">
- <item row="0" column="0" colspan="2">
- <widget class="QTreeView" name="packList"/>
- </item>
- <item row="0" column="2" colspan="2">
- <widget class="QTextBrowser" name="modpackInfo"/>
- </item>
- <item row="1" column="3">
- <widget class="QComboBox" name="packVersionSelection"/>
+ <layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0,0">
+ <item row="1" column="2" colspan="2">
+ <widget class="QTextBrowser" name="modpackInfo">
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAsNeeded</enum>
+ </property>
+ </widget>
</item>
- <item row="1" column="2">
+ <item row="2" column="2">
<widget class="QLabel" name="selectedVersionLabel">
<property name="text">
<string>Version selected:</string>
@@ -52,9 +50,64 @@
</property>
</widget>
</item>
- <item row="1" column="0" colspan="2">
+ <item row="2" column="3">
+ <widget class="QComboBox" name="packVersionSelection"/>
+ </item>
+ <item row="2" column="0">
<widget class="QComboBox" name="sortByBox"/>
</item>
+ <item row="0" column="0" rowspan="2">
+ <widget class="QTabWidget" name="tabWidget_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="tabShape">
+ <enum>QTabWidget::Rounded</enum>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Public Packs</string>
+ </attribute>
+ <widget class="QTreeView" name="publicPackList">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>221</width>
+ <height>491</height>
+ </rect>
+ </property>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOn</enum>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QWidget" name="tab_3">
+ <attribute name="title">
+ <string>3rd Party Packs</string>
+ </attribute>
+ <widget class="QTreeView" name="thirdPartyPackList">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>221</width>
+ <height>491</height>
+ </rect>
+ </property>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOn</enum>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ </item>
</layout>
</widget>
</widget>