Minor changes

This commit is contained in:
Loïc Guégan 2024-09-19 10:49:35 +02:00
parent f02e224d75
commit 8e24a71ea7
5 changed files with 40 additions and 8 deletions

View file

@ -6,8 +6,12 @@ class CalState:
def __init__(self): def __init__(self):
self.gotoToday() self.gotoToday()
self.selection=(self.year, self.month, self.day)
self.firstWeekDay=0 self.firstWeekDay=0
def setSelection(self, yy, mm, dd):
self.selection=(yy,mm,dd)
def setFirstWeekDay(self, i): def setFirstWeekDay(self, i):
self.firstWeekDay=i self.firstWeekDay=i

View file

@ -218,7 +218,8 @@ class CalDrawerScene(QGraphicsScene):
b=event.button() b=event.button()
if self.mouseOver>=0 and b==Qt.MouseButton.LeftButton: if self.mouseOver>=0 and b==Qt.MouseButton.LeftButton:
event.accept() event.accept()
self.selection=self.calState.getMonthDays()[self.mouseOver] s=self.calState.getMonthDays()[self.mouseOver]
self.calState.setSelection(s[0],s[1],s[2])
event = QEvent(DaySelectedEvent) event = QEvent(DaySelectedEvent)
QCoreApplication.postEvent(self.parent, event) QCoreApplication.postEvent(self.parent, event)

View file

@ -54,6 +54,9 @@
<property name="title"> <property name="title">
<string>File</string> <string>File</string>
</property> </property>
<addaction name="actionImport"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget> </widget>
<widget class="QMenu" name="menuAbout"> <widget class="QMenu" name="menuAbout">
<property name="title"> <property name="title">
@ -65,6 +68,9 @@
<string>Calendars</string> <string>Calendars</string>
</property> </property>
<addaction name="actionCreate"/> <addaction name="actionCreate"/>
<addaction name="actionEdit"/>
<addaction name="separator"/>
<addaction name="actionVisibility"/>
</widget> </widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuCalendars"/> <addaction name="menuCalendars"/>
@ -87,6 +93,26 @@
<string>Create</string> <string>Create</string>
</property> </property>
</action> </action>
<action name="actionEdit">
<property name="text">
<string>Edit</string>
</property>
</action>
<action name="actionVisibility">
<property name="text">
<string>Visibility</string>
</property>
</action>
<action name="actionImport">
<property name="text">
<string>Import</string>
</property>
</action>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

View file

@ -24,7 +24,7 @@ class EvtDrawerScene(QGraphicsScene):
self.env=env self.env=env
self.eventsRect=list() self.eventsRect=list()
self.eventsList=list() self.eventsList=list()
self.setDay(self.env.calState.today()) self.calStateChanged()
def drawForeground(self, painter, rect): def drawForeground(self, painter, rect):
self.eventsRect.clear() self.eventsRect.clear()
@ -62,9 +62,10 @@ class EvtDrawerScene(QGraphicsScene):
r=self.eventsRect[i] r=self.eventsRect[i]
painter.drawText(r.x(),r.y()+labelH,"Hello event") painter.drawText(r.x(),r.y()+labelH,"Hello event")
def setDay(self, day): def calStateChanged(self):
self.eventsList=self.env.listEventsOn(day[0],day[1],day[2]) s=self.env.calState.selection
self.update() self.eventsList=self.env.listEventsOn(s[0],s[1],s[2])
self.update()
class EvtDrawer(): class EvtDrawer():
@ -87,5 +88,5 @@ class EvtDrawer():
# self.gv.setSizePolicy(spLeft); # self.gv.setSizePolicy(spLeft);
layout.addWidget(self.gv) layout.addWidget(self.gv)
def setDay(self,day): def calStateChanged(self):
self.gs.setDay(day) self.gs.calStateChanged()

View file

@ -26,7 +26,7 @@ class MainWindow(QMainWindow):
def event(self, event): def event(self, event):
if event.type() == DaySelectedEvent: if event.type() == DaySelectedEvent:
self.evtDrawer.setDay(self.calDrawer.getSelection()) self.evtDrawer.calStateChanged()
return QWidget.event(self,event) #super().event(event) return QWidget.event(self,event) #super().event(event)
def StartApplication(env): def StartApplication(env):