2022-08-30 16:27:00 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
|
|
|
|
Item {
|
2022-09-07 09:40:25 +00:00
|
|
|
id: root
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2022-09-07 09:40:25 +00:00
|
|
|
property int mode: HoldingsTabs.Mode.Add
|
|
|
|
property alias tabLabels: tabLabelsRepeater.model
|
2022-08-30 16:27:00 +00:00
|
|
|
property alias sourceComponent: tabsLoader.sourceComponent
|
2022-09-07 09:40:25 +00:00
|
|
|
property alias addOrUpdateButtonEnabled: addOrUpdateButton.enabled
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2022-09-07 09:40:25 +00:00
|
|
|
property alias currentIndex: tabBar.currentIndex
|
2022-08-30 16:27:00 +00:00
|
|
|
readonly property alias item: tabsLoader.item
|
|
|
|
|
|
|
|
signal addClicked
|
2022-09-07 09:40:25 +00:00
|
|
|
signal updateClicked
|
|
|
|
signal removeClicked
|
|
|
|
|
|
|
|
enum Mode {
|
|
|
|
Add, Update
|
|
|
|
}
|
|
|
|
|
|
|
|
function setCurrentIndex(index) {
|
|
|
|
tabBar.setCurrentIndex(index)
|
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
// values from design
|
|
|
|
readonly property int tabBarHeight: 36
|
|
|
|
readonly property int tabBarFontPixelSize: 13
|
|
|
|
readonly property int contentTopMargin: 16
|
|
|
|
readonly property int buttonsHeight: 44
|
|
|
|
readonly property int buttonsSpacing: 8
|
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
|
|
|
|
StatusSwitchTabBar {
|
|
|
|
id: tabBar
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
2022-09-07 09:40:25 +00:00
|
|
|
height: d.tabBarHeight
|
2022-08-30 16:27:00 +00:00
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: tabLabelsRepeater
|
|
|
|
|
|
|
|
StatusSwitchTabButton {
|
|
|
|
text: modelData
|
2022-09-07 09:40:25 +00:00
|
|
|
fontPixelSize: d.tabBarFontPixelSize
|
2022-08-30 16:27:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: tabsLoader
|
|
|
|
|
|
|
|
anchors.top: tabBar.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
2022-09-07 09:40:25 +00:00
|
|
|
anchors.topMargin: d.contentTopMargin
|
2022-08-30 16:27:00 +00:00
|
|
|
}
|
|
|
|
|
2022-09-07 09:40:25 +00:00
|
|
|
Column {
|
|
|
|
spacing: d.buttonsSpacing
|
2022-08-30 16:27:00 +00:00
|
|
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
2022-09-07 09:40:25 +00:00
|
|
|
StatusButton {
|
|
|
|
id: addOrUpdateButton
|
|
|
|
|
|
|
|
text: (root.mode === HoldingsTabs.Mode.Add ? qsTr("Add") : qsTr("Update"))
|
|
|
|
height: d.buttonsHeight
|
|
|
|
width: parent.width
|
|
|
|
onClicked: root.mode === HoldingsTabs.Mode.Add
|
|
|
|
? root.addClicked() : root.updateClicked()
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusFlatButton {
|
|
|
|
text: qsTr("Remove")
|
|
|
|
height: d.buttonsHeight
|
|
|
|
width: parent.width
|
|
|
|
visible: root.mode === HoldingsTabs.Mode.Update
|
|
|
|
type: StatusBaseButton.Type.Danger
|
|
|
|
|
|
|
|
onClicked: root.removeClicked()
|
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
}
|
|
|
|
}
|