Exemplo n.º 1
0
 def addException(self):
     date = self.exceptionDateEdit.date()
     dateVar = QVariant(date)
     for num in xrange(self.exceptionList.count()):
         item = self.exceptionList.item(num)
         if item.data(Roles.DateRole) == dateVar:
             return
     
     item = DateSortedListWidgetItem(date.toString(Qt.DefaultLocaleLongDate))
     item.setData(Roles.DateRole,  dateVar)
     # Do not use self.exceptionList as parent, because this widget is sorted
     self.exceptionList.addItem(item)
     self.exceptionList.setCurrentItem(item)
Exemplo n.º 2
0
    def loadEntry(self,  type,  days,  exceptions,  start,  end,  interval):
        self.lastType = type
        self.lastDays = days
        self.lastExceptions = exceptions
        self.lastStart = start
        self.lastEnd = end
        self.lastInterval = interval

        self.recurrenceBox.setChecked(bool(type))

        if type:
            self.endingDateBox.setChecked(not bool(end and end.isValid()))
            if end and end.isValid():
                self.endDate.setDateTime(end)
            else:
                self.endDate.setDateTime(start.addYears(1))

            parsedDays = CalendarEntry.recurrenceParsedDays(type,  days)

            if type == "daily":
                self.dailyButton.click()
                self.recurDayBox.setValue(interval)
            elif type == "weekly":
                self.weeklyButton.click()
                self.recurWeekBox.setValue(interval)

                self.mondayBox.setChecked(0 in parsedDays)
                self.tuesdayBox.setChecked(1 in parsedDays)
                self.wednesdayBox.setChecked(2 in parsedDays)
                self.thursdayBox.setChecked(3 in parsedDays)
                self.fridayBox.setChecked(4 in parsedDays)
                self.saturdayBox.setChecked(5 in parsedDays)
                self.sundayBox.setChecked(6 in parsedDays)
            elif type == "monthly_by_dates":
                self.monthlyButton.click()
                self.monthlyByDatesButton.click()
                self.recurMonthBox.setValue(interval)

                self.monthlyDayInMonthBox.setCurrentIndex(self.monthlyDayInMonthBox.findData(QVariant(parsedDays[0]+1)))
            elif type == "monthly_by_days":
                week = parsedDays[0]['week'] + 1
                day = parsedDays[0]['day'] + 1

                self.monthlyButton.click()
                self.monthlyByDaysButton.click()
                self.recurMonthBox.setValue(interval)

                self.monthlyWeekInMonthBox.setCurrentIndex(self.monthlyWeekInMonthBox.findData(QVariant(week)))
                self.monthlyDayInWeekBox.setCurrentIndex(self.monthlyDayInWeekBox.findData(QVariant(day)))
            elif type == "yearly_by_date":
                self.yearlyButton.click()
                self.yearlyByDateButton.click()
                self.recurYearBox.setValue(interval)

                self.yearlyDayInMonthBox.setValue(start.date().day())
                self.yearlyMonthInYearBox_ByDate.setCurrentIndex(self.yearlyMonthInYearBox_ByDate.findData(QVariant(start.date().month())))
            elif type == "yearly_by_day":
                week = parsedDays['week'] + 1
                day = parsedDays['day'] + 1
                month = parsedDays['month'] + 1

                self.yearlyButton.click()
                self.yearlyByDaysButton.click()
                self.recurYearBox.setValue(interval)

                self.yearlyWeekInMonthBox.setCurrentIndex(self.yearlyWeekInMonthBox.findData(QVariant(week)))
                self.yearlyDayInWeekBox.setCurrentIndex(self.yearlyDayInWeekBox.findData(QVariant(day)))
                self.yearlyMonthInYearBox_ByDay.setCurrentIndex(self.yearlyMonthInYearBox_ByDay.findData(QVariant(month)))
            
            self.exceptionList.clear()
            if exceptions:
                for date in exceptions.split(","):
                    date = QDateTime.fromTime_t(int(float(date))).date()
                    item = DateSortedListWidgetItem(date.toString(Qt.DefaultLocaleLongDate))
                    item.setData(Roles.DateRole,  QVariant(date))
                    self.exceptionList.addItem(item)