Changeset View
Changeset View
Standalone View
Standalone View
src/presentation/taskfilterproxymodel.cpp
Show All 15 Lines | 1 | /* This file is part of Zanshin | |||
---|---|---|---|---|---|
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. | ||
17 | 17 | | |||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software | ||
20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
21 | USA. | 21 | USA. | ||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | #include <QRegularExpression> | ||||
24 | 25 | | |||
25 | #include "taskfilterproxymodel.h" | 26 | #include "taskfilterproxymodel.h" | ||
26 | 27 | | |||
27 | #include <limits> | 28 | #include <limits> | ||
28 | 29 | | |||
29 | #include "domain/task.h" | 30 | #include "domain/task.h" | ||
30 | #include "utils/datetime.h" | 31 | #include "utils/datetime.h" | ||
31 | 32 | | |||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 78 | { | |||
84 | return task->startDate() > Utils::DateTime::currentDate(); | 85 | return task->startDate() > Utils::DateTime::currentDate(); | ||
85 | } | 86 | } | ||
86 | 87 | | |||
87 | bool TaskFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const | 88 | bool TaskFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const | ||
88 | { | 89 | { | ||
89 | const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); | 90 | const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); | ||
90 | const auto task = index.data(QueryTreeModelBase::ObjectRole).value<Domain::Task::Ptr>(); | 91 | const auto task = index.data(QueryTreeModelBase::ObjectRole).value<Domain::Task::Ptr>(); | ||
91 | if (task) { | 92 | if (task) { | ||
92 | QRegExp regexp = filterRegExp(); | 93 | QRegularExpression regexp = filterRegularExpression(); | ||
93 | regexp.setCaseSensitivity(Qt::CaseInsensitive); | 94 | regexp.setPatternOptions(QRegularExpression::CaseInsensitiveOption); | ||
94 | 95 | | |||
95 | if (task->title().contains(regexp) | 96 | if (task->title().contains(regexp) | ||
96 | || task->text().contains(regexp)) { | 97 | || task->text().contains(regexp)) { | ||
97 | return m_showFuture || !isFutureTask(task); | 98 | return m_showFuture || !isFutureTask(task); | ||
98 | } | 99 | } | ||
99 | } | 100 | } | ||
100 | 101 | | |||
101 | for (int childRow = 0; childRow < sourceModel()->rowCount(index); childRow++) { | 102 | for (int childRow = 0; childRow < sourceModel()->rowCount(index); childRow++) { | ||
Show All 34 Lines |