-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshowlistproxymodel.cpp
More file actions
executable file
·38 lines (30 loc) · 1.27 KB
/
Copy pathshowlistproxymodel.cpp
File metadata and controls
executable file
·38 lines (30 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "showlistproxymodel.h"
#include "showlistmodel.h"
#include <QDebug>
ShowListProxyModel::ShowListProxyModel(QObject *parent)
: QSortFilterProxyModel(parent), filter_fav(false)
{
}
bool ShowListProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const
{
QModelIndex index_id = sourceModel()->index(sourceRow, ShowListModel::COLUMN_ID, sourceParent);
QModelIndex index_title = sourceModel()->index(sourceRow, ShowListModel::COLUMN_TITLE, sourceParent);
QModelIndex index_perso = sourceModel()->index(sourceRow, ShowListModel::COLUMN_PERSO, sourceParent);
if(filter_fav) {
// If we have our favorite filter enabled, don't show the item if it's not a favorite
ShowListModel *model = (ShowListModel*)sourceModel();
if(!model->isFavorite(sourceRow))
return false;
}
if(!filterRegExp().isEmpty()) {
return (sourceModel()->data(index_id).toString().contains(filterRegExp())
|| sourceModel()->data(index_title).toString().contains(filterRegExp())
|| sourceModel()->data(index_perso).toString().contains(filterRegExp()));
}
return true;
}
void ShowListProxyModel::setFilterFav(bool filter)
{
filter_fav = filter;
invalidateFilter();
}