Skip to content
Snippets Groups Projects
Commit 4d8ec562 authored by Allen, Bruce (CIV)'s avatar Allen, Bruce (CIV)
Browse files

adding graph list table dialog

parent 684491aa
No related branches found
No related tags found
No related merge requests found
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()
......@@ -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()):
......
......@@ -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)
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment