Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 13 additions & 31 deletions resources/SettingsTab.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@ import SwiftConsole 1.0
MainTab {
id: settingsTab

function selectedRow() {
var rowIdx = settingsTable.selectedRowIdx;
if (rowIdx < 0)
return ;

return settingsTable.table[settingsTable.rowOffsets[rowIdx]];
}

function selectedRowField(name) {
var row = selectedRow();
if (!row)
return "";

return row[name] || "";
}

function autoSurveyDialogText() {
var text = "This will set the Surveyed Position section to the mean position of up to the last 1000 position solutions. ";
text += "The fields that will be auto-populated are: \n\n";
Expand Down Expand Up @@ -156,12 +140,8 @@ MainTab {
SettingsTabComponents.SettingsTable {
id: settingsTable

showExpert: showAdvancedButton.checked
SplitView.minimumWidth: Constants.settingsTable.minimumWidth
onSelectedRowIdxChanged: {
if (!!selectedRow())
settingsPane.selectedRow = selectedRow();

}
}

ColumnLayout {
Expand Down Expand Up @@ -255,7 +235,7 @@ MainTab {
SwiftButton {
id: autoSurveyButton

property bool buttonEnabled: (selectedRowField("group") === "surveyed_position")
property bool buttonEnabled: (settingsPane.selectedRowField("group") === "surveyed_position")

Layout.columnSpan: 1
Layout.rowSpan: 1
Expand Down Expand Up @@ -298,6 +278,8 @@ MainTab {
}

SmallCheckBox {
id: showAdvancedButton

Layout.columnSpan: 1
Layout.rowSpan: 1
Layout.preferredWidth: parent.colWidth
Expand All @@ -308,14 +290,6 @@ MainTab {
font.pointSize: refreshButton.font.pointSize
font.family: Constants.fontFamily
font.bold: false
onClicked: {
if (this.enabled) {
this.enabled = false;
settingsTable.showExpert = checked;
settingsTable.selectedRowIdx = -1;
this.enabled = true;
}
}
}

}
Expand All @@ -330,12 +304,20 @@ MainTab {
SettingsTabComponents.SettingsPane {
id: settingsPane

function selectedRow() {
var rowIdx = settingsTable.selectedRowIdx;
if (rowIdx < 0)
return ;

return settingsTable.table[settingsTable.rowOffsets[rowIdx]];
}

Layout.rightMargin: 10
Layout.fillHeight: true
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
visible: {
var row = settingsTab.selectedRow();
var row = this.selectedRow();
if (row && row.hasOwnProperty("valueOnDevice"))
return true;
else
Expand Down
11 changes: 6 additions & 5 deletions resources/SettingsTabComponents/SettingsPane.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@ import SwiftConsole 1.0
Rectangle {
id: settingsPane

property var selectedRow
property var floatValidator
property var intValidator
property var stringValidator

function shouldShowField(name) {
if (!selectedRow)
let row = settingsPane.selectedRow();
if (!row)
return false;

return !!selectedRow[name];
return !!row[name];
}

function selectedRowField(name) {
if (!selectedRow)
let row = settingsPane.selectedRow();
if (!row)
return "";

return selectedRow[name] || "";
return row[name] || "";
}

clip: true
Expand Down
13 changes: 9 additions & 4 deletions resources/SettingsTabComponents/SettingsTable.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Rectangle {
property bool settingsHealthy: false
property real mouse_x: 0

function clearTableModel() {
tableView.model.clear();
}

function isHeader(entry) {
return !entry.hasOwnProperty("name");
}
Expand Down Expand Up @@ -53,10 +57,10 @@ Rectangle {
}

onVisibleChanged: {
if (visible && selectedRowIdx == -1) {
selectedRowIdx = 1;
tableView.focus = true;
}
if (visible)
clearTableModel();
else
selectedRowIdx = -1;
}
Keys.onUpPressed: {
let cellDecrease = 1;
Expand Down Expand Up @@ -247,6 +251,7 @@ Rectangle {
}
settingsHealthy = true;
if (lastShowExpert != showExpert) {
tableView._currentSelectedIndex = -1;
tableView.model.clear();
rowOffsets = {
};
Expand Down
5 changes: 5 additions & 0 deletions resources/TableComponents/SwiftTableView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ TableView {
id: _verticalScrollBar

policy: ScrollBar.AlwaysOn
onSizeChanged: {
if (position + size > 1)
position = 1 - size;

}
}

delegate: Rectangle {
Expand Down