mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Mobile/filtering: full text filter, instead of just dive site
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
0bc0b6bfe8
commit
8f7633eff8
4 changed files with 14 additions and 5 deletions
|
@ -434,3 +434,9 @@ QStringList DiveObjectHelper::firstGas() const
|
||||||
}
|
}
|
||||||
return gas;
|
return gas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for a full text search / filter function
|
||||||
|
QString DiveObjectHelper::fullText() const
|
||||||
|
{
|
||||||
|
return trip() + location() + buddy() + divemaster() + suit() + tags();
|
||||||
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ class DiveObjectHelper : public QObject {
|
||||||
Q_PROPERTY(QStringList startPressure READ startPressure CONSTANT)
|
Q_PROPERTY(QStringList startPressure READ startPressure CONSTANT)
|
||||||
Q_PROPERTY(QStringList endPressure READ endPressure CONSTANT)
|
Q_PROPERTY(QStringList endPressure READ endPressure CONSTANT)
|
||||||
Q_PROPERTY(QStringList firstGas READ firstGas CONSTANT)
|
Q_PROPERTY(QStringList firstGas READ firstGas CONSTANT)
|
||||||
|
Q_PROPERTY(QString fullText READ fullText CONSTANT)
|
||||||
public:
|
public:
|
||||||
DiveObjectHelper(struct dive *dive = NULL);
|
DiveObjectHelper(struct dive *dive = NULL);
|
||||||
~DiveObjectHelper();
|
~DiveObjectHelper();
|
||||||
|
@ -93,6 +94,7 @@ public:
|
||||||
QStringList startPressure() const;
|
QStringList startPressure() const;
|
||||||
QStringList endPressure() const;
|
QStringList endPressure() const;
|
||||||
QStringList firstGas() const;
|
QStringList firstGas() const;
|
||||||
|
QString fullText() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct dive *m_dive;
|
struct dive *m_dive;
|
||||||
|
|
|
@ -10,8 +10,9 @@ DiveListSortModel::DiveListSortModel(QObject *parent) : QSortFilterProxyModel(pa
|
||||||
|
|
||||||
void DiveListSortModel::setFilter(QString f)
|
void DiveListSortModel::setFilter(QString f)
|
||||||
{
|
{
|
||||||
setFilterRole(DiveListModel::DiveSiteRole);
|
setFilterRole(DiveListModel::FullTextRole);
|
||||||
setFilterRegExp(f);
|
setFilterRegExp(QString(".*%1.*").arg(f));
|
||||||
|
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveListSortModel::resetFilter()
|
void DiveListSortModel::resetFilter()
|
||||||
|
@ -162,7 +163,7 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
|
||||||
switch(role) {
|
switch(role) {
|
||||||
case DiveRole: return QVariant::fromValue<QObject*>(curr_dive);
|
case DiveRole: return QVariant::fromValue<QObject*>(curr_dive);
|
||||||
case DiveDateRole: return (qlonglong)curr_dive->timestamp();
|
case DiveDateRole: return (qlonglong)curr_dive->timestamp();
|
||||||
case DiveSiteRole: return curr_dive->location();
|
case FullTextRole: return curr_dive->fullText();
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
|
@ -173,7 +174,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
roles[DiveRole] = "dive";
|
roles[DiveRole] = "dive";
|
||||||
roles[DiveDateRole] = "date";
|
roles[DiveDateRole] = "date";
|
||||||
roles[DiveSiteRole] = "site";
|
roles[FullTextRole] = "fulltext";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
enum DiveListRoles {
|
enum DiveListRoles {
|
||||||
DiveRole = Qt::UserRole + 1,
|
DiveRole = Qt::UserRole + 1,
|
||||||
DiveDateRole,
|
DiveDateRole,
|
||||||
DiveSiteRole
|
FullTextRole
|
||||||
};
|
};
|
||||||
|
|
||||||
static DiveListModel *instance();
|
static DiveListModel *instance();
|
||||||
|
|
Loading…
Add table
Reference in a new issue