Skip to content

Commit

Permalink
Bug scroll in combobox (#393)
Browse files Browse the repository at this point in the history
* Recovery of filtering, some columns reordered

* Custom TimeEdit and SpinBox with disabled mouse scroll
  • Loading branch information
sergeikobelev authored May 14, 2021
1 parent fbec3b0 commit 24e1c3b
Show file tree
Hide file tree
Showing 19 changed files with 144 additions and 171 deletions.
5 changes: 2 additions & 3 deletions sportorg/gui/dialogs/cp_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
QDialogButtonBox,
QFormLayout,
QLabel,
QSpinBox,
QTextEdit,
)

from sportorg import config
from sportorg.gui.global_access import GlobalAccess
from sportorg.gui.utils.custom_controls import AdvSpinBox
from sportorg.language import translate
from sportorg.models.memory import race
from sportorg.models.result.result_calculation import ResultCalculation
Expand All @@ -37,8 +37,7 @@ def init_ui(self):

self.layout = QFormLayout(self)

self.item_number = QSpinBox()
self.item_number.setMaximum(10000)
self.item_number = AdvSpinBox(maximum=10000)
self.item_number.valueChanged.connect(self.show_info)
self.layout.addRow(QLabel(translate('Number CP')), self.item_number)

Expand Down
12 changes: 4 additions & 8 deletions sportorg/gui/dialogs/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@
QLineEdit,
QPushButton,
QScrollArea,
QSpinBox,
QTextEdit,
QTimeEdit,
QVBoxLayout,
QWidget,
)

from sportorg import config
from sportorg.gui.utils.custom_controls import AdvComboBox
from sportorg.gui.utils.custom_controls import AdvComboBox, AdvSpinBox, AdvTimeEdit
from sportorg.language import translate
from sportorg.utils.time import qdate_to_date, time_to_otime, time_to_qtime
from sportorg.utils.time import qdate_to_date, time_to_otime


@dataclass
Expand Down Expand Up @@ -157,7 +155,7 @@ def _init_ui(self) -> None:
if callback:
item.textChanged.connect(callback)
if isinstance(field, NumberField):
item = QSpinBox()
item = AdvSpinBox()
if field.maximum is not None:
item.setMaximum(field.maximum)
if field.minimum is not None:
Expand Down Expand Up @@ -205,9 +203,7 @@ def _init_ui(self) -> None:
if callback:
item.textChanged.connect(callback)
if isinstance(field, TimeField):
item = QTimeEdit()
item.setDisplayFormat(field.format)
item.setTime(time_to_qtime(value))
item = AdvTimeEdit(display_format=field.format, time=value)
if isinstance(field, DateField):
item = QDateEdit()
if field.maximum:
Expand Down
6 changes: 2 additions & 4 deletions sportorg/gui/dialogs/entry_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sportorg import config
from sportorg.gui.dialogs.person_edit import PersonEditDialog
from sportorg.gui.global_access import GlobalAccess
from sportorg.gui.utils.custom_controls import AdvComboBox
from sportorg.gui.utils.custom_controls import AdvComboBox, AdvSpinBox
from sportorg.language import translate
from sportorg.models.constant import get_race_groups, get_race_teams

Expand Down Expand Up @@ -46,9 +46,7 @@ def init_ui(self):

self.max_rows_count_label = QtWidgets.QLabel(self)

self.max_rows_count_spin_box = QtWidgets.QSpinBox(self)
self.max_rows_count_spin_box.setMaximum(100000)
self.max_rows_count_spin_box.setValue(5000)
self.max_rows_count_spin_box = AdvSpinBox(5000, 100000)
self.layout.addRow(self.max_rows_count_label, self.max_rows_count_spin_box)

button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
Expand Down
6 changes: 2 additions & 4 deletions sportorg/gui/dialogs/entry_mass_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from sportorg import config
from sportorg.gui.global_access import GlobalAccess
from sportorg.gui.utils.custom_controls import AdvComboBox
from sportorg.gui.utils.custom_controls import AdvComboBox, AdvSpinBox
from sportorg.language import translate
from sportorg.models.constant import get_race_groups, get_race_teams
from sportorg.models.memory import find, race
Expand Down Expand Up @@ -51,9 +51,7 @@ def init_ui(self):
self.layout.addRow(self.team_checkbox, self.team_combo)

