advotracker_qml: advotracker variant with Qt/Qml GUI
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
266
advotracker_qml/resources/pages/TestPage.qml
Executable file
266
advotracker_qml/resources/pages/TestPage.qml
Executable file
@@ -0,0 +1,266 @@
|
||||
|
||||
import QtQuick 2.10 // Qt 5.10
|
||||
import QtQuick.Controls 2.3 // Qt 5.10
|
||||
import QtQuick.Layouts 1.3 // Qt 5.10
|
||||
import QtQuick.Controls.Material 2.3 // Qt 5.10
|
||||
|
||||
// AdvoTracker Module
|
||||
import de.networkx.AdvoTracker 1.0 as Nwx
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
//Page {
|
||||
Pane {
|
||||
id: pane
|
||||
anchors.fill: parent
|
||||
anchors.margins: 12
|
||||
|
||||
Component {
|
||||
id: c0
|
||||
//id: swipeDelegateHistory
|
||||
|
||||
Nwx.IconButton {
|
||||
text: "Index:" + model.index
|
||||
width: parent.width
|
||||
}
|
||||
} // swipeDelegateBase
|
||||
|
||||
Component {
|
||||
id: c1
|
||||
//id: swipeDelegateBase
|
||||
|
||||
Nwx.IconButton {
|
||||
text: "Index:" + index
|
||||
width: parent.width
|
||||
}
|
||||
} // swipeDelegateHistory
|
||||
|
||||
SwipeView {
|
||||
id: swipeView
|
||||
anchors.fill: parent
|
||||
Layout.fillWidth: true
|
||||
|
||||
Repeater {
|
||||
model: 3
|
||||
//property var delegateComponent: {
|
||||
// "delegateComponent0": swipeDelegateBase,
|
||||
// "delegateComponent1": swipeDelegateHistory
|
||||
//} // delegateComponent
|
||||
|
||||
Loader {
|
||||
active: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem // <==
|
||||
// sourceComponent: delegateComponent[index]
|
||||
sourceComponent: Item {
|
||||
width: parent.width
|
||||
Loader { source: "PaneNumberHarmBase.qml" }
|
||||
|
||||
Component.onCompleted: console.log("created:", index)
|
||||
Component.onDestruction: console.log("destroyed:", index)
|
||||
}
|
||||
/* Text {
|
||||
text: index
|
||||
} */
|
||||
//} // Loader
|
||||
} // Loader
|
||||
} // Repeater
|
||||
} // swipeView
|
||||
|
||||
PageIndicator {
|
||||
id: indicatorNumber
|
||||
|
||||
count: swipeView.count
|
||||
currentIndex: swipeView.currentIndex
|
||||
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
} // Pane
|
||||
//} // Page
|
||||
|
||||
/*
|
||||
import QtQuick 2.6
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Controls 2.1
|
||||
|
||||
Pane {
|
||||
padding: 0
|
||||
|
||||
property var delegateComponentMap: {
|
||||
"ItemDelegate": itemDelegateComponent,
|
||||
"SwipeDelegate": swipeDelegateComponent,
|
||||
"CheckDelegate": checkDelegateComponent,
|
||||
"RadioDelegate": radioDelegateComponent,
|
||||
"SwitchDelegate": switchDelegateComponent
|
||||
} // delegate ComponentMap
|
||||
|
||||
Component {
|
||||
id: itemDelegateComponent
|
||||
|
||||
ItemDelegate {
|
||||
text: labelText
|
||||
width: parent.width
|
||||
}
|
||||
} // itemDelegateComponent
|
||||
|
||||
Component {
|
||||
id: swipeRemoveComponent
|
||||
|
||||
Label {
|
||||
font.pixelSize: swipeDelegate.font.pixelSize
|
||||
text: qsTr("Remove")
|
||||
color: "white"
|
||||
verticalAlignment: Label.AlignVCenter
|
||||
padding: 12
|
||||
anchors.centerIn: parent
|
||||
background: Rectangle {
|
||||
color: SwipeDelegate.pressed ? "#444" : "lightsteelblue"
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
clip: true
|
||||
}
|
||||
|
||||
SwipeDelegate.onClicked: view.model.remove(ourIndex)
|
||||
}
|
||||
} // swipeDelegateRemove
|
||||
|
||||
Component {
|
||||
id: swipeDelegateComponent
|
||||
|
||||
SwipeDelegate {
|
||||
id: swipeDelegate
|
||||
text: labelText + " " + ourIndex
|
||||
width: parent.width
|
||||
|
||||
Loader {
|
||||
id: swipeRemoveComponet
|
||||
sourceComponent: swipeRemoveComponent
|
||||
}
|
||||
|
||||
swipe.left: swipeRemoveComponent
|
||||
swipe.right: swipeRemoveComponent
|
||||
}
|
||||
} // swipeDelegateComponent
|
||||
|
||||
Component {
|
||||
id: checkDelegateComponent
|
||||
|
||||
CheckDelegate {
|
||||
text: labelText + " " + ourIndex
|
||||
width: parent.width
|
||||
}
|
||||
} // checkDelegateComponent
|
||||
|
||||
ButtonGroup {
|
||||
id: radioButtonGroup
|
||||
} // radioButtonGroup
|
||||
|
||||
Component {
|
||||
id: radioDelegateComponent
|
||||
|
||||
RadioDelegate {
|
||||
text: labelText
|
||||
ButtonGroup.group: radioButtonGroup
|
||||
}
|
||||
} // radioDelegateComponent
|
||||
|
||||
Component {
|
||||
id: switchDelegateComponent
|
||||
|
||||
SwitchDelegate {
|
||||
text: labelText
|
||||
}
|
||||
} // switchDelegateComponent
|
||||
|
||||
ColumnLayout {
|
||||
id: column
|
||||
spacing: 40
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 20
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
wrapMode: Label.Wrap
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
text: "Delegate controls are used as delegates in views such as ListView."
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: listView
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
clip: true
|
||||
|
||||
model: ListModel {
|
||||
ListElement { type: "ItemDelegate"; text: "ItemDelegate1" }
|
||||
ListElement { type: "ItemDelegate"; text: "ItemDelegate2" }
|
||||
ListElement { type: "ItemDelegate"; text: "ItemDelegate3" }
|
||||
ListElement { type: "SwipeDelegate"; text: "SwipeDelegate1" }
|
||||
ListElement { type: "SwipeDelegate"; text: "SwipeDelegate2" }
|
||||
ListElement { type: "SwipeDelegate"; text: "SwipeDelegate3" }
|
||||
ListElement { type: "CheckDelegate"; text: "CheckDelegate1" }
|
||||
ListElement { type: "CheckDelegate"; text: "CheckDelegate2" }
|
||||
ListElement { type: "CheckDelegate"; text: "CheckDelegate3" }
|
||||
ListElement { type: "RadioDelegate"; text: "RadioDelegate" }
|
||||
ListElement { type: "RadioDelegate"; text: "RadioDelegate" }
|
||||
ListElement { type: "RadioDelegate"; text: "RadioDelegate" }
|
||||
ListElement { type: "SwitchDelegate"; text: "SwitchDelegate" }
|
||||
ListElement { type: "SwitchDelegate"; text: "SwitchDelegate" }
|
||||
ListElement { type: "SwitchDelegate"; text: "SwitchDelegate" }
|
||||
} // ListModel
|
||||
|
||||
section.property: "type"
|
||||
section.delegate: Pane {
|
||||
id: paneLoader
|
||||
width: listView.width
|
||||
height: sectionLabel.implicitHeight + 20
|
||||
|
||||
Rectangle {
|
||||
width: listView.width
|
||||
height: sectionLabel.implicitHeight + 20
|
||||
color: "lightsteelblue"
|
||||
Label {
|
||||
id: sectionLabel
|
||||
text: section
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
} // paneLoader
|
||||
|
||||
delegate: Loader {
|
||||
id: delegateLoader
|
||||
width: listView.width
|
||||
sourceComponent: delegateComponentMap[text]
|
||||
|
||||
property string labelText: text
|
||||
property ListView view: listView
|
||||
property int ourIndex: index
|
||||
|
||||
// Can not find a way to do this in the SwipeDelegate component itself
|
||||
// so do it here instead.
|
||||
ListView.onRemove: SequentialAnimation {
|
||||
id: delegateAnimation
|
||||
PropertyAction {
|
||||
target: delegateLoader
|
||||
property: "ListView.delayRemove"
|
||||
value: true
|
||||
}
|
||||
NumberAnimation {
|
||||
target: item
|
||||
property: "height"
|
||||
to: 0
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
PropertyAction {
|
||||
target: delegateLoader
|
||||
property: "ListView.delayRemove"
|
||||
value: false
|
||||
}
|
||||
} // delegateAnimation
|
||||
} // delegateLoader
|
||||
|
||||
} // listView
|
||||
|
||||
} // column
|
||||
|
||||
} // pane
|
||||
*/
|
||||
Reference in New Issue
Block a user