korganizer

multiagendaview.cpp

00001 /*
00002     Copyright (c) 2007 Volker Krause <vkrause@kde.org>
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #include "multiagendaview.h"
00020 
00021 #include "koagendaview.h"
00022 #include "koagenda.h"
00023 #include "koprefs.h"
00024 #include "timelabels.h"
00025 
00026 #include <libkcal/calendarresources.h>
00027 
00028 #include <kglobalsettings.h>
00029 
00030 #include <qlayout.h>
00031 #include <qvbox.h>
00032 #include <qobjectlist.h>
00033 #include <qheader.h>
00034 
00035 #define FOREACH_VIEW(av) \
00036 for(QValueList<KOAgendaView*>::ConstIterator it = mAgendaViews.constBegin(); \
00037   it != mAgendaViews.constEnd();) \
00038   for(KOAgendaView* av = (it != mAgendaViews.constEnd() ? (*it) : 0); \
00039       it != mAgendaViews.constEnd(); ++it, av = (*it)  )
00040 
00041 using namespace KOrg;
00042 
00043 MultiAgendaView::MultiAgendaView( Calendar * cal, CalendarView *calendarView,
00044                                  QWidget * parent, const char *name ) :
00045     AgendaView( cal, parent, name ),
00046     mSelectedAgendaView( 0 ),
00047     mLastMovedSplitter( 0 ),
00048     mUpdateOnShow( false ),
00049     mPendingChanges( true ),
00050     mCalendarView( calendarView )
00051 {
00052   QBoxLayout *topLevelLayout = new QHBoxLayout( this );
00053 
00054   QFontMetrics fm( font() );
00055   int topLabelHeight = 2 * fm.height() + fm.lineSpacing();
00056 
00057   QVBox *topSideBox = new QVBox( this );
00058   mLeftTopSpacer = new QWidget( topSideBox );
00059   mLeftTopSpacer->setFixedHeight( topLabelHeight );
00060   mLeftSplitter = new QSplitter( Qt::Vertical, topSideBox );
00061   mLeftSplitter->setOpaqueResize( KGlobalSettings::opaqueResize() );
00062   QLabel *label = new QLabel( i18n("All Day"), mLeftSplitter );
00063   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::WordBreak );
00064   QVBox *sideBox = new QVBox( mLeftSplitter );
00065   EventIndicator *eiSpacer = new EventIndicator( EventIndicator::Top, sideBox );
00066   eiSpacer->changeColumns( 0 );
00067   mTimeLabels = new TimeLabels( 24, sideBox );
00068   eiSpacer = new EventIndicator( EventIndicator::Bottom, sideBox );
00069   eiSpacer->changeColumns( 0 );
00070   mLeftBottomSpacer = new QWidget( topSideBox );
00071   topLevelLayout->addWidget( topSideBox );
00072 
00073   mScrollView = new QScrollView( this );
00074   mScrollView->setResizePolicy( QScrollView::Manual );
00075   mScrollView->setVScrollBarMode( QScrollView::AlwaysOff );
00076   mScrollView->setFrameShape( QFrame::NoFrame );
00077   topLevelLayout->addWidget( mScrollView, 100 );
00078   mTopBox = new QHBox( mScrollView->viewport() );
00079   mScrollView->addChild( mTopBox );
00080 
00081   topSideBox = new QVBox( this );
00082   mRightTopSpacer = new QWidget( topSideBox );
00083   mRightTopSpacer->setFixedHeight( topLabelHeight );
00084   mRightSplitter = new QSplitter( Qt::Vertical, topSideBox );
00085   mRightSplitter->setOpaqueResize( KGlobalSettings::opaqueResize() );
00086   new QWidget( mRightSplitter );
00087   sideBox = new QVBox( mRightSplitter );
00088   eiSpacer = new EventIndicator( EventIndicator::Top, sideBox );
00089   eiSpacer->setFixedHeight( eiSpacer->minimumHeight() );
00090   eiSpacer->changeColumns( 0 );
00091   mScrollBar = new QScrollBar( Qt::Vertical, sideBox );
00092   eiSpacer = new EventIndicator( EventIndicator::Bottom, sideBox );
00093   eiSpacer->setFixedHeight( eiSpacer->minimumHeight() );
00094   eiSpacer->changeColumns( 0 );
00095   mRightBottomSpacer = new QWidget( topSideBox );
00096   topLevelLayout->addWidget( topSideBox );
00097 
00098   recreateViews();
00099 }
00100 
00101 void MultiAgendaView::recreateViews()
00102 {
00103   if ( !mPendingChanges ) {
00104     return;
00105   }
00106 
00107   mPendingChanges = false;
00108 
00109   deleteViews();
00110 
00111   CalendarResources *calres = dynamic_cast<CalendarResources*>( calendar() );
00112   if ( !calres ) {
00113     // fallback to single-agenda
00114     KOAgendaView* av = new KOAgendaView( calendar(), mCalendarView, mTopBox );
00115     mAgendaViews.append( av );
00116     mAgendaWidgets.append( av );
00117     mSelectedAgendaView = av;
00118     av->show();
00119   } else {
00120     CalendarResourceManager *manager = calres->resourceManager();
00121     for ( CalendarResourceManager::ActiveIterator it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
00122       if ( (*it)->canHaveSubresources() ) {
00123         QStringList subResources = (*it)->subresources();
00124         for ( QStringList::ConstIterator subit = subResources.constBegin(); subit != subResources.constEnd(); ++subit ) {
00125           QString type = (*it)->subresourceType( *subit );
00126 
00127           if ( !(*it)->subresourceActive( *subit ) || (!type.isEmpty() && type != "event") ) {
00128             continue;
00129           }
00130 
00131           addView( (*it)->labelForSubresource( *subit ), *it, *subit );
00132         }
00133       } else {
00134         addView( (*it)->resourceName(), *it );
00135       }
00136     }
00137   }
00138 
00139   // no resources activated, so stop here to avoid crashing somewhere down the line, TODO: show a nice message instead
00140   if ( mAgendaViews.isEmpty() ) {
00141     return;
00142   }
00143 
00144   setupViews();
00145   QTimer::singleShot( 0, this, SLOT(slotResizeScrollView()) );
00146   mTimeLabels->updateConfig();
00147 
00148   connect( mTimeLabels->verticalScrollBar(), SIGNAL(valueChanged(int)),
00149            mScrollBar, SLOT(setValue(int)) );
00150   connect( mScrollBar, SIGNAL(valueChanged(int)),
00151            mTimeLabels, SLOT(positionChanged(int)) );
00152 
00153   installSplitterEventFilter( mLeftSplitter );
00154   installSplitterEventFilter( mRightSplitter );
00155 
00156   QValueList<int> sizes = KOGlobals::self()->config()->readIntListEntry( "Separator AgendaView" );
00157   if ( sizes.count() != 2 ) {
00158     sizes = mLeftSplitter->sizes();
00159   }
00160   FOREACH_VIEW( agenda ) {
00161     agenda->splitter()->setSizes( sizes );
00162   }
00163   mLeftSplitter->setSizes( sizes );
00164   mRightSplitter->setSizes( sizes );
00165 
00166   QTimer::singleShot( 0, this, SLOT(setupScrollBar()) );
00167 
00168   mTimeLabels->positionChanged();
00169 }
00170 
00171 void MultiAgendaView::deleteViews()
00172 {
00173   for ( QValueList<QWidget*>::ConstIterator it = mAgendaWidgets.constBegin();
00174         it != mAgendaWidgets.constEnd(); ++it ) {
00175     delete *it;
00176   }
00177   mAgendaViews.clear();
00178   mTimeLabels->setAgenda( 0 );
00179   mAgendaWidgets.clear();
00180   mLastMovedSplitter = 0;
00181   mSelectedAgendaView = 0;
00182 }
00183 
00184 void MultiAgendaView::setupViews()
00185 {
00186   FOREACH_VIEW( agenda ) {
00187     if ( !agenda->readOnly() ) {
00188       connect( agenda,
00189                SIGNAL(newEventSignal(ResourceCalendar *,const QString &)),
00190                SIGNAL(newEventSignal(ResourceCalendar *,const QString &)) );
00191       connect( agenda,
00192                SIGNAL(newEventSignal(ResourceCalendar *,const QString &,const QDate &)),
00193                SIGNAL(newEventSignal(ResourceCalendar *,const QString &,const QDate &)) );
00194       connect( agenda,
00195                SIGNAL(newEventSignal(ResourceCalendar *,const QString &,const QDateTime &)),
00196                SIGNAL(newEventSignal(ResourceCalendar *,const QString &,const QDateTime &)) );
00197       connect( agenda,
00198                SIGNAL(newEventSignal(ResourceCalendar *,const QString &,const QDateTime &,const QDateTime &)),
00199                SIGNAL(newEventSignal(ResourceCalendar *,const QString &,const QDateTime &,const QDateTime&)) );
00200 
00201       connect( agenda,
00202                SIGNAL(newTodoSignal(ResourceCalendar *,const QString &,const QDate &)),
00203                SIGNAL(newTodoSignal(ResourceCalendar *,const QString &,const QDate &)) );
00204 
00205       connect( agenda,
00206                SIGNAL(editIncidenceSignal(Incidence *,const QDate &)),
00207                SIGNAL(editIncidenceSignal(Incidence *,const QDate &)) );
00208       connect( agenda,
00209                SIGNAL(deleteIncidenceSignal(Incidence *)),
00210                SIGNAL(deleteIncidenceSignal(Incidence *)) );
00211       connect( agenda,
00212                SIGNAL(startMultiModify(const QString &)),
00213                SIGNAL(startMultiModify(const QString &)) );
00214       connect( agenda,
00215                SIGNAL(endMultiModify()),
00216                SIGNAL(endMultiModify()) );
00217 
00218       connect( agenda,
00219                SIGNAL(cutIncidenceSignal(Incidence*)),
00220                SIGNAL(cutIncidenceSignal(Incidence*)) );
00221       connect( agenda,
00222                SIGNAL(pasteIncidenceSignal()),
00223                SIGNAL(pasteIncidenceSignal()) );
00224       connect( agenda,
00225                SIGNAL(toggleAlarmSignal(Incidence*)),
00226                SIGNAL(toggleAlarmSignal(Incidence*)) );
00227       connect( agenda,
00228                SIGNAL(dissociateOccurrenceSignal(Incidence*, const QDate&)),
00229                SIGNAL(dissociateOccurrenceSignal(Incidence*, const QDate&)) );
00230       connect( agenda,
00231                SIGNAL(dissociateFutureOccurrenceSignal(Incidence*, const QDate&)),
00232                SIGNAL(dissociateFutureOccurrenceSignal(Incidence*, const QDate&)) );
00233     }
00234 
00235     connect( agenda,
00236              SIGNAL(copyIncidenceSignal(Incidence*)),
00237              SIGNAL(copyIncidenceSignal(Incidence*)) );
00238     connect( agenda,
00239              SIGNAL(showIncidenceSignal(Incidence *,const QDate &)),
00240              SIGNAL(showIncidenceSignal(Incidence *,const QDate &)) );
00241     connect( agenda,
00242              SIGNAL(incidenceSelected(Incidence *,const QDate &)),
00243              SIGNAL(incidenceSelected(Incidence *,const QDate &)) );
00244     connect( agenda,
00245              SIGNAL(incidenceSelected(Incidence*,const QDate &)),
00246              SLOT(slotSelectionChanged()) );
00247 
00248     connect( agenda,
00249              SIGNAL(timeSpanSelectionChanged()),
00250              SLOT(slotClearTimeSpanSelection()) );
00251 
00252     disconnect( agenda->agenda(),
00253                 SIGNAL(zoomView(const int,const QPoint&,const Qt::Orientation)),
00254                 agenda, 0 );
00255     connect( agenda->agenda(),
00256              SIGNAL(zoomView(const int,const QPoint&,const Qt::Orientation)),
00257              SLOT(zoomView(const int,const QPoint&,const Qt::Orientation)) );
00258   }
00259 
00260   KOAgenda *anAgenda = mAgendaViews.first()->agenda();
00261   connect( anAgenda, SIGNAL(lowerYChanged(int) ), SLOT(resizeSpacers(int)) );
00262 
00263   FOREACH_VIEW( agenda ) {
00264     agenda->readSettings();
00265   }
00266 
00267   int minWidth = 0;
00268   for ( QValueList<QWidget*>::ConstIterator it = mAgendaWidgets.constBegin(); it != mAgendaWidgets.constEnd(); ++it )
00269     minWidth = QMAX( minWidth, (*it)->minimumSizeHint().width() );
00270   for ( QValueList<QWidget*>::ConstIterator it = mAgendaWidgets.constBegin(); it != mAgendaWidgets.constEnd(); ++it )
00271     (*it)->setMinimumWidth( minWidth );
00272 }
00273 
00274 MultiAgendaView::~ MultiAgendaView()
00275 {
00276 }
00277 
00278 Incidence::List MultiAgendaView::selectedIncidences()
00279 {
00280   Incidence::List list;
00281   FOREACH_VIEW(agendaView) {
00282     list += agendaView->selectedIncidences();
00283   }
00284   return list;
00285 }
00286 
00287 DateList MultiAgendaView::selectedIncidenceDates()
00288 {
00289   DateList list;
00290   FOREACH_VIEW(agendaView) {
00291     list += agendaView->selectedIncidenceDates();
00292   }
00293   return list;
00294 }
00295 
00296 int MultiAgendaView::currentDateCount()
00297 {
00298   FOREACH_VIEW( agendaView )
00299     return agendaView->currentDateCount();
00300   return 0;
00301 }
00302 
00303 void MultiAgendaView::showDates(const QDate & start, const QDate & end)
00304 {
00305   mStartDate = start;
00306   mEndDate = end;
00307   recreateViews();
00308   FOREACH_VIEW( agendaView )
00309     agendaView->showDates( start, end );
00310 }
00311 
00312 void MultiAgendaView::showIncidences(const Incidence::List & incidenceList, const QDate &date)
00313 {
00314   FOREACH_VIEW( agendaView )
00315     agendaView->showIncidences( incidenceList, date );
00316 }
00317 
00318 void MultiAgendaView::updateView()
00319 {
00320   recreateViews();
00321   FOREACH_VIEW( agendaView )
00322     agendaView->updateView();
00323 }
00324 
00325 void MultiAgendaView::changeIncidenceDisplay(Incidence * incidence, int mode)
00326 {
00327   FOREACH_VIEW( agendaView )
00328     agendaView->changeIncidenceDisplay( incidence, mode );
00329 }
00330 
00331 int MultiAgendaView::maxDatesHint()
00332 {
00333   FOREACH_VIEW( agendaView )
00334     return agendaView->maxDatesHint();
00335   return 0;
00336 }
00337 
00338 void MultiAgendaView::slotSelectionChanged()
00339 {
00340   FOREACH_VIEW( agenda ) {
00341     if ( agenda != sender() )
00342       agenda->clearSelection();
00343   }
00344 }
00345 
00346 bool MultiAgendaView::eventDurationHint(QDateTime & startDt, QDateTime & endDt, bool & allDay)
00347 {
00348   FOREACH_VIEW( agenda ) {
00349     bool valid = agenda->eventDurationHint( startDt, endDt, allDay );
00350     if ( valid )
00351       return true;
00352   }
00353   return false;
00354 }
00355 
00356 void MultiAgendaView::slotClearTimeSpanSelection()
00357 {
00358   FOREACH_VIEW( agenda ) {
00359     if ( agenda != sender() )
00360       agenda->clearTimeSpanSelection();
00361   }
00362 }
00363 
00364 void MultiAgendaView::setTypeAheadReceiver(QObject * o)
00365 {
00366   FOREACH_VIEW( agenda )
00367     agenda->setTypeAheadReceiver( o );
00368 }
00369 
00370 void MultiAgendaView::finishTypeAhead()
00371 {
00372   FOREACH_VIEW( agenda )
00373     agenda->finishTypeAhead();
00374 }
00375 
00376 void MultiAgendaView::addView( const QString &label, ResourceCalendar *res, const QString &subRes )
00377 {
00378   bool readOnlyView = false;
00379 
00380   QVBox *box = new QVBox( mTopBox );
00381 
00382   // First, the calendar folder title
00383   QHeader *title = new QHeader( 1, box );
00384   title->setClickEnabled( false );
00385   title->setStretchEnabled( true );
00386   if ( res->readOnly() || !res->subresourceWritable( subRes ) ) {
00387     readOnlyView = true;
00388     title->setLabel( 0, QIconSet( KOGlobals::self()->smallIcon( "readonlyevent" ) ), label );
00389   } else {
00390     QColor resColor;
00391     if ( subRes.isEmpty() ) {
00392       resColor = *KOPrefs::instance()->resourceColor( res->identifier() );
00393     } else {
00394       resColor = *KOPrefs::instance()->resourceColor( subRes );
00395     }
00396     QFontMetrics fm = fontMetrics();
00397     QPixmap px( fm.height(), fm.height() );
00398     px.fill( resColor );
00399     title->setLabel( 0, QIconSet( px, QIconSet::Small ), label );
00400   }
00401 
00402   // Now, the sub agenda view
00403   KOAgendaView* av = new KOAgendaView( calendar(), mCalendarView, box, 0, true );
00404   av->setReadOnly( readOnlyView );
00405   av->setResource( res, subRes );
00406   av->setIncidenceChanger( mChanger );
00407   av->agenda()->setVScrollBarMode( QScrollView::AlwaysOff );
00408   mAgendaViews.append( av );
00409   mAgendaWidgets.append( box );
00410   box->show();
00411   mTimeLabels->setAgenda( av->agenda() );
00412 
00413   connect( av->agenda()->verticalScrollBar(), SIGNAL(valueChanged(int)),
00414            mTimeLabels, SLOT(positionChanged(int)) );
00415   connect( mTimeLabels->verticalScrollBar(), SIGNAL(valueChanged(int)),
00416            av, SLOT(setContentsPos(int)) );
00417 
00418   av->installEventFilter( this );
00419   installSplitterEventFilter( av->splitter() );
00420 }
00421 
00422 void MultiAgendaView::resizeEvent(QResizeEvent * ev)
00423 {
00424   resizeScrollView( ev->size() );
00425   AgendaView::resizeEvent( ev );
00426 }
00427 
00428 void MultiAgendaView::resizeScrollView(const QSize & size)
00429 {
00430   const int widgetWidth = size.width() - mLeftSplitter->width() - mScrollBar->width();
00431   int width = QMAX( mTopBox->sizeHint().width(), widgetWidth );
00432   int height = size.height();
00433   if ( width > widgetWidth ) {
00434     const int sbHeight = mScrollView->horizontalScrollBar()->height();
00435     height -= sbHeight;
00436     mLeftBottomSpacer->setFixedHeight( sbHeight );
00437     mRightBottomSpacer->setFixedHeight( sbHeight );
00438   } else {
00439     mLeftBottomSpacer->setFixedHeight( 0 );
00440     mRightBottomSpacer->setFixedHeight( 0 );
00441   }
00442   mScrollView->resizeContents( width, height );
00443   mTopBox->resize( width, height );
00444 }
00445 
00446 void MultiAgendaView::setIncidenceChanger(IncidenceChangerBase * changer)
00447 {
00448   AgendaView::setIncidenceChanger( changer );
00449   FOREACH_VIEW( agenda )
00450     agenda->setIncidenceChanger( changer );
00451 }
00452 
00453 void MultiAgendaView::updateConfig()
00454 {
00455   AgendaView::updateConfig();
00456   mTimeLabels->updateConfig();
00457   FOREACH_VIEW( agenda )
00458     agenda->updateConfig();
00459 }
00460 
00461 bool MultiAgendaView::eventFilter(QObject * obj, QEvent * event)
00462 {
00463   if ( obj->className() == QCString("QSplitterHandle") ) {
00464     // KDE4: not needed anymore, QSplitter has a moved signal there
00465     if ( (event->type() == QEvent::MouseMove && KGlobalSettings::opaqueResize())
00466            || event->type() == QEvent::MouseButtonRelease ) {
00467       FOREACH_VIEW( agenda ) {
00468         if ( agenda->splitter() == obj->parent() )
00469           mLastMovedSplitter = agenda->splitter();
00470       }
00471       if ( mLeftSplitter == obj->parent() )
00472         mLastMovedSplitter = mLeftSplitter;
00473       else if ( mRightSplitter == obj->parent() )
00474         mLastMovedSplitter = mRightSplitter;
00475       QTimer::singleShot( 0, this, SLOT(resizeSplitters()) );
00476     }
00477   }
00478 
00479   if ( obj->className() == QCString( "KOAgendaView" ) ) {
00480     if ( event->type() == QEvent::MouseButtonRelease ||
00481          event->type() == QEvent::MouseButtonPress ) {
00482       mSelectedAgendaView = (KOAgendaView *)obj;
00483     }
00484   }
00485 
00486   return AgendaView::eventFilter( obj, event );
00487 }
00488 
00489 KOAgendaView *MultiAgendaView::selectedAgendaView()
00490 {
00491   return mSelectedAgendaView;
00492 }
00493 
00494 void MultiAgendaView::resizeSplitters()
00495 {
00496   if ( !mLastMovedSplitter )
00497     mLastMovedSplitter = mAgendaViews.first()->splitter();
00498   FOREACH_VIEW( agenda ) {
00499     if ( agenda->splitter() == mLastMovedSplitter )
00500       continue;
00501     agenda->splitter()->setSizes( mLastMovedSplitter->sizes() );
00502   }
00503   if ( mLastMovedSplitter != mLeftSplitter )
00504     mLeftSplitter->setSizes( mLastMovedSplitter->sizes() );
00505   if ( mLastMovedSplitter != mRightSplitter )
00506     mRightSplitter->setSizes( mLastMovedSplitter->sizes() );
00507 }
00508 
00509 void MultiAgendaView::resizeSpacers( int newY )
00510 {
00511   // this slot is needed because the Agenda view's day labels frame height
00512   // can change depending if holidays are shown. When this happens, all
00513   // the widgets move down except the timelabels, so we need to change
00514   // the top spacer height accordingly to move the timelabels up/down.
00515   // kolab/issue2656
00516   Q_UNUSED( newY );
00517   QFontMetrics fm( font() );
00518   int topLabelHeight = mAgendaViews.first()->dayLabels()->height() +
00519                        fm.height() + mLeftSplitter->handleWidth();
00520   mLeftTopSpacer->setFixedHeight( topLabelHeight );
00521   mRightTopSpacer->setFixedHeight( topLabelHeight );
00522 }
00523 
00524 void MultiAgendaView::zoomView( const int delta, const QPoint & pos, const Qt::Orientation ori )
00525 {
00526   if ( ori == Qt::Vertical ) {
00527     if ( delta > 0 ) {
00528       if ( KOPrefs::instance()->mHourSize > 4 )
00529         KOPrefs::instance()->mHourSize--;
00530     } else {
00531       KOPrefs::instance()->mHourSize++;
00532     }
00533   }
00534 
00535   FOREACH_VIEW( agenda )
00536     agenda->zoomView( delta, pos, ori );
00537 
00538   mTimeLabels->updateConfig();
00539   mTimeLabels->positionChanged();
00540   mTimeLabels->repaint();
00541 }
00542 
00543 // KDE4: not needed, use existing QSplitter signals instead
00544 void MultiAgendaView::installSplitterEventFilter(QSplitter * splitter)
00545 {
00546   QObjectList *objlist = splitter->queryList( "QSplitterHandle" );
00547   // HACK: when not being visible, the splitter handle is sometimes not found
00548   // for unknown reasons, so trigger an update when we are shown again
00549   if ( objlist->count() == 0 && !isVisible() )
00550     mUpdateOnShow = true;
00551   QObjectListIt it( *objlist );
00552   QObject *obj;
00553   while ( (obj = it.current()) != 0 ) {
00554     obj->removeEventFilter( this );
00555     obj->installEventFilter( this );
00556     ++it;
00557   }
00558   delete objlist;
00559 }
00560 
00561 void MultiAgendaView::slotResizeScrollView()
00562 {
00563   resizeScrollView( size() );
00564 }
00565 
00566 void MultiAgendaView::show()
00567 {
00568   AgendaView::show();
00569   if ( mUpdateOnShow ) {
00570     mUpdateOnShow = false;
00571     mPendingChanges = true; // force a full view recreation
00572     showDates( mStartDate, mEndDate );
00573   }
00574 }
00575 
00576 void MultiAgendaView::resourcesChanged()
00577 {
00578   mPendingChanges = true;
00579 
00580   kdDebug() << "mAgendaViews.size is " << mAgendaViews.size()
00581             << "; mAgendaWidgets.size is " << mAgendaWidgets.size()
00582             << "; mSelectedAgendaView is " << mSelectedAgendaView
00583             << endl;
00584 
00585   if ( mSelectedAgendaView ) {
00586     ResourceCalendar *res = mSelectedAgendaView->resourceCalendar();
00587     if ( res ) {
00588       if ( res->canHaveSubresources() ) {
00589         QString subRes = mSelectedAgendaView->subResourceCalendar();
00590         if ( !res->subresourceWritable( subRes ) ||
00591              !res->subresourceActive( subRes ) ) {
00592           mSelectedAgendaView = 0;
00593         }
00594       } else {
00595         if ( res->readOnly() || !res->isActive() ) {
00596           mSelectedAgendaView = 0;
00597         }
00598       }
00599     } else {
00600       mSelectedAgendaView = 0;
00601     }
00602   }
00603 
00604   FOREACH_VIEW( agenda )
00605     agenda->resourcesChanged();
00606 }
00607 
00608 void MultiAgendaView::setupScrollBar()
00609 {
00610   if ( !mAgendaViews.isEmpty() && mAgendaViews.first()->agenda() ) {
00611     QScrollBar *scrollBar = mAgendaViews.first()->agenda()->verticalScrollBar();
00612     mScrollBar->setMinValue( scrollBar->minValue() );
00613     mScrollBar->setMaxValue( scrollBar->maxValue() );
00614     mScrollBar->setLineStep( scrollBar->lineStep() );
00615     mScrollBar->setPageStep( scrollBar->pageStep() );
00616     mScrollBar->setValue( scrollBar->value() );
00617   }
00618 }
00619 
00620 #include "multiagendaview.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys