-rw-r--r-- | korganizer/koagenda.cpp | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index deadfc9..de964da 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -123,161 +123,162 @@ void MarcusBains::updateLocation(bool recalculate) | |||
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 | */ |
166 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 166 | KOAgenda::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 | */ |
187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 187 | KOAgenda::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 | ||
204 | KOAgenda::~KOAgenda() | 205 | KOAgenda::~KOAgenda() |
205 | { | 206 | { |
206 | if(mMarcusBains) delete mMarcusBains; | 207 | if(mMarcusBains) delete mMarcusBains; |
207 | 208 | ||
208 | } | 209 | } |
209 | 210 | ||
210 | Incidence *KOAgenda::selectedIncidence() const | 211 | Incidence *KOAgenda::selectedIncidence() const |
211 | { | 212 | { |
212 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
213 | } | 214 | } |
214 | 215 | ||
215 | 216 | ||
216 | QDate KOAgenda::selectedIncidenceDate() const | 217 | QDate KOAgenda::selectedIncidenceDate() const |
217 | { | 218 | { |
218 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
219 | } | 220 | } |
220 | 221 | ||
221 | 222 | ||
222 | void KOAgenda::init() | 223 | void 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; |
@@ -342,165 +343,203 @@ void KOAgenda::marcus_bains() | |||
342 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 343 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
343 | } | 344 | } |
344 | 345 | ||
345 | 346 | ||
346 | void KOAgenda::changeColumns(int columns) | 347 | void 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 | */ |
361 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 362 | bool 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 | } |
380 | void KOAgenda::popupMenu() | 381 | void 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 | ||
405 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 410 | bool 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 | } |