Changeset View
Changeset View
Standalone View
Standalone View
src/kcm/package/contents/ui/StreamRestoreTab.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright 2014-2015 Harald Sitter <sitter@kde.org> | ||||
3 | Copyright 2016 David Rosca <nowrep@gmail.com> | ||||
4 | | ||||
5 | This program is free software; you can redistribute it and/or | ||||
6 | modify it under the terms of the GNU General Public License as | ||||
7 | published by the Free Software Foundation; either version 2 of | ||||
8 | the License or (at your option) version 3 or any later version | ||||
9 | accepted by the membership of KDE e.V. (or its successor approved | ||||
10 | by the membership of KDE e.V.), which shall act as a proxy | ||||
11 | defined in Section 14 of version 3 of the license. | ||||
12 | | ||||
13 | This program is distributed in the hope that it will be useful, | ||||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
16 | GNU General Public License for more details. | ||||
17 | | ||||
18 | You should have received a copy of the GNU General Public License | ||||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
20 | */ | ||||
21 | | ||||
22 | import QtQuick 2.0 | ||||
23 | import QtQuick.Layouts 1.1 | ||||
24 | import QtQuick.Controls 1.3 | ||||
25 | import org.kde.plasma.core 2.1 as PlasmaCore | ||||
26 | | ||||
27 | import org.kde.plasma.private.volume 0.1 | ||||
28 | | ||||
29 | ColumnLayout { | ||||
30 | TextField { | ||||
31 | id: filterField | ||||
32 | Layout.fillWidth: true | ||||
33 | placeholderText: i18n("Search Streams") | ||||
34 | onTextChanged: filterModel.updateFilters() | ||||
35 | } | ||||
36 | | ||||
37 | ScrollView { | ||||
38 | id: scrollView | ||||
39 | Layout.fillWidth: true | ||||
40 | Layout.fillHeight: true | ||||
41 | | ||||
42 | ListView { | ||||
43 | id: eventStreamView | ||||
44 | interactive: false | ||||
45 | spacing: units.largeSpacing | ||||
46 | model: PlasmaCore.SortFilterModel { | ||||
47 | id: filterModel | ||||
48 | sourceModel: StreamRestoreModel {} | ||||
49 | filterCallback: filterModel.doFiltering | ||||
50 | | ||||
51 | function doFiltering(source_row, value) { | ||||
52 | var idx = sourceModel.index(source_row, 0); | ||||
53 | var streamName = sourceModel.data(idx, sourceModel.role("Name")); | ||||
54 | if (streamName.toLowerCase().indexOf(filterField.text.toLowerCase()) >= 0) { | ||||
55 | return true; | ||||
56 | } | ||||
57 | return false; | ||||
58 | } | ||||
59 | function emptyFilter(source_row, value) { | ||||
60 | return true; // Show all | ||||
61 | } | ||||
62 | function updateFilters() { | ||||
63 | // Manually trigger setFilterCallback() which will invalidate the filter. | ||||
64 | filterModel.filterCallback = filterModel.emptyFilter; | ||||
65 | filterModel.filterCallback = filterModel.doFiltering; | ||||
66 | } | ||||
67 | } | ||||
68 | delegate: StreamListItem { | ||||
69 | deviceModel: sinkModel | ||||
70 | } | ||||
71 | } | ||||
72 | } | ||||
73 | | ||||
74 | } |