-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatients_filter_proxy_model.cpp
More file actions
47 lines (41 loc) · 1.51 KB
/
patients_filter_proxy_model.cpp
File metadata and controls
47 lines (41 loc) · 1.51 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
39
40
41
42
43
44
45
46
47
#include "patients_filter_proxy_model.h"
#include <QString>
#include <QStringList>
#include <QDate>
#include <QtDebug>
PatientsFilterProxyModel::PatientsFilterProxyModel(QObject *parent)
: QSortFilterProxyModel(parent)
{
}
bool PatientsFilterProxyModel::filterAcceptsRow(
int source_row, const QModelIndex &source_parent) const
{
QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent);
QModelIndex index1 = sourceModel()->index(source_row, 1, source_parent);
QStringList splitted_string = index0.data().toString().split(' ');
QString fname = splitted_string.at(0);
QString lname = splitted_string.at(1);
QString dad_name = splitted_string.at(2);
QDate checkDate;
checkDate = QDate::fromString(index1.data().toString(), "dd/MM/yyyy");
return (fname.contains(filterRegExp()) ||
lname.contains(filterRegExp()) ||
dad_name.contains(filterRegExp()) ||
index0.data().toString().contains(filterRegExp())) &&
((m_stillHere && m_Left) ||
( (m_stillHere && !m_Left) &&
(checkDate >= QDate::currentDate() || !checkDate.isValid())
) ||
( (!m_stillHere && m_Left) &&
checkDate < QDate::currentDate() &&
checkDate.isValid())
);
}
void PatientsFilterProxyModel::setStillHere(bool still_here) {
m_stillHere = still_here;
invalidateFilter();
}
void PatientsFilterProxyModel::setLeft(bool left) {
m_Left = left;
invalidateFilter();
}