def demo_queries(self): ''' return a list of queries to populate a demo database ''' year = QtCore.QDate.currentDate().year() date_ = QtCore.QDate(year, 1, 1) finish_year = year + 3 while date_.year() < finish_year: if date_.dayOfWeek() < 6: start = QtCore.QDateTime(date_, QtCore.QTime(13,0)) self.record.clearValues() self.record.setValue('diary_id', 1) self.record.setValue('start', start) self.record.setValue('finish', start.addSecs(3600)) self.record.setValue('etype', 'lunch') yield self.record.insert_query date_ = date_.addDays(1) # now an entry for an exam done on patient one yesterday # (or previous work day) self.record.clearValues() date_ = QtCore.QDate.currentDate().addDays(-1) while date_.dayOfWeek() > 6: date_ = date_.addDays(-1) start = QtCore.QDateTime(date_, QtCore.QTime(9,0)) self.record.setValue('diary_id', 1) self.record.setValue('start', start) self.record.setValue('finish', start.addSecs(60*15)) self.record.setValue('etype', 'appointment') yield self.record.insert_query
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Dialog() self.ui.setupUi(self) self.Published = False self.setWindowFlags(QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowMinimizeButtonHint) self.setFixedSize(self.size()) QtCore.QObject.connect(self.ui.openBtn, QtCore.SIGNAL("clicked()"), self.file_dialog) QtCore.QObject.connect(self.ui.loadBtn, QtCore.SIGNAL("clicked()"), self.file_exec) QtCore.QObject.connect(self.ui.svnUpdateBtn, QtCore.SIGNAL("clicked()"), self.svn_update) QtCore.QObject.connect(self.ui.zipBtn, QtCore.SIGNAL("clicked()"), self.zip_file) QtCore.QObject.connect(self.ui.filepathTxt, QtCore.SIGNAL("textChanged(const QString&)"), self.refresh) QtCore.QObject.connect(self.ui.isIncrement, QtCore.SIGNAL("clicked()"), self.onCheckbox_click) self.GeneralConfig = None self.Configs = [] self.publishedPaths = [] self._LoadDefaultConfig() self.ui.dateTimeBefore.setDateTime( QtCore.QDateTime(QtCore.QDate.currentDate())) self.ui.dateTimeBefore.setMaximumDateTime( QtCore.QDateTime(QtCore.QDate.currentDate().addDays(1))) self.ui.resultTxt.setOpenExternalLinks(True) self.threads = []
def __init__(self, nodeId, nodeName, name, pid, ppid, user, start, fullCmd): self.mNodeId = nodeId self.mNodeName = nodeName self.mName = name self.mPID = pid self.mPPID = ppid self.mUser = user self.mStart = start self.mFullCmd = fullCmd # Try to convert start time string into a real QDateTime. if self.mStart != None: # Linux case date_time = QtCore.QDateTime.fromString( self.mStart, "ddd MMM dd hh:mm:ss yyyy") if date_time != QtCore.QDateTime(): self.mStart = date_time return # Windows case date_time = QtCore.QDateTime.fromString(self.mStart, "MM/dd/yyyy hh:mm:ss") if date_time != QtCore.QDateTime(): self.mStart = date_time return
def createMailModel(parent): model = QtGui.QStandardItemModel(0, 3, parent) model.setHeaderData(SUBJECT, QtCore.Qt.Horizontal, "Subject") model.setHeaderData(SENDER, QtCore.Qt.Horizontal, "Sender") model.setHeaderData(DATE, QtCore.Qt.Horizontal, "Date") addMail(model, "Happy New Year!", "Grace K. <*****@*****.**>", QtCore.QDateTime(QtCore.QDate(2006, 12, 31), QtCore.QTime(17, 3))) addMail(model, "Radically new concept", "Grace K. <*****@*****.**>", QtCore.QDateTime(QtCore.QDate(2006, 12, 22), QtCore.QTime(9, 44))) addMail(model, "Accounts", "*****@*****.**", QtCore.QDateTime(QtCore.QDate(2006, 12, 31), QtCore.QTime(12, 50))) addMail(model, "Expenses", "Joe Bloggs <*****@*****.**>", QtCore.QDateTime(QtCore.QDate(2006, 12, 25), QtCore.QTime(11, 39))) addMail(model, "Re: Expenses", "Andy <*****@*****.**>", QtCore.QDateTime(QtCore.QDate(2007, 1, 2), QtCore.QTime(16, 5))) addMail(model, "Re: Accounts", "Joe Bloggs <*****@*****.**>", QtCore.QDateTime(QtCore.QDate(2007, 1, 3), QtCore.QTime(14, 18))) addMail(model, "Re: Accounts", "Andy <*****@*****.**>", QtCore.QDateTime(QtCore.QDate(2007, 1, 3), QtCore.QTime(14, 26))) addMail(model, "Sports", "Linda Smith <*****@*****.**>", QtCore.QDateTime(QtCore.QDate(2007, 1, 5), QtCore.QTime(11, 33))) addMail(model, "AW: Sports", "Rolf Newschweinstein <*****@*****.**>", QtCore.QDateTime(QtCore.QDate(2007, 1, 5), QtCore.QTime(12, 0))) addMail(model, "RE: Sports", "Petra Schmidt <*****@*****.**>", QtCore.QDateTime(QtCore.QDate(2007, 1, 5), QtCore.QTime(12, 1))) return model
def register_hosting(self): """Perform the hosting registration on the server.""" destination = self.line_edit_destination.text() input_date = self.date_edit_input.date().getDate() output_date = self.date_edit_output.date().getDate() number_of_rooms = int(self.combo_number_of_rooms.currentText()) guest_ages = self.table_guests.get_column(0) guest_ages = [int(i) for i in guest_ages] handler = WebserviceHandler() handler.register_hosting(destination, input_date, output_date, number_of_rooms, guest_ages) QMessageBox.about(self, "Success", "hosting registered.") self.line_edit_destination.clear() self.clear_layout(self.vlayout_guests) data = OrderedDict([('Guest age', [])]) self.table_guests = MyTable(data, 0, 1) self.vlayout_guests.addWidget(self.table_guests) self.date_edit_input.setDateTime( QtCore.QDateTime(QtCore.QDate(2015, 1, 1), QtCore.QTime(0, 0, 0))) self.date_edit_output.setDateTime( QtCore.QDateTime(QtCore.QDate(2015, 1, 1), QtCore.QTime(0, 0, 0))) self.combo_number_of_rooms.setCurrentIndex(0) self.combo_age.setCurrentIndex(0)
def findReceivedNoEnd(orgStructureIdList=None): if not orgStructureIdList: orgStructureIdList = [] cols = self.getQueryCols(MKB=True, statusObservation=True, dateFeedFlag=True, orgStructurePropertyNameList=[u'Направлен в отделение'], currentOSHB=True, OSHBProfile=True, provisionalDiagnosis=True, admissionDiagnosis=True, params=params, order=True) queryTable, cond = self.getCondAndQueryTable(u'received%', ET=1, PWS=True, Ord=2, APT=2, AP=2, AT=2) cols.append( # u'QuotaType.`code`' CQuotaColQuery.QUOTA_COL ) queryTable, cond = self.compileCommonFilter(params, queryTable, cond) queryTable, cond = self.getCondByFilters(queryTable, cond, params) queryTable = self.compileFinanceCols(cols, cond, queryTable, params.get('financeId', None), True) filterBegDateTime = params.get('begDateTime', None) filterEndDateTime = params.get('endDateTime', None) changingDayTime = params.get('changingDayTime', QtCore.QTime(0, 0)) if not filterBegDateTime: filterBegDate = QtCore.QDate.currentDate() cond.append(db.joinOr([self.tables.Action['begDate'].isNull(), self.tables.Action['begDate'].datetimeBetween(QtCore.QDateTime(filterBegDate, changingDayTime), QtCore.QDateTime(filterBegDate.addDays(1), changingDayTime))])) else: cond.append(self.tables.Action['begDate'].isNotNull()) cond.append(self.tables.Action['begDate'].datetimeGe(filterBegDateTime)) if filterEndDateTime: cond.append(self.tables.Action['begDate'].isNotNull()) cond.append(self.tables.Action['begDate'].datetimeLe(filterEndDateTime)) if orgStructureIdList: cond.append(getDataOrgStructure(u'Направлен в отделение', orgStructureIdList)) orderBy = getOrderBy() return db.getRecordList(queryTable, cols, cond, orderBy)
def findHospitalized(orgStructureIdList=None): if not orgStructureIdList: orgStructureIdList = [] cols = self.getQueryCols(MKB=True, statusObservation=True, dateFeedFlag=True, currentOSHB=True, eventEndDate=True, eventBegDate=True, params=params) #cols.append(self.tables.Event['execDate']).alias('endDate') cols.append(self.tables.OS['name'].alias('nameOS')) queryTable, cond = self.getCondAndQueryTable(u'received%', AT=True, APT=1, AP=1, APOS=1, OS=1, PWS=True, ET=1) queryTable, cond = self.compileCommonFilter(params, queryTable, cond, actionPerson=True) cond += [ self.tables.APT['deleted'].eq(0), self.tables.OS['deleted'].eq(0), self.tables.Action['endDate'].isNotNull() ] cond.append(self.tables.APT['name'].like(u'Направлен в отделение')) filterBegDateTime = params.get('begDateTime', None) filterEndDateTime = params.get('endDateTime', None) changingDayTime = params.get('changingDayTime', QtCore.QTime(0, 0)) if not filterBegDateTime: filterBegDate = QtCore.QDate.currentDate() cond.append( db.joinOr([ self.tables.Action['begDate'].isNull(), self.tables.Action['begDate'].datetimeBetween( QtCore.QDateTime(filterBegDate, changingDayTime), QtCore.QDateTime(filterBegDate.addDays(1), changingDayTime)) ])) else: cond.append(self.tables.Action['begDate'].isNotNull()) cond.append(self.tables.Action['begDate'].datetimeGe( filterBegDateTime)) if filterEndDateTime: cond.append(self.tables.Action['begDate'].isNotNull()) cond.append(self.tables.Action['begDate'].datetimeLe( filterEndDateTime)) if orgStructureIdList: cond.append( self.tables.APOS['value'].inlist(orgStructureIdList)) orderBy = getOrderBy() return db.getRecordList(queryTable, cols, cond, orderBy)
def get_min_max_date_historic(self): min_datetime, max_datetime = ManagerCompany.get_minimum_maximum_value_date_daily( db) self.dateEdit_simulatorFrom.setDateTimeRange( QtCore.QDateTime(min_datetime), QtCore.QDateTime(max_datetime)) self.dateEdit_simulatorTo.setDateTimeRange( QtCore.QDateTime(min_datetime), QtCore.QDateTime(max_datetime)) self.dateEdit_simulatorTo.setDateTime(QtCore.QDateTime(max_datetime))
def _fixupDateTime(self, dt): if not dt or not dt.isValid(): return if dt <= QtCore.QDateTime(1970, 1, 1, 1, 0, 0): return QtCore.QDateTime(1970, 1, 1, 1, 0, 0) dt.setTime(QtCore.QTime(0, 0, 0)) return dt
def setupUi(self, JourneyNb): JourneyNb.setObjectName("JourneyNb") JourneyNb.resize(400, 230) self.buttonBox = QtGui.QDialogButtonBox(JourneyNb) self.buttonBox.setGeometry(QtCore.QRect(50, 190, 341, 32)) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") self.groupBox = QtGui.QGroupBox(JourneyNb) self.groupBox.setGeometry(QtCore.QRect(10, 10, 381, 171)) self.groupBox.setObjectName("groupBox") self.layoutWidget = QtGui.QWidget(self.groupBox) self.layoutWidget.setGeometry(QtCore.QRect(30, 43, 331, 121)) self.layoutWidget.setObjectName("layoutWidget") self.gridLayout = QtGui.QGridLayout(self.layoutWidget) self.gridLayout.setHorizontalSpacing(22) self.gridLayout.setObjectName("gridLayout") self.label = QtGui.QLabel(self.layoutWidget) self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 0, 0, 1, 1) self.label_2 = QtGui.QLabel(self.layoutWidget) self.label_2.setObjectName("label_2") self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1) self.label_3 = QtGui.QLabel(self.layoutWidget) self.label_3.setObjectName("label_3") self.gridLayout.addWidget(self.label_3, 2, 0, 1, 1) self.dateEdit = QtGui.QDateEdit(self.layoutWidget) self.dateEdit.setDateTime( QtCore.QDateTime(QtCore.QDate(2009, 7, 9), QtCore.QTime(0, 0, 0))) self.dateEdit.setTime(QtCore.QTime(0, 0, 0)) self.dateEdit.setDate(QtCore.QDate(2009, 7, 9)) self.dateEdit.setObjectName("dateEdit") self.gridLayout.addWidget(self.dateEdit, 0, 1, 1, 1) self.startTimeEdit = QtGui.QTimeEdit(self.layoutWidget) self.startTimeEdit.setDateTime( QtCore.QDateTime(QtCore.QDate(2000, 1, 1), QtCore.QTime(5, 0, 0))) self.startTimeEdit.setObjectName("startTimeEdit") self.gridLayout.addWidget(self.startTimeEdit, 1, 1, 1, 1) self.endTimeEdit = QtGui.QTimeEdit(self.layoutWidget) self.endTimeEdit.setDateTime( QtCore.QDateTime(QtCore.QDate(2000, 1, 1), QtCore.QTime(21, 0, 0))) self.endTimeEdit.setObjectName("endTimeEdit") self.gridLayout.addWidget(self.endTimeEdit, 2, 1, 1, 1) self.label_4 = QtGui.QLabel(self.groupBox) self.label_4.setGeometry(QtCore.QRect(10, 20, 361, 21)) self.label_4.setObjectName("label_4") self.retranslateUi(JourneyNb) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), JourneyNb.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), JourneyNb.reject) QtCore.QMetaObject.connectSlotsByName(JourneyNb) JourneyNb.setTabOrder(self.endTimeEdit, self.buttonBox) JourneyNb.setTabOrder(self.buttonBox, self.startTimeEdit) JourneyNb.setTabOrder(self.startTimeEdit, self.dateEdit)
def selectData(params): db = QtGui.qApp.db begDate = params.get('begDate', QtCore.QDate()) endDate = params.get('endDate', QtCore.QDate()) begTime = params.get('begTime', QtCore.QTime()) endTime = params.get('endTime', QtCore.QTime()) begDateTime = QtCore.QDateTime(begDate, begTime) endDateTime = QtCore.QDateTime(endDate, endTime) tableAction = db.table('Action').alias('a') cond = [ tableAction['begDate'].datetimeGe(begDateTime), tableAction['begDate'].datetimeLe(endDateTime) ] # получаем id отделения из выпадающего списка, и если у него есть дочерние подразделения то добавляем их в условие поиска orgStruct = forceString(params.get('orgStruct')) if orgStruct: children_list = db.getColumnValues( 'OrgStructure_Ancestors', 'id', where="fullPath RLIKE '[[:<:]]%s[[:>:]]'" % orgStruct, handler=forceInt) children_list.append(int(orgStruct)) tableOrgStructure = db.table('OrgStructure').alias('os') cond.append(tableOrgStructure['id'].inlist(children_list)) stmt = u"""SELECT os.name as org_struct, aps.value as patient_state FROM Action a INNER JOIN ActionType at ON at.id = a.actionType_id AND at.flatCode = 'received' LEFT JOIN ActionPropertyType apt1 ON apt1.actionType_id = at.id AND apt1.name = 'Направлен в отделение' LEFT JOIN ActionPropertyType apt2 ON apt2.actionType_id = at.id AND apt2.name = 'Cостояние пациента' LEFT JOIN ActionProperty ap1 ON ap1.type_id = apt1.id AND ap1.action_id = a.id LEFT JOIN ActionProperty ap2 ON ap2.type_id = apt2.id AND ap2.action_id = a.id LEFT JOIN ActionProperty_String aps ON aps.id = ap2.id LEFT JOIN ActionProperty_OrgStructure apos ON apos.id = ap1.id LEFT JOIN OrgStructure os ON os.id = apos.value WHERE %s AND a.deleted = 0 ORDER BY org_struct """ % (db.joinAnd(cond)) return db.query(stmt)
def _convertToDateTime(self, val): if isinstance(val, (int, long)): return self._fixupDateTime(QtCore.QDateTime.fromTime_t(val)) elif isinstance(val, (date, datetime)): return self._fixupDateTime( QtCore.QDateTime(val.year, val.month, val.day, 0, 0, 0)) elif isinstance(val, QtCore.QDate): return self._fixupDateTime( QtCore.QDateTime(val, QtCore.QTime(0, 0, 0))) elif isinstance(val, QtCore.QDateTime): return self._fixupDateTime(val)
def params(self): return { 'begDateTime': QtCore.QDateTime(self.edtBegDate.date(), self.edtBegTime.time()), 'endDateTime': QtCore.QDateTime(self.edtEndDate.date(), self.edtEndTime.time()), 'showPrevYear': self.chkShowPrevYear.isChecked(), 'orgStructureId': self.cmbOrgStructure.value() }
def selectData(params, reportOrgStructure = False): db = QtGui.qApp.db begDate = params.get('edtBegDateTime', QtCore.QDateTime()) endDate = params.get('edtEndDateTime', QtCore.QDateTime()) orgStructureId = params.get('orgStructureId') profileBed = params.get('profileBed') tableAction = db.table('Action') tableOrgStructure = db.table('OrgStructure') tableHospitalBedProfile = db.table('rbHospitalBedProfile') cond = [tableAction['begDate'].ge(begDate), tableAction['begDate'].le(endDate)] if profileBed: cond.append(tableHospitalBedProfile['id'].eq(profileBed)) if orgStructureId: cond.append(tableOrgStructure['id'].inlist(getOrgStructureDescendants(orgStructureId))) stmt = u'''SELECT %s, COUNT(act.id) AS countEvent, COUNT(aps.value) AS countRefusal FROM ActionType INNER JOIN Action ON Action.actionType_id = ActionType.id AND Action.deleted = 0 INNER JOIN Action act ON act.id = (SELECT MIN(a.id) AS id FROM ActionType INNER JOIN Action a ON a.actionType_id = ActionType.id AND a.deleted = 0 WHERE ActionType.flatCode = 'moving' AND a.event_id = Action.event_id AND ActionType.deleted = 0) INNER JOIN ActionProperty ON ActionProperty.action_id = act.id AND ActionProperty.deleted =0 INNER JOIN ActionPropertyType ON ActionPropertyType.id = ActionProperty.type_id AND ActionPropertyType.name = 'Отделение пребывания' AND ActionPropertyType.deleted =0 INNER JOIN ActionProperty_OrgStructure ON ActionProperty_OrgStructure.id = ActionProperty.id INNER JOIN OrgStructure ON OrgStructure.id = ActionProperty_OrgStructure.value LEFT JOIN ActionProperty ap ON ap.action_id = Action.id AND ap.type_id IN (SELECT apt.id FROM ActionPropertyType apt WHERE apt.name = 'Причина отказа от госпитализации' AND apt.deleted = 0) LEFT JOIN ActionProperty_String aps ON aps.id = ap.id LEFT JOIN ActionProperty apHospitalBedProfile ON apHospitalBedProfile.action_id = act.id AND apHospitalBedProfile.type_id IN (SELECT apt.id FROM ActionPropertyType apt INNER JOIN ActionType at ON at.id = apt.actionType_id AND at.flatCode = 'moving' AND at.deleted = 0 WHERE apt.name = 'Профиль') AND apHospitalBedProfile.deleted = 0 %s -- LEFT JOIN ActionProperty_rbHospitalBedProfile aphb ON aphb.id = apHospitalBedProfile.id -- LEFT JOIN rbHospitalBedProfile ON rbHospitalBedProfile.id = aphb.value -- LEFT JOIN OrgStructure_HospitalBed ON OrgStructure.id = OrgStructure_HospitalBed.master_id -- LEFT JOIN rbHospitalBedProfile ON OrgStructure_HospitalBed.profile_id = rbHospitalBedProfile.id WHERE ActionType.flatCode = 'received' AND %s GROUP BY %s''' % (u'OrgStructure.code' if reportOrgStructure else u'rbHospitalBedProfile.name AS code', u'LEFT JOIN ActionProperty_rbHospitalBedProfile aphb ON aphb.id = apHospitalBedProfile.id ' u'LEFT JOIN rbHospitalBedProfile ON rbHospitalBedProfile.id = aphb.value' if reportOrgStructure else u'LEFT JOIN OrgStructure_HospitalBed ON OrgStructure.id = OrgStructure_HospitalBed.master_id' u' LEFT JOIN rbHospitalBedProfile ON OrgStructure_HospitalBed.profile_id = rbHospitalBedProfile.id', db.joinAnd(cond), u'OrgStructure.id' if reportOrgStructure else u'rbHospitalBedProfile.id') return db.query(stmt)
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(603, 553) self.centralWidget = QtGui.QWidget(MainWindow) self.gridlayout = QtGui.QGridLayout(self.centralWidget) self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget) self.gridlayout.addWidget(self.vtkWidget, 0, 1, 1, 12) MainWindow.setCentralWidget(self.centralWidget) self.date2 = QtGui.QDateTimeEdit() dateTime2 = QtCore.QDateTime(2012, 5, 1, 00, 00) self.date2.setDateTime(dateTime2) self.gridlayout.addWidget(self.date2, 1, 3, 2, 2) self.date1 = QtGui.QDateTimeEdit() dateTime1 = QtCore.QDateTime(2012, 5, 31, 00, 00) self.date1.setDateTime(dateTime1) self.gridlayout.addWidget(self.date1, 1, 5, 2, 2) # Magnitude upper limit filtering+submit magnitudeLabel = QtGui.QLabel("Magnitude:") magnitudeLabel.setAlignment(QtCore.Qt.AlignRight) self.gridlayout.addWidget(magnitudeLabel, 5, 3, 2, 2) self.magnitudeValue = QtGui.QLineEdit() # Use input mask for input validation, instead of setMaxLength # or other manual checks by using if to let input only numbers. self.magnitudeValue.setInputMask("0.0") self.magnitudeValue.setAlignment(QtCore.Qt.AlignRight) self.gridlayout.addWidget(self.magnitudeValue, 5, 5, 2, 2) # Controls the planes opacity planeOpacityLabel = QtGui.QLabel("Plane Opacity:") planeOpacityLabel.setAlignment(QtCore.Qt.AlignRight) self.gridlayout.addWidget(planeOpacityLabel, 7, 3, 2, 2) self.opacityValue = QtGui.QLineEdit() # Use input mask for input validation, instead of setMaxLength # or other manual checks by using if to let input only numbers. self.opacityValue.setInputMask("0.0") self.opacityValue.setAlignment(QtCore.Qt.AlignRight) self.gridlayout.addWidget(self.opacityValue, 7, 5, 2, 2) self.submit = QtGui.QPushButton("submit") self.gridlayout.addWidget(self.submit, 7, 7, 2, 2) self.sld = QtGui.QSlider(QtCore.Qt.Horizontal) self.sld.setTracking(False) self.sld.setDisabled(True) self.gridlayout.addWidget(self.sld, 9, 3, 1, 6)
def params(self): return \ { 'begDateTime' : QtCore.QDateTime(self.edtBegDate.date(), self.edtBegTime.time()), 'endDateTime' : QtCore.QDateTime(self.edtEndDate.date(), self.edtEndTime.time()), 'flagDoc' : self.chkDoc.isChecked(), 'flagAddress' : self.chkAddress.isChecked(), 'flagAddressReg' : self.chkAddressReg.isChecked(), 'flagDMS' : self.chkDMS.isChecked(), 'flagOMS' : self.chkOMS.isChecked(), 'flagDiag' : self.chkDiag.isChecked(), 'flagDiagDir' : self.chkDiagDir.isChecked(), 'flagDir' : self.chkDir.isChecked(), 'flagWork' : self.chkWork.isChecked(), 'orgStructId' : self.cmbOrgStruct.value() }
def re_DT(self, re_text): data = link_layer.data_format(re_text) offset = 0 ret_dict = link_layer.get_SA_CA(data) offset += 5 + int(ret_dict['SA_len']) + 10 if data[offset] == '01': self.res_b.setStyleSheet('color: green') self.res_b.setText('成功') offset += 2 DT_read = QtCore.QDateTime( (int(data[offset], 16) << 8) | int(data[offset + 1], 16), int(data[offset + 2], 16), int(data[offset + 3], 16), int(data[offset + 4], 16), int(data[offset + 5], 16), int(data[offset + 6], 16), ) # print('DT_read', DT_read) self.DT_box.setDateTime(DT_read) else: self.res_b.setStyleSheet('color: red') self.res_b.setText('失败:' + data_translate.dar_explain[data[offset + 1]]) config.serial_window._receive_signal.disconnect() config.serial_window._receive_signal.connect( config.serial_window.re_text_to_box)
def on_edtAPCoordDate_dateChanged(self, date): self.edtAPCoordTime.setEnabled(bool(date)) time = self.edtAPDirectionTime.time( ) if date and self.edtAPDirectionTime.isVisible() else QtCore.QTime() self.onActionDataChanged('coordDate', QtCore.QDateTime(date, time)) if not self.edtAPCoordAgent.text(): self.edtAPCoordAgent.setText(getCurrentUserName())
def setCurrentIndex(self, index): notFirst = index > 0 notLast = index < len(self.idList) - 1 self.currentIndex = index self.btnPrev.setEnabled(notFirst) self.btnNext.setEnabled(notLast) message = self.messageCache.get(self.idList[self.currentIndex]) if message: createPersonId = forceRef(message.value('createPerson_id')) person = self.personCache.get(createPersonId) if person: personName = forceString(person.value('name')) else: personName = '' createDateTime = message.value('createDatetime').toDateTime() subject = forceString(message.value('subject')) text = forceString(message.value('text')) else: personName = '' createDateTime = QtCore.QDateTime() subject = '' text = '' self.lblCreatePersonValue.setText(personName) self.lblCreateDatetimeValue.setText( createDateTime.toString(QtCore.Qt.LocaleDate)) self.lblSubjectValue.setText(subject) self.edtText.setHtml(text) self.chkMarkViewed.setChecked( self.markList[self.currentIndex] != False) if notLast: self.btnNext.setFocus(QtCore.Qt.OtherFocusReason) else: self.buttonBox.button(QtGui.QDialogButtonBox.Close).setFocus( QtCore.Qt.OtherFocusReason)
def record(self, state): """The logic for recording and stopping recording.""" if state: # Start Recording. logo_rec = QtGui.QPixmap(":/freeseer/logo_rec.png") sysIcon2 = QtGui.QIcon(logo_rec) self.systray.setIcon(sysIcon2) self.controller.record() self.mainWidget.recordPushButton.setText(self.stopString) self.recordAction.setText(self.stopString) # Hide if auto-hide is set. if self.config.auto_hide: self.hide_window() self.visibilityAction.setText(self.showWindowString) log.debug( 'auto-hide is enabled, main window is now hidden in systray.' ) # Start timer. self.timer.start(1000) else: # Stop Recording. logo_rec = QtGui.QPixmap(":/freeseer/logo.png") sysIcon = QtGui.QIcon(logo_rec) self.systray.setIcon(sysIcon) self.controller.stop() self.mainWidget.pauseToolButton.setChecked(False) self.mainWidget.recordPushButton.setText(self.recordString) self.recordAction.setText(self.recordString) self.mainWidget.audioSlider.setValue(0) self.mainWidget.statusLabel.setText(u"{} {} --- {} ".format( self.freeSpaceString, get_free_space(self.config.videodir), self.idleString)) # Finally set the standby button back to unchecked position. self.standby(False) # Stop and reset timer. self.timer.stop() self.reset_timer() #Show playback button self.mainWidget.playPushButton.setVisible(True) self.mainWidget.playPushButton.setEnabled(True) # Select next talk if there is one within 15 minutes. if self.current_event and self.current_room: starttime = QtCore.QDateTime().currentDateTime() stoptime = starttime.addSecs(900) talkid = self.db.get_talk_between_time(self.current_event, self.current_room, starttime.toString(), stoptime.toString()) if talkid is not None: for i in range(self.mainWidget.talkComboBox.count()): if talkid == self.mainWidget.talkComboBox.model( ).index(i, 1).data(QtCore.Qt.DisplayRole).toString(): self.mainWidget.talkComboBox.setCurrentIndex(i)
def update(self): # update the date edit box self.dateSet.setDateTime( QtCore.QDateTime( QtCore.QDate(self.tr.start.year, self.tr.start.month, self.tr.start.day), QtCore.QTime(00, 00, 00))) # next update the plot # clear the plot if it exists if self.ax0 is not None: self.ax0.cla() # now create the matplotlib plot self.ax0 = self.fig0.add_subplot(1, 1, 1) self.ax0.plot(self.lc.data.index, self.lc.data['xrsa'], color='red') self.ax0.plot(self.lc.data.index, self.lc.data['xrsb'], color='blue') self.ax0.set_xlabel(str(self.tr.start)) self.ax0.set_yscale('log') self.ax0.set_ylim(1e-9, 1e-2) self.ax0.set_ylabel('Watts m$^{-2}$') self.ax0.tick_params(axis='both', labelsize=9) self.fig0.autofmt_xdate() # now draw it self.fig0.canvas.draw()
def updateFileInfo(self, fileName, fileInfoNode): """Update data of file info node. Arguments: fileName -- the TreeLine file path fileInfoNode -- the node to update """ try: status = os.stat(fileName) except OSError: fileInfoNode.data = {} return fileInfoNode.data[FileInfoFormat.fileFieldName] = ( os.path.basename(fileName)) fileInfoNode.data[FileInfoFormat.pathFieldName] = ( os.path.dirname(fileName)) fileInfoNode.data[FileInfoFormat.sizeFieldName] = str( status[stat.ST_SIZE]) modDateTime = QtCore.QDateTime() modDateTime.setTime_t(status[stat.ST_MTIME]) modDateTime = modDateTime.toLocalTime() modDate = modDateTime.date().toString(QtCore.Qt.ISODate) modTime = modDateTime.time().toString() fileInfoNode.data[FileInfoFormat.dateFieldName] = modDate fileInfoNode.data[FileInfoFormat.timeFieldName] = modTime if not sys.platform.startswith('win'): try: owner = pwd.getpwuid(status[stat.ST_UID])[0] except KeyError: owner = repr(status[stat.ST_UID]) fileInfoNode.data[FileInfoFormat.ownerFieldName] = owner
def render(self): html = None if self._message.is_joining(): html = self.MESSAGES["join"].format(user=self._message.user.name, room=self._room.name) elif (self._message.is_leaving() or self._message.is_kick()): html = self.MESSAGES["leave"].format(user=self._message.user.name, room=self._room.name) elif self._message.is_text() or self._message.is_upload(): if self._message.body: body = self._plainTextToHTML(self._message.tweet["tweet"] if self._message.is_tweet() else self._message.body) if self._message.is_tweet(): body = self.MESSAGES["tweet"].format( url_user = "******".format(user=self._message.tweet["user"]), user = self._message.tweet["user"], url = self._message.tweet["url"], message = body ) elif self._message.is_paste(): body = self.MESSAGES["paste"].format(message=body) elif self._message.is_upload(): body = self._displayUpload() elif self._isInlineLink(body): body = self._displayInline(body) else: body = self._autoLink(body) created = QtCore.QDateTime( self._message.created_at.year, self._message.created_at.month, self._message.created_at.day, self._message.created_at.hour, self._message.created_at.minute, self._message.created_at.second ) created.setTimeSpec(QtCore.Qt.UTC) createdFormat = "h:mm ap" if created.daysTo(QtCore.QDateTime.currentDateTime()): createdFormat = "MMM d, {createdFormat}".format(createdFormat=createdFormat) key = "message" if self._message.is_by_current_user(): if self._showTimestamps: key = "message_self" else: key = "no_time_message_self" elif self._alert: key = "alert" elif not self._showTimestamps: key = "no_time_message" html = self.MESSAGES[key].format( time = created.toLocalTime().toString(createdFormat), user = self._message.user.name, message = body ) elif self._message.is_topic_change(): html = self.MESSAGES["topic"].format(user=self._message.user.name, topic=self._message.body) return unicode(html)
def saveData(self): self.tableItems.ticketIsDirty = [False]*len(self.tableItems.tickets) for i, ticket in enumerate(self.tableItems.tickets): datetime = QtCore.QDateTime(self.items[i][4], self.items[i][0]) if i < len(self.items) else None ticket.setValue('datetime', toVariant(datetime)) ticket.setValue('idx', toVariant(i)) self.tableItems.ticketIsDirty[i] = True
def setData(self, index, value, role=QtCore.Qt.EditRole): if role == QtCore.Qt.EditRole: column = index.column() row = index.row() if row == len(self.items): if value.isNull(): return False execDateList = self.executionPlan.keys() if execDateList: execDate = execDateList[0] self.items.append([QtCore.QTime(), QtCore.QDate(execDate), None]) vCnt = len(self.items) vIndex = QtCore.QModelIndex() self.beginInsertRows(vIndex, vCnt, vCnt) self.insertRows(vCnt, 1, vIndex) self.endInsertRows() else: return False if 0 <= row < len(self.items): newTime = value.toTime() if newTime.isNull(): self.items[row][column] = None self.items[row][2] = None else: self.items[row][column] = value.toTime() record = self.items[row][2] if not record: db = QtGui.qApp.db table = db.table('Action_ExecutionPlan') record = table.newRecord() record.setValue('execDate', toVariant(QtCore.QDateTime(self.items[row][1], self.items[row][column]))) self.items[row][2] = record self.emitCellChanged(row, column) return True return False
def toQDateTime(dt): """ Converts a UTCDateTime object to a QDateTime object. """ return QtCore.QDateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond // 1000, QtCore.Qt.TimeSpec(1))
def get_file_list(self): url = str(self.URLlineEdit.text()) if url == '': QtGui.QMessageBox.warning(self, self.tr("Get remote zip content"), self.tr("Specify URL please"), QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.Escape); return self.StartpushButton.setDisabled(True) self.z = ZipFile(url) #print z.file_list() model = QtGui.QStandardItemModel(0, 4, self) model.setHeaderData(0, QtCore.Qt.Horizontal, QtCore.QVariant("File name")) model.setHeaderData(1, QtCore.Qt.Horizontal, QtCore.QVariant("Compressed size")) model.setHeaderData(2, QtCore.Qt.Horizontal, QtCore.QVariant("Uncompressed size")) model.setHeaderData(3, QtCore.Qt.Horizontal, QtCore.QVariant("File date")) from datetime import date, time for filename in self.z.TOC: #print type(z.TOC[filename][1]) compressed_size = self.z.TOC[filename][7] uncompressed_size = self.z.TOC[filename][8] d = self.z.TOC[filename][9] t = self.z.TOC[filename][10] model = self.add_file_item(model, filename, compressed_size, uncompressed_size, QtCore.QDateTime(QtCore.QDate(d[0],d[1],d[2]), QtCore.QTime(t[0],t[1],t[2]))) self.treeView.setModel(model) self.StartpushButton.setEnabled(True)
def get_settings(self): sqlquery = QtSql.QSqlQuery( QtCore.QString(""" SELECT course.fullname, course.shortname, course.startdate, course.metacourse FROM course WHERE course.id='%1' """).arg(self.id), self.db) sqlquery.first() value = sqlquery.value(0).toString() self.settings["fullname"] = { "title": u"Повна назва", "value": value, "widget": QtGui.QLineEdit(value) } value = sqlquery.value(1).toString() self.settings["shortname"] = { "title": u"Коротка назва", "value": value, "widget": QtGui.QLineEdit(value) } value = sqlquery.value(2).toInt()[0] datetime = QtCore.QDateTime() datetime.setTime_t(value) datetimeedit = QtGui.QDateTimeEdit(datetime) datetimeedit.setCalendarPopup(True) self.settings["startdate"] = { "title": u"Дата початку", "value": value, "widget": datetimeedit } value = sqlquery.value(3).toInt()[0] checkbox = QtGui.QCheckBox() checkbox.setChecked(value) self.settings["metacourse"] = { "title": u"Мета курс", "value": value, "widget": checkbox } formlayout = QtGui.QFormLayout() for setting_key in self.settings.keys(): setting = self.settings[setting_key] formlayout.addRow(setting["title"], setting["widget"]) if self.ui.groupBoxSettings.layout(): layout = self.ui.groupBoxSettings.layout() print "try del" layout.deleteLater() self.ui.groupBoxSettings.setLayout(formlayout)
def initialize_content(self): # Add functionality to copy and paste self.copyAction = QtGui.QAction("Copy", self) self.copyAction.setShortcut("Ctrl+C") self.addAction(self.copyAction) self.connect(self.copyAction, QtCore.SIGNAL("triggered()"), self.copyCells) self._content.job_table.setContextMenuPolicy( QtCore.Qt.CustomContextMenu) self.connect(self._content.job_table, QtCore.SIGNAL("customContextMenuRequested(QPoint)"), self.tableWidgetContext) self.connect(self._content.refresh_button, QtCore.SIGNAL("clicked()"), self._update_content) # Set the time of the oldest displayed job to 2 days ago self._content.date_time_edit.setDateTime( QtCore.QDateTime().currentDateTime().addDays(-2)) compute_resources = ConfigService.Instance().getFacility( ).computeResources() self._content.resource_combo.clear() for res in compute_resources: self._content.resource_combo.addItem( QtGui.QApplication.translate("Dialog", res, None, QtGui.QApplication.UnicodeUTF8)) self._clear_table()
def addMessage(self, messType, title, messageList): parentItem = QtGui.QTreeWidgetItem(self) if messType == 0: parentItem.setIcon( 0, QtGui.QIcon( os.path.join("Resources", "images", "security", "attention"))) elif messType == 1: parentItem.setIcon( 0, QtGui.QIcon( os.path.join("Resources", "images", "security", "warning"))) elif messType == 2: parentItem.setIcon( 0, QtGui.QIcon( os.path.join("Resources", "images", "security", "danger"))) parentItem.setText(0, title) parentItem.setText(1, QtCore.QDateTime().currentDateTime().toString()) for i in messageList: item = QtGui.QTreeWidgetItem(parentItem) item.setFirstColumnSpanned(True) item.setText(0, i) parentItem.addChild(item) parentItem.setExpanded(True) self.scrollToItem(parentItem, 1) self.vSplitter.showMessageAvailable() self.bottomStackSwitcher.setCount(self, str(self.topLevelItemCount())) self.bottomStackSwitcher.setCurrentWidget(self)