summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-19 12:41:09 (UTC)
committer zautrix <zautrix>2005-03-19 12:41:09 (UTC)
commit0aa5a7dce6ac1224395f7cb3fae488ba566f0e38 (patch) (unidiff)
treeb0950df228b2d9d2486977f7906ce4f0d9284cba
parentea9e00a1f70e9c3c855707213b51c6b6d43c330c (diff)
downloadkdepimpi-0aa5a7dce6ac1224395f7cb3fae488ba566f0e38.zip
kdepimpi-0aa5a7dce6ac1224395f7cb3fae488ba566f0e38.tar.gz
kdepimpi-0aa5a7dce6ac1224395f7cb3fae488ba566f0e38.tar.bz2
agenda fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index d7ea4d4..e029fdb 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -78,540 +78,542 @@ using 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 setMinimumHeight(mPixmap.height());
271 setMaximumHeight(0);
272 else
273 setMinimumHeight(mPixmap.height());
274} 271}
275 272
276EventIndicator::~EventIndicator() 273EventIndicator::~EventIndicator()
277{ 274{
278} 275}
279 276
280void EventIndicator::drawContents(QPainter *p) 277void EventIndicator::drawContents(QPainter *p)
281{ 278{
282 279
283 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 280 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
284 KDGanttSplitterHandle* han = 0; 281 KDGanttSplitterHandle* han = 0;
285 if ( mPaintWidget ) 282 if ( mPaintWidget )
286 han = mPaintWidget->firstHandle(); 283 han = mPaintWidget->firstHandle();
287 if ( ! han ) { 284 if ( ! han ) {
288 int i; 285 int i;
289 for(i=0;i<mColumns;++i) { 286 for(i=0;i<mColumns;++i) {
290 if (mEnabled[i]) { 287 if (mEnabled[i]) {
291 int cellWidth = contentsRect().right()/mColumns; 288 int cellWidth = contentsRect().right()/mColumns;
292 int xOffset = KOGlobals::self()->reverseLayout() ? 289 int xOffset = KOGlobals::self()->reverseLayout() ?
293 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 290 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
294 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 291 i*cellWidth + (cellWidth -mPixmap.width()) /2;
295 p->drawPixmap(QPoint(xOffset,0),mPixmap); 292 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
296 } 293 }
297 } 294 }
298 } else { 295 } else {
299 han->repaint(); 296 han->repaint();
300 //mPaintWidget->setBackgroundColor( red ); 297 //mPaintWidget->setBackgroundColor( red );
301 298
302 QPainter pa( han ); 299 QPainter pa( han );
303 int i; 300 int i;
304 bool setColor = false; 301 bool setColor = false;
305 for(i=0;i<mColumns;++i) { 302 for(i=0;i<mColumns;++i) {
306 if (mEnabled[i]) { 303 if (mEnabled[i]) {
307 setColor = true; 304 setColor = true;
308 305
309 int cellWidth = contentsRect().right()/mColumns; 306 int cellWidth = contentsRect().right()/mColumns;
310 int xOffset = KOGlobals::self()->reverseLayout() ? 307 int xOffset = KOGlobals::self()->reverseLayout() ?
311 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 308 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
312 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 309 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
313 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 310 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
314 //qDebug("222draw pix %d ",xOffset ); 311 //qDebug("222draw pix %d ",xOffset );
315 312
316 } 313 }
317 314
318 } 315 }
319 pa.end(); 316 pa.end();
320 317
321 } 318 }
322} 319}
323 320
324void EventIndicator::setXOffset( int x ) 321void EventIndicator::setXOffset( int x )
325{ 322{
326 mXOffset = x; 323 mXOffset = x;
327} 324}
328void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 325void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
329{ 326{
330 mPaintWidget = w; 327 mPaintWidget = w;
328 setMaximumHeight(0);
329 setMinimumHeight(0);
331} 330}
332void EventIndicator::changeColumns(int columns) 331void EventIndicator::changeColumns(int columns)
333{ 332{
334 mColumns = columns; 333 mColumns = columns;
335 mEnabled.resize(mColumns); 334 mEnabled.resize(mColumns);
336 335
337 update(); 336 update();
338} 337}
339 338
340void EventIndicator::enableColumn(int column, bool enable) 339void EventIndicator::enableColumn(int column, bool enable)
341{ 340{
342 mEnabled[column] = enable; 341 mEnabled[column] = enable;
343} 342}
344 343
345 344
346//////////////////////////////////////////////////////////////////////////// 345////////////////////////////////////////////////////////////////////////////
347//////////////////////////////////////////////////////////////////////////// 346////////////////////////////////////////////////////////////////////////////
348//////////////////////////////////////////////////////////////////////////// 347////////////////////////////////////////////////////////////////////////////
349 348
350KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 349KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
351 KOEventView (cal,parent,name) 350 KOEventView (cal,parent,name)
352{ 351{
353 mBlockUpdating = true; 352 mBlockUpdating = true;
354 mStartHour = 8; 353 mStartHour = 8;
355 mSelectedDates.append(QDate::currentDate()); 354 mSelectedDates.append(QDate::currentDate());
356 355
357 mLayoutDayLabels = 0; 356 mLayoutDayLabels = 0;
358 mDayLabelsFrame = 0; 357 mDayLabelsFrame = 0;
359 mDayLabels = 0; 358 mDayLabels = 0;
360 bool isRTL = KOGlobals::self()->reverseLayout(); 359 bool isRTL = KOGlobals::self()->reverseLayout();
361 360
362 if ( KOPrefs::instance()->mVerticalScreen ) { 361 if ( KOPrefs::instance()->mVerticalScreen ) {
363 mExpandedPixmap = SmallIcon( "1downarrow" ); 362 mExpandedPixmap = SmallIcon( "1downarrow" );
364 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 363 mNotExpandedPixmap = SmallIcon( "1uparrow" );
365 } else { 364 } else {
366 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 365 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
367 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 366 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
368 } 367 }
369 368
370 QBoxLayout *topLayout = new QVBoxLayout(this); 369 QBoxLayout *topLayout = new QVBoxLayout(this);
371 370
372 // Create day name labels for agenda columns 371 // Create day name labels for agenda columns
373 // Create agenda splitter 372 // Create agenda splitter
374 373
375 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 374 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
376 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 375 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
377 topLayout->addWidget( mSplitterAgenda ); 376 topLayout->addWidget( mSplitterAgenda );
378 mAllDayFrame = new QHBox(mSplitterAgenda); 377 mAllDayFrame = new QHBox(mSplitterAgenda);
379 mAllDayFrame->setFocusPolicy(NoFocus); 378 mAllDayFrame->setFocusPolicy(NoFocus);
380 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 379 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
381 agendaFrame->setFocusPolicy(NoFocus); 380 agendaFrame->setFocusPolicy(NoFocus);
382 381
383 // Create all-day agenda widget 382 // Create all-day agenda widget
384 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 383 mDummyAllDayLeft = new QVBox( mAllDayFrame );
385 384
386 mExpandButton = new QPushButton(mDummyAllDayLeft); 385 mExpandButton = new QPushButton(mDummyAllDayLeft);
387 mExpandButton->setPixmap( mNotExpandedPixmap ); 386 mExpandButton->setPixmap( mNotExpandedPixmap );
388 int widebut = mExpandButton->sizeHint().width(); 387 int widebut = mExpandButton->sizeHint().width();
389 if ( QApplication::desktop()->width() < 480 ) 388 if ( QApplication::desktop()->width() < 480 )
390 widebut = widebut*2; 389 widebut = widebut*2;
391 else 390 else
392 widebut = (widebut*3) / 2; 391 widebut = (widebut*3) / 2;
393 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 392 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
394 // QSizePolicy::Fixed ) ); 393 // QSizePolicy::Fixed ) );
395 mExpandButton->setFixedSize( widebut, widebut); 394 mExpandButton->setFixedSize( widebut, widebut);
396 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 395 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
397 mExpandButton->setFocusPolicy(NoFocus); 396 mExpandButton->setFocusPolicy(NoFocus);
398 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 397 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
399 mAllDayAgenda->setFocusPolicy(NoFocus); 398 mAllDayAgenda->setFocusPolicy(NoFocus);
400 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 399 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
401 400
402 // Create event context menu for all day agenda 401 // Create event context menu for all day agenda
403 mAllDayAgendaPopup = eventPopup(); 402 mAllDayAgendaPopup = eventPopup();
404 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 403 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
405 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 404 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
406 405
407 // Create agenda frame 406 // Create agenda frame
408 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 407 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
409 // QHBox *agendaFrame = new QHBox(splitterAgenda); 408 // QHBox *agendaFrame = new QHBox(splitterAgenda);
410 409
411 // create event indicator bars 410 // create event indicator bars
412 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 411 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
413 agendaLayout->addWidget(mEventIndicatorTop,0,1); 412#ifndef DESKTOP_VERSION
414 413 // FIX
414 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
415#endif
415 mDayLabelsFrame = new QHBox(agendaFrame); 416 mDayLabelsFrame = new QHBox(agendaFrame);
416 //topLayout->addWidget(mDayLabelsFrame); 417 //topLayout->addWidget(mDayLabelsFrame);
417 mDayLabels = new QFrame (mDayLabelsFrame); 418 mDayLabels = new QFrame (mDayLabelsFrame);
418 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 419 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
419 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,1,1,0,2); 420 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
420 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 421 agendaLayout->addWidget(mEventIndicatorTop,1,1);
422
421 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 423 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
422 agendaFrame); 424 agendaFrame);
423 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 425 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
424 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 426 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
425 agendaLayout->addWidget(dummyAgendaRight,0,2); 427 agendaLayout->addWidget(dummyAgendaRight,1,2);
426 428
427 // Create time labels 429 // Create time labels
428 mTimeLabels = new TimeLabels(24,agendaFrame); 430 mTimeLabels = new TimeLabels(24,agendaFrame);
429 agendaLayout->addWidget(mTimeLabels,2,0); 431 agendaLayout->addWidget(mTimeLabels,2,0);
430 connect(mTimeLabels,SIGNAL( scaleChanged()), 432 connect(mTimeLabels,SIGNAL( scaleChanged()),
431 this,SLOT(updateConfig())); 433 this,SLOT(updateConfig()));
432 434
433 // Create agenda 435 // Create agenda
434 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 436 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
435 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 437 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
436 agendaLayout->setColStretch(1,1); 438 agendaLayout->setColStretch(1,1);
437 mAgenda->setFocusPolicy(NoFocus); 439 mAgenda->setFocusPolicy(NoFocus);
438 // Create event context menu for agenda 440 // Create event context menu for agenda
439 mAgendaPopup = eventPopup(); 441 mAgendaPopup = eventPopup();
440 442
441 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 443 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
442 i18n("Toggle Alarm"),mAgenda, 444 i18n("Toggle Alarm"),mAgenda,
443 SLOT(popupAlarm()),true); 445 SLOT(popupAlarm()),true);
444 446
445 447
446 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 448 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
447 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 449 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
448 450
449 // make connections between dependent widgets 451 // make connections between dependent widgets
450 mTimeLabels->setAgenda(mAgenda); 452 mTimeLabels->setAgenda(mAgenda);
451 453
452 // Update widgets to reflect user preferences 454 // Update widgets to reflect user preferences
453 // updateConfig(); 455 // updateConfig();
454 456
455 // createDayLabels(); 457 // createDayLabels();
456 458
457 // these blank widgets make the All Day Event box line up with the agenda 459 // these blank widgets make the All Day Event box line up with the agenda
458 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 460 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
459 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 461 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
460 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 462 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
461 463
462 // Scrolling 464 // Scrolling
463 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 465 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
464 mTimeLabels, SLOT(positionChanged())); 466 mTimeLabels, SLOT(positionChanged()));
465 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 467 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
466 SLOT(setContentsPos(int))); 468 SLOT(setContentsPos(int)));
467 469
468 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 470 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
469 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 471 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
470 472
471 // Create/Show/Edit/Delete Event 473 // Create/Show/Edit/Delete Event
472 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 474 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
473 SLOT(newEvent(int,int))); 475 SLOT(newEvent(int,int)));
474 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 476 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
475 SLOT(newTodo(int,int))); 477 SLOT(newTodo(int,int)));
476 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 478 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
477 SLOT(newEvent(int,int,int,int))); 479 SLOT(newEvent(int,int,int,int)));
478 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 480 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
479 SLOT(newEventAllDay(int,int))); 481 SLOT(newEventAllDay(int,int)));
480 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 482 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
481 SLOT(newTodoAllDay(int,int))); 483 SLOT(newTodoAllDay(int,int)));
482 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 484 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
483 SLOT(newEventAllDay(int,int))); 485 SLOT(newEventAllDay(int,int)));
484 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 486 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
485 SLOT(newTimeSpanSelected(int,int,int,int))); 487 SLOT(newTimeSpanSelected(int,int,int,int)));
486 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 488 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
487 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 489 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
488 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 490 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
489 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 491 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
490 492
491 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 493 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
492 SIGNAL(editIncidenceSignal(Incidence *))); 494 SIGNAL(editIncidenceSignal(Incidence *)));
493 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 495 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
494 SIGNAL(editIncidenceSignal(Incidence *))); 496 SIGNAL(editIncidenceSignal(Incidence *)));
495 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 497 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
496 SIGNAL(showIncidenceSignal(Incidence *))); 498 SIGNAL(showIncidenceSignal(Incidence *)));
497 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 499 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
498 SIGNAL(showIncidenceSignal(Incidence *))); 500 SIGNAL(showIncidenceSignal(Incidence *)));
499 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 501 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
500 SIGNAL(deleteIncidenceSignal(Incidence *))); 502 SIGNAL(deleteIncidenceSignal(Incidence *)));
501 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 503 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
502 SIGNAL(deleteIncidenceSignal(Incidence *))); 504 SIGNAL(deleteIncidenceSignal(Incidence *)));
503 505
504 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 506 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
505 SLOT(updateEventDates(KOAgendaItem *, int ))); 507 SLOT(updateEventDates(KOAgendaItem *, int )));
506 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 508 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
507 SLOT(updateEventDates(KOAgendaItem *, int))); 509 SLOT(updateEventDates(KOAgendaItem *, int)));
508 510
509 // event indicator update 511 // event indicator update
510 connect(mAgenda,SIGNAL(lowerYChanged(int)), 512 connect(mAgenda,SIGNAL(lowerYChanged(int)),
511 SLOT(updateEventIndicatorTop(int))); 513 SLOT(updateEventIndicatorTop(int)));
512 connect(mAgenda,SIGNAL(upperYChanged(int)), 514 connect(mAgenda,SIGNAL(upperYChanged(int)),
513 SLOT(updateEventIndicatorBottom(int))); 515 SLOT(updateEventIndicatorBottom(int)));
514 // drag signals 516 // drag signals
515 /* 517 /*
516 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 518 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
517 SLOT(startDrag(Event *))); 519 SLOT(startDrag(Event *)));
518 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 520 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
519 SLOT(startDrag(Event *))); 521 SLOT(startDrag(Event *)));
520 */ 522 */
521 // synchronize selections 523 // synchronize selections
522 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 524 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
523 mAllDayAgenda, SLOT( deselectItem() ) ); 525 mAllDayAgenda, SLOT( deselectItem() ) );
524 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 526 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
525 mAgenda, SLOT( deselectItem() ) ); 527 mAgenda, SLOT( deselectItem() ) );
526 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 528 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
527 SIGNAL( incidenceSelected( Incidence * ) ) ); 529 SIGNAL( incidenceSelected( Incidence * ) ) );
528 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 530 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
529 SIGNAL( incidenceSelected( Incidence * ) ) ); 531 SIGNAL( incidenceSelected( Incidence * ) ) );
530 connect( mAgenda, SIGNAL( resizedSignal() ), 532 connect( mAgenda, SIGNAL( resizedSignal() ),
531 SLOT( updateConfig( ) ) ); 533 SLOT( updateConfig( ) ) );
532 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 534 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
533 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 535 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
534 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 536 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
535 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 537 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
536 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 538 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
537 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 539 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
538 540
539 541
540} 542}
541 543
542void KOAgendaView::toggleAllDay() 544void KOAgendaView::toggleAllDay()
543{ 545{
544 if ( mSplitterAgenda->firstHandle() ) 546 if ( mSplitterAgenda->firstHandle() )
545 mSplitterAgenda->firstHandle()->toggle(); 547 mSplitterAgenda->firstHandle()->toggle();
546} 548}
547void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 549void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
548{ 550{
549 calendar()->addIncidence( inc ); 551 calendar()->addIncidence( inc );
550 552
551 if ( incOld ) { 553 if ( incOld ) {
552 if ( incOld->type() == "Todo" ) 554 if ( incOld->type() == "Todo" )
553 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 555 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
554 else 556 else
555 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 557 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
556 } 558 }
557 559
558} 560}
559 561
560KOAgendaView::~KOAgendaView() 562KOAgendaView::~KOAgendaView()
561{ 563{
562 delete mAgendaPopup; 564 delete mAgendaPopup;
563 delete mAllDayAgendaPopup; 565 delete mAllDayAgendaPopup;
564 delete KOAgendaItem::paintPix(); 566 delete KOAgendaItem::paintPix();
565 delete KOAgendaItem::paintPixSel(); 567 delete KOAgendaItem::paintPixSel();
566} 568}
567void KOAgendaView::resizeEvent( QResizeEvent* e ) 569void KOAgendaView::resizeEvent( QResizeEvent* e )
568{ 570{
569 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 571 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
570 bool uc = false; 572 bool uc = false;
571 int ow = e->oldSize().width(); 573 int ow = e->oldSize().width();
572 int oh = e->oldSize().height(); 574 int oh = e->oldSize().height();
573 int w = e->size().width(); 575 int w = e->size().width();
574 int h = e->size().height(); 576 int h = e->size().height();
575 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 577 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
576 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 578 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
577 uc = true; 579 uc = true;
578 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 580 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
579 } 581 }
580 mUpcomingWidth = e->size().width() ; 582 mUpcomingWidth = e->size().width() ;
581 if ( mBlockUpdating || uc ) { 583 if ( mBlockUpdating || uc ) {
582 mBlockUpdating = false; 584 mBlockUpdating = false;
583 //mAgenda->setMinimumSize(800 , 600 ); 585 //mAgenda->setMinimumSize(800 , 600 );
584 //qDebug("mAgenda->resize+++++++++++++++ "); 586 //qDebug("mAgenda->resize+++++++++++++++ ");
585 updateConfig(); 587 updateConfig();
586 //qDebug("KOAgendaView::Updating now possible "); 588 //qDebug("KOAgendaView::Updating now possible ");
587 } else 589 } else
588 createDayLabels(); 590 createDayLabels();
589 //qDebug("resizeEvent end "); 591 //qDebug("resizeEvent end ");
590 592
591} 593}
592void KOAgendaView::slotDaylabelClicked( int num ) 594void KOAgendaView::slotDaylabelClicked( int num )
593{ 595{
594 596
595 QDate firstDate = mSelectedDates.first(); 597 QDate firstDate = mSelectedDates.first();
596 if ( num == -1 ) 598 if ( num == -1 )
597 emit showDateView( 6, firstDate ); 599 emit showDateView( 6, firstDate );
598 else if (num >= 0 ) { 600 else if (num >= 0 ) {
599 if ( mSelectedDates.count() == 1) 601 if ( mSelectedDates.count() == 1)
600 emit showDateView( 9, firstDate.addDays( num ) ); 602 emit showDateView( 9, firstDate.addDays( num ) );
601 else 603 else
602 emit showDateView( 3, firstDate.addDays( num ) ); 604 emit showDateView( 3, firstDate.addDays( num ) );
603 } 605 }
604 else 606 else
605 showDateView( 10, firstDate.addDays(1) ); 607 showDateView( 10, firstDate.addDays(1) );
606} 608}
607 609
608KOAgendaButton* KOAgendaView::getNewDaylabel() 610KOAgendaButton* KOAgendaView::getNewDaylabel()
609{ 611{
610 612
611 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 613 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
612 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 614 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
613 mDayLabelsList.append( dayLabel ); 615 mDayLabelsList.append( dayLabel );
614 mLayoutDayLabels->addWidget(dayLabel); 616 mLayoutDayLabels->addWidget(dayLabel);
615 return dayLabel ; 617 return dayLabel ;
616} 618}
617 619