self.start_group_checkbox = QtWidgets.QCheckBox(self)
self.start_group_spinbox = QtWidgets.QSpinBox()
self.start_group_spinbox.setMinimum(0)
self.start_group_spinbox.setMaximum(99)
self.start_group_spinbox = AdvSpinBox(minimum=0, maximum=99)
self.layout.addRow(self.start_group_checkbox, self.start_group_spinbox)

self.comment_checkbox = QtWidgets.QCheckBox(self)
Expand Down
8 changes: 2 additions & 6 deletions sportorg/gui/dialogs/event_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
QFormLayout,
QLabel,
QLineEdit,
QSpinBox,
QTextEdit,
)

from sportorg import config
from sportorg.gui.global_access import GlobalAccess
from sportorg.gui.utils.custom_controls import AdvComboBox
from sportorg.gui.utils.custom_controls import AdvComboBox, AdvSpinBox
from sportorg.language import translate
from sportorg.models.memory import RaceType, race
from sportorg.models.result.result_calculation import ResultCalculation
Expand Down Expand Up @@ -67,10 +66,7 @@ def init_ui(self):
self.layout.addRow(self.label_type, self.item_type)

self.label_relay_legs = QLabel(translate('Relay legs'))
self.item_relay_legs = QSpinBox()
self.item_relay_legs.setMinimum(1)
self.item_relay_legs.setMaximum(20)
self.item_relay_legs.setValue(3)
self.item_relay_legs = AdvSpinBox(minimum=1, maximum=20, value=3)
self.layout.addRow(self.label_relay_legs, self.item_relay_legs)

self.item_type.currentTextChanged.connect(self.change_type)
Expand Down
21 changes: 7 additions & 14 deletions sportorg/gui/dialogs/group_ranking.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@
QDialogButtonBox,
QFormLayout,
QHBoxLayout,
QSpinBox,
QTimeEdit,
)

from sportorg import config
from sportorg.gui.global_access import GlobalAccess
from sportorg.gui.utils.custom_controls import AdvComboBox
from sportorg.gui.utils.custom_controls import AdvComboBox, AdvSpinBox, AdvTimeEdit
from sportorg.language import translate
from sportorg.models.memory import Qualification, race
from sportorg.models.result.result_calculation import ResultCalculation
from sportorg.utils.time import time_to_otime, time_to_qtime


class GroupRankingDialog(QDialog):
Expand Down Expand Up @@ -74,10 +71,9 @@ def apply_changes_impl(self):
rank.is_active = self.findChild(
QCheckBox, name + '_checkbox'
).isChecked()
rank.max_place = self.findChild(QSpinBox, name + '_place').value()
rank.max_time = time_to_otime(
self.findChild(QTimeEdit, name + '_time').time()
)
rank.max_place = self.findChild(AdvSpinBox, name + '_place').value()
rank.max_time = self.findChild(AdvTimeEdit, name + '_time').getOTime()

rank.use_scores = self.findChild(
AdvComboBox, name + '_combo'
).currentText() == translate('Rank')
Expand All @@ -97,14 +93,11 @@ def get_widget_from_ranking(ranking):
type_combo.setFixedWidth(150)
type_combo.setObjectName(qual + '_combo')

max_place = QSpinBox()
max_place.setValue(0)
max_place = AdvSpinBox(value=0)
max_place.setFixedWidth(70)
max_place.setObjectName(qual + '_place')

max_time = QTimeEdit()
max_time.setFixedWidth(70)
max_time.setDisplayFormat('hh:mm:ss')
max_time = AdvTimeEdit(display_format='hh:mm:ss', max_width=70)
max_time.setObjectName(qual + '_time')

def select_type():
Expand All @@ -128,7 +121,7 @@ def set_enabled():
max_place.setValue(ranking.max_place)
else:
type_combo.setCurrentText(translate('Result time'))
max_time.setTime(time_to_qtime(ranking.max_time))
max_time.setOTime(ranking.max_time)

qual_checkbox.setChecked(ranking.is_active)
select_type()
Expand Down
7 changes: 3 additions & 4 deletions sportorg/gui/dialogs/number_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from PySide2.QtWidgets import QDialog

