summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp144
-rw-r--r--korganizer/kodaymatrix.h2
-rw-r--r--korganizer/komonthview.cpp34
-rw-r--r--korganizer/komonthview.h6
4 files changed, 173 insertions, 13 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index c7e1b45..322131f 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -1,637 +1,773 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> 3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
4 Parts of the source code have been copied from kdpdatebutton.cpp 4 Parts of the source code have been copied from kdpdatebutton.cpp
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source ode for Qt in the source distribution. 22 without including the source ode for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qevent.h> 25#include <qevent.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qptrlist.h> 27#include <qptrlist.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#include <libkcal/vcaldrag.h> 35#include <libkcal/vcaldrag.h>
36#include <libkcal/icaldrag.h> 36#include <libkcal/icaldrag.h>
37#include <libkcal/dndfactory.h> 37#include <libkcal/dndfactory.h>
38#include <libkcal/calendarresources.h> 38#include <libkcal/calendarresources.h>
39#include <libkcal/resourcecalendar.h> 39#include <libkcal/resourcecalendar.h>
40#include <kresources/resourceselectdialog.h> 40#include <kresources/resourceselectdialog.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPLUGINS 44#ifndef KORG_NOPLUGINS
45#include "kocore.h" 45#include "kocore.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#include "koglobals.h" 48#include "koglobals.h"
49 49
50#include "kodaymatrix.h" 50#include "kodaymatrix.h"
51 51
52// ============================================================================ 52// ============================================================================
53// D Y N A M I C T I P 53// D Y N A M I C T I P
54// ============================================================================ 54// ============================================================================
55 55
56DynamicTip::DynamicTip( QWidget * parent ) 56DynamicTip::DynamicTip( QWidget * parent )
57 : QToolTip( parent ) 57 : QToolTip( parent )
58{ 58{
59 matrix = (KODayMatrix*)parent; 59 matrix = (KODayMatrix*)parent;
60} 60}
61 61
62class KODaymatrixWhatsThis :public QWhatsThis 62class KODaymatrixWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; 65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;};
66 ~KODaymatrixWhatsThis() { ; }; 66 ~KODaymatrixWhatsThis() { ; };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p ) 69 virtual QString text( const QPoint& p )
70 { 70 {
71 return _view->getWhatsThisText( p ) ; 71 return _view->getWhatsThisText( p ) ;
72 } 72 }
73private: 73private:
74 KODayMatrix * _view; 74 KODayMatrix * _view;
75}; 75};
76 76
77void DynamicTip::maybeTip( const QPoint &pos ) 77void DynamicTip::maybeTip( const QPoint &pos )
78{ 78{
79 //calculate which cell of the matrix the mouse is in 79 //calculate which cell of the matrix the mouse is in
80 QRect sz = matrix->frameRect(); 80 QRect sz = matrix->frameRect();
81 int dheight = sz.height()*7 / 42; 81 int dheight = sz.height()*7 / 42;
82 int dwidth = sz.width() / 7; 82 int dwidth = sz.width() / 7;
83 int row = pos.y()/dheight; 83 int row = pos.y()/dheight;
84 int col = pos.x()/dwidth; 84 int col = pos.x()/dwidth;
85 85
86 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 86 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
87 87
88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
89// col << "][" << row << "] => " <<(col+row*7) << endl; 89// col << "][" << row << "] => " <<(col+row*7) << endl;
90 90
91 //show holiday names only 91 //show holiday names only
92 QString str = matrix->getHolidayLabel(col+row*7); 92 QString str = matrix->getHolidayLabel(col+row*7);
93 if (str.isEmpty()) return; 93 if (str.isEmpty()) return;
94 tip(rct, str); 94 tip(rct, str);
95} 95}
96 96
97 97
98// ============================================================================ 98// ============================================================================
99// K O D A Y M A T R I X 99// K O D A Y M A T R I X
100// ============================================================================ 100// ============================================================================
101 101
102const int KODayMatrix::NOSELECTION = -1000; 102const int KODayMatrix::NOSELECTION = -1000;
103const int KODayMatrix::NUMDAYS = 42; 103const int KODayMatrix::NUMDAYS = 42;
104 104
105KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) 105KODayMatrix::KODayMatrix( QWidget *parent, const char *name )
106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) 106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 )
107 107
108#if 0 108#if 0
109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : 109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
110 QFrame(parent, name) 110 QFrame(parent, name)
111#endif 111#endif
112{ 112{
113 oldW = 0; 113 oldW = 0;
114 oldH = 0; 114 oldH = 0;
115 myPix.resize( 150, 120 ); 115 myPix.resize( 150, 120 );
116 mRedrawNeeded = true; 116 mRedrawNeeded = true;
117 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); 117 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this);
118 mPendingUpdateBeforeRepaint = false; 118 mPendingUpdateBeforeRepaint = false;
119 mouseDown = false; 119 mouseDown = false;
120 // initialize dynamic arrays 120 // initialize dynamic arrays
121 bDays.resize ( NUMDAYS ); 121 bDays.resize ( NUMDAYS );
122 pDays.resize ( NUMDAYS );
122 hDays.resize ( NUMDAYS ); 123 hDays.resize ( NUMDAYS );
123 eDays.resize ( NUMDAYS ); 124 eDays.resize ( NUMDAYS );
124 days = new QDate[NUMDAYS]; 125 days = new QDate[NUMDAYS];
125 daylbls = new QString[NUMDAYS]; 126 daylbls = new QString[NUMDAYS];
126 //events = new int[NUMDAYS]; 127 //events = new int[NUMDAYS];
127 mToolTip = new DynamicTip(this); 128 mToolTip = new DynamicTip(this);
128 129
129 // set default values used for drawing the matrix 130 // set default values used for drawing the matrix
130 mDefaultBackColor = palette().active().base(); 131 mDefaultBackColor = palette().active().base();
131 mDefaultTextColor = palette().active().foreground(); 132 mDefaultTextColor = palette().active().foreground();
132 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 133 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
133 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 134 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
134 mSelectedDaysColor = QColor("white"); 135 mSelectedDaysColor = QColor("white");
135 mTodayMarginWidth = 2; 136 mTodayMarginWidth = 2;
136 mSelEnd = mSelStart = NOSELECTION; 137 mSelEnd = mSelStart = NOSELECTION;
137 138
138 setAcceptDrops(true); 139 setAcceptDrops(true);
139 //setFont( QFont("Arial", 10) ); 140 //setFont( QFont("Arial", 10) );
140 141
141 mUpdateTimer = new QTimer( this ); 142 mUpdateTimer = new QTimer( this );
142 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 143 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
143 mRepaintTimer = new QTimer( this ); 144 mRepaintTimer = new QTimer( this );
144 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 145 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
145 mDayChanged = false; 146 mDayChanged = false;
146 updateView(); 147 updateView();
147} 148}
148QString KODayMatrix::getWhatsThisText( QPoint p ) 149QString KODayMatrix::getWhatsThisText( QPoint p )
149{ 150{
150 151
151 int tmp = getDayIndexFrom(p.x(), p.y()); 152 int tmp = getDayIndexFrom(p.x(), p.y());
152 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) 153 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar )
153 return QString(); 154 return QString();
154 QDate mDate = days[tmp]; 155 QDate mDate = days[tmp];
155 QPtrList<Event> eventlist = mCalendar->events(mDate); 156 QPtrList<Event> eventlist = mCalendar->events(mDate);
156 Event *event; 157 Event *event;
157 QStringList mToolTip; 158 QStringList mToolTip;
158 for(event=eventlist.first();event != 0;event=eventlist.next()) { 159 for(event=eventlist.first();event != 0;event=eventlist.next()) {
159 QString mToolTipText; 160 QString mToolTipText;
160 QString text; 161 QString text;
161 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 162 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
162 if (event->isMultiDay()) { 163 if (event->isMultiDay()) {
163 QString prefix = "<->";multiday = 2; 164 QString prefix = "<->";multiday = 2;
164 QString time; 165 QString time;
165 if ( event->doesRecur() ) { 166 if ( event->doesRecur() ) {
166 if ( event->recursOn( mDate) ) { 167 if ( event->recursOn( mDate) ) {
167 prefix ="->" ;multiday = 1; 168 prefix ="->" ;multiday = 1;
168 } 169 }
169 else { 170 else {
170 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 171 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
171 if ( event->recursOn( mDate.addDays( -days)) ) { 172 if ( event->recursOn( mDate.addDays( -days)) ) {
172 prefix ="<-" ;multiday = 3; 173 prefix ="<-" ;multiday = 3;
173 } 174 }
174 } 175 }
175 } else { 176 } else {
176 if (mDate == event->dtStart().date()) { 177 if (mDate == event->dtStart().date()) {
177 prefix ="->" ;multiday = 1; 178 prefix ="->" ;multiday = 1;
178 } else if (mDate == event->dtEnd().date()) { 179 } else if (mDate == event->dtEnd().date()) {
179 prefix ="<-" ;multiday = 3; 180 prefix ="<-" ;multiday = 3;
180 } 181 }
181 } 182 }
182 if ( !event->doesFloat() ) { 183 if ( !event->doesFloat() ) {
183 if ( mDate == event->dtStart().date () ) 184 if ( mDate == event->dtStart().date () )
184 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 185 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
185 else if ( mDate == event->dtEnd().date () ) 186 else if ( mDate == event->dtEnd().date () )
186 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 187 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
187 188
188 } 189 }
189 text = time + event->summary(); 190 text = time + event->summary();
190 mToolTipText += prefix + text; 191 mToolTipText += prefix + text;
191 } else { 192 } else {
192 if (event->doesFloat()) { 193 if (event->doesFloat()) {
193 text = event->summary(); 194 text = event->summary();
194 mToolTipText += text; 195 mToolTipText += text;
195 } 196 }
196 else { 197 else {
197 text = KGlobal::locale()->formatTime(event->dtStart().time()); 198 text = KGlobal::locale()->formatTime(event->dtStart().time());
198 text += " " + event->summary(); 199 text += " " + event->summary();
199 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 200 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
200 } 201 }
201 } 202 }
202 if ( !event->location().isEmpty() ) 203 if ( !event->location().isEmpty() )
203 mToolTipText += " (" + event->location() + ")"; 204 mToolTipText += " (" + event->location() + ")";
204#if QT_VERSION >= 0x030000 205#if QT_VERSION >= 0x030000
205 mToolTipText.replace( '<' , "&lt;" ); 206 mToolTipText.replace( '<' , "&lt;" );
206 mToolTipText.replace( '>' , "&gt;" ); 207 mToolTipText.replace( '>' , "&gt;" );
207#else 208#else
208 if ( mToolTipText.find ('<') >= 0 ) { 209 if ( mToolTipText.find ('<') >= 0 ) {
209 mToolTipText.replace( QRegExp("<") , "&lt;" ); 210 mToolTipText.replace( QRegExp("<") , "&lt;" );
210 } 211 }
211 if ( mToolTipText.find ('>') >= 0 ) { 212 if ( mToolTipText.find ('>') >= 0 ) {
212 mToolTipText.replace( QRegExp(">") , "&gt;" ); 213 mToolTipText.replace( QRegExp(">") , "&gt;" );
213 } 214 }
214#endif 215#endif
215 //qDebug("TTT: %s ", mToolTipText.latin1()); 216 //qDebug("TTT: %s ", mToolTipText.latin1());
216 mToolTip.append( mToolTipText ); 217 mToolTip.append( mToolTipText );
217 } 218 }
218 mToolTip.sort(); 219 mToolTip.sort();
219 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); 220 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>");
220} 221}
221void KODayMatrix::setCalendar( Calendar *cal ) 222void KODayMatrix::setCalendar( Calendar *cal )
222{ 223{
223 mCalendar = cal; 224 mCalendar = cal;
224 225
225 setAcceptDrops( mCalendar ); 226 setAcceptDrops( mCalendar );
226 227
227 updateEvents(); 228 updateEvents();
228} 229}
229 230
230QColor KODayMatrix::getShadedColor(QColor color) 231QColor KODayMatrix::getShadedColor(QColor color)
231{ 232{
232 QColor shaded; 233 QColor shaded;
233 int h=0; 234 int h=0;
234 int s=0; 235 int s=0;
235 int v=0; 236 int v=0;
236 color.hsv(&h,&s,&v); 237 color.hsv(&h,&s,&v);
237 s = s/4; 238 s = s/4;
238 v = 192+v/4; 239 v = 192+v/4;
239 shaded.setHsv(h,s,v); 240 shaded.setHsv(h,s,v);
240 241
241 return shaded; 242 return shaded;
242} 243}
243 244
244KODayMatrix::~KODayMatrix() 245KODayMatrix::~KODayMatrix()
245{ 246{
246 // delete mKODaymatrixWhatsThis; 247 // delete mKODaymatrixWhatsThis;
247 delete [] days; 248 delete [] days;
248 delete [] daylbls; 249 delete [] daylbls;
249 //delete [] events; 250 //delete [] events;
250 delete mToolTip; 251 delete mToolTip;
251} 252}
252 253
253/* 254/*
254void KODayMatrix::setStartDate(QDate start) 255void KODayMatrix::setStartDate(QDate start)
255{ 256{
256 updateView(start); 257 updateView(start);
257} 258}
258*/ 259*/
259 260
260void KODayMatrix::addSelectedDaysTo(DateList& selDays) 261void KODayMatrix::addSelectedDaysTo(DateList& selDays)
261{ 262{
262 263
263 if (mSelStart == NOSELECTION) { 264 if (mSelStart == NOSELECTION) {
264 return; 265 return;
265 } 266 }
266 267
267 //cope with selection being out of matrix limits at top (< 0) 268 //cope with selection being out of matrix limits at top (< 0)
268 int i0 = mSelStart; 269 int i0 = mSelStart;
269 if (i0 < 0) { 270 if (i0 < 0) {
270 for (int i = i0; i < 0; i++) { 271 for (int i = i0; i < 0; i++) {
271 selDays.append(days[0].addDays(i)); 272 selDays.append(days[0].addDays(i));
272 } 273 }
273 i0 = 0; 274 i0 = 0;
274 } 275 }
275 276
276 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 277 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
277 if (mSelEnd > NUMDAYS-1) { 278 if (mSelEnd > NUMDAYS-1) {
278 for (int i = i0; i <= NUMDAYS-1; i++) { 279 for (int i = i0; i <= NUMDAYS-1; i++) {
279 selDays.append(days[i]); 280 selDays.append(days[i]);
280 } 281 }
281 for (int i = NUMDAYS; i < mSelEnd; i++) { 282 for (int i = NUMDAYS; i < mSelEnd; i++) {
282 selDays.append(days[0].addDays(i)); 283 selDays.append(days[0].addDays(i));
283 } 284 }
284 285
285 // apply normal routine to selection being entirely within matrix limits 286 // apply normal routine to selection being entirely within matrix limits
286 } else { 287 } else {
287 for (int i = i0; i <= mSelEnd; i++) { 288 for (int i = i0; i <= mSelEnd; i++) {
288 selDays.append(days[i]); 289 selDays.append(days[i]);
289 } 290 }
290 } 291 }
291} 292}
292 293
293bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 294bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
294{ 295{
295 mRedrawNeeded = true; 296 mRedrawNeeded = true;
296 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); 297 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION );
297 mSelStart = startdate.daysTo(start); 298 mSelStart = startdate.daysTo(start);
298 if ( mSelStart < 0 ) 299 if ( mSelStart < 0 )
299 mSelStart = 0; 300 mSelStart = 0;
300 mSelEnd = startdate.daysTo(end); 301 mSelEnd = startdate.daysTo(end);
301 if ( mSelEnd > NUMDAYS-1 ) 302 if ( mSelEnd > NUMDAYS-1 )
302 mSelEnd = NUMDAYS-1; 303 mSelEnd = NUMDAYS-1;
303 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { 304 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) {
304 clearSelection(); 305 clearSelection();
305 if ( noSel ) 306 if ( noSel )
306 return false; 307 return false;
307 } 308 }
308 309
309 return true; 310 return true;
310} 311}
311void KODayMatrix::clearSelection() 312void KODayMatrix::clearSelection()
312{ 313{
313 mSelEnd = mSelStart = NOSELECTION; 314 mSelEnd = mSelStart = NOSELECTION;
314} 315}
315 316
316 317
317void KODayMatrix::recalculateToday() 318void KODayMatrix::recalculateToday()
318{ 319{
319 today = -1; 320 today = -1;
320 for (int i=0; i<NUMDAYS; i++) { 321 for (int i=0; i<NUMDAYS; i++) {
321 //events[i] = 0; 322 //events[i] = 0;
322 days[i] = startdate.addDays(i); 323 days[i] = startdate.addDays(i);
323 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 324 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
324 325
325 // if today is in the currently displayed month, hilight today 326 // if today is in the currently displayed month, hilight today
326 if (days[i].year() == QDate::currentDate().year() && 327 if (days[i].year() == QDate::currentDate().year() &&
327 days[i].month() == QDate::currentDate().month() && 328 days[i].month() == QDate::currentDate().month() &&
328 days[i].day() == QDate::currentDate().day()) { 329 days[i].day() == QDate::currentDate().day()) {
329 today = i; 330 today = i;
330 } 331 }
331 } 332 }
332 // qDebug(QString("Today is visible at %1.").arg(today)); 333 // qDebug(QString("Today is visible at %1.").arg(today));
333} 334}
334 335
335void KODayMatrix::updateView() 336void KODayMatrix::updateView()
336{ 337{
337 updateView(startdate); 338 updateView(startdate);
338} 339}
339void KODayMatrix::repaintViewTimed() 340void KODayMatrix::repaintViewTimed()
340{ 341{
341 mRedrawNeeded = true; 342 mRedrawNeeded = true;
342 bDays.fill( false); 343 bDays.fill( false);
344 pDays.fill( false);
343 hDays.fill( false); 345 hDays.fill( false);
344 eDays.fill( false); 346 eDays.fill( false);
345 mRepaintTimer->stop(); 347 mRepaintTimer->stop();
348 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
349 int i;
350 for(i = 0; i < NUMDAYS; i++) {
351 if ( ( (i+startDay) % 7 == 0 ) ) {
352 pDays.setBit(i);
353 }
354 }
346 repaint(false); 355 repaint(false);
347} 356}
357void KODayMatrix::computeEvent(Event *event, int i )
358{
359 QString holiStr = mHolidays[i];
360 if ( event->isHoliday()) {
361 pDays.setBit(i);
362 hDays.setBit(i);
363 if ( !holiStr.isEmpty() )
364 holiStr += "\n";
365 holiStr += event->summary();
366 if ( !event->location().isEmpty() )
367 holiStr += " (" + event->location() + ")";
368 mHolidays[i] =holiStr ;
369 }
370 if ( event->isBirthday()) {
371 pDays.setBit(i);
372 if ( !holiStr.isEmpty() )
373 holiStr += "\n";
374 holiStr += i18n("Birthday") + ": "+event->summary();
375 if ( !event->location().isEmpty() )
376 holiStr += " (" + event->location() + ")";
377 bDays.setBit(i);
378 mHolidays[i] =holiStr ;
379 }
380 eDays.setBit(i);
381}
348void KODayMatrix::updateViewTimed() 382void KODayMatrix::updateViewTimed()
349{ 383{
350 mUpdateTimer->stop(); 384 mUpdateTimer->stop();
351 if ( !mCalendar ) { 385 if ( !mCalendar ) {
352 qDebug("NOT CAL "); 386 qDebug("NOT CAL ");
353 return; 387 return;
354 } 388 }
389#if 1
390
391 int i;
392 int timeSpan = NUMDAYS-1;
393 QPtrList<Event> events = mCalendar->events();
394 Event *event;
395 QDateTime dt;
396 bool ok;
397 bDays.fill( false);
398 pDays.fill( false);
399 hDays.fill( false);
400 eDays.fill( false);
401 mHolidays.clear();
402 QDate mStartDate = days[0];
403 QDate endDate = mStartDate.addDays( timeSpan );
404 for( event = events.first(); event; event = events.next() ) { // for event
405 ushort recurType = event->recurrence()->doesRecur();
406 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
407 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
408 continue;
409 }
410 if ( event->doesRecur() ) {
411 bool last;
412 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
413 QDateTime incidenceEnd;
414 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
415 bool invalid = false;
416 while( true ) {
417 if ( incidenceStart.isValid() ) {
418 incidenceEnd = incidenceStart.addDays( eventlen );
419 int st = incidenceStart.date().daysTo( endDate );
420 if ( st >= 0 ) { // start before timeend
421 int end = mStartDate.daysTo( incidenceEnd.date() );
422 if ( end >= 0 ) { // end after timestart --- got one!
423 //normalize
424 st = timeSpan - st;
425 if ( st < 0 ) st = 0;
426 if ( end > timeSpan ) end = timeSpan;
427 int iii;
428 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
429 for ( iii = st;iii<= end;++iii) {
430 computeEvent( event, iii );
431 }
432 }
433 }
434 } else {
435 if ( invalid )
436 break;
437 invalid = true;
438 //qDebug("invalid %s", event->summary().latin1());
439 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
440 }
441 if ( last )
442 break;
443 bool ok;
444 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
445 if ( ! ok )
446 break;
447 if ( incidenceStart.date() > endDate )
448 break;
449 }
450 } else { // no recur
451 int st = event->dtStart().date().daysTo( endDate );
452 if ( st >= 0 ) { // start before timeend
453 int end = mStartDate.daysTo( event->dtEnd().date() );
454 if ( end >= 0 ) { // end after timestart --- got one!
455 //normalize
456 st = timeSpan - st;
457 if ( st < 0 ) st = 0;
458 if ( end > timeSpan ) end = timeSpan;
459 int iii;
460 for ( iii = st;iii<= end;++iii)
461 computeEvent( event, iii );
462 }
463 }
464 }
465 }
466 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
467 for(i = 0; i < NUMDAYS; i++) {
468 if ( ( (i+startDay) % 7 == 0 ) ) {
469 pDays.setBit(i);
470 }
471 }
472
473#if 0
474 // insert due todos
475 QPtrList<Todo> todos = calendar()->todos( );
476 Todo *todo;
477 for(todo = todos.first(); todo; todo = todos.next()) {
478 //insertTodo( todo );
479 if ( todo->hasDueDate() ) {
480 int day = mStartDate.daysTo( todo->dtDue().date() );
481 if ( day >= 0 && day < timeSpan + 1) {
482 (*cells)[day]->insertTodo( todo );
483 }
484 }
485 }
486#endif
487
488#else
355 //qDebug("KODayMatrix::updateViewTimed "); 489 //qDebug("KODayMatrix::updateViewTimed ");
356 for(int i = 0; i < NUMDAYS; i++) { 490 for(int i = 0; i < NUMDAYS; i++) {
357 // if events are set for the day then remember to draw it bold 491 // if events are set for the day then remember to draw it bold
358 QPtrList<Event> eventlist = mCalendar->events(days[i]); 492 QPtrList<Event> eventlist = mCalendar->events(days[i]);
359 Event *event; 493 Event *event;
360 int numEvents = eventlist.count(); 494 int numEvents = eventlist.count();
361 QString holiStr = ""; 495 QString holiStr = "";
362 bDays.clearBit(i); 496 bDays.clearBit(i);
363 hDays.clearBit(i); 497 hDays.clearBit(i);
364 eDays.clearBit(i); 498 eDays.clearBit(i);
365 for(event=eventlist.first();event != 0;event=eventlist.next()) { 499 for(event=eventlist.first();event != 0;event=eventlist.next()) {
500 qDebug("FFFFFFFFFFFFFFFFFFFFFFFFF ");
366 ushort recurType = event->recurrence()->doesRecur(); 501 ushort recurType = event->recurrence()->doesRecur();
367 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 502 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
368 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 503 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
369 numEvents--; 504 numEvents--;
370 } 505 }
371 if ( event->isHoliday()) { 506 if ( event->isHoliday()) {
372 hDays.setBit(i); 507 hDays.setBit(i);
373 if ( !holiStr.isEmpty() ) 508 if ( !holiStr.isEmpty() )
374 holiStr += "\n"; 509 holiStr += "\n";
375 holiStr += event->summary(); 510 holiStr += event->summary();
376 if ( !event->location().isEmpty() ) 511 if ( !event->location().isEmpty() )
377 holiStr += " (" + event->location() + ")"; 512 holiStr += " (" + event->location() + ")";
378 } 513 }
379 if ( event->isBirthday()) { 514 if ( event->isBirthday()) {
380 if ( !holiStr.isEmpty() ) 515 if ( !holiStr.isEmpty() )
381 holiStr += "\n"; 516 holiStr += "\n";
382 holiStr += i18n("Birthday") + ": "+event->summary(); 517 holiStr += i18n("Birthday") + ": "+event->summary();
383 if ( !event->location().isEmpty() ) 518 if ( !event->location().isEmpty() )
384 holiStr += " (" + event->location() + ")"; 519 holiStr += " (" + event->location() + ")";
385 bDays.setBit(i); 520 bDays.setBit(i);
386 } 521 }
387 } 522 }
388 if ( numEvents ) 523 if ( numEvents )
389 eDays.setBit(i); 524 eDays.setBit(i);
390 //if it is a holy day then draw it red. Sundays are consider holidays, too 525 //if it is a holy day then draw it red. Sundays are consider holidays, too
391 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 526 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
392 !holiStr.isEmpty()) { 527 !holiStr.isEmpty()) {
393 mHolidays[i] = holiStr; 528 mHolidays[i] = holiStr;
394 } else { 529 } else {
395 mHolidays[i] = QString::null; 530 mHolidays[i] = QString::null;
396 } 531 }
397 } 532 }
533#endif
398 mRedrawNeeded = true; 534 mRedrawNeeded = true;
399 if ( ! mPendingUpdateBeforeRepaint ) 535 if ( ! mPendingUpdateBeforeRepaint )
400 repaint(false); 536 repaint(false);
401} 537}
402void KODayMatrix::updateView(QDate actdate) 538void KODayMatrix::updateView(QDate actdate)
403{ 539{
404 540
405 if ( ! actdate.isValid() ) { 541 if ( ! actdate.isValid() ) {
406 //qDebug("date not valid "); 542 //qDebug("date not valid ");
407 return; 543 return;
408 } 544 }
409 mDayChanged = false; 545 mDayChanged = false;
410 //flag to indicate if the starting day of the matrix has changed by this call 546 //flag to indicate if the starting day of the matrix has changed by this call
411 //mDayChanged = false; 547 //mDayChanged = false;
412 // if a new startdate is to be set then apply Cornelius's calculation 548 // if a new startdate is to be set then apply Cornelius's calculation
413 // of the first day to be shown 549 // of the first day to be shown
414 if (actdate != startdate) { 550 if (actdate != startdate) {
415 // reset index of selection according to shift of starting date from startdate to actdate 551 // reset index of selection according to shift of starting date from startdate to actdate
416 if (mSelStart != NOSELECTION) { 552 if (mSelStart != NOSELECTION) {
417 int tmp = actdate.daysTo(startdate); 553 int tmp = actdate.daysTo(startdate);
418 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 554 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
419 // shift selection if new one would be visible at least partly ! 555 // shift selection if new one would be visible at least partly !
420 556
421 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 557 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
422 // nested if is required for next X display pushed from a different month - correction required 558 // nested if is required for next X display pushed from a different month - correction required
423 // otherwise, for month forward and backward, it must be avoided 559 // otherwise, for month forward and backward, it must be avoided
424 if( mSelStart > NUMDAYS || mSelStart < 0 ) 560 if( mSelStart > NUMDAYS || mSelStart < 0 )
425 mSelStart = mSelStart + tmp; 561 mSelStart = mSelStart + tmp;
426 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 562 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
427 mSelEnd = mSelEnd + tmp; 563 mSelEnd = mSelEnd + tmp;
428 } 564 }
429 } 565 }
430 startdate = actdate; 566 startdate = actdate;
431 mDayChanged = true; 567 mDayChanged = true;
432 recalculateToday(); 568 recalculateToday();
433 mRedrawNeeded = true; 569 mRedrawNeeded = true;
434 } 570 }
435 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 571 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
436 if ( !isVisible() ) { 572 if ( !isVisible() ) {
437 mPendingUpdateBeforeRepaint = true; 573 mPendingUpdateBeforeRepaint = true;
438 } else { 574 } else {
439#ifdef DESKTOP_VERSION 575#ifdef DESKTOP_VERSION
440 //mRepaintTimer->start( 100 ); 576 //mRepaintTimer->start( 100 );
441 //updateViewTimed(); 577 //updateViewTimed();
442 mUpdateTimer->start( 50 ); 578 mUpdateTimer->start( 50 );
443#else 579#else
444 mRepaintTimer->start( 350 ); 580 mRepaintTimer->start( 350 );
445 mUpdateTimer->start( 1200 ); 581 mUpdateTimer->start( 800 );
446#endif 582#endif
447 } 583 }
448} 584}
449void KODayMatrix::updateEvents() 585void KODayMatrix::updateEvents()
450{ 586{
451 if ( !mCalendar ) return; 587 if ( !mCalendar ) return;
452 588
453 for( int i = 0; i < NUMDAYS; i++ ) { 589 for( int i = 0; i < NUMDAYS; i++ ) {
454 // if events are set for the day then remember to draw it bold 590 // if events are set for the day then remember to draw it bold
455 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 591 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
456 int numEvents = eventlist.count(); 592 int numEvents = eventlist.count();
457 Event *event; 593 Event *event;
458 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 594 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
459 ushort recurType = event->doesRecur(); 595 ushort recurType = event->doesRecur();
460 596
461 if ( ( recurType == Recurrence::rDaily && 597 if ( ( recurType == Recurrence::rDaily &&
462 !KOPrefs::instance()->mDailyRecur ) || 598 !KOPrefs::instance()->mDailyRecur ) ||
463 ( recurType == Recurrence::rWeekly && 599 ( recurType == Recurrence::rWeekly &&
464 !KOPrefs::instance()->mWeeklyRecur ) ) { 600 !KOPrefs::instance()->mWeeklyRecur ) ) {
465 numEvents--; 601 numEvents--;
466 } 602 }
467 } 603 }
468 if ( numEvents ) 604 if ( numEvents )
469 eDays.setBit(i); 605 eDays.setBit(i);
470 else 606 else
471 eDays.clearBit(i); 607 eDays.clearBit(i);
472 } 608 }
473} 609}
474 610
475const QDate& KODayMatrix::getDate(int offset) 611const QDate& KODayMatrix::getDate(int offset)
476{ 612{
477 if (offset < 0 || offset > NUMDAYS-1) { 613 if (offset < 0 || offset > NUMDAYS-1) {
478 qDebug("Wrong offset2 %d", offset); 614 qDebug("Wrong offset2 %d", offset);
479 return days[0]; 615 return days[0];
480 } 616 }
481 return days[offset]; 617 return days[offset];
482} 618}
483 619
484QString KODayMatrix::getHolidayLabel(int offset) 620QString KODayMatrix::getHolidayLabel(int offset)
485{ 621{
486 if (offset < 0 || offset > NUMDAYS-1) { 622 if (offset < 0 || offset > NUMDAYS-1) {
487 qDebug("Wrong offset1 %d", offset); 623 qDebug("Wrong offset1 %d", offset);
488 return QString(); 624 return QString();
489 } 625 }
490 return mHolidays[offset]; 626 return mHolidays[offset];
491} 627}
492 628
493int KODayMatrix::getDayIndexFrom(int x, int y) 629int KODayMatrix::getDayIndexFrom(int x, int y)
494{ 630{
495 int colModulo = (width()-2) % 7; 631 int colModulo = (width()-2) % 7;
496 int rowModulo = (height()-2) % 6; 632 int rowModulo = (height()-2) % 6;
497#if 0 633#if 0
498 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 634 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
499 6 - x/daysize.width() : x/daysize.width()); 635 6 - x/daysize.width() : x/daysize.width());
500#endif 636#endif
501 int xVal = (x-colModulo/2-2)/daysize.width(); 637 int xVal = (x-colModulo/2-2)/daysize.width();
502 int yVal = (y-rowModulo/2-2)/daysize.height(); 638 int yVal = (y-rowModulo/2-2)/daysize.height();
503 639
504 640
505 return 7*(yVal) + xVal; 641 return 7*(yVal) + xVal;
506 642
507} 643}
508 644
509// ---------------------------------------------------------------------------- 645// ----------------------------------------------------------------------------
510// M O U S E E V E N T H A N D L I N G 646// M O U S E E V E N T H A N D L I N G
511// ---------------------------------------------------------------------------- 647// ----------------------------------------------------------------------------
512 648
513void KODayMatrix::mousePressEvent (QMouseEvent* e) 649void KODayMatrix::mousePressEvent (QMouseEvent* e)
514{ 650{
515 651
516 if ( e->button() == LeftButton ) 652 if ( e->button() == LeftButton )
517 mouseDown = true; 653 mouseDown = true;
518 mSelStart = getDayIndexFrom(e->x(), e->y()); 654 mSelStart = getDayIndexFrom(e->x(), e->y());
519 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 655 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
520 mSelInit = mSelStart; 656 mSelInit = mSelStart;
521 mSelEnd = mSelStart; 657 mSelEnd = mSelStart;
522 mRedrawNeeded = true; 658 mRedrawNeeded = true;
523 repaint(false); 659 repaint(false);
524} 660}
525 661
526void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 662void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
527{ 663{
528 mRedrawNeeded = true; 664 mRedrawNeeded = true;
529 if ( e->button() == LeftButton ) 665 if ( e->button() == LeftButton )
530 if ( ! mouseDown ) { 666 if ( ! mouseDown ) {
531 return; 667 return;
532 } 668 }
533 else 669 else
534 mouseDown = false; 670 mouseDown = false;
535 int tmp = getDayIndexFrom(e->x(), e->y()); 671 int tmp = getDayIndexFrom(e->x(), e->y());
536 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 672 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
537 673
538 if (mSelInit > tmp) { 674 if (mSelInit > tmp) {
539 mSelEnd = mSelInit; 675 mSelEnd = mSelInit;
540 if (tmp != mSelStart) { 676 if (tmp != mSelStart) {
541 mSelStart = tmp; 677 mSelStart = tmp;
542 repaint(false); 678 repaint(false);
543 } 679 }
544 } else { 680 } else {
545 mSelStart = mSelInit; 681 mSelStart = mSelInit;
546 682
547 //repaint only if selection has changed 683 //repaint only if selection has changed
548 if (tmp != mSelEnd) { 684 if (tmp != mSelEnd) {
549 mSelEnd = tmp; 685 mSelEnd = tmp;
550 repaint(false); 686 repaint(false);
551 } 687 }
552 } 688 }
553 689
554 DateList daylist; 690 DateList daylist;
555 if ( mSelStart < 0 ) 691 if ( mSelStart < 0 )
556 mSelStart = 0; 692 mSelStart = 0;
557 for (int i = mSelStart; i <= mSelEnd; i++) { 693 for (int i = mSelStart; i <= mSelEnd; i++) {
558 daylist.append(days[i]); 694 daylist.append(days[i]);
559 } 695 }
560 emit selected((const DateList)daylist); 696 emit selected((const DateList)daylist);
561 697
562} 698}
563 699
564void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 700void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
565{ 701{
566 if ( ! mouseDown ) { 702 if ( ! mouseDown ) {
567 return; 703 return;
568 } 704 }
569 mRedrawNeeded = true; 705 mRedrawNeeded = true;
570 int tmp = getDayIndexFrom(e->x(), e->y()); 706 int tmp = getDayIndexFrom(e->x(), e->y());
571 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 707 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
572 708
573 if (mSelInit > tmp) { 709 if (mSelInit > tmp) {
574 mSelEnd = mSelInit; 710 mSelEnd = mSelInit;
575 if (tmp != mSelStart) { 711 if (tmp != mSelStart) {
576 mSelStart = tmp; 712 mSelStart = tmp;
577 repaint(false); 713 repaint(false);
578 } 714 }
579 } else { 715 } else {
580 mSelStart = mSelInit; 716 mSelStart = mSelInit;
581 717
582 //repaint only if selection has changed 718 //repaint only if selection has changed
583 if (tmp != mSelEnd) { 719 if (tmp != mSelEnd) {
584 mSelEnd = tmp; 720 mSelEnd = tmp;
585 repaint(false); 721 repaint(false);
586 } 722 }
587 } 723 }
588} 724}
589 725
590// ---------------------------------------------------------------------------- 726// ----------------------------------------------------------------------------
591// D R A G ' N D R O P H A N D L I N G 727// D R A G ' N D R O P H A N D L I N G
592// ---------------------------------------------------------------------------- 728// ----------------------------------------------------------------------------
593 729
594void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) 730void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
595{ 731{
596#ifndef KORG_NODND 732#ifndef KORG_NODND
597 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 733 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
598 e->ignore(); 734 e->ignore();
599 return; 735 return;
600 } 736 }
601 737
602 // some visual feedback 738 // some visual feedback
603// oldPalette = palette(); 739// oldPalette = palette();
604// setPalette(my_HilitePalette); 740// setPalette(my_HilitePalette);
605// update(); 741// update();
606#endif 742#endif
607} 743}
608 744
609void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) 745void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
610{ 746{
611#ifndef KORG_NODND 747#ifndef KORG_NODND
612 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 748 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
613 e->ignore(); 749 e->ignore();
614 return; 750 return;
615 } 751 }
616 752
617 e->accept(); 753 e->accept();
618#endif 754#endif
619} 755}
620 756
621void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 757void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
622{ 758{
623#ifndef KORG_NODND 759#ifndef KORG_NODND
624// setPalette(oldPalette); 760// setPalette(oldPalette);
625// update(); 761// update();
626#endif 762#endif
627} 763}
628 764
629void KODayMatrix::dropEvent(QDropEvent *e) 765void KODayMatrix::dropEvent(QDropEvent *e)
630{ 766{
631#ifndef KORG_NODND 767#ifndef KORG_NODND
632// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 768// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
633 769
634 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 770 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
635 e->ignore(); 771 e->ignore();
636 return; 772 return;
637 } 773 }
@@ -684,311 +820,311 @@ void KODayMatrix::dropEvent(QDropEvent *e)
684void KODayMatrix::paintEvent(QPaintEvent * pevent) 820void KODayMatrix::paintEvent(QPaintEvent * pevent)
685{ 821{
686 822
687 if ( width() <= 0 || height() <= 0 ) 823 if ( width() <= 0 || height() <= 0 )
688 return; 824 return;
689 if ( mPendingUpdateBeforeRepaint ) { 825 if ( mPendingUpdateBeforeRepaint ) {
690 updateViewTimed(); 826 updateViewTimed();
691 mPendingUpdateBeforeRepaint = false; 827 mPendingUpdateBeforeRepaint = false;
692 } 828 }
693#if 0 829#if 0
694 if ( myPix.width() != width() || myPix.height()!=height() ) { 830 if ( myPix.width() != width() || myPix.height()!=height() ) {
695 myPix.resize(size() ); 831 myPix.resize(size() );
696 mRedrawNeeded = true; 832 mRedrawNeeded = true;
697 } 833 }
698#endif 834#endif
699 if ( oldW != width() || oldH !=height() ) 835 if ( oldW != width() || oldH !=height() )
700 mRedrawNeeded = true; 836 mRedrawNeeded = true;
701 837
702 oldH = height() ; 838 oldH = height() ;
703 oldW = width(); 839 oldW = width();
704 if ( myPix.width() < width() || myPix.height() < height() ) { 840 if ( myPix.width() < width() || myPix.height() < height() ) {
705 myPix.resize(size() ); 841 myPix.resize(size() );
706 mRedrawNeeded = true; 842 mRedrawNeeded = true;
707 843
708 } 844 }
709 845
710 if ( mRedrawNeeded ) { 846 if ( mRedrawNeeded ) {
711 //qDebug("REDRAW "); 847 //qDebug("REDRAW ");
712 QPainter p(&myPix); 848 QPainter p(&myPix);
713 p.setFont(font()); 849 p.setFont(font());
714 850
715 851
716 int dheight = daysize.height(); 852 int dheight = daysize.height();
717 int dwidth = daysize.width(); 853 int dwidth = daysize.width();
718 int row,col; 854 int row,col;
719 int selw, selh; 855 int selw, selh;
720 int xyOff = frameWidth(); 856 int xyOff = frameWidth();
721 int colModulo = (width()-2) % 7; 857 int colModulo = (width()-2) % 7;
722 int rowModulo = (height()-2) % 6; 858 int rowModulo = (height()-2) % 6;
723 //qDebug("col %d row %d ",colModulo,rowModulo ); 859 //qDebug("col %d row %d ",colModulo,rowModulo );
724 860
725 bool isRTL = KOGlobals::self()->reverseLayout(); 861 bool isRTL = KOGlobals::self()->reverseLayout();
726 862
727 // draw background and topleft frame 863 // draw background and topleft frame
728 p.fillRect(0,0,width(),height(), mDefaultBackColor); 864 p.fillRect(0,0,width(),height(), mDefaultBackColor);
729 p.setPen(mDefaultTextColor); 865 p.setPen(mDefaultTextColor);
730 p.drawRect(0, 0, width(), height()); 866 p.drawRect(0, 0, width(), height());
731 int mSelStartT = mSelStart; 867 int mSelStartT = mSelStart;
732 int mSelEndT = mSelEnd; 868 int mSelEndT = mSelEnd;
733 if ( mSelEndT >= NUMDAYS ) 869 if ( mSelEndT >= NUMDAYS )
734 mSelEndT = NUMDAYS-1; 870 mSelEndT = NUMDAYS-1;
735 // draw selected days with highlighted background color 871 // draw selected days with highlighted background color
736 if (mSelStart != NOSELECTION) { 872 if (mSelStart != NOSELECTION) {
737 bool skip = false; 873 bool skip = false;
738 if ( ! mouseDown ) { 874 if ( ! mouseDown ) {
739 int mo = days[20].month(); 875 int mo = days[20].month();
740 //qDebug("-- %d %d ", mSelStartT, mSelEndT); 876 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
741 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); 877 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
742 int startMo = days[mSelStartT].month(); 878 int startMo = days[mSelStartT].month();
743 int endMo = days[mSelEndT].month(); 879 int endMo = days[mSelEndT].month();
744 if ( startMo == 12 && mo == 1 && endMo <= 2 ) 880 if ( startMo == 12 && mo == 1 && endMo <= 2 )
745 startMo = 1; 881 startMo = 1;
746 if ( endMo == 1 && mo == 12 ) 882 if ( endMo == 1 && mo == 12 )
747 endMo = 12; 883 endMo = 12;
748 if ( mo == 12 && startMo == 1 ) 884 if ( mo == 12 && startMo == 1 )
749 startMo = 13; 885 startMo = 13;
750 if ( (startMo > mo || endMo < mo) ) { 886 if ( (startMo > mo || endMo < mo) ) {
751 skip = true; 887 skip = true;
752 } else { 888 } else {
753 if ( days[mSelStartT].month() != mo ) { 889 if ( days[mSelStartT].month() != mo ) {
754 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); 890 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
755 mSelStartT += add +1; 891 mSelStartT += add +1;
756 } 892 }
757 if ( days[mSelEndT].month() != mo ) { 893 if ( days[mSelEndT].month() != mo ) {
758 int sub = days[mSelEndT].day(); 894 int sub = days[mSelEndT].day();
759 mSelEndT -= sub ; 895 mSelEndT -= sub ;
760 } 896 }
761 } 897 }
762 } 898 }
763 //qDebug("SKIP %d ", skip); 899 //qDebug("SKIP %d ", skip);
764 if ( ! skip ) { 900 if ( ! skip ) {
765 row = mSelStartT/7; 901 row = mSelStartT/7;
766 col = mSelStartT -row*7; 902 col = mSelStartT -row*7;
767 QColor selcol = KOPrefs::instance()->mHighlightColor; 903 QColor selcol = KOPrefs::instance()->mHighlightColor;
768 int addCol = 0; 904 int addCol = 0;
769 int addRow = 0; 905 int addRow = 0;
770 int addRow2 = 0; 906 int addRow2 = 0;
771 int addCol2 = 0; 907 int addCol2 = 0;
772 if (row == mSelEndT/7) { 908 if (row == mSelEndT/7) {
773 if ( rowModulo ) { 909 if ( rowModulo ) {
774 if ( row >= 6 - rowModulo ) 910 if ( row >= 6 - rowModulo )
775 addRow = row - 5 + rowModulo; 911 addRow = row - 5 + rowModulo;
776 } 912 }
777 if ( colModulo ) { 913 if ( colModulo ) {
778 int colt1 = mSelEndT%7; 914 int colt1 = mSelEndT%7;
779 //qDebug("colt1 %d ", colt1 ); 915 //qDebug("colt1 %d ", colt1 );
780 if ( colt1 >= 7 - colModulo ) 916 if ( colt1 >= 7 - colModulo )
781 addCol = colt1 - 7 + colModulo+1; 917 addCol = colt1 - 7 + colModulo+1;
782 int colt = mSelStartT%7; 918 int colt = mSelStartT%7;
783 if ( colt >= 7 - colModulo ) 919 if ( colt >= 7 - colModulo )
784 addCol2 = colt - 7 + colModulo; 920 addCol2 = colt - 7 + colModulo;
785 addCol -= addCol2; 921 addCol -= addCol2;
786 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); 922 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
787 } 923 }
788 // Single row selection 924 // Single row selection
789 //if ( row == 0) 925 //if ( row == 0)
790 // addRow = 1; 926 // addRow = 1;
791 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, 927 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
792 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); 928 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
793 } else { 929 } else {
794 // draw first row to the right 930 // draw first row to the right
795 if ( colModulo ) { 931 if ( colModulo ) {
796 if ( col >= 7 - colModulo ) 932 if ( col >= 7 - colModulo )
797 addCol2 = col - 7 + colModulo; 933 addCol2 = col - 7 + colModulo;
798 } 934 }
799 if ( rowModulo ) { 935 if ( rowModulo ) {
800 if ( row >= 6 - rowModulo ) 936 if ( row >= 6 - rowModulo )
801 addRow = row - 5 + rowModulo; 937 addRow = row - 5 + rowModulo;
802 } 938 }
803 //if ( row == 0) 939 //if ( row == 0)
804 // addRow = 1; 940 // addRow = 1;
805 int drawWid = width()-(col*dwidth+1+addCol2)-1; 941 int drawWid = width()-(col*dwidth+1+addCol2)-1;
806 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, 942 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid,
807 dheight+1, selcol); 943 dheight+1, selcol);
808 // draw full block till last line 944 // draw full block till last line
809 selh = mSelEndT/7-row; 945 selh = mSelEndT/7-row;
810 addRow = 0; 946 addRow = 0;
811 if ( rowModulo ) { 947 if ( rowModulo ) {
812 if ( mSelEndT/7 >= 6 - rowModulo ) 948 if ( mSelEndT/7 >= 6 - rowModulo )
813 addRow = mSelEndT/7 - 5 + rowModulo; 949 addRow = mSelEndT/7 - 5 + rowModulo;
814 } 950 }
815 //qDebug("%d %d %d ",selh, row, addRow ); 951 //qDebug("%d %d %d ",selh, row, addRow );
816 int addrow2 = addRow-selh+1; 952 int addrow2 = addRow-selh+1;
817 if ( addrow2 < 0 ) 953 if ( addrow2 < 0 )
818 addrow2 = 0; 954 addrow2 = 0;
819 if (selh > 1) { 955 if (selh > 1) {
820 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); 956 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
821 } 957 }
822 // draw last block from left to mSelEndT 958 // draw last block from left to mSelEndT
823 selw = mSelEndT-7*(mSelEndT/7)+1; 959 selw = mSelEndT-7*(mSelEndT/7)+1;
824 //qDebug("esl %d ",selw ); 960 //qDebug("esl %d ",selw );
825 int add = 0; 961 int add = 0;
826 if ( colModulo ) { 962 if ( colModulo ) {
827 add = 7 - colModulo; 963 add = 7 - colModulo;
828 if ( selw > add ) 964 if ( selw > add )
829 add = selw - add; 965 add = selw - add;
830 else 966 else
831 add = 0; 967 add = 0;
832 } 968 }
833 //qDebug("add %d ", add); 969 //qDebug("add %d ", add);
834 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, 970 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
835 selw*dwidth+add, dheight+1, selcol); 971 selw*dwidth+add, dheight+1, selcol);
836 } 972 }
837 } 973 }
838 } 974 }
839 975
840 // iterate over all days in the matrix and draw the day label in appropriate colors 976 // iterate over all days in the matrix and draw the day label in appropriate colors
841 QColor actcol = mDefaultTextColorShaded; 977 QColor actcol = mDefaultTextColorShaded;
842 p.setPen(actcol); 978 p.setPen(actcol);
843 QPen tmppen; 979 QPen tmppen;
844 for(int i = 0; i < NUMDAYS; i++) { 980 for(int i = 0; i < NUMDAYS; i++) {
845 row = i/7; 981 row = i/7;
846 col = isRTL ? 6-(i-row*7) : i-row*7; 982 col = isRTL ? 6-(i-row*7) : i-row*7;
847 983
848 // if it is the first day of a month switch color from normal to shaded and vice versa 984 // if it is the first day of a month switch color from normal to shaded and vice versa
849 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 985 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
850 if (actcol == mDefaultTextColorShaded) { 986 if (actcol == mDefaultTextColorShaded) {
851 actcol = mDefaultTextColor; 987 actcol = mDefaultTextColor;
852 } else { 988 } else {
853 actcol = mDefaultTextColorShaded; 989 actcol = mDefaultTextColorShaded;
854 } 990 }
855 p.setPen(actcol); 991 p.setPen(actcol);
856 } 992 }
857 if (actcol == mDefaultTextColorShaded) { 993 if (actcol == mDefaultTextColorShaded) {
858 if ( ! mouseDown ) { 994 if ( ! mouseDown ) {
859 continue; 995 continue;
860 } 996 }
861 } 997 }
862 //Reset pen color after selected days block 998 //Reset pen color after selected days block
863 if (i == mSelEndT+1) { 999 if (i == mSelEndT+1) {
864 p.setPen(actcol); 1000 p.setPen(actcol);
865 } 1001 }
866 1002
867 // if today then draw rectangle around day 1003 // if today then draw rectangle around day
868 if (today == i) { 1004 if (today == i) {
869 tmppen = p.pen(); 1005 tmppen = p.pen();
870 QPen mTodayPen(p.pen()); 1006 QPen mTodayPen(p.pen());
871 if ( daysize.width() < 20 ) 1007 if ( daysize.width() < 20 )
872 mTodayPen.setWidth(1); 1008 mTodayPen.setWidth(1);
873 else 1009 else
874 mTodayPen.setWidth(mTodayMarginWidth); 1010 mTodayPen.setWidth(mTodayMarginWidth);
875 //draw red rectangle for holidays 1011 //draw red rectangle for holidays
876 if (!mHolidays[i].isNull()) { 1012 if (pDays.testBit(i)) {
877 if (actcol == mDefaultTextColor) { 1013 if (actcol == mDefaultTextColor) {
878 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 1014 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
879 } else { 1015 } else {
880 mTodayPen.setColor(mHolidayColorShaded); 1016 mTodayPen.setColor(mHolidayColorShaded);
881 } 1017 }
882 } 1018 }
883 //draw gray rectangle for today if in selection 1019 //draw gray rectangle for today if in selection
884 if (i >= mSelStartT && i <= mSelEndT) { 1020 if (i >= mSelStartT && i <= mSelEndT) {
885 QColor grey("grey"); 1021 QColor grey("grey");
886 mTodayPen.setColor(grey); 1022 mTodayPen.setColor(grey);
887 } 1023 }
888 p.setPen(mTodayPen); 1024 p.setPen(mTodayPen);
889 1025
890 1026
891 int addCol = 0; 1027 int addCol = 0;
892 int addRow = 0; 1028 int addRow = 0;
893 if (rowModulo) { 1029 if (rowModulo) {
894 if ( row >= 6 - rowModulo ) 1030 if ( row >= 6 - rowModulo )
895 addRow = row - 5 + rowModulo; 1031 addRow = row - 5 + rowModulo;
896 } 1032 }
897 if ( colModulo ) { 1033 if ( colModulo ) {
898 if ( col >= 7 - colModulo ) 1034 if ( col >= 7 - colModulo )
899 addCol = col - 6 + colModulo-1; 1035 addCol = col - 6 + colModulo-1;
900 } 1036 }
901 1037
902 addCol += 1; 1038 addCol += 1;
903 if ( row == 0 ) 1039 if ( row == 0 )
904 addRow = 1; 1040 addRow = 1;
905 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); 1041 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1);
906 p.setPen(tmppen); 1042 p.setPen(tmppen);
907 } 1043 }
908 1044
909 // if any events are on that day then draw it using a bold font 1045 // if any events are on that day then draw it using a bold font
910 if ( eDays.testBit(i) ) { 1046 if ( eDays.testBit(i) ) {
911 QFont myFont = font(); 1047 QFont myFont = font();
912 myFont.setBold(true); 1048 myFont.setBold(true);
913 p.setFont(myFont); 1049 p.setFont(myFont);
914 } 1050 }
915 1051
916 // if it is a holiday then use the default holiday color 1052 // if it is a holiday then use the default holiday color
917 if ( !mHolidays[i].isNull()) { 1053 if ( pDays.testBit(i)) {
918 if ( bDays.testBit(i) ) { 1054 if ( bDays.testBit(i) ) {
919 if ( hDays.testBit(i) ) 1055 if ( hDays.testBit(i) )
920 p.setPen(QColor(Qt::green)); 1056 p.setPen(QColor(Qt::green));
921 else 1057 else
922 p.setPen(QColor(Qt::green).dark()); 1058 p.setPen(QColor(Qt::green).dark());
923 } else { 1059 } else {
924 if (actcol == mDefaultTextColor ) { 1060 if (actcol == mDefaultTextColor ) {
925 p.setPen(KOPrefs::instance()->mHolidayColor); 1061 p.setPen(KOPrefs::instance()->mHolidayColor);
926 } else { 1062 } else {
927 p.setPen(mHolidayColorShaded); 1063 p.setPen(mHolidayColorShaded);
928 } 1064 }
929 } 1065 }
930 } 1066 }
931 1067
932 // draw selected days with special color 1068 // draw selected days with special color
933 // DO NOT specially highlight holidays in selection ! 1069 // DO NOT specially highlight holidays in selection !
934 if (i >= mSelStartT && i <= mSelEndT) { 1070 if (i >= mSelStartT && i <= mSelEndT) {
935 ;//p.setPen(mSelectedDaysColor); 1071 ;//p.setPen(mSelectedDaysColor);
936 } 1072 }
937 1073
938 int addCol = 0; 1074 int addCol = 0;
939 int addRow = 0; 1075 int addRow = 0;
940 if ( colModulo ) { 1076 if ( colModulo ) {
941 if ( col >= 7 - colModulo ) 1077 if ( col >= 7 - colModulo )
942 addCol = col - 7 + colModulo; 1078 addCol = col - 7 + colModulo;
943 } 1079 }
944 if ( rowModulo ) { 1080 if ( rowModulo ) {
945 if ( row >= 6 - rowModulo ) 1081 if ( row >= 6 - rowModulo )
946 addRow = row - 5 + rowModulo; 1082 addRow = row - 5 + rowModulo;
947 } 1083 }
948 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 1084 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
949 ++addCol;//++addCol; 1085 ++addCol;//++addCol;
950 if ( row == 0) 1086 if ( row == 0)
951 addRow = 1; 1087 addRow = 1;
952 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 1088 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
953 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 1089 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
954 1090
955 // reset color to actual color 1091 // reset color to actual color
956 if (!mHolidays[i].isNull()) { 1092 if (pDays.testBit(i)) {
957 p.setPen(actcol); 1093 p.setPen(actcol);
958 } 1094 }
959 // reset bold font to plain font 1095 // reset bold font to plain font
960 if ( eDays.testBit(i)) { 1096 if ( eDays.testBit(i)) {
961 QFont myFont = font(); 1097 QFont myFont = font();
962 myFont.setBold(false); 1098 myFont.setBold(false);
963 p.setFont(myFont); 1099 p.setFont(myFont);
964 } 1100 }
965 } 1101 }
966 } else { 1102 } else {
967 //qDebug("NO redraw "); 1103 //qDebug("NO redraw ");
968 } 1104 }
969 1105
970 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP); 1106 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP);
971 mRedrawNeeded = false; 1107 mRedrawNeeded = false;
972} 1108}
973 1109
974// ---------------------------------------------------------------------------- 1110// ----------------------------------------------------------------------------
975// R E SI Z E E V E N T H A N D L I N G 1111// R E SI Z E E V E N T H A N D L I N G
976// ---------------------------------------------------------------------------- 1112// ----------------------------------------------------------------------------
977 1113
978void KODayMatrix::resizeEvent(QResizeEvent *) 1114void KODayMatrix::resizeEvent(QResizeEvent *)
979{ 1115{
980 QRect sz = frameRect(); 1116 QRect sz = frameRect();
981 daysize.setHeight(sz.height()*7 / NUMDAYS); 1117 daysize.setHeight(sz.height()*7 / NUMDAYS);
982 daysize.setWidth(sz.width() / 7); 1118 daysize.setWidth(sz.width() / 7);
983} 1119}
984 1120
985QSize KODayMatrix::sizeHint() const 1121QSize KODayMatrix::sizeHint() const
986{ 1122{
987 1123
988 QFontMetrics fm ( font() ); 1124 QFontMetrics fm ( font() );
989 int wid = fm.width( "30") *7+3; 1125 int wid = fm.width( "30") *7+3;
990 int hei = fm.height() * 6+3; 1126 int hei = fm.height() * 6+3;
991 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); 1127 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
992 return QSize ( wid, hei ); 1128 return QSize ( wid, hei );
993 1129
994} 1130}
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index d725ead..b686bd7 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -38,291 +38,293 @@
38class QDragEnterEvent; 38class QDragEnterEvent;
39class QDragMoveEvent; 39class QDragMoveEvent;
40class QDragLeaveEvent; 40class QDragLeaveEvent;
41class QDropEvent; 41class QDropEvent;
42 42
43class KODayMatrix; 43class KODayMatrix;
44class KODaymatrixWhatsThis; 44class KODaymatrixWhatsThis;
45 45
46using namespace KCal; 46using namespace KCal;
47 47
48 48
49/** 49/**
50 * small helper class to dynamically show tooltips inside the day matrix. 50 * small helper class to dynamically show tooltips inside the day matrix.
51 * This class asks the day matrix object for a appropriate label which 51 * This class asks the day matrix object for a appropriate label which
52 * is in our special case the name of the holiday or null if this day is no holiday. 52 * is in our special case the name of the holiday or null if this day is no holiday.
53 */ 53 */
54class DynamicTip : public QToolTip 54class DynamicTip : public QToolTip
55{ 55{
56public: 56public:
57 57
58 /** 58 /**
59 * Constructor that expects a KODayMatrix object as parent. 59 * Constructor that expects a KODayMatrix object as parent.
60 * 60 *
61 * @param parent the parent KODayMatrix control. 61 * @param parent the parent KODayMatrix control.
62 */ 62 */
63 DynamicTip(QWidget* parent ); 63 DynamicTip(QWidget* parent );
64 64
65protected: 65protected:
66 66
67 /** 67 /**
68 * Qt's callback to ask the object to provide an approrpiate text for the 68 * Qt's callback to ask the object to provide an approrpiate text for the
69 * tooltip to be shown. 69 * tooltip to be shown.
70 * 70 *
71 * @param pos coordinates of the mouse. 71 * @param pos coordinates of the mouse.
72 */ 72 */
73 void maybeTip( const QPoint & pos); 73 void maybeTip( const QPoint & pos);
74 74
75private: 75private:
76 76
77 /** the parent control this tooltip is designed for. */ 77 /** the parent control this tooltip is designed for. */
78 KODayMatrix* matrix; 78 KODayMatrix* matrix;
79}; 79};
80 80
81/** 81/**
82 * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. 82 * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed.
83 * Cornelius thought this was a waste of memory and a lot of overhead. 83 * Cornelius thought this was a waste of memory and a lot of overhead.
84 * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame 84 * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame
85 * that draws the labels and allows for dragging selection while maintaining nearly full 85 * that draws the labels and allows for dragging selection while maintaining nearly full
86 * compatibility in behaviour with its predecessor. 86 * compatibility in behaviour with its predecessor.
87 * 87 *
88 * The following functionality has been changed: 88 * The following functionality has been changed:
89 * 89 *
90 * o when shifting events in the agenda view from one day to another the day matrix is updated now 90 * o when shifting events in the agenda view from one day to another the day matrix is updated now
91 * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. 91 * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date.
92 * o no support for Ctrl+click to create groups of dates 92 * o no support for Ctrl+click to create groups of dates
93 * (This has not really been supported in the predecessor. It was not very intuitive nor was it 93 * (This has not really been supported in the predecessor. It was not very intuitive nor was it
94 * user friendly.) 94 * user friendly.)
95 * This feature has been replaced with dragging a selection on the matrix. The matrix will 95 * This feature has been replaced with dragging a selection on the matrix. The matrix will
96 * automatically choose the appropriate selection (e.g. you are not any longer able to select 96 * automatically choose the appropriate selection (e.g. you are not any longer able to select
97 * two distinct groups of date selections as in the old class) 97 * two distinct groups of date selections as in the old class)
98 * o now that you can select more then a week it can happen that not all selected days are 98 * o now that you can select more then a week it can happen that not all selected days are
99 * displayed in the matrix. However this is preferred to the alternative which would mean to 99 * displayed in the matrix. However this is preferred to the alternative which would mean to
100 * adjust the selection and leave some days undisplayed while scrolling through the months 100 * adjust the selection and leave some days undisplayed while scrolling through the months
101 * 101 *
102 * @short day matrix widget of the KDateNavigator 102 * @short day matrix widget of the KDateNavigator
103 * 103 *
104 * @author Eitzenberger Thomas 104 * @author Eitzenberger Thomas
105 */ 105 */
106class KODayMatrix: public QFrame { 106class KODayMatrix: public QFrame {
107 107
108 Q_OBJECT 108 Q_OBJECT
109 109
110public: 110public:
111 111
112 /** constructor to create a day matrix widget. 112 /** constructor to create a day matrix widget.
113 * 113 *
114 * @param parent widget that is the parent of the day matrix. Normally this should 114 * @param parent widget that is the parent of the day matrix. Normally this should
115 * be a KDateNavigator 115 * be a KDateNavigator
116 * @param calendar instance of a calendar on which all calculations are based 116 * @param calendar instance of a calendar on which all calculations are based
117 * @param date start date of the matrix (is expected to be already fixed). It is 117 * @param date start date of the matrix (is expected to be already fixed). It is
118 * assumed that this date is the first week day to be shown in the matrix. 118 * assumed that this date is the first week day to be shown in the matrix.
119 * @param name name of the widget 119 * @param name name of the widget
120 */ 120 */
121 KODayMatrix( QWidget *parent, const char *name ); 121 KODayMatrix( QWidget *parent, const char *name );
122 //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); 122 //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name );
123 123
124 /** destructor that deallocates all dynamically allocated private members. 124 /** destructor that deallocates all dynamically allocated private members.
125 */ 125 */
126 ~KODayMatrix(); 126 ~KODayMatrix();
127 127
128 /** updates the day matrix to start with the given date. Does all the necessary 128 /** updates the day matrix to start with the given date. Does all the necessary
129 * checks for holidays or events on a day and stores them for display later on. 129 * checks for holidays or events on a day and stores them for display later on.
130 * Does NOT update the view visually. Call repaint() for this. 130 * Does NOT update the view visually. Call repaint() for this.
131 * 131 *
132 * @param actdate recalculates the day matrix to show NUMDAYS starting from this 132 * @param actdate recalculates the day matrix to show NUMDAYS starting from this
133 * date. 133 * date.
134 */ 134 */
135 void updateView(QDate actdate); 135 void updateView(QDate actdate);
136 void updateEvents(); 136 void updateEvents();
137 137
138 /** returns the QDate object associated with day indexed by the 138 /** returns the QDate object associated with day indexed by the
139 * supplied offset. 139 * supplied offset.
140 */ 140 */
141 const QDate& getDate(int offset); 141 const QDate& getDate(int offset);
142 void setCalendar( Calendar * ); 142 void setCalendar( Calendar * );
143 /** returns the official name of this holy day or 0 if there is no label 143 /** returns the official name of this holy day or 0 if there is no label
144 * for this day. 144 * for this day.
145 */ 145 */
146 QString getHolidayLabel(int offset); 146 QString getHolidayLabel(int offset);
147 147
148 /** adds all actual selected days from mSelStart to mSelEnd to the supplied 148 /** adds all actual selected days from mSelStart to mSelEnd to the supplied
149 * DateList. 149 * DateList.
150 */ 150 */
151 void addSelectedDaysTo(DateList&); 151 void addSelectedDaysTo(DateList&);
152 152
153 /** sets the actual to be displayed selection in the day matrix starting from 153 /** sets the actual to be displayed selection in the day matrix starting from
154 * start and ending with end. Theview must be manually updated by calling 154 * start and ending with end. Theview must be manually updated by calling
155 * repaint. (?) 155 * repaint. (?)
156 */ 156 */
157 bool setSelectedDaysFrom(const QDate& start, const QDate& end); 157 bool setSelectedDaysFrom(const QDate& start, const QDate& end);
158 void clearSelection(); 158 void clearSelection();
159 159
160 /** Is today visible in the view? Keep this in sync with 160 /** Is today visible in the view? Keep this in sync with
161 * the values today (below) can take. 161 * the values today (below) can take.
162 */ 162 */
163 bool isTodayVisible() const { return today>=0; } ; 163 bool isTodayVisible() const { return today>=0; } ;
164 164
165 /** If today is visible, then we can find out if today is 165 /** If today is visible, then we can find out if today is
166 * near the beginning or the end of the month. 166 * near the beginning or the end of the month.
167 * This is dependent on today remaining the index 167 * This is dependent on today remaining the index
168 * in the array of visible dates and going from 168 * in the array of visible dates and going from
169 * top left (0) to bottom right (41). 169 * top left (0) to bottom right (41).
170 */ 170 */
171 bool isBeginningOfMonth() const { return today<=8; } ; 171 bool isBeginningOfMonth() const { return today<=8; } ;
172 bool isEndOfMonth() const { return today>=27; } ; 172 bool isEndOfMonth() const { return today>=27; } ;
173 QString getWhatsThisText( QPoint ) ; 173 QString getWhatsThisText( QPoint ) ;
174 QSize sizeHint() const; 174 QSize sizeHint() const;
175 QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} 175 QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);}
176public slots: 176public slots:
177 /** Recalculates all the flags of the days in the matrix like holidays or events 177 /** Recalculates all the flags of the days in the matrix like holidays or events
178 * on a day (Actually calls above method with the actual startdate). 178 * on a day (Actually calls above method with the actual startdate).
179 */ 179 */
180 void updateView(); 180 void updateView();
181 void updateViewTimed(); 181 void updateViewTimed();
182 void repaintViewTimed(); 182 void repaintViewTimed();
183 183
184 /** 184 /**
185 * Calculate which square in the matrix should be 185 * Calculate which square in the matrix should be
186 * hilighted to indicate it's today. 186 * hilighted to indicate it's today.
187 */ 187 */
188 void recalculateToday(); 188 void recalculateToday();
189 189
190/* 190/*
191 void setStartDate(QDate); 191 void setStartDate(QDate);
192*/ 192*/
193 193
194signals: 194signals:
195 195
196 /** emitted if the user selects a block of days with the mouse by dragging a rectangle 196 /** emitted if the user selects a block of days with the mouse by dragging a rectangle
197 * inside the matrix 197 * inside the matrix
198 * 198 *
199 * @param daylist list of days that have been selected by the user 199 * @param daylist list of days that have been selected by the user
200 */ 200 */
201 void selected( const KCal::DateList &daylist ); 201 void selected( const KCal::DateList &daylist );
202 202
203 /** emitted if the user has dropped an event inside the matrix 203 /** emitted if the user has dropped an event inside the matrix
204 * 204 *
205 * @param event the dropped calendar event 205 * @param event the dropped calendar event
206 */ 206 */
207 void eventDropped(Event *event); 207 void eventDropped(Event *event);
208 208
209protected: 209protected:
210 210
211 void paintEvent(QPaintEvent *ev); 211 void paintEvent(QPaintEvent *ev);
212 212
213 void mousePressEvent (QMouseEvent* e); 213 void mousePressEvent (QMouseEvent* e);
214 214
215 void mouseReleaseEvent (QMouseEvent* e); 215 void mouseReleaseEvent (QMouseEvent* e);
216 216
217 void mouseMoveEvent (QMouseEvent* e); 217 void mouseMoveEvent (QMouseEvent* e);
218 218
219 void dragEnterEvent(QDragEnterEvent *); 219 void dragEnterEvent(QDragEnterEvent *);
220 220
221 void dragMoveEvent(QDragMoveEvent *); 221 void dragMoveEvent(QDragMoveEvent *);
222 222
223 void dragLeaveEvent(QDragLeaveEvent *); 223 void dragLeaveEvent(QDragLeaveEvent *);
224 224
225 void dropEvent(QDropEvent *); 225 void dropEvent(QDropEvent *);
226 226
227 void resizeEvent(QResizeEvent *); 227 void resizeEvent(QResizeEvent *);
228 228
229private: 229private:
230 void computeEvent(Event *even, int dayindex );
230 int oldW, oldH; 231 int oldW, oldH;
231 bool mRedrawNeeded; 232 bool mRedrawNeeded;
232 KODaymatrixWhatsThis* mKODaymatrixWhatsThis; 233 KODaymatrixWhatsThis* mKODaymatrixWhatsThis;
233 bool mouseDown; 234 bool mouseDown;
234 QBitArray bDays; 235 QBitArray bDays;
235 QBitArray hDays; 236 QBitArray hDays;
236 QBitArray eDays; 237 QBitArray eDays;
238 QBitArray pDays;
237 QPixmap myPix; 239 QPixmap myPix;
238 QTimer* mUpdateTimer; 240 QTimer* mUpdateTimer;
239 QTimer* mRepaintTimer; 241 QTimer* mRepaintTimer;
240 bool mDayChanged; 242 bool mDayChanged;
241 bool mPendingUpdateBeforeRepaint; 243 bool mPendingUpdateBeforeRepaint;
242 244
243 /** returns the index of the day located at the matrix's widget (x,y) position. 245 /** returns the index of the day located at the matrix's widget (x,y) position.
244 * 246 *
245 * @param x horizontal coordinate 247 * @param x horizontal coordinate
246 * @param y vertical coordinate 248 * @param y vertical coordinate
247 */ 249 */
248 int getDayIndexFrom(int x, int y); 250 int getDayIndexFrom(int x, int y);
249 251
250 /** calculates a "shaded" color from the supplied color object. 252 /** calculates a "shaded" color from the supplied color object.
251 * (Copied from Cornelius's kdpdatebutton.cpp) 253 * (Copied from Cornelius's kdpdatebutton.cpp)
252 * 254 *
253 * @param color source based on which a shaded color should be calculated. 255 * @param color source based on which a shaded color should be calculated.
254 */ 256 */
255 QColor getShadedColor(QColor color); 257 QColor getShadedColor(QColor color);
256 258
257 /** number of days to be displayed. For now there is no support for any other number then 42. 259 /** number of days to be displayed. For now there is no support for any other number then 42.
258 so change it at your own risk :o) */ 260 so change it at your own risk :o) */
259 static const int NUMDAYS; 261 static const int NUMDAYS;
260 262
261 /** calendar instance to be queried for holidays, events, ... */ 263 /** calendar instance to be queried for holidays, events, ... */
262 Calendar *mCalendar; 264 Calendar *mCalendar;
263 265
264 /** starting date of the matrix */ 266 /** starting date of the matrix */
265 QDate startdate; 267 QDate startdate;
266 268
267 /** array of day labels to optimeize drawing performance. */ 269 /** array of day labels to optimeize drawing performance. */
268 QString *daylbls; 270 QString *daylbls;
269 271
270 /** array of days displayed to reduce memory consumption by 272 /** array of days displayed to reduce memory consumption by
271 subsequently calling QDate::addDays(). */ 273 subsequently calling QDate::addDays(). */
272 QDate *days; 274 QDate *days;
273 275
274 /** array of storing the number of events on a given day. 276 /** array of storing the number of events on a given day.
275 * used for drawing a bold font if there is at least one event on that day. 277 * used for drawing a bold font if there is at least one event on that day.
276 */ 278 */
277 //int *events; 279 //int *events;
278 280
279 /** stores holiday names of the days shown in the matrix. */ 281 /** stores holiday names of the days shown in the matrix. */
280 QMap<int,QString> mHolidays; 282 QMap<int,QString> mHolidays;
281 283
282 /** indey of today or -1 if today is not visible in the matrix. */ 284 /** indey of today or -1 if today is not visible in the matrix. */
283 int today; 285 int today;
284 286
285 /** index of day where dragged selection was initiated. 287 /** index of day where dragged selection was initiated.
286 used to detect "negative" timely selections */ 288 used to detect "negative" timely selections */
287 int mSelInit; 289 int mSelInit;
288 290
289 /** if mSelStart has this value it indicates that there is no 291 /** if mSelStart has this value it indicates that there is no
290 actual selection in the matrix. */ 292 actual selection in the matrix. */
291 static const int NOSELECTION; 293 static const int NOSELECTION;
292 294
293 /** index of first selected day. */ 295 /** index of first selected day. */
294 int mSelStart; 296 int mSelStart;
295 297
296 /** index of last selected day. */ 298 /** index of last selected day. */
297 int mSelEnd; 299 int mSelEnd;
298 300
299 /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ 301 /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */
300 DynamicTip* mToolTip; 302 DynamicTip* mToolTip;
301 303
302 304
303 /** default background colour of the matrix. */ 305 /** default background colour of the matrix. */
304 QColor mDefaultBackColor; 306 QColor mDefaultBackColor;
305 307
306 /** default text color of the matrix. */ 308 /** default text color of the matrix. */
307 QColor mDefaultTextColor; 309 QColor mDefaultTextColor;
308 310
309 /** default text color for days not in the actual month. */ 311 /** default text color for days not in the actual month. */
310 QColor mDefaultTextColorShaded; 312 QColor mDefaultTextColorShaded;
311 313
312 /** default text color for holidays not in the actual month. */ 314 /** default text color for holidays not in the actual month. */
313 QColor mHolidayColorShaded; 315 QColor mHolidayColorShaded;
314 316
315 /** text color for selected days. */ 317 /** text color for selected days. */
316 QColor mSelectedDaysColor; 318 QColor mSelectedDaysColor;
317 319
318 /** default width of the frame drawn around today if it is visible in the matrix. */ 320 /** default width of the frame drawn around today if it is visible in the matrix. */
319 int mTodayMarginWidth; 321 int mTodayMarginWidth;
320 322
321 /** stores actual size of each day in the widget so that I dont need to ask this data 323 /** stores actual size of each day in the widget so that I dont need to ask this data
322 * on every repaint. 324 * on every repaint.
323 */ 325 */
324 QRect daysize; 326 QRect daysize;
325 327
326}; 328};
327 329
328#endif 330#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 1ed288b..425496a 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -80,920 +80,938 @@ KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
80 : QListBox(parent, name, WRepaintNoErase) 80 : QListBox(parent, name, WRepaintNoErase)
81{ 81{
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mWT = new KNOWhatsThis(this); 85 mWT = new KNOWhatsThis(this);
86 resetOnFocusIn = true; 86 resetOnFocusIn = true;
87 setVScrollBarMode(QScrollView::AlwaysOff); 87 setVScrollBarMode(QScrollView::AlwaysOff);
88 setHScrollBarMode(QScrollView::AlwaysOff); 88 setHScrollBarMode(QScrollView::AlwaysOff);
89} 89}
90KNoScrollListBox::~KNoScrollListBox() 90KNoScrollListBox::~KNoScrollListBox()
91{ 91{
92 92
93} 93}
94 94
95 95
96void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 96void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
97{ 97{
98 QListBox::focusInEvent ( e ); 98 QListBox::focusInEvent ( e );
99 QListBoxItem * i = item ( 0 ); 99 QListBoxItem * i = item ( 0 );
100 if ( i && resetOnFocusIn ) { 100 if ( i && resetOnFocusIn ) {
101 setCurrentItem( i ); 101 setCurrentItem( i );
102 setSelected ( 0, true ); 102 setSelected ( 0, true );
103 } 103 }
104 resetOnFocusIn = true; 104 resetOnFocusIn = true;
105 105
106 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { 106 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
107 QListBoxItem *fi = firstItem (); 107 QListBoxItem *fi = firstItem ();
108 if (fi ) { 108 if (fi ) {
109 int ihei = fi->height( this ); 109 int ihei = fi->height( this );
110 int hei = numRows () * ihei; 110 int hei = numRows () * ihei;
111 if ( hei < height() - horizontalScrollBar()->height () ) { 111 if ( hei < height() - horizontalScrollBar()->height () ) {
112 setVScrollBarMode(QScrollView::AlwaysOff); 112 setVScrollBarMode(QScrollView::AlwaysOff);
113 } 113 }
114 else 114 else
115 setVScrollBarMode(QScrollView::Auto); 115 setVScrollBarMode(QScrollView::Auto);
116 if ( ihei *3 > height() ) { 116 if ( ihei *3 > height() ) {
117 setHScrollBarMode(QScrollView::AlwaysOff); 117 setHScrollBarMode(QScrollView::AlwaysOff);
118 } 118 }
119 else { 119 else {
120 setHScrollBarMode(QScrollView::Auto); 120 setHScrollBarMode(QScrollView::Auto);
121 } 121 }
122 } else { 122 } else {
123 setVScrollBarMode(QScrollView::Auto); 123 setVScrollBarMode(QScrollView::Auto);
124 setHScrollBarMode(QScrollView::Auto); 124 setHScrollBarMode(QScrollView::Auto);
125 } 125 }
126 } 126 }
127} 127}
128void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 128void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
129{ 129{
130 int i = currentItem (); 130 int i = currentItem ();
131 if ( i >= 0 ) { 131 if ( i >= 0 ) {
132 setSelected ( i, false ); 132 setSelected ( i, false );
133 } 133 }
134 QListBox::focusOutEvent ( e ); 134 QListBox::focusOutEvent ( e );
135 setVScrollBarMode(QScrollView::AlwaysOff); 135 setVScrollBarMode(QScrollView::AlwaysOff);
136 setHScrollBarMode(QScrollView::AlwaysOff); 136 setHScrollBarMode(QScrollView::AlwaysOff);
137} 137}
138 138
139QString KNoScrollListBox::getWhatsThisText(QPoint p) 139QString KNoScrollListBox::getWhatsThisText(QPoint p)
140{ 140{
141 QListBoxItem* item = itemAt ( p ); 141 QListBoxItem* item = itemAt ( p );
142 if ( ! item ) { 142 if ( ! item ) {
143 return i18n("Click in the cell\nto add an event!"); 143 return i18n("Click in the cell\nto add an event!");
144 } 144 }
145 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 145 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
146 KOPrefs::instance()->mWTshowDetails, 146 KOPrefs::instance()->mWTshowDetails,
147 KOPrefs::instance()->mWTshowCreated, 147 KOPrefs::instance()->mWTshowCreated,
148 KOPrefs::instance()->mWTshowChanged); 148 KOPrefs::instance()->mWTshowChanged);
149} 149}
150void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 150void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
151{ 151{
152 //qDebug("KNoScrollListBox::keyPressEvent "); 152 //qDebug("KNoScrollListBox::keyPressEvent ");
153 switch(e->key()) { 153 switch(e->key()) {
154 case Key_Right: 154 case Key_Right:
155 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 155 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
156 { 156 {
157 e->ignore(); 157 e->ignore();
158 return; 158 return;
159 } 159 }
160 scrollBy(10,0); 160 scrollBy(10,0);
161 break; 161 break;
162 case Key_Left: 162 case Key_Left:
163 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 163 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
164 { 164 {
165 e->ignore(); 165 e->ignore();
166 return; 166 return;
167 } 167 }
168 scrollBy(-10,0); 168 scrollBy(-10,0);
169 break; 169 break;
170 case Key_Up: 170 case Key_Up:
171 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 171 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
172 e->ignore(); 172 e->ignore();
173 break; 173 break;
174 } 174 }
175 if ( count() ) { 175 if ( count() ) {
176 setCurrentItem((currentItem()+count()-1)%count()); 176 setCurrentItem((currentItem()+count()-1)%count());
177 if(!itemVisible(currentItem())) { 177 if(!itemVisible(currentItem())) {
178 if((unsigned int) currentItem() == (count()-1)) { 178 if((unsigned int) currentItem() == (count()-1)) {
179 setTopItem(currentItem()-numItemsVisible()+1); 179 setTopItem(currentItem()-numItemsVisible()+1);
180 } else { 180 } else {
181 setTopItem(topItem()-1); 181 setTopItem(topItem()-1);
182 } 182 }
183 } 183 }
184 } 184 }
185 break; 185 break;
186 case Key_Down: 186 case Key_Down:
187 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 187 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
188 e->ignore(); 188 e->ignore();
189 break; 189 break;
190 } 190 }
191 if ( count () ) { 191 if ( count () ) {
192 setCurrentItem((currentItem()+1)%count()); 192 setCurrentItem((currentItem()+1)%count());
193 if(!itemVisible(currentItem())) { 193 if(!itemVisible(currentItem())) {
194 if(currentItem() == 0) { 194 if(currentItem() == 0) {
195 setTopItem(0); 195 setTopItem(0);
196 } else { 196 } else {
197 setTopItem(topItem()+1); 197 setTopItem(topItem()+1);
198 } 198 }
199 } 199 }
200 } 200 }
201 break; 201 break;
202 case Key_I: 202 case Key_I:
203 QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 203 QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
204 e->ignore(); 204 e->ignore();
205 break; 205 break;
206 case Key_Return: 206 case Key_Return:
207 case Key_Enter: 207 case Key_Enter:
208 { 208 {
209 if ( currentItem() >= 0 ) { 209 if ( currentItem() >= 0 ) {
210 emit doubleClicked( item( currentItem() ) ); 210 emit doubleClicked( item( currentItem() ) );
211 e->accept(); 211 e->accept();
212 } else { 212 } else {
213 e->ignore(); 213 e->ignore();
214 } 214 }
215 } 215 }
216 break; 216 break;
217 case Key_Shift: 217 case Key_Shift:
218 emit shiftDown(); 218 emit shiftDown();
219 break; 219 break;
220 default: 220 default:
221 e->ignore(); 221 e->ignore();
222 break; 222 break;
223 } 223 }
224} 224}
225 225
226void KNoScrollListBox::oneDown() 226void KNoScrollListBox::oneDown()
227{ 227{
228 if ( count () ) { 228 if ( count () ) {
229 resetOnFocusIn = false; 229 resetOnFocusIn = false;
230 setCurrentItem((currentItem()+1)%count()); 230 setCurrentItem((currentItem()+1)%count());
231 if(!itemVisible(currentItem())) { 231 if(!itemVisible(currentItem())) {
232 if(currentItem() == 0) { 232 if(currentItem() == 0) {
233 setTopItem(0); 233 setTopItem(0);
234 } else { 234 } else {
235 setTopItem(topItem()+1); 235 setTopItem(topItem()+1);
236 } 236 }
237 } 237 }
238 } 238 }
239} 239}
240void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 240void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
241{ 241{
242 switch(e->key()) { 242 switch(e->key()) {
243 case Key_Shift: 243 case Key_Shift:
244 emit shiftUp(); 244 emit shiftUp();
245 break; 245 break;
246 default: 246 default:
247 break; 247 break;
248 } 248 }
249} 249}
250 250
251void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 251void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
252{ 252{
253 QListBox::mousePressEvent(e); 253 QListBox::mousePressEvent(e);
254 254
255 if(e->button() == RightButton) { 255 if(e->button() == RightButton) {
256 emit rightClick(); 256 emit rightClick();
257 } 257 }
258} 258}
259 259
260MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 260MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
261 : QListBoxItem() 261 : QListBoxItem()
262{ 262{
263 mblockRepaint = true; 263 mblockRepaint = true;
264 setText( s ); 264 setText( s );
265 mMultiday = 0; 265 mMultiday = 0;
266 mIncidence = incidence; 266 mIncidence = incidence;
267 mDate = qd; 267 mDate = qd;
268 mRecur = false; 268 mRecur = false;
269 mAlarm = false; 269 mAlarm = false;
270 mReply = false; 270 mReply = false;
271 mInfo = false; 271 mInfo = false;
272 mdayPos = 0;
272 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 273 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
273 //qDebug("NEWWWWWWWWWWWWW "); 274 //qDebug("NEWWWWWWWWWWWWW ");
274} 275}
275void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 276void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
276{ 277{
277 setText( s ); 278 setText( s );
278 mMultiday = 0; 279 mMultiday = 0;
279 mIncidence = incidence; 280 mIncidence = incidence;
280 mDate = qd; 281 mDate = qd;
281 mRecur = false; 282 mRecur = false;
282 mAlarm = false; 283 mAlarm = false;
283 mReply = false; 284 mReply = false;
284 mInfo = false; 285 mInfo = false;
286 mdayPos = 0;
285 //qDebug("recucleeeeeeeeeeeeeeeee "); 287 //qDebug("recucleeeeeeeeeeeeeeeee ");
286} 288}
287 289
288void MonthViewItem::paint(QPainter *p) 290void MonthViewItem::paint(QPainter *p)
289{ 291{
290 if ( mblockRepaint ) { 292 if ( mblockRepaint ) {
291 //qDebug("block "); 293 //qDebug("block ");
292 return; 294 return;
293 } 295 }
294 //qDebug("NON block "); 296 //qDebug("NON block ");
295#if QT_VERSION >= 0x030000 297#if QT_VERSION >= 0x030000
296 bool sel = isSelected(); 298 bool sel = isSelected();
297#else 299#else
298 bool sel = selected(); 300 bool sel = selected();
299#endif 301#endif
300 302
301 303
302 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 304 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
303 { 305 {
304 p->setBackgroundColor( palette().color( QPalette::Normal, \ 306 p->setBackgroundColor( palette().color( QPalette::Normal, \
305 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 307 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
306 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 308 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
307 } 309 }
308 int x = 1; 310 int x = 1;
309 //int y = 3;//(height() - mRecurPixmap.height()) /2; 311 //int y = 3;//(height() - mRecurPixmap.height()) /2;
310 int size = PIXMAP_SIZE; 312 int size = PIXMAP_SIZE;
311 if ( QApplication::desktop()->width() < 300 ) 313 if ( QApplication::desktop()->width() < 300 )
312 size = 3; 314 size = 3;
313 int heihei = height( listBox () ); 315 int heihei = height( listBox () );
314 int y = (heihei - size -1 ) /2; 316 int y = (heihei - size -1 ) /2;
315 317
316 if ( KOPrefs::instance()->mMonthShowIcons ) { 318 if ( KOPrefs::instance()->mMonthShowIcons ) {
317 if ( mInfo ) { 319 if ( mInfo ) {
318 p->fillRect ( x, y,size,size, Qt::darkGreen ); 320 p->fillRect ( x, y,size,size, Qt::darkGreen );
319 x += size + 1; 321 x += size + 1;
320 } 322 }
321 if ( mRecur ) { 323 if ( mRecur ) {
322 p->fillRect ( x, y,size,size, Qt::blue ); 324 p->fillRect ( x, y,size,size, Qt::blue );
323 x += size + 1; 325 x += size + 1;
324 } 326 }
325 if ( mAlarm ) { 327 if ( mAlarm ) {
326 p->fillRect ( x, y,size,size, Qt::red ); 328 p->fillRect ( x, y,size,size, Qt::red );
327 x += size + 1; 329 x += size + 1;
328 } 330 }
329 if ( mReply ) { 331 if ( mReply ) {
330 p->fillRect ( x, y,size,size, Qt::yellow ); 332 p->fillRect ( x, y,size,size, Qt::yellow );
331 x += size + 1; 333 x += size + 1;
332 } 334 }
333 } 335 }
334 if ( mMultiday ) { 336 if ( mMultiday ) {
335 int yyy = y+(size/2); 337 int yyy = y+(size/2);
336 int sizeM = size+2; 338 int sizeM = size+2;
337 p->setBrush( QBrush::SolidPattern ); 339 p->setBrush( QBrush::SolidPattern );
338 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 340 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
339 if ( mMultiday == 2 || mMultiday == 3 ) { 341 if ( mMultiday == 2 || mMultiday == 3 ) {
340 QPointArray pa ( 3 ); 342 QPointArray pa ( 3 );
341 pa.setPoint (0, x, yyy ); 343 pa.setPoint (0, x, yyy );
342 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 344 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
343 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 345 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
344 p->drawPolygon( pa ); 346 p->drawPolygon( pa );
345 } 347 }
346 if ( mMultiday == 2 || mMultiday == 1 ) { 348 if ( mMultiday == 2 || mMultiday == 1 ) {
347 QPointArray pa ( 3 ); 349 QPointArray pa ( 3 );
348 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 350 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
349 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 351 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
350 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 352 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
351 p->drawPolygon( pa ); 353 p->drawPolygon( pa );
352 } 354 }
353 if ( mMultiday == 1 ) { 355 if ( mMultiday == 1 ) {
354 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 356 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
355 357
356 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 358 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
357 } 359 }
358 if ( mMultiday == 3 ) { 360 if ( mMultiday == 3 ) {
359 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 361 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
360 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 362 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
361 363
362 } 364 }
363 x += sizeM/2 + 1; 365 x += sizeM/2 + 1;
364 x += sizeM + 1; 366 x += sizeM + 1;
365 } 367 }
366 368
367 if ( mIncidence->type() == "Todo" ){ 369 if ( mIncidence->type() == "Todo" ){
368 Todo* td = ( Todo* ) mIncidence; 370 Todo* td = ( Todo* ) mIncidence;
369 if ( td->isCompleted() ) { 371 if ( td->isCompleted() ) {
370 int half = size/2; 372 int half = size/2;
371 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 373 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
372 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 374 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
373 x += half+half + 4; 375 x += half+half + 4;
374 376
375 } else { 377 } else {
376 int val = td->percentComplete()/20; 378 int val = td->percentComplete()/20;
377 p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); 379 p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
378 p->drawRect ( x, y-2,7,size+4); 380 p->drawRect ( x, y-2,7,size+4);
379 x += size + 3; 381 x += size + 3;
380 } 382 }
381 } 383 }
382 QFontMetrics fm = p->fontMetrics(); 384 QFontMetrics fm = p->fontMetrics();
383 int yPos; 385 int yPos;
384 int pmheight = size; 386 int pmheight = size;
385 if( pmheight < fm.height() ) 387 if( pmheight < fm.height() )
386 yPos = fm.ascent() + fm.leading()/2; 388 yPos = fm.ascent() + fm.leading()/2;
387 else 389 else
388 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 390 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
389 p->setPen( palette().color( QPalette::Normal, sel ? \ 391 p->setPen( palette().color( QPalette::Normal, sel ? \
390 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 392 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
391 p->drawText( x, yPos, text() ); 393 p->drawText( x, yPos, text() );
392 if ( mIncidence->cancelled() ) { 394 if ( mIncidence->cancelled() ) {
393 int wid = fm.width( text() ); 395 int wid = fm.width( text() );
394 p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); 396 p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 );
395 } 397 }
396 398
397} 399}
398 400
399int MonthViewItem::height(const QListBox *lb) const 401int MonthViewItem::height(const QListBox *lb) const
400{ 402{
401 int ret = 10; 403 int ret = 10;
402 if ( lb ) 404 if ( lb )
403 ret = lb->fontMetrics().lineSpacing()+1; 405 ret = lb->fontMetrics().lineSpacing()+1;
404 return ret; 406 return ret;
405} 407}
406 408
407int MonthViewItem::width(const QListBox *lb) const 409int MonthViewItem::width(const QListBox *lb) const
408{ 410{
409 411
410 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 412 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
411 int size = PIXMAP_SIZE; 413 int size = PIXMAP_SIZE;
412 if ( QApplication::desktop()->width() < 300 ) 414 if ( QApplication::desktop()->width() < 300 )
413 size = 3; 415 size = 3;
414 int x = 1; 416 int x = 1;
415 if ( KOPrefs::instance()->mMonthShowIcons ) { 417 if ( KOPrefs::instance()->mMonthShowIcons ) {
416 if ( mInfo ) { 418 if ( mInfo ) {
417 x += size + 1; 419 x += size + 1;
418 } 420 }
419 if( mRecur ) { 421 if( mRecur ) {
420 x += size+1; 422 x += size+1;
421 } 423 }
422 if( mAlarm ) { 424 if( mAlarm ) {
423 x += size+1; 425 x += size+1;
424 } 426 }
425 if( mReply ) { 427 if( mReply ) {
426 x += size+1; 428 x += size+1;
427 } 429 }
428 } 430 }
429 if( mMultiday ) { 431 if( mMultiday ) {
430 x += size+1+2+size/2; 432 x += size+1+2+size/2;
431 } 433 }
432 return( x + lb->fontMetrics().width( text() ) + 1 ); 434 return( x + lb->fontMetrics().width( text() ) + 1 );
433 } 435 }
434 if ( ! lb ) 436 if ( ! lb )
435 return 10; 437 return 10;
436 //qDebug("ret wid %d ", lb->width()); 438 //qDebug("ret wid %d ", lb->width());
437 return lb->width(); 439 return lb->width();
438} 440}
439 441
440 442
441MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 443MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
442 : KNoScrollListBox( par ), 444 : KNoScrollListBox( par ),
443 mMonthView( parent ) 445 mMonthView( parent )
444{ 446{
445 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 447 //QVBoxLayout *topLayout = new QVBoxLayout( this );
446 currentPalette = 0; 448 currentPalette = 0;
447 // mLabel = new QLabel( this );QPushButton 449 // mLabel = new QLabel( this );QPushButton
448 mLabel = new QPushButton( this ); 450 mLabel = new QPushButton( this );
449 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 451 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
450 //mLabel->setLineWidth( 1 ); 452 //mLabel->setLineWidth( 1 );
451 //mLabel->setAlignment( AlignCenter ); 453 //mLabel->setAlignment( AlignCenter );
452 mLabel->setFlat( true ); 454 mLabel->setFlat( true );
453 mLabel->setFocusPolicy(NoFocus); 455 mLabel->setFocusPolicy(NoFocus);
454 //mItemList = new KNoScrollListBox( this ); 456 //mItemList = new KNoScrollListBox( this );
455 setMinimumSize( 10, 10 ); 457 setMinimumSize( 10, 10 );
456 setFrameStyle( QFrame::Panel | QFrame::Plain ); 458 setFrameStyle( QFrame::Panel | QFrame::Plain );
457 setLineWidth( 1 ); 459 setLineWidth( 1 );
458 //topLayout->addWidget( mItemList ); 460 //topLayout->addWidget( mItemList );
459 mLabel->raise(); 461 mLabel->raise();
460 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 462 // QColor( 0,0,255 ) QColor( 160,1600,255 )
461 mStandardPalette = palette(); 463 mStandardPalette = palette();
462 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 464 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
463 465
464 enableScrollBars( false ); 466 enableScrollBars( false );
465 updateConfig(); 467 updateConfig();
466 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 468 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
467 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 469 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
468 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 470 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
469 SLOT( defaultAction( QListBoxItem * ) ) ); 471 SLOT( defaultAction( QListBoxItem * ) ) );
470 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 472 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
471 const QPoint &) ), 473 const QPoint &) ),
472 SLOT( contextMenu( QListBoxItem * ) ) ); 474 SLOT( contextMenu( QListBoxItem * ) ) );
473 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 475 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
474 SLOT( selection( QListBoxItem * ) ) ); 476 SLOT( selection( QListBoxItem * ) ) );
475 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 477 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
476 SLOT( cellClicked( QListBoxItem * ) ) ); 478 SLOT( cellClicked( QListBoxItem * ) ) );
477 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 479 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
478 SLOT( selection( QListBoxItem * ) ) ); 480 SLOT( selection( QListBoxItem * ) ) );
479} 481}
480#ifdef DESKTOP_VERSION 482#ifdef DESKTOP_VERSION
481QToolTipGroup *MonthViewCell::toolTipGroup() 483QToolTipGroup *MonthViewCell::toolTipGroup()
482{ 484{
483 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 485 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
484 return mToolTipGroup; 486 return mToolTipGroup;
485} 487}
486#endif 488#endif
487 489
488void MonthViewCell::setDate( const QDate &date ) 490void MonthViewCell::setDate( const QDate &date )
489{ 491{
490 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 492 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
491 mDate = date; 493 mDate = date;
492 494
493 495
494 496
495 //resizeEvent( 0 ); 497 //resizeEvent( 0 );
496} 498}
497 499
498QDate MonthViewCell::date() const 500QDate MonthViewCell::date() const
499{ 501{
500 return mDate; 502 return mDate;
501} 503}
502 504
503void MonthViewCell::setPrimary( bool primary ) 505void MonthViewCell::setPrimary( bool primary )
504{ 506{
505 mPrimary = primary; 507 mPrimary = primary;
506 //setMyPalette(); 508 //setMyPalette();
507} 509}
508void MonthViewCell::setMyPalette() 510void MonthViewCell::setMyPalette()
509{ 511{
510 512
511 if ( mHoliday) { 513 if ( mHoliday) {
512 if ( currentPalette == 1 ) return; 514 if ( currentPalette == 1 ) return;
513 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 515 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
514 setPalette( mHolidayPalette ); 516 setPalette( mHolidayPalette );
515 //mLabel->setPalette( mHolidayPalette ); 517 //mLabel->setPalette( mHolidayPalette );
516 currentPalette = 1; 518 currentPalette = 1;
517 519
518 } else { 520 } else {
519 if ( mPrimary ) { 521 if ( mPrimary ) {
520 if ( currentPalette == 2 ) return; 522 if ( currentPalette == 2 ) return;
521 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 523 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
522 //mLabel->setPalette( mPrimaryPalette ); 524 //mLabel->setPalette( mPrimaryPalette );
523 setPalette( mPrimaryPalette ); 525 setPalette( mPrimaryPalette );
524 currentPalette = 2; 526 currentPalette = 2;
525 527
526 } else { 528 } else {
527 if ( currentPalette == 3 ) return; 529 if ( currentPalette == 3 ) return;
528 setPalette( mNonPrimaryPalette ); 530 setPalette( mNonPrimaryPalette );
529 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 531 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
530 //mLabel->setPalette( mNonPrimaryPalette );; 532 //mLabel->setPalette( mNonPrimaryPalette );;
531 currentPalette = 3; 533 currentPalette = 3;
532 } 534 }
533 } 535 }
534 //QPalette pal = palette(); 536 //QPalette pal = palette();
535 537
536 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 538 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
537} 539}
538QPalette MonthViewCell::getPalette () 540QPalette MonthViewCell::getPalette ()
539{ 541{
540 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 542 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
541 return mStandardPalette; 543 return mStandardPalette;
542 if ( mHoliday) { 544 if ( mHoliday) {
543 return mHolidayPalette ; 545 return mHolidayPalette ;
544 } else { 546 } else {
545 if ( mPrimary ) { 547 if ( mPrimary ) {
546 return mPrimaryPalette ; 548 return mPrimaryPalette ;
547 } 549 }
548 } 550 }
549 return mNonPrimaryPalette; 551 return mNonPrimaryPalette;
550} 552}
551bool MonthViewCell::isPrimary() const 553bool MonthViewCell::isPrimary() const
552{ 554{
553 return mPrimary; 555 return mPrimary;
554} 556}
555 557
556void MonthViewCell::setHoliday( bool holiday ) 558void MonthViewCell::setHoliday( bool holiday )
557{ 559{
558 mHoliday = holiday; 560 mHoliday = holiday;
559 //setMyPalette(); 561 //setMyPalette();
560} 562}
561 563
562void MonthViewCell::setHoliday( const QString &holiday ) 564void MonthViewCell::setHoliday( const QString &holiday )
563{ 565{
564 mHolidayString = holiday; 566 mHolidayString = holiday;
565 567
566 if ( !holiday.isEmpty() ) { 568 if ( !holiday.isEmpty() ) {
567 setHoliday( true ); 569 setHoliday( true );
568 } 570 }
569} 571}
570 572
571void MonthViewCell::startUpdateCell() 573void MonthViewCell::startUpdateCell()
572{ 574{
573 575 mdayCount = 0;
574 setFocusPolicy(NoFocus); 576 setFocusPolicy(NoFocus);
575 if ( !mMonthView->isUpdatePossible() ) 577 if ( !mMonthView->isUpdatePossible() )
576 return; 578 return;
577 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 579 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
578 while ( mitem ) { 580 while ( mitem ) {
579 mitem->setBlockRepaint( true ); 581 mitem->setBlockRepaint( true );
580 mitem = (MonthViewItem *)mitem->next(); 582 mitem = (MonthViewItem *)mitem->next();
581 } 583 }
582 if ( mAvailItemList.count() > 20 ) { 584 if ( mAvailItemList.count() > 20 ) {
583 mAvailItemList.setAutoDelete( true ); 585 mAvailItemList.setAutoDelete( true );
584 mAvailItemList.clear(); 586 mAvailItemList.clear();
585 mAvailItemList.setAutoDelete( false ); 587 mAvailItemList.setAutoDelete( false );
586 } 588 }
587 /* 589 /*
588 if ( !isVisible() ){ 590 if ( !isVisible() ){
589 return; 591 return;
590 } 592 }
591 */ 593 */
592 // qDebug("MonthViewCell::updateCell() "); 594 // qDebug("MonthViewCell::updateCell() ");
593 setPrimary( mDate.month()%2 ); 595 setPrimary( mDate.month()%2 );
594 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 596 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
595 if ( mDate == QDate::currentDate() ) { 597 if ( mDate == QDate::currentDate() ) {
596 setLineWidth( 3 ); 598 setLineWidth( 3 );
597 } else { 599 } else {
598 setLineWidth( 1 ); 600 setLineWidth( 1 );
599 } 601 }
600 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 602 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
601 //clear(); 603 //clear();
602 while ( CurrentAvailItem ) { 604 while ( CurrentAvailItem ) {
603 MonthViewItem *item = CurrentAvailItem; 605 MonthViewItem *item = CurrentAvailItem;
604 CurrentAvailItem = (MonthViewItem *)item->next(); 606 CurrentAvailItem = (MonthViewItem *)item->next();
605 mAvailItemList.append( item ); 607 mAvailItemList.append( item );
606 takeItem ( item ); 608 takeItem ( item );
607 } 609 }
608 610
609#ifdef DESKTOP_VERSION 611#ifdef DESKTOP_VERSION
610 QToolTip::remove(this); 612 QToolTip::remove(this);
611#endif 613#endif
612 mToolTip.clear(); 614 mToolTip.clear();
613 //qApp->processEvents(); 615 //qApp->processEvents();
614#if 0 616#if 0
615 if ( !mHolidayString.isEmpty() ) { 617 if ( !mHolidayString.isEmpty() ) {
616 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 618 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
617 item->setPalette( mHolidayPalette ); 619 item->setPalette( mHolidayPalette );
618 insertItem( item ); 620 insertItem( item );
619 mToolTip.append ( mHolidayString ); 621 mToolTip.append ( mHolidayString );
620 } 622 }
621#endif 623#endif
622} 624}
623 625
624void MonthViewCell::insertEvent(Event *event) 626int MonthViewCell::insertEvent(Event *event)
625{ 627{
626 QString mToolTipText; 628 QString mToolTipText;
627 setFocusPolicy(WheelFocus); 629 setFocusPolicy(WheelFocus);
628 if ( !(event->doesRecur() == Recurrence::rNone) ) { 630 if ( !(event->doesRecur() == Recurrence::rNone) ) {
629 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 631 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
630 return; 632 return mdayCount;
631 else 633 else
632 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 634 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
633 return; 635 return mdayCount;
634 } 636 }
635 637
636 if ( event->isHoliday()) { 638 if ( event->isHoliday()) {
637 setHoliday( true ); 639 setHoliday( true );
638 if ( mDate.dayOfWeek() == 7 ) 640 if ( mDate.dayOfWeek() == 7 )
639 setLineWidth( 3 ); 641 setLineWidth( 3 );
640 } 642 }
641 QString text; 643 QString text;
642 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 644 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
643 if (event->isMultiDay()) { 645 if (event->isMultiDay()) {
644 QString prefix = "<->";multiday = 2; 646 QString prefix = "<->";multiday = 2;
645 QString time; 647 QString time;
646 if ( event->doesRecur() ) { 648 if ( event->doesRecur() ) {
647 if ( event->recursOn( mDate) ) { 649 if ( event->recursOn( mDate) ) {
648 prefix ="->" ;multiday = 1; 650 prefix ="->" ;multiday = 1;
649 } 651 }
650 else { 652 else {
651 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 653 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
652 if ( event->recursOn( mDate.addDays( -days)) ) { 654 if ( event->recursOn( mDate.addDays( -days)) ) {
653 prefix ="<-" ;multiday = 3; 655 prefix ="<-" ;multiday = 3;
654 } 656 }
655 } 657 }
656 658
657 } else { 659 } else {
658 if (mDate == event->dtStart().date()) { 660 if (mDate == event->dtStart().date()) {
659 prefix ="->" ;multiday = 1; 661 prefix ="->" ;multiday = 1;
660 } else if (mDate == event->dtEnd().date()) { 662 } else if (mDate == event->dtEnd().date()) {
661 prefix ="<-" ;multiday = 3; 663 prefix ="<-" ;multiday = 3;
662 } 664 }
663 } 665 }
664 if ( !event->doesFloat() ) { 666 if ( !event->doesFloat() ) {
665 if ( mDate == event->dtStart().date () ) 667 if ( mDate == event->dtStart().date () )
666 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 668 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
667 else if ( mDate == event->dtEnd().date () ) 669 else if ( mDate == event->dtEnd().date () )
668 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 670 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
669 671
670 } 672 }
671 text = time + event->summary(); 673 text = time + event->summary();
672 mToolTipText += prefix + text; 674 mToolTipText += prefix + text;
673 } else { 675 } else {
674 if (event->doesFloat()) { 676 if (event->doesFloat()) {
675 text = event->summary(); 677 text = event->summary();
676 mToolTipText += text; 678 mToolTipText += text;
677 } 679 }
678 else { 680 else {
679 text = KGlobal::locale()->formatTime(event->dtStart().time()); 681 text = KGlobal::locale()->formatTime(event->dtStart().time());
680 text += " " + event->summary(); 682 text += " " + event->summary();
681 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 683 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
682 } 684 }
683 } 685 }
684 MonthViewItem *item ; 686 MonthViewItem *item ;
685 687
686 if ( mAvailItemList.count() ) { 688 if ( mAvailItemList.count() ) {
687 item = mAvailItemList.first(); 689 item = mAvailItemList.first();
688 mAvailItemList.remove( item ); 690 mAvailItemList.remove( item );
689 item->recycle( event, mDate, text ); 691 item->recycle( event, mDate, text );
690 } else { 692 } else {
691 item = new MonthViewItem( event, mDate, text ); 693 item = new MonthViewItem( event, mDate, text );
692 } 694 }
693 695
694 QPalette pal; 696 QPalette pal;
695 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 697 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
696 QStringList categories = event->categories(); 698 QStringList categories = event->categories();
697 QString cat = categories.first(); 699 QString cat = categories.first();
698 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 700 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
699 pal = getPalette(); 701 pal = getPalette();
700 if (cat.isEmpty()) { 702 if (cat.isEmpty()) {
701 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 703 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
702 } else { 704 } else {
703 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 705 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
704 } 706 }
705 707
706 } else { 708 } else {
707 if (cat.isEmpty()) { 709 if (cat.isEmpty()) {
708 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 710 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
709 } else { 711 } else {
710 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 712 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
711 } 713 }
712 } 714 }
713 715
714 } else { 716 } else {
715 pal = mStandardPalette ; 717 pal = mStandardPalette ;
716 } 718 }
717 item->setPalette( pal ); 719 item->setPalette( pal );
718 item->setRecur( event->recurrence()->doesRecur() ); 720 item->setRecur( event->recurrence()->doesRecur() );
719 item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); 721 item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
720 item->setMoreInfo( event->description().length() > 0 ); 722 item->setMoreInfo( event->description().length() > 0 );
721#ifdef DESKTOP_VERSION 723#ifdef DESKTOP_VERSION
722 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 724 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
723 KOPrefs::instance()->email()); 725 KOPrefs::instance()->email());
724 if ( me != 0 ) { 726 if ( me != 0 ) {
725 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 727 if ( me->status() == Attendee::NeedsAction && me->RSVP())
726 item->setReply(true && multiday < 2); 728 item->setReply(true && multiday < 2);
727 else 729 else
728 item->setReply(false); 730 item->setReply(false);
729 } else 731 } else
730 item->setReply(false); 732 item->setReply(false);
731#endif 733#endif
732 item->setMultiDay( multiday ); 734 item->setMultiDay( multiday );
733 insertItem( item ); 735 if ( multiday ) {
736 insertItem( item ,mdayCount);
737 ++mdayCount;
738 } else {
739 uint i;
740 int pos = mdayCount;
741 for ( i = mdayCount; i < count();++i ) {
742 QListBoxItem* it = this->item ( i );
743 if ( text < it->text() ) {
744 pos = i;
745 break;
746 }
747 ++pos;
748 }
749 insertItem( item ,pos);
750 }
734 mToolTip.append( mToolTipText ); 751 mToolTip.append( mToolTipText );
752 return mdayCount;
735} 753}
736void MonthViewCell::insertTodo(Todo *todo) 754void MonthViewCell::insertTodo(Todo *todo)
737{ 755{
738 setFocusPolicy(WheelFocus); 756 setFocusPolicy(WheelFocus);
739 QString text; 757 QString text;
740 if (todo->hasDueDate()) { 758 if (todo->hasDueDate()) {
741 if (!todo->doesFloat()) { 759 if (!todo->doesFloat()) {
742 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 760 text += KGlobal::locale()->formatTime(todo->dtDue().time());
743 text += " "; 761 text += " ";
744 } 762 }
745 } 763 }
746 text += todo->summary(); 764 text += todo->summary();
747 MonthViewItem *item ; 765 MonthViewItem *item ;
748 if ( mAvailItemList.count() ) { 766 if ( mAvailItemList.count() ) {
749 item = mAvailItemList.first(); 767 item = mAvailItemList.first();
750 mAvailItemList.remove( item ); 768 mAvailItemList.remove( item );
751 item->recycle( todo, mDate, text ); 769 item->recycle( todo, mDate, text );
752 } else { 770 } else {
753 item = new MonthViewItem( todo, mDate, text ); 771 item = new MonthViewItem( todo, mDate, text );
754 } 772 }
755 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 773 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
756 //item->setPalette( mStandardPalette ); 774 //item->setPalette( mStandardPalette );
757 QPalette pal; 775 QPalette pal;
758 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 776 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
759 QStringList categories = todo->categories(); 777 QStringList categories = todo->categories();
760 QString cat = categories.first(); 778 QString cat = categories.first();
761 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 779 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
762 pal = getPalette(); 780 pal = getPalette();
763 if (cat.isEmpty()) { 781 if (cat.isEmpty()) {
764 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 782 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
765 } else { 783 } else {
766 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 784 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
767 } 785 }
768 786
769 } else { 787 } else {
770 if (cat.isEmpty()) { 788 if (cat.isEmpty()) {
771 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 789 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
772 } else { 790 } else {
773 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 791 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
774 } 792 }
775 } 793 }
776 794
777 } else { 795 } else {
778 pal = mStandardPalette ; 796 pal = mStandardPalette ;
779 } 797 }
780 item->setPalette( pal ); 798 item->setPalette( pal );
781 item->setRecur( todo->recurrence()->doesRecur() ); 799 item->setRecur( todo->recurrence()->doesRecur() );
782 item->setAlarm( todo->isAlarmEnabled() ); 800 item->setAlarm( todo->isAlarmEnabled() );
783 item->setMoreInfo( todo->description().length() > 0 ); 801 item->setMoreInfo( todo->description().length() > 0 );
784 insertItem( item ); 802 insertItem( item , count());
785 mToolTip.append( text ); 803 mToolTip.append( text );
786} 804}
787void MonthViewCell::repaintfinishUpdateCell() 805void MonthViewCell::repaintfinishUpdateCell()
788{ 806{
789 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 807 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
790 while ( mitem ) { 808 while ( mitem ) {
791 mitem->setBlockRepaint( false ); 809 mitem->setBlockRepaint( false );
792 updateItem ( mitem ); 810 updateItem ( mitem );
793 mitem = (MonthViewItem *)mitem->next(); 811 mitem = (MonthViewItem *)mitem->next();
794 } 812 }
795} 813}
796void MonthViewCell::finishUpdateCell() 814void MonthViewCell::finishUpdateCell()
797{ 815{
798 816
799 817
800 818
801#ifdef DESKTOP_VERSION 819#ifdef DESKTOP_VERSION
802 if (mToolTip.count() > 0 ) { 820 if (mToolTip.count() > 0 ) {
803 mToolTip.sort(); 821 mToolTip.sort();
804 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 822 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
805 } 823 }
806#endif 824#endif
807 sort(); 825 //sort();
808 //setMyPalette(); 826 //setMyPalette();
809 setMyPalette(); 827 setMyPalette();
810 828
811 resizeEvent( 0 ); 829 resizeEvent( 0 );
812 830
813} 831}
814void MonthViewCell::updateCell() 832void MonthViewCell::updateCell()
815{ 833{
816 //qDebug("MonthViewCell::updateCell() "); 834 //qDebug("MonthViewCell::updateCell() ");
817 if ( !mMonthView->isUpdatePossible() ) 835 if ( !mMonthView->isUpdatePossible() )
818 return; 836 return;
819 startUpdateCell(); 837 startUpdateCell();
820 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 838 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
821 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 839 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
822 Event *event; 840 Event *event;
823 for( event = events.first(); event; event = events.next() ) { // for event 841 for( event = events.first(); event; event = events.next() ) { // for event
824 insertEvent(event); 842 insertEvent(event);
825 } 843 }
826 // insert due todos 844 // insert due todos
827 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 845 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
828 Todo *todo; 846 Todo *todo;
829 for(todo = todos.first(); todo; todo = todos.next()) { 847 for(todo = todos.first(); todo; todo = todos.next()) {
830 insertTodo( todo ); 848 insertTodo( todo );
831 } 849 }
832 finishUpdateCell(); 850 finishUpdateCell();
833 // if ( isVisible()) 851 // if ( isVisible())
834 //qApp->processEvents(); 852 //qApp->processEvents();
835} 853}
836 854
837void MonthViewCell::updateConfig( bool bigFont ) // = false 855void MonthViewCell::updateConfig( bool bigFont ) // = false
838{ 856{
839 857
840 if ( bigFont ) { 858 if ( bigFont ) {
841 QFont fo = KOPrefs::instance()->mMonthViewFont; 859 QFont fo = KOPrefs::instance()->mMonthViewFont;
842 int ps = fo.pointSize() + 2; 860 int ps = fo.pointSize() + 2;
843 if ( ps < 18 ) 861 if ( ps < 18 )
844 ps += 2; 862 ps += 2;
845 fo.setPointSize( ps ); 863 fo.setPointSize( ps );
846 setFont( fo ); 864 setFont( fo );
847 } else 865 } else
848 setFont( KOPrefs::instance()->mMonthViewFont ); 866 setFont( KOPrefs::instance()->mMonthViewFont );
849 867
850 QFontMetrics fm( font() ); 868 QFontMetrics fm( font() );
851 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 869 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
852 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 870 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
853 mHolidayPalette = mStandardPalette; 871 mHolidayPalette = mStandardPalette;
854 mPrimaryPalette = mStandardPalette; 872 mPrimaryPalette = mStandardPalette;
855 mNonPrimaryPalette = mStandardPalette; 873 mNonPrimaryPalette = mStandardPalette;
856 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 874 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
857 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 875 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
858 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 876 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
859 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 877 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
860 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 878 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
861 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 879 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
862 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 880 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
863 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 881 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
864 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 882 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
865 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 883 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
866 } 884 }
867 //updateCell(); 885 //updateCell();
868} 886}
869 887
870void MonthViewCell::enableScrollBars( bool enabled ) 888void MonthViewCell::enableScrollBars( bool enabled )
871{ 889{
872 890
873 return; 891 return;
874 if ( enabled ) { 892 if ( enabled ) {
875 QListBoxItem *fi = firstItem (); 893 QListBoxItem *fi = firstItem ();
876 if (fi ) { 894 if (fi ) {
877 int ihei = fi->height( this ); 895 int ihei = fi->height( this );
878 int hei = numRows () * ihei; 896 int hei = numRows () * ihei;
879 if ( hei < height() - horizontalScrollBar()->height () ) { 897 if ( hei < height() - horizontalScrollBar()->height () ) {
880 setVScrollBarMode(QScrollView::AlwaysOff); 898 setVScrollBarMode(QScrollView::AlwaysOff);
881 } 899 }
882 else 900 else
883 setVScrollBarMode(QScrollView::Auto); 901 setVScrollBarMode(QScrollView::Auto);
884 if ( ihei *3 > height() ) { 902 if ( ihei *3 > height() ) {
885 setHScrollBarMode(QScrollView::AlwaysOff); 903 setHScrollBarMode(QScrollView::AlwaysOff);
886 } 904 }
887 else { 905 else {
888 setHScrollBarMode(QScrollView::Auto); 906 setHScrollBarMode(QScrollView::Auto);
889 } 907 }
890 } else { 908 } else {
891 setVScrollBarMode(QScrollView::Auto); 909 setVScrollBarMode(QScrollView::Auto);
892 setHScrollBarMode(QScrollView::Auto); 910 setHScrollBarMode(QScrollView::Auto);
893 } 911 }
894 } else { 912 } else {
895 setVScrollBarMode(QScrollView::AlwaysOff); 913 setVScrollBarMode(QScrollView::AlwaysOff);
896 setHScrollBarMode(QScrollView::AlwaysOff); 914 setHScrollBarMode(QScrollView::AlwaysOff);
897 } 915 }
898} 916}
899 917
900Incidence *MonthViewCell::selectedIncidence() 918Incidence *MonthViewCell::selectedIncidence()
901{ 919{
902 int index = currentItem(); 920 int index = currentItem();
903 if ( index < 0 ) return 0; 921 if ( index < 0 ) return 0;
904 922
905 MonthViewItem *mitem = 923 MonthViewItem *mitem =
906 static_cast<MonthViewItem *>( item( index ) ); 924 static_cast<MonthViewItem *>( item( index ) );
907 925
908 if ( !mitem ) return 0; 926 if ( !mitem ) return 0;
909 927
910 return mitem->incidence(); 928 return mitem->incidence();
911} 929}
912 930
913QDate MonthViewCell::selectedIncidenceDate() 931QDate MonthViewCell::selectedIncidenceDate()
914{ 932{
915 QDate qd; 933 QDate qd;
916 int index = currentItem(); 934 int index = currentItem();
917 if ( index < 0 ) return qd; 935 if ( index < 0 ) return qd;
918 936
919 MonthViewItem *mitem = 937 MonthViewItem *mitem =
920 static_cast<MonthViewItem *>( item( index ) ); 938 static_cast<MonthViewItem *>( item( index ) );
921 939
922 if ( !mitem ) return qd; 940 if ( !mitem ) return qd;
923 941
924 return mitem->incidenceDate(); 942 return mitem->incidenceDate();
925} 943}
926 944
927void MonthViewCell::deselect() 945void MonthViewCell::deselect()
928{ 946{
929 clearSelection(); 947 clearSelection();
930 enableScrollBars( false ); 948 enableScrollBars( false );
931 // updateCell(); 949 // updateCell();
932} 950}
933void MonthViewCell::select() 951void MonthViewCell::select()
934{ 952{
935 ;// updateCell(); 953 ;// updateCell();
936} 954}
937 955
938void MonthViewCell::resizeEvent ( QResizeEvent * e ) 956void MonthViewCell::resizeEvent ( QResizeEvent * e )
939{ 957{
940 if ( !mMonthView->isUpdatePossible() ) 958 if ( !mMonthView->isUpdatePossible() )
941 return; 959 return;
942 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 960 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
943 deselect(); 961 deselect();
944 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 962 mLabel->setMaximumHeight( height() - lineWidth()*2 );
945 963
946 QString text; 964 QString text;
947 mLabel->setText( text ); 965 mLabel->setText( text );
948 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 966 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
949 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 967 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
950 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 968 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
951 mLabel->resize( mLabelBigSize ); 969 mLabel->resize( mLabelBigSize );
952 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 970 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
953 } else { 971 } else {
954 mLabel->resize( mLabelSize ); 972 mLabel->resize( mLabelSize );
955 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 973 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
956 } 974 }
957 mLabel->setText( text ); 975 mLabel->setText( text );
958 976
959 int size = height() - mLabel->height() - lineWidth()-1; 977 int size = height() - mLabel->height() - lineWidth()-1;
960 //qDebug("LW %d ", lineWidth()); 978 //qDebug("LW %d ", lineWidth());
961 if ( size > 0 ) 979 if ( size > 0 )
962 verticalScrollBar()->setMaximumHeight( size ); 980 verticalScrollBar()->setMaximumHeight( size );
963 size = width() - mLabel->width() -lineWidth()-1; 981 size = width() - mLabel->width() -lineWidth()-1;
964 if ( size > 0 ) 982 if ( size > 0 )
965 horizontalScrollBar()->setMaximumWidth( size ); 983 horizontalScrollBar()->setMaximumWidth( size );
966 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 984 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
967 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 985 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
968 // mItemList->resize ( width(), height () ); 986 // mItemList->resize ( width(), height () );
969 if ( e ) 987 if ( e )
970 KNoScrollListBox::resizeEvent ( e ); 988 KNoScrollListBox::resizeEvent ( e );
971} 989}
972 990
973void MonthViewCell::defaultAction( QListBoxItem *item ) 991void MonthViewCell::defaultAction( QListBoxItem *item )
974{ 992{
975 if ( !item ) { 993 if ( !item ) {
976 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 994 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
977 emit newEventSignal( dt ); 995 emit newEventSignal( dt );
978 return; 996 return;
979 } 997 }
980 998
981 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 999 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
982 Incidence *incidence = eventItem->incidence(); 1000 Incidence *incidence = eventItem->incidence();
983 if ( incidence ) mMonthView->defaultAction( incidence ); 1001 if ( incidence ) mMonthView->defaultAction( incidence );
984} 1002}
985void MonthViewCell::showDay() 1003void MonthViewCell::showDay()
986{ 1004{
987 emit showDaySignal( date() ); 1005 emit showDaySignal( date() );
988} 1006}
989void MonthViewCell::newEvent() 1007void MonthViewCell::newEvent()
990{ 1008{
991 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1009 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
992 emit newEventSignal( dt ); 1010 emit newEventSignal( dt );
993} 1011}
994void MonthViewCell::cellClicked( QListBoxItem *item ) 1012void MonthViewCell::cellClicked( QListBoxItem *item )
995{ 1013{
996 if ( item == 0 ) { 1014 if ( item == 0 ) {
997 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1015 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
998 emit newEventSignal( dt ); 1016 emit newEventSignal( dt );
999 return; 1017 return;
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index e962756..e39eeb0 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,325 +1,329 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qintdict.h> 31#include <qintdict.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qvaluelist.h> 33#include <qvaluelist.h>
34#include <qptrvector.h> 34#include <qptrvector.h>
35 35
36#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
37#include <libkcal/event.h> 37#include <libkcal/event.h>
38 38
39#include "koeventview.h" 39#include "koeventview.h"
40#include "navigatorbar.h" 40#include "navigatorbar.h"
41 41
42#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
43class QToolTipGroup; 43class QToolTipGroup;
44#endif 44#endif
45 45
46class KNOWhatsThis; 46class KNOWhatsThis;
47class KOWeekButton : public QPushButton 47class KOWeekButton : public QPushButton
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 51 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
52 QPushButton( parent, name) 52 QPushButton( parent, name)
53 { 53 {
54 connect( this, SIGNAL( clicked() ), 54 connect( this, SIGNAL( clicked() ),
55 SLOT( bottonClicked() )); 55 SLOT( bottonClicked() ));
56 mNumber = -1; 56 mNumber = -1;
57 } 57 }
58 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 58 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
59 int getWeekNum() { return mNumber;} 59 int getWeekNum() { return mNumber;}
60 signals: 60 signals:
61 void selectWeekNum ( int ); 61 void selectWeekNum ( int );
62private: 62private:
63 void focusInEvent ( QFocusEvent * ){;} 63 void focusInEvent ( QFocusEvent * ){;}
64 int mNumber; 64 int mNumber;
65 void keyPressEvent ( QKeyEvent * e ) 65 void keyPressEvent ( QKeyEvent * e )
66 { 66 {
67 e->ignore(); 67 e->ignore();
68 } 68 }
69 69
70private slots : 70private slots :
71 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 71 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
72}; 72};
73 73
74class KNoScrollListBox: public QListBox 74class KNoScrollListBox: public QListBox
75{ 75{
76 Q_OBJECT 76 Q_OBJECT
77 public: 77 public:
78 KNoScrollListBox(QWidget *parent=0, const char *name=0); 78 KNoScrollListBox(QWidget *parent=0, const char *name=0);
79 ~KNoScrollListBox(); 79 ~KNoScrollListBox();
80 QString getWhatsThisText(QPoint p) ; 80 QString getWhatsThisText(QPoint p) ;
81 81
82 signals: 82 signals:
83 void shiftDown(); 83 void shiftDown();
84 void shiftUp(); 84 void shiftUp();
85 void rightClick(); 85 void rightClick();
86 86
87 protected slots: 87 protected slots:
88 void oneDown(); 88 void oneDown();
89 void keyPressEvent(QKeyEvent *); 89 void keyPressEvent(QKeyEvent *);
90 void keyReleaseEvent(QKeyEvent *); 90 void keyReleaseEvent(QKeyEvent *);
91 void mousePressEvent(QMouseEvent *); 91 void mousePressEvent(QMouseEvent *);
92 void focusInEvent ( QFocusEvent * ); 92 void focusInEvent ( QFocusEvent * );
93 void focusOutEvent ( QFocusEvent * ); 93 void focusOutEvent ( QFocusEvent * );
94 94
95 private: 95 private:
96 bool resetOnFocusIn; 96 bool resetOnFocusIn;
97 KNOWhatsThis * mWT; 97 KNOWhatsThis * mWT;
98}; 98};
99 99
100 100
101class MonthViewItem: public QListBoxItem 101class MonthViewItem: public QListBoxItem
102{ 102{
103 public: 103 public:
104 MonthViewItem( Incidence *, QDate qd, const QString & title ); 104 MonthViewItem( Incidence *, QDate qd, const QString & title );
105 void recycle( Incidence *incidence, QDate qd, const QString & s); 105 void recycle( Incidence *incidence, QDate qd, const QString & s);
106 void setRecur(bool on) { mRecur = on; } 106 void setRecur(bool on) { mRecur = on; }
107 void setAlarm(bool on) { mAlarm = on; } 107 void setAlarm(bool on) { mAlarm = on; }
108 void setReply(bool on) { mReply = on; } 108 void setReply(bool on) { mReply = on; }
109 void setMoreInfo(bool on) { mInfo = on; } 109 void setMoreInfo(bool on) { mInfo = on; }
110 void setMultiDay(int type) { mMultiday = type; } 110 void setMultiDay(int type) { mMultiday = type; }
111 void setMultiDayPos(int type) { mdayPos = type; }
112 int gettMultiDayPos() { return mdayPos; }
111 void setBlockRepaint(bool on) { mblockRepaint = on; } 113 void setBlockRepaint(bool on) { mblockRepaint = on; }
112 114
113 115
114 void setPalette(const QPalette &p) { mPalette = p; } 116 void setPalette(const QPalette &p) { mPalette = p; }
115 QPalette palette() const { return mPalette; } 117 QPalette palette() const { return mPalette; }
116 118
117 Incidence *incidence() const { return mIncidence; } 119 Incidence *incidence() const { return mIncidence; }
118 QDate incidenceDate() { return mDate; } 120 QDate incidenceDate() { return mDate; }
119 121
120 protected: 122 protected:
121 virtual void paint(QPainter *); 123 virtual void paint(QPainter *);
122 virtual int height(const QListBox *) const; 124 virtual int height(const QListBox *) const;
123 virtual int width(const QListBox *) const; 125 virtual int width(const QListBox *) const;
124 126
125 private: 127 private:
128 int mdayPos;
126 bool isWeekItem; 129 bool isWeekItem;
127 bool mblockRepaint; 130 bool mblockRepaint;
128 int mMultiday; 131 int mMultiday;
129 bool mRecur; 132 bool mRecur;
130 bool mAlarm; 133 bool mAlarm;
131 bool mReply; 134 bool mReply;
132 bool mInfo; 135 bool mInfo;
133 136
134 QPalette mPalette; 137 QPalette mPalette;
135 QDate mDate; 138 QDate mDate;
136 139
137 Incidence *mIncidence; 140 Incidence *mIncidence;
138}; 141};
139 142
140 143
141class KOMonthView; 144class KOMonthView;
142 145
143class MonthViewCell : public KNoScrollListBox 146class MonthViewCell : public KNoScrollListBox
144{ 147{
145 Q_OBJECT 148 Q_OBJECT
146 public: 149 public:
147 MonthViewCell(KOMonthView *,QWidget* ); 150 MonthViewCell(KOMonthView *,QWidget* );
148 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} 151 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
149 152
150 void setDate( const QDate & ); 153 void setDate( const QDate & );
151 QDate date() const; 154 QDate date() const;
152 155
153 void setPrimary( bool ); 156 void setPrimary( bool );
154 bool isPrimary() const; 157 bool isPrimary() const;
155 158
156 void setHoliday( bool ); 159 void setHoliday( bool );
157 void setHoliday( const QString & ); 160 void setHoliday( const QString & );
158 161
159 void updateCell(); 162 void updateCell();
160 void startUpdateCell(); 163 void startUpdateCell();
161 void finishUpdateCell(); 164 void finishUpdateCell();
162 void repaintfinishUpdateCell(); 165 void repaintfinishUpdateCell();
163 void insertEvent(Event *); 166 int insertEvent(Event *);
164 void insertTodo(Todo *); 167 void insertTodo(Todo *);
165 168
166 void updateConfig( bool bigFont = false ); 169 void updateConfig( bool bigFont = false );
167 170
168 void enableScrollBars( bool ); 171 void enableScrollBars( bool );
169 172
170 Incidence *selectedIncidence(); 173 Incidence *selectedIncidence();
171 QDate selectedIncidenceDate(); 174 QDate selectedIncidenceDate();
172 QPushButton * dateLabel() { return mLabel; } 175 QPushButton * dateLabel() { return mLabel; }
173 176
174 void deselect(); 177 void deselect();
175 void select(); 178 void select();
176#ifdef DESKTOP_VERSION 179#ifdef DESKTOP_VERSION
177 static QToolTipGroup *toolTipGroup(); 180 static QToolTipGroup *toolTipGroup();
178#endif 181#endif
179 signals: 182 signals:
180 void defaultAction( Incidence * ); 183 void defaultAction( Incidence * );
181 void newEventSignal( QDateTime ); 184 void newEventSignal( QDateTime );
182 void showDaySignal( QDate ); 185 void showDaySignal( QDate );
183 186
184 protected: 187 protected:
185 QStringList mToolTip; 188 QStringList mToolTip;
186 void resizeEvent( QResizeEvent * ); 189 void resizeEvent( QResizeEvent * );
187 190
188 191
189public slots: 192public slots:
190 void showDay(); 193 void showDay();
191 194
192 protected slots: 195 protected slots:
193 void defaultAction( QListBoxItem * ); 196 void defaultAction( QListBoxItem * );
194 void contextMenu( QListBoxItem * ); 197 void contextMenu( QListBoxItem * );
195 void selection( QListBoxItem * ); 198 void selection( QListBoxItem * );
196 void cellClicked( QListBoxItem * ); 199 void cellClicked( QListBoxItem * );
197 void newEvent(); 200 void newEvent();
198 201
199 private: 202 private:
203 int mdayCount;
200 QPtrList <MonthViewItem> mAvailItemList; 204 QPtrList <MonthViewItem> mAvailItemList;
201 KOMonthView *mMonthView; 205 KOMonthView *mMonthView;
202 int currentPalette; 206 int currentPalette;
203 207
204 QDate mDate; 208 QDate mDate;
205 bool mPrimary; 209 bool mPrimary;
206 bool mHoliday; 210 bool mHoliday;
207 QString mHolidayString; 211 QString mHolidayString;
208 212
209 //QLabel *mLabel; 213 //QLabel *mLabel;
210 QPushButton *mLabel; 214 QPushButton *mLabel;
211 //QListBox *mItemList; 215 //QListBox *mItemList;
212#ifdef DESKTOP_VERSION 216#ifdef DESKTOP_VERSION
213 static QToolTipGroup *mToolTipGroup; 217 static QToolTipGroup *mToolTipGroup;
214#endif 218#endif
215 QSize mLabelSize; 219 QSize mLabelSize;
216 QSize mLabelBigSize; 220 QSize mLabelBigSize;
217 QPalette mHolidayPalette; 221 QPalette mHolidayPalette;
218 QPalette mStandardPalette; 222 QPalette mStandardPalette;
219 QPalette mPrimaryPalette; 223 QPalette mPrimaryPalette;
220 QPalette mNonPrimaryPalette; 224 QPalette mNonPrimaryPalette;
221 void setMyPalette(); 225 void setMyPalette();
222 QPalette getPalette (); 226 QPalette getPalette ();
223 227
224}; 228};
225 229
226 230
227class KOMonthView: public KOEventView 231class KOMonthView: public KOEventView
228{ 232{
229 Q_OBJECT 233 Q_OBJECT
230 public: 234 public:
231 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 235 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
232 ~KOMonthView(); 236 ~KOMonthView();
233 237
234 /** Returns maximum number of days supported by the komonthview */ 238 /** Returns maximum number of days supported by the komonthview */
235 virtual int maxDatesHint(); 239 virtual int maxDatesHint();
236 240
237 /** Returns number of currently shown dates. */ 241 /** Returns number of currently shown dates. */
238 virtual int currentDateCount(); 242 virtual int currentDateCount();
239 243
240 /** returns the currently selected events */ 244 /** returns the currently selected events */
241 virtual QPtrList<Incidence> selectedIncidences(); 245 virtual QPtrList<Incidence> selectedIncidences();
242 246
243 /** returns dates of the currently selected events */ 247 /** returns dates of the currently selected events */
244 virtual DateList selectedDates(); 248 virtual DateList selectedDates();
245 249
246 virtual void printPreview(CalPrinter *calPrinter, 250 virtual void printPreview(CalPrinter *calPrinter,
247 const QDate &, const QDate &); 251 const QDate &, const QDate &);
248 bool isMonthView() { return !mShowWeekView; } 252 bool isMonthView() { return !mShowWeekView; }
249 bool isUpdatePossible() { return updatePossible; } 253 bool isUpdatePossible() { return updatePossible; }
250 254
251 MonthViewCell * selectedCell(); 255 MonthViewCell * selectedCell();
252 bool skipResize; 256 bool skipResize;
253 NavigatorBar* navigatorBar() { return mNavigatorBar ;} 257 NavigatorBar* navigatorBar() { return mNavigatorBar ;}
254 public slots: 258 public slots:
255 virtual void updateView(); 259 virtual void updateView();
256 virtual void updateConfig(); 260 virtual void updateConfig();
257 virtual void showDates(const QDate &start, const QDate &end); 261 virtual void showDates(const QDate &start, const QDate &end);
258 virtual void showEvents(QPtrList<Event> eventList); 262 virtual void showEvents(QPtrList<Event> eventList);
259 263
260 void changeEventDisplay(Event *, int); 264 void changeEventDisplay(Event *, int);
261 265
262 void clearSelection(); 266 void clearSelection();
263 267
264 void showContextMenu( Incidence * ); 268 void showContextMenu( Incidence * );
265 269
266 void setSelectedCell( MonthViewCell * ); 270 void setSelectedCell( MonthViewCell * );
267 void switchView(); 271 void switchView();
268 void setKeyBoardFocus(); 272 void setKeyBoardFocus();
269 void setKeyBFocus(); 273 void setKeyBFocus();
270 274
271 protected slots: 275 protected slots:
272 void slotComputeLayout(); 276 void slotComputeLayout();
273 void selectInternalWeekNum ( int ); 277 void selectInternalWeekNum ( int );
274 void processSelectionChange(); 278 void processSelectionChange();
275 signals: 279 signals:
276 void nextMonth(); 280 void nextMonth();
277 void prevMonth(); 281 void prevMonth();
278 void selectWeekNum ( int ); 282 void selectWeekNum ( int );
279 void selectMonth (); 283 void selectMonth ();
280 void showDaySignal( QDate ); 284 void showDaySignal( QDate );
281 protected: 285 protected:
282 void resizeEvent(QResizeEvent *); 286 void resizeEvent(QResizeEvent *);
283 void viewChanged(); 287 void viewChanged();
284 void updateDayLabels(); 288 void updateDayLabels();
285 289
286 private: 290 private:
287 QTimer* mComputeLayoutTimer; 291 QTimer* mComputeLayoutTimer;
288 NavigatorBar* mNavigatorBar; 292 NavigatorBar* mNavigatorBar;
289 int currentWeek(); 293 int currentWeek();
290 bool clPending; 294 bool clPending;
291 QWidgetStack * mWidStack; 295 QWidgetStack * mWidStack;
292 QWidget* mMonthView; 296 QWidget* mMonthView;
293 QWidget* mWeekView; 297 QWidget* mWeekView;
294 bool mShowWeekView; 298 bool mShowWeekView;
295 bool updatePossible; 299 bool updatePossible;
296 int mDaysPerWeek; 300 int mDaysPerWeek;
297 int mNumWeeks; 301 int mNumWeeks;
298 int mNumCells; 302 int mNumCells;
299 //bool mWeekStartsMonday; 303 //bool mWeekStartsMonday;
300 bool mShowSatSunComp; 304 bool mShowSatSunComp;
301 void computeLayout(); 305 void computeLayout();
302 void computeLayoutWeek(); 306 void computeLayoutWeek();
303 307
304 QPtrVector<MonthViewCell> mCells; 308 QPtrVector<MonthViewCell> mCells;
305 QPtrVector<QLabel> mDayLabels; 309 QPtrVector<QLabel> mDayLabels;
306 QPtrVector<KOWeekButton> mWeekLabels; 310 QPtrVector<KOWeekButton> mWeekLabels;
307 QPtrVector<MonthViewCell> mCellsW; 311 QPtrVector<MonthViewCell> mCellsW;
308 QPtrVector<QLabel> mDayLabelsW; 312 QPtrVector<QLabel> mDayLabelsW;
309 QPtrVector<KOWeekButton> mWeekLabelsW; 313 QPtrVector<KOWeekButton> mWeekLabelsW;
310 314
311 bool mShortDayLabelsM; 315 bool mShortDayLabelsM;
312 bool mShortDayLabelsW; 316 bool mShortDayLabelsW;
313 int mWidthLongDayLabel; 317 int mWidthLongDayLabel;
314 318
315 QDate mStartDate; 319 QDate mStartDate;
316 320
317 MonthViewCell *mSelectedCell; 321 MonthViewCell *mSelectedCell;
318 bool mFlagKeyPressed; 322 bool mFlagKeyPressed;
319 KOEventPopupMenu *mContextMenu; 323 KOEventPopupMenu *mContextMenu;
320 void keyPressEvent ( QKeyEvent * ) ; 324 void keyPressEvent ( QKeyEvent * ) ;
321 void keyReleaseEvent ( QKeyEvent * ) ; 325 void keyReleaseEvent ( QKeyEvent * ) ;
322 326
323}; 327};
324 328
325#endif 329#endif