Debian Codegraph @

Source/Core/DolphinQt/GameList/ListProxyModel.cpp

raw symbols SCIP
1 // Copyright 2017 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #include "DolphinQt/GameList/ListProxyModel.h"
5
6 #include "DolphinQt/GameList/GameListModel.h"
7
8 ListProxyModel::ListProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
9 {
10 setDynamicSortFilter(true);
11 }
12
13 bool ListProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
14 {
15 GameListModel* glm = qobject_cast<GameListModel*>(sourceModel());
16 return glm->ShouldDisplayGameListItem(source_row);
17 }
18
19 bool ListProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right) const
20 {
21 if (left.data(GameListModel::SORT_ROLE) != right.data(GameListModel::SORT_ROLE))
22 return QSortFilterProxyModel::lessThan(left, right);
23
24 // If two items are otherwise equal, compare them by their title
25 const auto right_title = sourceModel()
26 ->index(right.row(), static_cast<int>(GameListModel::Column::Title))
27 .data()
28 .toString();
29 const auto left_title = sourceModel()
30 ->index(left.row(), static_cast<int>(GameListModel::Column::Title))
31 .data()
32 .toString();
33
34 if (sortOrder() == Qt::AscendingOrder)
35 return left_title < right_title;
36
37 return right_title < left_title;
38 }