コード例 #1
0
ファイル: ui.py プロジェクト: ErfanBagheri/starcal
 def __init__(self, jd):
     self.eventsData = []
     self.eventsDataIsSet = False
     self.pluginsText = ''
     ###
     self.jd = jd
     date = core.jd_to(jd, core.primaryMode)
     self.year, self.month, self.day = date
     self.weekDay = core.jwday(jd)
     self.weekNum = core.getWeekNumber(self.year, self.month, self.day)
     self.holiday = (self.weekDay in core.holidayWeekDays)
     ###################
     self.dates = []
     for mode in range(len(calTypes)):
         if mode==core.primaryMode:
             self.dates.append((self.year, self.month, self.day))
         else:
             self.dates.append(core.jd_to(jd, mode))
     ###################
     for k in core.plugIndex:
         plug = core.allPlugList[k]
         if plug.enable:
             try:
                 plug.update_cell(self)
             except:
                 myRaiseTback()
     ###################
     self.eventsData = event_lib.getDayOccurrenceData(jd, eventGroups)
コード例 #2
0
ファイル: starcal2.py プロジェクト: seacgroup/starcal
 def getTrayTooltip(self):
     ##tt = core.weekDayName[core.getWeekDay(*ddate)]
     tt = core.weekDayName[core.jwday(ui.todayCell.jd)]
     #if ui.pluginsTextTray:##?????????
     #    sep = _(',')+' '
     #else:
     sep = '\n'
     for mode in calTypes.active:
         y, m, d = ui.todayCell.dates[mode]
         tt += '%s%s %s %s'%(sep, _(d), getMonthName(mode, m, y), _(y))
     if ui.pluginsTextTray:
         text = ui.todayCell.pluginsText
         if text!='':
             tt += '\n\n%s'%text ## .replace('\t', '\n') ## FIXME
     return tt
コード例 #3
0
ファイル: ui.py プロジェクト: ilius/starcal2
    def __init__(self, jd):
        self.eventsData = []
        #self.eventsDataIsSet = False ## not used
        self.pluginsText = ''
        ###
        self.jd = jd
        date = core.jd_to_primary(jd)
        self.year, self.month, self.day = date
        self.weekDay = core.jwday(jd)
        self.weekNum = core.getWeekNumber(self.year, self.month, self.day)
        #self.weekNumNeg = self.weekNum + 1 - core.getYearWeeksCount(self.year)
        self.weekNumNeg = self.weekNum - int(
            calTypes.primaryModule().avgYearLen / 7)
        self.holiday = (self.weekDay in core.holidayWeekDays)
        ###################
        self.dates = [
            date if mode == calTypes.primary else jd_to(jd, mode)
            for mode in range(len(calTypes))
        ]
        '''
		self.dates = dict([
			(
				mode, date if mode==calTypes.primary else jd_to(jd, mode)
			)
			for mode in calTypes.active
		])
		'''
        ###################
        for k in core.plugIndex:
            plug = core.allPlugList[k]
            if plug.enable:
                try:
                    plug.update_cell(self)
                except:
                    myRaiseTback()
        ###################
        #t0 = now()
        self.eventsData = event_lib.getDayOccurrenceData(
            jd, eventGroups)  ## here? FIXME
コード例 #4
0
ファイル: starcal2.py プロジェクト: amirkarimi/starcal
 def getStatusIconTooltip(self):
     ##tt = core.weekDayName[core.getWeekDay(*ddate)]
     tt = core.weekDayName[core.jwday(ui.todayCell.jd)]
     #if ui.pluginsTextStatusIcon:##?????????
     #    sep = _(',')+' '
     #else:
     sep = '\n'
     for mode in calTypes.active:
         y, m, d = ui.todayCell.dates[mode]
         tt += '%s%s %s %s'%(sep, _(d), locale_man.getMonthName(mode, m, y), _(y))
     if ui.pluginsTextStatusIcon:
         text = ui.todayCell.pluginsText
         if text!='':
             tt += '\n\n%s'%text ## .replace('\t', '\n') ## FIXME
     for item in ui.todayCell.eventsData:
         if not item['showInStatusIcon']:
             continue
         itemS = ''
         if item['time']:
             itemS += item['time'] + ' - '
         itemS += item['text'][0]
         tt += '\n\n%s'%itemS
     return tt
