on bbbdccd help sign in
unity8/tests/qmltests/Panel/IndicatorTest.qml
74 lines 2.4 kB history raw
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.4
18import QtQuick.Layouts 1.1
19import QtTest 1.0
20import "../../../qml/Panel"
21import Ubuntu.Components 1.3
22import Unity.Test 0.1 as UT
23import Unity.Indicators 0.1 as Indicators
25Rectangle {
26 id: root
27 color: "white"
29 property alias indicatorsModel: __indicatorsModel
30 property alias originalModelData: __indicatorsModel.originalModelData
32 Indicators.IndicatorsModel {
33 id: __indicatorsModel
34 Component.onCompleted: load();
35 }
37 function insertIndicator(index) {
38 var i;
39 var insertIndex = 0;
40 var done = false;
41 for (i = index; !done && i >= 1; i--) {
43 var lookFor = __indicatorsModel.originalModelData[i-1]["identifier"]
45 var j;
46 for (j = __indicatorsModel.modelData.length-1; !done && j >= 0; j--) {
47 if (__indicatorsModel.modelData[j]["identifier"] === lookFor) {
48 insertIndex = j+1;
49 done = true;
50 }
51 }
52 }
53 __indicatorsModel.insert(insertIndex, __indicatorsModel.originalModelData[index]);
54 }
56 function removeIndicator(index) {
57 var i;
58 for (i = 0; i < __indicatorsModel.modelData.length; i++) {
59 if (__indicatorsModel.modelData[i]["identifier"] === __indicatorsModel.originalModelData[index]["identifier"]) {
60 __indicatorsModel.remove(i);
61 break;
62 }
63 }
64 }
66 function setIndicatorVisible(index, visible) {
67 var identifier = __indicatorsModel.originalModelData[index]["identifier"];
68 __indicatorsModel.setIndicatorVisible(identifier, visible);
69 }
71 function resetData() {
72 __indicatorsModel.load();
73 }