author | zautrix <zautrix> | 2005-02-16 22:08:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-16 22:08:18 (UTC) |
commit | 451b4de59893b5c0801a7bbb2f8cbe8e0266b324 (patch) (unidiff) | |
tree | ce3f535541583d37cfe951ddd8d7474770d9c374 /korganizer/datenavigator.cpp | |
parent | b2cf8e9a08082539e0a5578a98766e5990783f9a (diff) | |
download | kdepimpi-451b4de59893b5c0801a7bbb2f8cbe8e0266b324.zip kdepimpi-451b4de59893b5c0801a7bbb2f8cbe8e0266b324.tar.gz kdepimpi-451b4de59893b5c0801a7bbb2f8cbe8e0266b324.tar.bz2 |
month view fixes
-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 | |||
@@ -38,96 +38,102 @@ DateNavigator::DateNavigator( QObject *parent, const char *name , KOViewManager | |||
38 | { | 38 | { |
39 | mViewManager = v; | 39 | mViewManager = v; |
40 | mSelectedDates.append( QDate::currentDate() ); | 40 | mSelectedDates.append( QDate::currentDate() ); |
41 | } | 41 | } |
42 | 42 | ||
43 | DateNavigator::~DateNavigator() | 43 | DateNavigator::~DateNavigator() |
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | void DateNavigator::slotMonthSelect( int m ) | 47 | void DateNavigator::slotMonthSelect( int m ) |
48 | { | 48 | { |
49 | QDate firstSelected = mSelectedDates.first(); | 49 | QDate firstSelected = mSelectedDates.first(); |
50 | int weekDay = firstSelected.dayOfWeek(); | 50 | int weekDay = firstSelected.dayOfWeek(); |
51 | int diff = m - firstSelected.month() ; | 51 | int diff = m - firstSelected.month() ; |
52 | firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, diff ); | 52 | firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, diff ); |
53 | 53 | ||
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 | } |
118 | 124 | ||
119 | void DateNavigator::selectDates( int count ) | 125 | void DateNavigator::selectDates( int count ) |
120 | { | 126 | { |
121 | 127 | ||
122 | QDate d = mSelectedDates.first(); | 128 | QDate d = mSelectedDates.first(); |
123 | selectDates( d, count ); | 129 | selectDates( d, count ); |
124 | } | 130 | } |
125 | 131 | ||
126 | void DateNavigator::selectDates( const QDate &d, int count ) | 132 | void DateNavigator::selectDates( const QDate &d, int count ) |
127 | { | 133 | { |
128 | DateList dates; | 134 | DateList dates; |
129 | 135 | ||
130 | int i; | 136 | int i; |
131 | for( i = 0; i < count; ++i ) { | 137 | for( i = 0; i < count; ++i ) { |
132 | dates.append( d.addDays( i ) ); | 138 | dates.append( d.addDays( i ) ); |
133 | } | 139 | } |
@@ -213,88 +219,97 @@ void DateNavigator::selectTodayMonth() | |||
213 | selectDates( date , date.daysInMonth ()); | 219 | selectDates( date , date.daysInMonth ()); |
214 | 220 | ||
215 | } | 221 | } |
216 | void DateNavigator::selectToday() | 222 | void DateNavigator::selectToday() |
217 | { | 223 | { |
218 | QDate d = QDate::currentDate(); | 224 | QDate d = QDate::currentDate(); |
219 | 225 | ||
220 | int dateCount = mSelectedDates.count(); | 226 | int dateCount = mSelectedDates.count(); |
221 | if ( dateCount == 5 && d.dayOfWeek() < 6 ) selectWorkWeek( d ); | 227 | if ( dateCount == 5 && d.dayOfWeek() < 6 ) selectWorkWeek( d ); |
222 | else if ( dateCount == 7 ) selectWeek( d ); | 228 | else if ( dateCount == 7 ) selectWeek( d ); |
223 | else selectDates( d, dateCount ); | 229 | else selectDates( d, dateCount ); |
224 | } | 230 | } |
225 | 231 | ||
226 | void DateNavigator::selectPreviousYear() | 232 | void DateNavigator::selectPreviousYear() |
227 | { | 233 | { |
228 | QDate firstSelected = mSelectedDates.first(); | 234 | QDate firstSelected = mSelectedDates.first(); |
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() ); |
293 | } | 308 | } |
294 | 309 | ||
295 | void DateNavigator::emitSelected() | 310 | void DateNavigator::emitSelected() |
296 | { | 311 | { |
297 | emit datesSelected( mSelectedDates ); | 312 | emit datesSelected( mSelectedDates ); |
298 | } | 313 | } |
299 | 314 | ||
300 | //#include "datenavigator.moc" | 315 | //#include "datenavigator.moc" |