2022-06-09 15:27:14 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
2023-03-23 18:26:38 +00:00
|
|
|
import utils 1.0
|
2022-06-09 15:27:14 +00:00
|
|
|
|
|
|
|
StatusListView {
|
|
|
|
id: root
|
|
|
|
|
2023-01-24 21:49:07 +00:00
|
|
|
property var checkedKeys: []
|
|
|
|
|
2023-03-23 21:45:45 +00:00
|
|
|
property string footerButtonText
|
|
|
|
|
2022-06-09 15:27:14 +00:00
|
|
|
property var headerModel
|
2023-01-26 14:21:35 +00:00
|
|
|
property bool areHeaderButtonsVisible: true
|
2023-03-23 21:45:45 +00:00
|
|
|
property bool isFooterButtonVisible: true
|
|
|
|
property bool areSectionsVisible: true
|
|
|
|
|
2023-01-26 14:21:35 +00:00
|
|
|
property bool searchMode: false
|
2023-03-23 18:26:38 +00:00
|
|
|
property bool availableData: false
|
|
|
|
property string noDataText: qsTr("No data found")
|
2023-01-26 14:21:35 +00:00
|
|
|
|
2022-08-23 08:46:37 +00:00
|
|
|
property int maxHeight: 381 // default by design
|
2023-08-08 19:32:46 +00:00
|
|
|
property bool showTokenAmount: true
|
2022-06-09 15:27:14 +00:00
|
|
|
|
2022-08-23 08:46:37 +00:00
|
|
|
signal headerItemClicked(string key)
|
|
|
|
signal itemClicked(var key, string name, var shortName, url iconSource, var subItems)
|
2022-06-09 15:27:14 +00:00
|
|
|
|
2023-03-23 21:45:45 +00:00
|
|
|
signal footerButtonClicked
|
|
|
|
|
2022-06-09 15:27:14 +00:00
|
|
|
implicitWidth: 273
|
2022-08-23 08:46:37 +00:00
|
|
|
implicitHeight: Math.min(contentHeight, root.maxHeight)
|
2022-06-09 15:27:14 +00:00
|
|
|
currentIndex: -1
|
2023-07-27 13:42:12 +00:00
|
|
|
leftMargin: d.padding
|
|
|
|
rightMargin: 14 // scrollbar width
|
2023-01-26 14:21:35 +00:00
|
|
|
|
|
|
|
header: ColumnLayout {
|
2023-07-27 13:42:12 +00:00
|
|
|
width: root.availableWidth
|
2023-01-26 14:21:35 +00:00
|
|
|
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: root.areHeaderButtonsVisible
|
|
|
|
? columnHeader.implicitHeight + 2 * columnHeader.anchors.topMargin
|
|
|
|
: 0
|
|
|
|
|
|
|
|
visible: root.areHeaderButtonsVisible
|
|
|
|
z: 3 // Above delegate (z=1) and above section.delegate (z = 2)
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: columnHeader
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 6
|
|
|
|
anchors.rightMargin: anchors.leftMargin
|
|
|
|
anchors.topMargin: 8
|
|
|
|
anchors.bottomMargin: 2 * anchors.topMargin
|
|
|
|
spacing: 20
|
|
|
|
Repeater {
|
|
|
|
model: root.headerModel
|
|
|
|
delegate: StatusIconTextButton {
|
|
|
|
z: 3 // Above delegate (z=1) and above section.delegate (z = 2)
|
|
|
|
spacing: model.spacing
|
|
|
|
statusIcon: model.icon
|
|
|
|
icon.width: model.iconSize
|
|
|
|
icon.height: model.iconSize
|
|
|
|
iconRotation: model.rotation
|
|
|
|
text: model.description
|
|
|
|
onClicked: root.headerItemClicked(model.index)
|
|
|
|
}
|
2022-06-09 15:27:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-26 14:21:35 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
Layout.preferredHeight: visible ? d.sectionHeight : 0
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2023-03-23 18:26:38 +00:00
|
|
|
visible: !root.availableData || root.searchMode
|
2023-01-26 14:21:35 +00:00
|
|
|
sourceComponent: sectionComponent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
delegate: TokenItem {
|
2023-07-27 13:42:12 +00:00
|
|
|
width: root.availableWidth
|
2023-04-19 11:55:12 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
name: model.name
|
2023-02-21 20:00:39 +00:00
|
|
|
shortName: model.shortName ?? ""
|
|
|
|
iconSource: model.iconSource ?? ""
|
2023-04-19 11:55:12 +00:00
|
|
|
showSubItemsIcon: !!model.subItems && model.subItems.count > 0
|
2023-01-24 21:49:07 +00:00
|
|
|
selected: root.checkedKeys.includes(model.key)
|
2023-08-08 19:32:46 +00:00
|
|
|
amount: {
|
|
|
|
if(!model.infiniteSupply && !!model.supply && model.supply == 1)
|
|
|
|
return qsTr("Max. 1")
|
|
|
|
|
|
|
|
if(root.showTokenAmount)
|
|
|
|
return !!model.infiniteSupply ? "∞" : model.supply ?? ""
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
2023-01-24 21:49:07 +00:00
|
|
|
|
2023-02-21 20:00:39 +00:00
|
|
|
onItemClicked: root.itemClicked(
|
2023-04-19 11:55:12 +00:00
|
|
|
model.key, name, shortName, iconSource, model.subItems)
|
2023-01-18 19:54:14 +00:00
|
|
|
}
|
2023-01-26 14:21:35 +00:00
|
|
|
|
2023-03-23 21:45:45 +00:00
|
|
|
section.property: root.searchMode || !root.areSectionsVisible
|
|
|
|
? "" : "categoryLabel"
|
2023-07-27 13:42:12 +00:00
|
|
|
section.delegate: ColumnLayout {
|
|
|
|
width: root.availableWidth
|
|
|
|
height: root.searchMode || root.areSectionsVisible ? d.sectionHeight : 0
|
|
|
|
spacing: 0
|
2023-01-26 14:21:35 +00:00
|
|
|
|
2023-07-27 13:42:12 +00:00
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
color: Theme.palette.statusListItem.backgroundColor
|
2023-01-26 14:21:35 +00:00
|
|
|
|
2023-07-27 13:42:12 +00:00
|
|
|
Loader {
|
|
|
|
id: loader
|
|
|
|
anchors.fill: parent
|
|
|
|
sourceComponent: sectionComponent
|
2023-01-26 14:21:35 +00:00
|
|
|
|
2023-07-27 13:42:12 +00:00
|
|
|
Binding {
|
|
|
|
target: loader.item
|
|
|
|
property: "section"
|
|
|
|
value: section
|
|
|
|
when: !root.searchMode
|
|
|
|
}
|
2023-01-26 14:21:35 +00:00
|
|
|
}
|
|
|
|
}
|
2023-07-27 13:42:12 +00:00
|
|
|
|
|
|
|
// floating divider
|
|
|
|
Rectangle {
|
|
|
|
visible: parent.y === root.contentY && (root.searchMode || root.areSectionsVisible)
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: -d.padding
|
|
|
|
Layout.rightMargin: -d.padding*2
|
|
|
|
Layout.preferredHeight: 4
|
|
|
|
color: Theme.palette.directColor8
|
|
|
|
}
|
2023-01-26 14:21:35 +00:00
|
|
|
}
|
2023-07-27 13:42:12 +00:00
|
|
|
section.labelPositioning: ViewSection.InlineLabels | ViewSection.CurrentLabelAtStart
|
2023-01-26 14:21:35 +00:00
|
|
|
|
2023-03-23 21:45:45 +00:00
|
|
|
Component {
|
|
|
|
id: footerComponent
|
|
|
|
|
|
|
|
Item {
|
2023-07-27 13:42:12 +00:00
|
|
|
width: ListView.view ? ListView.view.width - Style.current.smallPadding : 0
|
2023-03-23 21:45:45 +00:00
|
|
|
height: d.sectionHeight
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: footerLoader
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
sourceComponent: sectionComponent
|
|
|
|
|
|
|
|
Binding {
|
|
|
|
target: footerLoader.item
|
|
|
|
property: "section"
|
|
|
|
value: root.footerButtonText
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusIcon {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 16
|
|
|
|
|
|
|
|
icon: "tiny/chevron-right"
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
|
|
|
onClicked: root.footerButtonClicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: root.isFooterButtonVisible ? footerComponent : null
|
|
|
|
|
2023-01-26 14:21:35 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
2023-07-27 13:42:12 +00:00
|
|
|
readonly property int padding: Style.current.halfPadding
|
2023-01-26 14:21:35 +00:00
|
|
|
readonly property int sectionHeight: 34
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: sectionComponent
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: sectionDelegateRoot
|
|
|
|
|
2023-03-23 18:26:38 +00:00
|
|
|
property string section: {
|
|
|
|
if(!root.availableData)
|
|
|
|
return root.noDataText
|
|
|
|
if(root.count)
|
2023-07-27 13:42:12 +00:00
|
|
|
return qsTr("Search results")
|
2023-03-23 18:26:38 +00:00
|
|
|
return qsTr("No results")
|
|
|
|
}
|
2023-01-26 14:21:35 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
2023-03-23 18:26:38 +00:00
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
2023-01-26 14:21:35 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2023-06-14 07:19:45 +00:00
|
|
|
width: parent.width - anchors.leftMargin
|
2023-01-26 14:21:35 +00:00
|
|
|
text: sectionDelegateRoot.section
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: 12
|
|
|
|
elide: Text.ElideRight
|
2023-03-23 18:26:38 +00:00
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
lineHeight: 1.2
|
2023-01-26 14:21:35 +00:00
|
|
|
}
|
2022-06-09 15:27:14 +00:00
|
|
|
}
|
2023-01-26 14:21:35 +00:00
|
|
|
}
|
|
|
|
}
|