summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-02 12:16:34 (UTC)
committer zautrix <zautrix>2005-04-02 12:16:34 (UTC)
commit997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe (patch) (unidiff)
treef788b37459574b5cea0d2ab874882c6a396c240d /korganizer
parente0d51120d2f0c178115746e0c1357af40f95bc77 (diff)
downloadkdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.zip
kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.gz
kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.bz2
more fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp57
-rw-r--r--korganizer/koagenda.h4
-rw-r--r--korganizer/koagendaview.cpp18
-rw-r--r--korganizer/koagendaview.h4
-rw-r--r--korganizer/kotodoview.cpp49
5 files changed, 97 insertions, 35 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index deadfc9..de964da 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -75,480 +75,519 @@ MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
75 QPalette pal = mTimeBox->palette(); 75 QPalette pal = mTimeBox->palette();
76 pal.setColor(QColorGroup::Foreground, Qt::red); 76 pal.setColor(QColorGroup::Foreground, Qt::red);
77 mTimeBox->setPalette(pal); 77 mTimeBox->setPalette(pal);
78 //mTimeBox->setAutoMask(true); 78 //mTimeBox->setAutoMask(true);
79 79
80 agenda->addChild(mTimeBox); 80 agenda->addChild(mTimeBox);
81 81
82 oldToday = -1; 82 oldToday = -1;
83} 83}
84 84
85MarcusBains::~MarcusBains() 85MarcusBains::~MarcusBains()
86{ 86{
87 delete minutes; 87 delete minutes;
88} 88}
89 89
90int MarcusBains::todayColumn() 90int MarcusBains::todayColumn()
91{ 91{
92 QDate currentDate = QDate::currentDate(); 92 QDate currentDate = QDate::currentDate();
93 93
94 DateList dateList = agenda->dateList(); 94 DateList dateList = agenda->dateList();
95 DateList::ConstIterator it; 95 DateList::ConstIterator it;
96 int col = 0; 96 int col = 0;
97 for(it = dateList.begin(); it != dateList.end(); ++it) { 97 for(it = dateList.begin(); it != dateList.end(); ++it) {
98 if((*it) == currentDate) 98 if((*it) == currentDate)
99 return KOGlobals::self()->reverseLayout() ? 99 return KOGlobals::self()->reverseLayout() ?
100 agenda->columns() - 1 - col : col; 100 agenda->columns() - 1 - col : col;
101 ++col; 101 ++col;
102 } 102 }
103 103
104 return -1; 104 return -1;
105} 105}
106void MarcusBains::updateLoc() 106void MarcusBains::updateLoc()
107{ 107{
108 updateLocation(); 108 updateLocation();
109} 109}
110void MarcusBains::updateLocation(bool recalculate) 110void MarcusBains::updateLocation(bool recalculate)
111{ 111{
112 112
113 QTime tim = QTime::currentTime(); 113 QTime tim = QTime::currentTime();
114 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 114 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
115 if((tim.hour() == 0) && (oldTime.hour()==23)) 115 if((tim.hour() == 0) && (oldTime.hour()==23))
116 recalculate = true; 116 recalculate = true;
117 117
118 int mins = tim.hour()*60 + tim.minute(); 118 int mins = tim.hour()*60 + tim.minute();
119 int minutesPerCell = 24 * 60 / agenda->rows(); 119 int minutesPerCell = 24 * 60 / agenda->rows();
120 int y = mins*agenda->gridSpacingY()/minutesPerCell; 120 int y = mins*agenda->gridSpacingY()/minutesPerCell;
121 int today = recalculate ? todayColumn() : oldToday; 121 int today = recalculate ? todayColumn() : oldToday;
122 int x = agenda->gridSpacingX()*today; 122 int x = agenda->gridSpacingX()*today;
123 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 123 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
124 124
125 oldTime = tim; 125 oldTime = tim;
126 oldToday = today; 126 oldToday = today;
127 127
128 if(disabled || (today<0)) { 128 if(disabled || (today<0)) {
129 hide(); mTimeBox->hide(); 129 hide(); mTimeBox->hide();
130 return; 130 return;
131 } else { 131 } else {
132 show(); mTimeBox->show(); 132 show(); mTimeBox->show();
133 } 133 }
134 134
135 if(recalculate) 135 if(recalculate)
136 setFixedSize(agenda->gridSpacingX(),1); 136 setFixedSize(agenda->gridSpacingX(),1);
137 agenda->moveChild(this, x, y); 137 agenda->moveChild(this, x, y);
138 raise(); 138 raise();
139 139
140 if(recalculate) 140 if(recalculate)
141 //mTimeBox->setFont(QFont("helvetica",10)); 141 //mTimeBox->setFont(QFont("helvetica",10));
142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
143 143
144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
145 mTimeBox->adjustSize(); 145 mTimeBox->adjustSize();
146 // the -2 below is there because there is a bug in this program 146 // the -2 below is there because there is a bug in this program
147 // somewhere, where the last column of this widget is a few pixels 147 // somewhere, where the last column of this widget is a few pixels
148 // narrower than the other columns. 148 // narrower than the other columns.
149 int offs = (today==agenda->columns()-1) ? -4 : 0; 149 int offs = (today==agenda->columns()-1) ? -4 : 0;
150 agenda->moveChild(mTimeBox, 150 agenda->moveChild(mTimeBox,
151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
152 y-mTimeBox->height()); 152 y-mTimeBox->height());
153 153
154 mTimeBox->raise(); 154 mTimeBox->raise();
155 //mTimeBox->setAutoMask(true); 155 //mTimeBox->setAutoMask(true);
156 minutes->start(5000,true); 156 minutes->start(5000,true);
157} 157}
158 158
159 159
160//////////////////////////////////////////////////////////////////////////// 160////////////////////////////////////////////////////////////////////////////
161 161
162 162
163/* 163/*
164 Create an agenda widget with rows rows and columns columns. 164 Create an agenda widget with rows rows and columns columns.
165*/ 165*/
166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
167 const char *name,WFlags f) : 167 const char *name,WFlags f) :
168 QScrollView(parent,name,f) 168 QScrollView(parent,name,f)
169{ 169{
170 170
171 171 mAllAgendaPopup = 0;
172 mColumns = columns; 172 mColumns = columns;
173 mRows = rows; 173 mRows = rows;
174 mGridSpacingY = rowSize; 174 mGridSpacingY = rowSize;
175 mAllDayMode = false; 175 mAllDayMode = false;
176#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
178#endif 178#endif
179 mHolidayMask = 0; 179 mHolidayMask = 0;
180 init(); 180 init();
181} 181}
182 182
183/* 183/*
184 Create an agenda widget with columns columns and one row. This is used for 184 Create an agenda widget with columns columns and one row. This is used for
185 all-day events. 185 all-day events.
186*/ 186*/
187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
188 QScrollView(parent,name,f) 188 QScrollView(parent,name,f)
189{ 189{
190 mAllAgendaPopup = 0;
190 blockResize = false; 191 blockResize = false;
191 mColumns = columns; 192 mColumns = columns;
192 mRows = 1; 193 mRows = 1;
193 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
194 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 195 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
195 mAllDayMode = true; 196 mAllDayMode = true;
196#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
197 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 198 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
198#endif 199#endif
199 mHolidayMask = 0; 200 mHolidayMask = 0;
200 init(); 201 init();
201} 202}
202 203
203 204
204KOAgenda::~KOAgenda() 205KOAgenda::~KOAgenda()
205{ 206{
206 if(mMarcusBains) delete mMarcusBains; 207 if(mMarcusBains) delete mMarcusBains;
207 208
208} 209}
209 210
210Incidence *KOAgenda::selectedIncidence() const 211Incidence *KOAgenda::selectedIncidence() const
211{ 212{
212 return (mSelectedItem ? mSelectedItem->incidence() : 0); 213 return (mSelectedItem ? mSelectedItem->incidence() : 0);
213} 214}
214 215
215 216
216QDate KOAgenda::selectedIncidenceDate() const 217QDate KOAgenda::selectedIncidenceDate() const
217{ 218{
218 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
219} 220}
220 221
221 222
222void KOAgenda::init() 223void KOAgenda::init()
223{ 224{
224 mPopupTimer = new QTimer(this); 225 mPopupTimer = new QTimer(this);
225 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 226 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
226 227
227 mNewItemPopup = new QPopupMenu( this ); 228 mNewItemPopup = new QPopupMenu( this );
228 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 229 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
229 QString pathString = ""; 230 QString pathString = "";
230 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 231 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
231 if ( QApplication::desktop()->width() < 480 ) 232 if ( QApplication::desktop()->width() < 480 )
232 pathString += "icons16/"; 233 pathString += "icons16/";
233 } else 234 } else
234 pathString += "iconsmini/"; 235 pathString += "iconsmini/";
235 236
236 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 238 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
238 mNewItemPopup->insertSeparator ( ); 239 mNewItemPopup->insertSeparator ( );
239 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 245 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
245#ifndef _WIN32_ 246#ifndef _WIN32_
246 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 247 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
247 viewport()->setWFlags ( wflags); 248 viewport()->setWFlags ( wflags);
248#endif 249#endif
249 mGridSpacingX = 80; 250 mGridSpacingX = 80;
250 mResizeBorderWidth = 8; 251 mResizeBorderWidth = 8;
251 mScrollBorderWidth = 8; 252 mScrollBorderWidth = 8;
252 mScrollDelay = 30; 253 mScrollDelay = 30;
253 mScrollOffset = 10; 254 mScrollOffset = 10;
254 mPaintPixmap.resize( 20,20); 255 mPaintPixmap.resize( 20,20);
255 //enableClipper(true); 256 //enableClipper(true);
256 257
257 // Grab key strokes for keyboard navigation of agenda. Seems to have no 258 // Grab key strokes for keyboard navigation of agenda. Seems to have no
258 // effect. Has to be fixed. 259 // effect. Has to be fixed.
259 setFocusPolicy(WheelFocus); 260 setFocusPolicy(WheelFocus);
260 261
261 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 262 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
262 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 263 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
263 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 264 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
264 265
265 mStartCellX = 0; 266 mStartCellX = 0;
266 mStartCellY = 0; 267 mStartCellY = 0;
267 mCurrentCellX = 0; 268 mCurrentCellX = 0;
268 mCurrentCellY = 0; 269 mCurrentCellY = 0;
269 270
270 mSelectionCellX = 0; 271 mSelectionCellX = 0;
271 mSelectionYTop = 0; 272 mSelectionYTop = 0;
272 mSelectionHeight = 0; 273 mSelectionHeight = 0;
273 274
274 mOldLowerScrollValue = -1; 275 mOldLowerScrollValue = -1;
275 mOldUpperScrollValue = -1; 276 mOldUpperScrollValue = -1;
276 277
277 mClickedItem = 0; 278 mClickedItem = 0;
278 279
279 mActionItem = 0; 280 mActionItem = 0;
280 mActionType = NOP; 281 mActionType = NOP;
281 mItemMoved = false; 282 mItemMoved = false;
282 283
283 mSelectedItem = 0; 284 mSelectedItem = 0;
284 285
285 // mItems.setAutoDelete(true); 286 // mItems.setAutoDelete(true);
286 287
287 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 288 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
288 289
289 viewport()->update(); 290 viewport()->update();
290 291
291 setMinimumSize(30, 1); 292 setMinimumSize(30, 1);
292// setMaximumHeight(mGridSpacingY * mRows + 5); 293// setMaximumHeight(mGridSpacingY * mRows + 5);
293 294
294 // Disable horizontal scrollbar. This is a hack. The geometry should be 295 // Disable horizontal scrollbar. This is a hack. The geometry should be
295 // controlled in a way that the contents horizontally always fits. Then it is 296 // controlled in a way that the contents horizontally always fits. Then it is
296 // not necessary to turn off the scrollbar. 297 // not necessary to turn off the scrollbar.
297 setHScrollBarMode(AlwaysOff); 298 setHScrollBarMode(AlwaysOff);
298 if ( ! mAllDayMode ) 299 if ( ! mAllDayMode )
299 setVScrollBarMode(AlwaysOn); 300 setVScrollBarMode(AlwaysOn);
300 else 301 else
301 setVScrollBarMode(AlwaysOff); 302 setVScrollBarMode(AlwaysOff);
302 303
303 setStartHour(KOPrefs::instance()->mDayBegins); 304 setStartHour(KOPrefs::instance()->mDayBegins);
304 305
305 calculateWorkingHours(); 306 calculateWorkingHours();
306 307
307 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 308 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
308 SLOT(checkScrollBoundaries(int))); 309 SLOT(checkScrollBoundaries(int)));
309 310
310 // Create the Marcus Bains line. 311 // Create the Marcus Bains line.
311 if(mAllDayMode) 312 if(mAllDayMode)
312 mMarcusBains = 0; 313 mMarcusBains = 0;
313 else { 314 else {
314 mMarcusBains = new MarcusBains(this); 315 mMarcusBains = new MarcusBains(this);
315 addChild(mMarcusBains); 316 addChild(mMarcusBains);
316 } 317 }
317 mPopupKind = 0; 318 mPopupKind = 0;
318 mPopupItem = 0; 319 mPopupItem = 0;
319} 320}
320 321
321void KOAgenda::clear() 322void KOAgenda::clear()
322{ 323{
323 KOAgendaItem *item; 324 KOAgendaItem *item;
324 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 325 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
325 mUnusedItems.append( item ); 326 mUnusedItems.append( item );
326 //item->hide(); 327 //item->hide();
327 } 328 }
328 mItems.clear(); 329 mItems.clear();
329 mSelectedItem = 0; 330 mSelectedItem = 0;
330 clearSelection(); 331 clearSelection();
331} 332}
332 333
333void KOAgenda::clearSelection() 334void KOAgenda::clearSelection()
334{ 335{
335 mSelectionCellX = 0; 336 mSelectionCellX = 0;
336 mSelectionYTop = 0; 337 mSelectionYTop = 0;
337 mSelectionHeight = 0; 338 mSelectionHeight = 0;
338} 339}
339 340
340void KOAgenda::marcus_bains() 341void KOAgenda::marcus_bains()
341{ 342{
342 if(mMarcusBains) mMarcusBains->updateLocation(true); 343 if(mMarcusBains) mMarcusBains->updateLocation(true);
343} 344}
344 345
345 346
346void KOAgenda::changeColumns(int columns) 347void KOAgenda::changeColumns(int columns)
347{ 348{
348 if (columns == 0) { 349 if (columns == 0) {
349 qDebug("KOAgenda::changeColumns() called with argument 0 "); 350 qDebug("KOAgenda::changeColumns() called with argument 0 ");
350 return; 351 return;
351 } 352 }
352 clear(); 353 clear();
353 mColumns = columns; 354 mColumns = columns;
354 computeSizes(); 355 computeSizes();
355} 356}
356 357
357/* 358/*
358 This is the eventFilter function, which gets all events from the KOAgendaItems 359 This is the eventFilter function, which gets all events from the KOAgendaItems
359 contained in the agenda. It has to handle moving and resizing for all items. 360 contained in the agenda. It has to handle moving and resizing for all items.
360*/ 361*/
361bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 362bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
362{ 363{
363 // kdDebug() << "KOAgenda::eventFilter" << endl; 364 // kdDebug() << "KOAgenda::eventFilter" << endl;
364 switch(event->type()) { 365 switch(event->type()) {
365 case QEvent::MouseButtonPress: 366 case QEvent::MouseButtonPress:
366 case QEvent::MouseButtonDblClick: 367 case QEvent::MouseButtonDblClick:
367 case QEvent::MouseButtonRelease: 368 case QEvent::MouseButtonRelease:
368 case QEvent::MouseMove: 369 case QEvent::MouseMove:
369 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
370 371
371 case (QEvent::Leave): 372 case (QEvent::Leave):
372 if (!mActionItem) 373 if (!mActionItem)
373 setCursor(arrowCursor); 374 setCursor(arrowCursor);
374 return true; 375 return true;
375 376
376 default: 377 default:
377 return QScrollView::eventFilter(object,event); 378 return QScrollView::eventFilter(object,event);
378 } 379 }
379} 380}
380void KOAgenda::popupMenu() 381void KOAgenda::popupMenu()
381{ 382{
382 mPopupTimer->stop(); 383 mPopupTimer->stop();
383 if ( mPopupKind == 1 ) { 384 if ( mPopupKind == 1 ) {
384 if (mActionItem ) { 385 if (mActionItem ) {
385 endItemAction(); 386 endItemAction();
386 } 387 }
387 mLeftMouseDown = false; // no more leftMouse computation 388 mLeftMouseDown = false; // no more leftMouse computation
388 if (mPopupItem) { 389 if (mPopupItem) {
389 selectItem(mPopupItem); 390 selectItem(mPopupItem);
391 if ( mAllAgendaPopup )
392 mAllAgendaPopup->installEventFilter( this );
390 emit showIncidencePopupSignal(mPopupItem->incidence()); 393 emit showIncidencePopupSignal(mPopupItem->incidence());
391 394
392 } 395 }
393 } else if ( mPopupKind == 2 ) { 396 } else if ( mPopupKind == 2 ) {
394 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 397 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
395 endSelectAction( false ); // do not emit new event signal 398 endSelectAction( false ); // do not emit new event signal
396 mLeftMouseDown = false; // no more leftMouse computation 399 mLeftMouseDown = false; // no more leftMouse computation
397 } 400 }
401 mNewItemPopup->installEventFilter( this );
398 mNewItemPopup->popup( mPopupPos); 402 mNewItemPopup->popup( mPopupPos);
403
399 } 404 }
400 mLeftMouseDown = false; 405 mLeftMouseDown = false;
401 mPopupItem = 0; 406 mPopupItem = 0;
402 mPopupKind = 0; 407 mPopupKind = 0;
403} 408}
404 409
405bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 410bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
406{ 411{
407 //qDebug("KOAgenda::eventFilter_mous "); 412 static int startX = 0;
413 static int startY = 0;
414 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
415 static bool blockMoving = true;
416
417 //qDebug("KOAgenda::eventFilter_mous ");
418 if ( object == mNewItemPopup ) {
419 //qDebug("mNewItemPopup ");
420 if ( me->type() == QEvent::MouseButtonRelease ) {
421 mNewItemPopup->removeEventFilter( this );
422 int dX = me->globalPos().x() - mPopupPos.x();;
423 if ( dX < 0 )
424 dX = -dX;
425 int dY = me->globalPos().y() - mPopupPos.y();
426 if ( dY < 0 )
427 dY = -dY;
428 if ( dX > blockmoveDist || dY > blockmoveDist ) {
429 mNewItemPopup->hide();
430 }
431 }
432 return true;
433 }
434 if ( object == mAllAgendaPopup ) {
435 //qDebug(" mAllAgendaPopup ");
436 if ( me->type() == QEvent::MouseButtonRelease ) {
437 mAllAgendaPopup->removeEventFilter( this );
438 int dX = me->globalPos().x() - mPopupPos.x();;
439 if ( dX < 0 )
440 dX = -dX;
441 int dY = me->globalPos().y() - mPopupPos.y();
442 if ( dY < 0 )
443 dY = -dY;
444 if ( dX > blockmoveDist || dY > blockmoveDist ) {
445 mAllAgendaPopup->hide();
446 }
447 }
448 return true;
449 }
408 QPoint viewportPos; 450 QPoint viewportPos;
409 if (object != viewport()) { 451 if (object != viewport()) {
410 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 452 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
411 } else { 453 } else {
412 viewportPos = me->pos(); 454 viewportPos = me->pos();
413 } 455 }
414 static int startX = 0; 456
415 static int startY = 0;
416 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
417 static bool blockMoving = true;
418 switch (me->type()) { 457 switch (me->type()) {
419 case QEvent::MouseButtonPress: 458 case QEvent::MouseButtonPress:
420 if (me->button() == LeftButton) { 459 if (me->button() == LeftButton) {
421 mPopupTimer->start( 600 ); 460 mPopupTimer->start( 600 );
422 mLeftMouseDown = true; 461 mLeftMouseDown = true;
423 } 462 }
424 blockMoving = true; 463 blockMoving = true;
425 startX = viewportPos.x(); 464 startX = viewportPos.x();
426 startY = viewportPos.y(); 465 startY = viewportPos.y();
466 mPopupPos = me->globalPos();
427 if (object != viewport()) { 467 if (object != viewport()) {
428 mPopupItem = (KOAgendaItem *)object; 468 mPopupItem = (KOAgendaItem *)object;
429 mPopupKind = 1; 469 mPopupKind = 1;
430 if (me->button() == RightButton) { 470 if (me->button() == RightButton) {
431 popupMenu(); 471 popupMenu();
432 } else if (me->button() == LeftButton) { 472 } else if (me->button() == LeftButton) {
433 mActionItem = (KOAgendaItem *)object; 473 mActionItem = (KOAgendaItem *)object;
434 if (mActionItem) { 474 if (mActionItem) {
435 if ( mSelectionHeight > 0 ) { 475 if ( mSelectionHeight > 0 ) {
436 int selectionCellX = mSelectionCellX * mGridSpacingX; 476 int selectionCellX = mSelectionCellX * mGridSpacingX;
437 int selectionYTop = mSelectionYTop; 477 int selectionYTop = mSelectionYTop;
438 int gridSpacingX = mGridSpacingX; 478 int gridSpacingX = mGridSpacingX;
439 int selectionHeight = mSelectionHeight; 479 int selectionHeight = mSelectionHeight;
440 clearSelection(); 480 clearSelection();
441 repaintContents( selectionCellX, selectionYTop, 481 repaintContents( selectionCellX, selectionYTop,
442 gridSpacingX, selectionHeight,false ); 482 gridSpacingX, selectionHeight,false );
443 } 483 }
444 selectItem(mActionItem); 484 selectItem(mActionItem);
445 Incidence *incidence = mActionItem->incidence(); 485 Incidence *incidence = mActionItem->incidence();
446 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 486 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
447 mActionItem = 0; 487 mActionItem = 0;
448 } else { 488 } else {
449 startItemAction(viewportPos); 489 startItemAction(viewportPos);
450 } 490 }
451 } 491 }
452 } 492 }
453 } else { // ---------- viewport() 493 } else { // ---------- viewport()
454 mPopupItem = 0; 494 mPopupItem = 0;
455 mPopupKind = 2; 495 mPopupKind = 2;
456 selectItem(0); 496 selectItem(0);
457 mActionItem = 0; 497 mActionItem = 0;
458 mPopupPos = viewport()->mapToGlobal( me->pos() );
459 if (me->button() == RightButton) { 498 if (me->button() == RightButton) {
460 int x,y; 499 int x,y;
461 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 500 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
462 int gx,gy; 501 int gx,gy;
463 contentsToGrid(x,y,gx,gy); 502 contentsToGrid(x,y,gx,gy);
464 mCurrentCellX = gx; 503 mCurrentCellX = gx;
465 mCurrentCellY = gy; 504 mCurrentCellY = gy;
466 mStartCellX = gx; 505 mStartCellX = gx;
467 mStartCellY = gy; 506 mStartCellY = gy;
468 popupMenu(); 507 popupMenu();
469 } else if (me->button() == LeftButton) { 508 } else if (me->button() == LeftButton) {
470 setCursor(arrowCursor); 509 setCursor(arrowCursor);
471 startSelectAction(viewportPos); 510 startSelectAction(viewportPos);
472 } 511 }
473 } 512 }
474 break; 513 break;
475 514
476 case QEvent::MouseButtonRelease: 515 case QEvent::MouseButtonRelease:
477 if (me->button() == LeftButton ) { 516 if (me->button() == LeftButton ) {
478 mPopupTimer->stop(); 517 mPopupTimer->stop();
479 } 518 }
480 if (object != viewport()) { 519 if (object != viewport()) {
481 if (me->button() == LeftButton && mLeftMouseDown) { 520 if (me->button() == LeftButton && mLeftMouseDown) {
482 if (mActionItem) { 521 if (mActionItem) {
483 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 522 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
484 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 523 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
485 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 524 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
486 mScrollUpTimer.stop(); 525 mScrollUpTimer.stop();
487 mScrollDownTimer.stop(); 526 mScrollDownTimer.stop();
488 mActionItem->resetMove(); 527 mActionItem->resetMove();
489 placeSubCells( mActionItem ); 528 placeSubCells( mActionItem );
490 // emit startDragSignal( mActionItem->incidence() ); 529 // emit startDragSignal( mActionItem->incidence() );
491 setCursor( arrowCursor ); 530 setCursor( arrowCursor );
492 mActionItem = 0; 531 mActionItem = 0;
493 mActionType = NOP; 532 mActionType = NOP;
494 mItemMoved = 0; 533 mItemMoved = 0;
495 mLeftMouseDown = false; 534 mLeftMouseDown = false;
496 return true; 535 return true;
497 } 536 }
498 endItemAction(); 537 endItemAction();
499 } 538 }
500 } 539 }
501 540
502 } else { // ---------- viewport() 541 } else { // ---------- viewport()
503 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 542 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
504 endSelectAction( true ); // emit new event signal 543 endSelectAction( true ); // emit new event signal
505 } 544 }
506 } 545 }
507 if (me->button() == LeftButton) 546 if (me->button() == LeftButton)
508 mLeftMouseDown = false; 547 mLeftMouseDown = false;
509 548
510 break; 549 break;
511 550
512 case QEvent::MouseMove: 551 case QEvent::MouseMove:
513 //qDebug("mm "); 552 //qDebug("mm ");
514 if ( !mLeftMouseDown ) 553 if ( !mLeftMouseDown )
515 return false; 554 return false;
516 if ( blockMoving ) { 555 if ( blockMoving ) {
517 int dX, dY; 556 int dX, dY;
518 dX = startX - viewportPos.x(); 557 dX = startX - viewportPos.x();
519 if ( dX < 0 ) 558 if ( dX < 0 )
520 dX = -dX; 559 dX = -dX;
521 dY = viewportPos.y() - startY; 560 dY = viewportPos.y() - startY;
522 if ( dY < 0 ) 561 if ( dY < 0 )
523 dY = -dY; 562 dY = -dY;
524 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 563 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
525 if ( dX > blockmoveDist || dY > blockmoveDist ) { 564 if ( dX > blockmoveDist || dY > blockmoveDist ) {
526 blockMoving = false; 565 blockMoving = false;
527 } 566 }
528 } 567 }
529 if ( ! blockMoving ) 568 if ( ! blockMoving )
530 mPopupTimer->stop(); 569 mPopupTimer->stop();
531 if (object != viewport()) { 570 if (object != viewport()) {
532 KOAgendaItem *moveItem = (KOAgendaItem *)object; 571 KOAgendaItem *moveItem = (KOAgendaItem *)object;
533 if (!moveItem->incidence()->isReadOnly() ) { 572 if (!moveItem->incidence()->isReadOnly() ) {
534 if (!mActionItem) 573 if (!mActionItem)
535 setNoActionCursor(moveItem,viewportPos); 574 setNoActionCursor(moveItem,viewportPos);
536 else { 575 else {
537 if ( !blockMoving ) 576 if ( !blockMoving )
538 performItemAction(viewportPos); 577 performItemAction(viewportPos);
539 } 578 }
540 } 579 }
541 } else { // ---------- viewport() 580 } else { // ---------- viewport()
542 mPopupPos = viewport()->mapToGlobal( me->pos() ); 581 mPopupPos = viewport()->mapToGlobal( me->pos() );
543 if ( mActionType == SELECT ) { 582 if ( mActionType == SELECT ) {
544 performSelectAction( viewportPos ); 583 performSelectAction( viewportPos );
545 } 584 }
546 } 585 }
547 break; 586 break;
548 587
549 case QEvent::MouseButtonDblClick: 588 case QEvent::MouseButtonDblClick:
550 mPopupTimer->stop(); 589 mPopupTimer->stop();
551 if (object == viewport()) { 590 if (object == viewport()) {
552 selectItem(0); 591 selectItem(0);
553 int x,y; 592 int x,y;
554 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 593 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 35c08b6..4f1fdb9 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -1,266 +1,268 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDA_H 23#ifndef KOAGENDA_H
24#define KOAGENDA_H 24#define KOAGENDA_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qmemarray.h> 28#include <qmemarray.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qpixmap.h> 30#include <qpixmap.h>
31#include <qguardedptr.h> 31#include <qguardedptr.h>
32 32
33#include "koagendaitem.h" 33#include "koagendaitem.h"
34#include "koeventview.h"
34 35
35class QPopupMenu; 36class QPopupMenu;
36class QTime; 37class QTime;
37class KConfig; 38class KConfig;
38class QFrame; 39class QFrame;
39class KOAgenda; 40class KOAgenda;
40class KCal::Event; 41class KCal::Event;
41class KCal::Todo; 42class KCal::Todo;
42 43
43using namespace KCal; 44using namespace KCal;
44 45
45class MarcusBains : public QFrame { 46class MarcusBains : public QFrame {
46 Q_OBJECT 47 Q_OBJECT
47 public: 48 public:
48 MarcusBains(KOAgenda *agenda=0,const char *name=0); 49 MarcusBains(KOAgenda *agenda=0,const char *name=0);
49 virtual ~MarcusBains(); 50 virtual ~MarcusBains();
50 51
51 public slots: 52 public slots:
52 void updateLocation(bool recalculate=false); 53 void updateLocation(bool recalculate=false);
53 void updateLoc(); 54 void updateLoc();
54 55
55 private: 56 private:
56 int todayColumn(); 57 int todayColumn();
57 QTimer *minutes; 58 QTimer *minutes;
58 QLabel *mTimeBox; 59 QLabel *mTimeBox;
59 KOAgenda *agenda; 60 KOAgenda *agenda;
60 QTime oldTime; 61 QTime oldTime;
61 int oldToday; 62 int oldToday;
62}; 63};
63 64
64 65
65class KOAgenda : public QScrollView 66class KOAgenda : public QScrollView
66{ 67{
67 Q_OBJECT 68 Q_OBJECT
68 public: 69 public:
69 enum MouseActionType { NOP, MOVE, SELECT, 70 enum MouseActionType { NOP, MOVE, SELECT,
70 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
71 72
72 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
73 const char * name=0, WFlags f=0 ); 74 const char * name=0, WFlags f=0 );
74 KOAgenda ( int columns, QWidget * parent=0, 75 KOAgenda ( int columns, QWidget * parent=0,
75 const char * name=0, WFlags f=0 ); 76 const char * name=0, WFlags f=0 );
76 virtual ~KOAgenda(); 77 virtual ~KOAgenda();
77 78
78 Incidence *selectedIncidence() const; 79 Incidence *selectedIncidence() const;
79 QDate selectedIncidenceDate() const; 80 QDate selectedIncidenceDate() const;
80 81
81 virtual bool eventFilter ( QObject *, QEvent * ); 82 virtual bool eventFilter ( QObject *, QEvent * );
82 83
83 void contentsToGrid (int x, int y, int& gx, int& gy); 84 void contentsToGrid (int x, int y, int& gx, int& gy);
84 void gridToContents (int gx, int gy, int& x, int& y); 85 void gridToContents (int gx, int gy, int& x, int& y);
85 86
86 int timeToY (const QTime &time); 87 int timeToY (const QTime &time);
87 QTime gyToTime (int y); 88 QTime gyToTime (int y);
88 89
89 void setStartHour(int startHour); 90 void setStartHour(int startHour);
90 91
91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 92 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 93 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 94 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
94 int YTop,int YBottom); 95 int YTop,int YBottom);
95 96
96 void changeColumns(int columns); 97 void changeColumns(int columns);
97 98
98 int columns() { return mColumns; } 99 int columns() { return mColumns; }
99 int rows() { return mRows; } 100 int rows() { return mRows; }
100 101
101 int gridSpacingX() const { return mGridSpacingX; } 102 int gridSpacingX() const { return mGridSpacingX; }
102 int gridSpacingY() const { return mGridSpacingY; } 103 int gridSpacingY() const { return mGridSpacingY; }
103 104
104// virtual QSizePolicy sizePolicy() const; 105// virtual QSizePolicy sizePolicy() const;
105 106
106 void clear(); 107 void clear();
107 108
108 void clearSelection(); 109 void clearSelection();
109 void hideUnused(); 110 void hideUnused();
110 111
111 /** Calculates the minimum width */ 112 /** Calculates the minimum width */
112 virtual int minimumWidth() const; 113 virtual int minimumWidth() const;
113 /** Update configuration from preference settings */ 114 /** Update configuration from preference settings */
114 void updateConfig(); 115 void updateConfig();
115 116
116 void checkScrollBoundaries(); 117 void checkScrollBoundaries();
117 118
118 void setHolidayMask(QMemArray<bool> *); 119 void setHolidayMask(QMemArray<bool> *);
119 void setDateList(const DateList &selectedDates); 120 void setDateList(const DateList &selectedDates);
120 DateList dateList() const; 121 DateList dateList() const;
121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 122 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
122 void finishUpdate(); 123 void finishUpdate();
123 void printSelection(); 124 void printSelection();
124 void storePosition(); 125 void storePosition();
125 void restorePosition(); 126 void restorePosition();
126 127 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
127 128
128 public slots: 129 public slots:
129 void popupMenu(); 130 void popupMenu();
130 void newItem( int ); 131 void newItem( int );
131 void moveChild( QWidget *, int, int ); 132 void moveChild( QWidget *, int, int );
132 void scrollUp(); 133 void scrollUp();
133 void scrollDown(); 134 void scrollDown();
134 void updateTodo( Todo * t, int , bool ); 135 void updateTodo( Todo * t, int , bool );
135 void popupAlarm(); 136 void popupAlarm();
136 137
137 void checkScrollBoundaries(int); 138 void checkScrollBoundaries(int);
138 139
139 /** Deselect selected items. This function does not emit any signals. */ 140 /** Deselect selected items. This function does not emit any signals. */
140 void deselectItem(); 141 void deselectItem();
141 /** Select item. If the argument is 0, the currently selected item gets 142 /** Select item. If the argument is 0, the currently selected item gets
142 deselected. This function emits the itemSelected(bool) signal to inform 143 deselected. This function emits the itemSelected(bool) signal to inform
143 about selection/deseelction of events. */ 144 about selection/deseelction of events. */
144 void selectItem(KOAgendaItem *); 145 void selectItem(KOAgendaItem *);
145 void finishResize(); 146 void finishResize();
146 147
147 signals: 148 signals:
148 void showDateView( int, int); 149 void showDateView( int, int);
149 void newEventSignal(); 150 void newEventSignal();
150 void newEventSignal(int gx,int gy); 151 void newEventSignal(int gx,int gy);
151 void newTodoSignal(int gx,int gy); 152 void newTodoSignal(int gx,int gy);
152 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 153 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
153 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 154 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
154 void newStartSelectSignal(); 155 void newStartSelectSignal();
155 void showIncidenceSignal(Incidence *); 156 void showIncidenceSignal(Incidence *);
156 void editIncidenceSignal(Incidence *); 157 void editIncidenceSignal(Incidence *);
157 void deleteIncidenceSignal(Incidence *); 158 void deleteIncidenceSignal(Incidence *);
158 void showIncidencePopupSignal(Incidence *); 159 void showIncidencePopupSignal(Incidence *);
159 160
160 void itemModified(KOAgendaItem *item, int ); 161 void itemModified(KOAgendaItem *item, int );
161 void incidenceSelected(Incidence *); 162 void incidenceSelected(Incidence *);
162 163
163 void lowerYChanged(int); 164 void lowerYChanged(int);
164 void upperYChanged(int); 165 void upperYChanged(int);
165 166
166 void startDragSignal(Incidence *); 167 void startDragSignal(Incidence *);
167 void addToCalSignal(Incidence *, Incidence *); 168 void addToCalSignal(Incidence *, Incidence *);
168 void resizedSignal(); 169 void resizedSignal();
169 170
170 protected: 171 protected:
172 KOEventPopupMenu * mAllAgendaPopup;
171 QPainter mPixPainter; 173 QPainter mPixPainter;
172 QPixmap mPaintPixmap; 174 QPixmap mPaintPixmap;
173 QPixmap mHighlightPixmap; 175 QPixmap mHighlightPixmap;
174 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 176 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
175 virtual void resizeEvent ( QResizeEvent * ); 177 virtual void resizeEvent ( QResizeEvent * );
176 178
177 /** Handles mouse events. Called from eventFilter */ 179 /** Handles mouse events. Called from eventFilter */
178 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 180 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
179 181
180 /** Start selecting time span. */ 182 /** Start selecting time span. */
181 void startSelectAction(QPoint viewportPos); 183 void startSelectAction(QPoint viewportPos);
182 184
183 /** Select time span. */ 185 /** Select time span. */
184 void performSelectAction(QPoint viewportPos); 186 void performSelectAction(QPoint viewportPos);
185 187
186 /** Emd selecting time span. */ 188 /** Emd selecting time span. */
187 void endSelectAction( bool emitNewEvent = false ); 189 void endSelectAction( bool emitNewEvent = false );
188 190
189 /** Start moving/resizing agenda item */ 191 /** Start moving/resizing agenda item */
190 void startItemAction(QPoint viewportPos); 192 void startItemAction(QPoint viewportPos);
191 193
192 /** Move/resize agenda item */ 194 /** Move/resize agenda item */
193 void performItemAction(QPoint viewportPos); 195 void performItemAction(QPoint viewportPos);
194 196
195 /** End moving/resizing agenda item */ 197 /** End moving/resizing agenda item */
196 void endItemAction(); 198 void endItemAction();
197 199
198 /** Set cursor, when no item action is in progress */ 200 /** Set cursor, when no item action is in progress */
199 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 201 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
200 202
201 /** Place agenda item in agenda and adjust other cells if necessary */ 203 /** Place agenda item in agenda and adjust other cells if necessary */
202 void placeSubCells(KOAgendaItem *placeItem); 204 void placeSubCells(KOAgendaItem *placeItem);
203 205
204 /** Process the keyevent, including the ignored keyevents of eventwidgets. 206 /** Process the keyevent, including the ignored keyevents of eventwidgets.
205 * Implements pgup/pgdn and cursor key navigation in the view. 207 * Implements pgup/pgdn and cursor key navigation in the view.
206 */ 208 */
207 void keyPressEvent( QKeyEvent * ); 209 void keyPressEvent( QKeyEvent * );
208 210
209 void calculateWorkingHours(); 211 void calculateWorkingHours();
210 212
211 virtual void contentsMousePressEvent ( QMouseEvent * ); 213 virtual void contentsMousePressEvent ( QMouseEvent * );
212 214
213 private: 215 private:
214 void init(); 216 void init();
215 void marcus_bains(); 217 void marcus_bains();
216 bool mAllDayMode; 218 bool mAllDayMode;
217 bool blockResize; 219 bool blockResize;
218 bool mLeftMouseDown; 220 bool mLeftMouseDown;
219 KOAgendaItem *mPopupItem; 221 KOAgendaItem *mPopupItem;
220 QTimer* mPopupTimer; 222 QTimer* mPopupTimer;
221 int mPopupKind; 223 int mPopupKind;
222 QPoint mPopupPos; 224 QPoint mPopupPos;
223 QTimer mResizeTimer; 225 QTimer mResizeTimer;
224 double mContentPosition; 226 double mContentPosition;
225 227
226 // Width and height of agenda cells 228 // Width and height of agenda cells
227 int mGridSpacingX; 229 int mGridSpacingX;
228 int mGridSpacingY; 230 int mGridSpacingY;
229 231
230 // size of border, where mouse action will resize the KOAgendaItem 232 // size of border, where mouse action will resize the KOAgendaItem
231 int mResizeBorderWidth; 233 int mResizeBorderWidth;
232 234
233 // size of border, where mouse mve will cause a scroll of the agenda 235 // size of border, where mouse mve will cause a scroll of the agenda
234 int mScrollBorderWidth; 236 int mScrollBorderWidth;
235 int mScrollDelay; 237 int mScrollDelay;
236 int mScrollOffset; 238 int mScrollOffset;
237 239
238 QTimer mScrollUpTimer; 240 QTimer mScrollUpTimer;
239 QTimer mScrollDownTimer; 241 QTimer mScrollDownTimer;
240 242
241 // Number of Columns/Rows of agenda grid 243 // Number of Columns/Rows of agenda grid
242 int mColumns; 244 int mColumns;
243 int mRows; 245 int mRows;
244 246
245 // Cells to store Move and Resize coordiantes 247 // Cells to store Move and Resize coordiantes
246 int mStartCellX; 248 int mStartCellX;
247 int mStartCellY; 249 int mStartCellY;
248 int mCurrentCellX; 250 int mCurrentCellX;
249 int mCurrentCellY; 251 int mCurrentCellY;
250 252
251 // Working Hour coordiantes 253 // Working Hour coordiantes
252 bool mWorkingHoursEnable; 254 bool mWorkingHoursEnable;
253 int mWorkingHoursYTop; 255 int mWorkingHoursYTop;
254 int mWorkingHoursYBottom; 256 int mWorkingHoursYBottom;
255 257
256 // Selection 258 // Selection
257 int mSelectionCellX; 259 int mSelectionCellX;
258 int mSelectionYTop; 260 int mSelectionYTop;
259 int mSelectionHeight; 261 int mSelectionHeight;
260 262
261 // List of dates to be displayed 263 // List of dates to be displayed
262 DateList mSelectedDates; 264 DateList mSelectedDates;
263 265
264 // The KOAgendaItem, which has been right-clicked last 266 // The KOAgendaItem, which has been right-clicked last
265 KOAgendaItem *mClickedItem; 267 KOAgendaItem *mClickedItem;
266 268
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 8d32152..95388ef 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -412,356 +412,358 @@ void EventIndicator::drawContents(QPainter *p)
412 setColor = true; 412 setColor = true;
413 413
414 int cellWidth = contentsRect().right()/mColumns; 414 int cellWidth = contentsRect().right()/mColumns;
415 int xOffset = KOGlobals::self()->reverseLayout() ? 415 int xOffset = KOGlobals::self()->reverseLayout() ?
416 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 416 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
417 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 417 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
418 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 418 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
419 //qDebug("222draw pix %d ",xOffset ); 419 //qDebug("222draw pix %d ",xOffset );
420 420
421 } 421 }
422 422
423 } 423 }
424 pa.end(); 424 pa.end();
425 425
426 } 426 }
427} 427}
428 428
429void EventIndicator::setXOffset( int x ) 429void EventIndicator::setXOffset( int x )
430{ 430{
431 mXOffset = x; 431 mXOffset = x;
432} 432}
433void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 433void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
434{ 434{
435 mPaintWidget = w; 435 mPaintWidget = w;
436 setMaximumHeight(0); 436 setMaximumHeight(0);
437 setMinimumHeight(0); 437 setMinimumHeight(0);
438} 438}
439void EventIndicator::changeColumns(int columns) 439void EventIndicator::changeColumns(int columns)
440{ 440{
441 mColumns = columns; 441 mColumns = columns;
442 mEnabled.resize(mColumns); 442 mEnabled.resize(mColumns);
443 443
444 update(); 444 update();
445} 445}
446 446
447void EventIndicator::enableColumn(int column, bool enable) 447void EventIndicator::enableColumn(int column, bool enable)
448{ 448{
449 mEnabled[column] = enable; 449 mEnabled[column] = enable;
450} 450}
451 451
452 452
453//////////////////////////////////////////////////////////////////////////// 453////////////////////////////////////////////////////////////////////////////
454//////////////////////////////////////////////////////////////////////////// 454////////////////////////////////////////////////////////////////////////////
455//////////////////////////////////////////////////////////////////////////// 455////////////////////////////////////////////////////////////////////////////
456 456
457KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 457KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
458 KOEventView (cal,parent,name) 458 KOEventView (cal,parent,name)
459{ 459{
460 mBlockUpdating = true; 460 mBlockUpdating = true;
461 mStartHour = 8; 461 mStartHour = 8;
462 mSelectedDates.append(QDate::currentDate()); 462 mSelectedDates.append(QDate::currentDate());
463 463
464 mLayoutDayLabels = 0; 464 mLayoutDayLabels = 0;
465 mDayLabelsFrame = 0; 465 mDayLabelsFrame = 0;
466 mDayLabels = 0; 466 mDayLabels = 0;
467 bool isRTL = KOGlobals::self()->reverseLayout(); 467 bool isRTL = KOGlobals::self()->reverseLayout();
468 QPixmap expandPix; 468 QPixmap expandPix;
469 if ( KOPrefs::instance()->mVerticalScreen ) { 469 if ( KOPrefs::instance()->mVerticalScreen ) {
470 expandPix = SmallIcon( "1updownarrow" ); 470 expandPix = SmallIcon( "1updownarrow" );
471 } else { 471 } else {
472 expandPix = SmallIcon("1leftrightarrow" ); 472 expandPix = SmallIcon("1leftrightarrow" );
473 } 473 }
474 474
475 QBoxLayout *topLayout = new QVBoxLayout(this); 475 QBoxLayout *topLayout = new QVBoxLayout(this);
476 476
477 // Create day name labels for agenda columns 477 // Create day name labels for agenda columns
478 // Create agenda splitter 478 // Create agenda splitter
479 479
480 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 480 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
481 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 481 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
482 topLayout->addWidget( mSplitterAgenda ); 482 topLayout->addWidget( mSplitterAgenda );
483 mAllDayFrame = new QHBox(mSplitterAgenda); 483 mAllDayFrame = new QHBox(mSplitterAgenda);
484 mAllDayFrame->setFocusPolicy(NoFocus); 484 mAllDayFrame->setFocusPolicy(NoFocus);
485 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 485 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
486 agendaFrame->setFocusPolicy(NoFocus); 486 agendaFrame->setFocusPolicy(NoFocus);
487 487
488 // Create all-day agenda widget 488 // Create all-day agenda widget
489 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 489 mDummyAllDayLeft = new QVBox( mAllDayFrame );
490 490
491 mExpandButton = new QPushButton(mDummyAllDayLeft); 491 mExpandButton = new QPushButton(mDummyAllDayLeft);
492 mExpandButton->setPixmap( expandPix ); 492 mExpandButton->setPixmap( expandPix );
493 int widebut = mExpandButton->sizeHint().width()+4; 493 int widebut = mExpandButton->sizeHint().width()+4;
494 int heibut = mExpandButton->sizeHint().height()+4; 494 int heibut = mExpandButton->sizeHint().height()+4;
495 if ( heibut > widebut ) 495 if ( heibut > widebut )
496 widebut = heibut ; 496 widebut = heibut ;
497 497
498 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 498 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
499 // QSizePolicy::Fixed ) ); 499 // QSizePolicy::Fixed ) );
500 mExpandButton->setFixedSize( widebut, widebut); 500 mExpandButton->setFixedSize( widebut, widebut);
501 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 501 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
502 mExpandButton->setFocusPolicy(NoFocus); 502 mExpandButton->setFocusPolicy(NoFocus);
503 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 503 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
504 mAllDayAgenda->setFocusPolicy(NoFocus); 504 mAllDayAgenda->setFocusPolicy(NoFocus);
505 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 505 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
506 506
507 // Create event context menu for all day agenda 507 // Create event context menu for all day agenda
508 mAllDayAgendaPopup = eventPopup(); 508 //mAllDayAgendaPopup = eventPopup();
509 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
510 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
511 509
512 // Create agenda frame 510 // Create agenda frame
513 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 511 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
514 // QHBox *agendaFrame = new QHBox(splitterAgenda); 512 // QHBox *agendaFrame = new QHBox(splitterAgenda);
515 513
516 // create event indicator bars 514 // create event indicator bars
517 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 515 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
518#ifndef DESKTOP_VERSION 516#ifndef DESKTOP_VERSION
519 // FIX 517 // FIX
520 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 518 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
521#endif 519#endif
522 mDayLabelsFrame = new QHBox(agendaFrame); 520 mDayLabelsFrame = new QHBox(agendaFrame);
523 //topLayout->addWidget(mDayLabelsFrame); 521 //topLayout->addWidget(mDayLabelsFrame);
524 mDayLabels = new QFrame (mDayLabelsFrame); 522 mDayLabels = new QFrame (mDayLabelsFrame);
525 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 523 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
526 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 524 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
527 agendaLayout->addWidget(mEventIndicatorTop,1,1); 525 agendaLayout->addWidget(mEventIndicatorTop,1,1);
528 526
529 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 527 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
530 agendaFrame); 528 agendaFrame);
531 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 529 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
532 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 530 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
533 agendaLayout->addWidget(dummyAgendaRight,1,2); 531 agendaLayout->addWidget(dummyAgendaRight,1,2);
534 532
535 // Create time labels 533 // Create time labels
536 mTimeLabels = new TimeLabels(24,agendaFrame); 534 mTimeLabels = new TimeLabels(24,agendaFrame);
537 agendaLayout->addWidget(mTimeLabels,2,0); 535 agendaLayout->addWidget(mTimeLabels,2,0);
538 connect(mTimeLabels,SIGNAL( scaleChanged()), 536 connect(mTimeLabels,SIGNAL( scaleChanged()),
539 this,SLOT(updateConfig())); 537 this,SLOT(updateConfig()));
540 538
541 // Create agenda 539 // Create agenda
542 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 540 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
543 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 541 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
544 agendaLayout->setColStretch(1,1); 542 agendaLayout->setColStretch(1,1);
545 mAgenda->setFocusPolicy(NoFocus); 543 mAgenda->setFocusPolicy(NoFocus);
546 // Create event context menu for agenda 544 // Create event context menu for agenda
547 mAgendaPopup = eventPopup(); 545 mAllAgendaPopup = eventPopup();
548 546
549 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 547 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
550 i18n("Toggle Alarm"),mAgenda, 548 i18n("Toggle Alarm"),mAgenda,
551 SLOT(popupAlarm()),true); 549 SLOT(popupAlarm()),true);
552 550
553 551
554 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 552 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
555 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 553 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
556 554
555 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
556 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
557 mAgenda->setPopup( mAllAgendaPopup );
558 mAllDayAgenda->setPopup( mAllAgendaPopup );
557 // make connections between dependent widgets 559 // make connections between dependent widgets
558 mTimeLabels->setAgenda(mAgenda); 560 mTimeLabels->setAgenda(mAgenda);
559 561
560 // Update widgets to reflect user preferences 562 // Update widgets to reflect user preferences
561 // updateConfig(); 563 // updateConfig();
562 564
563 // createDayLabels(); 565 // createDayLabels();
564 566
565 // these blank widgets make the All Day Event box line up with the agenda 567 // these blank widgets make the All Day Event box line up with the agenda
566 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 568 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
567 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 569 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
568 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 570 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
569 571
570 // Scrolling 572 // Scrolling
571 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 573 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
572 mTimeLabels, SLOT(positionChanged())); 574 mTimeLabels, SLOT(positionChanged()));
573 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 575 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
574 SLOT(setContentsPos(int))); 576 SLOT(setContentsPos(int)));
575 577
576 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 578 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
577 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 579 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
578 580
579 // Create/Show/Edit/Delete Event 581 // Create/Show/Edit/Delete Event
580 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 582 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
581 SLOT(newEvent(int,int))); 583 SLOT(newEvent(int,int)));
582 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 584 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
583 SLOT(newTodo(int,int))); 585 SLOT(newTodo(int,int)));
584 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 586 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
585 SLOT(newEvent(int,int,int,int))); 587 SLOT(newEvent(int,int,int,int)));
586 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 588 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
587 SLOT(newEventAllDay(int,int))); 589 SLOT(newEventAllDay(int,int)));
588 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 590 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
589 SLOT(newTodoAllDay(int,int))); 591 SLOT(newTodoAllDay(int,int)));
590 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 592 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
591 SLOT(newEventAllDay(int,int))); 593 SLOT(newEventAllDay(int,int)));
592 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 594 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
593 SLOT(newTimeSpanSelected(int,int,int,int))); 595 SLOT(newTimeSpanSelected(int,int,int,int)));
594 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 596 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
595 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 597 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
596 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 598 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
597 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 599 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
598 600
599 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 601 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
600 SIGNAL(editIncidenceSignal(Incidence *))); 602 SIGNAL(editIncidenceSignal(Incidence *)));
601 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 603 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
602 SIGNAL(editIncidenceSignal(Incidence *))); 604 SIGNAL(editIncidenceSignal(Incidence *)));
603 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 605 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
604 SIGNAL(showIncidenceSignal(Incidence *))); 606 SIGNAL(showIncidenceSignal(Incidence *)));
605 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 607 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
606 SIGNAL(showIncidenceSignal(Incidence *))); 608 SIGNAL(showIncidenceSignal(Incidence *)));
607 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 609 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
608 SIGNAL(deleteIncidenceSignal(Incidence *))); 610 SIGNAL(deleteIncidenceSignal(Incidence *)));
609 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 611 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
610 SIGNAL(deleteIncidenceSignal(Incidence *))); 612 SIGNAL(deleteIncidenceSignal(Incidence *)));
611 613
612 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 614 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
613 SLOT(updateEventDates(KOAgendaItem *, int ))); 615 SLOT(updateEventDates(KOAgendaItem *, int )));
614 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 616 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
615 SLOT(updateEventDates(KOAgendaItem *, int))); 617 SLOT(updateEventDates(KOAgendaItem *, int)));
616 618
617 // event indicator update 619 // event indicator update
618 connect(mAgenda,SIGNAL(lowerYChanged(int)), 620 connect(mAgenda,SIGNAL(lowerYChanged(int)),
619 SLOT(updateEventIndicatorTop(int))); 621 SLOT(updateEventIndicatorTop(int)));
620 connect(mAgenda,SIGNAL(upperYChanged(int)), 622 connect(mAgenda,SIGNAL(upperYChanged(int)),
621 SLOT(updateEventIndicatorBottom(int))); 623 SLOT(updateEventIndicatorBottom(int)));
622 // drag signals 624 // drag signals
623 /* 625 /*
624 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 626 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
625 SLOT(startDrag(Event *))); 627 SLOT(startDrag(Event *)));
626 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 628 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
627 SLOT(startDrag(Event *))); 629 SLOT(startDrag(Event *)));
628 */ 630 */
629 // synchronize selections 631 // synchronize selections
630 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 632 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
631 mAllDayAgenda, SLOT( deselectItem() ) ); 633 mAllDayAgenda, SLOT( deselectItem() ) );
632 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 634 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
633 mAgenda, SLOT( deselectItem() ) ); 635 mAgenda, SLOT( deselectItem() ) );
634 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 636 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
635 SIGNAL( incidenceSelected( Incidence * ) ) ); 637 SIGNAL( incidenceSelected( Incidence * ) ) );
636 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 638 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
637 SIGNAL( incidenceSelected( Incidence * ) ) ); 639 SIGNAL( incidenceSelected( Incidence * ) ) );
638 connect( mAgenda, SIGNAL( resizedSignal() ), 640 connect( mAgenda, SIGNAL( resizedSignal() ),
639 SLOT( updateConfig( ) ) ); 641 SLOT( updateConfig( ) ) );
640 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 642 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
641 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 643 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
642 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 644 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
643 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 645 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
644 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 646 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
645 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 647 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
646 648
647 649
648} 650}
649 651
650void KOAgendaView::toggleAllDay() 652void KOAgendaView::toggleAllDay()
651{ 653{
652 if ( mSplitterAgenda->firstHandle() ) 654 if ( mSplitterAgenda->firstHandle() )
653 mSplitterAgenda->firstHandle()->toggle(); 655 mSplitterAgenda->firstHandle()->toggle();
654} 656}
655void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 657void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
656{ 658{
657 calendar()->addIncidence( inc ); 659 calendar()->addIncidence( inc );
658 660
659 if ( incOld ) { 661 if ( incOld ) {
660 if ( incOld->type() == "Todo" ) 662 if ( incOld->type() == "Todo" )
661 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 663 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
662 else 664 else
663 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 665 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
664 } 666 }
665 667
666} 668}
667 669
668KOAgendaView::~KOAgendaView() 670KOAgendaView::~KOAgendaView()
669{ 671{
670 delete mAgendaPopup; 672 delete mAllAgendaPopup;
671 delete mAllDayAgendaPopup; 673 //delete mAllDayAgendaPopup;
672 delete KOAgendaItem::paintPix(); 674 delete KOAgendaItem::paintPix();
673 delete KOAgendaItem::paintPixSel(); 675 delete KOAgendaItem::paintPixSel();
674} 676}
675void KOAgendaView::resizeEvent( QResizeEvent* e ) 677void KOAgendaView::resizeEvent( QResizeEvent* e )
676{ 678{
677 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 679 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
678 bool uc = false; 680 bool uc = false;
679 int ow = e->oldSize().width(); 681 int ow = e->oldSize().width();
680 int oh = e->oldSize().height(); 682 int oh = e->oldSize().height();
681 int w = e->size().width(); 683 int w = e->size().width();
682 int h = e->size().height(); 684 int h = e->size().height();
683 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 685 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
684 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 686 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
685 uc = true; 687 uc = true;
686 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 688 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
687 } 689 }
688 mUpcomingWidth = e->size().width() ; 690 mUpcomingWidth = e->size().width() ;
689 if ( mBlockUpdating || uc ) { 691 if ( mBlockUpdating || uc ) {
690 mBlockUpdating = false; 692 mBlockUpdating = false;
691 //mAgenda->setMinimumSize(800 , 600 ); 693 //mAgenda->setMinimumSize(800 , 600 );
692 //qDebug("mAgenda->resize+++++++++++++++ "); 694 //qDebug("mAgenda->resize+++++++++++++++ ");
693 updateConfig(); 695 updateConfig();
694 //qDebug("KOAgendaView::Updating now possible "); 696 //qDebug("KOAgendaView::Updating now possible ");
695 } else 697 } else
696 createDayLabels(); 698 createDayLabels();
697 //qDebug("resizeEvent end "); 699 //qDebug("resizeEvent end ");
698 700
699} 701}
700void KOAgendaView::slotDaylabelClicked( int num ) 702void KOAgendaView::slotDaylabelClicked( int num )
701{ 703{
702 704
703 QDate firstDate = mSelectedDates.first(); 705 QDate firstDate = mSelectedDates.first();
704 if ( num == -1 ) 706 if ( num == -1 )
705 emit showDateView( 6, firstDate ); 707 emit showDateView( 6, firstDate );
706 else if (num >= 0 ) { 708 else if (num >= 0 ) {
707 if ( mSelectedDates.count() == 1) 709 if ( mSelectedDates.count() == 1)
708 emit showDateView( 9, firstDate.addDays( num ) ); 710 emit showDateView( 9, firstDate.addDays( num ) );
709 else 711 else
710 emit showDateView( 3, firstDate.addDays( num ) ); 712 emit showDateView( 3, firstDate.addDays( num ) );
711 } 713 }
712 else 714 else
713 showDateView( 10, firstDate.addDays(1) ); 715 showDateView( 10, firstDate.addDays(1) );
714} 716}
715 717
716KOAgendaButton* KOAgendaView::getNewDaylabel() 718KOAgendaButton* KOAgendaView::getNewDaylabel()
717{ 719{
718 720
719 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 721 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
720 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 722 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
721 mDayLabelsList.append( dayLabel ); 723 mDayLabelsList.append( dayLabel );
722 mLayoutDayLabels->addWidget(dayLabel); 724 mLayoutDayLabels->addWidget(dayLabel);
723 return dayLabel ; 725 return dayLabel ;
724} 726}
725 727
726void KOAgendaView::createDayLabels() 728void KOAgendaView::createDayLabels()
727{ 729{
728 730
729 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 731 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
730 // qDebug(" KOAgendaView::createDayLabels() blocked "); 732 // qDebug(" KOAgendaView::createDayLabels() blocked ");
731 return; 733 return;
732 734
733 } 735 }
734 int newHight; 736 int newHight;
735 737
736 // ### Before deleting and recreating we could check if mSelectedDates changed... 738 // ### Before deleting and recreating we could check if mSelectedDates changed...
737 // It would remove some flickering and gain speed (since this is called by 739 // It would remove some flickering and gain speed (since this is called by
738 // each updateView() call) 740 // each updateView() call)
739 741
740 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 742 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
741 if ( QApplication::desktop()->width() <= 320 ) 743 if ( QApplication::desktop()->width() <= 320 )
742 maxWid -= 10; 744 maxWid -= 10;
743 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 745 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
744 if ( maxWid < 0 ) 746 if ( maxWid < 0 )
745 maxWid = 20; 747 maxWid = 20;
746 748
747 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 749 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
748 QFontMetrics fm ( dlf ); 750 QFontMetrics fm ( dlf );
749 int selCount = mSelectedDates.count(); 751 int selCount = mSelectedDates.count();
750 QString dayTest = "Mon 20"; 752 QString dayTest = "Mon 20";
751 //QString dayTest = "Mon 20"; 753 //QString dayTest = "Mon 20";
752 int wid = fm.width( dayTest ); 754 int wid = fm.width( dayTest );
753 //maxWid -= ( selCount * 3 ); //working for QLabels 755 //maxWid -= ( selCount * 3 ); //working for QLabels
754 maxWid -= ( selCount * 3 ); //working for QPushButton 756 maxWid -= ( selCount * 3 ); //working for QPushButton
755 if ( maxWid < 0 ) 757 if ( maxWid < 0 )
756 maxWid = 20; 758 maxWid = 20;
757 int needWid = wid * selCount; 759 int needWid = wid * selCount;
758 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 760 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
759 //if ( needWid > maxWid ) 761 //if ( needWid > maxWid )
760 // qDebug("DAYLABELS TOOOOOOO BIG "); 762 // qDebug("DAYLABELS TOOOOOOO BIG ");
761 while ( needWid > maxWid ) { 763 while ( needWid > maxWid ) {
762 dayTest = dayTest.left( dayTest.length() - 1 ); 764 dayTest = dayTest.left( dayTest.length() - 1 );
763 wid = fm.width( dayTest ); 765 wid = fm.width( dayTest );
764 needWid = wid * selCount; 766 needWid = wid * selCount;
765 } 767 }
766 int maxLen = dayTest.length(); 768 int maxLen = dayTest.length();
767 int fontPoint = dlf.pointSize(); 769 int fontPoint = dlf.pointSize();
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 30c9b05..c6e6602 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -178,115 +178,115 @@ class KOAgendaView : public KOEventView {
178 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 178 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
179 /** make selected start/end invalid */ 179 /** make selected start/end invalid */
180 void deleteSelectedDateTime(); 180 void deleteSelectedDateTime();
181 void repaintAgenda(); 181 void repaintAgenda();
182 public slots: 182 public slots:
183 void setInitStartHour(); 183 void setInitStartHour();
184 virtual void updateView(); 184 virtual void updateView();
185 virtual void updateConfig(); 185 virtual void updateConfig();
186 virtual void showDates(const QDate &start, const QDate &end); 186 virtual void showDates(const QDate &start, const QDate &end);
187 virtual void showEvents(QPtrList<Event> eventList); 187 virtual void showEvents(QPtrList<Event> eventList);
188 188
189 void updateTodo( Todo *, int ); 189 void updateTodo( Todo *, int );
190 void changeEventDisplay(Event *, int); 190 void changeEventDisplay(Event *, int);
191 191
192 void clearSelection(); 192 void clearSelection();
193 193
194 void newTodo(int gx,int gy); 194 void newTodo(int gx,int gy);
195 void newEvent(int gx,int gy); 195 void newEvent(int gx,int gy);
196 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 196 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
197 void newEventAllDay(int gx, int gy); 197 void newEventAllDay(int gx, int gy);
198 void newTodoAllDay(int gx, int gy); 198 void newTodoAllDay(int gx, int gy);
199 199
200 void startDrag(Event *); 200 void startDrag(Event *);
201 201
202 void readSettings(); 202 void readSettings();
203 void readSettings(KConfig *); 203 void readSettings(KConfig *);
204 void writeSettings(KConfig *); 204 void writeSettings(KConfig *);
205 205
206 void setContentsPos(int y); 206 void setContentsPos(int y);
207 207
208 void scrollOneHourUp(); 208 void scrollOneHourUp();
209 void scrollOneHourDown(); 209 void scrollOneHourDown();
210 void addToCalSlot(Incidence *, Incidence *); 210 void addToCalSlot(Incidence *, Incidence *);
211 void slotShowDateView( int, int ); 211 void slotShowDateView( int, int );
212 212
213 signals: 213 signals:
214 void showDateView( int, QDate ); 214 void showDateView( int, QDate );
215 void newTodoSignal( QDateTime ,bool ); 215 void newTodoSignal( QDateTime ,bool );
216 void toggleExpand(); 216 void toggleExpand();
217 void selectWeekNum( int ); 217 void selectWeekNum( int );
218 void todoMoved( Todo *, int ); 218 void todoMoved( Todo *, int );
219 void incidenceChanged(Incidence * , int ); 219 void incidenceChanged(Incidence * , int );
220 // void cloneIncidenceSignal(Incidence *); 220 // void cloneIncidenceSignal(Incidence *);
221 221
222 protected: 222 protected:
223 KOAgendaButton* getNewDaylabel(); 223 KOAgendaButton* getNewDaylabel();
224 bool mBlockUpdating; 224 bool mBlockUpdating;
225 int mUpcomingWidth; 225 int mUpcomingWidth;
226 /** Fill agenda beginning with date startDate */ 226 /** Fill agenda beginning with date startDate */
227 void fillAgenda(const QDate &startDate); 227 void fillAgenda(const QDate &startDate);
228 void resizeEvent( QResizeEvent* e ); 228 void resizeEvent( QResizeEvent* e );
229 /** Fill agenda using the current set value for the start date */ 229 /** Fill agenda using the current set value for the start date */
230 void fillAgenda(); 230 void fillAgenda();
231 231
232 /** Create labels for the selected dates. */ 232 /** Create labels for the selected dates. */
233 void createDayLabels(); 233 void createDayLabels();
234 234
235 /** 235 /**
236 Set the masks on the agenda widgets indicating, which days are holidays. 236 Set the masks on the agenda widgets indicating, which days are holidays.
237 */ 237 */
238 void setHolidayMasks(); 238 void setHolidayMasks();
239 239
240 protected slots: 240 protected slots:
241 void slotDaylabelClicked( int ); 241 void slotDaylabelClicked( int );
242 /** Update event belonging to agenda item */ 242 /** Update event belonging to agenda item */
243 void updateEventDates(KOAgendaItem *item, int mode = -1); 243 void updateEventDates(KOAgendaItem *item, int mode = -1);
244 //void updateMovedTodo(); 244 //void updateMovedTodo();
245 245
246 void updateEventIndicatorTop(int newY); 246 void updateEventIndicatorTop(int newY);
247 void updateEventIndicatorBottom(int newY); 247 void updateEventIndicatorBottom(int newY);
248 248
249 /** Updates data for selected timespan */ 249 /** Updates data for selected timespan */
250 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 250 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
251 /** Updates data for selected timespan for all day event*/ 251 /** Updates data for selected timespan for all day event*/
252 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 252 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
253 253
254 private: 254 private:
255 // view widgets 255 // view widgets
256 QFrame *mDayLabels; 256 QFrame *mDayLabels;
257 QHBox *mDayLabelsFrame; 257 QHBox *mDayLabelsFrame;
258 QBoxLayout *mLayoutDayLabels; 258 QBoxLayout *mLayoutDayLabels;
259 QFrame *mAllDayFrame; 259 QFrame *mAllDayFrame;
260 KOAgenda *mAllDayAgenda; 260 KOAgenda *mAllDayAgenda;
261 KOAgenda *mAgenda; 261 KOAgenda *mAgenda;
262 TimeLabels *mTimeLabels; 262 TimeLabels *mTimeLabels;
263 QWidget *mDummyAllDayLeft; 263 QWidget *mDummyAllDayLeft;
264 264
265 KDGanttMinimizeSplitter* mSplitterAgenda; 265 KDGanttMinimizeSplitter* mSplitterAgenda;
266 QPushButton *mExpandButton; 266 QPushButton *mExpandButton;
267 267
268 DateList mSelectedDates; // List of dates to be displayed 268 DateList mSelectedDates; // List of dates to be displayed
269 int mViewType; 269 int mViewType;
270 270
271 bool mWeekStartsMonday; 271 bool mWeekStartsMonday;
272 int mStartHour; 272 int mStartHour;
273 273
274 KOEventPopupMenu *mAgendaPopup; 274 KOEventPopupMenu *mAllAgendaPopup;
275 KOEventPopupMenu *mAllDayAgendaPopup; 275 //KOEventPopupMenu *mAllDayAgendaPopup;
276 276
277 EventIndicator *mEventIndicatorTop; 277 EventIndicator *mEventIndicatorTop;
278 EventIndicator *mEventIndicatorBottom; 278 EventIndicator *mEventIndicatorBottom;
279 279
280 QMemArray<int> mMinY; 280 QMemArray<int> mMinY;
281 QMemArray<int> mMaxY; 281 QMemArray<int> mMaxY;
282 282
283 QMemArray<bool> mHolidayMask; 283 QMemArray<bool> mHolidayMask;
284 284
285 QPtrList<KOAgendaButton> mDayLabelsList; 285 QPtrList<KOAgendaButton> mDayLabelsList;
286 QDateTime mTimeSpanBegin; 286 QDateTime mTimeSpanBegin;
287 QDateTime mTimeSpanEnd; 287 QDateTime mTimeSpanEnd;
288 bool mTimeSpanInAllDay; 288 bool mTimeSpanInAllDay;
289 void keyPressEvent ( QKeyEvent * e ); 289 void keyPressEvent ( QKeyEvent * e );
290}; 290};
291 291
292#endif // KOAGENDAVIEW_H 292#endif // KOAGENDAVIEW_H
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index ccc4b01..0a315cb 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -114,211 +114,222 @@ void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
114 114
115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
116 !QTextDrag::canDecode( e ) ) { 116 !QTextDrag::canDecode( e ) ) {
117 e->ignore(); 117 e->ignore();
118 return; 118 return;
119 } 119 }
120 120
121 e->accept(); 121 e->accept();
122#endif 122#endif
123} 123}
124 124
125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
126{ 126{
127#ifndef KORG_NODND 127#ifndef KORG_NODND
128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
129 129
130 setCurrentItem(mOldCurrent); 130 setCurrentItem(mOldCurrent);
131 setSelected(mOldCurrent,true); 131 setSelected(mOldCurrent,true);
132#endif 132#endif
133} 133}
134 134
135void KOTodoListView::contentsDropEvent(QDropEvent *e) 135void KOTodoListView::contentsDropEvent(QDropEvent *e)
136{ 136{
137#ifndef KORG_NODND 137#ifndef KORG_NODND
138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
139 139
140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
141 !QTextDrag::canDecode( e ) ) { 141 !QTextDrag::canDecode( e ) ) {
142 e->ignore(); 142 e->ignore();
143 return; 143 return;
144 } 144 }
145 145
146 DndFactory factory( mCalendar ); 146 DndFactory factory( mCalendar );
147 Todo *todo = factory.createDropTodo(e); 147 Todo *todo = factory.createDropTodo(e);
148 148
149 if (todo) { 149 if (todo) {
150 e->acceptAction(); 150 e->acceptAction();
151 151
152 KOTodoViewItem *destination = 152 KOTodoViewItem *destination =
153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
154 Todo *destinationEvent = 0; 154 Todo *destinationEvent = 0;
155 if (destination) destinationEvent = destination->todo(); 155 if (destination) destinationEvent = destination->todo();
156 156
157 Todo *existingTodo = mCalendar->todo(todo->uid()); 157 Todo *existingTodo = mCalendar->todo(todo->uid());
158 158
159 if(existingTodo) { 159 if(existingTodo) {
160 Incidence *to = destinationEvent; 160 Incidence *to = destinationEvent;
161 while(to) { 161 while(to) {
162 if (to->uid() == todo->uid()) { 162 if (to->uid() == todo->uid()) {
163 KMessageBox::sorry(this, 163 KMessageBox::sorry(this,
164 i18n("Cannot move To-Do to itself\nor a child of itself"), 164 i18n("Cannot move To-Do to itself\nor a child of itself"),
165 i18n("Drop To-Do")); 165 i18n("Drop To-Do"));
166 delete todo; 166 delete todo;
167 return; 167 return;
168 } 168 }
169 to = to->relatedTo(); 169 to = to->relatedTo();
170 } 170 }
171 internalDrop = true; 171 internalDrop = true;
172 if ( destinationEvent ) 172 if ( destinationEvent )
173 reparentTodoSignal( destinationEvent, existingTodo ); 173 reparentTodoSignal( destinationEvent, existingTodo );
174 else 174 else
175 unparentTodoSignal(existingTodo); 175 unparentTodoSignal(existingTodo);
176 delete todo; 176 delete todo;
177 } else { 177 } else {
178 mCalendar->addTodo(todo); 178 mCalendar->addTodo(todo);
179 emit todoDropped(todo, KOGlobals::EVENTADDED); 179 emit todoDropped(todo, KOGlobals::EVENTADDED);
180 if ( destinationEvent ) 180 if ( destinationEvent )
181 reparentTodoSignal( destinationEvent, todo ); 181 reparentTodoSignal( destinationEvent, todo );
182 } 182 }
183 } 183 }
184 else { 184 else {
185 QString text; 185 QString text;
186 if (QTextDrag::decode(e,text)) { 186 if (QTextDrag::decode(e,text)) {
187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
189 qDebug("Dropped : " + text); 189 qDebug("Dropped : " + text);
190 QStringList emails = QStringList::split(",",text); 190 QStringList emails = QStringList::split(",",text);
191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
192 int pos = (*it).find("<"); 192 int pos = (*it).find("<");
193 QString name = (*it).left(pos); 193 QString name = (*it).left(pos);
194 QString email = (*it).mid(pos); 194 QString email = (*it).mid(pos);
195 if (!email.isEmpty() && todoi) { 195 if (!email.isEmpty() && todoi) {
196 todoi->todo()->addAttendee(new Attendee(name,email)); 196 todoi->todo()->addAttendee(new Attendee(name,email));
197 } 197 }
198 } 198 }
199 } 199 }
200 else { 200 else {
201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
202 e->ignore(); 202 e->ignore();
203 } 203 }
204 } 204 }
205#endif 205#endif
206} 206}
207 207
208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
209{ 209{
210
211 QPoint p(contentsToViewport(e->pos()));
212 QListViewItem *i = itemAt(p);
213 bool rootClicked = true;
214 if (i) {
215 // if the user clicked into the root decoration of the item, don't
216 // try to start a drag!
217 int X = p.x();
218 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
219 if (X > header()->sectionPos(0) +
220 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
221 itemMargin() ||
222 X < header()->sectionPos(0)) {
223 rootClicked = false;
224 }
225 }
210#ifndef KORG_NODND 226#ifndef KORG_NODND
211 QPoint p(contentsToViewport(e->pos())); 227 mMousePressed = false;
212 QListViewItem *i = itemAt(p); 228 if (! rootClicked ) {
213 mMousePressed = false;
214 if (i) {
215 // if the user clicked into the root decoration of the item, don't
216 // try to start a drag!
217 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
218 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
219 itemMargin() ||
220 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
221 if (e->button()==Qt::LeftButton) {
222 mPressPos = e->pos(); 229 mPressPos = e->pos();
223 mMousePressed = true; 230 mMousePressed = true;
224 }
225 } 231 }
226 }
227#endif 232#endif
228 QListView::contentsMousePressEvent(e); 233 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
234#ifndef DESKTOP_VERSION
235 if (!( e->button() == RightButton && rootClicked) )
236 QListView::contentsMousePressEvent(e);
237#else
238 QListView::contentsMousePressEvent(e);
239#endif
229} 240}
230void KOTodoListView::paintEvent(QPaintEvent* e) 241void KOTodoListView::paintEvent(QPaintEvent* e)
231{ 242{
232 emit paintNeeded(); 243 emit paintNeeded();
233 QListView::paintEvent( e); 244 QListView::paintEvent( e);
234} 245}
235void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 246void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
236{ 247{
237 248
238#ifndef KORG_NODND 249#ifndef KORG_NODND
239 //QListView::contentsMouseMoveEvent(e); 250 //QListView::contentsMouseMoveEvent(e);
240 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 251 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
241 QApplication::startDragDistance()*3) { 252 QApplication::startDragDistance()*3) {
242 mMousePressed = false; 253 mMousePressed = false;
243 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 254 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
244 if (item) { 255 if (item) {
245 DndFactory factory( mCalendar ); 256 DndFactory factory( mCalendar );
246 ICalDrag *vd = factory.createDrag( 257 ICalDrag *vd = factory.createDrag(
247 ((KOTodoViewItem *)item)->todo(),viewport()); 258 ((KOTodoViewItem *)item)->todo(),viewport());
248 internalDrop = false; 259 internalDrop = false;
249 // we cannot do any senseful here, because the DnD is still broken in Qt 260 // we cannot do any senseful here, because the DnD is still broken in Qt
250 if (vd->drag()) { 261 if (vd->drag()) {
251 if ( !internalDrop ) { 262 if ( !internalDrop ) {
252 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 263 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
253 qDebug("Dnd: External move: Delete drag source "); 264 qDebug("Dnd: External move: Delete drag source ");
254 } else 265 } else
255 qDebug("Dnd: Internal move "); 266 qDebug("Dnd: Internal move ");
256 267
257 } else { 268 } else {
258 if ( !internalDrop ) { 269 if ( !internalDrop ) {
259 qDebug("Dnd: External Copy"); 270 qDebug("Dnd: External Copy");
260 } else 271 } else
261 qDebug("DnD: Internal copy: Copy pending"); 272 qDebug("DnD: Internal copy: Copy pending");
262 } 273 }
263 } 274 }
264 } 275 }
265#endif 276#endif
266} 277}
267void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 278void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
268{ 279{
269 if ( !e->isAutoRepeat() ) { 280 if ( !e->isAutoRepeat() ) {
270 mFlagKeyPressed = false; 281 mFlagKeyPressed = false;
271 } 282 }
272} 283}
273 284
274 285
275void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 286void KOTodoListView::keyPressEvent ( QKeyEvent * e )
276{ 287{
277 qApp->processEvents(); 288 qApp->processEvents();
278 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 289 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
279 e->ignore(); 290 e->ignore();
280 // qDebug(" ignore %d",e->isAutoRepeat() ); 291 // qDebug(" ignore %d",e->isAutoRepeat() );
281 return; 292 return;
282 } 293 }
283 if (! e->isAutoRepeat() ) 294 if (! e->isAutoRepeat() )
284 mFlagKeyPressed = true; 295 mFlagKeyPressed = true;
285 QListViewItem* cn; 296 QListViewItem* cn;
286 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 297 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
287 cn = currentItem(); 298 cn = currentItem();
288 if ( cn ) { 299 if ( cn ) {
289 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 300 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
290 if ( ci ){ 301 if ( ci ){
291 if ( e->state() == ShiftButton ) 302 if ( e->state() == ShiftButton )
292 ci->setOn( false ); 303 ci->setOn( false );
293 else 304 else
294 ci->setOn( true ); 305 ci->setOn( true );
295 cn = cn->itemBelow(); 306 cn = cn->itemBelow();
296 if ( cn ) { 307 if ( cn ) {
297 setCurrentItem ( cn ); 308 setCurrentItem ( cn );
298 ensureItemVisible ( cn ); 309 ensureItemVisible ( cn );
299 } 310 }
300 311
301 } 312 }
302 } 313 }
303 314
304 return; 315 return;
305 } 316 }
306 317
307 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 318 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
308 switch ( e->key() ) { 319 switch ( e->key() ) {
309 case Qt::Key_Down: 320 case Qt::Key_Down:
310 case Qt::Key_Up: 321 case Qt::Key_Up:
311 QListView::keyPressEvent ( e ); 322 QListView::keyPressEvent ( e );
312 break; 323 break;
313 case Qt::Key_Left: 324 case Qt::Key_Left:
314 case Qt::Key_Right: 325 case Qt::Key_Right:
315 QListView::keyPressEvent ( e ); 326 QListView::keyPressEvent ( e );
316 e->accept(); 327 e->accept();
317 return; 328 return;
318 break; 329 break;
319 default: 330 default:
320 e->ignore(); 331 e->ignore();
321 break; 332 break;
322 } 333 }
323 return; 334 return;
324 } 335 }
@@ -970,204 +981,212 @@ void KOTodoView::beamTodo()
970void KOTodoView::showTodo() 981void KOTodoView::showTodo()
971{ 982{
972 if (mActiveItem) { 983 if (mActiveItem) {
973 emit showTodoSignal(mActiveItem->todo()); 984 emit showTodoSignal(mActiveItem->todo());
974 } 985 }
975} 986}
976 987
977void KOTodoView::deleteTodo() 988void KOTodoView::deleteTodo()
978{ 989{
979 if (mActiveItem) { 990 if (mActiveItem) {
980 emit deleteTodoSignal(mActiveItem->todo()); 991 emit deleteTodoSignal(mActiveItem->todo());
981 } 992 }
982} 993}
983 994
984void KOTodoView::setNewPriority(int index) 995void KOTodoView::setNewPriority(int index)
985{ 996{
986 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 997 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
987 mActiveItem->todo()->setPriority(mPriority[index]); 998 mActiveItem->todo()->setPriority(mPriority[index]);
988 mActiveItem->construct(); 999 mActiveItem->construct();
989 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1000 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
990 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1001 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
991 } 1002 }
992} 1003}
993 1004
994void KOTodoView::setNewPercentage(int index) 1005void KOTodoView::setNewPercentage(int index)
995{ 1006{
996 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1007 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
997 1008
998 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1009 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
999 mActiveItem->setOn( true ); 1010 mActiveItem->setOn( true );
1000 return; 1011 return;
1001 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1012 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1002 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1013 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1003 if ( par && par->isOn() ) 1014 if ( par && par->isOn() )
1004 par->setOn( false ); 1015 par->setOn( false );
1005 } 1016 }
1006 if (mPercentage[index] == 100) { 1017 if (mPercentage[index] == 100) {
1007 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1018 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1008 } else { 1019 } else {
1009 mActiveItem->todo()->setCompleted(false); 1020 mActiveItem->todo()->setCompleted(false);
1010 } 1021 }
1011 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1022 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1012 mActiveItem->construct(); 1023 mActiveItem->construct();
1013 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1024 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1014 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1025 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1015 } 1026 }
1016} 1027}
1017 1028
1018 1029
1019QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 1030QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
1020{ 1031{
1021 QPopupMenu* tempMenu = new QPopupMenu (this); 1032 QPopupMenu* tempMenu = new QPopupMenu (this);
1022 QStringList checkedCategories = todoItem->todo()->categories (); 1033 QStringList checkedCategories = todoItem->todo()->categories ();
1023 1034
1024 tempMenu->setCheckable (true); 1035 tempMenu->setCheckable (true);
1025 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1036 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1026 it != KOPrefs::instance()->mCustomCategories.end (); 1037 it != KOPrefs::instance()->mCustomCategories.end ();
1027 ++it) { 1038 ++it) {
1028 int index = tempMenu->insertItem (*it); 1039 int index = tempMenu->insertItem (*it);
1029 mCategory[index] = *it; 1040 mCategory[index] = *it;
1030 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 1041 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
1031 } 1042 }
1032 1043
1033 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 1044 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
1034 return tempMenu; 1045 return tempMenu;
1035 1046
1036 1047
1037} 1048}
1038void KOTodoView::changedCategories(int index) 1049void KOTodoView::changedCategories(int index)
1039{ 1050{
1040 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1051 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1041 QStringList categories = mActiveItem->todo()->categories (); 1052 QStringList categories = mActiveItem->todo()->categories ();
1042 QString colcat = categories.first(); 1053 QString colcat = categories.first();
1043 if (categories.find (mCategory[index]) != categories.end ()) 1054 if (categories.find (mCategory[index]) != categories.end ())
1044 categories.remove (mCategory[index]); 1055 categories.remove (mCategory[index]);
1045 else 1056 else
1046 categories.insert (categories.end(), mCategory[index]); 1057 categories.insert (categories.end(), mCategory[index]);
1047 categories.sort (); 1058 categories.sort ();
1048 if ( !colcat.isEmpty() ) { 1059 if ( !colcat.isEmpty() ) {
1049 if ( categories.find ( colcat ) != categories.end () ) { 1060 if ( categories.find ( colcat ) != categories.end () ) {
1050 categories.remove( colcat ); 1061 categories.remove( colcat );
1051 categories.prepend( colcat ); 1062 categories.prepend( colcat );
1052 } 1063 }
1053 } 1064 }
1054 mActiveItem->todo()->setCategories (categories); 1065 mActiveItem->todo()->setCategories (categories);
1055 mActiveItem->construct(); 1066 mActiveItem->construct();
1056 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1067 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1057 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1068 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1058 } 1069 }
1059} 1070}
1060void KOTodoView::itemDoubleClicked(QListViewItem *item) 1071void KOTodoView::itemDoubleClicked(QListViewItem *item)
1061{ 1072{
1062 if ( pendingSubtodo != 0 ) { 1073 if ( pendingSubtodo != 0 ) {
1063 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1074 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1064 } 1075 }
1065 pendingSubtodo = 0; 1076 pendingSubtodo = 0;
1077 int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1078 //qDebug("ROW %d ", row);
1066 if (!item) { 1079 if (!item) {
1067 newTodo(); 1080 newTodo();
1068 return; 1081 return;
1082 } else {
1083 if ( row == 1 ) {
1084 mActiveItem = (KOTodoViewItem *) item;
1085 newSubTodo();
1086 return;
1087 }
1069 } 1088 }
1070 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1089 if ( KOPrefs::instance()->mEditOnDoubleClick )
1071 editItem( item ); 1090 editItem( item );
1072 else 1091 else
1073 showItem( item , QPoint(), 0 ); 1092 showItem( item , QPoint(), 0 );
1074} 1093}
1075void KOTodoView::itemClicked(QListViewItem *item) 1094void KOTodoView::itemClicked(QListViewItem *item)
1076{ 1095{
1077 1096 //qDebug("KOTodoView::itemClicked %d", item);
1078 if (!item) { 1097 if (!item) {
1079 if ( pendingSubtodo != 0 ) { 1098 if ( pendingSubtodo != 0 ) {
1080 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1099 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1081 } 1100 }
1082 pendingSubtodo = 0; 1101 pendingSubtodo = 0;
1083 return; 1102 return;
1084 } 1103 }
1085 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1104 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1086 if ( pendingSubtodo != 0 ) { 1105 if ( pendingSubtodo != 0 ) {
1087 bool allowReparent = true; 1106 bool allowReparent = true;
1088 QListViewItem *par = item; 1107 QListViewItem *par = item;
1089 while ( par ) { 1108 while ( par ) {
1090 if ( par == pendingSubtodo ) { 1109 if ( par == pendingSubtodo ) {
1091 allowReparent = false; 1110 allowReparent = false;
1092 break; 1111 break;
1093 } 1112 }
1094 par = par->parent(); 1113 par = par->parent();
1095 } 1114 }
1096 if ( !allowReparent ) { 1115 if ( !allowReparent ) {
1097 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1116 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1098 qDebug("Recursive reparenting not possible "); 1117 qDebug("Recursive reparenting not possible ");
1099 pendingSubtodo = 0; 1118 pendingSubtodo = 0;
1100 } else { 1119 } else {
1101 Todo* newParent = todoItem->todo(); 1120 Todo* newParent = todoItem->todo();
1102 Todo* newSub = pendingSubtodo->todo(); 1121 Todo* newSub = pendingSubtodo->todo();
1103 pendingSubtodo = 0; 1122 pendingSubtodo = 0;
1104 emit reparentTodoSignal( newParent,newSub ); 1123 emit reparentTodoSignal( newParent,newSub );
1105 return; 1124 return;
1106 } 1125 }
1107 } 1126 }
1108#if 0 1127#if 0
1109 // handled by the item itself 1128 // handled by the item itself
1110 bool completed = todoItem->todo()->isCompleted(); // Completed or not? 1129 bool completed = todoItem->todo()->isCompleted(); // Completed or not?
1111 qDebug("com %d ",completed ); 1130 qDebug("com %d ",completed );
1112 qDebug("itemclicked "); 1131 qDebug("itemclicked ");
1113 if (todoItem->isOn()) { 1132 if (todoItem->isOn()) {
1114 qDebug("on "); 1133 qDebug("on ");
1115 if (!completed) { 1134 if (!completed) {
1116 qDebug("set true "); 1135 qDebug("set true ");
1117 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 1136 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
1118 } 1137 }
1119 } else { 1138 } else {
1120 qDebug("not on "); 1139 qDebug("not on ");
1121 if (completed) { 1140 if (completed) {
1122 qDebug("set false "); 1141 qDebug("set false ");
1123 todoItem->todo()->setCompleted(false); 1142 todoItem->todo()->setCompleted(false);
1124 } 1143 }
1125 } 1144 }
1126#endif 1145#endif
1127} 1146}
1128 1147
1129void KOTodoView::setDocumentId( const QString &id ) 1148void KOTodoView::setDocumentId( const QString &id )
1130{ 1149{
1131 kdDebug() << "KOTodoView::setDocumentId()" << endl; 1150 kdDebug() << "KOTodoView::setDocumentId()" << endl;
1132 1151
1133 mDocPrefs->setDoc( id ); 1152 mDocPrefs->setDoc( id );
1134} 1153}
1135 1154
1136void KOTodoView::itemStateChanged( QListViewItem *item ) 1155void KOTodoView::itemStateChanged( QListViewItem *item )
1137{ 1156{
1138 if (!item) return; 1157 if (!item) return;
1139 1158
1140 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1159 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1141 1160
1142// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1161// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1143 1162
1144 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1163 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1145} 1164}
1146 1165
1147void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1166void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1148{ 1167{
1149 mTodoListView->saveLayout(config,group); 1168 mTodoListView->saveLayout(config,group);
1150} 1169}
1151 1170
1152void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1171void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1153{ 1172{
1154 mTodoListView->restoreLayout(config,group); 1173 mTodoListView->restoreLayout(config,group);
1155} 1174}
1156 1175
1157void KOTodoView::processSelectionChange() 1176void KOTodoView::processSelectionChange()
1158{ 1177{
1159// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1178// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1160 1179
1161 KOTodoViewItem *item = 1180 KOTodoViewItem *item =
1162 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1181 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1163 1182
1164 if ( !item ) { 1183 if ( !item ) {
1165 emit incidenceSelected( 0 ); 1184 emit incidenceSelected( 0 );
1166 } else { 1185 } else {
1167 emit incidenceSelected( item->todo() ); 1186 emit incidenceSelected( item->todo() );
1168 } 1187 }
1169} 1188}
1170 1189
1171void KOTodoView::modified(bool b) 1190void KOTodoView::modified(bool b)
1172{ 1191{
1173 emit isModified(b); 1192 emit isModified(b);