-rw-r--r-- | korganizer/koagenda.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index dcb46a8..5420822 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,1477 +1,1477 @@ | |||
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 | //////////////////////////////////////////////////////////////////////////// | 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 | 73 | ||
74 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
78 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
79 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
80 | 80 | ||
81 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
82 | 82 | ||
83 | oldToday = -1; | 83 | oldToday = -1; |
84 | } | 84 | } |
85 | 85 | ||
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 | ||
160 | 160 | ||
161 | //////////////////////////////////////////////////////////////////////////// | 161 | //////////////////////////////////////////////////////////////////////////// |
162 | 162 | ||
163 | 163 | ||
164 | /* | 164 | /* |
165 | Create an agenda widget with rows rows and columns columns. | 165 | Create an agenda widget with rows rows and columns columns. |
166 | */ | 166 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
168 | const char *name,WFlags f) : | 168 | const char *name,WFlags f) : |
169 | QScrollView(parent,name,f) | 169 | QScrollView(parent,name,f) |
170 | { | 170 | { |
171 | 171 | ||
172 | 172 | ||
173 | mColumns = columns; | 173 | mColumns = columns; |
174 | mRows = rows; | 174 | mRows = rows; |
175 | mGridSpacingY = rowSize; | 175 | mGridSpacingY = rowSize; |
176 | mAllDayMode = false; | 176 | mAllDayMode = false; |
177 | #ifndef DESKTOP_VERSION | 177 | #ifndef DESKTOP_VERSION |
178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
179 | #endif | 179 | #endif |
180 | mHolidayMask = 0; | 180 | mHolidayMask = 0; |
181 | init(); | 181 | init(); |
182 | } | 182 | } |
183 | 183 | ||
184 | /* | 184 | /* |
185 | Create an agenda widget with columns columns and one row. This is used for | 185 | Create an agenda widget with columns columns and one row. This is used for |
186 | all-day events. | 186 | all-day events. |
187 | */ | 187 | */ |
188 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 188 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
189 | QScrollView(parent,name,f) | 189 | QScrollView(parent,name,f) |
190 | { | 190 | { |
191 | blockResize = false; | 191 | blockResize = false; |
192 | mColumns = columns; | 192 | mColumns = columns; |
193 | mRows = 1; | 193 | mRows = 1; |
194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
196 | mAllDayMode = true; | 196 | mAllDayMode = true; |
197 | #ifndef DESKTOP_VERSION | 197 | #ifndef DESKTOP_VERSION |
198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
199 | #endif | 199 | #endif |
200 | mHolidayMask = 0; | 200 | mHolidayMask = 0; |
201 | init(); | 201 | init(); |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | KOAgenda::~KOAgenda() | 205 | KOAgenda::~KOAgenda() |
206 | { | 206 | { |
207 | if(mMarcusBains) delete mMarcusBains; | 207 | if(mMarcusBains) delete mMarcusBains; |
208 | 208 | ||
209 | } | 209 | } |
210 | 210 | ||
211 | Incidence *KOAgenda::selectedIncidence() const | 211 | Incidence *KOAgenda::selectedIncidence() const |
212 | { | 212 | { |
213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | QDate KOAgenda::selectedIncidenceDate() const | 217 | QDate KOAgenda::selectedIncidenceDate() const |
218 | { | 218 | { |
219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | void KOAgenda::init() | 223 | void KOAgenda::init() |
224 | { | 224 | { |
225 | mNewItemPopup = new QPopupMenu( this ); | 225 | mNewItemPopup = new QPopupMenu( this ); |
226 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 226 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
227 | QString pathString = ""; | 227 | QString pathString = ""; |
228 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 228 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
229 | if ( QApplication::desktop()->width() < 480 ) | 229 | if ( QApplication::desktop()->width() < 480 ) |
230 | pathString += "icons16/"; | 230 | pathString += "icons16/"; |
231 | } else | 231 | } else |
232 | pathString += "iconsmini/"; | 232 | pathString += "iconsmini/"; |
233 | 233 | ||
234 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 234 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
235 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 235 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
236 | mNewItemPopup->insertSeparator ( ); | 236 | mNewItemPopup->insertSeparator ( ); |
237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); | 241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
243 | #ifndef _WIN32_ | 243 | #ifndef _WIN32_ |
244 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 244 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
245 | viewport()->setWFlags ( wflags); | 245 | viewport()->setWFlags ( wflags); |
246 | #endif | 246 | #endif |
247 | mGridSpacingX = 80; | 247 | mGridSpacingX = 80; |
248 | mResizeBorderWidth = 8; | 248 | mResizeBorderWidth = 8; |
249 | mScrollBorderWidth = 8; | 249 | mScrollBorderWidth = 8; |
250 | mScrollDelay = 30; | 250 | mScrollDelay = 30; |
251 | mScrollOffset = 10; | 251 | mScrollOffset = 10; |
252 | mPaintPixmap.resize( 20,20); | 252 | mPaintPixmap.resize( 20,20); |
253 | //enableClipper(true); | 253 | //enableClipper(true); |
254 | 254 | ||
255 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 255 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
256 | // effect. Has to be fixed. | 256 | // effect. Has to be fixed. |
257 | setFocusPolicy(WheelFocus); | 257 | setFocusPolicy(WheelFocus); |
258 | 258 | ||
259 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 259 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
260 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 260 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
261 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 261 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
262 | 262 | ||
263 | mStartCellX = 0; | 263 | mStartCellX = 0; |
264 | mStartCellY = 0; | 264 | mStartCellY = 0; |
265 | mCurrentCellX = 0; | 265 | mCurrentCellX = 0; |
266 | mCurrentCellY = 0; | 266 | mCurrentCellY = 0; |
267 | 267 | ||
268 | mSelectionCellX = 0; | 268 | mSelectionCellX = 0; |
269 | mSelectionYTop = 0; | 269 | mSelectionYTop = 0; |
270 | mSelectionHeight = 0; | 270 | mSelectionHeight = 0; |
271 | 271 | ||
272 | mOldLowerScrollValue = -1; | 272 | mOldLowerScrollValue = -1; |
273 | mOldUpperScrollValue = -1; | 273 | mOldUpperScrollValue = -1; |
274 | 274 | ||
275 | mClickedItem = 0; | 275 | mClickedItem = 0; |
276 | 276 | ||
277 | mActionItem = 0; | 277 | mActionItem = 0; |
278 | mActionType = NOP; | 278 | mActionType = NOP; |
279 | mItemMoved = false; | 279 | mItemMoved = false; |
280 | 280 | ||
281 | mSelectedItem = 0; | 281 | mSelectedItem = 0; |
282 | 282 | ||
283 | // mItems.setAutoDelete(true); | 283 | // mItems.setAutoDelete(true); |
284 | 284 | ||
285 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 285 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
286 | 286 | ||
287 | viewport()->update(); | 287 | viewport()->update(); |
288 | 288 | ||
289 | setMinimumSize(30, 1); | 289 | setMinimumSize(30, 1); |
290 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 290 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
291 | 291 | ||
292 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 292 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
293 | // controlled in a way that the contents horizontally always fits. Then it is | 293 | // controlled in a way that the contents horizontally always fits. Then it is |
294 | // not necessary to turn off the scrollbar. | 294 | // not necessary to turn off the scrollbar. |
295 | setHScrollBarMode(AlwaysOff); | 295 | setHScrollBarMode(AlwaysOff); |
296 | if ( ! mAllDayMode ) | 296 | if ( ! mAllDayMode ) |
297 | setVScrollBarMode(AlwaysOn); | 297 | setVScrollBarMode(AlwaysOn); |
298 | else | 298 | else |
299 | setVScrollBarMode(AlwaysOff); | 299 | setVScrollBarMode(AlwaysOff); |
300 | 300 | ||
301 | setStartHour(KOPrefs::instance()->mDayBegins); | 301 | setStartHour(KOPrefs::instance()->mDayBegins); |
302 | 302 | ||
303 | calculateWorkingHours(); | 303 | calculateWorkingHours(); |
304 | 304 | ||
305 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 305 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
306 | SLOT(checkScrollBoundaries(int))); | 306 | SLOT(checkScrollBoundaries(int))); |
307 | 307 | ||
308 | // Create the Marcus Bains line. | 308 | // Create the Marcus Bains line. |
309 | if(mAllDayMode) | 309 | if(mAllDayMode) |
310 | mMarcusBains = 0; | 310 | mMarcusBains = 0; |
311 | else { | 311 | else { |
312 | mMarcusBains = new MarcusBains(this); | 312 | mMarcusBains = new MarcusBains(this); |
313 | addChild(mMarcusBains); | 313 | addChild(mMarcusBains); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | void KOAgenda::clear() | 317 | void KOAgenda::clear() |
318 | { | 318 | { |
319 | KOAgendaItem *item; | 319 | KOAgendaItem *item; |
320 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 320 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
321 | mUnusedItems.append( item ); | 321 | mUnusedItems.append( item ); |
322 | //item->hide(); | 322 | //item->hide(); |
323 | } | 323 | } |
324 | mItems.clear(); | 324 | mItems.clear(); |
325 | mSelectedItem = 0; | 325 | mSelectedItem = 0; |
326 | clearSelection(); | 326 | clearSelection(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void KOAgenda::clearSelection() | 329 | void KOAgenda::clearSelection() |
330 | { | 330 | { |
331 | mSelectionCellX = 0; | 331 | mSelectionCellX = 0; |
332 | mSelectionYTop = 0; | 332 | mSelectionYTop = 0; |
333 | mSelectionHeight = 0; | 333 | mSelectionHeight = 0; |
334 | } | 334 | } |
335 | 335 | ||
336 | void KOAgenda::marcus_bains() | 336 | void KOAgenda::marcus_bains() |
337 | { | 337 | { |
338 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 338 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void KOAgenda::changeColumns(int columns) | 342 | void KOAgenda::changeColumns(int columns) |
343 | { | 343 | { |
344 | if (columns == 0) { | 344 | if (columns == 0) { |
345 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; | 345 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; |
346 | return; | 346 | return; |
347 | } | 347 | } |
348 | 348 | ||
349 | clear(); | 349 | clear(); |
350 | 350 | ||
351 | mColumns = columns; | 351 | mColumns = columns; |
352 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); | 352 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); |
353 | // init(); | 353 | // init(); |
354 | // update(); | 354 | // update(); |
355 | //qDebug("KOAgenda::changeColumns "); | 355 | //qDebug("KOAgenda::changeColumns "); |
356 | computeSizes(); | 356 | computeSizes(); |
357 | // QResizeEvent event( size(), size() ); | 357 | // QResizeEvent event( size(), size() ); |
358 | 358 | ||
359 | //QApplication::sendEvent( this, &event ); | 359 | //QApplication::sendEvent( this, &event ); |
360 | } | 360 | } |
361 | 361 | ||
362 | /* | 362 | /* |
363 | This is the eventFilter function, which gets all events from the KOAgendaItems | 363 | This is the eventFilter function, which gets all events from the KOAgendaItems |
364 | contained in the agenda. It has to handle moving and resizing for all items. | 364 | contained in the agenda. It has to handle moving and resizing for all items. |
365 | */ | 365 | */ |
366 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 366 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
367 | { | 367 | { |
368 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 368 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
369 | switch(event->type()) { | 369 | switch(event->type()) { |
370 | case QEvent::MouseButtonPress: | 370 | case QEvent::MouseButtonPress: |
371 | case QEvent::MouseButtonDblClick: | 371 | case QEvent::MouseButtonDblClick: |
372 | case QEvent::MouseButtonRelease: | 372 | case QEvent::MouseButtonRelease: |
373 | case QEvent::MouseMove: | 373 | case QEvent::MouseMove: |
374 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 374 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
375 | 375 | ||
376 | case (QEvent::Leave): | 376 | case (QEvent::Leave): |
377 | if (!mActionItem) | 377 | if (!mActionItem) |
378 | setCursor(arrowCursor); | 378 | setCursor(arrowCursor); |
379 | return true; | 379 | return true; |
380 | 380 | ||
381 | default: | 381 | default: |
382 | return QScrollView::eventFilter(object,event); | 382 | return QScrollView::eventFilter(object,event); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
388 | { | 388 | { |
389 | //qDebug("KOAgenda::eventFilter_mous "); | 389 | //qDebug("KOAgenda::eventFilter_mous "); |
390 | QPoint viewportPos; | 390 | QPoint viewportPos; |
391 | if (object != viewport()) { | 391 | if (object != viewport()) { |
392 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 392 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
393 | } else { | 393 | } else { |
394 | viewportPos = me->pos(); | 394 | viewportPos = me->pos(); |
395 | } | 395 | } |
396 | static int startX = 0; | 396 | static int startX = 0; |
397 | static int startY = 0; | 397 | static int startY = 0; |
398 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | 398 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); |
399 | static bool blockMoving = true; | 399 | static bool blockMoving = true; |
400 | static bool leftMouseDown = false; | 400 | static bool leftMouseDown = false; |
401 | static bool rightMouseDown = false; | 401 | static bool rightMouseDown = false; |
402 | static QTime rightClickTime; | 402 | static QTime rightClickTime; |
403 | bool rightButtonPressed = false; | 403 | bool rightButtonPressed = false; |
404 | switch (me->type()) { | 404 | switch (me->type()) { |
405 | case QEvent::MouseButtonPress: | 405 | case QEvent::MouseButtonPress: |
406 | rightClickTime.restart(); | 406 | rightClickTime.restart(); |
407 | if (me->button() == LeftButton) { | 407 | if (me->button() == LeftButton) { |
408 | leftMouseDown = true; | 408 | leftMouseDown = true; |
409 | } | 409 | } |
410 | else if (me->button() == RightButton) | 410 | else if (me->button() == RightButton) |
411 | rightMouseDown = true; | 411 | rightMouseDown = true; |
412 | blockMoving = true; | 412 | blockMoving = true; |
413 | startX = viewportPos.x(); | 413 | startX = viewportPos.x(); |
414 | startY = viewportPos.y(); | 414 | startY = viewportPos.y(); |
415 | if (object != viewport()) { | 415 | if (object != viewport()) { |
416 | if (me->button() == RightButton) { | 416 | if (me->button() == RightButton) { |
417 | mClickedItem = (KOAgendaItem *)object; | 417 | mClickedItem = (KOAgendaItem *)object; |
418 | if (mClickedItem) { | 418 | if (mClickedItem) { |
419 | selectItem(mClickedItem); | 419 | selectItem(mClickedItem); |
420 | } | 420 | } |
421 | } else if (me->button() == LeftButton) { | 421 | } else if (me->button() == LeftButton) { |
422 | mActionItem = (KOAgendaItem *)object; | 422 | mActionItem = (KOAgendaItem *)object; |
423 | if (mActionItem) { | 423 | if (mActionItem) { |
424 | if ( mSelectionHeight > 0 ) { | 424 | if ( mSelectionHeight > 0 ) { |
425 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 425 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
426 | int selectionYTop = mSelectionYTop; | 426 | int selectionYTop = mSelectionYTop; |
427 | int gridSpacingX = mGridSpacingX; | 427 | int gridSpacingX = mGridSpacingX; |
428 | int selectionHeight = mSelectionHeight; | 428 | int selectionHeight = mSelectionHeight; |
429 | clearSelection(); | 429 | clearSelection(); |
430 | repaintContents( selectionCellX, selectionYTop, | 430 | repaintContents( selectionCellX, selectionYTop, |
431 | gridSpacingX, selectionHeight,false ); | 431 | gridSpacingX, selectionHeight,false ); |
432 | } | 432 | } |
433 | selectItem(mActionItem); | 433 | selectItem(mActionItem); |
434 | Incidence *incidence = mActionItem->incidence(); | 434 | Incidence *incidence = mActionItem->incidence(); |
435 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 435 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
436 | mActionItem = 0; | 436 | mActionItem = 0; |
437 | } else { | 437 | } else { |
438 | startItemAction(viewportPos); | 438 | startItemAction(viewportPos); |
439 | } | 439 | } |
440 | } | 440 | } |
441 | } | 441 | } |
442 | } else { // ---------- viewport() | 442 | } else { // ---------- viewport() |
443 | selectItem(0); | 443 | selectItem(0); |
444 | mActionItem = 0; | 444 | mActionItem = 0; |
445 | if (me->button() == LeftButton ) { | 445 | if (me->button() == LeftButton ) { |
446 | setCursor(arrowCursor); | 446 | setCursor(arrowCursor); |
447 | startSelectAction(viewportPos); | 447 | startSelectAction(viewportPos); |
448 | } | 448 | } |
449 | } | 449 | } |
450 | break; | 450 | break; |
451 | 451 | ||
452 | case QEvent::MouseButtonRelease: | 452 | case QEvent::MouseButtonRelease: |
453 | if ( rightClickTime.elapsed() > 700 && blockMoving ) | 453 | if ( rightClickTime.elapsed() > 500 && blockMoving ) |
454 | rightButtonPressed = true; | 454 | rightButtonPressed = true; |
455 | if (object != viewport()) { | 455 | if (object != viewport()) { |
456 | if (me->button() == RightButton || rightButtonPressed ) { | 456 | if (me->button() == RightButton || rightButtonPressed ) { |
457 | if ( blockMoving ) { | 457 | if ( blockMoving ) { |
458 | mClickedItem = (KOAgendaItem *)object; | 458 | mClickedItem = (KOAgendaItem *)object; |
459 | if (mActionItem ) { | 459 | if (mActionItem ) { |
460 | endItemAction(); | 460 | endItemAction(); |
461 | } | 461 | } |
462 | leftMouseDown = false; // no more leftMouse computation | 462 | leftMouseDown = false; // no more leftMouse computation |
463 | if (mClickedItem) { | 463 | if (mClickedItem) { |
464 | selectItem(mClickedItem); | 464 | selectItem(mClickedItem); |
465 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 465 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
466 | } | 466 | } |
467 | } | 467 | } |
468 | } else if (me->button() == LeftButton && leftMouseDown) { | 468 | } else if (me->button() == LeftButton && leftMouseDown) { |
469 | if (mActionItem) { | 469 | if (mActionItem) { |
470 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 470 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
471 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 471 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
472 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 472 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
473 | mScrollUpTimer.stop(); | 473 | mScrollUpTimer.stop(); |
474 | mScrollDownTimer.stop(); | 474 | mScrollDownTimer.stop(); |
475 | mActionItem->resetMove(); | 475 | mActionItem->resetMove(); |
476 | placeSubCells( mActionItem ); | 476 | placeSubCells( mActionItem ); |
477 | // emit startDragSignal( mActionItem->incidence() ); | 477 | // emit startDragSignal( mActionItem->incidence() ); |
478 | setCursor( arrowCursor ); | 478 | setCursor( arrowCursor ); |
479 | mActionItem = 0; | 479 | mActionItem = 0; |
480 | mActionType = NOP; | 480 | mActionType = NOP; |
481 | mItemMoved = 0; | 481 | mItemMoved = 0; |
482 | leftMouseDown = false; | 482 | leftMouseDown = false; |
483 | return true; | 483 | return true; |
484 | } | 484 | } |
485 | endItemAction(); | 485 | endItemAction(); |
486 | } | 486 | } |
487 | } | 487 | } |
488 | 488 | ||
489 | } else { // ---------- viewport() | 489 | } else { // ---------- viewport() |
490 | if (me->button() == RightButton || rightButtonPressed ) { //right click | 490 | if (me->button() == RightButton || rightButtonPressed ) { //right click |
491 | if ( blockMoving ) { // we did mot moved the mouse much - popup menu | 491 | if ( blockMoving ) { // we did mot moved the mouse much - popup menu |
492 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action | 492 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action |
493 | endSelectAction( false ); // do not emit new event signal | 493 | endSelectAction( false ); // do not emit new event signal |
494 | leftMouseDown = false; // no more leftMouse computation | 494 | leftMouseDown = false; // no more leftMouse computation |
495 | } | 495 | } |
496 | int x,y; | 496 | int x,y; |
497 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 497 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
498 | int gx,gy; | 498 | int gx,gy; |
499 | contentsToGrid(x,y,gx,gy); | 499 | contentsToGrid(x,y,gx,gy); |
500 | mCurrentCellX = gx; | 500 | mCurrentCellX = gx; |
501 | mCurrentCellY = gy; | 501 | mCurrentCellY = gy; |
502 | mStartCellX = gx; | 502 | mStartCellX = gx; |
503 | mStartCellY = gy; | 503 | mStartCellY = gy; |
504 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | 504 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); |
505 | } | 505 | } |
506 | } | 506 | } |
507 | else if (me->button() == LeftButton && leftMouseDown ) { //left click | 507 | else if (me->button() == LeftButton && leftMouseDown ) { //left click |
508 | endSelectAction( true ); // emit new event signal | 508 | endSelectAction( true ); // emit new event signal |
509 | } | 509 | } |
510 | } | 510 | } |
511 | if (me->button() == LeftButton) | 511 | if (me->button() == LeftButton) |
512 | leftMouseDown = false; | 512 | leftMouseDown = false; |
513 | else if (me->button() == RightButton) | 513 | else if (me->button() == RightButton) |
514 | rightMouseDown = false; | 514 | rightMouseDown = false; |
515 | break; | 515 | break; |
516 | 516 | ||
517 | case QEvent::MouseMove: | 517 | case QEvent::MouseMove: |
518 | if ( !rightMouseDown && !leftMouseDown ) | 518 | if ( !rightMouseDown && !leftMouseDown ) |
519 | return true; | 519 | return true; |
520 | if ( blockMoving ) { | 520 | if ( blockMoving ) { |
521 | int dX, dY; | 521 | int dX, dY; |
522 | dX = startX - viewportPos.x(); | 522 | dX = startX - viewportPos.x(); |
523 | if ( dX < 0 ) | 523 | if ( dX < 0 ) |
524 | dX = -dX; | 524 | dX = -dX; |
525 | dY = viewportPos.y() - startY; | 525 | dY = viewportPos.y() - startY; |
526 | if ( dY < 0 ) | 526 | if ( dY < 0 ) |
527 | dY = -dY; | 527 | dY = -dY; |
528 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 528 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
529 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 529 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
530 | blockMoving = false; | 530 | blockMoving = false; |
531 | } | 531 | } |
532 | } | 532 | } |
533 | if (object != viewport()) { | 533 | if (object != viewport()) { |
534 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 534 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
535 | if (!moveItem->incidence()->isReadOnly() ) { | 535 | if (!moveItem->incidence()->isReadOnly() ) { |
536 | if (!mActionItem) | 536 | if (!mActionItem) |
537 | setNoActionCursor(moveItem,viewportPos); | 537 | setNoActionCursor(moveItem,viewportPos); |
538 | else { | 538 | else { |
539 | if ( !blockMoving ) | 539 | if ( !blockMoving ) |
540 | performItemAction(viewportPos); | 540 | performItemAction(viewportPos); |
541 | } | 541 | } |
542 | } | 542 | } |
543 | } else { // ---------- viewport() | 543 | } else { // ---------- viewport() |
544 | if ( mActionType == SELECT ) { | 544 | if ( mActionType == SELECT ) { |
545 | performSelectAction( viewportPos ); | 545 | performSelectAction( viewportPos ); |
546 | } | 546 | } |
547 | } | 547 | } |
548 | break; | 548 | break; |
549 | 549 | ||
550 | case QEvent::MouseButtonDblClick: | 550 | case QEvent::MouseButtonDblClick: |
551 | if (object == viewport()) { | 551 | if (object == viewport()) { |
552 | selectItem(0); | 552 | selectItem(0); |
553 | int x,y; | 553 | int x,y; |
554 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 554 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
555 | int gx,gy; | 555 | int gx,gy; |
556 | contentsToGrid(x,y,gx,gy); | 556 | contentsToGrid(x,y,gx,gy); |
557 | emit newEventSignal(gx,gy); | 557 | emit newEventSignal(gx,gy); |
558 | } else { | 558 | } else { |
559 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 559 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
560 | selectItem(doubleClickedItem); | 560 | selectItem(doubleClickedItem); |
561 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 561 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
562 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 562 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
563 | else | 563 | else |
564 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 564 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
565 | } | 565 | } |
566 | break; | 566 | break; |
567 | 567 | ||
568 | default: | 568 | default: |
569 | break; | 569 | break; |
570 | } | 570 | } |
571 | return true; | 571 | return true; |
572 | } | 572 | } |
573 | 573 | ||
574 | void KOAgenda::newItem( int item ) | 574 | void KOAgenda::newItem( int item ) |
575 | { | 575 | { |
576 | if ( item == 1 ) { //new event | 576 | if ( item == 1 ) { //new event |
577 | newEventSignal(mStartCellX ,mStartCellY ); | 577 | newEventSignal(mStartCellX ,mStartCellY ); |
578 | } else | 578 | } else |
579 | if ( item == 2 ) { //new event | 579 | if ( item == 2 ) { //new event |
580 | newTodoSignal(mStartCellX ,mStartCellY ); | 580 | newTodoSignal(mStartCellX ,mStartCellY ); |
581 | } else | 581 | } else |
582 | { | 582 | { |
583 | QDate day = mSelectedDates[mStartCellX]; | 583 | QDate day = mSelectedDates[mStartCellX]; |
584 | emit showDateView( item, day ); | 584 | emit showDateView( item, day ); |
585 | // 3Day view | 585 | // 3Day view |
586 | // 4Week view | 586 | // 4Week view |
587 | // 5Month view | 587 | // 5Month view |
588 | // 6Journal view | 588 | // 6Journal view |
589 | } | 589 | } |
590 | } | 590 | } |
591 | void KOAgenda::startSelectAction(QPoint viewportPos) | 591 | void KOAgenda::startSelectAction(QPoint viewportPos) |
592 | { | 592 | { |
593 | //emit newStartSelectSignal(); | 593 | //emit newStartSelectSignal(); |
594 | 594 | ||
595 | mActionType = SELECT; | 595 | mActionType = SELECT; |
596 | 596 | ||
597 | int x,y; | 597 | int x,y; |
598 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 598 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
599 | int gx,gy; | 599 | int gx,gy; |
600 | contentsToGrid(x,y,gx,gy); | 600 | contentsToGrid(x,y,gx,gy); |
601 | 601 | ||
602 | mStartCellX = gx; | 602 | mStartCellX = gx; |
603 | mStartCellY = gy; | 603 | mStartCellY = gy; |
604 | mCurrentCellX = gx; | 604 | mCurrentCellX = gx; |
605 | mCurrentCellY = gy; | 605 | mCurrentCellY = gy; |
606 | 606 | ||
607 | // Store coordinates of old selection | 607 | // Store coordinates of old selection |
608 | int selectionX = mSelectionCellX * mGridSpacingX; | 608 | int selectionX = mSelectionCellX * mGridSpacingX; |
609 | int selectionYTop = mSelectionYTop; | 609 | int selectionYTop = mSelectionYTop; |
610 | int selectionHeight = mSelectionHeight; | 610 | int selectionHeight = mSelectionHeight; |
611 | 611 | ||
612 | // Store new selection | 612 | // Store new selection |
613 | mSelectionCellX = gx; | 613 | mSelectionCellX = gx; |
614 | mSelectionYTop = gy * mGridSpacingY; | 614 | mSelectionYTop = gy * mGridSpacingY; |
615 | mSelectionHeight = mGridSpacingY; | 615 | mSelectionHeight = mGridSpacingY; |
616 | 616 | ||
617 | // Clear old selection | 617 | // Clear old selection |
618 | repaintContents( selectionX, selectionYTop, | 618 | repaintContents( selectionX, selectionYTop, |
619 | mGridSpacingX, selectionHeight,false ); | 619 | mGridSpacingX, selectionHeight,false ); |
620 | 620 | ||
621 | // Paint new selection | 621 | // Paint new selection |
622 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, | 622 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, |
623 | // mGridSpacingX, mSelectionHeight ); | 623 | // mGridSpacingX, mSelectionHeight ); |
624 | } | 624 | } |
625 | 625 | ||
626 | void KOAgenda::performSelectAction(QPoint viewportPos) | 626 | void KOAgenda::performSelectAction(QPoint viewportPos) |
627 | { | 627 | { |
628 | int x,y; | 628 | int x,y; |
629 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 629 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
630 | int gx,gy; | 630 | int gx,gy; |
631 | contentsToGrid(x,y,gx,gy); | 631 | contentsToGrid(x,y,gx,gy); |
632 | 632 | ||
633 | QPoint clipperPos = clipper()-> | 633 | QPoint clipperPos = clipper()-> |
634 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 634 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
635 | 635 | ||
636 | // Scroll if cursor was moved to upper or lower end of agenda. | 636 | // Scroll if cursor was moved to upper or lower end of agenda. |
637 | if (clipperPos.y() < mScrollBorderWidth) { | 637 | if (clipperPos.y() < mScrollBorderWidth) { |
638 | mScrollUpTimer.start(mScrollDelay); | 638 | mScrollUpTimer.start(mScrollDelay); |
639 | } else if (visibleHeight() - clipperPos.y() < | 639 | } else if (visibleHeight() - clipperPos.y() < |
640 | mScrollBorderWidth) { | 640 | mScrollBorderWidth) { |
641 | mScrollDownTimer.start(mScrollDelay); | 641 | mScrollDownTimer.start(mScrollDelay); |
642 | } else { | 642 | } else { |
643 | mScrollUpTimer.stop(); | 643 | mScrollUpTimer.stop(); |
644 | mScrollDownTimer.stop(); | 644 | mScrollDownTimer.stop(); |
645 | } | 645 | } |
646 | 646 | ||
647 | if ( gy > mCurrentCellY ) { | 647 | if ( gy > mCurrentCellY ) { |
648 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 648 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
649 | 649 | ||
650 | #if 0 | 650 | #if 0 |
651 | // FIXME: Repaint only the newly selected region | 651 | // FIXME: Repaint only the newly selected region |
652 | repaintContents( mSelectionCellX * mGridSpacingX, | 652 | repaintContents( mSelectionCellX * mGridSpacingX, |
653 | mCurrentCellY + mGridSpacingY, | 653 | mCurrentCellY + mGridSpacingY, |
654 | mGridSpacingX, | 654 | mGridSpacingX, |
655 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); | 655 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); |
656 | #else | 656 | #else |
657 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 657 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
658 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 658 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
659 | mGridSpacingX, mSelectionYTop, | 659 | mGridSpacingX, mSelectionYTop, |
660 | mGridSpacingX, mSelectionHeight , false); | 660 | mGridSpacingX, mSelectionHeight , false); |
661 | #endif | 661 | #endif |
662 | 662 | ||
663 | mCurrentCellY = gy; | 663 | mCurrentCellY = gy; |
664 | } else if ( gy < mCurrentCellY ) { | 664 | } else if ( gy < mCurrentCellY ) { |
665 | if ( gy >= mStartCellY ) { | 665 | if ( gy >= mStartCellY ) { |
666 | int selectionHeight = mSelectionHeight; | 666 | int selectionHeight = mSelectionHeight; |
667 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 667 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
668 | 668 | ||
669 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 669 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
670 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 670 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
671 | mGridSpacingX, mSelectionYTop, | 671 | mGridSpacingX, mSelectionYTop, |
672 | mGridSpacingX, selectionHeight,false ); | 672 | mGridSpacingX, selectionHeight,false ); |
673 | 673 | ||
674 | mCurrentCellY = gy; | 674 | mCurrentCellY = gy; |
675 | } else { | 675 | } else { |
676 | } | 676 | } |
677 | } | 677 | } |
678 | } | 678 | } |
679 | 679 | ||
680 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 680 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
681 | { | 681 | { |
682 | mActionType = NOP; | 682 | mActionType = NOP; |
683 | mScrollUpTimer.stop(); | 683 | mScrollUpTimer.stop(); |
684 | mScrollDownTimer.stop(); | 684 | mScrollDownTimer.stop(); |
685 | 685 | ||
686 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 686 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
687 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 687 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
688 | qDebug("ew event signal "); | 688 | qDebug("ew event signal "); |
689 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 689 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
690 | } | 690 | } |
691 | } | 691 | } |
692 | 692 | ||
693 | void KOAgenda::startItemAction(QPoint viewportPos) | 693 | void KOAgenda::startItemAction(QPoint viewportPos) |
694 | { | 694 | { |
695 | int x,y; | 695 | int x,y; |
696 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 696 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
697 | int gx,gy; | 697 | int gx,gy; |
698 | contentsToGrid(x,y,gx,gy); | 698 | contentsToGrid(x,y,gx,gy); |
699 | 699 | ||
700 | mStartCellX = gx; | 700 | mStartCellX = gx; |
701 | mStartCellY = gy; | 701 | mStartCellY = gy; |
702 | mCurrentCellX = gx; | 702 | mCurrentCellX = gx; |
703 | mCurrentCellY = gy; | 703 | mCurrentCellY = gy; |
704 | 704 | ||
705 | if (mAllDayMode) { | 705 | if (mAllDayMode) { |
706 | int gridDistanceX = (x - gx * mGridSpacingX); | 706 | int gridDistanceX = (x - gx * mGridSpacingX); |
707 | if (gridDistanceX < mResizeBorderWidth && | 707 | if (gridDistanceX < mResizeBorderWidth && |
708 | mActionItem->cellX() == mCurrentCellX) { | 708 | mActionItem->cellX() == mCurrentCellX) { |
709 | mActionType = RESIZELEFT; | 709 | mActionType = RESIZELEFT; |
710 | setCursor(sizeHorCursor); | 710 | setCursor(sizeHorCursor); |
711 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 711 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
712 | mActionItem->cellXWidth() == mCurrentCellX) { | 712 | mActionItem->cellXWidth() == mCurrentCellX) { |
713 | mActionType = RESIZERIGHT; | 713 | mActionType = RESIZERIGHT; |
714 | setCursor(sizeHorCursor); | 714 | setCursor(sizeHorCursor); |
715 | } else { | 715 | } else { |
716 | mActionType = MOVE; | 716 | mActionType = MOVE; |
717 | mActionItem->startMove(); | 717 | mActionItem->startMove(); |
718 | setCursor(sizeAllCursor); | 718 | setCursor(sizeAllCursor); |
719 | } | 719 | } |
720 | } else { | 720 | } else { |
721 | int gridDistanceY = (y - gy * mGridSpacingY); | 721 | int gridDistanceY = (y - gy * mGridSpacingY); |
722 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 722 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); |
723 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 723 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
724 | mActionItem->cellYTop() == mCurrentCellY && | 724 | mActionItem->cellYTop() == mCurrentCellY && |
725 | !mActionItem->firstMultiItem()) { | 725 | !mActionItem->firstMultiItem()) { |
726 | mActionType = RESIZETOP; | 726 | mActionType = RESIZETOP; |
727 | setCursor(sizeVerCursor); | 727 | setCursor(sizeVerCursor); |
728 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 728 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
729 | mActionItem->cellYBottom() == mCurrentCellY && | 729 | mActionItem->cellYBottom() == mCurrentCellY && |
730 | !mActionItem->lastMultiItem()) { | 730 | !mActionItem->lastMultiItem()) { |
731 | mActionType = RESIZEBOTTOM; | 731 | mActionType = RESIZEBOTTOM; |
732 | setCursor(sizeVerCursor); | 732 | setCursor(sizeVerCursor); |
733 | } else { | 733 | } else { |
734 | mActionType = MOVE; | 734 | mActionType = MOVE; |
735 | mActionItem->startMove(); | 735 | mActionItem->startMove(); |
736 | setCursor(sizeAllCursor); | 736 | setCursor(sizeAllCursor); |
737 | } | 737 | } |
738 | } | 738 | } |
739 | } | 739 | } |
740 | 740 | ||
741 | void KOAgenda::performItemAction(QPoint viewportPos) | 741 | void KOAgenda::performItemAction(QPoint viewportPos) |
742 | { | 742 | { |
743 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 743 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
744 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 744 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
745 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 745 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
746 | // point = clipper()->mapFromGlobal(point); | 746 | // point = clipper()->mapFromGlobal(point); |
747 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 747 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
748 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 748 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
749 | int x,y; | 749 | int x,y; |
750 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 750 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
751 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 751 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
752 | int gx,gy; | 752 | int gx,gy; |
753 | contentsToGrid(x,y,gx,gy); | 753 | contentsToGrid(x,y,gx,gy); |
754 | QPoint clipperPos = clipper()-> | 754 | QPoint clipperPos = clipper()-> |
755 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 755 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
756 | 756 | ||
757 | // Cursor left active agenda area. | 757 | // Cursor left active agenda area. |
758 | // This starts a drag. | 758 | // This starts a drag. |
759 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 759 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
760 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 760 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
761 | if ( mActionType == MOVE ) { | 761 | if ( mActionType == MOVE ) { |
762 | mScrollUpTimer.stop(); | 762 | mScrollUpTimer.stop(); |
763 | mScrollDownTimer.stop(); | 763 | mScrollDownTimer.stop(); |
764 | mActionItem->resetMove(); | 764 | mActionItem->resetMove(); |
765 | placeSubCells( mActionItem ); | 765 | placeSubCells( mActionItem ); |
766 | // emit startDragSignal( mActionItem->incidence() ); | 766 | // emit startDragSignal( mActionItem->incidence() ); |
767 | setCursor( arrowCursor ); | 767 | setCursor( arrowCursor ); |
768 | mActionItem = 0; | 768 | mActionItem = 0; |
769 | mActionType = NOP; | 769 | mActionType = NOP; |
770 | mItemMoved = 0; | 770 | mItemMoved = 0; |
771 | return; | 771 | return; |
772 | } | 772 | } |
773 | } else { | 773 | } else { |
774 | switch ( mActionType ) { | 774 | switch ( mActionType ) { |
775 | case MOVE: | 775 | case MOVE: |
776 | setCursor( sizeAllCursor ); | 776 | setCursor( sizeAllCursor ); |
777 | break; | 777 | break; |
778 | case RESIZETOP: | 778 | case RESIZETOP: |
779 | case RESIZEBOTTOM: | 779 | case RESIZEBOTTOM: |
780 | setCursor( sizeVerCursor ); | 780 | setCursor( sizeVerCursor ); |
781 | break; | 781 | break; |
782 | case RESIZELEFT: | 782 | case RESIZELEFT: |
783 | case RESIZERIGHT: | 783 | case RESIZERIGHT: |
784 | setCursor( sizeHorCursor ); | 784 | setCursor( sizeHorCursor ); |
785 | break; | 785 | break; |
786 | default: | 786 | default: |
787 | setCursor( arrowCursor ); | 787 | setCursor( arrowCursor ); |
788 | } | 788 | } |
789 | } | 789 | } |
790 | 790 | ||
791 | // Scroll if item was moved to upper or lower end of agenda. | 791 | // Scroll if item was moved to upper or lower end of agenda. |
792 | if (clipperPos.y() < mScrollBorderWidth) { | 792 | if (clipperPos.y() < mScrollBorderWidth) { |
793 | mScrollUpTimer.start(mScrollDelay); | 793 | mScrollUpTimer.start(mScrollDelay); |
794 | } else if (visibleHeight() - clipperPos.y() < | 794 | } else if (visibleHeight() - clipperPos.y() < |
795 | mScrollBorderWidth) { | 795 | mScrollBorderWidth) { |
796 | mScrollDownTimer.start(mScrollDelay); | 796 | mScrollDownTimer.start(mScrollDelay); |
797 | } else { | 797 | } else { |
798 | mScrollUpTimer.stop(); | 798 | mScrollUpTimer.stop(); |
799 | mScrollDownTimer.stop(); | 799 | mScrollDownTimer.stop(); |
800 | } | 800 | } |
801 | 801 | ||
802 | // Move or resize item if necessary | 802 | // Move or resize item if necessary |
803 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 803 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
804 | mItemMoved = true; | 804 | mItemMoved = true; |
805 | mActionItem->raise(); | 805 | mActionItem->raise(); |
806 | if (mActionType == MOVE) { | 806 | if (mActionType == MOVE) { |
807 | // Move all items belonging to a multi item | 807 | // Move all items belonging to a multi item |
808 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 808 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
809 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 809 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
810 | if (!moveItem) moveItem = mActionItem; | 810 | if (!moveItem) moveItem = mActionItem; |
811 | while (moveItem) { | 811 | while (moveItem) { |
812 | int dy; | 812 | int dy; |
813 | if (isMultiItem) dy = 0; | 813 | if (isMultiItem) dy = 0; |
814 | else dy = gy - mCurrentCellY; | 814 | else dy = gy - mCurrentCellY; |
815 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 815 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
816 | int x,y; | 816 | int x,y; |
817 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 817 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
818 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 818 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
819 | mGridSpacingY * moveItem->cellHeight()); | 819 | mGridSpacingY * moveItem->cellHeight()); |
820 | moveChild(moveItem,x,y); | 820 | moveChild(moveItem,x,y); |
821 | moveItem = moveItem->nextMultiItem(); | 821 | moveItem = moveItem->nextMultiItem(); |
822 | } | 822 | } |
823 | } else if (mActionType == RESIZETOP) { | 823 | } else if (mActionType == RESIZETOP) { |
824 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 824 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
825 | mActionItem->expandTop(gy - mCurrentCellY); | 825 | mActionItem->expandTop(gy - mCurrentCellY); |
826 | mActionItem->resize(mActionItem->width(), | 826 | mActionItem->resize(mActionItem->width(), |
827 | mGridSpacingY * mActionItem->cellHeight()); | 827 | mGridSpacingY * mActionItem->cellHeight()); |
828 | int x,y; | 828 | int x,y; |
829 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 829 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
830 | //moveChild(mActionItem,childX(mActionItem),y); | 830 | //moveChild(mActionItem,childX(mActionItem),y); |
831 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 831 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
832 | } | 832 | } |
833 | } else if (mActionType == RESIZEBOTTOM) { | 833 | } else if (mActionType == RESIZEBOTTOM) { |
834 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 834 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
835 | mActionItem->expandBottom(gy - mCurrentCellY); | 835 | mActionItem->expandBottom(gy - mCurrentCellY); |
836 | mActionItem->resize(mActionItem->width(), | 836 | mActionItem->resize(mActionItem->width(), |
837 | mGridSpacingY * mActionItem->cellHeight()); | 837 | mGridSpacingY * mActionItem->cellHeight()); |
838 | } | 838 | } |
839 | } else if (mActionType == RESIZELEFT) { | 839 | } else if (mActionType == RESIZELEFT) { |
840 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 840 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
841 | mActionItem->expandLeft(gx - mCurrentCellX); | 841 | mActionItem->expandLeft(gx - mCurrentCellX); |
842 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 842 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
843 | mActionItem->height()); | 843 | mActionItem->height()); |
844 | int x,y; | 844 | int x,y; |
845 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 845 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
846 | moveChild(mActionItem,x,childY(mActionItem)); | 846 | moveChild(mActionItem,x,childY(mActionItem)); |
847 | } | 847 | } |
848 | } else if (mActionType == RESIZERIGHT) { | 848 | } else if (mActionType == RESIZERIGHT) { |
849 | if (mCurrentCellX >= mActionItem->cellX()) { | 849 | if (mCurrentCellX >= mActionItem->cellX()) { |
850 | mActionItem->expandRight(gx - mCurrentCellX); | 850 | mActionItem->expandRight(gx - mCurrentCellX); |
851 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 851 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
852 | mActionItem->height()); | 852 | mActionItem->height()); |
853 | } | 853 | } |
854 | } | 854 | } |
855 | mCurrentCellX = gx; | 855 | mCurrentCellX = gx; |
856 | mCurrentCellY = gy; | 856 | mCurrentCellY = gy; |
857 | } | 857 | } |
858 | } | 858 | } |
859 | 859 | ||
860 | void KOAgenda::endItemAction() | 860 | void KOAgenda::endItemAction() |
861 | { | 861 | { |
862 | 862 | ||
863 | if ( mItemMoved ) { | 863 | if ( mItemMoved ) { |
864 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 864 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
865 | if ( !placeItem ) { | 865 | if ( !placeItem ) { |
866 | placeItem = mActionItem; | 866 | placeItem = mActionItem; |
867 | } | 867 | } |
868 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 868 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
869 | Incidence* oldInc = placeItem->incidence(); | 869 | Incidence* oldInc = placeItem->incidence(); |
870 | placeItem->recreateIncidence(); | 870 | placeItem->recreateIncidence(); |
871 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 871 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
872 | } | 872 | } |
873 | int type = mActionType; | 873 | int type = mActionType; |
874 | if ( mAllDayMode ) | 874 | if ( mAllDayMode ) |
875 | type = -1; | 875 | type = -1; |
876 | KOAgendaItem *modifiedItem = placeItem; | 876 | KOAgendaItem *modifiedItem = placeItem; |
877 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 877 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
878 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 878 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
879 | KOAgendaItem *item; | 879 | KOAgendaItem *item; |
880 | 880 | ||
881 | if ( placeItem->incidence()->type() == "Todo" ) { | 881 | if ( placeItem->incidence()->type() == "Todo" ) { |
882 | mSelectedItem = 0; | 882 | mSelectedItem = 0; |
883 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 883 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
884 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 884 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
885 | emit itemModified( modifiedItem, mActionType ); | 885 | emit itemModified( modifiedItem, mActionType ); |
886 | } | 886 | } |
887 | else { | 887 | else { |
888 | #if 0 | 888 | #if 0 |
889 | for ( item=oldconflictItems.first(); item != 0; | 889 | for ( item=oldconflictItems.first(); item != 0; |
890 | item=oldconflictItems.next() ) { | 890 | item=oldconflictItems.next() ) { |
891 | placeSubCells(item); | 891 | placeSubCells(item); |
892 | } | 892 | } |
893 | while ( placeItem ) { | 893 | while ( placeItem ) { |
894 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 894 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
895 | placeSubCells( placeItem ); | 895 | placeSubCells( placeItem ); |
896 | placeItem = placeItem->nextMultiItem(); | 896 | placeItem = placeItem->nextMultiItem(); |
897 | } | 897 | } |
898 | #endif | 898 | #endif |
899 | 899 | ||
900 | globalFlagBlockAgendaItemPaint = 1; | 900 | globalFlagBlockAgendaItemPaint = 1; |
901 | for ( item=oldconflictItems.first(); item != 0; | 901 | for ( item=oldconflictItems.first(); item != 0; |
902 | item=oldconflictItems.next() ) { | 902 | item=oldconflictItems.next() ) { |
903 | placeSubCells(item); | 903 | placeSubCells(item); |
904 | } | 904 | } |
905 | while ( placeItem ) { | 905 | while ( placeItem ) { |
906 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 906 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
907 | oldconflictItems = placeItem->conflictItems(); | 907 | oldconflictItems = placeItem->conflictItems(); |
908 | for ( item=oldconflictItems.first(); item != 0; | 908 | for ( item=oldconflictItems.first(); item != 0; |
909 | item=oldconflictItems.next() ) { | 909 | item=oldconflictItems.next() ) { |
910 | placeSubCells(item); | 910 | placeSubCells(item); |
911 | } | 911 | } |
912 | placeSubCells( placeItem ); | 912 | placeSubCells( placeItem ); |
913 | placeItem = placeItem->nextMultiItem(); | 913 | placeItem = placeItem->nextMultiItem(); |
914 | } | 914 | } |
915 | globalFlagBlockAgendaItemPaint = 0; | 915 | globalFlagBlockAgendaItemPaint = 0; |
916 | for ( item=oldconflictItems.first(); item != 0; | 916 | for ( item=oldconflictItems.first(); item != 0; |
917 | item=oldconflictItems.next() ) { | 917 | item=oldconflictItems.next() ) { |
918 | globalFlagBlockAgendaItemUpdate = 0; | 918 | globalFlagBlockAgendaItemUpdate = 0; |
919 | item->repaintMe(); | 919 | item->repaintMe(); |
920 | globalFlagBlockAgendaItemUpdate = 1; | 920 | globalFlagBlockAgendaItemUpdate = 1; |
921 | item->repaint( false ); | 921 | item->repaint( false ); |
922 | } | 922 | } |
923 | placeItem = modifiedItem; | 923 | placeItem = modifiedItem; |
924 | 924 | ||
925 | while ( placeItem ) { | 925 | while ( placeItem ) { |
926 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 926 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
927 | globalFlagBlockAgendaItemUpdate = 0; | 927 | globalFlagBlockAgendaItemUpdate = 0; |
928 | placeItem->repaintMe(); | 928 | placeItem->repaintMe(); |
929 | globalFlagBlockAgendaItemUpdate = 1; | 929 | globalFlagBlockAgendaItemUpdate = 1; |
930 | placeItem->repaint(false); | 930 | placeItem->repaint(false); |
931 | placeItem = placeItem->nextMultiItem(); | 931 | placeItem = placeItem->nextMultiItem(); |
932 | } | 932 | } |
933 | emit itemModified( modifiedItem, mActionType ); | 933 | emit itemModified( modifiedItem, mActionType ); |
934 | 934 | ||
935 | 935 | ||
936 | placeItem = modifiedItem; | 936 | placeItem = modifiedItem; |
937 | while ( placeItem ) { | 937 | while ( placeItem ) { |
938 | oldconflictItems = placeItem->conflictItems(); | 938 | oldconflictItems = placeItem->conflictItems(); |
939 | for ( item=oldconflictItems.first(); item != 0; | 939 | for ( item=oldconflictItems.first(); item != 0; |
940 | item=oldconflictItems.next() ) { | 940 | item=oldconflictItems.next() ) { |
941 | placeSubCells(item); | 941 | placeSubCells(item); |
942 | } | 942 | } |
943 | placeSubCells( placeItem ); | 943 | placeSubCells( placeItem ); |
944 | placeItem = placeItem->nextMultiItem(); | 944 | placeItem = placeItem->nextMultiItem(); |
945 | 945 | ||
946 | } | 946 | } |
947 | placeItem = modifiedItem; | 947 | placeItem = modifiedItem; |
948 | while ( placeItem ) { | 948 | while ( placeItem ) { |
949 | oldconflictItems = placeItem->conflictItems(); | 949 | oldconflictItems = placeItem->conflictItems(); |
950 | for ( item=oldconflictItems.first(); item != 0; | 950 | for ( item=oldconflictItems.first(); item != 0; |
951 | item=oldconflictItems.next() ) { | 951 | item=oldconflictItems.next() ) { |
952 | globalFlagBlockAgendaItemUpdate = 0; | 952 | globalFlagBlockAgendaItemUpdate = 0; |
953 | item->repaintMe(); | 953 | item->repaintMe(); |
954 | globalFlagBlockAgendaItemUpdate = 1; | 954 | globalFlagBlockAgendaItemUpdate = 1; |
955 | item->repaint(false); | 955 | item->repaint(false); |
956 | } | 956 | } |
957 | placeItem = placeItem->nextMultiItem(); | 957 | placeItem = placeItem->nextMultiItem(); |
958 | } | 958 | } |
959 | /* | 959 | /* |
960 | 960 | ||
961 | oldconflictItems = modifiedItem->conflictItems(); | 961 | oldconflictItems = modifiedItem->conflictItems(); |
962 | for ( item=oldconflictItems.first(); item != 0; | 962 | for ( item=oldconflictItems.first(); item != 0; |
963 | item=oldconflictItems.next() ) { | 963 | item=oldconflictItems.next() ) { |
964 | globalFlagBlockAgendaItemUpdate = 0; | 964 | globalFlagBlockAgendaItemUpdate = 0; |
965 | item->paintMe(false); | 965 | item->paintMe(false); |
966 | globalFlagBlockAgendaItemUpdate = 1; | 966 | globalFlagBlockAgendaItemUpdate = 1; |
967 | item->repaint(false); | 967 | item->repaint(false); |
968 | } | 968 | } |
969 | */ | 969 | */ |
970 | 970 | ||
971 | 971 | ||
972 | } | 972 | } |
973 | 973 | ||
974 | } | 974 | } |
975 | 975 | ||
976 | mScrollUpTimer.stop(); | 976 | mScrollUpTimer.stop(); |
977 | mScrollDownTimer.stop(); | 977 | mScrollDownTimer.stop(); |
978 | setCursor( arrowCursor ); | 978 | setCursor( arrowCursor ); |
979 | mActionItem = 0; | 979 | mActionItem = 0; |
980 | mActionType = NOP; | 980 | mActionType = NOP; |
981 | mItemMoved = 0; | 981 | mItemMoved = 0; |
982 | 982 | ||
983 | } | 983 | } |
984 | 984 | ||
985 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 985 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
986 | { | 986 | { |
987 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 987 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
988 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 988 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
989 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 989 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
990 | // point = clipper()->mapFromGlobal(point); | 990 | // point = clipper()->mapFromGlobal(point); |
991 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 991 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
992 | 992 | ||
993 | int x,y; | 993 | int x,y; |
994 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 994 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
995 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 995 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
996 | int gx,gy; | 996 | int gx,gy; |
997 | contentsToGrid(x,y,gx,gy); | 997 | contentsToGrid(x,y,gx,gy); |
998 | 998 | ||
999 | // Change cursor to resize cursor if appropriate | 999 | // Change cursor to resize cursor if appropriate |
1000 | if (mAllDayMode) { | 1000 | if (mAllDayMode) { |
1001 | int gridDistanceX = (x - gx * mGridSpacingX); | 1001 | int gridDistanceX = (x - gx * mGridSpacingX); |
1002 | if (gridDistanceX < mResizeBorderWidth && | 1002 | if (gridDistanceX < mResizeBorderWidth && |
1003 | moveItem->cellX() == gx) { | 1003 | moveItem->cellX() == gx) { |
1004 | setCursor(sizeHorCursor); | 1004 | setCursor(sizeHorCursor); |
1005 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1005 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1006 | moveItem->cellXWidth() == gx) { | 1006 | moveItem->cellXWidth() == gx) { |
1007 | setCursor(sizeHorCursor); | 1007 | setCursor(sizeHorCursor); |
1008 | } else { | 1008 | } else { |
1009 | setCursor(arrowCursor); | 1009 | setCursor(arrowCursor); |
1010 | } | 1010 | } |
1011 | } else { | 1011 | } else { |
1012 | int gridDistanceY = (y - gy * mGridSpacingY); | 1012 | int gridDistanceY = (y - gy * mGridSpacingY); |
1013 | if (gridDistanceY < mResizeBorderWidth && | 1013 | if (gridDistanceY < mResizeBorderWidth && |
1014 | moveItem->cellYTop() == gy && | 1014 | moveItem->cellYTop() == gy && |
1015 | !moveItem->firstMultiItem()) { | 1015 | !moveItem->firstMultiItem()) { |
1016 | setCursor(sizeVerCursor); | 1016 | setCursor(sizeVerCursor); |
1017 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1017 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1018 | moveItem->cellYBottom() == gy && | 1018 | moveItem->cellYBottom() == gy && |
1019 | !moveItem->lastMultiItem()) { | 1019 | !moveItem->lastMultiItem()) { |
1020 | setCursor(sizeVerCursor); | 1020 | setCursor(sizeVerCursor); |
1021 | } else { | 1021 | } else { |
1022 | setCursor(arrowCursor); | 1022 | setCursor(arrowCursor); |
1023 | } | 1023 | } |
1024 | } | 1024 | } |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | 1027 | ||
1028 | /* | 1028 | /* |
1029 | Place item in cell and take care that multiple items using the same cell do | 1029 | Place item in cell and take care that multiple items using the same cell do |
1030 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1030 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1031 | it can get in all cases. | 1031 | it can get in all cases. |
1032 | At the moment the method has a bug: When an item is placed only the sub cell | 1032 | At the moment the method has a bug: When an item is placed only the sub cell |
1033 | widths of the items are changed, which are within the Y region the item to | 1033 | widths of the items are changed, which are within the Y region the item to |
1034 | place spans. When the sub cell width change of one of this items affects a | 1034 | place spans. When the sub cell width change of one of this items affects a |
1035 | cell, where other items are, which do not overlap in Y with the item to place, | 1035 | cell, where other items are, which do not overlap in Y with the item to place, |
1036 | the display gets corrupted, although the corruption looks quite nice. | 1036 | the display gets corrupted, although the corruption looks quite nice. |
1037 | */ | 1037 | */ |
1038 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1038 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1039 | { | 1039 | { |
1040 | 1040 | ||
1041 | QPtrList<KOAgendaItem> conflictItems; | 1041 | QPtrList<KOAgendaItem> conflictItems; |
1042 | int maxSubCells = 0; | 1042 | int maxSubCells = 0; |
1043 | QIntDict<KOAgendaItem> subCellDict(5); | 1043 | QIntDict<KOAgendaItem> subCellDict(5); |
1044 | 1044 | ||
1045 | KOAgendaItem *item; | 1045 | KOAgendaItem *item; |
1046 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1046 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1047 | if (item != placeItem) { | 1047 | if (item != placeItem) { |
1048 | if (placeItem->cellX() <= item->cellXWidth() && | 1048 | if (placeItem->cellX() <= item->cellXWidth() && |
1049 | placeItem->cellXWidth() >= item->cellX()) { | 1049 | placeItem->cellXWidth() >= item->cellX()) { |
1050 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1050 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1051 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1051 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1052 | conflictItems.append(item); | 1052 | conflictItems.append(item); |
1053 | if (item->subCells() > maxSubCells) | 1053 | if (item->subCells() > maxSubCells) |
1054 | maxSubCells = item->subCells(); | 1054 | maxSubCells = item->subCells(); |
1055 | subCellDict.insert(item->subCell(),item); | 1055 | subCellDict.insert(item->subCell(),item); |
1056 | } | 1056 | } |
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | if (conflictItems.count() > 0) { | 1061 | if (conflictItems.count() > 0) { |
1062 | // Look for unused sub cell and insert item | 1062 | // Look for unused sub cell and insert item |
1063 | int i; | 1063 | int i; |
1064 | for(i=0;i<maxSubCells;++i) { | 1064 | for(i=0;i<maxSubCells;++i) { |
1065 | if (!subCellDict.find(i)) { | 1065 | if (!subCellDict.find(i)) { |
1066 | placeItem->setSubCell(i); | 1066 | placeItem->setSubCell(i); |
1067 | break; | 1067 | break; |
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | if (i == maxSubCells) { | 1070 | if (i == maxSubCells) { |
1071 | placeItem->setSubCell(maxSubCells); | 1071 | placeItem->setSubCell(maxSubCells); |
1072 | maxSubCells++; // add new item to number of sub cells | 1072 | maxSubCells++; // add new item to number of sub cells |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | // Prepare for sub cell geometry adjustment | 1075 | // Prepare for sub cell geometry adjustment |
1076 | int newSubCellWidth; | 1076 | int newSubCellWidth; |
1077 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1077 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1078 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1078 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1079 | conflictItems.append(placeItem); | 1079 | conflictItems.append(placeItem); |
1080 | 1080 | ||
1081 | 1081 | ||
1082 | // Adjust sub cell geometry of all direct conflict items | 1082 | // Adjust sub cell geometry of all direct conflict items |
1083 | for ( item=conflictItems.first(); item != 0; | 1083 | for ( item=conflictItems.first(); item != 0; |
1084 | item=conflictItems.next() ) { | 1084 | item=conflictItems.next() ) { |
1085 | item->setSubCells(maxSubCells); | 1085 | item->setSubCells(maxSubCells); |
1086 | if (mAllDayMode) { | 1086 | if (mAllDayMode) { |
1087 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1087 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1088 | } else { | 1088 | } else { |
1089 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1089 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1090 | } | 1090 | } |
1091 | int x,y; | 1091 | int x,y; |
1092 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1092 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1093 | if (mAllDayMode) { | 1093 | if (mAllDayMode) { |
1094 | y += item->subCell() * newSubCellWidth; | 1094 | y += item->subCell() * newSubCellWidth; |
1095 | } else { | 1095 | } else { |
1096 | x += item->subCell() * newSubCellWidth; | 1096 | x += item->subCell() * newSubCellWidth; |
1097 | } | 1097 | } |
1098 | moveChild(item,x,y); | 1098 | moveChild(item,x,y); |
1099 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1099 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1100 | //item->updateItem(); | 1100 | //item->updateItem(); |
1101 | } | 1101 | } |
1102 | // Adjust sub cell geometry of all conflict items of all conflict items | 1102 | // Adjust sub cell geometry of all conflict items of all conflict items |
1103 | for ( item=conflictItems.first(); item != 0; | 1103 | for ( item=conflictItems.first(); item != 0; |
1104 | item=conflictItems.next() ) { | 1104 | item=conflictItems.next() ) { |
1105 | if ( placeItem != item ) { | 1105 | if ( placeItem != item ) { |
1106 | KOAgendaItem *item2; | 1106 | KOAgendaItem *item2; |
1107 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1107 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1108 | for ( item2=conflictItems2.first(); item2 != 0; | 1108 | for ( item2=conflictItems2.first(); item2 != 0; |
1109 | item2=conflictItems2.next() ) { | 1109 | item2=conflictItems2.next() ) { |
1110 | if ( item2->subCells() != maxSubCells) { | 1110 | if ( item2->subCells() != maxSubCells) { |
1111 | item2->setSubCells(maxSubCells); | 1111 | item2->setSubCells(maxSubCells); |
1112 | if (mAllDayMode) { | 1112 | if (mAllDayMode) { |
1113 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1113 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1114 | } else { | 1114 | } else { |
1115 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1115 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1116 | } | 1116 | } |
1117 | int x,y; | 1117 | int x,y; |
1118 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1118 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1119 | if (mAllDayMode) { | 1119 | if (mAllDayMode) { |
1120 | y += item2->subCell() * newSubCellWidth; | 1120 | y += item2->subCell() * newSubCellWidth; |
1121 | } else { | 1121 | } else { |
1122 | x += item2->subCell() * newSubCellWidth; | 1122 | x += item2->subCell() * newSubCellWidth; |
1123 | } | 1123 | } |
1124 | moveChild(item2,x,y); | 1124 | moveChild(item2,x,y); |
1125 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1125 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | } | 1128 | } |
1129 | } | 1129 | } |
1130 | } else { | 1130 | } else { |
1131 | placeItem->setSubCell(0); | 1131 | placeItem->setSubCell(0); |
1132 | placeItem->setSubCells(1); | 1132 | placeItem->setSubCells(1); |
1133 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1133 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1134 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1134 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1135 | int x,y; | 1135 | int x,y; |
1136 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1136 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1137 | moveChild(placeItem,x,y); | 1137 | moveChild(placeItem,x,y); |
1138 | } | 1138 | } |
1139 | placeItem->setConflictItems(conflictItems); | 1139 | placeItem->setConflictItems(conflictItems); |
1140 | // for ( item=conflictItems.first(); item != 0; | 1140 | // for ( item=conflictItems.first(); item != 0; |
1141 | // item=conflictItems.next() ) { | 1141 | // item=conflictItems.next() ) { |
1142 | // //item->updateItem(); | 1142 | // //item->updateItem(); |
1143 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1143 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1144 | // } | 1144 | // } |
1145 | // placeItem->updateItem(); | 1145 | // placeItem->updateItem(); |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1148 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1149 | { | 1149 | { |
1150 | if ( globalFlagBlockAgenda ) | 1150 | if ( globalFlagBlockAgenda ) |
1151 | return; | 1151 | return; |
1152 | //qDebug("KOAgenda::drawContents "); | 1152 | //qDebug("KOAgenda::drawContents "); |
1153 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1153 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1154 | ;//drawContentsToPainter(); | 1154 | ;//drawContentsToPainter(); |
1155 | 1155 | ||
1156 | QPaintDevice* pd = p->device(); | 1156 | QPaintDevice* pd = p->device(); |
1157 | p->end(); | 1157 | p->end(); |
1158 | int vx, vy; | 1158 | int vx, vy; |
1159 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1159 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1160 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1160 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1161 | mSelectionCellX * mGridSpacingX; | 1161 | mSelectionCellX * mGridSpacingX; |
1162 | contentsToViewport ( cx, cy, vx,vy); | 1162 | contentsToViewport ( cx, cy, vx,vy); |
1163 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1163 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1164 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1164 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1165 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1165 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1166 | 1166 | ||
1167 | if ( mSelectionHeight > 0 ) { | 1167 | if ( mSelectionHeight > 0 ) { |
1168 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1168 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1169 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1169 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1170 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1170 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1171 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1171 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1172 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1172 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | //qDebug("btbl "); | 1175 | //qDebug("btbl "); |
1176 | p->begin( pd ); | 1176 | p->begin( pd ); |
1177 | //qDebug("end "); | 1177 | //qDebug("end "); |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | void KOAgenda::finishUpdate() | 1180 | void KOAgenda::finishUpdate() |
1181 | { | 1181 | { |
1182 | 1182 | ||
1183 | KOAgendaItem *item; | 1183 | KOAgendaItem *item; |
1184 | globalFlagBlockAgendaItemPaint = 1; | 1184 | globalFlagBlockAgendaItemPaint = 1; |
1185 | // 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 | 1185 | // 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 |
1186 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1186 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1187 | if ( !item->checkLayout() ) { | 1187 | if ( !item->checkLayout() ) { |
1188 | //qDebug(" conflictitem found "); | 1188 | //qDebug(" conflictitem found "); |
1189 | int newSubCellWidth; | 1189 | int newSubCellWidth; |
1190 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1190 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1191 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1191 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1192 | 1192 | ||
1193 | if (mAllDayMode) { | 1193 | if (mAllDayMode) { |
1194 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1194 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1195 | } else { | 1195 | } else { |
1196 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1196 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1197 | } | 1197 | } |
1198 | int x,y; | 1198 | int x,y; |
1199 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1199 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1200 | if (mAllDayMode) { | 1200 | if (mAllDayMode) { |
1201 | y += item->subCell() * newSubCellWidth; | 1201 | y += item->subCell() * newSubCellWidth; |
1202 | } else { | 1202 | } else { |
1203 | x += item->subCell() * newSubCellWidth; | 1203 | x += item->subCell() * newSubCellWidth; |
1204 | } | 1204 | } |
1205 | moveChild(item,x,y); | 1205 | moveChild(item,x,y); |
1206 | } | 1206 | } |
1207 | } | 1207 | } |
1208 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1208 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1209 | if ( !item->isVisible() ) | 1209 | if ( !item->isVisible() ) |
1210 | item->show(); | 1210 | item->show(); |
1211 | 1211 | ||
1212 | } | 1212 | } |
1213 | globalFlagBlockAgendaItemUpdate = 0; | 1213 | globalFlagBlockAgendaItemUpdate = 0; |
1214 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1214 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1215 | item->repaintMe( ); | 1215 | item->repaintMe( ); |
1216 | } | 1216 | } |
1217 | globalFlagBlockAgendaItemUpdate = 1; | 1217 | globalFlagBlockAgendaItemUpdate = 1; |
1218 | qApp->processEvents(); | 1218 | qApp->processEvents(); |
1219 | globalFlagBlockAgendaItemPaint = 0; | 1219 | globalFlagBlockAgendaItemPaint = 0; |
1220 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1220 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1221 | item->repaint( false ); | 1221 | item->repaint( false ); |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | } | 1224 | } |
1225 | 1225 | ||
1226 | /* | 1226 | /* |
1227 | Draw grid in the background of the agenda. | 1227 | Draw grid in the background of the agenda. |
1228 | */ | 1228 | */ |
1229 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1229 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1230 | { | 1230 | { |
1231 | 1231 | ||
1232 | 1232 | ||
1233 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1233 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1234 | return; | 1234 | return; |
1235 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1235 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1236 | return; | 1236 | return; |
1237 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1237 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1238 | if ( ch < 1 ) | 1238 | if ( ch < 1 ) |
1239 | ch = 1; | 1239 | ch = 1; |
1240 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1240 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1241 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1241 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1242 | } | 1242 | } |
1243 | mCurPixWid = contentsWidth(); | 1243 | mCurPixWid = contentsWidth(); |
1244 | mCurPixHei = ch; | 1244 | mCurPixHei = ch; |
1245 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1245 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1246 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1246 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1247 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1247 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1248 | } | 1248 | } |
1249 | mPixPainter.begin( &mPaintPixmap) ; | 1249 | mPixPainter.begin( &mPaintPixmap) ; |
1250 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1250 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1251 | QPainter * p ; | 1251 | QPainter * p ; |
1252 | if (paint == 0) { | 1252 | if (paint == 0) { |
1253 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1253 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1254 | p = &mPixPainter; | 1254 | p = &mPixPainter; |
1255 | } | 1255 | } |
1256 | else | 1256 | else |
1257 | p = paint ; | 1257 | p = paint ; |
1258 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1258 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1259 | 1259 | ||
1260 | //--cx;++cw; | 1260 | //--cx;++cw; |
1261 | int lGridSpacingY = mGridSpacingY*2; | 1261 | int lGridSpacingY = mGridSpacingY*2; |
1262 | int selDay; | 1262 | int selDay; |
1263 | if ( !backgroundOnly ) | 1263 | if ( !backgroundOnly ) |
1264 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1264 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1265 | { | 1265 | { |
1266 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1266 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1267 | int x1 = cx; | 1267 | int x1 = cx; |
1268 | int y1 = 0; | 1268 | int y1 = 0; |
1269 | if (y1 < cy) y1 = cy; | 1269 | if (y1 < cy) y1 = cy; |
1270 | int x2 = cx+cw-1; | 1270 | int x2 = cx+cw-1; |
1271 | int y2 = contentsHeight(); | 1271 | int y2 = contentsHeight(); |
1272 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1272 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1273 | if (x2 >= x1 && y2 >= y1) { | 1273 | if (x2 >= x1 && y2 >= y1) { |
1274 | int gxStart = selDay; | 1274 | int gxStart = selDay; |
1275 | int gxEnd = gxStart ; | 1275 | int gxEnd = gxStart ; |
1276 | int xStart = KOGlobals::self()->reverseLayout() ? | 1276 | int xStart = KOGlobals::self()->reverseLayout() ? |
1277 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1277 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1278 | gxStart*mGridSpacingX; | 1278 | gxStart*mGridSpacingX; |
1279 | if (xStart < x1) xStart = x1; | 1279 | if (xStart < x1) xStart = x1; |
1280 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1280 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1281 | (mColumns - gxStart)*mGridSpacingX-1 : | 1281 | (mColumns - gxStart)*mGridSpacingX-1 : |
1282 | (gxStart+1)*mGridSpacingX-1; | 1282 | (gxStart+1)*mGridSpacingX-1; |
1283 | if (xEnd > x2) xEnd = x2; | 1283 | if (xEnd > x2) xEnd = x2; |
1284 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1284 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1285 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1285 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1286 | KOPrefs::instance()->mAgendaBgColor.light()); | 1286 | KOPrefs::instance()->mAgendaBgColor.light()); |
1287 | else | 1287 | else |
1288 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1288 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1289 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1289 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1290 | 1290 | ||
1291 | } | 1291 | } |
1292 | } | 1292 | } |
1293 | } | 1293 | } |
1294 | // Highlight working hours | 1294 | // Highlight working hours |
1295 | 1295 | ||
1296 | if ( !backgroundOnly ) | 1296 | if ( !backgroundOnly ) |
1297 | if (mWorkingHoursEnable) { | 1297 | if (mWorkingHoursEnable) { |
1298 | int x1 = cx; | 1298 | int x1 = cx; |
1299 | int y1 = mWorkingHoursYTop; | 1299 | int y1 = mWorkingHoursYTop; |
1300 | if (y1 < cy) y1 = cy; | 1300 | if (y1 < cy) y1 = cy; |
1301 | int x2 = cx+cw-1; | 1301 | int x2 = cx+cw-1; |
1302 | // int x2 = mGridSpacingX * 5 - 1; | 1302 | // int x2 = mGridSpacingX * 5 - 1; |
1303 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1303 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1304 | int y2 = mWorkingHoursYBottom; | 1304 | int y2 = mWorkingHoursYBottom; |
1305 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1305 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1306 | 1306 | ||
1307 | if (x2 >= x1 && y2 >= y1) { | 1307 | if (x2 >= x1 && y2 >= y1) { |
1308 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1308 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1309 | int gxStart = x1/mGridSpacingX; | 1309 | int gxStart = x1/mGridSpacingX; |
1310 | int gxEnd = x2/mGridSpacingX; | 1310 | int gxEnd = x2/mGridSpacingX; |
1311 | while(gxStart <= gxEnd) { | 1311 | while(gxStart <= gxEnd) { |
1312 | if (gxStart < int(mHolidayMask->count()) && | 1312 | if (gxStart < int(mHolidayMask->count()) && |
1313 | !mHolidayMask->at(gxStart)) { | 1313 | !mHolidayMask->at(gxStart)) { |
1314 | int xStart = KOGlobals::self()->reverseLayout() ? | 1314 | int xStart = KOGlobals::self()->reverseLayout() ? |
1315 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1315 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1316 | gxStart*mGridSpacingX; | 1316 | gxStart*mGridSpacingX; |
1317 | if (xStart < x1) xStart = x1; | 1317 | if (xStart < x1) xStart = x1; |
1318 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1318 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1319 | (mColumns - gxStart)*mGridSpacingX-1 : | 1319 | (mColumns - gxStart)*mGridSpacingX-1 : |
1320 | (gxStart+1)*mGridSpacingX-1; | 1320 | (gxStart+1)*mGridSpacingX-1; |
1321 | if (xEnd > x2) xEnd = x2; | 1321 | if (xEnd > x2) xEnd = x2; |
1322 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1322 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { |
1323 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1323 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1324 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1324 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1325 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1325 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1326 | else | 1326 | else |
1327 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1327 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1328 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1328 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1329 | } else { | 1329 | } else { |
1330 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1330 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1331 | KOPrefs::instance()->mWorkingHoursColor); | 1331 | KOPrefs::instance()->mWorkingHoursColor); |
1332 | } | 1332 | } |
1333 | } | 1333 | } |
1334 | ++gxStart; | 1334 | ++gxStart; |
1335 | } | 1335 | } |
1336 | } | 1336 | } |
1337 | } | 1337 | } |
1338 | /* | 1338 | /* |
1339 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1339 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1340 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1340 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1341 | mSelectionCellX * mGridSpacingX; | 1341 | mSelectionCellX * mGridSpacingX; |
1342 | 1342 | ||
1343 | // Draw selection | 1343 | // Draw selection |
1344 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1344 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1345 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1345 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1346 | // TODO: paint only part within cx,cy,cw,ch | 1346 | // TODO: paint only part within cx,cy,cw,ch |
1347 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1347 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1348 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1348 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1349 | } | 1349 | } |
1350 | */ | 1350 | */ |
1351 | // Draw vertical lines of grid | 1351 | // Draw vertical lines of grid |
1352 | 1352 | ||
1353 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1353 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1354 | if ( mGridSpacingX > 0 ) { | 1354 | if ( mGridSpacingX > 0 ) { |
1355 | while (x < cx + cw) { | 1355 | while (x < cx + cw) { |
1356 | p->drawLine(x,cy,x,cy+ch); | 1356 | p->drawLine(x,cy,x,cy+ch); |
1357 | x+=mGridSpacingX; | 1357 | x+=mGridSpacingX; |
1358 | } | 1358 | } |
1359 | } | 1359 | } |
1360 | // Draw horizontal lines of grid | 1360 | // Draw horizontal lines of grid |
1361 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1361 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1362 | if ( lGridSpacingY > 0 ) { | 1362 | if ( lGridSpacingY > 0 ) { |
1363 | while (y < cy + ch) { | 1363 | while (y < cy + ch) { |
1364 | p->setPen( SolidLine ); | 1364 | p->setPen( SolidLine ); |
1365 | p->drawLine(cx,y,cx+cw,y); | 1365 | p->drawLine(cx,y,cx+cw,y); |
1366 | y+=lGridSpacingY; | 1366 | y+=lGridSpacingY; |
1367 | p->setPen( DotLine ); | 1367 | p->setPen( DotLine ); |
1368 | p->drawLine(cx,y,cx+cw,y); | 1368 | p->drawLine(cx,y,cx+cw,y); |
1369 | y+=lGridSpacingY; | 1369 | y+=lGridSpacingY; |
1370 | } | 1370 | } |
1371 | p->setPen( SolidLine ); | 1371 | p->setPen( SolidLine ); |
1372 | } | 1372 | } |
1373 | mPixPainter.end() ; | 1373 | mPixPainter.end() ; |
1374 | } | 1374 | } |
1375 | 1375 | ||
1376 | /* | 1376 | /* |
1377 | Convert srcollview contents coordinates to agenda grid coordinates. | 1377 | Convert srcollview contents coordinates to agenda grid coordinates. |
1378 | */ | 1378 | */ |
1379 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1379 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1380 | { | 1380 | { |
1381 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1381 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1382 | x/mGridSpacingX; | 1382 | x/mGridSpacingX; |
1383 | gy = y/mGridSpacingY; | 1383 | gy = y/mGridSpacingY; |
1384 | } | 1384 | } |
1385 | 1385 | ||
1386 | /* | 1386 | /* |
1387 | Convert agenda grid coordinates to scrollview contents coordinates. | 1387 | Convert agenda grid coordinates to scrollview contents coordinates. |
1388 | */ | 1388 | */ |
1389 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1389 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1390 | { | 1390 | { |
1391 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1391 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1392 | gx*mGridSpacingX; | 1392 | gx*mGridSpacingX; |
1393 | y = gy*mGridSpacingY; | 1393 | y = gy*mGridSpacingY; |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | 1396 | ||
1397 | /* | 1397 | /* |
1398 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1398 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1399 | the grid. | 1399 | the grid. |
1400 | */ | 1400 | */ |
1401 | int KOAgenda::timeToY(const QTime &time) | 1401 | int KOAgenda::timeToY(const QTime &time) |
1402 | { | 1402 | { |
1403 | int minutesPerCell = 24 * 60 / mRows; | 1403 | int minutesPerCell = 24 * 60 / mRows; |
1404 | int timeMinutes = time.hour() * 60 + time.minute(); | 1404 | int timeMinutes = time.hour() * 60 + time.minute(); |
1405 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1405 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1406 | return Y; | 1406 | return Y; |
1407 | } | 1407 | } |
1408 | 1408 | ||
1409 | 1409 | ||
1410 | /* | 1410 | /* |
1411 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1411 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1412 | fit into the grid. | 1412 | fit into the grid. |
1413 | */ | 1413 | */ |
1414 | QTime KOAgenda::gyToTime(int gy) | 1414 | QTime KOAgenda::gyToTime(int gy) |
1415 | { | 1415 | { |
1416 | 1416 | ||
1417 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1417 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1418 | 1418 | ||
1419 | int timeSeconds = secondsPerCell * gy; | 1419 | int timeSeconds = secondsPerCell * gy; |
1420 | 1420 | ||
1421 | QTime time( 0, 0, 0 ); | 1421 | QTime time( 0, 0, 0 ); |
1422 | if ( timeSeconds < 24 * 60 * 60 ) { | 1422 | if ( timeSeconds < 24 * 60 * 60 ) { |
1423 | time = time.addSecs(timeSeconds); | 1423 | time = time.addSecs(timeSeconds); |
1424 | } else { | 1424 | } else { |
1425 | time.setHMS( 23, 59, 59 ); | 1425 | time.setHMS( 23, 59, 59 ); |
1426 | } | 1426 | } |
1427 | 1427 | ||
1428 | return time; | 1428 | return time; |
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | void KOAgenda::setStartHour(int startHour) | 1431 | void KOAgenda::setStartHour(int startHour) |
1432 | { | 1432 | { |
1433 | int startCell = startHour * mRows / 24; | 1433 | int startCell = startHour * mRows / 24; |
1434 | setContentsPos(0,startCell * gridSpacingY()); | 1434 | setContentsPos(0,startCell * gridSpacingY()); |
1435 | } | 1435 | } |
1436 | void KOAgenda::hideUnused() | 1436 | void KOAgenda::hideUnused() |
1437 | { | 1437 | { |
1438 | // experimental only | 1438 | // experimental only |
1439 | // return; | 1439 | // return; |
1440 | KOAgendaItem *item; | 1440 | KOAgendaItem *item; |
1441 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1441 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1442 | item->hide(); | 1442 | item->hide(); |
1443 | } | 1443 | } |
1444 | } | 1444 | } |
1445 | 1445 | ||
1446 | 1446 | ||
1447 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1447 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1448 | { | 1448 | { |
1449 | 1449 | ||
1450 | KOAgendaItem *fi; | 1450 | KOAgendaItem *fi; |
1451 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1451 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1452 | if ( fi->incidence() == event ) { | 1452 | if ( fi->incidence() == event ) { |
1453 | mUnusedItems.remove(); | 1453 | mUnusedItems.remove(); |
1454 | fi->init( event, qd ); | 1454 | fi->init( event, qd ); |
1455 | return fi; | 1455 | return fi; |
1456 | } | 1456 | } |
1457 | } | 1457 | } |
1458 | fi=mUnusedItems.first(); | 1458 | fi=mUnusedItems.first(); |
1459 | if ( fi ) { | 1459 | if ( fi ) { |
1460 | mUnusedItems.remove(); | 1460 | mUnusedItems.remove(); |
1461 | fi->init( event, qd ); | 1461 | fi->init( event, qd ); |
1462 | return fi; | 1462 | return fi; |
1463 | } | 1463 | } |
1464 | // qDebug("new KOAgendaItem "); | 1464 | // qDebug("new KOAgendaItem "); |
1465 | 1465 | ||
1466 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1466 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1467 | agendaItem->installEventFilter(this); | 1467 | agendaItem->installEventFilter(this); |
1468 | addChild(agendaItem,0,0); | 1468 | addChild(agendaItem,0,0); |
1469 | return agendaItem; | 1469 | return agendaItem; |
1470 | } | 1470 | } |
1471 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1471 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1472 | { | 1472 | { |
1473 | KOAgendaItem *item; | 1473 | KOAgendaItem *item; |
1474 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1474 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1475 | if ( item->incidence() == todo ) { | 1475 | if ( item->incidence() == todo ) { |
1476 | mItems.remove(); | 1476 | mItems.remove(); |
1477 | return item; | 1477 | return item; |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 042a789..0ea2860 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,784 +1,784 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qvbox.h> | 23 | #include <qvbox.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qwhatsthis.h> | 25 | #include <qwhatsthis.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | 29 | ||
30 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 36 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 37 | #else |
38 | #define AGENDA_ICON_SIZE 7 | 38 | #define AGENDA_ICON_SIZE 7 |
39 | #endif | 39 | #endif |
40 | #include <libkcal/icaldrag.h> | 40 | #include <libkcal/icaldrag.h> |
41 | #include <libkcal/vcaldrag.h> | 41 | #include <libkcal/vcaldrag.h> |
42 | #include <libkcal/kincidenceformatter.h> | 42 | #include <libkcal/kincidenceformatter.h> |
43 | extern int globalFlagBlockAgenda; | 43 | extern int globalFlagBlockAgenda; |
44 | extern int globalFlagBlockAgendaItemPaint; | 44 | extern int globalFlagBlockAgendaItemPaint; |
45 | extern int globalFlagBlockAgendaItemUpdate; | 45 | extern int globalFlagBlockAgendaItemUpdate; |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "koagendaitem.h" | 49 | #include "koagendaitem.h" |
50 | //#include "koagendaitem.moc" | 50 | //#include "koagendaitem.moc" |
51 | 51 | ||
52 | 52 | ||
53 | //-------------------------------------------------------------------------- | 53 | //-------------------------------------------------------------------------- |
54 | 54 | ||
55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
56 | 56 | ||
57 | //-------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------- |
58 | 58 | ||
59 | class KOAgendaItemWhatsThis :public QWhatsThis | 59 | class KOAgendaItemWhatsThis :public QWhatsThis |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | virtual QString text( const QPoint& ) | 65 | virtual QString text( const QPoint& ) |
66 | { | 66 | { |
67 | return _view->getWhatsThisText() ; | 67 | return _view->getWhatsThisText() ; |
68 | } | 68 | } |
69 | private: | 69 | private: |
70 | KOAgendaItem * _view; | 70 | KOAgendaItem * _view; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
74 | const char *name,WFlags) : | 74 | const char *name,WFlags) : |
75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
76 | { | 76 | { |
77 | #ifndef DESKTOP_VERSION | 77 | #ifndef DESKTOP_VERSION |
78 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 78 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
79 | #endif | 79 | #endif |
80 | new KOAgendaItemWhatsThis(this); | 80 | new KOAgendaItemWhatsThis(this); |
81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
82 | setWFlags ( wflags); | 82 | setWFlags ( wflags); |
83 | mAllDay = allday; | 83 | mAllDay = allday; |
84 | init ( incidence, qd ); | 84 | init ( incidence, qd ); |
85 | setMouseTracking(true); | 85 | //setMouseTracking(true); |
86 | //setAcceptDrops(true); | 86 | //setAcceptDrops(true); |
87 | xPaintCoord = -1; | 87 | xPaintCoord = -1; |
88 | yPaintCoord = -1; | 88 | yPaintCoord = -1; |
89 | } | 89 | } |
90 | QString KOAgendaItem::getWhatsThisText() | 90 | QString KOAgendaItem::getWhatsThisText() |
91 | { | 91 | { |
92 | if ( mIncidence ) | 92 | if ( mIncidence ) |
93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, | 93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, |
94 | KOPrefs::instance()->mWTshowDetails, | 94 | KOPrefs::instance()->mWTshowDetails, |
95 | KOPrefs::instance()->mWTshowCreated, | 95 | KOPrefs::instance()->mWTshowCreated, |
96 | KOPrefs::instance()->mWTshowChanged); | 96 | KOPrefs::instance()->mWTshowChanged); |
97 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 97 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
98 | } | 98 | } |
99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
100 | { | 100 | { |
101 | mIncidence = incidence; | 101 | mIncidence = incidence; |
102 | mDate = qd; | 102 | mDate = qd; |
103 | mFirstMultiItem = 0; | 103 | mFirstMultiItem = 0; |
104 | mNextMultiItem = 0; | 104 | mNextMultiItem = 0; |
105 | mLastMultiItem = 0; | 105 | mLastMultiItem = 0; |
106 | computeText(); | 106 | computeText(); |
107 | 107 | ||
108 | if ( (incidence->type() == "Todo") && | 108 | if ( (incidence->type() == "Todo") && |
109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
113 | else | 113 | else |
114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
115 | } | 115 | } |
116 | else { | 116 | else { |
117 | QStringList categories = mIncidence->categories(); | 117 | QStringList categories = mIncidence->categories(); |
118 | QString cat = categories.first(); | 118 | QString cat = categories.first(); |
119 | if (cat.isEmpty()) { | 119 | if (cat.isEmpty()) { |
120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) | 120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) |
121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
122 | else | 122 | else |
123 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 123 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
124 | } else { | 124 | } else { |
125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { | 126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { |
127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | } | 132 | } |
133 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 133 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
134 | mBackgroundColor.dark(),mBackgroundColor.light(), | 134 | mBackgroundColor.dark(),mBackgroundColor.light(), |
135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
136 | setBackgroundColor( mBackgroundColor ); | 136 | setBackgroundColor( mBackgroundColor ); |
137 | 137 | ||
138 | mConflictItems.clear(); | 138 | mConflictItems.clear(); |
139 | setCellXY(0,0,1); | 139 | setCellXY(0,0,1); |
140 | setCellXWidth(0); | 140 | setCellXWidth(0); |
141 | setSubCell(0); | 141 | setSubCell(0); |
142 | setSubCells(1); | 142 | setSubCells(1); |
143 | setMultiItem(0,0,0); | 143 | setMultiItem(0,0,0); |
144 | startMove(); | 144 | startMove(); |
145 | mSelected = true; | 145 | mSelected = true; |
146 | select(false); | 146 | select(false); |
147 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 147 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
148 | mFontPixelSize = fontinf.height();; | 148 | mFontPixelSize = fontinf.height();; |
149 | hide(); | 149 | hide(); |
150 | xPaintCoord = -1; | 150 | xPaintCoord = -1; |
151 | yPaintCoord = -1; | 151 | yPaintCoord = -1; |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | KOAgendaItem::~KOAgendaItem() | 155 | KOAgendaItem::~KOAgendaItem() |
156 | { | 156 | { |
157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
158 | 158 | ||
159 | } | 159 | } |
160 | 160 | ||
161 | void KOAgendaItem::recreateIncidence() | 161 | void KOAgendaItem::recreateIncidence() |
162 | { | 162 | { |
163 | #if 0 | 163 | #if 0 |
164 | Incidence* newInc = mIncidence->clone(); | 164 | Incidence* newInc = mIncidence->clone(); |
165 | newInc->recreate(); | 165 | newInc->recreate(); |
166 | if ( mIncidence->doesRecur() ) { | 166 | if ( mIncidence->doesRecur() ) { |
167 | mIncidence->addExDate( mDate ); | 167 | mIncidence->addExDate( mDate ); |
168 | newInc->recurrence()->unsetRecurs(); | 168 | newInc->recurrence()->unsetRecurs(); |
169 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 169 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
170 | QTime tim = mIncidence->dtStart().time(); | 170 | QTime tim = mIncidence->dtStart().time(); |
171 | newInc->setDtStart( QDateTime(mDate, tim) ); | 171 | newInc->setDtStart( QDateTime(mDate, tim) ); |
172 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 172 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
173 | } | 173 | } |
174 | #endif | 174 | #endif |
175 | mIncidence = mIncidence->recreateCloneException( mDate ); | 175 | mIncidence = mIncidence->recreateCloneException( mDate ); |
176 | } | 176 | } |
177 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 177 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
178 | { | 178 | { |
179 | int size = AGENDA_ICON_SIZE; | 179 | int size = AGENDA_ICON_SIZE; |
180 | 180 | ||
181 | int yOff = 0; | 181 | int yOff = 0; |
182 | int xOff = 0; | 182 | int xOff = 0; |
183 | int x = pos().x() +3; | 183 | int x = pos().x() +3; |
184 | int y; | 184 | int y; |
185 | if ( mAllDay ) | 185 | if ( mAllDay ) |
186 | y = pos().y()+3; | 186 | y = pos().y()+3; |
187 | else | 187 | else |
188 | y = mCellYTop * ( height() / cellHeight() ) +3; | 188 | y = mCellYTop * ( height() / cellHeight() ) +3; |
189 | if (mIncidence->cancelled()) { | 189 | if (mIncidence->cancelled()) { |
190 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 190 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
191 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 191 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
192 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 192 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
193 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 193 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
194 | if ( horLayout ) | 194 | if ( horLayout ) |
195 | ++xOff; | 195 | ++xOff; |
196 | else | 196 | else |
197 | ++yOff; | 197 | ++yOff; |
198 | } | 198 | } |
199 | if (mIncidence->isAlarmEnabled()) { | 199 | if (mIncidence->isAlarmEnabled()) { |
200 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 200 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
201 | if ( horLayout ) | 201 | if ( horLayout ) |
202 | ++xOff; | 202 | ++xOff; |
203 | else | 203 | else |
204 | ++yOff; | 204 | ++yOff; |
205 | } | 205 | } |
206 | if (mIncidence->recurrence()->doesRecur()) { | 206 | if (mIncidence->recurrence()->doesRecur()) { |
207 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 207 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
208 | if ( horLayout ) | 208 | if ( horLayout ) |
209 | ++xOff; | 209 | ++xOff; |
210 | else | 210 | else |
211 | ++yOff; | 211 | ++yOff; |
212 | } | 212 | } |
213 | if (mIncidence->description().length() > 0) { | 213 | if (mIncidence->description().length() > 0) { |
214 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 214 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
215 | if ( horLayout ) | 215 | if ( horLayout ) |
216 | ++xOff; | 216 | ++xOff; |
217 | else | 217 | else |
218 | ++yOff; | 218 | ++yOff; |
219 | } | 219 | } |
220 | if (mIncidence->isReadOnly()) { | 220 | if (mIncidence->isReadOnly()) { |
221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
222 | if ( horLayout ) | 222 | if ( horLayout ) |
223 | ++xOff; | 223 | ++xOff; |
224 | else | 224 | else |
225 | ++yOff; | 225 | ++yOff; |
226 | } | 226 | } |
227 | 227 | ||
228 | if (mIncidence->attendeeCount()>0) { | 228 | if (mIncidence->attendeeCount()>0) { |
229 | 229 | ||
230 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 230 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
232 | if ( horLayout ) | 232 | if ( horLayout ) |
233 | ++xOff; | 233 | ++xOff; |
234 | else | 234 | else |
235 | ++yOff; | 235 | ++yOff; |
236 | } else { | 236 | } else { |
237 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 237 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
238 | if (me!=0) { | 238 | if (me!=0) { |
239 | 239 | ||
240 | 240 | ||
241 | } else { | 241 | } else { |
242 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 242 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
243 | if ( horLayout ) | 243 | if ( horLayout ) |
244 | ++xOff; | 244 | ++xOff; |
245 | else | 245 | else |
246 | ++yOff; | 246 | ++yOff; |
247 | 247 | ||
248 | } | 248 | } |
249 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 249 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
250 | if ( horLayout ) | 250 | if ( horLayout ) |
251 | ++xOff; | 251 | ++xOff; |
252 | else | 252 | else |
253 | ++yOff; | 253 | ++yOff; |
254 | 254 | ||
255 | } | 255 | } |
256 | 256 | ||
257 | } | 257 | } |
258 | return ( yOff || xOff ); | 258 | return ( yOff || xOff ); |
259 | } | 259 | } |
260 | 260 | ||
261 | 261 | ||
262 | void KOAgendaItem::select(bool selected) | 262 | void KOAgendaItem::select(bool selected) |
263 | { | 263 | { |
264 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 264 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
265 | if (mSelected == selected) return; | 265 | if (mSelected == selected) return; |
266 | mSelected = selected; | 266 | mSelected = selected; |
267 | if ( ! isVisible() ) | 267 | if ( ! isVisible() ) |
268 | return; | 268 | return; |
269 | if ( firstMultiItem() ) | 269 | if ( firstMultiItem() ) |
270 | firstMultiItem()->select( selected ); | 270 | firstMultiItem()->select( selected ); |
271 | if ( !firstMultiItem() && nextMultiItem() ) { | 271 | if ( !firstMultiItem() && nextMultiItem() ) { |
272 | KOAgendaItem * placeItem = nextMultiItem(); | 272 | KOAgendaItem * placeItem = nextMultiItem(); |
273 | while ( placeItem ) { | 273 | while ( placeItem ) { |
274 | placeItem->select( selected ); | 274 | placeItem->select( selected ); |
275 | placeItem = placeItem->nextMultiItem(); | 275 | placeItem = placeItem->nextMultiItem(); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | globalFlagBlockAgendaItemUpdate = 0; | 278 | globalFlagBlockAgendaItemUpdate = 0; |
279 | paintMe( selected ); | 279 | paintMe( selected ); |
280 | globalFlagBlockAgendaItemUpdate = 1; | 280 | globalFlagBlockAgendaItemUpdate = 1; |
281 | repaint( false ); | 281 | repaint( false ); |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | /* | 285 | /* |
286 | The eventFilter has to filter the mouse events of the agenda item childs. The | 286 | The eventFilter has to filter the mouse events of the agenda item childs. The |
287 | events are fed into the event handling method of KOAgendaItem. This allows the | 287 | events are fed into the event handling method of KOAgendaItem. This allows the |
288 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 288 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
289 | */ | 289 | */ |
290 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 290 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
291 | { | 291 | { |
292 | if (e->type() == QEvent::MouseButtonPress || | 292 | if (e->type() == QEvent::MouseButtonPress || |
293 | e->type() == QEvent::MouseButtonDblClick || | 293 | e->type() == QEvent::MouseButtonDblClick || |
294 | e->type() == QEvent::MouseButtonRelease || | 294 | e->type() == QEvent::MouseButtonRelease || |
295 | e->type() == QEvent::MouseMove) { | 295 | e->type() == QEvent::MouseMove) { |
296 | QMouseEvent *me = (QMouseEvent *)e; | 296 | QMouseEvent *me = (QMouseEvent *)e; |
297 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 297 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
298 | mapToGlobal(me->pos())); | 298 | mapToGlobal(me->pos())); |
299 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 299 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
300 | return event(&returnEvent); | 300 | return event(&returnEvent); |
301 | } else { | 301 | } else { |
302 | return false; | 302 | return false; |
303 | } | 303 | } |
304 | } | 304 | } |
305 | void KOAgendaItem::repaintMe( ) | 305 | void KOAgendaItem::repaintMe( ) |
306 | { | 306 | { |
307 | paintMe ( mSelected ); | 307 | paintMe ( mSelected ); |
308 | } | 308 | } |
309 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 309 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
310 | { | 310 | { |
311 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 311 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
312 | return; | 312 | return; |
313 | QPainter pa; | 313 | QPainter pa; |
314 | 314 | ||
315 | if ( mSelected ) { | 315 | if ( mSelected ) { |
316 | pa.begin( paintPixSel() ); | 316 | pa.begin( paintPixSel() ); |
317 | } else { | 317 | } else { |
318 | if ( mAllDay ) | 318 | if ( mAllDay ) |
319 | pa.begin( paintPixAllday() ); | 319 | pa.begin( paintPixAllday() ); |
320 | else | 320 | else |
321 | pa.begin( paintPix() ); | 321 | pa.begin( paintPix() ); |
322 | } | 322 | } |
323 | int x, yy, w, h; | 323 | int x, yy, w, h; |
324 | float nfh = 7.0; | 324 | float nfh = 7.0; |
325 | x = pos().x(); w = width(); h = height (); | 325 | x = pos().x(); w = width(); h = height (); |
326 | if ( mAllDay ) | 326 | if ( mAllDay ) |
327 | yy = y(); | 327 | yy = y(); |
328 | else | 328 | else |
329 | yy = mCellYTop * ( height() / cellHeight() ); | 329 | yy = mCellYTop * ( height() / cellHeight() ); |
330 | xPaintCoord= x; | 330 | xPaintCoord= x; |
331 | yPaintCoord = yy; | 331 | yPaintCoord = yy; |
332 | wPaintCoord = width(); | 332 | wPaintCoord = width(); |
333 | hPaintCoord = height(); | 333 | hPaintCoord = height(); |
334 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 334 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
335 | if ( paint == 0 ) | 335 | if ( paint == 0 ) |
336 | paint = &pa; | 336 | paint = &pa; |
337 | bool horLayout = ( w < h ); | 337 | bool horLayout = ( w < h ); |
338 | int maxhei = mFontPixelSize+4; | 338 | int maxhei = mFontPixelSize+4; |
339 | if ( horLayout ) | 339 | if ( horLayout ) |
340 | maxhei += AGENDA_ICON_SIZE -4; | 340 | maxhei += AGENDA_ICON_SIZE -4; |
341 | bool small = ( h < maxhei ); | 341 | bool small = ( h < maxhei ); |
342 | if ( ! small ) | 342 | if ( ! small ) |
343 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 343 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
344 | else { | 344 | else { |
345 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 345 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
346 | f.setBold( false ); | 346 | f.setBold( false ); |
347 | int fh = f.pointSize(); | 347 | int fh = f.pointSize(); |
348 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 348 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
349 | if ( nfh < 6 ) | 349 | if ( nfh < 6 ) |
350 | nfh = 6; | 350 | nfh = 6; |
351 | f.setPointSize( nfh ); | 351 | f.setPointSize( nfh ); |
352 | paint->setFont(f); | 352 | paint->setFont(f); |
353 | } | 353 | } |
354 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 354 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
355 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 355 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
356 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 356 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
357 | if ( mIncidence->type() == "Todo" ) { | 357 | if ( mIncidence->type() == "Todo" ) { |
358 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 358 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
359 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 359 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
360 | int yyy = yy+3; | 360 | int yyy = yy+3; |
361 | if ( tempTodo->isCompleted() ) | 361 | if ( tempTodo->isCompleted() ) |
362 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 362 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
363 | else { | 363 | else { |
364 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 364 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
365 | 365 | ||
366 | } | 366 | } |
367 | } | 367 | } |
368 | bool addIcon = false; | 368 | bool addIcon = false; |
369 | if ( ! small || w > 3 * h || h > 3* w ) | 369 | if ( ! small || w > 3 * h || h > 3* w ) |
370 | addIcon = updateIcons( paint, horLayout ); | 370 | addIcon = updateIcons( paint, horLayout ); |
371 | 371 | ||
372 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 372 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
373 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 373 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
374 | if ( ! small ) { | 374 | if ( ! small ) { |
375 | x += 3; yy += 3;w -= 6; h-= 5; | 375 | x += 3; yy += 3;w -= 6; h-= 5; |
376 | } else { | 376 | } else { |
377 | x += 2; yy += 1;w -= 4; h-= 4; | 377 | x += 2; yy += 1;w -= 4; h-= 4; |
378 | if ( nfh < 6.01 ) { | 378 | if ( nfh < 6.01 ) { |
379 | yy -= 2; | 379 | yy -= 2; |
380 | h += 4; | 380 | h += 4; |
381 | } | 381 | } |
382 | else | 382 | else |
383 | if ( nfh < h -2 ) | 383 | if ( nfh < h -2 ) |
384 | ++yy; | 384 | ++yy; |
385 | } | 385 | } |
386 | int align; | 386 | int align; |
387 | #ifndef DESKTOP_VERSION | 387 | #ifndef DESKTOP_VERSION |
388 | align = ( AlignLeft|WordBreak|AlignTop); | 388 | align = ( AlignLeft|WordBreak|AlignTop); |
389 | #else | 389 | #else |
390 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 390 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
391 | #endif | 391 | #endif |
392 | if ( addIcon ) { | 392 | if ( addIcon ) { |
393 | if ( ! horLayout ) { | 393 | if ( ! horLayout ) { |
394 | x += AGENDA_ICON_SIZE+3; | 394 | x += AGENDA_ICON_SIZE+3; |
395 | w -= (AGENDA_ICON_SIZE+3); | 395 | w -= (AGENDA_ICON_SIZE+3); |
396 | } | 396 | } |
397 | else { | 397 | else { |
398 | yy+= AGENDA_ICON_SIZE+2; | 398 | yy+= AGENDA_ICON_SIZE+2; |
399 | h -=(AGENDA_ICON_SIZE+3); | 399 | h -=(AGENDA_ICON_SIZE+3); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
403 | if ( colsum < 250 ) | 403 | if ( colsum < 250 ) |
404 | paint->setPen ( white); | 404 | paint->setPen ( white); |
405 | if ( x < 0 ) { | 405 | if ( x < 0 ) { |
406 | w = w+x-3; | 406 | w = w+x-3; |
407 | x = 3; | 407 | x = 3; |
408 | if ( w > parentWidget()->width() ){ | 408 | if ( w > parentWidget()->width() ){ |
409 | w = parentWidget()->width() - 6; | 409 | w = parentWidget()->width() - 6; |
410 | #ifndef DESKTOP_VERSION | 410 | #ifndef DESKTOP_VERSION |
411 | align = ( AlignHCenter|WordBreak|AlignTop); | 411 | align = ( AlignHCenter|WordBreak|AlignTop); |
412 | #else | 412 | #else |
413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
414 | #endif | 414 | #endif |
415 | 415 | ||
416 | } | 416 | } |
417 | } | 417 | } |
418 | QRect dr; | 418 | QRect dr; |
419 | if ( w + x > parentWidget()->width() ) | 419 | if ( w + x > parentWidget()->width() ) |
420 | w = parentWidget()->width()-x; | 420 | w = parentWidget()->width()-x; |
421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
422 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 422 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
423 | if ( mIncidence->cancelled() ){ | 423 | if ( mIncidence->cancelled() ){ |
424 | if ( ! small ) { | 424 | if ( ! small ) { |
425 | QFontMetrics fm ( paint->font() ); | 425 | QFontMetrics fm ( paint->font() ); |
426 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 426 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
427 | } | 427 | } |
428 | 428 | ||
429 | } | 429 | } |
430 | pa.end(); | 430 | pa.end(); |
431 | 431 | ||
432 | } | 432 | } |
433 | void KOAgendaItem::resizePixmap( int w , int h ) | 433 | void KOAgendaItem::resizePixmap( int w , int h ) |
434 | { | 434 | { |
435 | paintPix()->resize( w, h ); | 435 | paintPix()->resize( w, h ); |
436 | paintPixSel()->resize( w, h ); | 436 | paintPixSel()->resize( w, h ); |
437 | 437 | ||
438 | } | 438 | } |
439 | QPixmap * KOAgendaItem::paintPix() | 439 | QPixmap * KOAgendaItem::paintPix() |
440 | { | 440 | { |
441 | static QPixmap* mPaintPix = 0; | 441 | static QPixmap* mPaintPix = 0; |
442 | if ( ! mPaintPix ) | 442 | if ( ! mPaintPix ) |
443 | mPaintPix = new QPixmap(1,1); | 443 | mPaintPix = new QPixmap(1,1); |
444 | return mPaintPix ; | 444 | return mPaintPix ; |
445 | } | 445 | } |
446 | QPixmap * KOAgendaItem::paintPixAllday() | 446 | QPixmap * KOAgendaItem::paintPixAllday() |
447 | { | 447 | { |
448 | static QPixmap* mPaintPixA = 0; | 448 | static QPixmap* mPaintPixA = 0; |
449 | if ( ! mPaintPixA ) | 449 | if ( ! mPaintPixA ) |
450 | mPaintPixA = new QPixmap(1,1); | 450 | mPaintPixA = new QPixmap(1,1); |
451 | return mPaintPixA ; | 451 | return mPaintPixA ; |
452 | } | 452 | } |
453 | QPixmap * KOAgendaItem::paintPixSel() | 453 | QPixmap * KOAgendaItem::paintPixSel() |
454 | { | 454 | { |
455 | static QPixmap* mPaintPixSel = 0; | 455 | static QPixmap* mPaintPixSel = 0; |
456 | if ( ! mPaintPixSel ) | 456 | if ( ! mPaintPixSel ) |
457 | mPaintPixSel = new QPixmap(1,1); | 457 | mPaintPixSel = new QPixmap(1,1); |
458 | return mPaintPixSel ; | 458 | return mPaintPixSel ; |
459 | } | 459 | } |
460 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 460 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
461 | { | 461 | { |
462 | 462 | ||
463 | if ( globalFlagBlockAgendaItemPaint ) | 463 | if ( globalFlagBlockAgendaItemPaint ) |
464 | return; | 464 | return; |
465 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 465 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
466 | return; | 466 | return; |
467 | int yy; | 467 | int yy; |
468 | if ( mAllDay ) | 468 | if ( mAllDay ) |
469 | yy = y(); | 469 | yy = y(); |
470 | else | 470 | else |
471 | yy = mCellYTop * ( height() / cellHeight() ); | 471 | yy = mCellYTop * ( height() / cellHeight() ); |
472 | int xx = x(); | 472 | int xx = x(); |
473 | if ( xPaintCoord != xx || yPaintCoord != yy || | 473 | if ( xPaintCoord != xx || yPaintCoord != yy || |
474 | wPaintCoord != width() || hPaintCoord != height()) { | 474 | wPaintCoord != width() || hPaintCoord != height()) { |
475 | xPaintCoord= xx; | 475 | xPaintCoord= xx; |
476 | yPaintCoord = yy; | 476 | yPaintCoord = yy; |
477 | wPaintCoord = width(); | 477 | wPaintCoord = width(); |
478 | hPaintCoord = height(); | 478 | hPaintCoord = height(); |
479 | globalFlagBlockAgendaItemUpdate = 0; | 479 | globalFlagBlockAgendaItemUpdate = 0; |
480 | paintMe( mSelected ); | 480 | paintMe( mSelected ); |
481 | //qDebug("calling paintMe "); | 481 | //qDebug("calling paintMe "); |
482 | globalFlagBlockAgendaItemUpdate = 1; | 482 | globalFlagBlockAgendaItemUpdate = 1; |
483 | } | 483 | } |
484 | int rx, ry, rw, rh; | 484 | int rx, ry, rw, rh; |
485 | rx = e->rect().x(); | 485 | rx = e->rect().x(); |
486 | ry = e->rect().y(); | 486 | ry = e->rect().y(); |
487 | rw = e->rect().width(); | 487 | rw = e->rect().width(); |
488 | rh = e->rect().height(); | 488 | rh = e->rect().height(); |
489 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 489 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
490 | 490 | ||
491 | QPixmap* paintFrom ; | 491 | QPixmap* paintFrom ; |
492 | if ( mSelected ) { | 492 | if ( mSelected ) { |
493 | paintFrom = paintPixSel(); | 493 | paintFrom = paintPixSel(); |
494 | } else { | 494 | } else { |
495 | if ( mAllDay ) | 495 | if ( mAllDay ) |
496 | paintFrom = paintPixAllday(); | 496 | paintFrom = paintPixAllday(); |
497 | else | 497 | else |
498 | paintFrom = paintPix(); | 498 | paintFrom = paintPix(); |
499 | } | 499 | } |
500 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); | 500 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); |
501 | } | 501 | } |
502 | void KOAgendaItem::computeText() | 502 | void KOAgendaItem::computeText() |
503 | { | 503 | { |
504 | 504 | ||
505 | mDisplayedText = mIncidence->summary(); | 505 | mDisplayedText = mIncidence->summary(); |
506 | if ( (mIncidence->type() == "Todo") ) { | 506 | if ( (mIncidence->type() == "Todo") ) { |
507 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 507 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
508 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 508 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
509 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 509 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
510 | else if ( !(mIncidence->doesFloat())) | 510 | else if ( !(mIncidence->doesFloat())) |
511 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 511 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
512 | } | 512 | } |
513 | } else { | 513 | } else { |
514 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 514 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
515 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 515 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
516 | 516 | ||
517 | if ( mAllDay ) { | 517 | if ( mAllDay ) { |
518 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 518 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
519 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 519 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
520 | } | 520 | } |
521 | } | 521 | } |
522 | 522 | ||
523 | } | 523 | } |
524 | 524 | ||
525 | if ( !mIncidence->location().isEmpty() ) { | 525 | if ( !mIncidence->location().isEmpty() ) { |
526 | if ( mAllDay ) | 526 | if ( mAllDay ) |
527 | mDisplayedText += " ("; | 527 | mDisplayedText += " ("; |
528 | else | 528 | else |
529 | mDisplayedText += "\n("; | 529 | mDisplayedText += "\n("; |
530 | mDisplayedText += mIncidence->location() +")"; | 530 | mDisplayedText += mIncidence->location() +")"; |
531 | } | 531 | } |
532 | 532 | ||
533 | QString tipText = mIncidence->summary(); | 533 | QString tipText = mIncidence->summary(); |
534 | if ( !mIncidence->doesFloat() ) { | 534 | if ( !mIncidence->doesFloat() ) { |
535 | if ( mIncidence->type() == "Event" ) { | 535 | if ( mIncidence->type() == "Event" ) { |
536 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 536 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
537 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 537 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
538 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 538 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
539 | } | 539 | } |
540 | else { | 540 | else { |
541 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 541 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
542 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 542 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | else if ( mIncidence->type() == "Todo" ) { | 545 | else if ( mIncidence->type() == "Todo" ) { |
546 | if (mIncidence->hasStartDate()) | 546 | if (mIncidence->hasStartDate()) |
547 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 547 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
548 | if (((Todo*)mIncidence)->hasDueDate()) | 548 | if (((Todo*)mIncidence)->hasDueDate()) |
549 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 549 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
550 | } | 550 | } |
551 | } else if ( mIncidence->type() == "Todo" ) { | 551 | } else if ( mIncidence->type() == "Todo" ) { |
552 | if (mIncidence->hasStartDate()) | 552 | if (mIncidence->hasStartDate()) |
553 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 553 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
554 | if (((Todo*)mIncidence)->hasDueDate()) | 554 | if (((Todo*)mIncidence)->hasDueDate()) |
555 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 555 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
556 | } | 556 | } |
557 | 557 | ||
558 | if (!mIncidence->location().isEmpty()) { | 558 | if (!mIncidence->location().isEmpty()) { |
559 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 559 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
560 | } | 560 | } |
561 | QToolTip::add(this,tipText,toolTipGroup(),""); | 561 | QToolTip::add(this,tipText,toolTipGroup(),""); |
562 | 562 | ||
563 | } | 563 | } |
564 | void KOAgendaItem::updateItem() | 564 | void KOAgendaItem::updateItem() |
565 | { | 565 | { |
566 | computeText(); | 566 | computeText(); |
567 | 567 | ||
568 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 568 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
569 | paintMe( mSelected ); | 569 | paintMe( mSelected ); |
570 | repaint( false); | 570 | repaint( false); |
571 | } | 571 | } |
572 | 572 | ||
573 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 573 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
574 | { | 574 | { |
575 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 575 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
576 | paintMe( mSelected ); | 576 | paintMe( mSelected ); |
577 | repaint( false ); | 577 | repaint( false ); |
578 | } | 578 | } |
579 | 579 | ||
580 | /* | 580 | /* |
581 | Return height of item in units of agenda cells | 581 | Return height of item in units of agenda cells |
582 | */ | 582 | */ |
583 | int KOAgendaItem::cellHeight() | 583 | int KOAgendaItem::cellHeight() |
584 | { | 584 | { |
585 | int ret = mCellYBottom - mCellYTop + 1; | 585 | int ret = mCellYBottom - mCellYTop + 1; |
586 | if ( ret <= 0 ) { | 586 | if ( ret <= 0 ) { |
587 | ret = 1; | 587 | ret = 1; |
588 | mCellYBottom = 0; | 588 | mCellYBottom = 0; |
589 | mCellYTop = 0; | 589 | mCellYTop = 0; |
590 | } | 590 | } |
591 | return ret; | 591 | return ret; |
592 | } | 592 | } |
593 | 593 | ||
594 | /* | 594 | /* |
595 | Return height of item in units of agenda cells | 595 | Return height of item in units of agenda cells |
596 | */ | 596 | */ |
597 | int KOAgendaItem::cellWidth() | 597 | int KOAgendaItem::cellWidth() |
598 | { | 598 | { |
599 | return mCellXWidth - mCellX + 1; | 599 | return mCellXWidth - mCellX + 1; |
600 | } | 600 | } |
601 | 601 | ||
602 | void KOAgendaItem::setItemDate(QDate qd) | 602 | void KOAgendaItem::setItemDate(QDate qd) |
603 | { | 603 | { |
604 | mDate = qd; | 604 | mDate = qd; |
605 | } | 605 | } |
606 | 606 | ||
607 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 607 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
608 | { | 608 | { |
609 | mCellX = X; | 609 | mCellX = X; |
610 | mCellYTop = YTop; | 610 | mCellYTop = YTop; |
611 | mCellYBottom = YBottom; | 611 | mCellYBottom = YBottom; |
612 | } | 612 | } |
613 | 613 | ||
614 | void KOAgendaItem::setCellXWidth(int xwidth) | 614 | void KOAgendaItem::setCellXWidth(int xwidth) |
615 | { | 615 | { |
616 | mCellXWidth = xwidth; | 616 | mCellXWidth = xwidth; |
617 | } | 617 | } |
618 | 618 | ||
619 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 619 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
620 | { | 620 | { |
621 | mCellX = XLeft; | 621 | mCellX = XLeft; |
622 | mCellXWidth = XRight; | 622 | mCellXWidth = XRight; |
623 | } | 623 | } |
624 | 624 | ||
625 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 625 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
626 | { | 626 | { |
627 | mCellYTop = YTop; | 627 | mCellYTop = YTop; |
628 | mCellYBottom = YBottom; | 628 | mCellYBottom = YBottom; |
629 | } | 629 | } |
630 | 630 | ||
631 | void KOAgendaItem::setSubCell(int subCell) | 631 | void KOAgendaItem::setSubCell(int subCell) |
632 | { | 632 | { |
633 | mSubCell = subCell; | 633 | mSubCell = subCell; |
634 | } | 634 | } |
635 | 635 | ||
636 | void KOAgendaItem::setSubCells(int subCells) | 636 | void KOAgendaItem::setSubCells(int subCells) |
637 | { | 637 | { |
638 | mSubCells = subCells; | 638 | mSubCells = subCells; |
639 | } | 639 | } |
640 | 640 | ||
641 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 641 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
642 | KOAgendaItem *last) | 642 | KOAgendaItem *last) |
643 | { | 643 | { |
644 | mFirstMultiItem = first; | 644 | mFirstMultiItem = first; |
645 | mNextMultiItem = next; | 645 | mNextMultiItem = next; |
646 | mLastMultiItem = last; | 646 | mLastMultiItem = last; |
647 | } | 647 | } |
648 | 648 | ||
649 | void KOAgendaItem::startMove() | 649 | void KOAgendaItem::startMove() |
650 | { | 650 | { |
651 | mStartCellX = mCellX; | 651 | mStartCellX = mCellX; |
652 | mStartCellXWidth = mCellXWidth; | 652 | mStartCellXWidth = mCellXWidth; |
653 | mStartCellYTop = mCellYTop; | 653 | mStartCellYTop = mCellYTop; |
654 | mStartCellYBottom = mCellYBottom; | 654 | mStartCellYBottom = mCellYBottom; |
655 | } | 655 | } |
656 | 656 | ||
657 | void KOAgendaItem::resetMove() | 657 | void KOAgendaItem::resetMove() |
658 | { | 658 | { |
659 | mCellX = mStartCellX; | 659 | mCellX = mStartCellX; |
660 | mCellXWidth = mStartCellXWidth; | 660 | mCellXWidth = mStartCellXWidth; |
661 | mCellYTop = mStartCellYTop; | 661 | mCellYTop = mStartCellYTop; |
662 | mCellYBottom = mStartCellYBottom; | 662 | mCellYBottom = mStartCellYBottom; |
663 | } | 663 | } |
664 | 664 | ||
665 | void KOAgendaItem::moveRelative(int dx, int dy) | 665 | void KOAgendaItem::moveRelative(int dx, int dy) |
666 | { | 666 | { |
667 | int newX = cellX() + dx; | 667 | int newX = cellX() + dx; |
668 | int newXWidth = cellXWidth() + dx; | 668 | int newXWidth = cellXWidth() + dx; |
669 | int newYTop = cellYTop() + dy; | 669 | int newYTop = cellYTop() + dy; |
670 | int newYBottom = cellYBottom() + dy; | 670 | int newYBottom = cellYBottom() + dy; |
671 | setCellXY(newX,newYTop,newYBottom); | 671 | setCellXY(newX,newYTop,newYBottom); |
672 | setCellXWidth(newXWidth); | 672 | setCellXWidth(newXWidth); |
673 | } | 673 | } |
674 | 674 | ||
675 | void KOAgendaItem::expandTop(int dy) | 675 | void KOAgendaItem::expandTop(int dy) |
676 | { | 676 | { |
677 | int newYTop = cellYTop() + dy; | 677 | int newYTop = cellYTop() + dy; |
678 | int newYBottom = cellYBottom(); | 678 | int newYBottom = cellYBottom(); |
679 | if (newYTop > newYBottom) newYTop = newYBottom; | 679 | if (newYTop > newYBottom) newYTop = newYBottom; |
680 | setCellY(newYTop, newYBottom); | 680 | setCellY(newYTop, newYBottom); |
681 | } | 681 | } |
682 | 682 | ||
683 | void KOAgendaItem::expandBottom(int dy) | 683 | void KOAgendaItem::expandBottom(int dy) |
684 | { | 684 | { |
685 | int newYTop = cellYTop(); | 685 | int newYTop = cellYTop(); |
686 | int newYBottom = cellYBottom() + dy; | 686 | int newYBottom = cellYBottom() + dy; |
687 | if (newYBottom < newYTop) newYBottom = newYTop; | 687 | if (newYBottom < newYTop) newYBottom = newYTop; |
688 | setCellY(newYTop, newYBottom); | 688 | setCellY(newYTop, newYBottom); |
689 | } | 689 | } |
690 | 690 | ||
691 | void KOAgendaItem::expandLeft(int dx) | 691 | void KOAgendaItem::expandLeft(int dx) |
692 | { | 692 | { |
693 | int newX = cellX() + dx; | 693 | int newX = cellX() + dx; |
694 | int newXWidth = cellXWidth(); | 694 | int newXWidth = cellXWidth(); |
695 | if (newX > newXWidth) newX = newXWidth; | 695 | if (newX > newXWidth) newX = newXWidth; |
696 | setCellX(newX,newXWidth); | 696 | setCellX(newX,newXWidth); |
697 | } | 697 | } |
698 | 698 | ||
699 | void KOAgendaItem::expandRight(int dx) | 699 | void KOAgendaItem::expandRight(int dx) |
700 | { | 700 | { |
701 | int newX = cellX(); | 701 | int newX = cellX(); |
702 | int newXWidth = cellXWidth() + dx; | 702 | int newXWidth = cellXWidth() + dx; |
703 | if (newXWidth < newX) newXWidth = newX; | 703 | if (newXWidth < newX) newXWidth = newX; |
704 | setCellX(newX,newXWidth); | 704 | setCellX(newX,newXWidth); |
705 | } | 705 | } |
706 | 706 | ||
707 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 707 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
708 | { | 708 | { |
709 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 709 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
710 | return mToolTipGroup; | 710 | return mToolTipGroup; |
711 | } | 711 | } |
712 | 712 | ||
713 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 713 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
714 | { | 714 | { |
715 | #ifndef KORG_NODND | 715 | #ifndef KORG_NODND |
716 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 716 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
717 | !QTextDrag::canDecode( e ) ) { | 717 | !QTextDrag::canDecode( e ) ) { |
718 | e->ignore(); | 718 | e->ignore(); |
719 | return; | 719 | return; |
720 | } | 720 | } |
721 | e->accept(); | 721 | e->accept(); |
722 | #endif | 722 | #endif |
723 | } | 723 | } |
724 | 724 | ||
725 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 725 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
726 | { | 726 | { |
727 | #ifndef KORG_NODND | 727 | #ifndef KORG_NODND |
728 | QString text; | 728 | QString text; |
729 | if(QTextDrag::decode(e,text)) | 729 | if(QTextDrag::decode(e,text)) |
730 | { | 730 | { |
731 | kdDebug() << "Dropped : " << text << endl; | 731 | kdDebug() << "Dropped : " << text << endl; |
732 | QStringList emails = QStringList::split(",",text); | 732 | QStringList emails = QStringList::split(",",text); |
733 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 733 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
734 | kdDebug() << " Email: " << (*it) << endl; | 734 | kdDebug() << " Email: " << (*it) << endl; |
735 | int pos = (*it).find("<"); | 735 | int pos = (*it).find("<"); |
736 | QString name = (*it).left(pos); | 736 | QString name = (*it).left(pos); |
737 | QString email = (*it).mid(pos); | 737 | QString email = (*it).mid(pos); |
738 | if (!email.isEmpty()) { | 738 | if (!email.isEmpty()) { |
739 | mIncidence->addAttendee(new Attendee(name,email)); | 739 | mIncidence->addAttendee(new Attendee(name,email)); |
740 | } | 740 | } |
741 | } | 741 | } |
742 | } | 742 | } |
743 | #endif | 743 | #endif |
744 | } | 744 | } |
745 | 745 | ||
746 | 746 | ||
747 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 747 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
748 | { | 748 | { |
749 | return mConflictItems; | 749 | return mConflictItems; |
750 | } | 750 | } |
751 | 751 | ||
752 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 752 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
753 | { | 753 | { |
754 | mConflictItems = ci; | 754 | mConflictItems = ci; |
755 | KOAgendaItem *item; | 755 | KOAgendaItem *item; |
756 | for ( item=mConflictItems.first(); item != 0; | 756 | for ( item=mConflictItems.first(); item != 0; |
757 | item=mConflictItems.next() ) { | 757 | item=mConflictItems.next() ) { |
758 | item->addConflictItem(this); | 758 | item->addConflictItem(this); |
759 | } | 759 | } |
760 | } | 760 | } |
761 | 761 | ||
762 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 762 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
763 | { | 763 | { |
764 | if (mConflictItems.find(ci)<0) | 764 | if (mConflictItems.find(ci)<0) |
765 | mConflictItems.append(ci); | 765 | mConflictItems.append(ci); |
766 | } | 766 | } |
767 | 767 | ||
768 | bool KOAgendaItem::checkLayout() | 768 | bool KOAgendaItem::checkLayout() |
769 | { | 769 | { |
770 | if ( !mConflictItems.count() ) | 770 | if ( !mConflictItems.count() ) |
771 | return true; | 771 | return true; |
772 | int max = 0; | 772 | int max = 0; |
773 | KOAgendaItem *item; | 773 | KOAgendaItem *item; |
774 | for ( item=mConflictItems.first(); item != 0; | 774 | for ( item=mConflictItems.first(); item != 0; |
775 | item=mConflictItems.next() ) { | 775 | item=mConflictItems.next() ) { |
776 | if ( item->subCells() > max ) | 776 | if ( item->subCells() > max ) |
777 | max = item->subCells(); | 777 | max = item->subCells(); |
778 | } | 778 | } |
779 | if ( max > subCells() ) { | 779 | if ( max > subCells() ) { |
780 | setSubCells( max ); | 780 | setSubCells( max ); |
781 | return false; | 781 | return false; |
782 | } | 782 | } |
783 | return true; | 783 | return true; |
784 | } | 784 | } |