diff --git a/resources/AdvancedTabComponents/ThreadStateTable.qml b/resources/AdvancedTabComponents/ThreadStateTable.qml
index 97dc87d5b..c5493f49b 100644
--- a/resources/AdvancedTabComponents/ThreadStateTable.qml
+++ b/resources/AdvancedTabComponents/ThreadStateTable.qml
@@ -1,4 +1,5 @@
import "../Constants"
+import "../TableComponents"
import Qt.labs.qmlmodels 1.0
import QtCharts 2.2
import QtQuick 2.15
@@ -74,33 +75,14 @@ Item {
}
- TableView {
+ SwiftTableView {
id: tableView
- property int selectedRow: -1
-
- Component.onCompleted: {
- Globals.tablesWithHighlights.push(this);
- }
- columnSpacing: -1
- rowSpacing: -1
- columnWidthProvider: function(column) {
- return columnWidths[column];
- }
- reuseItems: true
- boundsBehavior: Flickable.StopAtBounds
anchors.top: horizontalHeader.bottom
- width: parent.width
- height: parent.height - horizontalHeader.height
- onWidthChanged: {
- tableView.forceLayout();
- }
-
- ScrollBar.horizontal: ScrollBar {
- }
-
- ScrollBar.vertical: ScrollBar {
- }
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ columnWidths: parent.columnWidths
model: TableModel {
id: tableModel
@@ -121,41 +103,6 @@ Item {
}
- delegate: Rectangle {
- implicitHeight: Constants.genericTable.cellHeight
- implicitWidth: tableView.columnWidthProvider(column)
- border.color: Constants.genericTable.borderColor
- color: row == tableView.selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
-
- Label {
- width: parent.width
- horizontalAlignment: Text.AlignLeft
- clip: true
- font.family: Constants.genericTable.fontFamily
- font.pointSize: Constants.largePointSize
- text: model.display
- elide: Text.ElideRight
- padding: Constants.genericTable.padding
- }
-
- MouseArea {
- width: parent.width
- height: parent.height
- anchors.centerIn: parent
- onPressed: {
- Globals.clearHighlightedRows();
- tableView.focus = true;
- if (tableView.selectedRow == row) {
- tableView.selectedRow = -1;
- } else {
- tableView.selectedRow = row;
- Globals.copyClipboard = JSON.stringify(tableView.model.getRow(tableView.selectedRow));
- }
- }
- }
-
- }
-
}
Timer {
diff --git a/resources/TableComponents/SwiftTableView.qml b/resources/TableComponents/SwiftTableView.qml
new file mode 100644
index 000000000..fad5ebaa2
--- /dev/null
+++ b/resources/TableComponents/SwiftTableView.qml
@@ -0,0 +1,68 @@
+import "../Constants"
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import SwiftConsole 1.0
+
+TableView {
+ id: tableView
+
+ property variant columnWidths: []
+ property int selectedRow: -1
+
+ columnSpacing: -1
+ rowSpacing: -1
+ columnWidthProvider: function(column) {
+ return columnWidths[column];
+ }
+ reuseItems: true
+ boundsBehavior: Flickable.StopAtBounds
+ Component.onCompleted: {
+ console.assert(columnWidths.length == model.columnCount, "length of columnWidths does not match column count.");
+ Globals.tablesWithHighlights.push(this);
+ }
+ onWidthChanged: {
+ tableView.forceLayout();
+ }
+
+ ScrollBar.horizontal: ScrollBar {
+ }
+
+ ScrollBar.vertical: ScrollBar {
+ }
+
+ delegate: Rectangle {
+ implicitHeight: Constants.genericTable.cellHeight
+ implicitWidth: tableView.columnWidthProvider(column)
+ border.color: Constants.genericTable.borderColor
+ color: row == tableView.selectedRow ? Constants.genericTable.cellHighlightedColor : Constants.genericTable.cellColor
+
+ Label {
+ width: parent.width
+ horizontalAlignment: Text.AlignLeft
+ clip: true
+ font.family: Constants.genericTable.fontFamily
+ font.pointSize: Constants.largePointSize
+ text: model.display
+ elide: Text.ElideRight
+ padding: Constants.genericTable.padding
+ }
+
+ MouseArea {
+ width: parent.width
+ height: parent.height
+ anchors.centerIn: parent
+ onPressed: {
+ Globals.clearHighlightedRows();
+ tableView.focus = true;
+ if (tableView.selectedRow == row) {
+ tableView.selectedRow = -1;
+ } else {
+ tableView.selectedRow = row;
+ Globals.copyClipboard = JSON.stringify(tableView.model.getRow(tableView.selectedRow));
+ }
+ }
+ }
+
+ }
+
+}
diff --git a/resources/console_resources.qrc b/resources/console_resources.qrc
index 786f7e94f..cf860610e 100644
--- a/resources/console_resources.qrc
+++ b/resources/console_resources.qrc
@@ -101,6 +101,7 @@
images/icon.ico
TableComponents/SortableColumnHeading.qml
TableComponents/TableCellDelegate.qml
+ TableComponents/SwiftTableView.qml
BaseComponents/SmallCheckBox.qml
BaseComponents/SwiftGroupBox.qml
ChartLegend.qml