-rw-r--r-- | korganizer/koagenda.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 9720f43..deadfc9 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -129,770 +129,771 @@ void MarcusBains::updateLocation(bool recalculate) | |||
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 | ||
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 | blockResize = false; | 190 | blockResize = false; |
191 | mColumns = columns; | 191 | mColumns = columns; |
192 | mRows = 1; | 192 | mRows = 1; |
193 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 193 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
194 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 194 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
195 | mAllDayMode = true; | 195 | mAllDayMode = true; |
196 | #ifndef DESKTOP_VERSION | 196 | #ifndef DESKTOP_VERSION |
197 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 197 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
198 | #endif | 198 | #endif |
199 | mHolidayMask = 0; | 199 | mHolidayMask = 0; |
200 | init(); | 200 | init(); |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | KOAgenda::~KOAgenda() | 204 | KOAgenda::~KOAgenda() |
205 | { | 205 | { |
206 | if(mMarcusBains) delete mMarcusBains; | 206 | if(mMarcusBains) delete mMarcusBains; |
207 | 207 | ||
208 | } | 208 | } |
209 | 209 | ||
210 | Incidence *KOAgenda::selectedIncidence() const | 210 | Incidence *KOAgenda::selectedIncidence() const |
211 | { | 211 | { |
212 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 212 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | QDate KOAgenda::selectedIncidenceDate() const | 216 | QDate KOAgenda::selectedIncidenceDate() const |
217 | { | 217 | { |
218 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 218 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | void KOAgenda::init() | 222 | void KOAgenda::init() |
223 | { | 223 | { |
224 | mPopupTimer = new QTimer(this); | 224 | mPopupTimer = new QTimer(this); |
225 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 225 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
226 | 226 | ||
227 | mNewItemPopup = new QPopupMenu( this ); | 227 | mNewItemPopup = new QPopupMenu( this ); |
228 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 228 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
229 | QString pathString = ""; | 229 | QString pathString = ""; |
230 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 230 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
231 | if ( QApplication::desktop()->width() < 480 ) | 231 | if ( QApplication::desktop()->width() < 480 ) |
232 | pathString += "icons16/"; | 232 | pathString += "icons16/"; |
233 | } else | 233 | } else |
234 | pathString += "iconsmini/"; | 234 | pathString += "iconsmini/"; |
235 | 235 | ||
236 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 236 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
238 | mNewItemPopup->insertSeparator ( ); | 238 | mNewItemPopup->insertSeparator ( ); |
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
245 | #ifndef _WIN32_ | 245 | #ifndef _WIN32_ |
246 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 246 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
247 | viewport()->setWFlags ( wflags); | 247 | viewport()->setWFlags ( wflags); |
248 | #endif | 248 | #endif |
249 | mGridSpacingX = 80; | 249 | mGridSpacingX = 80; |
250 | mResizeBorderWidth = 8; | 250 | mResizeBorderWidth = 8; |
251 | mScrollBorderWidth = 8; | 251 | mScrollBorderWidth = 8; |
252 | mScrollDelay = 30; | 252 | mScrollDelay = 30; |
253 | mScrollOffset = 10; | 253 | mScrollOffset = 10; |
254 | mPaintPixmap.resize( 20,20); | 254 | mPaintPixmap.resize( 20,20); |
255 | //enableClipper(true); | 255 | //enableClipper(true); |
256 | 256 | ||
257 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 257 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
258 | // effect. Has to be fixed. | 258 | // effect. Has to be fixed. |
259 | setFocusPolicy(WheelFocus); | 259 | setFocusPolicy(WheelFocus); |
260 | 260 | ||
261 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 261 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
262 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 262 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
263 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 263 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
264 | 264 | ||
265 | mStartCellX = 0; | 265 | mStartCellX = 0; |
266 | mStartCellY = 0; | 266 | mStartCellY = 0; |
267 | mCurrentCellX = 0; | 267 | mCurrentCellX = 0; |
268 | mCurrentCellY = 0; | 268 | mCurrentCellY = 0; |
269 | 269 | ||
270 | mSelectionCellX = 0; | 270 | mSelectionCellX = 0; |
271 | mSelectionYTop = 0; | 271 | mSelectionYTop = 0; |
272 | mSelectionHeight = 0; | 272 | mSelectionHeight = 0; |
273 | 273 | ||
274 | mOldLowerScrollValue = -1; | 274 | mOldLowerScrollValue = -1; |
275 | mOldUpperScrollValue = -1; | 275 | mOldUpperScrollValue = -1; |
276 | 276 | ||
277 | mClickedItem = 0; | 277 | mClickedItem = 0; |
278 | 278 | ||
279 | mActionItem = 0; | 279 | mActionItem = 0; |
280 | mActionType = NOP; | 280 | mActionType = NOP; |
281 | mItemMoved = false; | 281 | mItemMoved = false; |
282 | 282 | ||
283 | mSelectedItem = 0; | 283 | mSelectedItem = 0; |
284 | 284 | ||
285 | // mItems.setAutoDelete(true); | 285 | // mItems.setAutoDelete(true); |
286 | 286 | ||
287 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 287 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
288 | 288 | ||
289 | viewport()->update(); | 289 | viewport()->update(); |
290 | 290 | ||
291 | setMinimumSize(30, 1); | 291 | setMinimumSize(30, 1); |
292 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 292 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
293 | 293 | ||
294 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 294 | // 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 | 295 | // controlled in a way that the contents horizontally always fits. Then it is |
296 | // not necessary to turn off the scrollbar. | 296 | // not necessary to turn off the scrollbar. |
297 | setHScrollBarMode(AlwaysOff); | 297 | setHScrollBarMode(AlwaysOff); |
298 | if ( ! mAllDayMode ) | 298 | if ( ! mAllDayMode ) |
299 | setVScrollBarMode(AlwaysOn); | 299 | setVScrollBarMode(AlwaysOn); |
300 | else | 300 | else |
301 | setVScrollBarMode(AlwaysOff); | 301 | setVScrollBarMode(AlwaysOff); |
302 | 302 | ||
303 | setStartHour(KOPrefs::instance()->mDayBegins); | 303 | setStartHour(KOPrefs::instance()->mDayBegins); |
304 | 304 | ||
305 | calculateWorkingHours(); | 305 | calculateWorkingHours(); |
306 | 306 | ||
307 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 307 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
308 | SLOT(checkScrollBoundaries(int))); | 308 | SLOT(checkScrollBoundaries(int))); |
309 | 309 | ||
310 | // Create the Marcus Bains line. | 310 | // Create the Marcus Bains line. |
311 | if(mAllDayMode) | 311 | if(mAllDayMode) |
312 | mMarcusBains = 0; | 312 | mMarcusBains = 0; |
313 | else { | 313 | else { |
314 | mMarcusBains = new MarcusBains(this); | 314 | mMarcusBains = new MarcusBains(this); |
315 | addChild(mMarcusBains); | 315 | addChild(mMarcusBains); |
316 | } | 316 | } |
317 | mPopupKind = 0; | 317 | mPopupKind = 0; |
318 | mPopupItem = 0; | 318 | mPopupItem = 0; |
319 | } | 319 | } |
320 | 320 | ||
321 | void KOAgenda::clear() | 321 | void KOAgenda::clear() |
322 | { | 322 | { |
323 | KOAgendaItem *item; | 323 | KOAgendaItem *item; |
324 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 324 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
325 | mUnusedItems.append( item ); | 325 | mUnusedItems.append( item ); |
326 | //item->hide(); | 326 | //item->hide(); |
327 | } | 327 | } |
328 | mItems.clear(); | 328 | mItems.clear(); |
329 | mSelectedItem = 0; | 329 | mSelectedItem = 0; |
330 | clearSelection(); | 330 | clearSelection(); |
331 | } | 331 | } |
332 | 332 | ||
333 | void KOAgenda::clearSelection() | 333 | void KOAgenda::clearSelection() |
334 | { | 334 | { |
335 | mSelectionCellX = 0; | 335 | mSelectionCellX = 0; |
336 | mSelectionYTop = 0; | 336 | mSelectionYTop = 0; |
337 | mSelectionHeight = 0; | 337 | mSelectionHeight = 0; |
338 | } | 338 | } |
339 | 339 | ||
340 | void KOAgenda::marcus_bains() | 340 | void KOAgenda::marcus_bains() |
341 | { | 341 | { |
342 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 342 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
343 | } | 343 | } |
344 | 344 | ||
345 | 345 | ||
346 | void KOAgenda::changeColumns(int columns) | 346 | void KOAgenda::changeColumns(int columns) |
347 | { | 347 | { |
348 | if (columns == 0) { | 348 | if (columns == 0) { |
349 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 349 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
350 | return; | 350 | return; |
351 | } | 351 | } |
352 | clear(); | 352 | clear(); |
353 | mColumns = columns; | 353 | mColumns = columns; |
354 | computeSizes(); | 354 | computeSizes(); |
355 | } | 355 | } |
356 | 356 | ||
357 | /* | 357 | /* |
358 | This is the eventFilter function, which gets all events from the KOAgendaItems | 358 | 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. | 359 | contained in the agenda. It has to handle moving and resizing for all items. |
360 | */ | 360 | */ |
361 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 361 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
362 | { | 362 | { |
363 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 363 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
364 | switch(event->type()) { | 364 | switch(event->type()) { |
365 | case QEvent::MouseButtonPress: | 365 | case QEvent::MouseButtonPress: |
366 | case QEvent::MouseButtonDblClick: | 366 | case QEvent::MouseButtonDblClick: |
367 | case QEvent::MouseButtonRelease: | 367 | case QEvent::MouseButtonRelease: |
368 | case QEvent::MouseMove: | 368 | case QEvent::MouseMove: |
369 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 369 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
370 | 370 | ||
371 | case (QEvent::Leave): | 371 | case (QEvent::Leave): |
372 | if (!mActionItem) | 372 | if (!mActionItem) |
373 | setCursor(arrowCursor); | 373 | setCursor(arrowCursor); |
374 | return true; | 374 | return true; |
375 | 375 | ||
376 | default: | 376 | default: |
377 | return QScrollView::eventFilter(object,event); | 377 | return QScrollView::eventFilter(object,event); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | void KOAgenda::popupMenu() | 380 | void KOAgenda::popupMenu() |
381 | { | 381 | { |
382 | mPopupTimer->stop(); | 382 | mPopupTimer->stop(); |
383 | if ( mPopupKind == 1 ) { | 383 | if ( mPopupKind == 1 ) { |
384 | if (mActionItem ) { | 384 | if (mActionItem ) { |
385 | endItemAction(); | 385 | endItemAction(); |
386 | } | 386 | } |
387 | mLeftMouseDown = false; // no more leftMouse computation | 387 | mLeftMouseDown = false; // no more leftMouse computation |
388 | if (mPopupItem) { | 388 | if (mPopupItem) { |
389 | selectItem(mPopupItem); | 389 | selectItem(mPopupItem); |
390 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 390 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
391 | 391 | ||
392 | } | 392 | } |
393 | } else if ( mPopupKind == 2 ) { | 393 | } else if ( mPopupKind == 2 ) { |
394 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 394 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
395 | endSelectAction( false ); // do not emit new event signal | 395 | endSelectAction( false ); // do not emit new event signal |
396 | mLeftMouseDown = false; // no more leftMouse computation | 396 | mLeftMouseDown = false; // no more leftMouse computation |
397 | } | 397 | } |
398 | mNewItemPopup->popup( mPopupPos); | 398 | mNewItemPopup->popup( mPopupPos); |
399 | } | 399 | } |
400 | mLeftMouseDown = false; | 400 | mLeftMouseDown = false; |
401 | mPopupItem = 0; | 401 | mPopupItem = 0; |
402 | mPopupKind = 0; | 402 | mPopupKind = 0; |
403 | } | 403 | } |
404 | 404 | ||
405 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 405 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
406 | { | 406 | { |
407 | //qDebug("KOAgenda::eventFilter_mous "); | 407 | //qDebug("KOAgenda::eventFilter_mous "); |
408 | QPoint viewportPos; | 408 | QPoint viewportPos; |
409 | if (object != viewport()) { | 409 | if (object != viewport()) { |
410 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 410 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
411 | } else { | 411 | } else { |
412 | viewportPos = me->pos(); | 412 | viewportPos = me->pos(); |
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 | switch (me->type()) { | 418 | switch (me->type()) { |
419 | case QEvent::MouseButtonPress: | 419 | case QEvent::MouseButtonPress: |
420 | if (me->button() == LeftButton) { | 420 | if (me->button() == LeftButton) { |
421 | mPopupTimer->start( 600 ); | 421 | mPopupTimer->start( 600 ); |
422 | mLeftMouseDown = true; | 422 | mLeftMouseDown = true; |
423 | } | 423 | } |
424 | blockMoving = true; | 424 | blockMoving = true; |
425 | startX = viewportPos.x(); | 425 | startX = viewportPos.x(); |
426 | startY = viewportPos.y(); | 426 | startY = viewportPos.y(); |
427 | if (object != viewport()) { | 427 | if (object != viewport()) { |
428 | mPopupItem = (KOAgendaItem *)object; | 428 | mPopupItem = (KOAgendaItem *)object; |
429 | mPopupKind = 1; | 429 | mPopupKind = 1; |
430 | if (me->button() == RightButton) { | 430 | if (me->button() == RightButton) { |
431 | popupMenu(); | 431 | popupMenu(); |
432 | } else if (me->button() == LeftButton) { | 432 | } else if (me->button() == LeftButton) { |
433 | mActionItem = (KOAgendaItem *)object; | 433 | mActionItem = (KOAgendaItem *)object; |
434 | if (mActionItem) { | 434 | if (mActionItem) { |
435 | if ( mSelectionHeight > 0 ) { | 435 | if ( mSelectionHeight > 0 ) { |
436 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 436 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
437 | int selectionYTop = mSelectionYTop; | 437 | int selectionYTop = mSelectionYTop; |
438 | int gridSpacingX = mGridSpacingX; | 438 | int gridSpacingX = mGridSpacingX; |
439 | int selectionHeight = mSelectionHeight; | 439 | int selectionHeight = mSelectionHeight; |
440 | clearSelection(); | 440 | clearSelection(); |
441 | repaintContents( selectionCellX, selectionYTop, | 441 | repaintContents( selectionCellX, selectionYTop, |
442 | gridSpacingX, selectionHeight,false ); | 442 | gridSpacingX, selectionHeight,false ); |
443 | } | 443 | } |
444 | selectItem(mActionItem); | 444 | selectItem(mActionItem); |
445 | Incidence *incidence = mActionItem->incidence(); | 445 | Incidence *incidence = mActionItem->incidence(); |
446 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 446 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
447 | mActionItem = 0; | 447 | mActionItem = 0; |
448 | } else { | 448 | } else { |
449 | startItemAction(viewportPos); | 449 | startItemAction(viewportPos); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | } | 452 | } |
453 | } else { // ---------- viewport() | 453 | } else { // ---------- viewport() |
454 | mPopupItem = 0; | 454 | mPopupItem = 0; |
455 | mPopupKind = 2; | 455 | mPopupKind = 2; |
456 | selectItem(0); | 456 | selectItem(0); |
457 | mActionItem = 0; | 457 | mActionItem = 0; |
458 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 458 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
459 | if (me->button() == RightButton) { | 459 | if (me->button() == RightButton) { |
460 | int x,y; | 460 | int x,y; |
461 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 461 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
462 | int gx,gy; | 462 | int gx,gy; |
463 | contentsToGrid(x,y,gx,gy); | 463 | contentsToGrid(x,y,gx,gy); |
464 | mCurrentCellX = gx; | 464 | mCurrentCellX = gx; |
465 | mCurrentCellY = gy; | 465 | mCurrentCellY = gy; |
466 | mStartCellX = gx; | 466 | mStartCellX = gx; |
467 | mStartCellY = gy; | 467 | mStartCellY = gy; |
468 | popupMenu(); | 468 | popupMenu(); |
469 | } else if (me->button() == LeftButton) { | 469 | } else if (me->button() == LeftButton) { |
470 | setCursor(arrowCursor); | 470 | setCursor(arrowCursor); |
471 | startSelectAction(viewportPos); | 471 | startSelectAction(viewportPos); |
472 | } | 472 | } |
473 | } | 473 | } |
474 | break; | 474 | break; |
475 | 475 | ||
476 | case QEvent::MouseButtonRelease: | 476 | case QEvent::MouseButtonRelease: |
477 | if (me->button() == LeftButton ) { | 477 | if (me->button() == LeftButton ) { |
478 | mPopupTimer->stop(); | 478 | mPopupTimer->stop(); |
479 | } | 479 | } |
480 | if (object != viewport()) { | 480 | if (object != viewport()) { |
481 | if (me->button() == LeftButton && mLeftMouseDown) { | 481 | if (me->button() == LeftButton && mLeftMouseDown) { |
482 | if (mActionItem) { | 482 | if (mActionItem) { |
483 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 483 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
484 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 484 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
485 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 485 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
486 | mScrollUpTimer.stop(); | 486 | mScrollUpTimer.stop(); |
487 | mScrollDownTimer.stop(); | 487 | mScrollDownTimer.stop(); |
488 | mActionItem->resetMove(); | 488 | mActionItem->resetMove(); |
489 | placeSubCells( mActionItem ); | 489 | placeSubCells( mActionItem ); |
490 | // emit startDragSignal( mActionItem->incidence() ); | 490 | // emit startDragSignal( mActionItem->incidence() ); |
491 | setCursor( arrowCursor ); | 491 | setCursor( arrowCursor ); |
492 | mActionItem = 0; | 492 | mActionItem = 0; |
493 | mActionType = NOP; | 493 | mActionType = NOP; |
494 | mItemMoved = 0; | 494 | mItemMoved = 0; |
495 | mLeftMouseDown = false; | 495 | mLeftMouseDown = false; |
496 | return true; | 496 | return true; |
497 | } | 497 | } |
498 | endItemAction(); | 498 | endItemAction(); |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | } else { // ---------- viewport() | 502 | } else { // ---------- viewport() |
503 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 503 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
504 | endSelectAction( true ); // emit new event signal | 504 | endSelectAction( true ); // emit new event signal |
505 | } | 505 | } |
506 | } | 506 | } |
507 | if (me->button() == LeftButton) | 507 | if (me->button() == LeftButton) |
508 | mLeftMouseDown = false; | 508 | mLeftMouseDown = false; |
509 | 509 | ||
510 | break; | 510 | break; |
511 | 511 | ||
512 | case QEvent::MouseMove: | 512 | case QEvent::MouseMove: |
513 | //qDebug("mm "); | ||
513 | if ( !mLeftMouseDown ) | 514 | if ( !mLeftMouseDown ) |
514 | return true; | 515 | return false; |
515 | if ( blockMoving ) { | 516 | if ( blockMoving ) { |
516 | int dX, dY; | 517 | int dX, dY; |
517 | dX = startX - viewportPos.x(); | 518 | dX = startX - viewportPos.x(); |
518 | if ( dX < 0 ) | 519 | if ( dX < 0 ) |
519 | dX = -dX; | 520 | dX = -dX; |
520 | dY = viewportPos.y() - startY; | 521 | dY = viewportPos.y() - startY; |
521 | if ( dY < 0 ) | 522 | if ( dY < 0 ) |
522 | dY = -dY; | 523 | dY = -dY; |
523 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 524 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
524 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 525 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
525 | blockMoving = false; | 526 | blockMoving = false; |
526 | } | 527 | } |
527 | } | 528 | } |
528 | if ( ! blockMoving ) | 529 | if ( ! blockMoving ) |
529 | mPopupTimer->stop(); | 530 | mPopupTimer->stop(); |
530 | if (object != viewport()) { | 531 | if (object != viewport()) { |
531 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 532 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
532 | if (!moveItem->incidence()->isReadOnly() ) { | 533 | if (!moveItem->incidence()->isReadOnly() ) { |
533 | if (!mActionItem) | 534 | if (!mActionItem) |
534 | setNoActionCursor(moveItem,viewportPos); | 535 | setNoActionCursor(moveItem,viewportPos); |
535 | else { | 536 | else { |
536 | if ( !blockMoving ) | 537 | if ( !blockMoving ) |
537 | performItemAction(viewportPos); | 538 | performItemAction(viewportPos); |
538 | } | 539 | } |
539 | } | 540 | } |
540 | } else { // ---------- viewport() | 541 | } else { // ---------- viewport() |
541 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 542 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
542 | if ( mActionType == SELECT ) { | 543 | if ( mActionType == SELECT ) { |
543 | performSelectAction( viewportPos ); | 544 | performSelectAction( viewportPos ); |
544 | } | 545 | } |
545 | } | 546 | } |
546 | break; | 547 | break; |
547 | 548 | ||
548 | case QEvent::MouseButtonDblClick: | 549 | case QEvent::MouseButtonDblClick: |
549 | mPopupTimer->stop(); | 550 | mPopupTimer->stop(); |
550 | if (object == viewport()) { | 551 | if (object == viewport()) { |
551 | selectItem(0); | 552 | selectItem(0); |
552 | int x,y; | 553 | int x,y; |
553 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 554 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
554 | int gx,gy; | 555 | int gx,gy; |
555 | contentsToGrid(x,y,gx,gy); | 556 | contentsToGrid(x,y,gx,gy); |
556 | emit newEventSignal(gx,gy); | 557 | emit newEventSignal(gx,gy); |
557 | } else { | 558 | } else { |
558 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 559 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
559 | selectItem(doubleClickedItem); | 560 | selectItem(doubleClickedItem); |
560 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 561 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
561 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 562 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
562 | else | 563 | else |
563 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 564 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
564 | } | 565 | } |
565 | break; | 566 | break; |
566 | 567 | ||
567 | default: | 568 | default: |
568 | break; | 569 | break; |
569 | } | 570 | } |
570 | return true; | 571 | return true; |
571 | #if 0 | 572 | #if 0 |
572 | //qDebug("KOAgenda::eventFilter_mous "); | 573 | //qDebug("KOAgenda::eventFilter_mous "); |
573 | QPoint viewportPos; | 574 | QPoint viewportPos; |
574 | if (object != viewport()) { | 575 | if (object != viewport()) { |
575 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 576 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
576 | } else { | 577 | } else { |
577 | viewportPos = me->pos(); | 578 | viewportPos = me->pos(); |
578 | } | 579 | } |
579 | static int startX = 0; | 580 | static int startX = 0; |
580 | static int startY = 0; | 581 | static int startY = 0; |
581 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | 582 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); |
582 | static bool blockMoving = true; | 583 | static bool blockMoving = true; |
583 | static bool leftMouseDown = false; | 584 | static bool leftMouseDown = false; |
584 | bool rightButtonPressed = false; | 585 | bool rightButtonPressed = false; |
585 | switch (me->type()) { | 586 | switch (me->type()) { |
586 | case QEvent::MouseButtonPress: | 587 | case QEvent::MouseButtonPress: |
587 | if (me->button() == LeftButton) { | 588 | if (me->button() == LeftButton) { |
588 | leftMouseDown = true; | 589 | leftMouseDown = true; |
589 | } | 590 | } |
590 | else if (me->button() == RightButton) { | 591 | else if (me->button() == RightButton) { |
591 | leftMouseDown = false; | 592 | leftMouseDown = false; |
592 | } | 593 | } |
593 | blockMoving = true; | 594 | blockMoving = true; |
594 | startX = viewportPos.x(); | 595 | startX = viewportPos.x(); |
595 | startY = viewportPos.y(); | 596 | startY = viewportPos.y(); |
596 | if (object != viewport()) { // item clicked ************** | 597 | if (object != viewport()) { // item clicked ************** |
597 | if (me->button() == RightButton) { | 598 | if (me->button() == RightButton) { |
598 | leftMouseDown = false; | 599 | leftMouseDown = false; |
599 | mClickedItem = (KOAgendaItem *)object; | 600 | mClickedItem = (KOAgendaItem *)object; |
600 | if (mActionItem ) { | 601 | if (mActionItem ) { |
601 | endItemAction(); | 602 | endItemAction(); |
602 | } | 603 | } |
603 | if (mClickedItem) { | 604 | if (mClickedItem) { |
604 | selectItem(mClickedItem); | 605 | selectItem(mClickedItem); |
605 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 606 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
606 | } | 607 | } |
607 | return true; | 608 | return true; |
608 | } else if (me->button() == LeftButton) { | 609 | } else if (me->button() == LeftButton) { |
609 | mActionItem = (KOAgendaItem *)object; | 610 | mActionItem = (KOAgendaItem *)object; |
610 | if (mActionItem) { | 611 | if (mActionItem) { |
611 | if ( mSelectionHeight > 0 ) { | 612 | if ( mSelectionHeight > 0 ) { |
612 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 613 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
613 | int selectionYTop = mSelectionYTop; | 614 | int selectionYTop = mSelectionYTop; |
614 | int gridSpacingX = mGridSpacingX; | 615 | int gridSpacingX = mGridSpacingX; |
615 | int selectionHeight = mSelectionHeight; | 616 | int selectionHeight = mSelectionHeight; |
616 | clearSelection(); | 617 | clearSelection(); |
617 | repaintContents( selectionCellX, selectionYTop, | 618 | repaintContents( selectionCellX, selectionYTop, |
618 | gridSpacingX, selectionHeight,false ); | 619 | gridSpacingX, selectionHeight,false ); |
619 | } | 620 | } |
620 | selectItem(mActionItem); | 621 | selectItem(mActionItem); |
621 | Incidence *incidence = mActionItem->incidence(); | 622 | Incidence *incidence = mActionItem->incidence(); |
622 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 623 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
623 | mActionItem = 0; | 624 | mActionItem = 0; |
624 | } else { | 625 | } else { |
625 | startItemAction(viewportPos); | 626 | startItemAction(viewportPos); |
626 | } | 627 | } |
627 | } | 628 | } |
628 | } | 629 | } |
629 | } else { // ---------- viewport() | 630 | } else { // ---------- viewport() |
630 | selectItem(0); | 631 | selectItem(0); |
631 | mActionItem = 0; | 632 | mActionItem = 0; |
632 | if (me->button() == LeftButton ) { | 633 | if (me->button() == LeftButton ) { |
633 | setCursor(arrowCursor); | 634 | setCursor(arrowCursor); |
634 | startSelectAction(viewportPos); | 635 | startSelectAction(viewportPos); |
635 | } else if (me->button() == RightButton ) { | 636 | } else if (me->button() == RightButton ) { |
636 | setCursor(arrowCursor); | 637 | setCursor(arrowCursor); |
637 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action | 638 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action |
638 | endSelectAction( false ); // do not emit new event signal | 639 | endSelectAction( false ); // do not emit new event signal |
639 | leftMouseDown = false; // no more leftMouse computation | 640 | leftMouseDown = false; // no more leftMouse computation |
640 | } | 641 | } |
641 | int x,y; | 642 | int x,y; |
642 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 643 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
643 | int gx,gy; | 644 | int gx,gy; |
644 | contentsToGrid(x,y,gx,gy); | 645 | contentsToGrid(x,y,gx,gy); |
645 | mCurrentCellX = gx; | 646 | mCurrentCellX = gx; |
646 | mCurrentCellY = gy; | 647 | mCurrentCellY = gy; |
647 | mStartCellX = gx; | 648 | mStartCellX = gx; |
648 | mStartCellY = gy; | 649 | mStartCellY = gy; |
649 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | 650 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); |
650 | } | 651 | } |
651 | } | 652 | } |
652 | break; | 653 | break; |
653 | 654 | ||
654 | case QEvent::MouseButtonRelease: | 655 | case QEvent::MouseButtonRelease: |
655 | 656 | ||
656 | if (object != viewport()) { | 657 | if (object != viewport()) { |
657 | if (me->button() == LeftButton && leftMouseDown) { | 658 | if (me->button() == LeftButton && leftMouseDown) { |
658 | if (mActionItem) { | 659 | if (mActionItem) { |
659 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 660 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
660 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 661 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
661 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 662 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
662 | mScrollUpTimer.stop(); | 663 | mScrollUpTimer.stop(); |
663 | mScrollDownTimer.stop(); | 664 | mScrollDownTimer.stop(); |
664 | mActionItem->resetMove(); | 665 | mActionItem->resetMove(); |
665 | placeSubCells( mActionItem ); | 666 | placeSubCells( mActionItem ); |
666 | // emit startDragSignal( mActionItem->incidence() ); | 667 | // emit startDragSignal( mActionItem->incidence() ); |
667 | setCursor( arrowCursor ); | 668 | setCursor( arrowCursor ); |
668 | mActionItem = 0; | 669 | mActionItem = 0; |
669 | mActionType = NOP; | 670 | mActionType = NOP; |
670 | mItemMoved = 0; | 671 | mItemMoved = 0; |
671 | leftMouseDown = false; | 672 | leftMouseDown = false; |
672 | return true; | 673 | return true; |
673 | } | 674 | } |
674 | endItemAction(); | 675 | endItemAction(); |
675 | } | 676 | } |
676 | } | 677 | } |
677 | 678 | ||
678 | } else { // ---------- viewport() | 679 | } else { // ---------- viewport() |
679 | if (me->button() == LeftButton && leftMouseDown ) { //left click | 680 | if (me->button() == LeftButton && leftMouseDown ) { //left click |
680 | endSelectAction( true ); // emit new event signal | 681 | endSelectAction( true ); // emit new event signal |
681 | } | 682 | } |
682 | } | 683 | } |
683 | if (me->button() == LeftButton) | 684 | if (me->button() == LeftButton) |
684 | leftMouseDown = false; | 685 | leftMouseDown = false; |
685 | 686 | ||
686 | break; | 687 | break; |
687 | 688 | ||
688 | case QEvent::MouseMove: | 689 | case QEvent::MouseMove: |
689 | if ( !leftMouseDown ) | 690 | if ( !leftMouseDown ) |
690 | return true; | 691 | return true; |
691 | if ( blockMoving ) { | 692 | if ( blockMoving ) { |
692 | int dX, dY; | 693 | int dX, dY; |
693 | dX = startX - viewportPos.x(); | 694 | dX = startX - viewportPos.x(); |
694 | if ( dX < 0 ) | 695 | if ( dX < 0 ) |
695 | dX = -dX; | 696 | dX = -dX; |
696 | dY = viewportPos.y() - startY; | 697 | dY = viewportPos.y() - startY; |
697 | if ( dY < 0 ) | 698 | if ( dY < 0 ) |
698 | dY = -dY; | 699 | dY = -dY; |
699 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 700 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
700 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 701 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
701 | blockMoving = false; | 702 | blockMoving = false; |
702 | } | 703 | } |
703 | } | 704 | } |
704 | if (object != viewport()) { | 705 | if (object != viewport()) { |
705 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 706 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
706 | if (!moveItem->incidence()->isReadOnly() ) { | 707 | if (!moveItem->incidence()->isReadOnly() ) { |
707 | if (!mActionItem) | 708 | if (!mActionItem) |
708 | setNoActionCursor(moveItem,viewportPos); | 709 | setNoActionCursor(moveItem,viewportPos); |
709 | else { | 710 | else { |
710 | if ( !blockMoving ) | 711 | if ( !blockMoving ) |
711 | performItemAction(viewportPos); | 712 | performItemAction(viewportPos); |
712 | } | 713 | } |
713 | } | 714 | } |
714 | } else { // ---------- viewport() | 715 | } else { // ---------- viewport() |
715 | if ( mActionType == SELECT ) { | 716 | if ( mActionType == SELECT ) { |
716 | performSelectAction( viewportPos ); | 717 | performSelectAction( viewportPos ); |
717 | } | 718 | } |
718 | } | 719 | } |
719 | break; | 720 | break; |
720 | 721 | ||
721 | case QEvent::MouseButtonDblClick: | 722 | case QEvent::MouseButtonDblClick: |
722 | blockMoving = false; | 723 | blockMoving = false; |
723 | leftMouseDown = false; | 724 | leftMouseDown = false; |
724 | if (object == viewport()) { | 725 | if (object == viewport()) { |
725 | selectItem(0); | 726 | selectItem(0); |
726 | int x,y; | 727 | int x,y; |
727 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 728 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
728 | int gx,gy; | 729 | int gx,gy; |
729 | contentsToGrid(x,y,gx,gy); | 730 | contentsToGrid(x,y,gx,gy); |
730 | emit newEventSignal(gx,gy); | 731 | emit newEventSignal(gx,gy); |
731 | } else { | 732 | } else { |
732 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 733 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
733 | selectItem(doubleClickedItem); | 734 | selectItem(doubleClickedItem); |
734 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 735 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
735 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 736 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
736 | else | 737 | else |
737 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 738 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
738 | } | 739 | } |
739 | break; | 740 | break; |
740 | 741 | ||
741 | default: | 742 | default: |
742 | break; | 743 | break; |
743 | } | 744 | } |
744 | return true; | 745 | return true; |
745 | #endif | 746 | #endif |
746 | } | 747 | } |
747 | 748 | ||
748 | void KOAgenda::newItem( int item ) | 749 | void KOAgenda::newItem( int item ) |
749 | { | 750 | { |
750 | if ( item == 1 ) { //new event | 751 | if ( item == 1 ) { //new event |
751 | newEventSignal(mStartCellX ,mStartCellY ); | 752 | newEventSignal(mStartCellX ,mStartCellY ); |
752 | } else | 753 | } else |
753 | if ( item == 2 ) { //new event | 754 | if ( item == 2 ) { //new event |
754 | newTodoSignal(mStartCellX ,mStartCellY ); | 755 | newTodoSignal(mStartCellX ,mStartCellY ); |
755 | } else | 756 | } else |
756 | { | 757 | { |
757 | emit showDateView( item, mStartCellX ); | 758 | emit showDateView( item, mStartCellX ); |
758 | // 3Day view | 759 | // 3Day view |
759 | // 4Week view | 760 | // 4Week view |
760 | // 5Month view | 761 | // 5Month view |
761 | // 6Journal view | 762 | // 6Journal view |
762 | } | 763 | } |
763 | } | 764 | } |
764 | void KOAgenda::startSelectAction(QPoint viewportPos) | 765 | void KOAgenda::startSelectAction(QPoint viewportPos) |
765 | { | 766 | { |
766 | //emit newStartSelectSignal(); | 767 | //emit newStartSelectSignal(); |
767 | 768 | ||
768 | mActionType = SELECT; | 769 | mActionType = SELECT; |
769 | 770 | ||
770 | int x,y; | 771 | int x,y; |
771 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 772 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
772 | int gx,gy; | 773 | int gx,gy; |
773 | contentsToGrid(x,y,gx,gy); | 774 | contentsToGrid(x,y,gx,gy); |
774 | 775 | ||
775 | mStartCellX = gx; | 776 | mStartCellX = gx; |
776 | mStartCellY = gy; | 777 | mStartCellY = gy; |
777 | mCurrentCellX = gx; | 778 | mCurrentCellX = gx; |
778 | mCurrentCellY = gy; | 779 | mCurrentCellY = gy; |
779 | 780 | ||
780 | // Store coordinates of old selection | 781 | // Store coordinates of old selection |
781 | int selectionX = mSelectionCellX * mGridSpacingX; | 782 | int selectionX = mSelectionCellX * mGridSpacingX; |
782 | int selectionYTop = mSelectionYTop; | 783 | int selectionYTop = mSelectionYTop; |
783 | int selectionHeight = mSelectionHeight; | 784 | int selectionHeight = mSelectionHeight; |
784 | 785 | ||
785 | // Store new selection | 786 | // Store new selection |
786 | mSelectionCellX = gx; | 787 | mSelectionCellX = gx; |
787 | mSelectionYTop = gy * mGridSpacingY; | 788 | mSelectionYTop = gy * mGridSpacingY; |
788 | mSelectionHeight = mGridSpacingY; | 789 | mSelectionHeight = mGridSpacingY; |
789 | 790 | ||
790 | // Clear old selection | 791 | // Clear old selection |
791 | repaintContents( selectionX, selectionYTop, | 792 | repaintContents( selectionX, selectionYTop, |
792 | mGridSpacingX, selectionHeight,false ); | 793 | mGridSpacingX, selectionHeight,false ); |
793 | 794 | ||
794 | // Paint new selection | 795 | // Paint new selection |
795 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, | 796 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, |
796 | // mGridSpacingX, mSelectionHeight ); | 797 | // mGridSpacingX, mSelectionHeight ); |
797 | } | 798 | } |
798 | 799 | ||
799 | void KOAgenda::performSelectAction(QPoint viewportPos) | 800 | void KOAgenda::performSelectAction(QPoint viewportPos) |
800 | { | 801 | { |
801 | int x,y; | 802 | int x,y; |
802 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 803 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
803 | int gx,gy; | 804 | int gx,gy; |
804 | contentsToGrid(x,y,gx,gy); | 805 | contentsToGrid(x,y,gx,gy); |
805 | 806 | ||
806 | QPoint clipperPos = clipper()-> | 807 | QPoint clipperPos = clipper()-> |
807 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 808 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
808 | 809 | ||
809 | // Scroll if cursor was moved to upper or lower end of agenda. | 810 | // Scroll if cursor was moved to upper or lower end of agenda. |
810 | if (clipperPos.y() < mScrollBorderWidth) { | 811 | if (clipperPos.y() < mScrollBorderWidth) { |
811 | mScrollUpTimer.start(mScrollDelay); | 812 | mScrollUpTimer.start(mScrollDelay); |
812 | } else if (visibleHeight() - clipperPos.y() < | 813 | } else if (visibleHeight() - clipperPos.y() < |
813 | mScrollBorderWidth) { | 814 | mScrollBorderWidth) { |
814 | mScrollDownTimer.start(mScrollDelay); | 815 | mScrollDownTimer.start(mScrollDelay); |
815 | } else { | 816 | } else { |
816 | mScrollUpTimer.stop(); | 817 | mScrollUpTimer.stop(); |
817 | mScrollDownTimer.stop(); | 818 | mScrollDownTimer.stop(); |
818 | } | 819 | } |
819 | 820 | ||
820 | if ( gy > mCurrentCellY ) { | 821 | if ( gy > mCurrentCellY ) { |
821 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 822 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
822 | 823 | ||
823 | #if 0 | 824 | #if 0 |
824 | // FIXME: Repaint only the newly selected region | 825 | // FIXME: Repaint only the newly selected region |
825 | repaintContents( mSelectionCellX * mGridSpacingX, | 826 | repaintContents( mSelectionCellX * mGridSpacingX, |
826 | mCurrentCellY + mGridSpacingY, | 827 | mCurrentCellY + mGridSpacingY, |
827 | mGridSpacingX, | 828 | mGridSpacingX, |
828 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); | 829 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); |
829 | #else | 830 | #else |
830 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 831 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
831 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 832 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
832 | mGridSpacingX, mSelectionYTop, | 833 | mGridSpacingX, mSelectionYTop, |
833 | mGridSpacingX, mSelectionHeight , false); | 834 | mGridSpacingX, mSelectionHeight , false); |
834 | #endif | 835 | #endif |
835 | 836 | ||
836 | mCurrentCellY = gy; | 837 | mCurrentCellY = gy; |
837 | } else if ( gy < mCurrentCellY ) { | 838 | } else if ( gy < mCurrentCellY ) { |
838 | if ( gy >= mStartCellY ) { | 839 | if ( gy >= mStartCellY ) { |
839 | int selectionHeight = mSelectionHeight; | 840 | int selectionHeight = mSelectionHeight; |
840 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 841 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
841 | 842 | ||
842 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 843 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
843 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 844 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
844 | mGridSpacingX, mSelectionYTop, | 845 | mGridSpacingX, mSelectionYTop, |
845 | mGridSpacingX, selectionHeight,false ); | 846 | mGridSpacingX, selectionHeight,false ); |
846 | 847 | ||
847 | mCurrentCellY = gy; | 848 | mCurrentCellY = gy; |
848 | } else { | 849 | } else { |
849 | } | 850 | } |
850 | } | 851 | } |
851 | } | 852 | } |
852 | 853 | ||
853 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 854 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
854 | { | 855 | { |
855 | mActionType = NOP; | 856 | mActionType = NOP; |
856 | mScrollUpTimer.stop(); | 857 | mScrollUpTimer.stop(); |
857 | mScrollDownTimer.stop(); | 858 | mScrollDownTimer.stop(); |
858 | 859 | ||
859 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 860 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
860 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 861 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
861 | qDebug("ew event signal "); | 862 | qDebug("ew event signal "); |
862 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 863 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
863 | } | 864 | } |
864 | } | 865 | } |
865 | 866 | ||
866 | void KOAgenda::startItemAction(QPoint viewportPos) | 867 | void KOAgenda::startItemAction(QPoint viewportPos) |
867 | { | 868 | { |
868 | int x,y; | 869 | int x,y; |
869 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 870 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
870 | int gx,gy; | 871 | int gx,gy; |
871 | contentsToGrid(x,y,gx,gy); | 872 | contentsToGrid(x,y,gx,gy); |
872 | 873 | ||
873 | mStartCellX = gx; | 874 | mStartCellX = gx; |
874 | mStartCellY = gy; | 875 | mStartCellY = gy; |
875 | mCurrentCellX = gx; | 876 | mCurrentCellX = gx; |
876 | mCurrentCellY = gy; | 877 | mCurrentCellY = gy; |
877 | 878 | ||
878 | if (mAllDayMode) { | 879 | if (mAllDayMode) { |
879 | int gridDistanceX = (x - gx * mGridSpacingX); | 880 | int gridDistanceX = (x - gx * mGridSpacingX); |
880 | if (gridDistanceX < mResizeBorderWidth && | 881 | if (gridDistanceX < mResizeBorderWidth && |
881 | mActionItem->cellX() == mCurrentCellX) { | 882 | mActionItem->cellX() == mCurrentCellX) { |
882 | mActionType = RESIZELEFT; | 883 | mActionType = RESIZELEFT; |
883 | setCursor(sizeHorCursor); | 884 | setCursor(sizeHorCursor); |
884 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 885 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
885 | mActionItem->cellXWidth() == mCurrentCellX) { | 886 | mActionItem->cellXWidth() == mCurrentCellX) { |
886 | mActionType = RESIZERIGHT; | 887 | mActionType = RESIZERIGHT; |
887 | setCursor(sizeHorCursor); | 888 | setCursor(sizeHorCursor); |
888 | } else { | 889 | } else { |
889 | mActionType = MOVE; | 890 | mActionType = MOVE; |
890 | mActionItem->startMove(); | 891 | mActionItem->startMove(); |
891 | setCursor(sizeAllCursor); | 892 | setCursor(sizeAllCursor); |
892 | } | 893 | } |
893 | } else { | 894 | } else { |
894 | int gridDistanceY = (y - gy * mGridSpacingY); | 895 | int gridDistanceY = (y - gy * mGridSpacingY); |
895 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 896 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); |
896 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 897 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
897 | mActionItem->cellYTop() == mCurrentCellY && | 898 | mActionItem->cellYTop() == mCurrentCellY && |
898 | !mActionItem->firstMultiItem()) { | 899 | !mActionItem->firstMultiItem()) { |