from sportorg import config
from sportorg.gui.utils.custom_controls import AdvSpinBox
from sportorg.language import translate


Expand All @@ -28,15 +29,13 @@ def setupUi(self):
self.number_grid_layout.setContentsMargins(0, 0, 0, 0)
self.source_num_label = QtWidgets.QLabel(self.layoutWidget)
self.number_grid_layout.addWidget(self.source_num_label, 0, 0, 1, 1)
self.source_num_spin_box = QtWidgets.QSpinBox(self.layoutWidget)
self.source_num_spin_box.setMaximum(100000)
self.source_num_spin_box = AdvSpinBox(maximum=100000, parent=self.layoutWidget)
self.number_grid_layout.addWidget(self.source_num_spin_box, 0, 1, 1, 1)
self.source_info_label = QtWidgets.QLabel(self.layoutWidget)
self.number_grid_layout.addWidget(self.source_info_label, 0, 2, 1, 1)
self.target_num_label = QtWidgets.QLabel(self.layoutWidget)
self.number_grid_layout.addWidget(self.target_num_label, 1, 0, 1, 1)
self.target_num_spin_box = QtWidgets.QSpinBox(self.layoutWidget)
self.target_num_spin_box.setMaximum(100000)
self.target_num_spin_box = AdvSpinBox(maximum=100000, parent=self.layoutWidget)
self.number_grid_layout.addWidget(self.target_num_spin_box, 1, 1, 1, 1)
self.target_info_label = QtWidgets.QLabel(self.layoutWidget)
self.number_grid_layout.addWidget(self.target_info_label, 1, 2, 1, 1)
Expand Down
15 changes: 5 additions & 10 deletions sportorg/gui/dialogs/relay_clone_dialog.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import logging

from PySide2.QtGui import QIcon
from PySide2.QtWidgets import QDialog, QDialogButtonBox, QFormLayout, QLabel, QSpinBox
from PySide2.QtWidgets import QDialog, QDialogButtonBox, QFormLayout, QLabel

from sportorg import config
from sportorg.gui.global_access import GlobalAccess
from sportorg.gui.utils.custom_controls import AdvSpinBox
from sportorg.language import translate
from sportorg.models.start.start_preparation import clone_relay_legs

Expand All @@ -19,19 +20,13 @@ def __init__(self):
self.setModal(True)
self.layout = QFormLayout(self)

self.min_bib = QSpinBox()
self.min_bib.setMaximum(10000000)
self.min_bib.setValue(1001)
self.min_bib = AdvSpinBox(maximum=10000000, value=1001)
self.layout.addRow(QLabel(translate('Minimal bib')), self.min_bib)

self.max_bib = QSpinBox()
self.max_bib.setMaximum(10000000)
self.max_bib.setValue(2999)
self.max_bib = AdvSpinBox(maximum=10000000, value=2999)
self.layout.addRow(QLabel(translate('Maximal bib')), self.max_bib)

self.increment = QSpinBox()
self.increment.setMaximum(10000000)
self.increment.setValue(2000)
self.increment = AdvSpinBox(maximum=10000000, value=2000)
self.layout.addRow(QLabel(translate('Increment')), self.increment)

def cancel_changes():
Expand Down
7 changes: 3 additions & 4 deletions sportorg/gui/dialogs/relay_number_dialog.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import logging

from PySide2.QtGui import QIcon
from PySide2.QtWidgets import QDialog, QDialogButtonBox, QFormLayout, QLabel, QSpinBox
from PySide2.QtWidgets import QDialog, QDialogButtonBox, QFormLayout, QLabel

from sportorg import config
from sportorg.gui.global_access import GlobalAccess
from sportorg.gui.utils.custom_controls import AdvSpinBox
from sportorg.language import translate
from sportorg.models.start.relay import (
get_next_relay_number_protocol,
Expand All @@ -28,9 +29,7 @@ def init_ui(self):
self.layout = QFormLayout(self)

self.number_label = QLabel(translate('First relay number'))
self.number_item = QSpinBox()
self.number_item.setMinimum(1001)
self.number_item.setMaximum(9999)
self.number_item = AdvSpinBox(1001, 9999)

next_number = get_next_relay_number_protocol()
self.number_item.setValue(next_number)
Expand Down
Loading

0 comments on commit 24e1c3b

Please sign in to comment.