class CEventsListDialog(CDialogBase, Ui_eventsListDialog): def __init__(self, parent, eventIdList): CDialogBase.__init__(self, parent) self.setupUi(self) cols = [ CDateCol(u'Назначен', ['setDate'], 10), CDateCol(u'Выполнен', ['execDate'], 10), CRefBookCol(u'Тип', ['eventType_id'], 'EventType', 40), CRefBookCol(u'Врач', ['execPerson_id'], 'vrbPersonWithSpeciality', 15), CRefBookCol(u'Результат', ['result_id'], 'rbResult', 40), ] self.setup(cols, 'Event', ['id'], eventIdList, parent.recSelectClient, parent.recSelectCorrect) self.setWindowTitleEx(u'Логический контроль - события') def setup(self, cols, tableName, order, eventIdList, recSelectClient = u'', recSelectCorrect = u''): self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowCloseButtonHint) self.booleanRowEnabled = False self.booleanCloseCorrect = False self.props = {} self.order = order self.model = CTableModel(self, cols, tableName) self.model.setIdList(eventIdList) self.tblListWidget.setModel(self.model) if eventIdList: self.tblListWidget.selectRow(0) self.tblListWidget.setFocus(QtCore.Qt.OtherFocusReason) self.lblClientInfo.setText(recSelectClient) self.lblSelectInfo.setText(recSelectCorrect) QtCore.QObject.connect(self.tblListWidget.horizontalHeader(), QtCore.SIGNAL('sectionClicked(int)'), self.setSort) def setCurrentItemId(self, itemId): self.tblListWidget.setCurrentItemId(itemId) def currentItemId(self): return self.tblListWidget.currentItemId() def renewListAndSetTo(self, itemId=None): idList = self.select(self.props) self.tblListWidget.setIdList(idList, itemId) self.lblClientInfo.setText(u'всего: %d' % len(idList)) self.lblSelectInfo.setText(u'всего: %d' % len(idList)) @QtCore.pyqtSlot(QtCore.QModelIndex) def on_tblListWidget_doubleClicked(self, index): self.booleanRowEnabled = False event_id = self.currentItemId() if event_id: self.booleanRowEnabled = self.editEvent(event_id) @QtCore.pyqtSlot() def on_btnClose_clicked(self): self.close() @QtCore.pyqtSlot() def on_btnCloseCorrect_clicked(self): self.booleanCloseCorrect = True self.close() # def getReportHeader(self): # return self.objectName() # # # def contentToHTML(self): # reportHeader = self.getReportHeader() # self.tblListWidget.setReportHeader(reportHeader) # reportDescription = u'' # self.tblListWidget.setReportDescription(reportDescription) # return self.tblListWidget.contentToHTML() def setSort(self, col): name = self.model.cols()[col].fields()[0] self.order = name header=self.tblListWidget.horizontalHeader() header.setSortIndicatorShown(True) header.setSortIndicator(col, QtCore.Qt.AscendingOrder) self.renewListAndSetTo(self.currentItemId()) def editEvent(self, eventId): formClass = getEventFormClass(eventId) dialog = formClass(self) dialog.load(eventId) return dialog.exec_()
class CMenuDialog(CDialogBase, Ui_MenuDialog): def __init__(self, parent, cols, tableName, order, forSelect=False, filterClass=None): CDialogBase.__init__(self, parent) self.setupUi(self) self.setup(cols, tableName, order, forSelect, filterClass) def setup(self, cols, tableName, order, forSelect=False, filterClass=None): self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowCloseButtonHint) self.forSelect = forSelect self.filterClass = filterClass self.props = {} self.order = order self.model = CTableModel(self, cols, tableName) idList = self.select(self.props) self.model.setIdList(idList) self.tblItems.setModel(self.model) if idList: self.tblItems.selectRow(0) self.btnEdit.setDefault(not self.forSelect) self.tblItems.setFocus(QtCore.Qt.OtherFocusReason) self.label.setText(u'всего: %d' % len(idList)) QtCore.QObject.connect(self.tblItems.horizontalHeader(), QtCore.SIGNAL('sectionClicked(int)'), self.setSort) def select(self, props): table = self.model.table() return QtGui.qApp.db.getIdList(table.name(), 'id', '', self.order) def selectItem(self): return self.exec_() def setCurrentItemId(self, itemId): self.tblItems.setCurrentItemId(itemId) def currentItemId(self): return self.tblItems.currentItemId() def renewListAndSetTo(self, itemId=None): idList = self.select(self.props) self.tblItems.setIdList(idList, itemId) self.label.setText(u'всего: %d' % len(idList)) @QtCore.pyqtSlot(QtCore.QModelIndex) def on_tblItems_doubleClicked(self, index): self.selected = True self.close() @QtCore.pyqtSlot() def on_btnSelected_clicked(self): self.selected = True self.close() @QtCore.pyqtSlot() def on_btnEdit_clicked(self): itemId = self.currentItemId() if itemId: dialog = self.getItemEditor() dialog.load(itemId) if dialog.exec_(): itemId = dialog.itemId() self.renewListAndSetTo(itemId) def getReportHeader(self): return self.objectName() def getFilterAsText(self): return u'' def contentToHTML(self): reportHeader = self.getReportHeader() self.tblItems.setReportHeader(reportHeader) reportDescription = self.getFilterAsText() self.tblItems.setReportDescription(reportDescription) return self.tblItems.contentToHTML() @QtCore.pyqtSlot() def on_btnPrint_clicked(self): html = self.contentToHTML() view = CReportViewDialog(self) view.setText(html) view.exec_() def setSort(self, col): name = self.model.cols()[col].fields()[0] self.order = name header = self.tblItems.horizontalHeader() header.setSortIndicatorShown(True) header.setSortIndicator(col, QtCore.Qt.AscendingOrder) self.renewListAndSetTo(self.currentItemId())
class CCheckEnteredOpenEvents(CDialogBase, Ui_CheckEnteredOpenEventsDialog): def __init__(self, parent, eventIdList=None, clientId=None): if not eventIdList: eventIdList = [] CDialogBase.__init__(self, parent) self.setupUi(self) self.btnResult = 0 self.resultEventId = None self.eventIdList = eventIdList self.clientId = clientId self.setup([ CDateTimeFixedCol(u'Дата начала', ['setDate'], 10), CRefBookCol(u'Тип', ['eventType_id'], 'EventType', 40), CICDCol(u'МКБ', ['id'], 5, 'l'), CRefBookCol(u'Врач назначивший', ['setPerson_id'], 'vrbPersonWithSpeciality', 15), CRefBookCol(u'Врач выполнивший', ['execPerson_id'], 'vrbPersonWithSpeciality', 15), CEnumCol(u'Порядок', ['order'], [ u'', u'плановый', u'экстренный', u'самотёком', u'принудительный' ], 5), CTextCol(u'Примечания', ['note'], 6) ], 'Event', ['id']) self.setWindowTitleEx(u'Открытые события') def setup(self, cols, tableName, order): self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowCloseButtonHint) self.props = {} self.order = order self.model = CTableModel(self, cols, tableName) self.model.setIdList(self.eventIdList) self.tblOpenEvents.setModel(self.model) if self.eventIdList: self.tblOpenEvents.selectRow(0) if self.clientId: self.txtClientInfoEventsBrowser.setHtml( getClientBanner(self.clientId)) else: self.txtClientInfoEventsBrowser.setText('') QtCore.QObject.connect(self.tblOpenEvents.horizontalHeader(), QtCore.SIGNAL('sectionClicked(int)'), self.setSort) def currentItemId(self): return self.tblOpenEvents.currentItemId() def select(self): table = self.model.table() return QtGui.qApp.db.getIdList(table.name(), 'id', table['id'].inlist(self.eventIdList), self.order) def renewListAndSetTo(self, itemId=None): idList = self.select(self.props) self.tblOpenEvents.setIdList(idList, itemId) @QtCore.pyqtSlot() def on_btnClose_clicked(self): self.resultEventId = None self.btnResult = 0 self.close() @QtCore.pyqtSlot() def on_btnOpen_clicked(self): event_id = self.currentItemId() self.resultEventId = event_id if event_id else None self.btnResult = 2 self.close() @QtCore.pyqtSlot() def on_btnReverse_clicked(self): self.resultEventId = None self.btnResult = 1 self.close() @QtCore.pyqtSlot() def on_btnCreate_clicked(self): self.resultEventId = None self.btnResult = 3 self.close() def setSort(self, col): name = self.model.cols()[col].fields()[0] self.order = name header = self.tblOpenEvents.horizontalHeader() header.setSortIndicatorShown(True) header.setSortIndicator(col, QtCore.Qt.AscendingOrder) self.renewListAndSetTo(self.currentItemId())