|
1 /* |
|
2 * Hedgewars, a free turn based strategy game |
|
3 * Copyright (c) 2004-2018 Andrey Korotaev <unC0Rr@gmail.com> |
|
4 * |
|
5 * This program is free software; you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License as published by |
|
7 * the Free Software Foundation; version 2 of the License |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU General Public License |
|
15 * along with this program; if not, write to the Free Software |
|
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
17 */ |
|
18 |
|
19 /** |
|
20 * @file |
|
21 * @brief ThemeFilterProxyModel class implementation |
|
22 */ |
|
23 |
|
24 #include "ThemeModel.h" |
|
25 #include "ThemeFilterProxyModel.h" |
|
26 |
|
27 ThemeFilterProxyModel::ThemeFilterProxyModel(QObject *parent) |
|
28 : QSortFilterProxyModel(parent) |
|
29 { |
|
30 isFilteringDLC = false; |
|
31 } |
|
32 |
|
33 bool ThemeFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const |
|
34 { |
|
35 if(isFilteringDLC) |
|
36 { |
|
37 QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); |
|
38 bool isDLC = index.data(ThemeModel::IsDlcRole).toBool(); |
|
39 return !isDLC; |
|
40 } |
|
41 else |
|
42 { |
|
43 return true; |
|
44 } |
|
45 } |
|
46 |
|
47 void ThemeFilterProxyModel::setFilterDLC(bool enable) |
|
48 { |
|
49 isFilteringDLC = enable; |
|
50 invalidateFilter(); |
|
51 } |