-rw-r--r-- | korganizer/koagenda.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 1a24887..9720f43 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -51,385 +51,385 @@ | |||
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; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | //////////////////////////////////////////////////////////////////////////// | 63 | //////////////////////////////////////////////////////////////////////////// |
64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 64 | MarcusBains::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 | mTimeBox = new QLabel(this); | 73 | mTimeBox = new QLabel(this); |
74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
75 | QPalette pal = mTimeBox->palette(); | 75 | QPalette pal = mTimeBox->palette(); |
76 | pal.setColor(QColorGroup::Foreground, Qt::red); | 76 | pal.setColor(QColorGroup::Foreground, Qt::red); |
77 | mTimeBox->setPalette(pal); | 77 | mTimeBox->setPalette(pal); |
78 | //mTimeBox->setAutoMask(true); | 78 | //mTimeBox->setAutoMask(true); |
79 | 79 | ||
80 | agenda->addChild(mTimeBox); | 80 | agenda->addChild(mTimeBox); |
81 | 81 | ||
82 | oldToday = -1; | 82 | oldToday = -1; |
83 | } | 83 | } |
84 | 84 | ||
85 | MarcusBains::~MarcusBains() | 85 | MarcusBains::~MarcusBains() |
86 | { | 86 | { |
87 | delete minutes; | 87 | delete minutes; |
88 | } | 88 | } |
89 | 89 | ||
90 | int MarcusBains::todayColumn() | 90 | int MarcusBains::todayColumn() |
91 | { | 91 | { |
92 | QDate currentDate = QDate::currentDate(); | 92 | QDate currentDate = QDate::currentDate(); |
93 | 93 | ||
94 | DateList dateList = agenda->dateList(); | 94 | DateList dateList = agenda->dateList(); |
95 | DateList::ConstIterator it; | 95 | DateList::ConstIterator it; |
96 | int col = 0; | 96 | int col = 0; |
97 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 97 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
98 | if((*it) == currentDate) | 98 | if((*it) == currentDate) |
99 | return KOGlobals::self()->reverseLayout() ? | 99 | return KOGlobals::self()->reverseLayout() ? |
100 | agenda->columns() - 1 - col : col; | 100 | agenda->columns() - 1 - col : col; |
101 | ++col; | 101 | ++col; |
102 | } | 102 | } |
103 | 103 | ||
104 | return -1; | 104 | return -1; |
105 | } | 105 | } |
106 | void MarcusBains::updateLoc() | 106 | void MarcusBains::updateLoc() |
107 | { | 107 | { |
108 | updateLocation(); | 108 | updateLocation(); |
109 | } | 109 | } |
110 | void MarcusBains::updateLocation(bool recalculate) | 110 | void MarcusBains::updateLocation(bool recalculate) |
111 | { | 111 | { |
112 | 112 | ||
113 | QTime tim = QTime::currentTime(); | 113 | QTime tim = QTime::currentTime(); |
114 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 114 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
115 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 115 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
116 | recalculate = true; | 116 | recalculate = true; |
117 | 117 | ||
118 | int mins = tim.hour()*60 + tim.minute(); | 118 | int mins = tim.hour()*60 + tim.minute(); |
119 | int minutesPerCell = 24 * 60 / agenda->rows(); | 119 | int minutesPerCell = 24 * 60 / agenda->rows(); |
120 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 120 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
121 | int today = recalculate ? todayColumn() : oldToday; | 121 | int today = recalculate ? todayColumn() : oldToday; |
122 | int x = agenda->gridSpacingX()*today; | 122 | int x = agenda->gridSpacingX()*today; |
123 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 123 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
124 | 124 | ||
125 | oldTime = tim; | 125 | oldTime = tim; |
126 | oldToday = today; | 126 | oldToday = today; |
127 | 127 | ||
128 | if(disabled || (today<0)) { | 128 | if(disabled || (today<0)) { |
129 | hide(); mTimeBox->hide(); | 129 | hide(); mTimeBox->hide(); |
130 | return; | 130 | return; |
131 | } else { | 131 | } else { |
132 | show(); mTimeBox->show(); | 132 | show(); mTimeBox->show(); |
133 | } | 133 | } |
134 | 134 | ||
135 | if(recalculate) | 135 | if(recalculate) |
136 | setFixedSize(agenda->gridSpacingX(),1); | 136 | setFixedSize(agenda->gridSpacingX(),1); |
137 | agenda->moveChild(this, x, y); | 137 | agenda->moveChild(this, x, y); |
138 | raise(); | 138 | raise(); |
139 | 139 | ||
140 | if(recalculate) | 140 | if(recalculate) |
141 | //mTimeBox->setFont(QFont("helvetica",10)); | 141 | //mTimeBox->setFont(QFont("helvetica",10)); |
142 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 142 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
143 | 143 | ||
144 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 144 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
145 | mTimeBox->adjustSize(); | 145 | mTimeBox->adjustSize(); |
146 | // the -2 below is there because there is a bug in this program | 146 | // the -2 below is there because there is a bug in this program |
147 | // somewhere, where the last column of this widget is a few pixels | 147 | // somewhere, where the last column of this widget is a few pixels |
148 | // narrower than the other columns. | 148 | // narrower than the other columns. |
149 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 149 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
150 | agenda->moveChild(mTimeBox, | 150 | agenda->moveChild(mTimeBox, |
151 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 151 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
152 | y-mTimeBox->height()); | 152 | y-mTimeBox->height()); |
153 | 153 | ||
154 | mTimeBox->raise(); | 154 | mTimeBox->raise(); |
155 | //mTimeBox->setAutoMask(true); | 155 | //mTimeBox->setAutoMask(true); |
156 | minutes->start(5000,true); | 156 | minutes->start(5000,true); |
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
160 | //////////////////////////////////////////////////////////////////////////// | 160 | //////////////////////////////////////////////////////////////////////////// |
161 | 161 | ||
162 | 162 | ||
163 | /* | 163 | /* |
164 | Create an agenda widget with rows rows and columns columns. | 164 | Create an agenda widget with rows rows and columns columns. |
165 | */ | 165 | */ |
166 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 166 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
167 | const char *name,WFlags f) : | 167 | const char *name,WFlags f) : |
168 | QScrollView(parent,name,f) | 168 | QScrollView(parent,name,f) |
169 | { | 169 | { |
170 | 170 | ||
171 | 171 | ||
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("Next 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 ) { |
@@ -565,386 +565,385 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | |||
565 | break; | 565 | break; |
566 | 566 | ||
567 | default: | 567 | default: |
568 | break; | 568 | break; |
569 | } | 569 | } |
570 | return true; | 570 | return true; |
571 | #if 0 | 571 | #if 0 |
572 | //qDebug("KOAgenda::eventFilter_mous "); | 572 | //qDebug("KOAgenda::eventFilter_mous "); |
573 | QPoint viewportPos; | 573 | QPoint viewportPos; |
574 | if (object != viewport()) { | 574 | if (object != viewport()) { |
575 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 575 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
576 | } else { | 576 | } else { |
577 | viewportPos = me->pos(); | 577 | viewportPos = me->pos(); |
578 | } | 578 | } |
579 | static int startX = 0; | 579 | static int startX = 0; |
580 | static int startY = 0; | 580 | static int startY = 0; |
581 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | 581 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); |
582 | static bool blockMoving = true; | 582 | static bool blockMoving = true; |
583 | static bool leftMouseDown = false; | 583 | static bool leftMouseDown = false; |
584 | bool rightButtonPressed = false; | 584 | bool rightButtonPressed = false; |
585 | switch (me->type()) { | 585 | switch (me->type()) { |
586 | case QEvent::MouseButtonPress: | 586 | case QEvent::MouseButtonPress: |
587 | if (me->button() == LeftButton) { | 587 | if (me->button() == LeftButton) { |
588 | leftMouseDown = true; | 588 | leftMouseDown = true; |
589 | } | 589 | } |
590 | else if (me->button() == RightButton) { | 590 | else if (me->button() == RightButton) { |
591 | leftMouseDown = false; | 591 | leftMouseDown = false; |
592 | } | 592 | } |
593 | blockMoving = true; | 593 | blockMoving = true; |
594 | startX = viewportPos.x(); | 594 | startX = viewportPos.x(); |
595 | startY = viewportPos.y(); | 595 | startY = viewportPos.y(); |
596 | if (object != viewport()) { // item clicked ************** | 596 | if (object != viewport()) { // item clicked ************** |
597 | if (me->button() == RightButton) { | 597 | if (me->button() == RightButton) { |
598 | leftMouseDown = false; | 598 | leftMouseDown = false; |
599 | mClickedItem = (KOAgendaItem *)object; | 599 | mClickedItem = (KOAgendaItem *)object; |
600 | if (mActionItem ) { | 600 | if (mActionItem ) { |
601 | endItemAction(); | 601 | endItemAction(); |
602 | } | 602 | } |
603 | if (mClickedItem) { | 603 | if (mClickedItem) { |
604 | selectItem(mClickedItem); | 604 | selectItem(mClickedItem); |
605 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 605 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
606 | } | 606 | } |
607 | return true; | 607 | return true; |
608 | } else if (me->button() == LeftButton) { | 608 | } else if (me->button() == LeftButton) { |
609 | mActionItem = (KOAgendaItem *)object; | 609 | mActionItem = (KOAgendaItem *)object; |
610 | if (mActionItem) { | 610 | if (mActionItem) { |
611 | if ( mSelectionHeight > 0 ) { | 611 | if ( mSelectionHeight > 0 ) { |
612 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 612 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
613 | int selectionYTop = mSelectionYTop; | 613 | int selectionYTop = mSelectionYTop; |
614 | int gridSpacingX = mGridSpacingX; | 614 | int gridSpacingX = mGridSpacingX; |
615 | int selectionHeight = mSelectionHeight; | 615 | int selectionHeight = mSelectionHeight; |
616 | clearSelection(); | 616 | clearSelection(); |
617 | repaintContents( selectionCellX, selectionYTop, | 617 | repaintContents( selectionCellX, selectionYTop, |
618 | gridSpacingX, selectionHeight,false ); | 618 | gridSpacingX, selectionHeight,false ); |
619 | } | 619 | } |
620 | selectItem(mActionItem); | 620 | selectItem(mActionItem); |
621 | Incidence *incidence = mActionItem->incidence(); | 621 | Incidence *incidence = mActionItem->incidence(); |
622 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 622 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
623 | mActionItem = 0; | 623 | mActionItem = 0; |
624 | } else { | 624 | } else { |
625 | startItemAction(viewportPos); | 625 | startItemAction(viewportPos); |
626 | } | 626 | } |
627 | } | 627 | } |
628 | } | 628 | } |
629 | } else { // ---------- viewport() | 629 | } else { // ---------- viewport() |
630 | selectItem(0); | 630 | selectItem(0); |
631 | mActionItem = 0; | 631 | mActionItem = 0; |
632 | if (me->button() == LeftButton ) { | 632 | if (me->button() == LeftButton ) { |
633 | setCursor(arrowCursor); | 633 | setCursor(arrowCursor); |
634 | startSelectAction(viewportPos); | 634 | startSelectAction(viewportPos); |
635 | } else if (me->button() == RightButton ) { | 635 | } else if (me->button() == RightButton ) { |
636 | setCursor(arrowCursor); | 636 | setCursor(arrowCursor); |
637 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action | 637 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action |
638 | endSelectAction( false ); // do not emit new event signal | 638 | endSelectAction( false ); // do not emit new event signal |
639 | leftMouseDown = false; // no more leftMouse computation | 639 | leftMouseDown = false; // no more leftMouse computation |
640 | } | 640 | } |
641 | int x,y; | 641 | int x,y; |
642 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 642 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
643 | int gx,gy; | 643 | int gx,gy; |
644 | contentsToGrid(x,y,gx,gy); | 644 | contentsToGrid(x,y,gx,gy); |
645 | mCurrentCellX = gx; | 645 | mCurrentCellX = gx; |
646 | mCurrentCellY = gy; | 646 | mCurrentCellY = gy; |
647 | mStartCellX = gx; | 647 | mStartCellX = gx; |
648 | mStartCellY = gy; | 648 | mStartCellY = gy; |
649 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | 649 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); |
650 | } | 650 | } |
651 | } | 651 | } |
652 | break; | 652 | break; |
653 | 653 | ||
654 | case QEvent::MouseButtonRelease: | 654 | case QEvent::MouseButtonRelease: |
655 | 655 | ||
656 | if (object != viewport()) { | 656 | if (object != viewport()) { |
657 | if (me->button() == LeftButton && leftMouseDown) { | 657 | if (me->button() == LeftButton && leftMouseDown) { |
658 | if (mActionItem) { | 658 | if (mActionItem) { |
659 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 659 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
660 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 660 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
661 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 661 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
662 | mScrollUpTimer.stop(); | 662 | mScrollUpTimer.stop(); |
663 | mScrollDownTimer.stop(); | 663 | mScrollDownTimer.stop(); |
664 | mActionItem->resetMove(); | 664 | mActionItem->resetMove(); |
665 | placeSubCells( mActionItem ); | 665 | placeSubCells( mActionItem ); |
666 | // emit startDragSignal( mActionItem->incidence() ); | 666 | // emit startDragSignal( mActionItem->incidence() ); |
667 | setCursor( arrowCursor ); | 667 | setCursor( arrowCursor ); |
668 | mActionItem = 0; | 668 | mActionItem = 0; |
669 | mActionType = NOP; | 669 | mActionType = NOP; |
670 | mItemMoved = 0; | 670 | mItemMoved = 0; |
671 | leftMouseDown = false; | 671 | leftMouseDown = false; |
672 | return true; | 672 | return true; |
673 | } | 673 | } |
674 | endItemAction(); | 674 | endItemAction(); |
675 | } | 675 | } |
676 | } | 676 | } |
677 | 677 | ||
678 | } else { // ---------- viewport() | 678 | } else { // ---------- viewport() |
679 | if (me->button() == LeftButton && leftMouseDown ) { //left click | 679 | if (me->button() == LeftButton && leftMouseDown ) { //left click |
680 | endSelectAction( true ); // emit new event signal | 680 | endSelectAction( true ); // emit new event signal |
681 | } | 681 | } |
682 | } | 682 | } |
683 | if (me->button() == LeftButton) | 683 | if (me->button() == LeftButton) |
684 | leftMouseDown = false; | 684 | leftMouseDown = false; |
685 | 685 | ||
686 | break; | 686 | break; |
687 | 687 | ||
688 | case QEvent::MouseMove: | 688 | case QEvent::MouseMove: |
689 | if ( !leftMouseDown ) | 689 | if ( !leftMouseDown ) |
690 | return true; | 690 | return true; |
691 | if ( blockMoving ) { | 691 | if ( blockMoving ) { |
692 | int dX, dY; | 692 | int dX, dY; |
693 | dX = startX - viewportPos.x(); | 693 | dX = startX - viewportPos.x(); |
694 | if ( dX < 0 ) | 694 | if ( dX < 0 ) |
695 | dX = -dX; | 695 | dX = -dX; |
696 | dY = viewportPos.y() - startY; | 696 | dY = viewportPos.y() - startY; |
697 | if ( dY < 0 ) | 697 | if ( dY < 0 ) |
698 | dY = -dY; | 698 | dY = -dY; |
699 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 699 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
700 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 700 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
701 | blockMoving = false; | 701 | blockMoving = false; |
702 | } | 702 | } |
703 | } | 703 | } |
704 | if (object != viewport()) { | 704 | if (object != viewport()) { |
705 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 705 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
706 | if (!moveItem->incidence()->isReadOnly() ) { | 706 | if (!moveItem->incidence()->isReadOnly() ) { |
707 | if (!mActionItem) | 707 | if (!mActionItem) |
708 | setNoActionCursor(moveItem,viewportPos); | 708 | setNoActionCursor(moveItem,viewportPos); |
709 | else { | 709 | else { |
710 | if ( !blockMoving ) | 710 | if ( !blockMoving ) |
711 | performItemAction(viewportPos); | 711 | performItemAction(viewportPos); |
712 | } | 712 | } |
713 | } | 713 | } |
714 | } else { // ---------- viewport() | 714 | } else { // ---------- viewport() |
715 | if ( mActionType == SELECT ) { | 715 | if ( mActionType == SELECT ) { |
716 | performSelectAction( viewportPos ); | 716 | performSelectAction( viewportPos ); |
717 | } | 717 | } |
718 | } | 718 | } |
719 | break; | 719 | break; |
720 | 720 | ||
721 | case QEvent::MouseButtonDblClick: | 721 | case QEvent::MouseButtonDblClick: |
722 | blockMoving = false; | 722 | blockMoving = false; |
723 | leftMouseDown = false; | 723 | leftMouseDown = false; |
724 | if (object == viewport()) { | 724 | if (object == viewport()) { |
725 | selectItem(0); | 725 | selectItem(0); |
726 | int x,y; | 726 | int x,y; |
727 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 727 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
728 | int gx,gy; | 728 | int gx,gy; |
729 | contentsToGrid(x,y,gx,gy); | 729 | contentsToGrid(x,y,gx,gy); |
730 | emit newEventSignal(gx,gy); | 730 | emit newEventSignal(gx,gy); |
731 | } else { | 731 | } else { |
732 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 732 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
733 | selectItem(doubleClickedItem); | 733 | selectItem(doubleClickedItem); |
734 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 734 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
735 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 735 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
736 | else | 736 | else |
737 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 737 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
738 | } | 738 | } |
739 | break; | 739 | break; |
740 | 740 | ||
741 | default: | 741 | default: |
742 | break; | 742 | break; |
743 | } | 743 | } |
744 | return true; | 744 | return true; |
745 | #endif | 745 | #endif |
746 | } | 746 | } |
747 | 747 | ||
748 | void KOAgenda::newItem( int item ) | 748 | void KOAgenda::newItem( int item ) |
749 | { | 749 | { |
750 | if ( item == 1 ) { //new event | 750 | if ( item == 1 ) { //new event |
751 | newEventSignal(mStartCellX ,mStartCellY ); | 751 | newEventSignal(mStartCellX ,mStartCellY ); |
752 | } else | 752 | } else |
753 | if ( item == 2 ) { //new event | 753 | if ( item == 2 ) { //new event |
754 | newTodoSignal(mStartCellX ,mStartCellY ); | 754 | newTodoSignal(mStartCellX ,mStartCellY ); |
755 | } else | 755 | } else |
756 | { | 756 | { |
757 | QDate day = mSelectedDates[mStartCellX]; | 757 | emit showDateView( item, mStartCellX ); |
758 | emit showDateView( item, day ); | ||
759 | // 3Day view | 758 | // 3Day view |
760 | // 4Week view | 759 | // 4Week view |
761 | // 5Month view | 760 | // 5Month view |
762 | // 6Journal view | 761 | // 6Journal view |
763 | } | 762 | } |
764 | } | 763 | } |
765 | void KOAgenda::startSelectAction(QPoint viewportPos) | 764 | void KOAgenda::startSelectAction(QPoint viewportPos) |
766 | { | 765 | { |
767 | //emit newStartSelectSignal(); | 766 | //emit newStartSelectSignal(); |
768 | 767 | ||
769 | mActionType = SELECT; | 768 | mActionType = SELECT; |
770 | 769 | ||
771 | int x,y; | 770 | int x,y; |
772 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 771 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
773 | int gx,gy; | 772 | int gx,gy; |
774 | contentsToGrid(x,y,gx,gy); | 773 | contentsToGrid(x,y,gx,gy); |
775 | 774 | ||
776 | mStartCellX = gx; | 775 | mStartCellX = gx; |
777 | mStartCellY = gy; | 776 | mStartCellY = gy; |
778 | mCurrentCellX = gx; | 777 | mCurrentCellX = gx; |
779 | mCurrentCellY = gy; | 778 | mCurrentCellY = gy; |
780 | 779 | ||
781 | // Store coordinates of old selection | 780 | // Store coordinates of old selection |
782 | int selectionX = mSelectionCellX * mGridSpacingX; | 781 | int selectionX = mSelectionCellX * mGridSpacingX; |
783 | int selectionYTop = mSelectionYTop; | 782 | int selectionYTop = mSelectionYTop; |
784 | int selectionHeight = mSelectionHeight; | 783 | int selectionHeight = mSelectionHeight; |
785 | 784 | ||
786 | // Store new selection | 785 | // Store new selection |
787 | mSelectionCellX = gx; | 786 | mSelectionCellX = gx; |
788 | mSelectionYTop = gy * mGridSpacingY; | 787 | mSelectionYTop = gy * mGridSpacingY; |
789 | mSelectionHeight = mGridSpacingY; | 788 | mSelectionHeight = mGridSpacingY; |
790 | 789 | ||
791 | // Clear old selection | 790 | // Clear old selection |
792 | repaintContents( selectionX, selectionYTop, | 791 | repaintContents( selectionX, selectionYTop, |
793 | mGridSpacingX, selectionHeight,false ); | 792 | mGridSpacingX, selectionHeight,false ); |
794 | 793 | ||
795 | // Paint new selection | 794 | // Paint new selection |
796 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, | 795 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, |
797 | // mGridSpacingX, mSelectionHeight ); | 796 | // mGridSpacingX, mSelectionHeight ); |
798 | } | 797 | } |
799 | 798 | ||
800 | void KOAgenda::performSelectAction(QPoint viewportPos) | 799 | void KOAgenda::performSelectAction(QPoint viewportPos) |
801 | { | 800 | { |
802 | int x,y; | 801 | int x,y; |
803 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 802 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
804 | int gx,gy; | 803 | int gx,gy; |
805 | contentsToGrid(x,y,gx,gy); | 804 | contentsToGrid(x,y,gx,gy); |
806 | 805 | ||
807 | QPoint clipperPos = clipper()-> | 806 | QPoint clipperPos = clipper()-> |
808 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 807 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
809 | 808 | ||
810 | // Scroll if cursor was moved to upper or lower end of agenda. | 809 | // Scroll if cursor was moved to upper or lower end of agenda. |
811 | if (clipperPos.y() < mScrollBorderWidth) { | 810 | if (clipperPos.y() < mScrollBorderWidth) { |
812 | mScrollUpTimer.start(mScrollDelay); | 811 | mScrollUpTimer.start(mScrollDelay); |
813 | } else if (visibleHeight() - clipperPos.y() < | 812 | } else if (visibleHeight() - clipperPos.y() < |
814 | mScrollBorderWidth) { | 813 | mScrollBorderWidth) { |
815 | mScrollDownTimer.start(mScrollDelay); | 814 | mScrollDownTimer.start(mScrollDelay); |
816 | } else { | 815 | } else { |
817 | mScrollUpTimer.stop(); | 816 | mScrollUpTimer.stop(); |
818 | mScrollDownTimer.stop(); | 817 | mScrollDownTimer.stop(); |
819 | } | 818 | } |
820 | 819 | ||
821 | if ( gy > mCurrentCellY ) { | 820 | if ( gy > mCurrentCellY ) { |
822 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 821 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
823 | 822 | ||
824 | #if 0 | 823 | #if 0 |
825 | // FIXME: Repaint only the newly selected region | 824 | // FIXME: Repaint only the newly selected region |
826 | repaintContents( mSelectionCellX * mGridSpacingX, | 825 | repaintContents( mSelectionCellX * mGridSpacingX, |
827 | mCurrentCellY + mGridSpacingY, | 826 | mCurrentCellY + mGridSpacingY, |
828 | mGridSpacingX, | 827 | mGridSpacingX, |
829 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); | 828 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); |
830 | #else | 829 | #else |
831 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 830 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
832 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 831 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
833 | mGridSpacingX, mSelectionYTop, | 832 | mGridSpacingX, mSelectionYTop, |
834 | mGridSpacingX, mSelectionHeight , false); | 833 | mGridSpacingX, mSelectionHeight , false); |
835 | #endif | 834 | #endif |
836 | 835 | ||
837 | mCurrentCellY = gy; | 836 | mCurrentCellY = gy; |
838 | } else if ( gy < mCurrentCellY ) { | 837 | } else if ( gy < mCurrentCellY ) { |
839 | if ( gy >= mStartCellY ) { | 838 | if ( gy >= mStartCellY ) { |
840 | int selectionHeight = mSelectionHeight; | 839 | int selectionHeight = mSelectionHeight; |
841 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 840 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
842 | 841 | ||
843 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 842 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
844 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 843 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
845 | mGridSpacingX, mSelectionYTop, | 844 | mGridSpacingX, mSelectionYTop, |
846 | mGridSpacingX, selectionHeight,false ); | 845 | mGridSpacingX, selectionHeight,false ); |
847 | 846 | ||
848 | mCurrentCellY = gy; | 847 | mCurrentCellY = gy; |
849 | } else { | 848 | } else { |
850 | } | 849 | } |
851 | } | 850 | } |
852 | } | 851 | } |
853 | 852 | ||
854 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 853 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
855 | { | 854 | { |
856 | mActionType = NOP; | 855 | mActionType = NOP; |
857 | mScrollUpTimer.stop(); | 856 | mScrollUpTimer.stop(); |
858 | mScrollDownTimer.stop(); | 857 | mScrollDownTimer.stop(); |
859 | 858 | ||
860 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 859 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
861 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 860 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
862 | qDebug("ew event signal "); | 861 | qDebug("ew event signal "); |
863 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 862 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
864 | } | 863 | } |
865 | } | 864 | } |
866 | 865 | ||
867 | void KOAgenda::startItemAction(QPoint viewportPos) | 866 | void KOAgenda::startItemAction(QPoint viewportPos) |
868 | { | 867 | { |
869 | int x,y; | 868 | int x,y; |
870 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 869 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
871 | int gx,gy; | 870 | int gx,gy; |
872 | contentsToGrid(x,y,gx,gy); | 871 | contentsToGrid(x,y,gx,gy); |
873 | 872 | ||
874 | mStartCellX = gx; | 873 | mStartCellX = gx; |
875 | mStartCellY = gy; | 874 | mStartCellY = gy; |
876 | mCurrentCellX = gx; | 875 | mCurrentCellX = gx; |
877 | mCurrentCellY = gy; | 876 | mCurrentCellY = gy; |
878 | 877 | ||
879 | if (mAllDayMode) { | 878 | if (mAllDayMode) { |
880 | int gridDistanceX = (x - gx * mGridSpacingX); | 879 | int gridDistanceX = (x - gx * mGridSpacingX); |
881 | if (gridDistanceX < mResizeBorderWidth && | 880 | if (gridDistanceX < mResizeBorderWidth && |
882 | mActionItem->cellX() == mCurrentCellX) { | 881 | mActionItem->cellX() == mCurrentCellX) { |
883 | mActionType = RESIZELEFT; | 882 | mActionType = RESIZELEFT; |
884 | setCursor(sizeHorCursor); | 883 | setCursor(sizeHorCursor); |
885 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 884 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
886 | mActionItem->cellXWidth() == mCurrentCellX) { | 885 | mActionItem->cellXWidth() == mCurrentCellX) { |
887 | mActionType = RESIZERIGHT; | 886 | mActionType = RESIZERIGHT; |
888 | setCursor(sizeHorCursor); | 887 | setCursor(sizeHorCursor); |
889 | } else { | 888 | } else { |
890 | mActionType = MOVE; | 889 | mActionType = MOVE; |
891 | mActionItem->startMove(); | 890 | mActionItem->startMove(); |
892 | setCursor(sizeAllCursor); | 891 | setCursor(sizeAllCursor); |
893 | } | 892 | } |
894 | } else { | 893 | } else { |
895 | int gridDistanceY = (y - gy * mGridSpacingY); | 894 | int gridDistanceY = (y - gy * mGridSpacingY); |
896 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 895 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); |
897 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 896 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
898 | mActionItem->cellYTop() == mCurrentCellY && | 897 | mActionItem->cellYTop() == mCurrentCellY && |
899 | !mActionItem->firstMultiItem()) { | 898 | !mActionItem->firstMultiItem()) { |
900 | mActionType = RESIZETOP; | 899 | mActionType = RESIZETOP; |
901 | setCursor(sizeVerCursor); | 900 | setCursor(sizeVerCursor); |
902 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 901 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
903 | mActionItem->cellYBottom() == mCurrentCellY && | 902 | mActionItem->cellYBottom() == mCurrentCellY && |
904 | !mActionItem->lastMultiItem()) { | 903 | !mActionItem->lastMultiItem()) { |
905 | mActionType = RESIZEBOTTOM; | 904 | mActionType = RESIZEBOTTOM; |
906 | setCursor(sizeVerCursor); | 905 | setCursor(sizeVerCursor); |
907 | } else { | 906 | } else { |
908 | mActionType = MOVE; | 907 | mActionType = MOVE; |
909 | mActionItem->startMove(); | 908 | mActionItem->startMove(); |
910 | setCursor(sizeAllCursor); | 909 | setCursor(sizeAllCursor); |
911 | } | 910 | } |
912 | } | 911 | } |
913 | } | 912 | } |
914 | 913 | ||
915 | void KOAgenda::performItemAction(QPoint viewportPos) | 914 | void KOAgenda::performItemAction(QPoint viewportPos) |
916 | { | 915 | { |
917 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 916 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
918 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 917 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
919 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 918 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
920 | // point = clipper()->mapFromGlobal(point); | 919 | // point = clipper()->mapFromGlobal(point); |
921 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 920 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
922 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 921 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
923 | int x,y; | 922 | int x,y; |
924 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 923 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
925 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 924 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
926 | int gx,gy; | 925 | int gx,gy; |
927 | contentsToGrid(x,y,gx,gy); | 926 | contentsToGrid(x,y,gx,gy); |
928 | QPoint clipperPos = clipper()-> | 927 | QPoint clipperPos = clipper()-> |
929 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 928 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
930 | 929 | ||
931 | // Cursor left active agenda area. | 930 | // Cursor left active agenda area. |
932 | // This starts a drag. | 931 | // This starts a drag. |
933 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 932 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
934 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 933 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
935 | if ( mActionType == MOVE ) { | 934 | if ( mActionType == MOVE ) { |
936 | mScrollUpTimer.stop(); | 935 | mScrollUpTimer.stop(); |
937 | mScrollDownTimer.stop(); | 936 | mScrollDownTimer.stop(); |
938 | mActionItem->resetMove(); | 937 | mActionItem->resetMove(); |
939 | placeSubCells( mActionItem ); | 938 | placeSubCells( mActionItem ); |
940 | // emit startDragSignal( mActionItem->incidence() ); | 939 | // emit startDragSignal( mActionItem->incidence() ); |
941 | setCursor( arrowCursor ); | 940 | setCursor( arrowCursor ); |
942 | mActionItem = 0; | 941 | mActionItem = 0; |
943 | mActionType = NOP; | 942 | mActionType = NOP; |
944 | mItemMoved = 0; | 943 | mItemMoved = 0; |
945 | return; | 944 | return; |
946 | } | 945 | } |
947 | } else { | 946 | } else { |
948 | switch ( mActionType ) { | 947 | switch ( mActionType ) { |
949 | case MOVE: | 948 | case MOVE: |
950 | setCursor( sizeAllCursor ); | 949 | setCursor( sizeAllCursor ); |