Browse Source

Work on Parameter Editor

QGC4.4
dogmaphobic 10 years ago
parent
commit
2de8a49b1b
  1. 476
      src/QmlControls/ParameterEditor.qml

476
src/QmlControls/ParameterEditor.qml

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

Loading…
Cancel
Save