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