on bb09f86 help sign in
unity8/tests/qmltests/Panel/PanelTest.qml
70 lines 2.3 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 Unity.Indicators 0.1 as Indicators
20Rectangle {
21 id: root
22 color: theme.palette.normal.background
23 Component.onCompleted: theme.name = "Ubuntu.Components.Themes.SuruDark"
25 property alias indicatorsModel: __indicatorsModel
26 property alias originalModelData: __indicatorsModel.originalModelData
28 Indicators.IndicatorsModel {
29 id: __indicatorsModel
30 Component.onCompleted: load();
31 }
33 function insertIndicator(index) {
34 var i;
35 var insertIndex = 0;
36 var done = false;
37 for (i = index; !done && i >= 1; i--) {
39 var lookFor = __indicatorsModel.originalModelData[i-1]["identifier"]
41 var j;
42 for (j = __indicatorsModel.modelData.length-1; !done && j >= 0; j--) {
43 if (__indicatorsModel.modelData[j]["identifier"] === lookFor) {
44 insertIndex = j+1;
45 done = true;
46 }
47 }
48 }
49 __indicatorsModel.insert(insertIndex, __indicatorsModel.originalModelData[index]);
50 }
52 function removeIndicator(index) {
53 var i;
54 for (i = 0; i < __indicatorsModel.modelData.length; i++) {
55 if (__indicatorsModel.modelData[i]["identifier"] === __indicatorsModel.originalModelData[index]["identifier"]) {
56 __indicatorsModel.remove(i);
57 break;
58 }
59 }
60 }
62 function setIndicatorVisible(index, visible) {
63 var identifier = __indicatorsModel.originalModelData[index]["identifier"];
64 __indicatorsModel.setIndicatorVisible(identifier, visible);
65 }
67 function resetData() {
68 __indicatorsModel.load();
69 }