summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-05-24 19:56:05 (UTC)
committer zautrix <zautrix>2005-05-24 19:56:05 (UTC)
commitbebdc6ca63f4bcbfb735c3d75710ca53959ef48f (patch) (unidiff)
treeed755ca04104d571799e91a31443fe94bbf00fdd
parentb441ef64338079e3e29c07d8884a02588050a54a (diff)
downloadkdepimpi-bebdc6ca63f4bcbfb735c3d75710ca53959ef48f.zip
kdepimpi-bebdc6ca63f4bcbfb735c3d75710ca53959ef48f.tar.gz
kdepimpi-bebdc6ca63f4bcbfb735c3d75710ca53959ef48f.tar.bz2
menu fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 355f4bb..99009a5 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -128,630 +128,632 @@ void MarcusBains::updateLocation(bool recalculate)
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 mAllAgendaPopup = 0; 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 mAllAgendaPopup = 0;
191 blockResize = false; 191 blockResize = false;
192 mColumns = columns; 192 mColumns = columns;
193 mRows = 1; 193 mRows = 1;
194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
195 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 195 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
196 mAllDayMode = true; 196 mAllDayMode = true;
197#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
198 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 198 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
199#endif 199#endif
200 mHolidayMask = 0; 200 mHolidayMask = 0;
201 init(); 201 init();
202} 202}
203 203
204 204
205KOAgenda::~KOAgenda() 205KOAgenda::~KOAgenda()
206{ 206{
207 if(mMarcusBains) delete mMarcusBains; 207 if(mMarcusBains) delete mMarcusBains;
208 208
209} 209}
210 210
211Incidence *KOAgenda::selectedIncidence() const 211Incidence *KOAgenda::selectedIncidence() const
212{ 212{
213 return (mSelectedItem ? mSelectedItem->incidence() : 0); 213 return (mSelectedItem ? mSelectedItem->incidence() : 0);
214} 214}
215 215
216 216
217QDate KOAgenda::selectedIncidenceDate() const 217QDate KOAgenda::selectedIncidenceDate() const
218{ 218{
219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
220} 220}
221 221
222 222
223void KOAgenda::init() 223void KOAgenda::init()
224{ 224{
225 mPopupTimer = new QTimer(this); 225 mPopupTimer = new QTimer(this);
226 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 226 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
227 227
228 mNewItemPopup = new QPopupMenu( this ); 228 mNewItemPopup = new QPopupMenu( this );
229 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 229 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
230 QString pathString = ""; 230 QString pathString = "";
231 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 231 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
232 if ( QApplication::desktop()->width() < 480 ) 232 if ( QApplication::desktop()->width() < 480 )
233 pathString += "icons16/"; 233 pathString += "icons16/";
234 } else 234 } else
235 pathString += "iconsmini/"; 235 pathString += "iconsmini/";
236 236
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
238 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 238 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
239 mNewItemPopup->insertSeparator ( ); 239 mNewItemPopup->insertSeparator ( );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
245 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 245 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
246#ifndef _WIN32_ 246#ifndef _WIN32_
247 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 247 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
248 viewport()->setWFlags ( wflags); 248 viewport()->setWFlags ( wflags);
249#endif 249#endif
250 mGridSpacingX = 80; 250 mGridSpacingX = 80;
251 mResizeBorderWidth = 8; 251 mResizeBorderWidth = 8;
252 mScrollBorderWidth = 8; 252 mScrollBorderWidth = 8;
253 mScrollDelay = 30; 253 mScrollDelay = 30;
254 mScrollOffset = 10; 254 mScrollOffset = 10;
255 mPaintPixmap.resize( 20,20); 255 mPaintPixmap.resize( 20,20);
256 //enableClipper(true); 256 //enableClipper(true);
257 257
258 // 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
259 // effect. Has to be fixed. 259 // effect. Has to be fixed.
260 setFocusPolicy(WheelFocus); 260 setFocusPolicy(WheelFocus);
261 261
262 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 262 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
263 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 263 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
264 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 264 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
265 265
266 mStartCellX = 0; 266 mStartCellX = 0;
267 mStartCellY = 0; 267 mStartCellY = 0;
268 mCurrentCellX = 0; 268 mCurrentCellX = 0;
269 mCurrentCellY = 0; 269 mCurrentCellY = 0;
270 270
271 mSelectionCellX = 0; 271 mSelectionCellX = 0;
272 mSelectionYTop = 0; 272 mSelectionYTop = 0;
273 mSelectionHeight = 0; 273 mSelectionHeight = 0;
274 274
275 mOldLowerScrollValue = -1; 275 mOldLowerScrollValue = -1;
276 mOldUpperScrollValue = -1; 276 mOldUpperScrollValue = -1;
277 277
278 mClickedItem = 0; 278 mClickedItem = 0;
279 279
280 mActionItem = 0; 280 mActionItem = 0;
281 mActionType = NOP; 281 mActionType = NOP;
282 mItemMoved = false; 282 mItemMoved = false;
283 283
284 mSelectedItem = 0; 284 mSelectedItem = 0;
285 285
286 // mItems.setAutoDelete(true); 286 // mItems.setAutoDelete(true);
287 287
288 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 288 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
289 289
290 viewport()->update(); 290 viewport()->update();
291 291
292 setMinimumSize(30, 1); 292 setMinimumSize(30, 1);
293// setMaximumHeight(mGridSpacingY * mRows + 5); 293// setMaximumHeight(mGridSpacingY * mRows + 5);
294 294
295 // Disable horizontal scrollbar. This is a hack. The geometry should be 295 // Disable horizontal scrollbar. This is a hack. The geometry should be
296 // 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
297 // not necessary to turn off the scrollbar. 297 // not necessary to turn off the scrollbar.
298 setHScrollBarMode(AlwaysOff); 298 setHScrollBarMode(AlwaysOff);
299 if ( ! mAllDayMode ) 299 if ( ! mAllDayMode )
300 setVScrollBarMode(AlwaysOn); 300 setVScrollBarMode(AlwaysOn);
301 else 301 else
302 setVScrollBarMode(AlwaysOff); 302 setVScrollBarMode(AlwaysOff);
303 303
304 setStartHour(KOPrefs::instance()->mDayBegins); 304 setStartHour(KOPrefs::instance()->mDayBegins);
305 305
306 calculateWorkingHours(); 306 calculateWorkingHours();
307 307
308 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 308 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
309 SLOT(checkScrollBoundaries(int))); 309 SLOT(checkScrollBoundaries(int)));
310 310
311 // Create the Marcus Bains line. 311 // Create the Marcus Bains line.
312 if(mAllDayMode) 312 if(mAllDayMode)
313 mMarcusBains = 0; 313 mMarcusBains = 0;
314 else { 314 else {
315 mMarcusBains = new MarcusBains(this); 315 mMarcusBains = new MarcusBains(this);
316 addChild(mMarcusBains); 316 addChild(mMarcusBains);
317 } 317 }
318 mPopupKind = 0; 318 mPopupKind = 0;
319 mPopupItem = 0; 319 mPopupItem = 0;
320} 320}
321 321
322void KOAgenda::clear() 322void KOAgenda::clear()
323{ 323{
324 KOAgendaItem *item; 324 KOAgendaItem *item;
325 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 325 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
326 mUnusedItems.append( item ); 326 mUnusedItems.append( item );
327 //item->hide(); 327 //item->hide();
328 } 328 }
329 mItems.clear(); 329 mItems.clear();
330 mSelectedItem = 0; 330 mSelectedItem = 0;
331 clearSelection(); 331 clearSelection();
332} 332}
333 333
334void KOAgenda::clearSelection() 334void KOAgenda::clearSelection()
335{ 335{
336 mSelectionCellX = 0; 336 mSelectionCellX = 0;
337 mSelectionYTop = 0; 337 mSelectionYTop = 0;
338 mSelectionHeight = 0; 338 mSelectionHeight = 0;
339} 339}
340 340
341void KOAgenda::marcus_bains() 341void KOAgenda::marcus_bains()
342{ 342{
343 if(mMarcusBains) mMarcusBains->updateLocation(true); 343 if(mMarcusBains) mMarcusBains->updateLocation(true);
344} 344}
345 345
346 346
347void KOAgenda::changeColumns(int columns) 347void KOAgenda::changeColumns(int columns)
348{ 348{
349 if (columns == 0) { 349 if (columns == 0) {
350 qDebug("KOAgenda::changeColumns() called with argument 0 "); 350 qDebug("KOAgenda::changeColumns() called with argument 0 ");
351 return; 351 return;
352 } 352 }
353 clear(); 353 clear();
354 mColumns = columns; 354 mColumns = columns;
355 computeSizes(); 355 computeSizes();
356} 356}
357 357
358/* 358/*
359 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
360 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.
361*/ 361*/
362bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 362bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
363{ 363{
364 // kdDebug() << "KOAgenda::eventFilter" << endl; 364 // kdDebug() << "KOAgenda::eventFilter" << endl;
365 switch(event->type()) { 365 switch(event->type()) {
366 case QEvent::MouseButtonPress: 366 case QEvent::MouseButtonPress:
367 case QEvent::MouseButtonDblClick: 367 case QEvent::MouseButtonDblClick:
368 case QEvent::MouseButtonRelease: 368 case QEvent::MouseButtonRelease:
369 case QEvent::MouseMove: 369 case QEvent::MouseMove:
370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
371 371
372 case (QEvent::Leave): 372 case (QEvent::Leave):
373 if (!mActionItem) 373 if (!mActionItem)
374 setCursor(arrowCursor); 374 setCursor(arrowCursor);
375 return true; 375 return true;
376 376
377 default: 377 default:
378 return QScrollView::eventFilter(object,event); 378 return QScrollView::eventFilter(object,event);
379 } 379 }
380} 380}
381void KOAgenda::popupMenu() 381void KOAgenda::popupMenu()
382{ 382{
383 mPopupTimer->stop(); 383 mPopupTimer->stop();
384 if ( mPopupKind == 1 ) { 384 if ( mPopupKind == 1 || mPopupKind == 3 ) {
385 if (mActionItem ) { 385 if (mActionItem ) {
386 endItemAction(); 386 endItemAction();
387 } 387 }
388 mLeftMouseDown = false; // no more leftMouse computation 388 mLeftMouseDown = false; // no more leftMouse computation
389 if (mPopupItem) { 389 if (mPopupItem) {
390 //mClickedItem = mPopupItem; 390 //mClickedItem = mPopupItem;
391 selectItem(mPopupItem); 391 selectItem(mPopupItem);
392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu ) 392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 )
393 mAllAgendaPopup->installEventFilter( this ); 393 mAllAgendaPopup->installEventFilter( this );
394 emit showIncidencePopupSignal(mPopupItem->incidence()); 394 emit showIncidencePopupSignal(mPopupItem->incidence());
395 395
396 } 396 }
397 } else if ( mPopupKind == 2 ) { 397 } else if ( mPopupKind == 2 || mPopupKind == 4 ) {
398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
399 endSelectAction( false ); // do not emit new event signal 399 endSelectAction( false ); // do not emit new event signal
400 mLeftMouseDown = false; // no more leftMouse computation 400 mLeftMouseDown = false; // no more leftMouse computation
401 } 401 }
402 if ( KOPrefs::instance()->mBlockPopupMenu ) 402 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 )
403 mNewItemPopup->installEventFilter( this ); 403 mNewItemPopup->installEventFilter( this );
404 mNewItemPopup->popup( mPopupPos); 404 mNewItemPopup->popup( mPopupPos);
405 405
406 } 406 }
407 mLeftMouseDown = false; 407 mLeftMouseDown = false;
408 mPopupItem = 0; 408 mPopupItem = 0;
409 mPopupKind = 0; 409 mPopupKind = 0;
410} 410}
411 411
412bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 412bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
413{ 413{
414 static int startX = 0; 414 static int startX = 0;
415 static int startY = 0; 415 static int startY = 0;
416 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 416 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
417 static bool blockMoving = true; 417 static bool blockMoving = true;
418 418
419 //qDebug("KOAgenda::eventFilter_mous "); 419 //qDebug("KOAgenda::eventFilter_mous ");
420 if ( object == mNewItemPopup ) { 420 if ( object == mNewItemPopup ) {
421 //qDebug("mNewItemPopup "); 421 //qDebug("mNewItemPopup ");
422 if ( me->type() == QEvent::MouseButtonRelease ) { 422 if ( me->type() == QEvent::MouseButtonRelease ) {
423 mNewItemPopup->removeEventFilter( this ); 423 mNewItemPopup->removeEventFilter( this );
424 int dX = me->globalPos().x() - mPopupPos.x();; 424 int dX = me->globalPos().x() - mPopupPos.x();;
425 if ( dX < 0 ) 425 if ( dX < 0 )
426 dX = -dX; 426 dX = -dX;
427 int dY = me->globalPos().y() - mPopupPos.y(); 427 int dY = me->globalPos().y() - mPopupPos.y();
428 if ( dY < 0 ) 428 if ( dY < 0 )
429 dY = -dY; 429 dY = -dY;
430 if ( dX > blockmoveDist || dY > blockmoveDist ) { 430 if ( dX > blockmoveDist || dY > blockmoveDist ) {
431 mNewItemPopup->hide(); 431 mNewItemPopup->hide();
432 } 432 }
433 } 433 }
434 return true; 434 return true;
435 } 435 }
436 if ( object == mAllAgendaPopup ) { 436 if ( object == mAllAgendaPopup ) {
437 //qDebug(" mAllAgendaPopup "); 437 //qDebug(" mAllAgendaPopup ");
438 if ( me->type() == QEvent::MouseButtonRelease ) { 438 if ( me->type() == QEvent::MouseButtonRelease ) {
439 mAllAgendaPopup->removeEventFilter( this ); 439 mAllAgendaPopup->removeEventFilter( this );
440 int dX = me->globalPos().x() - mPopupPos.x();; 440 int dX = me->globalPos().x() - mPopupPos.x();;
441 if ( dX < 0 ) 441 if ( dX < 0 )
442 dX = -dX; 442 dX = -dX;
443 int dY = me->globalPos().y() - mPopupPos.y(); 443 int dY = me->globalPos().y() - mPopupPos.y();
444 if ( dY < 0 ) 444 if ( dY < 0 )
445 dY = -dY; 445 dY = -dY;
446 if ( dX > blockmoveDist || dY > blockmoveDist ) { 446 if ( dX > blockmoveDist || dY > blockmoveDist ) {
447 mAllAgendaPopup->hide(); 447 mAllAgendaPopup->hide();
448 } 448 }
449 } 449 }
450 return true; 450 return true;
451 } 451 }
452 QPoint viewportPos; 452 QPoint viewportPos;
453 if (object != viewport()) { 453 if (object != viewport()) {
454 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 454 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
455 } else { 455 } else {
456 viewportPos = me->pos(); 456 viewportPos = me->pos();
457 } 457 }
458 458
459 switch (me->type()) { 459 switch (me->type()) {
460 case QEvent::MouseButtonPress: 460 case QEvent::MouseButtonPress:
461 if (me->button() == LeftButton) { 461 if (me->button() == LeftButton) {
462 mPopupTimer->start( 600 ); 462 mPopupTimer->start( 600 );
463 mLeftMouseDown = true; 463 mLeftMouseDown = true;
464 } 464 }
465 blockMoving = true; 465 blockMoving = true;
466 startX = viewportPos.x(); 466 startX = viewportPos.x();
467 startY = viewportPos.y(); 467 startY = viewportPos.y();
468 mPopupPos = me->globalPos(); 468 mPopupPos = me->globalPos();
469 if (object != viewport()) { 469 if (object != viewport()) {
470 mPopupItem = (KOAgendaItem *)object; 470 mPopupItem = (KOAgendaItem *)object;
471 mPopupKind = 1; 471 mPopupKind = 1;
472 if (me->button() == RightButton) { 472 if (me->button() == RightButton) {
473 mPopupKind = 3;
473 popupMenu(); 474 popupMenu();
474 } else if (me->button() == LeftButton) { 475 } else if (me->button() == LeftButton) {
475 mActionItem = (KOAgendaItem *)object; 476 mActionItem = (KOAgendaItem *)object;
476 if (mActionItem) { 477 if (mActionItem) {
477 emit signalClearSelection(); 478 emit signalClearSelection();
478 slotClearSelection(); 479 slotClearSelection();
479 selectItem(mActionItem); 480 selectItem(mActionItem);
480 Incidence *incidence = mActionItem->incidence(); 481 Incidence *incidence = mActionItem->incidence();
481 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 482 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
482 mActionItem = 0; 483 mActionItem = 0;
483 } else { 484 } else {
484 startItemAction(viewportPos); 485 startItemAction(viewportPos);
485 } 486 }
486 } 487 }
487 } 488 }
488 } else { // ---------- viewport() 489 } else { // ---------- viewport()
489 mPopupItem = 0; 490 mPopupItem = 0;
490 mPopupKind = 2; 491 mPopupKind = 2;
491 selectItem(0); 492 selectItem(0);
492 mActionItem = 0; 493 mActionItem = 0;
493 if (me->button() == RightButton) { 494 if (me->button() == RightButton) {
494 int x,y; 495 int x,y;
495 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 496 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
496 int gx,gy; 497 int gx,gy;
497 contentsToGrid(x,y,gx,gy); 498 contentsToGrid(x,y,gx,gy);
498 mCurrentCellX = gx; 499 mCurrentCellX = gx;
499 mCurrentCellY = gy; 500 mCurrentCellY = gy;
500 mStartCellX = gx; 501 mStartCellX = gx;
501 mStartCellY = gy; 502 mStartCellY = gy;
503 mPopupKind = 4;
502 popupMenu(); 504 popupMenu();
503 } else if (me->button() == LeftButton) { 505 } else if (me->button() == LeftButton) {
504 setCursor(arrowCursor); 506 setCursor(arrowCursor);
505 startSelectAction(viewportPos); 507 startSelectAction(viewportPos);
506 } 508 }
507 } 509 }
508 break; 510 break;
509 511
510 case QEvent::MouseButtonRelease: 512 case QEvent::MouseButtonRelease:
511 if (me->button() == LeftButton ) { 513 if (me->button() == LeftButton ) {
512 mPopupTimer->stop(); 514 mPopupTimer->stop();
513 } 515 }
514 if (object != viewport()) { 516 if (object != viewport()) {
515 if (me->button() == LeftButton && mLeftMouseDown) { 517 if (me->button() == LeftButton && mLeftMouseDown) {
516 if (mActionItem) { 518 if (mActionItem) {
517 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 519 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
518 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 520 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
519 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 521 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
520 mScrollUpTimer.stop(); 522 mScrollUpTimer.stop();
521 mScrollDownTimer.stop(); 523 mScrollDownTimer.stop();
522 mActionItem->resetMove(); 524 mActionItem->resetMove();
523 placeSubCells( mActionItem ); 525 placeSubCells( mActionItem );
524 // emit startDragSignal( mActionItem->incidence() ); 526 // emit startDragSignal( mActionItem->incidence() );
525 setCursor( arrowCursor ); 527 setCursor( arrowCursor );
526 mActionItem = 0; 528 mActionItem = 0;
527 mActionType = NOP; 529 mActionType = NOP;
528 mItemMoved = 0; 530 mItemMoved = 0;
529 mLeftMouseDown = false; 531 mLeftMouseDown = false;
530 return true; 532 return true;
531 } 533 }
532 endItemAction(); 534 endItemAction();
533 } 535 }
534 } 536 }
535 537
536 } else { // ---------- viewport() 538 } else { // ---------- viewport()
537 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 539 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
538 endSelectAction( true ); // emit new event signal 540 endSelectAction( true ); // emit new event signal
539 } 541 }
540 } 542 }
541 if (me->button() == LeftButton) 543 if (me->button() == LeftButton)
542 mLeftMouseDown = false; 544 mLeftMouseDown = false;
543 545
544 break; 546 break;
545 547
546 case QEvent::MouseMove: 548 case QEvent::MouseMove:
547 //qDebug("mm "); 549 //qDebug("mm ");
548 if ( !mLeftMouseDown ) 550 if ( !mLeftMouseDown )
549 return false; 551 return false;
550 if ( blockMoving ) { 552 if ( blockMoving ) {
551 int dX, dY; 553 int dX, dY;
552 dX = startX - viewportPos.x(); 554 dX = startX - viewportPos.x();
553 if ( dX < 0 ) 555 if ( dX < 0 )
554 dX = -dX; 556 dX = -dX;
555 dY = viewportPos.y() - startY; 557 dY = viewportPos.y() - startY;
556 if ( dY < 0 ) 558 if ( dY < 0 )
557 dY = -dY; 559 dY = -dY;
558 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 560 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
559 if ( dX > blockmoveDist || dY > blockmoveDist ) { 561 if ( dX > blockmoveDist || dY > blockmoveDist ) {
560 blockMoving = false; 562 blockMoving = false;
561 } 563 }
562 } 564 }
563 if ( ! blockMoving ) 565 if ( ! blockMoving )
564 mPopupTimer->stop(); 566 mPopupTimer->stop();
565 if (object != viewport()) { 567 if (object != viewport()) {
566 KOAgendaItem *moveItem = (KOAgendaItem *)object; 568 KOAgendaItem *moveItem = (KOAgendaItem *)object;
567 if (!moveItem->incidence()->isReadOnly() ) { 569 if (!moveItem->incidence()->isReadOnly() ) {
568 if (!mActionItem) 570 if (!mActionItem)
569 setNoActionCursor(moveItem,viewportPos); 571 setNoActionCursor(moveItem,viewportPos);
570 else { 572 else {
571 if ( !blockMoving ) 573 if ( !blockMoving )
572 performItemAction(viewportPos); 574 performItemAction(viewportPos);
573 } 575 }
574 } 576 }
575 } else { // ---------- viewport() 577 } else { // ---------- viewport()
576 mPopupPos = viewport()->mapToGlobal( me->pos() ); 578 mPopupPos = viewport()->mapToGlobal( me->pos() );
577 if ( mActionType == SELECT ) { 579 if ( mActionType == SELECT ) {
578 performSelectAction( viewportPos ); 580 performSelectAction( viewportPos );
579 } 581 }
580 } 582 }
581 break; 583 break;
582 584
583 case QEvent::MouseButtonDblClick: 585 case QEvent::MouseButtonDblClick:
584 mPopupTimer->stop(); 586 mPopupTimer->stop();
585 if (object == viewport()) { 587 if (object == viewport()) {
586 selectItem(0); 588 selectItem(0);
587 int x,y; 589 int x,y;
588 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 590 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
589 int gx,gy; 591 int gx,gy;
590 contentsToGrid(x,y,gx,gy); 592 contentsToGrid(x,y,gx,gy);
591 emit newEventSignal(gx,gy); 593 emit newEventSignal(gx,gy);
592 } else { 594 } else {
593 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 595 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
594 selectItem(doubleClickedItem); 596 selectItem(doubleClickedItem);
595 if ( KOPrefs::instance()->mEditOnDoubleClick ) 597 if ( KOPrefs::instance()->mEditOnDoubleClick )
596 emit editIncidenceSignal(doubleClickedItem->incidence()); 598 emit editIncidenceSignal(doubleClickedItem->incidence());
597 else 599 else
598 emit showIncidenceSignal(doubleClickedItem->incidence()); 600 emit showIncidenceSignal(doubleClickedItem->incidence());
599 } 601 }
600 break; 602 break;
601 603
602 default: 604 default:
603 break; 605 break;
604 } 606 }
605 return true; 607 return true;
606 608
607} 609}
608 610
609void KOAgenda::newItem( int item ) 611void KOAgenda::newItem( int item )
610{ 612{
611 if ( item == 1 ) { //new event 613 if ( item == 1 ) { //new event
612 newEventSignal(mStartCellX ,mStartCellY ); 614 newEventSignal(mStartCellX ,mStartCellY );
613 } else 615 } else
614 if ( item == 2 ) { //new event 616 if ( item == 2 ) { //new event
615 newTodoSignal(mStartCellX ,mStartCellY ); 617 newTodoSignal(mStartCellX ,mStartCellY );
616 } else 618 } else
617 { 619 {
618 emit showDateView( item, mStartCellX ); 620 emit showDateView( item, mStartCellX );
619 // 3Day view 621 // 3Day view
620 // 4Week view 622 // 4Week view
621 // 5Month view 623 // 5Month view
622 // 6Journal view 624 // 6Journal view
623 } 625 }
624} 626}
625void KOAgenda::slotClearSelection() 627void KOAgenda::slotClearSelection()
626{ 628{
627 if (mSelectionHeight) { 629 if (mSelectionHeight) {
628 int selectionX = mSelectionCellX * mGridSpacingX; 630 int selectionX = mSelectionCellX * mGridSpacingX;
629 int top = mSelectionYTop - 2 *mGridSpacingY; 631 int top = mSelectionYTop - 2 *mGridSpacingY;
630 int hei = mSelectionHeight + 4 *mGridSpacingY; 632 int hei = mSelectionHeight + 4 *mGridSpacingY;
631 clearSelection(); 633 clearSelection();
632 repaintContents( selectionX, top, 634 repaintContents( selectionX, top,
633 mGridSpacingX, hei ,false ); 635 mGridSpacingX, hei ,false );
634 } 636 }
635 637
636} 638}
637void KOAgenda::startSelectAction(QPoint viewportPos) 639void KOAgenda::startSelectAction(QPoint viewportPos)
638{ 640{
639 641
640 emit signalClearSelection(); 642 emit signalClearSelection();
641 slotClearSelection(); 643 slotClearSelection();
642 644
643 mActionType = SELECT; 645 mActionType = SELECT;
644 646
645 int x,y; 647 int x,y;
646 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 648 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
647 int gx,gy; 649 int gx,gy;
648 contentsToGrid(x,y,gx,gy); 650 contentsToGrid(x,y,gx,gy);
649 651
650 mStartCellX = gx; 652 mStartCellX = gx;
651 mStartCellY = gy; 653 mStartCellY = gy;
652 mCurrentCellX = gx; 654 mCurrentCellX = gx;
653 mCurrentCellY = gy; 655 mCurrentCellY = gy;
654 656
655 // Store new selection 657 // Store new selection
656 mSelectionCellX = gx; 658 mSelectionCellX = gx;
657 mSelectionYTop = gy * mGridSpacingY; 659 mSelectionYTop = gy * mGridSpacingY;
658 mSelectionHeight = mGridSpacingY; 660 mSelectionHeight = mGridSpacingY;
659 661
660 // Paint new selection 662 // Paint new selection
661 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, 663 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop,
662 mGridSpacingX-1, mSelectionHeight ); 664 mGridSpacingX-1, mSelectionHeight );
663} 665}
664 666
665void KOAgenda::performSelectAction(QPoint viewportPos) 667void KOAgenda::performSelectAction(QPoint viewportPos)
666{ 668{
667 int x,y; 669 int x,y;
668 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 670 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
669 int gx,gy; 671 int gx,gy;
670 contentsToGrid(x,y,gx,gy); 672 contentsToGrid(x,y,gx,gy);
671 673
672 QPoint clipperPos = clipper()-> 674 QPoint clipperPos = clipper()->
673 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 675 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
674 676
675 // Scroll if cursor was moved to upper or lower end of agenda. 677 // Scroll if cursor was moved to upper or lower end of agenda.
676 if (clipperPos.y() < mScrollBorderWidth) { 678 if (clipperPos.y() < mScrollBorderWidth) {
677 mScrollUpTimer.start(mScrollDelay); 679 mScrollUpTimer.start(mScrollDelay);
678 } else if (visibleHeight() - clipperPos.y() < 680 } else if (visibleHeight() - clipperPos.y() <
679 mScrollBorderWidth) { 681 mScrollBorderWidth) {
680 mScrollDownTimer.start(mScrollDelay); 682 mScrollDownTimer.start(mScrollDelay);
681 } else { 683 } else {
682 mScrollUpTimer.stop(); 684 mScrollUpTimer.stop();
683 mScrollDownTimer.stop(); 685 mScrollDownTimer.stop();
684 } 686 }
685 687
686 if ( gy > mCurrentCellY ) { 688 if ( gy > mCurrentCellY ) {
687 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 689 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
688 690
689 691
690 repaintContents( (KOGlobals::self()->reverseLayout() ? 692 repaintContents( (KOGlobals::self()->reverseLayout() ?
691 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 693 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
692 mGridSpacingX, mSelectionYTop, 694 mGridSpacingX, mSelectionYTop,
693 mGridSpacingX, mSelectionHeight , false); 695 mGridSpacingX, mSelectionHeight , false);
694 696
695 mCurrentCellY = gy; 697 mCurrentCellY = gy;
696 } else if ( gy < mCurrentCellY ) { 698 } else if ( gy < mCurrentCellY ) {
697 if ( gy >= mStartCellY ) { 699 if ( gy >= mStartCellY ) {
698 int selectionHeight = mSelectionHeight; 700 int selectionHeight = mSelectionHeight;
699 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 701 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
700 702
701 repaintContents( (KOGlobals::self()->reverseLayout() ? 703 repaintContents( (KOGlobals::self()->reverseLayout() ?
702 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 704 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
703 mGridSpacingX, mSelectionYTop, 705 mGridSpacingX, mSelectionYTop,
704 mGridSpacingX, selectionHeight,false ); 706 mGridSpacingX, selectionHeight,false );
705 707
706 mCurrentCellY = gy; 708 mCurrentCellY = gy;
707 } else { 709 } else {
708 } 710 }
709 } 711 }
710} 712}
711 713
712void KOAgenda::endSelectAction( bool emitNewEvent ) 714void KOAgenda::endSelectAction( bool emitNewEvent )
713{ 715{
714 mActionType = NOP; 716 mActionType = NOP;
715 mScrollUpTimer.stop(); 717 mScrollUpTimer.stop();
716 mScrollDownTimer.stop(); 718 mScrollDownTimer.stop();
717 719
718 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 720 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
719 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 721 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
720 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 722 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
721 } 723 }
722} 724}
723 725
724void KOAgenda::startItemAction(QPoint viewportPos) 726void KOAgenda::startItemAction(QPoint viewportPos)
725{ 727{
726 int x,y; 728 int x,y;
727 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 729 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
728 int gx,gy; 730 int gx,gy;
729 contentsToGrid(x,y,gx,gy); 731 contentsToGrid(x,y,gx,gy);
730 732
731 mStartCellX = gx; 733 mStartCellX = gx;
732 mStartCellY = gy; 734 mStartCellY = gy;
733 mCurrentCellX = gx; 735 mCurrentCellX = gx;
734 mCurrentCellY = gy; 736 mCurrentCellY = gy;
735 737
736 if (mAllDayMode) { 738 if (mAllDayMode) {
737 int gridDistanceX = (x - gx * mGridSpacingX); 739 int gridDistanceX = (x - gx * mGridSpacingX);
738 if (gridDistanceX < mResizeBorderWidth && 740 if (gridDistanceX < mResizeBorderWidth &&
739 mActionItem->cellX() == mCurrentCellX) { 741 mActionItem->cellX() == mCurrentCellX) {
740 mActionType = RESIZELEFT; 742 mActionType = RESIZELEFT;
741 setCursor(sizeHorCursor); 743 setCursor(sizeHorCursor);
742 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 744 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
743 mActionItem->cellXWidth() == mCurrentCellX) { 745 mActionItem->cellXWidth() == mCurrentCellX) {
744 mActionType = RESIZERIGHT; 746 mActionType = RESIZERIGHT;
745 setCursor(sizeHorCursor); 747 setCursor(sizeHorCursor);
746 } else { 748 } else {
747 mActionType = MOVE; 749 mActionType = MOVE;
748 mActionItem->startMove(); 750 mActionItem->startMove();
749 setCursor(sizeAllCursor); 751 setCursor(sizeAllCursor);
750 } 752 }
751 } else { 753 } else {
752 int gridDistanceY = (y - gy * mGridSpacingY); 754 int gridDistanceY = (y - gy * mGridSpacingY);
753 bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); 755 bool allowResize = ( mActionItem->incidence()->type() != "Todo" );
754 if (allowResize && gridDistanceY < mResizeBorderWidth && 756 if (allowResize && gridDistanceY < mResizeBorderWidth &&
755 mActionItem->cellYTop() == mCurrentCellY && 757 mActionItem->cellYTop() == mCurrentCellY &&
756 !mActionItem->firstMultiItem()) { 758 !mActionItem->firstMultiItem()) {
757 mActionType = RESIZETOP; 759 mActionType = RESIZETOP;