-rw-r--r-- | korganizer/koagendaview.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 6428757..b5596d9 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -156,97 +156,132 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | |||
156 | cell++; | 156 | cell++; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | /** | 160 | /** |
161 | Calculates the minimum width. | 161 | Calculates the minimum width. |
162 | */ | 162 | */ |
163 | int TimeLabels::minimumWidth() const | 163 | int TimeLabels::minimumWidth() const |
164 | { | 164 | { |
165 | QFontMetrics fm = fontMetrics(); | 165 | QFontMetrics fm = fontMetrics(); |
166 | 166 | ||
167 | //TODO: calculate this value | 167 | //TODO: calculate this value |
168 | int borderWidth = 4; | 168 | int borderWidth = 4; |
169 | 169 | ||
170 | // the maximum width possible | 170 | // the maximum width possible |
171 | int width = fm.width("88:88x") + borderWidth; | 171 | int width = fm.width("88:88x") + borderWidth; |
172 | 172 | ||
173 | return width; | 173 | return width; |
174 | } | 174 | } |
175 | 175 | ||
176 | /** updates widget's internal state */ | 176 | /** updates widget's internal state */ |
177 | void TimeLabels::updateConfig() | 177 | void TimeLabels::updateConfig() |
178 | { | 178 | { |
179 | // set the font | 179 | // set the font |
180 | // config->setGroup("Fonts"); | 180 | // config->setGroup("Fonts"); |
181 | // QFont font = config->readFontEntry("TimeBar Font"); | 181 | // QFont font = config->readFontEntry("TimeBar Font"); |
182 | setFont(KOPrefs::instance()->mTimeBarFont); | 182 | setFont(KOPrefs::instance()->mTimeBarFont); |
183 | 183 | ||
184 | // update geometry restrictions based on new settings | 184 | // update geometry restrictions based on new settings |
185 | setFixedWidth(minimumWidth()); | 185 | setFixedWidth(minimumWidth()); |
186 | 186 | ||
187 | // update HourSize | 187 | // update HourSize |
188 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 188 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
189 | resizeContents(50,mRows * mCellHeight); | 189 | resizeContents(50,mRows * mCellHeight); |
190 | } | 190 | } |
191 | 191 | ||
192 | /** update time label positions */ | 192 | /** update time label positions */ |
193 | void TimeLabels::positionChanged() | 193 | void TimeLabels::positionChanged() |
194 | { | 194 | { |
195 | int adjustment = mAgenda->contentsY(); | 195 | int adjustment = mAgenda->contentsY(); |
196 | setContentsPos(0, adjustment); | 196 | setContentsPos(0, adjustment); |
197 | } | 197 | } |
198 | 198 | ||
199 | /** */ | 199 | /** */ |
200 | void TimeLabels::setAgenda(KOAgenda* agenda) | 200 | void TimeLabels::setAgenda(KOAgenda* agenda) |
201 | { | 201 | { |
202 | mAgenda = agenda; | 202 | mAgenda = agenda; |
203 | } | 203 | } |
204 | |||
205 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | ||
206 | { | ||
207 | mMouseDownY = e->pos().y(); | ||
208 | } | ||
209 | |||
210 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | ||
211 | { | ||
212 | int diff = mMouseDownY - e->pos().y(); | ||
213 | if ( diff < 10 && diff > -10 ) | ||
214 | return; | ||
215 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | ||
216 | if ( tSize < 4 ) | ||
217 | tSize = 4; | ||
218 | if ( tSize > 18 ) | ||
219 | tSize = 18; | ||
220 | tSize = (tSize-2)/2; | ||
221 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | ||
204 | 222 | ||
223 | } | ||
224 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | ||
225 | { | ||
226 | int diff = mMouseDownY - e->pos().y(); | ||
227 | if ( diff < 10 && diff > -10 ) | ||
228 | return; | ||
229 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | ||
230 | if ( tSize < 4 ) | ||
231 | tSize = 4; | ||
232 | if ( tSize > 18 ) | ||
233 | tSize = 18; | ||
234 | tSize = (tSize/2)*2; | ||
235 | if ( tSize == KOPrefs::instance()->mHourSize ) | ||
236 | return; | ||
237 | KOPrefs::instance()->mHourSize = tSize; | ||
238 | emit scaleChanged(); | ||
239 | } | ||
205 | 240 | ||
206 | /** This is called in response to repaint() */ | 241 | /** This is called in response to repaint() */ |
207 | void TimeLabels::paintEvent(QPaintEvent*) | 242 | void TimeLabels::paintEvent(QPaintEvent*) |
208 | { | 243 | { |
209 | 244 | ||
210 | // kdDebug() << "paintevent..." << endl; | 245 | // kdDebug() << "paintevent..." << endl; |
211 | // this is another hack! | 246 | // this is another hack! |
212 | // QPainter painter(this); | 247 | // QPainter painter(this); |
213 | //QString c | 248 | //QString c |
214 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 249 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
215 | } | 250 | } |
216 | 251 | ||
217 | //////////////////////////////////////////////////////////////////////////// | 252 | //////////////////////////////////////////////////////////////////////////// |
218 | 253 | ||
219 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 254 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
220 | : QFrame(parent,name) | 255 | : QFrame(parent,name) |
221 | { | 256 | { |
222 | mColumns = 1; | 257 | mColumns = 1; |
223 | mTopBox = 0; | 258 | mTopBox = 0; |
224 | mLocation = loc; | 259 | mLocation = loc; |
225 | mTopLayout = 0; | 260 | mTopLayout = 0; |
226 | mPaintWidget = 0; | 261 | mPaintWidget = 0; |
227 | mXOffset = 0; | 262 | mXOffset = 0; |
228 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 263 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
229 | else mPixmap = SmallIcon("1downarrow"); | 264 | else mPixmap = SmallIcon("1downarrow"); |
230 | mEnabled.resize(mColumns); | 265 | mEnabled.resize(mColumns); |
231 | if (mLocation == Top) | 266 | if (mLocation == Top) |
232 | setMaximumHeight(0); | 267 | setMaximumHeight(0); |
233 | else | 268 | else |
234 | setMinimumHeight(mPixmap.height()); | 269 | setMinimumHeight(mPixmap.height()); |
235 | } | 270 | } |
236 | 271 | ||
237 | EventIndicator::~EventIndicator() | 272 | EventIndicator::~EventIndicator() |
238 | { | 273 | { |
239 | } | 274 | } |
240 | 275 | ||
241 | void EventIndicator::drawContents(QPainter *p) | 276 | void EventIndicator::drawContents(QPainter *p) |
242 | { | 277 | { |
243 | 278 | ||
244 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 279 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
245 | KDGanttSplitterHandle* han = 0; | 280 | KDGanttSplitterHandle* han = 0; |
246 | if ( mPaintWidget ) | 281 | if ( mPaintWidget ) |
247 | han = mPaintWidget->firstHandle(); | 282 | han = mPaintWidget->firstHandle(); |
248 | if ( ! han ) { | 283 | if ( ! han ) { |
249 | int i; | 284 | int i; |
250 | for(i=0;i<mColumns;++i) { | 285 | for(i=0;i<mColumns;++i) { |
251 | if (mEnabled[i]) { | 286 | if (mEnabled[i]) { |
252 | int cellWidth = contentsRect().right()/mColumns; | 287 | int cellWidth = contentsRect().right()/mColumns; |
@@ -365,96 +400,98 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
365 | mAllDayFrame = new QHBox(mSplitterAgenda); | 400 | mAllDayFrame = new QHBox(mSplitterAgenda); |
366 | mAllDayFrame->setFocusPolicy(NoFocus); | 401 | mAllDayFrame->setFocusPolicy(NoFocus); |
367 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 402 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
368 | agendaFrame->setFocusPolicy(NoFocus); | 403 | agendaFrame->setFocusPolicy(NoFocus); |
369 | 404 | ||
370 | #endif | 405 | #endif |
371 | 406 | ||
372 | // Create all-day agenda widget | 407 | // Create all-day agenda widget |
373 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 408 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
374 | 409 | ||
375 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 410 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
376 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 411 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
377 | int widebut = mExpandButton->sizeHint().width(); | 412 | int widebut = mExpandButton->sizeHint().width(); |
378 | if ( QApplication::desktop()->width() < 480 ) | 413 | if ( QApplication::desktop()->width() < 480 ) |
379 | widebut = widebut*2; | 414 | widebut = widebut*2; |
380 | else | 415 | else |
381 | widebut = (widebut*3) / 2; | 416 | widebut = (widebut*3) / 2; |
382 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 417 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
383 | // QSizePolicy::Fixed ) ); | 418 | // QSizePolicy::Fixed ) ); |
384 | mExpandButton->setFixedSize( widebut, widebut); | 419 | mExpandButton->setFixedSize( widebut, widebut); |
385 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 420 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
386 | mExpandButton->setFocusPolicy(NoFocus); | 421 | mExpandButton->setFocusPolicy(NoFocus); |
387 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 422 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
388 | mAllDayAgenda->setFocusPolicy(NoFocus); | 423 | mAllDayAgenda->setFocusPolicy(NoFocus); |
389 | QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); | 424 | QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); |
390 | 425 | ||
391 | // Create event context menu for all day agenda | 426 | // Create event context menu for all day agenda |
392 | mAllDayAgendaPopup = eventPopup(); | 427 | mAllDayAgendaPopup = eventPopup(); |
393 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 428 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
394 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 429 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
395 | 430 | ||
396 | // Create agenda frame | 431 | // Create agenda frame |
397 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); | 432 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); |
398 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 433 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
399 | 434 | ||
400 | // create event indicator bars | 435 | // create event indicator bars |
401 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 436 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
402 | agendaLayout->addWidget(mEventIndicatorTop,0,1); | 437 | agendaLayout->addWidget(mEventIndicatorTop,0,1); |
403 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 438 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
404 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 439 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
405 | agendaFrame); | 440 | agendaFrame); |
406 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); | 441 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); |
407 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 442 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
408 | agendaLayout->addWidget(dummyAgendaRight,0,2); | 443 | agendaLayout->addWidget(dummyAgendaRight,0,2); |
409 | 444 | ||
410 | // Create time labels | 445 | // Create time labels |
411 | mTimeLabels = new TimeLabels(24,agendaFrame); | 446 | mTimeLabels = new TimeLabels(24,agendaFrame); |
412 | agendaLayout->addWidget(mTimeLabels,1,0); | 447 | agendaLayout->addWidget(mTimeLabels,1,0); |
448 | connect(mTimeLabels,SIGNAL( scaleChanged()), | ||
449 | this,SLOT(updateConfig())); | ||
413 | 450 | ||
414 | // Create agenda | 451 | // Create agenda |
415 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 452 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
416 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); | 453 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); |
417 | agendaLayout->setColStretch(1,1); | 454 | agendaLayout->setColStretch(1,1); |
418 | mAgenda->setFocusPolicy(NoFocus); | 455 | mAgenda->setFocusPolicy(NoFocus); |
419 | // Create event context menu for agenda | 456 | // Create event context menu for agenda |
420 | mAgendaPopup = eventPopup(); | 457 | mAgendaPopup = eventPopup(); |
421 | 458 | ||
422 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 459 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
423 | i18n("Toggle Alarm"),mAgenda, | 460 | i18n("Toggle Alarm"),mAgenda, |
424 | SLOT(popupAlarm()),true); | 461 | SLOT(popupAlarm()),true); |
425 | 462 | ||
426 | 463 | ||
427 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 464 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
428 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 465 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
429 | 466 | ||
430 | // make connections between dependent widgets | 467 | // make connections between dependent widgets |
431 | mTimeLabels->setAgenda(mAgenda); | 468 | mTimeLabels->setAgenda(mAgenda); |
432 | 469 | ||
433 | // Update widgets to reflect user preferences | 470 | // Update widgets to reflect user preferences |
434 | // updateConfig(); | 471 | // updateConfig(); |
435 | 472 | ||
436 | // createDayLabels(); | 473 | // createDayLabels(); |
437 | 474 | ||
438 | // these blank widgets make the All Day Event box line up with the agenda | 475 | // these blank widgets make the All Day Event box line up with the agenda |
439 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 476 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
440 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 477 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
441 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 478 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
442 | 479 | ||
443 | // Scrolling | 480 | // Scrolling |
444 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 481 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
445 | mTimeLabels, SLOT(positionChanged())); | 482 | mTimeLabels, SLOT(positionChanged())); |
446 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 483 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
447 | SLOT(setContentsPos(int))); | 484 | SLOT(setContentsPos(int))); |
448 | 485 | ||
449 | // Create/Show/Edit/Delete Event | 486 | // Create/Show/Edit/Delete Event |
450 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 487 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
451 | SLOT(newEvent(int,int))); | 488 | SLOT(newEvent(int,int))); |
452 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 489 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
453 | SLOT(newEvent(int,int,int,int))); | 490 | SLOT(newEvent(int,int,int,int))); |
454 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 491 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
455 | SLOT(newEventAllDay(int,int))); | 492 | SLOT(newEventAllDay(int,int))); |
456 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 493 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
457 | SLOT(newEventAllDay(int,int))); | 494 | SLOT(newEventAllDay(int,int))); |
458 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 495 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
459 | SLOT(newTimeSpanSelected(int,int,int,int))); | 496 | SLOT(newTimeSpanSelected(int,int,int,int))); |
460 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 497 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |