-rw-r--r-- | korganizer/koagendaview.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 218396d..072d464 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -25,255 +25,256 @@ | |||
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #ifndef KORG_NOSPLITTER | 29 | #ifndef KORG_NOSPLITTER |
30 | #include <qsplitter.h> | 30 | #include <qsplitter.h> |
31 | #endif | 31 | #endif |
32 | #include <qfont.h> | 32 | #include <qfont.h> |
33 | #include <qfontmetrics.h> | 33 | #include <qfontmetrics.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <KDGanttMinimizeSplitter.h> | 41 | #include <KDGanttMinimizeSplitter.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
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 | myPix.resize( 1, 1 ); | 84 | myPix.resize( 1, 1 ); |
85 | mRows = rows; | 85 | mRows = rows; |
86 | 86 | ||
87 | mRedrawNeeded = true; | 87 | mRedrawNeeded = true; |
88 | setMinimumHeight( 20 ); | 88 | setMinimumHeight( 20 ); |
89 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 89 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
90 | 90 | ||
91 | enableClipper(true); | 91 | enableClipper(true); |
92 | 92 | ||
93 | setHScrollBarMode(AlwaysOff); | 93 | setHScrollBarMode(AlwaysOff); |
94 | setVScrollBarMode(AlwaysOff); | 94 | setVScrollBarMode(AlwaysOff); |
95 | 95 | ||
96 | resizeContents(50,mRows * mCellHeight); | 96 | resizeContents(50,mRows * mCellHeight); |
97 | 97 | ||
98 | viewport()->setBackgroundMode( PaletteBackground ); | 98 | viewport()->setBackgroundMode( PaletteBackground ); |
99 | } | 99 | } |
100 | 100 | ||
101 | void TimeLabels::setCellHeight(int height) | 101 | void TimeLabels::setCellHeight(int height) |
102 | { | 102 | { |
103 | mCellHeight = height; | 103 | mCellHeight = height; |
104 | } | 104 | } |
105 | 105 | ||
106 | /* | 106 | /* |
107 | Optimization so that only the "dirty" portion of the scroll view | 107 | Optimization so that only the "dirty" portion of the scroll view |
108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
109 | */ | 109 | */ |
110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
111 | { | 111 | { |
112 | 112 | ||
113 | // if ( globalFlagBlockAgenda ) | 113 | // if ( globalFlagBlockAgenda ) |
114 | // return; | 114 | // return; |
115 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 115 | // bug: the parameters cx, cy, cw, ch are the areas that need to be |
116 | // redrawn, not the area of the widget. unfortunately, this | 116 | // redrawn, not the area of the widget. unfortunately, this |
117 | // code assumes the latter... | 117 | // code assumes the latter... |
118 | 118 | ||
119 | // now, for a workaround... | 119 | // now, for a workaround... |
120 | // these two assignments fix the weird redraw bug | 120 | // these two assignments fix the weird redraw bug |
121 | mRedrawNeeded = true; | ||
121 | if ( mRedrawNeeded ) { | 122 | if ( mRedrawNeeded ) { |
122 | cx = contentsX() + 2; | 123 | cx = contentsX() + frameWidth()*2; |
123 | cw = contentsWidth() - 2; | 124 | cw = contentsWidth() ; |
124 | // end of workaround | 125 | // end of workaround |
125 | 126 | ||
126 | int cell = ((int)(cy/mCellHeight)); | 127 | int cell = ((int)(cy/mCellHeight)); |
127 | int y = cell * mCellHeight; | 128 | int y = cell * mCellHeight; |
128 | QFontMetrics fm = fontMetrics(); | 129 | QFontMetrics fm = fontMetrics(); |
129 | QString hour; | 130 | QString hour; |
130 | QString suffix; | 131 | QString suffix; |
131 | int tW = fm.width("24:00i"); | 132 | int tW = fm.width("24:00i"); |
132 | int timeHeight = fm.height(); | 133 | int timeHeight = fm.height(); |
133 | //timeHeight -= (timeHeight/4-2); | 134 | //timeHeight -= (timeHeight/4-2); |
134 | int borderWidth = 0; | 135 | int borderWidth = 0; |
135 | QFont nFont = p->font(); | 136 | QFont nFont = p->font(); |
136 | 137 | ||
137 | if (!KGlobal::locale()->use12Clock()) | 138 | if (!KGlobal::locale()->use12Clock()) |
138 | suffix = "00"; | 139 | suffix = "00"; |
139 | else | 140 | else |
140 | borderWidth = 0; | 141 | borderWidth = 0; |
141 | if ( timeHeight > mCellHeight ) { | 142 | if ( timeHeight > mCellHeight ) { |
142 | timeHeight = mCellHeight-1; | 143 | timeHeight = mCellHeight-1; |
143 | int pointS = nFont.pointSize(); | 144 | int pointS = nFont.pointSize(); |
144 | while ( pointS > 4 ) { | 145 | while ( pointS > 4 ) { |
145 | nFont.setPointSize( pointS ); | 146 | nFont.setPointSize( pointS ); |
146 | fm = QFontMetrics( nFont ); | 147 | fm = QFontMetrics( nFont ); |
147 | if ( fm.height() < mCellHeight ) | 148 | if ( fm.height() < mCellHeight ) |
148 | break; | 149 | break; |
149 | -- pointS; | 150 | -- pointS; |
150 | } | 151 | } |
151 | fm = QFontMetrics( nFont ); | 152 | fm = QFontMetrics( nFont ); |
152 | borderWidth = 4; | 153 | borderWidth = 4; |
153 | timeHeight = fm.height(); | 154 | timeHeight = fm.height(); |
154 | } | 155 | } |
155 | timeHeight -= (timeHeight/4-2); | 156 | //timeHeight -= (timeHeight/4-2); |
156 | QFont sFont = nFont; | 157 | QFont sFont = nFont; |
157 | sFont.setPointSize( sFont.pointSize()/2+2 ); | 158 | sFont.setPointSize( sFont.pointSize()/2+2 ); |
158 | QFontMetrics fmS( sFont ); | 159 | QFontMetrics fmS( sFont ); |
159 | int sHei = fmS.height(); | 160 | int sHei = fmS.height(); |
160 | sHei -= (sHei/4-2); | 161 | //sHei -= (sHei/4-2); |
161 | int startW = this->width() - frameWidth(); | 162 | int startW = this->width() - frameWidth()-1; |
162 | while (y < cy + ch) { | 163 | while (y < cy + ch) { |
163 | p->drawLine(cx,y,cx+tW,y); | 164 | p->drawLine(cx,y,cx+tW,y); |
164 | hour.setNum(cell); | 165 | hour.setNum(cell); |
165 | 166 | ||
166 | // handle 24h and am/pm time formats | 167 | // handle 24h and am/pm time formats |
167 | if (KGlobal::locale()->use12Clock()) { | 168 | if (KGlobal::locale()->use12Clock()) { |
168 | if (cell > 11) suffix = "pm"; | 169 | if (cell > 11) suffix = "pm"; |
169 | else | 170 | else |
170 | suffix = "am"; | 171 | suffix = "am"; |
171 | if (cell == 0) hour.setNum(12); | 172 | if (cell == 0) hour.setNum(12); |
172 | if (cell > 12) hour.setNum(cell - 12); | 173 | if (cell > 12) hour.setNum(cell - 12); |
173 | } | 174 | } |
174 | 175 | ||
175 | // center and draw the time label | 176 | // center and draw the time label |
176 | int timeWidth = fm.width(hour+"i"); | 177 | int timeWidth = fm.width(hour); |
177 | int tw2 = fm.width(suffix); | 178 | int tw2 = fm.width(suffix); |
178 | int offset = startW - timeWidth - tw2 ; | 179 | int offset = startW - timeWidth - tw2 ; |
179 | p->setFont( nFont ); | 180 | p->setFont( nFont ); |
180 | p->drawText(cx - borderWidth + offset, y+ timeHeight, hour); | 181 | p->drawText( offset, y+ timeHeight, hour); |
181 | p->setFont( sFont ); | 182 | p->setFont( sFont ); |
182 | offset = startW - tw2-1; | 183 | offset = startW - tw2+1; |
183 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); | 184 | p->drawText( offset, y+ sHei, suffix); |
184 | 185 | ||
185 | // increment indices | 186 | // increment indices |
186 | y += mCellHeight; | 187 | y += mCellHeight; |
187 | cell++; | 188 | cell++; |
188 | } | 189 | } |
189 | } else { | 190 | } else { |
190 | //qDebug("NO redraw "); | 191 | //qDebug("NO redraw "); |
191 | } | 192 | } |
192 | // double buffer not yet implemented | 193 | // double buffer not yet implemented |
193 | //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 194 | //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
194 | //mRedrawNeeded = false; | 195 | //mRedrawNeeded = false; |
195 | } | 196 | } |
196 | 197 | ||
197 | /** | 198 | /** |
198 | Calculates the minimum width. | 199 | Calculates the minimum width. |
199 | */ | 200 | */ |
200 | int TimeLabels::minimumWidth() const | 201 | int TimeLabels::minimumWidth() const |
201 | { | 202 | { |
202 | return mMiniWidth; | 203 | return mMiniWidth; |
203 | } | 204 | } |
204 | 205 | ||
205 | /** updates widget's internal state */ | 206 | /** updates widget's internal state */ |
206 | void TimeLabels::updateConfig() | 207 | void TimeLabels::updateConfig() |
207 | { | 208 | { |
208 | mRedrawNeeded = true; | 209 | mRedrawNeeded = true; |
209 | // set the font | 210 | // set the font |
210 | // config->setGroup("Fonts"); | 211 | // config->setGroup("Fonts"); |
211 | // QFont font = config->readFontEntry("TimeBar Font"); | 212 | // QFont font = config->readFontEntry("TimeBar Font"); |
212 | setFont(KOPrefs::instance()->mTimeBarFont); | 213 | setFont(KOPrefs::instance()->mTimeBarFont); |
213 | QString test = "88:88"; | 214 | QString test = "88:88"; |
214 | if (KGlobal::locale()->use12Clock()) | 215 | if (KGlobal::locale()->use12Clock()) |
215 | test += "i"; | 216 | test += "i"; |
216 | mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; | 217 | mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; |
217 | // update geometry restrictions based on new settings | 218 | // update geometry restrictions based on new settings |
218 | setFixedWidth(minimumWidth()); | 219 | setFixedWidth(minimumWidth()); |
219 | 220 | ||
220 | // update HourSize | 221 | // update HourSize |
221 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 222 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
222 | resizeContents(50,mRows * mCellHeight); | 223 | resizeContents(50,mRows * mCellHeight); |
223 | } | 224 | } |
224 | 225 | ||
225 | /** update time label positions */ | 226 | /** update time label positions */ |
226 | void TimeLabels::positionChanged() | 227 | void TimeLabels::positionChanged() |
227 | { | 228 | { |
228 | int adjustment = mAgenda->contentsY(); | 229 | int adjustment = mAgenda->contentsY(); |
229 | setContentsPos(0, adjustment); | 230 | setContentsPos(0, adjustment); |
230 | } | 231 | } |
231 | 232 | ||
232 | /** */ | 233 | /** */ |
233 | void TimeLabels::setAgenda(KOAgenda* agenda) | 234 | void TimeLabels::setAgenda(KOAgenda* agenda) |
234 | { | 235 | { |
235 | mAgenda = agenda; | 236 | mAgenda = agenda; |
236 | } | 237 | } |
237 | 238 | ||
238 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 239 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
239 | { | 240 | { |
240 | mMouseDownY = e->pos().y(); | 241 | mMouseDownY = e->pos().y(); |
241 | mOrgCap = topLevelWidget()->caption(); | 242 | mOrgCap = topLevelWidget()->caption(); |
242 | } | 243 | } |
243 | 244 | ||
244 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 245 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
245 | { | 246 | { |
246 | int diff = mMouseDownY - e->pos().y(); | 247 | int diff = mMouseDownY - e->pos().y(); |
247 | if ( diff < 10 && diff > -10 ) | 248 | if ( diff < 10 && diff > -10 ) |
248 | return; | 249 | return; |
249 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 250 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
250 | if ( tSize < 4 ) | 251 | if ( tSize < 4 ) |
251 | tSize = 4; | 252 | tSize = 4; |
252 | if ( tSize > 22 ) | 253 | if ( tSize > 22 ) |
253 | tSize = 22; | 254 | tSize = 22; |
254 | tSize = (tSize-2)/2; | 255 | tSize = (tSize-2)/2; |
255 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 256 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
256 | 257 | ||
257 | } | 258 | } |
258 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 259 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
259 | { | 260 | { |
260 | topLevelWidget()->setCaption( mOrgCap ); | 261 | topLevelWidget()->setCaption( mOrgCap ); |
261 | int diff = mMouseDownY - e->pos().y(); | 262 | int diff = mMouseDownY - e->pos().y(); |
262 | if ( diff < 10 && diff > -10 ) | 263 | if ( diff < 10 && diff > -10 ) |
263 | return; | 264 | return; |
264 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 265 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
265 | if ( tSize < 4 ) | 266 | if ( tSize < 4 ) |
266 | tSize = 4; | 267 | tSize = 4; |
267 | if ( tSize > 22 ) | 268 | if ( tSize > 22 ) |
268 | tSize = 22; | 269 | tSize = 22; |
269 | tSize = (tSize/2)*2; | 270 | tSize = (tSize/2)*2; |
270 | if ( tSize == KOPrefs::instance()->mHourSize ) | 271 | if ( tSize == KOPrefs::instance()->mHourSize ) |
271 | return; | 272 | return; |
272 | KOPrefs::instance()->mHourSize = tSize; | 273 | KOPrefs::instance()->mHourSize = tSize; |
273 | emit scaleChanged(); | 274 | emit scaleChanged(); |
274 | } | 275 | } |
275 | 276 | ||
276 | /** This is called in response to repaint() */ | 277 | /** This is called in response to repaint() */ |
277 | void TimeLabels::paintEvent(QPaintEvent*) | 278 | void TimeLabels::paintEvent(QPaintEvent*) |
278 | { | 279 | { |
279 | 280 | ||
@@ -325,194 +326,193 @@ void EventIndicator::drawContents(QPainter *p) | |||
325 | } | 326 | } |
326 | } | 327 | } |
327 | } else { | 328 | } else { |
328 | han->repaint(); | 329 | han->repaint(); |
329 | //mPaintWidget->setBackgroundColor( red ); | 330 | //mPaintWidget->setBackgroundColor( red ); |
330 | 331 | ||
331 | QPainter pa( han ); | 332 | QPainter pa( han ); |
332 | int i; | 333 | int i; |
333 | bool setColor = false; | 334 | bool setColor = false; |
334 | for(i=0;i<mColumns;++i) { | 335 | for(i=0;i<mColumns;++i) { |
335 | if (mEnabled[i]) { | 336 | if (mEnabled[i]) { |
336 | setColor = true; | 337 | setColor = true; |
337 | 338 | ||
338 | int cellWidth = contentsRect().right()/mColumns; | 339 | int cellWidth = contentsRect().right()/mColumns; |
339 | int xOffset = KOGlobals::self()->reverseLayout() ? | 340 | int xOffset = KOGlobals::self()->reverseLayout() ? |
340 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 341 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
341 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 342 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
342 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 343 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
343 | //qDebug("222draw pix %d ",xOffset ); | 344 | //qDebug("222draw pix %d ",xOffset ); |
344 | 345 | ||
345 | } | 346 | } |
346 | 347 | ||
347 | } | 348 | } |
348 | pa.end(); | 349 | pa.end(); |
349 | 350 | ||
350 | } | 351 | } |
351 | } | 352 | } |
352 | 353 | ||
353 | void EventIndicator::setXOffset( int x ) | 354 | void EventIndicator::setXOffset( int x ) |
354 | { | 355 | { |
355 | mXOffset = x; | 356 | mXOffset = x; |
356 | } | 357 | } |
357 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 358 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
358 | { | 359 | { |
359 | mPaintWidget = w; | 360 | mPaintWidget = w; |
360 | setMaximumHeight(0); | 361 | setMaximumHeight(0); |
361 | setMinimumHeight(0); | 362 | setMinimumHeight(0); |
362 | } | 363 | } |
363 | void EventIndicator::changeColumns(int columns) | 364 | void EventIndicator::changeColumns(int columns) |
364 | { | 365 | { |
365 | mColumns = columns; | 366 | mColumns = columns; |
366 | mEnabled.resize(mColumns); | 367 | mEnabled.resize(mColumns); |
367 | 368 | ||
368 | update(); | 369 | update(); |
369 | } | 370 | } |
370 | 371 | ||
371 | void EventIndicator::enableColumn(int column, bool enable) | 372 | void EventIndicator::enableColumn(int column, bool enable) |
372 | { | 373 | { |
373 | mEnabled[column] = enable; | 374 | mEnabled[column] = enable; |
374 | } | 375 | } |
375 | 376 | ||
376 | 377 | ||
377 | //////////////////////////////////////////////////////////////////////////// | 378 | //////////////////////////////////////////////////////////////////////////// |
378 | //////////////////////////////////////////////////////////////////////////// | 379 | //////////////////////////////////////////////////////////////////////////// |
379 | //////////////////////////////////////////////////////////////////////////// | 380 | //////////////////////////////////////////////////////////////////////////// |
380 | 381 | ||
381 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 382 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
382 | KOEventView (cal,parent,name) | 383 | KOEventView (cal,parent,name) |
383 | { | 384 | { |
384 | mBlockUpdating = true; | 385 | mBlockUpdating = true; |
385 | mStartHour = 8; | 386 | mStartHour = 8; |
386 | mSelectedDates.append(QDate::currentDate()); | 387 | mSelectedDates.append(QDate::currentDate()); |
387 | 388 | ||
388 | mLayoutDayLabels = 0; | 389 | mLayoutDayLabels = 0; |
389 | mDayLabelsFrame = 0; | 390 | mDayLabelsFrame = 0; |
390 | mDayLabels = 0; | 391 | mDayLabels = 0; |
391 | bool isRTL = KOGlobals::self()->reverseLayout(); | 392 | bool isRTL = KOGlobals::self()->reverseLayout(); |
392 | QPixmap expandPix; | 393 | QPixmap expandPix; |
393 | if ( KOPrefs::instance()->mVerticalScreen ) { | 394 | if ( KOPrefs::instance()->mVerticalScreen ) { |
394 | expandPix = SmallIcon( "1updownarrow" ); | 395 | expandPix = SmallIcon( "1updownarrow" ); |
395 | } else { | 396 | } else { |
396 | expandPix = SmallIcon("1leftrightarrow" ); | 397 | expandPix = SmallIcon("1leftrightarrow" ); |
397 | } | 398 | } |
398 | 399 | ||
399 | QBoxLayout *topLayout = new QVBoxLayout(this); | 400 | QBoxLayout *topLayout = new QVBoxLayout(this); |
400 | 401 | ||
401 | // Create day name labels for agenda columns | 402 | // Create day name labels for agenda columns |
402 | // Create agenda splitter | 403 | // Create agenda splitter |
403 | 404 | ||
404 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 405 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
405 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 406 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
406 | topLayout->addWidget( mSplitterAgenda ); | 407 | topLayout->addWidget( mSplitterAgenda ); |
407 | mAllDayFrame = new QHBox(mSplitterAgenda); | 408 | mAllDayFrame = new QHBox(mSplitterAgenda); |
408 | mAllDayFrame->setFocusPolicy(NoFocus); | 409 | mAllDayFrame->setFocusPolicy(NoFocus); |
409 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 410 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
410 | agendaFrame->setFocusPolicy(NoFocus); | 411 | agendaFrame->setFocusPolicy(NoFocus); |
411 | 412 | ||
412 | // Create all-day agenda widget | 413 | // Create all-day agenda widget |
413 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 414 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
414 | 415 | ||
415 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 416 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
416 | mExpandButton->setPixmap( expandPix ); | 417 | mExpandButton->setPixmap( expandPix ); |
417 | int widebut = mExpandButton->sizeHint().width()+4; | 418 | int widebut = mExpandButton->sizeHint().width()+4; |
418 | int heibut = mExpandButton->sizeHint().height()+4; | 419 | int heibut = mExpandButton->sizeHint().height()+4; |
419 | if ( heibut > widebut ) | 420 | if ( heibut > widebut ) |
420 | widebut = heibut ; | 421 | widebut = heibut ; |
421 | if ( QApplication::desktop()->width() < 480 ) | 422 | |
422 | widebut = widebut*3/2; | ||
423 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 423 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
424 | // QSizePolicy::Fixed ) ); | 424 | // QSizePolicy::Fixed ) ); |
425 | mExpandButton->setFixedSize( widebut, widebut); | 425 | mExpandButton->setFixedSize( widebut, widebut); |
426 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 426 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
427 | mExpandButton->setFocusPolicy(NoFocus); | 427 | mExpandButton->setFocusPolicy(NoFocus); |
428 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 428 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
429 | mAllDayAgenda->setFocusPolicy(NoFocus); | 429 | mAllDayAgenda->setFocusPolicy(NoFocus); |
430 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 430 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
431 | 431 | ||
432 | // Create event context menu for all day agenda | 432 | // Create event context menu for all day agenda |
433 | mAllDayAgendaPopup = eventPopup(); | 433 | mAllDayAgendaPopup = eventPopup(); |
434 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 434 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
435 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 435 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
436 | 436 | ||
437 | // Create agenda frame | 437 | // Create agenda frame |
438 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); | 438 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); |
439 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 439 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
440 | 440 | ||
441 | // create event indicator bars | 441 | // create event indicator bars |
442 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 442 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
443 | #ifndef DESKTOP_VERSION | 443 | #ifndef DESKTOP_VERSION |
444 | // FIX | 444 | // FIX |
445 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 445 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
446 | #endif | 446 | #endif |
447 | mDayLabelsFrame = new QHBox(agendaFrame); | 447 | mDayLabelsFrame = new QHBox(agendaFrame); |
448 | //topLayout->addWidget(mDayLabelsFrame); | 448 | //topLayout->addWidget(mDayLabelsFrame); |
449 | mDayLabels = new QFrame (mDayLabelsFrame); | 449 | mDayLabels = new QFrame (mDayLabelsFrame); |
450 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 450 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
451 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); | 451 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); |
452 | agendaLayout->addWidget(mEventIndicatorTop,1,1); | 452 | agendaLayout->addWidget(mEventIndicatorTop,1,1); |
453 | 453 | ||
454 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 454 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
455 | agendaFrame); | 455 | agendaFrame); |
456 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); | 456 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); |
457 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 457 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
458 | agendaLayout->addWidget(dummyAgendaRight,1,2); | 458 | agendaLayout->addWidget(dummyAgendaRight,1,2); |
459 | 459 | ||
460 | // Create time labels | 460 | // Create time labels |
461 | mTimeLabels = new TimeLabels(24,agendaFrame); | 461 | mTimeLabels = new TimeLabels(24,agendaFrame); |
462 | agendaLayout->addWidget(mTimeLabels,2,0); | 462 | agendaLayout->addWidget(mTimeLabels,2,0); |
463 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 463 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
464 | this,SLOT(updateConfig())); | 464 | this,SLOT(updateConfig())); |
465 | 465 | ||
466 | // Create agenda | 466 | // Create agenda |
467 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 467 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
468 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); | 468 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); |
469 | agendaLayout->setColStretch(1,1); | 469 | agendaLayout->setColStretch(1,1); |
470 | mAgenda->setFocusPolicy(NoFocus); | 470 | mAgenda->setFocusPolicy(NoFocus); |
471 | // Create event context menu for agenda | 471 | // Create event context menu for agenda |
472 | mAgendaPopup = eventPopup(); | 472 | mAgendaPopup = eventPopup(); |
473 | 473 | ||
474 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 474 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
475 | i18n("Toggle Alarm"),mAgenda, | 475 | i18n("Toggle Alarm"),mAgenda, |
476 | SLOT(popupAlarm()),true); | 476 | SLOT(popupAlarm()),true); |
477 | 477 | ||
478 | 478 | ||
479 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 479 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
480 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 480 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
481 | 481 | ||
482 | // make connections between dependent widgets | 482 | // make connections between dependent widgets |
483 | mTimeLabels->setAgenda(mAgenda); | 483 | mTimeLabels->setAgenda(mAgenda); |
484 | 484 | ||
485 | // Update widgets to reflect user preferences | 485 | // Update widgets to reflect user preferences |
486 | // updateConfig(); | 486 | // updateConfig(); |
487 | 487 | ||
488 | // createDayLabels(); | 488 | // createDayLabels(); |
489 | 489 | ||
490 | // these blank widgets make the All Day Event box line up with the agenda | 490 | // these blank widgets make the All Day Event box line up with the agenda |
491 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 491 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
492 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 492 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
493 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 493 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
494 | 494 | ||
495 | // Scrolling | 495 | // Scrolling |
496 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 496 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
497 | mTimeLabels, SLOT(positionChanged())); | 497 | mTimeLabels, SLOT(positionChanged())); |
498 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 498 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
499 | SLOT(setContentsPos(int))); | 499 | SLOT(setContentsPos(int))); |
500 | 500 | ||
501 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); | 501 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); |
502 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); | 502 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); |
503 | 503 | ||
504 | // Create/Show/Edit/Delete Event | 504 | // Create/Show/Edit/Delete Event |
505 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 505 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
506 | SLOT(newEvent(int,int))); | 506 | SLOT(newEvent(int,int))); |
507 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 507 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
508 | SLOT(newTodo(int,int))); | 508 | SLOT(newTodo(int,int))); |
509 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 509 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
510 | SLOT(newEvent(int,int,int,int))); | 510 | SLOT(newEvent(int,int,int,int))); |
511 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 511 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
512 | SLOT(newEventAllDay(int,int))); | 512 | SLOT(newEventAllDay(int,int))); |
513 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 513 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
514 | SLOT(newTodoAllDay(int,int))); | 514 | SLOT(newTodoAllDay(int,int))); |
515 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 515 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
516 | SLOT(newEventAllDay(int,int))); | 516 | SLOT(newEventAllDay(int,int))); |
517 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 517 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
518 | SLOT(newTimeSpanSelected(int,int,int,int))); | 518 | SLOT(newTimeSpanSelected(int,int,int,int))); |
@@ -624,305 +624,305 @@ void KOAgendaView::resizeEvent( QResizeEvent* e ) | |||
624 | } | 624 | } |
625 | void KOAgendaView::slotDaylabelClicked( int num ) | 625 | void KOAgendaView::slotDaylabelClicked( int num ) |
626 | { | 626 | { |
627 | 627 | ||
628 | QDate firstDate = mSelectedDates.first(); | 628 | QDate firstDate = mSelectedDates.first(); |
629 | if ( num == -1 ) | 629 | if ( num == -1 ) |
630 | emit showDateView( 6, firstDate ); | 630 | emit showDateView( 6, firstDate ); |
631 | else if (num >= 0 ) { | 631 | else if (num >= 0 ) { |
632 | if ( mSelectedDates.count() == 1) | 632 | if ( mSelectedDates.count() == 1) |
633 | emit showDateView( 9, firstDate.addDays( num ) ); | 633 | emit showDateView( 9, firstDate.addDays( num ) ); |
634 | else | 634 | else |
635 | emit showDateView( 3, firstDate.addDays( num ) ); | 635 | emit showDateView( 3, firstDate.addDays( num ) ); |
636 | } | 636 | } |
637 | else | 637 | else |
638 | showDateView( 10, firstDate.addDays(1) ); | 638 | showDateView( 10, firstDate.addDays(1) ); |
639 | } | 639 | } |
640 | 640 | ||
641 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 641 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
642 | { | 642 | { |
643 | 643 | ||
644 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 644 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
645 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 645 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
646 | mDayLabelsList.append( dayLabel ); | 646 | mDayLabelsList.append( dayLabel ); |
647 | mLayoutDayLabels->addWidget(dayLabel); | 647 | mLayoutDayLabels->addWidget(dayLabel); |
648 | return dayLabel ; | 648 | return dayLabel ; |
649 | } | 649 | } |
650 | 650 | ||
651 | void KOAgendaView::createDayLabels() | 651 | void KOAgendaView::createDayLabels() |
652 | { | 652 | { |
653 | 653 | ||
654 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 654 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
655 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 655 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
656 | return; | 656 | return; |
657 | 657 | ||
658 | } | 658 | } |
659 | int newHight; | 659 | int newHight; |
660 | 660 | ||
661 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 661 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
662 | // It would remove some flickering and gain speed (since this is called by | 662 | // It would remove some flickering and gain speed (since this is called by |
663 | // each updateView() call) | 663 | // each updateView() call) |
664 | 664 | ||
665 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 665 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
666 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 666 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
667 | if ( maxWid < 0 ) | 667 | if ( maxWid < 0 ) |
668 | maxWid = 20; | 668 | maxWid = 20; |
669 | 669 | ||
670 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 670 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
671 | QFontMetrics fm ( dlf ); | 671 | QFontMetrics fm ( dlf ); |
672 | int selCount = mSelectedDates.count(); | 672 | int selCount = mSelectedDates.count(); |
673 | QString dayTest = "Mon 20"; | 673 | QString dayTest = "Mon 20"; |
674 | //QString dayTest = "Mon 20"; | 674 | //QString dayTest = "Mon 20"; |
675 | int wid = fm.width( dayTest ); | 675 | int wid = fm.width( dayTest ); |
676 | //maxWid -= ( selCount * 3 ); //working for QLabels | 676 | //maxWid -= ( selCount * 3 ); //working for QLabels |
677 | maxWid -= ( selCount * 3 ); //working for QPushButton | 677 | maxWid -= ( selCount * 3 ); //working for QPushButton |
678 | if ( maxWid < 0 ) | 678 | if ( maxWid < 0 ) |
679 | maxWid = 20; | 679 | maxWid = 20; |
680 | int needWid = wid * selCount; | 680 | int needWid = wid * selCount; |
681 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 681 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
682 | //if ( needWid > maxWid ) | 682 | //if ( needWid > maxWid ) |
683 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 683 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
684 | while ( needWid > maxWid ) { | 684 | while ( needWid > maxWid ) { |
685 | dayTest = dayTest.left( dayTest.length() - 1 ); | 685 | dayTest = dayTest.left( dayTest.length() - 1 ); |
686 | wid = fm.width( dayTest ); | 686 | wid = fm.width( dayTest ); |
687 | needWid = wid * selCount; | 687 | needWid = wid * selCount; |
688 | } | 688 | } |
689 | int maxLen = dayTest.length(); | 689 | int maxLen = dayTest.length(); |
690 | int fontPoint = dlf.pointSize(); | 690 | int fontPoint = dlf.pointSize(); |
691 | if ( maxLen < 2 ) { | 691 | if ( maxLen < 2 ) { |
692 | int fontPoint = dlf.pointSize(); | 692 | int fontPoint = dlf.pointSize(); |
693 | while ( fontPoint > 4 ) { | 693 | while ( fontPoint > 4 ) { |
694 | --fontPoint; | 694 | --fontPoint; |
695 | dlf.setPointSize( fontPoint ); | 695 | dlf.setPointSize( fontPoint ); |
696 | QFontMetrics f( dlf ); | 696 | QFontMetrics f( dlf ); |
697 | wid = f.width( "30" ); | 697 | wid = f.width( "30" ); |
698 | needWid = wid * selCount; | 698 | needWid = wid * selCount; |
699 | if ( needWid < maxWid ) | 699 | if ( needWid < maxWid ) |
700 | break; | 700 | break; |
701 | } | 701 | } |
702 | maxLen = 2; | 702 | maxLen = 2; |
703 | } | 703 | } |
704 | //qDebug("Max len %d ", dayTest.length() ); | 704 | //qDebug("Max len %d ", dayTest.length() ); |
705 | 705 | ||
706 | QFontMetrics tempF( dlf ); | 706 | QFontMetrics tempF( dlf ); |
707 | newHight = tempF.height(); | 707 | newHight = tempF.height(); |
708 | mDayLabels->setFont( dlf ); | 708 | mDayLabels->setFont( dlf ); |
709 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 709 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
710 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 710 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
711 | //mLayoutDayLabels->addSpacing( 2 ); | 711 | //mLayoutDayLabels->addSpacing( 2 ); |
712 | // QFont lFont = dlf; | 712 | // QFont lFont = dlf; |
713 | bool appendLabels = false; | 713 | bool appendLabels = false; |
714 | KOAgendaButton *dayLabel; | 714 | KOAgendaButton *dayLabel; |
715 | dayLabel = mDayLabelsList.first(); | 715 | dayLabel = mDayLabelsList.first(); |
716 | if ( !dayLabel ) { | 716 | if ( !dayLabel ) { |
717 | appendLabels = true; | 717 | appendLabels = true; |
718 | dayLabel = getNewDaylabel(); | 718 | dayLabel = getNewDaylabel(); |
719 | } | 719 | } |
720 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 720 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
721 | dayLabel->setFont( dlf ); | 721 | dayLabel->setFont( dlf ); |
722 | dayLabel->setNum( -1 ); | 722 | dayLabel->setNum( -1 ); |
723 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 723 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
724 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 724 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
725 | dayLabel->show(); | 725 | dayLabel->show(); |
726 | DateList::ConstIterator dit; | 726 | DateList::ConstIterator dit; |
727 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 727 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
728 | int counter = -1; | 728 | int counter = -1; |
729 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 729 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
730 | ++counter; | 730 | ++counter; |
731 | QDate date = *dit; | 731 | QDate date = *dit; |
732 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 732 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
733 | if ( ! appendLabels ) { | 733 | if ( ! appendLabels ) { |
734 | dayLabel = mDayLabelsList.next(); | 734 | dayLabel = mDayLabelsList.next(); |
735 | if ( !dayLabel ) | 735 | if ( !dayLabel ) |
736 | appendLabels = true; | 736 | appendLabels = true; |
737 | } | 737 | } |
738 | if ( appendLabels ) { | 738 | if ( appendLabels ) { |
739 | dayLabel = getNewDaylabel(); | 739 | dayLabel = getNewDaylabel(); |
740 | } | 740 | } |
741 | dayLabel->setMinimumWidth( 1 ); | 741 | dayLabel->setMinimumWidth( 1 ); |
742 | dayLabel->setMaximumWidth( 10240 ); | 742 | dayLabel->setMaximumWidth( 10240 ); |
743 | dayLabel->setFont( dlf ); | 743 | dayLabel->setFont( dlf ); |
744 | dayLabel->show(); | 744 | dayLabel->show(); |
745 | dayLabel->setAutoRepeat( false ); | 745 | dayLabel->setAutoRepeat( false ); |
746 | dayLabel->setNum( counter ); | 746 | dayLabel->setNum( counter ); |
747 | QString str; | 747 | QString str; |
748 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 748 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
749 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 749 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
750 | switch ( maxLen ) { | 750 | switch ( maxLen ) { |
751 | case 2: | 751 | case 2: |
752 | str = QString::number( date.day() ); | 752 | str = QString::number( date.day() ); |
753 | break; | 753 | break; |
754 | 754 | ||
755 | case 3: | 755 | case 3: |
756 | str = dayName.left( 1 ) +QString::number( date.day()); | 756 | str = dayName.left( 1 ) +QString::number( date.day()); |
757 | 757 | ||
758 | break; | 758 | break; |
759 | case 4: | 759 | case 4: |
760 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 760 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
761 | 761 | ||
762 | break; | 762 | break; |
763 | case 5: | 763 | case 5: |
764 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 764 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
765 | 765 | ||
766 | break; | 766 | break; |
767 | case 6: | 767 | case 6: |
768 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 768 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
769 | break; | 769 | break; |
770 | 770 | ||
771 | default: | 771 | default: |
772 | break; | 772 | break; |
773 | } | 773 | } |
774 | if ( oneday ) { | 774 | if ( oneday ) { |
775 | QString addString; | 775 | QString addString; |
776 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 776 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
777 | addString = i18n("Today"); | 777 | addString = i18n("Today"); |
778 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 778 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
779 | addString = i18n("Tomorrow"); | 779 | addString = i18n("Tomorrow"); |
780 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 780 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
781 | addString = i18n("Yesterday"); | 781 | addString = i18n("Yesterday"); |
782 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 782 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
783 | addString = i18n("Day before yesterday"); | 783 | addString = i18n("Day before yesterday"); |
784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
785 | addString = i18n("Day after tomorrow"); | 785 | addString = i18n("Day after tomorrow"); |
786 | if ( !addString.isEmpty() ) { | 786 | if ( !addString.isEmpty() ) { |
787 | str = addString+", " + str; | 787 | str = addString+", " + str; |
788 | } else { | 788 | } else { |
789 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 789 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
790 | } | 790 | } |
791 | } | 791 | } |
792 | dayLabel->setText(str); | 792 | dayLabel->setText(str); |
793 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 793 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
794 | if (date == QDate::currentDate()) { | 794 | if (date == QDate::currentDate()) { |
795 | QFont bFont = dlf; | 795 | QFont bFont = dlf; |
796 | bFont.setBold( true ); | 796 | bFont.setBold( true ); |
797 | dayLabel->setFont(bFont); | 797 | dayLabel->setFont(bFont); |
798 | } | 798 | } |
799 | //dayLayout->addWidget(dayLabel); | 799 | //dayLayout->addWidget(dayLabel); |
800 | 800 | ||
801 | #ifndef KORG_NOPLUGINS | 801 | #ifndef KORG_NOPLUGINS |
802 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 802 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
803 | CalendarDecoration *it; | 803 | CalendarDecoration *it; |
804 | for(it = cds.first(); it; it = cds.next()) { | 804 | for(it = cds.first(); it; it = cds.next()) { |
805 | QString text = it->shortText( date ); | 805 | QString text = it->shortText( date ); |
806 | if ( !text.isEmpty() ) { | 806 | if ( !text.isEmpty() ) { |
807 | QLabel *label = new QLabel(text,mDayLabels); | 807 | QLabel *label = new QLabel(text,mDayLabels); |
808 | label->setAlignment(AlignCenter); | 808 | label->setAlignment(AlignCenter); |
809 | dayLayout->addWidget(label); | 809 | dayLayout->addWidget(label); |
810 | } | 810 | } |
811 | } | 811 | } |
812 | 812 | ||
813 | for(it = cds.first(); it; it = cds.next()) { | 813 | for(it = cds.first(); it; it = cds.next()) { |
814 | QWidget *wid = it->smallWidget(mDayLabels,date); | 814 | QWidget *wid = it->smallWidget(mDayLabels,date); |
815 | if ( wid ) { | 815 | if ( wid ) { |
816 | // wid->setHeight(20); | 816 | // wid->setHeight(20); |
817 | dayLayout->addWidget(wid); | 817 | dayLayout->addWidget(wid); |
818 | } | 818 | } |
819 | } | 819 | } |
820 | #endif | 820 | #endif |
821 | } | 821 | } |
822 | if ( ! appendLabels ) { | 822 | if ( ! appendLabels ) { |
823 | dayLabel = mDayLabelsList.next(); | 823 | dayLabel = mDayLabelsList.next(); |
824 | if ( !dayLabel ) | 824 | if ( !dayLabel ) |
825 | appendLabels = true; | 825 | appendLabels = true; |
826 | } | 826 | } |
827 | if ( appendLabels ) { | 827 | if ( appendLabels ) { |
828 | dayLabel = getNewDaylabel(); | 828 | dayLabel = getNewDaylabel(); |
829 | } | 829 | } |
830 | //dayLabel->hide();//test only | 830 | //dayLabel->hide();//test only |
831 | 831 | qDebug("fremwidd %d ", mAgenda->frameWidth()); | |
832 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 832 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; |
833 | if ( offset < 0 ) offset = 0; | 833 | if ( offset < 0 ) offset = 0; |
834 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 834 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
835 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 835 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
836 | dayLabel->setFont( dlf ); | 836 | dayLabel->setFont( dlf ); |
837 | dayLabel->setAutoRepeat( true ); | 837 | dayLabel->setAutoRepeat( true ); |
838 | dayLabel->show(); | 838 | dayLabel->show(); |
839 | dayLabel->setNum( -2 ); | 839 | dayLabel->setNum( -2 ); |
840 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 840 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
841 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 841 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
842 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 842 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
843 | if ( !appendLabels ) { | 843 | if ( !appendLabels ) { |
844 | dayLabel = mDayLabelsList.next(); | 844 | dayLabel = mDayLabelsList.next(); |
845 | while ( dayLabel ) { | 845 | while ( dayLabel ) { |
846 | //qDebug("!dayLabel %d",dayLabel ); | 846 | //qDebug("!dayLabel %d",dayLabel ); |
847 | dayLabel->hide(); | 847 | dayLabel->hide(); |
848 | dayLabel = mDayLabelsList.next(); | 848 | dayLabel = mDayLabelsList.next(); |
849 | } | 849 | } |
850 | } | 850 | } |
851 | 851 | ||
852 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 852 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
853 | } | 853 | } |
854 | 854 | ||
855 | int KOAgendaView::maxDatesHint() | 855 | int KOAgendaView::maxDatesHint() |
856 | { | 856 | { |
857 | // Not sure about the max number of events, so return 0 for now. | 857 | // Not sure about the max number of events, so return 0 for now. |
858 | return 0; | 858 | return 0; |
859 | } | 859 | } |
860 | 860 | ||
861 | int KOAgendaView::currentDateCount() | 861 | int KOAgendaView::currentDateCount() |
862 | { | 862 | { |
863 | return mSelectedDates.count(); | 863 | return mSelectedDates.count(); |
864 | } | 864 | } |
865 | 865 | ||
866 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 866 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
867 | { | 867 | { |
868 | QPtrList<Incidence> selected; | 868 | QPtrList<Incidence> selected; |
869 | Incidence *incidence; | 869 | Incidence *incidence; |
870 | 870 | ||
871 | incidence = mAgenda->selectedIncidence(); | 871 | incidence = mAgenda->selectedIncidence(); |
872 | if (incidence) selected.append(incidence); | 872 | if (incidence) selected.append(incidence); |
873 | 873 | ||
874 | incidence = mAllDayAgenda->selectedIncidence(); | 874 | incidence = mAllDayAgenda->selectedIncidence(); |
875 | if (incidence) selected.append(incidence); | 875 | if (incidence) selected.append(incidence); |
876 | 876 | ||
877 | return selected; | 877 | return selected; |
878 | } | 878 | } |
879 | 879 | ||
880 | DateList KOAgendaView::selectedDates() | 880 | DateList KOAgendaView::selectedDates() |
881 | { | 881 | { |
882 | DateList selected; | 882 | DateList selected; |
883 | QDate qd; | 883 | QDate qd; |
884 | 884 | ||
885 | qd = mAgenda->selectedIncidenceDate(); | 885 | qd = mAgenda->selectedIncidenceDate(); |
886 | if (qd.isValid()) selected.append(qd); | 886 | if (qd.isValid()) selected.append(qd); |
887 | 887 | ||
888 | qd = mAllDayAgenda->selectedIncidenceDate(); | 888 | qd = mAllDayAgenda->selectedIncidenceDate(); |
889 | if (qd.isValid()) selected.append(qd); | 889 | if (qd.isValid()) selected.append(qd); |
890 | 890 | ||
891 | return selected; | 891 | return selected; |
892 | } | 892 | } |
893 | 893 | ||
894 | 894 | ||
895 | void KOAgendaView::updateView() | 895 | void KOAgendaView::updateView() |
896 | { | 896 | { |
897 | if ( mBlockUpdating ) | 897 | if ( mBlockUpdating ) |
898 | return; | 898 | return; |
899 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 899 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
900 | fillAgenda(); | 900 | fillAgenda(); |
901 | 901 | ||
902 | } | 902 | } |
903 | 903 | ||
904 | 904 | ||
905 | /* | 905 | /* |
906 | Update configuration settings for the agenda view. This method is not | 906 | Update configuration settings for the agenda view. This method is not |
907 | complete. | 907 | complete. |
908 | */ | 908 | */ |
909 | void KOAgendaView::updateConfig() | 909 | void KOAgendaView::updateConfig() |
910 | { | 910 | { |
911 | if ( mBlockUpdating ) | 911 | if ( mBlockUpdating ) |
912 | return; | 912 | return; |
913 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 913 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
914 | int old = KOPrefs::instance()->mHourSize; | 914 | int old = KOPrefs::instance()->mHourSize; |
915 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 915 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
916 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 916 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
917 | } | 917 | } |
918 | 918 | ||
919 | 919 | ||
920 | // update config for children | 920 | // update config for children |
921 | mTimeLabels->updateConfig(); | 921 | mTimeLabels->updateConfig(); |
922 | mAgenda->storePosition(); | 922 | mAgenda->storePosition(); |
923 | mAgenda->updateConfig(); | 923 | mAgenda->updateConfig(); |
924 | mAllDayAgenda->updateConfig(); | 924 | mAllDayAgenda->updateConfig(); |
925 | // widget synchronization | 925 | // widget synchronization |
926 | //TODO: find a better way, maybe signal/slot | 926 | //TODO: find a better way, maybe signal/slot |
927 | mTimeLabels->positionChanged(); | 927 | mTimeLabels->positionChanged(); |
928 | 928 | ||