Employee/Applicant GUI and DB
This commit is contained in:
@@ -21,21 +21,22 @@ class EmployeeModel(QAbstractTableModel):
|
||||
self.__getData()
|
||||
|
||||
@Slot(dict, bool)
|
||||
def addEmployee(self, new_employee, employee = False):
|
||||
print(new_employee)
|
||||
self.__employee_dao.addEmployee(new_employee, self.__key, employee)
|
||||
def addEmployee(self, new_employee, applicant = True):
|
||||
new_employee['worklicense'] = int(new_employee['worklicense'])
|
||||
new_employee['residencetype'] = int(new_employee['residencetype'])
|
||||
self.__employee_dao.addEmployee(new_employee, self.__key, applicant)
|
||||
|
||||
@Slot(str)
|
||||
def viewCriterion(self, criterion):
|
||||
self.__getData(criterion)
|
||||
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):
|
||||
def __getData(self, criterion = "Alle", processed = False, fired = False):
|
||||
self.beginResetModel()
|
||||
rows, self.__visible_columns = self.__employee_dao.getEmployees(self.__key, criterion, 0, processed)
|
||||
rows, self.__visible_columns = self.__employee_dao.getEmployees(self.__key, criterion, processed, fired)
|
||||
self.__data = rows
|
||||
self.endResetModel()
|
||||
|
||||
@@ -45,14 +46,32 @@ class EmployeeModel(QAbstractTableModel):
|
||||
def columnCount(self, parent= QModelIndex()):
|
||||
return len(self.__visible_columns) - 2
|
||||
|
||||
@Slot(str, bool, bool)
|
||||
def viewCriterion(self, criterion, processed, fired):
|
||||
self.__getData(criterion, processed, fired)
|
||||
|
||||
def data(self, index, role= Qt.DisplayRole):
|
||||
if role == Qt.DisplayRole:
|
||||
row = self.__data[index.row()]
|
||||
return row[index.column() + 2]
|
||||
tr = row[index.column() + 2] #if type(row[index.column() + 2]) is str else str(row[index.column() + 2], "utf-8")
|
||||
#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:
|
||||
def headerData(self, section, orientation, role = Qt.DisplayRole):
|
||||
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
|
||||
self.__col_name = self.__visible_columns[section + 2]
|
||||
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