def trayUpdate(self, gdate=None, checkDate=True):## FIXME if gdate==None: gdate = localtime()[:3] if self.lastGDate!=gdate or not checkDate: jd = core.modules[core.DATE_GREG].to_jd(*gdate) if core.primaryMode==core.DATE_GREG: ddate = gdate else: ddate = core.modules[core.primaryMode].jd_to(jd) self.lastGDate = gdate ui.todayCell = ui.cellCache.getTodayCell() imPath = ui.trayImageHoli if ui.todayCell.holiday else ui.trayImage self.pmap.load(imPath) try: self.painter.end() except: pass self.painter.begin(self.pmap) w = self.pmap.width() h = self.pmap.height() self.painter.drawText(qc.QPoint(0, h-2), _(ddate[2])) self.iconT.setPixmap(self.pmap) self.icon.setWidget(self.iconT) #self.icon.setGeometry(qc.QRectF(0, 0, w, h)) #self.iconT.setGeometry(qc.QRect(0, 0, w, h)) self.iconT.setFixedWidth(w) #self.iconT.setFixedHeight(h) ## position of left lower corner of text ^^ ## trayTextColor, ui.trayFont, ui.fontUseDefault ?????? #################### wd = core.getWeekDay(*ddate) tt = core.getWeekDayN(wd) #if ui.pluginsTextTray:##????????? # sep = _(',')+' ' #else: sep = u'<br>' for item in ui.shownCals: if item['enable']: mode = item['mode'] (y, m, d) = ui.todayCell.dates[mode] tt += u'%s%s %s %s'%(sep, _(d), core.getMonthName(mode, m), _(y)) if ui.pluginsTextTray: text = ui.todayCell.pluginsText if text!='': tt += u'%s%s'%(sep, text.replace(u'\t', sep)) #???????????? if rtl:## tags: div, p, body tt = u'<p dir="rtl">%s</p>'%tt #else: # tt = '<p dir="ltr">%s</p>'%tt self.tooltipContent.setMainText('') ## self.name self.tooltipContent.setSubText(tt) self.tooltipMgr.setContent(self.papplet.applet, self.tooltipContent) return True
def __init__(self, cellCache, year, month): self.year = year self.month = month self.monthLen = getMonthLen(year, month, calTypes.primary) self.offset = getWeekDay(year, month, 1) ## month start offset initJd = core.primary_to_jd(year, month, 1) self.weekNum = [getWeekNumberByJd(initJd + i * 7) for i in range(6)] ######### startJd, endJd = core.getJdRangeForMonth(year, month, calTypes.primary) tableStartJd = startJd - self.offset ##### list.__init__(self, [[ cellCache.getCell(tableStartJd + yPos * 7 + xPos) for xPos in range(7) ] for yPos in range(6)])
def __init__(self, cellCache, year, month): self.year = year self.month = month self.monthLen = getMonthLen(year, month, calTypes.primary) self.offset = getWeekDay(year, month, 1)## month start offset self.weekNum = [getWeekNumber(year, month, 1+7*i) for i in range(6)] ######### startJd, endJd = core.getJdRangeForMonth(year, month, calTypes.primary) tableStartJd = startJd - self.offset ##### list.__init__(self, [ [ cellCache.getCell( tableStartJd + yPos*7 + xPos ) for xPos in range(7) ] for yPos in range(6) ])
def setParamsFunc(cell): offset = getWeekDay(cell.year, cell.month, 1)## month start offset yPos, xPos = divmod(offset + cell.day - 1, 7) cell.monthPos = (xPos, yPos) ### """
def buildStatus(self, year, month, addCache=True): #print 'Building cache (%s, %s)'%(year, month) s = MonthStatus()#s = [] s.year = year s.month = month pyear = year pmonth = month -1 if pmonth <= 0 : pmonth =12 pyear -=1 prevMonthLen = core.getMonthLen(pyear, pmonth, self.mode) currentMonthLen = core.getMonthLen(year, month, self.mode) s.monthLen = currentMonthLen ##################### s.weekNum = [self.weekNumber(year, month, 1+7*i) for i in xrange(6)] offset = core.getWeekDay(year, month, 1) if offset==0: ###### Which Method ???????????????????? #day = prevMonthLen - 6 ; s.weekNum = [self.weekNumber(year, month, 1+7*i)-1 for i in xrange(6)] day = 1 else: day = prevMonthLen - offset + 1 s.monthStartOffset = offset ###################### for i in xrange(6): s.append([]) for j in xrange(7): c = Cell() c.pos = (j, i) s[i].append(c) c.jd = core.to_jd(year, month, day, self.mode) if i<2 and day>15: c.gray = -1 c.date = (pyear, pmonth, day) #c.ym = (pyear, pmonth) elif i>=4 and day<20: c.gray = 1 nyear = year nmonth = month +1 if nmonth > 12 : nmonth =1 nyear += 1 c.date = (nyear, nmonth, day) else: c.gray = 0 c.date = (year, month, day) cyear, cmonth, cday = c.date if c.gray==0: wd = (core.firstWeekDay + j) % 7 ##?????????? if wd in self.holidayWeekDays: c.holiday = True day+=1 if i>3 and day>currentMonthLen: day =1 sday=1 if i<2 and day>prevMonthLen: day =1 if addCache: ## Clean Cache n = len(self.months) #print 'Cache size: %s'%n if n >= self.maxCache: keys = self.months.keys() keys.sort() if keys[n/2] < (year, month): rm = keys[0] if rm==self.today[:2]: rm = keys[1] else: rm = keys[-1] if rm==self.today[:2]: rm = keys[-2] #if rm != (year, month): #print 'Removing cache (%s, %s)'%(rm[0], rm[1]) self.months.pop(rm) try:#### for memory emhancement del self.months[(year, month)] except: pass self.months[(year, month)] = s return s
def weekNumber(self, year, month, day):## week number in year first = core.getWeekDay(year, 1, 1) - core.firstWeekDay - 1 return (core.datesDiff(year, 1, 1, year, month, day) + first%7) / 7 + 1
def setParamsFunc(cell): offset = getWeekDay(cell.year, cell.month, 1) ## month start offset yPos, xPos = divmod(offset + cell.day - 1, 7) cell.monthPos = (xPos, yPos) ### """