Skip to content

Commit 4194ad0

Browse files
Deselect all table rows selected on press or copy.
1 parent e153bb7 commit 4194ad0

File tree

10 files changed

+119
-58
lines changed

10 files changed

+119
-58
lines changed

resources/AdvancedTabComponents/MetricsMonitor.qml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import SwiftConsole 1.0
99
Item {
1010
property variant columnWidths: [width / 2, width / 2]
1111
property real mouse_x: 0
12-
property int selectedRow: -1
1312
property variant entries: []
1413
property bool csacReceived: false
1514

@@ -96,6 +95,11 @@ Item {
9695
TableView {
9796
id: tableView
9897

98+
property int selectedRow: -1
99+
100+
Component.onCompleted: {
101+
Globals.tablesWithHighlights.push(this);
102+
}
99103
columnSpacing: -1
100104
rowSpacing: -1
101105
columnWidthProvider: function(column) {
@@ -132,7 +136,7 @@ Item {
132136
implicitHeight: Constants.genericTable.cellHeight
133137
implicitWidth: tableView.columnWidthProvider(column)
134138
border.color: Constants.genericTable.borderColor
135-
color: row == selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
139+
color: row == tableView.selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
136140

137141
Label {
138142
width: parent.width
@@ -150,11 +154,13 @@ Item {
150154
height: parent.height
151155
anchors.centerIn: parent
152156
onPressed: {
153-
if (selectedRow == row) {
154-
selectedRow = -1;
157+
Globals.clearHighlightedRows();
158+
tableView.focus = true;
159+
if (tableView.selectedRow == row) {
160+
tableView.selectedRow = -1;
155161
} else {
156-
selectedRow = row;
157-
Globals.copyClipboard = JSON.stringify(tableView.model.getRow(selectedRow));
162+
tableView.selectedRow = row;
163+
Globals.copyClipboard = JSON.stringify(tableView.model.getRow(tableView.selectedRow));
158164
}
159165
}
160166
}

resources/AdvancedTabComponents/NetworkInfo.qml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ ColumnLayout {
99
property variant entries: []
1010
property var columnWidths: [parent.width / 5, parent.width / 5, parent.width / 5, parent.width / 5, parent.width / 5]
1111
property real mouse_x: 0
12-
property int selectedRow: -1
1312

1413
spacing: Constants.networking.layoutSpacing
1514

@@ -19,7 +18,7 @@ ColumnLayout {
1918
Layout.fillWidth: true
2019
Layout.preferredHeight: Constants.genericTable.cellHeight
2120
interactive: false
22-
syncView: table
21+
syncView: tableView
2322
z: Constants.genericTable.headerZOffset
2423

2524
delegate: Rectangle {
@@ -32,7 +31,7 @@ ColumnLayout {
3231
anchors.centerIn: parent
3332
horizontalAlignment: Text.AlignHCenter
3433
verticalAlignment: Text.AlignVCenter
35-
text: table.model.columns[index].display
34+
text: tableView.model.columns[index].display
3635
elide: Text.ElideRight
3736
clip: true
3837
font.family: Constants.genericTable.fontFamily
@@ -51,12 +50,12 @@ ColumnLayout {
5150
if (pressed) {
5251
var delta_x = (mouseX - mouse_x);
5352
var next_idx = (index + 1) % 5;
54-
var min_width = table.width / 10;
53+
var min_width = tableView.width / 10;
5554
if (columnWidths[index] + delta_x > min_width && columnWidths[next_idx] - delta_x > min_width) {
5655
columnWidths[index] += delta_x;
5756
columnWidths[next_idx] -= delta_x;
5857
}
59-
table.forceLayout();
58+
tableView.forceLayout();
6059
}
6160
}
6261
}
@@ -79,8 +78,13 @@ ColumnLayout {
7978
}
8079

8180
TableView {
82-
id: table
81+
id: tableView
8382

83+
property int selectedRow: -1
84+
85+
Component.onCompleted: {
86+
Globals.tablesWithHighlights.push(this);
87+
}
8488
columnSpacing: -1
8589
rowSpacing: -1
8690
columnWidthProvider: function(column) {
@@ -91,7 +95,7 @@ ColumnLayout {
9195
Layout.fillWidth: true
9296
Layout.fillHeight: true
9397
onWidthChanged: {
94-
table.forceLayout();
98+
tableView.forceLayout();
9599
}
96100

97101
ScrollBar.horizontal: ScrollBar {
@@ -127,9 +131,9 @@ ColumnLayout {
127131

128132
delegate: Rectangle {
129133
implicitHeight: Constants.genericTable.cellHeight
130-
implicitWidth: table.columnWidthProvider(column)
134+
implicitWidth: tableView.columnWidthProvider(column)
131135
border.color: Constants.genericTable.borderColor
132-
color: row == selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
136+
color: row == tableView.selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
133137

134138
Label {
135139
width: parent.width
@@ -147,11 +151,13 @@ ColumnLayout {
147151
height: parent.height
148152
anchors.centerIn: parent
149153
onPressed: {
150-
if (selectedRow == row) {
151-
selectedRow = -1;
154+
Globals.clearHighlightedRows();
155+
tableView.focus = true;
156+
if (tableView.selectedRow == row) {
157+
tableView.selectedRow = -1;
152158
} else {
153-
selectedRow = row;
154-
Globals.copyClipboard = JSON.stringify(table.model.getRow(selectedRow));
159+
tableView.selectedRow = row;
160+
Globals.copyClipboard = JSON.stringify(tableView.model.getRow(tableView.selectedRow));
155161
}
156162
}
157163
}
@@ -176,7 +182,7 @@ ColumnLayout {
176182
new_row[Constants.networking.columnHeaders[2]] = entries[idx][2];
177183
new_row[Constants.networking.columnHeaders[3]] = entries[idx][3];
178184
new_row[Constants.networking.columnHeaders[4]] = entries[idx][4];
179-
table.model.setRow(idx, new_row);
185+
tableView.model.setRow(idx, new_row);
180186
}
181187
}
182188
}

resources/AdvancedTabComponents/ThreadStateTable.qml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import SwiftConsole 1.0
99
Item {
1010
property variant columnWidths: [parent.width / 3, parent.width / 3, parent.width / 3]
1111
property real mouse_x: 0
12-
property int selectedRow: -1
1312
property variant entries: []
1413

1514
HorizontalHeaderView {
@@ -78,6 +77,11 @@ Item {
7877
TableView {
7978
id: tableView
8079

80+
property int selectedRow: -1
81+
82+
Component.onCompleted: {
83+
Globals.tablesWithHighlights.push(this);
84+
}
8185
columnSpacing: -1
8286
rowSpacing: -1
8387
columnWidthProvider: function(column) {
@@ -121,7 +125,7 @@ Item {
121125
implicitHeight: Constants.genericTable.cellHeight
122126
implicitWidth: tableView.columnWidthProvider(column)
123127
border.color: Constants.genericTable.borderColor
124-
color: row == selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
128+
color: row == tableView.selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
125129

126130
Label {
127131
width: parent.width
@@ -139,11 +143,13 @@ Item {
139143
height: parent.height
140144
anchors.centerIn: parent
141145
onPressed: {
142-
if (selectedRow == row) {
143-
selectedRow = -1;
146+
Globals.clearHighlightedRows();
147+
tableView.focus = true;
148+
if (tableView.selectedRow == row) {
149+
tableView.selectedRow = -1;
144150
} else {
145-
selectedRow = row;
146-
Globals.copyClipboard = JSON.stringify(tableView.model.getRow(selectedRow));
151+
tableView.selectedRow = row;
152+
Globals.copyClipboard = JSON.stringify(tableView.model.getRow(tableView.selectedRow));
147153
}
148154
}
149155
}

resources/BaselineTabComponents/BaselineTable.qml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Item {
1111

1212
property variant columnWidths: [Constants.baselineTable.defaultColumnWidth, Constants.baselineTable.defaultColumnWidth]
1313
property real mouse_x: 0
14-
property int selectedRow: -1
1514

1615
function syncColumnWidthsWithSplitView() {
1716
var oldcols = columnWidths.slice();
@@ -105,6 +104,11 @@ Item {
105104
TableView {
106105
id: tableView
107106

107+
property int selectedRow: -1
108+
109+
Component.onCompleted: {
110+
Globals.tablesWithHighlights.push(this);
111+
}
108112
onWidthChanged: syncColumnWidthsWithSplitView()
109113
columnSpacing: -1
110114
rowSpacing: -1
@@ -145,7 +149,7 @@ Item {
145149
implicitHeight: Constants.genericTable.cellHeight
146150
implicitWidth: tableView.columnWidthProvider(column)
147151
border.color: Constants.genericTable.borderColor
148-
color: row == selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
152+
color: row == tableView.selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
149153

150154
Label {
151155
width: parent.width
@@ -163,11 +167,13 @@ Item {
163167
height: parent.height
164168
anchors.centerIn: parent
165169
onPressed: {
166-
if (selectedRow == row) {
167-
selectedRow = -1;
170+
Globals.clearHighlightedRows();
171+
tableView.focus = true;
172+
if (tableView.selectedRow == row) {
173+
tableView.selectedRow = -1;
168174
} else {
169-
selectedRow = row;
170-
Globals.copyClipboard = JSON.stringify(tableView.model.getRow(selectedRow));
175+
tableView.selectedRow = row;
176+
Globals.copyClipboard = JSON.stringify(tableView.model.getRow(tableView.selectedRow));
171177
}
172178
}
173179
}

resources/Constants/Globals.qml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@ QtObject {
1616
property string conn_state: Constants.connection.disconnected
1717
property bool connected_at_least_once: false
1818
property string copyClipboard: ""
19+
property var tablesWithHighlights: []
20+
21+
function clearHighlightedRows() {
22+
for (var i in tablesWithHighlights) {
23+
tablesWithHighlights[i].selectedRow = -1;
24+
}
25+
}
26+
1927
}

resources/LogPanel.qml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Item {
88
property var logEntries: []
99
property variant columnWidths: [parent.width * Constants.logPanel.defaultColumnWidthRatios[0], parent.width * Constants.logPanel.defaultColumnWidthRatios[1], parent.width * Constants.logPanel.defaultColumnWidthRatios[2]]
1010
property real mouse_x: 0
11-
property int selectedRow: -1
1211
property bool forceLayoutLock: false
1312
property variant logLevelLabels: []
1413
property int logLevelIndex: 3
@@ -206,6 +205,11 @@ Item {
206205
TableView {
207206
id: tableView
208207

208+
property int selectedRow: -1
209+
210+
Component.onCompleted: {
211+
Globals.tablesWithHighlights.push(this);
212+
}
209213
columnSpacing: -1
210214
rowSpacing: -1
211215
columnWidthProvider: function(column) {
@@ -256,7 +260,7 @@ Item {
256260
delegate: Rectangle {
257261
implicitHeight: Constants.logPanel.cellHeight
258262
implicitWidth: tableView.columnWidthProvider(column)
259-
color: row == selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
263+
color: row == tableView.selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
260264

261265
Label {
262266
width: parent.width
@@ -274,11 +278,13 @@ Item {
274278
height: parent.height
275279
anchors.centerIn: parent
276280
onPressed: {
277-
if (selectedRow == row) {
278-
selectedRow = -1;
281+
Globals.clearHighlightedRows();
282+
tableView.focus = true;
283+
if (tableView.selectedRow == row) {
284+
tableView.selectedRow = -1;
279285
} else {
280-
selectedRow = row;
281-
Globals.copyClipboard = JSON.stringify(tableView.model.getRow(selectedRow));
286+
tableView.selectedRow = row;
287+
Globals.copyClipboard = JSON.stringify(tableView.model.getRow(tableView.selectedRow));
282288
}
283289
}
284290
}
@@ -318,8 +324,8 @@ Item {
318324
for (var idx in logEntries) {
319325
tableView.model.setRow(idx, logEntries[idx]);
320326
}
321-
if (logPanelData.entries.length && selectedRow != -1)
322-
selectedRow += logPanelData.entries.length;
327+
if (logPanelData.entries.length && tableView.selectedRow != -1)
328+
tableView.selectedRow += logPanelData.entries.length;
323329

324330
logPanelData.entries = [];
325331
}

resources/SettingsTabComponents/InsSettingsPopup.qml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import SwiftConsole 1.0
88
Item {
99
property variant columnWidths: [layout.width / 3, layout.width / 3, layout.width / 3]
1010
property real mouse_x: 0
11-
property int selectedRow: -1
1211
property alias insPopup: dialog
1312
property variant settings: []
1413

@@ -135,6 +134,11 @@ Item {
135134
TableView {
136135
id: tableView
137136

137+
property int selectedRow: -1
138+
139+
Component.onCompleted: {
140+
Globals.tablesWithHighlights.push(this);
141+
}
138142
columnSpacing: -1
139143
rowSpacing: -1
140144
columnWidthProvider: function(column) {
@@ -174,7 +178,7 @@ Item {
174178
implicitHeight: Constants.genericTable.cellHeight
175179
implicitWidth: tableView.columnWidthProvider(column)
176180
border.color: Constants.genericTable.borderColor
177-
color: row == selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
181+
color: row == tableView.selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
178182

179183
Label {
180184
width: parent.width
@@ -192,10 +196,14 @@ Item {
192196
height: parent.height
193197
anchors.centerIn: parent
194198
onPressed: {
195-
if (selectedRow == row)
196-
selectedRow = -1;
197-
else
198-
selectedRow = row;
199+
Globals.clearHighlightedRows();
200+
tableView.focus = true;
201+
if (tableView.selectedRow == row) {
202+
tableView.selectedRow = -1;
203+
} else {
204+
tableView.selectedRow = row;
205+
Globals.copyClipboard = JSON.stringify(tableView.model.getRow(tableView.selectedRow));
206+
}
199207
}
200208
}
201209

0 commit comments

Comments
 (0)