author | zautrix <zautrix> | 2005-07-05 08:37:52 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-05 08:37:52 (UTC) |
commit | 7e49703511de87f624cc8813b18ebbfcc01752cd (patch) (unidiff) | |
tree | 896918396dbf518f6358a066f93a04bd4185f535 /korganizer/koagenda.cpp | |
parent | 28ca4c37fb0e131b2978584992840b3fdca21d3e (diff) | |
download | kdepimpi-7e49703511de87f624cc8813b18ebbfcc01752cd.zip kdepimpi-7e49703511de87f624cc8813b18ebbfcc01752cd.tar.gz kdepimpi-7e49703511de87f624cc8813b18ebbfcc01752cd.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/koagenda.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index c339b57..662576f 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,159 +1,159 @@ | |||
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; |
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 | bool KOAgenda::mInvalidPixmap = false; | 63 | |
64 | //////////////////////////////////////////////////////////////////////////// | 64 | //////////////////////////////////////////////////////////////////////////// |
65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
67 | { | 67 | { |
68 | setLineWidth(0); | 68 | setLineWidth(0); |
69 | setMargin(0); | 69 | setMargin(0); |
70 | setBackgroundColor(Qt::red); | 70 | setBackgroundColor(Qt::red); |
71 | minutes = new QTimer(this); | 71 | minutes = new QTimer(this); |
72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
73 | minutes->start(0, true); | 73 | minutes->start(0, true); |
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 | ||
86 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
87 | { | 87 | { |
88 | delete minutes; | 88 | delete minutes; |
89 | } | 89 | } |
90 | 90 | ||
91 | int MarcusBains::todayColumn() | 91 | int 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 | } |
107 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
108 | { | 108 | { |
109 | updateLocation(); | 109 | updateLocation(); |
110 | } | 110 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 111 | void 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 | ||
@@ -237,300 +237,310 @@ void KOAgenda::init() | |||
237 | pathString += "iconsmini/"; | 237 | pathString += "iconsmini/"; |
238 | 238 | ||
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
241 | mNewItemPopup->insertSeparator ( ); | 241 | mNewItemPopup->insertSeparator ( ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
248 | #ifndef _WIN32_ | 248 | #ifndef _WIN32_ |
249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
250 | viewport()->setWFlags ( wflags); | 250 | viewport()->setWFlags ( wflags); |
251 | #endif | 251 | #endif |
252 | mGridSpacingX = 80; | 252 | mGridSpacingX = 80; |
253 | mResizeBorderWidth = 8; | 253 | mResizeBorderWidth = 8; |
254 | mScrollBorderWidth = 8; | 254 | mScrollBorderWidth = 8; |
255 | mScrollDelay = 30; | 255 | mScrollDelay = 30; |
256 | mScrollOffset = 10; | 256 | mScrollOffset = 10; |
257 | mPaintPixmap.resize( 20,20); | 257 | mPaintPixmap.resize( 20,20); |
258 | //enableClipper(true); | 258 | //enableClipper(true); |
259 | 259 | ||
260 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 260 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
261 | // effect. Has to be fixed. | 261 | // effect. Has to be fixed. |
262 | setFocusPolicy(WheelFocus); | 262 | setFocusPolicy(WheelFocus); |
263 | 263 | ||
264 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 264 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
265 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 265 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
266 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 266 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
267 | 267 | ||
268 | mStartCellX = 0; | 268 | mStartCellX = 0; |
269 | mStartCellY = 0; | 269 | mStartCellY = 0; |
270 | mCurrentCellX = 0; | 270 | mCurrentCellX = 0; |
271 | mCurrentCellY = 0; | 271 | mCurrentCellY = 0; |
272 | 272 | ||
273 | mSelectionCellX = 0; | 273 | mSelectionCellX = 0; |
274 | mSelectionYTop = 0; | 274 | mSelectionYTop = 0; |
275 | mSelectionHeight = 0; | 275 | mSelectionHeight = 0; |
276 | 276 | ||
277 | mOldLowerScrollValue = -1; | 277 | mOldLowerScrollValue = -1; |
278 | mOldUpperScrollValue = -1; | 278 | mOldUpperScrollValue = -1; |
279 | 279 | ||
280 | mClickedItem = 0; | 280 | mClickedItem = 0; |
281 | 281 | ||
282 | mActionItem = 0; | 282 | mActionItem = 0; |
283 | mActionType = NOP; | 283 | mActionType = NOP; |
284 | mItemMoved = false; | 284 | mItemMoved = false; |
285 | 285 | ||
286 | mSelectedItem = 0; | 286 | mSelectedItem = 0; |
287 | 287 | ||
288 | // mItems.setAutoDelete(true); | 288 | // mItems.setAutoDelete(true); |
289 | 289 | ||
290 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 290 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
291 | 291 | ||
292 | viewport()->update(); | 292 | viewport()->update(); |
293 | 293 | ||
294 | setMinimumSize(30, 1); | 294 | setMinimumSize(30, 1); |
295 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 295 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
296 | 296 | ||
297 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 297 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
298 | // controlled in a way that the contents horizontally always fits. Then it is | 298 | // controlled in a way that the contents horizontally always fits. Then it is |
299 | // not necessary to turn off the scrollbar. | 299 | // not necessary to turn off the scrollbar. |
300 | setHScrollBarMode(AlwaysOff); | 300 | setHScrollBarMode(AlwaysOff); |
301 | if ( ! mAllDayMode ) | 301 | if ( ! mAllDayMode ) |
302 | setVScrollBarMode(AlwaysOn); | 302 | setVScrollBarMode(AlwaysOn); |
303 | else | 303 | else |
304 | setVScrollBarMode(AlwaysOff); | 304 | setVScrollBarMode(AlwaysOff); |
305 | 305 | ||
306 | setStartHour(KOPrefs::instance()->mDayBegins); | 306 | setStartHour(KOPrefs::instance()->mDayBegins); |
307 | 307 | ||
308 | calculateWorkingHours(); | 308 | calculateWorkingHours(); |
309 | 309 | ||
310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
311 | SLOT(checkScrollBoundaries(int))); | 311 | SLOT(checkScrollBoundaries(int))); |
312 | 312 | ||
313 | // Create the Marcus Bains line. | 313 | // Create the Marcus Bains line. |
314 | if(mAllDayMode) | 314 | if(mAllDayMode) |
315 | mMarcusBains = 0; | 315 | mMarcusBains = 0; |
316 | else { | 316 | else { |
317 | mMarcusBains = new MarcusBains(this); | 317 | mMarcusBains = new MarcusBains(this); |
318 | addChild(mMarcusBains); | 318 | addChild(mMarcusBains); |
319 | } | 319 | } |
320 | mPopupKind = 0; | 320 | mPopupKind = 0; |
321 | mPopupItem = 0; | 321 | mPopupItem = 0; |
322 | mInvalidPixmap = false; | 322 | mInvalidPixmap = false; |
323 | 323 | ||
324 | } | 324 | } |
325 | 325 | ||
326 | void KOAgenda::shrinkPixmap() | 326 | void KOAgenda::shrinkPixmap() |
327 | { | 327 | { |
328 | mPaintPixmap.resize( 20,20); | 328 | mPaintPixmap.resize( 20,20); |
329 | mInvalidPixmap = true; | 329 | mInvalidPixmap = true; |
330 | } | 330 | } |
331 | void KOAgenda::slotContentMove(int,int) | 331 | void KOAgenda::slotContentMove(int,int) |
332 | { | 332 | { |
333 | emit sendPing(); | ||
333 | if ( mActionType == NOP ) | 334 | if ( mActionType == NOP ) |
334 | slotClearSelection(); | 335 | slotClearSelection(); |
335 | if ( mSelectedItem && !mActionItem ) { | 336 | if ( mSelectedItem && !mActionItem ) { |
336 | deselectItem(); | 337 | deselectItem(); |
337 | emit incidenceSelected( 0 ); | 338 | emit incidenceSelected( 0 ); |
338 | } | 339 | } |
339 | } | 340 | } |
340 | void KOAgenda::clear() | 341 | void KOAgenda::clear() |
341 | { | 342 | { |
342 | KOAgendaItem *item; | 343 | KOAgendaItem *item; |
343 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 344 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
344 | mUnusedItems.append( item ); | 345 | mUnusedItems.append( item ); |
345 | //item->hide(); | 346 | //item->hide(); |
346 | } | 347 | } |
347 | mItems.clear(); | 348 | mItems.clear(); |
348 | mSelectedItem = 0; | 349 | mSelectedItem = 0; |
349 | clearSelection(); | 350 | clearSelection(); |
350 | } | 351 | } |
351 | 352 | ||
352 | void KOAgenda::clearSelection() | 353 | void KOAgenda::clearSelection() |
353 | { | 354 | { |
354 | mSelectionCellX = 0; | 355 | mSelectionCellX = 0; |
355 | mSelectionYTop = 0; | 356 | mSelectionYTop = 0; |
356 | mSelectionHeight = 0; | 357 | mSelectionHeight = 0; |
357 | } | 358 | } |
358 | 359 | ||
359 | void KOAgenda::marcus_bains() | 360 | void KOAgenda::marcus_bains() |
360 | { | 361 | { |
361 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 362 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
362 | } | 363 | } |
363 | 364 | ||
364 | 365 | ||
365 | void KOAgenda::changeColumns(int columns) | 366 | void KOAgenda::changeColumns(int columns) |
366 | { | 367 | { |
367 | if (columns == 0) { | 368 | if (columns == 0) { |
368 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 369 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
369 | return; | 370 | return; |
370 | } | 371 | } |
371 | clear(); | 372 | clear(); |
372 | mColumns = columns; | 373 | mColumns = columns; |
373 | computeSizes(); | 374 | computeSizes(); |
374 | } | 375 | } |
375 | 376 | ||
376 | /* | 377 | /* |
377 | This is the eventFilter function, which gets all events from the KOAgendaItems | 378 | This is the eventFilter function, which gets all events from the KOAgendaItems |
378 | contained in the agenda. It has to handle moving and resizing for all items. | 379 | contained in the agenda. It has to handle moving and resizing for all items. |
379 | */ | 380 | */ |
380 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 381 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
381 | { | 382 | { |
382 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 383 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
383 | switch(event->type()) { | 384 | switch(event->type()) { |
384 | case QEvent::MouseButtonPress: | 385 | case QEvent::MouseButtonPress: |
385 | case QEvent::MouseButtonDblClick: | 386 | case QEvent::MouseButtonDblClick: |
386 | case QEvent::MouseButtonRelease: | 387 | case QEvent::MouseButtonRelease: |
387 | case QEvent::MouseMove: | 388 | case QEvent::MouseMove: |
388 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 389 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
389 | 390 | ||
390 | case (QEvent::Leave): | 391 | case (QEvent::Leave): |
391 | if (!mActionItem) | 392 | if (!mActionItem) |
392 | setCursor(arrowCursor); | 393 | setCursor(arrowCursor); |
393 | return true; | 394 | return true; |
394 | 395 | ||
395 | default: | 396 | default: |
396 | return QScrollView::eventFilter(object,event); | 397 | return QScrollView::eventFilter(object,event); |
397 | } | 398 | } |
398 | } | 399 | } |
399 | void KOAgenda::popupMenu() | 400 | void KOAgenda::popupMenu() |
400 | { | 401 | { |
401 | mPopupTimer->stop(); | 402 | mPopupTimer->stop(); |
402 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
403 | if (mActionItem ) { | 404 | if (mActionItem ) { |
404 | endItemAction(); | 405 | endItemAction(); |
405 | } | 406 | } |
406 | mLeftMouseDown = false; // no more leftMouse computation | 407 | mLeftMouseDown = false; // no more leftMouse computation |
407 | if (mPopupItem) { | 408 | if (mPopupItem) { |
408 | //mClickedItem = mPopupItem; | 409 | //mClickedItem = mPopupItem; |
409 | selectItem(mPopupItem); | 410 | selectItem(mPopupItem); |
410 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
411 | mAllAgendaPopup->installEventFilter( this ); | 412 | mAllAgendaPopup->installEventFilter( this ); |
412 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 413 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
413 | 414 | ||
414 | } | 415 | } |
415 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
416 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
417 | endSelectAction( false ); // do not emit new event signal | 418 | endSelectAction( false ); // do not emit new event signal |
418 | mLeftMouseDown = false; // no more leftMouse computation | 419 | mLeftMouseDown = false; // no more leftMouse computation |
419 | } | 420 | } |
420 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
421 | mNewItemPopup->installEventFilter( this ); | 422 | mNewItemPopup->installEventFilter( this ); |
422 | mNewItemPopup->popup( mPopupPos); | 423 | mNewItemPopup->popup( mPopupPos); |
423 | 424 | ||
424 | } | 425 | } |
425 | mLeftMouseDown = false; | 426 | mLeftMouseDown = false; |
426 | mPopupItem = 0; | 427 | mPopupItem = 0; |
427 | mPopupKind = 0; | 428 | mPopupKind = 0; |
428 | } | 429 | } |
429 | void KOAgenda::categoryChanged(Incidence * inc) | 430 | void KOAgenda::categoryChanged(Incidence * inc) |
430 | { | 431 | { |
431 | KOAgendaItem *item; | 432 | KOAgendaItem *item; |
432 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
433 | if ( item->incidence() == inc ) { | 434 | if ( item->incidence() == inc ) { |
434 | item->initColor (); | 435 | item->initColor (); |
435 | item->updateItem(); | 436 | item->updateItem(); |
436 | } | 437 | } |
437 | } | 438 | } |
438 | } | 439 | } |
439 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
440 | { | 441 | { |
442 | |||
443 | if ( mInvalidPixmap ) { | ||
444 | mInvalidPixmap = false; | ||
445 | qDebug("InvalidPixmap "); | ||
446 | computeSizes(); | ||
447 | emit updateViewSignal(); | ||
448 | return true; | ||
449 | } | ||
450 | emit sendPing(); | ||
441 | static int startX = 0; | 451 | static int startX = 0; |
442 | static int startY = 0; | 452 | static int startY = 0; |
443 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
444 | static bool blockMoving = true; | 454 | static bool blockMoving = true; |
445 | 455 | ||
446 | //qDebug("KOAgenda::eventFilter_mous "); | 456 | //qDebug("KOAgenda::eventFilter_mous "); |
447 | if ( object == mNewItemPopup ) { | 457 | if ( object == mNewItemPopup ) { |
448 | //qDebug("mNewItemPopup "); | 458 | //qDebug("mNewItemPopup "); |
449 | if ( me->type() == QEvent::MouseButtonRelease ) { | 459 | if ( me->type() == QEvent::MouseButtonRelease ) { |
450 | mNewItemPopup->removeEventFilter( this ); | 460 | mNewItemPopup->removeEventFilter( this ); |
451 | int dX = me->globalPos().x() - mPopupPos.x();; | 461 | int dX = me->globalPos().x() - mPopupPos.x();; |
452 | if ( dX < 0 ) | 462 | if ( dX < 0 ) |
453 | dX = -dX; | 463 | dX = -dX; |
454 | int dY = me->globalPos().y() - mPopupPos.y(); | 464 | int dY = me->globalPos().y() - mPopupPos.y(); |
455 | if ( dY < 0 ) | 465 | if ( dY < 0 ) |
456 | dY = -dY; | 466 | dY = -dY; |
457 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
458 | mNewItemPopup->hide(); | 468 | mNewItemPopup->hide(); |
459 | } | 469 | } |
460 | } | 470 | } |
461 | return true; | 471 | return true; |
462 | } | 472 | } |
463 | if ( object == mAllAgendaPopup ) { | 473 | if ( object == mAllAgendaPopup ) { |
464 | //qDebug(" mAllAgendaPopup "); | 474 | //qDebug(" mAllAgendaPopup "); |
465 | if ( me->type() == QEvent::MouseButtonRelease ) { | 475 | if ( me->type() == QEvent::MouseButtonRelease ) { |
466 | mAllAgendaPopup->removeEventFilter( this ); | 476 | mAllAgendaPopup->removeEventFilter( this ); |
467 | int dX = me->globalPos().x() - mPopupPos.x();; | 477 | int dX = me->globalPos().x() - mPopupPos.x();; |
468 | if ( dX < 0 ) | 478 | if ( dX < 0 ) |
469 | dX = -dX; | 479 | dX = -dX; |
470 | int dY = me->globalPos().y() - mPopupPos.y(); | 480 | int dY = me->globalPos().y() - mPopupPos.y(); |
471 | if ( dY < 0 ) | 481 | if ( dY < 0 ) |
472 | dY = -dY; | 482 | dY = -dY; |
473 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
474 | mAllAgendaPopup->hide(); | 484 | mAllAgendaPopup->hide(); |
475 | } | 485 | } |
476 | } | 486 | } |
477 | return true; | 487 | return true; |
478 | } | 488 | } |
479 | QPoint viewportPos; | 489 | QPoint viewportPos; |
480 | if (object != viewport()) { | 490 | if (object != viewport()) { |
481 | blockmoveDist = blockmoveDist*2; | 491 | blockmoveDist = blockmoveDist*2; |
482 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
483 | } else { | 493 | } else { |
484 | viewportPos = me->pos(); | 494 | viewportPos = me->pos(); |
485 | } | 495 | } |
486 | bool objIsNotViewport = (object != viewport()); | 496 | bool objIsNotViewport = (object != viewport()); |
487 | bool leftButt = false; | 497 | bool leftButt = false; |
488 | #ifdef DESKTOP_VERSION | 498 | #ifdef DESKTOP_VERSION |
489 | leftButt = (me->button() == LeftButton); | 499 | leftButt = (me->button() == LeftButton); |
490 | #endif | 500 | #endif |
491 | switch (me->type()) { | 501 | switch (me->type()) { |
492 | case QEvent::MouseButtonPress: | 502 | case QEvent::MouseButtonPress: |
493 | if (me->button() == LeftButton) { | 503 | if (me->button() == LeftButton) { |
494 | mPopupTimer->start( 600 ); | 504 | mPopupTimer->start( 600 ); |
495 | mLeftMouseDown = true; | 505 | mLeftMouseDown = true; |
496 | } | 506 | } |
497 | blockMoving = true; | 507 | blockMoving = true; |
498 | startX = viewportPos.x(); | 508 | startX = viewportPos.x(); |
499 | startY = viewportPos.y(); | 509 | startY = viewportPos.y(); |
500 | mPopupPos = me->globalPos(); | 510 | mPopupPos = me->globalPos(); |
501 | if ( objIsNotViewport && !leftButt ) { | 511 | if ( objIsNotViewport && !leftButt ) { |
502 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 512 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
503 | if (mAllDayMode) { | 513 | if (mAllDayMode) { |
504 | if ( tempItem->height() > 10 ) { | 514 | if ( tempItem->height() > 10 ) { |
505 | int minV = tempItem->height()/4; | 515 | int minV = tempItem->height()/4; |
506 | if ( minV > (blockmoveDist/2)-2 ) { | 516 | if ( minV > (blockmoveDist/2)-2 ) { |
507 | if ( minV > blockmoveDist ) | 517 | if ( minV > blockmoveDist ) |
508 | minV = blockmoveDist; | 518 | minV = blockmoveDist; |
509 | else | 519 | else |
510 | minV = (blockmoveDist/2); | 520 | minV = (blockmoveDist/2); |
511 | } | 521 | } |
512 | bool border = false; | 522 | bool border = false; |
513 | int diff = tempItem->y() - viewportPos.y(); | 523 | int diff = tempItem->y() - viewportPos.y(); |
514 | if ( diff < 0 ) | 524 | if ( diff < 0 ) |
515 | diff *= -1; | 525 | diff *= -1; |
516 | if ( diff < minV ) { | 526 | if ( diff < minV ) { |
517 | border = true; | 527 | border = true; |
518 | objIsNotViewport = false; | 528 | objIsNotViewport = false; |
519 | } | 529 | } |
520 | if ( ! border ) { | 530 | if ( ! border ) { |
521 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 531 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
522 | if ( diff < 0 ) | 532 | if ( diff < 0 ) |
523 | diff *= -1; | 533 | diff *= -1; |
524 | if ( diff < minV ) { | 534 | if ( diff < minV ) { |
525 | border = true; | 535 | border = true; |
526 | objIsNotViewport = false; | 536 | objIsNotViewport = false; |
527 | } | 537 | } |
528 | } | 538 | } |
529 | } | 539 | } |
530 | } else { // not allday | 540 | } else { // not allday |
531 | if ( tempItem->width() > 10 ) { | 541 | if ( tempItem->width() > 10 ) { |
532 | int minH = tempItem->width()/4; | 542 | int minH = tempItem->width()/4; |
533 | if ( minH > (blockmoveDist/2)-2 ) { | 543 | if ( minH > (blockmoveDist/2)-2 ) { |
534 | if ( minH > blockmoveDist ) | 544 | if ( minH > blockmoveDist ) |
535 | minH = blockmoveDist; | 545 | minH = blockmoveDist; |
536 | else | 546 | else |
@@ -1174,249 +1184,256 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | |||
1174 | 1184 | ||
1175 | if (conflictItems.count() > 0) { | 1185 | if (conflictItems.count() > 0) { |
1176 | // Look for unused sub cell and insert item | 1186 | // Look for unused sub cell and insert item |
1177 | int i; | 1187 | int i; |
1178 | for(i=0;i<maxSubCells;++i) { | 1188 | for(i=0;i<maxSubCells;++i) { |
1179 | if (!subCellDict.find(i)) { | 1189 | if (!subCellDict.find(i)) { |
1180 | placeItem->setSubCell(i); | 1190 | placeItem->setSubCell(i); |
1181 | break; | 1191 | break; |
1182 | } | 1192 | } |
1183 | } | 1193 | } |
1184 | if (i == maxSubCells) { | 1194 | if (i == maxSubCells) { |
1185 | placeItem->setSubCell(maxSubCells); | 1195 | placeItem->setSubCell(maxSubCells); |
1186 | maxSubCells++; // add new item to number of sub cells | 1196 | maxSubCells++; // add new item to number of sub cells |
1187 | } | 1197 | } |
1188 | 1198 | ||
1189 | // Prepare for sub cell geometry adjustment | 1199 | // Prepare for sub cell geometry adjustment |
1190 | int newSubCellWidth; | 1200 | int newSubCellWidth; |
1191 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1201 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1192 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1202 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1193 | conflictItems.append(placeItem); | 1203 | conflictItems.append(placeItem); |
1194 | 1204 | ||
1195 | 1205 | ||
1196 | // Adjust sub cell geometry of all direct conflict items | 1206 | // Adjust sub cell geometry of all direct conflict items |
1197 | for ( item=conflictItems.first(); item != 0; | 1207 | for ( item=conflictItems.first(); item != 0; |
1198 | item=conflictItems.next() ) { | 1208 | item=conflictItems.next() ) { |
1199 | item->setSubCells(maxSubCells); | 1209 | item->setSubCells(maxSubCells); |
1200 | if (mAllDayMode) { | 1210 | if (mAllDayMode) { |
1201 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1211 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1202 | } else { | 1212 | } else { |
1203 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1213 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1204 | } | 1214 | } |
1205 | int x,y; | 1215 | int x,y; |
1206 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1216 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1207 | if (mAllDayMode) { | 1217 | if (mAllDayMode) { |
1208 | y += item->subCell() * newSubCellWidth; | 1218 | y += item->subCell() * newSubCellWidth; |
1209 | } else { | 1219 | } else { |
1210 | x += item->subCell() * newSubCellWidth; | 1220 | x += item->subCell() * newSubCellWidth; |
1211 | } | 1221 | } |
1212 | moveChild(item,x,y); | 1222 | moveChild(item,x,y); |
1213 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1223 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1214 | //item->updateItem(); | 1224 | //item->updateItem(); |
1215 | } | 1225 | } |
1216 | // Adjust sub cell geometry of all conflict items of all conflict items | 1226 | // Adjust sub cell geometry of all conflict items of all conflict items |
1217 | for ( item=conflictItems.first(); item != 0; | 1227 | for ( item=conflictItems.first(); item != 0; |
1218 | item=conflictItems.next() ) { | 1228 | item=conflictItems.next() ) { |
1219 | if ( placeItem != item ) { | 1229 | if ( placeItem != item ) { |
1220 | KOAgendaItem *item2; | 1230 | KOAgendaItem *item2; |
1221 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1231 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1222 | for ( item2=conflictItems2.first(); item2 != 0; | 1232 | for ( item2=conflictItems2.first(); item2 != 0; |
1223 | item2=conflictItems2.next() ) { | 1233 | item2=conflictItems2.next() ) { |
1224 | if ( item2->subCells() != maxSubCells) { | 1234 | if ( item2->subCells() != maxSubCells) { |
1225 | item2->setSubCells(maxSubCells); | 1235 | item2->setSubCells(maxSubCells); |
1226 | if (mAllDayMode) { | 1236 | if (mAllDayMode) { |
1227 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1237 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1228 | } else { | 1238 | } else { |
1229 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1239 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1230 | } | 1240 | } |
1231 | int x,y; | 1241 | int x,y; |
1232 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1242 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1233 | if (mAllDayMode) { | 1243 | if (mAllDayMode) { |
1234 | y += item2->subCell() * newSubCellWidth; | 1244 | y += item2->subCell() * newSubCellWidth; |
1235 | } else { | 1245 | } else { |
1236 | x += item2->subCell() * newSubCellWidth; | 1246 | x += item2->subCell() * newSubCellWidth; |
1237 | } | 1247 | } |
1238 | moveChild(item2,x,y); | 1248 | moveChild(item2,x,y); |
1239 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1249 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1240 | } | 1250 | } |
1241 | } | 1251 | } |
1242 | } | 1252 | } |
1243 | } | 1253 | } |
1244 | } else { | 1254 | } else { |
1245 | placeItem->setSubCell(0); | 1255 | placeItem->setSubCell(0); |
1246 | placeItem->setSubCells(1); | 1256 | placeItem->setSubCells(1); |
1247 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1257 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1248 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1258 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1249 | int x,y; | 1259 | int x,y; |
1250 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1260 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1251 | moveChild(placeItem,x,y); | 1261 | moveChild(placeItem,x,y); |
1252 | } | 1262 | } |
1253 | placeItem->setConflictItems(conflictItems); | 1263 | placeItem->setConflictItems(conflictItems); |
1254 | // for ( item=conflictItems.first(); item != 0; | 1264 | // for ( item=conflictItems.first(); item != 0; |
1255 | // item=conflictItems.next() ) { | 1265 | // item=conflictItems.next() ) { |
1256 | // //item->updateItem(); | 1266 | // //item->updateItem(); |
1257 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1267 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1258 | // } | 1268 | // } |
1259 | // placeItem->updateItem(); | 1269 | // placeItem->updateItem(); |
1260 | } | 1270 | } |
1261 | 1271 | ||
1262 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1272 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1263 | { | 1273 | { |
1264 | if ( globalFlagBlockAgenda ) | 1274 | if ( globalFlagBlockAgenda ) |
1265 | return; | 1275 | return; |
1266 | 1276 | ||
1267 | if ( mInvalidPixmap ) { | 1277 | if ( mInvalidPixmap ) { |
1268 | mInvalidPixmap = false; | 1278 | mInvalidPixmap = false; |
1269 | qDebug("InvalidPixmap "); | 1279 | qDebug("InvalidPixmap "); |
1270 | QTimer::singleShot( 0, this, SIGNAL( updateViewSignal() )); | 1280 | computeSizes(); |
1281 | emit updateViewSignal(); | ||
1271 | return; | 1282 | return; |
1272 | } | 1283 | } |
1273 | if ( ! mAllDayMode ) { | 1284 | if ( ! mAllDayMode ) { |
1274 | // currently not working for | 1285 | // currently not working for |
1275 | 1286 | ||
1276 | //qDebug("KOAgenda::drawContents "); | 1287 | //qDebug("KOAgenda::drawContents "); |
1277 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1288 | #if 0 |
1278 | ;//drawContentsToPainter(); | 1289 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1279 | 1290 | qDebug("WAU "); | |
1291 | drawContentsToPainter(); | ||
1292 | } | ||
1293 | #endif | ||
1280 | QPaintDevice* pd = p->device(); | 1294 | QPaintDevice* pd = p->device(); |
1281 | p->end(); | 1295 | p->end(); |
1282 | int vx, vy; | 1296 | int vx, vy; |
1283 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1297 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1284 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1298 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1285 | mSelectionCellX * mGridSpacingX; | 1299 | mSelectionCellX * mGridSpacingX; |
1286 | contentsToViewport ( cx, cy, vx,vy); | 1300 | contentsToViewport ( cx, cy, vx,vy); |
1287 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1301 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1288 | 1302 | ||
1289 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1303 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1290 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1304 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1291 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1305 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1292 | 1306 | ||
1293 | int vxSel, vySel; | 1307 | int vxSel, vySel; |
1294 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1308 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1295 | int off = mSelectionHeight; | 1309 | int off = mSelectionHeight; |
1296 | if ( vySel < 0 ) | 1310 | if ( vySel < 0 ) |
1297 | off += vySel; | 1311 | off += vySel; |
1298 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1312 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1299 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1313 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1300 | } else { | 1314 | } else { |
1301 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1315 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1302 | } | 1316 | } |
1303 | } | 1317 | } |
1304 | if ( mSelectionHeight > 0 ) { | 1318 | if ( mSelectionHeight > 0 ) { |
1305 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1319 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1306 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1320 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1307 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1321 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1308 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1322 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1309 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1323 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1310 | int hei = mSelectionHeight; | 1324 | int hei = mSelectionHeight; |
1311 | int offset = 0; | 1325 | int offset = 0; |
1312 | while ( hei > 0 ) { | 1326 | while ( hei > 0 ) { |
1313 | int p_hei = 5; | 1327 | int p_hei = 5; |
1314 | if ( hei < 5 ) p_hei = hei; | 1328 | if ( hei < 5 ) p_hei = hei; |
1315 | hei -= 5; | 1329 | hei -= 5; |
1316 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1330 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1317 | offset += 5; | 1331 | offset += 5; |
1318 | } | 1332 | } |
1319 | } | 1333 | } |
1320 | } | 1334 | } |
1321 | p->begin( pd ); | 1335 | p->begin( pd ); |
1322 | } else { | 1336 | } else { |
1323 | 1337 | #if 0 | |
1324 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1338 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); |
1325 | ;//drawContentsToPainter(); | 1339 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1326 | 1340 | qDebug("WAUWAU "); | |
1341 | drawContentsToPainter(); | ||
1342 | } | ||
1343 | #endif | ||
1327 | QPaintDevice* pd = p->device(); | 1344 | QPaintDevice* pd = p->device(); |
1328 | p->end(); | 1345 | p->end(); |
1329 | int vx, vy; | 1346 | int vx, vy; |
1330 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1347 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1331 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1348 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1332 | mSelectionCellX * mGridSpacingX; | 1349 | mSelectionCellX * mGridSpacingX; |
1333 | contentsToViewport ( cx, cy, vx,vy); | 1350 | contentsToViewport ( cx, cy, vx,vy); |
1334 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1351 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1335 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1352 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1336 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1353 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1337 | 1354 | ||
1338 | if ( mSelectionHeight > 0 ) { | 1355 | if ( mSelectionHeight > 0 ) { |
1339 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1356 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1340 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1357 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1341 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1358 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1342 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1359 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1343 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1360 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1344 | int hei = mSelectionHeight; | 1361 | int hei = mSelectionHeight; |
1345 | int offset = 0; | 1362 | int offset = 0; |
1346 | while ( hei > 0 ) { | 1363 | while ( hei > 0 ) { |
1347 | int p_hei = 5; | 1364 | int p_hei = 5; |
1348 | if ( hei < 5 ) p_hei = hei; | 1365 | if ( hei < 5 ) p_hei = hei; |
1349 | hei -= 5; | 1366 | hei -= 5; |
1350 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1367 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1351 | offset += 5; | 1368 | offset += 5; |
1352 | } | 1369 | } |
1353 | } | 1370 | } |
1354 | } | 1371 | } |
1355 | p->begin( pd ); | 1372 | p->begin( pd ); |
1356 | } | 1373 | } |
1357 | 1374 | ||
1358 | } | 1375 | } |
1359 | 1376 | ||
1360 | void KOAgenda::finishUpdate() | 1377 | void KOAgenda::finishUpdate() |
1361 | { | 1378 | { |
1362 | 1379 | ||
1363 | KOAgendaItem *item; | 1380 | KOAgendaItem *item; |
1364 | globalFlagBlockAgendaItemPaint = 1; | 1381 | globalFlagBlockAgendaItemPaint = 1; |
1365 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1382 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1366 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1383 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1367 | if ( !item->checkLayout() ) { | 1384 | if ( !item->checkLayout() ) { |
1368 | //qDebug(" conflictitem found "); | 1385 | //qDebug(" conflictitem found "); |
1369 | int newSubCellWidth; | 1386 | int newSubCellWidth; |
1370 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1387 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1371 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1388 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1372 | 1389 | ||
1373 | if (mAllDayMode) { | 1390 | if (mAllDayMode) { |
1374 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1391 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1375 | } else { | 1392 | } else { |
1376 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1393 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1377 | } | 1394 | } |
1378 | int x,y; | 1395 | int x,y; |
1379 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1396 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1380 | if (mAllDayMode) { | 1397 | if (mAllDayMode) { |
1381 | y += item->subCell() * newSubCellWidth; | 1398 | y += item->subCell() * newSubCellWidth; |
1382 | } else { | 1399 | } else { |
1383 | x += item->subCell() * newSubCellWidth; | 1400 | x += item->subCell() * newSubCellWidth; |
1384 | } | 1401 | } |
1385 | moveChild(item,x,y); | 1402 | moveChild(item,x,y); |
1386 | } | 1403 | } |
1387 | } | 1404 | } |
1388 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1405 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1389 | if ( !item->isVisible() ) | 1406 | if ( !item->isVisible() ) |
1390 | item->show(); | 1407 | item->show(); |
1391 | 1408 | ||
1392 | } | 1409 | } |
1393 | globalFlagBlockAgendaItemUpdate = 0; | 1410 | globalFlagBlockAgendaItemUpdate = 0; |
1394 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1411 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1395 | item->repaintMe( ); | 1412 | item->repaintMe( ); |
1396 | } | 1413 | } |
1397 | globalFlagBlockAgendaItemUpdate = 1; | 1414 | globalFlagBlockAgendaItemUpdate = 1; |
1398 | qApp->processEvents(); | 1415 | qApp->processEvents(); |
1399 | globalFlagBlockAgendaItemPaint = 0; | 1416 | globalFlagBlockAgendaItemPaint = 0; |
1400 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1417 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1401 | item->repaint( false ); | 1418 | item->repaint( false ); |
1402 | } | 1419 | } |
1403 | 1420 | ||
1404 | } | 1421 | } |
1405 | 1422 | ||
1406 | /* | 1423 | /* |
1407 | Draw grid in the background of the agenda. | 1424 | Draw grid in the background of the agenda. |
1408 | */ | 1425 | */ |
1409 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1426 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1410 | { | 1427 | { |
1411 | 1428 | ||
1412 | 1429 | ||
1413 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1430 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1414 | return; | 1431 | return; |
1415 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1432 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1416 | return; | 1433 | return; |
1417 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1434 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1418 | if ( ch < 1 ) | 1435 | if ( ch < 1 ) |
1419 | ch = 1; | 1436 | ch = 1; |
1420 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1437 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1421 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1438 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1422 | } | 1439 | } |