2023-09-08 15:14:42 +03:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
2023-10-06 18:50:32 +03:00
|
|
|
import QtQuick.Layouts
|
2023-10-04 18:22:35 +03:00
|
|
|
import HelperWidgets 2.0 as HelperWidgets
|
2023-09-08 15:14:42 +03:00
|
|
|
import StudioTheme 1.0 as StudioTheme
|
2023-10-04 12:15:41 +03:00
|
|
|
import StudioControls 1.0 as StudioControls
|
2023-09-08 15:14:42 +03:00
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
required property var model
|
|
|
|
|
|
2023-10-18 11:25:10 +03:00
|
|
|
implicitWidth: 600
|
|
|
|
|
implicitHeight: 400
|
|
|
|
|
|
2023-09-08 15:14:42 +03:00
|
|
|
color: StudioTheme.Values.themeBackgroundColorAlternate
|
|
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
ColumnLayout {
|
2023-09-08 15:14:42 +03:00
|
|
|
id: topRow
|
|
|
|
|
|
2023-10-18 11:25:10 +03:00
|
|
|
visible: collectionNameText.text !== ""
|
|
|
|
|
|
2023-09-08 15:14:42 +03:00
|
|
|
spacing: 0
|
2023-10-06 18:50:32 +03:00
|
|
|
anchors {
|
|
|
|
|
fill: parent
|
|
|
|
|
topMargin: 10
|
|
|
|
|
leftMargin: 15
|
|
|
|
|
rightMargin: 15
|
|
|
|
|
bottomMargin: 10
|
|
|
|
|
}
|
2023-09-08 15:14:42 +03:00
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
id: collectionNameText
|
|
|
|
|
|
|
|
|
|
leftPadding: 8
|
|
|
|
|
rightPadding: 8
|
|
|
|
|
topPadding: 3
|
|
|
|
|
bottomPadding: 3
|
|
|
|
|
|
|
|
|
|
color: StudioTheme.Values.themeTextColor
|
|
|
|
|
text: root.model.collectionName
|
|
|
|
|
font.pixelSize: StudioTheme.Values.mediumIconFont
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
z: parent.z - 1
|
|
|
|
|
color: StudioTheme.Values.themeBackgroundColorNormal
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item { // spacer
|
|
|
|
|
width: 1
|
|
|
|
|
height: 10
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-06 13:15:07 +03:00
|
|
|
CollectionDetailsToolbar {
|
|
|
|
|
model: root.model
|
2023-10-06 18:50:32 +03:00
|
|
|
Layout.fillWidth: true
|
2023-10-06 13:15:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item { // spacer
|
|
|
|
|
width: 1
|
|
|
|
|
height: 5
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
GridLayout {
|
|
|
|
|
columns: 2
|
|
|
|
|
rowSpacing: 1
|
|
|
|
|
columnSpacing: 1
|
2023-09-08 15:14:42 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
2023-09-08 15:14:42 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
Rectangle {
|
2023-09-08 15:14:42 +03:00
|
|
|
clip: true
|
2023-10-06 18:50:32 +03:00
|
|
|
visible: root.model.isEmpty === false
|
|
|
|
|
color: StudioTheme.Values.themeControlBackground
|
|
|
|
|
border.color: StudioTheme.Values.themeControlOutline
|
|
|
|
|
border.width: 2
|
|
|
|
|
|
|
|
|
|
Layout.preferredWidth: rowIdView.width
|
|
|
|
|
Layout.preferredHeight: headerView.height
|
2023-09-08 15:14:42 +03:00
|
|
|
|
|
|
|
|
Text {
|
2023-10-06 18:50:32 +03:00
|
|
|
anchors.fill: parent
|
|
|
|
|
font: headerTextMetrics.font
|
|
|
|
|
text: "#"
|
2023-09-08 15:14:42 +03:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2023-10-06 18:50:32 +03:00
|
|
|
color: StudioTheme.Values.themeTextColor
|
2023-09-08 15:14:42 +03:00
|
|
|
}
|
2023-10-06 18:50:32 +03:00
|
|
|
}
|
2023-10-04 12:15:41 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
HorizontalHeaderView {
|
|
|
|
|
id: headerView
|
|
|
|
|
|
|
|
|
|
property real topPadding: 5
|
|
|
|
|
property real bottomPadding: 5
|
2023-10-06 11:09:41 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
Layout.preferredHeight: headerTextMetrics.height + topPadding + bottomPadding
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
syncView: tableView
|
|
|
|
|
clip: true
|
2023-10-06 11:09:41 +03:00
|
|
|
|
2023-10-09 10:51:01 +03:00
|
|
|
delegate: HeaderDelegate {
|
|
|
|
|
selectedItem: root.model.selectedColumn
|
2023-10-06 11:09:41 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
2023-10-09 10:51:01 +03:00
|
|
|
anchors.margins: 5
|
2023-10-06 18:50:32 +03:00
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
|
onClicked: (mouse) => {
|
|
|
|
|
root.model.selectColumn(index)
|
2023-10-06 11:09:41 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
if (mouse.button === Qt.RightButton)
|
|
|
|
|
headerMenu.popIndex(index)
|
2023-10-06 11:09:41 +03:00
|
|
|
}
|
|
|
|
|
}
|
2023-10-06 18:50:32 +03:00
|
|
|
}
|
2023-10-04 12:15:41 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
StudioControls.Menu {
|
|
|
|
|
id: headerMenu
|
2023-10-04 12:15:41 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
property int clickedHeader: -1
|
2023-10-04 12:15:41 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
function popIndex(clickedIndex)
|
|
|
|
|
{
|
|
|
|
|
headerMenu.clickedHeader = clickedIndex
|
|
|
|
|
headerMenu.popup()
|
|
|
|
|
}
|
2023-10-04 12:15:41 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
onClosed: {
|
|
|
|
|
headerMenu.clickedHeader = -1
|
|
|
|
|
}
|
2023-10-04 12:15:41 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
StudioControls.MenuItem {
|
|
|
|
|
text: qsTr("Edit")
|
|
|
|
|
onTriggered: editProperyDialog.editProperty(headerMenu.clickedHeader)
|
|
|
|
|
}
|
2023-10-04 18:22:35 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
StudioControls.MenuItem {
|
|
|
|
|
text: qsTr("Delete")
|
|
|
|
|
onTriggered: deleteColumnDialog.popUp(headerMenu.clickedHeader)
|
|
|
|
|
}
|
2023-10-04 18:22:35 +03:00
|
|
|
}
|
2023-10-04 12:15:41 +03:00
|
|
|
}
|
2023-09-08 15:14:42 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
VerticalHeaderView {
|
|
|
|
|
id: rowIdView
|
2023-09-08 15:14:42 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
syncView: tableView
|
|
|
|
|
clip: true
|
2023-09-08 15:14:42 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
2023-10-09 10:51:01 +03:00
|
|
|
delegate: HeaderDelegate {
|
|
|
|
|
selectedItem: root.model.selectedRow
|
2023-09-08 15:14:42 +03:00
|
|
|
|
2023-10-09 10:51:01 +03:00
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
anchors.margins: 5
|
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
|
onClicked: root.model.selectRow(index)
|
2023-10-06 18:50:32 +03:00
|
|
|
}
|
2023-10-09 10:51:01 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
}
|
2023-09-08 15:14:42 +03:00
|
|
|
}
|
2023-10-06 11:09:41 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
TableView {
|
|
|
|
|
id: tableView
|
2023-10-06 11:09:41 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
model: root.model
|
|
|
|
|
clip: true
|
2023-10-06 11:09:41 +03:00
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
|
|
delegate: Rectangle {
|
|
|
|
|
id: itemCell
|
|
|
|
|
implicitWidth: 100
|
|
|
|
|
implicitHeight: itemText.height
|
|
|
|
|
border.width: 1
|
|
|
|
|
border.color: StudioTheme.Values.themeControlOutline
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
id: itemText
|
|
|
|
|
|
|
|
|
|
text: display ? display : ""
|
|
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
leftPadding: 5
|
|
|
|
|
topPadding: 3
|
|
|
|
|
bottomPadding: 3
|
|
|
|
|
font.pixelSize: StudioTheme.Values.baseFontSize
|
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
elide: Text.ElideRight
|
2023-10-06 11:09:41 +03:00
|
|
|
}
|
|
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
states: [
|
|
|
|
|
State {
|
|
|
|
|
name: "default"
|
|
|
|
|
when: !itemSelected
|
|
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: itemCell
|
|
|
|
|
color: StudioTheme.Values.themeControlBackground
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: itemText
|
|
|
|
|
color: StudioTheme.Values.themeTextColor
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
State {
|
|
|
|
|
name: "selected"
|
|
|
|
|
when: itemSelected
|
|
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: itemCell
|
|
|
|
|
color: StudioTheme.Values.themeControlBackgroundInteraction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: itemText
|
|
|
|
|
color: StudioTheme.Values.themeInteraction
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
2023-10-06 11:09:41 +03:00
|
|
|
}
|
2023-10-06 18:50:32 +03:00
|
|
|
}
|
2023-09-08 15:14:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
2023-10-04 12:15:41 +03:00
|
|
|
|
2023-10-18 11:25:10 +03:00
|
|
|
Text {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
text: qsTr("Select a collection to continue")
|
|
|
|
|
visible: !topRow.visible
|
|
|
|
|
textFormat: Text.RichText
|
|
|
|
|
color: StudioTheme.Values.themeTextColor
|
|
|
|
|
font.pixelSize: StudioTheme.Values.mediumFontSize
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-06 18:50:32 +03:00
|
|
|
TextMetrics {
|
|
|
|
|
id: headerTextMetrics
|
|
|
|
|
|
|
|
|
|
font.pixelSize: StudioTheme.Values.baseFontSize
|
|
|
|
|
text: "Xq"
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 10:51:01 +03:00
|
|
|
component HeaderDelegate: Rectangle {
|
|
|
|
|
id: headerItem
|
|
|
|
|
|
|
|
|
|
required property int selectedItem
|
|
|
|
|
property alias horizontalAlignment: headerText.horizontalAlignment
|
|
|
|
|
property alias verticalAlignment: headerText.verticalAlignment
|
|
|
|
|
|
|
|
|
|
implicitWidth: headerText.width
|
|
|
|
|
implicitHeight: headerText.height
|
|
|
|
|
border.width: 2
|
|
|
|
|
border.color: StudioTheme.Values.themeControlOutline
|
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
id: headerText
|
|
|
|
|
|
|
|
|
|
topPadding: headerView.topPadding
|
|
|
|
|
bottomPadding: headerView.bottomPadding
|
|
|
|
|
leftPadding: 5
|
|
|
|
|
rightPadding: 5
|
|
|
|
|
text: display
|
|
|
|
|
font: headerTextMetrics.font
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
states: [
|
|
|
|
|
State {
|
|
|
|
|
name: "default"
|
|
|
|
|
when: index !== selectedItem
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: headerItem
|
|
|
|
|
color: StudioTheme.Values.themeControlBackground
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: headerText
|
|
|
|
|
color: StudioTheme.Values.themeIdleGreen
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
State {
|
|
|
|
|
name: "selected"
|
|
|
|
|
when: index === selectedItem
|
|
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: headerItem
|
|
|
|
|
color: StudioTheme.Values.themeControlBackgroundInteraction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: headerText
|
|
|
|
|
color: StudioTheme.Values.themeRunningGreen
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-04 12:15:41 +03:00
|
|
|
EditPropertyDialog {
|
|
|
|
|
id: editProperyDialog
|
|
|
|
|
model: root.model
|
|
|
|
|
}
|
2023-10-04 18:22:35 +03:00
|
|
|
|
|
|
|
|
StudioControls.Dialog {
|
|
|
|
|
id: deleteColumnDialog
|
|
|
|
|
|
|
|
|
|
property int clickedIndex: -1
|
|
|
|
|
|
|
|
|
|
title: qsTr("Delete Column")
|
|
|
|
|
width: 400
|
|
|
|
|
|
|
|
|
|
onAccepted: {
|
|
|
|
|
root.model.removeColumn(clickedIndex)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function popUp(index)
|
|
|
|
|
{
|
|
|
|
|
deleteColumnDialog.clickedIndex = index
|
|
|
|
|
deleteColumnDialog.open()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
contentItem: Column {
|
|
|
|
|
spacing: 2
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
text: qsTr("Are you sure that you want to delete column \"%1\"?").arg(
|
|
|
|
|
root.model.headerData(
|
|
|
|
|
deleteColumnDialog.clickedIndex, Qt.Horizontal))
|
|
|
|
|
color: StudioTheme.Values.themeTextColor
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item { // spacer
|
|
|
|
|
width: 1
|
|
|
|
|
height: 20
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Row {
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
spacing: 10
|
|
|
|
|
|
|
|
|
|
HelperWidgets.Button {
|
|
|
|
|
text: qsTr("Delete")
|
|
|
|
|
onClicked: deleteColumnDialog.accept()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HelperWidgets.Button {
|
|
|
|
|
text: qsTr("Cancel")
|
|
|
|
|
onClicked: deleteColumnDialog.reject()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-08 15:14:42 +03:00
|
|
|
}
|