add Btype
This commit is contained in:
@@ -189,6 +189,8 @@ ColumnLayout
|
|||||||
id: typeid
|
id: typeid
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
editable: false
|
editable: false
|
||||||
|
model: btm
|
||||||
|
textRole: "display"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ class AddressModel(QAbstractListModel):
|
|||||||
def data(self, index, role = Qt.DisplayRole):
|
def data(self, index, role = Qt.DisplayRole):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
data= self.__address_data[row][2]
|
data = self.__address_data[row][2]
|
||||||
return data
|
return data
|
||||||
elif role == PyqcrmDataRoles.CITY_ROLE:
|
elif role == PyqcrmDataRoles.CITY_ROLE:
|
||||||
data= self.__address_data[row][3]
|
data = self.__address_data[row][3]
|
||||||
return data
|
return data
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
12
lib/DB/BTypeDAO.py
Normal file
12
lib/DB/BTypeDAO.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from .DbManager import DbManager
|
||||||
|
|
||||||
|
|
||||||
|
class BTypeDAO:
|
||||||
|
def __init__(self):
|
||||||
|
self.__con = DbManager().getConnection()
|
||||||
|
self.__cur = self.__con.cursor()
|
||||||
|
|
||||||
|
def getBType(self):
|
||||||
|
self.__cur.callproc("getBType")
|
||||||
|
data = self.__cur.fetchall()
|
||||||
|
return(data)
|
||||||
19
lib/DB/BTypeModel.py
Normal file
19
lib/DB/BTypeModel.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
from PySide6.QtCore import QAbstractListModel, Qt, QModelIndex
|
||||||
|
from .BTypeDAO import BTypeDAO
|
||||||
|
|
||||||
|
|
||||||
|
class BTypeModel(QAbstractListModel):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.__btype_data = BTypeDAO().getBType()
|
||||||
|
|
||||||
|
def rowCount(self, parent = QModelIndex()):
|
||||||
|
return len(self.__btype_data)
|
||||||
|
|
||||||
|
def data(self, index, role = Qt.DisplayRole):
|
||||||
|
row = index.row()
|
||||||
|
if role == Qt.DisplayRole:
|
||||||
|
data= self.__btype_data[row][1]
|
||||||
|
return data
|
||||||
|
return None
|
||||||
|
|
||||||
10
main.py
10
main.py
@@ -1,6 +1,6 @@
|
|||||||
# This Python file uses the following encoding: utf-8
|
# This Python file uses the following encoding: utf-8
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
# from pathlib import Path
|
||||||
from PySide6.QtGui import QGuiApplication
|
from PySide6.QtGui import QGuiApplication
|
||||||
from PySide6.QtQml import QQmlApplicationEngine
|
from PySide6.QtQml import QQmlApplicationEngine
|
||||||
#from PySide6.QtCore import QResource
|
#from PySide6.QtCore import QResource
|
||||||
@@ -11,6 +11,7 @@ import rc_qml
|
|||||||
from lib.DB.DbManager import DbManager
|
from lib.DB.DbManager import DbManager
|
||||||
from lib.DB.UserManager import UserManager
|
from lib.DB.UserManager import UserManager
|
||||||
from lib.DB.AddressModel import AddressModel
|
from lib.DB.AddressModel import AddressModel
|
||||||
|
from lib.DB.BTypeModel import BTypeModel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -29,11 +30,12 @@ from lib.DB.AddressModel import AddressModel
|
|||||||
bad_config = False
|
bad_config = False
|
||||||
am = None
|
am = None
|
||||||
bm = None
|
bm = None
|
||||||
|
btm = None
|
||||||
user = None
|
user = None
|
||||||
|
|
||||||
def initializeProgram():
|
def initializeProgram():
|
||||||
# print(f"In {__file__} file, initializeProgram()")
|
# print(f"In {__file__} file, initializeProgram()")
|
||||||
global am, bad_config, bm, user
|
global am, bad_config, bm, user, btm
|
||||||
if not bad_config:
|
if not bad_config:
|
||||||
dbconf = config.getConfig()['database']
|
dbconf = config.getConfig()['database']
|
||||||
DbManager(dbconf)
|
DbManager(dbconf)
|
||||||
@@ -41,15 +43,17 @@ def initializeProgram():
|
|||||||
bm = BusinessModel()
|
bm = BusinessModel()
|
||||||
user = UserManager()
|
user = UserManager()
|
||||||
am = AddressModel()
|
am = AddressModel()
|
||||||
|
btm = BTypeModel()
|
||||||
|
|
||||||
publishContext()
|
publishContext()
|
||||||
|
|
||||||
def publishContext():
|
def publishContext():
|
||||||
# print(f"In {__file__} file, publishContext()")
|
# print(f"In {__file__} file, publishContext()")
|
||||||
global engine, am, bad_config, bm, user
|
global engine, am, bad_config, bm, user, btm
|
||||||
engine.rootContext().setContextProperty("loggedin_user", user)
|
engine.rootContext().setContextProperty("loggedin_user", user)
|
||||||
engine.rootContext().setContextProperty("bm", bm)
|
engine.rootContext().setContextProperty("bm", bm)
|
||||||
engine.rootContext().setContextProperty("am", am)
|
engine.rootContext().setContextProperty("am", am)
|
||||||
|
engine.rootContext().setContextProperty("btm", btm)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
#QResource.registerResource("rc_qml.py")
|
#QResource.registerResource("rc_qml.py")
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
"lib/DB/BusinessDAO.py",
|
"lib/DB/BusinessDAO.py",
|
||||||
"lib/DB/AddressModel.py",
|
"lib/DB/AddressModel.py",
|
||||||
"lib/DB/AddressDAO.py",
|
"lib/DB/AddressDAO.py",
|
||||||
"lib/PyqcrmDataRoles.py"
|
"lib/PyqcrmDataRoles.py",
|
||||||
|
"lib/DB/BTypeModel.py",
|
||||||
|
"lib/DB/BTypeDAO.py"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user