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 <tqlayout.h> 00031 #include <tqvbox.h> 00032 #include <tqobjectlist.h> 00033 #include <tqheader.h> 00034 00035 #define FOREACH_VIEW(av) \ 00036 for(TQValueList<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 TQWidget * 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 TQBoxLayout *topLevelLayout = new TQHBoxLayout( this ); 00053 00054 TQFontMetrics fm( font() ); 00055 int topLabelHeight = 2 * fm.height() + fm.lineSpacing(); 00056 00057 TQVBox *topSideBox = new TQVBox( this ); 00058 mLeftTopSpacer = new TQWidget( topSideBox ); 00059 mLeftTopSpacer->setFixedHeight( topLabelHeight ); 00060 mLeftSplitter = new TQSplitter( Qt::Vertical, topSideBox ); 00061 mLeftSplitter->setOpaqueResize( KGlobalSettings::opaqueResize() ); 00062 TQLabel *label = new TQLabel( i18n("All Day"), mLeftSplitter ); 00063 label->setAlignment( TQt::AlignRight | TQt::AlignVCenter | TQt::WordBreak ); 00064 TQVBox *sideBox = new TQVBox( 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 TQWidget( topSideBox ); 00071 topLevelLayout->addWidget( topSideBox ); 00072 00073 mScrollView = new TQScrollView( this ); 00074 mScrollView->setResizePolicy( TQScrollView::Manual ); 00075 mScrollView->setVScrollBarMode( TQScrollView::AlwaysOff ); 00076 mScrollView->setFrameShape( TQFrame::NoFrame ); 00077 topLevelLayout->addWidget( mScrollView, 100 ); 00078 mTopBox = new TQHBox( mScrollView->viewport() ); 00079 mScrollView->addChild( mTopBox ); 00080 00081 topSideBox = new TQVBox( this ); 00082 mRightTopSpacer = new TQWidget( topSideBox ); 00083 mRightTopSpacer->setFixedHeight( topLabelHeight ); 00084 mRightSplitter = new TQSplitter( Qt::Vertical, topSideBox ); 00085 mRightSplitter->setOpaqueResize( KGlobalSettings::opaqueResize() ); 00086 new TQWidget( mRightSplitter ); 00087 sideBox = new TQVBox( mRightSplitter ); 00088 eiSpacer = new EventIndicator( EventIndicator::Top, sideBox ); 00089 eiSpacer->setFixedHeight( eiSpacer->minimumHeight() ); 00090 eiSpacer->changeColumns( 0 ); 00091 mScrollBar = new TQScrollBar( Qt::Vertical, sideBox ); 00092 eiSpacer = new EventIndicator( EventIndicator::Bottom, sideBox ); 00093 eiSpacer->setFixedHeight( eiSpacer->minimumHeight() ); 00094 eiSpacer->changeColumns( 0 ); 00095 mRightBottomSpacer = new TQWidget( 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 TQStringList subResources = (*it)->subresources(); 00124 for ( TQStringList::ConstIterator subit = subResources.constBegin(); subit != subResources.constEnd(); ++subit ) { 00125 TQString 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 TQTimer::singleShot( 0, this, TQT_SLOT(slotResizeScrollView()) ); 00146 mTimeLabels->updateConfig(); 00147 00148 connect( mTimeLabels->verticalScrollBar(), TQT_SIGNAL(valueChanged(int)), 00149 mScrollBar, TQT_SLOT(setValue(int)) ); 00150 connect( mScrollBar, TQT_SIGNAL(valueChanged(int)), 00151 mTimeLabels, TQT_SLOT(positionChanged(int)) ); 00152 00153 installSplitterEventFilter( mLeftSplitter ); 00154 installSplitterEventFilter( mRightSplitter ); 00155 00156 TQValueList<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 TQTimer::singleShot( 0, this, TQT_SLOT(setupScrollBar()) ); 00167 00168 mTimeLabels->positionChanged(); 00169 } 00170 00171 void MultiAgendaView::deleteViews() 00172 { 00173 for ( TQValueList<TQWidget*>::ConstIterator it = mAgendaWidgets.constBegin(); 00174 it != mAgendaWidgets.constEnd(); ++it ) { 00175 delete *it; 00176 } 00177 mAgendaViews.clear(); 00178 mAgendaWidgets.clear(); 00179 mLastMovedSplitter = 0; 00180 mSelectedAgendaView = 0; 00181 } 00182 00183 void MultiAgendaView::setupViews() 00184 { 00185 FOREACH_VIEW( agenda ) { 00186 if ( !agenda->readOnly() ) { 00187 connect( agenda, 00188 TQT_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &)), 00189 TQT_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &)) ); 00190 connect( agenda, 00191 TQT_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &,const TQDate &)), 00192 TQT_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &,const TQDate &)) ); 00193 connect( agenda, 00194 TQT_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &,const TQDateTime &)), 00195 TQT_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &,const TQDateTime &)) ); 00196 connect( agenda, 00197 TQT_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &,const TQDateTime &,const TQDateTime &)), 00198 TQT_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &,const TQDateTime &,const TQDateTime&)) ); 00199 00200 connect( agenda, 00201 TQT_SIGNAL(newTodoSignal(ResourceCalendar *,const TQString &,const TQDate &)), 00202 TQT_SIGNAL(newTodoSignal(ResourceCalendar *,const TQString &,const TQDate &)) ); 00203 00204 connect( agenda, 00205 TQT_SIGNAL(editIncidenceSignal(Incidence *,const TQDate &)), 00206 TQT_SIGNAL(editIncidenceSignal(Incidence *,const TQDate &)) ); 00207 connect( agenda, 00208 TQT_SIGNAL(deleteIncidenceSignal(Incidence *)), 00209 TQT_SIGNAL(deleteIncidenceSignal(Incidence *)) ); 00210 connect( agenda, 00211 TQT_SIGNAL(startMultiModify(const TQString &)), 00212 TQT_SIGNAL(startMultiModify(const TQString &)) ); 00213 connect( agenda, 00214 TQT_SIGNAL(endMultiModify()), 00215 TQT_SIGNAL(endMultiModify()) ); 00216 00217 connect( agenda, 00218 TQT_SIGNAL(cutIncidenceSignal(Incidence*)), 00219 TQT_SIGNAL(cutIncidenceSignal(Incidence*)) ); 00220 connect( agenda, 00221 TQT_SIGNAL(pasteIncidenceSignal()), 00222 TQT_SIGNAL(pasteIncidenceSignal()) ); 00223 connect( agenda, 00224 TQT_SIGNAL(toggleAlarmSignal(Incidence*)), 00225 TQT_SIGNAL(toggleAlarmSignal(Incidence*)) ); 00226 connect( agenda, 00227 TQT_SIGNAL(dissociateOccurrenceSignal(Incidence*, const TQDate&)), 00228 TQT_SIGNAL(dissociateOccurrenceSignal(Incidence*, const TQDate&)) ); 00229 connect( agenda, 00230 TQT_SIGNAL(dissociateFutureOccurrenceSignal(Incidence*, const TQDate&)), 00231 TQT_SIGNAL(dissociateFutureOccurrenceSignal(Incidence*, const TQDate&)) ); 00232 } 00233 00234 connect( agenda, 00235 TQT_SIGNAL(copyIncidenceSignal(Incidence*)), 00236 TQT_SIGNAL(copyIncidenceSignal(Incidence*)) ); 00237 connect( agenda, 00238 TQT_SIGNAL(showIncidenceSignal(Incidence *,const TQDate &)), 00239 TQT_SIGNAL(showIncidenceSignal(Incidence *,const TQDate &)) ); 00240 connect( agenda, 00241 TQT_SIGNAL(incidenceSelected(Incidence *,const TQDate &)), 00242 TQT_SIGNAL(incidenceSelected(Incidence *,const TQDate &)) ); 00243 connect( agenda, 00244 TQT_SIGNAL(incidenceSelected(Incidence*,const TQDate &)), 00245 TQT_SLOT(slotSelectionChanged()) ); 00246 00247 connect( agenda, 00248 TQT_SIGNAL(timeSpanSelectionChanged()), 00249 TQT_SLOT(slotClearTimeSpanSelection()) ); 00250 00251 disconnect( agenda->agenda(), 00252 TQT_SIGNAL(zoomView(const int,const TQPoint&,const Qt::Orientation)), 00253 agenda, 0 ); 00254 connect( agenda->agenda(), 00255 TQT_SIGNAL(zoomView(const int,const TQPoint&,const Qt::Orientation)), 00256 TQT_SLOT(zoomView(const int,const TQPoint&,const Qt::Orientation)) ); 00257 } 00258 00259 KOAgenda *anAgenda = mAgendaViews.first()->agenda(); 00260 connect( anAgenda, TQT_SIGNAL(lowerYChanged(int) ), TQT_SLOT(resizeSpacers(int)) ); 00261 00262 FOREACH_VIEW( agenda ) { 00263 agenda->readSettings(); 00264 } 00265 00266 int minWidth = 0; 00267 for ( TQValueList<TQWidget*>::ConstIterator it = mAgendaWidgets.constBegin(); it != mAgendaWidgets.constEnd(); ++it ) 00268 minWidth = TQMAX( minWidth, (*it)->minimumSizeHint().width() ); 00269 for ( TQValueList<TQWidget*>::ConstIterator it = mAgendaWidgets.constBegin(); it != mAgendaWidgets.constEnd(); ++it ) 00270 (*it)->setMinimumWidth( minWidth ); 00271 } 00272 00273 MultiAgendaView::~ MultiAgendaView() 00274 { 00275 } 00276 00277 Incidence::List MultiAgendaView::selectedIncidences() 00278 { 00279 Incidence::List list; 00280 FOREACH_VIEW(agendaView) { 00281 list += agendaView->selectedIncidences(); 00282 } 00283 return list; 00284 } 00285 00286 DateList MultiAgendaView::selectedIncidenceDates() 00287 { 00288 DateList list; 00289 FOREACH_VIEW(agendaView) { 00290 list += agendaView->selectedIncidenceDates(); 00291 } 00292 return list; 00293 } 00294 00295 int MultiAgendaView::currentDateCount() 00296 { 00297 FOREACH_VIEW( agendaView ) 00298 return agendaView->currentDateCount(); 00299 return 0; 00300 } 00301 00302 void MultiAgendaView::showDates(const TQDate & start, const TQDate & end) 00303 { 00304 mStartDate = start; 00305 mEndDate = end; 00306 recreateViews(); 00307 FOREACH_VIEW( agendaView ) 00308 agendaView->showDates( start, end ); 00309 } 00310 00311 void MultiAgendaView::showIncidences(const Incidence::List & incidenceList, const TQDate &date) 00312 { 00313 FOREACH_VIEW( agendaView ) 00314 agendaView->showIncidences( incidenceList, date ); 00315 } 00316 00317 void MultiAgendaView::updateView() 00318 { 00319 recreateViews(); 00320 FOREACH_VIEW( agendaView ) 00321 agendaView->updateView(); 00322 } 00323 00324 void MultiAgendaView::changeIncidenceDisplay(Incidence * incidence, int mode) 00325 { 00326 FOREACH_VIEW( agendaView ) 00327 agendaView->changeIncidenceDisplay( incidence, mode ); 00328 } 00329 00330 int MultiAgendaView::maxDatesHint() 00331 { 00332 FOREACH_VIEW( agendaView ) 00333 return agendaView->maxDatesHint(); 00334 return 0; 00335 } 00336 00337 void MultiAgendaView::slotSelectionChanged() 00338 { 00339 FOREACH_VIEW( agenda ) { 00340 if ( agenda != sender() ) 00341 agenda->clearSelection(); 00342 } 00343 } 00344 00345 bool MultiAgendaView::eventDurationHint(TQDateTime & startDt, TQDateTime & endDt, bool & allDay) 00346 { 00347 FOREACH_VIEW( agenda ) { 00348 bool valid = agenda->eventDurationHint( startDt, endDt, allDay ); 00349 if ( valid ) 00350 return true; 00351 } 00352 return false; 00353 } 00354 00355 void MultiAgendaView::slotClearTimeSpanSelection() 00356 { 00357 FOREACH_VIEW( agenda ) { 00358 if ( agenda != sender() ) 00359 agenda->clearTimeSpanSelection(); 00360 } 00361 } 00362 00363 void MultiAgendaView::setTypeAheadReceiver(TQObject * o) 00364 { 00365 FOREACH_VIEW( agenda ) 00366 agenda->setTypeAheadReceiver( o ); 00367 } 00368 00369 void MultiAgendaView::finishTypeAhead() 00370 { 00371 FOREACH_VIEW( agenda ) 00372 agenda->finishTypeAhead(); 00373 } 00374 00375 void MultiAgendaView::addView( const TQString &label, ResourceCalendar *res, const TQString &subRes ) 00376 { 00377 bool readOnlyView = false; 00378 00379 TQVBox *box = new TQVBox( mTopBox ); 00380 00381 // First, the calendar folder title 00382 TQHeader *title = new TQHeader( 1, box ); 00383 title->setClickEnabled( false ); 00384 title->setStretchEnabled( true ); 00385 if ( res->readOnly() || !res->subresourceWritable( subRes ) ) { 00386 readOnlyView = true; 00387 title->setLabel( 0, TQIconSet( KOGlobals::self()->smallIcon( "readonlyevent" ) ), label ); 00388 } else { 00389 TQColor resColor; 00390 if ( subRes.isEmpty() ) { 00391 resColor = *KOPrefs::instance()->resourceColor( res->identifier() ); 00392 } else { 00393 resColor = *KOPrefs::instance()->resourceColor( subRes ); 00394 } 00395 TQFontMetrics fm = fontMetrics(); 00396 TQPixmap px( fm.height(), fm.height() ); 00397 px.fill( resColor ); 00398 title->setLabel( 0, TQIconSet( px, TQIconSet::Small ), label ); 00399 } 00400 00401 // Now, the sub agenda view 00402 KOAgendaView* av = new KOAgendaView( calendar(), mCalendarView, box, 0, true ); 00403 av->setReadOnly( readOnlyView ); 00404 av->setResource( res, subRes ); 00405 av->setIncidenceChanger( mChanger ); 00406 av->agenda()->setVScrollBarMode( TQScrollView::AlwaysOff ); 00407 mAgendaViews.append( av ); 00408 mAgendaWidgets.append( box ); 00409 box->show(); 00410 mTimeLabels->setAgenda( av->agenda() ); 00411 00412 connect( av->agenda()->verticalScrollBar(), TQT_SIGNAL(valueChanged(int)), 00413 mTimeLabels, TQT_SLOT(positionChanged(int)) ); 00414 connect( mTimeLabels->verticalScrollBar(), TQT_SIGNAL(valueChanged(int)), 00415 av, TQT_SLOT(setContentsPos(int)) ); 00416 00417 av->installEventFilter( this ); 00418 installSplitterEventFilter( av->splitter() ); 00419 } 00420 00421 void MultiAgendaView::resizeEvent(TQResizeEvent * ev) 00422 { 00423 resizeScrollView( ev->size() ); 00424 AgendaView::resizeEvent( ev ); 00425 } 00426 00427 void MultiAgendaView::resizeScrollView(const TQSize & size) 00428 { 00429 const int widgetWidth = size.width() - mTimeLabels->width() - mScrollBar->width(); 00430 int width = TQMAX( mTopBox->sizeHint().width(), widgetWidth ); 00431 int height = size.height(); 00432 if ( width > widgetWidth ) { 00433 const int sbHeight = mScrollView->horizontalScrollBar()->height(); 00434 height -= sbHeight; 00435 mLeftBottomSpacer->setFixedHeight( sbHeight ); 00436 mRightBottomSpacer->setFixedHeight( sbHeight ); 00437 } else { 00438 mLeftBottomSpacer->setFixedHeight( 0 ); 00439 mRightBottomSpacer->setFixedHeight( 0 ); 00440 } 00441 mScrollView->resizeContents( width, height ); 00442 mTopBox->resize( width, height ); 00443 } 00444 00445 void MultiAgendaView::setIncidenceChanger(IncidenceChangerBase * changer) 00446 { 00447 AgendaView::setIncidenceChanger( changer ); 00448 FOREACH_VIEW( agenda ) 00449 agenda->setIncidenceChanger( changer ); 00450 } 00451 00452 void MultiAgendaView::updateConfig() 00453 { 00454 AgendaView::updateConfig(); 00455 mTimeLabels->updateConfig(); 00456 FOREACH_VIEW( agenda ) 00457 agenda->updateConfig(); 00458 } 00459 00460 bool MultiAgendaView::eventFilter(TQObject * obj, TQEvent * event) 00461 { 00462 if ( obj->className() == TQCString(TQSPLITTERHANDLE_OBJECT_NAME_STRING) ) { 00463 // KDE4: not needed anymore, TQSplitter has a moved signal there 00464 if ( (event->type() == TQEvent::MouseMove && KGlobalSettings::opaqueResize()) 00465 || event->type() == TQEvent::MouseButtonRelease ) { 00466 FOREACH_VIEW( agenda ) { 00467 if ( TQT_BASE_OBJECT(agenda->splitter()) == TQT_BASE_OBJECT(obj->parent()) ) 00468 mLastMovedSplitter = agenda->splitter(); 00469 } 00470 if ( TQT_BASE_OBJECT(mLeftSplitter )== TQT_BASE_OBJECT(obj->parent()) ) 00471 mLastMovedSplitter = mLeftSplitter; 00472 else if ( TQT_BASE_OBJECT(mRightSplitter) == TQT_BASE_OBJECT(obj->parent()) ) 00473 mLastMovedSplitter = mRightSplitter; 00474 TQTimer::singleShot( 0, this, TQT_SLOT(resizeSplitters()) ); 00475 } 00476 } 00477 00478 if ( obj->className() == TQCString( "KOAgendaView" ) ) { 00479 if ( event->type() == TQEvent::MouseButtonRelease || 00480 event->type() == TQEvent::MouseButtonPress ) { 00481 mSelectedAgendaView = (KOAgendaView *)obj; 00482 } 00483 } 00484 00485 return AgendaView::eventFilter( obj, event ); 00486 } 00487 00488 KOAgendaView *MultiAgendaView::selectedAgendaView() 00489 { 00490 return mSelectedAgendaView; 00491 } 00492 00493 void MultiAgendaView::resizeSplitters() 00494 { 00495 if ( !mLastMovedSplitter ) 00496 mLastMovedSplitter = mAgendaViews.first()->splitter(); 00497 FOREACH_VIEW( agenda ) { 00498 if ( agenda->splitter() == mLastMovedSplitter ) 00499 continue; 00500 agenda->splitter()->setSizes( mLastMovedSplitter->sizes() ); 00501 } 00502 if ( mLastMovedSplitter != mLeftSplitter ) 00503 mLeftSplitter->setSizes( mLastMovedSplitter->sizes() ); 00504 if ( mLastMovedSplitter != mRightSplitter ) 00505 mRightSplitter->setSizes( mLastMovedSplitter->sizes() ); 00506 } 00507 00508 void MultiAgendaView::resizeSpacers( int newY ) 00509 { 00510 // this slot is needed because the Agenda view's day labels frame height 00511 // can change depending if holidays are shown. When this happens, all 00512 // the widgets move down except the timelabels, so we need to change 00513 // the top spacer height accordingly to move the timelabels up/down. 00514 // kolab/issue2656 00515 Q_UNUSED( newY ); 00516 TQFontMetrics fm( font() ); 00517 int topLabelHeight = mAgendaViews.first()->dayLabels()->height() + 00518 fm.height() + mLeftSplitter->handleWidth(); 00519 mLeftTopSpacer->setFixedHeight( topLabelHeight ); 00520 mRightTopSpacer->setFixedHeight( topLabelHeight ); 00521 } 00522 00523 void MultiAgendaView::zoomView( const int delta, const TQPoint & pos, const Qt::Orientation ori ) 00524 { 00525 if ( ori == Qt::Vertical ) { 00526 if ( delta > 0 ) { 00527 if ( KOPrefs::instance()->mHourSize > 4 ) 00528 KOPrefs::instance()->mHourSize--; 00529 } else { 00530 KOPrefs::instance()->mHourSize++; 00531 } 00532 } 00533 00534 FOREACH_VIEW( agenda ) 00535 agenda->zoomView( delta, pos, ori ); 00536 00537 mTimeLabels->updateConfig(); 00538 mTimeLabels->positionChanged(); 00539 mTimeLabels->repaint(); 00540 } 00541 00542 // KDE4: not needed, use existing TQSplitter signals instead 00543 void MultiAgendaView::installSplitterEventFilter(TQSplitter * splitter) 00544 { 00545 TQObjectList *objlist = splitter->queryList( TQSPLITTERHANDLE_OBJECT_NAME_STRING ); 00546 // HACK: when not being visible, the splitter handle is sometimes not found 00547 // for unknown reasons, so trigger an update when we are shown again 00548 if ( objlist->count() == 0 && !isVisible() ) 00549 mUpdateOnShow = true; 00550 TQObjectListIt it( *objlist ); 00551 TQObject *obj; 00552 while ( (obj = it.current()) != 0 ) { 00553 obj->removeEventFilter( this ); 00554 obj->installEventFilter( this ); 00555 ++it; 00556 } 00557 delete objlist; 00558 } 00559 00560 void MultiAgendaView::slotResizeScrollView() 00561 { 00562 resizeScrollView( size() ); 00563 } 00564 00565 void MultiAgendaView::show() 00566 { 00567 AgendaView::show(); 00568 if ( mUpdateOnShow ) { 00569 mUpdateOnShow = false; 00570 mPendingChanges = true; // force a full view recreation 00571 showDates( mStartDate, mEndDate ); 00572 } 00573 } 00574 00575 void MultiAgendaView::resourcesChanged() 00576 { 00577 mPendingChanges = true; 00578 00579 kdDebug() << "mAgendaViews.size is " << mAgendaViews.size() 00580 << "; mAgendaWidgets.size is " << mAgendaWidgets.size() 00581 << "; mSelectedAgendaView is " << mSelectedAgendaView 00582 << endl; 00583 00584 if ( mSelectedAgendaView ) { 00585 ResourceCalendar *res = mSelectedAgendaView->resourceCalendar(); 00586 if ( res ) { 00587 if ( res->canHaveSubresources() ) { 00588 TQString subRes = mSelectedAgendaView->subResourceCalendar(); 00589 if ( !res->subresourceWritable( subRes ) || 00590 !res->subresourceActive( subRes ) ) { 00591 mSelectedAgendaView = 0; 00592 } 00593 } else { 00594 if ( res->readOnly() || !res->isActive() ) { 00595 mSelectedAgendaView = 0; 00596 } 00597 } 00598 } else { 00599 mSelectedAgendaView = 0; 00600 } 00601 } 00602 00603 FOREACH_VIEW( agenda ) 00604 agenda->resourcesChanged(); 00605 } 00606 00607 void MultiAgendaView::setupScrollBar() 00608 { 00609 if ( !mAgendaViews.isEmpty() && mAgendaViews.first()->agenda() ) { 00610 TQScrollBar *scrollBar = mAgendaViews.first()->agenda()->verticalScrollBar(); 00611 mScrollBar->setMinValue( scrollBar->minValue() ); 00612 mScrollBar->setMaxValue( scrollBar->maxValue() ); 00613 mScrollBar->setLineStep( scrollBar->lineStep() ); 00614 mScrollBar->setPageStep( scrollBar->pageStep() ); 00615 mScrollBar->setValue( scrollBar->value() ); 00616 } 00617 } 00618 00619 #include "multiagendaview.moc"