Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • software_public/passoft/sohstationviewer
1 result
Show changes
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
Credit: https://stackoverflow.com/questions/53353450/how-to-highlight-a-words-in-qtablewidget-from-a-searchlist # noqa Credit: https://stackoverflow.com/questions/53353450/how-to-highlight-a-words-in-qtablewidget-from-a-searchlist # noqa
""" """
from typing import List, Dict from typing import List, Dict
from PySide2 import QtCore, QtGui, QtWidgets from PySide6 import QtCore, QtGui, QtWidgets
from PySide2.QtGui import QPen, QTextCursor, QTextCharFormat, QColor from PySide6.QtGui import QPen, QTextCursor, QTextCharFormat, QColor
class HighlightDelegate(QtWidgets.QStyledItemDelegate): class HighlightDelegate(QtWidgets.QStyledItemDelegate):
...@@ -52,20 +52,21 @@ class HighlightDelegate(QtWidgets.QStyledItemDelegate): ...@@ -52,20 +52,21 @@ class HighlightDelegate(QtWidgets.QStyledItemDelegate):
options.text = "" options.text = ""
style = QtWidgets.QApplication.style() if options.widget is None \ style = QtWidgets.QApplication.style() if options.widget is None \
else options.widget.style() else options.widget.style()
style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter) style.drawControl(QtWidgets.QStyle.ControlElement.CE_ItemViewItem,
options, painter)
context = QtGui.QAbstractTextDocumentLayout.PaintContext() context = QtGui.QAbstractTextDocumentLayout.PaintContext()
if option.state & QtWidgets.QStyle.State_Selected: if option.state & QtWidgets.QStyle.StateFlag.State_Selected:
role = QtGui.QPalette.HighlightedText role = QtGui.QPalette.ColorRole.HighlightedText
else: else:
role = QtGui.QPalette.Text role = QtGui.QPalette.ColorRole.Text
context.palette.setColor( context.palette.setColor(
QtGui.QPalette.Text, QtGui.QPalette.ColorRole.Text,
option.palette.color(QtGui.QPalette.Active, role) option.palette.color(QtGui.QPalette.ColorGroup.Active, role)
) )
text_rect = style.subElementRect( text_rect = style.subElementRect(
QtWidgets.QStyle.SE_ItemViewItemText, options) QtWidgets.QStyle.SubElement.SE_ItemViewItemText, options)
if index.column() != 0: if index.column() != 0:
text_rect.adjust(5, 0, 0, 0) text_rect.adjust(5, 0, 0, 0)
......
...@@ -3,9 +3,9 @@ import os ...@@ -3,9 +3,9 @@ import os
from pathlib import PosixPath, Path from pathlib import PosixPath, Path
from typing import Dict, List, Tuple, Callable, Union, Optional from typing import Dict, List, Tuple, Callable, Union, Optional
from PySide2 import QtGui, QtCore, QtWidgets from PySide6 import QtGui, QtCore, QtWidgets
from PySide2.QtWidgets import QStyle, QAbstractItemView from PySide6.QtWidgets import QStyle, QAbstractItemView
from PySide2.QtGui import QPalette from PySide6.QtGui import QPalette
from sohstationviewer.view.search_message.highlight_delegate import ( from sohstationviewer.view.search_message.highlight_delegate import (
HighlightDelegate) HighlightDelegate)
...@@ -178,17 +178,18 @@ class SearchMessageDialog(QtWidgets.QWidget): ...@@ -178,17 +178,18 @@ class SearchMessageDialog(QtWidgets.QWidget):
self.scroll_to_selected) self.scroll_to_selected)
self.add_nav_button( self.add_nav_button(
navigation, navigation,
self.style().standardIcon(QStyle.SP_ArrowBack), self.style().standardIcon(QStyle.StandardPixmap.SP_ArrowBack),
'Scroll to previous search text', 'Scroll to previous search text',
self.scroll_to_previous_search_text) self.scroll_to_previous_search_text)
self.add_nav_button( self.add_nav_button(
navigation, navigation,
self.style().standardIcon(QStyle.SP_ArrowForward), self.style().standardIcon(QStyle.StandardPixmap.SP_ArrowForward),
'Scroll to next search text', 'Scroll to next search text',
self.scroll_to_next_search_text) self.scroll_to_next_search_text)
self.save_button = self.add_nav_button( self.save_button = self.add_nav_button(
navigation, navigation,
self.style().standardIcon(QStyle.SP_DialogSaveButton), self.style().standardIcon(
QStyle.StandardPixmap.SP_DialogSaveButton),
'Save messages in current tab to text file', 'Save messages in current tab to text file',
self.save_messages) self.save_messages)
...@@ -366,7 +367,8 @@ class SearchMessageDialog(QtWidgets.QWidget): ...@@ -366,7 +367,8 @@ class SearchMessageDialog(QtWidgets.QWidget):
# set background color for header of a block of soh messages # set background color for header of a block of soh messages
it.setBackground( it.setBackground(
QtGui.QColor(self.display_color['state_of_health'])) QtGui.QColor(self.display_color['state_of_health']))
it.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) it.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable |
QtCore.Qt.ItemFlag.ItemIsEnabled)
table.setItem(count, 1, it) table.setItem(count, 1, it)
def create_table(self, rows: int, cols: int, hidden: List[int] = [])\ def create_table(self, rows: int, cols: int, hidden: List[int] = [])\
...@@ -413,13 +415,17 @@ class SearchMessageDialog(QtWidgets.QWidget): ...@@ -413,13 +415,17 @@ class SearchMessageDialog(QtWidgets.QWidget):
table.horizontalHeader().setStretchLastSection(True) table.horizontalHeader().setStretchLastSection(True)
table.horizontalHeader().setSectionResizeMode( table.horizontalHeader().setSectionResizeMode(
1, QtWidgets.QHeaderView.ResizeToContents) 1, QtWidgets.QHeaderView.ResizeMode.ResizeToContents)
# Hide cell grid # Hide cell grid
table.setShowGrid(False) table.setShowGrid(False)
table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) table.setSelectionBehavior(
table.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows
)
table.setSelectionMode(
QtWidgets.QAbstractItemView.SelectionMode.SingleSelection
)
table.itemClicked.connect(self.on_log_entry_clicked) table.itemClicked.connect(self.on_log_entry_clicked)
for index in hidden: for index in hidden:
...@@ -496,7 +502,9 @@ class SearchMessageDialog(QtWidgets.QWidget): ...@@ -496,7 +502,9 @@ class SearchMessageDialog(QtWidgets.QWidget):
item : QTableWidgetItem item : QTableWidgetItem
A valid QTableWidgetIem A valid QTableWidgetIem
""" """
self.current_table.scrollToItem(item, QAbstractItemView.PositionAtTop) self.current_table.scrollToItem(
item, QAbstractItemView.ScrollMode.PositionAtTop
)
self.current_table.setFocus() self.current_table.setFocus()
def show_log_entry_from_log_indexes(self, log_indexes: List[int]): def show_log_entry_from_log_indexes(self, log_indexes: List[int]):
...@@ -519,14 +527,15 @@ class SearchMessageDialog(QtWidgets.QWidget): ...@@ -519,14 +527,15 @@ class SearchMessageDialog(QtWidgets.QWidget):
self.current_table.clearSelection() self.current_table.clearSelection()
# Allow to select multiple rows # Allow to select multiple rows
self.current_table.setSelectionMode( self.current_table.setSelectionMode(
QAbstractItemView.MultiSelection) QAbstractItemView.SelectionMode.MultiSelection
)
# select all rows according to log_indexes # select all rows according to log_indexes
for idx in log_indexes: for idx in log_indexes:
self.current_table.selectRow(idx) self.current_table.selectRow(idx)
# scroll to the first index and place the row at top of the table # scroll to the first index and place the row at top of the table
self.current_table.scrollToItem( self.current_table.scrollToItem(
self.current_table.item(log_indexes[0], 1), self.current_table.item(log_indexes[0], 1),
QAbstractItemView.PositionAtTop QAbstractItemView.ScrollMode.PositionAtTop
) )
# raise the message dialog on top of others # raise the message dialog on top of others
self.setWindowState(QtCore.Qt.WindowState.WindowActive) self.setWindowState(QtCore.Qt.WindowState.WindowActive)
...@@ -535,7 +544,8 @@ class SearchMessageDialog(QtWidgets.QWidget): ...@@ -535,7 +544,8 @@ class SearchMessageDialog(QtWidgets.QWidget):
self.current_table.setFocus() # focus row to not faded out self.current_table.setFocus() # focus row to not faded out
# return back to select single row # return back to select single row
self.current_table.setSelectionMode( self.current_table.setSelectionMode(
QAbstractItemView.SingleSelection) QAbstractItemView.SelectionMode.SingleSelection
)
def show_log_entry_from_data_index(self, data_index: int): def show_log_entry_from_data_index(self, data_index: int):
""" """
...@@ -679,8 +689,9 @@ class SearchMessageDialog(QtWidgets.QWidget): ...@@ -679,8 +689,9 @@ class SearchMessageDialog(QtWidgets.QWidget):
if ret is None: if ret is None:
return return
self.selected_item, self.search_rowidx = ret self.selected_item, self.search_rowidx = ret
self.current_table.scrollToItem(self.selected_item, self.current_table.scrollToItem(
QAbstractItemView.PositionAtTop) self.selected_item, QAbstractItemView.ScrollMode.PositionAtTop
)
def _filter_lines_with_search_text_from_soh_messages(self): def _filter_lines_with_search_text_from_soh_messages(self):
""" """
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
from PySide2 import QtCore, QtGui, QtWidgets from PySide6 import QtCore, QtGui, QtWidgets
class Ui_About(object): class Ui_About(object):
def setupUi(self, About): def setupUi(self, About):
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
from PySide2 import QtCore, QtWidgets from PySide6 import QtCore, QtWidgets
from sohstationviewer.view.calendar.calendar_widget import CalendarWidget from sohstationviewer.view.calendar.calendar_widget import CalendarWidget
...@@ -25,8 +25,10 @@ class Ui_CalendarDialog(object): ...@@ -25,8 +25,10 @@ class Ui_CalendarDialog(object):
self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout") self.horizontalLayout.setObjectName("horizontalLayout")
self.buttonBox = QtWidgets.QDialogButtonBox(CalendarDialog) self.buttonBox = QtWidgets.QDialogButtonBox(CalendarDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setStandardButtons(
QtWidgets.QDialogButtonBox.StandardButton.Ok
)
self.buttonBox.setObjectName("buttonBox") self.buttonBox.setObjectName("buttonBox")
self.horizontalLayout.addWidget(self.buttonBox) self.horizontalLayout.addWidget(self.buttonBox)
self.verticalLayout.addLayout(self.horizontalLayout) self.verticalLayout.addLayout(self.horizontalLayout)
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
import configparser import configparser
from typing import Union, List, Optional from typing import Union, List, Optional
from PySide2 import QtCore, QtGui, QtWidgets from PySide6 import QtCore, QtGui, QtWidgets
from PySide2.QtWidgets import ( from PySide6.QtWidgets import (
QMainWindow, QWidget, QTextBrowser, QPushButton, QLineEdit, QDateEdit, QMainWindow, QWidget, QTextBrowser, QPushButton, QLineEdit, QDateEdit,
QListWidget, QCheckBox, QRadioButton, QMenu, QLabel, QFrame, QListWidget, QCheckBox, QRadioButton, QMenu, QLabel, QFrame,
QVBoxLayout, QHBoxLayout, QGridLayout, QAbstractItemView, QButtonGroup, QVBoxLayout, QHBoxLayout, QGridLayout, QAbstractItemView, QButtonGroup,
QSplitter, QSplitter,
) )
from PySide2.QtWidgets import ( from PySide6.QtGui import (
QAction, QActionGroup, QShortcut QAction, QActionGroup, QShortcut
) )
from sohstationviewer.view.calendar.calendar_widget import CalendarWidget from sohstationviewer.view.calendar.calendar_widget import CalendarWidget
...@@ -29,7 +29,7 @@ def add_separation_line(layout): ...@@ -29,7 +29,7 @@ def add_separation_line(layout):
:param layout: QLayout - the layout that contains the line :param layout: QLayout - the layout that contains the line
""" """
label = QLabel() label = QLabel()
label.setFrameStyle(QFrame.HLine | QFrame.Sunken) label.setFrameStyle(QFrame.Shape.HLine | QFrame.Shadow.Sunken)
label.setLineWidth(1) label.setLineWidth(1)
layout.addWidget(label) layout.addWidget(label)
...@@ -423,12 +423,14 @@ class UIMainWindow(object): ...@@ -423,12 +423,14 @@ class UIMainWindow(object):
left_layout.addWidget(self.open_files_list, 1) left_layout.addWidget(self.open_files_list, 1)
pal = self.open_files_list.palette() pal = self.open_files_list.palette()
pal.setColor(QtGui.QPalette.Highlight, QtGui.QColor(128, 255, 128)) pal.setColor(QtGui.QPalette.ColorRole.Highlight,
pal.setColor(QtGui.QPalette.HighlightedText, QtGui.QColor(0, 0, 0)) QtGui.QColor(128, 255, 128))
pal.setColor(QtGui.QPalette.ColorRole.HighlightedText,
QtGui.QColor(0, 0, 0))
self.open_files_list.setPalette(pal) self.open_files_list.setPalette(pal)
# allow multiple-line selection # allow multiple-line selection
self.open_files_list.setSelectionMode( self.open_files_list.setSelectionMode(
QAbstractItemView.ExtendedSelection) QAbstractItemView.SelectionMode.ExtendedSelection)
read_option_grid = QGridLayout() read_option_grid = QGridLayout()
left_layout.addLayout(read_option_grid) left_layout.addLayout(read_option_grid)
...@@ -480,7 +482,9 @@ class UIMainWindow(object): ...@@ -480,7 +482,9 @@ class UIMainWindow(object):
self.gap_len_line_edit = QLineEdit(self.central_widget) self.gap_len_line_edit = QLineEdit(self.central_widget)
gap_validator = QtGui.QDoubleValidator() gap_validator = QtGui.QDoubleValidator()
gap_validator.setDecimals(2) gap_validator.setDecimals(2)
gap_validator.setNotation(QtGui.QDoubleValidator.StandardNotation) gap_validator.setNotation(
QtGui.QDoubleValidator.Notation.StandardNotation
)
self.gap_len_line_edit.setValidator(gap_validator) self.gap_len_line_edit.setValidator(gap_validator)
gap_layout.addWidget(self.gap_len_line_edit) gap_layout.addWidget(self.gap_len_line_edit)
gap_layout.addWidget(QLabel(' m')) gap_layout.addWidget(QLabel(' m'))
...@@ -507,7 +511,7 @@ class UIMainWindow(object): ...@@ -507,7 +511,7 @@ class UIMainWindow(object):
ds_grid = QGridLayout() ds_grid = QGridLayout()
left_layout.addLayout(ds_grid) left_layout.addLayout(ds_grid)
ds_grid.addWidget(QLabel('DSs '), 0, 0, 2, 1, ds_grid.addWidget(QLabel('DSs '), 0, 0, 2, 1,
QtGui.Qt.AlignVCenter) QtGui.Qt.AlignmentFlag.AlignVCenter)
self.ds_check_boxes = [] self.ds_check_boxes = []
count = 0 count = 0
for r in range(2): for r in range(2):
...@@ -580,7 +584,8 @@ class UIMainWindow(object): ...@@ -580,7 +584,8 @@ class UIMainWindow(object):
self.info_list_widget = FileInfoWidget(self.central_widget) self.info_list_widget = FileInfoWidget(self.central_widget)
self.info_list_widget.setSelectionMode( self.info_list_widget.setSelectionMode(
QtWidgets.QAbstractItemView.ExtendedSelection) QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection
)
left_layout.addWidget(self.info_list_widget, 1) left_layout.addWidget(self.info_list_widget, 1)
def create_shortcuts(self, main_window): def create_shortcuts(self, main_window):
...@@ -792,7 +797,7 @@ class UIMainWindow(object): ...@@ -792,7 +797,7 @@ class UIMainWindow(object):
# first Row # first Row
self.time_from_date_edit.setCalendarWidget(CalendarWidget(main_window)) self.time_from_date_edit.setCalendarWidget(CalendarWidget(main_window))
self.time_from_date_edit.setDate(QtCore.QDate.fromString( self.time_from_date_edit.setDate(QtCore.QDate.fromString(
constants.DEFAULT_START_TIME, QtCore.Qt.ISODate constants.DEFAULT_START_TIME, QtCore.Qt.DateFormat.ISODate
)) ))
self.curr_dir_button.clicked.connect( self.curr_dir_button.clicked.connect(
......
...@@ -2,7 +2,7 @@ from typing import List, Union, Optional, Tuple, Dict ...@@ -2,7 +2,7 @@ from typing import List, Union, Optional, Tuple, Dict
import sys import sys
import os import os
from PySide2.QtWidgets import QMessageBox, QApplication from PySide6.QtWidgets import QMessageBox, QApplication
from obspy.io.reftek.core import _is_reftek130 from obspy.io.reftek.core import _is_reftek130
from sohstationviewer.conf.constants import BIG_FILE_SIZE from sohstationviewer.conf.constants import BIG_FILE_SIZE
...@@ -300,12 +300,12 @@ def _abort_dialog(msg: str) -> bool: ...@@ -300,12 +300,12 @@ def _abort_dialog(msg: str) -> bool:
dlg = QMessageBox() dlg = QMessageBox()
dlg.setText(msg) dlg.setText(msg)
dlg.setInformativeText('Do you want to proceed?') dlg.setInformativeText('Do you want to proceed?')
dlg.setStandardButtons(QMessageBox.Yes | dlg.setStandardButtons(QMessageBox.StandardButton.Yes |
QMessageBox.Abort) QMessageBox.StandardButton.Abort)
dlg.setDefaultButton(QMessageBox.Abort) dlg.setDefaultButton(QMessageBox.StandardButton.Abort)
dlg.setIcon(QMessageBox.Question) dlg.setIcon(QMessageBox.Icon.Question)
ret = dlg.exec_() ret = dlg.exec_()
if ret == QMessageBox.Abort: if ret == QMessageBox.StandardButton.Abort:
return False return False
else: else:
return True return True
......
from __future__ import annotations from __future__ import annotations
from PySide2 import QtCore from PySide6 import QtCore
from PySide2.QtGui import QCloseEvent from PySide6.QtGui import QCloseEvent
from PySide2.QtWidgets import QWidget from PySide6.QtWidgets import QWidget
class DialogAlreadyOpenedError(Exception): class DialogAlreadyOpenedError(Exception):
...@@ -38,7 +38,7 @@ class OneWindowAtATimeDialog(QWidget): ...@@ -38,7 +38,7 @@ class OneWindowAtATimeDialog(QWidget):
# If we don't have this line, all dialogs of this type will be kept in # If we don't have this line, all dialogs of this type will be kept in
# memory (even when they are closed) until the program is closed. This # memory (even when they are closed) until the program is closed. This
# creates a memory leak. # creates a memory leak.
self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setAttribute(QtCore.Qt.WidgetAttribute.WA_DeleteOnClose)
def closeEvent(self, event: QCloseEvent) -> None: def closeEvent(self, event: QCloseEvent) -> None:
""" """
......
...@@ -12,7 +12,7 @@ from sohstationviewer.controller.processing import ( ...@@ -12,7 +12,7 @@ from sohstationviewer.controller.processing import (
get_next_channel_from_mseed_file, get_next_channel_from_mseed_file,
) )
from sohstationviewer.database.extract_data import get_signature_channels from sohstationviewer.database.extract_data import get_signature_channels
from PySide2 import QtWidgets from PySide6 import QtWidgets
from tests.base_test_case import BaseTestCase from tests.base_test_case import BaseTestCase
......