add AddressModel, AddressDAO class

This commit is contained in:
2024-12-06 19:00:19 +01:00
parent 5865b33c1d
commit f4bd9c296a
8 changed files with 909 additions and 846 deletions

38
lib/DB/AddressModel.py Normal file
View File

@@ -0,0 +1,38 @@
from PySide6.QtCore import QAbstractListModel, Qt, Slot, QModelIndex
from .AddressDAO import AddressDAO
class AddressModel(QAbstractListModel):
def __init__(self):
super().__init__()
self.__address_data = AddressDAO().getAddressData()
def rowCount(self, parent = QModelIndex()):
return 10
def data(self, index, role = Qt.DisplayRole):
row = index.row()
if role == Qt.DisplayRole:
data= self.__address_data[row][2]
print(type(data))
return data
@Slot(bool, str)
def getAddresses(self, all, zipcode):
data = AddressDAO().getAddressData(all, zipcode)
return data