File: deadModelData.qml

package info (click to toggle)
qt6-declarative 6.8.2%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 305,852 kB
  • sloc: cpp: 760,684; javascript: 514,174; xml: 10,618; python: 2,806; ansic: 2,253; java: 815; sh: 213; makefile: 41; php: 27
file content (45 lines) | stat: -rw-r--r-- 1,299 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import QtQml

QtObject {
    function swapCorpses() {
        const lhsData = getModelData(lhsButtonListModel);
        const rhsData = getModelData(rhsButtonListModel);

        lhsButtonListModel.clear();
        rhsButtonListModel.clear();

        addToModel(lhsButtonListModel, rhsData);
        addToModel(rhsButtonListModel, lhsData);
    }

    property ListModel l1: ListModel {
        id: lhsButtonListModel
    }

    property ListModel l2: ListModel {
        id: rhsButtonListModel
    }

    Component.onCompleted: {
        lhsButtonListModel.append({ "ident": 1,  "buttonText": "B 1"});
        lhsButtonListModel.append({ "ident": 2,  "buttonText": "B 2"});
        lhsButtonListModel.append({ "ident": 3,  "buttonText": "B 3"});

        rhsButtonListModel.append({ "ident": 4,  "buttonText": "B 4"});
        rhsButtonListModel.append({ "ident": 5,  "buttonText": "B 5"});
        rhsButtonListModel.append({ "ident": 6,  "buttonText": "B 6"});
    }

    function getModelData(model) {
        var dataList = []
        for (var i = 0; i < model.count; ++i)
            dataList.push(model.get(i));

        return dataList;
    }

    function addToModel(model, buttonData) {
        for (var i = 0; i < buttonData.length; ++i)
            model.append(buttonData[i]);
    }
}