~jocave/checkbox/hybrid-amd-gpu-mods

« back to all changes in this revision

Viewing changes to checkbox-gui/checkbox-gui/qml/SuiteSelectionView.qml

  • Committer: Sylvain Pineau
  • Date: 2014-07-29 16:05:54 UTC
  • mto: This revision was merged to the branch mainline in revision 3149.
  • Revision ID: sylvain.pineau@canonical.com-20140729160554-qev8887xbunn9tmi
checkbox-ng:launchers:checkbox-cli: The checkbox-cli launcher

Running the default whitelist (with the suite selection screen skipped)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of Checkbox
 
3
 *
 
4
 * Copyright 2013 Canonical Ltd.
 
5
 *
 
6
 * Authors:
 
7
 * - Julia Segal <julia.segal@cellsoftware.co.uk>
 
8
 * - Andrew Haigh <andrew.haigh@cellsoftware.co.uk>
 
9
 *
 
10
 * This program is free software; you can redistribute it and/or modify
 
11
 * it under the terms of the GNU General Public License as published by
 
12
 * the Free Software Foundation; version 3.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
21
 */
 
22
 
 
23
 
 
24
import QtQuick 2.0
 
25
import Ubuntu.Components 0.1
 
26
import Ubuntu.Components.ListItems 0.1 as ListItem
 
27
import "."
 
28
 
 
29
 
 
30
 
 
31
 
 
32
Page {
 
33
    id: suiteselection
 
34
    title: i18n.tr("Suite Selection")
 
35
 
 
36
    tools: ToolbarItems {
 
37
        locked: true
 
38
        opened: false
 
39
    }
 
40
 
 
41
    Item {
 
42
        id: filler
 
43
        height: units.gu(4)
 
44
    }
 
45
 
 
46
    Rectangle {
 
47
        id: suitelist
 
48
        width: parent.width - units.gu(4)
 
49
        color: "white"
 
50
        height: parent.height - filler.height - okbutton.height - units.gu(6)
 
51
        anchors{
 
52
            horizontalCenter: parent.horizontalCenter
 
53
            top: filler.bottom
 
54
        }
 
55
 
 
56
        ListView {
 
57
            id: testselection
 
58
            height: parent.height
 
59
            width: parent.width
 
60
            anchors.fill: parent
 
61
            contentHeight: units.gu(12) * whiteListModel.count
 
62
            interactive: true
 
63
            clip: true
 
64
            boundsBehavior : Flickable.StopAtBounds
 
65
            model: whiteListModel
 
66
 
 
67
            delegate: SuiteSelectionDelegate{}
 
68
 
 
69
            signal suiteSelect();
 
70
 
 
71
            Component.onCompleted: {
 
72
                // First uncheck all the suites
 
73
                for (var i = whiteListModel.count - 1; i >= 0; i--){
 
74
                    var item = whiteListModel.get(i);
 
75
                    whiteListModel.setProperty(i, "check", false);
 
76
                }
 
77
                // Select only the one(s) matching the 'default' pattern
 
78
                for (var i = whiteListModel.count - 1; i >= 0; i--){
 
79
                    var item = whiteListModel.get(i);
 
80
                    if (item.testname.match(/default/i)) {
 
81
                        whiteListModel.setProperty(i, "check", true);
 
82
                    }
 
83
                }
 
84
                suiteSelect();
 
85
            }
 
86
        }
 
87
 
 
88
        Scrollbar {
 
89
            flickableItem: testselection
 
90
            align: Qt.AlignTrailing
 
91
        }
 
92
 
 
93
        // At least one whitelist MUST be selected
 
94
        function ensure_one_selection() {
 
95
            var one_selection = false;
 
96
 
 
97
            for (var i = whiteListModel.count - 1; i >= 0; i--){
 
98
                var item = whiteListModel.get(i);
 
99
 
 
100
                if (item.check === "true") {
 
101
                    one_selection = true;
 
102
                }
 
103
            }
 
104
 
 
105
            // If nothing is selected, disable the ok button
 
106
            okbutton.enabled = one_selection
 
107
        }
 
108
    }
 
109
 
 
110
    ActivityIndicator {
 
111
        id: suite_sel_activity
 
112
 
 
113
        running: false
 
114
 
 
115
        anchors.horizontalCenter: suitelist.horizontalCenter
 
116
        anchors.verticalCenter: suitelist.verticalCenter
 
117
    }
 
118
 
 
119
    Button {
 
120
        id: okbutton
 
121
        width: parent.width - units.gu(4)
 
122
        anchors {
 
123
            horizontalCenter:parent.horizontalCenter
 
124
            bottom: parent.bottom
 
125
            margins: units.gu(2)
 
126
        }
 
127
        enabled: false
 
128
        text: i18n.tr("OK")
 
129
        color: UbuntuColors.lightAubergine
 
130
        onClicked: {
 
131
            // Ensure we only ask the service about this once (Bug 1209284)
 
132
            okbutton.enabled = false;
 
133
 
 
134
            suite_sel_activity.running = true;
 
135
 
 
136
            suitelist.visible = false;
 
137
 
 
138
            /* Now, we should go run the guiengine update to run the local jobs
 
139
              which happen to match the whitelist. Then we can collect the
 
140
              test jobs and show them to the user.
 
141
             */
 
142
            guiEngine.RunLocalJobs();
 
143
        }
 
144
    }
 
145
 
 
146
    Connections {
 
147
        target: guiEngine
 
148
        onLocalJobsCompleted: {
 
149
            suite_sel_activity.running = false;
 
150
 
 
151
            // Now, we should repopulate the testlistmodel...
 
152
            testitemFactory.CreateTestListModel(testListModel);
 
153
            // NOTE: When the user is done, this is where to load up the TestSelection list
 
154
            mainView.state = "TESTSELECTION"
 
155
        }
 
156
    }
 
157
 
 
158
}