def accept(self): try: # apply filter here if self.table is not None: assert (isinstance(self.table, QTableView)) proxy_model = self.table.model() proxy_model.clear_filter() group_column = 4 team_column = 5 if GlobalAccess().get_main_window().current_tab == 1: group_column = 2 team_column = 3 proxy_model.set_filter_for_column( group_column, self.group_combo.currentText()) proxy_model.set_filter_for_column( team_column, self.team_combo.currentText()) proxy_model.apply_filter() EntryEditDialog.GROUP_NAME = self.group_combo.currentText() EntryEditDialog.ORGANIZATION_NAME = self.team_combo.currentText( ) GlobalAccess().get_main_window().refresh() except Exception as e: logging.error(str(e)) self.destroy()
def apply_changes_impl(self): obj = race() mw = GlobalAccess().get_main_window() map_items = [ obj.persons, obj.results, obj.groups, obj.courses, obj.organizations ] map_names = [ 'persons', 'results', 'groups', 'courses', 'organizations' ] selected_items = { 'persons': [], 'results': [], 'groups': [], 'courses': [], 'organizations': [], } template_path = self.item_template.currentText() _settings['last_template'] = template_path _settings['open_in_browser'] = self.item_open_in_browser.isChecked() _settings['save_to_last_file'] = self.item_save_to_last_file.isChecked( ) _settings['selected'] = self.item_selected.isChecked() if _settings['selected']: cur_items = map_items[mw.current_tab] for i in mw.get_selected_rows(): selected_items[map_names[mw.current_tab]].append( cur_items[i].to_dict()) races_dict = [r.to_dict() for r in races()] template = get_text_from_file( template_path, race=races_dict[get_current_race_index()], races=races_dict, current_race=get_current_race_index(), selected=selected_items) if _settings['save_to_last_file']: file_name = _settings['last_file'] else: file_name = get_save_file_name( _('Save As HTML file'), _("HTML file (*.html)"), '{}_start'.format( obj.data.get_start_datetime().strftime("%Y%m%d"))) if file_name: _settings['last_file'] = file_name with codecs.open(file_name, 'w', 'utf-8') as file: file.write(template) file.close() # Open file in your browser if _settings['open_in_browser']: webbrowser.open('file://' + file_name, new=2)
def apply_changes_impl(self): status_comment = StatusComments().remove_hint( self.item_status_comment.currentText()) text = self.item_numbers.toPlainText() numbers = [] for item in text.split('\n'): if not len(item): continue for n_item in item.split(): if n_item.isdigit(): numbers.append(int(n_item)) old_numbers = [] obj = race() for number in numbers: if number not in old_numbers: person = find(obj.persons, bib=number) if person: result = race().new_result(ResultManual) result.person = person result.status = ResultStatus.DID_NOT_START result.status_comment = status_comment Teamwork().send(result.to_dict()) obj.add_new_result(result) else: logging.info('{} not found'.format(number)) old_numbers.append(number) GlobalAccess().get_main_window().refresh()
def accept(self, *args, **kwargs): try: # apply filter here if self.table is not None: assert (isinstance(self.table, QTableView)) proxy_model = self.table.model() proxy_model.clear_filter() proxy_model.max_rows_count = self.max_rows_count_spin_box.value( ) group_column = 4 team_column = 5 if GlobalAccess().get_main_window().current_tab == 1: group_column = 2 team_column = 3 proxy_model.set_filter_for_column( group_column, self.group_combo.currentText()) proxy_model.set_filter_for_column( team_column, self.team_combo.currentText()) proxy_model.apply_filter() PersonEditDialog.GROUP_NAME = self.group_combo.currentText() PersonEditDialog.ORGANIZATION_NAME = self.team_combo.currentText( ) except Exception as e: logging.error(str(e)) super().accept(*args, **kwargs)
def apply_changes_impl(self): org = self.current_object assert (isinstance(org, Organization)) if self.is_new: race().organizations.insert(0, org) if org.name != self.item_name.text(): org.name = self.item_name.text() if org.address.country.name != self.item_country.currentText(): org.address.country.name = self.item_country.currentText() if org.address.state != self.item_region.currentText(): org.address.state = self.item_region.currentText() if org.address.city != self.item_city.text(): org.address.city = self.item_city.text() if org.address.street != self.item_address.text(): org.address.street = self.item_address.text() if org.contact.value != self.item_contact.text(): org.contact.value = self.item_contact.text() org.contact.name = 'phone' GlobalAccess().get_main_window().refresh() Teamwork().send(org.to_dict())
def __init__(self): super().__init__(GlobalAccess().get_main_window()) self.widgets = [ (MainTab(self), _('Main settings')), (SoundTab(self), _('Sounds')), (MultidayTab(self), _('Multi day')), ]
def apply_changes_impl(self): obj = race() start_date = self.item_start_date.dateTime().toPython() end_date = self.item_end_date.dateTime().toPython() obj.data.title = self.item_main_title.text() obj.data.description = self.item_sub_title.toPlainText() obj.data.description = obj.data.description.replace('\n', '<br>\n') obj.data.location = self.item_location.text() obj.data.url = self.item_url.text() obj.data.chief_referee = self.item_refery.text() obj.data.secretary = self.item_secretary.text() obj.data.start_datetime = start_date obj.data.end_datetime = end_date t = RaceType.get_by_name(self.item_type.currentText()) if t is not None: obj.data.race_type = t obj.data.relay_leg_count = self.item_relay_legs.value() obj.set_setting('system_zero_time', (start_date.hour, start_date.minute, 0)) ResultCalculation(race()).process_results() GlobalAccess().get_main_window().set_title()
def group_double_clicked(index): try: if index.row() < len(race().groups): dialog = GroupEditDialog(race().groups[index.row()]) dialog.exec_() GlobalAccess().get_main_window().refresh() except Exception as e: logging.error(str(e))
def __init__(self): super().__init__(GlobalAccess().get_main_window()) self.url_regex = re.compile( r'^(?:http|ftp)s?://' # http:// or https:// r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain... r'localhost|' # localhost... r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip r'(?::\d+)?' # optional port r'(?:/?|[/?]\S+)$', re.IGNORECASE)
def keyPressEvent(self, e): key_numbers = [i for i in range(48, 58)] key = e.key() try: if key in key_numbers: self.EntryTable.set_start_group(NumberClicker().click( key_numbers.index(key))) GlobalAccess().get_main_window().refresh() except Exception as e: print(str(e))
def double_clicked(self, index): try: logging.debug('Clicked on ' + str(index.row())) if index.row() < len(race().results): dialog = ResultEditDialog(race().results[index.row()]) dialog.exec_() GlobalAccess().get_main_window().refresh() # self.selectRow(index.row()+1) except Exception as e: logging.error(str(e))
def __init__(self, result, is_new=False): super().__init__(GlobalAccess().get_main_window()) assert (isinstance(result, Result)) self.current_object = result self.is_new = is_new self.time_format = 'hh:mm:ss' time_accuracy = race().get_setting('time_accuracy', 0) if time_accuracy: self.time_format = 'hh:mm:ss.zzz'
def __init__(self, person, is_new=False): super().__init__(GlobalAccess().get_main_window()) self.is_ok = {} assert (isinstance(person, Person)) self.current_object = person self.is_new = is_new self.time_format = 'hh:mm:ss' time_accuracy = race().get_setting('time_accuracy', 0) if time_accuracy: self.time_format = 'hh:mm:ss.zzz'
def guess_courses_for_groups(): obj = race() for cur_group in obj.groups: assert isinstance(cur_group, Group) if not cur_group.course or True: # TODO check empty courses after export! for cur_course in obj.courses: course_name = cur_course.name group_name = cur_group.name if str(course_name).find(group_name) > -1: cur_group.course = cur_course logging.debug('Connecting: group ' + group_name + ' with course ' + course_name) break GlobalAccess().get_main_window().refresh()
def __init__(self): super().__init__(GlobalAccess().get_main_window()) self.setWindowTitle(_('Clone relay legs')) self.setWindowIcon(QIcon(config.ICON)) self.setSizeGripEnabled(False) self.setModal(True) self.layout = QFormLayout(self) self.min_bib = QSpinBox() self.min_bib.setMaximum(10000000) self.min_bib.setValue(1001) self.layout.addRow(QLabel(_('Minimal bib')), self.min_bib) self.max_bib = QSpinBox() self.max_bib.setMaximum(10000000) self.max_bib.setValue(2999) self.layout.addRow(QLabel(_('Maximal bib')), self.max_bib) self.increment = QSpinBox() self.increment.setMaximum(10000000) self.increment.setValue(2000) self.layout.addRow(QLabel(_('Increment')), self.increment) def cancel_changes(): self.close() def apply_changes(): try: self.apply_changes_impl() except Exception as e: logging.error(str(e)) logging.exception(e) self.close() button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_ok = button_box.button(QDialogButtonBox.Ok) self.button_ok.setText(_('OK')) self.button_ok.clicked.connect(apply_changes) self.button_cancel = button_box.button(QDialogButtonBox.Cancel) self.button_cancel.setText(_('Cancel')) self.button_cancel.clicked.connect(cancel_changes) self.layout.addRow(button_box) self.show()
def apply_changes_impl(self): obj = race() obj.set_setting('handicap_mode', self.handicap_mode.isChecked()) obj.set_setting('handicap_start', time_to_otime(self.zero_time.time()).to_msec()) obj.set_setting('handicap_max_gap', time_to_otime(self.max_gap.time()).to_msec()) obj.set_setting('handicap_second_start', time_to_otime(self.second_time.time()).to_msec()) obj.set_setting('handicap_interval', time_to_otime(self.interval_time.time()).to_msec()) obj.set_setting('handicap_dsq_offset', time_to_otime(self.dsq_offset.time()).to_msec()) if obj.get_setting('handicap_mode', True): handicap_start_time() else: reverse_start_time() GlobalAccess().get_main_window().refresh()
def apply_changes_impl(self): number = self.item_number.value() if not number: return obj = race() is_course = self.item_is_course.isChecked() if is_course: courses = obj.courses for course in courses: controls = [] for i, control in enumerate(course.controls): if str(number) == control.code: if i < len(course.controls) - 1: course.controls[i + 1].length += control.length logging.info('Del {} from {}'.format( number, course.name)) else: controls.append(control) course.controls = controls is_result = self.item_is_result.isChecked() if is_result: results = obj.results for result in results: splits = [] for split in result.splits: if str(number) == str(split.code): logging.info('Del {} from {} {}'.format( number, result.card_number, split.time)) else: splits.append(split) result.splits = splits obj.clear_results() ResultChecker.check_all() ResultCalculation(obj).process_results() RaceSplits(obj).generate() ScoreCalculation(obj).calculate_scores() GlobalAccess().get_main_window().refresh()
def apply_changes_impl(self): course = self.current_object if self.is_new: race().courses.insert(0, course) if course.name != self.item_name.text(): course.name = self.item_name.text() if course.length != self.item_length.value(): course.length = self.item_length.value() if course.climb != self.item_climb.value(): course.climb = self.item_climb.value() text = self.item_controls.toPlainText() course.controls.clear() for i in text.split('\n'): control = CourseControl() if i is None or len(i) == 0: continue control.code = i.split()[0] if len(i.split()) > 1: try: control.length = int(i.split()[1]) except Exception as e: logging.error(str(e)) control.length = 0 course.controls.append(control) obj = race() ResultChecker.check_all() ResultCalculation(obj).process_results() RaceSplits(obj).generate() ScoreCalculation(obj).calculate_scores() GlobalAccess().get_main_window().refresh() Teamwork().send(course.to_dict())
def __init__(self): super().__init__(GlobalAccess().get_main_window()) self.time_format = 'hh:mm:ss'
def __init__(self, table=None): super().__init__(GlobalAccess().get_main_window()) if table is not None: self.table = table
def __init__(self, organization, is_new=False): super().__init__(GlobalAccess().get_main_window()) assert (isinstance(organization, Organization)) self.current_object = organization self.is_new = is_new
def __init__(self): super().__init__(GlobalAccess().get_main_window())
def __init__(self, text=''): super().__init__(GlobalAccess().get_main_window()) self.bib = 0 self.text = text self.person = None
def __init__(self): super().__init__(GlobalAccess().get_main_window()) self.time_format = 'hh:mm:ss' self.setWindowTitle(_('Handicap start time')) self.setWindowIcon(QIcon(config.ICON)) self.setSizeGripEnabled(False) self.setModal(True) self.layout = QFormLayout(self) self.handicap_mode = QRadioButton(_('Handicap mode')) self.reverse_mode = QRadioButton(_('Reverse mode')) self.layout.addRow(self.handicap_mode) self.layout.addRow(self.reverse_mode) self.zero_time_label = QLabel(_('Start time')) self.zero_time = QTimeEdit() self.zero_time.setDisplayFormat(self.time_format) self.layout.addRow(self.zero_time_label, self.zero_time) self.max_gap_label = QLabel(_('Max gap from leader')) self.max_gap = QTimeEdit() self.max_gap.setDisplayFormat(self.time_format) self.layout.addRow(self.max_gap_label, self.max_gap) self.second_start_time_label = QLabel(_('Start time for 2 group')) self.second_time = QTimeEdit() self.second_time.setDisplayFormat(self.time_format) self.layout.addRow(self.second_start_time_label, self.second_time) self.interval_time_label = QLabel(_('Start interval')) self.interval_time = QTimeEdit() self.interval_time.setDisplayFormat(self.time_format) self.layout.addRow(self.interval_time_label, self.interval_time) self.dsq_offset_label = QLabel(_('Offset after DSQ')) self.dsq_offset = QTimeEdit() self.dsq_offset.setDisplayFormat(self.time_format) self.layout.addRow(self.dsq_offset_label, self.dsq_offset) def mode_changed(): status = self.handicap_mode.isChecked() self.max_gap.setEnabled(status) self.second_time.setEnabled(status) self.dsq_offset.setDisabled(status) self.handicap_mode.toggled.connect(mode_changed) self.reverse_mode.toggled.connect(mode_changed) def cancel_changes(): self.close() def apply_changes(): try: self.apply_changes_impl() except Exception as e: logging.error(str(e)) logging.exception(e) self.close() button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_ok = button_box.button(QDialogButtonBox.Ok) self.button_ok.setText(_('OK')) self.button_ok.clicked.connect(apply_changes) self.button_cancel = button_box.button(QDialogButtonBox.Cancel) self.button_cancel.setText(_('Cancel')) self.button_cancel.clicked.connect(cancel_changes) self.layout.addRow(button_box) self.set_values() self.show()
def set_next_relay_number_to_person(person): assert isinstance(person, Person) person.bib = get_next_relay_number_setting() set_next_relay_number(get_next_relay_number(person.bib)) GlobalAccess().get_main_window().refresh()
def __init__(self): self.argv = sys.argv self.app = QApplication(self.argv) self.main_window = MainWindow(self.argv) GlobalAccess().set_app(self)
def __init__(self, table=None): super().__init__(GlobalAccess().get_main_window()) if table is not None: assert (isinstance(table, QTableView)) self.table = table
def __init__(self, races, current_race=0): super().__init__(GlobalAccess().get_main_window()) self.races = races self.current_race = current_race
def apply_changes_impl(self): change_start_time(self.time_add.isChecked(), time_to_otime(self.time_value.time())) GlobalAccess().get_main_window().refresh()
def __init__(self): super().__init__(GlobalAccess().get_main_window()) self.setWindowModality(QtCore.Qt.WindowModal) self.resize(319, 462) self.setSizeGripEnabled(False) self.setModal(True) self.layout = QVBoxLayout(self) self.grid_layout = QtWidgets.QGridLayout() widget = QWidget(self) widget.setLayout(self.grid_layout) self.value_group_box = QtWidgets.QGroupBox(self) self.grid_layout_child = QtWidgets.QGridLayout(self.value_group_box) self.id_label = QtWidgets.QLabel(self.value_group_box) self.grid_layout_child.addWidget(self.id_label, 0, 0, 1, 1) self.id_layout = QtWidgets.QVBoxLayout() self.bib_radio_button = QtWidgets.QRadioButton(self.value_group_box) self.bib_radio_button.setChecked(True) self.id_layout.addWidget(self.bib_radio_button) self.name_radio_button = QtWidgets.QRadioButton(self.value_group_box) self.id_layout.addWidget(self.name_radio_button) self.grid_layout_child.addLayout(self.id_layout, 0, 1, 1, 1) self.value_label = QtWidgets.QLabel(self.value_group_box) self.grid_layout_child.addWidget(self.value_label, 1, 0, 1, 1) self.value_combo_box = QtWidgets.QComboBox(self.value_group_box) self.value_combo_box.addItems(get_value_options()) self.grid_layout_child.addWidget(self.value_combo_box, 1, 1, 1, 1) self.id_label.raise_() self.bib_radio_button.raise_() self.value_label.raise_() self.value_combo_box.raise_() self.grid_layout.addWidget(self.value_group_box, 0, 0, 1, 1) self.separator_group_box = QtWidgets.QGroupBox(self) self.separator_grid_layout = QtWidgets.QGridLayout( self.separator_group_box) self.space_radio_button = QtWidgets.QRadioButton( self.separator_group_box) self.separator_grid_layout.addWidget(self.space_radio_button, 0, 0, 1, 1) self.tab_radio_button = QtWidgets.QRadioButton( self.separator_group_box) self.tab_radio_button.setChecked(True) self.separator_grid_layout.addWidget(self.tab_radio_button, 1, 0, 1, 1) self.semicolon_radio_button = QtWidgets.QRadioButton( self.separator_group_box) self.separator_grid_layout.addWidget(self.semicolon_radio_button, 2, 0, 1, 1) self.custom_layout = QtWidgets.QHBoxLayout() self.custom_radio_button = QtWidgets.QRadioButton( self.separator_group_box) self.custom_layout.addWidget(self.custom_radio_button) self.custom_edit = QtWidgets.QLineEdit(self.separator_group_box) self.custom_layout.addWidget(self.custom_edit) self.separator_grid_layout.addLayout(self.custom_layout, 3, 0, 1, 1) self.grid_layout.addWidget(self.separator_group_box, 0, 1, 1, 1) self.options_group_box = QtWidgets.QGroupBox(self) self.options_grid_layout = QtWidgets.QGridLayout( self.options_group_box) self.option_creating_new_result_checkbox = QCheckBox( _("Create new result, if doesn't exist")) self.options_grid_layout.addWidget( self.option_creating_new_result_checkbox, 0, 0, 1, 1) self.grid_layout.addWidget(self.options_group_box, 1, 0, 1, 2) self.text_edit = QtWidgets.QPlainTextEdit(self) self.grid_layout.addWidget(self.text_edit, 2, 0, 1, 2) button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_ok = button_box.button(QDialogButtonBox.Ok) self.button_ok.setText(_('OK')) self.button_ok.clicked.connect(self.accept) self.button_cancel = button_box.button(QDialogButtonBox.Cancel) self.button_cancel.setText(_('Cancel')) self.button_cancel.clicked.connect(self.reject) stf_button = button_box.addButton(_('Save to file'), QDialogButtonBox.ActionRole) stf_button.clicked.connect(self.save_to_file) stf_button.setDisabled(True) lff_button = button_box.addButton(_('Load from file'), QDialogButtonBox.ActionRole) lff_button.clicked.connect(self.load_from_file) lff_button.setDisabled(True) self.layout.addWidget(widget) self.layout.addWidget(button_box) self.retranslate_ui(self)