feat: Integrate newly created filter dialog in ModPage
This commit is contained in:
parent
e0ab8207ed
commit
c2b97c3e3f
@ -80,7 +80,7 @@ void ModDownloadDialog::confirm()
|
||||
tr("Confirm mods to download")
|
||||
);
|
||||
|
||||
for(auto task : keys){
|
||||
for(auto& task : keys){
|
||||
confirm_dialog->appendMod(task, modTask.find(task).value()->getFilename());
|
||||
}
|
||||
|
||||
|
@ -2,21 +2,29 @@
|
||||
#include "ui_ModPage.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <memory>
|
||||
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "minecraft/PackProfile.h"
|
||||
#include "ui/dialogs/ModDownloadDialog.h"
|
||||
|
||||
ModPage::ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api)
|
||||
: QWidget(dialog), m_instance(instance), ui(new Ui::ModPage), dialog(dialog), api(api)
|
||||
: QWidget(dialog)
|
||||
, m_instance(instance)
|
||||
, ui(new Ui::ModPage)
|
||||
, dialog(dialog)
|
||||
, filter_dialog(static_cast<MinecraftInstance*>(instance)->getPackProfile()->getComponentVersion("net.minecraft"), this)
|
||||
, api(api)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->searchButton, &QPushButton::clicked, this, &ModPage::triggerSearch);
|
||||
connect(ui->modFilterButton, &QPushButton::clicked, this, &ModPage::filterMods);
|
||||
ui->searchEdit->installEventFilter(this);
|
||||
|
||||
ui->versionSelectionBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->versionSelectionBox->view()->parentWidget()->setMaximumHeight(300);
|
||||
|
||||
m_filter = filter_dialog.getFilter();
|
||||
}
|
||||
|
||||
ModPage::~ModPage()
|
||||
@ -49,6 +57,13 @@ auto ModPage::eventFilter(QObject* watched, QEvent* event) -> bool
|
||||
|
||||
/******** Callbacks to events in the UI (set up in the derived classes) ********/
|
||||
|
||||
void ModPage::filterMods()
|
||||
{
|
||||
filter_dialog.execWithInstance(static_cast<MinecraftInstance*>(m_instance));
|
||||
|
||||
m_filter = filter_dialog.getFilter();
|
||||
}
|
||||
|
||||
void ModPage::triggerSearch()
|
||||
{
|
||||
listModel->searchWithTerm(ui->searchEdit->text(), ui->sortByBox->currentIndex());
|
||||
@ -141,10 +156,15 @@ void ModPage::updateModVersions()
|
||||
|
||||
for (int i = 0; i < current.versions.size(); i++) {
|
||||
auto version = current.versions[i];
|
||||
bool valid = false;
|
||||
//NOTE: Flame doesn't care about loaderString, so passing it changes nothing.
|
||||
if (!validateVersion(version, mcVersion, loaderString)) {
|
||||
continue;
|
||||
for(auto& mcVer : m_filter->versions){
|
||||
if (validateVersion(version, mcVer.toString(), loaderString)) {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(valid)
|
||||
ui->versionSelectionBox->addItem(version.version, QVariant(i));
|
||||
}
|
||||
if (ui->versionSelectionBox->count() == 0) { ui->versionSelectionBox->addItem(tr("No valid version found!"), QVariant(-1)); }
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "Application.h"
|
||||
#include "modplatform/ModAPI.h"
|
||||
#include "modplatform/ModIndex.h"
|
||||
#include "ui/dialogs/FilterModsDialog.h"
|
||||
#include "ui/pages/BasePage.h"
|
||||
#include "ui/pages/modplatform/ModModel.h"
|
||||
|
||||
@ -39,6 +40,7 @@ class ModPage : public QWidget, public BasePage {
|
||||
virtual auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const -> bool = 0;
|
||||
|
||||
auto apiProvider() const -> const ModAPI* { return api.get(); };
|
||||
auto getFilter() const -> const std::shared_ptr<FilterModsDialog::Filter> { return m_filter; }
|
||||
|
||||
auto getCurrent() -> ModPlatform::IndexedPack& { return current; }
|
||||
void updateModVersions();
|
||||
@ -52,6 +54,7 @@ class ModPage : public QWidget, public BasePage {
|
||||
void updateSelectionButton();
|
||||
|
||||
protected slots:
|
||||
void filterMods();
|
||||
void triggerSearch();
|
||||
void onSelectionChanged(QModelIndex first, QModelIndex second);
|
||||
void onVersionSelectionChanged(QString data);
|
||||
@ -60,6 +63,10 @@ class ModPage : public QWidget, public BasePage {
|
||||
protected:
|
||||
Ui::ModPage* ui = nullptr;
|
||||
ModDownloadDialog* dialog = nullptr;
|
||||
|
||||
FilterModsDialog filter_dialog;
|
||||
std::shared_ptr<FilterModsDialog::Filter> m_filter;
|
||||
|
||||
ModPlatform::ListModel* listModel = nullptr;
|
||||
ModPlatform::IndexedPack current;
|
||||
|
||||
|
@ -51,12 +51,12 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="searchEdit">
|
||||
<property name="placeholderText">
|
||||
<string>Search and filter...</string>
|
||||
<string>Search for mods...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0,0">
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0">
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="versionSelectionBox"/>
|
||||
</item>
|
||||
@ -80,6 +80,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="modFilterButton">
|
||||
<property name="text">
|
||||
<string>Filter options</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user