summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-21 09:12:37 (UTC)
committer zautrix <zautrix>2005-03-21 09:12:37 (UTC)
commit9707cf053ab0e64949518ebd2729d432435f583c (patch) (unidiff)
treedad8fca3e1eafc17062f1f183f50bfdb3fac5b8b
parente0351d382e7344191c3a7963eefe3396f816f7a0 (diff)
downloadkdepimpi-9707cf053ab0e64949518ebd2729d432435f583c.zip
kdepimpi-9707cf053ab0e64949518ebd2729d432435f583c.tar.gz
kdepimpi-9707cf053ab0e64949518ebd2729d432435f583c.tar.bz2
agenda mouse fix
Diffstat (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
@@ -1,995 +1,1002 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 Marcus Bains line. 5 Marcus Bains line.
6 Copyright (c) 2001 Ali Rahimi 6 Copyright (c) 2001 Ali Rahimi
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#define protected public 28#define protected public
29#include <qwidget.h> 29#include <qwidget.h>
30#undef protected 30#undef protected
31#endif 31#endif
32#include <qintdict.h> 32#include <qintdict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qpainter.h> 37#include <qpainter.h>
38 38
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kglobal.h> 42#include <kglobal.h>
43 43
44#include "koagendaitem.h" 44#include "koagendaitem.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47 47
48#include "koagenda.h" 48#include "koagenda.h"
49 49
50#include <libkcal/event.h> 50#include <libkcal/event.h>
51#include <libkcal/todo.h> 51#include <libkcal/todo.h>
52 52
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#endif 55#endif
56 56
57//extern bool globalFlagBlockPainting; 57//extern bool globalFlagBlockPainting;
58extern int globalFlagBlockAgenda; 58extern int globalFlagBlockAgenda;
59extern int globalFlagBlockAgendaItemPaint; 59extern int globalFlagBlockAgendaItemPaint;
60extern int globalFlagBlockAgendaItemUpdate; 60extern int globalFlagBlockAgendaItemUpdate;
61extern int globalFlagBlockStartup; 61extern int globalFlagBlockStartup;
62 62
63//////////////////////////////////////////////////////////////////////////// 63////////////////////////////////////////////////////////////////////////////
64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
65 : QFrame(_agenda->viewport(),name), agenda(_agenda) 65 : QFrame(_agenda->viewport(),name), agenda(_agenda)
66{ 66{
67 setLineWidth(0); 67 setLineWidth(0);
68 setMargin(0); 68 setMargin(0);
69 setBackgroundColor(Qt::red); 69 setBackgroundColor(Qt::red);
70 minutes = new QTimer(this); 70 minutes = new QTimer(this);
71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
72 minutes->start(0, true); 72 minutes->start(0, true);
73 73
74 mTimeBox = new QLabel(this); 74 mTimeBox = new QLabel(this);
75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
76 QPalette pal = mTimeBox->palette(); 76 QPalette pal = mTimeBox->palette();
77 pal.setColor(QColorGroup::Foreground, Qt::red); 77 pal.setColor(QColorGroup::Foreground, Qt::red);
78 mTimeBox->setPalette(pal); 78 mTimeBox->setPalette(pal);
79 //mTimeBox->setAutoMask(true); 79 //mTimeBox->setAutoMask(true);
80 80
81 agenda->addChild(mTimeBox); 81 agenda->addChild(mTimeBox);
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
275 mClickedItem = 0; 275 mClickedItem = 0;
276 276
277 mActionItem = 0; 277 mActionItem = 0;
278 mActionType = NOP; 278 mActionType = NOP;
279 mItemMoved = false; 279 mItemMoved = false;
280 280
281 mSelectedItem = 0; 281 mSelectedItem = 0;
282 282
283 // mItems.setAutoDelete(true); 283 // mItems.setAutoDelete(true);
284 284
285 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 285 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
286 286
287 viewport()->update(); 287 viewport()->update();
288 288
289 setMinimumSize(30, 1); 289 setMinimumSize(30, 1);
290// setMaximumHeight(mGridSpacingY * mRows + 5); 290// setMaximumHeight(mGridSpacingY * mRows + 5);
291 291
292 // Disable horizontal scrollbar. This is a hack. The geometry should be 292 // Disable horizontal scrollbar. This is a hack. The geometry should be
293 // controlled in a way that the contents horizontally always fits. Then it is 293 // controlled in a way that the contents horizontally always fits. Then it is
294 // not necessary to turn off the scrollbar. 294 // not necessary to turn off the scrollbar.
295 setHScrollBarMode(AlwaysOff); 295 setHScrollBarMode(AlwaysOff);
296 if ( ! mAllDayMode ) 296 if ( ! mAllDayMode )
297 setVScrollBarMode(AlwaysOn); 297 setVScrollBarMode(AlwaysOn);
298 else 298 else
299 setVScrollBarMode(AlwaysOff); 299 setVScrollBarMode(AlwaysOff);
300 300
301 setStartHour(KOPrefs::instance()->mDayBegins); 301 setStartHour(KOPrefs::instance()->mDayBegins);
302 302
303 calculateWorkingHours(); 303 calculateWorkingHours();
304 304
305 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 305 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
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
580 // 5Month view 587 // 5Month view
581 // 6Journal view 588 // 6Journal view
582 } 589 }
583} 590}
584void KOAgenda::startSelectAction(QPoint viewportPos) 591void KOAgenda::startSelectAction(QPoint viewportPos)
585{ 592{
586 //emit newStartSelectSignal(); 593 //emit newStartSelectSignal();
587 594
588 mActionType = SELECT; 595 mActionType = SELECT;
589 596
590 int x,y; 597 int x,y;
591 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 598 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
592 int gx,gy; 599 int gx,gy;
593 contentsToGrid(x,y,gx,gy); 600 contentsToGrid(x,y,gx,gy);
594 601
595 mStartCellX = gx; 602 mStartCellX = gx;
596 mStartCellY = gy; 603 mStartCellY = gy;
597 mCurrentCellX = gx; 604 mCurrentCellX = gx;
598 mCurrentCellY = gy; 605 mCurrentCellY = gy;
599 606
600 // Store coordinates of old selection 607 // Store coordinates of old selection
601 int selectionX = mSelectionCellX * mGridSpacingX; 608 int selectionX = mSelectionCellX * mGridSpacingX;
602 int selectionYTop = mSelectionYTop; 609 int selectionYTop = mSelectionYTop;
603 int selectionHeight = mSelectionHeight; 610 int selectionHeight = mSelectionHeight;
604 611
605 // Store new selection 612 // Store new selection
606 mSelectionCellX = gx; 613 mSelectionCellX = gx;
607 mSelectionYTop = gy * mGridSpacingY; 614 mSelectionYTop = gy * mGridSpacingY;
608 mSelectionHeight = mGridSpacingY; 615 mSelectionHeight = mGridSpacingY;
609 616
610 // Clear old selection 617 // Clear old selection
611 repaintContents( selectionX, selectionYTop, 618 repaintContents( selectionX, selectionYTop,
612 mGridSpacingX, selectionHeight,false ); 619 mGridSpacingX, selectionHeight,false );
613 620
614 // Paint new selection 621 // Paint new selection
615 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, 622 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
616 // mGridSpacingX, mSelectionHeight ); 623 // mGridSpacingX, mSelectionHeight );
617} 624}
618 625
619void KOAgenda::performSelectAction(QPoint viewportPos) 626void KOAgenda::performSelectAction(QPoint viewportPos)
620{ 627{
621 int x,y; 628 int x,y;
622 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 629 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
623 int gx,gy; 630 int gx,gy;
624 contentsToGrid(x,y,gx,gy); 631 contentsToGrid(x,y,gx,gy);
625 632
626 QPoint clipperPos = clipper()-> 633 QPoint clipperPos = clipper()->
627 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 634 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
628 635
629 // Scroll if cursor was moved to upper or lower end of agenda. 636 // Scroll if cursor was moved to upper or lower end of agenda.
630 if (clipperPos.y() < mScrollBorderWidth) { 637 if (clipperPos.y() < mScrollBorderWidth) {
631 mScrollUpTimer.start(mScrollDelay); 638 mScrollUpTimer.start(mScrollDelay);
632 } else if (visibleHeight() - clipperPos.y() < 639 } else if (visibleHeight() - clipperPos.y() <
633 mScrollBorderWidth) { 640 mScrollBorderWidth) {
634 mScrollDownTimer.start(mScrollDelay); 641 mScrollDownTimer.start(mScrollDelay);
635 } else { 642 } else {
636 mScrollUpTimer.stop(); 643 mScrollUpTimer.stop();
637 mScrollDownTimer.stop(); 644 mScrollDownTimer.stop();
638 } 645 }
639 646
640 if ( gy > mCurrentCellY ) { 647 if ( gy > mCurrentCellY ) {
641 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 648 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
642 649
643#if 0 650#if 0
644 // FIXME: Repaint only the newly selected region 651 // FIXME: Repaint only the newly selected region
645 repaintContents( mSelectionCellX * mGridSpacingX, 652 repaintContents( mSelectionCellX * mGridSpacingX,
646 mCurrentCellY + mGridSpacingY, 653 mCurrentCellY + mGridSpacingY,
647 mGridSpacingX, 654 mGridSpacingX,
648 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); 655 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY );
649#else 656#else
650 repaintContents( (KOGlobals::self()->reverseLayout() ? 657 repaintContents( (KOGlobals::self()->reverseLayout() ?
651 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 658 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
652 mGridSpacingX, mSelectionYTop, 659 mGridSpacingX, mSelectionYTop,
653 mGridSpacingX, mSelectionHeight , false); 660 mGridSpacingX, mSelectionHeight , false);
654#endif 661#endif
655 662
656 mCurrentCellY = gy; 663 mCurrentCellY = gy;
657 } else if ( gy < mCurrentCellY ) { 664 } else if ( gy < mCurrentCellY ) {
658 if ( gy >= mStartCellY ) { 665 if ( gy >= mStartCellY ) {
659 int selectionHeight = mSelectionHeight; 666 int selectionHeight = mSelectionHeight;
660 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 667 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
661 668
662 repaintContents( (KOGlobals::self()->reverseLayout() ? 669 repaintContents( (KOGlobals::self()->reverseLayout() ?
663 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 670 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
664 mGridSpacingX, mSelectionYTop, 671 mGridSpacingX, mSelectionYTop,
665 mGridSpacingX, selectionHeight,false ); 672 mGridSpacingX, selectionHeight,false );
666 673
667 mCurrentCellY = gy; 674 mCurrentCellY = gy;
668 } else { 675 } else {
669 } 676 }
670 } 677 }
671} 678}
672 679
673void KOAgenda::endSelectAction( bool emitNewEvent ) 680void KOAgenda::endSelectAction( bool emitNewEvent )
674{ 681{
675 mActionType = NOP; 682 mActionType = NOP;
676 mScrollUpTimer.stop(); 683 mScrollUpTimer.stop();
677 mScrollDownTimer.stop(); 684 mScrollDownTimer.stop();
678 685
679 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 686 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
680 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 687 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
681 qDebug("ew event signal "); 688 qDebug("ew event signal ");
682 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 689 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
683 } 690 }
684} 691}
685 692
686void KOAgenda::startItemAction(QPoint viewportPos) 693void KOAgenda::startItemAction(QPoint viewportPos)
687{ 694{
688 int x,y; 695 int x,y;
689 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 696 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
690 int gx,gy; 697 int gx,gy;
691 contentsToGrid(x,y,gx,gy); 698 contentsToGrid(x,y,gx,gy);
692 699
693 mStartCellX = gx; 700 mStartCellX = gx;
694 mStartCellY = gy; 701 mStartCellY = gy;
695 mCurrentCellX = gx; 702 mCurrentCellX = gx;
696 mCurrentCellY = gy; 703 mCurrentCellY = gy;
697 704
698 if (mAllDayMode) { 705 if (mAllDayMode) {
699 int gridDistanceX = (x - gx * mGridSpacingX); 706 int gridDistanceX = (x - gx * mGridSpacingX);
700 if (gridDistanceX < mResizeBorderWidth && 707 if (gridDistanceX < mResizeBorderWidth &&
701 mActionItem->cellX() == mCurrentCellX) { 708 mActionItem->cellX() == mCurrentCellX) {
702 mActionType = RESIZELEFT; 709 mActionType = RESIZELEFT;
703 setCursor(sizeHorCursor); 710 setCursor(sizeHorCursor);
704 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 711 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
705 mActionItem->cellXWidth() == mCurrentCellX) { 712 mActionItem->cellXWidth() == mCurrentCellX) {
706 mActionType = RESIZERIGHT; 713 mActionType = RESIZERIGHT;
707 setCursor(sizeHorCursor); 714 setCursor(sizeHorCursor);
708 } else { 715 } else {
709 mActionType = MOVE; 716 mActionType = MOVE;
710 mActionItem->startMove(); 717 mActionItem->startMove();
711 setCursor(sizeAllCursor); 718 setCursor(sizeAllCursor);
712 } 719 }
713 } else { 720 } else {
714 int gridDistanceY = (y - gy * mGridSpacingY); 721 int gridDistanceY = (y - gy * mGridSpacingY);
715 bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); 722 bool allowResize = ( mActionItem->incidence()->type() != "Todo" );
716 if (allowResize && gridDistanceY < mResizeBorderWidth && 723 if (allowResize && gridDistanceY < mResizeBorderWidth &&
717 mActionItem->cellYTop() == mCurrentCellY && 724 mActionItem->cellYTop() == mCurrentCellY &&
718 !mActionItem->firstMultiItem()) { 725 !mActionItem->firstMultiItem()) {
719 mActionType = RESIZETOP; 726 mActionType = RESIZETOP;
720 setCursor(sizeVerCursor); 727 setCursor(sizeVerCursor);
721 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 728 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
722 mActionItem->cellYBottom() == mCurrentCellY && 729 mActionItem->cellYBottom() == mCurrentCellY &&
723 !mActionItem->lastMultiItem()) { 730 !mActionItem->lastMultiItem()) {
724 mActionType = RESIZEBOTTOM; 731 mActionType = RESIZEBOTTOM;
725 setCursor(sizeVerCursor); 732 setCursor(sizeVerCursor);
726 } else { 733 } else {
727 mActionType = MOVE; 734 mActionType = MOVE;
728 mActionItem->startMove(); 735 mActionItem->startMove();
729 setCursor(sizeAllCursor); 736 setCursor(sizeAllCursor);
730 } 737 }
731 } 738 }
732} 739}
733 740
734void KOAgenda::performItemAction(QPoint viewportPos) 741void KOAgenda::performItemAction(QPoint viewportPos)
735{ 742{
736// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 743// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
737// QPoint point = viewport()->mapToGlobal(viewportPos); 744// QPoint point = viewport()->mapToGlobal(viewportPos);
738// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 745// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
739// point = clipper()->mapFromGlobal(point); 746// point = clipper()->mapFromGlobal(point);
740// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 747// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
741// kdDebug() << "visible height: " << visibleHeight() << endl; 748// kdDebug() << "visible height: " << visibleHeight() << endl;
742 int x,y; 749 int x,y;
743 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 750 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
744// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 751// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
745 int gx,gy; 752 int gx,gy;
746 contentsToGrid(x,y,gx,gy); 753 contentsToGrid(x,y,gx,gy);
747 QPoint clipperPos = clipper()-> 754 QPoint clipperPos = clipper()->
748 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 755 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
749 756
750 // Cursor left active agenda area. 757 // Cursor left active agenda area.
751 // This starts a drag. 758 // This starts a drag.
752 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 759 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
753 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 760 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
754 if ( mActionType == MOVE ) { 761 if ( mActionType == MOVE ) {
755 mScrollUpTimer.stop(); 762 mScrollUpTimer.stop();
756 mScrollDownTimer.stop(); 763 mScrollDownTimer.stop();
757 mActionItem->resetMove(); 764 mActionItem->resetMove();
758 placeSubCells( mActionItem ); 765 placeSubCells( mActionItem );
759 // emit startDragSignal( mActionItem->incidence() ); 766 // emit startDragSignal( mActionItem->incidence() );
760 setCursor( arrowCursor ); 767 setCursor( arrowCursor );
761 mActionItem = 0; 768 mActionItem = 0;
762 mActionType = NOP; 769 mActionType = NOP;
763 mItemMoved = 0; 770 mItemMoved = 0;
764 return; 771 return;
765 } 772 }
766 } else { 773 } else {
767 switch ( mActionType ) { 774 switch ( mActionType ) {
768 case MOVE: 775 case MOVE:
769 setCursor( sizeAllCursor ); 776 setCursor( sizeAllCursor );
770 break; 777 break;
771 case RESIZETOP: 778 case RESIZETOP:
772 case RESIZEBOTTOM: 779 case RESIZEBOTTOM:
773 setCursor( sizeVerCursor ); 780 setCursor( sizeVerCursor );
774 break; 781 break;
775 case RESIZELEFT: 782 case RESIZELEFT:
776 case RESIZERIGHT: 783 case RESIZERIGHT:
777 setCursor( sizeHorCursor ); 784 setCursor( sizeHorCursor );
778 break; 785 break;
779 default: 786 default:
780 setCursor( arrowCursor ); 787 setCursor( arrowCursor );
781 } 788 }
782 } 789 }
783 790
784 // Scroll if item was moved to upper or lower end of agenda. 791 // Scroll if item was moved to upper or lower end of agenda.
785 if (clipperPos.y() < mScrollBorderWidth) { 792 if (clipperPos.y() < mScrollBorderWidth) {
786 mScrollUpTimer.start(mScrollDelay); 793 mScrollUpTimer.start(mScrollDelay);
787 } else if (visibleHeight() - clipperPos.y() < 794 } else if (visibleHeight() - clipperPos.y() <
788 mScrollBorderWidth) { 795 mScrollBorderWidth) {
789 mScrollDownTimer.start(mScrollDelay); 796 mScrollDownTimer.start(mScrollDelay);
790 } else { 797 } else {
791 mScrollUpTimer.stop(); 798 mScrollUpTimer.stop();
792 mScrollDownTimer.stop(); 799 mScrollDownTimer.stop();
793 } 800 }
794 801
795 // Move or resize item if necessary 802 // Move or resize item if necessary
796 if (mCurrentCellX != gx || mCurrentCellY != gy) { 803 if (mCurrentCellX != gx || mCurrentCellY != gy) {
797 mItemMoved = true; 804 mItemMoved = true;
798 mActionItem->raise(); 805 mActionItem->raise();
799 if (mActionType == MOVE) { 806 if (mActionType == MOVE) {
800 // Move all items belonging to a multi item 807 // Move all items belonging to a multi item
801 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 808 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
802 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 809 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
803 if (!moveItem) moveItem = mActionItem; 810 if (!moveItem) moveItem = mActionItem;
804 while (moveItem) { 811 while (moveItem) {
805 int dy; 812 int dy;
806 if (isMultiItem) dy = 0; 813 if (isMultiItem) dy = 0;
807 else dy = gy - mCurrentCellY; 814 else dy = gy - mCurrentCellY;
808 moveItem->moveRelative(gx - mCurrentCellX,dy); 815 moveItem->moveRelative(gx - mCurrentCellX,dy);
809 int x,y; 816 int x,y;
810 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 817 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
811 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 818 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
812 mGridSpacingY * moveItem->cellHeight()); 819 mGridSpacingY * moveItem->cellHeight());
813 moveChild(moveItem,x,y); 820 moveChild(moveItem,x,y);
814 moveItem = moveItem->nextMultiItem(); 821 moveItem = moveItem->nextMultiItem();
815 } 822 }
816 } else if (mActionType == RESIZETOP) { 823 } else if (mActionType == RESIZETOP) {
817 if (mCurrentCellY <= mActionItem->cellYBottom()) { 824 if (mCurrentCellY <= mActionItem->cellYBottom()) {
818 mActionItem->expandTop(gy - mCurrentCellY); 825 mActionItem->expandTop(gy - mCurrentCellY);
819 mActionItem->resize(mActionItem->width(), 826 mActionItem->resize(mActionItem->width(),
820 mGridSpacingY * mActionItem->cellHeight()); 827 mGridSpacingY * mActionItem->cellHeight());
821 int x,y; 828 int x,y;
822 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 829 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
823 //moveChild(mActionItem,childX(mActionItem),y); 830 //moveChild(mActionItem,childX(mActionItem),y);
824 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 831 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
825 } 832 }
826 } else if (mActionType == RESIZEBOTTOM) { 833 } else if (mActionType == RESIZEBOTTOM) {
827 if (mCurrentCellY >= mActionItem->cellYTop()) { 834 if (mCurrentCellY >= mActionItem->cellYTop()) {
828 mActionItem->expandBottom(gy - mCurrentCellY); 835 mActionItem->expandBottom(gy - mCurrentCellY);
829 mActionItem->resize(mActionItem->width(), 836 mActionItem->resize(mActionItem->width(),
830 mGridSpacingY * mActionItem->cellHeight()); 837 mGridSpacingY * mActionItem->cellHeight());
831 } 838 }
832 } else if (mActionType == RESIZELEFT) { 839 } else if (mActionType == RESIZELEFT) {
833 if (mCurrentCellX <= mActionItem->cellXWidth()) { 840 if (mCurrentCellX <= mActionItem->cellXWidth()) {
834 mActionItem->expandLeft(gx - mCurrentCellX); 841 mActionItem->expandLeft(gx - mCurrentCellX);
835 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 842 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
836 mActionItem->height()); 843 mActionItem->height());
837 int x,y; 844 int x,y;
838 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 845 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
839 moveChild(mActionItem,x,childY(mActionItem)); 846 moveChild(mActionItem,x,childY(mActionItem));
840 } 847 }
841 } else if (mActionType == RESIZERIGHT) { 848 } else if (mActionType == RESIZERIGHT) {
842 if (mCurrentCellX >= mActionItem->cellX()) { 849 if (mCurrentCellX >= mActionItem->cellX()) {
843 mActionItem->expandRight(gx - mCurrentCellX); 850 mActionItem->expandRight(gx - mCurrentCellX);
844 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 851 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
845 mActionItem->height()); 852 mActionItem->height());
846 } 853 }
847 } 854 }
848 mCurrentCellX = gx; 855 mCurrentCellX = gx;
849 mCurrentCellY = gy; 856 mCurrentCellY = gy;
850 } 857 }
851} 858}
852 859
853void KOAgenda::endItemAction() 860void KOAgenda::endItemAction()
854{ 861{
855 862
856 if ( mItemMoved ) { 863 if ( mItemMoved ) {
857 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 864 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
858 if ( !placeItem ) { 865 if ( !placeItem ) {
859 placeItem = mActionItem; 866 placeItem = mActionItem;
860 } 867 }
861 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 868 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
862 Incidence* oldInc = placeItem->incidence(); 869 Incidence* oldInc = placeItem->incidence();
863 placeItem->recreateIncidence(); 870 placeItem->recreateIncidence();
864 emit addToCalSignal(placeItem->incidence(), oldInc ); 871 emit addToCalSignal(placeItem->incidence(), oldInc );
865 } 872 }
866 int type = mActionType; 873 int type = mActionType;
867 if ( mAllDayMode ) 874 if ( mAllDayMode )
868 type = -1; 875 type = -1;
869 KOAgendaItem *modifiedItem = placeItem; 876 KOAgendaItem *modifiedItem = placeItem;
870 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 877 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
871 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 878 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
872 KOAgendaItem *item; 879 KOAgendaItem *item;
873 880
874 if ( placeItem->incidence()->type() == "Todo" ) { 881 if ( placeItem->incidence()->type() == "Todo" ) {
875 mSelectedItem = 0; 882 mSelectedItem = 0;
876 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 883 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
877 modifiedItem->mLastMoveXPos = mCurrentCellX; 884 modifiedItem->mLastMoveXPos = mCurrentCellX;
878 emit itemModified( modifiedItem, mActionType ); 885 emit itemModified( modifiedItem, mActionType );
879 } 886 }
880 else { 887 else {
881#if 0 888#if 0
882 for ( item=oldconflictItems.first(); item != 0; 889 for ( item=oldconflictItems.first(); item != 0;
883 item=oldconflictItems.next() ) { 890 item=oldconflictItems.next() ) {
884 placeSubCells(item); 891 placeSubCells(item);
885 } 892 }
886 while ( placeItem ) { 893 while ( placeItem ) {
887 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 894 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
888 placeSubCells( placeItem ); 895 placeSubCells( placeItem );
889 placeItem = placeItem->nextMultiItem(); 896 placeItem = placeItem->nextMultiItem();
890 } 897 }
891#endif 898#endif
892 899
893 globalFlagBlockAgendaItemPaint = 1; 900 globalFlagBlockAgendaItemPaint = 1;
894 for ( item=oldconflictItems.first(); item != 0; 901 for ( item=oldconflictItems.first(); item != 0;
895 item=oldconflictItems.next() ) { 902 item=oldconflictItems.next() ) {
896 placeSubCells(item); 903 placeSubCells(item);
897 } 904 }
898 while ( placeItem ) { 905 while ( placeItem ) {
899 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 906 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
900 oldconflictItems = placeItem->conflictItems(); 907 oldconflictItems = placeItem->conflictItems();
901 for ( item=oldconflictItems.first(); item != 0; 908 for ( item=oldconflictItems.first(); item != 0;
902 item=oldconflictItems.next() ) { 909 item=oldconflictItems.next() ) {
903 placeSubCells(item); 910 placeSubCells(item);
904 } 911 }
905 placeSubCells( placeItem ); 912 placeSubCells( placeItem );
906 placeItem = placeItem->nextMultiItem(); 913 placeItem = placeItem->nextMultiItem();
907 } 914 }
908 globalFlagBlockAgendaItemPaint = 0; 915 globalFlagBlockAgendaItemPaint = 0;
909 for ( item=oldconflictItems.first(); item != 0; 916 for ( item=oldconflictItems.first(); item != 0;
910 item=oldconflictItems.next() ) { 917 item=oldconflictItems.next() ) {
911 globalFlagBlockAgendaItemUpdate = 0; 918 globalFlagBlockAgendaItemUpdate = 0;
912 item->repaintMe(); 919 item->repaintMe();
913 globalFlagBlockAgendaItemUpdate = 1; 920 globalFlagBlockAgendaItemUpdate = 1;
914 item->repaint( false ); 921 item->repaint( false );
915 } 922 }
916 placeItem = modifiedItem; 923 placeItem = modifiedItem;
917 924
918 while ( placeItem ) { 925 while ( placeItem ) {
919 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 926 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
920 globalFlagBlockAgendaItemUpdate = 0; 927 globalFlagBlockAgendaItemUpdate = 0;
921 placeItem->repaintMe(); 928 placeItem->repaintMe();
922 globalFlagBlockAgendaItemUpdate = 1; 929 globalFlagBlockAgendaItemUpdate = 1;
923 placeItem->repaint(false); 930 placeItem->repaint(false);
924 placeItem = placeItem->nextMultiItem(); 931 placeItem = placeItem->nextMultiItem();
925 } 932 }
926 emit itemModified( modifiedItem, mActionType ); 933 emit itemModified( modifiedItem, mActionType );
927 934
928 935
929 placeItem = modifiedItem; 936 placeItem = modifiedItem;
930 while ( placeItem ) { 937 while ( placeItem ) {
931 oldconflictItems = placeItem->conflictItems(); 938 oldconflictItems = placeItem->conflictItems();
932 for ( item=oldconflictItems.first(); item != 0; 939 for ( item=oldconflictItems.first(); item != 0;
933 item=oldconflictItems.next() ) { 940 item=oldconflictItems.next() ) {
934 placeSubCells(item); 941 placeSubCells(item);
935 } 942 }
936 placeSubCells( placeItem ); 943 placeSubCells( placeItem );
937 placeItem = placeItem->nextMultiItem(); 944 placeItem = placeItem->nextMultiItem();
938 945
939 } 946 }
940 placeItem = modifiedItem; 947 placeItem = modifiedItem;
941 while ( placeItem ) { 948 while ( placeItem ) {
942 oldconflictItems = placeItem->conflictItems(); 949 oldconflictItems = placeItem->conflictItems();
943 for ( item=oldconflictItems.first(); item != 0; 950 for ( item=oldconflictItems.first(); item != 0;
944 item=oldconflictItems.next() ) { 951 item=oldconflictItems.next() ) {
945 globalFlagBlockAgendaItemUpdate = 0; 952 globalFlagBlockAgendaItemUpdate = 0;
946 item->repaintMe(); 953 item->repaintMe();
947 globalFlagBlockAgendaItemUpdate = 1; 954 globalFlagBlockAgendaItemUpdate = 1;
948 item->repaint(false); 955 item->repaint(false);
949 } 956 }
950 placeItem = placeItem->nextMultiItem(); 957 placeItem = placeItem->nextMultiItem();
951 } 958 }
952 /* 959 /*
953 960
954 oldconflictItems = modifiedItem->conflictItems(); 961 oldconflictItems = modifiedItem->conflictItems();
955 for ( item=oldconflictItems.first(); item != 0; 962 for ( item=oldconflictItems.first(); item != 0;
956 item=oldconflictItems.next() ) { 963 item=oldconflictItems.next() ) {
957 globalFlagBlockAgendaItemUpdate = 0; 964 globalFlagBlockAgendaItemUpdate = 0;
958 item->paintMe(false); 965 item->paintMe(false);
959 globalFlagBlockAgendaItemUpdate = 1; 966 globalFlagBlockAgendaItemUpdate = 1;
960 item->repaint(false); 967 item->repaint(false);
961 } 968 }
962 */ 969 */
963 970
964 971
965 } 972 }
966 973
967 } 974 }
968 975
969 mScrollUpTimer.stop(); 976 mScrollUpTimer.stop();
970 mScrollDownTimer.stop(); 977 mScrollDownTimer.stop();
971 setCursor( arrowCursor ); 978 setCursor( arrowCursor );
972 mActionItem = 0; 979 mActionItem = 0;
973 mActionType = NOP; 980 mActionType = NOP;
974 mItemMoved = 0; 981 mItemMoved = 0;
975 982
976} 983}
977 984
978void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 985void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
979{ 986{
980// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 987// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
981// QPoint point = viewport()->mapToGlobal(viewportPos); 988// QPoint point = viewport()->mapToGlobal(viewportPos);
982// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 989// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
983// point = clipper()->mapFromGlobal(point); 990// point = clipper()->mapFromGlobal(point);
984// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 991// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
985 992
986 int x,y; 993 int x,y;
987 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 994 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
988// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 995// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
989 int gx,gy; 996 int gx,gy;
990 contentsToGrid(x,y,gx,gy); 997 contentsToGrid(x,y,gx,gy);
991 998
992 // Change cursor to resize cursor if appropriate 999 // Change cursor to resize cursor if appropriate
993 if (mAllDayMode) { 1000 if (mAllDayMode) {
994 int gridDistanceX = (x - gx * mGridSpacingX); 1001 int gridDistanceX = (x - gx * mGridSpacingX);
995 if (gridDistanceX < mResizeBorderWidth && 1002 if (gridDistanceX < mResizeBorderWidth &&