def on_dtBtn_clicked(self): """Show datetime edit dialog""" if self.readOnly: return dtStr = currentDatetime() if self.datetime is None else self.datetime newDt = DateTimeDialog.getDateTime(datetimeToQt(dtStr), fullDatetimeFmt, self) if newDt is not None: newDtStr = newDt.toString(DB_DATETIME_FMT_QT) if newDtStr != self.datetime: self.datetime = newDtStr self.dtBtn.setText(datetimeTrans(newDtStr)) self.timeModified = True
def fromDiaryDict(self, dic): self.timeModified = self.tagModified = False self.id = dic['id'] self.datetime = dic.get('datetime') self.dtBtn.setText(datetimeTrans(self.datetime) if self.datetime else '') self.titleEditor.setText(dic.get('title', '')) self.tagEditor.setText(dic.get('tags', '')) self.textEditor.setRichText(dic.get('text', ''), dic.get('formats')) # if title is empty, use datetime instead. if no datetime (new), use "New Diary" t = (dic.get('title') or (datetimeTrans(self.datetime, stripTime=True) if 'datetime' in dic else None) or self.tr('New Diary')) self.setWindowTitle("%s - Hazama" % t) readOnly = (settings['Editor'].getboolean('autoReadOnly') and self.datetime is not None and datetimeToQt(self.datetime).daysTo(QDateTime.currentDateTime()) > 3) self.setReadOnly(readOnly)