67 lines
2.7 KiB
Python
67 lines
2.7 KiB
Python
"""! @brief Defines the model class to handle type of client."""
|
|
##
|
|
# @file BTypeModel.py
|
|
#
|
|
# @brief Defines the BTypeModel class.
|
|
#
|
|
# @section description_businesstypemodel Description
|
|
# Defines the model class to handle CRUD operations on customers types.
|
|
# - BTypeModel (Model class)
|
|
#
|
|
# @section libraries_businesstypemodel Libraries/Modules
|
|
# - <a href="https://doc.qt.io/qtforpython-6/PySide6/QtCore/QAbstractListModel.html">QAbstractListModel</a> PySid6 core Class
|
|
# - Provides an abstract model that can be subclassed to create one-dimensional list models.
|
|
# - <a href="https://doc.qt.io/qtforpython-6/PySide6/QtCore/QModelIndex.html">QModelIndex</a> PySid6 core Class
|
|
# - Used to locate data in a data model.
|
|
# - <a href="https://doc.qt.io/qtforpython-6/PySide6/QtCore/Slot.html">Slot</a> PySide6 function
|
|
# - A function that is called in response to a particular signal.
|
|
# - <a href="https://doc.qt.io/qtforpython-6/PySide6/QtCore/Qt.html">Qt</a> PySid6 core Class
|
|
# - A namespace contains miscellaneous identifiers used throughout the Qt library.
|
|
# - <a href="">BTypeDAO</a> Local class
|
|
# - Defines the low-lever DAO class to handle CRUD operations on customers types.
|
|
#
|
|
# @section notes_businesstypemodel Notes
|
|
# - None.
|
|
#
|
|
# @section todo_businesstypemodel TODO
|
|
# - None.
|
|
#
|
|
# @section author_businesstypemodel Author(s)
|
|
# - Created by Linuxero on 03/14/2025.
|
|
# - Modified by Linuxero on 03/14/2025.
|
|
#
|
|
# Copyright (c) 2025 Schnaxero. All rights reserved.
|
|
|
|
from PySide6.QtCore import QAbstractListModel, Qt, QModelIndex
|
|
from .BTypeDAO import BTypeDAO
|
|
|
|
|
|
class BTypeModel(QAbstractListModel):
|
|
"""! The BTypeModel class.
|
|
Defines a model class utilized to handle data.
|
|
Inherits from QAbstractListModel
|
|
Handles the customers types data operations.
|
|
"""
|
|
def __init__(self):
|
|
"""! The AddressModel class initializer.
|
|
"""
|
|
super().__init__()
|
|
self.__btype_data = BTypeDAO().getBType()
|
|
|
|
def rowCount(self, parent = QModelIndex()):
|
|
"""! Returns the number of rows under the given parent.
|
|
Ref. <a href="https://doc.qt.io/qtforpython-6/PySide6/QtCore/QAbstractItemModel.html#PySide6.QtCore.QAbstractItemModel.rowCount">rowCount()</a>
|
|
"""
|
|
return len(self.__btype_data)
|
|
|
|
def data(self, index, role = Qt.DisplayRole):
|
|
"""! Returns the data stored under the given role for the item referred to by the index.
|
|
Ref. <a href="https://doc.qt.io/qtforpython-6/PySide6/QtCore/QAbstractItemModel.html#PySide6.QtCore.QAbstractItemModel.data">data()</a>
|
|
"""
|
|
row = index.row()
|
|
if role == Qt.DisplayRole:
|
|
data= self.__btype_data[row][1]
|
|
return data
|
|
return None
|
|
|