on xenial help sign in
make use of actual workspace model instead of dummy ListModels
6c68622Michael Zanetti
plugins/WindowManager/WorkspaceModel.h+4−4
@@ -40,10 +40,10 @@ public:
40
40
41 explicit WorkspaceModel(QObject *parent = 0);
41 explicit WorkspaceModel(QObject *parent = 0);
42
42
43− void append(Workspace* workspace);
43+ Q_INVOKABLE void append(Workspace* workspace);
44− void insert(int index, Workspace* workspace);
44+ Q_INVOKABLE void insert(int index, Workspace* workspace);
45− void remove(Workspace* workspace);
45+ Q_INVOKABLE void remove(Workspace* workspace);
46− void move(int from, int to);
46+ Q_INVOKABLE void move(int from, int to);
47
47
48 // From QAbstractItemModel
48 // From QAbstractItemModel
49 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
49 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
qml/Stage/Spread/ScreensAndWorkspaces.qml+6−14
@@ -1,7 +1,7 @@
1import QtQuick 2.4
1import QtQuick 2.4
2import Ubuntu.Components 1.3
2import Ubuntu.Components 1.3
3import Ubuntu.Components.Popups 1.3
3import Ubuntu.Components.Popups 1.3
4−import Unity.Screens 0.1
4+import WindowManager 1.0
5import Unity.Application 0.1
5import Unity.Application 0.1
6import ".."
6import ".."
7
7
@@ -91,7 +91,10 @@ Item {
91 actions: ActionList {
91 actions: ActionList {
92 Action {
92 Action {
93 text: "Add workspace"
93 text: "Add workspace"
94+ onTriggered: {
95+ var workspace = WorkspaceManager.createWorkspace();
94− onTriggered: workspaces.workspaceModel.append({text: "" + (workspaces.workspaceModel.count + 1)})
96+ workspaces.workspaceModel.append(workspace);
97+ }
95 }
98 }
96 }
99 }
97 }
100 }
@@ -110,18 +113,7 @@ Item {
110 screen: model.screen
113 screen: model.screen
111 background: root.background
114 background: root.background
112
115
113− workspaceModel: ListModel {
116+ workspaceModel: model.screen.workspaces
114− onCountChanged: print("model count changed to", count)
115− ListElement {text: "1"}
116− ListElement {text: "2"}
117− ListElement {text: "3"}
118− ListElement {text: "4"}
119− ListElement {text: "5"}
120− ListElement {text: "6"}
121−// ListElement {text: "7"}
122−// ListElement {text: "8"}
123−// ListElement {text: "9"}
124− }
125 }
117 }
126 }
118 }
127 }
119 }
qml/Stage/Spread/WorkspacePreview.qml−1
@@ -1,6 +1,5 @@
1import QtQuick 2.4
1import QtQuick 2.4
2import Ubuntu.Components 1.3
2import Ubuntu.Components 1.3
3−import Unity.Screens 0.1
4import Unity.Application 0.1
3import Unity.Application 0.1
5import ".."
4import ".."
6import "../../Components"
5import "../../Components"
qml/Stage/Spread/Workspaces.qml+3−9
@@ -19,7 +19,7 @@ Item {
19
19
20 onEntered: {
20 onEntered: {
21 var index = listView.getDropIndex(drag);
21 var index = listView.getDropIndex(drag);
22− listView.model.insert(index, {text: drag.source.text})
22+ listView.model.insert(index, drag.source.workspace)
23 listView.dropItemIndex = index;
23 listView.dropItemIndex = index;
24 drag.source.inDropArea = true;
24 drag.source.inDropArea = true;
25 }
25 }
@@ -243,7 +243,7 @@ Item {
243 var itemCoords = clickedItem.mapToItem(listView, -listView.leftMargin, 0);
243 var itemCoords = clickedItem.mapToItem(listView, -listView.leftMargin, 0);
244 fakeDragItem.x = itemCoords.x
244 fakeDragItem.x = itemCoords.x
245 fakeDragItem.y = itemCoords.y
245 fakeDragItem.y = itemCoords.y
246− fakeDragItem.text = listView.model.get(draggedIndex).text
246+ fakeDragItem.workspace = model.workspace
247
247
248 var mouseCoordsInItem = mapToItem(clickedItem, mouseX, mouseY);
248 var mouseCoordsInItem = mapToItem(clickedItem, mouseX, mouseY);
249 fakeDragItem.Drag.hotSpot.x = mouseCoordsInItem.x
249 fakeDragItem.Drag.hotSpot.x = mouseCoordsInItem.x
@@ -264,14 +264,8 @@ Item {
264 Drag.active: mouseArea.drag.active
264 Drag.active: mouseArea.drag.active
265 Drag.keys: ['workspace']
265 Drag.keys: ['workspace']
266
266
267− property string text
267+ property var workspace
268 property bool inDropArea: false
268 property bool inDropArea: false
269− Label {
270− anchors.centerIn: parent
271− text: parent.text
272− color: "red"
273− fontSize: "large"
274− }
275
269
276 Rectangle {
270 Rectangle {
277 anchors.fill: parent
271 anchors.fill: parent