summaryrefslogtreecommitdiffstats
path: root/application/pages/modplatform/FTBPage.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2018-07-15 14:51:05 +0200
committerPetr Mrázek <peterix@gmail.com>2018-07-15 14:51:05 +0200
commitbbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9 (patch)
treee6497e304b7b9368367565fbc7c06efab1124b1c /application/pages/modplatform/FTBPage.cpp
parent03280cc62e75f8073f8d3d9e9e3952acf21fa77d (diff)
downloadMultiMC-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.tar
MultiMC-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.tar.gz
MultiMC-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.tar.lz
MultiMC-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.tar.xz
MultiMC-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.zip
NOISSUE tabs -> spaces
Diffstat (limited to 'application/pages/modplatform/FTBPage.cpp')
-rw-r--r--application/pages/modplatform/FTBPage.cpp292
1 files changed, 146 insertions, 146 deletions
diff --git a/application/pages/modplatform/FTBPage.cpp b/application/pages/modplatform/FTBPage.cpp
index f438fce7..ae4dd92e 100644
--- a/application/pages/modplatform/FTBPage.cpp
+++ b/application/pages/modplatform/FTBPage.cpp
@@ -10,213 +10,213 @@
#include "FtbListModel.h"
FTBPage::FTBPage(NewInstanceDialog* dialog, QWidget *parent)
- : QWidget(parent), dialog(dialog), ui(new Ui::FTBPage)
+ : QWidget(parent), dialog(dialog), ui(new Ui::FTBPage)
{
- ftbFetchTask = new FtbPackFetchTask();
+ ftbFetchTask = new FtbPackFetchTask();
- ui->setupUi(this);
- ui->tabWidget->tabBar()->hide();
+ ui->setupUi(this);
+ ui->tabWidget->tabBar()->hide();
- {
- publicFilterModel = new FtbFilterModel(this);
- publicListModel = new FtbListModel(this);
- publicFilterModel->setSourceModel(publicListModel);
+ {
+ publicFilterModel = new FtbFilterModel(this);
+ publicListModel = new FtbListModel(this);
+ publicFilterModel->setSourceModel(publicListModel);
- ui->publicPackList->setModel(publicFilterModel);
- ui->publicPackList->setSortingEnabled(true);
- ui->publicPackList->header()->hide();
- ui->publicPackList->setIndentation(0);
- ui->publicPackList->setIconSize(QSize(42, 42));
+ ui->publicPackList->setModel(publicFilterModel);
+ ui->publicPackList->setSortingEnabled(true);
+ ui->publicPackList->header()->hide();
+ ui->publicPackList->setIndentation(0);
+ ui->publicPackList->setIconSize(QSize(42, 42));
- for(int i = 0; i < publicFilterModel->getAvailableSortings().size(); i++)
- {
- ui->sortByBox->addItem(publicFilterModel->getAvailableSortings().keys().at(i));
- }
+ for(int i = 0; i < publicFilterModel->getAvailableSortings().size(); i++)
+ {
+ ui->sortByBox->addItem(publicFilterModel->getAvailableSortings().keys().at(i));
+ }
- ui->sortByBox->setCurrentText(publicFilterModel->translateCurrentSorting());
- }
+ ui->sortByBox->setCurrentText(publicFilterModel->translateCurrentSorting());
+ }
- {
- thirdPartyFilterModel = new FtbFilterModel(this);
- thirdPartyModel = new FtbListModel(this);
- thirdPartyFilterModel->setSourceModel(thirdPartyModel);
+ {
+ 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);
- ui->thirdPartyPackList->setIconSize(QSize(42, 42));
+ ui->thirdPartyPackList->setModel(thirdPartyFilterModel);
+ ui->thirdPartyPackList->setSortingEnabled(true);
+ ui->thirdPartyPackList->header()->hide();
+ ui->thirdPartyPackList->setIndentation(0);
+ ui->thirdPartyPackList->setIconSize(QSize(42, 42));
- thirdPartyFilterModel->setSorting(publicFilterModel->getCurrentSorting());
- }
+ thirdPartyFilterModel->setSorting(publicFilterModel->getCurrentSorting());
+ }
- ui->packVersionSelection->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
- ui->packVersionSelection->view()->parentWidget()->setMaximumHeight(300);
+ ui->packVersionSelection->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ ui->packVersionSelection->view()->parentWidget()->setMaximumHeight(300);
- connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &FTBPage::onSortingSelectionChanged);
- connect(ui->packVersionSelection, &QComboBox::currentTextChanged, this, &FTBPage::onVersionSelectionItemChanged);
+ connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &FTBPage::onSortingSelectionChanged);
+ connect(ui->packVersionSelection, &QComboBox::currentTextChanged, this, &FTBPage::onVersionSelectionItemChanged);
- connect(ui->publicPackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &FTBPage::onPublicPackSelectionChanged);
- connect(ui->thirdPartyPackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &FTBPage::onThirdPartyPackSelectionChanged);
+ connect(ui->publicPackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &FTBPage::onPublicPackSelectionChanged);
+ connect(ui->thirdPartyPackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &FTBPage::onThirdPartyPackSelectionChanged);
- connect(ui->ftbTabWidget, &QTabWidget::currentChanged, this, &FTBPage::onTabChanged);
+ connect(ui->ftbTabWidget, &QTabWidget::currentChanged, this, &FTBPage::onTabChanged);
- ui->modpackInfo->setOpenExternalLinks(true);
+ ui->modpackInfo->setOpenExternalLinks(true);
- ui->publicPackList->selectionModel()->reset();
- ui->thirdPartyPackList->selectionModel()->reset();
+ ui->publicPackList->selectionModel()->reset();
+ ui->thirdPartyPackList->selectionModel()->reset();
}
FTBPage::~FTBPage()
{
- delete ui;
- if(ftbFetchTask) {
- ftbFetchTask->deleteLater();
- }
+ delete ui;
+ if(ftbFetchTask) {
+ ftbFetchTask->deleteLater();
+ }
}
bool FTBPage::shouldDisplay() const
{
- return true;
+ return true;
}
void FTBPage::openedImpl()
{
- if(!initialized)
- {
- connect(ftbFetchTask, &FtbPackFetchTask::finished, this, &FTBPage::ftbPackDataDownloadSuccessfully);
- connect(ftbFetchTask, &FtbPackFetchTask::failed, this, &FTBPage::ftbPackDataDownloadFailed);
- ftbFetchTask->fetch();
- initialized = true;
- }
- suggestCurrent();
+ if(!initialized)
+ {
+ connect(ftbFetchTask, &FtbPackFetchTask::finished, this, &FTBPage::ftbPackDataDownloadSuccessfully);
+ connect(ftbFetchTask, &FtbPackFetchTask::failed, this, &FTBPage::ftbPackDataDownloadFailed);
+ ftbFetchTask->fetch();
+ initialized = true;
+ }
+ suggestCurrent();
}
void FTBPage::suggestCurrent()
{
- if(isOpened)
- {
- if(!selected.broken)
- {
- dialog->setSuggestedPack(selected.name, new FtbPackInstallTask(selected, selectedVersion));
- if(selected.type == FtbPackType::Public) {
- publicListModel->getLogo(selected.logo, [this](QString logo){
- dialog->setSuggestedIconFromFile(logo, "ftb_" + selected.name);
- });
- } else if (selected.type == FtbPackType::ThirdParty) {
- thirdPartyModel->getLogo(selected.logo, [this](QString logo){
- dialog->setSuggestedIconFromFile(logo, "ftb_" + selected.name);
- });
- }
- }
- else
- {
- dialog->setSuggestedPack();
- }
- }
+ if(isOpened)
+ {
+ if(!selected.broken)
+ {
+ dialog->setSuggestedPack(selected.name, new FtbPackInstallTask(selected, selectedVersion));
+ if(selected.type == FtbPackType::Public) {
+ publicListModel->getLogo(selected.logo, [this](QString logo){
+ dialog->setSuggestedIconFromFile(logo, "ftb_" + selected.name);
+ });
+ } else if (selected.type == FtbPackType::ThirdParty) {
+ thirdPartyModel->getLogo(selected.logo, [this](QString logo){
+ dialog->setSuggestedIconFromFile(logo, "ftb_" + selected.name);
+ });
+ }
+ }
+ else
+ {
+ dialog->setSuggestedPack();
+ }
+ }
}
void FTBPage::ftbPackDataDownloadSuccessfully(FtbModpackList publicPacks, FtbModpackList thirdPartyPacks)
{
- publicListModel->fill(publicPacks);
- thirdPartyModel->fill(thirdPartyPacks);
+ publicListModel->fill(publicPacks);
+ thirdPartyModel->fill(thirdPartyPacks);
}
void FTBPage::ftbPackDataDownloadFailed(QString reason)
{
- //TODO: Display the error
+ //TODO: Display the error
}
void FTBPage::onPublicPackSelectionChanged(QModelIndex now, QModelIndex prev)
{
- if(!now.isValid())
- {
- onPackSelectionChanged();
- return;
- }
- FtbModpack selectedPack = publicFilterModel->data(now, Qt::UserRole).value<FtbModpack>();
- onPackSelectionChanged(&selectedPack);
+ if(!now.isValid())
+ {
+ onPackSelectionChanged();
+ return;
+ }
+ FtbModpack selectedPack = publicFilterModel->data(now, Qt::UserRole).value<FtbModpack>();
+ onPackSelectionChanged(&selectedPack);
}
void FTBPage::onThirdPartyPackSelectionChanged(QModelIndex now, QModelIndex prev)
{
- if(!now.isValid())
- {
- onPackSelectionChanged();
- return;
- }
- FtbModpack selectedPack = thirdPartyFilterModel->data(now, Qt::UserRole).value<FtbModpack>();
- onPackSelectionChanged(&selectedPack);
+ if(!now.isValid())
+ {
+ onPackSelectionChanged();
+ return;
+ }
+ FtbModpack selectedPack = thirdPartyFilterModel->data(now, Qt::UserRole).value<FtbModpack>();
+ onPackSelectionChanged(&selectedPack);
}
void FTBPage::onPackSelectionChanged(FtbModpack* pack)
{
- ui->packVersionSelection->clear();
- if(pack)
- {
- ui->modpackInfo->setHtml("Pack by <b>" + pack->author + "</b>" + "<br>Minecraft " + pack->mcVersion + "<br>"
- "<br>" + pack->description + "<ul><li>" + pack->mods.replace(";", "</li><li>") + "</li></ul>");
- bool currentAdded = false;
-
- for(int i = 0; i < pack->oldVersions.size(); i++)
- {
- if(pack->currentVersion == pack->oldVersions.at(i))
- {
- currentAdded = true;
- }
- ui->packVersionSelection->addItem(pack->oldVersions.at(i));
- }
-
- if(!currentAdded)
- {
- ui->packVersionSelection->addItem(pack->currentVersion);
- }
- selected = *pack;
- }
- suggestCurrent();
+ ui->packVersionSelection->clear();
+ if(pack)
+ {
+ ui->modpackInfo->setHtml("Pack by <b>" + pack->author + "</b>" + "<br>Minecraft " + pack->mcVersion + "<br>"
+ "<br>" + pack->description + "<ul><li>" + pack->mods.replace(";", "</li><li>") + "</li></ul>");
+ bool currentAdded = false;
+
+ for(int i = 0; i < pack->oldVersions.size(); i++)
+ {
+ if(pack->currentVersion == pack->oldVersions.at(i))
+ {
+ currentAdded = true;
+ }
+ ui->packVersionSelection->addItem(pack->oldVersions.at(i));
+ }
+
+ if(!currentAdded)
+ {
+ ui->packVersionSelection->addItem(pack->currentVersion);
+ }
+ selected = *pack;
+ }
+ suggestCurrent();
}
void FTBPage::onVersionSelectionItemChanged(QString data)
{
- if(data.isNull() || data.isEmpty())
- {
- selectedVersion = "";
- return;
- }
-
- selectedVersion = data;
- suggestCurrent();
+ if(data.isNull() || data.isEmpty())
+ {
+ selectedVersion = "";
+ return;
+ }
+
+ selectedVersion = data;
+ suggestCurrent();
}
void FTBPage::onSortingSelectionChanged(QString data)
{
- FtbFilterModel::Sorting toSet = publicFilterModel->getAvailableSortings().value(data);
- publicFilterModel->setSorting(toSet);
- thirdPartyFilterModel->setSorting(toSet);
+ FtbFilterModel::Sorting toSet = publicFilterModel->getAvailableSortings().value(data);
+ publicFilterModel->setSorting(toSet);
+ thirdPartyFilterModel->setSorting(toSet);
}
void FTBPage::onTabChanged(int tab)
{
- FtbFilterModel* currentModel = nullptr;
- QTreeView* currentList = nullptr;
- if (tab == 0)
- {
- currentModel = publicFilterModel;
- currentList = ui->publicPackList;
- }
- else
- {
- currentModel = thirdPartyFilterModel;
- currentList = ui->thirdPartyPackList;
- }
- QModelIndex idx = currentList->currentIndex();
- if(idx.isValid())
- {
- auto pack = currentModel->data(idx, Qt::UserRole).value<FtbModpack>();
- onPackSelectionChanged(&pack);
- }
- else
- {
- onPackSelectionChanged();
- }
+ FtbFilterModel* currentModel = nullptr;
+ QTreeView* currentList = nullptr;
+ if (tab == 0)
+ {
+ currentModel = publicFilterModel;
+ currentList = ui->publicPackList;
+ }
+ else
+ {
+ currentModel = thirdPartyFilterModel;
+ currentList = ui->thirdPartyPackList;
+ }
+ QModelIndex idx = currentList->currentIndex();
+ if(idx.isValid())
+ {
+ auto pack = currentModel->data(idx, Qt::UserRole).value<FtbModpack>();
+ onPackSelectionChanged(&pack);
+ }
+ else
+ {
+ onPackSelectionChanged();
+ }
}