Mercurial > retraceit
comparison src/includeemptysortmodel.cpp @ 88:3916cb3c9105
Add new FilterSort model that allows to include empty values
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 19 Jun 2015 14:26:16 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
87:3b3a1384eb5f | 88:3916cb3c9105 |
---|---|
1 /* Copyright (C) 2015 by ETH Zürich | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=2) | |
5 * and comes with ABSOLUTELY NO WARRANTY! | |
6 * See LICENSE.txt for details. | |
7 */ | |
8 #include "includeemptysortmodel.h" | |
9 | |
10 bool IncludeEmptySortModel::filterAcceptsRow(int row, const QModelIndex &parent) const | |
11 { | |
12 bool parentAcceptsRow = QSortFilterProxyModel::filterAcceptsRow(row, parent); | |
13 if (!mIncludeEmpty || parentAcceptsRow) { | |
14 return parentAcceptsRow; | |
15 } | |
16 | |
17 QModelIndex source_index = sourceModel()->index(row, filterKeyColumn(), parent); | |
18 if (!source_index.isValid()) // the column may not exist | |
19 return true; | |
20 QString key = sourceModel()->data(source_index).toString(); | |
21 return key.isEmpty(); | |
22 } |