author | zautrix <zautrix> | 2005-02-01 08:44:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-01 08:44:35 (UTC) |
commit | 00b559c52051c05d6df41724b207a038c0e548bf (patch) (unidiff) | |
tree | e48f4ef8d51a99e54ba713a8f8f9845b3db5c741 /korganizer | |
parent | 74c59cea6db3e3a1c0a5922f7fa12ada24f4672b (diff) | |
download | kdepimpi-00b559c52051c05d6df41724b207a038c0e548bf.zip kdepimpi-00b559c52051c05d6df41724b207a038c0e548bf.tar.gz kdepimpi-00b559c52051c05d6df41724b207a038c0e548bf.tar.bz2 |
two font fixes
-rw-r--r-- | korganizer/koagendaview.cpp | 1 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index d43712f..aa36553 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -55,1526 +55,1527 @@ | |||
55 | #include <kcalendarsystem.h> | 55 | #include <kcalendarsystem.h> |
56 | 56 | ||
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #ifndef KORG_NOPLUGINS | 58 | #ifndef KORG_NOPLUGINS |
59 | #include "kocore.h" | 59 | #include "kocore.h" |
60 | #endif | 60 | #endif |
61 | #include "koprefs.h" | 61 | #include "koprefs.h" |
62 | #include "koagenda.h" | 62 | #include "koagenda.h" |
63 | #include "koagendaitem.h" | 63 | #include "koagendaitem.h" |
64 | #ifndef KORG_NOPRINTER | 64 | #ifndef KORG_NOPRINTER |
65 | #include "calprinter.h" | 65 | #include "calprinter.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #include "koagendaview.h" | 68 | #include "koagendaview.h" |
69 | //#include "koagendaview.moc" | 69 | //#include "koagendaview.moc" |
70 | 70 | ||
71 | //extern bool globalFlagBlockPainting; | 71 | //extern bool globalFlagBlockPainting; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 79 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
80 | QScrollView(parent,name,f) | 80 | QScrollView(parent,name,f) |
81 | { | 81 | { |
82 | mRows = rows; | 82 | mRows = rows; |
83 | 83 | ||
84 | setMinimumHeight( 20 ); | 84 | setMinimumHeight( 20 ); |
85 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 85 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
86 | 86 | ||
87 | enableClipper(true); | 87 | enableClipper(true); |
88 | 88 | ||
89 | setHScrollBarMode(AlwaysOff); | 89 | setHScrollBarMode(AlwaysOff); |
90 | setVScrollBarMode(AlwaysOff); | 90 | setVScrollBarMode(AlwaysOff); |
91 | 91 | ||
92 | resizeContents(50,mRows * mCellHeight); | 92 | resizeContents(50,mRows * mCellHeight); |
93 | 93 | ||
94 | viewport()->setBackgroundMode( PaletteBackground ); | 94 | viewport()->setBackgroundMode( PaletteBackground ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void TimeLabels::setCellHeight(int height) | 97 | void TimeLabels::setCellHeight(int height) |
98 | { | 98 | { |
99 | mCellHeight = height; | 99 | mCellHeight = height; |
100 | } | 100 | } |
101 | 101 | ||
102 | /* | 102 | /* |
103 | Optimization so that only the "dirty" portion of the scroll view | 103 | Optimization so that only the "dirty" portion of the scroll view |
104 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 104 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
105 | */ | 105 | */ |
106 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 106 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
107 | { | 107 | { |
108 | 108 | ||
109 | // if ( globalFlagBlockAgenda ) | 109 | // if ( globalFlagBlockAgenda ) |
110 | // return; | 110 | // return; |
111 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 111 | // bug: the parameters cx, cy, cw, ch are the areas that need to be |
112 | // redrawn, not the area of the widget. unfortunately, this | 112 | // redrawn, not the area of the widget. unfortunately, this |
113 | // code assumes the latter... | 113 | // code assumes the latter... |
114 | 114 | ||
115 | // now, for a workaround... | 115 | // now, for a workaround... |
116 | // these two assignments fix the weird redraw bug | 116 | // these two assignments fix the weird redraw bug |
117 | cx = contentsX() + 2; | 117 | cx = contentsX() + 2; |
118 | cw = contentsWidth() - 2; | 118 | cw = contentsWidth() - 2; |
119 | // end of workaround | 119 | // end of workaround |
120 | 120 | ||
121 | int cell = ((int)(cy/mCellHeight)); | 121 | int cell = ((int)(cy/mCellHeight)); |
122 | int y = cell * mCellHeight; | 122 | int y = cell * mCellHeight; |
123 | QFontMetrics fm = fontMetrics(); | 123 | QFontMetrics fm = fontMetrics(); |
124 | QString hour; | 124 | QString hour; |
125 | QString suffix; | 125 | QString suffix; |
126 | QString fullTime; | 126 | QString fullTime; |
127 | int tW = fm.width("24:00i"); | 127 | int tW = fm.width("24:00i"); |
128 | 128 | ||
129 | while (y < cy + ch) { | 129 | while (y < cy + ch) { |
130 | p->drawLine(cx,y,cx+tW,y); | 130 | p->drawLine(cx,y,cx+tW,y); |
131 | hour.setNum(cell); | 131 | hour.setNum(cell); |
132 | suffix = "am"; | 132 | suffix = "am"; |
133 | 133 | ||
134 | // handle 24h and am/pm time formats | 134 | // handle 24h and am/pm time formats |
135 | if (KGlobal::locale()->use12Clock()) { | 135 | if (KGlobal::locale()->use12Clock()) { |
136 | if (cell > 11) suffix = "pm"; | 136 | if (cell > 11) suffix = "pm"; |
137 | if (cell == 0) hour.setNum(12); | 137 | if (cell == 0) hour.setNum(12); |
138 | if (cell > 12) hour.setNum(cell - 12); | 138 | if (cell > 12) hour.setNum(cell - 12); |
139 | } else { | 139 | } else { |
140 | suffix = ":00"; | 140 | suffix = ":00"; |
141 | } | 141 | } |
142 | 142 | ||
143 | // create string in format of "XX:XX" or "XXpm/am" | 143 | // create string in format of "XX:XX" or "XXpm/am" |
144 | fullTime = hour + suffix; | 144 | fullTime = hour + suffix; |
145 | 145 | ||
146 | // center and draw the time label | 146 | // center and draw the time label |
147 | int timeWidth = fm.width(fullTime+"i"); | 147 | int timeWidth = fm.width(fullTime+"i"); |
148 | int offset = this->width() - timeWidth; | 148 | int offset = this->width() - timeWidth; |
149 | int borderWidth = 5; | 149 | int borderWidth = 5; |
150 | int timeHeight = fm.height(); | 150 | int timeHeight = fm.height(); |
151 | timeHeight = timeHeight + 2 - ( timeHeight / 4 ); | 151 | timeHeight = timeHeight + 2 - ( timeHeight / 4 ); |
152 | p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); | 152 | p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); |
153 | 153 | ||
154 | // increment indices | 154 | // increment indices |
155 | y += mCellHeight; | 155 | y += mCellHeight; |
156 | cell++; | 156 | cell++; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | /** | 160 | /** |
161 | Calculates the minimum width. | 161 | Calculates the minimum width. |
162 | */ | 162 | */ |
163 | int TimeLabels::minimumWidth() const | 163 | int TimeLabels::minimumWidth() const |
164 | { | 164 | { |
165 | QFontMetrics fm = fontMetrics(); | 165 | QFontMetrics fm = fontMetrics(); |
166 | 166 | ||
167 | //TODO: calculate this value | 167 | //TODO: calculate this value |
168 | int borderWidth = 4; | 168 | int borderWidth = 4; |
169 | 169 | ||
170 | // the maximum width possible | 170 | // the maximum width possible |
171 | int width = fm.width("88:88x") + borderWidth; | 171 | int width = fm.width("88:88x") + borderWidth; |
172 | 172 | ||
173 | return width; | 173 | return width; |
174 | } | 174 | } |
175 | 175 | ||
176 | /** updates widget's internal state */ | 176 | /** updates widget's internal state */ |
177 | void TimeLabels::updateConfig() | 177 | void TimeLabels::updateConfig() |
178 | { | 178 | { |
179 | // set the font | 179 | // set the font |
180 | // config->setGroup("Fonts"); | 180 | // config->setGroup("Fonts"); |
181 | // QFont font = config->readFontEntry("TimeBar Font"); | 181 | // QFont font = config->readFontEntry("TimeBar Font"); |
182 | setFont(KOPrefs::instance()->mTimeBarFont); | 182 | setFont(KOPrefs::instance()->mTimeBarFont); |
183 | 183 | ||
184 | // update geometry restrictions based on new settings | 184 | // update geometry restrictions based on new settings |
185 | setFixedWidth(minimumWidth()); | 185 | setFixedWidth(minimumWidth()); |
186 | 186 | ||
187 | // update HourSize | 187 | // update HourSize |
188 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 188 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
189 | resizeContents(50,mRows * mCellHeight); | 189 | resizeContents(50,mRows * mCellHeight); |
190 | } | 190 | } |
191 | 191 | ||
192 | /** update time label positions */ | 192 | /** update time label positions */ |
193 | void TimeLabels::positionChanged() | 193 | void TimeLabels::positionChanged() |
194 | { | 194 | { |
195 | int adjustment = mAgenda->contentsY(); | 195 | int adjustment = mAgenda->contentsY(); |
196 | setContentsPos(0, adjustment); | 196 | setContentsPos(0, adjustment); |
197 | } | 197 | } |
198 | 198 | ||
199 | /** */ | 199 | /** */ |
200 | void TimeLabels::setAgenda(KOAgenda* agenda) | 200 | void TimeLabels::setAgenda(KOAgenda* agenda) |
201 | { | 201 | { |
202 | mAgenda = agenda; | 202 | mAgenda = agenda; |
203 | } | 203 | } |
204 | 204 | ||
205 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 205 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
206 | { | 206 | { |
207 | mMouseDownY = e->pos().y(); | 207 | mMouseDownY = e->pos().y(); |
208 | mOrgCap = topLevelWidget()->caption(); | 208 | mOrgCap = topLevelWidget()->caption(); |
209 | } | 209 | } |
210 | 210 | ||
211 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 211 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
212 | { | 212 | { |
213 | int diff = mMouseDownY - e->pos().y(); | 213 | int diff = mMouseDownY - e->pos().y(); |
214 | if ( diff < 10 && diff > -10 ) | 214 | if ( diff < 10 && diff > -10 ) |
215 | return; | 215 | return; |
216 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 216 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
217 | if ( tSize < 4 ) | 217 | if ( tSize < 4 ) |
218 | tSize = 4; | 218 | tSize = 4; |
219 | if ( tSize > 22 ) | 219 | if ( tSize > 22 ) |
220 | tSize = 22; | 220 | tSize = 22; |
221 | tSize = (tSize-2)/2; | 221 | tSize = (tSize-2)/2; |
222 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 222 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
223 | 223 | ||
224 | } | 224 | } |
225 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 225 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
226 | { | 226 | { |
227 | topLevelWidget()->setCaption( mOrgCap ); | 227 | topLevelWidget()->setCaption( mOrgCap ); |
228 | int diff = mMouseDownY - e->pos().y(); | 228 | int diff = mMouseDownY - e->pos().y(); |
229 | if ( diff < 10 && diff > -10 ) | 229 | if ( diff < 10 && diff > -10 ) |
230 | return; | 230 | return; |
231 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 231 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
232 | if ( tSize < 4 ) | 232 | if ( tSize < 4 ) |
233 | tSize = 4; | 233 | tSize = 4; |
234 | if ( tSize > 22 ) | 234 | if ( tSize > 22 ) |
235 | tSize = 22; | 235 | tSize = 22; |
236 | tSize = (tSize/2)*2; | 236 | tSize = (tSize/2)*2; |
237 | if ( tSize == KOPrefs::instance()->mHourSize ) | 237 | if ( tSize == KOPrefs::instance()->mHourSize ) |
238 | return; | 238 | return; |
239 | KOPrefs::instance()->mHourSize = tSize; | 239 | KOPrefs::instance()->mHourSize = tSize; |
240 | emit scaleChanged(); | 240 | emit scaleChanged(); |
241 | } | 241 | } |
242 | 242 | ||
243 | /** This is called in response to repaint() */ | 243 | /** This is called in response to repaint() */ |
244 | void TimeLabels::paintEvent(QPaintEvent*) | 244 | void TimeLabels::paintEvent(QPaintEvent*) |
245 | { | 245 | { |
246 | 246 | ||
247 | // kdDebug() << "paintevent..." << endl; | 247 | // kdDebug() << "paintevent..." << endl; |
248 | // this is another hack! | 248 | // this is another hack! |
249 | // QPainter painter(this); | 249 | // QPainter painter(this); |
250 | //QString c | 250 | //QString c |
251 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 251 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
252 | } | 252 | } |
253 | 253 | ||
254 | //////////////////////////////////////////////////////////////////////////// | 254 | //////////////////////////////////////////////////////////////////////////// |
255 | 255 | ||
256 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 256 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
257 | : QFrame(parent,name) | 257 | : QFrame(parent,name) |
258 | { | 258 | { |
259 | mColumns = 1; | 259 | mColumns = 1; |
260 | mTopBox = 0; | 260 | mTopBox = 0; |
261 | mLocation = loc; | 261 | mLocation = loc; |
262 | mTopLayout = 0; | 262 | mTopLayout = 0; |
263 | mPaintWidget = 0; | 263 | mPaintWidget = 0; |
264 | mXOffset = 0; | 264 | mXOffset = 0; |
265 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 265 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
266 | else mPixmap = SmallIcon("1downarrow"); | 266 | else mPixmap = SmallIcon("1downarrow"); |
267 | mEnabled.resize(mColumns); | 267 | mEnabled.resize(mColumns); |
268 | if (mLocation == Top) | 268 | if (mLocation == Top) |
269 | setMaximumHeight(0); | 269 | setMaximumHeight(0); |
270 | else | 270 | else |
271 | setMinimumHeight(mPixmap.height()); | 271 | setMinimumHeight(mPixmap.height()); |
272 | } | 272 | } |
273 | 273 | ||
274 | EventIndicator::~EventIndicator() | 274 | EventIndicator::~EventIndicator() |
275 | { | 275 | { |
276 | } | 276 | } |
277 | 277 | ||
278 | void EventIndicator::drawContents(QPainter *p) | 278 | void EventIndicator::drawContents(QPainter *p) |
279 | { | 279 | { |
280 | 280 | ||
281 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 281 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
282 | KDGanttSplitterHandle* han = 0; | 282 | KDGanttSplitterHandle* han = 0; |
283 | if ( mPaintWidget ) | 283 | if ( mPaintWidget ) |
284 | han = mPaintWidget->firstHandle(); | 284 | han = mPaintWidget->firstHandle(); |
285 | if ( ! han ) { | 285 | if ( ! han ) { |
286 | int i; | 286 | int i; |
287 | for(i=0;i<mColumns;++i) { | 287 | for(i=0;i<mColumns;++i) { |
288 | if (mEnabled[i]) { | 288 | if (mEnabled[i]) { |
289 | int cellWidth = contentsRect().right()/mColumns; | 289 | int cellWidth = contentsRect().right()/mColumns; |
290 | int xOffset = KOGlobals::self()->reverseLayout() ? | 290 | int xOffset = KOGlobals::self()->reverseLayout() ? |
291 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 291 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
292 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 292 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
293 | p->drawPixmap(QPoint(xOffset,0),mPixmap); | 293 | p->drawPixmap(QPoint(xOffset,0),mPixmap); |
294 | } | 294 | } |
295 | } | 295 | } |
296 | } else { | 296 | } else { |
297 | han->repaint(); | 297 | han->repaint(); |
298 | //mPaintWidget->setBackgroundColor( red ); | 298 | //mPaintWidget->setBackgroundColor( red ); |
299 | 299 | ||
300 | QPainter pa( han ); | 300 | QPainter pa( han ); |
301 | int i; | 301 | int i; |
302 | bool setColor = false; | 302 | bool setColor = false; |
303 | for(i=0;i<mColumns;++i) { | 303 | for(i=0;i<mColumns;++i) { |
304 | if (mEnabled[i]) { | 304 | if (mEnabled[i]) { |
305 | setColor = true; | 305 | setColor = true; |
306 | 306 | ||
307 | int cellWidth = contentsRect().right()/mColumns; | 307 | int cellWidth = contentsRect().right()/mColumns; |
308 | int xOffset = KOGlobals::self()->reverseLayout() ? | 308 | int xOffset = KOGlobals::self()->reverseLayout() ? |
309 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 309 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
310 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 310 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
311 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 311 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
312 | //qDebug("222draw pix %d ",xOffset ); | 312 | //qDebug("222draw pix %d ",xOffset ); |
313 | 313 | ||
314 | } | 314 | } |
315 | 315 | ||
316 | } | 316 | } |
317 | pa.end(); | 317 | pa.end(); |
318 | 318 | ||
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | void EventIndicator::setXOffset( int x ) | 322 | void EventIndicator::setXOffset( int x ) |
323 | { | 323 | { |
324 | mXOffset = x; | 324 | mXOffset = x; |
325 | } | 325 | } |
326 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 326 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
327 | { | 327 | { |
328 | mPaintWidget = w; | 328 | mPaintWidget = w; |
329 | } | 329 | } |
330 | void EventIndicator::changeColumns(int columns) | 330 | void EventIndicator::changeColumns(int columns) |
331 | { | 331 | { |
332 | mColumns = columns; | 332 | mColumns = columns; |
333 | mEnabled.resize(mColumns); | 333 | mEnabled.resize(mColumns); |
334 | 334 | ||
335 | update(); | 335 | update(); |
336 | } | 336 | } |
337 | 337 | ||
338 | void EventIndicator::enableColumn(int column, bool enable) | 338 | void EventIndicator::enableColumn(int column, bool enable) |
339 | { | 339 | { |
340 | mEnabled[column] = enable; | 340 | mEnabled[column] = enable; |
341 | } | 341 | } |
342 | 342 | ||
343 | 343 | ||
344 | //////////////////////////////////////////////////////////////////////////// | 344 | //////////////////////////////////////////////////////////////////////////// |
345 | //////////////////////////////////////////////////////////////////////////// | 345 | //////////////////////////////////////////////////////////////////////////// |
346 | //////////////////////////////////////////////////////////////////////////// | 346 | //////////////////////////////////////////////////////////////////////////// |
347 | 347 | ||
348 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 348 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
349 | KOEventView (cal,parent,name) | 349 | KOEventView (cal,parent,name) |
350 | { | 350 | { |
351 | mBlockUpdating = true; | 351 | mBlockUpdating = true; |
352 | mStartHour = 8; | 352 | mStartHour = 8; |
353 | mSelectedDates.append(QDate::currentDate()); | 353 | mSelectedDates.append(QDate::currentDate()); |
354 | 354 | ||
355 | mLayoutDayLabels = 0; | 355 | mLayoutDayLabels = 0; |
356 | mDayLabelsFrame = 0; | 356 | mDayLabelsFrame = 0; |
357 | mDayLabels = 0; | 357 | mDayLabels = 0; |
358 | bool isRTL = KOGlobals::self()->reverseLayout(); | 358 | bool isRTL = KOGlobals::self()->reverseLayout(); |
359 | 359 | ||
360 | if ( KOPrefs::instance()->mVerticalScreen ) { | 360 | if ( KOPrefs::instance()->mVerticalScreen ) { |
361 | mExpandedPixmap = SmallIcon( "1downarrow" ); | 361 | mExpandedPixmap = SmallIcon( "1downarrow" ); |
362 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); | 362 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); |
363 | } else { | 363 | } else { |
364 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); | 364 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); |
365 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); | 365 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); |
366 | } | 366 | } |
367 | 367 | ||
368 | QBoxLayout *topLayout = new QVBoxLayout(this); | 368 | QBoxLayout *topLayout = new QVBoxLayout(this); |
369 | 369 | ||
370 | // Create day name labels for agenda columns | 370 | // Create day name labels for agenda columns |
371 | mDayLabelsFrame = new QHBox(this); | 371 | mDayLabelsFrame = new QHBox(this); |
372 | topLayout->addWidget(mDayLabelsFrame); | 372 | topLayout->addWidget(mDayLabelsFrame); |
373 | mDayLabels = new QFrame (mDayLabelsFrame); | 373 | mDayLabels = new QFrame (mDayLabelsFrame); |
374 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 374 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
375 | // Create agenda splitter | 375 | // Create agenda splitter |
376 | #ifndef KORG_NOSPLITTER | 376 | #ifndef KORG_NOSPLITTER |
377 | mSplitterAgenda = new QSplitter(Vertical,this); | 377 | mSplitterAgenda = new QSplitter(Vertical,this); |
378 | topLayout->addWidget(mSplitterAgenda); | 378 | topLayout->addWidget(mSplitterAgenda); |
379 | mSplitterAgenda->setOpaqueResize(); | 379 | mSplitterAgenda->setOpaqueResize(); |
380 | 380 | ||
381 | mAllDayFrame = new QHBox(mSplitterAgenda); | 381 | mAllDayFrame = new QHBox(mSplitterAgenda); |
382 | 382 | ||
383 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 383 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
384 | #else | 384 | #else |
385 | #if 0 | 385 | #if 0 |
386 | QWidget *mainBox = new QWidget( this ); | 386 | QWidget *mainBox = new QWidget( this ); |
387 | topLayout->addWidget( mainBox ); | 387 | topLayout->addWidget( mainBox ); |
388 | QBoxLayout *mainLayout = new QVBoxLayout(mainBox); | 388 | QBoxLayout *mainLayout = new QVBoxLayout(mainBox); |
389 | mAllDayFrame = new QHBox(mainBox); | 389 | mAllDayFrame = new QHBox(mainBox); |
390 | mainLayout->addWidget(mAllDayFrame); | 390 | mainLayout->addWidget(mAllDayFrame); |
391 | mainLayout->setStretchFactor( mAllDayFrame, 0 ); | 391 | mainLayout->setStretchFactor( mAllDayFrame, 0 ); |
392 | mAllDayFrame->setFocusPolicy(NoFocus); | 392 | mAllDayFrame->setFocusPolicy(NoFocus); |
393 | QWidget *agendaFrame = new QWidget(mainBox); | 393 | QWidget *agendaFrame = new QWidget(mainBox); |
394 | mainLayout->addWidget(agendaFrame); | 394 | mainLayout->addWidget(agendaFrame); |
395 | mainLayout->setStretchFactor( agendaFrame, 10 ); | 395 | mainLayout->setStretchFactor( agendaFrame, 10 ); |
396 | 396 | ||
397 | agendaFrame->setFocusPolicy(NoFocus); | 397 | agendaFrame->setFocusPolicy(NoFocus); |
398 | #endif | 398 | #endif |
399 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 399 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
400 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 400 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
401 | topLayout->addWidget( mSplitterAgenda ); | 401 | topLayout->addWidget( mSplitterAgenda ); |
402 | mAllDayFrame = new QHBox(mSplitterAgenda); | 402 | mAllDayFrame = new QHBox(mSplitterAgenda); |
403 | mAllDayFrame->setFocusPolicy(NoFocus); | 403 | mAllDayFrame->setFocusPolicy(NoFocus); |
404 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 404 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
405 | agendaFrame->setFocusPolicy(NoFocus); | 405 | agendaFrame->setFocusPolicy(NoFocus); |
406 | 406 | ||
407 | #endif | 407 | #endif |
408 | 408 | ||
409 | // Create all-day agenda widget | 409 | // Create all-day agenda widget |
410 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 410 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
411 | 411 | ||
412 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 412 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
413 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 413 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
414 | int widebut = mExpandButton->sizeHint().width(); | 414 | int widebut = mExpandButton->sizeHint().width(); |
415 | if ( QApplication::desktop()->width() < 480 ) | 415 | if ( QApplication::desktop()->width() < 480 ) |
416 | widebut = widebut*2; | 416 | widebut = widebut*2; |
417 | else | 417 | else |
418 | widebut = (widebut*3) / 2; | 418 | widebut = (widebut*3) / 2; |
419 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 419 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
420 | // QSizePolicy::Fixed ) ); | 420 | // QSizePolicy::Fixed ) ); |
421 | mExpandButton->setFixedSize( widebut, widebut); | 421 | mExpandButton->setFixedSize( widebut, widebut); |
422 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 422 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
423 | mExpandButton->setFocusPolicy(NoFocus); | 423 | mExpandButton->setFocusPolicy(NoFocus); |
424 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 424 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
425 | mAllDayAgenda->setFocusPolicy(NoFocus); | 425 | mAllDayAgenda->setFocusPolicy(NoFocus); |
426 | QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); | 426 | QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); |
427 | 427 | ||
428 | // Create event context menu for all day agenda | 428 | // Create event context menu for all day agenda |
429 | mAllDayAgendaPopup = eventPopup(); | 429 | mAllDayAgendaPopup = eventPopup(); |
430 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 430 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
431 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 431 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
432 | 432 | ||
433 | // Create agenda frame | 433 | // Create agenda frame |
434 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); | 434 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); |
435 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 435 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
436 | 436 | ||
437 | // create event indicator bars | 437 | // create event indicator bars |
438 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 438 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
439 | agendaLayout->addWidget(mEventIndicatorTop,0,1); | 439 | agendaLayout->addWidget(mEventIndicatorTop,0,1); |
440 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 440 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
441 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 441 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
442 | agendaFrame); | 442 | agendaFrame); |
443 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); | 443 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); |
444 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 444 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
445 | agendaLayout->addWidget(dummyAgendaRight,0,2); | 445 | agendaLayout->addWidget(dummyAgendaRight,0,2); |
446 | 446 | ||
447 | // Create time labels | 447 | // Create time labels |
448 | mTimeLabels = new TimeLabels(24,agendaFrame); | 448 | mTimeLabels = new TimeLabels(24,agendaFrame); |
449 | agendaLayout->addWidget(mTimeLabels,1,0); | 449 | agendaLayout->addWidget(mTimeLabels,1,0); |
450 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 450 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
451 | this,SLOT(updateConfig())); | 451 | this,SLOT(updateConfig())); |
452 | 452 | ||
453 | // Create agenda | 453 | // Create agenda |
454 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 454 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
455 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); | 455 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); |
456 | agendaLayout->setColStretch(1,1); | 456 | agendaLayout->setColStretch(1,1); |
457 | mAgenda->setFocusPolicy(NoFocus); | 457 | mAgenda->setFocusPolicy(NoFocus); |
458 | // Create event context menu for agenda | 458 | // Create event context menu for agenda |
459 | mAgendaPopup = eventPopup(); | 459 | mAgendaPopup = eventPopup(); |
460 | 460 | ||
461 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 461 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
462 | i18n("Toggle Alarm"),mAgenda, | 462 | i18n("Toggle Alarm"),mAgenda, |
463 | SLOT(popupAlarm()),true); | 463 | SLOT(popupAlarm()),true); |
464 | 464 | ||
465 | 465 | ||
466 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 466 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
467 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 467 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
468 | 468 | ||
469 | // make connections between dependent widgets | 469 | // make connections between dependent widgets |
470 | mTimeLabels->setAgenda(mAgenda); | 470 | mTimeLabels->setAgenda(mAgenda); |
471 | 471 | ||
472 | // Update widgets to reflect user preferences | 472 | // Update widgets to reflect user preferences |
473 | // updateConfig(); | 473 | // updateConfig(); |
474 | 474 | ||
475 | // createDayLabels(); | 475 | // createDayLabels(); |
476 | 476 | ||
477 | // these blank widgets make the All Day Event box line up with the agenda | 477 | // these blank widgets make the All Day Event box line up with the agenda |
478 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 478 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
479 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 479 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
480 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 480 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
481 | 481 | ||
482 | // Scrolling | 482 | // Scrolling |
483 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 483 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
484 | mTimeLabels, SLOT(positionChanged())); | 484 | mTimeLabels, SLOT(positionChanged())); |
485 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 485 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
486 | SLOT(setContentsPos(int))); | 486 | SLOT(setContentsPos(int))); |
487 | 487 | ||
488 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 488 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
489 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 489 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
490 | 490 | ||
491 | // Create/Show/Edit/Delete Event | 491 | // Create/Show/Edit/Delete Event |
492 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 492 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
493 | SLOT(newEvent(int,int))); | 493 | SLOT(newEvent(int,int))); |
494 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 494 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
495 | SLOT(newTodo(int,int))); | 495 | SLOT(newTodo(int,int))); |
496 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 496 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
497 | SLOT(newEvent(int,int,int,int))); | 497 | SLOT(newEvent(int,int,int,int))); |
498 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 498 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
499 | SLOT(newEventAllDay(int,int))); | 499 | SLOT(newEventAllDay(int,int))); |
500 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 500 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
501 | SLOT(newTodoAllDay(int,int))); | 501 | SLOT(newTodoAllDay(int,int))); |
502 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 502 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
503 | SLOT(newEventAllDay(int,int))); | 503 | SLOT(newEventAllDay(int,int))); |
504 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 504 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
505 | SLOT(newTimeSpanSelected(int,int,int,int))); | 505 | SLOT(newTimeSpanSelected(int,int,int,int))); |
506 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 506 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
507 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 507 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
508 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 508 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
509 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 509 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
510 | 510 | ||
511 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 511 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
512 | SIGNAL(editIncidenceSignal(Incidence *))); | 512 | SIGNAL(editIncidenceSignal(Incidence *))); |
513 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 513 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
514 | SIGNAL(editIncidenceSignal(Incidence *))); | 514 | SIGNAL(editIncidenceSignal(Incidence *))); |
515 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 515 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
516 | SIGNAL(showIncidenceSignal(Incidence *))); | 516 | SIGNAL(showIncidenceSignal(Incidence *))); |
517 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 517 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
518 | SIGNAL(showIncidenceSignal(Incidence *))); | 518 | SIGNAL(showIncidenceSignal(Incidence *))); |
519 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 519 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
520 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 520 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
521 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 521 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
522 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 522 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
523 | 523 | ||
524 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 524 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
525 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 525 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
526 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 526 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
527 | SLOT(updateEventDates(KOAgendaItem *, int))); | 527 | SLOT(updateEventDates(KOAgendaItem *, int))); |
528 | 528 | ||
529 | // event indicator update | 529 | // event indicator update |
530 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 530 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
531 | SLOT(updateEventIndicatorTop(int))); | 531 | SLOT(updateEventIndicatorTop(int))); |
532 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 532 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
533 | SLOT(updateEventIndicatorBottom(int))); | 533 | SLOT(updateEventIndicatorBottom(int))); |
534 | // drag signals | 534 | // drag signals |
535 | /* | 535 | /* |
536 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 536 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
537 | SLOT(startDrag(Event *))); | 537 | SLOT(startDrag(Event *))); |
538 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 538 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
539 | SLOT(startDrag(Event *))); | 539 | SLOT(startDrag(Event *))); |
540 | */ | 540 | */ |
541 | // synchronize selections | 541 | // synchronize selections |
542 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 542 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
543 | mAllDayAgenda, SLOT( deselectItem() ) ); | 543 | mAllDayAgenda, SLOT( deselectItem() ) ); |
544 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 544 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
545 | mAgenda, SLOT( deselectItem() ) ); | 545 | mAgenda, SLOT( deselectItem() ) ); |
546 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 546 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
547 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 547 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
548 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 548 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
549 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 549 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
550 | connect( mAgenda, SIGNAL( resizedSignal() ), | 550 | connect( mAgenda, SIGNAL( resizedSignal() ), |
551 | SLOT( updateConfig( ) ) ); | 551 | SLOT( updateConfig( ) ) ); |
552 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 552 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
553 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 553 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
554 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 554 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
555 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 555 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
556 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 556 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
557 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 557 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
558 | 558 | ||
559 | 559 | ||
560 | } | 560 | } |
561 | 561 | ||
562 | void KOAgendaView::toggleAllDay() | 562 | void KOAgendaView::toggleAllDay() |
563 | { | 563 | { |
564 | if ( mSplitterAgenda->firstHandle() ) | 564 | if ( mSplitterAgenda->firstHandle() ) |
565 | mSplitterAgenda->firstHandle()->toggle(); | 565 | mSplitterAgenda->firstHandle()->toggle(); |
566 | } | 566 | } |
567 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 567 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
568 | { | 568 | { |
569 | calendar()->addIncidence( inc ); | 569 | calendar()->addIncidence( inc ); |
570 | 570 | ||
571 | if ( incOld ) { | 571 | if ( incOld ) { |
572 | if ( incOld->type() == "Todo" ) | 572 | if ( incOld->type() == "Todo" ) |
573 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 573 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
574 | else | 574 | else |
575 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 575 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
576 | } | 576 | } |
577 | 577 | ||
578 | } | 578 | } |
579 | 579 | ||
580 | KOAgendaView::~KOAgendaView() | 580 | KOAgendaView::~KOAgendaView() |
581 | { | 581 | { |
582 | delete mAgendaPopup; | 582 | delete mAgendaPopup; |
583 | delete mAllDayAgendaPopup; | 583 | delete mAllDayAgendaPopup; |
584 | delete KOAgendaItem::paintPix(); | 584 | delete KOAgendaItem::paintPix(); |
585 | delete KOAgendaItem::paintPixSel(); | 585 | delete KOAgendaItem::paintPixSel(); |
586 | } | 586 | } |
587 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 587 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
588 | { | 588 | { |
589 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 589 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
590 | bool uc = false; | 590 | bool uc = false; |
591 | int ow = e->oldSize().width(); | 591 | int ow = e->oldSize().width(); |
592 | int oh = e->oldSize().height(); | 592 | int oh = e->oldSize().height(); |
593 | int w = e->size().width(); | 593 | int w = e->size().width(); |
594 | int h = e->size().height(); | 594 | int h = e->size().height(); |
595 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 595 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
596 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 596 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
597 | uc = true; | 597 | uc = true; |
598 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 598 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
599 | } | 599 | } |
600 | mUpcomingWidth = e->size().width() ; | 600 | mUpcomingWidth = e->size().width() ; |
601 | if ( mBlockUpdating || uc ) { | 601 | if ( mBlockUpdating || uc ) { |
602 | mBlockUpdating = false; | 602 | mBlockUpdating = false; |
603 | //mAgenda->setMinimumSize(800 , 600 ); | 603 | //mAgenda->setMinimumSize(800 , 600 ); |
604 | //qDebug("mAgenda->resize+++++++++++++++ "); | 604 | //qDebug("mAgenda->resize+++++++++++++++ "); |
605 | updateConfig(); | 605 | updateConfig(); |
606 | //qDebug("KOAgendaView::Updating now possible "); | 606 | //qDebug("KOAgendaView::Updating now possible "); |
607 | } else | 607 | } else |
608 | createDayLabels(); | 608 | createDayLabels(); |
609 | //qDebug("resizeEvent end "); | 609 | //qDebug("resizeEvent end "); |
610 | 610 | ||
611 | } | 611 | } |
612 | void KOAgendaView::slotDaylabelClicked() | 612 | void KOAgendaView::slotDaylabelClicked() |
613 | { | 613 | { |
614 | QString cap = ((QPushButton*) sender() )->caption(); | 614 | QString cap = ((QPushButton*) sender() )->caption(); |
615 | 615 | ||
616 | QDate firstDate = mSelectedDates.first(); | 616 | QDate firstDate = mSelectedDates.first(); |
617 | if ( cap == "0" ) | 617 | if ( cap == "0" ) |
618 | emit showDateView( 6, firstDate ); | 618 | emit showDateView( 6, firstDate ); |
619 | else if ( cap != "last" ) { | 619 | else if ( cap != "last" ) { |
620 | if ( mSelectedDates.count() == 1) | 620 | if ( mSelectedDates.count() == 1) |
621 | emit showDateView( 9, firstDate.addDays( cap.toInt()-1 ) ); | 621 | emit showDateView( 9, firstDate.addDays( cap.toInt()-1 ) ); |
622 | else | 622 | else |
623 | emit showDateView( 3, firstDate.addDays( cap.toInt()-1 ) ); | 623 | emit showDateView( 3, firstDate.addDays( cap.toInt()-1 ) ); |
624 | } | 624 | } |
625 | else | 625 | else |
626 | showDateView( 10, firstDate.addDays(1 ) ); | 626 | showDateView( 10, firstDate.addDays(1 ) ); |
627 | } | 627 | } |
628 | void KOAgendaView::createDayLabels() | 628 | void KOAgendaView::createDayLabels() |
629 | { | 629 | { |
630 | 630 | ||
631 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 631 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
632 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 632 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
633 | return; | 633 | return; |
634 | 634 | ||
635 | } | 635 | } |
636 | int newHight; | 636 | int newHight; |
637 | 637 | ||
638 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 638 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
639 | // It would remove some flickering and gain speed (since this is called by | 639 | // It would remove some flickering and gain speed (since this is called by |
640 | // each updateView() call) | 640 | // each updateView() call) |
641 | 641 | ||
642 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 642 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
643 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 643 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
644 | if ( maxWid < 0 ) | 644 | if ( maxWid < 0 ) |
645 | maxWid = 20; | 645 | maxWid = 20; |
646 | 646 | ||
647 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 647 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
648 | QFontMetrics fm ( dlf ); | 648 | QFontMetrics fm ( dlf ); |
649 | int selCount = mSelectedDates.count(); | 649 | int selCount = mSelectedDates.count(); |
650 | QString dayTest = "Mon 20"; | 650 | QString dayTest = "Mon 20"; |
651 | int wid = fm.width( dayTest ); | 651 | int wid = fm.width( dayTest ); |
652 | maxWid -= ( selCount * 3 ); | 652 | maxWid -= ( selCount * 3 ); |
653 | if ( maxWid < 0 ) | 653 | if ( maxWid < 0 ) |
654 | maxWid = 20; | 654 | maxWid = 20; |
655 | int needWid = wid * selCount; | 655 | int needWid = wid * selCount; |
656 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 656 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
657 | //if ( needWid > maxWid ) | 657 | //if ( needWid > maxWid ) |
658 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 658 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
659 | while ( needWid > maxWid ) { | 659 | while ( needWid > maxWid ) { |
660 | dayTest = dayTest.left( dayTest.length() - 1 ); | 660 | dayTest = dayTest.left( dayTest.length() - 1 ); |
661 | wid = fm.width( dayTest ); | 661 | wid = fm.width( dayTest ); |
662 | needWid = wid * selCount; | 662 | needWid = wid * selCount; |
663 | } | 663 | } |
664 | int maxLen = dayTest.length(); | 664 | int maxLen = dayTest.length(); |
665 | int fontPoint = dlf.pointSize(); | 665 | int fontPoint = dlf.pointSize(); |
666 | if ( maxLen < 2 ) { | 666 | if ( maxLen < 2 ) { |
667 | int fontPoint = dlf.pointSize(); | 667 | int fontPoint = dlf.pointSize(); |
668 | while ( fontPoint > 4 ) { | 668 | while ( fontPoint > 4 ) { |
669 | --fontPoint; | 669 | --fontPoint; |
670 | dlf.setPointSize( fontPoint ); | 670 | dlf.setPointSize( fontPoint ); |
671 | QFontMetrics f( dlf ); | 671 | QFontMetrics f( dlf ); |
672 | wid = f.width( "20" ); | 672 | wid = f.width( "20" ); |
673 | needWid = wid * selCount; | 673 | needWid = wid * selCount; |
674 | if ( needWid < maxWid ) | 674 | if ( needWid < maxWid ) |
675 | break; | 675 | break; |
676 | } | 676 | } |
677 | maxLen = 2; | 677 | maxLen = 2; |
678 | } | 678 | } |
679 | //qDebug("Max len %d ", dayTest.length() ); | 679 | //qDebug("Max len %d ", dayTest.length() ); |
680 | 680 | ||
681 | QFontMetrics tempF( dlf ); | 681 | QFontMetrics tempF( dlf ); |
682 | newHight = tempF.height(); | 682 | newHight = tempF.height(); |
683 | mDayLabels->setFont( dlf ); | 683 | mDayLabels->setFont( dlf ); |
684 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 684 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
685 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 685 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
686 | //mLayoutDayLabels->addSpacing( 2 ); | 686 | //mLayoutDayLabels->addSpacing( 2 ); |
687 | // QFont lFont = dlf; | 687 | // QFont lFont = dlf; |
688 | bool appendLabels = false; | 688 | bool appendLabels = false; |
689 | QPushButton *dayLabel; | 689 | QPushButton *dayLabel; |
690 | dayLabel = mDayLabelsList.first(); | 690 | dayLabel = mDayLabelsList.first(); |
691 | if ( !dayLabel ) { | 691 | if ( !dayLabel ) { |
692 | appendLabels = true; | 692 | appendLabels = true; |
693 | dayLabel = new QPushButton(mDayLabels); | 693 | dayLabel = new QPushButton(mDayLabels); |
694 | dayLabel->setFlat( true ); | 694 | dayLabel->setFlat( true ); |
695 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); | 695 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); |
696 | dayLabel->setFocusPolicy(NoFocus); | 696 | dayLabel->setFocusPolicy(NoFocus); |
697 | mDayLabelsList.append( dayLabel ); | 697 | mDayLabelsList.append( dayLabel ); |
698 | mLayoutDayLabels->addWidget(dayLabel); | 698 | mLayoutDayLabels->addWidget(dayLabel); |
699 | } | 699 | } |
700 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 700 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
701 | dayLabel->setFont( dlf ); | 701 | dayLabel->setFont( dlf ); |
702 | dayLabel->setCaption("0"); | 702 | dayLabel->setCaption("0"); |
703 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 703 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
704 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 704 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
705 | dayLabel->show(); | 705 | dayLabel->show(); |
706 | DateList::ConstIterator dit; | 706 | DateList::ConstIterator dit; |
707 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 707 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
708 | int counter = 0; | 708 | int counter = 0; |
709 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 709 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
710 | ++counter; | 710 | ++counter; |
711 | QDate date = *dit; | 711 | QDate date = *dit; |
712 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 712 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
713 | if ( ! appendLabels ) { | 713 | if ( ! appendLabels ) { |
714 | dayLabel = mDayLabelsList.next(); | 714 | dayLabel = mDayLabelsList.next(); |
715 | if ( !dayLabel ) | 715 | if ( !dayLabel ) |
716 | appendLabels = true; | 716 | appendLabels = true; |
717 | } | 717 | } |
718 | if ( appendLabels ) { | 718 | if ( appendLabels ) { |
719 | dayLabel = new QPushButton(mDayLabels); | 719 | dayLabel = new QPushButton(mDayLabels); |
720 | dayLabel->setFlat( true ); | 720 | dayLabel->setFlat( true ); |
721 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); | 721 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); |
722 | dayLabel->setFocusPolicy(NoFocus); | 722 | dayLabel->setFocusPolicy(NoFocus); |
723 | mDayLabelsList.append( dayLabel ); | 723 | mDayLabelsList.append( dayLabel ); |
724 | mLayoutDayLabels->addWidget(dayLabel); | 724 | mLayoutDayLabels->addWidget(dayLabel); |
725 | } | 725 | } |
726 | dayLabel->setMinimumWidth( 1 ); | 726 | dayLabel->setMinimumWidth( 1 ); |
727 | dayLabel->setMaximumWidth( 2048 ); | 727 | dayLabel->setMaximumWidth( 2048 ); |
728 | dayLabel->setFont( dlf ); | 728 | dayLabel->setFont( dlf ); |
729 | dayLabel->show(); | 729 | dayLabel->show(); |
730 | dayLabel->setCaption(QString::number( counter )); | 730 | dayLabel->setCaption(QString::number( counter )); |
731 | QString str; | 731 | QString str; |
732 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 732 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
733 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 733 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
734 | switch ( maxLen ) { | 734 | switch ( maxLen ) { |
735 | case 2: | 735 | case 2: |
736 | str = QString::number( date.day() ); | 736 | str = QString::number( date.day() ); |
737 | break; | 737 | break; |
738 | 738 | ||
739 | case 3: | 739 | case 3: |
740 | str = dayName.left( 1 ) +QString::number( date.day()); | 740 | str = dayName.left( 1 ) +QString::number( date.day()); |
741 | 741 | ||
742 | break; | 742 | break; |
743 | case 4: | 743 | case 4: |
744 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 744 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
745 | 745 | ||
746 | break; | 746 | break; |
747 | case 5: | 747 | case 5: |
748 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 748 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
749 | 749 | ||
750 | break; | 750 | break; |
751 | case 6: | 751 | case 6: |
752 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 752 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
753 | break; | 753 | break; |
754 | 754 | ||
755 | default: | 755 | default: |
756 | break; | 756 | break; |
757 | } | 757 | } |
758 | if ( oneday ) { | 758 | if ( oneday ) { |
759 | QString addString; | 759 | QString addString; |
760 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 760 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
761 | addString = i18n("Today"); | 761 | addString = i18n("Today"); |
762 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 762 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
763 | addString = i18n("Tomorrow"); | 763 | addString = i18n("Tomorrow"); |
764 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 764 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
765 | addString = i18n("Yesterday"); | 765 | addString = i18n("Yesterday"); |
766 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 766 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
767 | addString = i18n("Day before yesterday"); | 767 | addString = i18n("Day before yesterday"); |
768 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 768 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
769 | addString = i18n("Day after tomorrow"); | 769 | addString = i18n("Day after tomorrow"); |
770 | if ( !addString.isEmpty() ) { | 770 | if ( !addString.isEmpty() ) { |
771 | str = addString+", " + str; | 771 | str = addString+", " + str; |
772 | } | 772 | } |
773 | } | 773 | } |
774 | dayLabel->setText(str); | 774 | dayLabel->setText(str); |
775 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 775 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
776 | if (date == QDate::currentDate()) { | 776 | if (date == QDate::currentDate()) { |
777 | QFont bFont = dlf; | 777 | QFont bFont = dlf; |
778 | bFont.setBold( true ); | 778 | bFont.setBold( true ); |
779 | dayLabel->setFont(bFont); | 779 | dayLabel->setFont(bFont); |
780 | } | 780 | } |
781 | //dayLayout->addWidget(dayLabel); | 781 | //dayLayout->addWidget(dayLabel); |
782 | 782 | ||
783 | #ifndef KORG_NOPLUGINS | 783 | #ifndef KORG_NOPLUGINS |
784 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 784 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
785 | CalendarDecoration *it; | 785 | CalendarDecoration *it; |
786 | for(it = cds.first(); it; it = cds.next()) { | 786 | for(it = cds.first(); it; it = cds.next()) { |
787 | QString text = it->shortText( date ); | 787 | QString text = it->shortText( date ); |
788 | if ( !text.isEmpty() ) { | 788 | if ( !text.isEmpty() ) { |
789 | QLabel *label = new QLabel(text,mDayLabels); | 789 | QLabel *label = new QLabel(text,mDayLabels); |
790 | label->setAlignment(AlignCenter); | 790 | label->setAlignment(AlignCenter); |
791 | dayLayout->addWidget(label); | 791 | dayLayout->addWidget(label); |
792 | } | 792 | } |
793 | } | 793 | } |
794 | 794 | ||
795 | for(it = cds.first(); it; it = cds.next()) { | 795 | for(it = cds.first(); it; it = cds.next()) { |
796 | QWidget *wid = it->smallWidget(mDayLabels,date); | 796 | QWidget *wid = it->smallWidget(mDayLabels,date); |
797 | if ( wid ) { | 797 | if ( wid ) { |
798 | // wid->setHeight(20); | 798 | // wid->setHeight(20); |
799 | dayLayout->addWidget(wid); | 799 | dayLayout->addWidget(wid); |
800 | } | 800 | } |
801 | } | 801 | } |
802 | #endif | 802 | #endif |
803 | } | 803 | } |
804 | if ( ! appendLabels ) { | 804 | if ( ! appendLabels ) { |
805 | dayLabel = mDayLabelsList.next(); | 805 | dayLabel = mDayLabelsList.next(); |
806 | if ( !dayLabel ) | 806 | if ( !dayLabel ) |
807 | appendLabels = true; | 807 | appendLabels = true; |
808 | } | 808 | } |
809 | if ( appendLabels ) { | 809 | if ( appendLabels ) { |
810 | dayLabel = new QPushButton(mDayLabels); | 810 | dayLabel = new QPushButton(mDayLabels); |
811 | dayLabel->setFlat( true ); | 811 | dayLabel->setFlat( true ); |
812 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); | 812 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); |
813 | dayLabel->setFocusPolicy(NoFocus); | 813 | dayLabel->setFocusPolicy(NoFocus); |
814 | mDayLabelsList.append( dayLabel ); | 814 | mDayLabelsList.append( dayLabel ); |
815 | mLayoutDayLabels->addWidget(dayLabel); | 815 | mLayoutDayLabels->addWidget(dayLabel); |
816 | } | 816 | } |
817 | //dayLabel->hide();//test only | 817 | //dayLabel->hide();//test only |
818 | 818 | ||
819 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 819 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
820 | if ( offset < 0 ) offset = 0; | 820 | if ( offset < 0 ) offset = 0; |
821 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 821 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
822 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 822 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
823 | dayLabel->setFont( dlf ); | ||
823 | dayLabel->show(); | 824 | dayLabel->show(); |
824 | dayLabel->setCaption("last"); | 825 | dayLabel->setCaption("last"); |
825 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 826 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
826 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 827 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
827 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 828 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
828 | if ( !appendLabels ) { | 829 | if ( !appendLabels ) { |
829 | dayLabel = mDayLabelsList.next(); | 830 | dayLabel = mDayLabelsList.next(); |
830 | while ( dayLabel ) { | 831 | while ( dayLabel ) { |
831 | //qDebug("!dayLabel %d",dayLabel ); | 832 | //qDebug("!dayLabel %d",dayLabel ); |
832 | dayLabel->hide(); | 833 | dayLabel->hide(); |
833 | dayLabel = mDayLabelsList.next(); | 834 | dayLabel = mDayLabelsList.next(); |
834 | } | 835 | } |
835 | } | 836 | } |
836 | //mDayLabelsFrame->show(); | 837 | //mDayLabelsFrame->show(); |
837 | //mDayLabels->show(); | 838 | //mDayLabels->show(); |
838 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 839 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
839 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 840 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
840 | mDayLabelsFrame->setFixedHeight( newHight ); | 841 | mDayLabelsFrame->setFixedHeight( newHight ); |
841 | } | 842 | } |
842 | 843 | ||
843 | int KOAgendaView::maxDatesHint() | 844 | int KOAgendaView::maxDatesHint() |
844 | { | 845 | { |
845 | // Not sure about the max number of events, so return 0 for now. | 846 | // Not sure about the max number of events, so return 0 for now. |
846 | return 0; | 847 | return 0; |
847 | } | 848 | } |
848 | 849 | ||
849 | int KOAgendaView::currentDateCount() | 850 | int KOAgendaView::currentDateCount() |
850 | { | 851 | { |
851 | return mSelectedDates.count(); | 852 | return mSelectedDates.count(); |
852 | } | 853 | } |
853 | 854 | ||
854 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 855 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
855 | { | 856 | { |
856 | QPtrList<Incidence> selected; | 857 | QPtrList<Incidence> selected; |
857 | Incidence *incidence; | 858 | Incidence *incidence; |
858 | 859 | ||
859 | incidence = mAgenda->selectedIncidence(); | 860 | incidence = mAgenda->selectedIncidence(); |
860 | if (incidence) selected.append(incidence); | 861 | if (incidence) selected.append(incidence); |
861 | 862 | ||
862 | incidence = mAllDayAgenda->selectedIncidence(); | 863 | incidence = mAllDayAgenda->selectedIncidence(); |
863 | if (incidence) selected.append(incidence); | 864 | if (incidence) selected.append(incidence); |
864 | 865 | ||
865 | return selected; | 866 | return selected; |
866 | } | 867 | } |
867 | 868 | ||
868 | DateList KOAgendaView::selectedDates() | 869 | DateList KOAgendaView::selectedDates() |
869 | { | 870 | { |
870 | DateList selected; | 871 | DateList selected; |
871 | QDate qd; | 872 | QDate qd; |
872 | 873 | ||
873 | qd = mAgenda->selectedIncidenceDate(); | 874 | qd = mAgenda->selectedIncidenceDate(); |
874 | if (qd.isValid()) selected.append(qd); | 875 | if (qd.isValid()) selected.append(qd); |
875 | 876 | ||
876 | qd = mAllDayAgenda->selectedIncidenceDate(); | 877 | qd = mAllDayAgenda->selectedIncidenceDate(); |
877 | if (qd.isValid()) selected.append(qd); | 878 | if (qd.isValid()) selected.append(qd); |
878 | 879 | ||
879 | return selected; | 880 | return selected; |
880 | } | 881 | } |
881 | 882 | ||
882 | 883 | ||
883 | void KOAgendaView::updateView() | 884 | void KOAgendaView::updateView() |
884 | { | 885 | { |
885 | if ( mBlockUpdating ) | 886 | if ( mBlockUpdating ) |
886 | return; | 887 | return; |
887 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 888 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
888 | fillAgenda(); | 889 | fillAgenda(); |
889 | 890 | ||
890 | } | 891 | } |
891 | 892 | ||
892 | 893 | ||
893 | /* | 894 | /* |
894 | Update configuration settings for the agenda view. This method is not | 895 | Update configuration settings for the agenda view. This method is not |
895 | complete. | 896 | complete. |
896 | */ | 897 | */ |
897 | void KOAgendaView::updateConfig() | 898 | void KOAgendaView::updateConfig() |
898 | { | 899 | { |
899 | if ( mBlockUpdating ) | 900 | if ( mBlockUpdating ) |
900 | return; | 901 | return; |
901 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; | 902 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; |
902 | 903 | ||
903 | // update config for children | 904 | // update config for children |
904 | mTimeLabels->updateConfig(); | 905 | mTimeLabels->updateConfig(); |
905 | mAgenda->storePosition(); | 906 | mAgenda->storePosition(); |
906 | mAgenda->updateConfig(); | 907 | mAgenda->updateConfig(); |
907 | mAllDayAgenda->updateConfig(); | 908 | mAllDayAgenda->updateConfig(); |
908 | // widget synchronization | 909 | // widget synchronization |
909 | //TODO: find a better way, maybe signal/slot | 910 | //TODO: find a better way, maybe signal/slot |
910 | mTimeLabels->positionChanged(); | 911 | mTimeLabels->positionChanged(); |
911 | 912 | ||
912 | // for some reason, this needs to be called explicitly | 913 | // for some reason, this needs to be called explicitly |
913 | mTimeLabels->repaint(); | 914 | mTimeLabels->repaint(); |
914 | 915 | ||
915 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 916 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
916 | 917 | ||
917 | // ToolTips displaying summary of events | 918 | // ToolTips displaying summary of events |
918 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 919 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
919 | ->mEnableToolTips); | 920 | ->mEnableToolTips); |
920 | 921 | ||
921 | //setHolidayMasks(); | 922 | //setHolidayMasks(); |
922 | 923 | ||
923 | //createDayLabels(); called by via updateView(); | 924 | //createDayLabels(); called by via updateView(); |
924 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 925 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
925 | updateView(); | 926 | updateView(); |
926 | mAgenda->restorePosition(); | 927 | mAgenda->restorePosition(); |
927 | } | 928 | } |
928 | 929 | ||
929 | 930 | ||
930 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 931 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
931 | { | 932 | { |
932 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 933 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
933 | //qDebug("KOAgendaView::updateEventDates "); | 934 | //qDebug("KOAgendaView::updateEventDates "); |
934 | QDateTime startDt,endDt; | 935 | QDateTime startDt,endDt; |
935 | QDate startDate; | 936 | QDate startDate; |
936 | int lenInSecs; | 937 | int lenInSecs; |
937 | // if ( type == KOAgenda::RESIZETOP ) | 938 | // if ( type == KOAgenda::RESIZETOP ) |
938 | // qDebug("RESIZETOP "); | 939 | // qDebug("RESIZETOP "); |
939 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 940 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
940 | // qDebug("RESIZEBOTTOM "); | 941 | // qDebug("RESIZEBOTTOM "); |
941 | // if ( type == KOAgenda::MOVE ) | 942 | // if ( type == KOAgenda::MOVE ) |
942 | // qDebug("MOVE "); | 943 | // qDebug("MOVE "); |
943 | if ( item->incidence()->type() == "Event" ) { | 944 | if ( item->incidence()->type() == "Event" ) { |
944 | startDt =item->incidence()->dtStart(); | 945 | startDt =item->incidence()->dtStart(); |
945 | endDt = item->incidence()->dtEnd(); | 946 | endDt = item->incidence()->dtEnd(); |
946 | lenInSecs = startDt.secsTo( endDt ); | 947 | lenInSecs = startDt.secsTo( endDt ); |
947 | } | 948 | } |
948 | 949 | ||
949 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 950 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
950 | 951 | ||
951 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 952 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
952 | startDate = mSelectedDates[item->mLastMoveXPos]; | 953 | startDate = mSelectedDates[item->mLastMoveXPos]; |
953 | } else { | 954 | } else { |
954 | if (item->cellX() < 0) { | 955 | if (item->cellX() < 0) { |
955 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 956 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
956 | } else { | 957 | } else { |
957 | startDate = mSelectedDates[item->cellX()]; | 958 | startDate = mSelectedDates[item->cellX()]; |
958 | } | 959 | } |
959 | } | 960 | } |
960 | startDt.setDate(startDate); | 961 | startDt.setDate(startDate); |
961 | 962 | ||
962 | if (item->incidence()->doesFloat()) { | 963 | if (item->incidence()->doesFloat()) { |
963 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 964 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
964 | } else { | 965 | } else { |
965 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 966 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
966 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 967 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
967 | if ( item->incidence()->type() == "Event" ) { | 968 | if ( item->incidence()->type() == "Event" ) { |
968 | if ( type == KOAgenda::MOVE ) { | 969 | if ( type == KOAgenda::MOVE ) { |
969 | endDt = startDt.addSecs(lenInSecs); | 970 | endDt = startDt.addSecs(lenInSecs); |
970 | 971 | ||
971 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 972 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
972 | if (item->lastMultiItem()) { | 973 | if (item->lastMultiItem()) { |
973 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 974 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
974 | endDt.setDate(startDate. | 975 | endDt.setDate(startDate. |
975 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 976 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
976 | } else { | 977 | } else { |
977 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 978 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
978 | endDt.setDate(startDate); | 979 | endDt.setDate(startDate); |
979 | } | 980 | } |
980 | } | 981 | } |
981 | } else { | 982 | } else { |
982 | // todo | 983 | // todo |
983 | qDebug("tooooodoooooo "); | 984 | qDebug("tooooodoooooo "); |
984 | if (item->lastMultiItem()) { | 985 | if (item->lastMultiItem()) { |
985 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 986 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
986 | endDt.setDate(startDate. | 987 | endDt.setDate(startDate. |
987 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 988 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
988 | } else { | 989 | } else { |
989 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 990 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
990 | if ( item->cellYBottom() > 0 ) | 991 | if ( item->cellYBottom() > 0 ) |
991 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 992 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
992 | else | 993 | else |
993 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 994 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
994 | endDt.setDate(startDate); | 995 | endDt.setDate(startDate); |
995 | } | 996 | } |
996 | } | 997 | } |
997 | } | 998 | } |
998 | 999 | ||
999 | qDebug("to888"); | 1000 | qDebug("to888"); |
1000 | if ( item->incidence()->type() == "Event" ) { | 1001 | if ( item->incidence()->type() == "Event" ) { |
1001 | item->incidence()->setDtStart(startDt); | 1002 | item->incidence()->setDtStart(startDt); |
1002 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1003 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1003 | } else if ( item->incidence()->type() == "Todo" ) { | 1004 | } else if ( item->incidence()->type() == "Todo" ) { |
1004 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); | 1005 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); |
1005 | } | 1006 | } |
1006 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1007 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1007 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1008 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1008 | item->setItemDate(startDt.date()); | 1009 | item->setItemDate(startDt.date()); |
1009 | //item->updateItem(); | 1010 | //item->updateItem(); |
1010 | if ( item->incidence()->type() == "Todo" ) { | 1011 | if ( item->incidence()->type() == "Todo" ) { |
1011 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1012 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1012 | 1013 | ||
1013 | } | 1014 | } |
1014 | else | 1015 | else |
1015 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1016 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1016 | item->updateItem(); | 1017 | item->updateItem(); |
1017 | } | 1018 | } |
1018 | 1019 | ||
1019 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1020 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1020 | { | 1021 | { |
1021 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1022 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1022 | 1023 | ||
1023 | mSelectedDates.clear(); | 1024 | mSelectedDates.clear(); |
1024 | // qDebug("KOAgendaView::showDates "); | 1025 | // qDebug("KOAgendaView::showDates "); |
1025 | QDate d = start; | 1026 | QDate d = start; |
1026 | while (d <= end) { | 1027 | while (d <= end) { |
1027 | mSelectedDates.append(d); | 1028 | mSelectedDates.append(d); |
1028 | d = d.addDays( 1 ); | 1029 | d = d.addDays( 1 ); |
1029 | } | 1030 | } |
1030 | 1031 | ||
1031 | // and update the view | 1032 | // and update the view |
1032 | fillAgenda(); | 1033 | fillAgenda(); |
1033 | } | 1034 | } |
1034 | 1035 | ||
1035 | 1036 | ||
1036 | void KOAgendaView::showEvents(QPtrList<Event>) | 1037 | void KOAgendaView::showEvents(QPtrList<Event>) |
1037 | { | 1038 | { |
1038 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1039 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1039 | } | 1040 | } |
1040 | 1041 | ||
1041 | void KOAgendaView::changeEventDisplay(Event *, int) | 1042 | void KOAgendaView::changeEventDisplay(Event *, int) |
1042 | { | 1043 | { |
1043 | // qDebug("KOAgendaView::changeEventDisplay "); | 1044 | // qDebug("KOAgendaView::changeEventDisplay "); |
1044 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1045 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1045 | // this should be re-written to be MUCH smarter. Right now we | 1046 | // this should be re-written to be MUCH smarter. Right now we |
1046 | // are just playing dumb. | 1047 | // are just playing dumb. |
1047 | fillAgenda(); | 1048 | fillAgenda(); |
1048 | } | 1049 | } |
1049 | 1050 | ||
1050 | void KOAgendaView::fillAgenda(const QDate &) | 1051 | void KOAgendaView::fillAgenda(const QDate &) |
1051 | { | 1052 | { |
1052 | // qDebug("KOAgendaView::fillAgenda "); | 1053 | // qDebug("KOAgendaView::fillAgenda "); |
1053 | fillAgenda(); | 1054 | fillAgenda(); |
1054 | } | 1055 | } |
1055 | 1056 | ||
1056 | void KOAgendaView::fillAgenda() | 1057 | void KOAgendaView::fillAgenda() |
1057 | { | 1058 | { |
1058 | if ( globalFlagBlockStartup ) | 1059 | if ( globalFlagBlockStartup ) |
1059 | return; | 1060 | return; |
1060 | if ( globalFlagBlockAgenda == 1 ) | 1061 | if ( globalFlagBlockAgenda == 1 ) |
1061 | return; | 1062 | return; |
1062 | //if ( globalFlagBlockAgenda == 2 ) | 1063 | //if ( globalFlagBlockAgenda == 2 ) |
1063 | //globalFlagBlockAgenda = 0; | 1064 | //globalFlagBlockAgenda = 0; |
1064 | // globalFlagBlockPainting = false; | 1065 | // globalFlagBlockPainting = false; |
1065 | if ( globalFlagBlockAgenda == 0 ) | 1066 | if ( globalFlagBlockAgenda == 0 ) |
1066 | globalFlagBlockAgenda = 1; | 1067 | globalFlagBlockAgenda = 1; |
1067 | // clearView(); | 1068 | // clearView(); |
1068 | //qDebug("fillAgenda()++++ "); | 1069 | //qDebug("fillAgenda()++++ "); |
1069 | globalFlagBlockAgendaItemPaint = 1; | 1070 | globalFlagBlockAgendaItemPaint = 1; |
1070 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1071 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1071 | mAgenda->changeColumns(mSelectedDates.count()); | 1072 | mAgenda->changeColumns(mSelectedDates.count()); |
1072 | qApp->processEvents(); | 1073 | qApp->processEvents(); |
1073 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1074 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1074 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1075 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1075 | setHolidayMasks(); | 1076 | setHolidayMasks(); |
1076 | 1077 | ||
1077 | //mAgenda->hideUnused(); | 1078 | //mAgenda->hideUnused(); |
1078 | //mAllDayAgenda->hideUnused(); | 1079 | //mAllDayAgenda->hideUnused(); |
1079 | 1080 | ||
1080 | // mAgenda->blockNextRepaint( false ); | 1081 | // mAgenda->blockNextRepaint( false ); |
1081 | // mAgenda->viewport()->repaint(); | 1082 | // mAgenda->viewport()->repaint(); |
1082 | // mAgenda->blockNextRepaint( true ); | 1083 | // mAgenda->blockNextRepaint( true ); |
1083 | mMinY.resize(mSelectedDates.count()); | 1084 | mMinY.resize(mSelectedDates.count()); |
1084 | mMaxY.resize(mSelectedDates.count()); | 1085 | mMaxY.resize(mSelectedDates.count()); |
1085 | 1086 | ||
1086 | QPtrList<Event> dayEvents; | 1087 | QPtrList<Event> dayEvents; |
1087 | 1088 | ||
1088 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1089 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1089 | // Therefore, gtodoset all of them. | 1090 | // Therefore, gtodoset all of them. |
1090 | QPtrList<Todo> todos = calendar()->todos(); | 1091 | QPtrList<Todo> todos = calendar()->todos(); |
1091 | 1092 | ||
1092 | mAgenda->setDateList(mSelectedDates); | 1093 | mAgenda->setDateList(mSelectedDates); |
1093 | 1094 | ||
1094 | QDate today = QDate::currentDate(); | 1095 | QDate today = QDate::currentDate(); |
1095 | 1096 | ||
1096 | DateList::ConstIterator dit; | 1097 | DateList::ConstIterator dit; |
1097 | int curCol = 0; | 1098 | int curCol = 0; |
1098 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1099 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1099 | QDate currentDate = *dit; | 1100 | QDate currentDate = *dit; |
1100 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1101 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1101 | // << endl; | 1102 | // << endl; |
1102 | 1103 | ||
1103 | dayEvents = calendar()->events(currentDate,true); | 1104 | dayEvents = calendar()->events(currentDate,true); |
1104 | 1105 | ||
1105 | // Default values, which can never be reached | 1106 | // Default values, which can never be reached |
1106 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1107 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1107 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1108 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1108 | 1109 | ||
1109 | unsigned int numEvent; | 1110 | unsigned int numEvent; |
1110 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1111 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1111 | Event *event = dayEvents.at(numEvent); | 1112 | Event *event = dayEvents.at(numEvent); |
1112 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1113 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1113 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1114 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1114 | continue; | 1115 | continue; |
1115 | // kdDebug() << " Event: " << event->summary() << endl; | 1116 | // kdDebug() << " Event: " << event->summary() << endl; |
1116 | 1117 | ||
1117 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1118 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1118 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1119 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1119 | 1120 | ||
1120 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1121 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1121 | 1122 | ||
1122 | if (event->doesFloat()) { | 1123 | if (event->doesFloat()) { |
1123 | if (event->recurrence()->doesRecur()) { | 1124 | if (event->recurrence()->doesRecur()) { |
1124 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1125 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1125 | } else { | 1126 | } else { |
1126 | if (beginX <= 0 && curCol == 0) { | 1127 | if (beginX <= 0 && curCol == 0) { |
1127 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1128 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1128 | } else if (beginX == curCol) { | 1129 | } else if (beginX == curCol) { |
1129 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1130 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1130 | } | 1131 | } |
1131 | } | 1132 | } |
1132 | } else if (event->isMultiDay()) { | 1133 | } else if (event->isMultiDay()) { |
1133 | if ( event->doesRecur () ) { | 1134 | if ( event->doesRecur () ) { |
1134 | QDate dateit = currentDate; | 1135 | QDate dateit = currentDate; |
1135 | int count = 0; | 1136 | int count = 0; |
1136 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1137 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1137 | while (! event->recursOn( dateit ) && count <= max ) { | 1138 | while (! event->recursOn( dateit ) && count <= max ) { |
1138 | ++count; | 1139 | ++count; |
1139 | dateit = dateit.addDays( -1 ); | 1140 | dateit = dateit.addDays( -1 ); |
1140 | } | 1141 | } |
1141 | bool ok; | 1142 | bool ok; |
1142 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1143 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1143 | if ( ok ) | 1144 | if ( ok ) |
1144 | { | 1145 | { |
1145 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1146 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1146 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1147 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1147 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1148 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1148 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1149 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1149 | 1150 | ||
1150 | } | 1151 | } |
1151 | } | 1152 | } |
1152 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1153 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1153 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1154 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1154 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1155 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1155 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1156 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1156 | //qDebug("insert!!! "); | 1157 | //qDebug("insert!!! "); |
1157 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1158 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1158 | } | 1159 | } |
1159 | if (beginX == curCol) { | 1160 | if (beginX == curCol) { |
1160 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1161 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1161 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1162 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1162 | } else if (endX == curCol) { | 1163 | } else if (endX == curCol) { |
1163 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1164 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1164 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1165 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1165 | } else { | 1166 | } else { |
1166 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1167 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1167 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1168 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1168 | } | 1169 | } |
1169 | } else { | 1170 | } else { |
1170 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1171 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1171 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1172 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1172 | if (endY < startY) endY = startY; | 1173 | if (endY < startY) endY = startY; |
1173 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1174 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1174 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1175 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1175 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1176 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1176 | } | 1177 | } |
1177 | } | 1178 | } |
1178 | // ---------- [display Todos -------------- | 1179 | // ---------- [display Todos -------------- |
1179 | unsigned int numTodo; | 1180 | unsigned int numTodo; |
1180 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1181 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1181 | Todo *todo = todos.at(numTodo); | 1182 | Todo *todo = todos.at(numTodo); |
1182 | 1183 | ||
1183 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1184 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1184 | 1185 | ||
1185 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1186 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1186 | // Already completed items can be displayed on their original due date | 1187 | // Already completed items can be displayed on their original due date |
1187 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1188 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1188 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1189 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1189 | bool fillIn = false; | 1190 | bool fillIn = false; |
1190 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1191 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1191 | fillIn = true; | 1192 | fillIn = true; |
1192 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1193 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1193 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1194 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1194 | if ( fillIn ) { | 1195 | if ( fillIn ) { |
1195 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1196 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1196 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1197 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1197 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1198 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1198 | } | 1199 | } |
1199 | else { | 1200 | else { |
1200 | QDateTime dt; | 1201 | QDateTime dt; |
1201 | if ( todo->hasCompletedDate() ) | 1202 | if ( todo->hasCompletedDate() ) |
1202 | dt = todo->completed(); | 1203 | dt = todo->completed(); |
1203 | else | 1204 | else |
1204 | dt = todo->dtDue();; | 1205 | dt = todo->dtDue();; |
1205 | 1206 | ||
1206 | 1207 | ||
1207 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1208 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1208 | int hi = (18/KOPrefs::instance()->mHourSize); | 1209 | int hi = (18/KOPrefs::instance()->mHourSize); |
1209 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1210 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1210 | int startY = endY -hi; | 1211 | int startY = endY -hi; |
1211 | 1212 | ||
1212 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1213 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1213 | 1214 | ||
1214 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1215 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1215 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1216 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1216 | } | 1217 | } |
1217 | } | 1218 | } |
1218 | } | 1219 | } |
1219 | // ---------- display Todos] -------------- | 1220 | // ---------- display Todos] -------------- |
1220 | 1221 | ||
1221 | ++curCol; | 1222 | ++curCol; |
1222 | } | 1223 | } |
1223 | mAgenda->hideUnused(); | 1224 | mAgenda->hideUnused(); |
1224 | mAllDayAgenda->hideUnused(); | 1225 | mAllDayAgenda->hideUnused(); |
1225 | mAgenda->checkScrollBoundaries(); | 1226 | mAgenda->checkScrollBoundaries(); |
1226 | 1227 | ||
1227 | deleteSelectedDateTime(); | 1228 | deleteSelectedDateTime(); |
1228 | 1229 | ||
1229 | createDayLabels(); | 1230 | createDayLabels(); |
1230 | emit incidenceSelected( 0 ); | 1231 | emit incidenceSelected( 0 ); |
1231 | 1232 | ||
1232 | if ( globalFlagBlockAgenda == 2 ) { | 1233 | if ( globalFlagBlockAgenda == 2 ) { |
1233 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1234 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1234 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1235 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1235 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1236 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1236 | setStartHour( QTime::currentTime ().hour() ); | 1237 | setStartHour( QTime::currentTime ().hour() ); |
1237 | // qApp->processEvents(); | 1238 | // qApp->processEvents(); |
1238 | } | 1239 | } |
1239 | qApp->processEvents(); | 1240 | qApp->processEvents(); |
1240 | //qDebug("qApp->processEvents(); END "); | 1241 | //qDebug("qApp->processEvents(); END "); |
1241 | globalFlagBlockAgenda = 0; | 1242 | globalFlagBlockAgenda = 0; |
1242 | 1243 | ||
1243 | // mAgenda->hideUnused(); | 1244 | // mAgenda->hideUnused(); |
1244 | //mAllDayAgenda->hideUnused(); | 1245 | //mAllDayAgenda->hideUnused(); |
1245 | mAllDayAgenda->drawContentsToPainter(); | 1246 | mAllDayAgenda->drawContentsToPainter(); |
1246 | mAgenda->drawContentsToPainter(); | 1247 | mAgenda->drawContentsToPainter(); |
1247 | repaintAgenda(); | 1248 | repaintAgenda(); |
1248 | // mAgenda->finishUpdate(); | 1249 | // mAgenda->finishUpdate(); |
1249 | //mAllDayAgenda->finishUpdate(); | 1250 | //mAllDayAgenda->finishUpdate(); |
1250 | 1251 | ||
1251 | // repaintAgenda(); | 1252 | // repaintAgenda(); |
1252 | //qApp->processEvents(); | 1253 | //qApp->processEvents(); |
1253 | // globalFlagBlockAgenda = 0; | 1254 | // globalFlagBlockAgenda = 0; |
1254 | } | 1255 | } |
1255 | void KOAgendaView::repaintAgenda() | 1256 | void KOAgendaView::repaintAgenda() |
1256 | { | 1257 | { |
1257 | // mAllDayAgenda->drawContentsToPainter(); | 1258 | // mAllDayAgenda->drawContentsToPainter(); |
1258 | // mAllDayAgenda->viewport()->repaint( false ); | 1259 | // mAllDayAgenda->viewport()->repaint( false ); |
1259 | // mAgenda->drawContentsToPainter(); | 1260 | // mAgenda->drawContentsToPainter(); |
1260 | // mAgenda->viewport()->repaint( false ); | 1261 | // mAgenda->viewport()->repaint( false ); |
1261 | // qApp->processEvents(); | 1262 | // qApp->processEvents(); |
1262 | 1263 | ||
1263 | //qDebug("KOAgendaView::repaintAgenda() "); | 1264 | //qDebug("KOAgendaView::repaintAgenda() "); |
1264 | //qApp->processEvents(); | 1265 | //qApp->processEvents(); |
1265 | mAgenda->viewport()->repaint( false ); | 1266 | mAgenda->viewport()->repaint( false ); |
1266 | mAllDayAgenda->viewport()->repaint( false ); | 1267 | mAllDayAgenda->viewport()->repaint( false ); |
1267 | mAgenda->finishUpdate(); | 1268 | mAgenda->finishUpdate(); |
1268 | mAllDayAgenda->finishUpdate(); | 1269 | mAllDayAgenda->finishUpdate(); |
1269 | } | 1270 | } |
1270 | 1271 | ||
1271 | 1272 | ||
1272 | void KOAgendaView::clearView() | 1273 | void KOAgendaView::clearView() |
1273 | { | 1274 | { |
1274 | // kdDebug() << "ClearView" << endl; | 1275 | // kdDebug() << "ClearView" << endl; |
1275 | mAllDayAgenda->clear(); | 1276 | mAllDayAgenda->clear(); |
1276 | mAgenda->clear(); | 1277 | mAgenda->clear(); |
1277 | } | 1278 | } |
1278 | 1279 | ||
1279 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1280 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1280 | const QDate &td) | 1281 | const QDate &td) |
1281 | { | 1282 | { |
1282 | #ifndef KORG_NOPRINTER | 1283 | #ifndef KORG_NOPRINTER |
1283 | if (fd == td) | 1284 | if (fd == td) |
1284 | calPrinter->preview(CalPrinter::Day, fd, td); | 1285 | calPrinter->preview(CalPrinter::Day, fd, td); |
1285 | else | 1286 | else |
1286 | calPrinter->preview(CalPrinter::Week, fd, td); | 1287 | calPrinter->preview(CalPrinter::Week, fd, td); |
1287 | #endif | 1288 | #endif |
1288 | } | 1289 | } |
1289 | 1290 | ||
1290 | // void KOAgendaView::updateMovedTodo() | 1291 | // void KOAgendaView::updateMovedTodo() |
1291 | // { | 1292 | // { |
1292 | // // updateConfig(); | 1293 | // // updateConfig(); |
1293 | // // emit updateTodoViews(); | 1294 | // // emit updateTodoViews(); |
1294 | // } | 1295 | // } |
1295 | 1296 | ||
1296 | void KOAgendaView::newEvent(int gx, int gy) | 1297 | void KOAgendaView::newEvent(int gx, int gy) |
1297 | { | 1298 | { |
1298 | if (!mSelectedDates.count()) return; | 1299 | if (!mSelectedDates.count()) return; |
1299 | 1300 | ||
1300 | QDate day = mSelectedDates[gx]; | 1301 | QDate day = mSelectedDates[gx]; |
1301 | 1302 | ||
1302 | QTime time = mAgenda->gyToTime(gy); | 1303 | QTime time = mAgenda->gyToTime(gy); |
1303 | QDateTime dt(day,time); | 1304 | QDateTime dt(day,time); |
1304 | // if ( dt < QDateTime::currentDateTime () ) | 1305 | // if ( dt < QDateTime::currentDateTime () ) |
1305 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1306 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1306 | emit newEventSignal(dt); | 1307 | emit newEventSignal(dt); |
1307 | } | 1308 | } |
1308 | 1309 | ||
1309 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1310 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1310 | { | 1311 | { |
1311 | if (!mSelectedDates.count()) return; | 1312 | if (!mSelectedDates.count()) return; |
1312 | 1313 | ||
1313 | QDate dayStart = mSelectedDates[gxStart]; | 1314 | QDate dayStart = mSelectedDates[gxStart]; |
1314 | QDate dayEnd = mSelectedDates[gxEnd]; | 1315 | QDate dayEnd = mSelectedDates[gxEnd]; |
1315 | 1316 | ||
1316 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1317 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1317 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1318 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1318 | 1319 | ||
1319 | QDateTime dtStart(dayStart,timeStart); | 1320 | QDateTime dtStart(dayStart,timeStart); |
1320 | QDateTime dtEnd(dayEnd,timeEnd); | 1321 | QDateTime dtEnd(dayEnd,timeEnd); |
1321 | 1322 | ||
1322 | emit newEventSignal(dtStart,dtEnd); | 1323 | emit newEventSignal(dtStart,dtEnd); |
1323 | } | 1324 | } |
1324 | 1325 | ||
1325 | void KOAgendaView::newEventAllDay(int gx, int ) | 1326 | void KOAgendaView::newEventAllDay(int gx, int ) |
1326 | { | 1327 | { |
1327 | if (!mSelectedDates.count()) return; | 1328 | if (!mSelectedDates.count()) return; |
1328 | 1329 | ||
1329 | QDate day = mSelectedDates[gx]; | 1330 | QDate day = mSelectedDates[gx]; |
1330 | 1331 | ||
1331 | emit newEventSignal(day); | 1332 | emit newEventSignal(day); |
1332 | } | 1333 | } |
1333 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1334 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1334 | { | 1335 | { |
1335 | if (!mSelectedDates.count()) return; | 1336 | if (!mSelectedDates.count()) return; |
1336 | 1337 | ||
1337 | QDateTime day (mSelectedDates[gx] ); | 1338 | QDateTime day (mSelectedDates[gx] ); |
1338 | emit newTodoSignal(day, true); | 1339 | emit newTodoSignal(day, true); |
1339 | } | 1340 | } |
1340 | void KOAgendaView::newTodo(int gx, int gy ) | 1341 | void KOAgendaView::newTodo(int gx, int gy ) |
1341 | { | 1342 | { |
1342 | if (!mSelectedDates.count()) return; | 1343 | if (!mSelectedDates.count()) return; |
1343 | QDate dayStart = mSelectedDates[gx]; | 1344 | QDate dayStart = mSelectedDates[gx]; |
1344 | QTime timeStart = mAgenda->gyToTime(gy); | 1345 | QTime timeStart = mAgenda->gyToTime(gy); |
1345 | QDateTime dt (dayStart,timeStart); | 1346 | QDateTime dt (dayStart,timeStart); |
1346 | emit newTodoSignal( dt, false ); | 1347 | emit newTodoSignal( dt, false ); |
1347 | } | 1348 | } |
1348 | 1349 | ||
1349 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1350 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1350 | { | 1351 | { |
1351 | uint i; | 1352 | uint i; |
1352 | for(i=0;i<mMinY.size();++i) { | 1353 | for(i=0;i<mMinY.size();++i) { |
1353 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1354 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1354 | else mEventIndicatorTop->enableColumn(i,false); | 1355 | else mEventIndicatorTop->enableColumn(i,false); |
1355 | } | 1356 | } |
1356 | 1357 | ||
1357 | mEventIndicatorTop->update(); | 1358 | mEventIndicatorTop->update(); |
1358 | } | 1359 | } |
1359 | 1360 | ||
1360 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1361 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1361 | { | 1362 | { |
1362 | uint i; | 1363 | uint i; |
1363 | for(i=0;i<mMaxY.size();++i) { | 1364 | for(i=0;i<mMaxY.size();++i) { |
1364 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1365 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1365 | else mEventIndicatorBottom->enableColumn(i,false); | 1366 | else mEventIndicatorBottom->enableColumn(i,false); |
1366 | } | 1367 | } |
1367 | 1368 | ||
1368 | mEventIndicatorBottom->update(); | 1369 | mEventIndicatorBottom->update(); |
1369 | } | 1370 | } |
1370 | 1371 | ||
1371 | void KOAgendaView::startDrag(Event *event) | 1372 | void KOAgendaView::startDrag(Event *event) |
1372 | { | 1373 | { |
1373 | #ifndef KORG_NODND | 1374 | #ifndef KORG_NODND |
1374 | DndFactory factory( calendar() ); | 1375 | DndFactory factory( calendar() ); |
1375 | ICalDrag *vd = factory.createDrag(event,this); | 1376 | ICalDrag *vd = factory.createDrag(event,this); |
1376 | if (vd->drag()) { | 1377 | if (vd->drag()) { |
1377 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1378 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1378 | } | 1379 | } |
1379 | #endif | 1380 | #endif |
1380 | } | 1381 | } |
1381 | 1382 | ||
1382 | void KOAgendaView::readSettings() | 1383 | void KOAgendaView::readSettings() |
1383 | { | 1384 | { |
1384 | readSettings(KOGlobals::config()); | 1385 | readSettings(KOGlobals::config()); |
1385 | } | 1386 | } |
1386 | 1387 | ||
1387 | void KOAgendaView::readSettings(KConfig *config) | 1388 | void KOAgendaView::readSettings(KConfig *config) |
1388 | { | 1389 | { |
1389 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1390 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1390 | 1391 | ||
1391 | config->setGroup("Views"); | 1392 | config->setGroup("Views"); |
1392 | 1393 | ||
1393 | //#ifndef KORG_NOSPLITTER | 1394 | //#ifndef KORG_NOSPLITTER |
1394 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1395 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1395 | if (sizes.count() == 2) { | 1396 | if (sizes.count() == 2) { |
1396 | if ( sizes[0] < 20 ) { | 1397 | if ( sizes[0] < 20 ) { |
1397 | sizes[1] = sizes[1] +20 - sizes[0]; | 1398 | sizes[1] = sizes[1] +20 - sizes[0]; |
1398 | sizes[0] = 20; | 1399 | sizes[0] = 20; |
1399 | } | 1400 | } |
1400 | mSplitterAgenda->setSizes(sizes); | 1401 | mSplitterAgenda->setSizes(sizes); |
1401 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1402 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1402 | } | 1403 | } |
1403 | //#endif | 1404 | //#endif |
1404 | 1405 | ||
1405 | // updateConfig(); | 1406 | // updateConfig(); |
1406 | } | 1407 | } |
1407 | 1408 | ||
1408 | void KOAgendaView::writeSettings(KConfig *config) | 1409 | void KOAgendaView::writeSettings(KConfig *config) |
1409 | { | 1410 | { |
1410 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1411 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1411 | 1412 | ||
1412 | config->setGroup("Views"); | 1413 | config->setGroup("Views"); |
1413 | 1414 | ||
1414 | //#ifndef KORG_NOSPLITTER | 1415 | //#ifndef KORG_NOSPLITTER |
1415 | QValueList<int> list = mSplitterAgenda->sizes(); | 1416 | QValueList<int> list = mSplitterAgenda->sizes(); |
1416 | config->writeEntry("Separator AgendaView",list); | 1417 | config->writeEntry("Separator AgendaView",list); |
1417 | //qDebug("write %d %d ", list[0],list[1] ); | 1418 | //qDebug("write %d %d ", list[0],list[1] ); |
1418 | //#endif | 1419 | //#endif |
1419 | } | 1420 | } |
1420 | 1421 | ||
1421 | void KOAgendaView::setHolidayMasks() | 1422 | void KOAgendaView::setHolidayMasks() |
1422 | { | 1423 | { |
1423 | mHolidayMask.resize(mSelectedDates.count()); | 1424 | mHolidayMask.resize(mSelectedDates.count()); |
1424 | 1425 | ||
1425 | uint i; | 1426 | uint i; |
1426 | for(i=0;i<mSelectedDates.count();++i) { | 1427 | for(i=0;i<mSelectedDates.count();++i) { |
1427 | QDate date = mSelectedDates[i]; | 1428 | QDate date = mSelectedDates[i]; |
1428 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1429 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1429 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1430 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1430 | bool showHoliday = false; | 1431 | bool showHoliday = false; |
1431 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1432 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1432 | QPtrList<Event> events = calendar()->events( date, true ); | 1433 | QPtrList<Event> events = calendar()->events( date, true ); |
1433 | Event *event; | 1434 | Event *event; |
1434 | for( event = events.first(); event; event = events.next() ) { | 1435 | for( event = events.first(); event; event = events.next() ) { |
1435 | if ( event->categories().contains("Holiday") || | 1436 | if ( event->categories().contains("Holiday") || |
1436 | event->categories().contains(i18n("Holiday"))) { | 1437 | event->categories().contains(i18n("Holiday"))) { |
1437 | showHoliday = true; | 1438 | showHoliday = true; |
1438 | break; | 1439 | break; |
1439 | } | 1440 | } |
1440 | } | 1441 | } |
1441 | 1442 | ||
1442 | } | 1443 | } |
1443 | 1444 | ||
1444 | #ifndef KORG_NOPLUGINS | 1445 | #ifndef KORG_NOPLUGINS |
1445 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1446 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1446 | !KOCore::self()->holiday(date).isEmpty(); | 1447 | !KOCore::self()->holiday(date).isEmpty(); |
1447 | #endif | 1448 | #endif |
1448 | bool showDay = showSaturday || showSunday || showHoliday; | 1449 | bool showDay = showSaturday || showSunday || showHoliday; |
1449 | 1450 | ||
1450 | if (showDay) { | 1451 | if (showDay) { |
1451 | mHolidayMask.at(i) = true; | 1452 | mHolidayMask.at(i) = true; |
1452 | } else { | 1453 | } else { |
1453 | mHolidayMask.at(i) = false; | 1454 | mHolidayMask.at(i) = false; |
1454 | } | 1455 | } |
1455 | } | 1456 | } |
1456 | 1457 | ||
1457 | mAgenda->setHolidayMask(&mHolidayMask); | 1458 | mAgenda->setHolidayMask(&mHolidayMask); |
1458 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1459 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1459 | } | 1460 | } |
1460 | 1461 | ||
1461 | void KOAgendaView::setContentsPos(int y) | 1462 | void KOAgendaView::setContentsPos(int y) |
1462 | { | 1463 | { |
1463 | mAgenda->setContentsPos(0,y); | 1464 | mAgenda->setContentsPos(0,y); |
1464 | } | 1465 | } |
1465 | 1466 | ||
1466 | void KOAgendaView::setExpandedButton( bool expanded ) | 1467 | void KOAgendaView::setExpandedButton( bool expanded ) |
1467 | { | 1468 | { |
1468 | if ( expanded ) { | 1469 | if ( expanded ) { |
1469 | mExpandButton->setPixmap( mExpandedPixmap ); | 1470 | mExpandButton->setPixmap( mExpandedPixmap ); |
1470 | } else { | 1471 | } else { |
1471 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 1472 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
1472 | } | 1473 | } |
1473 | } | 1474 | } |
1474 | 1475 | ||
1475 | void KOAgendaView::clearSelection() | 1476 | void KOAgendaView::clearSelection() |
1476 | { | 1477 | { |
1477 | mAgenda->deselectItem(); | 1478 | mAgenda->deselectItem(); |
1478 | mAllDayAgenda->deselectItem(); | 1479 | mAllDayAgenda->deselectItem(); |
1479 | } | 1480 | } |
1480 | 1481 | ||
1481 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1482 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1482 | int gxEnd, int gyEnd) | 1483 | int gxEnd, int gyEnd) |
1483 | { | 1484 | { |
1484 | mTimeSpanInAllDay = true; | 1485 | mTimeSpanInAllDay = true; |
1485 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1486 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1486 | } | 1487 | } |
1487 | 1488 | ||
1488 | 1489 | ||
1489 | 1490 | ||
1490 | 1491 | ||
1491 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1492 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1492 | int gxEnd, int gyEnd) | 1493 | int gxEnd, int gyEnd) |
1493 | { | 1494 | { |
1494 | if (!mSelectedDates.count()) return; | 1495 | if (!mSelectedDates.count()) return; |
1495 | 1496 | ||
1496 | QDate dayStart = mSelectedDates[gxStart]; | 1497 | QDate dayStart = mSelectedDates[gxStart]; |
1497 | QDate dayEnd = mSelectedDates[gxEnd]; | 1498 | QDate dayEnd = mSelectedDates[gxEnd]; |
1498 | 1499 | ||
1499 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1500 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1500 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1501 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1501 | 1502 | ||
1502 | QDateTime dtStart(dayStart,timeStart); | 1503 | QDateTime dtStart(dayStart,timeStart); |
1503 | QDateTime dtEnd(dayEnd,timeEnd); | 1504 | QDateTime dtEnd(dayEnd,timeEnd); |
1504 | 1505 | ||
1505 | mTimeSpanBegin = dtStart; | 1506 | mTimeSpanBegin = dtStart; |
1506 | mTimeSpanEnd = dtEnd; | 1507 | mTimeSpanEnd = dtEnd; |
1507 | 1508 | ||
1508 | } | 1509 | } |
1509 | 1510 | ||
1510 | void KOAgendaView::deleteSelectedDateTime() | 1511 | void KOAgendaView::deleteSelectedDateTime() |
1511 | { | 1512 | { |
1512 | mTimeSpanBegin.setDate(QDate()); | 1513 | mTimeSpanBegin.setDate(QDate()); |
1513 | mTimeSpanEnd.setDate(QDate()); | 1514 | mTimeSpanEnd.setDate(QDate()); |
1514 | mTimeSpanInAllDay = false; | 1515 | mTimeSpanInAllDay = false; |
1515 | } | 1516 | } |
1516 | 1517 | ||
1517 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1518 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1518 | { | 1519 | { |
1519 | e->ignore(); | 1520 | e->ignore(); |
1520 | } | 1521 | } |
1521 | 1522 | ||
1522 | void KOAgendaView::scrollOneHourUp() | 1523 | void KOAgendaView::scrollOneHourUp() |
1523 | { | 1524 | { |
1524 | 1525 | ||
1525 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1526 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1526 | } | 1527 | } |
1527 | void KOAgendaView::scrollOneHourDown() | 1528 | void KOAgendaView::scrollOneHourDown() |
1528 | { | 1529 | { |
1529 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1530 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1530 | } | 1531 | } |
1531 | 1532 | ||
1532 | void KOAgendaView::setStartHour( int h ) | 1533 | void KOAgendaView::setStartHour( int h ) |
1533 | { | 1534 | { |
1534 | mAgenda->setStartHour( h ); | 1535 | mAgenda->setStartHour( h ); |
1535 | 1536 | ||
1536 | } | 1537 | } |
1537 | 1538 | ||
1538 | void KOAgendaView::updateTodo( Todo * t, int ) | 1539 | void KOAgendaView::updateTodo( Todo * t, int ) |
1539 | { | 1540 | { |
1540 | if ( !isVisible() ) | 1541 | if ( !isVisible() ) |
1541 | return; | 1542 | return; |
1542 | bool remove = false; | 1543 | bool remove = false; |
1543 | bool removeAD = false; | 1544 | bool removeAD = false; |
1544 | QDate da; | 1545 | QDate da; |
1545 | if ( t->hasCompletedDate() ) | 1546 | if ( t->hasCompletedDate() ) |
1546 | da = t->completed().date(); | 1547 | da = t->completed().date(); |
1547 | else | 1548 | else |
1548 | da = t->dtDue().date(); | 1549 | da = t->dtDue().date(); |
1549 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1550 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1550 | remove = true; | 1551 | remove = true; |
1551 | removeAD = true; | 1552 | removeAD = true; |
1552 | } | 1553 | } |
1553 | else { | 1554 | else { |
1554 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1555 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1555 | if ( overdue && | 1556 | if ( overdue && |
1556 | QDate::currentDate() >= mSelectedDates.first() && | 1557 | QDate::currentDate() >= mSelectedDates.first() && |
1557 | QDate::currentDate() <= mSelectedDates.last()) { | 1558 | QDate::currentDate() <= mSelectedDates.last()) { |
1558 | removeAD = false; | 1559 | removeAD = false; |
1559 | remove = true; | 1560 | remove = true; |
1560 | } | 1561 | } |
1561 | else { | 1562 | else { |
1562 | 1563 | ||
1563 | if ( da < mSelectedDates.first() || | 1564 | if ( da < mSelectedDates.first() || |
1564 | da > mSelectedDates.last() ) { | 1565 | da > mSelectedDates.last() ) { |
1565 | remove = true; | 1566 | remove = true; |
1566 | removeAD = true; | 1567 | removeAD = true; |
1567 | } else { | 1568 | } else { |
1568 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1569 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1569 | removeAD = !remove; | 1570 | removeAD = !remove; |
1570 | } | 1571 | } |
1571 | } | 1572 | } |
1572 | } | 1573 | } |
1573 | int days = mSelectedDates.first().daysTo( da ); | 1574 | int days = mSelectedDates.first().daysTo( da ); |
1574 | //qDebug("daysto %d %d %d", days, remove,removeAD ); | 1575 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1575 | mAgenda->updateTodo( t , days, remove); | 1576 | mAgenda->updateTodo( t , days, remove); |
1576 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1577 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1577 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1578 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1578 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1579 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1579 | 1580 | ||
1580 | } | 1581 | } |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 549ef2a..dd83d48 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,628 +1,629 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | 29 | ||
30 | #include <kglobal.h> | 30 | #include <kglobal.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | 33 | ||
34 | #include <libkcal/vcaldrag.h> | 34 | #include <libkcal/vcaldrag.h> |
35 | #include <libkcal/icaldrag.h> | 35 | #include <libkcal/icaldrag.h> |
36 | #include <libkcal/dndfactory.h> | 36 | #include <libkcal/dndfactory.h> |
37 | #include <libkcal/calendarresources.h> | 37 | #include <libkcal/calendarresources.h> |
38 | #include <libkcal/resourcecalendar.h> | 38 | #include <libkcal/resourcecalendar.h> |
39 | #include <kresources/resourceselectdialog.h> | 39 | #include <kresources/resourceselectdialog.h> |
40 | 40 | ||
41 | #include <kcalendarsystem.h> | 41 | #include <kcalendarsystem.h> |
42 | 42 | ||
43 | #ifndef KORG_NOPLUGINS | 43 | #ifndef KORG_NOPLUGINS |
44 | #include "kocore.h" | 44 | #include "kocore.h" |
45 | #endif | 45 | #endif |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "koglobals.h" | 47 | #include "koglobals.h" |
48 | 48 | ||
49 | #include "kodaymatrix.h" | 49 | #include "kodaymatrix.h" |
50 | 50 | ||
51 | // ============================================================================ | 51 | // ============================================================================ |
52 | // D Y N A M I C T I P | 52 | // D Y N A M I C T I P |
53 | // ============================================================================ | 53 | // ============================================================================ |
54 | 54 | ||
55 | DynamicTip::DynamicTip( QWidget * parent ) | 55 | DynamicTip::DynamicTip( QWidget * parent ) |
56 | : QToolTip( parent ) | 56 | : QToolTip( parent ) |
57 | { | 57 | { |
58 | matrix = (KODayMatrix*)parent; | 58 | matrix = (KODayMatrix*)parent; |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | void DynamicTip::maybeTip( const QPoint &pos ) | 62 | void DynamicTip::maybeTip( const QPoint &pos ) |
63 | { | 63 | { |
64 | //calculate which cell of the matrix the mouse is in | 64 | //calculate which cell of the matrix the mouse is in |
65 | QRect sz = matrix->frameRect(); | 65 | QRect sz = matrix->frameRect(); |
66 | int dheight = sz.height()*7 / 42; | 66 | int dheight = sz.height()*7 / 42; |
67 | int dwidth = sz.width() / 7; | 67 | int dwidth = sz.width() / 7; |
68 | int row = pos.y()/dheight; | 68 | int row = pos.y()/dheight; |
69 | int col = pos.x()/dwidth; | 69 | int col = pos.x()/dwidth; |
70 | 70 | ||
71 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 71 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
72 | 72 | ||
73 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 73 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
74 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 74 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
75 | 75 | ||
76 | //show holiday names only | 76 | //show holiday names only |
77 | QString str = matrix->getHolidayLabel(col+row*7); | 77 | QString str = matrix->getHolidayLabel(col+row*7); |
78 | if (str.isEmpty()) return; | 78 | if (str.isEmpty()) return; |
79 | tip(rct, str); | 79 | tip(rct, str); |
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | // ============================================================================ | 83 | // ============================================================================ |
84 | // K O D A Y M A T R I X | 84 | // K O D A Y M A T R I X |
85 | // ============================================================================ | 85 | // ============================================================================ |
86 | 86 | ||
87 | const int KODayMatrix::NOSELECTION = -1000; | 87 | const int KODayMatrix::NOSELECTION = -1000; |
88 | const int KODayMatrix::NUMDAYS = 42; | 88 | const int KODayMatrix::NUMDAYS = 42; |
89 | 89 | ||
90 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 90 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
91 | QFrame(parent, name) | 91 | QFrame(parent, name) |
92 | { | 92 | { |
93 | mCalendar = calendar; | 93 | mCalendar = calendar; |
94 | mPendingUpdateBeforeRepaint = false; | 94 | mPendingUpdateBeforeRepaint = false; |
95 | 95 | ||
96 | // initialize dynamic arrays | 96 | // initialize dynamic arrays |
97 | days = new QDate[NUMDAYS]; | 97 | days = new QDate[NUMDAYS]; |
98 | daylbls = new QString[NUMDAYS]; | 98 | daylbls = new QString[NUMDAYS]; |
99 | events = new int[NUMDAYS]; | 99 | events = new int[NUMDAYS]; |
100 | mToolTip = new DynamicTip(this); | 100 | mToolTip = new DynamicTip(this); |
101 | 101 | ||
102 | // set default values used for drawing the matrix | 102 | // set default values used for drawing the matrix |
103 | mDefaultBackColor = palette().active().base(); | 103 | mDefaultBackColor = palette().active().base(); |
104 | mDefaultTextColor = palette().active().foreground(); | 104 | mDefaultTextColor = palette().active().foreground(); |
105 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 105 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
106 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 106 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
107 | mSelectedDaysColor = QColor("white"); | 107 | mSelectedDaysColor = QColor("white"); |
108 | mTodayMarginWidth = 2; | 108 | mTodayMarginWidth = 2; |
109 | mSelEnd = mSelStart = NOSELECTION; | 109 | mSelEnd = mSelStart = NOSELECTION; |
110 | 110 | ||
111 | setAcceptDrops(true); | 111 | setAcceptDrops(true); |
112 | //setFont( QFont("Arial", 10) ); | 112 | //setFont( QFont("Arial", 10) ); |
113 | 113 | ||
114 | mUpdateTimer = new QTimer( this ); | 114 | mUpdateTimer = new QTimer( this ); |
115 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 115 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
116 | mRepaintTimer = new QTimer( this ); | 116 | mRepaintTimer = new QTimer( this ); |
117 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 117 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
118 | mDayChanged = false; | 118 | mDayChanged = false; |
119 | updateView(); | 119 | updateView(); |
120 | } | 120 | } |
121 | 121 | ||
122 | QColor KODayMatrix::getShadedColor(QColor color) | 122 | QColor KODayMatrix::getShadedColor(QColor color) |
123 | { | 123 | { |
124 | QColor shaded; | 124 | QColor shaded; |
125 | int h=0; | 125 | int h=0; |
126 | int s=0; | 126 | int s=0; |
127 | int v=0; | 127 | int v=0; |
128 | color.hsv(&h,&s,&v); | 128 | color.hsv(&h,&s,&v); |
129 | s = s/4; | 129 | s = s/4; |
130 | v = 192+v/4; | 130 | v = 192+v/4; |
131 | shaded.setHsv(h,s,v); | 131 | shaded.setHsv(h,s,v); |
132 | 132 | ||
133 | return shaded; | 133 | return shaded; |
134 | } | 134 | } |
135 | 135 | ||
136 | KODayMatrix::~KODayMatrix() | 136 | KODayMatrix::~KODayMatrix() |
137 | { | 137 | { |
138 | delete [] days; | 138 | delete [] days; |
139 | delete [] daylbls; | 139 | delete [] daylbls; |
140 | delete [] events; | 140 | delete [] events; |
141 | delete mToolTip; | 141 | delete mToolTip; |
142 | } | 142 | } |
143 | 143 | ||
144 | /* | 144 | /* |
145 | void KODayMatrix::setStartDate(QDate start) | 145 | void KODayMatrix::setStartDate(QDate start) |
146 | { | 146 | { |
147 | updateView(start); | 147 | updateView(start); |
148 | } | 148 | } |
149 | */ | 149 | */ |
150 | 150 | ||
151 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 151 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
152 | { | 152 | { |
153 | 153 | ||
154 | if (mSelStart == NOSELECTION) { | 154 | if (mSelStart == NOSELECTION) { |
155 | return; | 155 | return; |
156 | } | 156 | } |
157 | 157 | ||
158 | //cope with selection being out of matrix limits at top (< 0) | 158 | //cope with selection being out of matrix limits at top (< 0) |
159 | int i0 = mSelStart; | 159 | int i0 = mSelStart; |
160 | if (i0 < 0) { | 160 | if (i0 < 0) { |
161 | for (int i = i0; i < 0; i++) { | 161 | for (int i = i0; i < 0; i++) { |
162 | selDays.append(days[0].addDays(i)); | 162 | selDays.append(days[0].addDays(i)); |
163 | } | 163 | } |
164 | i0 = 0; | 164 | i0 = 0; |
165 | } | 165 | } |
166 | 166 | ||
167 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 167 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
168 | if (mSelEnd > NUMDAYS-1) { | 168 | if (mSelEnd > NUMDAYS-1) { |
169 | for (int i = i0; i <= NUMDAYS-1; i++) { | 169 | for (int i = i0; i <= NUMDAYS-1; i++) { |
170 | selDays.append(days[i]); | 170 | selDays.append(days[i]); |
171 | } | 171 | } |
172 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 172 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
173 | selDays.append(days[0].addDays(i)); | 173 | selDays.append(days[0].addDays(i)); |
174 | } | 174 | } |
175 | 175 | ||
176 | // apply normal routine to selection being entirely within matrix limits | 176 | // apply normal routine to selection being entirely within matrix limits |
177 | } else { | 177 | } else { |
178 | for (int i = i0; i <= mSelEnd; i++) { | 178 | for (int i = i0; i <= mSelEnd; i++) { |
179 | selDays.append(days[i]); | 179 | selDays.append(days[i]); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 184 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
185 | { | 185 | { |
186 | mSelStart = startdate.daysTo(start); | 186 | mSelStart = startdate.daysTo(start); |
187 | mSelEnd = startdate.daysTo(end); | 187 | mSelEnd = startdate.daysTo(end); |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | void KODayMatrix::recalculateToday() | 191 | void KODayMatrix::recalculateToday() |
192 | { | 192 | { |
193 | today = -1; | 193 | today = -1; |
194 | for (int i=0; i<NUMDAYS; i++) { | 194 | for (int i=0; i<NUMDAYS; i++) { |
195 | events[i] = 0; | 195 | events[i] = 0; |
196 | days[i] = startdate.addDays(i); | 196 | days[i] = startdate.addDays(i); |
197 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 197 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
198 | 198 | ||
199 | // if today is in the currently displayed month, hilight today | 199 | // if today is in the currently displayed month, hilight today |
200 | if (days[i].year() == QDate::currentDate().year() && | 200 | if (days[i].year() == QDate::currentDate().year() && |
201 | days[i].month() == QDate::currentDate().month() && | 201 | days[i].month() == QDate::currentDate().month() && |
202 | days[i].day() == QDate::currentDate().day()) { | 202 | days[i].day() == QDate::currentDate().day()) { |
203 | today = i; | 203 | today = i; |
204 | } | 204 | } |
205 | } | 205 | } |
206 | // qDebug(QString("Today is visible at %1.").arg(today)); | 206 | // qDebug(QString("Today is visible at %1.").arg(today)); |
207 | } | 207 | } |
208 | 208 | ||
209 | void KODayMatrix::updateView() | 209 | void KODayMatrix::updateView() |
210 | { | 210 | { |
211 | updateView(startdate); | 211 | updateView(startdate); |
212 | } | 212 | } |
213 | void KODayMatrix::repaintViewTimed() | 213 | void KODayMatrix::repaintViewTimed() |
214 | { | 214 | { |
215 | mRepaintTimer->stop(); | 215 | mRepaintTimer->stop(); |
216 | repaint(false); | 216 | repaint(false); |
217 | } | 217 | } |
218 | void KODayMatrix::updateViewTimed() | 218 | void KODayMatrix::updateViewTimed() |
219 | { | 219 | { |
220 | 220 | ||
221 | mUpdateTimer->stop(); | 221 | mUpdateTimer->stop(); |
222 | for(int i = 0; i < NUMDAYS; i++) { | 222 | for(int i = 0; i < NUMDAYS; i++) { |
223 | // if events are set for the day then remember to draw it bold | 223 | // if events are set for the day then remember to draw it bold |
224 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 224 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
225 | Event *event; | 225 | Event *event; |
226 | int numEvents = eventlist.count(); | 226 | int numEvents = eventlist.count(); |
227 | QString holiStr = ""; | 227 | QString holiStr = ""; |
228 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 228 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
229 | ushort recurType = event->recurrence()->doesRecur(); | 229 | ushort recurType = event->recurrence()->doesRecur(); |
230 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 230 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
231 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 231 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
232 | numEvents--; | 232 | numEvents--; |
233 | } | 233 | } |
234 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | 234 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { |
235 | if ( !holiStr.isEmpty() ) | 235 | if ( !holiStr.isEmpty() ) |
236 | holiStr += "\n"; | 236 | holiStr += "\n"; |
237 | holiStr += event->summary(); | 237 | holiStr += event->summary(); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | events[i] = numEvents; | 240 | events[i] = numEvents; |
241 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 241 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
242 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 242 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
243 | !holiStr.isEmpty()) { | 243 | !holiStr.isEmpty()) { |
244 | mHolidays[i] = holiStr; | 244 | mHolidays[i] = holiStr; |
245 | } else { | 245 | } else { |
246 | mHolidays[i] = QString::null; | 246 | mHolidays[i] = QString::null; |
247 | } | 247 | } |
248 | } | 248 | } |
249 | if ( ! mPendingUpdateBeforeRepaint ) | 249 | if ( ! mPendingUpdateBeforeRepaint ) |
250 | repaint(false); | 250 | repaint(false); |
251 | } | 251 | } |
252 | void KODayMatrix::updateView(QDate actdate) | 252 | void KODayMatrix::updateView(QDate actdate) |
253 | { | 253 | { |
254 | 254 | ||
255 | if ( ! actdate.isValid() ) { | 255 | if ( ! actdate.isValid() ) { |
256 | //qDebug("date not valid "); | 256 | //qDebug("date not valid "); |
257 | return; | 257 | return; |
258 | } | 258 | } |
259 | mDayChanged = false; | 259 | mDayChanged = false; |
260 | //flag to indicate if the starting day of the matrix has changed by this call | 260 | //flag to indicate if the starting day of the matrix has changed by this call |
261 | //mDayChanged = false; | 261 | //mDayChanged = false; |
262 | // if a new startdate is to be set then apply Cornelius's calculation | 262 | // if a new startdate is to be set then apply Cornelius's calculation |
263 | // of the first day to be shown | 263 | // of the first day to be shown |
264 | if (actdate != startdate) { | 264 | if (actdate != startdate) { |
265 | // reset index of selection according to shift of starting date from startdate to actdate | 265 | // reset index of selection according to shift of starting date from startdate to actdate |
266 | if (mSelStart != NOSELECTION) { | 266 | if (mSelStart != NOSELECTION) { |
267 | int tmp = actdate.daysTo(startdate); | 267 | int tmp = actdate.daysTo(startdate); |
268 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 268 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
269 | // shift selection if new one would be visible at least partly ! | 269 | // shift selection if new one would be visible at least partly ! |
270 | 270 | ||
271 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 271 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
272 | // nested if is required for next X display pushed from a different month - correction required | 272 | // nested if is required for next X display pushed from a different month - correction required |
273 | // otherwise, for month forward and backward, it must be avoided | 273 | // otherwise, for month forward and backward, it must be avoided |
274 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 274 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
275 | mSelStart = mSelStart + tmp; | 275 | mSelStart = mSelStart + tmp; |
276 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 276 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
277 | mSelEnd = mSelEnd + tmp; | 277 | mSelEnd = mSelEnd + tmp; |
278 | } | 278 | } |
279 | } | 279 | } |
280 | startdate = actdate; | 280 | startdate = actdate; |
281 | mDayChanged = true; | 281 | mDayChanged = true; |
282 | recalculateToday(); | 282 | recalculateToday(); |
283 | } | 283 | } |
284 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 284 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
285 | if ( !isVisible() ) { | 285 | if ( !isVisible() ) { |
286 | mPendingUpdateBeforeRepaint = true; | 286 | mPendingUpdateBeforeRepaint = true; |
287 | } else { | 287 | } else { |
288 | #ifdef DESKTOP_VERSION | 288 | #ifdef DESKTOP_VERSION |
289 | //mRepaintTimer->start( 250 ); | 289 | //mRepaintTimer->start( 250 ); |
290 | mUpdateTimer->start( 250 ); | 290 | mUpdateTimer->start( 250 ); |
291 | #else | 291 | #else |
292 | mRepaintTimer->start( 350 ); | 292 | mRepaintTimer->start( 350 ); |
293 | mUpdateTimer->start( 2000 ); | 293 | mUpdateTimer->start( 2000 ); |
294 | #endif | 294 | #endif |
295 | } | 295 | } |
296 | } | 296 | } |
297 | 297 | ||
298 | const QDate& KODayMatrix::getDate(int offset) | 298 | const QDate& KODayMatrix::getDate(int offset) |
299 | { | 299 | { |
300 | if (offset < 0 || offset > NUMDAYS-1) { | 300 | if (offset < 0 || offset > NUMDAYS-1) { |
301 | qDebug("Wrong offset2 "); | 301 | qDebug("Wrong offset2 "); |
302 | return days[0]; | 302 | return days[0]; |
303 | } | 303 | } |
304 | return days[offset]; | 304 | return days[offset]; |
305 | } | 305 | } |
306 | 306 | ||
307 | QString KODayMatrix::getHolidayLabel(int offset) | 307 | QString KODayMatrix::getHolidayLabel(int offset) |
308 | { | 308 | { |
309 | if (offset < 0 || offset > NUMDAYS-1) { | 309 | if (offset < 0 || offset > NUMDAYS-1) { |
310 | qDebug("Wrong offset1 "); | 310 | qDebug("Wrong offset1 "); |
311 | return 0; | 311 | return 0; |
312 | } | 312 | } |
313 | return mHolidays[offset]; | 313 | return mHolidays[offset]; |
314 | } | 314 | } |
315 | 315 | ||
316 | int KODayMatrix::getDayIndexFrom(int x, int y) | 316 | int KODayMatrix::getDayIndexFrom(int x, int y) |
317 | { | 317 | { |
318 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 318 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
319 | 6 - x/daysize.width() : x/daysize.width()); | 319 | 6 - x/daysize.width() : x/daysize.width()); |
320 | } | 320 | } |
321 | 321 | ||
322 | // ---------------------------------------------------------------------------- | 322 | // ---------------------------------------------------------------------------- |
323 | // M O U S E E V E N T H A N D L I N G | 323 | // M O U S E E V E N T H A N D L I N G |
324 | // ---------------------------------------------------------------------------- | 324 | // ---------------------------------------------------------------------------- |
325 | 325 | ||
326 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 326 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
327 | { | 327 | { |
328 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 328 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
329 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 329 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
330 | mSelInit = mSelStart; | 330 | mSelInit = mSelStart; |
331 | } | 331 | } |
332 | 332 | ||
333 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 333 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
334 | { | 334 | { |
335 | 335 | ||
336 | int tmp = getDayIndexFrom(e->x(), e->y()); | 336 | int tmp = getDayIndexFrom(e->x(), e->y()); |
337 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 337 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
338 | 338 | ||
339 | if (mSelInit > tmp) { | 339 | if (mSelInit > tmp) { |
340 | mSelEnd = mSelInit; | 340 | mSelEnd = mSelInit; |
341 | if (tmp != mSelStart) { | 341 | if (tmp != mSelStart) { |
342 | mSelStart = tmp; | 342 | mSelStart = tmp; |
343 | repaint(); | 343 | repaint(); |
344 | } | 344 | } |
345 | } else { | 345 | } else { |
346 | mSelStart = mSelInit; | 346 | mSelStart = mSelInit; |
347 | 347 | ||
348 | //repaint only if selection has changed | 348 | //repaint only if selection has changed |
349 | if (tmp != mSelEnd) { | 349 | if (tmp != mSelEnd) { |
350 | mSelEnd = tmp; | 350 | mSelEnd = tmp; |
351 | repaint(); | 351 | repaint(); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | 354 | ||
355 | DateList daylist; | 355 | DateList daylist; |
356 | if ( mSelStart < 0 ) | 356 | if ( mSelStart < 0 ) |
357 | mSelStart = 0; | 357 | mSelStart = 0; |
358 | for (int i = mSelStart; i <= mSelEnd; i++) { | 358 | for (int i = mSelStart; i <= mSelEnd; i++) { |
359 | daylist.append(days[i]); | 359 | daylist.append(days[i]); |
360 | } | 360 | } |
361 | emit selected((const DateList)daylist); | 361 | emit selected((const DateList)daylist); |
362 | 362 | ||
363 | } | 363 | } |
364 | 364 | ||
365 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 365 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
366 | { | 366 | { |
367 | int tmp = getDayIndexFrom(e->x(), e->y()); | 367 | int tmp = getDayIndexFrom(e->x(), e->y()); |
368 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 368 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
369 | 369 | ||
370 | if (mSelInit > tmp) { | 370 | if (mSelInit > tmp) { |
371 | mSelEnd = mSelInit; | 371 | mSelEnd = mSelInit; |
372 | if (tmp != mSelStart) { | 372 | if (tmp != mSelStart) { |
373 | mSelStart = tmp; | 373 | mSelStart = tmp; |
374 | repaint(); | 374 | repaint(); |
375 | } | 375 | } |
376 | } else { | 376 | } else { |
377 | mSelStart = mSelInit; | 377 | mSelStart = mSelInit; |
378 | 378 | ||
379 | //repaint only if selection has changed | 379 | //repaint only if selection has changed |
380 | if (tmp != mSelEnd) { | 380 | if (tmp != mSelEnd) { |
381 | mSelEnd = tmp; | 381 | mSelEnd = tmp; |
382 | repaint(); | 382 | repaint(); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | // ---------------------------------------------------------------------------- | 387 | // ---------------------------------------------------------------------------- |
388 | // D R A G ' N D R O P H A N D L I N G | 388 | // D R A G ' N D R O P H A N D L I N G |
389 | // ---------------------------------------------------------------------------- | 389 | // ---------------------------------------------------------------------------- |
390 | 390 | ||
391 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 391 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
392 | { | 392 | { |
393 | #ifndef KORG_NODND | 393 | #ifndef KORG_NODND |
394 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 394 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
395 | e->ignore(); | 395 | e->ignore(); |
396 | return; | 396 | return; |
397 | } | 397 | } |
398 | 398 | ||
399 | // some visual feedback | 399 | // some visual feedback |
400 | // oldPalette = palette(); | 400 | // oldPalette = palette(); |
401 | // setPalette(my_HilitePalette); | 401 | // setPalette(my_HilitePalette); |
402 | // update(); | 402 | // update(); |
403 | #endif | 403 | #endif |
404 | } | 404 | } |
405 | 405 | ||
406 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 406 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
407 | { | 407 | { |
408 | #ifndef KORG_NODND | 408 | #ifndef KORG_NODND |
409 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 409 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
410 | e->ignore(); | 410 | e->ignore(); |
411 | return; | 411 | return; |
412 | } | 412 | } |
413 | 413 | ||
414 | e->accept(); | 414 | e->accept(); |
415 | #endif | 415 | #endif |
416 | } | 416 | } |
417 | 417 | ||
418 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 418 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
419 | { | 419 | { |
420 | #ifndef KORG_NODND | 420 | #ifndef KORG_NODND |
421 | // setPalette(oldPalette); | 421 | // setPalette(oldPalette); |
422 | // update(); | 422 | // update(); |
423 | #endif | 423 | #endif |
424 | } | 424 | } |
425 | 425 | ||
426 | void KODayMatrix::dropEvent(QDropEvent *e) | 426 | void KODayMatrix::dropEvent(QDropEvent *e) |
427 | { | 427 | { |
428 | #ifndef KORG_NODND | 428 | #ifndef KORG_NODND |
429 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 429 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
430 | 430 | ||
431 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 431 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
432 | e->ignore(); | 432 | e->ignore(); |
433 | return; | 433 | return; |
434 | } | 434 | } |
435 | 435 | ||
436 | DndFactory factory( mCalendar ); | 436 | DndFactory factory( mCalendar ); |
437 | Event *event = factory.createDrop(e); | 437 | Event *event = factory.createDrop(e); |
438 | 438 | ||
439 | if (event) { | 439 | if (event) { |
440 | e->acceptAction(); | 440 | e->acceptAction(); |
441 | 441 | ||
442 | Event *existingEvent = mCalendar->event(event->uid()); | 442 | Event *existingEvent = mCalendar->event(event->uid()); |
443 | 443 | ||
444 | if(existingEvent) { | 444 | if(existingEvent) { |
445 | // uniquify event | 445 | // uniquify event |
446 | event->recreate(); | 446 | event->recreate(); |
447 | /* | 447 | /* |
448 | KMessageBox::sorry(this, | 448 | KMessageBox::sorry(this, |
449 | i18n("Event already exists in this calendar."), | 449 | i18n("Event already exists in this calendar."), |
450 | i18n("Drop Event")); | 450 | i18n("Drop Event")); |
451 | delete event; | 451 | delete event; |
452 | return; | 452 | return; |
453 | */ | 453 | */ |
454 | } | 454 | } |
455 | // kdDebug() << "Drop new Event" << endl; | 455 | // kdDebug() << "Drop new Event" << endl; |
456 | // Adjust date | 456 | // Adjust date |
457 | QDateTime start = event->dtStart(); | 457 | QDateTime start = event->dtStart(); |
458 | QDateTime end = event->dtEnd(); | 458 | QDateTime end = event->dtEnd(); |
459 | int duration = start.daysTo(end); | 459 | int duration = start.daysTo(end); |
460 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 460 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
461 | 461 | ||
462 | start.setDate(days[idx]); | 462 | start.setDate(days[idx]); |
463 | end.setDate(days[idx].addDays(duration)); | 463 | end.setDate(days[idx].addDays(duration)); |
464 | 464 | ||
465 | event->setDtStart(start); | 465 | event->setDtStart(start); |
466 | event->setDtEnd(end); | 466 | event->setDtEnd(end); |
467 | mCalendar->addEvent(event); | 467 | mCalendar->addEvent(event); |
468 | 468 | ||
469 | emit eventDropped(event); | 469 | emit eventDropped(event); |
470 | } else { | 470 | } else { |
471 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 471 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
472 | e->ignore(); | 472 | e->ignore(); |
473 | } | 473 | } |
474 | #endif | 474 | #endif |
475 | } | 475 | } |
476 | 476 | ||
477 | // ---------------------------------------------------------------------------- | 477 | // ---------------------------------------------------------------------------- |
478 | // P A I N T E V E N T H A N D L I N G | 478 | // P A I N T E V E N T H A N D L I N G |
479 | // ---------------------------------------------------------------------------- | 479 | // ---------------------------------------------------------------------------- |
480 | 480 | ||
481 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 481 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
482 | { | 482 | { |
483 | if ( width() <= 0 || height() <= 0 ) | 483 | if ( width() <= 0 || height() <= 0 ) |
484 | return; | 484 | return; |
485 | if ( mPendingUpdateBeforeRepaint ) { | 485 | if ( mPendingUpdateBeforeRepaint ) { |
486 | updateViewTimed(); | 486 | updateViewTimed(); |
487 | mPendingUpdateBeforeRepaint = false; | 487 | mPendingUpdateBeforeRepaint = false; |
488 | } | 488 | } |
489 | if ( myPix.width() != width() || myPix.height()!=height() ) { | 489 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
490 | myPix.resize(size() ); | 490 | myPix.resize(size() ); |
491 | } | 491 | } |
492 | QPainter p(&myPix); | 492 | QPainter p(&myPix); |
493 | p.setFont(font()); | ||
493 | 494 | ||
494 | QRect sz = frameRect(); | 495 | QRect sz = frameRect(); |
495 | int dheight = daysize.height(); | 496 | int dheight = daysize.height(); |
496 | int dwidth = daysize.width(); | 497 | int dwidth = daysize.width(); |
497 | int row,col; | 498 | int row,col; |
498 | int selw, selh; | 499 | int selw, selh; |
499 | bool isRTL = KOGlobals::self()->reverseLayout(); | 500 | bool isRTL = KOGlobals::self()->reverseLayout(); |
500 | 501 | ||
501 | // draw background and topleft frame | 502 | // draw background and topleft frame |
502 | p.fillRect(pevent->rect(), mDefaultBackColor); | 503 | p.fillRect(pevent->rect(), mDefaultBackColor); |
503 | p.setPen(mDefaultTextColor); | 504 | p.setPen(mDefaultTextColor); |
504 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 505 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
505 | 506 | ||
506 | // draw selected days with highlighted background color | 507 | // draw selected days with highlighted background color |
507 | if (mSelStart != NOSELECTION) { | 508 | if (mSelStart != NOSELECTION) { |
508 | 509 | ||
509 | row = mSelStart/7; | 510 | row = mSelStart/7; |
510 | col = mSelStart -row*7; | 511 | col = mSelStart -row*7; |
511 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 512 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
512 | 513 | ||
513 | if (row == mSelEnd/7) { | 514 | if (row == mSelEnd/7) { |
514 | // Single row selection | 515 | // Single row selection |
515 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, | 516 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, |
516 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); | 517 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); |
517 | } else { | 518 | } else { |
518 | // draw first row to the right | 519 | // draw first row to the right |
519 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, | 520 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, |
520 | dheight, selcol); | 521 | dheight, selcol); |
521 | // draw full block till last line | 522 | // draw full block till last line |
522 | selh = mSelEnd/7-row; | 523 | selh = mSelEnd/7-row; |
523 | if (selh > 1) { | 524 | if (selh > 1) { |
524 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); | 525 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); |
525 | } | 526 | } |
526 | // draw last block from left to mSelEnd | 527 | // draw last block from left to mSelEnd |
527 | selw = mSelEnd-7*(mSelEnd/7)+1; | 528 | selw = mSelEnd-7*(mSelEnd/7)+1; |
528 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, | 529 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, |
529 | selw*dwidth, dheight, selcol); | 530 | selw*dwidth, dheight, selcol); |
530 | } | 531 | } |
531 | } | 532 | } |
532 | 533 | ||
533 | // iterate over all days in the matrix and draw the day label in appropriate colors | 534 | // iterate over all days in the matrix and draw the day label in appropriate colors |
534 | QColor actcol = mDefaultTextColorShaded; | 535 | QColor actcol = mDefaultTextColorShaded; |
535 | p.setPen(actcol); | 536 | p.setPen(actcol); |
536 | QPen tmppen; | 537 | QPen tmppen; |
537 | for(int i = 0; i < NUMDAYS; i++) { | 538 | for(int i = 0; i < NUMDAYS; i++) { |
538 | row = i/7; | 539 | row = i/7; |
539 | col = isRTL ? 6-(i-row*7) : i-row*7; | 540 | col = isRTL ? 6-(i-row*7) : i-row*7; |
540 | 541 | ||
541 | // if it is the first day of a month switch color from normal to shaded and vice versa | 542 | // if it is the first day of a month switch color from normal to shaded and vice versa |
542 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 543 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
543 | if (actcol == mDefaultTextColorShaded) { | 544 | if (actcol == mDefaultTextColorShaded) { |
544 | actcol = mDefaultTextColor; | 545 | actcol = mDefaultTextColor; |
545 | } else { | 546 | } else { |
546 | actcol = mDefaultTextColorShaded; | 547 | actcol = mDefaultTextColorShaded; |
547 | } | 548 | } |
548 | p.setPen(actcol); | 549 | p.setPen(actcol); |
549 | } | 550 | } |
550 | 551 | ||
551 | //Reset pen color after selected days block | 552 | //Reset pen color after selected days block |
552 | if (i == mSelEnd+1) { | 553 | if (i == mSelEnd+1) { |
553 | p.setPen(actcol); | 554 | p.setPen(actcol); |
554 | } | 555 | } |
555 | 556 | ||
556 | // if today then draw rectangle around day | 557 | // if today then draw rectangle around day |
557 | if (today == i) { | 558 | if (today == i) { |
558 | tmppen = p.pen(); | 559 | tmppen = p.pen(); |
559 | QPen mTodayPen(p.pen()); | 560 | QPen mTodayPen(p.pen()); |
560 | 561 | ||
561 | mTodayPen.setWidth(mTodayMarginWidth); | 562 | mTodayPen.setWidth(mTodayMarginWidth); |
562 | //draw red rectangle for holidays | 563 | //draw red rectangle for holidays |
563 | if (!mHolidays[i].isNull()) { | 564 | if (!mHolidays[i].isNull()) { |
564 | if (actcol == mDefaultTextColor) { | 565 | if (actcol == mDefaultTextColor) { |
565 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 566 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
566 | } else { | 567 | } else { |
567 | mTodayPen.setColor(mHolidayColorShaded); | 568 | mTodayPen.setColor(mHolidayColorShaded); |
568 | } | 569 | } |
569 | } | 570 | } |
570 | //draw gray rectangle for today if in selection | 571 | //draw gray rectangle for today if in selection |
571 | if (i >= mSelStart && i <= mSelEnd) { | 572 | if (i >= mSelStart && i <= mSelEnd) { |
572 | QColor grey("grey"); | 573 | QColor grey("grey"); |
573 | mTodayPen.setColor(grey); | 574 | mTodayPen.setColor(grey); |
574 | } | 575 | } |
575 | p.setPen(mTodayPen); | 576 | p.setPen(mTodayPen); |
576 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); | 577 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); |
577 | p.setPen(tmppen); | 578 | p.setPen(tmppen); |
578 | } | 579 | } |
579 | 580 | ||
580 | // if any events are on that day then draw it using a bold font | 581 | // if any events are on that day then draw it using a bold font |
581 | if (events[i] > 0) { | 582 | if (events[i] > 0) { |
582 | QFont myFont = font(); | 583 | QFont myFont = font(); |
583 | myFont.setBold(true); | 584 | myFont.setBold(true); |
584 | p.setFont(myFont); | 585 | p.setFont(myFont); |
585 | } | 586 | } |
586 | 587 | ||
587 | // if it is a holiday then use the default holiday color | 588 | // if it is a holiday then use the default holiday color |
588 | if (!mHolidays[i].isNull()) { | 589 | if (!mHolidays[i].isNull()) { |
589 | if (actcol == mDefaultTextColor) { | 590 | if (actcol == mDefaultTextColor) { |
590 | p.setPen(KOPrefs::instance()->mHolidayColor); | 591 | p.setPen(KOPrefs::instance()->mHolidayColor); |
591 | } else { | 592 | } else { |
592 | p.setPen(mHolidayColorShaded); | 593 | p.setPen(mHolidayColorShaded); |
593 | } | 594 | } |
594 | } | 595 | } |
595 | 596 | ||
596 | // draw selected days with special color | 597 | // draw selected days with special color |
597 | // DO NOT specially highlight holidays in selection ! | 598 | // DO NOT specially highlight holidays in selection ! |
598 | if (i >= mSelStart && i <= mSelEnd) { | 599 | if (i >= mSelStart && i <= mSelEnd) { |
599 | p.setPen(mSelectedDaysColor); | 600 | p.setPen(mSelectedDaysColor); |
600 | } | 601 | } |
601 | 602 | ||
602 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, | 603 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, |
603 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 604 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
604 | 605 | ||
605 | // reset color to actual color | 606 | // reset color to actual color |
606 | if (!mHolidays[i].isNull()) { | 607 | if (!mHolidays[i].isNull()) { |
607 | p.setPen(actcol); | 608 | p.setPen(actcol); |
608 | } | 609 | } |
609 | // reset bold font to plain font | 610 | // reset bold font to plain font |
610 | if (events[i] > 0) { | 611 | if (events[i] > 0) { |
611 | QFont myFont = font(); | 612 | QFont myFont = font(); |
612 | myFont.setBold(false); | 613 | myFont.setBold(false); |
613 | p.setFont(myFont); | 614 | p.setFont(myFont); |
614 | } | 615 | } |
615 | } | 616 | } |
616 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 617 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
617 | } | 618 | } |
618 | 619 | ||
619 | // ---------------------------------------------------------------------------- | 620 | // ---------------------------------------------------------------------------- |
620 | // R E SI Z E E V E N T H A N D L I N G | 621 | // R E SI Z E E V E N T H A N D L I N G |
621 | // ---------------------------------------------------------------------------- | 622 | // ---------------------------------------------------------------------------- |
622 | 623 | ||
623 | void KODayMatrix::resizeEvent(QResizeEvent *) | 624 | void KODayMatrix::resizeEvent(QResizeEvent *) |
624 | { | 625 | { |
625 | QRect sz = frameRect(); | 626 | QRect sz = frameRect(); |
626 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 627 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
627 | daysize.setWidth(sz.width() / 7); | 628 | daysize.setWidth(sz.width() / 7); |
628 | } | 629 | } |