Mobile/filtering: full text filter, instead of just dive site

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2018-10-16 07:56:41 -04:00
parent 0bc0b6bfe8
commit 8f7633eff8
4 changed files with 14 additions and 5 deletions

View file

@ -10,8 +10,9 @@ DiveListSortModel::DiveListSortModel(QObject *parent) : QSortFilterProxyModel(pa
void DiveListSortModel::setFilter(QString f)
{
setFilterRole(DiveListModel::DiveSiteRole);
setFilterRegExp(f);
setFilterRole(DiveListModel::FullTextRole);
setFilterRegExp(QString(".*%1.*").arg(f));
setFilterCaseSensitivity(Qt::CaseInsensitive);
}
void DiveListSortModel::resetFilter()
@ -162,7 +163,7 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
switch(role) {
case DiveRole: return QVariant::fromValue<QObject*>(curr_dive);
case DiveDateRole: return (qlonglong)curr_dive->timestamp();
case DiveSiteRole: return curr_dive->location();
case FullTextRole: return curr_dive->fullText();
}
return QVariant();
@ -173,7 +174,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
QHash<int, QByteArray> roles;
roles[DiveRole] = "dive";
roles[DiveDateRole] = "date";
roles[DiveSiteRole] = "site";
roles[FullTextRole] = "fulltext";
return roles;
}