summaryrefslogtreecommitdiffstats
path: root/examples/demos/stocqt/content/StockListView.qml
blob: f12a8e75c6acc7782e3b07c01fae0ed24a3a572e (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick 6.5
import QtQuick.Controls 6.5
import "components"
import content

import custom.StockEngine

Rectangle {
    id: root
    property var chosenElement: null
    color: "#101010"

    Rectangle {
        id: banner
        width: parent.width
        height: root.width < root.height? 70 : 0
        color: parent.color
        anchors.top: parent.top
        anchors.topMargin: 10
        visible: root.width < root.height
        Image {
            id: logoBig
            visible: root.width < root.height
            source: "images/qtLogo.png"
            anchors.verticalCenter: parent.verticalCenter
            anchors.horizontalCenter: parent.horizontalCenter
            fillMode: Image.PreserveAspectFit
        }

        Image {
            id: logoSmall
            visible: root.width > root.height
            source: "images/qtLogo2.png"
            anchors.verticalCenter: parent.verticalCenter
            anchors.horizontalCenter: parent.horizontalCenter
            fillMode: Image.PreserveAspectFit
        }
    }

    Search {
        id: searchBar
        anchors.top: banner.bottom
        anchors.horizontalCenter: parent.horizontalCenter
    }

    StockTitle {
        id: title
        width: parent.width
        height: 29
        anchors.top: searchBar.bottom
        date: qsTr("%1").arg(new Date().toLocaleDateString())
    }

    ListView {
        id: listView
        width: parent.width
        anchors.top: title.bottom
        anchors.bottom: parent.bottom
        clip: true
        boundsBehavior: Flickable.DragAndOvershootBounds
        model: StockEngine.filterModel

        currentIndex: -1
        delegate: StockDelegate {
            selectButton.onClicked: mainWindow.stateGroup.state = "StockView"
            width: listView.width
        }
    }
}