-rw-r--r-- | korganizer/datenavigator.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/korganizer/datenavigator.cpp b/korganizer/datenavigator.cpp index 8b7c993..b0eac51 100644 --- a/korganizer/datenavigator.cpp +++ b/korganizer/datenavigator.cpp | |||
@@ -54,64 +54,70 @@ void DateNavigator::slotMonthSelect( int m ) | |||
54 | if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) | 54 | if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) |
55 | selectMonthByDate( firstSelected ); | 55 | selectMonthByDate( firstSelected ); |
56 | else | 56 | else |
57 | selectWeekByDay( weekDay, firstSelected ); | 57 | selectWeekByDay( weekDay, firstSelected ); |
58 | 58 | ||
59 | } | 59 | } |
60 | 60 | ||
61 | void DateNavigator::slotDaySelect( QDate d ) | 61 | void DateNavigator::slotDaySelect( QDate d ) |
62 | { | 62 | { |
63 | QDate firstSelected = mSelectedDates.first(); | 63 | QDate firstSelected = mSelectedDates.first(); |
64 | int weekDay = firstSelected.dayOfWeek(); | 64 | int weekDay = firstSelected.dayOfWeek(); |
65 | //int diff = firstSelected.daysTo( d ) ; | 65 | //int diff = firstSelected.daysTo( d ) ; |
66 | firstSelected = firstSelected.addDays( firstSelected .daysTo( d ) ); | 66 | firstSelected = firstSelected.addDays( firstSelected .daysTo( d ) ); |
67 | 67 | ||
68 | selectWeekByDay( weekDay, firstSelected ); | 68 | selectWeekByDay( weekDay, firstSelected ); |
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | void DateNavigator::selectMonthByDate( const QDate & firstSelected ) | 72 | void DateNavigator::selectMonthByDate( const QDate & firstSelected ) |
73 | { | 73 | { |
74 | 74 | ||
75 | int monthDay = firstSelected.day(); | 75 | int monthDay = firstSelected.day(); |
76 | QDate date = firstSelected.addDays( 1-monthDay ); | 76 | QDate date = firstSelected.addDays( 1-monthDay ); |
77 | selectDates( date , date.daysInMonth ()); | 77 | selectDates( date , date.daysInMonth ()); |
78 | 78 | ||
79 | } | 79 | } |
80 | void DateNavigator::selectMonth() | 80 | void DateNavigator::selectMonth() |
81 | { | 81 | { |
82 | 82 | ||
83 | QDate date =mSelectedDates.first(); | 83 | QDate date =mSelectedDates.first(); |
84 | selectMonthByDate( date ); | 84 | selectMonthByDate( date ); |
85 | } | 85 | } |
86 | void DateNavigator::selectMonthFromMonthview() | ||
87 | { | ||
88 | |||
89 | QDate date =mSelectedDates.first().addDays( 7 ); | ||
90 | selectMonthByDate( date ); | ||
91 | } | ||
86 | 92 | ||
87 | DateList DateNavigator::selectedDates() | 93 | DateList DateNavigator::selectedDates() |
88 | { | 94 | { |
89 | return mSelectedDates; | 95 | return mSelectedDates; |
90 | } | 96 | } |
91 | 97 | ||
92 | int DateNavigator::datesCount() const | 98 | int DateNavigator::datesCount() const |
93 | { | 99 | { |
94 | return mSelectedDates.count(); | 100 | return mSelectedDates.count(); |
95 | } | 101 | } |
96 | 102 | ||
97 | void DateNavigator::selectDates( const DateList& dateList ) | 103 | void DateNavigator::selectDates( const DateList& dateList ) |
98 | { | 104 | { |
99 | if (dateList.count() > 0) { | 105 | if (dateList.count() > 0) { |
100 | mSelectedDates = dateList; | 106 | mSelectedDates = dateList; |
101 | emitSelected(); | 107 | emitSelected(); |
102 | } | 108 | } |
103 | } | 109 | } |
104 | 110 | ||
105 | void DateNavigator::selectDate( const QDate &date ) | 111 | void DateNavigator::selectDate( const QDate &date ) |
106 | { | 112 | { |
107 | QDate d = date; | 113 | QDate d = date; |
108 | 114 | ||
109 | if ( !d.isValid() ) { | 115 | if ( !d.isValid() ) { |
110 | d = QDate::currentDate(); | 116 | d = QDate::currentDate(); |
111 | } | 117 | } |
112 | 118 | ||
113 | mSelectedDates.clear(); | 119 | mSelectedDates.clear(); |
114 | mSelectedDates.append( d ); | 120 | mSelectedDates.append( d ); |
115 | 121 | ||
116 | emitSelected(); | 122 | emitSelected(); |
117 | } | 123 | } |
@@ -229,64 +235,73 @@ void DateNavigator::selectPreviousYear() | |||
229 | int weekDay = firstSelected.dayOfWeek(); | 235 | int weekDay = firstSelected.dayOfWeek(); |
230 | firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, -1 ); | 236 | firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, -1 ); |
231 | 237 | ||
232 | selectWeekByDay( weekDay, firstSelected ); | 238 | selectWeekByDay( weekDay, firstSelected ); |
233 | } | 239 | } |
234 | 240 | ||
235 | void DateNavigator::selectPreviousMonth() | 241 | void DateNavigator::selectPreviousMonth() |
236 | { | 242 | { |
237 | QDate firstSelected = mSelectedDates.first(); | 243 | QDate firstSelected = mSelectedDates.first(); |
238 | int weekDay = firstSelected.dayOfWeek(); | 244 | int weekDay = firstSelected.dayOfWeek(); |
239 | firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, -1 ); | 245 | firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, -1 ); |
240 | 246 | ||
241 | 247 | ||
242 | if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) | 248 | if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) |
243 | selectMonthByDate( firstSelected ); | 249 | selectMonthByDate( firstSelected ); |
244 | else | 250 | else |
245 | selectWeekByDay( weekDay, firstSelected ); | 251 | selectWeekByDay( weekDay, firstSelected ); |
246 | } | 252 | } |
247 | 253 | ||
248 | void DateNavigator::selectNextMonth() | 254 | void DateNavigator::selectNextMonth() |
249 | { | 255 | { |
250 | QDate firstSelected = mSelectedDates.first(); | 256 | QDate firstSelected = mSelectedDates.first(); |
251 | int weekDay = firstSelected.dayOfWeek(); | 257 | int weekDay = firstSelected.dayOfWeek(); |
252 | 258 | ||
253 | firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, 1 ); | 259 | firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, 1 ); |
254 | 260 | ||
255 | if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) | 261 | if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) |
256 | selectMonthByDate( firstSelected ); | 262 | selectMonthByDate( firstSelected ); |
257 | else | 263 | else |
258 | selectWeekByDay( weekDay, firstSelected ); | 264 | selectWeekByDay( weekDay, firstSelected ); |
259 | 265 | ||
260 | } | 266 | } |
267 | void DateNavigator::selectPreviousWeek() | ||
268 | { | ||
269 | selectDates( mSelectedDates.first().addDays( -7 ), datesCount() ); | ||
270 | } | ||
271 | |||
272 | void DateNavigator::selectNextWeek() | ||
273 | { | ||
274 | selectDates( mSelectedDates.first().addDays( 7 ), datesCount() ); | ||
275 | } | ||
261 | 276 | ||
262 | void DateNavigator::selectNextYear() | 277 | void DateNavigator::selectNextYear() |
263 | { | 278 | { |
264 | QDate firstSelected = mSelectedDates.first(); | 279 | QDate firstSelected = mSelectedDates.first(); |
265 | int weekDay = firstSelected.dayOfWeek(); | 280 | int weekDay = firstSelected.dayOfWeek(); |
266 | firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, 1 ); | 281 | firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, 1 ); |
267 | 282 | ||
268 | selectWeekByDay( weekDay, firstSelected ); | 283 | selectWeekByDay( weekDay, firstSelected ); |
269 | } | 284 | } |
270 | 285 | ||
271 | void DateNavigator::selectPrevious() | 286 | void DateNavigator::selectPrevious() |
272 | { | 287 | { |
273 | int offset = -7; | 288 | int offset = -7; |
274 | if ( datesCount() == 1 ) { | 289 | if ( datesCount() == 1 ) { |
275 | offset = -1; | 290 | offset = -1; |
276 | } | 291 | } |
277 | if ( mViewManager ) | 292 | if ( mViewManager ) |
278 | if ( mViewManager->showsNextDays() ) | 293 | if ( mViewManager->showsNextDays() ) |
279 | offset = -datesCount(); | 294 | offset = -datesCount(); |
280 | selectDates( mSelectedDates.first().addDays( offset ), datesCount() ); | 295 | selectDates( mSelectedDates.first().addDays( offset ), datesCount() ); |
281 | } | 296 | } |
282 | 297 | ||
283 | void DateNavigator::selectNext() | 298 | void DateNavigator::selectNext() |
284 | { | 299 | { |
285 | int offset = 7; | 300 | int offset = 7; |
286 | if ( datesCount() == 1 ) { | 301 | if ( datesCount() == 1 ) { |
287 | offset = 1; | 302 | offset = 1; |
288 | } | 303 | } |
289 | if ( mViewManager ) | 304 | if ( mViewManager ) |
290 | if ( mViewManager->showsNextDays() ) | 305 | if ( mViewManager->showsNextDays() ) |
291 | offset = datesCount(); | 306 | offset = datesCount(); |
292 | selectDates( mSelectedDates.first().addDays( offset ), datesCount() ); | 307 | selectDates( mSelectedDates.first().addDays( offset ), datesCount() ); |