summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-25 18:26:36 (UTC)
committer zautrix <zautrix>2005-03-25 18:26:36 (UTC)
commit89a72c007045dcfa5dbf57012b4cf0c2aebd1495 (patch) (unidiff)
tree6accbe5706b724e307d1590152fa2d2c78cdef70 /korganizer
parent3326831dbf6f962e97a978781361db5198f6a035 (diff)
downloadkdepimpi-89a72c007045dcfa5dbf57012b4cf0c2aebd1495.zip
kdepimpi-89a72c007045dcfa5dbf57012b4cf0c2aebd1495.tar.gz
kdepimpi-89a72c007045dcfa5dbf57012b4cf0c2aebd1495.tar.bz2
layout fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp77
-rw-r--r--korganizer/koagendaitem.cpp2
-rw-r--r--korganizer/kolistview.cpp46
-rw-r--r--korganizer/kolistview.h2
-rw-r--r--korganizer/komonthview.cpp11
5 files changed, 48 insertions, 90 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 2820ca2..66ad4ec 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -82,193 +82,193 @@ MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
82 82
83 oldToday = -1; 83 oldToday = -1;
84} 84}
85 85
86MarcusBains::~MarcusBains() 86MarcusBains::~MarcusBains()
87{ 87{
88 delete minutes; 88 delete minutes;
89} 89}
90 90
91int MarcusBains::todayColumn() 91int MarcusBains::todayColumn()
92{ 92{
93 QDate currentDate = QDate::currentDate(); 93 QDate currentDate = QDate::currentDate();
94 94
95 DateList dateList = agenda->dateList(); 95 DateList dateList = agenda->dateList();
96 DateList::ConstIterator it; 96 DateList::ConstIterator it;
97 int col = 0; 97 int col = 0;
98 for(it = dateList.begin(); it != dateList.end(); ++it) { 98 for(it = dateList.begin(); it != dateList.end(); ++it) {
99 if((*it) == currentDate) 99 if((*it) == currentDate)
100 return KOGlobals::self()->reverseLayout() ? 100 return KOGlobals::self()->reverseLayout() ?
101 agenda->columns() - 1 - col : col; 101 agenda->columns() - 1 - col : col;
102 ++col; 102 ++col;
103 } 103 }
104 104
105 return -1; 105 return -1;
106} 106}
107void MarcusBains::updateLoc() 107void MarcusBains::updateLoc()
108{ 108{
109 updateLocation(); 109 updateLocation();
110} 110}
111void MarcusBains::updateLocation(bool recalculate) 111void MarcusBains::updateLocation(bool recalculate)
112{ 112{
113 113
114 QTime tim = QTime::currentTime(); 114 QTime tim = QTime::currentTime();
115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
116 if((tim.hour() == 0) && (oldTime.hour()==23)) 116 if((tim.hour() == 0) && (oldTime.hour()==23))
117 recalculate = true; 117 recalculate = true;
118 118
119 int mins = tim.hour()*60 + tim.minute(); 119 int mins = tim.hour()*60 + tim.minute();
120 int minutesPerCell = 24 * 60 / agenda->rows(); 120 int minutesPerCell = 24 * 60 / agenda->rows();
121 int y = mins*agenda->gridSpacingY()/minutesPerCell; 121 int y = mins*agenda->gridSpacingY()/minutesPerCell;
122 int today = recalculate ? todayColumn() : oldToday; 122 int today = recalculate ? todayColumn() : oldToday;
123 int x = agenda->gridSpacingX()*today; 123 int x = agenda->gridSpacingX()*today;
124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
125 125
126 oldTime = tim; 126 oldTime = tim;
127 oldToday = today; 127 oldToday = today;
128 128
129 if(disabled || (today<0)) { 129 if(disabled || (today<0)) {
130 hide(); mTimeBox->hide(); 130 hide(); mTimeBox->hide();
131 return; 131 return;
132 } else { 132 } else {
133 show(); mTimeBox->show(); 133 show(); mTimeBox->show();
134 } 134 }
135 135
136 if(recalculate) 136 if(recalculate)
137 setFixedSize(agenda->gridSpacingX(),1); 137 setFixedSize(agenda->gridSpacingX(),1);
138 agenda->moveChild(this, x, y); 138 agenda->moveChild(this, x, y);
139 raise(); 139 raise();
140 140
141 if(recalculate) 141 if(recalculate)
142 //mTimeBox->setFont(QFont("helvetica",10)); 142 //mTimeBox->setFont(QFont("helvetica",10));
143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
144 144
145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
146 mTimeBox->adjustSize(); 146 mTimeBox->adjustSize();
147 // the -2 below is there because there is a bug in this program 147 // the -2 below is there because there is a bug in this program
148 // somewhere, where the last column of this widget is a few pixels 148 // somewhere, where the last column of this widget is a few pixels
149 // narrower than the other columns. 149 // narrower than the other columns.
150 int offs = (today==agenda->columns()-1) ? -4 : 0; 150 int offs = (today==agenda->columns()-1) ? -4 : 0;
151 agenda->moveChild(mTimeBox, 151 agenda->moveChild(mTimeBox,
152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
153 y-mTimeBox->height()); 153 y-mTimeBox->height());
154 154
155 mTimeBox->raise(); 155 mTimeBox->raise();
156 //mTimeBox->setAutoMask(true); 156 //mTimeBox->setAutoMask(true);
157 minutes->start(5000,true); 157 minutes->start(5000,true);
158} 158}
159 159
160 160
161//////////////////////////////////////////////////////////////////////////// 161////////////////////////////////////////////////////////////////////////////
162 162
163 163
164/* 164/*
165 Create an agenda widget with rows rows and columns columns. 165 Create an agenda widget with rows rows and columns columns.
166*/ 166*/
167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
168 const char *name,WFlags f) : 168 const char *name,WFlags f) :
169 QScrollView(parent,name,f) 169 QScrollView(parent,name,f)
170{ 170{
171 171
172 172
173 mColumns = columns; 173 mColumns = columns;
174 mRows = rows; 174 mRows = rows;
175 mGridSpacingY = rowSize; 175 mGridSpacingY = rowSize;
176 mAllDayMode = false; 176 mAllDayMode = false;
177#ifndef DESKTOP_VERSION 177#ifndef DESKTOP_VERSION
178 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 178 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
179#endif 179#endif
180 mHolidayMask = 0; 180 mHolidayMask = 0;
181 init(); 181 init();
182} 182}
183 183
184/* 184/*
185 Create an agenda widget with columns columns and one row. This is used for 185 Create an agenda widget with columns columns and one row. This is used for
186 all-day events. 186 all-day events.
187*/ 187*/
188KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 188KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
189 QScrollView(parent,name,f) 189 QScrollView(parent,name,f)
190{ 190{
191 blockResize = false; 191 blockResize = false;
192 mColumns = columns; 192 mColumns = columns;
193 mRows = 1; 193 mRows = 1;
194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
195 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 195 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
196 mAllDayMode = true; 196 mAllDayMode = true;
197#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
198 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 198 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
199#endif 199#endif
200 mHolidayMask = 0; 200 mHolidayMask = 0;
201 init(); 201 init();
202} 202}
203 203
204 204
205KOAgenda::~KOAgenda() 205KOAgenda::~KOAgenda()
206{ 206{
207 if(mMarcusBains) delete mMarcusBains; 207 if(mMarcusBains) delete mMarcusBains;
208 208
209} 209}
210 210
211Incidence *KOAgenda::selectedIncidence() const 211Incidence *KOAgenda::selectedIncidence() const
212{ 212{
213 return (mSelectedItem ? mSelectedItem->incidence() : 0); 213 return (mSelectedItem ? mSelectedItem->incidence() : 0);
214} 214}
215 215
216 216
217QDate KOAgenda::selectedIncidenceDate() const 217QDate KOAgenda::selectedIncidenceDate() const
218{ 218{
219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
220} 220}
221 221
222 222
223void KOAgenda::init() 223void KOAgenda::init()
224{ 224{
225 mNewItemPopup = new QPopupMenu( this ); 225 mNewItemPopup = new QPopupMenu( this );
226 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 226 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
227 QString pathString = ""; 227 QString pathString = "";
228 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 228 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
229 if ( QApplication::desktop()->width() < 480 ) 229 if ( QApplication::desktop()->width() < 480 )
230 pathString += "icons16/"; 230 pathString += "icons16/";
231 } else 231 } else
232 pathString += "iconsmini/"; 232 pathString += "iconsmini/";
233 233
234 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 234 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
235 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 235 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
236 mNewItemPopup->insertSeparator ( ); 236 mNewItemPopup->insertSeparator ( );
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 237 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
238 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 238 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
239 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 239 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
243#ifndef _WIN32_ 243#ifndef _WIN32_
244 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 244 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
245 viewport()->setWFlags ( wflags); 245 viewport()->setWFlags ( wflags);
246#endif 246#endif
247 mGridSpacingX = 80; 247 mGridSpacingX = 80;
248 mResizeBorderWidth = 8; 248 mResizeBorderWidth = 8;
249 mScrollBorderWidth = 8; 249 mScrollBorderWidth = 8;
250 mScrollDelay = 30; 250 mScrollDelay = 30;
251 mScrollOffset = 10; 251 mScrollOffset = 10;
252 mPaintPixmap.resize( 20,20); 252 mPaintPixmap.resize( 20,20);
253 //enableClipper(true); 253 //enableClipper(true);
254 254
255 // Grab key strokes for keyboard navigation of agenda. Seems to have no 255 // Grab key strokes for keyboard navigation of agenda. Seems to have no
256 // effect. Has to be fixed. 256 // effect. Has to be fixed.
257 setFocusPolicy(WheelFocus); 257 setFocusPolicy(WheelFocus);
258 258
259 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 259 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
260 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 260 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
261 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 261 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
262 262
263 mStartCellX = 0; 263 mStartCellX = 0;
264 mStartCellY = 0; 264 mStartCellY = 0;
265 mCurrentCellX = 0; 265 mCurrentCellX = 0;
266 mCurrentCellY = 0; 266 mCurrentCellY = 0;
267 267
268 mSelectionCellX = 0; 268 mSelectionCellX = 0;
269 mSelectionYTop = 0; 269 mSelectionYTop = 0;
270 mSelectionHeight = 0; 270 mSelectionHeight = 0;
271 271
272 mOldLowerScrollValue = -1; 272 mOldLowerScrollValue = -1;
273 mOldUpperScrollValue = -1; 273 mOldUpperScrollValue = -1;
274 274
@@ -305,345 +305,332 @@ void KOAgenda::init()
305 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 305 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
306 SLOT(checkScrollBoundaries(int))); 306 SLOT(checkScrollBoundaries(int)));
307 307
308 // Create the Marcus Bains line. 308 // Create the Marcus Bains line.
309 if(mAllDayMode) 309 if(mAllDayMode)
310 mMarcusBains = 0; 310 mMarcusBains = 0;
311 else { 311 else {
312 mMarcusBains = new MarcusBains(this); 312 mMarcusBains = new MarcusBains(this);
313 addChild(mMarcusBains); 313 addChild(mMarcusBains);
314 } 314 }
315} 315}
316 316
317void KOAgenda::clear() 317void KOAgenda::clear()
318{ 318{
319 KOAgendaItem *item; 319 KOAgendaItem *item;
320 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 320 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
321 mUnusedItems.append( item ); 321 mUnusedItems.append( item );
322 //item->hide(); 322 //item->hide();
323 } 323 }
324 mItems.clear(); 324 mItems.clear();
325 mSelectedItem = 0; 325 mSelectedItem = 0;
326 clearSelection(); 326 clearSelection();
327} 327}
328 328
329void KOAgenda::clearSelection() 329void KOAgenda::clearSelection()
330{ 330{
331 mSelectionCellX = 0; 331 mSelectionCellX = 0;
332 mSelectionYTop = 0; 332 mSelectionYTop = 0;
333 mSelectionHeight = 0; 333 mSelectionHeight = 0;
334} 334}
335 335
336void KOAgenda::marcus_bains() 336void KOAgenda::marcus_bains()
337{ 337{
338 if(mMarcusBains) mMarcusBains->updateLocation(true); 338 if(mMarcusBains) mMarcusBains->updateLocation(true);
339} 339}
340 340
341 341
342void KOAgenda::changeColumns(int columns) 342void KOAgenda::changeColumns(int columns)
343{ 343{
344 if (columns == 0) { 344 if (columns == 0) {
345 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; 345 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl;
346 return; 346 return;
347 } 347 }
348 348
349 clear(); 349 clear();
350 350
351 mColumns = columns; 351 mColumns = columns;
352// setMinimumSize(mColumns * 10, mGridSpacingY + 1); 352// setMinimumSize(mColumns * 10, mGridSpacingY + 1);
353// init(); 353// init();
354// update(); 354// update();
355 //qDebug("KOAgenda::changeColumns "); 355 //qDebug("KOAgenda::changeColumns ");
356 computeSizes(); 356 computeSizes();
357 // QResizeEvent event( size(), size() ); 357 // QResizeEvent event( size(), size() );
358 358
359 //QApplication::sendEvent( this, &event ); 359 //QApplication::sendEvent( this, &event );
360} 360}
361 361
362/* 362/*
363 This is the eventFilter function, which gets all events from the KOAgendaItems 363 This is the eventFilter function, which gets all events from the KOAgendaItems
364 contained in the agenda. It has to handle moving and resizing for all items. 364 contained in the agenda. It has to handle moving and resizing for all items.
365*/ 365*/
366bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 366bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
367{ 367{
368// kdDebug() << "KOAgenda::eventFilter" << endl; 368// kdDebug() << "KOAgenda::eventFilter" << endl;
369 switch(event->type()) { 369 switch(event->type()) {
370 case QEvent::MouseButtonPress: 370 case QEvent::MouseButtonPress:
371 case QEvent::MouseButtonDblClick: 371 case QEvent::MouseButtonDblClick:
372 case QEvent::MouseButtonRelease: 372 case QEvent::MouseButtonRelease:
373 case QEvent::MouseMove: 373 case QEvent::MouseMove:
374 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 374 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
375 375
376 case (QEvent::Leave): 376 case (QEvent::Leave):
377 if (!mActionItem) 377 if (!mActionItem)
378 setCursor(arrowCursor); 378 setCursor(arrowCursor);
379 return true; 379 return true;
380 380
381 default: 381 default:
382 return QScrollView::eventFilter(object,event); 382 return QScrollView::eventFilter(object,event);
383 } 383 }
384} 384}
385 385
386 386
387bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 387bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
388{ 388{
389 //qDebug("KOAgenda::eventFilter_mous "); 389 //qDebug("KOAgenda::eventFilter_mous ");
390 QPoint viewportPos; 390 QPoint viewportPos;
391 if (object != viewport()) { 391 if (object != viewport()) {
392 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 392 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
393 } else { 393 } else {
394 viewportPos = me->pos(); 394 viewportPos = me->pos();
395 } 395 }
396 static int startX = 0; 396 static int startX = 0;
397 static int startY = 0; 397 static int startY = 0;
398 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 398 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
399 static bool blockMoving = true; 399 static bool blockMoving = true;
400 static bool leftMouseDown = false; 400 static bool leftMouseDown = false;
401 static bool rightMouseDown = false;
402 static QTime rightClickTime;
403 bool rightButtonPressed = false; 401 bool rightButtonPressed = false;
404 switch (me->type()) { 402 switch (me->type()) {
405 case QEvent::MouseButtonPress: 403 case QEvent::MouseButtonPress:
406 rightClickTime.restart();
407 if (me->button() == LeftButton) { 404 if (me->button() == LeftButton) {
408 leftMouseDown = true; 405 leftMouseDown = true;
409 } 406 }
410 else if (me->button() == RightButton) 407 else if (me->button() == RightButton) {
411 rightMouseDown = true; 408 leftMouseDown = false;
409 }
412 blockMoving = true; 410 blockMoving = true;
413 startX = viewportPos.x(); 411 startX = viewportPos.x();
414 startY = viewportPos.y(); 412 startY = viewportPos.y();
415 if (object != viewport()) { 413 if (object != viewport()) { // item clicked **************
416 if (me->button() == RightButton) { 414 if (me->button() == RightButton) {
415 leftMouseDown = false;
417 mClickedItem = (KOAgendaItem *)object; 416 mClickedItem = (KOAgendaItem *)object;
417 if (mActionItem ) {
418 endItemAction();
419 }
418 if (mClickedItem) { 420 if (mClickedItem) {
419 selectItem(mClickedItem); 421 selectItem(mClickedItem);
420 } 422 emit showIncidencePopupSignal(mClickedItem->incidence());
423 }
424 return true;
421 } else if (me->button() == LeftButton) { 425 } else if (me->button() == LeftButton) {
422 mActionItem = (KOAgendaItem *)object; 426 mActionItem = (KOAgendaItem *)object;
423 if (mActionItem) { 427 if (mActionItem) {
424 if ( mSelectionHeight > 0 ) { 428 if ( mSelectionHeight > 0 ) {
425 int selectionCellX = mSelectionCellX * mGridSpacingX; 429 int selectionCellX = mSelectionCellX * mGridSpacingX;
426 int selectionYTop = mSelectionYTop; 430 int selectionYTop = mSelectionYTop;
427 int gridSpacingX = mGridSpacingX; 431 int gridSpacingX = mGridSpacingX;
428 int selectionHeight = mSelectionHeight; 432 int selectionHeight = mSelectionHeight;
429 clearSelection(); 433 clearSelection();
430 repaintContents( selectionCellX, selectionYTop, 434 repaintContents( selectionCellX, selectionYTop,
431 gridSpacingX, selectionHeight,false ); 435 gridSpacingX, selectionHeight,false );
432 } 436 }
433 selectItem(mActionItem); 437 selectItem(mActionItem);
434 Incidence *incidence = mActionItem->incidence(); 438 Incidence *incidence = mActionItem->incidence();
435 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 439 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
436 mActionItem = 0; 440 mActionItem = 0;
437 } else { 441 } else {
438 startItemAction(viewportPos); 442 startItemAction(viewportPos);
439 } 443 }
440 } 444 }
441 } 445 }
442 } else { // ---------- viewport() 446 } else { // ---------- viewport()
443 selectItem(0); 447 selectItem(0);
444 mActionItem = 0; 448 mActionItem = 0;
445 if (me->button() == LeftButton ) { 449 if (me->button() == LeftButton ) {
446 setCursor(arrowCursor); 450 setCursor(arrowCursor);
447 startSelectAction(viewportPos); 451 startSelectAction(viewportPos);
452 } else if (me->button() == RightButton ) {
453 setCursor(arrowCursor);
454 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
455 endSelectAction( false ); // do not emit new event signal
456 leftMouseDown = false; // no more leftMouse computation
457 }
458 int x,y;
459 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
460 int gx,gy;
461 contentsToGrid(x,y,gx,gy);
462 mCurrentCellX = gx;
463 mCurrentCellY = gy;
464 mStartCellX = gx;
465 mStartCellY = gy;
466 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
448 } 467 }
449 } 468 }
450 break; 469 break;
451 470
452 case QEvent::MouseButtonRelease: 471 case QEvent::MouseButtonRelease:
453 if ( rightClickTime.elapsed() > 500 && blockMoving ) 472
454 rightButtonPressed = true;
455 if (object != viewport()) { 473 if (object != viewport()) {
456 if (me->button() == RightButton || rightButtonPressed ) { 474 if (me->button() == LeftButton && leftMouseDown) {
457 if ( blockMoving ) {
458 mClickedItem = (KOAgendaItem *)object;
459 if (mActionItem ) {
460 endItemAction();
461 }
462 leftMouseDown = false; // no more leftMouse computation
463 if (mClickedItem) {
464 selectItem(mClickedItem);
465 emit showIncidencePopupSignal(mClickedItem->incidence());
466 }
467 }
468 } else if (me->button() == LeftButton && leftMouseDown) {
469 if (mActionItem) { 475 if (mActionItem) {
470 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 476 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
471 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 477 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
472 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 478 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
473 mScrollUpTimer.stop(); 479 mScrollUpTimer.stop();
474 mScrollDownTimer.stop(); 480 mScrollDownTimer.stop();
475 mActionItem->resetMove(); 481 mActionItem->resetMove();
476 placeSubCells( mActionItem ); 482 placeSubCells( mActionItem );
477 // emit startDragSignal( mActionItem->incidence() ); 483 // emit startDragSignal( mActionItem->incidence() );
478 setCursor( arrowCursor ); 484 setCursor( arrowCursor );
479 mActionItem = 0; 485 mActionItem = 0;
480 mActionType = NOP; 486 mActionType = NOP;
481 mItemMoved = 0; 487 mItemMoved = 0;
482 leftMouseDown = false; 488 leftMouseDown = false;
483 return true; 489 return true;
484 } 490 }
485 endItemAction(); 491 endItemAction();
486 } 492 }
487 } 493 }
488 494
489 } else { // ---------- viewport() 495 } else { // ---------- viewport()
490 if (me->button() == RightButton || rightButtonPressed ) { //right click 496 if (me->button() == LeftButton && leftMouseDown ) { //left click
491 if ( blockMoving ) { // we did mot moved the mouse much - popup menu
492 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
493 endSelectAction( false ); // do not emit new event signal
494 leftMouseDown = false; // no more leftMouse computation
495 }
496 int x,y;
497 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
498 int gx,gy;
499 contentsToGrid(x,y,gx,gy);
500 mCurrentCellX = gx;
501 mCurrentCellY = gy;
502 mStartCellX = gx;
503 mStartCellY = gy;
504 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
505 }
506 }
507 else if (me->button() == LeftButton && leftMouseDown ) { //left click
508 endSelectAction( true ); // emit new event signal 497 endSelectAction( true ); // emit new event signal
509 } 498 }
510 } 499 }
511 if (me->button() == LeftButton) 500 if (me->button() == LeftButton)
512 leftMouseDown = false; 501 leftMouseDown = false;
513 else if (me->button() == RightButton) 502
514 rightMouseDown = false;
515 break; 503 break;
516 504
517 case QEvent::MouseMove: 505 case QEvent::MouseMove:
518 if ( !rightMouseDown && !leftMouseDown ) 506 if ( !leftMouseDown )
519 return true; 507 return true;
520 if ( blockMoving ) { 508 if ( blockMoving ) {
521 int dX, dY; 509 int dX, dY;
522 dX = startX - viewportPos.x(); 510 dX = startX - viewportPos.x();
523 if ( dX < 0 ) 511 if ( dX < 0 )
524 dX = -dX; 512 dX = -dX;
525 dY = viewportPos.y() - startY; 513 dY = viewportPos.y() - startY;
526 if ( dY < 0 ) 514 if ( dY < 0 )
527 dY = -dY; 515 dY = -dY;
528 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 516 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
529 if ( dX > blockmoveDist || dY > blockmoveDist ) { 517 if ( dX > blockmoveDist || dY > blockmoveDist ) {
530 blockMoving = false; 518 blockMoving = false;
531 } 519 }
532 } 520 }
533 if (object != viewport()) { 521 if (object != viewport()) {
534 KOAgendaItem *moveItem = (KOAgendaItem *)object; 522 KOAgendaItem *moveItem = (KOAgendaItem *)object;
535 if (!moveItem->incidence()->isReadOnly() ) { 523 if (!moveItem->incidence()->isReadOnly() ) {
536 if (!mActionItem) 524 if (!mActionItem)
537 setNoActionCursor(moveItem,viewportPos); 525 setNoActionCursor(moveItem,viewportPos);
538 else { 526 else {
539 if ( !blockMoving ) 527 if ( !blockMoving )
540 performItemAction(viewportPos); 528 performItemAction(viewportPos);
541 } 529 }
542 } 530 }
543 } else { // ---------- viewport() 531 } else { // ---------- viewport()
544 if ( mActionType == SELECT ) { 532 if ( mActionType == SELECT ) {
545 performSelectAction( viewportPos ); 533 performSelectAction( viewportPos );
546 } 534 }
547 } 535 }
548 break; 536 break;
549 537
550 case QEvent::MouseButtonDblClick: 538 case QEvent::MouseButtonDblClick:
551 blockMoving = false; 539 blockMoving = false;
552 leftMouseDown = false; 540 leftMouseDown = false;
553 rightMouseDown = false;
554 if (object == viewport()) { 541 if (object == viewport()) {
555 selectItem(0); 542 selectItem(0);
556 int x,y; 543 int x,y;
557 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 544 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
558 int gx,gy; 545 int gx,gy;
559 contentsToGrid(x,y,gx,gy); 546 contentsToGrid(x,y,gx,gy);
560 emit newEventSignal(gx,gy); 547 emit newEventSignal(gx,gy);
561 } else { 548 } else {
562 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 549 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
563 selectItem(doubleClickedItem); 550 selectItem(doubleClickedItem);
564 if ( KOPrefs::instance()->mEditOnDoubleClick ) 551 if ( KOPrefs::instance()->mEditOnDoubleClick )
565 emit editIncidenceSignal(doubleClickedItem->incidence()); 552 emit editIncidenceSignal(doubleClickedItem->incidence());
566 else 553 else
567 emit showIncidenceSignal(doubleClickedItem->incidence()); 554 emit showIncidenceSignal(doubleClickedItem->incidence());
568 } 555 }
569 break; 556 break;
570 557
571 default: 558 default:
572 break; 559 break;
573 } 560 }
574 return true; 561 return true;
575} 562}
576 563
577void KOAgenda::newItem( int item ) 564void KOAgenda::newItem( int item )
578{ 565{
579 if ( item == 1 ) { //new event 566 if ( item == 1 ) { //new event
580 newEventSignal(mStartCellX ,mStartCellY ); 567 newEventSignal(mStartCellX ,mStartCellY );
581 } else 568 } else
582 if ( item == 2 ) { //new event 569 if ( item == 2 ) { //new event
583 newTodoSignal(mStartCellX ,mStartCellY ); 570 newTodoSignal(mStartCellX ,mStartCellY );
584 } else 571 } else
585 { 572 {
586 QDate day = mSelectedDates[mStartCellX]; 573 QDate day = mSelectedDates[mStartCellX];
587 emit showDateView( item, day ); 574 emit showDateView( item, day );
588 // 3Day view 575 // 3Day view
589 // 4Week view 576 // 4Week view
590 // 5Month view 577 // 5Month view
591 // 6Journal view 578 // 6Journal view
592 } 579 }
593} 580}
594void KOAgenda::startSelectAction(QPoint viewportPos) 581void KOAgenda::startSelectAction(QPoint viewportPos)
595{ 582{
596 //emit newStartSelectSignal(); 583 //emit newStartSelectSignal();
597 584
598 mActionType = SELECT; 585 mActionType = SELECT;
599 586
600 int x,y; 587 int x,y;
601 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 588 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
602 int gx,gy; 589 int gx,gy;
603 contentsToGrid(x,y,gx,gy); 590 contentsToGrid(x,y,gx,gy);
604 591
605 mStartCellX = gx; 592 mStartCellX = gx;
606 mStartCellY = gy; 593 mStartCellY = gy;
607 mCurrentCellX = gx; 594 mCurrentCellX = gx;
608 mCurrentCellY = gy; 595 mCurrentCellY = gy;
609 596
610 // Store coordinates of old selection 597 // Store coordinates of old selection
611 int selectionX = mSelectionCellX * mGridSpacingX; 598 int selectionX = mSelectionCellX * mGridSpacingX;
612 int selectionYTop = mSelectionYTop; 599 int selectionYTop = mSelectionYTop;
613 int selectionHeight = mSelectionHeight; 600 int selectionHeight = mSelectionHeight;
614 601
615 // Store new selection 602 // Store new selection
616 mSelectionCellX = gx; 603 mSelectionCellX = gx;
617 mSelectionYTop = gy * mGridSpacingY; 604 mSelectionYTop = gy * mGridSpacingY;
618 mSelectionHeight = mGridSpacingY; 605 mSelectionHeight = mGridSpacingY;
619 606
620 // Clear old selection 607 // Clear old selection
621 repaintContents( selectionX, selectionYTop, 608 repaintContents( selectionX, selectionYTop,
622 mGridSpacingX, selectionHeight,false ); 609 mGridSpacingX, selectionHeight,false );
623 610
624 // Paint new selection 611 // Paint new selection
625 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, 612 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
626 // mGridSpacingX, mSelectionHeight ); 613 // mGridSpacingX, mSelectionHeight );
627} 614}
628 615
629void KOAgenda::performSelectAction(QPoint viewportPos) 616void KOAgenda::performSelectAction(QPoint viewportPos)
630{ 617{
631 int x,y; 618 int x,y;
632 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 619 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
633 int gx,gy; 620 int gx,gy;
634 contentsToGrid(x,y,gx,gy); 621 contentsToGrid(x,y,gx,gy);
635 622
636 QPoint clipperPos = clipper()-> 623 QPoint clipperPos = clipper()->
637 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 624 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
638 625
639 // Scroll if cursor was moved to upper or lower end of agenda. 626 // Scroll if cursor was moved to upper or lower end of agenda.
640 if (clipperPos.y() < mScrollBorderWidth) { 627 if (clipperPos.y() < mScrollBorderWidth) {
641 mScrollUpTimer.start(mScrollDelay); 628 mScrollUpTimer.start(mScrollDelay);
642 } else if (visibleHeight() - clipperPos.y() < 629 } else if (visibleHeight() - clipperPos.y() <
643 mScrollBorderWidth) { 630 mScrollBorderWidth) {
644 mScrollDownTimer.start(mScrollDelay); 631 mScrollDownTimer.start(mScrollDelay);
645 } else { 632 } else {
646 mScrollUpTimer.stop(); 633 mScrollUpTimer.stop();
647 mScrollDownTimer.stop(); 634 mScrollDownTimer.stop();
648 } 635 }
649 636
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index b30ad75..905c1bf 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,174 +1,174 @@
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#include <qlabel.h> 20#include <qlabel.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qwhatsthis.h> 25#include <qwhatsthis.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qpainter.h> 28#include <qpainter.h>
29 29
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#define AGENDA_ICON_SIZE 5 36#define AGENDA_ICON_SIZE 5
37#else 37#else
38#define AGENDA_ICON_SIZE 7 38#define AGENDA_ICON_SIZE 7
39#endif 39#endif
40#include <libkcal/icaldrag.h> 40#include <libkcal/icaldrag.h>
41#include <libkcal/vcaldrag.h> 41#include <libkcal/vcaldrag.h>
42#include <libkcal/kincidenceformatter.h> 42#include <libkcal/kincidenceformatter.h>
43extern int globalFlagBlockAgenda; 43extern int globalFlagBlockAgenda;
44extern int globalFlagBlockAgendaItemPaint; 44extern int globalFlagBlockAgendaItemPaint;
45extern int globalFlagBlockAgendaItemUpdate; 45extern int globalFlagBlockAgendaItemUpdate;
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48 48
49#include "koagendaitem.h" 49#include "koagendaitem.h"
50//#include "koagendaitem.moc" 50//#include "koagendaitem.moc"
51 51
52 52
53//-------------------------------------------------------------------------- 53//--------------------------------------------------------------------------
54 54
55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
56 56
57//-------------------------------------------------------------------------- 57//--------------------------------------------------------------------------
58 58
59class KOAgendaItemWhatsThis :public QWhatsThis 59class KOAgendaItemWhatsThis :public QWhatsThis
60{ 60{
61public: 61public:
62 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 62 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
63 63
64protected: 64protected:
65 virtual QString text( const QPoint& ) 65 virtual QString text( const QPoint& )
66 { 66 {
67 return _view->getWhatsThisText() ; 67 return _view->getWhatsThisText() ;
68 } 68 }
69private: 69private:
70 KOAgendaItem * _view; 70 KOAgendaItem * _view;
71}; 71};
72 72
73KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 73KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
74 const char *name,WFlags) : 74 const char *name,WFlags) :
75 QWidget(parent, name), mIncidence(incidence), mDate(qd) 75 QWidget(parent, name), mIncidence(incidence), mDate(qd)
76{ 76{
77#ifndef DESKTOP_VERSION 77#ifndef DESKTOP_VERSION
78 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 78 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
79#endif 79#endif
80 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); 80 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this);
81 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 81 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
82 setWFlags ( wflags); 82 setWFlags ( wflags);
83 mAllDay = allday; 83 mAllDay = allday;
84 init ( incidence, qd ); 84 init ( incidence, qd );
85 //setMouseTracking(true); 85 //setMouseTracking(true);
86 //setAcceptDrops(true); 86 //setAcceptDrops(true);
87 xPaintCoord = -1; 87 xPaintCoord = -1;
88 yPaintCoord = -1; 88 yPaintCoord = -1;
89} 89}
90QString KOAgendaItem::getWhatsThisText() 90QString KOAgendaItem::getWhatsThisText()
91{ 91{
92 if ( mIncidence ) 92 if ( mIncidence )
93 return KIncidenceFormatter::instance()->getFormattedText( mIncidence, 93 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
94 KOPrefs::instance()->mWTshowDetails, 94 KOPrefs::instance()->mWTshowDetails,
95 KOPrefs::instance()->mWTshowCreated, 95 KOPrefs::instance()->mWTshowCreated,
96 KOPrefs::instance()->mWTshowChanged); 96 KOPrefs::instance()->mWTshowChanged);
97 return "KOAgendaItem::getWhatsThisText()::internal error"; 97 return "KOAgendaItem::getWhatsThisText()::internal error";
98} 98}
99void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 99void KOAgendaItem::init ( Incidence *incidence, QDate qd )
100{ 100{
101 mIncidence = incidence; 101 mIncidence = incidence;
102 mDate = qd; 102 mDate = qd;
103 mFirstMultiItem = 0; 103 mFirstMultiItem = 0;
104 mNextMultiItem = 0; 104 mNextMultiItem = 0;
105 mLastMultiItem = 0; 105 mLastMultiItem = 0;
106 computeText(); 106 computeText();
107 107
108 if ( (incidence->type() == "Todo") && 108 if ( (incidence->type() == "Todo") &&
109 ( !((static_cast<Todo*>(incidence))->isCompleted()) && 109 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
110 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { 110 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
111 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) 111 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
112 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 112 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
113 else 113 else
114 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 114 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
115 } 115 }
116 else { 116 else {
117 QStringList categories = mIncidence->categories(); 117 QStringList categories = mIncidence->categories();
118 QString cat = categories.first(); 118 QString cat = categories.first();
119 if (cat.isEmpty()) { 119 if (cat.isEmpty()) {
120 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) 120 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) )
121 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 121 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
122 else 122 else
123 mBackgroundColor =KOPrefs::instance()->mEventColor; 123 mBackgroundColor =KOPrefs::instance()->mEventColor;
124 } else { 124 } else {
125 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 125 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
126 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 126 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) {
127 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 127 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
128 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 128 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
129 } 129 }
130 } 130 }
131 131
132 } 132 }
133 mColorGroup = QColorGroup( mBackgroundColor.light(), 133 mColorGroup = QColorGroup( mBackgroundColor.light(),
134 mBackgroundColor.dark(),mBackgroundColor.light(), 134 mBackgroundColor.dark(),mBackgroundColor.light(),
135 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 135 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
136 setBackgroundColor( mBackgroundColor ); 136 setBackgroundColor( mBackgroundColor );
137 137
138 mConflictItems.clear(); 138 mConflictItems.clear();
139 setCellXY(0,0,1); 139 setCellXY(0,0,1);
140 setCellXWidth(0); 140 setCellXWidth(0);
141 setSubCell(0); 141 setSubCell(0);
142 setSubCells(1); 142 setSubCells(1);
143 setMultiItem(0,0,0); 143 setMultiItem(0,0,0);
144 startMove(); 144 startMove();
145 mSelected = true; 145 mSelected = true;
146 select(false); 146 select(false);
147 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 147 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
148 mFontPixelSize = fontinf.height();; 148 mFontPixelSize = fontinf.height();;
149 hide(); 149 hide();
150 xPaintCoord = -1; 150 xPaintCoord = -1;
151 yPaintCoord = -1; 151 yPaintCoord = -1;
152} 152}
153 153
154 154
155KOAgendaItem::~KOAgendaItem() 155KOAgendaItem::~KOAgendaItem()
156{ 156{
157 // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); 157 // qDebug("deleteKOAgendaItem::~KOAgendaItem( ");
158 // delete mKOAgendaItemWhatsThis; 158 // delete mKOAgendaItemWhatsThis;
159} 159}
160 160
161void KOAgendaItem::recreateIncidence() 161void KOAgendaItem::recreateIncidence()
162{ 162{
163#if 0 163#if 0
164 Incidence* newInc = mIncidence->clone(); 164 Incidence* newInc = mIncidence->clone();
165 newInc->recreate(); 165 newInc->recreate();
166 if ( mIncidence->doesRecur() ) { 166 if ( mIncidence->doesRecur() ) {
167 mIncidence->addExDate( mDate ); 167 mIncidence->addExDate( mDate );
168 newInc->recurrence()->unsetRecurs(); 168 newInc->recurrence()->unsetRecurs();
169 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 169 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
170 QTime tim = mIncidence->dtStart().time(); 170 QTime tim = mIncidence->dtStart().time();
171 newInc->setDtStart( QDateTime(mDate, tim) ); 171 newInc->setDtStart( QDateTime(mDate, tim) );
172 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 172 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
173 } 173 }
174#endif 174#endif
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 3519985..6b63d7f 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -215,193 +215,193 @@ bool ListItemVisitor::visit(Journal * j)
215 return true; 215 return true;
216} 216}
217 217
218KOListView::KOListView(Calendar *calendar, QWidget *parent, 218KOListView::KOListView(Calendar *calendar, QWidget *parent,
219 const char *name) 219 const char *name)
220 : KOEventView(calendar, parent, name) 220 : KOEventView(calendar, parent, name)
221{ 221{
222 mActiveItem = 0; 222 mActiveItem = 0;
223 mListView = new KOListViewListView(this); 223 mListView = new KOListViewListView(this);
224 mListView->addColumn(i18n("Summary")); 224 mListView->addColumn(i18n("Summary"));
225 mListView->addColumn(i18n("Start Date")); 225 mListView->addColumn(i18n("Start Date"));
226 mListView->addColumn(i18n("Start Time")); 226 mListView->addColumn(i18n("Start Time"));
227 mListView->addColumn(i18n("End Date")); 227 mListView->addColumn(i18n("End Date"));
228 mListView->addColumn(i18n("End Time")); 228 mListView->addColumn(i18n("End Time"));
229 mListView->addColumn(i18n("Alarm")); // alarm set? 229 mListView->addColumn(i18n("Alarm")); // alarm set?
230 mListView->addColumn(i18n("Recurs")); // recurs? 230 mListView->addColumn(i18n("Recurs")); // recurs?
231 mListView->addColumn(i18n("Due Date")); 231 mListView->addColumn(i18n("Due Date"));
232 mListView->addColumn(i18n("Due Time")); 232 mListView->addColumn(i18n("Due Time"));
233 mListView->addColumn(i18n("Cancelled")); 233 mListView->addColumn(i18n("Cancelled"));
234 mListView->addColumn(i18n("Categories")); 234 mListView->addColumn(i18n("Categories"));
235 235
236 mListView->setColumnAlignment(0,AlignLeft); 236 mListView->setColumnAlignment(0,AlignLeft);
237 mListView->setColumnAlignment(1,AlignLeft); 237 mListView->setColumnAlignment(1,AlignLeft);
238 mListView->setColumnAlignment(2,AlignHCenter); 238 mListView->setColumnAlignment(2,AlignHCenter);
239 mListView->setColumnAlignment(3,AlignLeft); 239 mListView->setColumnAlignment(3,AlignLeft);
240 mListView->setColumnAlignment(4,AlignHCenter); 240 mListView->setColumnAlignment(4,AlignHCenter);
241 mListView->setColumnAlignment(5,AlignLeft); 241 mListView->setColumnAlignment(5,AlignLeft);
242 mListView->setColumnAlignment(6,AlignLeft); 242 mListView->setColumnAlignment(6,AlignLeft);
243 mListView->setColumnAlignment(7,AlignLeft); 243 mListView->setColumnAlignment(7,AlignLeft);
244 mListView->setColumnAlignment(8,AlignLeft); 244 mListView->setColumnAlignment(8,AlignLeft);
245 mListView->setColumnAlignment(9,AlignLeft); 245 mListView->setColumnAlignment(9,AlignLeft);
246 mListView->setColumnAlignment(10,AlignLeft); 246 mListView->setColumnAlignment(10,AlignLeft);
247 mListView->setColumnWidthMode(10, QListView::Manual); 247 mListView->setColumnWidthMode(10, QListView::Manual);
248 new KOListViewWhatsThis(mListView->viewport(),this); 248 new KOListViewWhatsThis(mListView->viewport(),this);
249 249
250 int iii = 0; 250 int iii = 0;
251 for ( iii = 0; iii< 10 ; ++iii ) 251 for ( iii = 0; iii< 10 ; ++iii )
252 mListView->setColumnWidthMode( iii, QListView::Manual ); 252 mListView->setColumnWidthMode( iii, QListView::Manual );
253 253
254 QBoxLayout *layoutTop = new QVBoxLayout(this); 254 QBoxLayout *layoutTop = new QVBoxLayout(this);
255 layoutTop->addWidget(mListView); 255 layoutTop->addWidget(mListView);
256 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 256 mListView->setFont ( KOPrefs::instance()->mListViewFont );
257 mPopupMenu = eventPopup(); 257 mPopupMenu = eventPopup();
258 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 258 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
259 i18n("Select all"),this, 259 i18n("Select all"),this,
260 SLOT(allSelection()),true); 260 SLOT(allSelection()),true);
261 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 261 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
262 i18n("Deselect all"),this, 262 i18n("Deselect all"),this,
263 SLOT(clearSelection()),true); 263 SLOT(clearSelection()),true);
264 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 264 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
265 i18n("Delete all selected"),this, 265 i18n("Delete all selected"),this,
266 SLOT(deleteAll()),true); 266 SLOT(deleteAll()),true);
267 mPopupMenu->insertSeparator(); 267 mPopupMenu->insertSeparator();
268 QPopupMenu * exportPO = new QPopupMenu ( this ); 268 QPopupMenu * exportPO = new QPopupMenu ( this );
269 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 269 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
270 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 270 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
271 SLOT(saveToFile())); 271 SLOT(saveToFile()));
272 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 272 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
273 SLOT(saveToFileVCS())); 273 SLOT(saveToFileVCS()));
274 exportPO->insertItem( i18n("Journal/Details..."),this, 274 exportPO->insertItem( i18n("Journal/Details..."),this,
275 SLOT(saveDescriptionToFile())); 275 SLOT(saveDescriptionToFile()));
276 // mPopupMenu->insertSeparator(); 276 // mPopupMenu->insertSeparator();
277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
278 i18n("Add Categ. to selected..."),this, 278 i18n("Add Categ. to selected..."),this,
279 SLOT(addCat()),true); 279 SLOT(addCat()),true);
280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
281 i18n("Set Categ. for selected..."),this, 281 i18n("Set Categ. for selected..."),this,
282 SLOT(setCat()),true); 282 SLOT(setCat()),true);
283 //mPopupMenu->insertSeparator(); 283 //mPopupMenu->insertSeparator();
284 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 284 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
285 i18n("Set alarm for selected..."),this, 285 i18n("Set alarm for selected..."),this,
286 SLOT(setAlarm()),true); 286 SLOT(setAlarm()),true);
287 287
288 288
289#ifndef DESKTOP_VERSION 289#ifndef DESKTOP_VERSION
290 mPopupMenu->insertSeparator(); 290 mPopupMenu->insertSeparator();
291 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 291 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
292 i18n("Beam selected via IR"),this, 292 i18n("Beam selected via IR"),this,
293 SLOT(beamSelected()),true); 293 SLOT(beamSelected()),true);
294#endif 294#endif
295 /* 295 /*
296 mPopupMenu = new QPopupMenu; 296 mPopupMenu = new QPopupMenu;
297 mPopupMenu->insertItem(i18n("Edit Event"), this, 297 mPopupMenu->insertItem(i18n("Edit Event"), this,
298 SLOT (editEvent())); 298 SLOT (editEvent()));
299 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 299 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
300 SLOT (deleteEvent())); 300 SLOT (deleteEvent()));
301 mPopupMenu->insertSeparator(); 301 mPopupMenu->insertSeparator();
302 mPopupMenu->insertItem(i18n("Show Dates"), this, 302 mPopupMenu->insertItem(i18n("Show Dates"), this,
303 SLOT(showDates())); 303 SLOT(showDates()));
304 mPopupMenu->insertItem(i18n("Hide Dates"), this, 304 mPopupMenu->insertItem(i18n("Hide Dates"), this,
305 SLOT(hideDates())); 305 SLOT(hideDates()));
306 */ 306 */
307 QObject::connect(mListView,SIGNAL( newEvent()), 307 QObject::connect(mListView,SIGNAL( newEvent()),
308 this,SIGNAL(signalNewEvent())); 308 this,SIGNAL(signalNewEvent()));
309 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 309 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
310 this,SLOT(defaultItemAction(QListViewItem *))); 310 this,SLOT(defaultItemAction(QListViewItem *)));
311 QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, 311 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
312 const QPoint &, int )), 312 const QPoint &, int )),
313 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 313 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
314 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 314 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
315 SLOT(processSelectionChange(QListViewItem *))); 315 SLOT(processSelectionChange(QListViewItem *)));
316 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 316 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
317 SIGNAL(showIncidenceSignal(Incidence *)) ); 317 SIGNAL(showIncidenceSignal(Incidence *)) );
318 318
319 readSettings(KOGlobals::config(),"KOListView Layout"); 319 readSettings(KOGlobals::config(),"KOListView Layout");
320} 320}
321 321
322KOListView::~KOListView() 322KOListView::~KOListView()
323{ 323{
324 delete mPopupMenu; 324 delete mPopupMenu;
325} 325}
326QString KOListView::getWhatsThisText(QPoint p) 326QString KOListView::getWhatsThisText(QPoint p)
327{ 327{
328 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 328 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
329 if ( item ) 329 if ( item )
330 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 330 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
331 KOPrefs::instance()->mWTshowDetails, 331 KOPrefs::instance()->mWTshowDetails,
332 KOPrefs::instance()->mWTshowCreated, 332 KOPrefs::instance()->mWTshowCreated,
333 KOPrefs::instance()->mWTshowChanged); 333 KOPrefs::instance()->mWTshowChanged);
334 return i18n("That is the list view" ); 334 return i18n("That is the list view" );
335 335
336} 336}
337 337
338void KOListView::updateList() 338void KOListView::updateList()
339{ 339{
340 // qDebug(" KOListView::updateList() "); 340 // qDebug(" KOListView::updateList() ");
341 341
342} 342}
343 343
344void KOListView::addCat( ) 344void KOListView::addCat( )
345{ 345{
346 setCategories( false ); 346 setCategories( false );
347} 347}
348void KOListView::setCat() 348void KOListView::setCat()
349{ 349{
350 setCategories( true ); 350 setCategories( true );
351} 351}
352void KOListView::setAlarm() 352void KOListView::setAlarm()
353{ 353{
354 KOAlarmPrefs kap( this); 354 KOAlarmPrefs kap( this);
355 if ( !kap.exec() ) 355 if ( !kap.exec() )
356 return; 356 return;
357 357
358 358
359 QStringList itemList; 359 QStringList itemList;
360 QPtrList<KOListViewItem> sel ; 360 QPtrList<KOListViewItem> sel ;
361 QListViewItem *qitem = mListView->firstChild (); 361 QListViewItem *qitem = mListView->firstChild ();
362 while ( qitem ) { 362 while ( qitem ) {
363 if ( qitem->isSelected() ) { 363 if ( qitem->isSelected() ) {
364 Incidence* inc = ((KOListViewItem *) qitem)->data(); 364 Incidence* inc = ((KOListViewItem *) qitem)->data();
365 if ( inc->type() != "Journal" ) { 365 if ( inc->type() != "Journal" ) {
366 if ( inc->type() == "Todo" ) { 366 if ( inc->type() == "Todo" ) {
367 if ( ((Todo*)inc)->hasDueDate() ) 367 if ( ((Todo*)inc)->hasDueDate() )
368 sel.append(((KOListViewItem *)qitem)); 368 sel.append(((KOListViewItem *)qitem));
369 } else 369 } else
370 sel.append(((KOListViewItem *)qitem)); 370 sel.append(((KOListViewItem *)qitem));
371 } 371 }
372 } 372 }
373 qitem = qitem->nextSibling(); 373 qitem = qitem->nextSibling();
374 } 374 }
375 int count = 0; 375 int count = 0;
376 KOListViewItem * item, *temp; 376 KOListViewItem * item, *temp;
377 item = sel.first(); 377 item = sel.first();
378 Incidence* inc; 378 Incidence* inc;
379 while ( item ) { 379 while ( item ) {
380 inc = item->data(); 380 inc = item->data();
381 ++count; 381 ++count;
382 if (kap.mAlarmButton->isChecked()) { 382 if (kap.mAlarmButton->isChecked()) {
383 if (inc->alarms().count() == 0) 383 if (inc->alarms().count() == 0)
384 inc->newAlarm(); 384 inc->newAlarm();
385 QPtrList<Alarm> alarms = inc->alarms(); 385 QPtrList<Alarm> alarms = inc->alarms();
386 Alarm *alarm; 386 Alarm *alarm;
387 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 387 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
388 alarm->setEnabled(true); 388 alarm->setEnabled(true);
389 int j = kap.mAlarmTimeEdit->value()* -60; 389 int j = kap.mAlarmTimeEdit->value()* -60;
390 if (kap.mAlarmIncrCombo->currentItem() == 1) 390 if (kap.mAlarmIncrCombo->currentItem() == 1)
391 j = j * 60; 391 j = j * 60;
392 else if (kap.mAlarmIncrCombo->currentItem() == 2) 392 else if (kap.mAlarmIncrCombo->currentItem() == 2)
393 j = j * (60 * 24); 393 j = j * (60 * 24);
394 alarm->setStartOffset( j ); 394 alarm->setStartOffset( j );
395 395
396 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 396 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
397 alarm->setProcedureAlarm(kap.mAlarmProgram); 397 alarm->setProcedureAlarm(kap.mAlarmProgram);
398 } 398 }
399 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 399 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
400 alarm->setAudioAlarm(kap.mAlarmSound); 400 alarm->setAudioAlarm(kap.mAlarmSound);
401 else 401 else
402 alarm->setType(Alarm::Invalid); 402 alarm->setType(Alarm::Invalid);
403 //alarm->setAudioAlarm("default"); 403 //alarm->setAudioAlarm("default");
404 // TODO: Deal with multiple alarms 404 // TODO: Deal with multiple alarms
405 break; // For now, stop after the first alarm 405 break; // For now, stop after the first alarm
406 } 406 }
407 } else { 407 } else {
@@ -1066,162 +1066,130 @@ void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1066 cn = currentItem(); 1066 cn = currentItem();
1067 if ( ! cn ) 1067 if ( ! cn )
1068 return; 1068 return;
1069 if ( jump == 0 ) 1069 if ( jump == 0 )
1070 jump = 1; 1070 jump = 1;
1071 while ( jump && cn->nextSibling() ) { 1071 while ( jump && cn->nextSibling() ) {
1072 cn = cn->nextSibling(); 1072 cn = cn->nextSibling();
1073 --jump; 1073 --jump;
1074 } 1074 }
1075 setCurrentItem ( cn ); 1075 setCurrentItem ( cn );
1076 ensureItemVisible ( cn ); 1076 ensureItemVisible ( cn );
1077 1077
1078 } else 1078 } else
1079 QListView::keyPressEvent ( e ) ; 1079 QListView::keyPressEvent ( e ) ;
1080 e->accept(); 1080 e->accept();
1081 break; 1081 break;
1082 1082
1083 case Qt::Key_Up: 1083 case Qt::Key_Up:
1084 if ( e->state() == ShiftButton ) { 1084 if ( e->state() == ShiftButton ) {
1085 QListViewItem* cn = firstChild(); 1085 QListViewItem* cn = firstChild();
1086 if ( cn ) { 1086 if ( cn ) {
1087 setCurrentItem ( cn ); 1087 setCurrentItem ( cn );
1088 ensureItemVisible ( cn ); 1088 ensureItemVisible ( cn );
1089 } 1089 }
1090 e->accept(); 1090 e->accept();
1091 return; 1091 return;
1092 } 1092 }
1093 if ( e->state() == ControlButton ) { 1093 if ( e->state() == ControlButton ) {
1094 int count = childCount (); 1094 int count = childCount ();
1095 int jump = count / 5; 1095 int jump = count / 5;
1096 QListViewItem* cn; 1096 QListViewItem* cn;
1097 cn = currentItem(); 1097 cn = currentItem();
1098 if ( ! cn ) 1098 if ( ! cn )
1099 return; 1099 return;
1100 if ( jump == 0 ) 1100 if ( jump == 0 )
1101 jump = 1; 1101 jump = 1;
1102 while ( jump && cn->itemAbove ()) { 1102 while ( jump && cn->itemAbove ()) {
1103 cn = cn->itemAbove (); 1103 cn = cn->itemAbove ();
1104 --jump; 1104 --jump;
1105 } 1105 }
1106 setCurrentItem ( cn ); 1106 setCurrentItem ( cn );
1107 ensureItemVisible ( cn ); 1107 ensureItemVisible ( cn );
1108 } else 1108 } else
1109 QListView::keyPressEvent ( e ) ; 1109 QListView::keyPressEvent ( e ) ;
1110 e->accept(); 1110 e->accept();
1111 break; 1111 break;
1112 case Qt::Key_I: { 1112 case Qt::Key_I: {
1113 QListViewItem* cn; 1113 QListViewItem* cn;
1114 cn = currentItem(); 1114 cn = currentItem();
1115 if ( cn ) { 1115 if ( cn ) {
1116 KOListViewItem* ci = (KOListViewItem*)( cn ); 1116 KOListViewItem* ci = (KOListViewItem*)( cn );
1117 if ( ci ){ 1117 if ( ci ){
1118 //emit showIncidence( ci->data()); 1118 //emit showIncidence( ci->data());
1119 cn = cn->nextSibling(); 1119 cn = cn->nextSibling();
1120 if ( cn ) { 1120 if ( cn ) {
1121 setCurrentItem ( cn ); 1121 setCurrentItem ( cn );
1122 ensureItemVisible ( cn ); 1122 ensureItemVisible ( cn );
1123 } 1123 }
1124 emit showIncidence( ci->data()); 1124 emit showIncidence( ci->data());
1125 } 1125 }
1126 } 1126 }
1127 e->accept(); 1127 e->accept();
1128 } 1128 }
1129 break; 1129 break;
1130 case Qt::Key_Return: 1130 case Qt::Key_Return:
1131 case Qt::Key_Enter: 1131 case Qt::Key_Enter:
1132 { 1132 {
1133 QListViewItem* cn; 1133 QListViewItem* cn;
1134 cn = currentItem(); 1134 cn = currentItem();
1135 if ( cn ) { 1135 if ( cn ) {
1136 KOListViewItem* ci = (KOListViewItem*)( cn ); 1136 KOListViewItem* ci = (KOListViewItem*)( cn );
1137 if ( ci ){ 1137 if ( ci ){
1138 if ( e->state() == ShiftButton ) 1138 if ( e->state() == ShiftButton )
1139 ci->setSelected( false ); 1139 ci->setSelected( false );
1140 else 1140 else
1141 ci->setSelected( true ); 1141 ci->setSelected( true );
1142 cn = cn->nextSibling(); 1142 cn = cn->nextSibling();
1143 if ( cn ) { 1143 if ( cn ) {
1144 setCurrentItem ( cn ); 1144 setCurrentItem ( cn );
1145 ensureItemVisible ( cn ); 1145 ensureItemVisible ( cn );
1146 } 1146 }
1147 } 1147 }
1148 } 1148 }
1149 e->accept(); 1149 e->accept();
1150 } 1150 }
1151 break; 1151 break;
1152 default: 1152 default:
1153 e->ignore(); 1153 e->ignore();
1154 } 1154 }
1155} 1155}
1156KOListViewListView::KOListViewListView(KOListView * lv ) 1156KOListViewListView::KOListViewListView(KOListView * lv )
1157 : KListView( lv ) 1157 : KListView( lv )
1158{ 1158{
1159#ifndef DESKTOP_VERSION 1159#ifndef DESKTOP_VERSION
1160 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1160 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1161#endif 1161#endif
1162 mYMousePos = -1000;
1163 setSelectionMode( QListView::Multi ); 1162 setSelectionMode( QListView::Multi );
1164 setMultiSelection( true); 1163 setMultiSelection( true);
1165 mAllowPopupMenu = true;
1166 mMouseDown = false;
1167
1168} 1164}
1169void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1165void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1170{ 1166{
1171 if (!e) return; 1167 if (!e) return;
1172 QPoint vp = contentsToViewport(e->pos()); 1168 QPoint vp = contentsToViewport(e->pos());
1173 QListViewItem *item = itemAt(vp); 1169 QListViewItem *item = itemAt(vp);
1174 if (!item) { 1170 if (!item) {
1175 emit newEvent(); 1171 emit newEvent();
1176 return; 1172 return;
1177 } 1173 }
1178 KListView::contentsMouseDoubleClickEvent(e); 1174 KListView::contentsMouseDoubleClickEvent(e);
1179} 1175}
1180 1176
1181
1182void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1177void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1183{ 1178{
1184 //qDebug("contentsMousePressEvent++++ "); 1179 //qDebug("contentsMousePressEvent++++ ");
1185 if (! mMouseDown ) {
1186 mAllowPopupMenu = true;
1187 mYMousePos = mapToGlobal( (e->pos())).y();
1188 }
1189 if ( e->button() == RightButton && mMouseDown )
1190 return;
1191 if ( e->button() == LeftButton )
1192 mMouseDown = true;
1193 KListView::contentsMousePressEvent( e ); 1180 KListView::contentsMousePressEvent( e );
1181 if ( e->button() == RightButton ) {
1182 QListViewItem* ci = currentItem();
1183 clearSelection () ;
1184 if ( ci )
1185 ci->setSelected( true );
1186 }
1194} 1187}
1195void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1188void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1196{ 1189{
1197 //qDebug("contentsMouseReleaseEv---- ");
1198 if ( ! mMouseDown ) {
1199 if ( e->button() == RightButton && ! mAllowPopupMenu )
1200 return;
1201 QListViewItem* ci = currentItem();
1202 if ( ci )
1203 ci->setSelected( true );
1204 KListView::contentsMouseReleaseEvent(e);
1205 return;
1206 }
1207 if ( e->button() == LeftButton )
1208 mMouseDown = false;
1209 if ( e->button() == RightButton && ! mAllowPopupMenu )
1210 return;
1211 if ( e->button() == RightButton ) {
1212 QListViewItem* ci = currentItem();
1213 if ( ci )
1214 ci->setSelected( true );
1215 }
1216 KListView::contentsMouseReleaseEvent(e); 1190 KListView::contentsMouseReleaseEvent(e);
1217} 1191}
1218void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1192void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1219{ 1193{
1220 // qDebug("contentsMouseMoveEv....... ");
1221 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1222 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1223 if ( diff < 0 ) diff = -diff;
1224 if ( diff > 20 )
1225 mAllowPopupMenu = false;
1226 KListView::contentsMouseMoveEvent(e); 1194 KListView::contentsMouseMoveEvent(e);
1227} 1195}
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index 0d9c525..eca71e2 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -130,177 +130,175 @@ void pickAlarmSound()
130 if (!fileName.isEmpty()) { 130 if (!fileName.isEmpty()) {
131 mAlarmSound = fileName; 131 mAlarmSound = fileName;
132 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 132 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
133 QToolTip::remove(mAlarmSoundButton); 133 QToolTip::remove(mAlarmSoundButton);
134 QString dispStr = i18n("Playing '%1'").arg(fileName); 134 QString dispStr = i18n("Playing '%1'").arg(fileName);
135 QToolTip::add(mAlarmSoundButton, dispStr); 135 QToolTip::add(mAlarmSoundButton, dispStr);
136 mAlarmProgramButton->setOn(false); 136 mAlarmProgramButton->setOn(false);
137 mAlarmSoundButton->setOn(true); 137 mAlarmSoundButton->setOn(true);
138 } else { 138 } else {
139 mAlarmProgramButton->setOn(true); 139 mAlarmProgramButton->setOn(true);
140 mAlarmSoundButton->setOn(false); 140 mAlarmSoundButton->setOn(false);
141 141
142 } 142 }
143 } 143 }
144}; 144};
145 145
146void pickAlarmProgram() 146void pickAlarmProgram()
147{ 147{
148 if (!mAlarmProgramButton->isOn()) { 148 if (!mAlarmProgramButton->isOn()) {
149 //mAlarmProgram = ""; 149 //mAlarmProgram = "";
150 QToolTip::remove(mAlarmProgramButton); 150 QToolTip::remove(mAlarmProgramButton);
151 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 151 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
152 mAlarmProgramButton->setOn(false); 152 mAlarmProgramButton->setOn(false);
153 mAlarmSoundButton->setOn(true); 153 mAlarmSoundButton->setOn(true);
154 } else { 154 } else {
155 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); 155 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
156 if (!fileName.isEmpty()) { 156 if (!fileName.isEmpty()) {
157 mAlarmProgram = fileName; 157 mAlarmProgram = fileName;
158 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 158 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
159 QToolTip::remove(mAlarmProgramButton); 159 QToolTip::remove(mAlarmProgramButton);
160 QString dispStr = i18n("Running '%1'").arg(fileName); 160 QString dispStr = i18n("Running '%1'").arg(fileName);
161 QToolTip::add(mAlarmProgramButton, dispStr); 161 QToolTip::add(mAlarmProgramButton, dispStr);
162 mAlarmSoundButton->setOn(false); 162 mAlarmSoundButton->setOn(false);
163 mAlarmProgramButton->setOn(true); 163 mAlarmProgramButton->setOn(true);
164 } else { 164 } else {
165 mAlarmProgramButton->setOn(false); 165 mAlarmProgramButton->setOn(false);
166 mAlarmSoundButton->setOn(true); 166 mAlarmSoundButton->setOn(true);
167 } 167 }
168 } 168 }
169}; 169};
170 170
171}; 171};
172 172
173 173
174 174
175 175
176 176
177 177
178 178
179typedef CustomListViewItem<Incidence *> KOListViewItem; 179typedef CustomListViewItem<Incidence *> KOListViewItem;
180 180
181/** 181/**
182 This class provides the initialisation of a KOListViewItem for calendar 182 This class provides the initialisation of a KOListViewItem for calendar
183 components using the Incidence::Visitor. 183 components using the Incidence::Visitor.
184*/ 184*/
185class ListItemVisitor : public Incidence::Visitor 185class ListItemVisitor : public Incidence::Visitor
186{ 186{
187 public: 187 public:
188 ListItemVisitor(KOListViewItem *, QDate d); 188 ListItemVisitor(KOListViewItem *, QDate d);
189 ~ListItemVisitor(); 189 ~ListItemVisitor();
190 190
191 bool visit(Event *); 191 bool visit(Event *);
192 bool visit(Todo *); 192 bool visit(Todo *);
193 bool visit(Journal *); 193 bool visit(Journal *);
194 194
195 private: 195 private:
196 KOListViewItem *mItem; 196 KOListViewItem *mItem;
197 QDate mDate; 197 QDate mDate;
198}; 198};
199 199
200/** 200/**
201 This class provides a multi-column list view of events. It can 201 This class provides a multi-column list view of events. It can
202 display events from one particular day or several days, it doesn't 202 display events from one particular day or several days, it doesn't
203 matter. To use a view that only handles one day at a time, use 203 matter. To use a view that only handles one day at a time, use
204 KODayListView. 204 KODayListView.
205 205
206 @short multi-column list view of various events. 206 @short multi-column list view of various events.
207 @author Preston Brown <pbrown@kde.org> 207 @author Preston Brown <pbrown@kde.org>
208 @see KOBaseView, KODayListView 208 @see KOBaseView, KODayListView
209*/ 209*/
210class KOListView; 210class KOListView;
211 211
212class KOListViewListView : public KListView 212class KOListViewListView : public KListView
213{ 213{
214 Q_OBJECT 214 Q_OBJECT
215 public: 215 public:
216 KOListViewListView(KOListView * lv ); 216 KOListViewListView(KOListView * lv );
217 signals: 217 signals:
218 void newEvent(); 218 void newEvent();
219 void showIncidence( Incidence* ); 219 void showIncidence( Incidence* );
220 private: 220 private:
221 void keyPressEvent ( QKeyEvent * ) ; 221 void keyPressEvent ( QKeyEvent * ) ;
222 void contentsMouseDoubleClickEvent(QMouseEvent *e); 222 void contentsMouseDoubleClickEvent(QMouseEvent *e);
223 void contentsMousePressEvent(QMouseEvent *e); 223 void contentsMousePressEvent(QMouseEvent *e);
224 void contentsMouseReleaseEvent(QMouseEvent *e); 224 void contentsMouseReleaseEvent(QMouseEvent *e);
225 void contentsMouseMoveEvent(QMouseEvent *e); 225 void contentsMouseMoveEvent(QMouseEvent *e);
226 bool mAllowPopupMenu;
227 bool mMouseDown; 226 bool mMouseDown;
228 int mYMousePos;
229}; 227};
230 228
231class KOListView : public KOEventView 229class KOListView : public KOEventView
232{ 230{
233 Q_OBJECT 231 Q_OBJECT
234 public: 232 public:
235 KOListView(Calendar *calendar, QWidget *parent = 0, 233 KOListView(Calendar *calendar, QWidget *parent = 0,
236 const char *name = 0); 234 const char *name = 0);
237 ~KOListView(); 235 ~KOListView();
238 236
239 virtual int maxDatesHint(); 237 virtual int maxDatesHint();
240 virtual int currentDateCount(); 238 virtual int currentDateCount();
241 virtual QPtrList<Incidence> selectedIncidences(); 239 virtual QPtrList<Incidence> selectedIncidences();
242 virtual DateList selectedDates(); 240 virtual DateList selectedDates();
243 241
244 void showDates(bool show); 242 void showDates(bool show);
245 Incidence* currentItem(); 243 Incidence* currentItem();
246 void addTodos(QPtrList<Todo> eventList); 244 void addTodos(QPtrList<Todo> eventList);
247 void addJournals(QPtrList<Journal> eventList); 245 void addJournals(QPtrList<Journal> eventList);
248 virtual void printPreview(CalPrinter *calPrinter, 246 virtual void printPreview(CalPrinter *calPrinter,
249 const QDate &, const QDate &); 247 const QDate &, const QDate &);
250 248
251 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 249 void readSettings(KConfig *config, QString setting = "KOListView Layout");
252 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 250 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
253 void updateList(); 251 void updateList();
254 void setStartDate(const QDate &start); 252 void setStartDate(const QDate &start);
255 int count(); 253 int count();
256 QString getWhatsThisText(QPoint p); 254 QString getWhatsThisText(QPoint p);
257 void resetFocus(); 255 void resetFocus();
258 signals: 256 signals:
259 void signalNewEvent(); 257 void signalNewEvent();
260 void beamIncidenceList(QPtrList<Incidence>); 258 void beamIncidenceList(QPtrList<Incidence>);
261 259
262 public slots: 260 public slots:
263 virtual void updateView(); 261 virtual void updateView();
264 virtual void showDates(const QDate &start, const QDate &end); 262 virtual void showDates(const QDate &start, const QDate &end);
265 virtual void showEvents(QPtrList<Event> eventList); 263 virtual void showEvents(QPtrList<Event> eventList);
266 void clearSelection(); 264 void clearSelection();
267 void allSelection(); 265 void allSelection();
268 266
269 void clear(); 267 void clear();
270 void beamDone( Ir *ir ); 268 void beamDone( Ir *ir );
271 void showDates(); 269 void showDates();
272 void hideDates(); 270 void hideDates();
273 void deleteAll(); 271 void deleteAll();
274 void saveToFile(); 272 void saveToFile();
275 void saveToFileVCS(); 273 void saveToFileVCS();
276 void saveDescriptionToFile(); 274 void saveDescriptionToFile();
277 void beamSelected(); 275 void beamSelected();
278 void updateConfig(); 276 void updateConfig();
279 void addCat(); 277 void addCat();
280 void setCat(); 278 void setCat();
281 void setAlarm(); 279 void setAlarm();
282 void setCategories( bool removeOld ); 280 void setCategories( bool removeOld );
283 void changeEventDisplay(Event *, int); 281 void changeEventDisplay(Event *, int);
284 282
285 void defaultItemAction(QListViewItem *item); 283 void defaultItemAction(QListViewItem *item);
286 void popupMenu(QListViewItem *item,const QPoint &,int); 284 void popupMenu(QListViewItem *item,const QPoint &,int);
287 285
288 protected slots: 286 protected slots:
289 void processSelectionChange(QListViewItem *); 287 void processSelectionChange(QListViewItem *);
290 288
291 protected: 289 protected:
292 void writeToFile( bool iCal ); 290 void writeToFile( bool iCal );
293 void addEvents(QPtrList<Event> eventList); 291 void addEvents(QPtrList<Event> eventList);
294 void addIncidence(Incidence *); 292 void addIncidence(Incidence *);
295 KOListViewItem *getItemForEvent(Event *event); 293 KOListViewItem *getItemForEvent(Event *event);
296 294
297 private: 295 private:
298 KOListViewListView *mListView; 296 KOListViewListView *mListView;
299 KOEventPopupMenu *mPopupMenu; 297 KOEventPopupMenu *mPopupMenu;
300 KOListViewItem *mActiveItem; 298 KOListViewItem *mActiveItem;
301 QDict<Incidence> mUidDict; 299 QDict<Incidence> mUidDict;
302 QDate mStartDate; 300 QDate mStartDate;
303 void keyPressEvent ( QKeyEvent * ) ; 301 void keyPressEvent ( QKeyEvent * ) ;
304}; 302};
305 303
306#endif 304#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 12233ee..9085775 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -421,192 +421,197 @@ QToolTipGroup *MonthViewCell::toolTipGroup()
421#endif 421#endif
422 422
423void MonthViewCell::setDate( const QDate &date ) 423void MonthViewCell::setDate( const QDate &date )
424{ 424{
425 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 425 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
426 mDate = date; 426 mDate = date;
427 427
428 428
429 429
430 //resizeEvent( 0 ); 430 //resizeEvent( 0 );
431} 431}
432 432
433QDate MonthViewCell::date() const 433QDate MonthViewCell::date() const
434{ 434{
435 return mDate; 435 return mDate;
436} 436}
437 437
438void MonthViewCell::setPrimary( bool primary ) 438void MonthViewCell::setPrimary( bool primary )
439{ 439{
440 mPrimary = primary; 440 mPrimary = primary;
441 //setMyPalette(); 441 //setMyPalette();
442} 442}
443void MonthViewCell::setMyPalette() 443void MonthViewCell::setMyPalette()
444{ 444{
445 445
446 if ( mHoliday) { 446 if ( mHoliday) {
447 if ( currentPalette == 1 ) return; 447 if ( currentPalette == 1 ) return;
448 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 448 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
449 setPalette( mHolidayPalette ); 449 setPalette( mHolidayPalette );
450 //mLabel->setPalette( mHolidayPalette ); 450 //mLabel->setPalette( mHolidayPalette );
451 currentPalette = 1; 451 currentPalette = 1;
452 452
453 } else { 453 } else {
454 if ( mPrimary ) { 454 if ( mPrimary ) {
455 if ( currentPalette == 2 ) return; 455 if ( currentPalette == 2 ) return;
456 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 456 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
457 //mLabel->setPalette( mPrimaryPalette ); 457 //mLabel->setPalette( mPrimaryPalette );
458 setPalette( mPrimaryPalette ); 458 setPalette( mPrimaryPalette );
459 currentPalette = 2; 459 currentPalette = 2;
460 460
461 } else { 461 } else {
462 if ( currentPalette == 3 ) return; 462 if ( currentPalette == 3 ) return;
463 setPalette( mNonPrimaryPalette ); 463 setPalette( mNonPrimaryPalette );
464 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 464 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
465 //mLabel->setPalette( mNonPrimaryPalette );; 465 //mLabel->setPalette( mNonPrimaryPalette );;
466 currentPalette = 3; 466 currentPalette = 3;
467 } 467 }
468 } 468 }
469 //QPalette pal = palette(); 469 //QPalette pal = palette();
470 470
471 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 471 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
472} 472}
473QPalette MonthViewCell::getPalette () 473QPalette MonthViewCell::getPalette ()
474{ 474{
475 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 475 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
476 return mStandardPalette; 476 return mStandardPalette;
477 if ( mHoliday) { 477 if ( mHoliday) {
478 return mHolidayPalette ; 478 return mHolidayPalette ;
479 } else { 479 } else {
480 if ( mPrimary ) { 480 if ( mPrimary ) {
481 return mPrimaryPalette ; 481 return mPrimaryPalette ;
482 } 482 }
483 } 483 }
484 return mNonPrimaryPalette; 484 return mNonPrimaryPalette;
485} 485}
486bool MonthViewCell::isPrimary() const 486bool MonthViewCell::isPrimary() const
487{ 487{
488 return mPrimary; 488 return mPrimary;
489} 489}
490 490
491void MonthViewCell::setHoliday( bool holiday ) 491void MonthViewCell::setHoliday( bool holiday )
492{ 492{
493 mHoliday = holiday; 493 mHoliday = holiday;
494 //setMyPalette(); 494 //setMyPalette();
495} 495}
496 496
497void MonthViewCell::setHoliday( const QString &holiday ) 497void MonthViewCell::setHoliday( const QString &holiday )
498{ 498{
499 mHolidayString = holiday; 499 mHolidayString = holiday;
500 500
501 if ( !holiday.isEmpty() ) { 501 if ( !holiday.isEmpty() ) {
502 setHoliday( true ); 502 setHoliday( true );
503 } 503 }
504} 504}
505 505
506void MonthViewCell::startUpdateCell() 506void MonthViewCell::startUpdateCell()
507{ 507{
508 508
509 setFocusPolicy(NoFocus); 509 setFocusPolicy(NoFocus);
510 if ( !mMonthView->isUpdatePossible() ) 510 if ( !mMonthView->isUpdatePossible() )
511 return; 511 return;
512 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 512 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
513 while ( mitem ) { 513 while ( mitem ) {
514 mitem->setBlockRepaint( true ); 514 mitem->setBlockRepaint( true );
515 mitem = (MonthViewItem *)mitem->next(); 515 mitem = (MonthViewItem *)mitem->next();
516 } 516 }
517 if ( mAvailItemList.count() > 20 ) {
518 mAvailItemList.setAutoDelete( true );
519 mAvailItemList.clear();
520 mAvailItemList.setAutoDelete( false );
521 }
517 /* 522 /*
518 if ( !isVisible() ){ 523 if ( !isVisible() ){
519 return; 524 return;
520 } 525 }
521 */ 526 */
522 // qDebug("MonthViewCell::updateCell() "); 527 // qDebug("MonthViewCell::updateCell() ");
523 setPrimary( mDate.month()%2 ); 528 setPrimary( mDate.month()%2 );
524 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 529 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
525 if ( mDate == QDate::currentDate() ) { 530 if ( mDate == QDate::currentDate() ) {
526 setLineWidth( 3 ); 531 setLineWidth( 3 );
527 } else { 532 } else {
528 setLineWidth( 1 ); 533 setLineWidth( 1 );
529 } 534 }
530 mCurrentAvailItem = (MonthViewItem*) firstItem (); 535 mCurrentAvailItem = (MonthViewItem*) firstItem ();
531 //clear(); 536 //clear();
532 537
533#ifdef DESKTOP_VERSION 538#ifdef DESKTOP_VERSION
534 QToolTip::remove(this); 539 QToolTip::remove(this);
535#endif 540#endif
536 mToolTip.clear(); 541 mToolTip.clear();
537 //qApp->processEvents(); 542 //qApp->processEvents();
538#if 0 543#if 0
539 if ( !mHolidayString.isEmpty() ) { 544 if ( !mHolidayString.isEmpty() ) {
540 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 545 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
541 item->setPalette( mHolidayPalette ); 546 item->setPalette( mHolidayPalette );
542 insertItem( item ); 547 insertItem( item );
543 mToolTip.append ( mHolidayString ); 548 mToolTip.append ( mHolidayString );
544 } 549 }
545#endif 550#endif
546} 551}
547 552
548void MonthViewCell::insertEvent(Event *event) 553void MonthViewCell::insertEvent(Event *event)
549{ 554{
550 QString mToolTipText; 555 QString mToolTipText;
551 bool insertNewItem = false; 556 bool insertNewItem = false;
552 setFocusPolicy(WheelFocus); 557 setFocusPolicy(WheelFocus);
553 if ( !(event->doesRecur() == Recurrence::rNone) ) { 558 if ( !(event->doesRecur() == Recurrence::rNone) ) {
554 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 559 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
555 return; 560 return;
556 else 561 else
557 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 562 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
558 return; 563 return;
559 } 564 }
560 565
561 if ( event->isHoliday()) { 566 if ( event->isHoliday()) {
562 setHoliday( true ); 567 setHoliday( true );
563 if ( mDate.dayOfWeek() == 7 ) 568 if ( mDate.dayOfWeek() == 7 )
564 setLineWidth( 3 ); 569 setLineWidth( 3 );
565 } 570 }
566 QString text; 571 QString text;
567 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 572 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
568 if (event->isMultiDay()) { 573 if (event->isMultiDay()) {
569 QString prefix = "<->";multiday = 2; 574 QString prefix = "<->";multiday = 2;
570 QString time; 575 QString time;
571 if ( event->doesRecur() ) { 576 if ( event->doesRecur() ) {
572 if ( event->recursOn( mDate) ) { 577 if ( event->recursOn( mDate) ) {
573 prefix ="->" ;multiday = 1; 578 prefix ="->" ;multiday = 1;
574 } 579 }
575 else { 580 else {
576 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 581 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
577 if ( event->recursOn( mDate.addDays( -days)) ) { 582 if ( event->recursOn( mDate.addDays( -days)) ) {
578 prefix ="<-" ;multiday = 3; 583 prefix ="<-" ;multiday = 3;
579 } 584 }
580 } 585 }
581 586
582 } else { 587 } else {
583 if (mDate == event->dtStart().date()) { 588 if (mDate == event->dtStart().date()) {
584 prefix ="->" ;multiday = 1; 589 prefix ="->" ;multiday = 1;
585 } else if (mDate == event->dtEnd().date()) { 590 } else if (mDate == event->dtEnd().date()) {
586 prefix ="<-" ;multiday = 3; 591 prefix ="<-" ;multiday = 3;
587 } 592 }
588 } 593 }
589 if ( !event->doesFloat() ) { 594 if ( !event->doesFloat() ) {
590 if ( mDate == event->dtStart().date () ) 595 if ( mDate == event->dtStart().date () )
591 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 596 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
592 else if ( mDate == event->dtEnd().date () ) 597 else if ( mDate == event->dtEnd().date () )
593 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 598 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
594 599
595 } 600 }
596 text = time + event->summary(); 601 text = time + event->summary();
597 mToolTipText += prefix + text; 602 mToolTipText += prefix + text;
598 } else { 603 } else {
599 if (event->doesFloat()) { 604 if (event->doesFloat()) {
600 text = event->summary(); 605 text = event->summary();
601 mToolTipText += text; 606 mToolTipText += text;
602 } 607 }
603 else { 608 else {
604 text = KGlobal::locale()->formatTime(event->dtStart().time()); 609 text = KGlobal::locale()->formatTime(event->dtStart().time());
605 text += " " + event->summary(); 610 text += " " + event->summary();
606 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 611 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
607 } 612 }
608 } 613 }
609 MonthViewItem *item ; 614 MonthViewItem *item ;
610 if ( mCurrentAvailItem ) { 615 if ( mCurrentAvailItem ) {
611 item = mCurrentAvailItem; 616 item = mCurrentAvailItem;
612 mCurrentAvailItem = (MonthViewItem*) item->next(); 617 mCurrentAvailItem = (MonthViewItem*) item->next();
@@ -724,200 +729,200 @@ void MonthViewCell::insertTodo(Todo *todo)
724 item->setMoreInfo( todo->description().length() > 0 ); 729 item->setMoreInfo( todo->description().length() > 0 );
725 if ( insertNewItem) 730 if ( insertNewItem)
726 insertItem( item ); 731 insertItem( item );
727 mToolTip.append( text ); 732 mToolTip.append( text );
728} 733}
729void MonthViewCell::repaintfinishUpdateCell() 734void MonthViewCell::repaintfinishUpdateCell()
730{ 735{
731 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 736 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
732 while ( mitem ) { 737 while ( mitem ) {
733 mitem->setBlockRepaint( false ); 738 mitem->setBlockRepaint( false );
734 updateItem ( mitem ); 739 updateItem ( mitem );
735 mitem = (MonthViewItem *)mitem->next(); 740 mitem = (MonthViewItem *)mitem->next();
736 } 741 }
737} 742}
738void MonthViewCell::finishUpdateCell() 743void MonthViewCell::finishUpdateCell()
739{ 744{
740 while ( mCurrentAvailItem ) { 745 while ( mCurrentAvailItem ) {
741 MonthViewItem *item = mCurrentAvailItem; 746 MonthViewItem *item = mCurrentAvailItem;
742 mCurrentAvailItem = (MonthViewItem *)item->next(); 747 mCurrentAvailItem = (MonthViewItem *)item->next();
743 mAvailItemList.append( item ); 748 mAvailItemList.append( item );
744 takeItem ( item ); 749 takeItem ( item );
745 } 750 }
746 751
747 752
748#ifdef DESKTOP_VERSION 753#ifdef DESKTOP_VERSION
749 if (mToolTip.count() > 0 ) { 754 if (mToolTip.count() > 0 ) {
750 mToolTip.sort(); 755 mToolTip.sort();
751 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 756 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
752 } 757 }
753#endif 758#endif
754 sort(); 759 sort();
755 //setMyPalette(); 760 //setMyPalette();
756 setMyPalette(); 761 setMyPalette();
757 762
758 resizeEvent( 0 ); 763 resizeEvent( 0 );
759 764
760} 765}
761void MonthViewCell::updateCell() 766void MonthViewCell::updateCell()
762{ 767{
763 //qDebug("MonthViewCell::updateCell() "); 768 //qDebug("MonthViewCell::updateCell() ");
764 if ( !mMonthView->isUpdatePossible() ) 769 if ( !mMonthView->isUpdatePossible() )
765 return; 770 return;
766 startUpdateCell(); 771 startUpdateCell();
767 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 772 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
768 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 773 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
769 Event *event; 774 Event *event;
770 for( event = events.first(); event; event = events.next() ) { // for event 775 for( event = events.first(); event; event = events.next() ) { // for event
771 insertEvent(event); 776 insertEvent(event);
772 } 777 }
773 // insert due todos 778 // insert due todos
774 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 779 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
775 Todo *todo; 780 Todo *todo;
776 for(todo = todos.first(); todo; todo = todos.next()) { 781 for(todo = todos.first(); todo; todo = todos.next()) {
777 insertTodo( todo ); 782 insertTodo( todo );
778 } 783 }
779 finishUpdateCell(); 784 finishUpdateCell();
780 // if ( isVisible()) 785 // if ( isVisible())
781 //qApp->processEvents(); 786 //qApp->processEvents();
782} 787}
783 788
784void MonthViewCell::updateConfig( bool bigFont ) // = false 789void MonthViewCell::updateConfig( bool bigFont ) // = false
785{ 790{
786 791
787 if ( bigFont ) { 792 if ( bigFont ) {
788 QFont fo = KOPrefs::instance()->mMonthViewFont; 793 QFont fo = KOPrefs::instance()->mMonthViewFont;
789 int ps = fo.pointSize() + 2; 794 int ps = fo.pointSize() + 2;
790 if ( ps < 18 ) 795 if ( ps < 18 )
791 ps += 2; 796 ps += 2;
792 fo.setPointSize( ps ); 797 fo.setPointSize( ps );
793 setFont( fo ); 798 setFont( fo );
794 } else 799 } else
795 setFont( KOPrefs::instance()->mMonthViewFont ); 800 setFont( KOPrefs::instance()->mMonthViewFont );
796 801
797 QFontMetrics fm( font() ); 802 QFontMetrics fm( font() );
798 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 803 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
799 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 804 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
800 mHolidayPalette = mStandardPalette; 805 mHolidayPalette = mStandardPalette;
801 mPrimaryPalette = mStandardPalette; 806 mPrimaryPalette = mStandardPalette;
802 mNonPrimaryPalette = mStandardPalette; 807 mNonPrimaryPalette = mStandardPalette;
803 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 808 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
804 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 809 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
805 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 810 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
806 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 811 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
807 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 812 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
808 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 813 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
809 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 814 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
810 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 815 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
811 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 816 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
812 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 817 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
813 } 818 }
814 //updateCell(); 819 //updateCell();
815} 820}
816 821
817void MonthViewCell::enableScrollBars( bool enabled ) 822void MonthViewCell::enableScrollBars( bool enabled )
818{ 823{
819 if ( enabled ) { 824 if ( enabled ) {
820
821 QListBoxItem *fi = firstItem (); 825 QListBoxItem *fi = firstItem ();
822 if (fi ) { 826 if (fi ) {
823 int ihei = fi->height( this ); 827 int ihei = fi->height( this );
824 int hei = numRows () * ihei; 828 int hei = numRows () * ihei;
825 if ( hei < height() - horizontalScrollBar()->height () ) 829 if ( hei < height() - horizontalScrollBar()->height () ) {
826 setVScrollBarMode(QScrollView::AlwaysOff); 830 setVScrollBarMode(QScrollView::AlwaysOff);
827 else 831 }
832 else
828 setVScrollBarMode(QScrollView::Auto); 833 setVScrollBarMode(QScrollView::Auto);
829 if ( ihei *3 > height() ) 834 if ( ihei *3 > height() )
830 setHScrollBarMode(QScrollView::AlwaysOff); 835 setHScrollBarMode(QScrollView::AlwaysOff);
831 else 836 else
832 setHScrollBarMode(QScrollView::Auto); 837 setHScrollBarMode(QScrollView::Auto);
833 } else { 838 } else {
834 setVScrollBarMode(QScrollView::Auto); 839 setVScrollBarMode(QScrollView::Auto);
835 setHScrollBarMode(QScrollView::Auto); 840 setHScrollBarMode(QScrollView::Auto);
836 } 841 }
837 } else { 842 } else {
838 setVScrollBarMode(QScrollView::AlwaysOff); 843 setVScrollBarMode(QScrollView::AlwaysOff);
839 setHScrollBarMode(QScrollView::AlwaysOff); 844 setHScrollBarMode(QScrollView::AlwaysOff);
840 } 845 }
841} 846}
842 847
843Incidence *MonthViewCell::selectedIncidence() 848Incidence *MonthViewCell::selectedIncidence()
844{ 849{
845 int index = currentItem(); 850 int index = currentItem();
846 if ( index < 0 ) return 0; 851 if ( index < 0 ) return 0;
847 852
848 MonthViewItem *mitem = 853 MonthViewItem *mitem =
849 static_cast<MonthViewItem *>( item( index ) ); 854 static_cast<MonthViewItem *>( item( index ) );
850 855
851 if ( !mitem ) return 0; 856 if ( !mitem ) return 0;
852 857
853 return mitem->incidence(); 858 return mitem->incidence();
854} 859}
855 860
856QDate MonthViewCell::selectedIncidenceDate() 861QDate MonthViewCell::selectedIncidenceDate()
857{ 862{
858 QDate qd; 863 QDate qd;
859 int index = currentItem(); 864 int index = currentItem();
860 if ( index < 0 ) return qd; 865 if ( index < 0 ) return qd;
861 866
862 MonthViewItem *mitem = 867 MonthViewItem *mitem =
863 static_cast<MonthViewItem *>( item( index ) ); 868 static_cast<MonthViewItem *>( item( index ) );
864 869
865 if ( !mitem ) return qd; 870 if ( !mitem ) return qd;
866 871
867 return mitem->incidenceDate(); 872 return mitem->incidenceDate();
868} 873}
869 874
870void MonthViewCell::deselect() 875void MonthViewCell::deselect()
871{ 876{
872 clearSelection(); 877 clearSelection();
873 enableScrollBars( false ); 878 enableScrollBars( false );
874 // updateCell(); 879 // updateCell();
875} 880}
876void MonthViewCell::select() 881void MonthViewCell::select()
877{ 882{
878 ;// updateCell(); 883 ;// updateCell();
879} 884}
880 885
881void MonthViewCell::resizeEvent ( QResizeEvent * e ) 886void MonthViewCell::resizeEvent ( QResizeEvent * e )
882{ 887{
883 if ( !mMonthView->isUpdatePossible() ) 888 if ( !mMonthView->isUpdatePossible() )
884 return; 889 return;
885 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 890 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
886 deselect(); 891 deselect();
887 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 892 mLabel->setMaximumHeight( height() - lineWidth()*2 );
888 893
889 QString text; 894 QString text;
890 mLabel->setText( text ); 895 mLabel->setText( text );
891 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 896 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
892 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 897 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
893 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 898 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
894 mLabel->resize( mLabelBigSize ); 899 mLabel->resize( mLabelBigSize );
895 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 900 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
896 } else { 901 } else {
897 mLabel->resize( mLabelSize ); 902 mLabel->resize( mLabelSize );
898 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 903 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
899 } 904 }
900 mLabel->setText( text ); 905 mLabel->setText( text );
901 906
902 int size = height() - mLabel->height() - lineWidth()-1; 907 int size = height() - mLabel->height() - lineWidth()-1;
903 //qDebug("LW %d ", lineWidth()); 908 //qDebug("LW %d ", lineWidth());
904 if ( size > 0 ) 909 if ( size > 0 )
905 verticalScrollBar()->setMaximumHeight( size ); 910 verticalScrollBar()->setMaximumHeight( size );
906 size = width() - mLabel->width() -lineWidth()-1; 911 size = width() - mLabel->width() -lineWidth()-1;
907 if ( size > 0 ) 912 if ( size > 0 )
908 horizontalScrollBar()->setMaximumWidth( size ); 913 horizontalScrollBar()->setMaximumWidth( size );
909 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 914 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
910 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 915 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
911 // mItemList->resize ( width(), height () ); 916 // mItemList->resize ( width(), height () );
912 if ( e ) 917 if ( e )
913 KNoScrollListBox::resizeEvent ( e ); 918 KNoScrollListBox::resizeEvent ( e );
914} 919}
915 920
916void MonthViewCell::defaultAction( QListBoxItem *item ) 921void MonthViewCell::defaultAction( QListBoxItem *item )
917{ 922{
918 if ( !item ) return; 923 if ( !item ) return;
919 924
920 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 925 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
921 Incidence *incidence = eventItem->incidence(); 926 Incidence *incidence = eventItem->incidence();
922 if ( incidence ) mMonthView->defaultAction( incidence ); 927 if ( incidence ) mMonthView->defaultAction( incidence );
923} 928}