author | zautrix <zautrix> | 2005-02-23 10:58:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-23 10:58:09 (UTC) |
commit | 36704cb63582c161d2ab5c63e66ee63bbf3b865f (patch) (unidiff) | |
tree | 1541d63b50f7bc50278c6fed164f4b5228f18362 /korganizer | |
parent | 87a2f1a301beae2a8550c340348741c69f0ac1dd (diff) | |
download | kdepimpi-36704cb63582c161d2ab5c63e66ee63bbf3b865f.zip kdepimpi-36704cb63582c161d2ab5c63e66ee63bbf3b865f.tar.gz kdepimpi-36704cb63582c161d2ab5c63e66ee63bbf3b865f.tar.bz2 |
fixed layout problem
-rw-r--r-- | korganizer/koagenda.cpp | 31 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 1 |
2 files changed, 30 insertions, 2 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index a72e470..195b1fa 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,2013 +1,2040 @@ | |||
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 bool block = true; | 398 | static bool block = true; |
399 | switch (me->type()) { | 399 | switch (me->type()) { |
400 | case QEvent::MouseButtonPress: | 400 | case QEvent::MouseButtonPress: |
401 | //qDebug("QEvent::MouseButtonPress: "); | 401 | //qDebug("QEvent::MouseButtonPress: "); |
402 | // kdDebug() << "koagenda: filtered button press" << endl; | 402 | // kdDebug() << "koagenda: filtered button press" << endl; |
403 | if (object != viewport()) { | 403 | if (object != viewport()) { |
404 | if (me->button() == RightButton) { | 404 | if (me->button() == RightButton) { |
405 | mClickedItem = (KOAgendaItem *)object; | 405 | mClickedItem = (KOAgendaItem *)object; |
406 | if (mClickedItem) { | 406 | if (mClickedItem) { |
407 | selectItem(mClickedItem); | 407 | selectItem(mClickedItem); |
408 | // emit showIncidencePopupSignal(mClickedItem->incidence()); | 408 | // emit showIncidencePopupSignal(mClickedItem->incidence()); |
409 | } | 409 | } |
410 | //mItemPopup->popup(QCursor::pos()); | 410 | //mItemPopup->popup(QCursor::pos()); |
411 | } else { | 411 | } else { |
412 | mActionItem = (KOAgendaItem *)object; | 412 | mActionItem = (KOAgendaItem *)object; |
413 | if (mActionItem) { | 413 | if (mActionItem) { |
414 | if ( mSelectionHeight > 0 ) { | 414 | if ( mSelectionHeight > 0 ) { |
415 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 415 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
416 | int selectionYTop = mSelectionYTop; | 416 | int selectionYTop = mSelectionYTop; |
417 | int gridSpacingX = mGridSpacingX; | 417 | int gridSpacingX = mGridSpacingX; |
418 | int selectionHeight = mSelectionHeight; | 418 | int selectionHeight = mSelectionHeight; |
419 | clearSelection(); | 419 | clearSelection(); |
420 | repaintContents( selectionCellX, selectionYTop, | 420 | repaintContents( selectionCellX, selectionYTop, |
421 | gridSpacingX, selectionHeight,false ); | 421 | gridSpacingX, selectionHeight,false ); |
422 | } | 422 | } |
423 | selectItem(mActionItem); | 423 | selectItem(mActionItem); |
424 | Incidence *incidence = mActionItem->incidence(); | 424 | Incidence *incidence = mActionItem->incidence(); |
425 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 425 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
426 | mActionItem = 0; | 426 | mActionItem = 0; |
427 | } else { | 427 | } else { |
428 | startItemAction(viewportPos); | 428 | startItemAction(viewportPos); |
429 | startX = viewportPos.x(); | 429 | startX = viewportPos.x(); |
430 | startY = viewportPos.y(); | 430 | startY = viewportPos.y(); |
431 | block = true; | 431 | block = true; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | } | 434 | } |
435 | } else { | 435 | } else { |
436 | selectItem(0); | 436 | selectItem(0); |
437 | mActionItem = 0; | 437 | mActionItem = 0; |
438 | if (me->button() == RightButton ) { | 438 | if (me->button() == RightButton ) { |
439 | blockNewEvent = true; | 439 | blockNewEvent = true; |
440 | block = false; | 440 | block = false; |
441 | } else { | 441 | } else { |
442 | blockNewEvent = false; | 442 | blockNewEvent = false; |
443 | setCursor(arrowCursor); | 443 | setCursor(arrowCursor); |
444 | startSelectAction(viewportPos); | 444 | startSelectAction(viewportPos); |
445 | } | 445 | } |
446 | } | 446 | } |
447 | break; | 447 | break; |
448 | 448 | ||
449 | case QEvent::MouseButtonRelease: | 449 | case QEvent::MouseButtonRelease: |
450 | //qDebug("QEvent::MouseButtonRelease: %d",blockNewEvent ); | 450 | //qDebug("QEvent::MouseButtonRelease: %d",blockNewEvent ); |
451 | if (me->button() == RightButton && blockNewEvent && !block) { | 451 | if (me->button() == RightButton && blockNewEvent && !block) { |
452 | int x,y; | 452 | int x,y; |
453 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 453 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
454 | int gx,gy; | 454 | int gx,gy; |
455 | contentsToGrid(x,y,gx,gy); | 455 | contentsToGrid(x,y,gx,gy); |
456 | if ( object == viewport() ) { | 456 | if ( object == viewport() ) { |
457 | if ( mCurrentCellY < mStartCellY +1 ) { | 457 | if ( mCurrentCellY < mStartCellY +1 ) { |
458 | //qDebug("mCurrentCellY %d mStartCellY %d ", mCurrentCellY,mStartCellY); | 458 | //qDebug("mCurrentCellY %d mStartCellY %d ", mCurrentCellY,mStartCellY); |
459 | mCurrentCellX = gx; | 459 | mCurrentCellX = gx; |
460 | mCurrentCellY = gy; | 460 | mCurrentCellY = gy; |
461 | mStartCellX = gx; | 461 | mStartCellX = gx; |
462 | mStartCellY = gy; | 462 | mStartCellY = gy; |
463 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | 463 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); |
464 | break; | 464 | break; |
465 | } else { | 465 | } else { |
466 | blockNewEvent = false; | 466 | blockNewEvent = false; |
467 | } | 467 | } |
468 | } else { | 468 | } else { |
469 | mClickedItem = (KOAgendaItem *)object; | 469 | mClickedItem = (KOAgendaItem *)object; |
470 | if (mActionItem ) { | 470 | if (mActionItem ) { |
471 | endItemAction(); | 471 | endItemAction(); |
472 | } | 472 | } |
473 | if (mClickedItem) { | 473 | if (mClickedItem) { |
474 | selectItem(mClickedItem); | 474 | selectItem(mClickedItem); |
475 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 475 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
476 | } | 476 | } |
477 | } | 477 | } |
478 | } else if (me->button() == RightButton && block ) { | 478 | } else if (me->button() == RightButton && block ) { |
479 | if (object != viewport()) { | 479 | if (object != viewport()) { |
480 | mClickedItem = (KOAgendaItem *)object; | 480 | mClickedItem = (KOAgendaItem *)object; |
481 | if (mActionItem ) { | 481 | if (mActionItem ) { |
482 | endItemAction(); | 482 | endItemAction(); |
483 | } | 483 | } |
484 | if (mClickedItem) { | 484 | if (mClickedItem) { |
485 | selectItem(mClickedItem); | 485 | selectItem(mClickedItem); |
486 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 486 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
487 | } | 487 | } |
488 | } | 488 | } |
489 | break; | 489 | break; |
490 | } | 490 | } |
491 | block = true; | 491 | block = true; |
492 | if (mActionItem) { | 492 | if (mActionItem) { |
493 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 493 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
494 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 494 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
495 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 495 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
496 | mScrollUpTimer.stop(); | 496 | mScrollUpTimer.stop(); |
497 | mScrollDownTimer.stop(); | 497 | mScrollDownTimer.stop(); |
498 | mActionItem->resetMove(); | 498 | mActionItem->resetMove(); |
499 | placeSubCells( mActionItem ); | 499 | placeSubCells( mActionItem ); |
500 | // emit startDragSignal( mActionItem->incidence() ); | 500 | // emit startDragSignal( mActionItem->incidence() ); |
501 | setCursor( arrowCursor ); | 501 | setCursor( arrowCursor ); |
502 | mActionItem = 0; | 502 | mActionItem = 0; |
503 | mActionType = NOP; | 503 | mActionType = NOP; |
504 | mItemMoved = 0; | 504 | mItemMoved = 0; |
505 | return true; | 505 | return true; |
506 | } | 506 | } |
507 | endItemAction(); | 507 | endItemAction(); |
508 | } else if ( mActionType == SELECT ) { | 508 | } else if ( mActionType == SELECT ) { |
509 | if (me->button() == RightButton ) { | 509 | if (me->button() == RightButton ) { |
510 | } else { | 510 | } else { |
511 | endSelectAction( !blockNewEvent ); | 511 | endSelectAction( !blockNewEvent ); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | break; | 514 | break; |
515 | 515 | ||
516 | case QEvent::MouseMove: | 516 | case QEvent::MouseMove: |
517 | if (object != viewport()) { | 517 | if (object != viewport()) { |
518 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 518 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
519 | //qDebug("moveItem %d ",moveItem ); | 519 | //qDebug("moveItem %d ",moveItem ); |
520 | if (!moveItem->incidence()->isReadOnly() /*&& | 520 | if (!moveItem->incidence()->isReadOnly() /*&& |
521 | !moveItem->incidence()->recurrence()->doesRecur()*/ ) | 521 | !moveItem->incidence()->recurrence()->doesRecur()*/ ) |
522 | if (!mActionItem) | 522 | if (!mActionItem) |
523 | setNoActionCursor(moveItem,viewportPos); | 523 | setNoActionCursor(moveItem,viewportPos); |
524 | else { | 524 | else { |
525 | if ( block ) { | 525 | if ( block ) { |
526 | int dX, dY; | 526 | int dX, dY; |
527 | dX = startX - viewportPos.x(); | 527 | dX = startX - viewportPos.x(); |
528 | if ( dX < 0 ) | 528 | if ( dX < 0 ) |
529 | dX = -dX; | 529 | dX = -dX; |
530 | dY = viewportPos.y() - startY; | 530 | dY = viewportPos.y() - startY; |
531 | if ( dY < 0 ) | 531 | if ( dY < 0 ) |
532 | dY = -dY; | 532 | dY = -dY; |
533 | int diff = 30; | 533 | int diff = 30; |
534 | if ( QApplication::desktop()->width() < 480 ) | 534 | if ( QApplication::desktop()->width() < 480 ) |
535 | diff = 15; | 535 | diff = 15; |
536 | // qDebug(" %d %d ",dX, dY ); | 536 | // qDebug(" %d %d ",dX, dY ); |
537 | if ( dX > diff || dY > diff ) { | 537 | if ( dX > diff || dY > diff ) { |
538 | block = false; | 538 | block = false; |
539 | } | 539 | } |
540 | } | 540 | } |
541 | if ( !block ) | 541 | if ( !block ) |
542 | performItemAction(viewportPos); | 542 | performItemAction(viewportPos); |
543 | } | 543 | } |
544 | } else { | 544 | } else { |
545 | if ( mActionType == SELECT ) { | 545 | if ( mActionType == SELECT ) { |
546 | performSelectAction( viewportPos ); | 546 | performSelectAction( viewportPos ); |
547 | } | 547 | } |
548 | } | 548 | } |
549 | break; | 549 | break; |
550 | 550 | ||
551 | case QEvent::MouseButtonDblClick: | 551 | case QEvent::MouseButtonDblClick: |
552 | if (object == viewport()) { | 552 | if (object == viewport()) { |
553 | selectItem(0); | 553 | selectItem(0); |
554 | int x,y; | 554 | int x,y; |
555 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 555 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
556 | int gx,gy; | 556 | int gx,gy; |
557 | contentsToGrid(x,y,gx,gy); | 557 | contentsToGrid(x,y,gx,gy); |
558 | emit newEventSignal(gx,gy); | 558 | emit newEventSignal(gx,gy); |
559 | } else { | 559 | } else { |
560 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 560 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
561 | selectItem(doubleClickedItem); | 561 | selectItem(doubleClickedItem); |
562 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 562 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
563 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 563 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
564 | else | 564 | else |
565 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 565 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
566 | } | 566 | } |
567 | break; | 567 | break; |
568 | 568 | ||
569 | default: | 569 | default: |
570 | break; | 570 | break; |
571 | } | 571 | } |
572 | 572 | ||
573 | return true; | 573 | return true; |
574 | } | 574 | } |
575 | 575 | ||
576 | void KOAgenda::newItem( int item ) | 576 | void KOAgenda::newItem( int item ) |
577 | { | 577 | { |
578 | if ( item == 1 ) { //new event | 578 | if ( item == 1 ) { //new event |
579 | newEventSignal(mStartCellX ,mStartCellY ); | 579 | newEventSignal(mStartCellX ,mStartCellY ); |
580 | } else | 580 | } else |
581 | if ( item == 2 ) { //new event | 581 | if ( item == 2 ) { //new event |
582 | newTodoSignal(mStartCellX ,mStartCellY ); | 582 | newTodoSignal(mStartCellX ,mStartCellY ); |
583 | } else | 583 | } else |
584 | { | 584 | { |
585 | QDate day = mSelectedDates[mStartCellX]; | 585 | QDate day = mSelectedDates[mStartCellX]; |
586 | emit showDateView( item, day ); | 586 | emit showDateView( item, day ); |
587 | // 3Day view | 587 | // 3Day view |
588 | // 4Week view | 588 | // 4Week view |
589 | // 5Month view | 589 | // 5Month view |
590 | // 6Journal view | 590 | // 6Journal view |
591 | } | 591 | } |
592 | } | 592 | } |
593 | void KOAgenda::startSelectAction(QPoint viewportPos) | 593 | void KOAgenda::startSelectAction(QPoint viewportPos) |
594 | { | 594 | { |
595 | //emit newStartSelectSignal(); | 595 | //emit newStartSelectSignal(); |
596 | 596 | ||
597 | mActionType = SELECT; | 597 | mActionType = SELECT; |
598 | 598 | ||
599 | int x,y; | 599 | int x,y; |
600 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 600 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
601 | int gx,gy; | 601 | int gx,gy; |
602 | contentsToGrid(x,y,gx,gy); | 602 | contentsToGrid(x,y,gx,gy); |
603 | 603 | ||
604 | mStartCellX = gx; | 604 | mStartCellX = gx; |
605 | mStartCellY = gy; | 605 | mStartCellY = gy; |
606 | mCurrentCellX = gx; | 606 | mCurrentCellX = gx; |
607 | mCurrentCellY = gy; | 607 | mCurrentCellY = gy; |
608 | 608 | ||
609 | // Store coordinates of old selection | 609 | // Store coordinates of old selection |
610 | int selectionX = mSelectionCellX * mGridSpacingX; | 610 | int selectionX = mSelectionCellX * mGridSpacingX; |
611 | int selectionYTop = mSelectionYTop; | 611 | int selectionYTop = mSelectionYTop; |
612 | int selectionHeight = mSelectionHeight; | 612 | int selectionHeight = mSelectionHeight; |
613 | 613 | ||
614 | // Store new selection | 614 | // Store new selection |
615 | mSelectionCellX = gx; | 615 | mSelectionCellX = gx; |
616 | mSelectionYTop = gy * mGridSpacingY; | 616 | mSelectionYTop = gy * mGridSpacingY; |
617 | mSelectionHeight = mGridSpacingY; | 617 | mSelectionHeight = mGridSpacingY; |
618 | 618 | ||
619 | // Clear old selection | 619 | // Clear old selection |
620 | repaintContents( selectionX, selectionYTop, | 620 | repaintContents( selectionX, selectionYTop, |
621 | mGridSpacingX, selectionHeight,false ); | 621 | mGridSpacingX, selectionHeight,false ); |
622 | 622 | ||
623 | // Paint new selection | 623 | // Paint new selection |
624 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, | 624 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, |
625 | // mGridSpacingX, mSelectionHeight ); | 625 | // mGridSpacingX, mSelectionHeight ); |
626 | } | 626 | } |
627 | 627 | ||
628 | void KOAgenda::performSelectAction(QPoint viewportPos) | 628 | void KOAgenda::performSelectAction(QPoint viewportPos) |
629 | { | 629 | { |
630 | int x,y; | 630 | int x,y; |
631 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 631 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
632 | int gx,gy; | 632 | int gx,gy; |
633 | contentsToGrid(x,y,gx,gy); | 633 | contentsToGrid(x,y,gx,gy); |
634 | 634 | ||
635 | QPoint clipperPos = clipper()-> | 635 | QPoint clipperPos = clipper()-> |
636 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 636 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
637 | 637 | ||
638 | // Scroll if cursor was moved to upper or lower end of agenda. | 638 | // Scroll if cursor was moved to upper or lower end of agenda. |
639 | if (clipperPos.y() < mScrollBorderWidth) { | 639 | if (clipperPos.y() < mScrollBorderWidth) { |
640 | mScrollUpTimer.start(mScrollDelay); | 640 | mScrollUpTimer.start(mScrollDelay); |
641 | } else if (visibleHeight() - clipperPos.y() < | 641 | } else if (visibleHeight() - clipperPos.y() < |
642 | mScrollBorderWidth) { | 642 | mScrollBorderWidth) { |
643 | mScrollDownTimer.start(mScrollDelay); | 643 | mScrollDownTimer.start(mScrollDelay); |
644 | } else { | 644 | } else { |
645 | mScrollUpTimer.stop(); | 645 | mScrollUpTimer.stop(); |
646 | mScrollDownTimer.stop(); | 646 | mScrollDownTimer.stop(); |
647 | } | 647 | } |
648 | 648 | ||
649 | if ( gy > mCurrentCellY ) { | 649 | if ( gy > mCurrentCellY ) { |
650 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 650 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
651 | 651 | ||
652 | #if 0 | 652 | #if 0 |
653 | // FIXME: Repaint only the newly selected region | 653 | // FIXME: Repaint only the newly selected region |
654 | repaintContents( mSelectionCellX * mGridSpacingX, | 654 | repaintContents( mSelectionCellX * mGridSpacingX, |
655 | mCurrentCellY + mGridSpacingY, | 655 | mCurrentCellY + mGridSpacingY, |
656 | mGridSpacingX, | 656 | mGridSpacingX, |
657 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); | 657 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); |
658 | #else | 658 | #else |
659 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 659 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
660 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 660 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
661 | mGridSpacingX, mSelectionYTop, | 661 | mGridSpacingX, mSelectionYTop, |
662 | mGridSpacingX, mSelectionHeight , false); | 662 | mGridSpacingX, mSelectionHeight , false); |
663 | #endif | 663 | #endif |
664 | 664 | ||
665 | mCurrentCellY = gy; | 665 | mCurrentCellY = gy; |
666 | } else if ( gy < mCurrentCellY ) { | 666 | } else if ( gy < mCurrentCellY ) { |
667 | if ( gy >= mStartCellY ) { | 667 | if ( gy >= mStartCellY ) { |
668 | int selectionHeight = mSelectionHeight; | 668 | int selectionHeight = mSelectionHeight; |
669 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 669 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
670 | 670 | ||
671 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 671 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
672 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 672 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
673 | mGridSpacingX, mSelectionYTop, | 673 | mGridSpacingX, mSelectionYTop, |
674 | mGridSpacingX, selectionHeight,false ); | 674 | mGridSpacingX, selectionHeight,false ); |
675 | 675 | ||
676 | mCurrentCellY = gy; | 676 | mCurrentCellY = gy; |
677 | } else { | 677 | } else { |
678 | } | 678 | } |
679 | } | 679 | } |
680 | } | 680 | } |
681 | 681 | ||
682 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 682 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
683 | { | 683 | { |
684 | mActionType = NOP; | 684 | mActionType = NOP; |
685 | mScrollUpTimer.stop(); | 685 | mScrollUpTimer.stop(); |
686 | mScrollDownTimer.stop(); | 686 | mScrollDownTimer.stop(); |
687 | 687 | ||
688 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 688 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
689 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) | 689 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) |
690 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 690 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
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 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 | 1102 | // Adjust sub cell geometry of all conflict items of all conflict items | |
1103 | for ( item=conflictItems.first(); item != 0; | ||
1104 | item=conflictItems.next() ) { | ||
1105 | if ( placeItem != item ) { | ||
1106 | KOAgendaItem *item2; | ||
1107 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | ||
1108 | for ( item2=conflictItems2.first(); item2 != 0; | ||
1109 | item2=conflictItems2.next() ) { | ||
1110 | if ( item2->subCells() != maxSubCells) { | ||
1111 | item2->setSubCells(maxSubCells); | ||
1112 | if (mAllDayMode) { | ||
1113 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | ||
1114 | } else { | ||
1115 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | ||
1116 | } | ||
1117 | int x,y; | ||
1118 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | ||
1119 | if (mAllDayMode) { | ||
1120 | y += item2->subCell() * newSubCellWidth; | ||
1121 | } else { | ||
1122 | x += item2->subCell() * newSubCellWidth; | ||
1123 | } | ||
1124 | moveChild(item2,x,y); | ||
1125 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | ||
1126 | } | ||
1127 | } | ||
1128 | } | ||
1129 | } | ||
1103 | } else { | 1130 | } else { |
1104 | placeItem->setSubCell(0); | 1131 | placeItem->setSubCell(0); |
1105 | placeItem->setSubCells(1); | 1132 | placeItem->setSubCells(1); |
1106 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1133 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1107 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1134 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1108 | int x,y; | 1135 | int x,y; |
1109 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1136 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1110 | moveChild(placeItem,x,y); | 1137 | moveChild(placeItem,x,y); |
1111 | } | 1138 | } |
1112 | placeItem->setConflictItems(conflictItems); | 1139 | placeItem->setConflictItems(conflictItems); |
1113 | // for ( item=conflictItems.first(); item != 0; | 1140 | // for ( item=conflictItems.first(); item != 0; |
1114 | // item=conflictItems.next() ) { | 1141 | // item=conflictItems.next() ) { |
1115 | // //item->updateItem(); | 1142 | // //item->updateItem(); |
1116 | // //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() ); |
1117 | // } | 1144 | // } |
1118 | // placeItem->updateItem(); | 1145 | // placeItem->updateItem(); |
1119 | } | 1146 | } |
1120 | 1147 | ||
1121 | 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) |
1122 | { | 1149 | { |
1123 | if ( globalFlagBlockAgenda ) | 1150 | if ( globalFlagBlockAgenda ) |
1124 | return; | 1151 | return; |
1125 | //qDebug("KOAgenda::drawContents "); | 1152 | //qDebug("KOAgenda::drawContents "); |
1126 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1153 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1127 | ;//drawContentsToPainter(); | 1154 | ;//drawContentsToPainter(); |
1128 | 1155 | ||
1129 | QPaintDevice* pd = p->device(); | 1156 | QPaintDevice* pd = p->device(); |
1130 | p->end(); | 1157 | p->end(); |
1131 | int vx, vy; | 1158 | int vx, vy; |
1132 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1159 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1133 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1160 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1134 | mSelectionCellX * mGridSpacingX; | 1161 | mSelectionCellX * mGridSpacingX; |
1135 | contentsToViewport ( cx, cy, vx,vy); | 1162 | contentsToViewport ( cx, cy, vx,vy); |
1136 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1163 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1137 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1164 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1138 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1165 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1139 | 1166 | ||
1140 | if ( mSelectionHeight > 0 ) { | 1167 | if ( mSelectionHeight > 0 ) { |
1141 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1168 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1142 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1169 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1143 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1170 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1144 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1171 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1145 | 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); |
1146 | } | 1173 | } |
1147 | } | 1174 | } |
1148 | //qDebug("btbl "); | 1175 | //qDebug("btbl "); |
1149 | p->begin( pd ); | 1176 | p->begin( pd ); |
1150 | //qDebug("end "); | 1177 | //qDebug("end "); |
1151 | } | 1178 | } |
1152 | 1179 | ||
1153 | void KOAgenda::finishUpdate() | 1180 | void KOAgenda::finishUpdate() |
1154 | { | 1181 | { |
1155 | 1182 | ||
1156 | KOAgendaItem *item; | 1183 | KOAgendaItem *item; |
1157 | globalFlagBlockAgendaItemPaint = 1; | 1184 | globalFlagBlockAgendaItemPaint = 1; |
1158 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1185 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1159 | if ( !item->isVisible() ) | 1186 | if ( !item->isVisible() ) |
1160 | item->show(); | 1187 | item->show(); |
1161 | 1188 | ||
1162 | } | 1189 | } |
1163 | globalFlagBlockAgendaItemUpdate = 0; | 1190 | globalFlagBlockAgendaItemUpdate = 0; |
1164 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1191 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1165 | item->repaintMe( ); | 1192 | item->repaintMe( ); |
1166 | } | 1193 | } |
1167 | globalFlagBlockAgendaItemUpdate = 1; | 1194 | globalFlagBlockAgendaItemUpdate = 1; |
1168 | qApp->processEvents(); | 1195 | qApp->processEvents(); |
1169 | globalFlagBlockAgendaItemPaint = 0; | 1196 | globalFlagBlockAgendaItemPaint = 0; |
1170 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1197 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1171 | item->repaint( false ); | 1198 | item->repaint( false ); |
1172 | } | 1199 | } |
1173 | 1200 | ||
1174 | } | 1201 | } |
1175 | 1202 | ||
1176 | /* | 1203 | /* |
1177 | Draw grid in the background of the agenda. | 1204 | Draw grid in the background of the agenda. |
1178 | */ | 1205 | */ |
1179 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1206 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1180 | { | 1207 | { |
1181 | 1208 | ||
1182 | 1209 | ||
1183 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1210 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1184 | return; | 1211 | return; |
1185 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1212 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1186 | return; | 1213 | return; |
1187 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1214 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1188 | if ( ch < 1 ) | 1215 | if ( ch < 1 ) |
1189 | ch = 1; | 1216 | ch = 1; |
1190 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1217 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1191 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1218 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1192 | } | 1219 | } |
1193 | mCurPixWid = contentsWidth(); | 1220 | mCurPixWid = contentsWidth(); |
1194 | mCurPixHei = ch; | 1221 | mCurPixHei = ch; |
1195 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1222 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1196 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1223 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1197 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1224 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1198 | } | 1225 | } |
1199 | mPixPainter.begin( &mPaintPixmap) ; | 1226 | mPixPainter.begin( &mPaintPixmap) ; |
1200 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1227 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1201 | QPainter * p ; | 1228 | QPainter * p ; |
1202 | if (paint == 0) { | 1229 | if (paint == 0) { |
1203 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1230 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1204 | p = &mPixPainter; | 1231 | p = &mPixPainter; |
1205 | } | 1232 | } |
1206 | else | 1233 | else |
1207 | p = paint ; | 1234 | p = paint ; |
1208 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1235 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1209 | 1236 | ||
1210 | //--cx;++cw; | 1237 | //--cx;++cw; |
1211 | int lGridSpacingY = mGridSpacingY*2; | 1238 | int lGridSpacingY = mGridSpacingY*2; |
1212 | int selDay; | 1239 | int selDay; |
1213 | if ( !backgroundOnly ) | 1240 | if ( !backgroundOnly ) |
1214 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1241 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1215 | { | 1242 | { |
1216 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1243 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1217 | int x1 = cx; | 1244 | int x1 = cx; |
1218 | int y1 = 0; | 1245 | int y1 = 0; |
1219 | if (y1 < cy) y1 = cy; | 1246 | if (y1 < cy) y1 = cy; |
1220 | int x2 = cx+cw-1; | 1247 | int x2 = cx+cw-1; |
1221 | int y2 = contentsHeight(); | 1248 | int y2 = contentsHeight(); |
1222 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1249 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1223 | if (x2 >= x1 && y2 >= y1) { | 1250 | if (x2 >= x1 && y2 >= y1) { |
1224 | int gxStart = selDay; | 1251 | int gxStart = selDay; |
1225 | int gxEnd = gxStart ; | 1252 | int gxEnd = gxStart ; |
1226 | int xStart = KOGlobals::self()->reverseLayout() ? | 1253 | int xStart = KOGlobals::self()->reverseLayout() ? |
1227 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1254 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1228 | gxStart*mGridSpacingX; | 1255 | gxStart*mGridSpacingX; |
1229 | if (xStart < x1) xStart = x1; | 1256 | if (xStart < x1) xStart = x1; |
1230 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1257 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1231 | (mColumns - gxStart)*mGridSpacingX-1 : | 1258 | (mColumns - gxStart)*mGridSpacingX-1 : |
1232 | (gxStart+1)*mGridSpacingX-1; | 1259 | (gxStart+1)*mGridSpacingX-1; |
1233 | if (xEnd > x2) xEnd = x2; | 1260 | if (xEnd > x2) xEnd = x2; |
1234 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1261 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1235 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1262 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1236 | KOPrefs::instance()->mAgendaBgColor.light()); | 1263 | KOPrefs::instance()->mAgendaBgColor.light()); |
1237 | else | 1264 | else |
1238 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1265 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1239 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1266 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1240 | 1267 | ||
1241 | } | 1268 | } |
1242 | } | 1269 | } |
1243 | } | 1270 | } |
1244 | // Highlight working hours | 1271 | // Highlight working hours |
1245 | 1272 | ||
1246 | if ( !backgroundOnly ) | 1273 | if ( !backgroundOnly ) |
1247 | if (mWorkingHoursEnable) { | 1274 | if (mWorkingHoursEnable) { |
1248 | int x1 = cx; | 1275 | int x1 = cx; |
1249 | int y1 = mWorkingHoursYTop; | 1276 | int y1 = mWorkingHoursYTop; |
1250 | if (y1 < cy) y1 = cy; | 1277 | if (y1 < cy) y1 = cy; |
1251 | int x2 = cx+cw-1; | 1278 | int x2 = cx+cw-1; |
1252 | // int x2 = mGridSpacingX * 5 - 1; | 1279 | // int x2 = mGridSpacingX * 5 - 1; |
1253 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1280 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1254 | int y2 = mWorkingHoursYBottom; | 1281 | int y2 = mWorkingHoursYBottom; |
1255 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1282 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1256 | 1283 | ||
1257 | if (x2 >= x1 && y2 >= y1) { | 1284 | if (x2 >= x1 && y2 >= y1) { |
1258 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1285 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1259 | int gxStart = x1/mGridSpacingX; | 1286 | int gxStart = x1/mGridSpacingX; |
1260 | int gxEnd = x2/mGridSpacingX; | 1287 | int gxEnd = x2/mGridSpacingX; |
1261 | while(gxStart <= gxEnd) { | 1288 | while(gxStart <= gxEnd) { |
1262 | if (gxStart < int(mHolidayMask->count()) && | 1289 | if (gxStart < int(mHolidayMask->count()) && |
1263 | !mHolidayMask->at(gxStart)) { | 1290 | !mHolidayMask->at(gxStart)) { |
1264 | int xStart = KOGlobals::self()->reverseLayout() ? | 1291 | int xStart = KOGlobals::self()->reverseLayout() ? |
1265 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1292 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1266 | gxStart*mGridSpacingX; | 1293 | gxStart*mGridSpacingX; |
1267 | if (xStart < x1) xStart = x1; | 1294 | if (xStart < x1) xStart = x1; |
1268 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1295 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1269 | (mColumns - gxStart)*mGridSpacingX-1 : | 1296 | (mColumns - gxStart)*mGridSpacingX-1 : |
1270 | (gxStart+1)*mGridSpacingX-1; | 1297 | (gxStart+1)*mGridSpacingX-1; |
1271 | if (xEnd > x2) xEnd = x2; | 1298 | if (xEnd > x2) xEnd = x2; |
1272 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1299 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { |
1273 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1300 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1274 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1301 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1275 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1302 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1276 | else | 1303 | else |
1277 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1304 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1278 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1305 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1279 | } else { | 1306 | } else { |
1280 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1307 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1281 | KOPrefs::instance()->mWorkingHoursColor); | 1308 | KOPrefs::instance()->mWorkingHoursColor); |
1282 | } | 1309 | } |
1283 | } | 1310 | } |
1284 | ++gxStart; | 1311 | ++gxStart; |
1285 | } | 1312 | } |
1286 | } | 1313 | } |
1287 | } | 1314 | } |
1288 | /* | 1315 | /* |
1289 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1316 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1290 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1317 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1291 | mSelectionCellX * mGridSpacingX; | 1318 | mSelectionCellX * mGridSpacingX; |
1292 | 1319 | ||
1293 | // Draw selection | 1320 | // Draw selection |
1294 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1295 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1296 | // TODO: paint only part within cx,cy,cw,ch | 1323 | // TODO: paint only part within cx,cy,cw,ch |
1297 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1324 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1298 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1325 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1299 | } | 1326 | } |
1300 | */ | 1327 | */ |
1301 | // Draw vertical lines of grid | 1328 | // Draw vertical lines of grid |
1302 | 1329 | ||
1303 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1330 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1304 | if ( mGridSpacingX > 0 ) { | 1331 | if ( mGridSpacingX > 0 ) { |
1305 | while (x < cx + cw) { | 1332 | while (x < cx + cw) { |
1306 | p->drawLine(x,cy,x,cy+ch); | 1333 | p->drawLine(x,cy,x,cy+ch); |
1307 | x+=mGridSpacingX; | 1334 | x+=mGridSpacingX; |
1308 | } | 1335 | } |
1309 | } | 1336 | } |
1310 | // Draw horizontal lines of grid | 1337 | // Draw horizontal lines of grid |
1311 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1338 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1312 | if ( lGridSpacingY > 0 ) { | 1339 | if ( lGridSpacingY > 0 ) { |
1313 | while (y < cy + ch) { | 1340 | while (y < cy + ch) { |
1314 | p->setPen( SolidLine ); | 1341 | p->setPen( SolidLine ); |
1315 | p->drawLine(cx,y,cx+cw,y); | 1342 | p->drawLine(cx,y,cx+cw,y); |
1316 | y+=lGridSpacingY; | 1343 | y+=lGridSpacingY; |
1317 | p->setPen( DotLine ); | 1344 | p->setPen( DotLine ); |
1318 | p->drawLine(cx,y,cx+cw,y); | 1345 | p->drawLine(cx,y,cx+cw,y); |
1319 | y+=lGridSpacingY; | 1346 | y+=lGridSpacingY; |
1320 | } | 1347 | } |
1321 | p->setPen( SolidLine ); | 1348 | p->setPen( SolidLine ); |
1322 | } | 1349 | } |
1323 | mPixPainter.end() ; | 1350 | mPixPainter.end() ; |
1324 | } | 1351 | } |
1325 | 1352 | ||
1326 | /* | 1353 | /* |
1327 | Convert srcollview contents coordinates to agenda grid coordinates. | 1354 | Convert srcollview contents coordinates to agenda grid coordinates. |
1328 | */ | 1355 | */ |
1329 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1356 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1330 | { | 1357 | { |
1331 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1358 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1332 | x/mGridSpacingX; | 1359 | x/mGridSpacingX; |
1333 | gy = y/mGridSpacingY; | 1360 | gy = y/mGridSpacingY; |
1334 | } | 1361 | } |
1335 | 1362 | ||
1336 | /* | 1363 | /* |
1337 | Convert agenda grid coordinates to scrollview contents coordinates. | 1364 | Convert agenda grid coordinates to scrollview contents coordinates. |
1338 | */ | 1365 | */ |
1339 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1366 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1340 | { | 1367 | { |
1341 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1368 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1342 | gx*mGridSpacingX; | 1369 | gx*mGridSpacingX; |
1343 | y = gy*mGridSpacingY; | 1370 | y = gy*mGridSpacingY; |
1344 | } | 1371 | } |
1345 | 1372 | ||
1346 | 1373 | ||
1347 | /* | 1374 | /* |
1348 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1375 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1349 | the grid. | 1376 | the grid. |
1350 | */ | 1377 | */ |
1351 | int KOAgenda::timeToY(const QTime &time) | 1378 | int KOAgenda::timeToY(const QTime &time) |
1352 | { | 1379 | { |
1353 | int minutesPerCell = 24 * 60 / mRows; | 1380 | int minutesPerCell = 24 * 60 / mRows; |
1354 | int timeMinutes = time.hour() * 60 + time.minute(); | 1381 | int timeMinutes = time.hour() * 60 + time.minute(); |
1355 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1382 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1356 | return Y; | 1383 | return Y; |
1357 | } | 1384 | } |
1358 | 1385 | ||
1359 | 1386 | ||
1360 | /* | 1387 | /* |
1361 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1388 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1362 | fit into the grid. | 1389 | fit into the grid. |
1363 | */ | 1390 | */ |
1364 | QTime KOAgenda::gyToTime(int gy) | 1391 | QTime KOAgenda::gyToTime(int gy) |
1365 | { | 1392 | { |
1366 | 1393 | ||
1367 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1394 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1368 | 1395 | ||
1369 | int timeSeconds = secondsPerCell * gy; | 1396 | int timeSeconds = secondsPerCell * gy; |
1370 | 1397 | ||
1371 | QTime time( 0, 0, 0 ); | 1398 | QTime time( 0, 0, 0 ); |
1372 | if ( timeSeconds < 24 * 60 * 60 ) { | 1399 | if ( timeSeconds < 24 * 60 * 60 ) { |
1373 | time = time.addSecs(timeSeconds); | 1400 | time = time.addSecs(timeSeconds); |
1374 | } else { | 1401 | } else { |
1375 | time.setHMS( 23, 59, 59 ); | 1402 | time.setHMS( 23, 59, 59 ); |
1376 | } | 1403 | } |
1377 | 1404 | ||
1378 | return time; | 1405 | return time; |
1379 | } | 1406 | } |
1380 | 1407 | ||
1381 | void KOAgenda::setStartHour(int startHour) | 1408 | void KOAgenda::setStartHour(int startHour) |
1382 | { | 1409 | { |
1383 | int startCell = startHour * mRows / 24; | 1410 | int startCell = startHour * mRows / 24; |
1384 | setContentsPos(0,startCell * gridSpacingY()); | 1411 | setContentsPos(0,startCell * gridSpacingY()); |
1385 | } | 1412 | } |
1386 | void KOAgenda::hideUnused() | 1413 | void KOAgenda::hideUnused() |
1387 | { | 1414 | { |
1388 | // experimental only | 1415 | // experimental only |
1389 | // return; | 1416 | // return; |
1390 | KOAgendaItem *item; | 1417 | KOAgendaItem *item; |
1391 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1418 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1392 | item->hide(); | 1419 | item->hide(); |
1393 | } | 1420 | } |
1394 | } | 1421 | } |
1395 | 1422 | ||
1396 | 1423 | ||
1397 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1424 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1398 | { | 1425 | { |
1399 | 1426 | ||
1400 | KOAgendaItem *fi; | 1427 | KOAgendaItem *fi; |
1401 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1428 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1402 | if ( fi->incidence() == event ) { | 1429 | if ( fi->incidence() == event ) { |
1403 | mUnusedItems.remove(); | 1430 | mUnusedItems.remove(); |
1404 | fi->init( event, qd ); | 1431 | fi->init( event, qd ); |
1405 | return fi; | 1432 | return fi; |
1406 | } | 1433 | } |
1407 | } | 1434 | } |
1408 | fi=mUnusedItems.first(); | 1435 | fi=mUnusedItems.first(); |
1409 | if ( fi ) { | 1436 | if ( fi ) { |
1410 | mUnusedItems.remove(); | 1437 | mUnusedItems.remove(); |
1411 | fi->init( event, qd ); | 1438 | fi->init( event, qd ); |
1412 | return fi; | 1439 | return fi; |
1413 | } | 1440 | } |
1414 | // qDebug("new KOAgendaItem "); | 1441 | // qDebug("new KOAgendaItem "); |
1415 | 1442 | ||
1416 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1443 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1417 | agendaItem->installEventFilter(this); | 1444 | agendaItem->installEventFilter(this); |
1418 | addChild(agendaItem,0,0); | 1445 | addChild(agendaItem,0,0); |
1419 | return agendaItem; | 1446 | return agendaItem; |
1420 | } | 1447 | } |
1421 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1448 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1422 | { | 1449 | { |
1423 | KOAgendaItem *item; | 1450 | KOAgendaItem *item; |
1424 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1451 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1425 | if ( item->incidence() == todo ) { | 1452 | if ( item->incidence() == todo ) { |
1426 | mItems.remove(); | 1453 | mItems.remove(); |
1427 | return item; | 1454 | return item; |
1428 | } | 1455 | } |
1429 | } | 1456 | } |
1430 | return 0; | 1457 | return 0; |
1431 | } | 1458 | } |
1432 | 1459 | ||
1433 | 1460 | ||
1434 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1461 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1435 | { | 1462 | { |
1436 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1463 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1437 | KOAgendaItem *item; | 1464 | KOAgendaItem *item; |
1438 | item = getItemForTodo ( todo ); | 1465 | item = getItemForTodo ( todo ); |
1439 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1466 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1440 | if ( item ) { | 1467 | if ( item ) { |
1441 | blockSignals( true ); | 1468 | blockSignals( true ); |
1442 | //qDebug("item found "); | 1469 | //qDebug("item found "); |
1443 | item->hide(); | 1470 | item->hide(); |
1444 | item->setCellX(-2, -1 ); | 1471 | item->setCellX(-2, -1 ); |
1445 | item->select(false); | 1472 | item->select(false); |
1446 | mUnusedItems.append( item ); | 1473 | mUnusedItems.append( item ); |
1447 | mItems.remove( item ); | 1474 | mItems.remove( item ); |
1448 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1475 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1449 | KOAgendaItem *itemit; | 1476 | KOAgendaItem *itemit; |
1450 | //globalFlagBlockAgendaItemPaint = 1; | 1477 | //globalFlagBlockAgendaItemPaint = 1; |
1451 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1478 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1452 | itemit=oldconflictItems.next() ) { | 1479 | itemit=oldconflictItems.next() ) { |
1453 | if ( itemit != item ) | 1480 | if ( itemit != item ) |
1454 | placeSubCells(itemit); | 1481 | placeSubCells(itemit); |
1455 | } | 1482 | } |
1456 | qApp->processEvents(); | 1483 | qApp->processEvents(); |
1457 | //globalFlagBlockAgendaItemPaint = 0; | 1484 | //globalFlagBlockAgendaItemPaint = 0; |
1458 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1485 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1459 | itemit=oldconflictItems.next() ) { | 1486 | itemit=oldconflictItems.next() ) { |
1460 | globalFlagBlockAgendaItemUpdate = 0; | 1487 | globalFlagBlockAgendaItemUpdate = 0; |
1461 | if ( itemit != item ) | 1488 | if ( itemit != item ) |
1462 | itemit->repaintMe(); | 1489 | itemit->repaintMe(); |
1463 | globalFlagBlockAgendaItemUpdate = 1; | 1490 | globalFlagBlockAgendaItemUpdate = 1; |
1464 | itemit->repaint(); | 1491 | itemit->repaint(); |
1465 | } | 1492 | } |
1466 | blockSignals( false ); | 1493 | blockSignals( false ); |
1467 | } | 1494 | } |
1468 | if ( remove ) { | 1495 | if ( remove ) { |
1469 | //qDebug("remove****************************************** "); | 1496 | //qDebug("remove****************************************** "); |
1470 | return; | 1497 | return; |
1471 | } | 1498 | } |
1472 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1499 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1473 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1500 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1474 | QDate currentDate; | 1501 | QDate currentDate; |
1475 | QDateTime dt; | 1502 | QDateTime dt; |
1476 | if ( todo->hasCompletedDate() ) | 1503 | if ( todo->hasCompletedDate() ) |
1477 | dt = todo->completed(); | 1504 | dt = todo->completed(); |
1478 | else | 1505 | else |
1479 | dt = todo->dtDue(); | 1506 | dt = todo->dtDue(); |
1480 | if ( overdue ) { | 1507 | if ( overdue ) { |
1481 | currentDate = QDate::currentDate(); | 1508 | currentDate = QDate::currentDate(); |
1482 | days += todo->dtDue().date().daysTo( currentDate ); | 1509 | days += todo->dtDue().date().daysTo( currentDate ); |
1483 | } | 1510 | } |
1484 | else | 1511 | else |
1485 | currentDate = dt.date(); | 1512 | currentDate = dt.date(); |
1486 | 1513 | ||
1487 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1514 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1488 | if ( ! mAllDayMode ) return; | 1515 | if ( ! mAllDayMode ) return; |
1489 | // aldayagenda | 1516 | // aldayagenda |
1490 | globalFlagBlockAgendaItemPaint = 1; | 1517 | globalFlagBlockAgendaItemPaint = 1; |
1491 | item = insertAllDayItem(todo, currentDate,days, days); | 1518 | item = insertAllDayItem(todo, currentDate,days, days); |
1492 | item->show(); | 1519 | item->show(); |
1493 | 1520 | ||
1494 | } | 1521 | } |
1495 | else { | 1522 | else { |
1496 | if ( mAllDayMode ) return; | 1523 | if ( mAllDayMode ) return; |
1497 | // mAgenda | 1524 | // mAgenda |
1498 | globalFlagBlockAgendaItemPaint = 1; | 1525 | globalFlagBlockAgendaItemPaint = 1; |
1499 | int endY = timeToY(dt.time()) - 1; | 1526 | int endY = timeToY(dt.time()) - 1; |
1500 | int hi = 12/KOPrefs::instance()->mHourSize; | 1527 | int hi = 12/KOPrefs::instance()->mHourSize; |
1501 | int startY = endY - 1-hi; | 1528 | int startY = endY - 1-hi; |
1502 | item = insertItem(todo,currentDate,days,startY,endY); | 1529 | item = insertItem(todo,currentDate,days,startY,endY); |
1503 | item->show(); | 1530 | item->show(); |
1504 | } | 1531 | } |
1505 | qApp->processEvents(); | 1532 | qApp->processEvents(); |
1506 | globalFlagBlockAgendaItemPaint = 0; | 1533 | globalFlagBlockAgendaItemPaint = 0; |
1507 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1534 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1508 | KOAgendaItem *itemit; | 1535 | KOAgendaItem *itemit; |
1509 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1536 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1510 | itemit=oldconflictItems.next() ) { | 1537 | itemit=oldconflictItems.next() ) { |
1511 | globalFlagBlockAgendaItemUpdate = 0; | 1538 | globalFlagBlockAgendaItemUpdate = 0; |
1512 | itemit->repaintMe(); | 1539 | itemit->repaintMe(); |
1513 | globalFlagBlockAgendaItemUpdate = 1; | 1540 | globalFlagBlockAgendaItemUpdate = 1; |
1514 | itemit->repaint(); | 1541 | itemit->repaint(); |
1515 | } | 1542 | } |
1516 | globalFlagBlockAgendaItemUpdate = 0; | 1543 | globalFlagBlockAgendaItemUpdate = 0; |
1517 | item->repaintMe(); | 1544 | item->repaintMe(); |
1518 | globalFlagBlockAgendaItemUpdate = 1; | 1545 | globalFlagBlockAgendaItemUpdate = 1; |
1519 | item->repaint(); | 1546 | item->repaint(); |
1520 | } | 1547 | } |
1521 | /* | 1548 | /* |
1522 | Insert KOAgendaItem into agenda. | 1549 | Insert KOAgendaItem into agenda. |
1523 | */ | 1550 | */ |
1524 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1551 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1525 | { | 1552 | { |
1526 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; | 1553 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; |
1527 | 1554 | ||
1528 | if (mAllDayMode) { | 1555 | if (mAllDayMode) { |
1529 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; | 1556 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; |
1530 | return 0; | 1557 | return 0; |
1531 | } | 1558 | } |
1532 | 1559 | ||
1533 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1560 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1534 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1561 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1535 | 1562 | ||
1536 | int YSize = YBottom - YTop + 1; | 1563 | int YSize = YBottom - YTop + 1; |
1537 | if (YSize < 0) { | 1564 | if (YSize < 0) { |
1538 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; | 1565 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; |
1539 | YSize = 1; | 1566 | YSize = 1; |
1540 | } | 1567 | } |
1541 | int iheight = mGridSpacingY * YSize; | 1568 | int iheight = mGridSpacingY * YSize; |
1542 | 1569 | ||
1543 | agendaItem->resize(mGridSpacingX,iheight ); | 1570 | agendaItem->resize(mGridSpacingX,iheight ); |
1544 | agendaItem->setCellXY(X,YTop,YBottom); | 1571 | agendaItem->setCellXY(X,YTop,YBottom); |
1545 | agendaItem->setCellXWidth(X); | 1572 | agendaItem->setCellXWidth(X); |
1546 | 1573 | ||
1547 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1574 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1548 | mItems.append(agendaItem); | 1575 | mItems.append(agendaItem); |
1549 | 1576 | ||
1550 | placeSubCells(agendaItem); | 1577 | placeSubCells(agendaItem); |
1551 | 1578 | ||
1552 | //agendaItem->show(); | 1579 | //agendaItem->show(); |
1553 | 1580 | ||
1554 | marcus_bains(); | 1581 | marcus_bains(); |
1555 | 1582 | ||
1556 | return agendaItem; | 1583 | return agendaItem; |
1557 | } | 1584 | } |
1558 | 1585 | ||
1559 | 1586 | ||
1560 | /* | 1587 | /* |
1561 | Insert all-day KOAgendaItem into agenda. | 1588 | Insert all-day KOAgendaItem into agenda. |
1562 | */ | 1589 | */ |
1563 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1590 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1564 | { | 1591 | { |
1565 | if (!mAllDayMode) { | 1592 | if (!mAllDayMode) { |
1566 | return 0; | 1593 | return 0; |
1567 | } | 1594 | } |
1568 | 1595 | ||
1569 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1596 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1570 | 1597 | ||
1571 | agendaItem->setCellXY(XBegin,0,0); | 1598 | agendaItem->setCellXY(XBegin,0,0); |
1572 | agendaItem->setCellXWidth(XEnd); | 1599 | agendaItem->setCellXWidth(XEnd); |
1573 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1600 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1574 | 1601 | ||
1575 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1602 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1576 | mItems.append(agendaItem); | 1603 | mItems.append(agendaItem); |
1577 | 1604 | ||
1578 | placeSubCells(agendaItem); | 1605 | placeSubCells(agendaItem); |
1579 | 1606 | ||
1580 | //agendaItem->show(); | 1607 | //agendaItem->show(); |
1581 | 1608 | ||
1582 | return agendaItem; | 1609 | return agendaItem; |
1583 | } | 1610 | } |
1584 | 1611 | ||
1585 | 1612 | ||
1586 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1613 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1587 | int YTop,int YBottom) | 1614 | int YTop,int YBottom) |
1588 | { | 1615 | { |
1589 | if (mAllDayMode) { | 1616 | if (mAllDayMode) { |
1590 | ; | 1617 | ; |
1591 | return; | 1618 | return; |
1592 | } | 1619 | } |
1593 | 1620 | ||
1594 | int cellX,cellYTop,cellYBottom; | 1621 | int cellX,cellYTop,cellYBottom; |
1595 | QString newtext; | 1622 | QString newtext; |
1596 | int width = XEnd - XBegin + 1; | 1623 | int width = XEnd - XBegin + 1; |
1597 | int count = 0; | 1624 | int count = 0; |
1598 | KOAgendaItem *current = 0; | 1625 | KOAgendaItem *current = 0; |
1599 | QPtrList<KOAgendaItem> multiItems; | 1626 | QPtrList<KOAgendaItem> multiItems; |
1600 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1627 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1601 | if (cellX == XBegin) cellYTop = YTop; | 1628 | if (cellX == XBegin) cellYTop = YTop; |
1602 | else cellYTop = 0; | 1629 | else cellYTop = 0; |
1603 | if (cellX == XEnd) cellYBottom = YBottom; | 1630 | if (cellX == XEnd) cellYBottom = YBottom; |
1604 | else cellYBottom = rows() - 1; | 1631 | else cellYBottom = rows() - 1; |
1605 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1632 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1606 | newtext.append(event->summary()); | 1633 | newtext.append(event->summary()); |
1607 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1634 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1608 | current->setText(newtext); | 1635 | current->setText(newtext); |
1609 | multiItems.append(current); | 1636 | multiItems.append(current); |
1610 | } | 1637 | } |
1611 | 1638 | ||
1612 | KOAgendaItem *next = 0; | 1639 | KOAgendaItem *next = 0; |
1613 | KOAgendaItem *last = multiItems.last(); | 1640 | KOAgendaItem *last = multiItems.last(); |
1614 | KOAgendaItem *first = multiItems.first(); | 1641 | KOAgendaItem *first = multiItems.first(); |
1615 | KOAgendaItem *setFirst,*setLast; | 1642 | KOAgendaItem *setFirst,*setLast; |
1616 | current = first; | 1643 | current = first; |
1617 | while (current) { | 1644 | while (current) { |
1618 | next = multiItems.next(); | 1645 | next = multiItems.next(); |
1619 | if (current == first) setFirst = 0; | 1646 | if (current == first) setFirst = 0; |
1620 | else setFirst = first; | 1647 | else setFirst = first; |
1621 | if (current == last) setLast = 0; | 1648 | if (current == last) setLast = 0; |
1622 | else setLast = last; | 1649 | else setLast = last; |
1623 | 1650 | ||
1624 | current->setMultiItem(setFirst,next,setLast); | 1651 | current->setMultiItem(setFirst,next,setLast); |
1625 | current = next; | 1652 | current = next; |
1626 | } | 1653 | } |
1627 | 1654 | ||
1628 | marcus_bains(); | 1655 | marcus_bains(); |
1629 | } | 1656 | } |
1630 | 1657 | ||
1631 | 1658 | ||
1632 | //QSizePolicy KOAgenda::sizePolicy() const | 1659 | //QSizePolicy KOAgenda::sizePolicy() const |
1633 | //{ | 1660 | //{ |
1634 | // Thought this would make the all-day event agenda minimum size and the | 1661 | // Thought this would make the all-day event agenda minimum size and the |
1635 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1662 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1636 | // don´t seem to think that an Expanding widget needs more space than a | 1663 | // don´t seem to think that an Expanding widget needs more space than a |
1637 | // Preferred one. | 1664 | // Preferred one. |
1638 | // But it doesn´t hurt, so it stays. | 1665 | // But it doesn´t hurt, so it stays. |
1639 | // if (mAllDayMode) { | 1666 | // if (mAllDayMode) { |
1640 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1667 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1641 | // } else { | 1668 | // } else { |
1642 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1669 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1643 | // } | 1670 | // } |
1644 | //} | 1671 | //} |
1645 | void KOAgenda::finishResize ( ) | 1672 | void KOAgenda::finishResize ( ) |
1646 | { | 1673 | { |
1647 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1674 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1648 | if ( globalFlagBlockAgenda == 0 ) { | 1675 | if ( globalFlagBlockAgenda == 0 ) { |
1649 | finishUpdate(); | 1676 | finishUpdate(); |
1650 | //qDebug("finishUpdate() called "); | 1677 | //qDebug("finishUpdate() called "); |
1651 | } | 1678 | } |
1652 | } | 1679 | } |
1653 | /* | 1680 | /* |
1654 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1681 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1655 | */ | 1682 | */ |
1656 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1683 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1657 | { | 1684 | { |
1658 | 1685 | ||
1659 | mResizeTimer.start( 150 , true ); | 1686 | mResizeTimer.start( 150 , true ); |
1660 | computeSizes(); | 1687 | computeSizes(); |
1661 | return; | 1688 | return; |
1662 | 1689 | ||
1663 | } | 1690 | } |
1664 | void KOAgenda::computeSizes() | 1691 | void KOAgenda::computeSizes() |
1665 | { | 1692 | { |
1666 | if ( globalFlagBlockStartup ) | 1693 | if ( globalFlagBlockStartup ) |
1667 | return; | 1694 | return; |
1668 | 1695 | ||
1669 | if (mAllDayMode) { | 1696 | if (mAllDayMode) { |
1670 | mGridSpacingX = (width()-3) / mColumns; | 1697 | mGridSpacingX = (width()-3) / mColumns; |
1671 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1698 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1672 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1699 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1673 | // mGridSpacingY = height(); | 1700 | // mGridSpacingY = height(); |
1674 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1701 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1675 | 1702 | ||
1676 | KOAgendaItem *item; | 1703 | KOAgendaItem *item; |
1677 | int subCellWidth; | 1704 | int subCellWidth; |
1678 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1705 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1679 | subCellWidth = mGridSpacingY / item->subCells(); | 1706 | subCellWidth = mGridSpacingY / item->subCells(); |
1680 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1707 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1681 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1708 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1682 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1709 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1683 | item->cellX() * mGridSpacingX, | 1710 | item->cellX() * mGridSpacingX, |
1684 | item->subCell() * subCellWidth); | 1711 | item->subCell() * subCellWidth); |
1685 | } | 1712 | } |
1686 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1713 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1687 | } else { | 1714 | } else { |
1688 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; | 1715 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; |
1689 | if (height() > mGridSpacingY * mRows + 1 ) { | 1716 | if (height() > mGridSpacingY * mRows + 1 ) { |
1690 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1717 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1691 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1718 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1692 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1719 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1693 | emit resizedSignal(); | 1720 | emit resizedSignal(); |
1694 | } else | 1721 | } else |
1695 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1722 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1696 | KOAgendaItem *item; | 1723 | KOAgendaItem *item; |
1697 | int subCellWidth; | 1724 | int subCellWidth; |
1698 | 1725 | ||
1699 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1726 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1700 | subCellWidth = mGridSpacingX / item->subCells(); | 1727 | subCellWidth = mGridSpacingX / item->subCells(); |
1701 | item->resize(subCellWidth,item->height()); | 1728 | item->resize(subCellWidth,item->height()); |
1702 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1729 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1703 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1730 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1704 | item->cellX() * mGridSpacingX) + | 1731 | item->cellX() * mGridSpacingX) + |
1705 | item->subCell() * subCellWidth,childY(item)); | 1732 | item->subCell() * subCellWidth,childY(item)); |
1706 | } | 1733 | } |
1707 | } | 1734 | } |
1708 | int cw = contentsWidth(); | 1735 | int cw = contentsWidth(); |
1709 | int ch = contentsHeight(); | 1736 | int ch = contentsHeight(); |
1710 | if ( mAllDayMode ) { | 1737 | if ( mAllDayMode ) { |
1711 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1738 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1712 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | 1739 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) |
1713 | paintPixAll->resize( cw, ch ); | 1740 | paintPixAll->resize( cw, ch ); |
1714 | } else { | 1741 | } else { |
1715 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1742 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1716 | if ( paintPix->width() < cw || paintPix->height() < ch ) | 1743 | if ( paintPix->width() < cw || paintPix->height() < ch ) |
1717 | KOAgendaItem::resizePixmap( cw , ch ); | 1744 | KOAgendaItem::resizePixmap( cw , ch ); |
1718 | } | 1745 | } |
1719 | 1746 | ||
1720 | checkScrollBoundaries(); | 1747 | checkScrollBoundaries(); |
1721 | marcus_bains(); | 1748 | marcus_bains(); |
1722 | drawContentsToPainter(); | 1749 | drawContentsToPainter(); |
1723 | viewport()->repaint(false); | 1750 | viewport()->repaint(false); |
1724 | } | 1751 | } |
1725 | 1752 | ||
1726 | void KOAgenda::scrollUp() | 1753 | void KOAgenda::scrollUp() |
1727 | { | 1754 | { |
1728 | scrollBy(0,-mScrollOffset); | 1755 | scrollBy(0,-mScrollOffset); |
1729 | } | 1756 | } |
1730 | 1757 | ||
1731 | 1758 | ||
1732 | void KOAgenda::scrollDown() | 1759 | void KOAgenda::scrollDown() |
1733 | { | 1760 | { |
1734 | scrollBy(0,mScrollOffset); | 1761 | scrollBy(0,mScrollOffset); |
1735 | } | 1762 | } |
1736 | 1763 | ||
1737 | void KOAgenda::popupAlarm() | 1764 | void KOAgenda::popupAlarm() |
1738 | { | 1765 | { |
1739 | if (!mClickedItem) { | 1766 | if (!mClickedItem) { |
1740 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1767 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1741 | return; | 1768 | return; |
1742 | } | 1769 | } |
1743 | // TODO: deal correctly with multiple alarms | 1770 | // TODO: deal correctly with multiple alarms |
1744 | Alarm* alarm; | 1771 | Alarm* alarm; |
1745 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1772 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1746 | for(alarm=list.first();alarm;alarm=list.next()) { | 1773 | for(alarm=list.first();alarm;alarm=list.next()) { |
1747 | alarm->toggleAlarm(); | 1774 | alarm->toggleAlarm(); |
1748 | } | 1775 | } |
1749 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1776 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1750 | mClickedItem->paintMe( true ); | 1777 | mClickedItem->paintMe( true ); |
1751 | mClickedItem->repaint( false ); | 1778 | mClickedItem->repaint( false ); |
1752 | } | 1779 | } |
1753 | 1780 | ||
1754 | /* | 1781 | /* |
1755 | Calculates the minimum width | 1782 | Calculates the minimum width |
1756 | */ | 1783 | */ |
1757 | int KOAgenda::minimumWidth() const | 1784 | int KOAgenda::minimumWidth() const |
1758 | { | 1785 | { |
1759 | // TODO:: develop a way to dynamically determine the minimum width | 1786 | // TODO:: develop a way to dynamically determine the minimum width |
1760 | int min = 100; | 1787 | int min = 100; |
1761 | 1788 | ||
1762 | return min; | 1789 | return min; |
1763 | } | 1790 | } |
1764 | 1791 | ||
1765 | void KOAgenda::updateConfig() | 1792 | void KOAgenda::updateConfig() |
1766 | { | 1793 | { |
1767 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 1794 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
1768 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 1795 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
1769 | if ( mAllDayMode ) { | 1796 | if ( mAllDayMode ) { |
1770 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 1797 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
1771 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 1798 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
1772 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 1799 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
1773 | // setMaximumHeight( mGridSpacingY+1 ); | 1800 | // setMaximumHeight( mGridSpacingY+1 ); |
1774 | viewport()->repaint( false ); | 1801 | viewport()->repaint( false ); |
1775 | //setFixedHeight( mGridSpacingY+1 ); | 1802 | //setFixedHeight( mGridSpacingY+1 ); |
1776 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 1803 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
1777 | } | 1804 | } |
1778 | else { | 1805 | else { |
1779 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 1806 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
1780 | calculateWorkingHours(); | 1807 | calculateWorkingHours(); |
1781 | marcus_bains(); | 1808 | marcus_bains(); |
1782 | } | 1809 | } |
1783 | } | 1810 | } |
1784 | 1811 | ||
1785 | void KOAgenda::checkScrollBoundaries() | 1812 | void KOAgenda::checkScrollBoundaries() |
1786 | { | 1813 | { |
1787 | // Invalidate old values to force update | 1814 | // Invalidate old values to force update |
1788 | mOldLowerScrollValue = -1; | 1815 | mOldLowerScrollValue = -1; |
1789 | mOldUpperScrollValue = -1; | 1816 | mOldUpperScrollValue = -1; |
1790 | 1817 | ||
1791 | checkScrollBoundaries(verticalScrollBar()->value()); | 1818 | checkScrollBoundaries(verticalScrollBar()->value()); |
1792 | } | 1819 | } |
1793 | 1820 | ||
1794 | void KOAgenda::checkScrollBoundaries(int v) | 1821 | void KOAgenda::checkScrollBoundaries(int v) |
1795 | { | 1822 | { |
1796 | if ( mGridSpacingY == 0 ) | 1823 | if ( mGridSpacingY == 0 ) |
1797 | return; | 1824 | return; |
1798 | int yMin = v/mGridSpacingY; | 1825 | int yMin = v/mGridSpacingY; |
1799 | int yMax = (v+visibleHeight())/mGridSpacingY; | 1826 | int yMax = (v+visibleHeight())/mGridSpacingY; |
1800 | 1827 | ||
1801 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 1828 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
1802 | 1829 | ||
1803 | if (yMin != mOldLowerScrollValue) { | 1830 | if (yMin != mOldLowerScrollValue) { |
1804 | mOldLowerScrollValue = yMin; | 1831 | mOldLowerScrollValue = yMin; |
1805 | emit lowerYChanged(yMin); | 1832 | emit lowerYChanged(yMin); |
1806 | } | 1833 | } |
1807 | if (yMax != mOldUpperScrollValue) { | 1834 | if (yMax != mOldUpperScrollValue) { |
1808 | mOldUpperScrollValue = yMax; | 1835 | mOldUpperScrollValue = yMax; |
1809 | emit upperYChanged(yMax); | 1836 | emit upperYChanged(yMax); |
1810 | } | 1837 | } |
1811 | } | 1838 | } |
1812 | 1839 | ||
1813 | void KOAgenda::deselectItem() | 1840 | void KOAgenda::deselectItem() |
1814 | { | 1841 | { |
1815 | if (mSelectedItem.isNull()) return; | 1842 | if (mSelectedItem.isNull()) return; |
1816 | mSelectedItem->select(false); | 1843 | mSelectedItem->select(false); |
1817 | mSelectedItem = 0; | 1844 | mSelectedItem = 0; |
1818 | } | 1845 | } |
1819 | 1846 | ||
1820 | void KOAgenda::selectItem(KOAgendaItem *item) | 1847 | void KOAgenda::selectItem(KOAgendaItem *item) |
1821 | { | 1848 | { |
1822 | if ((KOAgendaItem *)mSelectedItem == item) return; | 1849 | if ((KOAgendaItem *)mSelectedItem == item) return; |
1823 | deselectItem(); | 1850 | deselectItem(); |
1824 | if (item == 0) { | 1851 | if (item == 0) { |
1825 | emit incidenceSelected( 0 ); | 1852 | emit incidenceSelected( 0 ); |
1826 | return; | 1853 | return; |
1827 | } | 1854 | } |
1828 | mSelectedItem = item; | 1855 | mSelectedItem = item; |
1829 | mSelectedItem->select(); | 1856 | mSelectedItem->select(); |
1830 | emit incidenceSelected( mSelectedItem->incidence() ); | 1857 | emit incidenceSelected( mSelectedItem->incidence() ); |
1831 | } | 1858 | } |
1832 | 1859 | ||
1833 | // This function seems never be called. | 1860 | // This function seems never be called. |
1834 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 1861 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
1835 | { | 1862 | { |
1836 | switch(kev->key()) { | 1863 | switch(kev->key()) { |
1837 | case Key_PageDown: | 1864 | case Key_PageDown: |
1838 | verticalScrollBar()->addPage(); | 1865 | verticalScrollBar()->addPage(); |
1839 | break; | 1866 | break; |
1840 | case Key_PageUp: | 1867 | case Key_PageUp: |
1841 | verticalScrollBar()->subtractPage(); | 1868 | verticalScrollBar()->subtractPage(); |
1842 | break; | 1869 | break; |
1843 | case Key_Down: | 1870 | case Key_Down: |
1844 | verticalScrollBar()->addLine(); | 1871 | verticalScrollBar()->addLine(); |
1845 | break; | 1872 | break; |
1846 | case Key_Up: | 1873 | case Key_Up: |
1847 | verticalScrollBar()->subtractLine(); | 1874 | verticalScrollBar()->subtractLine(); |
1848 | break; | 1875 | break; |
1849 | default: | 1876 | default: |
1850 | ; | 1877 | ; |
1851 | } | 1878 | } |
1852 | } | 1879 | } |
1853 | 1880 | ||
1854 | void KOAgenda::calculateWorkingHours() | 1881 | void KOAgenda::calculateWorkingHours() |
1855 | { | 1882 | { |
1856 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 1883 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
1857 | mWorkingHoursEnable = !mAllDayMode; | 1884 | mWorkingHoursEnable = !mAllDayMode; |
1858 | 1885 | ||
1859 | mWorkingHoursYTop = mGridSpacingY * | 1886 | mWorkingHoursYTop = mGridSpacingY * |
1860 | KOPrefs::instance()->mWorkingHoursStart * 4; | 1887 | KOPrefs::instance()->mWorkingHoursStart * 4; |
1861 | mWorkingHoursYBottom = mGridSpacingY * | 1888 | mWorkingHoursYBottom = mGridSpacingY * |
1862 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 1889 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
1863 | } | 1890 | } |
1864 | 1891 | ||
1865 | 1892 | ||
1866 | DateList KOAgenda::dateList() const | 1893 | DateList KOAgenda::dateList() const |
1867 | { | 1894 | { |
1868 | return mSelectedDates; | 1895 | return mSelectedDates; |
1869 | } | 1896 | } |
1870 | 1897 | ||
1871 | void KOAgenda::setDateList(const DateList &selectedDates) | 1898 | void KOAgenda::setDateList(const DateList &selectedDates) |
1872 | { | 1899 | { |
1873 | mSelectedDates = selectedDates; | 1900 | mSelectedDates = selectedDates; |
1874 | marcus_bains(); | 1901 | marcus_bains(); |
1875 | } | 1902 | } |
1876 | 1903 | ||
1877 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 1904 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
1878 | { | 1905 | { |
1879 | mHolidayMask = mask; | 1906 | mHolidayMask = mask; |
1880 | 1907 | ||
1881 | /* | 1908 | /* |
1882 | kdDebug() << "HolidayMask: "; | 1909 | kdDebug() << "HolidayMask: "; |
1883 | for(uint i=0;i<mask->count();++i) { | 1910 | for(uint i=0;i<mask->count();++i) { |
1884 | kdDebug() << (mask->at(i) ? "*" : "o"); | 1911 | kdDebug() << (mask->at(i) ? "*" : "o"); |
1885 | } | 1912 | } |
1886 | kdDebug() << endl; | 1913 | kdDebug() << endl; |
1887 | */ | 1914 | */ |
1888 | } | 1915 | } |
1889 | 1916 | ||
1890 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 1917 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
1891 | { | 1918 | { |
1892 | 1919 | ||
1893 | QScrollView::contentsMousePressEvent(event); | 1920 | QScrollView::contentsMousePressEvent(event); |
1894 | } | 1921 | } |
1895 | 1922 | ||
1896 | void KOAgenda::storePosition() | 1923 | void KOAgenda::storePosition() |
1897 | { | 1924 | { |
1898 | //mContentPosition | 1925 | //mContentPosition |
1899 | int max = mGridSpacingY*4*24; | 1926 | int max = mGridSpacingY*4*24; |
1900 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 1927 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
1901 | mContentPosition = 0; | 1928 | mContentPosition = 0; |
1902 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 1929 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
1903 | mContentPosition = -1.0; | 1930 | mContentPosition = -1.0; |
1904 | else | 1931 | else |
1905 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 1932 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
1906 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 1933 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
1907 | 1934 | ||
1908 | } | 1935 | } |
1909 | void KOAgenda::restorePosition() | 1936 | void KOAgenda::restorePosition() |
1910 | { | 1937 | { |
1911 | int posY; | 1938 | int posY; |
1912 | int max = mGridSpacingY*4*24; | 1939 | int max = mGridSpacingY*4*24; |
1913 | if ( mContentPosition < 0 ) | 1940 | if ( mContentPosition < 0 ) |
1914 | posY = max-viewport()->height(); | 1941 | posY = max-viewport()->height(); |
1915 | else | 1942 | else |
1916 | if ( mContentPosition == 0 ) | 1943 | if ( mContentPosition == 0 ) |
1917 | posY = 0; | 1944 | posY = 0; |
1918 | else | 1945 | else |
1919 | posY = (max/mContentPosition)-(viewport()->height()/2); | 1946 | posY = (max/mContentPosition)-(viewport()->height()/2); |
1920 | setContentsPos (0, posY ); | 1947 | setContentsPos (0, posY ); |
1921 | //qDebug("posY %d hei %d", posY, max); | 1948 | //qDebug("posY %d hei %d", posY, max); |
1922 | 1949 | ||
1923 | } | 1950 | } |
1924 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 1951 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
1925 | { | 1952 | { |
1926 | ++x; | 1953 | ++x; |
1927 | QScrollView::moveChild( w, x , y ); | 1954 | QScrollView::moveChild( w, x , y ); |
1928 | } | 1955 | } |
1929 | #include <qmessagebox.h> | 1956 | #include <qmessagebox.h> |
1930 | #ifdef DESKTOP_VERSION | 1957 | #ifdef DESKTOP_VERSION |
1931 | #include <qprinter.h> | 1958 | #include <qprinter.h> |
1932 | #include <qpainter.h> | 1959 | #include <qpainter.h> |
1933 | #include <qpaintdevicemetrics.h> | 1960 | #include <qpaintdevicemetrics.h> |
1934 | 1961 | ||
1935 | #endif | 1962 | #endif |
1936 | void KOAgenda::printSelection() | 1963 | void KOAgenda::printSelection() |
1937 | { | 1964 | { |
1938 | #ifdef DESKTOP_VERSION | 1965 | #ifdef DESKTOP_VERSION |
1939 | if ( mStartCellY == mCurrentCellY ) { | 1966 | if ( mStartCellY == mCurrentCellY ) { |
1940 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1967 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1941 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 1968 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
1942 | i18n("OK"), 0, 0, | 1969 | i18n("OK"), 0, 0, |
1943 | 0, 1 ); | 1970 | 0, 1 ); |
1944 | return; | 1971 | return; |
1945 | } | 1972 | } |
1946 | 1973 | ||
1947 | float dx, dy; | 1974 | float dx, dy; |
1948 | int x,y,w,h; | 1975 | int x,y,w,h; |
1949 | x= 0; | 1976 | x= 0; |
1950 | w= contentsWidth()+2; | 1977 | w= contentsWidth()+2; |
1951 | // h= contentsHeight(); | 1978 | // h= contentsHeight(); |
1952 | y = mGridSpacingY*mStartCellY; | 1979 | y = mGridSpacingY*mStartCellY; |
1953 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 1980 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
1954 | 1981 | ||
1955 | //return; | 1982 | //return; |
1956 | QPrinter* printer = new QPrinter(); | 1983 | QPrinter* printer = new QPrinter(); |
1957 | if ( !printer->setup()) { | 1984 | if ( !printer->setup()) { |
1958 | delete printer; | 1985 | delete printer; |
1959 | return; | 1986 | return; |
1960 | } | 1987 | } |
1961 | QPainter p( printer ); | 1988 | QPainter p( printer ); |
1962 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 1989 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
1963 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 1990 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
1964 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 1991 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
1965 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 1992 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
1966 | // p.drawText( 0, 0, date ); | 1993 | // p.drawText( 0, 0, date ); |
1967 | int offset = m.width()/8; | 1994 | int offset = m.width()/8; |
1968 | // compute the scale | 1995 | // compute the scale |
1969 | dx = ((float) m.width()-offset) / (float)w; | 1996 | dx = ((float) m.width()-offset) / (float)w; |
1970 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 1997 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
1971 | float scale; | 1998 | float scale; |
1972 | // scale to fit the width or height of the paper | 1999 | // scale to fit the width or height of the paper |
1973 | if ( dx < dy ) | 2000 | if ( dx < dy ) |
1974 | scale = dx; | 2001 | scale = dx; |
1975 | else | 2002 | else |
1976 | scale = dy; | 2003 | scale = dy; |
1977 | // set the scale | 2004 | // set the scale |
1978 | p.drawText( offset* scale, offset* scale*3/4, date ); | 2005 | p.drawText( offset* scale, offset* scale*3/4, date ); |
1979 | 2006 | ||
1980 | int selDay; | 2007 | int selDay; |
1981 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 2008 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
1982 | float startX = 1; | 2009 | float startX = 1; |
1983 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 2010 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1984 | { | 2011 | { |
1985 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 2012 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
1986 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 2013 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
1987 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 2014 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
1988 | startX += widOffset; | 2015 | startX += widOffset; |
1989 | 2016 | ||
1990 | } | 2017 | } |
1991 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 2018 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
1992 | p.scale( scale, scale ); | 2019 | p.scale( scale, scale ); |
1993 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 2020 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
1994 | // now printing with y offset: 2 hei | 2021 | // now printing with y offset: 2 hei |
1995 | // p.translate( 0, -y*scale); | 2022 | // p.translate( 0, -y*scale); |
1996 | 2023 | ||
1997 | drawContentsToPainter(&p, true ); | 2024 | drawContentsToPainter(&p, true ); |
1998 | globalFlagBlockAgendaItemUpdate = false; | 2025 | globalFlagBlockAgendaItemUpdate = false; |
1999 | KOAgendaItem *item; | 2026 | KOAgendaItem *item; |
2000 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 2027 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
2001 | item->select(false); | 2028 | item->select(false); |
2002 | item->paintMe( false, &p ); | 2029 | item->paintMe( false, &p ); |
2003 | } | 2030 | } |
2004 | globalFlagBlockAgendaItemUpdate = true; | 2031 | globalFlagBlockAgendaItemUpdate = true; |
2005 | p.end(); | 2032 | p.end(); |
2006 | delete printer; | 2033 | delete printer; |
2007 | #else | 2034 | #else |
2008 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2035 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2009 | i18n("Not supported \non PDA!\n"), | 2036 | i18n("Not supported \non PDA!\n"), |
2010 | i18n("OK"), 0, 0, | 2037 | i18n("OK"), 0, 0, |
2011 | 0, 1 ); | 2038 | 0, 1 ); |
2012 | #endif | 2039 | #endif |
2013 | } | 2040 | } |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index d0a7b07..38bd93a 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,765 +1,766 @@ | |||
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 | setCellXY(0,0,1); | 139 | setCellXY(0,0,1); |
139 | setCellXWidth(0); | 140 | setCellXWidth(0); |
140 | setSubCell(0); | 141 | setSubCell(0); |
141 | setSubCells(1); | 142 | setSubCells(1); |
142 | setMultiItem(0,0,0); | 143 | setMultiItem(0,0,0); |
143 | startMove(); | 144 | startMove(); |
144 | mSelected = true; | 145 | mSelected = true; |
145 | select(false); | 146 | select(false); |
146 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 147 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
147 | mFontPixelSize = fontinf.height();; | 148 | mFontPixelSize = fontinf.height();; |
148 | hide(); | 149 | hide(); |
149 | xPaintCoord = -1; | 150 | xPaintCoord = -1; |
150 | yPaintCoord = -1; | 151 | yPaintCoord = -1; |
151 | } | 152 | } |
152 | 153 | ||
153 | 154 | ||
154 | KOAgendaItem::~KOAgendaItem() | 155 | KOAgendaItem::~KOAgendaItem() |
155 | { | 156 | { |
156 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
157 | 158 | ||
158 | } | 159 | } |
159 | 160 | ||
160 | void KOAgendaItem::recreateIncidence() | 161 | void KOAgendaItem::recreateIncidence() |
161 | { | 162 | { |
162 | #if 0 | 163 | #if 0 |
163 | Incidence* newInc = mIncidence->clone(); | 164 | Incidence* newInc = mIncidence->clone(); |
164 | newInc->recreate(); | 165 | newInc->recreate(); |
165 | if ( mIncidence->doesRecur() ) { | 166 | if ( mIncidence->doesRecur() ) { |
166 | mIncidence->addExDate( mDate ); | 167 | mIncidence->addExDate( mDate ); |
167 | newInc->recurrence()->unsetRecurs(); | 168 | newInc->recurrence()->unsetRecurs(); |
168 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 169 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
169 | QTime tim = mIncidence->dtStart().time(); | 170 | QTime tim = mIncidence->dtStart().time(); |
170 | newInc->setDtStart( QDateTime(mDate, tim) ); | 171 | newInc->setDtStart( QDateTime(mDate, tim) ); |
171 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 172 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
172 | } | 173 | } |
173 | #endif | 174 | #endif |
174 | mIncidence = mIncidence->recreateCloneException( mDate ); | 175 | mIncidence = mIncidence->recreateCloneException( mDate ); |
175 | } | 176 | } |
176 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 177 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
177 | { | 178 | { |
178 | int size = AGENDA_ICON_SIZE; | 179 | int size = AGENDA_ICON_SIZE; |
179 | 180 | ||
180 | int yOff = 0; | 181 | int yOff = 0; |
181 | int xOff = 0; | 182 | int xOff = 0; |
182 | int x = pos().x() +3; | 183 | int x = pos().x() +3; |
183 | int y; | 184 | int y; |
184 | if ( mAllDay ) | 185 | if ( mAllDay ) |
185 | y = pos().y()+3; | 186 | y = pos().y()+3; |
186 | else | 187 | else |
187 | y = mCellYTop * ( height() / cellHeight() ) +3; | 188 | y = mCellYTop * ( height() / cellHeight() ) +3; |
188 | if (mIncidence->cancelled()) { | 189 | if (mIncidence->cancelled()) { |
189 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 190 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
190 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 191 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
191 | 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 ); |
192 | 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 ); |
193 | if ( horLayout ) | 194 | if ( horLayout ) |
194 | ++xOff; | 195 | ++xOff; |
195 | else | 196 | else |
196 | ++yOff; | 197 | ++yOff; |
197 | } | 198 | } |
198 | if (mIncidence->isAlarmEnabled()) { | 199 | if (mIncidence->isAlarmEnabled()) { |
199 | 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 ); |
200 | if ( horLayout ) | 201 | if ( horLayout ) |
201 | ++xOff; | 202 | ++xOff; |
202 | else | 203 | else |
203 | ++yOff; | 204 | ++yOff; |
204 | } | 205 | } |
205 | if (mIncidence->recurrence()->doesRecur()) { | 206 | if (mIncidence->recurrence()->doesRecur()) { |
206 | 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 ); |
207 | if ( horLayout ) | 208 | if ( horLayout ) |
208 | ++xOff; | 209 | ++xOff; |
209 | else | 210 | else |
210 | ++yOff; | 211 | ++yOff; |
211 | } | 212 | } |
212 | if (mIncidence->description().length() > 0) { | 213 | if (mIncidence->description().length() > 0) { |
213 | 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 ); |
214 | if ( horLayout ) | 215 | if ( horLayout ) |
215 | ++xOff; | 216 | ++xOff; |
216 | else | 217 | else |
217 | ++yOff; | 218 | ++yOff; |
218 | } | 219 | } |
219 | if (mIncidence->isReadOnly()) { | 220 | if (mIncidence->isReadOnly()) { |
220 | 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 ); |
221 | if ( horLayout ) | 222 | if ( horLayout ) |
222 | ++xOff; | 223 | ++xOff; |
223 | else | 224 | else |
224 | ++yOff; | 225 | ++yOff; |
225 | } | 226 | } |
226 | 227 | ||
227 | if (mIncidence->attendeeCount()>0) { | 228 | if (mIncidence->attendeeCount()>0) { |
228 | 229 | ||
229 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 230 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
230 | 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 ); |
231 | if ( horLayout ) | 232 | if ( horLayout ) |
232 | ++xOff; | 233 | ++xOff; |
233 | else | 234 | else |
234 | ++yOff; | 235 | ++yOff; |
235 | } else { | 236 | } else { |
236 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 237 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
237 | if (me!=0) { | 238 | if (me!=0) { |
238 | 239 | ||
239 | 240 | ||
240 | } else { | 241 | } else { |
241 | 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 ); |
242 | if ( horLayout ) | 243 | if ( horLayout ) |
243 | ++xOff; | 244 | ++xOff; |
244 | else | 245 | else |
245 | ++yOff; | 246 | ++yOff; |
246 | 247 | ||
247 | } | 248 | } |
248 | 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 ); |
249 | if ( horLayout ) | 250 | if ( horLayout ) |
250 | ++xOff; | 251 | ++xOff; |
251 | else | 252 | else |
252 | ++yOff; | 253 | ++yOff; |
253 | 254 | ||
254 | } | 255 | } |
255 | 256 | ||
256 | } | 257 | } |
257 | return ( yOff || xOff ); | 258 | return ( yOff || xOff ); |
258 | } | 259 | } |
259 | 260 | ||
260 | 261 | ||
261 | void KOAgendaItem::select(bool selected) | 262 | void KOAgendaItem::select(bool selected) |
262 | { | 263 | { |
263 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 264 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
264 | if (mSelected == selected) return; | 265 | if (mSelected == selected) return; |
265 | mSelected = selected; | 266 | mSelected = selected; |
266 | if ( ! isVisible() ) | 267 | if ( ! isVisible() ) |
267 | return; | 268 | return; |
268 | if ( firstMultiItem() ) | 269 | if ( firstMultiItem() ) |
269 | firstMultiItem()->select( selected ); | 270 | firstMultiItem()->select( selected ); |
270 | if ( !firstMultiItem() && nextMultiItem() ) { | 271 | if ( !firstMultiItem() && nextMultiItem() ) { |
271 | KOAgendaItem * placeItem = nextMultiItem(); | 272 | KOAgendaItem * placeItem = nextMultiItem(); |
272 | while ( placeItem ) { | 273 | while ( placeItem ) { |
273 | placeItem->select( selected ); | 274 | placeItem->select( selected ); |
274 | placeItem = placeItem->nextMultiItem(); | 275 | placeItem = placeItem->nextMultiItem(); |
275 | } | 276 | } |
276 | } | 277 | } |
277 | globalFlagBlockAgendaItemUpdate = 0; | 278 | globalFlagBlockAgendaItemUpdate = 0; |
278 | paintMe( selected ); | 279 | paintMe( selected ); |
279 | globalFlagBlockAgendaItemUpdate = 1; | 280 | globalFlagBlockAgendaItemUpdate = 1; |
280 | repaint( false ); | 281 | repaint( false ); |
281 | } | 282 | } |
282 | 283 | ||
283 | 284 | ||
284 | /* | 285 | /* |
285 | 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 |
286 | 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 |
287 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 288 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
288 | */ | 289 | */ |
289 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 290 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
290 | { | 291 | { |
291 | if (e->type() == QEvent::MouseButtonPress || | 292 | if (e->type() == QEvent::MouseButtonPress || |
292 | e->type() == QEvent::MouseButtonDblClick || | 293 | e->type() == QEvent::MouseButtonDblClick || |
293 | e->type() == QEvent::MouseButtonRelease || | 294 | e->type() == QEvent::MouseButtonRelease || |
294 | e->type() == QEvent::MouseMove) { | 295 | e->type() == QEvent::MouseMove) { |
295 | QMouseEvent *me = (QMouseEvent *)e; | 296 | QMouseEvent *me = (QMouseEvent *)e; |
296 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 297 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
297 | mapToGlobal(me->pos())); | 298 | mapToGlobal(me->pos())); |
298 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 299 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
299 | return event(&returnEvent); | 300 | return event(&returnEvent); |
300 | } else { | 301 | } else { |
301 | return false; | 302 | return false; |
302 | } | 303 | } |
303 | } | 304 | } |
304 | void KOAgendaItem::repaintMe( ) | 305 | void KOAgendaItem::repaintMe( ) |
305 | { | 306 | { |
306 | paintMe ( mSelected ); | 307 | paintMe ( mSelected ); |
307 | } | 308 | } |
308 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 309 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
309 | { | 310 | { |
310 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 311 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
311 | return; | 312 | return; |
312 | QPainter pa; | 313 | QPainter pa; |
313 | 314 | ||
314 | if ( mSelected ) { | 315 | if ( mSelected ) { |
315 | pa.begin( paintPixSel() ); | 316 | pa.begin( paintPixSel() ); |
316 | } else { | 317 | } else { |
317 | if ( mAllDay ) | 318 | if ( mAllDay ) |
318 | pa.begin( paintPixAllday() ); | 319 | pa.begin( paintPixAllday() ); |
319 | else | 320 | else |
320 | pa.begin( paintPix() ); | 321 | pa.begin( paintPix() ); |
321 | } | 322 | } |
322 | int x, yy, w, h; | 323 | int x, yy, w, h; |
323 | float nfh = 7.0; | 324 | float nfh = 7.0; |
324 | x = pos().x(); w = width(); h = height (); | 325 | x = pos().x(); w = width(); h = height (); |
325 | if ( mAllDay ) | 326 | if ( mAllDay ) |
326 | yy = y(); | 327 | yy = y(); |
327 | else | 328 | else |
328 | yy = mCellYTop * ( height() / cellHeight() ); | 329 | yy = mCellYTop * ( height() / cellHeight() ); |
329 | xPaintCoord= x; | 330 | xPaintCoord= x; |
330 | yPaintCoord = yy; | 331 | yPaintCoord = yy; |
331 | wPaintCoord = width(); | 332 | wPaintCoord = width(); |
332 | hPaintCoord = height(); | 333 | hPaintCoord = height(); |
333 | //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()); |
334 | if ( paint == 0 ) | 335 | if ( paint == 0 ) |
335 | paint = &pa; | 336 | paint = &pa; |
336 | bool horLayout = ( w < h ); | 337 | bool horLayout = ( w < h ); |
337 | int maxhei = mFontPixelSize+4; | 338 | int maxhei = mFontPixelSize+4; |
338 | if ( horLayout ) | 339 | if ( horLayout ) |
339 | maxhei += AGENDA_ICON_SIZE -4; | 340 | maxhei += AGENDA_ICON_SIZE -4; |
340 | bool small = ( h < maxhei ); | 341 | bool small = ( h < maxhei ); |
341 | if ( ! small ) | 342 | if ( ! small ) |
342 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 343 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
343 | else { | 344 | else { |
344 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 345 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
345 | f.setBold( false ); | 346 | f.setBold( false ); |
346 | int fh = f.pointSize(); | 347 | int fh = f.pointSize(); |
347 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 348 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
348 | if ( nfh < 6 ) | 349 | if ( nfh < 6 ) |
349 | nfh = 6; | 350 | nfh = 6; |
350 | f.setPointSize( nfh ); | 351 | f.setPointSize( nfh ); |
351 | paint->setFont(f); | 352 | paint->setFont(f); |
352 | } | 353 | } |
353 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 354 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
354 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 355 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
355 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 356 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
356 | if ( mIncidence->type() == "Todo" ) { | 357 | if ( mIncidence->type() == "Todo" ) { |
357 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 358 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
358 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 359 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
359 | int yyy = yy+3; | 360 | int yyy = yy+3; |
360 | if ( tempTodo->isCompleted() ) | 361 | if ( tempTodo->isCompleted() ) |
361 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 362 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
362 | else { | 363 | else { |
363 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 364 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
364 | 365 | ||
365 | } | 366 | } |
366 | } | 367 | } |
367 | bool addIcon = false; | 368 | bool addIcon = false; |
368 | if ( ! small || w > 3 * h || h > 3* w ) | 369 | if ( ! small || w > 3 * h || h > 3* w ) |
369 | addIcon = updateIcons( paint, horLayout ); | 370 | addIcon = updateIcons( paint, horLayout ); |
370 | 371 | ||
371 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 372 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
372 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 373 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
373 | if ( ! small ) { | 374 | if ( ! small ) { |
374 | x += 3; yy += 3;w -= 6; h-= 5; | 375 | x += 3; yy += 3;w -= 6; h-= 5; |
375 | } else { | 376 | } else { |
376 | x += 2; yy += 1;w -= 4; h-= 4; | 377 | x += 2; yy += 1;w -= 4; h-= 4; |
377 | if ( nfh < 6.01 ) { | 378 | if ( nfh < 6.01 ) { |
378 | yy -= 2; | 379 | yy -= 2; |
379 | h += 4; | 380 | h += 4; |
380 | } | 381 | } |
381 | else | 382 | else |
382 | if ( nfh < h -2 ) | 383 | if ( nfh < h -2 ) |
383 | ++yy; | 384 | ++yy; |
384 | } | 385 | } |
385 | int align; | 386 | int align; |
386 | #ifndef DESKTOP_VERSION | 387 | #ifndef DESKTOP_VERSION |
387 | align = ( AlignLeft|WordBreak|AlignTop); | 388 | align = ( AlignLeft|WordBreak|AlignTop); |
388 | #else | 389 | #else |
389 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 390 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
390 | #endif | 391 | #endif |
391 | if ( addIcon ) { | 392 | if ( addIcon ) { |
392 | if ( ! horLayout ) { | 393 | if ( ! horLayout ) { |
393 | x += AGENDA_ICON_SIZE+3; | 394 | x += AGENDA_ICON_SIZE+3; |
394 | w -= (AGENDA_ICON_SIZE+3); | 395 | w -= (AGENDA_ICON_SIZE+3); |
395 | } | 396 | } |
396 | else { | 397 | else { |
397 | yy+= AGENDA_ICON_SIZE+2; | 398 | yy+= AGENDA_ICON_SIZE+2; |
398 | h -=(AGENDA_ICON_SIZE+3); | 399 | h -=(AGENDA_ICON_SIZE+3); |
399 | } | 400 | } |
400 | } | 401 | } |
401 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
402 | if ( colsum < 250 ) | 403 | if ( colsum < 250 ) |
403 | paint->setPen ( white); | 404 | paint->setPen ( white); |
404 | if ( x < 0 ) { | 405 | if ( x < 0 ) { |
405 | w = w+x-3; | 406 | w = w+x-3; |
406 | x = 3; | 407 | x = 3; |
407 | if ( w > parentWidget()->width() ){ | 408 | if ( w > parentWidget()->width() ){ |
408 | w = parentWidget()->width() - 6; | 409 | w = parentWidget()->width() - 6; |
409 | #ifndef DESKTOP_VERSION | 410 | #ifndef DESKTOP_VERSION |
410 | align = ( AlignHCenter|WordBreak|AlignTop); | 411 | align = ( AlignHCenter|WordBreak|AlignTop); |
411 | #else | 412 | #else |
412 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
413 | #endif | 414 | #endif |
414 | 415 | ||
415 | } | 416 | } |
416 | } | 417 | } |
417 | QRect dr; | 418 | QRect dr; |
418 | if ( w + x > parentWidget()->width() ) | 419 | if ( w + x > parentWidget()->width() ) |
419 | w = parentWidget()->width()-x; | 420 | w = parentWidget()->width()-x; |
420 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
421 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 422 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
422 | if ( mIncidence->cancelled() ){ | 423 | if ( mIncidence->cancelled() ){ |
423 | if ( ! small ) { | 424 | if ( ! small ) { |
424 | QFontMetrics fm ( paint->font() ); | 425 | QFontMetrics fm ( paint->font() ); |
425 | 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); |
426 | } | 427 | } |
427 | 428 | ||
428 | } | 429 | } |
429 | pa.end(); | 430 | pa.end(); |
430 | 431 | ||
431 | } | 432 | } |
432 | void KOAgendaItem::resizePixmap( int w , int h ) | 433 | void KOAgendaItem::resizePixmap( int w , int h ) |
433 | { | 434 | { |
434 | paintPix()->resize( w, h ); | 435 | paintPix()->resize( w, h ); |
435 | paintPixSel()->resize( w, h ); | 436 | paintPixSel()->resize( w, h ); |
436 | 437 | ||
437 | } | 438 | } |
438 | QPixmap * KOAgendaItem::paintPix() | 439 | QPixmap * KOAgendaItem::paintPix() |
439 | { | 440 | { |
440 | static QPixmap* mPaintPix = 0; | 441 | static QPixmap* mPaintPix = 0; |
441 | if ( ! mPaintPix ) | 442 | if ( ! mPaintPix ) |
442 | mPaintPix = new QPixmap(1,1); | 443 | mPaintPix = new QPixmap(1,1); |
443 | return mPaintPix ; | 444 | return mPaintPix ; |
444 | } | 445 | } |
445 | QPixmap * KOAgendaItem::paintPixAllday() | 446 | QPixmap * KOAgendaItem::paintPixAllday() |
446 | { | 447 | { |
447 | static QPixmap* mPaintPixA = 0; | 448 | static QPixmap* mPaintPixA = 0; |
448 | if ( ! mPaintPixA ) | 449 | if ( ! mPaintPixA ) |
449 | mPaintPixA = new QPixmap(1,1); | 450 | mPaintPixA = new QPixmap(1,1); |
450 | return mPaintPixA ; | 451 | return mPaintPixA ; |
451 | } | 452 | } |
452 | QPixmap * KOAgendaItem::paintPixSel() | 453 | QPixmap * KOAgendaItem::paintPixSel() |
453 | { | 454 | { |
454 | static QPixmap* mPaintPixSel = 0; | 455 | static QPixmap* mPaintPixSel = 0; |
455 | if ( ! mPaintPixSel ) | 456 | if ( ! mPaintPixSel ) |
456 | mPaintPixSel = new QPixmap(1,1); | 457 | mPaintPixSel = new QPixmap(1,1); |
457 | return mPaintPixSel ; | 458 | return mPaintPixSel ; |
458 | } | 459 | } |
459 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 460 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
460 | { | 461 | { |
461 | 462 | ||
462 | if ( globalFlagBlockAgendaItemPaint ) | 463 | if ( globalFlagBlockAgendaItemPaint ) |
463 | return; | 464 | return; |
464 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 465 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
465 | return; | 466 | return; |
466 | int yy; | 467 | int yy; |
467 | if ( mAllDay ) | 468 | if ( mAllDay ) |
468 | yy = y(); | 469 | yy = y(); |
469 | else | 470 | else |
470 | yy = mCellYTop * ( height() / cellHeight() ); | 471 | yy = mCellYTop * ( height() / cellHeight() ); |
471 | int xx = x(); | 472 | int xx = x(); |
472 | if ( xPaintCoord != xx || yPaintCoord != yy || | 473 | if ( xPaintCoord != xx || yPaintCoord != yy || |
473 | wPaintCoord != width() || hPaintCoord != height()) { | 474 | wPaintCoord != width() || hPaintCoord != height()) { |
474 | xPaintCoord= xx; | 475 | xPaintCoord= xx; |
475 | yPaintCoord = yy; | 476 | yPaintCoord = yy; |
476 | wPaintCoord = width(); | 477 | wPaintCoord = width(); |
477 | hPaintCoord = height(); | 478 | hPaintCoord = height(); |
478 | globalFlagBlockAgendaItemUpdate = 0; | 479 | globalFlagBlockAgendaItemUpdate = 0; |
479 | paintMe( mSelected ); | 480 | paintMe( mSelected ); |
480 | //qDebug("calling paintMe "); | 481 | //qDebug("calling paintMe "); |
481 | globalFlagBlockAgendaItemUpdate = 1; | 482 | globalFlagBlockAgendaItemUpdate = 1; |
482 | } | 483 | } |
483 | int rx, ry, rw, rh; | 484 | int rx, ry, rw, rh; |
484 | rx = e->rect().x(); | 485 | rx = e->rect().x(); |
485 | ry = e->rect().y(); | 486 | ry = e->rect().y(); |
486 | rw = e->rect().width(); | 487 | rw = e->rect().width(); |
487 | rh = e->rect().height(); | 488 | rh = e->rect().height(); |
488 | //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()); |
489 | 490 | ||
490 | QPixmap* paintFrom ; | 491 | QPixmap* paintFrom ; |
491 | if ( mSelected ) { | 492 | if ( mSelected ) { |
492 | paintFrom = paintPixSel(); | 493 | paintFrom = paintPixSel(); |
493 | } else { | 494 | } else { |
494 | if ( mAllDay ) | 495 | if ( mAllDay ) |
495 | paintFrom = paintPixAllday(); | 496 | paintFrom = paintPixAllday(); |
496 | else | 497 | else |
497 | paintFrom = paintPix(); | 498 | paintFrom = paintPix(); |
498 | } | 499 | } |
499 | 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); |
500 | } | 501 | } |
501 | void KOAgendaItem::computeText() | 502 | void KOAgendaItem::computeText() |
502 | { | 503 | { |
503 | 504 | ||
504 | mDisplayedText = mIncidence->summary(); | 505 | mDisplayedText = mIncidence->summary(); |
505 | if ( (mIncidence->type() == "Todo") ) { | 506 | if ( (mIncidence->type() == "Todo") ) { |
506 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 507 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
507 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 508 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
508 | 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)+")"; |
509 | else if ( !(mIncidence->doesFloat())) | 510 | else if ( !(mIncidence->doesFloat())) |
510 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 511 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
511 | } | 512 | } |
512 | } else { | 513 | } else { |
513 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 514 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
514 | 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()) ; |
515 | 516 | ||
516 | if ( mAllDay ) { | 517 | if ( mAllDay ) { |
517 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 518 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
518 | 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) ; |
519 | } | 520 | } |
520 | } | 521 | } |
521 | 522 | ||
522 | } | 523 | } |
523 | 524 | ||
524 | if ( !mIncidence->location().isEmpty() ) { | 525 | if ( !mIncidence->location().isEmpty() ) { |
525 | if ( mAllDay ) | 526 | if ( mAllDay ) |
526 | mDisplayedText += " ("; | 527 | mDisplayedText += " ("; |
527 | else | 528 | else |
528 | mDisplayedText += "\n("; | 529 | mDisplayedText += "\n("; |
529 | mDisplayedText += mIncidence->location() +")"; | 530 | mDisplayedText += mIncidence->location() +")"; |
530 | } | 531 | } |
531 | 532 | ||
532 | QString tipText = mIncidence->summary(); | 533 | QString tipText = mIncidence->summary(); |
533 | if ( !mIncidence->doesFloat() ) { | 534 | if ( !mIncidence->doesFloat() ) { |
534 | if ( mIncidence->type() == "Event" ) { | 535 | if ( mIncidence->type() == "Event" ) { |
535 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 536 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
536 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 537 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
537 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 538 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
538 | } | 539 | } |
539 | else { | 540 | else { |
540 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 541 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
541 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 542 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
542 | } | 543 | } |
543 | } | 544 | } |
544 | else if ( mIncidence->type() == "Todo" ) { | 545 | else if ( mIncidence->type() == "Todo" ) { |
545 | if (mIncidence->hasStartDate()) | 546 | if (mIncidence->hasStartDate()) |
546 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 547 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
547 | if (((Todo*)mIncidence)->hasDueDate()) | 548 | if (((Todo*)mIncidence)->hasDueDate()) |
548 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 549 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
549 | } | 550 | } |
550 | } else if ( mIncidence->type() == "Todo" ) { | 551 | } else if ( mIncidence->type() == "Todo" ) { |
551 | if (mIncidence->hasStartDate()) | 552 | if (mIncidence->hasStartDate()) |
552 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 553 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
553 | if (((Todo*)mIncidence)->hasDueDate()) | 554 | if (((Todo*)mIncidence)->hasDueDate()) |
554 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 555 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
555 | } | 556 | } |
556 | 557 | ||
557 | if (!mIncidence->location().isEmpty()) { | 558 | if (!mIncidence->location().isEmpty()) { |
558 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 559 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
559 | } | 560 | } |
560 | QToolTip::add(this,tipText,toolTipGroup(),""); | 561 | QToolTip::add(this,tipText,toolTipGroup(),""); |
561 | 562 | ||
562 | } | 563 | } |
563 | void KOAgendaItem::updateItem() | 564 | void KOAgendaItem::updateItem() |
564 | { | 565 | { |
565 | computeText(); | 566 | computeText(); |
566 | 567 | ||
567 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 568 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
568 | paintMe( mSelected ); | 569 | paintMe( mSelected ); |
569 | repaint( false); | 570 | repaint( false); |
570 | } | 571 | } |
571 | 572 | ||
572 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 573 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
573 | { | 574 | { |
574 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 575 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
575 | paintMe( mSelected ); | 576 | paintMe( mSelected ); |
576 | repaint( false ); | 577 | repaint( false ); |
577 | } | 578 | } |
578 | 579 | ||
579 | /* | 580 | /* |
580 | Return height of item in units of agenda cells | 581 | Return height of item in units of agenda cells |
581 | */ | 582 | */ |
582 | int KOAgendaItem::cellHeight() | 583 | int KOAgendaItem::cellHeight() |
583 | { | 584 | { |
584 | int ret = mCellYBottom - mCellYTop + 1; | 585 | int ret = mCellYBottom - mCellYTop + 1; |
585 | if ( ret <= 0 ) { | 586 | if ( ret <= 0 ) { |
586 | ret = 1; | 587 | ret = 1; |
587 | mCellYBottom = 0; | 588 | mCellYBottom = 0; |
588 | mCellYTop = 0; | 589 | mCellYTop = 0; |
589 | } | 590 | } |
590 | return ret; | 591 | return ret; |
591 | } | 592 | } |
592 | 593 | ||
593 | /* | 594 | /* |
594 | Return height of item in units of agenda cells | 595 | Return height of item in units of agenda cells |
595 | */ | 596 | */ |
596 | int KOAgendaItem::cellWidth() | 597 | int KOAgendaItem::cellWidth() |
597 | { | 598 | { |
598 | return mCellXWidth - mCellX + 1; | 599 | return mCellXWidth - mCellX + 1; |
599 | } | 600 | } |
600 | 601 | ||
601 | void KOAgendaItem::setItemDate(QDate qd) | 602 | void KOAgendaItem::setItemDate(QDate qd) |
602 | { | 603 | { |
603 | mDate = qd; | 604 | mDate = qd; |
604 | } | 605 | } |
605 | 606 | ||
606 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 607 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
607 | { | 608 | { |
608 | mCellX = X; | 609 | mCellX = X; |
609 | mCellYTop = YTop; | 610 | mCellYTop = YTop; |
610 | mCellYBottom = YBottom; | 611 | mCellYBottom = YBottom; |
611 | } | 612 | } |
612 | 613 | ||
613 | void KOAgendaItem::setCellXWidth(int xwidth) | 614 | void KOAgendaItem::setCellXWidth(int xwidth) |
614 | { | 615 | { |
615 | mCellXWidth = xwidth; | 616 | mCellXWidth = xwidth; |
616 | } | 617 | } |
617 | 618 | ||
618 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 619 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
619 | { | 620 | { |
620 | mCellX = XLeft; | 621 | mCellX = XLeft; |
621 | mCellXWidth = XRight; | 622 | mCellXWidth = XRight; |
622 | } | 623 | } |
623 | 624 | ||
624 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 625 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
625 | { | 626 | { |
626 | mCellYTop = YTop; | 627 | mCellYTop = YTop; |
627 | mCellYBottom = YBottom; | 628 | mCellYBottom = YBottom; |
628 | } | 629 | } |
629 | 630 | ||
630 | void KOAgendaItem::setSubCell(int subCell) | 631 | void KOAgendaItem::setSubCell(int subCell) |
631 | { | 632 | { |
632 | mSubCell = subCell; | 633 | mSubCell = subCell; |
633 | } | 634 | } |
634 | 635 | ||
635 | void KOAgendaItem::setSubCells(int subCells) | 636 | void KOAgendaItem::setSubCells(int subCells) |
636 | { | 637 | { |
637 | mSubCells = subCells; | 638 | mSubCells = subCells; |
638 | } | 639 | } |
639 | 640 | ||
640 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 641 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
641 | KOAgendaItem *last) | 642 | KOAgendaItem *last) |
642 | { | 643 | { |
643 | mFirstMultiItem = first; | 644 | mFirstMultiItem = first; |
644 | mNextMultiItem = next; | 645 | mNextMultiItem = next; |
645 | mLastMultiItem = last; | 646 | mLastMultiItem = last; |
646 | } | 647 | } |
647 | 648 | ||
648 | void KOAgendaItem::startMove() | 649 | void KOAgendaItem::startMove() |
649 | { | 650 | { |
650 | mStartCellX = mCellX; | 651 | mStartCellX = mCellX; |
651 | mStartCellXWidth = mCellXWidth; | 652 | mStartCellXWidth = mCellXWidth; |
652 | mStartCellYTop = mCellYTop; | 653 | mStartCellYTop = mCellYTop; |
653 | mStartCellYBottom = mCellYBottom; | 654 | mStartCellYBottom = mCellYBottom; |
654 | } | 655 | } |
655 | 656 | ||
656 | void KOAgendaItem::resetMove() | 657 | void KOAgendaItem::resetMove() |
657 | { | 658 | { |
658 | mCellX = mStartCellX; | 659 | mCellX = mStartCellX; |
659 | mCellXWidth = mStartCellXWidth; | 660 | mCellXWidth = mStartCellXWidth; |
660 | mCellYTop = mStartCellYTop; | 661 | mCellYTop = mStartCellYTop; |
661 | mCellYBottom = mStartCellYBottom; | 662 | mCellYBottom = mStartCellYBottom; |
662 | } | 663 | } |
663 | 664 | ||
664 | void KOAgendaItem::moveRelative(int dx, int dy) | 665 | void KOAgendaItem::moveRelative(int dx, int dy) |
665 | { | 666 | { |
666 | int newX = cellX() + dx; | 667 | int newX = cellX() + dx; |
667 | int newXWidth = cellXWidth() + dx; | 668 | int newXWidth = cellXWidth() + dx; |
668 | int newYTop = cellYTop() + dy; | 669 | int newYTop = cellYTop() + dy; |
669 | int newYBottom = cellYBottom() + dy; | 670 | int newYBottom = cellYBottom() + dy; |
670 | setCellXY(newX,newYTop,newYBottom); | 671 | setCellXY(newX,newYTop,newYBottom); |
671 | setCellXWidth(newXWidth); | 672 | setCellXWidth(newXWidth); |
672 | } | 673 | } |
673 | 674 | ||
674 | void KOAgendaItem::expandTop(int dy) | 675 | void KOAgendaItem::expandTop(int dy) |
675 | { | 676 | { |
676 | int newYTop = cellYTop() + dy; | 677 | int newYTop = cellYTop() + dy; |
677 | int newYBottom = cellYBottom(); | 678 | int newYBottom = cellYBottom(); |
678 | if (newYTop > newYBottom) newYTop = newYBottom; | 679 | if (newYTop > newYBottom) newYTop = newYBottom; |
679 | setCellY(newYTop, newYBottom); | 680 | setCellY(newYTop, newYBottom); |
680 | } | 681 | } |
681 | 682 | ||
682 | void KOAgendaItem::expandBottom(int dy) | 683 | void KOAgendaItem::expandBottom(int dy) |
683 | { | 684 | { |
684 | int newYTop = cellYTop(); | 685 | int newYTop = cellYTop(); |
685 | int newYBottom = cellYBottom() + dy; | 686 | int newYBottom = cellYBottom() + dy; |
686 | if (newYBottom < newYTop) newYBottom = newYTop; | 687 | if (newYBottom < newYTop) newYBottom = newYTop; |
687 | setCellY(newYTop, newYBottom); | 688 | setCellY(newYTop, newYBottom); |
688 | } | 689 | } |
689 | 690 | ||
690 | void KOAgendaItem::expandLeft(int dx) | 691 | void KOAgendaItem::expandLeft(int dx) |
691 | { | 692 | { |
692 | int newX = cellX() + dx; | 693 | int newX = cellX() + dx; |
693 | int newXWidth = cellXWidth(); | 694 | int newXWidth = cellXWidth(); |
694 | if (newX > newXWidth) newX = newXWidth; | 695 | if (newX > newXWidth) newX = newXWidth; |
695 | setCellX(newX,newXWidth); | 696 | setCellX(newX,newXWidth); |
696 | } | 697 | } |
697 | 698 | ||
698 | void KOAgendaItem::expandRight(int dx) | 699 | void KOAgendaItem::expandRight(int dx) |
699 | { | 700 | { |
700 | int newX = cellX(); | 701 | int newX = cellX(); |
701 | int newXWidth = cellXWidth() + dx; | 702 | int newXWidth = cellXWidth() + dx; |
702 | if (newXWidth < newX) newXWidth = newX; | 703 | if (newXWidth < newX) newXWidth = newX; |
703 | setCellX(newX,newXWidth); | 704 | setCellX(newX,newXWidth); |
704 | } | 705 | } |
705 | 706 | ||
706 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 707 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
707 | { | 708 | { |
708 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 709 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
709 | return mToolTipGroup; | 710 | return mToolTipGroup; |
710 | } | 711 | } |
711 | 712 | ||
712 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 713 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
713 | { | 714 | { |
714 | #ifndef KORG_NODND | 715 | #ifndef KORG_NODND |
715 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 716 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
716 | !QTextDrag::canDecode( e ) ) { | 717 | !QTextDrag::canDecode( e ) ) { |
717 | e->ignore(); | 718 | e->ignore(); |
718 | return; | 719 | return; |
719 | } | 720 | } |
720 | e->accept(); | 721 | e->accept(); |
721 | #endif | 722 | #endif |
722 | } | 723 | } |
723 | 724 | ||
724 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 725 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
725 | { | 726 | { |
726 | #ifndef KORG_NODND | 727 | #ifndef KORG_NODND |
727 | QString text; | 728 | QString text; |
728 | if(QTextDrag::decode(e,text)) | 729 | if(QTextDrag::decode(e,text)) |
729 | { | 730 | { |
730 | kdDebug() << "Dropped : " << text << endl; | 731 | kdDebug() << "Dropped : " << text << endl; |
731 | QStringList emails = QStringList::split(",",text); | 732 | QStringList emails = QStringList::split(",",text); |
732 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 733 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
733 | kdDebug() << " Email: " << (*it) << endl; | 734 | kdDebug() << " Email: " << (*it) << endl; |
734 | int pos = (*it).find("<"); | 735 | int pos = (*it).find("<"); |
735 | QString name = (*it).left(pos); | 736 | QString name = (*it).left(pos); |
736 | QString email = (*it).mid(pos); | 737 | QString email = (*it).mid(pos); |
737 | if (!email.isEmpty()) { | 738 | if (!email.isEmpty()) { |
738 | mIncidence->addAttendee(new Attendee(name,email)); | 739 | mIncidence->addAttendee(new Attendee(name,email)); |
739 | } | 740 | } |
740 | } | 741 | } |
741 | } | 742 | } |
742 | #endif | 743 | #endif |
743 | } | 744 | } |
744 | 745 | ||
745 | 746 | ||
746 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 747 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
747 | { | 748 | { |
748 | return mConflictItems; | 749 | return mConflictItems; |
749 | } | 750 | } |
750 | 751 | ||
751 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 752 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
752 | { | 753 | { |
753 | mConflictItems = ci; | 754 | mConflictItems = ci; |
754 | KOAgendaItem *item; | 755 | KOAgendaItem *item; |
755 | for ( item=mConflictItems.first(); item != 0; | 756 | for ( item=mConflictItems.first(); item != 0; |
756 | item=mConflictItems.next() ) { | 757 | item=mConflictItems.next() ) { |
757 | item->addConflictItem(this); | 758 | item->addConflictItem(this); |
758 | } | 759 | } |
759 | } | 760 | } |
760 | 761 | ||
761 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 762 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
762 | { | 763 | { |
763 | if (mConflictItems.find(ci)<0) | 764 | if (mConflictItems.find(ci)<0) |
764 | mConflictItems.append(ci); | 765 | mConflictItems.append(ci); |
765 | } | 766 | } |