-rw-r--r-- | korganizer/koagendaview.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index f8301f8..918931a 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -51,928 +51,927 @@ | |||
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 | QVBox *dummyAllDayRight = new QVBox(mAllDayFrame); |
429 | 429 | ||
430 | QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight); | 430 | QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight); |
431 | mDummyAllDayRightL = new QLabel ( dummyAllDayRight ); | 431 | mDummyAllDayRightL = new QLabel ( dummyAllDayRight ); |
432 | 432 | ||
433 | dummyAllDayRightB->setFlat( true ); | 433 | dummyAllDayRightB->setFlat( true ); |
434 | dummyAllDayRightB->setFocusPolicy(NoFocus); | 434 | dummyAllDayRightB->setFocusPolicy(NoFocus); |
435 | // dummyAllDayRightB->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); | ||
436 | dummyAllDayRightB->setFixedHeight( (dummyAllDayRightB->sizeHint().height()/4)*3 ); | 435 | dummyAllDayRightB->setFixedHeight( (dummyAllDayRightB->sizeHint().height()/4)*3 ); |
437 | QPopupMenu * wpo = new QPopupMenu (this); | 436 | QPopupMenu * wpo = new QPopupMenu (this); |
438 | wpo->insertItem( i18n("W#"), 0 ); | 437 | wpo->insertItem( i18n("W#"), 0 ); |
439 | int i; | 438 | int i; |
440 | for ( i = 1; i < 53; i++ ) | 439 | for ( i = 1; i < 53; i++ ) |
441 | wpo->insertItem( QString::number( i ),i ); | 440 | wpo->insertItem( QString::number( i ),i ); |
442 | //Qt bug - we must add some empty fields... | 441 | //Qt bug - we must add some empty fields... |
443 | for ( i = 53; i < 54; ++i ) { | 442 | for ( i = 53; i < 54; ++i ) { |
444 | wpo->insertItem( "", 52 ); | 443 | wpo->insertItem( "", 52 ); |
445 | } | 444 | } |
446 | dummyAllDayRightB->setPopup( wpo ); | 445 | dummyAllDayRightB->setPopup( wpo ); |
447 | 446 | ||
448 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); | 447 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); |
449 | 448 | ||
450 | // Create event context menu for all day agenda | 449 | // Create event context menu for all day agenda |
451 | mAllDayAgendaPopup = eventPopup(); | 450 | mAllDayAgendaPopup = eventPopup(); |
452 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 451 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
453 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 452 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
454 | 453 | ||
455 | // Create agenda frame | 454 | // Create agenda frame |
456 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); | 455 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); |
457 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 456 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
458 | 457 | ||
459 | // create event indicator bars | 458 | // create event indicator bars |
460 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 459 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
461 | agendaLayout->addWidget(mEventIndicatorTop,0,1); | 460 | agendaLayout->addWidget(mEventIndicatorTop,0,1); |
462 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 461 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
463 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 462 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
464 | agendaFrame); | 463 | agendaFrame); |
465 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); | 464 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); |
466 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 465 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
467 | agendaLayout->addWidget(dummyAgendaRight,0,2); | 466 | agendaLayout->addWidget(dummyAgendaRight,0,2); |
468 | 467 | ||
469 | // Create time labels | 468 | // Create time labels |
470 | mTimeLabels = new TimeLabels(24,agendaFrame); | 469 | mTimeLabels = new TimeLabels(24,agendaFrame); |
471 | agendaLayout->addWidget(mTimeLabels,1,0); | 470 | agendaLayout->addWidget(mTimeLabels,1,0); |
472 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 471 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
473 | this,SLOT(updateConfig())); | 472 | this,SLOT(updateConfig())); |
474 | 473 | ||
475 | // Create agenda | 474 | // Create agenda |
476 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 475 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
477 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); | 476 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); |
478 | agendaLayout->setColStretch(1,1); | 477 | agendaLayout->setColStretch(1,1); |
479 | mAgenda->setFocusPolicy(NoFocus); | 478 | mAgenda->setFocusPolicy(NoFocus); |
480 | // Create event context menu for agenda | 479 | // Create event context menu for agenda |
481 | mAgendaPopup = eventPopup(); | 480 | mAgendaPopup = eventPopup(); |
482 | 481 | ||
483 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 482 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
484 | i18n("Toggle Alarm"),mAgenda, | 483 | i18n("Toggle Alarm"),mAgenda, |
485 | SLOT(popupAlarm()),true); | 484 | SLOT(popupAlarm()),true); |
486 | 485 | ||
487 | 486 | ||
488 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 487 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
489 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 488 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
490 | 489 | ||
491 | // make connections between dependent widgets | 490 | // make connections between dependent widgets |
492 | mTimeLabels->setAgenda(mAgenda); | 491 | mTimeLabels->setAgenda(mAgenda); |
493 | 492 | ||
494 | // Update widgets to reflect user preferences | 493 | // Update widgets to reflect user preferences |
495 | // updateConfig(); | 494 | // updateConfig(); |
496 | 495 | ||
497 | // createDayLabels(); | 496 | // createDayLabels(); |
498 | 497 | ||
499 | // these blank widgets make the All Day Event box line up with the agenda | 498 | // these blank widgets make the All Day Event box line up with the agenda |
500 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 499 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
501 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 500 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
502 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 501 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
503 | 502 | ||
504 | // Scrolling | 503 | // Scrolling |
505 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 504 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
506 | mTimeLabels, SLOT(positionChanged())); | 505 | mTimeLabels, SLOT(positionChanged())); |
507 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 506 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
508 | SLOT(setContentsPos(int))); | 507 | SLOT(setContentsPos(int))); |
509 | 508 | ||
510 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 509 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
511 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 510 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
512 | 511 | ||
513 | // Create/Show/Edit/Delete Event | 512 | // Create/Show/Edit/Delete Event |
514 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 513 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
515 | SLOT(newEvent(int,int))); | 514 | SLOT(newEvent(int,int))); |
516 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 515 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
517 | SLOT(newTodo(int,int))); | 516 | SLOT(newTodo(int,int))); |
518 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 517 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
519 | SLOT(newEvent(int,int,int,int))); | 518 | SLOT(newEvent(int,int,int,int))); |
520 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 519 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
521 | SLOT(newEventAllDay(int,int))); | 520 | SLOT(newEventAllDay(int,int))); |
522 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 521 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
523 | SLOT(newTodoAllDay(int,int))); | 522 | SLOT(newTodoAllDay(int,int))); |
524 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 523 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
525 | SLOT(newEventAllDay(int,int))); | 524 | SLOT(newEventAllDay(int,int))); |
526 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 525 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
527 | SLOT(newTimeSpanSelected(int,int,int,int))); | 526 | SLOT(newTimeSpanSelected(int,int,int,int))); |
528 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 527 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
529 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 528 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
530 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 529 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
531 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 530 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
532 | 531 | ||
533 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 532 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
534 | SIGNAL(editIncidenceSignal(Incidence *))); | 533 | SIGNAL(editIncidenceSignal(Incidence *))); |
535 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 534 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
536 | SIGNAL(editIncidenceSignal(Incidence *))); | 535 | SIGNAL(editIncidenceSignal(Incidence *))); |
537 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 536 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
538 | SIGNAL(showIncidenceSignal(Incidence *))); | 537 | SIGNAL(showIncidenceSignal(Incidence *))); |
539 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 538 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
540 | SIGNAL(showIncidenceSignal(Incidence *))); | 539 | SIGNAL(showIncidenceSignal(Incidence *))); |
541 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 540 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
542 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 541 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
543 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 542 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
544 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 543 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
545 | 544 | ||
546 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 545 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
547 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 546 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
548 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 547 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
549 | SLOT(updateEventDates(KOAgendaItem *, int))); | 548 | SLOT(updateEventDates(KOAgendaItem *, int))); |
550 | 549 | ||
551 | // event indicator update | 550 | // event indicator update |
552 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 551 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
553 | SLOT(updateEventIndicatorTop(int))); | 552 | SLOT(updateEventIndicatorTop(int))); |
554 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 553 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
555 | SLOT(updateEventIndicatorBottom(int))); | 554 | SLOT(updateEventIndicatorBottom(int))); |
556 | // drag signals | 555 | // drag signals |
557 | /* | 556 | /* |
558 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 557 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
559 | SLOT(startDrag(Event *))); | 558 | SLOT(startDrag(Event *))); |
560 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 559 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
561 | SLOT(startDrag(Event *))); | 560 | SLOT(startDrag(Event *))); |
562 | */ | 561 | */ |
563 | // synchronize selections | 562 | // synchronize selections |
564 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 563 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
565 | mAllDayAgenda, SLOT( deselectItem() ) ); | 564 | mAllDayAgenda, SLOT( deselectItem() ) ); |
566 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 565 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
567 | mAgenda, SLOT( deselectItem() ) ); | 566 | mAgenda, SLOT( deselectItem() ) ); |
568 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 567 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
569 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 568 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
570 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 569 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
571 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 570 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
572 | connect( mAgenda, SIGNAL( resizedSignal() ), | 571 | connect( mAgenda, SIGNAL( resizedSignal() ), |
573 | SLOT( updateConfig( ) ) ); | 572 | SLOT( updateConfig( ) ) ); |
574 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 573 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
575 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 574 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
576 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 575 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
577 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 576 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
578 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 577 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
579 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 578 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
580 | 579 | ||
581 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 580 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
582 | QFontMetrics fm ( dlf ); | 581 | QFontMetrics fm ( dlf ); |
583 | QString dayTest = "30"; | 582 | QString dayTest = "30"; |
584 | int wid = fm.width( dayTest ); | 583 | int wid = fm.width( dayTest ); |
585 | int maxWid = dummyAllDayRight->width(); | 584 | int maxWid = dummyAllDayRight->width(); |
586 | int fontPoint = dlf.pointSize(); | 585 | int fontPoint = dlf.pointSize(); |
587 | while ( wid > maxWid ) { | 586 | while ( wid > maxWid ) { |
588 | --fontPoint; | 587 | --fontPoint; |
589 | dlf.setPointSize( fontPoint ); | 588 | dlf.setPointSize( fontPoint ); |
590 | QFontMetrics f( dlf ); | 589 | QFontMetrics f( dlf ); |
591 | wid = f.width( dayTest ); | 590 | wid = f.width( dayTest ); |
592 | } | 591 | } |
593 | mDummyAllDayRightL->setFont( dlf ); | 592 | mDummyAllDayRightL->setFont( dlf ); |
594 | 593 | mDummyAllDayRightL->setAlignment( AlignHCenter ); | |
595 | } | 594 | } |
596 | 595 | ||
597 | void KOAgendaView::toggleAllDay() | 596 | void KOAgendaView::toggleAllDay() |
598 | { | 597 | { |
599 | if ( mSplitterAgenda->firstHandle() ) | 598 | if ( mSplitterAgenda->firstHandle() ) |
600 | mSplitterAgenda->firstHandle()->toggle(); | 599 | mSplitterAgenda->firstHandle()->toggle(); |
601 | } | 600 | } |
602 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 601 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
603 | { | 602 | { |
604 | calendar()->addIncidence( inc ); | 603 | calendar()->addIncidence( inc ); |
605 | 604 | ||
606 | if ( incOld ) { | 605 | if ( incOld ) { |
607 | if ( incOld->type() == "Todo" ) | 606 | if ( incOld->type() == "Todo" ) |
608 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 607 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
609 | else | 608 | else |
610 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 609 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
611 | } | 610 | } |
612 | 611 | ||
613 | } | 612 | } |
614 | 613 | ||
615 | KOAgendaView::~KOAgendaView() | 614 | KOAgendaView::~KOAgendaView() |
616 | { | 615 | { |
617 | delete mAgendaPopup; | 616 | delete mAgendaPopup; |
618 | delete mAllDayAgendaPopup; | 617 | delete mAllDayAgendaPopup; |
619 | delete KOAgendaItem::paintPix(); | 618 | delete KOAgendaItem::paintPix(); |
620 | delete KOAgendaItem::paintPixSel(); | 619 | delete KOAgendaItem::paintPixSel(); |
621 | } | 620 | } |
622 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 621 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
623 | { | 622 | { |
624 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 623 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
625 | bool uc = false; | 624 | bool uc = false; |
626 | int ow = e->oldSize().width(); | 625 | int ow = e->oldSize().width(); |
627 | int oh = e->oldSize().height(); | 626 | int oh = e->oldSize().height(); |
628 | int w = e->size().width(); | 627 | int w = e->size().width(); |
629 | int h = e->size().height(); | 628 | int h = e->size().height(); |
630 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 629 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
631 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 630 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
632 | uc = true; | 631 | uc = true; |
633 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 632 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
634 | } | 633 | } |
635 | mUpcomingWidth = e->size().width() ; | 634 | mUpcomingWidth = e->size().width() ; |
636 | if ( mBlockUpdating || uc ) { | 635 | if ( mBlockUpdating || uc ) { |
637 | mBlockUpdating = false; | 636 | mBlockUpdating = false; |
638 | //mAgenda->setMinimumSize(800 , 600 ); | 637 | //mAgenda->setMinimumSize(800 , 600 ); |
639 | //qDebug("mAgenda->resize+++++++++++++++ "); | 638 | //qDebug("mAgenda->resize+++++++++++++++ "); |
640 | updateConfig(); | 639 | updateConfig(); |
641 | //qDebug("KOAgendaView::Updating now possible "); | 640 | //qDebug("KOAgendaView::Updating now possible "); |
642 | } else | 641 | } else |
643 | createDayLabels(); | 642 | createDayLabels(); |
644 | //qDebug("resizeEvent end "); | 643 | //qDebug("resizeEvent end "); |
645 | 644 | ||
646 | } | 645 | } |
647 | void KOAgendaView::slotDaylabelClicked( int num ) | 646 | void KOAgendaView::slotDaylabelClicked( int num ) |
648 | { | 647 | { |
649 | 648 | ||
650 | QDate firstDate = mSelectedDates.first(); | 649 | QDate firstDate = mSelectedDates.first(); |
651 | if ( num == -1 ) | 650 | if ( num == -1 ) |
652 | emit showDateView( 6, firstDate ); | 651 | emit showDateView( 6, firstDate ); |
653 | else if (num >= 0 ) { | 652 | else if (num >= 0 ) { |
654 | if ( mSelectedDates.count() == 1) | 653 | if ( mSelectedDates.count() == 1) |
655 | emit showDateView( 9, firstDate.addDays( num ) ); | 654 | emit showDateView( 9, firstDate.addDays( num ) ); |
656 | else | 655 | else |
657 | emit showDateView( 3, firstDate.addDays( num ) ); | 656 | emit showDateView( 3, firstDate.addDays( num ) ); |
658 | } | 657 | } |
659 | else | 658 | else |
660 | showDateView( 10, firstDate.addDays(1) ); | 659 | showDateView( 10, firstDate.addDays(1) ); |
661 | } | 660 | } |
662 | 661 | ||
663 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 662 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
664 | { | 663 | { |
665 | 664 | ||
666 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 665 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
667 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 666 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
668 | mDayLabelsList.append( dayLabel ); | 667 | mDayLabelsList.append( dayLabel ); |
669 | mLayoutDayLabels->addWidget(dayLabel); | 668 | mLayoutDayLabels->addWidget(dayLabel); |
670 | return dayLabel ; | 669 | return dayLabel ; |
671 | } | 670 | } |
672 | 671 | ||
673 | void KOAgendaView::createDayLabels() | 672 | void KOAgendaView::createDayLabels() |
674 | { | 673 | { |
675 | 674 | ||
676 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 675 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
677 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 676 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
678 | return; | 677 | return; |
679 | 678 | ||
680 | } | 679 | } |
681 | int newHight; | 680 | int newHight; |
682 | 681 | ||
683 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 682 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
684 | // It would remove some flickering and gain speed (since this is called by | 683 | // It would remove some flickering and gain speed (since this is called by |
685 | // each updateView() call) | 684 | // each updateView() call) |
686 | 685 | ||
687 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 686 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
688 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 687 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
689 | if ( maxWid < 0 ) | 688 | if ( maxWid < 0 ) |
690 | maxWid = 20; | 689 | maxWid = 20; |
691 | 690 | ||
692 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 691 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
693 | QFontMetrics fm ( dlf ); | 692 | QFontMetrics fm ( dlf ); |
694 | int selCount = mSelectedDates.count(); | 693 | int selCount = mSelectedDates.count(); |
695 | QString dayTest = "Mon 20"; | 694 | QString dayTest = "Mon 20"; |
696 | //QString dayTest = "Mon 20"; | 695 | //QString dayTest = "Mon 20"; |
697 | int wid = fm.width( dayTest ); | 696 | int wid = fm.width( dayTest ); |
698 | //maxWid -= ( selCount * 3 ); //working for QLabels | 697 | //maxWid -= ( selCount * 3 ); //working for QLabels |
699 | maxWid -= ( selCount * 3 ); //working for QPushButton | 698 | maxWid -= ( selCount * 3 ); //working for QPushButton |
700 | if ( maxWid < 0 ) | 699 | if ( maxWid < 0 ) |
701 | maxWid = 20; | 700 | maxWid = 20; |
702 | int needWid = wid * selCount; | 701 | int needWid = wid * selCount; |
703 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 702 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
704 | //if ( needWid > maxWid ) | 703 | //if ( needWid > maxWid ) |
705 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 704 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
706 | while ( needWid > maxWid ) { | 705 | while ( needWid > maxWid ) { |
707 | dayTest = dayTest.left( dayTest.length() - 1 ); | 706 | dayTest = dayTest.left( dayTest.length() - 1 ); |
708 | wid = fm.width( dayTest ); | 707 | wid = fm.width( dayTest ); |
709 | needWid = wid * selCount; | 708 | needWid = wid * selCount; |
710 | } | 709 | } |
711 | int maxLen = dayTest.length(); | 710 | int maxLen = dayTest.length(); |
712 | int fontPoint = dlf.pointSize(); | 711 | int fontPoint = dlf.pointSize(); |
713 | if ( maxLen < 2 ) { | 712 | if ( maxLen < 2 ) { |
714 | int fontPoint = dlf.pointSize(); | 713 | int fontPoint = dlf.pointSize(); |
715 | while ( fontPoint > 4 ) { | 714 | while ( fontPoint > 4 ) { |
716 | --fontPoint; | 715 | --fontPoint; |
717 | dlf.setPointSize( fontPoint ); | 716 | dlf.setPointSize( fontPoint ); |
718 | QFontMetrics f( dlf ); | 717 | QFontMetrics f( dlf ); |
719 | wid = f.width( "30" ); | 718 | wid = f.width( "30" ); |
720 | needWid = wid * selCount; | 719 | needWid = wid * selCount; |
721 | if ( needWid < maxWid ) | 720 | if ( needWid < maxWid ) |
722 | break; | 721 | break; |
723 | } | 722 | } |
724 | maxLen = 2; | 723 | maxLen = 2; |
725 | } | 724 | } |
726 | //qDebug("Max len %d ", dayTest.length() ); | 725 | //qDebug("Max len %d ", dayTest.length() ); |
727 | 726 | ||
728 | QFontMetrics tempF( dlf ); | 727 | QFontMetrics tempF( dlf ); |
729 | newHight = tempF.height(); | 728 | newHight = tempF.height(); |
730 | mDayLabels->setFont( dlf ); | 729 | mDayLabels->setFont( dlf ); |
731 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 730 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
732 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 731 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
733 | //mLayoutDayLabels->addSpacing( 2 ); | 732 | //mLayoutDayLabels->addSpacing( 2 ); |
734 | // QFont lFont = dlf; | 733 | // QFont lFont = dlf; |
735 | bool appendLabels = false; | 734 | bool appendLabels = false; |
736 | KOAgendaButton *dayLabel; | 735 | KOAgendaButton *dayLabel; |
737 | dayLabel = mDayLabelsList.first(); | 736 | dayLabel = mDayLabelsList.first(); |
738 | if ( !dayLabel ) { | 737 | if ( !dayLabel ) { |
739 | appendLabels = true; | 738 | appendLabels = true; |
740 | dayLabel = getNewDaylabel(); | 739 | dayLabel = getNewDaylabel(); |
741 | } | 740 | } |
742 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 741 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
743 | dayLabel->setFont( dlf ); | 742 | dayLabel->setFont( dlf ); |
744 | dayLabel->setNum( -1 ); | 743 | dayLabel->setNum( -1 ); |
745 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 744 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
746 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 745 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
747 | dayLabel->show(); | 746 | dayLabel->show(); |
748 | DateList::ConstIterator dit; | 747 | DateList::ConstIterator dit; |
749 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 748 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
750 | int counter = -1; | 749 | int counter = -1; |
751 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 750 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
752 | ++counter; | 751 | ++counter; |
753 | QDate date = *dit; | 752 | QDate date = *dit; |
754 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 753 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
755 | if ( ! appendLabels ) { | 754 | if ( ! appendLabels ) { |
756 | dayLabel = mDayLabelsList.next(); | 755 | dayLabel = mDayLabelsList.next(); |
757 | if ( !dayLabel ) | 756 | if ( !dayLabel ) |
758 | appendLabels = true; | 757 | appendLabels = true; |
759 | } | 758 | } |
760 | if ( appendLabels ) { | 759 | if ( appendLabels ) { |
761 | dayLabel = getNewDaylabel(); | 760 | dayLabel = getNewDaylabel(); |
762 | } | 761 | } |
763 | dayLabel->setMinimumWidth( 1 ); | 762 | dayLabel->setMinimumWidth( 1 ); |
764 | dayLabel->setMaximumWidth( 1024 ); | 763 | dayLabel->setMaximumWidth( 1024 ); |
765 | dayLabel->setFont( dlf ); | 764 | dayLabel->setFont( dlf ); |
766 | dayLabel->show(); | 765 | dayLabel->show(); |
767 | dayLabel->setNum( counter ); | 766 | dayLabel->setNum( counter ); |
768 | QString str; | 767 | QString str; |
769 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 768 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
770 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 769 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
771 | switch ( maxLen ) { | 770 | switch ( maxLen ) { |
772 | case 2: | 771 | case 2: |
773 | str = QString::number( date.day() ); | 772 | str = QString::number( date.day() ); |
774 | break; | 773 | break; |
775 | 774 | ||
776 | case 3: | 775 | case 3: |
777 | str = dayName.left( 1 ) +QString::number( date.day()); | 776 | str = dayName.left( 1 ) +QString::number( date.day()); |
778 | 777 | ||
779 | break; | 778 | break; |
780 | case 4: | 779 | case 4: |
781 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 780 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
782 | 781 | ||
783 | break; | 782 | break; |
784 | case 5: | 783 | case 5: |
785 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 784 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
786 | 785 | ||
787 | break; | 786 | break; |
788 | case 6: | 787 | case 6: |
789 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 788 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
790 | break; | 789 | break; |
791 | 790 | ||
792 | default: | 791 | default: |
793 | break; | 792 | break; |
794 | } | 793 | } |
795 | if ( oneday ) { | 794 | if ( oneday ) { |
796 | QString addString; | 795 | QString addString; |
797 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 796 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
798 | addString = i18n("Today"); | 797 | addString = i18n("Today"); |
799 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 798 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
800 | addString = i18n("Tomorrow"); | 799 | addString = i18n("Tomorrow"); |
801 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 800 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
802 | addString = i18n("Yesterday"); | 801 | addString = i18n("Yesterday"); |
803 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 802 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
804 | addString = i18n("Day before yesterday"); | 803 | addString = i18n("Day before yesterday"); |
805 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 804 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
806 | addString = i18n("Day after tomorrow"); | 805 | addString = i18n("Day after tomorrow"); |
807 | if ( !addString.isEmpty() ) { | 806 | if ( !addString.isEmpty() ) { |
808 | str = addString+", " + str; | 807 | str = addString+", " + str; |
809 | } | 808 | } |
810 | } | 809 | } |
811 | dayLabel->setText(str); | 810 | dayLabel->setText(str); |
812 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 811 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
813 | if (date == QDate::currentDate()) { | 812 | if (date == QDate::currentDate()) { |
814 | QFont bFont = dlf; | 813 | QFont bFont = dlf; |
815 | bFont.setBold( true ); | 814 | bFont.setBold( true ); |
816 | dayLabel->setFont(bFont); | 815 | dayLabel->setFont(bFont); |
817 | } | 816 | } |
818 | //dayLayout->addWidget(dayLabel); | 817 | //dayLayout->addWidget(dayLabel); |
819 | 818 | ||
820 | #ifndef KORG_NOPLUGINS | 819 | #ifndef KORG_NOPLUGINS |
821 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 820 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
822 | CalendarDecoration *it; | 821 | CalendarDecoration *it; |
823 | for(it = cds.first(); it; it = cds.next()) { | 822 | for(it = cds.first(); it; it = cds.next()) { |
824 | QString text = it->shortText( date ); | 823 | QString text = it->shortText( date ); |
825 | if ( !text.isEmpty() ) { | 824 | if ( !text.isEmpty() ) { |
826 | QLabel *label = new QLabel(text,mDayLabels); | 825 | QLabel *label = new QLabel(text,mDayLabels); |
827 | label->setAlignment(AlignCenter); | 826 | label->setAlignment(AlignCenter); |
828 | dayLayout->addWidget(label); | 827 | dayLayout->addWidget(label); |
829 | } | 828 | } |
830 | } | 829 | } |
831 | 830 | ||
832 | for(it = cds.first(); it; it = cds.next()) { | 831 | for(it = cds.first(); it; it = cds.next()) { |
833 | QWidget *wid = it->smallWidget(mDayLabels,date); | 832 | QWidget *wid = it->smallWidget(mDayLabels,date); |
834 | if ( wid ) { | 833 | if ( wid ) { |
835 | // wid->setHeight(20); | 834 | // wid->setHeight(20); |
836 | dayLayout->addWidget(wid); | 835 | dayLayout->addWidget(wid); |
837 | } | 836 | } |
838 | } | 837 | } |
839 | #endif | 838 | #endif |
840 | } | 839 | } |
841 | if ( ! appendLabels ) { | 840 | if ( ! appendLabels ) { |
842 | dayLabel = mDayLabelsList.next(); | 841 | dayLabel = mDayLabelsList.next(); |
843 | if ( !dayLabel ) | 842 | if ( !dayLabel ) |
844 | appendLabels = true; | 843 | appendLabels = true; |
845 | } | 844 | } |
846 | if ( appendLabels ) { | 845 | if ( appendLabels ) { |
847 | dayLabel = getNewDaylabel(); | 846 | dayLabel = getNewDaylabel(); |
848 | } | 847 | } |
849 | //dayLabel->hide();//test only | 848 | //dayLabel->hide();//test only |
850 | 849 | ||
851 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 850 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
852 | if ( offset < 0 ) offset = 0; | 851 | if ( offset < 0 ) offset = 0; |
853 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 852 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
854 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 853 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
855 | dayLabel->setFont( dlf ); | 854 | dayLabel->setFont( dlf ); |
856 | dayLabel->show(); | 855 | dayLabel->show(); |
857 | dayLabel->setNum( -2 ); | 856 | dayLabel->setNum( -2 ); |
858 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 857 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
859 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 858 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
860 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 859 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
861 | if ( !appendLabels ) { | 860 | if ( !appendLabels ) { |
862 | dayLabel = mDayLabelsList.next(); | 861 | dayLabel = mDayLabelsList.next(); |
863 | while ( dayLabel ) { | 862 | while ( dayLabel ) { |
864 | //qDebug("!dayLabel %d",dayLabel ); | 863 | //qDebug("!dayLabel %d",dayLabel ); |
865 | dayLabel->hide(); | 864 | dayLabel->hide(); |
866 | dayLabel = mDayLabelsList.next(); | 865 | dayLabel = mDayLabelsList.next(); |
867 | } | 866 | } |
868 | } | 867 | } |
869 | //mDayLabelsFrame->show(); | 868 | //mDayLabelsFrame->show(); |
870 | //mDayLabels->show(); | 869 | //mDayLabels->show(); |
871 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 870 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
872 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 871 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
873 | mDayLabelsFrame->setFixedHeight( newHight ); | 872 | mDayLabelsFrame->setFixedHeight( newHight ); |
874 | } | 873 | } |
875 | 874 | ||
876 | int KOAgendaView::maxDatesHint() | 875 | int KOAgendaView::maxDatesHint() |
877 | { | 876 | { |
878 | // Not sure about the max number of events, so return 0 for now. | 877 | // Not sure about the max number of events, so return 0 for now. |
879 | return 0; | 878 | return 0; |
880 | } | 879 | } |
881 | 880 | ||
882 | int KOAgendaView::currentDateCount() | 881 | int KOAgendaView::currentDateCount() |
883 | { | 882 | { |
884 | return mSelectedDates.count(); | 883 | return mSelectedDates.count(); |
885 | } | 884 | } |
886 | 885 | ||
887 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 886 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
888 | { | 887 | { |
889 | QPtrList<Incidence> selected; | 888 | QPtrList<Incidence> selected; |
890 | Incidence *incidence; | 889 | Incidence *incidence; |
891 | 890 | ||
892 | incidence = mAgenda->selectedIncidence(); | 891 | incidence = mAgenda->selectedIncidence(); |
893 | if (incidence) selected.append(incidence); | 892 | if (incidence) selected.append(incidence); |
894 | 893 | ||
895 | incidence = mAllDayAgenda->selectedIncidence(); | 894 | incidence = mAllDayAgenda->selectedIncidence(); |
896 | if (incidence) selected.append(incidence); | 895 | if (incidence) selected.append(incidence); |
897 | 896 | ||
898 | return selected; | 897 | return selected; |
899 | } | 898 | } |
900 | 899 | ||
901 | DateList KOAgendaView::selectedDates() | 900 | DateList KOAgendaView::selectedDates() |
902 | { | 901 | { |
903 | DateList selected; | 902 | DateList selected; |
904 | QDate qd; | 903 | QDate qd; |
905 | 904 | ||
906 | qd = mAgenda->selectedIncidenceDate(); | 905 | qd = mAgenda->selectedIncidenceDate(); |
907 | if (qd.isValid()) selected.append(qd); | 906 | if (qd.isValid()) selected.append(qd); |
908 | 907 | ||
909 | qd = mAllDayAgenda->selectedIncidenceDate(); | 908 | qd = mAllDayAgenda->selectedIncidenceDate(); |
910 | if (qd.isValid()) selected.append(qd); | 909 | if (qd.isValid()) selected.append(qd); |
911 | 910 | ||
912 | return selected; | 911 | return selected; |
913 | } | 912 | } |
914 | 913 | ||
915 | 914 | ||
916 | void KOAgendaView::updateView() | 915 | void KOAgendaView::updateView() |
917 | { | 916 | { |
918 | if ( mBlockUpdating ) | 917 | if ( mBlockUpdating ) |
919 | return; | 918 | return; |
920 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 919 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
921 | fillAgenda(); | 920 | fillAgenda(); |
922 | 921 | ||
923 | } | 922 | } |
924 | 923 | ||
925 | 924 | ||
926 | /* | 925 | /* |
927 | Update configuration settings for the agenda view. This method is not | 926 | Update configuration settings for the agenda view. This method is not |
928 | complete. | 927 | complete. |
929 | */ | 928 | */ |
930 | void KOAgendaView::updateConfig() | 929 | void KOAgendaView::updateConfig() |
931 | { | 930 | { |
932 | if ( mBlockUpdating ) | 931 | if ( mBlockUpdating ) |
933 | return; | 932 | return; |
934 | 933 | ||
935 | 934 | ||
936 | 935 | ||
937 | // update config for children | 936 | // update config for children |
938 | mTimeLabels->updateConfig(); | 937 | mTimeLabels->updateConfig(); |
939 | mAgenda->storePosition(); | 938 | mAgenda->storePosition(); |
940 | mAgenda->updateConfig(); | 939 | mAgenda->updateConfig(); |
941 | mAllDayAgenda->updateConfig(); | 940 | mAllDayAgenda->updateConfig(); |
942 | // widget synchronization | 941 | // widget synchronization |
943 | //TODO: find a better way, maybe signal/slot | 942 | //TODO: find a better way, maybe signal/slot |
944 | mTimeLabels->positionChanged(); | 943 | mTimeLabels->positionChanged(); |
945 | 944 | ||
946 | // for some reason, this needs to be called explicitly | 945 | // for some reason, this needs to be called explicitly |
947 | mTimeLabels->repaint(); | 946 | mTimeLabels->repaint(); |
948 | 947 | ||
949 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 948 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
950 | 949 | ||
951 | // ToolTips displaying summary of events | 950 | // ToolTips displaying summary of events |
952 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 951 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
953 | ->mEnableToolTips); | 952 | ->mEnableToolTips); |
954 | 953 | ||
955 | //setHolidayMasks(); | 954 | //setHolidayMasks(); |
956 | 955 | ||
957 | //createDayLabels(); called by via updateView(); | 956 | //createDayLabels(); called by via updateView(); |
958 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 957 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
959 | updateView(); | 958 | updateView(); |
960 | mAgenda->restorePosition(); | 959 | mAgenda->restorePosition(); |
961 | } | 960 | } |
962 | 961 | ||
963 | 962 | ||
964 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 963 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
965 | { | 964 | { |
966 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 965 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
967 | //qDebug("KOAgendaView::updateEventDates "); | 966 | //qDebug("KOAgendaView::updateEventDates "); |
968 | QDateTime startDt,endDt; | 967 | QDateTime startDt,endDt; |
969 | QDate startDate; | 968 | QDate startDate; |
970 | int lenInSecs; | 969 | int lenInSecs; |
971 | // if ( type == KOAgenda::RESIZETOP ) | 970 | // if ( type == KOAgenda::RESIZETOP ) |
972 | // qDebug("RESIZETOP "); | 971 | // qDebug("RESIZETOP "); |
973 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 972 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
974 | // qDebug("RESIZEBOTTOM "); | 973 | // qDebug("RESIZEBOTTOM "); |
975 | // if ( type == KOAgenda::MOVE ) | 974 | // if ( type == KOAgenda::MOVE ) |
976 | // qDebug("MOVE "); | 975 | // qDebug("MOVE "); |
977 | if ( item->incidence()->type() == "Event" ) { | 976 | if ( item->incidence()->type() == "Event" ) { |
978 | startDt =item->incidence()->dtStart(); | 977 | startDt =item->incidence()->dtStart(); |