-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAllVisits.py
48 lines (36 loc) · 1.43 KB
/
AllVisits.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from PyQt5.QtCore import QAbstractTableModel, QVariant, Qt
import datetime
from database import VisitOperations, PatientOperations
from PyQt5 import QtCore
class AllVisitsModel(QtCore.QAbstractTableModel):
def __init__(self, parent, header, *args):
QAbstractTableModel.__init__(self, parent, *args)
results = VisitOperations.daily_visits()
self.mylist = results
self.header = header
def rowCount(self, parent):
if len(self.mylist) == 0:
return 0
return len(self.mylist)
def columnCount(self, parent):
if len(self.mylist) == 0:
return 0
return len(self.mylist[0])
def data(self, index, role):
# 5. populate data
if not index.isValid():
return None
if (role == Qt.DisplayRole):
value = self.mylist[index.row()][index.column()]
if isinstance(value, datetime.date):
date = PatientOperations.convert_to_jalali(value).strftime('%Y/%m/%d')
return date
if isinstance(value, int):
if index.column() == 4:
if value == 1:
return f"نامشخص"
return value
def headerData(self, col, orientation, role):
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
return self.header[col]
return None