File: main.qml

package info (click to toggle)
qt6-remoteobjects 6.8.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,832 kB
  • sloc: cpp: 20,582; sh: 29; makefile: 23
file content (58 lines) | stat: -rw-r--r-- 1,396 bytes parent folder | download | duplicates (4)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (C) 2016 Ford Motor Company
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick 2.5
import QtQuick.Window 2.2

Window {
    visible: true
    width: 800
    height: 600
    Text {
        id: dummy
    }

    ListView {
        id: view
        anchors.fill: parent
        focus: true

        currentIndex: 10

        model: remoteModel

        snapMode: ListView.SnapToItem
        highlightFollowsCurrentItem: true
        highlightMoveDuration: 0

        delegate: Rectangle {
            width: view.width
            height: dummy.font.pixelSize * 2
            color: _color
            Text {
                anchors.centerIn: parent
                text: _text
            }
        }
        Keys.onPressed: {
            switch (event.key) {
            case Qt.Key_Home:
                view.currentIndex = 0;
            break;
            case Qt.Key_PageUp:
                currentIndex -= Math.random() * 300;
                if (currentIndex < 0)
                    currentIndex = 0;
                break;
            case Qt.Key_PageDown:
                currentIndex += Math.random() * 300;
                if (currentIndex >= count)
                    currentIndex = count - 1;
                break;
            case Qt.Key_End:
                currentIndex = count - 1;
            break;
            }
        }
    }
}