コード例 #5
0
ファイル: ui.py プロジェクト: amirkarimi/starcal
 def __init__(self, jd):
     self.eventsData = []
     #self.eventsDataIsSet = False ## not used
     self.pluginsText = ''
     ###
     self.jd = jd
     date = core.jd_to_primary(jd)
     self.year, self.month, self.day = date
     self.weekDay = core.jwday(jd)
     self.weekNum = core.getWeekNumber(self.year, self.month, self.day)
     #self.weekNumNeg = self.weekNum + 1 - core.getYearWeeksCount(self.year)
     self.weekNumNeg = self.weekNum - int(calTypes.primaryModule().avgYearLen / 7)
     self.holiday = (self.weekDay in core.holidayWeekDays)
     ###################
     self.dates = [
         date if mode==calTypes.primary else jd_to(jd, mode)
         for mode in range(len(calTypes))
     ]
     '''
     self.dates = dict([
         (
             mode, date if mode==calTypes.primary else jd_to(jd, mode)
         )
         for mode in calTypes.active
     ])
     '''
     ###################
     for k in core.plugIndex:
         plug = core.allPlugList[k]
         if plug.enable:
             try:
                 plug.update_cell(self)
             except:
                 myRaiseTback()
     ###################
     #t0 = now()
     self.eventsData = event_lib.getDayOccurrenceData(jd, eventGroups)## here? FIXME
コード例 #6
0
ファイル: starcal2.py プロジェクト: ilius/starcal2
 def getStatusIconTooltip(self):
     ##tt = core.weekDayName[core.getWeekDay(*ddate)]
     tt = core.weekDayName[core.jwday(ui.todayCell.jd)]
     #if ui.pluginsTextStatusIcon:##?????????
     #	sep = _(',')+' '
     #else:
     sep = '\n'
     for mode in calTypes.active:
         y, m, d = ui.todayCell.dates[mode]
         tt += '%s%s %s %s' % (sep, _(d), locale_man.getMonthName(
             mode, m, y), _(y))
     if ui.pluginsTextStatusIcon:
         text = ui.todayCell.pluginsText
         if text != '':
             tt += '\n\n%s' % text  ## .replace('\t', '\n') ## FIXME
     for item in ui.todayCell.eventsData:
         if not item['showInStatusIcon']:
             continue
         itemS = ''
         if item['time']:
             itemS += item['time'] + ' - '
         itemS += item['text'][0]
         tt += '\n\n%s' % itemS
     return tt
