2
* Copyright 2012 Canonical Ltd.
4
* This file is part of telephony-app.
6
* telephony-app is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 3.
10
* telephony-app is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
property ListModel proxyModel: null
23
property ListModel model: ListModel { }
24
property string filter: ""
25
property variant fields: null
26
property int proxyCount: proxyModel ? proxyModel.count : 0
28
function checkFilter(element) {
29
if (filter.length == 0) {
33
var lowerFilter = filter.toLowerCase()
34
for (var i=0; i < fields.length; i++) {
35
var value = element[fields[i]].toLowerCase()
36
if (value.indexOf(lowerFilter) >= 0)
43
function applyFilter() {
45
for(var i=0; i < proxyModel.count; i++) {
46
var element = proxyModel.get(i)
47
if (checkFilter(element)) {
53
onProxyModelChanged: { applyFilter() }
54
onFilterChanged: { applyFilter() }
55
onProxyCountChanged: applyFilter()