diff options
author | Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> | 2016-11-18 17:35:29 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-11-30 14:28:25 +0000 |
commit | 63c34dc6c1c6f24f8e83f295adc70fdcc392f8c5 (patch) | |
tree | 8081b7de90b5f2deab0fe74af7991229070dbc6c /examples/quick/demos/stocqt/content/StockListView.qml | |
parent | 005857c492ff2a907987e5aed4c61163a6f3fc44 (diff) |
StocQt example: Use QtQuick.Layouts instead of anchors
- Move the StockListView delegate and the top banner to
separate files.
- Use QtQuick.Layouts in place of anchors for most parts,
improving code readability and app scalability.
Change-Id: Ie8f13ef261bb343f15e9484bd15f8b94101daeb5
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'examples/quick/demos/stocqt/content/StockListView.qml')
-rw-r--r-- | examples/quick/demos/stocqt/content/StockListView.qml | 124 |
1 files changed, 2 insertions, 122 deletions
diff --git a/examples/quick/demos/stocqt/content/StockListView.qml b/examples/quick/demos/stocqt/content/StockListView.qml index d2bd52a69d..177580cf6b 100644 --- a/examples/quick/demos/stocqt/content/StockListView.qml +++ b/examples/quick/demos/stocqt/content/StockListView.qml @@ -43,8 +43,6 @@ import "." Rectangle { id: root - width: 320 - height: 410 anchors.top: parent.top anchors.bottom: parent.bottom color: "white" @@ -55,13 +53,12 @@ Rectangle { ListView { id: view anchors.fill: parent - width: parent.width clip: true keyNavigationWraps: true highlightMoveDuration: 0 focus: true snapMode: ListView.SnapToItem - model: StockListModel{} + model: StockListModel {} currentIndex: -1 // Don't pre-select any item onCurrentIndexChanged: { @@ -71,124 +68,7 @@ Rectangle { } } - delegate: Rectangle { - height: 102 - width: parent.width - color: "transparent" - MouseArea { - anchors.fill: parent; - onClicked: { - if (view.currentIndex == index) - mainRect.currentIndex = 1; - else - view.currentIndex = index; - } - } - - Text { - id: stockIdText - anchors.top: parent.top - anchors.topMargin: 15 - anchors.left: parent.left - anchors.leftMargin: 15 - width: 125 - height: 40 - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 20 - font.weight: Font.Bold - verticalAlignment: Text.AlignVCenter - text: stockId - } - - Text { - id: stockValueText - anchors.top: parent.top - anchors.topMargin: 15 - anchors.right: parent.right - anchors.rightMargin: 0.31 * parent.width - width: 190 - height: 40 - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 20 - font.bold: true - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - text: value - } - - Text { - id: stockValueChangeText - anchors.top: parent.top - anchors.topMargin: 15 - anchors.right: parent.right - anchors.rightMargin: 20 - width: 135 - height: 40 - color: "#328930" - font.family: Settings.fontFamily - font.pointSize: 20 - font.bold: true - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - text: change - onTextChanged: { - if (parseFloat(text) >= 0.0) - color = "#328930"; - else - color = "#d40000"; - } - } - - Text { - id: stockNameText - anchors.top: stockIdText.bottom - anchors.left: parent.left - anchors.leftMargin: 15 - width: 330 - height: 30 - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 16 - font.bold: false - elide: Text.ElideRight - maximumLineCount: 1 - verticalAlignment: Text.AlignVCenter - text: name - } - - Text { - id: stockValueChangePercentageText - anchors.top: stockIdText.bottom - anchors.right: parent.right - anchors.rightMargin: 20 - width: 120 - height: 30 - color: "#328930" - font.family: Settings.fontFamily - font.pointSize: 18 - font.bold: false - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - text: changePercentage - onTextChanged: { - if (parseFloat(text) >= 0.0) - color = "#328930"; - else - color = "#d40000"; - } - } - - Rectangle { - id: endingLine - anchors.bottom: parent.bottom - anchors.left: parent.left - height: 1 - width: parent.width - color: "#d7d7d7" - } - } + delegate: StockListDelegate {} highlight: Rectangle { width: view.width |