def __init__(self, _parent): MDialog.__init__(self, _parent) if isActivePyKDE4: self.setButtons(MDialog.NoDefault) pbtnClose = MPushButton(translate("RecordsForm", "Close")) pbtnClear = MPushButton(translate("RecordsForm", "Clear")) self.connect(pbtnClose, SIGNAL("clicked()"), self.close) self.connect(pbtnClear, SIGNAL("clicked()"), self.clear) lblRecordList = MLabel(translate("RecordsForm", "Record File")) self.recordsList = [translate("RecordsForm", "Current Records") ] + Records.getBackupRecordsList() self.cbRecordsList = Options.MyComboBox( self, self.recordsList, _currentIndexChanged=self.getFromRecordList) self.teRecords = MTextEdit() self.teRecords.setWordWrapMode(MTextOption.ManualWrap) self.setRecordsFile() pnlMain = MWidget(self) vblMain = MVBoxLayout(pnlMain) hbox = MHBoxLayout() hbox.addStretch(1) hbox.addWidget(pbtnClear, 1) hbox.addWidget(pbtnClose, 1) hbox1 = MHBoxLayout() hbox1.addWidget(lblRecordList) hbox1.addWidget(self.cbRecordsList) vblMain.addLayout(hbox1) vblMain.addWidget(self.teRecords) vblMain.addLayout(hbox) if isActivePyKDE4: self.setMainWidget(pnlMain) else: self.setLayout(vblMain) self.setWindowTitle(translate("RecordsForm", "Last Records")) self.setWindowIcon(MIcon("Images:lastActions.png")) self.setMinimumWidth(500) self.setMinimumHeight(450) self.show()
def clear(self): try: answer = Dialogs.ask( translate("RecordsForm", "Are You Sure?"), translate("RecordsForm", "Are you sure you want to remove this record file?")) if answer == Dialogs.Yes: if self.cbRecordsList.currentIndex() == 0: Records.clearRecords() else: recordFilePath = self.recordsList[ self.cbRecordsList.currentIndex()] fu.removeFile( fu.joinPath(fu.oldRecordsDirectoryPath, recordFilePath)) self.recordsList = [ translate("RecordsForm", "Current Records") ] + Records.getBackupRecordsList() self.cbRecordsList.clear() self.cbRecordsList.addItems(self.recordsList) self.setRecordsFile() except: ReportBug.ReportBug()