aboutsummaryrefslogtreecommitdiff
path: root/application/pages/modplatform
diff options
context:
space:
mode:
authorJamie Mansfield <jmansfield@cadixdev.org>2021-02-11 00:19:49 +0000
committerJamie Mansfield <jmansfield@cadixdev.org>2021-02-11 00:57:07 +0000
commit152d476f20d06dff6aecca057c3d01776f3ac975 (patch)
tree7ca127b820d1799fa502976385c8bcd41da64b53 /application/pages/modplatform
parent40bdb0ffd6dd1c028f12b5a5b145325a200e056e (diff)
downloadPrismLauncher-152d476f20d06dff6aecca057c3d01776f3ac975.tar.gz
PrismLauncher-152d476f20d06dff6aecca057c3d01776f3ac975.tar.bz2
PrismLauncher-152d476f20d06dff6aecca057c3d01776f3ac975.zip
NOISSUE Add search to ATLauncher
Diffstat (limited to 'application/pages/modplatform')
-rw-r--r--application/pages/modplatform/atlauncher/AtlFilterModel.cpp16
-rw-r--r--application/pages/modplatform/atlauncher/AtlFilterModel.h2
-rw-r--r--application/pages/modplatform/atlauncher/AtlPage.cpp12
-rw-r--r--application/pages/modplatform/atlauncher/AtlPage.h3
-rw-r--r--application/pages/modplatform/atlauncher/AtlPage.ui63
5 files changed, 73 insertions, 23 deletions
diff --git a/application/pages/modplatform/atlauncher/AtlFilterModel.cpp b/application/pages/modplatform/atlauncher/AtlFilterModel.cpp
index 8ea1546a..b5d8f22b 100644
--- a/application/pages/modplatform/atlauncher/AtlFilterModel.cpp
+++ b/application/pages/modplatform/atlauncher/AtlFilterModel.cpp
@@ -14,6 +14,8 @@ FilterModel::FilterModel(QObject *parent) : QSortFilterProxyModel(parent)
sortings.insert(tr("Sort by popularity"), Sorting::ByPopularity);
sortings.insert(tr("Sort by name"), Sorting::ByName);
sortings.insert(tr("Sort by game version"), Sorting::ByGameVersion);
+
+ searchTerm = "";
}
const QMap<QString, FilterModel::Sorting> FilterModel::getAvailableSortings()
@@ -37,9 +39,21 @@ FilterModel::Sorting FilterModel::getCurrentSorting()
return currentSorting;
}
+void FilterModel::setSearchTerm(const QString term)
+{
+ searchTerm = term.trimmed();
+ invalidate();
+}
+
bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
- return true;
+ if (searchTerm.isEmpty()) {
+ return true;
+ }
+
+ QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
+ ATLauncher::IndexedPack pack = sourceModel()->data(index, Qt::UserRole).value<ATLauncher::IndexedPack>();
+ return pack.name.contains(searchTerm, Qt::CaseInsensitive);
}
bool FilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
diff --git a/application/pages/modplatform/atlauncher/AtlFilterModel.h b/application/pages/modplatform/atlauncher/AtlFilterModel.h
index 2aef81fb..bd72ad91 100644
--- a/application/pages/modplatform/atlauncher/AtlFilterModel.h
+++ b/application/pages/modplatform/atlauncher/AtlFilterModel.h
@@ -18,6 +18,7 @@ public:
QString translateCurrentSorting();
void setSorting(Sorting sorting);
Sorting getCurrentSorting();
+ void setSearchTerm(QString term);
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
@@ -26,6 +27,7 @@ protected:
private:
QMap<QString, Sorting> sortings;
Sorting currentSorting;
+ QString searchTerm;
};
diff --git a/application/pages/modplatform/atlauncher/AtlPage.cpp b/application/pages/modplatform/atlauncher/AtlPage.cpp
index 4518248d..f90d734c 100644
--- a/application/pages/modplatform/atlauncher/AtlPage.cpp
+++ b/application/pages/modplatform/atlauncher/AtlPage.cpp
@@ -25,6 +25,8 @@ AtlPage::AtlPage(NewInstanceDialog* dialog, QWidget *parent)
}
ui->sortByBox->setCurrentText(filterModel->translateCurrentSorting());
+ connect(ui->searchEdit, &QLineEdit::textChanged, this, &AtlPage::triggerSearch);
+ connect(ui->resetButton, &QPushButton::clicked, this, &AtlPage::resetSearch);
connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &AtlPage::onSortingSelectionChanged);
connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &AtlPage::onSelectionChanged);
connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &AtlPage::onVersionSelectionChanged);
@@ -59,6 +61,16 @@ void AtlPage::suggestCurrent()
});
}
+void AtlPage::triggerSearch()
+{
+ filterModel->setSearchTerm(ui->searchEdit->text());
+}
+
+void AtlPage::resetSearch()
+{
+ ui->searchEdit->setText("");
+}
+
void AtlPage::onSortingSelectionChanged(QString data)
{
auto toSet = filterModel->getAvailableSortings().value(data);
diff --git a/application/pages/modplatform/atlauncher/AtlPage.h b/application/pages/modplatform/atlauncher/AtlPage.h
index fceb0abf..368de666 100644
--- a/application/pages/modplatform/atlauncher/AtlPage.h
+++ b/application/pages/modplatform/atlauncher/AtlPage.h
@@ -62,6 +62,9 @@ private:
void suggestCurrent();
private slots:
+ void triggerSearch();
+ void resetSearch();
+
void onSortingSelectionChanged(QString data);
void onSelectionChanged(QModelIndex first, QModelIndex second);
diff --git a/application/pages/modplatform/atlauncher/AtlPage.ui b/application/pages/modplatform/atlauncher/AtlPage.ui
index dd17283c..1a5a450d 100644
--- a/application/pages/modplatform/atlauncher/AtlPage.ui
+++ b/application/pages/modplatform/atlauncher/AtlPage.ui
@@ -11,30 +11,11 @@
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" colspan="2">
- <widget class="QTreeView" name="packView">
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="iconSize">
- <size>
- <width>96</width>
- <height>48</height>
- </size>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QTextBrowser" name="packDescription"/>
- </item>
- <item row="1" column="0" colspan="3">
- <layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0">
+ <item row="2" column="0" colspan="2">
+ <layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0" rowminimumheight="0" columnminimumwidth="0,0,0">
<item row="0" column="2">
<widget class="QComboBox" name="versionSelectionBox"/>
</item>
- <item row="0" column="0">
- <widget class="QComboBox" name="sortByBox"/>
- </item>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="text">
@@ -45,12 +26,50 @@
</property>
</widget>
</item>
+ <item row="0" column="0">
+ <widget class="QComboBox" name="sortByBox"/>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLineEdit" name="searchEdit"/>
+ </item>
+ <item row="0" column="1">
+ <widget class="QPushButton" name="resetButton">
+ <property name="text">
+ <string>Reset</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QTreeView" name="packView">
+ <property name="iconSize">
+ <size>
+ <width>96</width>
+ <height>48</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QTextBrowser" name="packDescription">
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ <property name="openLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
</layout>
</widget>
<tabstops>
- <tabstop>packView</tabstop>
+ <tabstop>searchEdit</tabstop>
+ <tabstop>resetButton</tabstop>
<tabstop>versionSelectionBox</tabstop>
</tabstops>
<resources/>