author | zautrix <zautrix> | 2005-03-19 22:56:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-19 22:56:08 (UTC) |
commit | 84c18843bbd1203878367572d3a6800a0586c7f1 (patch) (unidiff) | |
tree | 9f58b7356ea700d47e6ec84fb4a462a666a24049 /korganizer/kodaymatrix.cpp | |
parent | 39b719bdc75d95913c3aaf9a03aaa57b1161cc61 (diff) | |
download | kdepimpi-84c18843bbd1203878367572d3a6800a0586c7f1.zip kdepimpi-84c18843bbd1203878367572d3a6800a0586c7f1.tar.gz kdepimpi-84c18843bbd1203878367572d3a6800a0586c7f1.tar.bz2 |
mochn fix
-rw-r--r-- | korganizer/kodaymatrix.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index a886f4a..17a8546 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -108,193 +108,193 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const | |||
108 | mDefaultBackColor = palette().active().base(); | 108 | mDefaultBackColor = palette().active().base(); |
109 | mDefaultTextColor = palette().active().foreground(); | 109 | mDefaultTextColor = palette().active().foreground(); |
110 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 110 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
111 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 111 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
112 | mSelectedDaysColor = QColor("white"); | 112 | mSelectedDaysColor = QColor("white"); |
113 | mTodayMarginWidth = 2; | 113 | mTodayMarginWidth = 2; |
114 | mSelEnd = mSelStart = NOSELECTION; | 114 | mSelEnd = mSelStart = NOSELECTION; |
115 | 115 | ||
116 | setAcceptDrops(true); | 116 | setAcceptDrops(true); |
117 | //setFont( QFont("Arial", 10) ); | 117 | //setFont( QFont("Arial", 10) ); |
118 | 118 | ||
119 | mUpdateTimer = new QTimer( this ); | 119 | mUpdateTimer = new QTimer( this ); |
120 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 120 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
121 | mRepaintTimer = new QTimer( this ); | 121 | mRepaintTimer = new QTimer( this ); |
122 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 122 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
123 | mDayChanged = false; | 123 | mDayChanged = false; |
124 | updateView(); | 124 | updateView(); |
125 | } | 125 | } |
126 | void KODayMatrix::setCalendar( Calendar *cal ) | 126 | void KODayMatrix::setCalendar( Calendar *cal ) |
127 | { | 127 | { |
128 | mCalendar = cal; | 128 | mCalendar = cal; |
129 | 129 | ||
130 | setAcceptDrops( mCalendar ); | 130 | setAcceptDrops( mCalendar ); |
131 | 131 | ||
132 | updateEvents(); | 132 | updateEvents(); |
133 | } | 133 | } |
134 | 134 | ||
135 | QColor KODayMatrix::getShadedColor(QColor color) | 135 | QColor KODayMatrix::getShadedColor(QColor color) |
136 | { | 136 | { |
137 | QColor shaded; | 137 | QColor shaded; |
138 | int h=0; | 138 | int h=0; |
139 | int s=0; | 139 | int s=0; |
140 | int v=0; | 140 | int v=0; |
141 | color.hsv(&h,&s,&v); | 141 | color.hsv(&h,&s,&v); |
142 | s = s/4; | 142 | s = s/4; |
143 | v = 192+v/4; | 143 | v = 192+v/4; |
144 | shaded.setHsv(h,s,v); | 144 | shaded.setHsv(h,s,v); |
145 | 145 | ||
146 | return shaded; | 146 | return shaded; |
147 | } | 147 | } |
148 | 148 | ||
149 | KODayMatrix::~KODayMatrix() | 149 | KODayMatrix::~KODayMatrix() |
150 | { | 150 | { |
151 | delete [] days; | 151 | delete [] days; |
152 | delete [] daylbls; | 152 | delete [] daylbls; |
153 | delete [] events; | 153 | delete [] events; |
154 | delete mToolTip; | 154 | delete mToolTip; |
155 | } | 155 | } |
156 | 156 | ||
157 | /* | 157 | /* |
158 | void KODayMatrix::setStartDate(QDate start) | 158 | void KODayMatrix::setStartDate(QDate start) |
159 | { | 159 | { |
160 | updateView(start); | 160 | updateView(start); |
161 | } | 161 | } |
162 | */ | 162 | */ |
163 | 163 | ||
164 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 164 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
165 | { | 165 | { |
166 | 166 | ||
167 | if (mSelStart == NOSELECTION) { | 167 | if (mSelStart == NOSELECTION) { |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | 170 | ||
171 | //cope with selection being out of matrix limits at top (< 0) | 171 | //cope with selection being out of matrix limits at top (< 0) |
172 | int i0 = mSelStart; | 172 | int i0 = mSelStart; |
173 | if (i0 < 0) { | 173 | if (i0 < 0) { |
174 | for (int i = i0; i < 0; i++) { | 174 | for (int i = i0; i < 0; i++) { |
175 | selDays.append(days[0].addDays(i)); | 175 | selDays.append(days[0].addDays(i)); |
176 | } | 176 | } |
177 | i0 = 0; | 177 | i0 = 0; |
178 | } | 178 | } |
179 | 179 | ||
180 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 180 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
181 | if (mSelEnd > NUMDAYS-1) { | 181 | if (mSelEnd > NUMDAYS-1) { |
182 | for (int i = i0; i <= NUMDAYS-1; i++) { | 182 | for (int i = i0; i <= NUMDAYS-1; i++) { |
183 | selDays.append(days[i]); | 183 | selDays.append(days[i]); |
184 | } | 184 | } |
185 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 185 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
186 | selDays.append(days[0].addDays(i)); | 186 | selDays.append(days[0].addDays(i)); |
187 | } | 187 | } |
188 | 188 | ||
189 | // apply normal routine to selection being entirely within matrix limits | 189 | // apply normal routine to selection being entirely within matrix limits |
190 | } else { | 190 | } else { |
191 | for (int i = i0; i <= mSelEnd; i++) { | 191 | for (int i = i0; i <= mSelEnd; i++) { |
192 | selDays.append(days[i]); | 192 | selDays.append(days[i]); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 197 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
198 | { | 198 | { |
199 | mSelStart = startdate.daysTo(start); | 199 | mSelStart = startdate.daysTo(start); |
200 | mSelEnd = startdate.daysTo(end); | 200 | mSelEnd = startdate.daysTo(end); |
201 | } | 201 | } |
202 | void KODayMatrix::clearSelection() | 202 | void KODayMatrix::clearSelection() |
203 | { | 203 | { |
204 | mSelEnd = mSelStart = NOSELECTION; | 204 | mSelEnd = mSelStart = NOSELECTION; |
205 | } | 205 | } |
206 | 206 | ||
207 | 207 | ||
208 | void KODayMatrix::recalculateToday() | 208 | void KODayMatrix::recalculateToday() |
209 | { | 209 | { |
210 | today = -1; | 210 | today = -1; |
211 | for (int i=0; i<NUMDAYS; i++) { | 211 | for (int i=0; i<NUMDAYS; i++) { |
212 | events[i] = 0; | 212 | events[i] = 0; |
213 | days[i] = startdate.addDays(i); | 213 | days[i] = startdate.addDays(i); |
214 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 214 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
215 | 215 | ||
216 | // if today is in the currently displayed month, hilight today | 216 | // if today is in the currently displayed month, hilight today |
217 | if (days[i].year() == QDate::currentDate().year() && | 217 | if (days[i].year() == QDate::currentDate().year() && |
218 | days[i].month() == QDate::currentDate().month() && | 218 | days[i].month() == QDate::currentDate().month() && |
219 | days[i].day() == QDate::currentDate().day()) { | 219 | days[i].day() == QDate::currentDate().day()) { |
220 | today = i; | 220 | today = i; |
221 | } | 221 | } |
222 | } | 222 | } |
223 | // qDebug(QString("Today is visible at %1.").arg(today)); | 223 | // qDebug(QString("Today is visible at %1.").arg(today)); |
224 | } | 224 | } |
225 | 225 | ||
226 | void KODayMatrix::updateView() | 226 | void KODayMatrix::updateView() |
227 | { | 227 | { |
228 | updateView(startdate); | 228 | updateView(startdate); |
229 | } | 229 | } |
230 | void KODayMatrix::repaintViewTimed() | 230 | void KODayMatrix::repaintViewTimed() |
231 | { | 231 | { |
232 | mRepaintTimer->stop(); | 232 | mRepaintTimer->stop(); |
233 | repaint(false); | 233 | repaint(false); |
234 | } | 234 | } |
235 | void KODayMatrix::updateViewTimed() | 235 | void KODayMatrix::updateViewTimed() |
236 | { | 236 | { |
237 | mUpdateTimer->stop(); | 237 | mUpdateTimer->stop(); |
238 | if ( !mCalendar ) { | 238 | if ( !mCalendar ) { |
239 | qDebug("NOT CAL "); | 239 | qDebug("NOT CAL "); |
240 | return; | 240 | return; |
241 | } | 241 | } |
242 | //qDebug("KODayMatrix::updateViewTimed "); | 242 | //qDebug("KODayMatrix::updateViewTimed "); |
243 | for(int i = 0; i < NUMDAYS; i++) { | 243 | for(int i = 0; i < NUMDAYS; i++) { |
244 | // if events are set for the day then remember to draw it bold | 244 | // if events are set for the day then remember to draw it bold |
245 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 245 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
246 | Event *event; | 246 | Event *event; |
247 | int numEvents = eventlist.count(); | 247 | int numEvents = eventlist.count(); |
248 | QString holiStr = ""; | 248 | QString holiStr = ""; |
249 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 249 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
250 | ushort recurType = event->recurrence()->doesRecur(); | 250 | ushort recurType = event->recurrence()->doesRecur(); |
251 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 251 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
252 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 252 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
253 | numEvents--; | 253 | numEvents--; |
254 | } | 254 | } |
255 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | 255 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { |
256 | if ( !holiStr.isEmpty() ) | 256 | if ( !holiStr.isEmpty() ) |
257 | holiStr += "\n"; | 257 | holiStr += "\n"; |
258 | holiStr += event->summary(); | 258 | holiStr += event->summary(); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | events[i] = numEvents; | 261 | events[i] = numEvents; |
262 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 262 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
263 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 263 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
264 | !holiStr.isEmpty()) { | 264 | !holiStr.isEmpty()) { |
265 | mHolidays[i] = holiStr; | 265 | mHolidays[i] = holiStr; |
266 | } else { | 266 | } else { |
267 | mHolidays[i] = QString::null; | 267 | mHolidays[i] = QString::null; |
268 | } | 268 | } |
269 | } | 269 | } |
270 | if ( ! mPendingUpdateBeforeRepaint ) | 270 | if ( ! mPendingUpdateBeforeRepaint ) |
271 | repaint(false); | 271 | repaint(false); |
272 | } | 272 | } |
273 | void KODayMatrix::updateView(QDate actdate) | 273 | void KODayMatrix::updateView(QDate actdate) |
274 | { | 274 | { |
275 | 275 | ||
276 | if ( ! actdate.isValid() ) { | 276 | if ( ! actdate.isValid() ) { |
277 | //qDebug("date not valid "); | 277 | //qDebug("date not valid "); |
278 | return; | 278 | return; |
279 | } | 279 | } |
280 | mDayChanged = false; | 280 | mDayChanged = false; |
281 | //flag to indicate if the starting day of the matrix has changed by this call | 281 | //flag to indicate if the starting day of the matrix has changed by this call |
282 | //mDayChanged = false; | 282 | //mDayChanged = false; |
283 | // if a new startdate is to be set then apply Cornelius's calculation | 283 | // if a new startdate is to be set then apply Cornelius's calculation |
284 | // of the first day to be shown | 284 | // of the first day to be shown |
285 | if (actdate != startdate) { | 285 | if (actdate != startdate) { |
286 | // reset index of selection according to shift of starting date from startdate to actdate | 286 | // reset index of selection according to shift of starting date from startdate to actdate |
287 | if (mSelStart != NOSELECTION) { | 287 | if (mSelStart != NOSELECTION) { |
288 | int tmp = actdate.daysTo(startdate); | 288 | int tmp = actdate.daysTo(startdate); |
289 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 289 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
290 | // shift selection if new one would be visible at least partly ! | 290 | // shift selection if new one would be visible at least partly ! |
291 | 291 | ||
292 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 292 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
293 | // nested if is required for next X display pushed from a different month - correction required | 293 | // nested if is required for next X display pushed from a different month - correction required |
294 | // otherwise, for month forward and backward, it must be avoided | 294 | // otherwise, for month forward and backward, it must be avoided |
295 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 295 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
296 | mSelStart = mSelStart + tmp; | 296 | mSelStart = mSelStart + tmp; |
297 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 297 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
298 | mSelEnd = mSelEnd + tmp; | 298 | mSelEnd = mSelEnd + tmp; |
299 | } | 299 | } |
300 | } | 300 | } |