コード例 #7
0
ファイル: timeline.py プロジェクト: ErfanBagheri/starcal
def calcTimeLineData(timeStart, timeWidth, pixelPerSec, borderTm):
    timeEnd = timeStart + timeWidth
    jd0 = getJdFromEpoch(timeStart)
    jd1 = getJdFromEpoch(timeEnd)
    widthDays = float(timeWidth) / dayLen
    dayPixel = dayLen * pixelPerSec ## px
    #print 'dayPixel = %s px'%dayPixel
    getEPos = lambda epoch: (epoch-timeStart)*pixelPerSec
    getJPos = lambda jd: (getEpochFromJd(jd)-timeStart)*pixelPerSec
    ######################## Holidays
    holidays = []
    if changeHolidayBg and changeHolidayBgMinDays < widthDays < changeHolidayBgMaxDays:
        for jd in getHolidaysJdList(jd0, jd1+1):
            holidays.append(getJPos(jd))
    ######################## Ticks
    ticks = []
    tickEpochList = []
    minStep = minorStepMin / pixelPerSec ## second
    #################
    year0, month0, day0 = jd_to(jd0, core.primaryMode)
    year1, month1, day1 = jd_to(jd1, core.primaryMode)
    ############ Year
    minStepYear = minStep // minYearLenSec ## years ## int or iceil?
    yearPixel = minYearLenSec * pixelPerSec ## pixels
    for (year, size) in getYearRangeTickValues(year0, year1+1, minStepYear):
        tmEpoch = getEpochFromDate(year, 1, 1, core.primaryMode)
        if tmEpoch in tickEpochList:
            continue
        unitSize = size * yearPixel
        label = formatYear(year) if unitSize >= majorStepMin else ''
        ticks.append(Tick(
            tmEpoch,
            getEPos(tmEpoch),
            unitSize,
            label,
        ))
        tickEpochList.append(tmEpoch)
    ############ Month
    monthPixel = avgMonthLen * pixelPerSec ## px
    minMonthUnit = float(minStep) / avgMonthLen ## month
    if minMonthUnit <= 3:
        for ym in range(year0*12+month0-1, year1*12+month1-1+1):## +1 FIXME
            if ym%3==0:
                monthUnit = 3
            else:
                monthUnit = 1
            if monthUnit < minMonthUnit:
                continue
            y, m = divmod(ym, 12) ; m+=1
            tmEpoch = getEpochFromDate(y, m, 1, core.primaryMode)
            if tmEpoch in tickEpochList:
                continue
            unitSize = monthPixel * monthUnit
            ticks.append(Tick(
                tmEpoch,
                getEPos(tmEpoch),
                unitSize,
                getMonthName(core.primaryMode, m) if unitSize >= majorStepMin else '',
            ))
            tickEpochList.append(tmEpoch)
    ################
    if showWeekStart and showWeekStartMinDays < widthDays < showWeekStartMaxDays:
        wd0 = jwday(jd0)
        jdw0 = jd0 + (core.firstWeekDay - wd0) % 7
        unitSize = dayPixel * 7
        if unitSize < majorStepMin:
            label = ''
        else:
            label = core.weekDayNameAb[core.firstWeekDay]
        for jd in range(jdw0, jd1+1, 7):
            tmEpoch = getEpochFromJd(jd)
            ticks.append(Tick(
                tmEpoch,
                getEPos(tmEpoch),
                unitSize,
                label,
                color=weekStartTickColor,
            ))
            #tickEpochList.append(tmEpoch)
    ############ Day of Month
    hasMonthName = timeWidth < 5 * dayLen
    minDayUnit = float(minStep) / dayLen ## days
    if minDayUnit <= 15:
        for jd in range(jd0, jd1+1):
            tmEpoch = getEpochFromJd(jd)
            if tmEpoch in tickEpochList:
                continue
            year, month, day = jd_to(jd, core.primaryMode)
            if day==16:
                dayUnit = 15
            elif day in (6, 11, 21, 26):
                dayUnit = 5
            else:
                dayUnit = 1
            if dayUnit < minDayUnit:
                continue
            unitSize = dayPixel*dayUnit
            if unitSize < majorStepMin:
                label = ''
            elif hasMonthName:
                label = _(day) + ' ' + getMonthName(core.primaryMode, month)
            else:
                label = _(day)
            ticks.append(Tick(
                tmEpoch,
                getEPos(tmEpoch),
                unitSize,
                label,
            ))
            tickEpochList.append(tmEpoch)
    ############ Hour, Minute, Second
    for stepUnit, stepValue in unitSteps:
        stepSec = stepUnit*stepValue
        if stepSec < minStep:
            break
        unitSize = stepSec*pixelPerSec
        firstEpoch = iceil(timeStart/stepSec)*stepSec
        for tmEpoch in range(firstEpoch, iceil(timeEnd), stepSec):
            if tmEpoch in tickEpochList:
                continue
            if unitSize < majorStepMin:
                label = ''
            else:
                jd, h, m, s = getJhmsFromEpoch(tmEpoch)
                if s==0:
                    label = '%s:%s'%(
                        _(h),
                        _(m, fillZero=2),
                    )
                else:# elif timeWidth < 60 or stepSec < 30:
                    label = LRM + '%s"'%_(s, fillZero=2)
                #else:
                #    label = '%s:%s:%s'%(
                #        _(h),
                #        _(m, fillZero=2),
                #        _(s, fillZero=2),
                #    )
            ticks.append(Tick(
                tmEpoch,
                getEPos(tmEpoch),
                unitSize,
                label,
            ))
            tickEpochList.append(tmEpoch)
    ######################## Event Boxes
    return {
        'holidays': holidays,
        'ticks': ticks,
        'boxes': calcEventBoxes(
            timeStart,
            timeEnd,
            pixelPerSec,
            borderTm,
        ),
    }