diff --git a/python/graph_list_table_dialog.py b/python/graph_list_table_dialog.py new file mode 100644 index 0000000000000000000000000000000000000000..4c822a1e70b7c6e3c6df0094b4a52575e475c4cc --- /dev/null +++ b/python/graph_list_table_dialog.py @@ -0,0 +1,60 @@ +from PySide6.QtCore import Slot +from PySide6.QtCore import Qt +from PySide6.QtCore import QSize +from PySide6.QtWidgets import QDialog, QAbstractItemView +from PySide6.QtWidgets import QTableView +from PySide6.QtWidgets import QLabel, QPushButton, QSizePolicy +from PySide6.QtWidgets import QLayout +from PySide6.QtWidgets import QScrollArea, QVBoxLayout + +_WINDOW_SIZE = QSize(800, 500) + +class GraphListTableDialog(QDialog): + + def __init__(self, parent_window, graph_list_proxy_model, + graph_list_selection_model): + super().__init__(parent_window) + + self.resize(_WINDOW_SIZE) + self.setFixedSize(self.width(), self.height()) + self.setWindowFlags(self.windowFlags() | Qt.Tool) + self.setAttribute(Qt.WA_MacAlwaysShowToolWindow) + self.setWindowTitle("Sort traces by attribute") + + self.layout = QVBoxLayout(self) + self.layout.setSpacing(0) + + # table + self.table = QTableView() + self.table.setSortingEnabled(True) + self.table.setModel(graph_list_proxy_model) + self.table.setSelectionModel(graph_list_selection_model) + self.table.setSelectionBehavior( + QAbstractItemView.SelectionBehavior.SelectRows) + self.table.setSelectionMode( + QAbstractItemView.SelectionMode.SingleSelection) + self.table.setAlternatingRowColors(True) + self.table.horizontalHeader().setStretchLastSection(True) + self.layout.addWidget(self.table) + + # close button + spacing = 10 + self.layout.addSpacing(spacing) + self.close_pb = QPushButton("Close") + self.close_pb.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, + QSizePolicy.Fixed)) + self.close_pb.clicked.connect(self._close_pb_clicked) + self.layout.addWidget(self.close_pb) + self.layout.addSpacing(spacing) + +#zz +# self.show() + + # close button + @Slot() + def _close_pb_clicked(self): + self.hide() + + def closeEvent(self, event): + self.hide() + diff --git a/python/graph_list_table_model.py b/python/graph_list_table_model.py index 1eb1186aa43ed5c75363ad997422f89d88ca69f9..6a474219e439b81081fd352982689b07664828b9 100644 --- a/python/graph_list_table_model.py +++ b/python/graph_list_table_model.py @@ -13,6 +13,8 @@ PROBABILITY_COLUMN = 3 # float 0.0 to 1.0 SIZE_COLUMN = 4 # int, see implementation COLUMN_COUNT = 5 # number of columns +_HEADERS = ["Graph", "index", "Mark", "Type 1 P", "Size"] + class GraphListTableModel(QAbstractTableModel): """Provides the graph list model for graph list accessors, consisting of column constants and implementations of headerData, rowCount, columnCount, @@ -42,10 +44,13 @@ class GraphListTableModel(QAbstractTableModel): self.graphs = graphs self.endResetModel() - def headerData(self, _section, _orientation, + def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole): - # we do not use headers - return None # QVariant() + if role == Qt.ItemDataRole.DisplayRole \ + and orientation == Qt.Orientation.Horizontal: + return _HEADERS[section] + else: + return None # QVariant() # number of rows def rowCount(self, parent=QModelIndex()): diff --git a/python/graph_list_view.py b/python/graph_list_view.py index 55b508b04219442442fd8d382b4f4f0f00197b6f..812edb993accd19624f67012e15dfb57c9ae1b25 100644 --- a/python/graph_list_view.py +++ b/python/graph_list_view.py @@ -54,7 +54,8 @@ class GraphListView(QTableView): # connect move scrollbar to top when graph is reloaded - graphs_manager.signal_graphs_loaded.connect(self._reset_scrollbar) +#zz graphs_manager.signal_graphs_loaded.connect(self._reset_scrollbar) + graph_list_proxy_model.sourceModelChanged.connect(self._reset_scrollbar) # connect scroll mode changed signal_preferences_changed.connect(self._set_scroll_mode) diff --git a/python/gui_manager.py b/python/gui_manager.py index a5f7d6bc54ce1b1b0d5615f2671ffdeecea4acac..f743e97812fd0d578414f986cd23507154402a62 100644 --- a/python/gui_manager.py +++ b/python/gui_manager.py @@ -24,6 +24,7 @@ from graph_list_selection_spinner import GraphListSelectionSpinner from main_graph_scene import MainGraphScene from main_graph_view import MainGraphView from graph_list_view import GraphListView +from graph_list_table_dialog import GraphListTableDialog from navigation_column_width_manager import NavigationColumnWidthManager from scope_spinner import ScopeSpinner from graph_metadata_label import GraphMetadataLabel @@ -148,6 +149,11 @@ class GUIManager(QObject): self.navigation_column_width_manager, self.preferences_manager.signal_preferences_changed) + # the graph list table dialog + self.graph_list_table_dialog = GraphListTableDialog(self.w, + self.graph_list_proxy_model, + self.graph_list_selection_model) + # the main graph scene and view self.main_graph_view = MainGraphView( self.graphs_manager.signal_graphs_loaded)