summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-21 09:12:37 (UTC)
committer zautrix <zautrix>2005-03-21 09:12:37 (UTC)
commit9707cf053ab0e64949518ebd2729d432435f583c (patch) (unidiff)
treedad8fca3e1eafc17062f1f183f50bfdb3fac5b8b /korganizer
parente0351d382e7344191c3a7963eefe3396f816f7a0 (diff)
downloadkdepimpi-9707cf053ab0e64949518ebd2729d432435f583c.zip
kdepimpi-9707cf053ab0e64949518ebd2729d432435f583c.tar.gz
kdepimpi-9707cf053ab0e64949518ebd2729d432435f583c.tar.bz2
agenda mouse fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 8c2996b..dcb46a8 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -82,193 +82,193 @@ MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
82 82
83 oldToday = -1; 83 oldToday = -1;
84} 84}
85 85
86MarcusBains::~MarcusBains() 86MarcusBains::~MarcusBains()
87{ 87{
88 delete minutes; 88 delete minutes;
89} 89}
90 90
91int MarcusBains::todayColumn() 91int MarcusBains::todayColumn()
92{ 92{
93 QDate currentDate = QDate::currentDate(); 93 QDate currentDate = QDate::currentDate();
94 94
95 DateList dateList = agenda->dateList(); 95 DateList dateList = agenda->dateList();
96 DateList::ConstIterator it; 96 DateList::ConstIterator it;
97 int col = 0; 97 int col = 0;
98 for(it = dateList.begin(); it != dateList.end(); ++it) { 98 for(it = dateList.begin(); it != dateList.end(); ++it) {
99 if((*it) == currentDate) 99 if((*it) == currentDate)
100 return KOGlobals::self()->reverseLayout() ? 100 return KOGlobals::self()->reverseLayout() ?
101 agenda->columns() - 1 - col : col; 101 agenda->columns() - 1 - col : col;
102 ++col; 102 ++col;
103 } 103 }
104 104
105 return -1; 105 return -1;
106} 106}
107void MarcusBains::updateLoc() 107void MarcusBains::updateLoc()
108{ 108{
109 updateLocation(); 109 updateLocation();
110} 110}
111void MarcusBains::updateLocation(bool recalculate) 111void MarcusBains::updateLocation(bool recalculate)
112{ 112{
113 113
114 QTime tim = QTime::currentTime(); 114 QTime tim = QTime::currentTime();
115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
116 if((tim.hour() == 0) && (oldTime.hour()==23)) 116 if((tim.hour() == 0) && (oldTime.hour()==23))
117 recalculate = true; 117 recalculate = true;
118 118
119 int mins = tim.hour()*60 + tim.minute(); 119 int mins = tim.hour()*60 + tim.minute();
120 int minutesPerCell = 24 * 60 / agenda->rows(); 120 int minutesPerCell = 24 * 60 / agenda->rows();
121 int y = mins*agenda->gridSpacingY()/minutesPerCell; 121 int y = mins*agenda->gridSpacingY()/minutesPerCell;
122 int today = recalculate ? todayColumn() : oldToday; 122 int today = recalculate ? todayColumn() : oldToday;
123 int x = agenda->gridSpacingX()*today; 123 int x = agenda->gridSpacingX()*today;
124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
125 125
126 oldTime = tim; 126 oldTime = tim;
127 oldToday = today; 127 oldToday = today;
128 128
129 if(disabled || (today<0)) { 129 if(disabled || (today<0)) {
130 hide(); mTimeBox->hide(); 130 hide(); mTimeBox->hide();
131 return; 131 return;
132 } else { 132 } else {
133 show(); mTimeBox->show(); 133 show(); mTimeBox->show();
134 } 134 }
135 135
136 if(recalculate) 136 if(recalculate)
137 setFixedSize(agenda->gridSpacingX(),1); 137 setFixedSize(agenda->gridSpacingX(),1);
138 agenda->moveChild(this, x, y); 138 agenda->moveChild(this, x, y);
139 raise(); 139 raise();
140 140
141 if(recalculate) 141 if(recalculate)
142 //mTimeBox->setFont(QFont("helvetica",10)); 142 //mTimeBox->setFont(QFont("helvetica",10));
143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
144 144
145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
146 mTimeBox->adjustSize(); 146 mTimeBox->adjustSize();
147 // the -2 below is there because there is a bug in this program 147 // the -2 below is there because there is a bug in this program
148 // somewhere, where the last column of this widget is a few pixels 148 // somewhere, where the last column of this widget is a few pixels
149 // narrower than the other columns. 149 // narrower than the other columns.
150 int offs = (today==agenda->columns()-1) ? -4 : 0; 150 int offs = (today==agenda->columns()-1) ? -4 : 0;
151 agenda->moveChild(mTimeBox, 151 agenda->moveChild(mTimeBox,
152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
153 y-mTimeBox->height()); 153 y-mTimeBox->height());
154 154
155 mTimeBox->raise(); 155 mTimeBox->raise();
156 //mTimeBox->setAutoMask(true); 156 //mTimeBox->setAutoMask(true);
157 minutes->start(5000,true); 157 minutes->start(5000,true);
158} 158}
159 159
160 160
161//////////////////////////////////////////////////////////////////////////// 161////////////////////////////////////////////////////////////////////////////
162 162
163 163
164/* 164/*
165 Create an agenda widget with rows rows and columns columns. 165 Create an agenda widget with rows rows and columns columns.
166*/ 166*/
167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
168 const char *name,WFlags f) : 168 const char *name,WFlags f) :
169 QScrollView(parent,name,f) 169 QScrollView(parent,name,f)
170{ 170{
171 171
172 172
173 mColumns = columns; 173 mColumns = columns;
174 mRows = rows; 174 mRows = rows;
175 mGridSpacingY = rowSize; 175 mGridSpacingY = rowSize;
176 mAllDayMode = false; 176 mAllDayMode = false;
177#ifndef DESKTOP_VERSION 177#ifndef DESKTOP_VERSION
178 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 178 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
179#endif 179#endif
180 mHolidayMask = 0; 180 mHolidayMask = 0;
181 init(); 181 init();
182} 182}
183 183
184/* 184/*
185 Create an agenda widget with columns columns and one row. This is used for 185 Create an agenda widget with columns columns and one row. This is used for
186 all-day events. 186 all-day events.
187*/ 187*/
188KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 188KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
189 QScrollView(parent,name,f) 189 QScrollView(parent,name,f)
190{ 190{
191 blockResize = false; 191 blockResize = false;
192 mColumns = columns; 192 mColumns = columns;
193 mRows = 1; 193 mRows = 1;
194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
195 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 195 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
196 mAllDayMode = true; 196 mAllDayMode = true;
197#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
198 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 198 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
199#endif 199#endif
200 mHolidayMask = 0; 200 mHolidayMask = 0;
201 init(); 201 init();
202} 202}
203 203
204 204
205KOAgenda::~KOAgenda() 205KOAgenda::~KOAgenda()
206{ 206{
207 if(mMarcusBains) delete mMarcusBains; 207 if(mMarcusBains) delete mMarcusBains;
208 208
209} 209}
210 210
211Incidence *KOAgenda::selectedIncidence() const 211Incidence *KOAgenda::selectedIncidence() const
212{ 212{
213 return (mSelectedItem ? mSelectedItem->incidence() : 0); 213 return (mSelectedItem ? mSelectedItem->incidence() : 0);
214} 214}
215 215
216 216
217QDate KOAgenda::selectedIncidenceDate() const 217QDate KOAgenda::selectedIncidenceDate() const
218{ 218{
219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
220} 220}
221 221
222 222
223void KOAgenda::init() 223void KOAgenda::init()
224{ 224{
225 mNewItemPopup = new QPopupMenu( this ); 225 mNewItemPopup = new QPopupMenu( this );
226 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 226 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
227 QString pathString = ""; 227 QString pathString = "";
228 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 228 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
229 if ( QApplication::desktop()->width() < 480 ) 229 if ( QApplication::desktop()->width() < 480 )
230 pathString += "icons16/"; 230 pathString += "icons16/";
231 } else 231 } else
232 pathString += "iconsmini/"; 232 pathString += "iconsmini/";
233 233
234 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 234 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
235 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 235 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
236 mNewItemPopup->insertSeparator ( ); 236 mNewItemPopup->insertSeparator ( );
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 237 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
238 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 238 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
239 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 239 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
243#ifndef _WIN32_ 243#ifndef _WIN32_
244 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 244 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
245 viewport()->setWFlags ( wflags); 245 viewport()->setWFlags ( wflags);
246#endif 246#endif
247 mGridSpacingX = 80; 247 mGridSpacingX = 80;
248 mResizeBorderWidth = 8; 248 mResizeBorderWidth = 8;
249 mScrollBorderWidth = 8; 249 mScrollBorderWidth = 8;
250 mScrollDelay = 30; 250 mScrollDelay = 30;
251 mScrollOffset = 10; 251 mScrollOffset = 10;
252 mPaintPixmap.resize( 20,20); 252 mPaintPixmap.resize( 20,20);
253 //enableClipper(true); 253 //enableClipper(true);
254 254
255 // Grab key strokes for keyboard navigation of agenda. Seems to have no 255 // Grab key strokes for keyboard navigation of agenda. Seems to have no
256 // effect. Has to be fixed. 256 // effect. Has to be fixed.
257 setFocusPolicy(WheelFocus); 257 setFocusPolicy(WheelFocus);
258 258
259 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 259 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
260 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 260 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
261 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 261 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
262 262
263 mStartCellX = 0; 263 mStartCellX = 0;
264 mStartCellY = 0; 264 mStartCellY = 0;
265 mCurrentCellX = 0; 265 mCurrentCellX = 0;
266 mCurrentCellY = 0; 266 mCurrentCellY = 0;
267 267
268 mSelectionCellX = 0; 268 mSelectionCellX = 0;
269 mSelectionYTop = 0; 269 mSelectionYTop = 0;
270 mSelectionHeight = 0; 270 mSelectionHeight = 0;
271 271
272 mOldLowerScrollValue = -1; 272 mOldLowerScrollValue = -1;
273 mOldUpperScrollValue = -1; 273 mOldUpperScrollValue = -1;
274 274
@@ -306,274 +306,281 @@ void KOAgenda::init()
306 SLOT(checkScrollBoundaries(int))); 306 SLOT(checkScrollBoundaries(int)));
307 307
308 // Create the Marcus Bains line. 308 // Create the Marcus Bains line.
309 if(mAllDayMode) 309 if(mAllDayMode)
310 mMarcusBains = 0; 310 mMarcusBains = 0;
311 else { 311 else {
312 mMarcusBains = new MarcusBains(this); 312 mMarcusBains = new MarcusBains(this);
313 addChild(mMarcusBains); 313 addChild(mMarcusBains);
314 } 314 }
315} 315}
316 316
317void KOAgenda::clear() 317void KOAgenda::clear()
318{ 318{
319 KOAgendaItem *item; 319 KOAgendaItem *item;
320 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 320 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
321 mUnusedItems.append( item ); 321 mUnusedItems.append( item );
322 //item->hide(); 322 //item->hide();
323 } 323 }
324 mItems.clear(); 324 mItems.clear();
325 mSelectedItem = 0; 325 mSelectedItem = 0;
326 clearSelection(); 326 clearSelection();
327} 327}
328 328
329void KOAgenda::clearSelection() 329void KOAgenda::clearSelection()
330{ 330{
331 mSelectionCellX = 0; 331 mSelectionCellX = 0;
332 mSelectionYTop = 0; 332 mSelectionYTop = 0;
333 mSelectionHeight = 0; 333 mSelectionHeight = 0;
334} 334}
335 335
336void KOAgenda::marcus_bains() 336void KOAgenda::marcus_bains()
337{ 337{
338 if(mMarcusBains) mMarcusBains->updateLocation(true); 338 if(mMarcusBains) mMarcusBains->updateLocation(true);
339} 339}
340 340
341 341
342void KOAgenda::changeColumns(int columns) 342void KOAgenda::changeColumns(int columns)
343{ 343{
344 if (columns == 0) { 344 if (columns == 0) {
345 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; 345 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl;
346 return; 346 return;
347 } 347 }
348 348
349 clear(); 349 clear();
350 350
351 mColumns = columns; 351 mColumns = columns;
352// setMinimumSize(mColumns * 10, mGridSpacingY + 1); 352// setMinimumSize(mColumns * 10, mGridSpacingY + 1);
353// init(); 353// init();
354// update(); 354// update();
355 //qDebug("KOAgenda::changeColumns "); 355 //qDebug("KOAgenda::changeColumns ");
356 computeSizes(); 356 computeSizes();
357 // QResizeEvent event( size(), size() ); 357 // QResizeEvent event( size(), size() );
358 358
359 //QApplication::sendEvent( this, &event ); 359 //QApplication::sendEvent( this, &event );
360} 360}
361 361
362/* 362/*
363 This is the eventFilter function, which gets all events from the KOAgendaItems 363 This is the eventFilter function, which gets all events from the KOAgendaItems
364 contained in the agenda. It has to handle moving and resizing for all items. 364 contained in the agenda. It has to handle moving and resizing for all items.
365*/ 365*/
366bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 366bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
367{ 367{
368// kdDebug() << "KOAgenda::eventFilter" << endl; 368// kdDebug() << "KOAgenda::eventFilter" << endl;
369 switch(event->type()) { 369 switch(event->type()) {
370 case QEvent::MouseButtonPress: 370 case QEvent::MouseButtonPress:
371 case QEvent::MouseButtonDblClick: 371 case QEvent::MouseButtonDblClick:
372 case QEvent::MouseButtonRelease: 372 case QEvent::MouseButtonRelease:
373 case QEvent::MouseMove: 373 case QEvent::MouseMove:
374 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 374 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
375 375
376 case (QEvent::Leave): 376 case (QEvent::Leave):
377 if (!mActionItem) 377 if (!mActionItem)
378 setCursor(arrowCursor); 378 setCursor(arrowCursor);
379 return true; 379 return true;
380 380
381 default: 381 default:
382 return QScrollView::eventFilter(object,event); 382 return QScrollView::eventFilter(object,event);
383 } 383 }
384} 384}
385 385
386 386
387bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 387bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
388{ 388{
389 //qDebug("KOAgenda::eventFilter_mous "); 389 //qDebug("KOAgenda::eventFilter_mous ");
390 QPoint viewportPos; 390 QPoint viewportPos;
391 if (object != viewport()) { 391 if (object != viewport()) {
392 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 392 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
393 } else { 393 } else {
394 viewportPos = me->pos(); 394 viewportPos = me->pos();
395 } 395 }
396 static int startX = 0; 396 static int startX = 0;
397 static int startY = 0; 397 static int startY = 0;
398 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 398 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
399 static bool blockMoving = true; 399 static bool blockMoving = true;
400 static bool leftMouseDown = false; 400 static bool leftMouseDown = false;
401 static bool rightMouseDown = false; 401 static bool rightMouseDown = false;
402 static QTime rightClickTime;
403 bool rightButtonPressed = false;
402 switch (me->type()) { 404 switch (me->type()) {
403 case QEvent::MouseButtonPress: 405 case QEvent::MouseButtonPress:
404 if (me->button() == LeftButton) 406 rightClickTime.restart();
407 if (me->button() == LeftButton) {
405 leftMouseDown = true; 408 leftMouseDown = true;
409 }
406 else if (me->button() == RightButton) 410 else if (me->button() == RightButton)
407 rightMouseDown = true; 411 rightMouseDown = true;
408 blockMoving = true; 412 blockMoving = true;
409 startX = viewportPos.x(); 413 startX = viewportPos.x();
410 startY = viewportPos.y(); 414 startY = viewportPos.y();
411 if (object != viewport()) { 415 if (object != viewport()) {
412 if (me->button() == RightButton) { 416 if (me->button() == RightButton) {
413 mClickedItem = (KOAgendaItem *)object; 417 mClickedItem = (KOAgendaItem *)object;
414 if (mClickedItem) { 418 if (mClickedItem) {
415 selectItem(mClickedItem); 419 selectItem(mClickedItem);
416 } 420 }
417 } else if (me->button() == LeftButton) { 421 } else if (me->button() == LeftButton) {
418 mActionItem = (KOAgendaItem *)object; 422 mActionItem = (KOAgendaItem *)object;
419 if (mActionItem) { 423 if (mActionItem) {
420 if ( mSelectionHeight > 0 ) { 424 if ( mSelectionHeight > 0 ) {
421 int selectionCellX = mSelectionCellX * mGridSpacingX; 425 int selectionCellX = mSelectionCellX * mGridSpacingX;
422 int selectionYTop = mSelectionYTop; 426 int selectionYTop = mSelectionYTop;
423 int gridSpacingX = mGridSpacingX; 427 int gridSpacingX = mGridSpacingX;
424 int selectionHeight = mSelectionHeight; 428 int selectionHeight = mSelectionHeight;
425 clearSelection(); 429 clearSelection();
426 repaintContents( selectionCellX, selectionYTop, 430 repaintContents( selectionCellX, selectionYTop,
427 gridSpacingX, selectionHeight,false ); 431 gridSpacingX, selectionHeight,false );
428 } 432 }
429 selectItem(mActionItem); 433 selectItem(mActionItem);
430 Incidence *incidence = mActionItem->incidence(); 434 Incidence *incidence = mActionItem->incidence();
431 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 435 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
432 mActionItem = 0; 436 mActionItem = 0;
433 } else { 437 } else {
434 startItemAction(viewportPos); 438 startItemAction(viewportPos);
435 } 439 }
436 } 440 }
437 } 441 }
438 } else { // ---------- viewport() 442 } else { // ---------- viewport()
439 selectItem(0); 443 selectItem(0);
440 mActionItem = 0; 444 mActionItem = 0;
441 if (me->button() == LeftButton ) { 445 if (me->button() == LeftButton ) {
442 setCursor(arrowCursor); 446 setCursor(arrowCursor);
443 startSelectAction(viewportPos); 447 startSelectAction(viewportPos);
444 } 448 }
445 } 449 }
446 break; 450 break;
447 451
448 case QEvent::MouseButtonRelease: 452 case QEvent::MouseButtonRelease:
453 if ( rightClickTime.elapsed() > 700 && blockMoving )
454 rightButtonPressed = true;
449 if (object != viewport()) { 455 if (object != viewport()) {
450 if (me->button() == RightButton) { 456 if (me->button() == RightButton || rightButtonPressed ) {
451 if ( blockMoving ) { 457 if ( blockMoving ) {
452 mClickedItem = (KOAgendaItem *)object; 458 mClickedItem = (KOAgendaItem *)object;
453 if (mActionItem ) { 459 if (mActionItem ) {
454 endItemAction(); 460 endItemAction();
455 } 461 }
456 leftMouseDown = false; // no more leftMouse computation 462 leftMouseDown = false; // no more leftMouse computation
457 if (mClickedItem) { 463 if (mClickedItem) {
458 selectItem(mClickedItem); 464 selectItem(mClickedItem);
459 emit showIncidencePopupSignal(mClickedItem->incidence()); 465 emit showIncidencePopupSignal(mClickedItem->incidence());
460 } 466 }
461 } 467 }
462 } else if (me->button() == LeftButton && leftMouseDown) { 468 } else if (me->button() == LeftButton && leftMouseDown) {
463 if (mActionItem) { 469 if (mActionItem) {
464 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 470 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
465 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 471 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
466 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 472 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
467 mScrollUpTimer.stop(); 473 mScrollUpTimer.stop();
468 mScrollDownTimer.stop(); 474 mScrollDownTimer.stop();
469 mActionItem->resetMove(); 475 mActionItem->resetMove();
470 placeSubCells( mActionItem ); 476 placeSubCells( mActionItem );
471 // emit startDragSignal( mActionItem->incidence() ); 477 // emit startDragSignal( mActionItem->incidence() );
472 setCursor( arrowCursor ); 478 setCursor( arrowCursor );
473 mActionItem = 0; 479 mActionItem = 0;
474 mActionType = NOP; 480 mActionType = NOP;
475 mItemMoved = 0; 481 mItemMoved = 0;
482 leftMouseDown = false;
476 return true; 483 return true;
477 } 484 }
478 endItemAction(); 485 endItemAction();
479 } 486 }
480 } 487 }
481 488
482 } else { // ---------- viewport() 489 } else { // ---------- viewport()
483 if (me->button() == RightButton) { //right click 490 if (me->button() == RightButton || rightButtonPressed ) { //right click
484 if ( blockMoving ) { // we did mot moved the mouse much - popup menu 491 if ( blockMoving ) { // we did mot moved the mouse much - popup menu
485 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action 492 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
486 endSelectAction( false ); // do not emit new event signal 493 endSelectAction( false ); // do not emit new event signal
487 leftMouseDown = false; // no more leftMouse computation 494 leftMouseDown = false; // no more leftMouse computation
488 } 495 }
489 int x,y; 496 int x,y;
490 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 497 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
491 int gx,gy; 498 int gx,gy;
492 contentsToGrid(x,y,gx,gy); 499 contentsToGrid(x,y,gx,gy);
493 mCurrentCellX = gx; 500 mCurrentCellX = gx;
494 mCurrentCellY = gy; 501 mCurrentCellY = gy;
495 mStartCellX = gx; 502 mStartCellX = gx;
496 mStartCellY = gy; 503 mStartCellY = gy;
497 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); 504 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
498 } 505 }
499 } 506 }
500 else if (me->button() == LeftButton && leftMouseDown ) { //left click 507 else if (me->button() == LeftButton && leftMouseDown ) { //left click
501 endSelectAction( true ); // emit new event signal 508 endSelectAction( true ); // emit new event signal
502 } 509 }
503 } 510 }
504 if (me->button() == LeftButton) 511 if (me->button() == LeftButton)
505 leftMouseDown = false; 512 leftMouseDown = false;
506 else if (me->button() == RightButton) 513 else if (me->button() == RightButton)
507 rightMouseDown = false; 514 rightMouseDown = false;
508 break; 515 break;
509 516
510 case QEvent::MouseMove: 517 case QEvent::MouseMove:
511 if ( !rightMouseDown && !leftMouseDown ) 518 if ( !rightMouseDown && !leftMouseDown )
512 return true; 519 return true;
513 if ( blockMoving ) { 520 if ( blockMoving ) {
514 int dX, dY; 521 int dX, dY;
515 dX = startX - viewportPos.x(); 522 dX = startX - viewportPos.x();
516 if ( dX < 0 ) 523 if ( dX < 0 )
517 dX = -dX; 524 dX = -dX;
518 dY = viewportPos.y() - startY; 525 dY = viewportPos.y() - startY;
519 if ( dY < 0 ) 526 if ( dY < 0 )
520 dY = -dY; 527 dY = -dY;
521 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 528 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
522 if ( dX > blockmoveDist || dY > blockmoveDist ) { 529 if ( dX > blockmoveDist || dY > blockmoveDist ) {
523 blockMoving = false; 530 blockMoving = false;
524 } 531 }
525 } 532 }
526 if (object != viewport()) { 533 if (object != viewport()) {
527 KOAgendaItem *moveItem = (KOAgendaItem *)object; 534 KOAgendaItem *moveItem = (KOAgendaItem *)object;
528 if (!moveItem->incidence()->isReadOnly() ) { 535 if (!moveItem->incidence()->isReadOnly() ) {
529 if (!mActionItem) 536 if (!mActionItem)
530 setNoActionCursor(moveItem,viewportPos); 537 setNoActionCursor(moveItem,viewportPos);
531 else { 538 else {
532 if ( !blockMoving ) 539 if ( !blockMoving )
533 performItemAction(viewportPos); 540 performItemAction(viewportPos);
534 } 541 }
535 } 542 }
536 } else { // ---------- viewport() 543 } else { // ---------- viewport()
537 if ( mActionType == SELECT ) { 544 if ( mActionType == SELECT ) {
538 performSelectAction( viewportPos ); 545 performSelectAction( viewportPos );
539 } 546 }
540 } 547 }
541 break; 548 break;
542 549
543 case QEvent::MouseButtonDblClick: 550 case QEvent::MouseButtonDblClick:
544 if (object == viewport()) { 551 if (object == viewport()) {
545 selectItem(0); 552 selectItem(0);
546 int x,y; 553 int x,y;
547 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 554 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
548 int gx,gy; 555 int gx,gy;
549 contentsToGrid(x,y,gx,gy); 556 contentsToGrid(x,y,gx,gy);
550 emit newEventSignal(gx,gy); 557 emit newEventSignal(gx,gy);
551 } else { 558 } else {
552 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 559 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
553 selectItem(doubleClickedItem); 560 selectItem(doubleClickedItem);
554 if ( KOPrefs::instance()->mEditOnDoubleClick ) 561 if ( KOPrefs::instance()->mEditOnDoubleClick )
555 emit editIncidenceSignal(doubleClickedItem->incidence()); 562 emit editIncidenceSignal(doubleClickedItem->incidence());
556 else 563 else
557 emit showIncidenceSignal(doubleClickedItem->incidence()); 564 emit showIncidenceSignal(doubleClickedItem->incidence());
558 } 565 }
559 break; 566 break;
560 567
561 default: 568 default:
562 break; 569 break;
563 } 570 }
564 return true; 571 return true;
565} 572}
566 573
567void KOAgenda::newItem( int item ) 574void KOAgenda::newItem( int item )
568{ 575{
569 if ( item == 1 ) { //new event 576 if ( item == 1 ) { //new event
570 newEventSignal(mStartCellX ,mStartCellY ); 577 newEventSignal(mStartCellX ,mStartCellY );
571 } else 578 } else
572 if ( item == 2 ) { //new event 579 if ( item == 2 ) { //new event
573 newTodoSignal(mStartCellX ,mStartCellY ); 580 newTodoSignal(mStartCellX ,mStartCellY );
574 } else 581 } else
575 { 582 {
576 QDate day = mSelectedDates[mStartCellX]; 583 QDate day = mSelectedDates[mStartCellX];
577 emit showDateView( item, day ); 584 emit showDateView( item, day );
578 // 3Day view 585 // 3Day view
579 // 4Week view 586 // 4Week view