summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-30 14:15:42 (UTC)
committer zautrix <zautrix>2005-01-30 14:15:42 (UTC)
commit8d543aa1d1d1ed20001c8b18352d1d29c2979e48 (patch) (unidiff)
tree9ca05f4d3bc1de81bcf0446a2f7471d552089c87 /korganizer
parent1bcef8b3f53419e7155e0862ad61e3e419763d70 (diff)
downloadkdepimpi-8d543aa1d1d1ed20001c8b18352d1d29c2979e48.zip
kdepimpi-8d543aa1d1d1ed20001c8b18352d1d29c2979e48.tar.gz
kdepimpi-8d543aa1d1d1ed20001c8b18352d1d29c2979e48.tar.bz2
many fixes
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kdatenavigator.cpp4
-rw-r--r--korganizer/koagendaitem.cpp5
-rw-r--r--korganizer/kodaymatrix.cpp100
-rw-r--r--korganizer/kodaymatrix.h5
4 files changed, 78 insertions, 36 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index b420351..f31e50a 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -216,25 +216,25 @@ void KDateNavigator::updateDates()
216 // update the matrix dates 216 // update the matrix dates
217 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; 217 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
218 218
219 219
220 daymatrix->updateView(dayone.addDays(index)); 220 daymatrix->updateView(dayone.addDays(index));
221//each updateDates is followed by an updateView -> repaint is issued there ! 221//each updateDates is followed by an updateView -> repaint is issued there !
222// daymatrix->repaint(); 222// daymatrix->repaint();
223} 223}
224 224
225void KDateNavigator::updateDayMatrix() 225void KDateNavigator::updateDayMatrix()
226{ 226{
227 daymatrix->updateView(); 227 daymatrix->updateView();
228 daymatrix->repaint(); 228 //daymatrix->repaint();
229} 229}
230 230
231 231
232void KDateNavigator::updateView() 232void KDateNavigator::updateView()
233{ 233{
234 234
235 setUpdatesEnabled( false ); 235 setUpdatesEnabled( false );
236 236
237 int i; 237 int i;
238 238
239// kdDebug() << "updateView() -> daymatrix->updateView()" << endl; 239// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
240 daymatrix->updateView(); 240 daymatrix->updateView();
@@ -253,25 +253,25 @@ void KDateNavigator::updateView()
253 if ( ! KGlobal::locale()->weekStartsMonday() ) 253 if ( ! KGlobal::locale()->weekStartsMonday() )
254 ++add; 254 ++add;
255 if (dayOfYear % 7 != 0) 255 if (dayOfYear % 7 != 0)
256 weeknum.setNum(dayOfYear / 7 + 1+add); 256 weeknum.setNum(dayOfYear / 7 + 1+add);
257 else 257 else
258 weeknum.setNum(dayOfYear / 7 +add); 258 weeknum.setNum(dayOfYear / 7 +add);
259 weeknos[i]->setText(weeknum); 259 weeknos[i]->setText(weeknum);
260 } 260 }
261 261
262 setUpdatesEnabled( true ); 262 setUpdatesEnabled( true );
263// kdDebug() << "updateView() -> repaint()" << endl; 263// kdDebug() << "updateView() -> repaint()" << endl;
264 repaint(); 264 repaint();
265 daymatrix->repaint(); 265 // daymatrix->repaint();
266} 266}
267 267
268void KDateNavigator::updateConfig() 268void KDateNavigator::updateConfig()
269{ 269{
270 int day; 270 int day;
271 for(int i=0; i<7; i++) { 271 for(int i=0; i<7; i++) {
272 // take the first letter of the day name to be the abbreviation 272 // take the first letter of the day name to be the abbreviation
273 if (KGlobal::locale()->weekStartsMonday()) { 273 if (KGlobal::locale()->weekStartsMonday()) {
274 day = i+1; 274 day = i+1;
275 } else { 275 } else {
276 if (i==0) day = 7; 276 if (i==0) day = 7;
277 else day = i; 277 else day = i;
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 39355b4..ee9f39a 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -460,31 +460,30 @@ void KOAgendaItem::paintEvent ( QPaintEvent *e )
460 if ( mAllDay ) 460 if ( mAllDay )
461 paintFrom = paintPixAllday(); 461 paintFrom = paintPixAllday();
462 else 462 else
463 paintFrom = paintPix(); 463 paintFrom = paintPix();
464 } 464 }
465 bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); 465 bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP);
466} 466}
467void KOAgendaItem::computeText() 467void KOAgendaItem::computeText()
468{ 468{
469 469
470 mDisplayedText = mIncidence->summary(); 470 mDisplayedText = mIncidence->summary();
471 if ( (mIncidence->type() == "Todo") ) { 471 if ( (mIncidence->type() == "Todo") ) {
472 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
472 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 473 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
473 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 474 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
474 else if ( !(mIncidence->doesFloat())) 475 else if ( !(mIncidence->doesFloat()))
475 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 476 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
476 477 }
477
478
479 } else { 478 } else {
480 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 479 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
481 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 480 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
482 481
483 if ( mAllDay ) { 482 if ( mAllDay ) {
484 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 483 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
485 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 484 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
486 } 485 }
487 } 486 }
488 487
489 } 488 }
490 489
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index fc00828..060b4c4 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -99,25 +99,31 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const
99 99
100 // set default values used for drawing the matrix 100 // set default values used for drawing the matrix
101 mDefaultBackColor = palette().active().base(); 101 mDefaultBackColor = palette().active().base();
102 mDefaultTextColor = palette().active().foreground(); 102 mDefaultTextColor = palette().active().foreground();
103 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 103 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
104 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 104 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
105 mSelectedDaysColor = QColor("white"); 105 mSelectedDaysColor = QColor("white");
106 mTodayMarginWidth = 2; 106 mTodayMarginWidth = 2;
107 mSelEnd = mSelStart = NOSELECTION; 107 mSelEnd = mSelStart = NOSELECTION;
108 108
109 setAcceptDrops(true); 109 setAcceptDrops(true);
110 //setFont( QFont("Arial", 10) ); 110 //setFont( QFont("Arial", 10) );
111 updateView(date); 111
112 mUpdateTimer = new QTimer( this );
113 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
114 mRepaintTimer = new QTimer( this );
115 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
116 mDayChanged = false;
117 updateView();
112} 118}
113 119
114QColor KODayMatrix::getShadedColor(QColor color) 120QColor KODayMatrix::getShadedColor(QColor color)
115{ 121{
116 QColor shaded; 122 QColor shaded;
117 int h=0; 123 int h=0;
118 int s=0; 124 int s=0;
119 int v=0; 125 int v=0;
120 color.hsv(&h,&s,&v); 126 color.hsv(&h,&s,&v);
121 s = s/4; 127 s = s/4;
122 v = 192+v/4; 128 v = 192+v/4;
123 shaded.setHsv(h,s,v); 129 shaded.setHsv(h,s,v);
@@ -193,57 +199,42 @@ void KODayMatrix::recalculateToday()
193 days[i].month() == QDate::currentDate().month() && 199 days[i].month() == QDate::currentDate().month() &&
194 days[i].day() == QDate::currentDate().day()) { 200 days[i].day() == QDate::currentDate().day()) {
195 today = i; 201 today = i;
196 } 202 }
197 } 203 }
198 // qDebug(QString("Today is visible at %1.").arg(today)); 204 // qDebug(QString("Today is visible at %1.").arg(today));
199} 205}
200 206
201void KODayMatrix::updateView() 207void KODayMatrix::updateView()
202{ 208{
203 updateView(startdate); 209 updateView(startdate);
204} 210}
205 211void KODayMatrix::repaintViewTimed()
206void KODayMatrix::updateView(QDate actdate)
207{ 212{
208 213 qDebug("KODayMatrix::repaintViewTimed ");
209// kdDebug() << "KODayMatrix::updateView() " << actdate.toString() << endl; 214 mRepaintTimer->stop();
210 215 repaint(false);
211 //flag to indicate if the starting day of the matrix has changed by this call
212 bool daychanged = false;
213 // if a new startdate is to be set then apply Cornelius's calculation
214 // of the first day to be shown
215 if (actdate != startdate) {
216 // reset index of selection according to shift of starting date from startdate to actdate
217 if (mSelStart != NOSELECTION) {
218 int tmp = actdate.daysTo(startdate);
219 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
220 // shift selection if new one would be visible at least partly !
221
222 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
223 // nested if is required for next X display pushed from a different month - correction required
224 // otherwise, for month forward and backward, it must be avoided
225 if( mSelStart > NUMDAYS || mSelStart < 0 )
226 mSelStart = mSelStart + tmp;
227 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
228 mSelEnd = mSelEnd + tmp;
229 }
230 } 216 }
217void KODayMatrix::updateViewTimed()
218{
231 219
232 startdate = actdate; 220 mUpdateTimer->stop();
233 daychanged = true; 221 //QDate actdate = mPendingNewDate;
234 } 222
223 static int iii = 0;
224 qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii );
235 225
236 if (daychanged) { 226 if (mDayChanged) {
237 recalculateToday(); 227 recalculateToday();
228 mDayChanged = false;
238 } 229 }
239 230
240 for(int i = 0; i < NUMDAYS; i++) { 231 for(int i = 0; i < NUMDAYS; i++) {
241 232
242 // if events are set for the day then remember to draw it bold 233 // if events are set for the day then remember to draw it bold
243 QPtrList<Event> eventlist = mCalendar->events(days[i]); 234 QPtrList<Event> eventlist = mCalendar->events(days[i]);
244 Event *event; 235 Event *event;
245 int numEvents = eventlist.count(); 236 int numEvents = eventlist.count();
246 237
247 for(event=eventlist.first();event != 0;event=eventlist.next()) { 238 for(event=eventlist.first();event != 0;event=eventlist.next()) {
248 ushort recurType = event->recurrence()->doesRecur(); 239 ushort recurType = event->recurrence()->doesRecur();
249 240
@@ -260,39 +251,86 @@ void KODayMatrix::updateView(QDate actdate)
260#else 251#else
261 QString holiStr = QString::null; 252 QString holiStr = QString::null;
262#endif 253#endif
263 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 254 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
264 !holiStr.isEmpty()) { 255 !holiStr.isEmpty()) {
265 if (holiStr.isNull()) holiStr = ""; 256 if (holiStr.isNull()) holiStr = "";
266 mHolidays[i] = holiStr; 257 mHolidays[i] = holiStr;
267 258
268 } else { 259 } else {
269 mHolidays[i] = QString::null; 260 mHolidays[i] = QString::null;
270 } 261 }
271 } 262 }
263 repaint(false);
264 }
265void KODayMatrix::updateView(QDate actdate)
266{
267
268 //flag to indicate if the starting day of the matrix has changed by this call
269 //mDayChanged = false;
270 // if a new startdate is to be set then apply Cornelius's calculation
271 // of the first day to be shown
272 if (actdate != startdate) {
273 // reset index of selection according to shift of starting date from startdate to actdate
274 if (mSelStart != NOSELECTION) {
275 int tmp = actdate.daysTo(startdate);
276 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
277 // shift selection if new one would be visible at least partly !
278
279 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
280 // nested if is required for next X display pushed from a different month - correction required
281 // otherwise, for month forward and backward, it must be avoided
282 if( mSelStart > NUMDAYS || mSelStart < 0 )
283 mSelStart = mSelStart + tmp;
284 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
285 mSelEnd = mSelEnd + tmp;
286 }
287 }
288
289 startdate = actdate;
290 mDayChanged = true;
291 }
292 qDebug("restart Timer %d", mDayChanged );
293 static int iii = 0;
294 if ( iii < 5 ) {
295 ++iii;
296 updateViewTimed();
297 } else {
298 if ( !isVisible() ) {
299 mUpdateTimer->start( 2000 );
300 } else {
301 if ( mDayChanged ) {
302 mUpdateTimer->start( 250 );
303 } else {
304 mRepaintTimer->start( 250 );
305 mUpdateTimer->start( 2000 );
306 }
307 }
308 }
309
272} 310}
273 311
274const QDate& KODayMatrix::getDate(int offset) 312const QDate& KODayMatrix::getDate(int offset)
275{ 313{
276 if (offset < 0 || offset > NUMDAYS-1) { 314 if (offset < 0 || offset > NUMDAYS-1) {
277 kdDebug() << "Wrong offset (" << offset << ") in KODayMatrix::getDate(int)" << endl; 315 qDebug("Wrong offset2 ");
278 return days[0]; 316 return days[0];
279 } 317 }
280 return days[offset]; 318 return days[offset];
281} 319}
282 320
283QString KODayMatrix::getHolidayLabel(int offset) 321QString KODayMatrix::getHolidayLabel(int offset)
284{ 322{
285 if (offset < 0 || offset > NUMDAYS-1) { 323 if (offset < 0 || offset > NUMDAYS-1) {
286 kdDebug() << "Wrong offset (" << offset << ") in KODayMatrix::getHolidayLabel(int)" << endl; 324 qDebug("Wrong offset1 ");
287 return 0; 325 return 0;
288 } 326 }
289 return mHolidays[offset]; 327 return mHolidays[offset];
290} 328}
291 329
292int KODayMatrix::getDayIndexFrom(int x, int y) 330int KODayMatrix::getDayIndexFrom(int x, int y)
293{ 331{
294 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 332 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
295 6 - x/daysize.width() : x/daysize.width()); 333 6 - x/daysize.width() : x/daysize.width());
296} 334}
297 335
298// ---------------------------------------------------------------------------- 336// ----------------------------------------------------------------------------
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index b4eb2a8..0e9640a 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -163,24 +163,26 @@ public:
163 * This is dependent on today remaining the index 163 * This is dependent on today remaining the index
164 * in the array of visible dates and going from 164 * in the array of visible dates and going from
165 * top left (0) to bottom right (41). 165 * top left (0) to bottom right (41).
166 */ 166 */
167 bool isBeginningOfMonth() const { return today<=8; } ; 167 bool isBeginningOfMonth() const { return today<=8; } ;
168 bool isEndOfMonth() const { return today>=27; } ; 168 bool isEndOfMonth() const { return today>=27; } ;
169 169
170public slots: 170public slots:
171 /** Recalculates all the flags of the days in the matrix like holidays or events 171 /** Recalculates all the flags of the days in the matrix like holidays or events
172 * on a day (Actually calls above method with the actual startdate). 172 * on a day (Actually calls above method with the actual startdate).
173 */ 173 */
174 void updateView(); 174 void updateView();
175 void updateViewTimed();
176 void repaintViewTimed();
175 177
176 /** 178 /**
177 * Calculate which square in the matrix should be 179 * Calculate which square in the matrix should be
178 * hilighted to indicate it's today. 180 * hilighted to indicate it's today.
179 */ 181 */
180 void recalculateToday(); 182 void recalculateToday();
181 183
182/* 184/*
183 void setStartDate(QDate); 185 void setStartDate(QDate);
184*/ 186*/
185 187
186signals: 188signals:
@@ -210,24 +212,27 @@ protected:
210 212
211 void dragEnterEvent(QDragEnterEvent *); 213 void dragEnterEvent(QDragEnterEvent *);
212 214
213 void dragMoveEvent(QDragMoveEvent *); 215 void dragMoveEvent(QDragMoveEvent *);
214 216
215 void dragLeaveEvent(QDragLeaveEvent *); 217 void dragLeaveEvent(QDragLeaveEvent *);
216 218
217 void dropEvent(QDropEvent *); 219 void dropEvent(QDropEvent *);
218 220
219 void resizeEvent(QResizeEvent *); 221 void resizeEvent(QResizeEvent *);
220 222
221private: 223private:
224 QTimer* mUpdateTimer;
225 QTimer* mRepaintTimer;
226 bool mDayChanged;
222 227
223 /** returns the index of the day located at the matrix's widget (x,y) position. 228 /** returns the index of the day located at the matrix's widget (x,y) position.
224 * 229 *
225 * @param x horizontal coordinate 230 * @param x horizontal coordinate
226 * @param y vertical coordinate 231 * @param y vertical coordinate
227 */ 232 */
228 int getDayIndexFrom(int x, int y); 233 int getDayIndexFrom(int x, int y);
229 234
230 /** calculates a "shaded" color from the supplied color object. 235 /** calculates a "shaded" color from the supplied color object.
231 * (Copied from Cornelius's kdpdatebutton.cpp) 236 * (Copied from Cornelius's kdpdatebutton.cpp)
232 * 237 *
233 * @param color source based on which a shaded color should be calculated. 238 * @param color source based on which a shaded color should be calculated.