Skip to content

Commit cb28239

Browse files
committed
qml: Demo ChainModel with a list view
1 parent d662b59 commit cb28239

File tree

4 files changed

+70
-15
lines changed

4 files changed

+70
-15
lines changed

src/Makefile.qt.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ QML_QRC_CPP = qml/qrc_bitcoin.cpp
304304
QML_QRC = qml/bitcoin_qml.qrc
305305
QML_RES_QML = \
306306
qml/components/BlockCounter.qml \
307+
qml/components/BlocksListView.qml \
307308
qml/components/ConnectionOptions.qml \
308309
qml/controls/OptionButton.qml \
309310
qml/pages/initerrormessage.qml \

src/qml/bitcoin_qml.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!DOCTYPE RCC><RCC version="1.0">
22
<qresource prefix="/qml">
33
<file>controls/OptionButton.qml</file>
4+
<file>components/BlocksListView.qml</file>
45
<file>components/BlockCounter.qml</file>
56
<file>components/ConnectionOptions.qml</file>
67
<file>pages/initerrormessage.qml</file>

src/qml/components/BlocksListView.qml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright (c) 2021 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
import BitcoinCore 1.0
6+
import QtQuick 2.12
7+
import QtQuick.Controls 2.12
8+
import QtQuick.Layouts 1.11
9+
import "../controls"
10+
11+
ListView {
12+
spacing: 15
13+
model: ChainModel {
14+
}
15+
delegate: ItemDelegate {
16+
id: delegate
17+
padding: 15
18+
background: Rectangle {
19+
border.width: 1
20+
border.color: delegate.hovered ? "white" : "#999999"
21+
radius: 10
22+
color: "transparent"
23+
}
24+
contentItem: ColumnLayout {
25+
spacing: 3
26+
Label {
27+
color: "white"
28+
font.family: "Inter"
29+
font.styleName: "Regular"
30+
font.pixelSize: 28
31+
text: qsTrId('Block #%1').arg(blockHeight)
32+
}
33+
Label {
34+
Layout.fillWidth: true
35+
Layout.preferredWidth: 0
36+
color: "white"
37+
elide: Text.ElideRight
38+
font.family: "Inter"
39+
font.styleName: "Regular"
40+
font.pixelSize: 13
41+
text: blockHash
42+
}
43+
}
44+
}
45+
}

src/qml/pages/stub.qml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,31 @@ ApplicationWindow {
2222
id: loader
2323
active: initExecutor.ready
2424
anchors.centerIn: parent
25-
sourceComponent: ColumnLayout {
25+
sourceComponent: RowLayout {
2626
spacing: 15
27-
width: 400
28-
NodeModel {
29-
id: node_model
27+
ColumnLayout {
28+
spacing: 15
29+
Layout.preferredWidth: 400
30+
NodeModel {
31+
id: nodeModel
32+
}
33+
Image {
34+
Layout.alignment: Qt.AlignCenter
35+
source: "image://images/app"
36+
sourceSize.width: 64
37+
sourceSize.height: 64
38+
}
39+
BlockCounter {
40+
Layout.alignment: Qt.AlignCenter
41+
blockHeight: nodeModel.blockTipHeight
42+
}
43+
ConnectionOptions {
44+
}
3045
}
31-
Image {
32-
Layout.alignment: Qt.AlignCenter
33-
source: "image://images/app"
34-
sourceSize.width: 64
35-
sourceSize.height: 64
36-
}
37-
BlockCounter {
38-
Layout.alignment: Qt.AlignCenter
39-
blockHeight: nodeModel.blockTipHeight
40-
}
41-
ConnectionOptions {
46+
BlocksListView {
47+
Layout.fillHeight: true
48+
Layout.preferredHeight: 0
49+
Layout.preferredWidth: 300
4250
}
4351
}
4452
}

0 commit comments

Comments
 (0)