コード例 #1
0
ファイル: ui.py プロジェクト: karoon/starcal2
def monthPlus(plus=1):
    global cell
    if plus==1:
        (year, month) = getNextMonth(cell.year, cell.month)
    elif plus==-1:
        (year, month) = getPrevMonth(cell.year, cell.month)
    else:
        raise ValueError('monthPlus: bad argument %s'%plus)
    day = min(cell.day, getMonthLen(year, month, core.primaryMode))
    cell = cellCache.getCellByDate(year, month, day)
コード例 #2
0
ファイル: monthcal.py プロジェクト: karoon/starcal2
 def keyPressEvent(self, event):
     k = event.key()
     print time(), 'MonthCal.keyPressEvent', k, hex(k)
     if k==qc.Qt.Key_Up:
         self.jdPlus(-7)
     elif k==qc.Qt.Key_Down:
         self.jdPlus(7)
     elif k==qc.Qt.Key_Right:
         if rtl:
             self.jdPlus(-1)
         else:
             self.jdPlus(1)
     elif k==qc.Qt.Key_Left:
         if rtl:
             self.jdPlus(1)
         else:
             self.jdPlus(-1)
     elif k==qc.Qt.Key_Space or k==qc.Qt.Key_Home:
         self.goToday()
     elif k==qc.Qt.Key_End:
         self.changeDate(ui.cell.year, ui.cell.month, getMonthLen(ui.cell.year, ui.cell.month, core.primaryMode))
     elif k==qc.Qt.Key_End:
         self.changeDate(ui.cell.year, ui.cell.month, getMonthLen(ui.cell.year, ui.cell.month, core.primaryMode))
     elif k==qc.Qt.Key_PageUp:
         (year, month) = getPrevMonth(ui.cell.year, ui.cell.month)
         self.changeDate(year, month, ui.cell.day)
     elif k==qc.Qt.Key_PageDown:
         (year, month) = getNextMonth(ui.cell.year, ui.cell.month)
         self.changeDate(year, month, ui.cell.day)
     elif k==qc.Qt.Key_Menu:# Simulate right click (key beside Right-Ctrl)
         self.emit(qc.SIGNAL('popup-menu-cell'), *self.getCellPos())
     elif k in (qc.Qt.Key_F10, qc.Qt.Key_M):
         #print 'keyPressEvent: menu', event.modifiers()
         if event.modifiers() & qc.Qt.ShiftModifier:
             ## Simulate right click (key beside Right-Ctrl)
             print 'popup-menu-cell'
             self.emit(qc.SIGNAL('popup-menu-cell'), *self.getCellPos())
         else:
             print 'popup-menu-main'
             self.emit(qc.SIGNAL('popup-menu-main'), *self.getMainMenuPos())
     else:
         event.ignore() ## I dont want the event. Propagate to the parent widget.
         #print time(), 'MonthCal.keyPressEvent', hex(k)
         return
     event.accept() ## I want the event. Do not propagate to the parent widget.