-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflightsproxymodel.cpp
More file actions
33 lines (26 loc) · 853 Bytes
/
Copy pathflightsproxymodel.cpp
File metadata and controls
33 lines (26 loc) · 853 Bytes
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
#include "flightsproxymodel.h"
#include <QModelIndex>
#include <QVariant>
FlightsProxyModel::FlightsProxyModel(QObject *parent)
: QSortFilterProxyModel(parent)
{
}
void FlightsProxyModel::setOnlyConflicts(bool onlyConflicts)
{
if (m_onlyConflicts == onlyConflicts)
return;
m_onlyConflicts = onlyConflicts;
invalidateFilter();
}
bool FlightsProxyModel::filterAcceptsRow(int sourceRow,
const QModelIndex &sourceParent) const
{
if (!m_onlyConflicts)
return true;
if (!sourceModel())
return false;
QModelIndex statusIndex = sourceModel()->index(sourceRow, 6, sourceParent);
const QString status =
sourceModel()->data(statusIndex, Qt::DisplayRole).toString();
return (status == QStringLiteral("CONFLICT"));
}