Änderungen letzt Woche
This commit is contained in:
94
lib/DB/ObjectModel.py
Normal file
94
lib/DB/ObjectModel.py
Normal file
@@ -0,0 +1,94 @@
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, Signal
|
||||
from .ObjectDAO import ObjectDAO
|
||||
from ..PyqcrmFlags import PyqcrmFlags, PyqcrmAppliEmpyFlags
|
||||
from ..ConfigLoader import ConfigLoader
|
||||
import re
|
||||
import json
|
||||
|
||||
class ObjectModel(QAbstractTableModel):
|
||||
__data = None
|
||||
__object_dao = None
|
||||
__visible_index = None
|
||||
__visible_columns = None
|
||||
__col_name = ""
|
||||
__employee_dao = None
|
||||
__col_skip = 2
|
||||
__everyone = True
|
||||
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.__object_dao = ObjectDAO()
|
||||
self.__object_dao.newObjectAdded.connect(self.__refreshView)
|
||||
self.__conf = ConfigLoader().getConfig()
|
||||
self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY']
|
||||
#self.__getData()
|
||||
|
||||
@Slot(dict, list, bool)
|
||||
def addObject(self, new_object, new_objcontact):
|
||||
print(new_object)
|
||||
|
||||
print(new_objcontact)
|
||||
|
||||
|
||||
self.__object_dao.addObject(new_object, new_objcontact, self.__key)
|
||||
|
||||
# @Slot(str)
|
||||
# def viewCriterion(self, criterion, processed = False, fired = False):
|
||||
# self.__getData(criterion, processed, fired)
|
||||
|
||||
@Slot()
|
||||
def __refreshView(self):
|
||||
self.__getData()
|
||||
|
||||
# def __getData(self, criterion = "Alle", processed = False, fired = False, every_state = True):
|
||||
# self.beginResetModel()
|
||||
# rows, self.__visible_columns = self.__employee_dao.getEmployees(self.__key, criterion, processed, fired, every_state)
|
||||
# self.__data = rows
|
||||
# self.endResetModel()
|
||||
|
||||
# def rowCount(self, parent= QModelIndex()):
|
||||
# return len (self.__data)
|
||||
|
||||
# def columnCount(self, parent= QModelIndex()):
|
||||
# return len(self.__visible_columns) - self.__col_skip
|
||||
|
||||
# @Slot(str, bool, bool, bool)
|
||||
# def viewCriterion(self, criterion, processed, fired, every_state):
|
||||
# self.__everyone = True if criterion == 'Alle' else False
|
||||
# if self.__everyone and criterion != "Alle":
|
||||
# self.__col_skip = 2
|
||||
# else:
|
||||
# self.__col_skip = 2
|
||||
# self.__getData(criterion, processed, fired, every_state)
|
||||
|
||||
# def data(self, index, role= Qt.DisplayRole):
|
||||
# if role == Qt.DisplayRole:
|
||||
# row = self.__data[index.row()]
|
||||
# applicant_col = index.column() + self.__col_skip
|
||||
# tr = row[applicant_col] #if type(row[index.column() + 2]) is str else str(row[index.column() + 2], "utf-8")
|
||||
# if applicant_col == 2 and self.__everyone:
|
||||
# tr = 'Ja' if tr == 1 else 'Nein'
|
||||
# else:
|
||||
# tr = re.sub("Keine Angabe ","", tr)
|
||||
# #print(f"Data: {tr}")
|
||||
# # return row[index.column() + 2]
|
||||
# return tr
|
||||
# return None
|
||||
|
||||
# def headerData(self, section, orientation, role = Qt.DisplayRole):
|
||||
# if orientation == Qt.Horizontal and role == Qt.DisplayRole:
|
||||
# self.__col_name = self.__visible_columns[section + self.__col_skip]
|
||||
# return self.__col_name
|
||||
# return super().headerData(section, orientation, role)
|
||||
|
||||
# @Slot(int)
|
||||
# def onRowClicked(self, row):
|
||||
# #print(self.__data)
|
||||
# print(f"Selected table row: {row}, corresponding DB ID: {self.__data[row][0]}")
|
||||
# #if not self.__employee_dict['employee'] or self.__data[row][0] != self.__employee_dict['employee']['id']:
|
||||
# #self.__employee = self.__employee_dao.getEmployee(self.__data[row][0], self.__key)
|
||||
# #print(self.__business)
|
||||
# #self.__getEmployeeInfo()
|
||||
# # self.__getContactInfo()
|
||||
# # print(self.__business_dict)
|
||||
Reference in New Issue
Block a user