class CActionTypeDialog(CDialogBase, Ui_ActionTypeDialog): def __init__(self, parent, cols, tableName, order, forSelect=False, filterClass=None, idList=None): if not idList: idList = [] CDialogBase.__init__(self, parent) self.setupUi(self) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowCloseButtonHint) self.filterClass = filterClass self.props = {} self.order = order self.model = CTableModel(self, cols, tableName) self.model.setIdList(idList) self.tblActionType.setModel(self.model) if idList: self.tblActionType.selectRow(0) def selectItem(self): return self.exec_() def setCurrentItemId(self, itemId): self.tblActionType.setCurrentItemId(itemId) def currentItemId(self): return self.tblActionType.currentItemId() @QtCore.pyqtSlot(QtCore.QModelIndex) def on_tblListWidget_doubleClicked(self, index): pass
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 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_()
def setIdList(self, idList, realItemCount=None): CTableModel.setIdList(self, idList, realItemCount) self.enabled = [None] * len(idList)
class CMKBSubclass(CDialogBase, Ui_MKBSubclassEditorDialog): def __init__(self, parent): CDialogBase.__init__(self, parent) self.setupUi(self) self.order = ['id'] colsSubclass = [ CTextCol(u'Код', ['code'], 5), CTextCol(u'Субклассификация', ['name'], 30), ] self.modelSubclass = CTableModel(self, colsSubclass, 'rbMKBSubclass') colsSubclass_Item = [ CTextCol(u'пятый знак', ['code'], 5), CTextCol(u'Субклассификация', ['name'], 30), ] self.modelSubclass_Item = CTableModel(self, colsSubclass_Item, 'rbMKBSubclass_Item') self.select() self.btnDel_Item.setVisible(False) self.btnDel.setVisible(False) self.tblSubclass.addPopupDelRow() self.tblSubclass_Item.addPopupDelRow() def select(self): table = self.modelSubclass.table() idList = QtGui.qApp.db.getIdList(table.name(), 'id', '', self.order) self.modelSubclass.setIdList(idList) self.tblSubclass.setModel(self.modelSubclass) def select_Item(self): id = self.tblSubclass.currentItemId() cond = 'master_id=%s' % (str(id) if id else 'null') idList = QtGui.qApp.db.getIdList('rbMKBSubclass_Item', 'id', cond, 'id') self.modelSubclass_Item.setIdList(idList) self.tblSubclass_Item.setModel(self.modelSubclass_Item) def editSubclass(self, itemId): dialog = CItemEditorDialog(self, 'rbMKBSubclass') if itemId: dialog.load(itemId) dialog.exec_() def editSubclass_Item(self, master_id, itemId): dialog = CMKBSubclassItemEditorDialog(self, master_id) if itemId: dialog.load(itemId) dialog.exec_() @QtCore.pyqtSlot(QtCore.QModelIndex) def on_tblSubclass_activated(self, index): self.select_Item() @QtCore.pyqtSlot(QtCore.QModelIndex) def on_tblSubclass_clicked(self, index): self.select_Item() @QtCore.pyqtSlot() def on_btnClose_clicked(self): self.close() @QtCore.pyqtSlot() def on_btnAdd_clicked(self): self.editSubclass(None) self.select() self.select_Item() @QtCore.pyqtSlot() def on_btnEdit_clicked(self): id = self.tblSubclass.currentItemId() self.editSubclass(id) self.select() self.select_Item() @QtCore.pyqtSlot() def on_btnDel_clicked(self): self.select() self.select_Item() @QtCore.pyqtSlot() def on_btnAdd_Item_clicked(self): master_id = self.tblSubclass.currentItemId() self.editSubclass_Item(master_id, None) self.select_Item() @QtCore.pyqtSlot() def on_btnEdit_Item_clicked(self): master_id = self.tblSubclass.currentItemId() id = self.tblSubclass_Item.currentItemId() self.editSubclass_Item(master_id, id) self.select_Item() @QtCore.pyqtSlot() def on_btnDel_Item_clicked(self): self.select_Item()
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())