diff options
author | Petr Mrázek <peterix@gmail.com> | 2018-04-06 21:59:04 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2018-04-06 21:59:04 +0200 |
commit | 15926b2b4a50daa9eb20a0ad7255c6b5fb0d7246 (patch) | |
tree | 19ecc31f1c71da3ac4b7a52349a0fcfe920167a8 | |
parent | 6323aae56ff8bd1fb06da9044f9dd5e0df983bdc (diff) | |
download | MultiMC-15926b2b4a50daa9eb20a0ad7255c6b5fb0d7246.tar MultiMC-15926b2b4a50daa9eb20a0ad7255c6b5fb0d7246.tar.gz MultiMC-15926b2b4a50daa9eb20a0ad7255c6b5fb0d7246.tar.lz MultiMC-15926b2b4a50daa9eb20a0ad7255c6b5fb0d7246.tar.xz MultiMC-15926b2b4a50daa9eb20a0ad7255c6b5fb0d7246.zip |
NOISSUE make FTB pack selection fancier
-rw-r--r-- | application/pages/modplatform/FTBPage.cpp | 89 | ||||
-rw-r--r-- | application/pages/modplatform/FTBPage.h | 6 |
2 files changed, 56 insertions, 39 deletions
diff --git a/application/pages/modplatform/FTBPage.cpp b/application/pages/modplatform/FTBPage.cpp index bdfd1d8e..70e3ebd4 100644 --- a/application/pages/modplatform/FTBPage.cpp +++ b/application/pages/modplatform/FTBPage.cpp @@ -115,41 +115,52 @@ void FTBPage::ftbPackDataDownloadFailed(QString reason) //TODO: Display the error } -void FTBPage::onPublicPackSelectionChanged(QModelIndex first, QModelIndex second) +void FTBPage::onPublicPackSelectionChanged(QModelIndex now, QModelIndex prev) { - onPackSelectionChanged(first, second, publicFilterModel); + if(!now.isValid()) + { + onPackSelectionChanged(); + return; + } + FtbModpack selectedPack = publicFilterModel->data(now, Qt::UserRole).value<FtbModpack>(); + onPackSelectionChanged(&selectedPack); } -void FTBPage::onThirdPartyPackSelectionChanged(QModelIndex first, QModelIndex second) +void FTBPage::onThirdPartyPackSelectionChanged(QModelIndex now, QModelIndex prev) { - onPackSelectionChanged(first, second, thirdPartyFilterModel); + if(!now.isValid()) + { + onPackSelectionChanged(); + return; + } + FtbModpack selectedPack = thirdPartyFilterModel->data(now, Qt::UserRole).value<FtbModpack>(); + onPackSelectionChanged(&selectedPack); } -void FTBPage::onPackSelectionChanged(QModelIndex now, QModelIndex prev, FtbFilterModel *model) +void FTBPage::onPackSelectionChanged(FtbModpack* pack) { ui->packVersionSelection->clear(); - 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>"); - - bool currentAdded = false; - - for(int i = 0; i < selectedPack.oldVersions.size(); i++) + if(pack) { - if(selectedPack.currentVersion == selectedPack.oldVersions.at(i)) + 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++) { - currentAdded = true; + if(pack->currentVersion == pack->oldVersions.at(i)) + { + currentAdded = true; + } + ui->packVersionSelection->addItem(pack->oldVersions.at(i)); } - ui->packVersionSelection->addItem(selectedPack.oldVersions.at(i)); - } - if(!currentAdded) - { - ui->packVersionSelection->addItem(selectedPack.currentVersion); + if(!currentAdded) + { + ui->packVersionSelection->addItem(pack->currentVersion); + } + selected = *pack; } - - selected = selectedPack; suggestCurrent(); } @@ -164,16 +175,6 @@ void FTBPage::onVersionSelectionItemChanged(QString data) selectedVersion = data; } -FtbModpack FTBPage::getSelectedModpack() -{ - return selected; -} - -QString FTBPage::getSelectedVersion() -{ - return selectedVersion; -} - void FTBPage::onSortingSelectionChanged(QString data) { FtbFilterModel::Sorting toSet = publicFilterModel->getAvailableSortings().value(data); @@ -183,6 +184,26 @@ void FTBPage::onSortingSelectionChanged(QString data) void FTBPage::onTabChanged(int tab) { - ui->publicPackList->selectionModel()->reset(); - ui->thirdPartyPackList->selectionModel()->reset(); + 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(); + } } diff --git a/application/pages/modplatform/FTBPage.h b/application/pages/modplatform/FTBPage.h index a5327d31..00c5e9c5 100644 --- a/application/pages/modplatform/FTBPage.h +++ b/application/pages/modplatform/FTBPage.h @@ -58,12 +58,9 @@ public: bool shouldDisplay() const override; void openedImpl() override; - FtbModpack getSelectedModpack(); - QString getSelectedVersion(); - private: void suggestCurrent(); - void onPackSelectionChanged(QModelIndex first, QModelIndex second, FtbFilterModel *model); + void onPackSelectionChanged(FtbModpack *pack = nullptr); private slots: void ftbPackDataDownloadSuccessfully(FtbModpackList publicPacks, FtbModpackList thirdPartyPacks); @@ -79,7 +76,6 @@ private slots: private: bool initialized = false; - FtbModpack selectedPack; FtbModpack selected; QString selectedVersion; |