mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Qt: Implement search
This commit is contained in:
@ -521,3 +521,11 @@ void GameList::OnHeaderViewChanged()
|
||||
QSettings().setValue(QStringLiteral("tableheader/state"),
|
||||
m_list->horizontalHeader()->saveState());
|
||||
}
|
||||
|
||||
void GameList::SetSearchTerm(const QString& term)
|
||||
{
|
||||
m_model->SetSearchTerm(term);
|
||||
|
||||
m_list_proxy->invalidate();
|
||||
m_grid_proxy->invalidate();
|
||||
}
|
||||
|
@ -27,9 +27,10 @@ public:
|
||||
void SetListView() { SetPreferredView(true); }
|
||||
void SetGridView() { SetPreferredView(false); }
|
||||
void SetViewColumn(int col, bool view) { m_list->setColumnHidden(col, !view); }
|
||||
void SetSearchTerm(const QString& term);
|
||||
|
||||
void OnColumnVisibilityToggled(const QString& row, bool visible);
|
||||
void OnGameListVisibilityChanged();
|
||||
|
||||
signals:
|
||||
void GameSelected();
|
||||
void NetPlayHost(const QString& game_id);
|
||||
|
@ -150,6 +150,10 @@ bool GameListModel::ShouldDisplayGameListItem(int index) const
|
||||
{
|
||||
const UICommon::GameFile& game = *m_games[index];
|
||||
|
||||
if (!m_term.isEmpty() &&
|
||||
!QString::fromStdString(game.GetName()).contains(m_term, Qt::CaseInsensitive))
|
||||
return false;
|
||||
|
||||
const bool show_platform = [&game] {
|
||||
switch (game.GetPlatform())
|
||||
{
|
||||
@ -244,3 +248,8 @@ int GameListModel::FindGame(const std::string& path) const
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void GameListModel::SetSearchTerm(const QString& term)
|
||||
{
|
||||
m_term = term;
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ public:
|
||||
return QString::fromStdString(m_games[index]->GetUniqueIdentifier());
|
||||
}
|
||||
bool ShouldDisplayGameListItem(int index) const;
|
||||
void SetSearchTerm(const QString& term);
|
||||
|
||||
enum
|
||||
{
|
||||
COL_PLATFORM = 0,
|
||||
@ -60,4 +62,5 @@ private:
|
||||
|
||||
GameTracker m_tracker;
|
||||
QList<std::shared_ptr<const UICommon::GameFile>> m_games;
|
||||
QString m_term;
|
||||
};
|
||||
|
Reference in New Issue
Block a user