Merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/devicepage into lp:qtcreator-plugin-ubuntu

Proposed by Benjamin Zeller
Status: Merged
Merged at revision: 134
Proposed branch: lp:~zeller-benjamin/qtcreator-plugin-ubuntu/devicepage
Merge into: lp:qtcreator-plugin-ubuntu
Diff against target: 3275 lines (+2562/-68)
34 files modified
manifest.json (+15/-0)
share/qtcreator/ubuntu/devicespage/DeviceAdvancedTab.qml (+92/-0)
share/qtcreator/ubuntu/devicespage/DeviceBuilderTab.qml (+42/-0)
share/qtcreator/ubuntu/devicespage/DeviceLogTab.qml (+12/-0)
share/qtcreator/ubuntu/devicespage/DevicePage.qml (+105/-0)
share/qtcreator/ubuntu/devicespage/DeviceStatusTab.qml (+108/-0)
share/qtcreator/ubuntu/devicespage/EmulatorPage.qml (+150/-0)
share/qtcreator/ubuntu/devicespage/FeatureStateItem.qml (+46/-0)
share/qtcreator/ubuntu/devicespage/LogPage.qml (+24/-0)
share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml (+46/-0)
share/qtcreator/ubuntu/devicespage/devicespage.qmlproject (+20/-0)
share/qtcreator/ubuntu/devicespage/dummydata/devicesModel.qml (+52/-0)
share/qtcreator/ubuntu/devicespage/main.qml (+25/-0)
share/qtcreator/ubuntu/devicespage/test.qml# (+18/-0)
share/qtcreator/ubuntu/scripts/local_start_emulator (+0/-1)
src/ubuntu/resources.qrc (+2/-0)
src/ubuntu/ubuntu.pro (+27/-5)
src/ubuntu/ubuntuconstants.h (+4/-2)
src/ubuntu/ubuntudevice.cpp (+125/-20)
src/ubuntu/ubuntudevice.h (+9/-4)
src/ubuntu/ubuntudevicemode.cpp (+91/-9)
src/ubuntu/ubuntudevicemode.h (+42/-2)
src/ubuntu/ubuntudevicesmodel.cpp (+734/-0)
src/ubuntu/ubuntudevicesmodel.h (+169/-0)
src/ubuntu/ubuntuemulatormodel.cpp (+408/-0)
src/ubuntu/ubuntuemulatormodel.h (+102/-0)
src/ubuntu/ubuntukitmanager.cpp (+50/-1)
src/ubuntu/ubuntukitmanager.h (+3/-0)
src/ubuntu/ubuntumenu.cpp (+9/-4)
src/ubuntu/ubuntuplugin.cpp (+4/-1)
src/ubuntu/ubuntuprocess.cpp (+5/-6)
src/ubuntu/ubuntuprocess.h (+3/-2)
src/ubuntu/ubunturemoterunconfiguration.cpp (+20/-10)
src/ubuntu/ubuntusettingsdeviceconnectivitywidget.cpp (+0/-1)
To merge this branch: bzr merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/devicepage
Reviewer Review Type Date Requested Status
Zoltan Balogh Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+217232@code.launchpad.net

Commit message

- Added new QML based devices mode
- Reworked backend that handles devices and emulators and put
  it into QAbstractListModel derived classes to control them from QML
- Fixed a bug with starting applications on the device that don't use
   a launcher
- Switched to the RemoteLinux configuration widget , it provides better
  informations about the device state in the options dialog
- Easy creation of Kits for devices that are not assigned (Autocreate Kit)

Description of the change

New devices page

To post a comment you must log in.
149. By Benjamin Zeller

Removed user file (how did they get in there?)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zoltan Balogh (bzoltan) wrote :

Is the welcome.qmlproject.user intentional?

Revision history for this message
Benjamin Zeller (zeller-benjamin) wrote :

> Is the welcome.qmlproject.user intentional?
Meh, of course not, also not the manifest and apparmor files

150. By Benjamin Zeller

Removed other not required files

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zoltan Balogh (bzoltan) wrote :

what about the share/qtcreator/ubuntu/devicespage/test.qml file ?

151. By Benjamin Zeller

deleted more files

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zoltan Balogh (bzoltan) wrote :

OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.excludes'
2=== added file 'manifest.json'
3--- manifest.json 1970-01-01 00:00:00 +0000
4+++ manifest.json 2014-04-27 13:29:17 +0000
5@@ -0,0 +1,15 @@
6+{
7+ "architecture": "all",
8+ "description": "description of qtcreator-plugin-ubuntu",
9+ "framework": "ubuntu-sdk-13.10",
10+ "hooks": {
11+ "qtcreator-plugin-ubuntu": {
12+ "apparmor": "qtcreator-plugin-ubuntu.json",
13+ "desktop": "qtcreator-plugin-ubuntu.desktop"
14+ }
15+ },
16+ "maintainer": "Benjamin Zeller <benjamin.zeller@canonical.com>",
17+ "name": "com.ubuntu.developer.zeller-benjamin.qtcreator-plugin-ubuntu",
18+ "title": "qtcreator-plugin-ubuntu",
19+ "version": "0.1"
20+}
21\ No newline at end of file
22
23=== added directory 'share/qtcreator/ubuntu/devicespage'
24=== added file 'share/qtcreator/ubuntu/devicespage/.excludes'
25=== added file 'share/qtcreator/ubuntu/devicespage/DeviceAdvancedTab.qml'
26--- share/qtcreator/ubuntu/devicespage/DeviceAdvancedTab.qml 1970-01-01 00:00:00 +0000
27+++ share/qtcreator/ubuntu/devicespage/DeviceAdvancedTab.qml 2014-04-27 13:29:17 +0000
28@@ -0,0 +1,92 @@
29+import QtQuick 2.0
30+import QtQuick.Controls 1.0 as Controls
31+import QtQuick.Layouts 1.0
32+import Ubuntu.Components 0.1
33+import Ubuntu.Components.ListItems 0.1 as ListItem
34+
35+
36+RowLayout {
37+ Controls.ScrollView {
38+ Layout.fillHeight: true
39+ Layout.minimumWidth: units.gu(78)
40+ UbuntuListView {
41+ model: VisualItemModel{
42+ Label {
43+ text: "Device Control"
44+ fontSize: "large"
45+ anchors.left: parent.left
46+ }
47+ ListItem.Standard {
48+ text:"Clone time config from Host to Device"
49+ control: Button{
50+ text: "Execute"
51+ enabled: !deviceItemView.deviceBusy
52+ onClicked: devicesModel.triggerCloneTimeConfig(deviceId)
53+ }
54+ }
55+ ListItem.Standard {
56+ text:"Enable port forwarding"
57+ control: Button{
58+ text: "Execute"
59+ enabled: !deviceItemView.deviceBusy
60+ onClicked: devicesModel.triggerPortForwarding(deviceId)
61+ }
62+ }
63+ ListItem.Standard {
64+ text:"Setup public key authentication"
65+ control: Button{
66+ text: "Execute"
67+ enabled: !deviceItemView.deviceBusy
68+ onClicked: devicesModel.triggerSSHSetup(deviceId)
69+ }
70+ }
71+ ListItem.Standard {
72+ text:"Open SSH connection to the device"
73+ control: Button{
74+ text: "Execute"
75+ enabled: !deviceItemView.deviceBusy
76+ onClicked: devicesModel.triggerSSHConnection(deviceId)
77+ }
78+ }
79+ ListItem.Divider{}
80+ Label {
81+ text: "Device Mode"
82+ fontSize: "large"
83+ }
84+ ListItem.Standard {
85+ text:"Reboot"
86+ control: Button{
87+ text: "Execute"
88+ enabled: !deviceItemView.deviceBusy
89+ onClicked: devicesModel.triggerReboot(deviceId)
90+ }
91+ }
92+ ListItem.Standard {
93+ text:"Reboot to bootloader"
94+ control: Button{
95+ text: "Execute"
96+ enabled: !deviceItemView.deviceBusy
97+ onClicked: devicesModel.triggerRebootBootloader(deviceId)
98+ }
99+ }
100+ ListItem.Standard {
101+ text:"Reboot to recovery"
102+ control: Button{
103+ text: "Execute"
104+ enabled: !deviceItemView.deviceBusy
105+ onClicked: devicesModel.triggerRebootRecovery(deviceId)
106+ }
107+ }
108+ ListItem.Standard {
109+ text:"Shutdown"
110+ control: Button{
111+ text: "Execute"
112+ enabled: !deviceItemView.deviceBusy
113+ onClicked: devicesModel.triggerShutdown(deviceId)
114+ }
115+ }
116+ }
117+ }
118+ }
119+}
120+
121
122=== added file 'share/qtcreator/ubuntu/devicespage/DeviceBuilderTab.qml'
123--- share/qtcreator/ubuntu/devicespage/DeviceBuilderTab.qml 1970-01-01 00:00:00 +0000
124+++ share/qtcreator/ubuntu/devicespage/DeviceBuilderTab.qml 2014-04-27 13:29:17 +0000
125@@ -0,0 +1,42 @@
126+import QtQuick 2.0
127+import QtQuick.Controls 1.0 as Controls
128+import QtQuick.Layouts 1.0
129+import Ubuntu.Components 0.1
130+import Ubuntu.Components.ListItems 0.1 as ListItem
131+
132+RowLayout {
133+ spacing: units.gu(1)
134+ Controls.ScrollView {
135+ Layout.fillHeight: true
136+ Layout.minimumWidth: units.gu(78)
137+
138+ ColumnLayout {
139+ Layout.fillWidth: true
140+ Label {
141+ text: "Platform development"
142+ fontSize: "large"
143+ anchors.left: parent.left
144+ Layout.fillWidth: true
145+ }
146+ Label {
147+ text: "The connected device can be turned to be a native development environment.\n Use this feature with care and only if you know what are you doing."
148+ }
149+ FeatureStateItem {
150+ text: "Has writeable image"
151+ input: hasWriteableImage
152+ inputRole: "hasWriteableImage"
153+ height: 24
154+ width: 300
155+ checkable: !deviceItemView.deviceBusy
156+ }
157+ FeatureStateItem {
158+ text: "Has device developer tools"
159+ input: hasDeveloperTools
160+ inputRole: "hasDeveloperTools"
161+ height: 24
162+ width: 300
163+ checkable: !deviceItemView.deviceBusy
164+ }
165+ }
166+ }
167+}
168
169=== added file 'share/qtcreator/ubuntu/devicespage/DeviceLogTab.qml'
170--- share/qtcreator/ubuntu/devicespage/DeviceLogTab.qml 1970-01-01 00:00:00 +0000
171+++ share/qtcreator/ubuntu/devicespage/DeviceLogTab.qml 2014-04-27 13:29:17 +0000
172@@ -0,0 +1,12 @@
173+import QtQuick 2.0
174+import QtQuick.Controls 1.0 as Controls
175+import QtQuick.Layouts 1.0
176+import Ubuntu.Components 0.1
177+import Ubuntu.Components.ListItems 0.1 as ListItem
178+
179+
180+Controls.TextArea {
181+ readOnly: true
182+ text: deviceLog
183+ textFormat: TextEdit.AutoText
184+}
185
186=== added file 'share/qtcreator/ubuntu/devicespage/DevicePage.qml'
187--- share/qtcreator/ubuntu/devicespage/DevicePage.qml 1970-01-01 00:00:00 +0000
188+++ share/qtcreator/ubuntu/devicespage/DevicePage.qml 2014-04-27 13:29:17 +0000
189@@ -0,0 +1,105 @@
190+import QtQuick 2.0
191+import QtQuick.Layouts 1.0
192+import QtQuick.Controls 1.0 as Controls
193+
194+import Ubuntu.Components 0.1
195+import Ubuntu.Components.ListItems 0.1 as ListItem
196+import Ubuntu.DevicesModel 0.1
197+
198+Page {
199+ flickable: null
200+
201+ Controls.SplitView {
202+ orientation: Qt.Horizontal
203+ anchors.fill: parent
204+ Controls.SplitView {
205+ orientation: Qt.Vertical
206+ width: 200
207+ Layout.minimumWidth: 200
208+ Layout.maximumWidth: 400
209+
210+ Controls.ScrollView {
211+ Layout.fillHeight: true
212+ UbuntuListView {
213+ id: devicesList
214+ objectName: "devicesList"
215+ model: devicesModel
216+ currentIndex: 0
217+ delegate: ListItem.Standard {
218+ id: delegate
219+ text: display
220+ selected: devicesList.currentIndex == index
221+ onClicked: devicesList.currentIndex = index
222+ }
223+ onCurrentIndexChanged: deviceMode.deviceSelected(currentIndex)
224+ }
225+ }
226+ Controls.ToolBar {
227+ Layout.fillWidth: true
228+ Layout.minimumHeight: units.gu(5)
229+ Layout.maximumHeight: units.gu(5)
230+ Row{
231+ anchors.fill: parent
232+ spacing: units.gu(2)
233+ Controls.ToolButton {
234+ text: i18n.tr("Refresh devices")
235+ tooltip: text
236+ iconSource: "qrc:/ubuntu/images/view-refresh.png"
237+ onClicked: devicesModel.refresh()
238+ }
239+ }
240+ }
241+ }
242+ Item {
243+ id: centerItem
244+ Layout.minimumWidth: 400
245+ Layout.fillWidth: true
246+ property int currentIndex: devicesList.currentIndex
247+ Repeater {
248+ model: devicesModel
249+ anchors.fill: parent
250+ Rectangle{
251+ id: deviceItemView
252+ property bool deviceBusy: (detectionState != States.Done && detectionState != States.NotStarted)
253+ anchors.fill: parent
254+ anchors.margins: 12
255+
256+ color: Qt.rgba(0.0, 0.0, 0.0, 0.01)
257+ visible: index == devicesList.currentIndex
258+
259+ Controls.TabView {
260+ id: pagesTabView
261+ anchors.fill: parent
262+ visible: connectionState === States.DeviceReadyToUse || connectionState === States.DeviceConnected
263+ Controls.Tab {
264+ title: "Device"
265+ DeviceStatusTab{
266+ }
267+ }
268+ Controls.Tab {
269+ title: "Advanced"
270+ DeviceAdvancedTab{
271+ }
272+ }
273+ Controls.Tab {
274+ title: "Builder"
275+ DeviceBuilderTab{
276+ }
277+ }
278+ Controls.Tab {
279+ title: "Log"
280+ DeviceLogTab{}
281+ }
282+ }
283+ Label {
284+ visible: !pagesTabView.visible
285+ anchors.centerIn: parent
286+ text: "The device is currently not connected"
287+ fontSize: "large"
288+ }
289+ }
290+ }
291+ }
292+ }
293+}
294+
295
296=== added file 'share/qtcreator/ubuntu/devicespage/DeviceStatusTab.qml'
297--- share/qtcreator/ubuntu/devicespage/DeviceStatusTab.qml 1970-01-01 00:00:00 +0000
298+++ share/qtcreator/ubuntu/devicespage/DeviceStatusTab.qml 2014-04-27 13:29:17 +0000
299@@ -0,0 +1,108 @@
300+import QtQuick 2.0
301+import QtQuick.Controls 1.0 as Controls
302+import QtQuick.Layouts 1.0
303+import Ubuntu.Components 0.1
304+import Ubuntu.Components.ListItems 0.1 as ListItem
305+import Ubuntu.DevicesModel 0.1
306+
307+RowLayout {
308+ Controls.ScrollView {
309+ id: scrollView
310+ Layout.fillHeight: true
311+ Layout.minimumWidth: units.gu(78)
312+ ColumnLayout {
313+ width: scrollView.width
314+ Row {
315+ Label {
316+ text:"Device Status: "+detectionStateString
317+ fontSize: "large"
318+ }
319+ Item {
320+ width: units.gu(2)
321+ height: parent.height
322+ }
323+ ActivityIndicator{
324+ visible: deviceItemView.deviceBusy
325+ running: true
326+ }
327+ }
328+ ListItem.SingleValue {
329+ text:i18n.tr("Serial ID")
330+ Layout.fillWidth: true
331+ value: serial
332+ }
333+ ListItem.SingleValue {
334+ text:i18n.tr("Device")
335+ Layout.fillWidth: true
336+ value: deviceInfo
337+ }
338+ ListItem.SingleValue {
339+ text:i18n.tr("Model")
340+ Layout.fillWidth: true
341+ value: modelInfo
342+ }
343+ ListItem.SingleValue {
344+ text:i18n.tr("Product")
345+ Layout.fillWidth: true
346+ value: productInfo
347+ }
348+ FeatureStateItem {
349+ text: "Has network connection"
350+ input: hasNetworkConnection
351+ inputRole: "hasNetworkConnection"
352+ Layout.fillWidth: true
353+ checkable: hasNetworkConnection == States.NotAvailable && !deviceItemView.deviceBusy
354+ }
355+ FeatureStateItem {
356+ text: "Has devloper mode enabled"
357+ input: developerModeEnabled
358+ inputRole: "developerModeEnabled"
359+ Layout.fillWidth: true
360+ checkable: !deviceItemView.deviceBusy
361+ }
362+ ListItem.Divider{}
363+
364+ Label {
365+ text: "Device Kits"
366+ fontSize: "large"
367+ anchors.left: parent.left
368+ }
369+ Repeater {
370+ model: kits
371+ delegate: ListItem.Standard {
372+ text: modelData.displayName
373+ Layout.fillWidth: true
374+ control: Button{
375+ text: "Remove"
376+ enabled: !deviceItemView.deviceBusy
377+ onClicked: devicesModel.triggerKitRemove(deviceId,modelData.id)
378+ }
379+ }
380+ }
381+ Item {
382+ clip: true
383+ visible: kits.length === 0
384+ Layout.minimumHeight: units.gu(25)
385+ Layout.fillWidth: true
386+ Label {
387+ id:label
388+ anchors.centerIn: parent
389+ anchors.bottom: button.top
390+ fontSize: "large"
391+ text: "There is currently no Kit defined for your device.\n In order to use the device in your Projects,\n you can either add a existing Kit "
392+ +"\nor let Qt Creator autocreate one for you."
393+ }
394+ Button {
395+ id: button
396+ anchors.left: label.left
397+ anchors.right: label.right
398+ anchors.top: label.bottom
399+ anchors.topMargin: units.gu(2)
400+ text: "Autocreate"
401+ enabled: !deviceItemView.deviceBusy
402+ onClicked: devicesModel.triggerKitAutocreate(deviceId)
403+ }
404+ }
405+ }
406+ }
407+}
408
409=== added file 'share/qtcreator/ubuntu/devicespage/EmulatorPage.qml'
410--- share/qtcreator/ubuntu/devicespage/EmulatorPage.qml 1970-01-01 00:00:00 +0000
411+++ share/qtcreator/ubuntu/devicespage/EmulatorPage.qml 2014-04-27 13:29:17 +0000
412@@ -0,0 +1,150 @@
413+import QtQuick 2.0
414+import QtQuick.Layouts 1.0
415+import QtQuick.Controls 1.0 as Controls
416+
417+import Ubuntu.Components 0.1
418+import Ubuntu.Components.ListItems 0.1 as ListItem
419+import Ubuntu.Components.Popups 0.1
420+
421+Page {
422+ flickable: null
423+ id: myPage
424+
425+ Item {
426+ anchors.fill: parent
427+ visible: emulatorModel.busy
428+
429+ Column {
430+ anchors.centerIn: parent
431+ spacing: units.gu(1)
432+
433+ ActivityIndicator{
434+ anchors.horizontalCenter: parent.horizontalCenter
435+ running: emulatorModel.busy
436+ }
437+ Label {
438+ text: i18n.tr("There is currently a process running in the background, please check the logs for details")
439+ fontSize: "large"
440+ anchors.left: parent.left
441+ }
442+ Button {
443+ visible: emulatorModel.cancellable
444+ anchors.horizontalCenter: parent.horizontalCenter
445+ text: "cancel"
446+ onClicked: emulatorModel.cancel()
447+ }
448+ }
449+ }
450+
451+ Controls.SplitView {
452+ orientation: Qt.Horizontal
453+ anchors.fill: parent
454+ visible: !emulatorModel.busy
455+
456+ Controls.SplitView {
457+ orientation: Qt.Vertical
458+ width: 200
459+ Layout.minimumWidth: 200
460+ Layout.maximumWidth: 400
461+
462+ Controls.ScrollView {
463+ Layout.fillHeight: true
464+ Layout.fillWidth: true
465+
466+ UbuntuListView {
467+ id: emulatorList
468+ objectName: "emulatorList"
469+ model: emulatorModel
470+ currentIndex: 0
471+ delegate: ListItem.Standard {
472+ id: delegate
473+ text: display
474+ selected: emulatorList.currentIndex == index
475+ onClicked: emulatorList.currentIndex = index
476+ }
477+ }
478+ }
479+
480+ Controls.ToolBar {
481+ Layout.fillWidth: true
482+ Layout.minimumHeight: units.gu(5)
483+ Layout.maximumHeight: units.gu(5)
484+ Row{
485+ anchors.fill: parent
486+ spacing: units.gu(2)
487+ Controls.ToolButton {
488+ text: i18n.tr("Add Emulator")
489+ tooltip: text
490+ iconSource: "qrc:/ubuntu/images/list-add.png"
491+ onClicked: PopupUtils.open(resourceRoot+"/NewEmulatorDialog.qml",myPage);
492+ }
493+ Controls.ToolButton {
494+ text: i18n.tr("Refresh emulators")
495+ tooltip: text
496+ iconSource: "qrc:/ubuntu/images/view-refresh.png"
497+ onClicked: emulatorModel.findEmulatorImages()
498+ }
499+ }
500+ }
501+ }
502+ Item {
503+ id: centerItem
504+ Layout.minimumWidth: units.gu(78)
505+ Layout.fillWidth: true
506+ property int currentIndex: emulatorList.currentIndex
507+ Repeater {
508+ model: emulatorModel
509+ anchors.fill: parent
510+ Rectangle{
511+ id: deviceItemView
512+ anchors.fill: parent
513+ anchors.margins: 12
514+
515+ color: Qt.rgba(0.0, 0.0, 0.0, 0.01)
516+ visible: index == emulatorList.currentIndex && !emulatorModel.busy
517+
518+ UbuntuListView {
519+ anchors.left: parent.left
520+ anchors.top: parent.top
521+ height: units.gu(50)
522+ width: units.gu(50)
523+ model: VisualItemModel {
524+ ListItem.SingleValue {
525+ text: i18n.tr("Ubuntu version")
526+ value: ubuntuVersion
527+ }
528+ ListItem.SingleValue {
529+ text: i18n.tr("Device version")
530+ value: deviceVersion
531+ }
532+ ListItem.SingleValue {
533+ text: i18n.tr("Image version")
534+ value: imageVersion
535+ }
536+ ListItem.SingleControl {
537+ control: Button {
538+ text: "Start emulator"
539+ onClicked: emulatorModel.startEmulator(display)
540+ }
541+ }
542+ /*
543+ ListItem.SingleControl {
544+ control: Button {
545+ text: "Delete emulator"
546+ }
547+ }
548+ */
549+ }
550+ }
551+
552+ Label {
553+ visible: emulatorModel.busy
554+ anchors.centerIn: parent
555+ text: emulatorModel.state
556+ fontSize: "large"
557+ }
558+ }
559+ }
560+ }
561+ }
562+}
563
564=== added file 'share/qtcreator/ubuntu/devicespage/FeatureStateItem.qml'
565--- share/qtcreator/ubuntu/devicespage/FeatureStateItem.qml 1970-01-01 00:00:00 +0000
566+++ share/qtcreator/ubuntu/devicespage/FeatureStateItem.qml 2014-04-27 13:29:17 +0000
567@@ -0,0 +1,46 @@
568+import QtQuick 2.0
569+import QtQuick.Layouts 1.0
570+import Ubuntu.Components 0.1
571+import Ubuntu.Components.ListItems 0.1 as ListItem
572+import Ubuntu.DevicesModel 0.1
573+
574+ListItem.Standard {
575+ id: item
576+ property var input: null
577+ property string inputRole
578+ property alias checkable: switchbox.enabled
579+
580+ onInputChanged: {
581+ console.log("INPUT CHANGED !!!!!"+input);
582+ if(input == States.Available)
583+ switchbox.checked = true;
584+ else
585+ switchbox.checked = false;
586+ }
587+
588+ selected: false
589+ control: Row {
590+ ActivityIndicator {
591+ visible: input === States.Detecting
592+ running: true
593+ }
594+ Switch {
595+ id: switchbox
596+ visible: input !== States.Detecting
597+ checked: input === States.Available
598+ enabled: checkable
599+ onCheckedChanged: {
600+ console.log("!!!!!!!!!!!!!!!!!!!!!!!!!!Checked changed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
601+
602+ if (checked && input == States.NotAvailable) {
603+ devicesModel.set(index,inputRole,true);
604+ checked = true;
605+ }
606+ else if ((!checked) && input == States.Available) {
607+ devicesModel.set(index,inputRole,false);
608+ checked = false;
609+ }
610+ }
611+ }
612+ }
613+}
614
615=== added file 'share/qtcreator/ubuntu/devicespage/LogPage.qml'
616--- share/qtcreator/ubuntu/devicespage/LogPage.qml 1970-01-01 00:00:00 +0000
617+++ share/qtcreator/ubuntu/devicespage/LogPage.qml 2014-04-27 13:29:17 +0000
618@@ -0,0 +1,24 @@
619+import QtQuick 2.0
620+import QtQuick.Layouts 1.0
621+import QtQuick.Controls 1.0 as Controls
622+
623+import Ubuntu.Components 0.1
624+import Ubuntu.Components.ListItems 0.1 as ListItem
625+import Ubuntu.Components.Popups 0.1
626+
627+Page {
628+ flickable: null
629+
630+ Controls.TextArea {
631+ id: logTextArea
632+ anchors.fill: parent
633+ readOnly: true
634+ textFormat: TextEdit.AutoText
635+ Component.onCompleted: {
636+ deviceMode.appendText.connect(appendToLog);
637+ }
638+ function appendToLog (txt) {
639+ logTextArea.append(txt);
640+ }
641+ }
642+}
643
644=== added file 'share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml'
645--- share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml 1970-01-01 00:00:00 +0000
646+++ share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml 2014-04-27 13:29:17 +0000
647@@ -0,0 +1,46 @@
648+import QtQuick 2.0
649+import Ubuntu.Components 0.1
650+import Ubuntu.Components.Popups 0.1
651+
652+Dialog {
653+ id: dialogue
654+ title: i18n.tr("Create emulator")
655+ text: i18n.tr("Please select a name for the emulator")
656+ modal: true
657+ TextField {
658+ id: inputName
659+ placeholderText: i18n.tr("Emulator name")
660+ property string lastError
661+ property bool hasError
662+ onTextChanged: validate()
663+ Component.onCompleted: validate()
664+ function validate() {
665+ var result = emulatorModel.validateEmulatorName(text);
666+ hasError = !result.valid;
667+ lastError = result.error;
668+ }
669+ }
670+ Label {
671+ horizontalAlignment: Text.AlignHCenter
672+ text: inputName.lastError
673+ color: "red"
674+ visible: inputName.hasError
675+ }
676+
677+ Button {
678+ text: "cancel"
679+ onClicked: PopupUtils.close(dialogue)
680+ }
681+ Button {
682+ text: "create"
683+ color: UbuntuColors.orange
684+ enabled: !inputName.hasError
685+ onClicked: {
686+ if(inputName.hasError)
687+ return;
688+ emulatorModel.createEmulatorImage(inputName.text);
689+ PopupUtils.close(dialogue);
690+ }
691+ }
692+}
693+
694
695=== added file 'share/qtcreator/ubuntu/devicespage/devicespage.qmlproject'
696--- share/qtcreator/ubuntu/devicespage/devicespage.qmlproject 1970-01-01 00:00:00 +0000
697+++ share/qtcreator/ubuntu/devicespage/devicespage.qmlproject 2014-04-27 13:29:17 +0000
698@@ -0,0 +1,20 @@
699+/* File generated by Qt Creator, version 2.7.0 */
700+
701+import QmlProject 1.1
702+
703+Project {
704+ mainFile: "devicespage.qml"
705+
706+ /* Include .qml, .js, and image files from current directory and subdirectories */
707+ QmlFiles {
708+ directory: "."
709+ }
710+ JavaScriptFiles {
711+ directory: "."
712+ }
713+ ImageFiles {
714+ directory: "."
715+ }
716+ /* List of plugin directories passed to QML runtime */
717+ // importPaths: [ "../exampleplugin" ]
718+}
719
720=== added directory 'share/qtcreator/ubuntu/devicespage/dummydata'
721=== added file 'share/qtcreator/ubuntu/devicespage/dummydata/devicesModel.qml'
722--- share/qtcreator/ubuntu/devicespage/dummydata/devicesModel.qml 1970-01-01 00:00:00 +0000
723+++ share/qtcreator/ubuntu/devicespage/dummydata/devicesModel.qml 2014-04-27 13:29:17 +0000
724@@ -0,0 +1,52 @@
725+import QtQuick 2.0
726+
727+ListModel {
728+ id: devicesModel
729+ ListElement {
730+ display: "Ubuntu Device Nexus S"
731+ isEmulator: false
732+ connectionState: 1
733+ connectionStateString: "Connected"
734+ developerModeEnabled: 0
735+ hasNetworkConnection: 0
736+ hasWriteableImage: 1
737+ hasDeveloperTools: 2
738+ kits: [
739+ ListElement{
740+ kitId: "1"
741+ displayName: "Nexus S UbuntuSDK for armhf (GCC ubuntu-sdk-14.04-trusty)"
742+ }
743+ ]
744+ deviceLog: "<p><strong>Checking for network.....</strong><strong> </strong><br/>available</p><p><strong>Checking for readable Image....</strong><br/>not available</p>"
745+ }
746+ ListElement {
747+ display: "Ubuntu Emulator"
748+ isEmulator: true
749+ connectionState: 1
750+ connectionStateString: "Connected"
751+ developerModeEnabled: 1
752+ hasNetworkConnection: 1
753+ hasWriteableImage: 1
754+ hasDeveloperTools: 1
755+ kits: [
756+ ]
757+ deviceLog: "<p><strong>Checking for network.....</strong><strong> </strong><br/>available</p><p><strong>Checking for readable Image....</strong><br/>not available</p>"
758+ }
759+ ListElement {
760+ display: "Ubuntu Device Tablet"
761+ isEmulator: false
762+ connectionState: 0
763+ connectionStateString: "Disconnected"
764+ developerModeEnabled: 0
765+ hasNetworkConnection: 0
766+ hasWriteableImage: 0
767+ hasDeveloperTools: 0
768+ kits: [
769+ ListElement{
770+ kitId: "1"
771+ displayName: "Tablet UbuntuSDK for armhf (GCC ubuntu-sdk-14.04-trusty)"
772+ }
773+ ]
774+ deviceLog: "<p><strong>Checking for network.....</strong><strong> </strong><br/>available</p><p><strong>Checking for readable Image....</strong><br/>not available</p>"
775+ }
776+}
777
778=== added file 'share/qtcreator/ubuntu/devicespage/main.qml'
779--- share/qtcreator/ubuntu/devicespage/main.qml 1970-01-01 00:00:00 +0000
780+++ share/qtcreator/ubuntu/devicespage/main.qml 2014-04-27 13:29:17 +0000
781@@ -0,0 +1,25 @@
782+import QtQuick 2.0
783+import Ubuntu.Components 0.1
784+
785+
786+MainView {
787+ id: modeRoot
788+ width: 860
789+ height: 548
790+
791+ Tabs {
792+ Tab {
793+ title: "Ubuntu Devices"
794+ page: DevicePage{}
795+ }
796+ Tab {
797+ title: "Emulators"
798+ page: EmulatorPage{}
799+ }
800+ Tab {
801+ title: "Log"
802+ page: LogPage{}
803+ }
804+ }
805+}
806+
807
808=== added file 'share/qtcreator/ubuntu/devicespage/test.qml#'
809--- share/qtcreator/ubuntu/devicespage/test.qml# 1970-01-01 00:00:00 +0000
810+++ share/qtcreator/ubuntu/devicespage/test.qml# 2014-04-27 13:29:17 +0000
811@@ -0,0 +1,18 @@
812+import QtQuick 2.0
813+import QtQuick.Layouts 1.0
814+import Ubuntu.Components 0.1
815+
816+MainView {
817+ height: 640
818+ width: 480
819+
820+ Page {
821+ title: "Hello World"
822+ ActivityIndicator {
823+ anchors.fill: parent
824+ visible: true
825+ running: true
826+ }
827+ }
828+
829+}
830
831=== modified file 'share/qtcreator/ubuntu/scripts/local_start_emulator'
832--- share/qtcreator/ubuntu/scripts/local_start_emulator 2014-02-05 12:13:31 +0000
833+++ share/qtcreator/ubuntu/scripts/local_start_emulator 2014-04-27 13:29:17 +0000
834@@ -19,5 +19,4 @@
835 ubuntu-emulator run ${EMULATOR} &
836 set +e
837 adb wait-for-device
838-adb forward tcp:9999 tcp:22
839 set -e
840
841=== added file 'share/qtcreator/ubuntu/welcome/.excludes'
842=== added file 'src/ubuntu/images/list-add.png'
843Binary files src/ubuntu/images/list-add.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/list-add.png 2014-04-27 13:29:17 +0000 differ
844=== added file 'src/ubuntu/images/list-remove.png'
845Binary files src/ubuntu/images/list-remove.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/list-remove.png 2014-04-27 13:29:17 +0000 differ
846=== added file 'src/ubuntu/images/view-refresh.png'
847Binary files src/ubuntu/images/view-refresh.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/view-refresh.png 2014-04-27 13:29:17 +0000 differ
848=== modified file 'src/ubuntu/resources.qrc'
849--- src/ubuntu/resources.qrc 2013-09-04 15:30:00 +0000
850+++ src/ubuntu/resources.qrc 2014-04-27 13:29:17 +0000
851@@ -14,5 +14,7 @@
852 <file>manifest.json.template</file>
853 <file>myapp.json.template</file>
854 <file>manifestlib.js</file>
855+ <file>images/view-refresh.png</file>
856+ <file>images/list-add.png</file>
857 </qresource>
858 </RCC>
859
860=== modified file 'src/ubuntu/ubuntu.pro'
861--- src/ubuntu/ubuntu.pro 2014-04-03 12:28:13 +0000
862+++ src/ubuntu/ubuntu.pro 2014-04-27 13:29:17 +0000
863@@ -26,11 +26,29 @@
864 RESOURCES += \
865 resources.qrc
866
867+#QML files
868+QML_ROOT="$${PWD}/../../share/qtcreator/ubuntu"
869+QML_FILES += \
870+ $$QML_ROOT/welcome/welcome.qml \
871+ $$QML_ROOT/welcome/Link.qml \
872+ $$QML_ROOT/welcome/NewsBox.qml\
873+ $$QML_ROOT/devicespage/main.qml \
874+ $$QML_ROOT/devicespage/DeviceAdvancedTab.qml \
875+ $$QML_ROOT/devicespage/DeviceBuilderTab.qml \
876+ $$QML_ROOT/devicespage/DeviceLogTab.qml \
877+ $$QML_ROOT/devicespage/DevicePage.qml \
878+ $$QML_ROOT/devicespage/DeviceStatusTab.qml \
879+ $$QML_ROOT/devicespage/EmulatorPage.qml \
880+ $$QML_ROOT/devicespage/FeatureStateItem.qml \
881+ $$QML_ROOT/devicespage/NewEmulatorDialog.qml \
882+ $$QML_ROOT/devicespage/LogPage.qml
883+
884 OTHER_FILES += \
885 UbuntuProject.mimetypes.xml \
886 manifest.json.template \
887 myapp.json.template \
888- manifestlib.js
889+ manifestlib.js \
890+ $$QML_FILES
891
892 SOURCES += \
893 ubuntuplugin.cpp \
894@@ -55,7 +73,7 @@
895 ubuntuclickmanifest.cpp \
896 ubuntuwebmode.cpp \
897 ubuntupastebinmode.cpp \
898- ubuntudeviceswidget.cpp \
899+ #ubuntudeviceswidget.cpp \
900 ubuntudevicemode.cpp \
901 ubuntuprocess.cpp \
902 ubuntudevicenotifier.cpp \
903@@ -88,7 +106,9 @@
904 ubunturemotedeployconfiguration.cpp \
905 ubuntulocalrunconfigurationfactory.cpp \
906 ubunturemoteruncontrolfactory.cpp \
907- ubuntulocalrunconfiguration.cpp
908+ ubuntulocalrunconfiguration.cpp \
909+ ubuntudevicesmodel.cpp \
910+ ubuntuemulatormodel.cpp
911
912 HEADERS += \
913 ubuntuplugin.h \
914@@ -117,7 +137,7 @@
915 ubuntuwebmode.h \
916 ubuntupastebinmode.h \
917 ubuntudevicemode.h \
918- ubuntudeviceswidget.h \
919+ #ubuntudeviceswidget.h \
920 ubuntuprocess.h \
921 ubuntudevicenotifier.h \
922 ubuntusettingspage.h \
923@@ -149,5 +169,7 @@
924 ubunturemotedeployconfiguration.h \
925 ubuntulocalrunconfigurationfactory.h \
926 ubunturemoteruncontrolfactory.h \
927- ubuntulocalrunconfiguration.h
928+ ubuntulocalrunconfiguration.h \
929+ ubuntudevicesmodel.h \
930+ ubuntuemulatormodel.h
931
932
933=== modified file 'src/ubuntu/ubuntuconstants.h'
934--- src/ubuntu/ubuntuconstants.h 2014-04-10 15:59:28 +0000
935+++ src/ubuntu/ubuntuconstants.h 2014-04-27 13:29:17 +0000
936@@ -120,7 +120,7 @@
937 const char UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR[] = "Creating new emulator instance.";
938 const char UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR_SCRIPT[] = "%0/local_create_emulator %1 %2";
939 const char UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR[] = "Starting the selected emulator.";
940-const char UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR_SCRIPT[] = "%0/local_start_emulator %1";
941+const char UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR_SCRIPT[] = "%0/local_start_emulator";
942
943
944 const char UBUNTUDEVICESWIDGET_STARTSSHSERVICE[] = "Start ssh service on device..";
945@@ -213,7 +213,7 @@
946 const char UBUNTUDEVICESWIDGET_DETECTOPENSSH[] = "Detecting if openssh-server is installed..";
947 const char UBUNTUDEVICESWIDGET_DETECTOPENSSH_SCRIPT[] = "%0/openssh_version %1";
948 const char UBUNTUDEVICESWIDGET_DETECTDEVICES[] = "Detecting device..";
949-const char UBUNTUDEVICESWIDGET_DETECTDEVICES_SCRIPT[] = "%0/device_search %1";
950+const char UBUNTUDEVICESWIDGET_DETECTDEVICES_SCRIPT[] = "%0/device_search";
951 const char UBUNTUDEVICESWIDGET_SSHCONNECT_SCRIPT[] = "%0/openssh_connect";
952 const char UBUNTUDEVICESWIDGET_SSHCONNECT[] = "Opening ssh connection to device";
953
954@@ -241,6 +241,8 @@
955 #endif
956
957 const QString UBUNTU_WELCOMESCREEN_QML = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/welcome/welcome.qml");
958+const QString UBUNTU_DEVICESCREEN_QML = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/devicespage/main.qml");
959+const QString UBUNTU_DEVICESCREEN_ROOT = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/devicespage");
960 const QString UBUNTU_TEMPLATESPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/templates/wizards/ubuntu/");
961 const QString UBUNTU_MENUPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/");
962 const QString UBUNTU_SHAREPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/");
963
964=== modified file 'src/ubuntu/ubuntudevice.cpp'
965--- src/ubuntu/ubuntudevice.cpp 2014-04-10 19:03:23 +0000
966+++ src/ubuntu/ubuntudevice.cpp 2014-04-27 13:29:17 +0000
967@@ -24,6 +24,7 @@
968 #include "localportsmanager.h"
969
970 #include <projectexplorer/devicesupport/devicemanager.h>
971+#include <remotelinux/genericlinuxdeviceconfigurationwidget.h>
972 #include <coreplugin/messagemanager.h>
973 #include <ssh/sshconnection.h>
974 #include <utils/portlist.h>
975@@ -32,11 +33,15 @@
976 #include <QCoreApplication>
977 #include <QDir>
978 #include <QDebug>
979+#include <QRegularExpression>
980
981 namespace Ubuntu {
982 namespace Internal {
983
984 const QLatin1String DEVICE_INFO_KEY("UbuntuDevice.InfoString");
985+const QLatin1String DEVICE_PRODUCT_INFO_KEY("UbuntuDevice.Product.InfoString");
986+const QLatin1String DEVICE_MODEL_INFO_KEY("UbuntuDevice.Model.InfoString");
987+const QLatin1String DEVICE_DEVICE_INFO_KEY("UbuntuDevice.Device.InfoString");
988
989 /*!
990 * \class UbuntuDeviceHelper
991@@ -125,8 +130,8 @@
992 m_clonedNwCount = 0;
993 if(m_dev->m_hasNetworkConnection != UbuntuDevice::Available) {
994 m_dev->m_hasNetworkConnection = UbuntuDevice::Available;
995- emit featureDetected();
996 }
997+ emit featureDetected();
998 detectOpenSsh();
999
1000 } else {
1001@@ -137,9 +142,9 @@
1002 //we tried to enable network and failed
1003 if(m_dev->m_hasNetworkConnection != UbuntuDevice::NotAvailable) {
1004 m_dev->m_hasNetworkConnection = UbuntuDevice::NotAvailable;
1005- emit featureDetected();
1006- emit deviceNeedsSetup();
1007 }
1008+ emit featureDetected();
1009+ emit deviceNeedsSetup();
1010 //detect other features
1011 detectOpenSsh();
1012 }
1013@@ -157,8 +162,8 @@
1014
1015 if(m_dev->m_hasOpenSSHServer != UbuntuDevice::Available) {
1016 m_dev->m_hasOpenSSHServer = UbuntuDevice::Available;
1017- emit featureDetected();
1018 }
1019+ emit featureDetected();
1020
1021 ProjectExplorer::DeviceManager::instance()->setDeviceState(m_dev->id(),ProjectExplorer::IDevice::DeviceConnected);
1022 endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_SSH_IS_INSTALLED).arg(m_reply.trimmed()));
1023@@ -170,9 +175,9 @@
1024
1025 if(m_dev->m_hasOpenSSHServer != UbuntuDevice::NotAvailable) {
1026 m_dev->m_hasOpenSSHServer = UbuntuDevice::NotAvailable;
1027- emit featureDetected();
1028- emit deviceNeedsSetup();
1029 }
1030+ emit featureDetected();
1031+ emit deviceNeedsSetup();
1032
1033 endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_SSH_NOT_INSTALLED));
1034
1035@@ -242,7 +247,6 @@
1036 m_dev->m_hasDeveloperTools = UbuntuDevice::Available;
1037 endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_DEVELOPERTOOLS_INSTALLED));
1038 }
1039-
1040 emit featureDetected();
1041 break;
1042 }
1043@@ -297,6 +301,10 @@
1044 void UbuntuDeviceHelper::detectOpenSsh()
1045 {
1046 setProcessState(UbuntuDevice::DetectOpenSSH);
1047+
1048+ m_dev->m_hasOpenSSHServer = UbuntuDevice::Unknown;
1049+ emit featureDetected();
1050+
1051 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTOPENSSH));
1052
1053 stopProcess();
1054@@ -323,6 +331,9 @@
1055 setProcessState(UbuntuDevice::InstallOpenSSH);
1056 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_INSTALL));
1057
1058+ m_dev->m_hasOpenSSHServer = UbuntuDevice::Unknown;
1059+ emit featureDetected();
1060+
1061 stopProcess();
1062
1063 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_INSTALL_SCRIPT)
1064@@ -335,6 +346,9 @@
1065 setProcessState(UbuntuDevice::RemoveOpenSSH);
1066 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_REMOVE));
1067
1068+ m_dev->m_hasOpenSSHServer = UbuntuDevice::Unknown;
1069+ emit featureDetected();
1070+
1071 stopProcess();
1072
1073 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_REMOVE_SCRIPT)
1074@@ -348,6 +362,10 @@
1075 // adb shell nmcli dev list iface <intfc> | grep IP4.ADDRESS
1076 // to find out the devices ip address
1077 setProcessState(UbuntuDevice::DetectNetworkConnection);
1078+
1079+ m_dev->m_hasNetworkConnection = UbuntuDevice::Unknown;
1080+ emit featureDetected();
1081+
1082 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_HASNETWORK));
1083
1084 stopProcess();
1085@@ -372,6 +390,10 @@
1086 void UbuntuDeviceHelper::detectDeviceWritableImage()
1087 {
1088 setProcessState(UbuntuDevice::DetectDeviceWriteableImage);
1089+
1090+ m_dev->m_hasWriteableImage = UbuntuDevice::Unknown;
1091+ emit featureDetected();
1092+
1093 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTWRITABLEIMAGE));
1094
1095 stopProcess();
1096@@ -384,6 +406,10 @@
1097 void UbuntuDeviceHelper::detectDeveloperTools()
1098 {
1099 setProcessState(UbuntuDevice::DetectDeveloperTools);
1100+
1101+ m_dev->m_hasDeveloperTools = UbuntuDevice::Unknown;
1102+ emit featureDetected();
1103+
1104 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTDEVELOPERTOOLS));
1105
1106 stopProcess();
1107@@ -503,6 +529,9 @@
1108 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSWRITABLE));
1109 stopProcess();
1110
1111+ m_dev->m_hasWriteableImage = UbuntuDevice::Unknown;
1112+ emit featureDetected();
1113+
1114 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSWRITABLE_SCRIPT)
1115 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
1116 .arg(m_dev->id().toSetting().toString()));
1117@@ -517,6 +546,9 @@
1118 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSREADONLY));
1119 stopProcess();
1120
1121+ m_dev->m_hasWriteableImage = UbuntuDevice::Unknown;
1122+ emit featureDetected();
1123+
1124 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSREADONLY_SCRIPT)
1125 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
1126 .arg(m_dev->id().toSetting().toString()));
1127@@ -589,6 +621,9 @@
1128 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ENABLEPLATFORMDEVELOPMENT));
1129 stopProcess();
1130
1131+ m_dev->m_hasDeveloperTools = UbuntuDevice::Unknown;
1132+ emit featureDetected();
1133+
1134 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ENABLEPLATFORMDEVELOPMENT_SCRIPT)
1135 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
1136 .arg(m_dev->id().toSetting().toString()));
1137@@ -604,6 +639,9 @@
1138 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DISABLEPLATFORMDEVELOPMENT));
1139 stopProcess();
1140
1141+ m_dev->m_hasDeveloperTools = UbuntuDevice::Unknown;
1142+ emit featureDetected();
1143+
1144 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DISABLEPLATFORMDEVELOPMENT_SCRIPT)
1145 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
1146 .arg(m_dev->id().toSetting().toString()));
1147@@ -630,9 +668,13 @@
1148 void UbuntuDeviceHelper::cloneNetwork()
1149 {
1150 m_clonedNwCount++;
1151+
1152 setProcessState(UbuntuDevice::CloneNetwork);
1153 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_CLONENETWORK));
1154
1155+ m_dev->m_hasNetworkConnection = UbuntuDevice::Unknown;
1156+ emit featureDetected();
1157+
1158 stopProcess();
1159 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_CLONENETWORK_SCRIPT)
1160 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
1161@@ -709,7 +751,9 @@
1162 : LinuxDevice(other)
1163 , m_helper(new UbuntuDeviceHelper(this))
1164 , m_processState(NotStarted)
1165- , m_deviceInfoString(other.deviceInfoString())
1166+ , m_deviceInfo(other.m_deviceInfo)
1167+ , m_modelInfo(other.m_modelInfo)
1168+ , m_productInfo(other.m_productInfo)
1169 {
1170 setDeviceState(ProjectExplorer::IDevice::DeviceDisconnected);
1171 setupPrivateKey();
1172@@ -772,6 +816,11 @@
1173 return m_helper;
1174 }
1175
1176+void UbuntuDevice::cloneNetwork()
1177+{
1178+ m_helper->cloneNetwork();
1179+}
1180+
1181 /*!
1182 * \brief UbuntuDevice::openTerminal
1183 * Opens a detached terminal, logged into the device
1184@@ -898,14 +947,48 @@
1185 m_helper->removeDevTools();
1186 }
1187
1188-void UbuntuDevice::setDeviceInfoString(const QString &info)
1189-{
1190- m_deviceInfoString = info;
1191-}
1192-
1193-QString UbuntuDevice::deviceInfoString() const
1194-{
1195- return m_deviceInfoString;
1196+void UbuntuDevice::setDeviceInfoString(const QString &deviceInfo)
1197+{
1198+ m_productInfo = tr("unknown");
1199+ m_modelInfo = m_productInfo;
1200+ m_deviceInfo = m_productInfo;
1201+
1202+ QRegularExpression expr(QStringLiteral("product:\\s?(\\w+)"));
1203+ QRegularExpressionMatch m = expr.match(deviceInfo);
1204+ if(m.hasMatch())
1205+ m_productInfo = m.captured(1);
1206+
1207+ expr.setPattern(QStringLiteral("model:\\s?(\\w+)"));
1208+ m = expr.match(deviceInfo);
1209+ if(m.hasMatch())
1210+ m_modelInfo = m.captured(1);
1211+
1212+ expr.setPattern(QStringLiteral("device:\\s?(\\w+)"));
1213+ m = expr.match(deviceInfo);
1214+ if(m.hasMatch())
1215+ m_deviceInfo = m.captured(1);
1216+}
1217+
1218+void UbuntuDevice::setDeviceInfo(const QString &productInfo, const QString &modelInfo, const QString &deviceInfo)
1219+{
1220+ m_productInfo = productInfo;
1221+ m_modelInfo = modelInfo;
1222+ m_deviceInfo = deviceInfo;
1223+}
1224+
1225+QString UbuntuDevice::modelInfo() const
1226+{
1227+ return m_modelInfo;
1228+}
1229+
1230+QString UbuntuDevice::deviceInfo() const
1231+{
1232+ return m_deviceInfo;
1233+}
1234+
1235+QString UbuntuDevice::productInfo() const
1236+{
1237+ return m_productInfo;
1238 }
1239
1240 UbuntuDevice::FeatureState UbuntuDevice::hasNetworkConnection() const
1241@@ -968,14 +1051,15 @@
1242 case RemoveDevTools:
1243 return tr("Removing development tools");
1244 case Done:
1245- return tr("Finished");
1246+ return tr("Ready");
1247 }
1248 return QString();
1249 }
1250
1251 ProjectExplorer::IDeviceWidget *UbuntuDevice::createWidget()
1252 {
1253- return new UbuntuDeviceConfigurationWidget(sharedFromThis());
1254+ return new RemoteLinux::GenericLinuxDeviceConfigurationWidget(sharedFromThis());
1255+ //return new UbuntuDeviceConfigurationWidget(sharedFromThis());
1256 }
1257
1258 QList<Core::Id> UbuntuDevice::actionIds() const
1259@@ -996,8 +1080,27 @@
1260 void UbuntuDevice::fromMap(const QVariantMap &map)
1261 {
1262 LinuxDevice::fromMap(map);
1263+
1264+ //legacy setting, will be converted to the new settings on the next save
1265 if(map.contains(DEVICE_INFO_KEY))
1266- m_deviceInfoString = map[DEVICE_INFO_KEY].toString();
1267+ setDeviceInfoString(map[DEVICE_INFO_KEY].toString());
1268+ else {
1269+ QString unknown = tr("unknown");
1270+ if(map.contains(DEVICE_DEVICE_INFO_KEY))
1271+ m_deviceInfo = map[DEVICE_DEVICE_INFO_KEY].toString();
1272+ else
1273+ m_deviceInfo = unknown;
1274+
1275+ if(map.contains(DEVICE_MODEL_INFO_KEY))
1276+ m_modelInfo = map[DEVICE_MODEL_INFO_KEY].toString();
1277+ else
1278+ m_modelInfo = unknown;
1279+
1280+ if(map.contains(DEVICE_PRODUCT_INFO_KEY))
1281+ m_productInfo = map[DEVICE_PRODUCT_INFO_KEY].toString();
1282+ else
1283+ m_productInfo = unknown;
1284+ }
1285
1286 setupPrivateKey();
1287 m_helper->init();
1288@@ -1006,7 +1109,9 @@
1289 QVariantMap UbuntuDevice::toMap() const
1290 {
1291 QVariantMap map = LinuxDevice::toMap();
1292- map.insert(DEVICE_INFO_KEY,m_deviceInfoString);
1293+ map.insert(DEVICE_PRODUCT_INFO_KEY,m_productInfo);
1294+ map.insert(DEVICE_MODEL_INFO_KEY,m_modelInfo);
1295+ map.insert(DEVICE_DEVICE_INFO_KEY,m_deviceInfo);
1296 return map;
1297 }
1298
1299
1300=== modified file 'src/ubuntu/ubuntudevice.h'
1301--- src/ubuntu/ubuntudevice.h 2014-04-10 15:59:28 +0000
1302+++ src/ubuntu/ubuntudevice.h 2014-04-27 13:29:17 +0000
1303@@ -36,7 +36,6 @@
1304 {
1305 Q_OBJECT
1306 friend class UbuntuDevice;
1307-
1308 public:
1309 explicit UbuntuDeviceHelper(UbuntuDevice* dev);
1310 ~UbuntuDeviceHelper();
1311@@ -150,6 +149,7 @@
1312 QString serialNumber () const;
1313 UbuntuDeviceHelper *helper () const;
1314
1315+ void cloneNetwork ();
1316 void openTerminal ();
1317 void cloneTimeConfig ();
1318 void enablePortForward ();
1319@@ -162,8 +162,11 @@
1320 void setWriteableImageEnabled ( const bool enabled = true );
1321 void setDeveloperToolsInstalled ( const bool installed = true );
1322
1323- void setDeviceInfoString (const QString &info);
1324- QString deviceInfoString () const;
1325+ void setDeviceInfoString (const QString &deviceInfo);
1326+ void setDeviceInfo (const QString &productInfo, const QString &modelInfo, const QString &deviceInfo);
1327+ QString modelInfo() const;
1328+ QString deviceInfo() const;
1329+ QString productInfo() const;
1330
1331 FeatureState developerModeEnabled () const;
1332 FeatureState hasNetworkConnection () const;
1333@@ -198,7 +201,9 @@
1334 FeatureState m_hasWriteableImage;
1335 FeatureState m_hasDeveloperTools;
1336 ProcessState m_processState;
1337- QString m_deviceInfoString;
1338+ QString m_modelInfo;
1339+ QString m_deviceInfo;
1340+ QString m_productInfo;
1341 Utils::PortList m_localForwardedPorts;
1342
1343 private:
1344
1345=== modified file 'src/ubuntu/ubuntudevicemode.cpp'
1346--- src/ubuntu/ubuntudevicemode.cpp 2013-09-04 15:30:00 +0000
1347+++ src/ubuntu/ubuntudevicemode.cpp 2014-04-27 13:29:17 +0000
1348@@ -18,6 +18,8 @@
1349
1350 #include "ubuntudevicemode.h"
1351 #include "ubuntuconstants.h"
1352+#include "ubuntudevicesmodel.h"
1353+#include "ubuntuemulatormodel.h"
1354
1355 #include <coreplugin/modemanager.h>
1356 #include <coreplugin/editormanager/editormanager.h>
1357@@ -29,18 +31,30 @@
1358 #include <utils/styledbar.h>
1359 #include <QVBoxLayout>
1360 #include <QScrollArea>
1361+#include <QQuickView>
1362+#include <QQmlContext>
1363+#include <QQmlEngine>
1364+#include <QDebug>
1365
1366 using namespace Ubuntu::Internal;
1367
1368+UbuntuDeviceMode *UbuntuDeviceMode::m_instance = 0;
1369+
1370 UbuntuDeviceMode::UbuntuDeviceMode(QObject *parent) :
1371 Core::IMode(parent)
1372 {
1373+ Q_ASSERT_X(m_instance == 0, Q_FUNC_INFO,"There can be only one instance of UbuntuDeviceMode");
1374+ m_instance = this;
1375+
1376+ m_qmlControl = new UbuntuQMLDeviceMode(this);
1377+
1378 setDisplayName(tr(Ubuntu::Constants::UBUNTU_MODE_DEVICES_DISPLAYNAME));
1379 setIcon(QIcon(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_DEVICES_ICON)));
1380 setPriority(Ubuntu::Constants::UBUNTU_MODE_DEVICES_PRIORITY);
1381 setId(Ubuntu::Constants::UBUNTU_MODE_DEVICES);
1382 setObjectName(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_DEVICES));
1383
1384+
1385 m_modeWidget = new QWidget;
1386 QVBoxLayout *layout = new QVBoxLayout;
1387 layout->setMargin(0);
1388@@ -49,22 +63,90 @@
1389
1390 Utils::StyledBar* styledBar = new Utils::StyledBar(m_modeWidget);
1391 layout->addWidget(styledBar);
1392- QScrollArea *scrollArea = new QScrollArea(m_modeWidget);
1393- scrollArea->setFrameShape(QFrame::NoFrame);
1394- layout->addWidget(scrollArea);
1395- scrollArea->setWidget(&m_ubuntuDevicesWidget);
1396- scrollArea->setWidgetResizable(true);
1397+
1398+ m_modeView = new QQuickView;
1399+ m_modeView->setResizeMode(QQuickView::SizeRootObjectToView);
1400+ m_devicesModel = new UbuntuDevicesModel(m_modeView);
1401+ m_emulatorModel = new UbuntuEmulatorModel(m_modeView);
1402+
1403+ connect(m_devicesModel,SIGNAL(stdOutMessage(QString)),m_qmlControl,SLOT(addText(QString)));
1404+ connect(m_devicesModel,SIGNAL(stdErrMessage(QString)),m_qmlControl,SLOT(addErrorText(QString)));
1405+ connect(m_emulatorModel,SIGNAL(logMessage(QString)),m_qmlControl,SLOT(addText(QString)));
1406+ connect(m_emulatorModel,SIGNAL(stdOutMessage(QString)),m_qmlControl,SLOT(addText(QString)));
1407+ connect(m_emulatorModel,SIGNAL(stdErrMessage(QString)),m_qmlControl,SLOT(addErrorText(QString)));
1408+
1409+ QWidget* container = QWidget::createWindowContainer(m_modeView);
1410+ container->setMinimumWidth(860);
1411+ container->setMinimumHeight(548);
1412+ container->setFocusPolicy(Qt::TabFocus);
1413+ layout->addWidget(container);
1414+
1415+ m_modeView->rootContext()->setContextProperty(QLatin1String("devicesModel") ,m_devicesModel);
1416+ m_modeView->rootContext()->setContextProperty(QLatin1String("emulatorModel"),m_emulatorModel);
1417+ m_modeView->rootContext()->setContextProperty(QLatin1String("deviceMode") ,m_qmlControl);
1418+ m_modeView->rootContext()->setContextProperty(QLatin1String("resourceRoot") ,Constants::UBUNTU_DEVICESCREEN_ROOT);
1419+ m_modeView->setSource(QUrl::fromLocalFile(Constants::UBUNTU_DEVICESCREEN_QML));
1420
1421 connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), SLOT(modeChanged(Core::IMode*)));
1422-
1423 setWidget(m_modeWidget);
1424 }
1425
1426-void UbuntuDeviceMode::modeChanged(Core::IMode *mode) {
1427-
1428+UbuntuDevice::ConstPtr UbuntuDeviceMode::device()
1429+{
1430+ if(m_devicesModel->rowCount() <= 0)
1431+ return UbuntuDevice::ConstPtr();
1432+
1433+ if(!m_deviceIndex.isValid()) {
1434+ m_deviceIndex = 0; //device 0 is always the first selected
1435+ }
1436+ return m_devicesModel->device(m_deviceIndex.toInt());
1437+}
1438+
1439+void UbuntuDeviceMode::deviceSelected(const QVariant index)
1440+{
1441+ m_deviceIndex = index;
1442+ emit updateDeviceActions ();
1443+}
1444+
1445+void UbuntuDeviceMode::modeChanged(Core::IMode *mode)
1446+{
1447+ Q_UNUSED(mode);
1448 }
1449
1450 void UbuntuDeviceMode::initialize() {
1451
1452-
1453+}
1454+
1455+UbuntuDeviceMode *UbuntuDeviceMode::instance()
1456+{
1457+ return m_instance;
1458+}
1459+
1460+
1461+UbuntuQMLDeviceMode::UbuntuQMLDeviceMode(UbuntuDeviceMode *parent)
1462+ : QObject(parent),
1463+ m_mode(parent)
1464+{
1465+
1466+}
1467+
1468+void UbuntuQMLDeviceMode::deviceSelected(const QVariant index)
1469+{
1470+ m_mode->deviceSelected(index);
1471+}
1472+
1473+void UbuntuQMLDeviceMode::addText(const QString &arg)
1474+{
1475+ QString in = arg;
1476+ in.replace(QStringLiteral("\n"),QStringLiteral("<br>"));
1477+ emit appendText(in);
1478+}
1479+
1480+void UbuntuQMLDeviceMode::addErrorText(const QString &error)
1481+{
1482+ QString in = error;
1483+ in.replace(QStringLiteral("\n"),QStringLiteral("<br>"));
1484+ in.prepend(QStringLiteral("<font color=\"#FF0000\">"));
1485+ in.append(QStringLiteral("</font>"));
1486+ emit appendText(in);
1487 }
1488
1489=== modified file 'src/ubuntu/ubuntudevicemode.h'
1490--- src/ubuntu/ubuntudevicemode.h 2013-09-04 15:30:00 +0000
1491+++ src/ubuntu/ubuntudevicemode.h 2014-04-27 13:29:17 +0000
1492@@ -19,12 +19,38 @@
1493 #ifndef UBUNTUDEVICEMODE_H
1494 #define UBUNTUDEVICEMODE_H
1495
1496+#include "ubuntudevice.h"
1497 #include <coreplugin/imode.h>
1498-#include "ubuntudeviceswidget.h"
1499+
1500+class QQuickView;
1501
1502 namespace Ubuntu {
1503 namespace Internal {
1504
1505+class UbuntuDevicesModel;
1506+class UbuntuEmulatorModel;
1507+class UbuntuDeviceMode;
1508+
1509+class UbuntuQMLDeviceMode : public QObject {
1510+ Q_OBJECT
1511+
1512+public:
1513+ UbuntuQMLDeviceMode( UbuntuDeviceMode *parent );
1514+
1515+public slots:
1516+ void deviceSelected ( const QVariant index );
1517+ void addText (const QString &arg);
1518+ void addErrorText (const QString &error);
1519+
1520+signals:
1521+ void logChanged(const QString &arg);
1522+ void appendText(const QString &newText);
1523+
1524+private:
1525+ UbuntuDeviceMode* m_mode;
1526+};
1527+
1528+
1529 class UbuntuDeviceMode : public Core::IMode
1530 {
1531 Q_OBJECT
1532@@ -33,12 +59,26 @@
1533 UbuntuDeviceMode(QObject *parent = 0);
1534 void initialize();
1535
1536+ static UbuntuDeviceMode *instance();
1537+ UbuntuDevice::ConstPtr device();
1538+
1539+ void deviceSelected ( const QVariant index );
1540+
1541+signals:
1542+ void updateDeviceActions ();
1543+
1544 protected slots:
1545 void modeChanged(Core::IMode*);
1546
1547 protected:
1548+ static UbuntuDeviceMode *m_instance;
1549+ UbuntuDevicesModel *m_devicesModel;
1550+ UbuntuEmulatorModel *m_emulatorModel;
1551+ UbuntuQMLDeviceMode *m_qmlControl;
1552+ QQuickView *m_modeView;
1553 QWidget* m_modeWidget;
1554- UbuntuDevicesWidget m_ubuntuDevicesWidget;
1555+ QVariant m_deviceIndex;
1556+ QString m_log;
1557 };
1558
1559
1560
1561=== added file 'src/ubuntu/ubuntudevicesmodel.cpp'
1562--- src/ubuntu/ubuntudevicesmodel.cpp 1970-01-01 00:00:00 +0000
1563+++ src/ubuntu/ubuntudevicesmodel.cpp 2014-04-27 13:29:17 +0000
1564@@ -0,0 +1,734 @@
1565+#include "ubuntudevicesmodel.h"
1566+#include "ubuntuconstants.h"
1567+#include "ubuntukitmanager.h"
1568+
1569+#include <projectexplorer/devicesupport/devicemanager.h>
1570+#include <projectexplorer/kitmanager.h>
1571+#include <projectexplorer/kit.h>
1572+#include <projectexplorer/kitinformation.h>
1573+
1574+#include <QCoreApplication>
1575+#include <QRegularExpression>
1576+#include <QRegularExpressionMatch>
1577+#include <QVariant>
1578+
1579+namespace Ubuntu {
1580+namespace Internal {
1581+
1582+UbuntuDevicesModel::UbuntuDevicesModel(QObject *parent) :
1583+ QAbstractListModel(parent)
1584+{
1585+ m_deviceNotifier = new UbuntuDeviceNotifier(this);
1586+ connect(m_deviceNotifier,SIGNAL(deviceConnected(QString)),this,SLOT(deviceConnected(QString)));
1587+
1588+ m_adbProcess = new QProcess(this);
1589+ connect(m_adbProcess,SIGNAL(finished(int)),this,SLOT(refreshFinished(int)));
1590+ connect(m_adbProcess,SIGNAL(readyRead()),this,SLOT(adbReadyRead()));
1591+
1592+
1593+ ProjectExplorer::KitManager* devMgr = static_cast<ProjectExplorer::KitManager*>(ProjectExplorer::KitManager::instance());
1594+ connect(devMgr,SIGNAL(kitsLoaded()),this,SLOT(refresh()));
1595+ connect(ProjectExplorer::DeviceManager::instance(),SIGNAL(deviceListReplaced()),this,SLOT(readDevicesFromSettings()));
1596+}
1597+
1598+bool UbuntuDevicesModel::set(int index, const QString &role, const QVariant &value)
1599+{
1600+ if(index < 0 || index >= rowCount())
1601+ return false;
1602+
1603+ QModelIndex idx = createIndex(index,0);
1604+ if(!roleNames().values().contains(role.toUtf8()))
1605+ return false;
1606+
1607+ return setData(idx,value,roleNames().key(role.toUtf8()));
1608+}
1609+
1610+int UbuntuDevicesModel::rowCount(const QModelIndex &parent) const
1611+{
1612+ if(parent.isValid())
1613+ return 0;
1614+ return m_knownDevices.size();
1615+}
1616+
1617+bool UbuntuDevicesModel::setData(const QModelIndex &index, const QVariant &value, int role)
1618+{
1619+ qDebug()<<"Setting index "<<index<<" with data "<<value<<" to role "<<role;
1620+ if(!index.isValid()
1621+ || index.parent().isValid()
1622+ || index.row() < 0
1623+ || index.row() > rowCount())
1624+ return false;
1625+
1626+ UbuntuDevice::Ptr dev = m_knownDevices[index.row()]->device();
1627+
1628+ switch (role) {
1629+ case Qt::DisplayRole:
1630+ case Qt::EditRole:
1631+ return false;
1632+ case KitListRole:
1633+ return false;
1634+ case DeveloperModeRole: {
1635+ if(!value.type() == QVariant::Bool)
1636+ return false;
1637+
1638+ bool set = value.toBool();
1639+ UbuntuDevice::FeatureState newState = set ? UbuntuDevice::Available : UbuntuDevice::NotAvailable;
1640+ UbuntuDevice::FeatureState oldState = dev->developerModeEnabled();
1641+
1642+ if(oldState == UbuntuDevice::Unknown)
1643+ return false;
1644+
1645+ if( oldState != newState )
1646+ dev->setDeveloperModeEnabled(set);
1647+ return true;
1648+ break;
1649+ }
1650+ case NetworkConnectionRole: {
1651+ if(!value.type() == QVariant::Bool)
1652+ return false;
1653+
1654+ bool set = value.toBool();
1655+ UbuntuDevice::FeatureState oldState = dev->hasNetworkConnection();
1656+
1657+ if( oldState == UbuntuDevice::Unknown || oldState == UbuntuDevice::Available )
1658+ return false;
1659+
1660+ if(set)
1661+ dev->cloneNetwork();
1662+ return true;
1663+
1664+ break;
1665+ }
1666+ case WriteableImageRole: {
1667+ if(!value.type() == QVariant::Bool)
1668+ return false;
1669+
1670+ bool set = value.toBool();
1671+ UbuntuDevice::FeatureState newState = set ? UbuntuDevice::Available : UbuntuDevice::NotAvailable;
1672+ UbuntuDevice::FeatureState oldState = dev->hasWriteableImage();
1673+
1674+ if(oldState == UbuntuDevice::Unknown)
1675+ return false;
1676+
1677+ if( oldState != newState )
1678+ dev->setWriteableImageEnabled(set);
1679+ return true;
1680+ break;
1681+ }
1682+ case DeveloperToolsRole: {
1683+ if(!value.type() == QVariant::Bool)
1684+ return false;
1685+
1686+ bool set = value.toBool();
1687+ UbuntuDevice::FeatureState newState = set ? UbuntuDevice::Available : UbuntuDevice::NotAvailable;
1688+ UbuntuDevice::FeatureState oldState = dev->hasDeveloperTools();
1689+
1690+ if(oldState == UbuntuDevice::Unknown)
1691+ return false;
1692+
1693+ if( oldState != newState )
1694+ dev->setDeveloperToolsInstalled(set);
1695+ return true;
1696+ break;
1697+ }
1698+ default:
1699+ break;
1700+ }
1701+
1702+ return false;
1703+}
1704+
1705+QVariant UbuntuDevicesModel::data(const QModelIndex &index, int role) const
1706+{
1707+ if(!index.isValid()
1708+ || index.parent().isValid()
1709+ || index.row() < 0
1710+ || index.row() > rowCount())
1711+ return QVariant();
1712+
1713+ switch (role) {
1714+ case Qt::DisplayRole:
1715+ case Qt::EditRole:
1716+ return m_knownDevices[index.row()]->device()->displayName();
1717+ case UniqueIdRole:
1718+ return m_knownDevices[index.row()]->id().uniqueIdentifier();
1719+ case DetectionStateRole:
1720+ return m_knownDevices[index.row()]->device()->detectionState();
1721+ case DetectionStateStringRole:
1722+ return m_knownDevices[index.row()]->device()->detectionStateString();
1723+ case ConnectionStateRole:
1724+ return m_knownDevices[index.row()]->device()->deviceState();
1725+ case ConnectionStateStringRole:
1726+ return m_knownDevices[index.row()]->device()->deviceStateToString();
1727+ case KitListRole:
1728+ return QVariant::fromValue(m_knownDevices[index.row()]->kits());
1729+ case DeveloperModeRole:
1730+ return m_knownDevices[index.row()]->device()->developerModeEnabled();
1731+ case NetworkConnectionRole:
1732+ return m_knownDevices[index.row()]->device()->hasNetworkConnection();
1733+ case WriteableImageRole:
1734+ return m_knownDevices[index.row()]->device()->hasWriteableImage();
1735+ case DeveloperToolsRole:
1736+ return m_knownDevices[index.row()]->device()->hasDeveloperTools();
1737+ case EmulatorRole:
1738+ return false;
1739+ case LogRole:
1740+ return m_knownDevices[index.row()]->device()->helper()->log();
1741+ case SerialIdRole:
1742+ return m_knownDevices[index.row()]->device()->id().toSetting();
1743+ case ModelInfoRole:
1744+ return m_knownDevices[index.row()]->device()->modelInfo();
1745+ case DeviceInfoRole:
1746+ return m_knownDevices[index.row()]->device()->deviceInfo();
1747+ case ProductInfoRole:
1748+ return m_knownDevices[index.row()]->device()->productInfo();
1749+ default:
1750+ break;
1751+ }
1752+
1753+ return QVariant();
1754+}
1755+
1756+QHash<int, QByteArray> UbuntuDevicesModel::roleNames() const
1757+{
1758+ QHash<int,QByteArray> roles = QAbstractListModel::roleNames();
1759+ roles.insert(UniqueIdRole,"deviceId");
1760+ roles.insert(DetectionStateRole,"detectionState");
1761+ roles.insert(DetectionStateStringRole,"detectionStateString");
1762+ roles.insert(ConnectionStateRole,"connectionState");
1763+ roles.insert(ConnectionStateStringRole,"connectionStateString");
1764+ roles.insert(KitListRole,"kits");
1765+ roles.insert(DeveloperModeRole,"developerModeEnabled");
1766+ roles.insert(NetworkConnectionRole,"hasNetworkConnection");
1767+ roles.insert(WriteableImageRole,"hasWriteableImage");
1768+ roles.insert(DeveloperToolsRole,"hasDeveloperTools");
1769+ roles.insert(EmulatorRole,"isEmulator");
1770+ roles.insert(LogRole,"deviceLog");
1771+ roles.insert(SerialIdRole,"serial");
1772+ roles.insert(ModelInfoRole,"modelInfo");
1773+ roles.insert(DeviceInfoRole,"deviceInfo");
1774+ roles.insert(ProductInfoRole,"productInfo");
1775+ return roles;
1776+}
1777+
1778+Qt::ItemFlags UbuntuDevicesModel::flags(const QModelIndex &index) const
1779+{
1780+ return QAbstractListModel::flags(index) | Qt::ItemIsEditable;
1781+}
1782+
1783+void UbuntuDevicesModel::triggerCloneTimeConfig(const int devId)
1784+{
1785+ int row = findDevice(devId);
1786+ if(row < 0)
1787+ return;
1788+ m_knownDevices[row]->device()->cloneTimeConfig();
1789+}
1790+
1791+void UbuntuDevicesModel::triggerPortForwarding(const int devId)
1792+{
1793+ int row = findDevice(devId);
1794+ if(row < 0)
1795+ return;
1796+ m_knownDevices[row]->device()->enablePortForward();
1797+}
1798+
1799+void UbuntuDevicesModel::triggerSSHSetup(const int devId)
1800+{
1801+ int row = findDevice(devId);
1802+ if(row < 0)
1803+ return;
1804+ m_knownDevices[row]->device()->deployPublicKey();
1805+}
1806+
1807+void UbuntuDevicesModel::triggerSSHConnection(const int devId)
1808+{
1809+ int row = findDevice(devId);
1810+ if(row < 0)
1811+ return;
1812+ m_knownDevices[row]->device()->openTerminal();
1813+}
1814+
1815+void UbuntuDevicesModel::triggerReboot(const int devId)
1816+{
1817+ int row = findDevice(devId);
1818+ if(row < 0)
1819+ return;
1820+ m_knownDevices[row]->device()->reboot();
1821+}
1822+
1823+void UbuntuDevicesModel::triggerRebootBootloader(const int devId)
1824+{
1825+ int row = findDevice(devId);
1826+ if(row < 0)
1827+ return;
1828+ m_knownDevices[row]->device()->rebootToBootloader();
1829+}
1830+
1831+void UbuntuDevicesModel::triggerRebootRecovery(const int devId)
1832+{
1833+ int row = findDevice(devId);
1834+ if(row < 0)
1835+ return;
1836+ m_knownDevices[row]->device()->rebootToRecovery();
1837+}
1838+
1839+void UbuntuDevicesModel::triggerShutdown(const int devId)
1840+{
1841+ int row = findDevice(devId);
1842+ if(row < 0)
1843+ return;
1844+ m_knownDevices[row]->device()->shutdown();
1845+}
1846+
1847+void UbuntuDevicesModel::triggerKitAutocreate(const int devId)
1848+{
1849+ int row = findDevice(devId);
1850+ if(row < 0)
1851+ return;
1852+ UbuntuKitManager::autoCreateKit(m_knownDevices[row]->device());
1853+}
1854+
1855+void UbuntuDevicesModel::triggerKitRemove(const int devId, const QVariant &kitid)
1856+{
1857+ int row = findDevice(devId);
1858+ if(row < 0)
1859+ return;
1860+
1861+ ProjectExplorer::Kit* k = ProjectExplorer::KitManager::find(Core::Id::fromSetting(kitid));
1862+ if(ProjectExplorer::DeviceKitInformation::deviceId(k) == Core::Id(devId)) {
1863+ //completely delete the kit
1864+ ProjectExplorer::KitManager::deregisterKit(k);
1865+ }
1866+}
1867+
1868+void UbuntuDevicesModel::refresh()
1869+{
1870+ if( m_adbProcess->state() != QProcess::NotRunning ) {
1871+ //make sure we use a clean QProcess
1872+ m_adbProcess->disconnect(this);
1873+ m_adbProcess->kill();
1874+ m_adbProcess->deleteLater();
1875+
1876+ m_adbProcess = new QProcess(this);
1877+ connect(m_adbProcess,SIGNAL(finished(int)),this,SLOT(refreshFinished(int)));
1878+ connect(m_adbProcess,SIGNAL(readyRead()),this,SLOT(adbReadyRead()));
1879+ }
1880+ bool restartAdb = true;
1881+ m_adbProcess->setWorkingDirectory(QCoreApplication::applicationDirPath());
1882+ QStringList args = QStringList() << (restartAdb ? QString::number(1) : QString::number(0));
1883+ m_adbProcess->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTDEVICES_SCRIPT)
1884+ .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH),args);
1885+
1886+ clear();
1887+}
1888+
1889+void UbuntuDevicesModel::clear()
1890+{
1891+ if(rowCount()) {
1892+ beginRemoveRows(QModelIndex(),0,rowCount()-1);
1893+ qDeleteAll(m_knownDevices.begin(),m_knownDevices.end());
1894+ m_knownDevices.clear();
1895+ endRemoveRows();
1896+ }
1897+}
1898+
1899+int UbuntuDevicesModel::findDevice(int uniqueIdentifier) const
1900+{
1901+ for ( int i = 0; i < m_knownDevices.size(); i++ ) {
1902+ if(m_knownDevices[i]->id().uniqueIdentifier() == uniqueIdentifier)
1903+ return i;
1904+ }
1905+ return -1;
1906+}
1907+
1908+bool UbuntuDevicesModel::hasDevice(int uniqueIdentifier) const
1909+{
1910+ return findDevice(uniqueIdentifier) >= 0;
1911+}
1912+
1913+UbuntuDevice::ConstPtr UbuntuDevicesModel::device(const int index)
1914+{
1915+ if(index < 0 || index >= rowCount())
1916+ return UbuntuDevice::ConstPtr();
1917+ return m_knownDevices[index]->device();
1918+}
1919+
1920+UbuntuDevicesItem *UbuntuDevicesModel::createItem(UbuntuDevice::Ptr dev)
1921+{
1922+ UbuntuDevicesItem *devItem = new UbuntuDevicesItem(dev,this);
1923+ connect(devItem,SIGNAL(kitsChanged()),this,SLOT(kitsChanged()));
1924+ connect(devItem,SIGNAL(detectionStateChanged()),this,SLOT(detectionStateChanged()));
1925+ connect(devItem,SIGNAL(featureDetected()),this,SLOT(featureDetected()));
1926+ connect(devItem,SIGNAL(logUpdated()),this,SLOT(logUpdated()));
1927+ return devItem;
1928+}
1929+
1930+/*!
1931+ * \brief UbuntuDevicesModel::indexFromHelper
1932+ * Checks if the passed QObject is a DeviceHelper and returns the
1933+ * row index of the related device
1934+ */
1935+int UbuntuDevicesModel::indexFromHelper(QObject *possibleHelper)
1936+{
1937+ UbuntuDevicesItem* hlpr = qobject_cast<UbuntuDevicesItem*>(possibleHelper);
1938+ if(!hlpr) return -1;
1939+ return findDevice(hlpr->id().uniqueIdentifier());
1940+}
1941+
1942+void UbuntuDevicesModel::deviceChanged(QObject *possibleHelper, const QVector<int> &relatedRoles)
1943+{
1944+ int idx = indexFromHelper(possibleHelper);
1945+ if(idx < 0)
1946+ return;
1947+ QModelIndex changed = createIndex(idx,0);
1948+ emit dataChanged(changed,changed,relatedRoles);
1949+}
1950+
1951+/*!
1952+ * \brief UbuntuDevicesModel::readDevicesFromSettings
1953+ * read all known devices from the DeviceManager, this is triggered
1954+ * automatically on startup
1955+ */
1956+void UbuntuDevicesModel::readDevicesFromSettings()
1957+{
1958+ clear();
1959+
1960+ QList<UbuntuDevicesItem*> devs;
1961+ ProjectExplorer::DeviceManager* devMgr = ProjectExplorer::DeviceManager::instance();
1962+ for(int i = 0; i < devMgr->deviceCount(); i++) {
1963+ ProjectExplorer::IDevice::ConstPtr dev = devMgr->deviceAt(i);
1964+ if(dev && dev->type() == Core::Id(Constants::UBUNTU_DEVICE_TYPE_ID)) {
1965+
1966+ //ugly hack to get a mutable version of the device
1967+ //no idea why its necessary to lock it up
1968+ Ubuntu::Internal::UbuntuDevice* cPtr = qSharedPointerCast<const Ubuntu::Internal::UbuntuDevice>(dev)->helper()->device();
1969+ if(cPtr)
1970+ devs.append(createItem(cPtr->sharedFromThis()));
1971+
1972+ }
1973+ }
1974+
1975+ beginInsertRows(QModelIndex(),0,devs.count()-1);
1976+ m_knownDevices = devs;
1977+ endInsertRows();
1978+
1979+ connect(devMgr,SIGNAL(deviceAdded(Core::Id)),this,SLOT(deviceAdded(Core::Id)));
1980+ connect(devMgr,SIGNAL(deviceRemoved(Core::Id)),this,SLOT(deviceRemoved(Core::Id)));
1981+ connect(devMgr,SIGNAL(deviceUpdated(Core::Id)),this,SLOT(deviceUpdated(Core::Id)));
1982+}
1983+
1984+void UbuntuDevicesModel::detectionStateChanged()
1985+{
1986+ //contains the possible changed roles when this slot is called
1987+ static QVector<int> relatedRoles = QVector<int>()
1988+ << DetectionStateRole << DetectionStateStringRole;
1989+
1990+ deviceChanged(sender(),relatedRoles);
1991+}
1992+
1993+void UbuntuDevicesModel::featureDetected()
1994+{
1995+ //contains the possible changed roles when this slot is called
1996+ static QVector<int> relatedRoles = QVector<int>()
1997+ << DeveloperModeRole << NetworkConnectionRole
1998+ << WriteableImageRole << DeveloperToolsRole;
1999+
2000+ deviceChanged(sender(),relatedRoles);
2001+}
2002+
2003+void UbuntuDevicesModel::logUpdated()
2004+{
2005+ //contains the possible changed roles when this slot is called
2006+ static QVector<int> relatedRoles = QVector<int>()
2007+ << LogRole;
2008+
2009+ deviceChanged(sender(),relatedRoles);
2010+}
2011+
2012+void UbuntuDevicesModel::kitsChanged()
2013+{
2014+ //contains the possible changed roles when this slot is called
2015+ static QVector<int> relatedRoles = QVector<int>()
2016+ << KitListRole;
2017+
2018+ deviceChanged(sender(),relatedRoles);
2019+}
2020+
2021+/*!
2022+ * \brief UbuntuDevicesModel::deviceAdded
2023+ * A device was added in the DeviceManager, check if know it and
2024+ * if we should know it. If its a new Ubuntu device its added to
2025+ * the known devices
2026+ */
2027+void UbuntuDevicesModel::deviceAdded(const Core::Id &id)
2028+{
2029+ ProjectExplorer::IDevice::ConstPtr ptr = ProjectExplorer::DeviceManager::instance()->find(id);
2030+ if(!ptr)
2031+ return;
2032+
2033+ if(ptr->type() != Core::Id(Constants::UBUNTU_DEVICE_TYPE_ID))
2034+ return;
2035+
2036+ qDebug()<<"Device Manager reports device added: "<<id.toString();
2037+ if (hasDevice(id.uniqueIdentifier()))
2038+ return;
2039+
2040+ Ubuntu::Internal::UbuntuDevice::ConstPtr ubuntuDev
2041+ = qSharedPointerCast<const Ubuntu::Internal::UbuntuDevice>(ptr);
2042+
2043+ Ubuntu::Internal::UbuntuDeviceHelper* hlp = ubuntuDev->helper();
2044+ Ubuntu::Internal::UbuntuDevice* dev = hlp->device();
2045+
2046+ beginInsertRows(QModelIndex(),rowCount(),rowCount());
2047+ m_knownDevices.append(createItem(dev->sharedFromThis()));
2048+ endInsertRows();
2049+}
2050+
2051+/*!
2052+ * \brief UbuntuDevicesWidget::deviceRemoved
2053+ * A device was removed from the device manager, if its one of ours
2054+ * we will also remove it
2055+ */
2056+void UbuntuDevicesModel::deviceRemoved(const Core::Id &id)
2057+{
2058+ int index = findDevice(id.uniqueIdentifier());
2059+ if(index < 0)
2060+ return;
2061+
2062+ qDebug()<<"Device Manager reports device removed: "<<id.toString();
2063+ beginRemoveRows(QModelIndex(),index,index);
2064+ delete m_knownDevices.takeAt(index);
2065+ endRemoveRows();
2066+}
2067+
2068+/*!
2069+ * \brief UbuntuDevicesModel::deviceUpdated
2070+ * called when a device state is changed between connected
2071+ * and disconnected or device data was changed
2072+ */
2073+void UbuntuDevicesModel::deviceUpdated(const Core::Id &id)
2074+{
2075+ //contains the possible changed roles when this slot is called
2076+ static QVector<int> relatedRoles = QVector<int>()
2077+ << Qt::DisplayRole << Qt::EditRole
2078+ << ConnectionStateRole << ConnectionStateStringRole;
2079+
2080+ int index = findDevice(id.uniqueIdentifier());
2081+ if(index >= 0) {
2082+ QModelIndex changed = createIndex(index,0);
2083+ emit dataChanged(changed, changed,relatedRoles);
2084+ }
2085+}
2086+
2087+void UbuntuDevicesModel::deviceConnected(const QString &id)
2088+{
2089+ int idx = findDevice(Core::Id::fromSetting(id).uniqueIdentifier());
2090+ if(idx >= 0)
2091+ return;
2092+
2093+ refresh();
2094+}
2095+
2096+void UbuntuDevicesModel::refreshFinished(int exitCode)
2097+{
2098+ readDevicesFromSettings();
2099+ foreach(UbuntuDevicesItem* item, m_knownDevices)
2100+ item->device()->helper()->refresh();
2101+
2102+ if(exitCode != 0) {
2103+ return;
2104+ }
2105+
2106+ //read all data from the process
2107+ adbReadyRead();
2108+
2109+ QStringList lines = m_adbReply.trimmed().split(QLatin1String(Constants::LINEFEED));
2110+ foreach(QString line, lines) {
2111+ line = line.trimmed();
2112+
2113+ if (line.isEmpty()) {
2114+ continue;
2115+ }
2116+
2117+ QRegularExpression exp(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_ADB_REGEX));
2118+ QRegularExpressionMatch match = exp.match(line);
2119+
2120+ if(match.hasMatch()) {
2121+ QStringList lineData = match.capturedTexts();
2122+
2123+ //The first entry is always the full match
2124+ //which means in our case its the complete string
2125+ lineData.takeFirst();
2126+
2127+ if (lineData.count() == 2) {
2128+ QString sSerialNumber = lineData.takeFirst();
2129+ QString sDeviceInfo = lineData.takeFirst();
2130+
2131+ //sometimes the adb server is not started when adb devices is
2132+ //executed, we just skip those lines
2133+ if(sSerialNumber == QLatin1String("*"))
2134+ continue;
2135+
2136+ if(sSerialNumber.isEmpty() || sSerialNumber.startsWith(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_ADB_NOACCESS))) {
2137+ continue;
2138+ }
2139+
2140+ registerNewDevice(sSerialNumber,sDeviceInfo);
2141+ }
2142+ }
2143+ }
2144+}
2145+
2146+void UbuntuDevicesModel::adbReadyRead()
2147+{
2148+ QString stderr = QString::fromLocal8Bit(m_adbProcess->readAllStandardError());
2149+ QString stdout = QString::fromLocal8Bit(m_adbProcess->readAllStandardOutput());
2150+
2151+ if(!stderr.trimmed().isEmpty()) {
2152+ emit stdErrMessage(stderr);
2153+ m_adbReply.append(stderr);
2154+ }
2155+
2156+ if(!stdout.trimmed().isEmpty()) {
2157+ emit stdOutMessage(stdout);
2158+ m_adbReply.append(stdout);
2159+ }
2160+ qDebug()<<m_adbReply;
2161+}
2162+
2163+/*!
2164+ * \brief UbuntuDevicesModel::registerNewDevice
2165+ * Registers a new device in the device manager if its not
2166+ * already in the known devices map.
2167+ * \note will not add it into model list, this
2168+ * will happen automatically when the device is
2169+ * registered in the device manager
2170+ */
2171+void UbuntuDevicesModel::registerNewDevice(const QString &serial, const QString &deviceInfo)
2172+{
2173+ if(findDevice(Core::Id::fromSetting(serial).uniqueIdentifier()) >= 0)
2174+ return;
2175+
2176+ bool isEmu = serial.startsWith(QLatin1String("emulator"));
2177+
2178+ Ubuntu::Internal::UbuntuDevice::Ptr dev = Ubuntu::Internal::UbuntuDevice::create(
2179+ tr("Ubuntu Device")
2180+ , serial
2181+ , isEmu ? ProjectExplorer::IDevice::Emulator : ProjectExplorer::IDevice::Hardware
2182+ , ProjectExplorer::IDevice::AutoDetected);
2183+
2184+ dev->setDeviceInfoString(deviceInfo);
2185+ ProjectExplorer::DeviceManager::instance()->addDevice(dev);
2186+}
2187+
2188+/*!
2189+ * \class UbuntuDevicesItem
2190+ * Represents a Device inside the UbuntuDevicesModel,
2191+ * the item tracks changes in the device and notifies the model
2192+ * accordingly
2193+ */
2194+UbuntuDevicesItem::UbuntuDevicesItem(UbuntuDevice::Ptr device, QObject* parent) :
2195+ QObject(parent),
2196+ m_device(device)
2197+{
2198+ QList<ProjectExplorer::Kit*> allkits = ProjectExplorer::KitManager::kits();
2199+ foreach (ProjectExplorer::Kit* k, allkits) {
2200+ if( ProjectExplorer::DeviceKitInformation::deviceId(k) == device->id() )
2201+ m_myKits.insert(k->id());
2202+ }
2203+
2204+ connect(ProjectExplorer::KitManager::instance(),SIGNAL(kitAdded(ProjectExplorer::Kit*)),
2205+ this,SLOT(onKitAdded(ProjectExplorer::Kit*)));
2206+ connect(ProjectExplorer::KitManager::instance(),SIGNAL(kitRemoved(ProjectExplorer::Kit*)),
2207+ this,SLOT(onKitRemoved(ProjectExplorer::Kit*)));
2208+ connect(ProjectExplorer::KitManager::instance(),SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
2209+ this,SLOT(onKitUpdated(ProjectExplorer::Kit*)));
2210+
2211+ connect(device->helper(),SIGNAL(detectionStateChanged()),this,SLOT(deviceStateChanged()));
2212+ connect(device->helper(),SIGNAL(featureDetected()),this,SIGNAL(featureDetected()));
2213+ connect(device->helper(),SIGNAL(message(QString)),this,SIGNAL(logUpdated()));
2214+}
2215+
2216+/*!
2217+ * \brief UbuntuDevicesItem::id
2218+ * Returns the internal device ID
2219+ */
2220+Core::Id UbuntuDevicesItem::id() const
2221+{
2222+ return m_device->id();
2223+}
2224+
2225+UbuntuDevice::Ptr UbuntuDevicesItem::device() const
2226+{
2227+ return m_device;
2228+}
2229+
2230+QVariantList UbuntuDevicesItem::kits() const
2231+{
2232+ QVariantList kits;
2233+ foreach (const Core::Id &id, m_myKits) {
2234+ ProjectExplorer::Kit* k = ProjectExplorer::KitManager::find(id);
2235+ if(!k)
2236+ continue;
2237+
2238+ qDebug()<<"Adding "<<k->displayName();
2239+
2240+ QVariantMap m;
2241+ m.insert(QStringLiteral("displayName"),k->displayName());
2242+ m.insert(QStringLiteral("id"),k->id().toSetting());
2243+ kits.append(QVariant::fromValue(m));
2244+ }
2245+
2246+ return kits;
2247+}
2248+
2249+/*!
2250+ * \brief UbuntuDevicesItem::onKitAdded
2251+ * Checks if the new Kit that just got added to the KitManager contains
2252+ * the device, if it does the Kit is added to the internal Kit list
2253+ */
2254+void UbuntuDevicesItem::onKitAdded(ProjectExplorer::Kit *k)
2255+{
2256+ if( ProjectExplorer::DeviceKitInformation::deviceId(k) == m_device->id() ) {
2257+ if(!m_myKits.contains(k->id())){
2258+ m_myKits.insert(k->id());
2259+ emit kitsChanged();
2260+ }
2261+ }
2262+}
2263+
2264+/*!
2265+ * \brief UbuntuDevicesItem::onKitRemoved
2266+ * Checks if the removed Kit \a k is in the internal Kit list
2267+ * and removes it
2268+ */
2269+void UbuntuDevicesItem::onKitRemoved(ProjectExplorer::Kit *k)
2270+{
2271+ if(m_myKits.contains(k->id())) {
2272+ m_myKits.remove(k->id());
2273+ emit kitsChanged();
2274+ }
2275+}
2276+
2277+/*!
2278+ * \brief UbuntuDevicesItem::onKitUpdated
2279+ * Checks if the updated Kit now contains the internal device
2280+ * or if it does NOT contain the device anymore
2281+ */
2282+void UbuntuDevicesItem::onKitUpdated(ProjectExplorer::Kit *k)
2283+{
2284+ if( ProjectExplorer::DeviceKitInformation::deviceId(k) == m_device->id() ) {
2285+ onKitAdded(k);
2286+ } else {
2287+ onKitRemoved(k);
2288+ }
2289+}
2290+
2291+void UbuntuDevicesItem::deviceStateChanged()
2292+{
2293+ emit detectionStateChanged();
2294+}
2295+
2296+}
2297+}
2298+
2299
2300=== added file 'src/ubuntu/ubuntudevicesmodel.h'
2301--- src/ubuntu/ubuntudevicesmodel.h 1970-01-01 00:00:00 +0000
2302+++ src/ubuntu/ubuntudevicesmodel.h 2014-04-27 13:29:17 +0000
2303@@ -0,0 +1,169 @@
2304+#ifndef UBUNTUDEVICESMODEL_H
2305+#define UBUNTUDEVICESMODEL_H
2306+
2307+#include "ubuntudevice.h"
2308+#include "ubuntudevicenotifier.h"
2309+
2310+#include <coreplugin/id.h>
2311+
2312+#include <QAbstractListModel>
2313+#include <QList>
2314+
2315+namespace ProjectExplorer {
2316+class Kit;
2317+}
2318+
2319+namespace Ubuntu {
2320+namespace Internal {
2321+
2322+class UbuntuDevicesItem;
2323+
2324+class UbuntuDevicesModel : public QAbstractListModel
2325+{
2326+ Q_OBJECT
2327+public:
2328+
2329+ enum Roles {
2330+ ConnectionStateRole = Qt::UserRole,
2331+ UniqueIdRole,
2332+ ConnectionStateStringRole,
2333+ DetectionStateRole,
2334+ DetectionStateStringRole,
2335+ KitListRole,
2336+ DeveloperModeRole,
2337+ NetworkConnectionRole,
2338+ WriteableImageRole,
2339+ DeveloperToolsRole,
2340+ EmulatorRole,
2341+ LogRole,
2342+ SerialIdRole,
2343+ ModelInfoRole,
2344+ DeviceInfoRole,
2345+ ProductInfoRole
2346+ };
2347+
2348+ explicit UbuntuDevicesModel(QObject *parent = 0);
2349+
2350+ Q_INVOKABLE bool set(int index, const QString &role, const QVariant &value);
2351+
2352+ int findDevice(int uniqueIdentifier) const;
2353+ bool hasDevice (int uniqueIdentifier) const;
2354+ UbuntuDevice::ConstPtr device ( const int index );
2355+
2356+ // QAbstractItemModel interface
2357+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
2358+ virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
2359+ virtual QVariant data(const QModelIndex &index, int role) const;
2360+ virtual QHash<int, QByteArray> roleNames() const;
2361+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
2362+signals:
2363+ void logMessage (const QString &str);
2364+ void stdOutMessage (const QString &str);
2365+ void stdErrMessage (const QString &str);
2366+
2367+public slots:
2368+ void triggerCloneTimeConfig ( const int devId );
2369+ void triggerPortForwarding ( const int devId );
2370+ void triggerSSHSetup ( const int devId );
2371+ void triggerSSHConnection ( const int devId );
2372+ void triggerReboot ( const int devId );
2373+ void triggerRebootBootloader( const int devId );
2374+ void triggerRebootRecovery ( const int devId );
2375+ void triggerShutdown ( const int devId );
2376+ void triggerKitAutocreate ( const int devId );
2377+ void triggerKitRemove (const int devId, const QVariant &kitid );
2378+ void refresh ();
2379+
2380+protected:
2381+ void clear ();
2382+ UbuntuDevicesItem *createItem (UbuntuDevice::Ptr dev);
2383+ int indexFromHelper (QObject* possibleHelper);
2384+ void deviceChanged(QObject* possibleHelper, const QVector<int> &relatedRoles);
2385+ void registerNewDevice(const QString &serial, const QString &deviceInfo);
2386+
2387+protected slots:
2388+ void readDevicesFromSettings();
2389+ void detectionStateChanged ();
2390+ void featureDetected ();
2391+ void logUpdated ();
2392+ void kitsChanged ();
2393+ void deviceAdded(const Core::Id &id);
2394+ void deviceRemoved(const Core::Id &id);
2395+ void deviceUpdated(const Core::Id &id);
2396+ void deviceConnected(const QString&id);
2397+ void refreshFinished(int exitCode);
2398+ void adbReadyRead();
2399+
2400+private:
2401+ QList<UbuntuDevicesItem*> m_knownDevices;
2402+ UbuntuDeviceNotifier *m_deviceNotifier;
2403+ QProcess *m_adbProcess;
2404+ QString m_adbReply;
2405+};
2406+
2407+/*!
2408+ * \brief The UbuntuDeviceStates class
2409+ * Provides enums for QML
2410+ */
2411+class UbuntuDeviceStates : public QObject
2412+{
2413+ Q_OBJECT
2414+public:
2415+ enum FeatureState {
2416+ NotAvailable = UbuntuDevice::NotAvailable,
2417+ Unknown = UbuntuDevice::Unknown,
2418+ Available = UbuntuDevice::Available
2419+ };
2420+ Q_ENUMS(FeatureState)
2421+
2422+ enum DeviceDetectionState {
2423+ NotStarted = UbuntuDevice::NotStarted,
2424+ Detecting,
2425+ Done = UbuntuDevice::Done
2426+ };
2427+ Q_ENUMS(DeviceDetectionState)
2428+
2429+ enum DeviceConnectionState {
2430+ DeviceReadyToUse = ProjectExplorer::IDevice::DeviceReadyToUse,
2431+ DeviceConnected = ProjectExplorer::IDevice::DeviceConnected,
2432+ DeviceDisconnected = ProjectExplorer::IDevice::DeviceDisconnected,
2433+ DeviceStateUnknown = ProjectExplorer::IDevice::DeviceStateUnknown
2434+ };
2435+ Q_ENUMS(DeviceConnectionState)
2436+};
2437+
2438+class UbuntuDevicesItem : public QObject
2439+{
2440+ Q_OBJECT
2441+public:
2442+ UbuntuDevicesItem(Ubuntu::Internal::UbuntuDevice::Ptr device, QObject* parent = 0);
2443+
2444+ Core::Id id() const;
2445+ UbuntuDevice::Ptr device() const;
2446+ QVariantList kits() const;
2447+
2448+signals:
2449+ void kitsChanged ();
2450+ void connectionChanged ();
2451+ void detectionStateChanged ();
2452+ void featureDetected ();
2453+ void logUpdated();
2454+
2455+private slots:
2456+ void onKitAdded(ProjectExplorer::Kit *k);
2457+ void onKitRemoved(ProjectExplorer::Kit *k);
2458+ void onKitUpdated(ProjectExplorer::Kit *k);
2459+ void deviceStateChanged ();
2460+
2461+
2462+private:
2463+ Ubuntu::Internal::UbuntuDevice::Ptr m_device;
2464+ QSet<Core::Id> m_myKits;
2465+};
2466+
2467+}
2468+}
2469+
2470+
2471+
2472+#endif // UBUNTUDEVICESMODEL_H
2473
2474=== added file 'src/ubuntu/ubuntuemulatormodel.cpp'
2475--- src/ubuntu/ubuntuemulatormodel.cpp 1970-01-01 00:00:00 +0000
2476+++ src/ubuntu/ubuntuemulatormodel.cpp 2014-04-27 13:29:17 +0000
2477@@ -0,0 +1,408 @@
2478+#include "ubuntuemulatormodel.h"
2479+#include "ubuntuconstants.h"
2480+
2481+#include <utils/projectnamevalidatinglineedit.h>
2482+
2483+#include <QMutableStringListIterator>
2484+#include <QCoreApplication>
2485+#include <QStandardPaths>
2486+#include <QDir>
2487+#include <QRegularExpression>
2488+#include <QRegularExpressionMatch>
2489+
2490+namespace Ubuntu {
2491+namespace Internal {
2492+
2493+/*!
2494+ \brief UbuntuEmulatorModel
2495+ Provides informations about all existing emulators
2496+ \note This will be merged with the devices model when the
2497+ emulator tool can query the serial number of not running
2498+ emulators
2499+ */
2500+
2501+UbuntuEmulatorModel::UbuntuEmulatorModel(QObject *parent) :
2502+ QAbstractListModel(parent) ,
2503+ m_process(0),
2504+ m_emulatorInstalled(false) ,
2505+ m_state(UbuntuEmulatorModel::Initial),
2506+ m_cancellable(false)
2507+{
2508+ m_process = new UbuntuProcess(this);
2509+ connect(m_process,SIGNAL(message(QString)),this,SLOT(onMessage(QString)));
2510+ connect(m_process,SIGNAL(finished(QString,int)),this,SLOT(processFinished(QString,int)));
2511+ connect(m_process,SIGNAL(stdOut(QString)),this,SIGNAL(stdOutMessage(QString)));
2512+ connect(m_process,SIGNAL(error(QString)),this,SIGNAL(stdErrMessage(QString)));
2513+
2514+ checkEmulatorInstalled();
2515+}
2516+
2517+bool UbuntuEmulatorModel::emulatorInstalled() const
2518+{
2519+ return m_emulatorInstalled;
2520+}
2521+
2522+void UbuntuEmulatorModel::setEmulatorInstalled(bool arg)
2523+{
2524+ if (m_emulatorInstalled != arg) {
2525+ m_emulatorInstalled = arg;
2526+ emit emulatorInstalledChanged(arg);
2527+ }
2528+}
2529+
2530+bool UbuntuEmulatorModel::busy() const
2531+{
2532+ return m_busy;
2533+}
2534+
2535+void UbuntuEmulatorModel::setBusy(bool arg)
2536+{
2537+ if (m_busy != arg) {
2538+ m_busy = arg;
2539+ emit busyChanged(arg);
2540+ }
2541+}
2542+
2543+QString UbuntuEmulatorModel::state() const
2544+{
2545+ switch(m_state) {
2546+ case CheckEmulator: {
2547+ return tr("Checking if emulator tool is installed");
2548+ break;
2549+ }
2550+ case InstallEmulator: {
2551+ return tr("Installing emulator tool");
2552+ break;
2553+ }
2554+ case CreateEmulatorImage: {
2555+ return tr("Creating emulator image");
2556+ break;
2557+ }
2558+ case FindImages: {
2559+ return tr("Searching for emulator images");
2560+ break;
2561+ }
2562+ default:
2563+ return QString();
2564+ break;
2565+ }
2566+}
2567+
2568+void UbuntuEmulatorModel::setState(UbuntuEmulatorModel::State newState)
2569+{
2570+ if(m_state != newState) {
2571+ m_state = newState;
2572+ if(m_state == UbuntuEmulatorModel::Initial || m_state == UbuntuEmulatorModel::Idle)
2573+ setBusy(false);
2574+ else
2575+ setBusy(true);
2576+
2577+ emit stateChanged(state());
2578+ }
2579+}
2580+
2581+bool UbuntuEmulatorModel::cancellable() const
2582+{
2583+ return m_cancellable;
2584+}
2585+
2586+void UbuntuEmulatorModel::setCancellable(bool arg)
2587+{
2588+ if (m_cancellable != arg) {
2589+ m_cancellable = arg;
2590+ emit cancellableChanged(arg);
2591+ }
2592+}
2593+
2594+void UbuntuEmulatorModel::beginAction(const QString &msg)
2595+{
2596+ emit logMessage(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ACTION_BEGIN).arg(msg));
2597+}
2598+
2599+void UbuntuEmulatorModel::endAction(const QString &msg)
2600+{
2601+ emit logMessage(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ACTION_END).arg(msg));
2602+}
2603+
2604+int UbuntuEmulatorModel::rowCount(const QModelIndex &parent) const
2605+{
2606+ if(parent.isValid())
2607+ return 0;
2608+ return m_data.size();
2609+}
2610+
2611+QVariant UbuntuEmulatorModel::data(const QModelIndex &index, int role) const
2612+{
2613+ if(!index.isValid()
2614+ || index.parent().isValid()
2615+ || index.row() < 0
2616+ || index.row() > rowCount())
2617+ return QVariant();
2618+
2619+ switch (role) {
2620+ case Qt::DisplayRole:
2621+ case Qt::EditRole:
2622+ return m_data[index.row()].name;
2623+ case UbuntuVersionRole:
2624+ return m_data[index.row()].ubuntuVersion;
2625+ case DeviceVersionRole:
2626+ return m_data[index.row()].deviceVersion;
2627+ case ImageVersionRole:
2628+ return m_data[index.row()].imageVersion;
2629+ default:
2630+ break;
2631+ }
2632+ return QVariant();
2633+}
2634+
2635+QHash<int, QByteArray> UbuntuEmulatorModel::roleNames() const
2636+{
2637+ QHash<int, QByteArray> rNames = QAbstractListModel::roleNames();
2638+ rNames.insert(UbuntuVersionRole,"ubuntuVersion");
2639+ rNames.insert(DeviceVersionRole,"deviceVersion");
2640+ rNames.insert(ImageVersionRole,"imageVersion");
2641+ return rNames;
2642+}
2643+
2644+Qt::ItemFlags UbuntuEmulatorModel::flags(const QModelIndex &index) const
2645+{
2646+ return QAbstractListModel::flags(index);
2647+}
2648+
2649+void UbuntuEmulatorModel::clear()
2650+{
2651+ if(rowCount()) {
2652+ beginResetModel();
2653+ m_data.clear();
2654+ endResetModel();
2655+ }
2656+}
2657+
2658+void UbuntuEmulatorModel::checkEmulatorInstalled()
2659+{
2660+ setState(CheckEmulator);
2661+ setCancellable(false);
2662+
2663+ beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_EMULATOR_INSTALLED));
2664+ m_process->stop();
2665+ QString sEmulatorPackageName = QLatin1String(Ubuntu::Constants::EMULATOR_PACKAGE_NAME);
2666+ m_process->append(QStringList()
2667+ << QString::fromLatin1(Constants::UBUNTUWIDGETS_LOCAL_PACKAGE_INSTALLED_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH).arg(sEmulatorPackageName)
2668+ << QCoreApplication::applicationDirPath());
2669+ m_process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_EMULATOR_INSTALLED));
2670+
2671+}
2672+
2673+void UbuntuEmulatorModel::findEmulatorImages()
2674+{
2675+ setState(FindImages);
2676+ setCancellable(false);
2677+
2678+ beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_SEARCH_IMAGES));
2679+ m_process->stop();
2680+ m_process->append(QStringList()
2681+ << QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_SEARCH_IMAGES_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
2682+ << QCoreApplication::applicationDirPath());
2683+ m_process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_SEARCH_IMAGES));
2684+}
2685+
2686+void UbuntuEmulatorModel::installEmulator()
2687+{
2688+ if(m_emulatorInstalled)
2689+ return;
2690+
2691+ setState(InstallEmulator);
2692+ setCancellable(false);
2693+
2694+ beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_INSTALL_EMULATOR_PACKAGE));
2695+ QString sEmulatorPackageName = QLatin1String(Ubuntu::Constants::EMULATOR_PACKAGE_NAME);
2696+ m_process->stop();
2697+ m_process->append(QStringList()
2698+ << QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_INSTALL_EMULATOR_PACKAGE_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH).arg(sEmulatorPackageName)
2699+ << QCoreApplication::applicationDirPath());
2700+ m_process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_INSTALL_EMULATOR_PACKAGE));
2701+}
2702+
2703+void UbuntuEmulatorModel::createEmulatorImage(const QString &name)
2704+{
2705+ setState(CreateEmulatorImage);
2706+ setCancellable(true);
2707+
2708+ beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR));
2709+ m_process->stop();
2710+ QString strEmulatorName = name;
2711+ QString strEmulatorPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
2712+ strEmulatorPath += QDir::separator();
2713+ strEmulatorPath += QLatin1String(Constants::DEFAULT_EMULATOR_PATH);
2714+ strEmulatorPath += QDir::separator();
2715+ m_process->append(QStringList()
2716+ << QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR_SCRIPT)
2717+ .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH).arg(strEmulatorPath).arg(strEmulatorName)
2718+ << QCoreApplication::applicationDirPath());
2719+ m_process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR));
2720+}
2721+
2722+void UbuntuEmulatorModel::startEmulator(const QString &name)
2723+{
2724+ QStringList args = QStringList() << name;
2725+ QProcess::startDetached(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
2726+ ,args
2727+ ,QCoreApplication::applicationDirPath());
2728+}
2729+
2730+QVariant UbuntuEmulatorModel::validateEmulatorName(const QString &name)
2731+{
2732+
2733+ QString error;
2734+ bool result = Utils::ProjectNameValidatingLineEdit::validateProjectName(name,&error);
2735+
2736+ if(result) {
2737+ foreach(const EmulatorItem &item, m_data){
2738+ if(item.name == name) {
2739+ result = false;
2740+ error = tr("Emulator name already exists");
2741+ }
2742+ }
2743+ }
2744+
2745+ QVariantMap m;
2746+ m.insert(QStringLiteral("valid"),result);
2747+ m.insert(QStringLiteral("error"),error);
2748+ return QVariant::fromValue(m);
2749+}
2750+
2751+void UbuntuEmulatorModel::cancel()
2752+{
2753+ if (m_cancellable && m_state == CreateEmulatorImage) {
2754+ m_process->stop();
2755+ }
2756+}
2757+
2758+void UbuntuEmulatorModel::onMessage(const QString &msg)
2759+{
2760+ if (msg.startsWith(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_UNABLE_TO_FETCH))) {
2761+ setEmulatorInstalled(false);
2762+ }
2763+ m_reply.append(msg);
2764+}
2765+
2766+void UbuntuEmulatorModel::processFinished(const QString &, int)
2767+{
2768+ State lastState = m_state;
2769+ setCancellable(false);
2770+
2771+ setState(UbuntuEmulatorModel::Idle);
2772+ switch(lastState) {
2773+ case CheckEmulator: {
2774+ QStringList lines = m_reply.trimmed().split(QLatin1String(Constants::LINEFEED));
2775+ foreach(QString line, lines) {
2776+ line = line.trimmed();
2777+ if (line.isEmpty()) {
2778+ continue;
2779+ }
2780+ if (line.startsWith(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_LOCAL_NO_EMULATOR_INSTALLED))) {
2781+ setEmulatorInstalled(false);
2782+ } else {
2783+ QStringList lineData = line.split(QLatin1String(Constants::SPACE));
2784+ QString sEmulatorPackageStatus = lineData.takeFirst();
2785+ //QString sEmulatorPackageName = lineData.takeFirst();
2786+ //QString sEmulatorPackageVersion = lineData.takeFirst();
2787+ if (sEmulatorPackageStatus.startsWith(QLatin1String(Constants::INSTALLED))) {
2788+ setEmulatorInstalled(true);
2789+ findEmulatorImages();
2790+ }
2791+ }
2792+ }
2793+ break;
2794+ }
2795+ case InstallEmulator: {
2796+ QStringList lines = m_reply.trimmed().split(QLatin1String(Constants::LINEFEED));
2797+ foreach(QString line, lines) {
2798+ line = line.trimmed();
2799+ if (line.isEmpty()) {
2800+ continue;
2801+ }
2802+ if (line.startsWith(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_LOCAL_NO_EMULATOR_INSTALLED))) {
2803+ setEmulatorInstalled(false);
2804+ break;
2805+ } else {
2806+ QStringList lineData = line.split(QLatin1String(Constants::SPACE));
2807+ QString sEmulatorPackageStatus = lineData.takeFirst();
2808+ //QString sEmulatorPackageName = lineData.takeFirst();
2809+ //QString sEmulatorPackageVersion = lineData.takeFirst();
2810+ if (sEmulatorPackageStatus.startsWith(QLatin1String(Constants::INSTALLED))) {
2811+ setEmulatorInstalled(true);
2812+ findEmulatorImages();
2813+ break;
2814+ }
2815+ }
2816+ }
2817+ break;
2818+ }
2819+ case CreateEmulatorImage: {
2820+ findEmulatorImages();
2821+ break;
2822+ }
2823+ case FindImages: {
2824+ QStringList lines = m_reply.trimmed().split(QLatin1String(Constants::LINEFEED));
2825+ clear();
2826+
2827+ QList<EmulatorItem> items;
2828+
2829+ QMutableStringListIterator iter(lines);
2830+ QRegularExpression regexName (QStringLiteral("^(\\w+)"));
2831+ QRegularExpression regexUbuntu (QStringLiteral("ubuntu=([0-9]+)"));
2832+ QRegularExpression regexDevice (QStringLiteral("device=([0-9]+)"));
2833+ QRegularExpression regexVersion(QStringLiteral("version=([0-9]+)"));
2834+ while (iter.hasNext()) {
2835+ QString line = iter.next();
2836+ if(line.isEmpty()) {
2837+ iter.remove();
2838+ continue;
2839+ }
2840+
2841+ qDebug()<<"Handling emulator: "<<line;
2842+ QRegularExpressionMatch mName = regexName.match(line);
2843+ QRegularExpressionMatch mUbu = regexUbuntu.match(line);
2844+ QRegularExpressionMatch mDev = regexDevice.match(line);
2845+ QRegularExpressionMatch mVer = regexVersion.match(line);
2846+
2847+ if(!mName.hasMatch())
2848+ continue;
2849+
2850+ EmulatorItem item;
2851+ item.name = mName.captured(1);
2852+
2853+ if(mUbu.hasMatch())
2854+ item.ubuntuVersion = mUbu.captured(1);
2855+ else
2856+ item.ubuntuVersion = tr("unknown");
2857+
2858+ if(mDev.hasMatch())
2859+ item.deviceVersion = mDev.captured(1);
2860+ else
2861+ item.deviceVersion = tr("unknown");
2862+
2863+ if(mVer.hasMatch())
2864+ item.imageVersion = mVer.captured(1);
2865+ else
2866+ item.imageVersion = tr("unknown");
2867+
2868+ items.append(item);
2869+ }
2870+
2871+ if(items.count()) {
2872+ beginResetModel();
2873+ m_data = items;
2874+ endResetModel();
2875+ }
2876+ break;
2877+ }
2878+ default:
2879+ break;
2880+ }
2881+ m_reply.clear();
2882+}
2883+
2884+} // namespace Internal
2885+} // namespace Ubuntu
2886
2887=== added file 'src/ubuntu/ubuntuemulatormodel.h'
2888--- src/ubuntu/ubuntuemulatormodel.h 1970-01-01 00:00:00 +0000
2889+++ src/ubuntu/ubuntuemulatormodel.h 2014-04-27 13:29:17 +0000
2890@@ -0,0 +1,102 @@
2891+#ifndef UBUNTU_INTERNAL_UBUNTUEMULATORMODEL_H
2892+#define UBUNTU_INTERNAL_UBUNTUEMULATORMODEL_H
2893+
2894+#include "ubuntuprocess.h"
2895+#include <QAbstractListModel>
2896+
2897+namespace Ubuntu {
2898+namespace Internal {
2899+
2900+class UbuntuEmulatorModel : public QAbstractListModel
2901+{
2902+ Q_OBJECT
2903+public:
2904+
2905+ enum State {
2906+ Initial,
2907+ CheckEmulator,
2908+ InstallEmulator,
2909+ CreateEmulatorImage,
2910+ FindImages,
2911+ Idle
2912+ };
2913+
2914+ enum Roles {
2915+ UbuntuVersionRole = Qt::UserRole,
2916+ DeviceVersionRole,
2917+ ImageVersionRole
2918+ };
2919+
2920+ struct EmulatorItem {
2921+ QString name;
2922+ QString ubuntuVersion;
2923+ QString deviceVersion;
2924+ QString imageVersion;
2925+ };
2926+
2927+ Q_PROPERTY(bool emulatorInstalled READ emulatorInstalled WRITE setEmulatorInstalled NOTIFY emulatorInstalledChanged)
2928+ Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
2929+ Q_PROPERTY(bool cancellable READ cancellable NOTIFY cancellableChanged)
2930+ Q_PROPERTY(QString state READ state NOTIFY stateChanged)
2931+
2932+ explicit UbuntuEmulatorModel(QObject *parent = 0);
2933+
2934+ void setEmulatorInstalled(bool arg);
2935+ bool emulatorInstalled() const;
2936+
2937+ bool busy() const;
2938+ QString state() const;
2939+ bool cancellable() const;
2940+
2941+ // QAbstractItemModel interface
2942+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
2943+ virtual QVariant data(const QModelIndex &index, int role) const;
2944+ virtual QHash<int, QByteArray> roleNames() const;
2945+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
2946+
2947+protected:
2948+ void clear();
2949+ void setBusy(bool arg);
2950+ void setState(State newState);
2951+ void beginAction (const QString &msg);
2952+ void endAction (const QString &msg);
2953+ void setCancellable(bool arg);
2954+
2955+public slots:
2956+ void checkEmulatorInstalled ();
2957+ void findEmulatorImages ();
2958+ void installEmulator ();
2959+ void createEmulatorImage (const QString &name);
2960+ void startEmulator (const QString &name);
2961+ QVariant validateEmulatorName ( const QString &name);
2962+ void cancel ();
2963+
2964+protected slots:
2965+ void onMessage (const QString &msg);
2966+ void processFinished (const QString &, int);
2967+
2968+signals:
2969+ void emulatorInstalledChanged(bool arg);
2970+ void busyChanged(bool arg);
2971+ void stateChanged(const QString &arg);
2972+ void logMessage (const QString &str);
2973+ void stdOutMessage (const QString &str);
2974+ void stdErrMessage (const QString &str);
2975+
2976+ void cancellableChanged(bool arg);
2977+
2978+private:
2979+ QString m_reply;
2980+ UbuntuProcess *m_process;
2981+ bool m_emulatorInstalled;
2982+ State m_state;
2983+ bool m_busy;
2984+
2985+ QList<EmulatorItem> m_data;
2986+ bool m_cancellable;
2987+};
2988+
2989+} // namespace Internal
2990+} // namespace Ubuntu
2991+
2992+#endif // UBUNTU_INTERNAL_UBUNTUEMULATORMODEL_H
2993
2994=== modified file 'src/ubuntu/ubuntukitmanager.cpp'
2995--- src/ubuntu/ubuntukitmanager.cpp 2014-04-09 15:00:21 +0000
2996+++ src/ubuntu/ubuntukitmanager.cpp 2014-04-27 13:29:17 +0000
2997@@ -23,11 +23,24 @@
2998 return ProjectExplorer::ToolChainKitInformation::toolChain(a) == ProjectExplorer::ToolChainKitInformation::ToolChainKitInformation::toolChain(b);
2999 }
3000
3001+static bool lessThanToolchain (const ClickToolChain* left, const ClickToolChain* right)
3002+{
3003+ const UbuntuClickTool::Target &leftTarget = left->clickTarget();
3004+ const UbuntuClickTool::Target &rightTarget = right->clickTarget();
3005+
3006+ if(leftTarget.majorVersion < rightTarget.majorVersion)
3007+ return true;
3008+ if(leftTarget.minorVersion < rightTarget.minorVersion)
3009+ return true;
3010+
3011+ return false;
3012+}
3013+
3014 UbuntuKitManager::UbuntuKitManager()
3015 {
3016 }
3017
3018-void UbuntuKitManager::autoDetectKits()
3019+QList<ClickToolChain *> UbuntuKitManager::clickToolChains()
3020 {
3021 QList<ClickToolChain *> toolchains;
3022 // having a empty toolchains list will remove all autodetected kits for android
3023@@ -41,6 +54,42 @@
3024 toolchains << static_cast<ClickToolChain *>(tc);
3025 }
3026 }
3027+ return toolchains;
3028+}
3029+
3030+void UbuntuKitManager::autoCreateKit(UbuntuDevice::Ptr device)
3031+{
3032+ QList<ClickToolChain*> toolchains = clickToolChains();
3033+ if(toolchains.size() == 0) {
3034+ //create target
3035+ return;
3036+ }
3037+
3038+ qSort(toolchains.begin(),toolchains.end(),lessThanToolchain);
3039+
3040+ //right now we are going to use the last toolchain, because its the one
3041+ //with the highest framework, this needs to be changed once we have x86 targets
3042+ ClickToolChain* tc = toolchains.last();
3043+ ProjectExplorer::Kit* newKit = createKit(tc);
3044+ if(newKit) {
3045+ fixKit(newKit);
3046+
3047+ newKit->setDisplayName(tr("%1 (GCC %2-%3-%4)")
3048+ .arg(device->displayName())
3049+ .arg(tc->clickTarget().architecture)
3050+ .arg(tc->clickTarget().framework)
3051+ .arg(tc->clickTarget().series));
3052+
3053+ ProjectExplorer::DeviceKitInformation::setDevice(newKit,device);
3054+ ProjectExplorer::KitManager::registerKit(newKit);
3055+ }
3056+}
3057+
3058+void UbuntuKitManager::autoDetectKits()
3059+{
3060+ // having a empty toolchains list will remove all autodetected kits for android
3061+ // exactly what we want in that case
3062+ QList<ClickToolChain *> toolchains = clickToolChains();
3063
3064 QList<ProjectExplorer::Kit *> existingKits;
3065 foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits()) {
3066
3067=== modified file 'src/ubuntu/ubuntukitmanager.h'
3068--- src/ubuntu/ubuntukitmanager.h 2014-04-10 10:56:24 +0000
3069+++ src/ubuntu/ubuntukitmanager.h 2014-04-27 13:29:17 +0000
3070@@ -19,6 +19,7 @@
3071 #define UBUNTU_INTERNAL_UBUNTUKITMANAGER_H
3072
3073 #include "clicktoolchain.h"
3074+#include "ubuntudevice.h"
3075 #include <projectexplorer/kit.h>
3076
3077 namespace Debugger{
3078@@ -34,10 +35,12 @@
3079 public:
3080 UbuntuKitManager();
3081
3082+ static void autoCreateKit ( UbuntuDevice::Ptr device );
3083 static void autoDetectKits ();
3084 static ProjectExplorer::Kit *createKit (ClickToolChain* tc);
3085 static QVariant createOrFindDebugger(const Utils::FileName &path);
3086 static void fixKit (ProjectExplorer::Kit* k);
3087+ static QList<ClickToolChain *> clickToolChains();
3088 };
3089
3090 } // namespace Internal
3091
3092=== modified file 'src/ubuntu/ubuntumenu.cpp'
3093--- src/ubuntu/ubuntumenu.cpp 2014-04-15 07:51:40 +0000
3094+++ src/ubuntu/ubuntumenu.cpp 2014-04-27 13:29:17 +0000
3095@@ -19,7 +19,7 @@
3096 #include "ubuntumenu.h"
3097 #include "ubuntushared.h"
3098 #include "ubuntuconstants.h"
3099-#include "ubuntudeviceswidget.h"
3100+#include "ubuntudevicemode.h"
3101 #include "ubuntuproject.h"
3102 #include "ubuntuclicktool.h"
3103 #include "ubuntudevice.h"
3104@@ -82,7 +82,7 @@
3105 connect(&m_ubuntuProcess,SIGNAL(error(QString)),this,SLOT(onError(QString)));
3106
3107 connect(ProjectExplorer::ProjectExplorerPlugin::instance(),SIGNAL(updateRunActions()),this,SLOT(slotUpdateActions()));
3108- connect(UbuntuDevicesWidget::instance(),SIGNAL(updateDeviceActions()),this,SLOT(slotUpdateActions()));
3109+ connect(UbuntuDeviceMode::instance(),SIGNAL(updateDeviceActions()),this,SLOT(slotUpdateActions()));
3110 }
3111
3112
3113@@ -103,7 +103,7 @@
3114
3115 //bool canRun = projectExplorerInstance->canRun(startupProject,ProjectExplorer::NormalRunMode);
3116 bool projectOpen = (startupProject!=NULL);
3117- bool deviceDetected = UbuntuDevicesWidget::instance()->deviceDetected();
3118+ bool deviceDetected = !UbuntuDeviceMode::instance()->device().isNull();
3119
3120 foreach(QAction* act, m_actions) {
3121 bool requiresDevice = act->property(Constants::UBUNTU_MENUJSON_DEVICEREQUIRED).toBool();
3122@@ -475,8 +475,13 @@
3123 }
3124 }
3125
3126- UbuntuDevice::ConstPtr device = UbuntuDevicesWidget::instance()->device();
3127+ UbuntuDevice::ConstPtr device = UbuntuDeviceMode::instance()->device();
3128 if (device) {
3129+ if( device->deviceState() != ProjectExplorer::IDevice::DeviceReadyToUse ) {
3130+ QMessageBox::warning(0,tr("Device not ready"),tr("The currently selected device is not ready, please select another one on the devices mode"));
3131+ return;
3132+ }
3133+
3134 command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_IP),device->sshParameters().host);
3135 command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_USERNAME),device->sshParameters().userName);
3136 command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_PORT),QString::number(device->sshParameters().port));
3137
3138=== modified file 'src/ubuntu/ubuntuplugin.cpp'
3139--- src/ubuntu/ubuntuplugin.cpp 2014-04-10 18:50:24 +0000
3140+++ src/ubuntu/ubuntuplugin.cpp 2014-04-27 13:29:17 +0000
3141@@ -31,6 +31,7 @@
3142 #include "ubuntucmakebuildconfiguration.h"
3143 #include "ubunturemotedeployconfiguration.h"
3144 #include "ubuntulocaldeployconfiguration.h"
3145+#include "ubuntudevicesmodel.h"
3146 #include "localportsmanager.h"
3147
3148 #include <coreplugin/modemanager.h>
3149@@ -42,6 +43,7 @@
3150 #include <QDebug>
3151 #include <QFileInfo>
3152 #include <QGuiApplication>
3153+#include <QtQml>
3154
3155 using namespace Ubuntu;
3156 using namespace Ubuntu::Internal;
3157@@ -61,8 +63,9 @@
3158 Q_UNUSED(arguments)
3159 Q_UNUSED(errorString)
3160
3161+ qmlRegisterUncreatableType<UbuntuDeviceStates>("Ubuntu.DevicesModel",0,1,"States",QStringLiteral("Not instantiable"));
3162+
3163 const QLatin1String mimetypesXml(Constants::UBUNTU_MIMETYPE_XML);
3164-
3165 if (!Core::MimeDatabase::addMimeTypes(mimetypesXml, errorString))
3166 return false;
3167
3168
3169=== modified file 'src/ubuntu/ubuntuprocess.cpp'
3170--- src/ubuntu/ubuntuprocess.cpp 2014-03-06 09:43:48 +0000
3171+++ src/ubuntu/ubuntuprocess.cpp 2014-04-27 13:29:17 +0000
3172@@ -122,11 +122,8 @@
3173 emit finished(m_currentProcess->program(), code);
3174 return;
3175 }
3176- QString errorMsg = QString::fromLocal8Bit(m_currentProcess->readAllStandardError());
3177- if (errorMsg.trimmed().length()>0) emit error(errorMsg);
3178- QString msg = QString::fromLocal8Bit(m_currentProcess->readAllStandardOutput());
3179- if (msg.trimmed().length()>0) emit message(msg);
3180
3181+ processReadyRead();
3182 emit finished(m_currentProcess->program(), code);
3183 emit finished(m_currentProcess,m_currentProcess->program(),code);
3184 processCmdQueue();
3185@@ -135,10 +132,12 @@
3186 void UbuntuProcess::processReadyRead() {
3187 QString stderr = QString::fromLocal8Bit(m_currentProcess->readAllStandardError());
3188 QString stdout = QString::fromLocal8Bit(m_currentProcess->readAllStandardOutput());
3189- if (!stderr.isEmpty()) {
3190+ if (!stderr.trimmed().isEmpty()) {
3191+ emit error(stderr);
3192 emit message(stderr);
3193 }
3194- if (!stdout.isEmpty()) {
3195+ if (!stdout.trimmed().isEmpty()) {
3196+ emit stdOut(stdout);
3197 emit message(stdout);
3198 }
3199 }
3200
3201=== modified file 'src/ubuntu/ubuntuprocess.h'
3202--- src/ubuntu/ubuntuprocess.h 2014-03-06 09:43:48 +0000
3203+++ src/ubuntu/ubuntuprocess.h 2014-04-27 13:29:17 +0000
3204@@ -45,8 +45,9 @@
3205 void start(QString taskTitle);
3206
3207 signals:
3208- void message(QString);
3209- void error(QString);
3210+ void message(const QString&);
3211+ void error (const QString&);
3212+ void stdOut(const QString&);
3213 void finished(QString,int);
3214 void finished(const QProcess*,QString,int);
3215 void started(QString);
3216
3217=== modified file 'src/ubuntu/ubunturemoterunconfiguration.cpp'
3218--- src/ubuntu/ubunturemoterunconfiguration.cpp 2014-04-10 11:04:55 +0000
3219+++ src/ubuntu/ubunturemoterunconfiguration.cpp 2014-04-27 13:29:17 +0000
3220@@ -95,6 +95,8 @@
3221 env.appendOrSet(QLatin1String("QML2_IMPORT_PATH"),
3222 QString::fromLatin1("lib/%1").arg(clickTc->gnutriplet()),
3223 QString::fromLatin1(":"));
3224+ env.prependOrSetPath(QStringLiteral("lib/")+clickTc->gnutriplet()+QStringLiteral("/bin"));
3225+ env.appendOrSetPath(QStringLiteral("$PATH"));
3226 }
3227 env.appendOrSet(QLatin1String("pkgdir"),workingDirectory());
3228 env.appendOrSet(QLatin1String("APP_ID"),m_appId);
3229@@ -199,16 +201,24 @@
3230 return false;
3231 } else {
3232 //looks like a application without a launcher
3233- m_localExecutable = target()->activeBuildConfiguration()->buildDirectory().toString()
3234- + QDir::separator()
3235- + QLatin1String(Constants::UBUNTU_DEPLOY_DESTDIR)
3236- + QDir::separator()
3237- + command;
3238-
3239- m_remoteExecutable = workingDirectory()
3240- + QDir::separator()
3241- + command;
3242-
3243+ CMakeProjectManager::CMakeProject* pro = static_cast<CMakeProjectManager::CMakeProject*> (target()->project());
3244+ foreach(const CMakeProjectManager::CMakeBuildTarget &t, pro->buildTargets()) {
3245+ if(t.library || t.executable.isEmpty())
3246+ continue;
3247+
3248+ QFileInfo execInfo(t.executable);
3249+
3250+ if(execInfo.fileName() == commInfo.fileName())
3251+ m_localExecutable = t.executable;
3252+ }
3253+
3254+ if (m_localExecutable.isEmpty()) {
3255+ if(errorMessage)
3256+ *errorMessage = tr("Could not find %1 in the project targets").arg(command);
3257+ return false;
3258+ }
3259+
3260+ m_remoteExecutable = command;
3261 }
3262
3263 QFileInfo desk(m_desktopFile);
3264
3265=== modified file 'src/ubuntu/ubuntusettingsdeviceconnectivitywidget.cpp'
3266--- src/ubuntu/ubuntusettingsdeviceconnectivitywidget.cpp 2014-04-10 12:29:54 +0000
3267+++ src/ubuntu/ubuntusettingsdeviceconnectivitywidget.cpp 2014-04-27 13:29:17 +0000
3268@@ -18,7 +18,6 @@
3269
3270 #include "ubuntusettingsdeviceconnectivitywidget.h"
3271 #include "ui_ubuntusettingsdeviceconnectivitywidget.h"
3272-#include "ubuntudeviceswidget.h"
3273 #include "ubuntuconstants.h"
3274
3275 using namespace Ubuntu;

Subscribers

People subscribed via source and target branches