summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-04 17:51:45 (UTC)
committer zautrix <zautrix>2005-02-04 17:51:45 (UTC)
commit4659ee80518c7d5108c21ba04a12a25eab783113 (patch) (unidiff)
tree50a9b0e55ca68c58d6159b7617db0b2d19d9338a
parentf4c3a3e3da57e957b920fe4662c6decd6764f0ee (diff)
downloadkdepimpi-4659ee80518c7d5108c21ba04a12a25eab783113.zip
kdepimpi-4659ee80518c7d5108c21ba04a12a25eab783113.tar.gz
kdepimpi-4659ee80518c7d5108c21ba04a12a25eab783113.tar.bz2
nochn fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 1908b1c..36c66ea 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -46,771 +46,772 @@
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;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::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
99void TimeLabels::setCellHeight(int height) 99void 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*/
108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 108void 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*/
165int TimeLabels::minimumWidth() const 165int 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 */
179void TimeLabels::updateConfig() 179void 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 */
195void TimeLabels::positionChanged() 195void 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/** */
202void TimeLabels::setAgenda(KOAgenda* agenda) 202void TimeLabels::setAgenda(KOAgenda* agenda)
203{ 203{
204 mAgenda = agenda; 204 mAgenda = agenda;
205} 205}
206 206
207void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 207void 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
213void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 213void 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}
227void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 227void 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() */
246void TimeLabels::paintEvent(QPaintEvent*) 246void 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
258EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 258EventIndicator::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
276EventIndicator::~EventIndicator() 276EventIndicator::~EventIndicator()
277{ 277{
278} 278}
279 279
280void EventIndicator::drawContents(QPainter *p) 280void 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
324void EventIndicator::setXOffset( int x ) 324void EventIndicator::setXOffset( int x )
325{ 325{
326 mXOffset = x; 326 mXOffset = x;
327} 327}
328void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 328void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
329{ 329{
330 mPaintWidget = w; 330 mPaintWidget = w;
331} 331}
332void EventIndicator::changeColumns(int columns) 332void 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
340void EventIndicator::enableColumn(int column, bool enable) 340void 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
350KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 350KOAgendaView::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);
431 mDummyAllDayRightL = new QLabel ( dummyAllDayRight ); 430 mDummyAllDayRightL = new QLabel ( dummyAllDayRight );
432 431 QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight);
432 new QLabel ( dummyAllDayRight );
433 mDummyAllDayRightL->setSizePolicy( QSizePolicy( QSizePolicy::Minimum,QSizePolicy::Fixed ) );
433 dummyAllDayRightB->setFlat( true ); 434 dummyAllDayRightB->setFlat( true );
434 dummyAllDayRightB->setFocusPolicy(NoFocus); 435 dummyAllDayRightB->setFocusPolicy(NoFocus);
435 dummyAllDayRightB->setFixedHeight( (dummyAllDayRightB->sizeHint().height()/4)*3 ); 436 dummyAllDayRightB->setFixedHeight( (dummyAllDayRightB->sizeHint().height()/4)*3 );
436 437
437 QPopupMenu * wpo = new QPopupMenu (this); 438 QPopupMenu * wpo = new QPopupMenu (this);
438 QPopupMenu * all = new QPopupMenu (this); 439 QPopupMenu * all = new QPopupMenu (this);
439 //wpo->insertItem( i18n("W#"), 0 ); 440 //wpo->insertItem( i18n("W#"), 0 );
440 int first = 1; 441 int first = 1;
441 int i; 442 int i;
442 for ( i = 1; i < 50; ++i ) { 443 for ( i = 1; i < 50; ++i ) {
443 if ( !(i%10) ) { 444 if ( !(i%10) ) {
444 all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); 445 all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo );
445 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); 446 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) );
446 first = i; 447 first = i;
447 wpo = new QPopupMenu (this); 448 wpo = new QPopupMenu (this);
448 } 449 }
449 wpo->insertItem( QString::number(i), i ); 450 wpo->insertItem( QString::number(i), i );
450 } 451 }
451 for ( i = 50; i < 53; ++i ) { 452 for ( i = 50; i < 53; ++i ) {
452 wpo->insertItem( QString::number(i), i); 453 wpo->insertItem( QString::number(i), i);
453 } 454 }
454 all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); 455 all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo );
455 dummyAllDayRightB->setPopup( all ); 456 dummyAllDayRightB->setPopup( all );
456 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); 457 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) );
457 458
458 // Create event context menu for all day agenda 459 // Create event context menu for all day agenda
459 mAllDayAgendaPopup = eventPopup(); 460 mAllDayAgendaPopup = eventPopup();
460 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 461 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
461 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 462 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
462 463
463 // Create agenda frame 464 // Create agenda frame
464 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 465 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
465 // QHBox *agendaFrame = new QHBox(splitterAgenda); 466 // QHBox *agendaFrame = new QHBox(splitterAgenda);
466 467
467 // create event indicator bars 468 // create event indicator bars
468 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 469 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
469 agendaLayout->addWidget(mEventIndicatorTop,0,1); 470 agendaLayout->addWidget(mEventIndicatorTop,0,1);
470 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 471 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
471 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 472 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
472 agendaFrame); 473 agendaFrame);
473 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 474 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
474 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 475 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
475 agendaLayout->addWidget(dummyAgendaRight,0,2); 476 agendaLayout->addWidget(dummyAgendaRight,0,2);
476 477
477 // Create time labels 478 // Create time labels
478 mTimeLabels = new TimeLabels(24,agendaFrame); 479 mTimeLabels = new TimeLabels(24,agendaFrame);
479 agendaLayout->addWidget(mTimeLabels,1,0); 480 agendaLayout->addWidget(mTimeLabels,1,0);
480 connect(mTimeLabels,SIGNAL( scaleChanged()), 481 connect(mTimeLabels,SIGNAL( scaleChanged()),
481 this,SLOT(updateConfig())); 482 this,SLOT(updateConfig()));
482 483
483 // Create agenda 484 // Create agenda
484 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 485 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
485 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 486 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
486 agendaLayout->setColStretch(1,1); 487 agendaLayout->setColStretch(1,1);
487 mAgenda->setFocusPolicy(NoFocus); 488 mAgenda->setFocusPolicy(NoFocus);
488 // Create event context menu for agenda 489 // Create event context menu for agenda
489 mAgendaPopup = eventPopup(); 490 mAgendaPopup = eventPopup();
490 491
491 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 492 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
492 i18n("Toggle Alarm"),mAgenda, 493 i18n("Toggle Alarm"),mAgenda,
493 SLOT(popupAlarm()),true); 494 SLOT(popupAlarm()),true);
494 495
495 496
496 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 497 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
497 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 498 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
498 499
499 // make connections between dependent widgets 500 // make connections between dependent widgets
500 mTimeLabels->setAgenda(mAgenda); 501 mTimeLabels->setAgenda(mAgenda);
501 502
502 // Update widgets to reflect user preferences 503 // Update widgets to reflect user preferences
503 // updateConfig(); 504 // updateConfig();
504 505
505 // createDayLabels(); 506 // createDayLabels();
506 507
507 // these blank widgets make the All Day Event box line up with the agenda 508 // these blank widgets make the All Day Event box line up with the agenda
508 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 509 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
509 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 510 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
510 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 511 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
511 512
512 // Scrolling 513 // Scrolling
513 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 514 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
514 mTimeLabels, SLOT(positionChanged())); 515 mTimeLabels, SLOT(positionChanged()));
515 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 516 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
516 SLOT(setContentsPos(int))); 517 SLOT(setContentsPos(int)));
517 518
518 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 519 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
519 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 520 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
520 521
521 // Create/Show/Edit/Delete Event 522 // Create/Show/Edit/Delete Event
522 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 523 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
523 SLOT(newEvent(int,int))); 524 SLOT(newEvent(int,int)));
524 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 525 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
525 SLOT(newTodo(int,int))); 526 SLOT(newTodo(int,int)));
526 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 527 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
527 SLOT(newEvent(int,int,int,int))); 528 SLOT(newEvent(int,int,int,int)));
528 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 529 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
529 SLOT(newEventAllDay(int,int))); 530 SLOT(newEventAllDay(int,int)));
530 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 531 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
531 SLOT(newTodoAllDay(int,int))); 532 SLOT(newTodoAllDay(int,int)));
532 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 533 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
533 SLOT(newEventAllDay(int,int))); 534 SLOT(newEventAllDay(int,int)));
534 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 535 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
535 SLOT(newTimeSpanSelected(int,int,int,int))); 536 SLOT(newTimeSpanSelected(int,int,int,int)));
536 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 537 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
537 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 538 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
538 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 539 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
539 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 540 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
540 541
541 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 542 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
542 SIGNAL(editIncidenceSignal(Incidence *))); 543 SIGNAL(editIncidenceSignal(Incidence *)));
543 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 544 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
544 SIGNAL(editIncidenceSignal(Incidence *))); 545 SIGNAL(editIncidenceSignal(Incidence *)));
545 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 546 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
546 SIGNAL(showIncidenceSignal(Incidence *))); 547 SIGNAL(showIncidenceSignal(Incidence *)));
547 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 548 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
548 SIGNAL(showIncidenceSignal(Incidence *))); 549 SIGNAL(showIncidenceSignal(Incidence *)));
549 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 550 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
550 SIGNAL(deleteIncidenceSignal(Incidence *))); 551 SIGNAL(deleteIncidenceSignal(Incidence *)));
551 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 552 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
552 SIGNAL(deleteIncidenceSignal(Incidence *))); 553 SIGNAL(deleteIncidenceSignal(Incidence *)));
553 554
554 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 555 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
555 SLOT(updateEventDates(KOAgendaItem *, int ))); 556 SLOT(updateEventDates(KOAgendaItem *, int )));
556 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 557 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
557 SLOT(updateEventDates(KOAgendaItem *, int))); 558 SLOT(updateEventDates(KOAgendaItem *, int)));
558 559
559 // event indicator update 560 // event indicator update
560 connect(mAgenda,SIGNAL(lowerYChanged(int)), 561 connect(mAgenda,SIGNAL(lowerYChanged(int)),
561 SLOT(updateEventIndicatorTop(int))); 562 SLOT(updateEventIndicatorTop(int)));
562 connect(mAgenda,SIGNAL(upperYChanged(int)), 563 connect(mAgenda,SIGNAL(upperYChanged(int)),
563 SLOT(updateEventIndicatorBottom(int))); 564 SLOT(updateEventIndicatorBottom(int)));
564 // drag signals 565 // drag signals
565 /* 566 /*
566 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 567 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
567 SLOT(startDrag(Event *))); 568 SLOT(startDrag(Event *)));
568 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 569 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
569 SLOT(startDrag(Event *))); 570 SLOT(startDrag(Event *)));
570 */ 571 */
571 // synchronize selections 572 // synchronize selections
572 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 573 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
573 mAllDayAgenda, SLOT( deselectItem() ) ); 574 mAllDayAgenda, SLOT( deselectItem() ) );
574 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 575 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
575 mAgenda, SLOT( deselectItem() ) ); 576 mAgenda, SLOT( deselectItem() ) );
576 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 577 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
577 SIGNAL( incidenceSelected( Incidence * ) ) ); 578 SIGNAL( incidenceSelected( Incidence * ) ) );
578 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 579 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
579 SIGNAL( incidenceSelected( Incidence * ) ) ); 580 SIGNAL( incidenceSelected( Incidence * ) ) );
580 connect( mAgenda, SIGNAL( resizedSignal() ), 581 connect( mAgenda, SIGNAL( resizedSignal() ),
581 SLOT( updateConfig( ) ) ); 582 SLOT( updateConfig( ) ) );
582 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 583 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
583 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 584 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
584 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 585 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
585 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 586 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
586 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 587 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
587 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 588 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
588 589
589 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 590 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
590 QFontMetrics fm ( dlf ); 591 QFontMetrics fm ( dlf );
591 QString dayTest = "30"; 592 QString dayTest = "30";
592 int wid = fm.width( dayTest ); 593 int wid = fm.width( dayTest );
593 int maxWid = dummyAllDayRight->width()-2; 594 int maxWid = dummyAllDayRight->width()-2;
594 int fontPoint = dlf.pointSize(); 595 int fontPoint = dlf.pointSize();
595 while ( wid > maxWid ) { 596 while ( wid > maxWid ) {
596 --fontPoint; 597 --fontPoint;
597 dlf.setPointSize( fontPoint ); 598 dlf.setPointSize( fontPoint );
598 QFontMetrics f( dlf ); 599 QFontMetrics f( dlf );
599 wid = f.width( dayTest ); 600 wid = f.width( dayTest );
600 } 601 }
601 mDummyAllDayRightL->setFont( dlf ); 602 mDummyAllDayRightL->setFont( dlf );
602 mDummyAllDayRightL->setAlignment( AlignHCenter ); 603 mDummyAllDayRightL->setAlignment( AlignHCenter );
603} 604}
604 605
605void KOAgendaView::toggleAllDay() 606void KOAgendaView::toggleAllDay()
606{ 607{
607 if ( mSplitterAgenda->firstHandle() ) 608 if ( mSplitterAgenda->firstHandle() )
608 mSplitterAgenda->firstHandle()->toggle(); 609 mSplitterAgenda->firstHandle()->toggle();
609} 610}
610void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 611void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
611{ 612{
612 calendar()->addIncidence( inc ); 613 calendar()->addIncidence( inc );
613 614
614 if ( incOld ) { 615 if ( incOld ) {
615 if ( incOld->type() == "Todo" ) 616 if ( incOld->type() == "Todo" )
616 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 617 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
617 else 618 else
618 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 619 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
619 } 620 }
620 621
621} 622}
622 623
623KOAgendaView::~KOAgendaView() 624KOAgendaView::~KOAgendaView()
624{ 625{
625 delete mAgendaPopup; 626 delete mAgendaPopup;
626 delete mAllDayAgendaPopup; 627 delete mAllDayAgendaPopup;
627 delete KOAgendaItem::paintPix(); 628 delete KOAgendaItem::paintPix();
628 delete KOAgendaItem::paintPixSel(); 629 delete KOAgendaItem::paintPixSel();
629} 630}
630void KOAgendaView::resizeEvent( QResizeEvent* e ) 631void KOAgendaView::resizeEvent( QResizeEvent* e )
631{ 632{
632 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 633 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
633 bool uc = false; 634 bool uc = false;
634 int ow = e->oldSize().width(); 635 int ow = e->oldSize().width();
635 int oh = e->oldSize().height(); 636 int oh = e->oldSize().height();
636 int w = e->size().width(); 637 int w = e->size().width();
637 int h = e->size().height(); 638 int h = e->size().height();
638 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 639 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
639 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 640 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
640 uc = true; 641 uc = true;
641 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 642 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
642 } 643 }
643 mUpcomingWidth = e->size().width() ; 644 mUpcomingWidth = e->size().width() ;
644 if ( mBlockUpdating || uc ) { 645 if ( mBlockUpdating || uc ) {
645 mBlockUpdating = false; 646 mBlockUpdating = false;
646 //mAgenda->setMinimumSize(800 , 600 ); 647 //mAgenda->setMinimumSize(800 , 600 );
647 //qDebug("mAgenda->resize+++++++++++++++ "); 648 //qDebug("mAgenda->resize+++++++++++++++ ");
648 updateConfig(); 649 updateConfig();
649 //qDebug("KOAgendaView::Updating now possible "); 650 //qDebug("KOAgendaView::Updating now possible ");
650 } else 651 } else
651 createDayLabels(); 652 createDayLabels();
652 //qDebug("resizeEvent end "); 653 //qDebug("resizeEvent end ");
653 654
654} 655}
655void KOAgendaView::slotDaylabelClicked( int num ) 656void KOAgendaView::slotDaylabelClicked( int num )
656{ 657{
657 658
658 QDate firstDate = mSelectedDates.first(); 659 QDate firstDate = mSelectedDates.first();
659 if ( num == -1 ) 660 if ( num == -1 )
660 emit showDateView( 6, firstDate ); 661 emit showDateView( 6, firstDate );
661 else if (num >= 0 ) { 662 else if (num >= 0 ) {
662 if ( mSelectedDates.count() == 1) 663 if ( mSelectedDates.count() == 1)
663 emit showDateView( 9, firstDate.addDays( num ) ); 664 emit showDateView( 9, firstDate.addDays( num ) );
664 else 665 else
665 emit showDateView( 3, firstDate.addDays( num ) ); 666 emit showDateView( 3, firstDate.addDays( num ) );
666 } 667 }
667 else 668 else
668 showDateView( 10, firstDate.addDays(1) ); 669 showDateView( 10, firstDate.addDays(1) );
669} 670}
670 671
671KOAgendaButton* KOAgendaView::getNewDaylabel() 672KOAgendaButton* KOAgendaView::getNewDaylabel()
672{ 673{
673 674
674 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 675 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
675 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 676 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
676 mDayLabelsList.append( dayLabel ); 677 mDayLabelsList.append( dayLabel );
677 mLayoutDayLabels->addWidget(dayLabel); 678 mLayoutDayLabels->addWidget(dayLabel);
678 return dayLabel ; 679 return dayLabel ;
679} 680}
680 681
681void KOAgendaView::createDayLabels() 682void KOAgendaView::createDayLabels()
682{ 683{
683 684
684 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 685 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
685 // qDebug(" KOAgendaView::createDayLabels() blocked "); 686 // qDebug(" KOAgendaView::createDayLabels() blocked ");
686 return; 687 return;
687 688
688 } 689 }
689 int newHight; 690 int newHight;
690 691
691 // ### Before deleting and recreating we could check if mSelectedDates changed... 692 // ### Before deleting and recreating we could check if mSelectedDates changed...
692 // It would remove some flickering and gain speed (since this is called by 693 // It would remove some flickering and gain speed (since this is called by
693 // each updateView() call) 694 // each updateView() call)
694 695
695 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 696 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
696 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 697 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
697 if ( maxWid < 0 ) 698 if ( maxWid < 0 )
698 maxWid = 20; 699 maxWid = 20;
699 700
700 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 701 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
701 QFontMetrics fm ( dlf ); 702 QFontMetrics fm ( dlf );
702 int selCount = mSelectedDates.count(); 703 int selCount = mSelectedDates.count();
703 QString dayTest = "Mon 20"; 704 QString dayTest = "Mon 20";
704 //QString dayTest = "Mon 20"; 705 //QString dayTest = "Mon 20";
705 int wid = fm.width( dayTest ); 706 int wid = fm.width( dayTest );
706 //maxWid -= ( selCount * 3 ); //working for QLabels 707 //maxWid -= ( selCount * 3 ); //working for QLabels
707 maxWid -= ( selCount * 3 ); //working for QPushButton 708 maxWid -= ( selCount * 3 ); //working for QPushButton
708 if ( maxWid < 0 ) 709 if ( maxWid < 0 )
709 maxWid = 20; 710 maxWid = 20;
710 int needWid = wid * selCount; 711 int needWid = wid * selCount;
711 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 712 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
712 //if ( needWid > maxWid ) 713 //if ( needWid > maxWid )
713 // qDebug("DAYLABELS TOOOOOOO BIG "); 714 // qDebug("DAYLABELS TOOOOOOO BIG ");
714 while ( needWid > maxWid ) { 715 while ( needWid > maxWid ) {
715 dayTest = dayTest.left( dayTest.length() - 1 ); 716 dayTest = dayTest.left( dayTest.length() - 1 );
716 wid = fm.width( dayTest ); 717 wid = fm.width( dayTest );
717 needWid = wid * selCount; 718 needWid = wid * selCount;
718 } 719 }
719 int maxLen = dayTest.length(); 720 int maxLen = dayTest.length();
720 int fontPoint = dlf.pointSize(); 721 int fontPoint = dlf.pointSize();
721 if ( maxLen < 2 ) { 722 if ( maxLen < 2 ) {
722 int fontPoint = dlf.pointSize(); 723 int fontPoint = dlf.pointSize();
723 while ( fontPoint > 4 ) { 724 while ( fontPoint > 4 ) {
724 --fontPoint; 725 --fontPoint;
725 dlf.setPointSize( fontPoint ); 726 dlf.setPointSize( fontPoint );
726 QFontMetrics f( dlf ); 727 QFontMetrics f( dlf );
727 wid = f.width( "30" ); 728 wid = f.width( "30" );
728 needWid = wid * selCount; 729 needWid = wid * selCount;
729 if ( needWid < maxWid ) 730 if ( needWid < maxWid )
730 break; 731 break;
731 } 732 }
732 maxLen = 2; 733 maxLen = 2;
733 } 734 }
734 //qDebug("Max len %d ", dayTest.length() ); 735 //qDebug("Max len %d ", dayTest.length() );
735 736
736 QFontMetrics tempF( dlf ); 737 QFontMetrics tempF( dlf );
737 newHight = tempF.height(); 738 newHight = tempF.height();
738 mDayLabels->setFont( dlf ); 739 mDayLabels->setFont( dlf );
739 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 740 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
740 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 741 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
741 //mLayoutDayLabels->addSpacing( 2 ); 742 //mLayoutDayLabels->addSpacing( 2 );
742 // QFont lFont = dlf; 743 // QFont lFont = dlf;
743 bool appendLabels = false; 744 bool appendLabels = false;
744 KOAgendaButton *dayLabel; 745 KOAgendaButton *dayLabel;
745 dayLabel = mDayLabelsList.first(); 746 dayLabel = mDayLabelsList.first();
746 if ( !dayLabel ) { 747 if ( !dayLabel ) {
747 appendLabels = true; 748 appendLabels = true;
748 dayLabel = getNewDaylabel(); 749 dayLabel = getNewDaylabel();
749 } 750 }
750 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 751 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
751 dayLabel->setFont( dlf ); 752 dayLabel->setFont( dlf );
752 dayLabel->setNum( -1 ); 753 dayLabel->setNum( -1 );
753 //dayLabel->setAlignment(QLabel::AlignHCenter); 754 //dayLabel->setAlignment(QLabel::AlignHCenter);
754 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 755 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
755 dayLabel->show(); 756 dayLabel->show();
756 DateList::ConstIterator dit; 757 DateList::ConstIterator dit;
757 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 758 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
758 int counter = -1; 759 int counter = -1;
759 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 760 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
760 ++counter; 761 ++counter;
761 QDate date = *dit; 762 QDate date = *dit;
762 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 763 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
763 if ( ! appendLabels ) { 764 if ( ! appendLabels ) {
764 dayLabel = mDayLabelsList.next(); 765 dayLabel = mDayLabelsList.next();
765 if ( !dayLabel ) 766 if ( !dayLabel )
766 appendLabels = true; 767 appendLabels = true;
767 } 768 }
768 if ( appendLabels ) { 769 if ( appendLabels ) {
769 dayLabel = getNewDaylabel(); 770 dayLabel = getNewDaylabel();
770 } 771 }
771 dayLabel->setMinimumWidth( 1 ); 772 dayLabel->setMinimumWidth( 1 );
772 dayLabel->setMaximumWidth( 1024 ); 773 dayLabel->setMaximumWidth( 1024 );
773 dayLabel->setFont( dlf ); 774 dayLabel->setFont( dlf );
774 dayLabel->show(); 775 dayLabel->show();
775 dayLabel->setNum( counter ); 776 dayLabel->setNum( counter );
776 QString str; 777 QString str;
777 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 778 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
778 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 779 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
779 switch ( maxLen ) { 780 switch ( maxLen ) {
780 case 2: 781 case 2:
781 str = QString::number( date.day() ); 782 str = QString::number( date.day() );
782 break; 783 break;
783 784
784 case 3: 785 case 3:
785 str = dayName.left( 1 ) +QString::number( date.day()); 786 str = dayName.left( 1 ) +QString::number( date.day());
786 787
787 break; 788 break;
788 case 4: 789 case 4:
789 str = dayName.left( 1 ) + " " +QString::number( date.day()); 790 str = dayName.left( 1 ) + " " +QString::number( date.day());
790 791
791 break; 792 break;
792 case 5: 793 case 5:
793 str = dayName.left( 2 ) + " " +QString::number( date.day()); 794 str = dayName.left( 2 ) + " " +QString::number( date.day());
794 795
795 break; 796 break;
796 case 6: 797 case 6:
797 str = dayName.left( 3 ) + " " +QString::number( date.day()); 798 str = dayName.left( 3 ) + " " +QString::number( date.day());
798 break; 799 break;
799 800
800 default: 801 default:
801 break; 802 break;
802 } 803 }
803 if ( oneday ) { 804 if ( oneday ) {
804 QString addString; 805 QString addString;
805 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 806 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
806 addString = i18n("Today"); 807 addString = i18n("Today");
807 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 808 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
808 addString = i18n("Tomorrow"); 809 addString = i18n("Tomorrow");
809 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 810 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
810 addString = i18n("Yesterday"); 811 addString = i18n("Yesterday");
811 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 812 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
812 addString = i18n("Day before yesterday"); 813 addString = i18n("Day before yesterday");
813 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 814 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
814 addString = i18n("Day after tomorrow"); 815 addString = i18n("Day after tomorrow");
815 if ( !addString.isEmpty() ) { 816 if ( !addString.isEmpty() ) {
816 str = addString+", " + str; 817 str = addString+", " + str;