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