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
65 changes: 6 additions & 59 deletions resources/AdvancedTabComponents/ThreadStateTable.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "../Constants"
import "../TableComponents"
import Qt.labs.qmlmodels 1.0
import QtCharts 2.2
import QtQuick 2.15
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
68 changes: 68 additions & 0 deletions resources/TableComponents/SwiftTableView.qml
Original file line number Diff line number Diff line change
@@ -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));
}
}
}

}

}
1 change: 1 addition & 0 deletions resources/console_resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<file>images/icon.ico</file>
<file>TableComponents/SortableColumnHeading.qml</file>
<file>TableComponents/TableCellDelegate.qml</file>
<file>TableComponents/SwiftTableView.qml</file>
<file>BaseComponents/SmallCheckBox.qml</file>
<file>BaseComponents/SwiftGroupBox.qml</file>
<file>ChartLegend.qml</file>
Expand Down