Commit 2de8a49b authored by dogmaphobic's avatar dogmaphobic

Work on Parameter Editor

parent ee06661a
......@@ -40,344 +40,350 @@ QGCView {
viewPanel: panel
QGCPalette { id: __qgcPal; colorGroupEnabled: true }
property Fact __editorDialogFact: Fact { }
readonly property real __leftMargin: 10
readonly property real __rightMargin: 20
readonly property int __maxParamChars: 16
property Fact __editorDialogFact: Fact { }
property int _rowHeight: ScreenTools.defaultFontPixelHeight * 2
property int _rowWidth: 10 // Dynamic adjusted at runtime
property bool _searchFilter: false ///< true: showing results of search
property var _searchResults ///< List of parameter names from search results
property string _currentGroup: ""
ParameterEditorController {
id: controller;
factPanel: panel
onShowErrorMessage: {
showMessage("Parameter Load Errors", errorMsg, StandardButton.Ok)
}
}
Component {
id: editorDialogComponent
ParameterEditorDialog { fact: __editorDialogFact }
QGCViewPanel {
id: panel
anchors.fill: parent
Column {
anchors.fill: parent
spacing: ScreenTools.defaultFontPixelHeight * 0.25
//---------------------------------------------
//-- Header
Item {
id: header
width: parent.width
height: ScreenTools.defaultFontPixelHeight * 1.75
QGCLabel {
text: "Search Results"
visible: _searchFilter
font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter
}
Component {
id: searchDialogComponent
QGCViewDialog {
function accept() {
_searchResults = controller.searchParametersForComponent(-1, searchFor.text, true /*searchInName.checked*/, true /*searchInDescriptions.checked*/)
_searchFilter = true
hideDialog()
Item {
id: groupTitle
visible: !_searchFilter
width: ScreenTools.defaultFontPixelWidth * 25
anchors.verticalCenter: parent.verticalCenter
QGCLabel {
text: "GROUPS"
font.weight: Font.DemiBold
anchors.centerIn: parent
}
function reject() {
}
QGCLabel {
text: _currentGroup + " Parameters"
visible: !_searchFilter
font.weight: Font.DemiBold
anchors.left: groupTitle.right
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
anchors.verticalCenter: parent.verticalCenter
}
QGCButton {
text: "Back"
visible: _searchFilter
anchors.right: parent.right
height: ScreenTools.defaultFontPixelHeight * 1.75
onClicked: {
_searchFilter = false
hideDialog()
}
QGCLabel {
id: searchForLabel
text: "Search for:"
}
QGCTextField {
id: searchFor
anchors.topMargin: defaultTextHeight / 3
anchors.top: searchForLabel.bottom
width: defaultTextWidth * 20
QGCButton {
text: "Tools"
visible: !_searchFilter
anchors.right: parent.right
height: ScreenTools.defaultFontPixelHeight * 1.75
menu: Menu {
MenuItem {
text: "Refresh"
onTriggered: controller.refresh()
}
/*
// Leaving in for possible future use. We'll see if needed from user comments.
QGCLabel {
id: searchInLabel
anchors.topMargin: defaultTextHeight
anchors.top: searchFor.bottom
text: "Search in:"
MenuItem {
text: "Reset all to defaults"
onTriggered: controller.resetAllToDefaults()
}
QGCCheckBox {
id: searchInName
anchors.topMargin: defaultTextHeight / 3
anchors.top: searchInLabel.bottom
text: "Name"
MenuItem {
text: "Search..."
onTriggered: showDialog(searchDialogComponent, "Parameter Search", 50, StandardButton.Reset | StandardButton.Apply)
}
QGCCheckBox {
id: searchInDescriptions
anchors.topMargin: defaultTextHeight / 3
anchors.top: searchInName.bottom
text: "Descriptions"
MenuSeparator { }
MenuItem {
text: "Load from file..."
onTriggered: controller.loadFromFile()
}
*/
QGCLabel {
anchors.topMargin: defaultTextHeight
anchors.top: searchFor.bottom
width: parent.width
wrapMode: Text.WordWrap
text: "Hint: Leave 'Search For' blank and click Apply to list all parameters sorted by name."
MenuItem {
text: "Save to file..."
onTriggered: controller.saveToFile()
}
MenuSeparator { }
MenuItem {
text: "Clear RC to Param"
onTriggered: controller.clearRCToParam()
}
}
}
Component {
id: factRowsComponent
Column {
id: factColumn
x: __leftMargin
QGCLabel {
text: group
verticalAlignment: Text.AlignVCenter
font.pixelSize: ScreenTools.mediumFontPixelSize
}
Rectangle {
color: __qgcPal.text
width: parent.width
height: 1
color: __qgcPal.text
opacity: 0.1
anchors.topMargin: -1
}
Repeater {
model: parameterNames
Column {
property Fact modelFact: controller.getParameterFact(componentId, modelData)
Item {
x: __leftMargin
//---------------------------------------------
//-- Contents
Loader {
width: parent.width
height: ScreenTools.defaultFontPixelSize * 1.75
QGCLabel {
id: nameLabel
width: defaultTextWidth * (__maxParamChars + 1)
height: parent.height
verticalAlignment: Text.AlignVCenter
text: modelFact.name
}
QGCLabel {
id: valueLabel
width: defaultTextWidth * 20
height: parent.height
anchors.left: nameLabel.right
verticalAlignment: Text.AlignVCenter
color: modelFact.valueEqualsDefault ? __qgcPal.text : "orange"
text: modelFact.valueString + " " + modelFact.units
}
QGCLabel {
height: parent.height
anchors.left: valueLabel.right
verticalAlignment: Text.AlignVCenter
text: modelFact.shortDescription
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
__editorDialogFact = modelFact
showDialog(editorDialogComponent, "Parameter Editor", 50, StandardButton.Cancel | StandardButton.Save)
}
height: parent.height - header.height
sourceComponent: _searchFilter ? searchResultsViewComponent: groupedViewComponent
}
}
Rectangle {
x: __leftMargin
width: factColumn.width - __leftMargin - __rightMargin
height: 1
color: __qgcPal.windowShade
}
} // Column - Fact
} // Repeater - Facts
} // Column - Facts
} // Component - factRowsComponent
//-- Parameter Groups
Component {
id: groupedViewComponent
Item {
Row {
spacing: ScreenTools.defaultFontPixelWidth * 0.5
//-- Parameter Groups
Flickable {
id : groupScroll
width: defaultTextWidth * 25
width: ScreenTools.defaultFontPixelWidth * 25
height: parent.height
clip: true
pixelAligned: true
contentHeight: groupedViewComponentColumn.height
contentWidth: groupedViewComponentColumn.width
boundsBehavior: Flickable.StopAtBounds
boundsBehavior: Flickable.OvershootBounds
flickableDirection: Flickable.VerticalFlick
Column {
id: groupedViewComponentColumn
spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
Repeater {
model: controller.componentIds
Column {
id: componentColumn
readonly property int componentId: parseInt(modelData)
spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
QGCLabel {
height: contentHeight + (ScreenTools.defaultFontPixelHeight * 0.5)
text: "Component #: " + componentId.toString()
verticalAlignment: Text.AlignVCenter
font.pixelSize: ScreenTools.mediumFontPixelSize
font.weight: Font.DemiBold
anchors.horizontalCenter: parent.horizontalCenter
}
ExclusiveGroup { id: groupGroup }
Repeater {
model: controller.getGroupsForComponent(componentColumn.componentId)
Column {
model: controller.getGroupsForComponent(componentId)
QGCButton {
x: __leftMargin
width: groupScroll.width - __leftMargin - __rightMargin
width: ScreenTools.defaultFontPixelWidth * 25
text: modelData
height: _rowHeight
exclusiveGroup: setupButtonGroup
onClicked: {
checked = true
factRowsLoader.sourceComponent = null
_rowWidth = 10
factRowsLoader.componentId = componentId
factRowsLoader.group = modelData
factRowsLoader.parameterNames = controller.getParametersForGroup(componentId, modelData)
factRowsLoader.sourceComponent = factRowsComponent
_currentGroup = modelData
}
}
Item {
width: 1
height: ScreenTools.defaultFontPixelSize * 0.25
}
} // Column - Group
} // Repeater - Groups
Item {
height: 10
width: 10
}
} // Column - Component
} // Repeater - Components
} // Column - Component
} // Flickable - Groups
}
}
}
Rectangle {
color: __qgcPal.text
width: 1
height: parent.height
opacity: 0.1
}
//-- Parameters
Flickable {
id: factScrollView
anchors.left: groupScroll.right
anchors.right: parent.right
width: parent.width - groupScroll.width
height: parent.height
contentHeight: factRowsLoader.height
contentWidth: panel.width * 2 //-- TODO: Find how to get actual resulting width. "factRowsLoader.sourceComponent.width" doesn't work.
boundsBehavior: Flickable.StopAtBounds
contentWidth: _rowWidth
boundsBehavior: Flickable.OvershootBounds
pixelAligned: true
clip: true
Loader {
id: factRowsLoader
sourceComponent: factRowsComponent
property int componentId: controller.componentIds[0]
property string group: controller.getGroupsForComponent(controller.componentIds[0])[0]
property var parameterNames: controller.getParametersForGroup(componentId, group)
property var parameterNames: controller.getParametersForGroup(componentId, controller.getGroupsForComponent(componentId)[0])
onLoaded: {
_currentGroup = controller.getGroupsForComponent(controller.componentIds[0])[0]
}
}
}
}
}
} // Flickable - Facts
} // Item
} // Component - groupedViewComponent
//---------------------------------------------
// Search result view
Component {
id: searchResultsViewComponent
Item {
ScrollView {
Flickable {
id: factScrollView
anchors.left: parent.left
anchors.right: parent.right
width: parent.width
height: parent.height
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
contentHeight: factRowsLoader.height
contentWidth: _rowWidth
boundsBehavior: Flickable.OvershootBounds
pixelAligned: true
clip: true
Loader {
id: factRowsLoader
width: factScrollView.width
sourceComponent: factRowsComponent
property int componentId: -1
property string group: "Search results"
property var parameterNames: _searchResults
}
} // ScrollView - Facts
} // Item
} // Component - sortedViewComponent
QGCViewPanel {
id: panel
anchors.fill: parent
}
}
}
//---------------------------------------------
// Paremeters view
Component {
id: factRowsComponent
Column {
anchors.fill: parent
Item {
width: parent.width
height: toolsButton.height
spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
Repeater {
model: parameterNames
Rectangle {
height: _rowHeight
width: _rowWidth
color: Qt.rgba(0,0,0,0)
Row {
id: factRow
property Fact modelFact: controller.getParameterFact(componentId, modelData)
spacing: Math.ceil(ScreenTools.defaultFontPixelWidth * 0.5)
anchors.verticalCenter: parent.verticalCenter
QGCLabel {
id: titleText
font.pixelSize: ScreenTools.mediumFontPixelSize
text: "PARAMETERS"
id: nameLabel
width: ScreenTools.defaultFontPixelWidth * 20
text: factRow.modelFact.name
}
QGCButton {
id: toolsButton
anchors.right: parent.right
text: "Tools"
menu: Menu {
MenuItem {
text: "Refresh"
onTriggered: controller.refresh()
QGCLabel {
id: valueLabel
width: ScreenTools.defaultFontPixelWidth * 20
color: factRow.modelFact.valueEqualsDefault ? __qgcPal.text : __qgcPal.warningText
text: factRow.modelFact.valueString + " " + factRow.modelFact.units
}
MenuItem {
text: "Reset all to defaults"
onTriggered: controller.resetAllToDefaults()
QGCLabel {
text: factRow.modelFact.shortDescription
}
MenuItem {
text: "Search..."
onTriggered: showDialog(searchDialogComponent, "Parameter Search", 50, StandardButton.Reset | StandardButton.Apply)
Component.onCompleted: {
if(_rowWidth < factRow.width + ScreenTools.defaultFontPixelWidth) {
_rowWidth = factRow.width + ScreenTools.defaultFontPixelWidth
}
MenuSeparator { }
MenuItem {
text: "Load from file..."
onTriggered: controller.loadFromFile()
}
MenuItem {
text: "Save to file..."
onTriggered: controller.saveToFile()
}
MenuSeparator { }
MenuItem {
text: "Clear RC to Param"
onTriggered: controller.clearRCToParam()
Rectangle {
width: _rowWidth
height: 1
color: __qgcPal.text
opacity: 0.15
anchors.bottom: parent.bottom
anchors.left: parent.left
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
__editorDialogFact = factRow.modelFact
showDialog(editorDialogComponent, "Parameter Editor", 50, StandardButton.Cancel | StandardButton.Save)
}
}
}
}
}
}
Item {
id: lastSpacer
height: 10
width: 5
Component {
id: editorDialogComponent
ParameterEditorDialog { fact: __editorDialogFact }
}
Loader {
Component {
id: searchDialogComponent
QGCViewDialog {
function accept() {
_searchResults = controller.searchParametersForComponent(-1, searchFor.text, true /*searchInName.checked*/, true /*searchInDescriptions.checked*/)
_searchFilter = true
hideDialog()
}
function reject() {
_searchFilter = false
hideDialog()
}
QGCLabel {
id: searchForLabel
text: "Search for:"
}
QGCTextField {
id: searchFor
anchors.topMargin: defaultTextHeight / 3
anchors.top: searchForLabel.bottom
width: ScreenTools.defaultFontPixelWidth * 20
}
/*
// Leaving in for possible future use. We'll see if needed from user comments.
QGCLabel {
id: searchInLabel
anchors.topMargin: defaultTextHeight
anchors.top: searchFor.bottom
text: "Search in:"
}
QGCCheckBox {
id: searchInName
anchors.topMargin: defaultTextHeight / 3
anchors.top: searchInLabel.bottom
text: "Name"
}
QGCCheckBox {
id: searchInDescriptions
anchors.topMargin: defaultTextHeight / 3
anchors.top: searchInName.bottom
text: "Descriptions"
}
*/
QGCLabel {
anchors.topMargin: defaultTextHeight
anchors.top: searchFor.bottom
width: parent.width
height: parent.height - (lastSpacer.y + lastSpacer.height)
sourceComponent: _searchFilter ? searchResultsViewComponent: groupedViewComponent
wrapMode: Text.WordWrap
text: "Hint: Leave 'Search For' blank and click Apply to list all parameters sorted by name."
}
}
} // Column - Outer
} // QGCViewPanel
}
} // QGCView
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment