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