File indexing completed on 2024-05-19 05:35:37
0001 # SPDX-License-Identifier: GPL-3.0-or-later 0002 # SPDX-FileCopyrightText: 2021 Anupam Basak <anupam.basak27@gmail.com> 0003 0004 import typing 0005 0006 import PySide2 0007 from PySide2.QtCore import QAbstractListModel, Qt, Slot 0008 from PicoWizard.modules.timezone.timezoneslist import TIMEZONES_LIST 0009 0010 0011 class TimezoneModel(QAbstractListModel): 0012 TzRole = Qt.UserRole + 1 0013 0014 def __init__(self, parent=None): 0015 super().__init__(parent) 0016 0017 def roleNames(self) -> typing.Dict: 0018 roles = dict() 0019 roles[self.TzRole] = b'tz' 0020 0021 return roles 0022 0023 def data(self, index: PySide2.QtCore.QModelIndex, role: int) -> typing.Any: 0024 if role == self.TzRole: 0025 return TIMEZONES_LIST[index.row()] 0026 0027 def rowCount(self, parent: PySide2.QtCore.QModelIndex) -> int: 0028 return len(TIMEZONES_LIST)