extended the modrinth search and applied the suggested change
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
6e5f616ced
commit
5bd5627a96
@ -391,7 +391,7 @@ QString ModrinthPage::getSerachTerm() const
|
|||||||
|
|
||||||
void ModrinthPage::createFilterWidget()
|
void ModrinthPage::createFilterWidget()
|
||||||
{
|
{
|
||||||
auto widget = ModFilterWidget::create(nullptr, false, this);
|
auto widget = ModFilterWidget::create(nullptr, true, this);
|
||||||
m_filterWidget.swap(widget);
|
m_filterWidget.swap(widget);
|
||||||
auto old = ui->splitter->replaceWidget(0, m_filterWidget.get());
|
auto old = ui->splitter->replaceWidget(0, m_filterWidget.get());
|
||||||
// because we replaced the widget we also need to delete it
|
// because we replaced the widget we also need to delete it
|
||||||
|
@ -64,6 +64,8 @@ class VersionBasicModel : public QIdentityProxyModel {
|
|||||||
{
|
{
|
||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DisplayRole)
|
||||||
return QIdentityProxyModel::data(index, BaseVersionList::VersionIdRole);
|
return QIdentityProxyModel::data(index, BaseVersionList::VersionIdRole);
|
||||||
|
if (role == Qt::UserRole)
|
||||||
|
return QIdentityProxyModel::data(index, BaseVersionList::VersionIdRole);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -86,6 +88,9 @@ class AllVersionProxyModel : public QSortFilterProxyModel {
|
|||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
return tr("All Versions");
|
return tr("All Versions");
|
||||||
}
|
}
|
||||||
|
if (role == Qt::UserRole) {
|
||||||
|
return "all";
|
||||||
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,17 +118,18 @@ ModFilterWidget::ModFilterWidget(MinecraftInstance* instance, bool extended, QWi
|
|||||||
QAbstractProxyModel* proxy = new VersionBasicModel(this);
|
QAbstractProxyModel* proxy = new VersionBasicModel(this);
|
||||||
proxy->setSourceModel(m_versions_proxy);
|
proxy->setSourceModel(m_versions_proxy);
|
||||||
|
|
||||||
if (!m_instance && !extended) {
|
if (extended) {
|
||||||
|
if (!m_instance) {
|
||||||
|
ui->environmentGroup->hide();
|
||||||
|
}
|
||||||
|
ui->versions->setSourceModel(proxy);
|
||||||
|
ui->versions->setSeparator(", ");
|
||||||
|
ui->versions->setDefaultText(tr("All Versions"));
|
||||||
|
ui->version->hide();
|
||||||
|
} else {
|
||||||
auto allVersions = new AllVersionProxyModel(this);
|
auto allVersions = new AllVersionProxyModel(this);
|
||||||
allVersions->setSourceModel(proxy);
|
allVersions->setSourceModel(proxy);
|
||||||
proxy = allVersions;
|
proxy = allVersions;
|
||||||
}
|
|
||||||
|
|
||||||
if (extended) {
|
|
||||||
ui->versions->setSourceModel(proxy);
|
|
||||||
ui->versions->setSeparator(", ");
|
|
||||||
ui->version->hide();
|
|
||||||
} else {
|
|
||||||
ui->version->setModel(proxy);
|
ui->version->setModel(proxy);
|
||||||
ui->versions->hide();
|
ui->versions->hide();
|
||||||
ui->showAllVersions->hide();
|
ui->showAllVersions->hide();
|
||||||
@ -293,7 +299,7 @@ void ModFilterWidget::onHideInstalledFilterChanged()
|
|||||||
void ModFilterWidget::onVersionFilterTextChanged(const QString& version)
|
void ModFilterWidget::onVersionFilterTextChanged(const QString& version)
|
||||||
{
|
{
|
||||||
m_filter->versions.clear();
|
m_filter->versions.clear();
|
||||||
if (version != tr("All Versions")) {
|
if (ui->version->currentData(Qt::UserRole) != "all") {
|
||||||
m_filter->versions.emplace_back(version);
|
m_filter->versions.emplace_back(version);
|
||||||
}
|
}
|
||||||
m_filter_changed = true;
|
m_filter_changed = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user