コード例 #1
0
 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
コード例 #2
0
ファイル: editor.py プロジェクト: zhangluqi2020/Hazama
 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
コード例 #3
0
    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)
コード例 #4
0
ファイル: editor.py プロジェクト: zhangluqi2020/Hazama
    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)