korganizer

multiagendaview.cpp
1 /*
2  Copyright (c) 2007 Volker Krause <vkrause@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
19 #include "multiagendaview.h"
20 
21 #include "koagendaview.h"
22 #include "koagenda.h"
23 #include "koprefs.h"
24 #include "timelabels.h"
25 
27 
28 #include <tdeglobalsettings.h>
29 
30 #include <tqlayout.h>
31 #include <tqvbox.h>
32 #include <tqobjectlist.h>
33 #include <tqheader.h>
34 
35 #define FOREACH_VIEW(av) \
36 for(TQValueList<KOAgendaView*>::ConstIterator it = mAgendaViews.constBegin(); \
37  it != mAgendaViews.constEnd();) \
38  for(KOAgendaView* av = (it != mAgendaViews.constEnd() ? (*it) : 0); \
39  it != mAgendaViews.constEnd(); ++it, av = (*it) )
40 
41 using namespace KOrg;
42 
43 MultiAgendaView::MultiAgendaView( Calendar * cal, CalendarView *calendarView,
44  TQWidget * parent, const char *name ) :
45  AgendaView( cal, parent, name ),
46  mSelectedAgendaView( 0 ),
47  mLastMovedSplitter( 0 ),
48  mUpdateOnShow( false ),
49  mPendingChanges( true ),
50  mCalendarView( calendarView )
51 {
52  TQBoxLayout *topLevelLayout = new TQHBoxLayout( this );
53 
54  TQFontMetrics fm( font() );
55  int topLabelHeight = 2 * fm.height() + fm.lineSpacing();
56 
57  TQVBox *topSideBox = new TQVBox( this );
58  mLeftTopSpacer = new TQWidget( topSideBox );
59  mLeftTopSpacer->setFixedHeight( topLabelHeight );
60  mLeftSplitter = new TQSplitter( TQt::Vertical, topSideBox );
61  mLeftSplitter->setOpaqueResize( TDEGlobalSettings::opaqueResize() );
62  TQLabel *label = new TQLabel( i18n("All Day"), mLeftSplitter );
63  label->setAlignment( TQt::AlignRight | TQt::AlignVCenter | TQt::WordBreak );
64  TQVBox *sideBox = new TQVBox( mLeftSplitter );
65  EventIndicator *eiSpacer = new EventIndicator( EventIndicator::Top, sideBox );
66  eiSpacer->changeColumns( 0 );
67  mTimeLabels = new TimeLabels( 24, sideBox );
68  eiSpacer = new EventIndicator( EventIndicator::Bottom, sideBox );
69  eiSpacer->changeColumns( 0 );
70  mLeftBottomSpacer = new TQWidget( topSideBox );
71  topLevelLayout->addWidget( topSideBox );
72 
73  mScrollView = new TQScrollView( this );
74  mScrollView->setResizePolicy( TQScrollView::Manual );
75  mScrollView->setVScrollBarMode( TQScrollView::AlwaysOff );
76  mScrollView->setFrameShape( TQFrame::NoFrame );
77  topLevelLayout->addWidget( mScrollView, 100 );
78  mTopBox = new TQHBox( mScrollView->viewport() );
79  mScrollView->addChild( mTopBox );
80 
81  topSideBox = new TQVBox( this );
82  mRightTopSpacer = new TQWidget( topSideBox );
83  mRightTopSpacer->setFixedHeight( topLabelHeight );
84  mRightSplitter = new TQSplitter( TQt::Vertical, topSideBox );
85  mRightSplitter->setOpaqueResize( TDEGlobalSettings::opaqueResize() );
86  new TQWidget( mRightSplitter );
87  sideBox = new TQVBox( mRightSplitter );
88  eiSpacer = new EventIndicator( EventIndicator::Top, sideBox );
89  eiSpacer->setFixedHeight( eiSpacer->minimumHeight() );
90  eiSpacer->changeColumns( 0 );
91  mScrollBar = new TQScrollBar( TQt::Vertical, sideBox );
92  eiSpacer = new EventIndicator( EventIndicator::Bottom, sideBox );
93  eiSpacer->setFixedHeight( eiSpacer->minimumHeight() );
94  eiSpacer->changeColumns( 0 );
95  mRightBottomSpacer = new TQWidget( topSideBox );
96  topLevelLayout->addWidget( topSideBox );
97 
98  recreateViews();
99 }
100 
101 void MultiAgendaView::recreateViews()
102 {
103  if ( !mPendingChanges ) {
104  return;
105  }
106 
107  mPendingChanges = false;
108 
109  deleteViews();
110 
111  CalendarResources *calres = dynamic_cast<CalendarResources*>( calendar() );
112  if ( !calres ) {
113  // fallback to single-agenda
114  KOAgendaView* av = new KOAgendaView( calendar(), mCalendarView, mTopBox );
115  mAgendaViews.append( av );
116  mAgendaWidgets.append( av );
117  mSelectedAgendaView = av;
118  av->show();
119  } else {
120  CalendarResourceManager *manager = calres->resourceManager();
121  for ( CalendarResourceManager::ActiveIterator it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
122  if ( (*it)->canHaveSubresources() ) {
123  TQStringList subResources = (*it)->subresources();
124  for ( TQStringList::ConstIterator subit = subResources.constBegin(); subit != subResources.constEnd(); ++subit ) {
125  TQString type = (*it)->subresourceType( *subit );
126 
127  if ( !(*it)->subresourceActive( *subit ) || (!type.isEmpty() && type != "event") ) {
128  continue;
129  }
130 
131  addView( (*it)->labelForSubresource( *subit ), *it, *subit );
132  }
133  } else {
134  addView( (*it)->resourceName(), *it );
135  }
136  }
137  }
138 
139  // no resources activated, so stop here to avoid crashing somewhere down the line, TODO: show a nice message instead
140  if ( mAgendaViews.isEmpty() ) {
141  return;
142  }
143 
144  setupViews();
145  TQTimer::singleShot( 0, this, TQ_SLOT(slotResizeScrollView()) );
146  mTimeLabels->updateConfig();
147 
148  connect( mTimeLabels->verticalScrollBar(), TQ_SIGNAL(valueChanged(int)),
149  mScrollBar, TQ_SLOT(setValue(int)) );
150  connect( mScrollBar, TQ_SIGNAL(valueChanged(int)),
151  mTimeLabels, TQ_SLOT(positionChanged(int)) );
152 
153  installSplitterEventFilter( mLeftSplitter );
154  installSplitterEventFilter( mRightSplitter );
155 
156  TQValueList<int> sizes = KOGlobals::self()->config()->readIntListEntry( "Separator AgendaView" );
157  if ( sizes.count() != 2 ) {
158  sizes = mLeftSplitter->sizes();
159  }
160  FOREACH_VIEW( agenda ) {
161  agenda->splitter()->setSizes( sizes );
162  }
163  mLeftSplitter->setSizes( sizes );
164  mRightSplitter->setSizes( sizes );
165 
166  TQTimer::singleShot( 0, this, TQ_SLOT(setupScrollBar()) );
167 
168  mTimeLabels->positionChanged();
169 }
170 
171 void MultiAgendaView::deleteViews()
172 {
173  for ( TQValueList<TQWidget*>::ConstIterator it = mAgendaWidgets.constBegin();
174  it != mAgendaWidgets.constEnd(); ++it ) {
175  delete *it;
176  }
177  mAgendaViews.clear();
178  mAgendaWidgets.clear();
179  mLastMovedSplitter = 0;
180  mSelectedAgendaView = 0;
181 }
182 
183 void MultiAgendaView::setupViews()
184 {
185  FOREACH_VIEW( agenda ) {
186  if ( !agenda->readOnly() ) {
187  connect( agenda,
188  TQ_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &)),
189  TQ_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &)) );
190  connect( agenda,
191  TQ_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &,const TQDate &)),
192  TQ_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &,const TQDate &)) );
193  connect( agenda,
194  TQ_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &,const TQDateTime &)),
195  TQ_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &,const TQDateTime &)) );
196  connect( agenda,
197  TQ_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &,const TQDateTime &,const TQDateTime &)),
198  TQ_SIGNAL(newEventSignal(ResourceCalendar *,const TQString &,const TQDateTime &,const TQDateTime&)) );
199 
200  connect( agenda,
201  TQ_SIGNAL(newTodoSignal(ResourceCalendar *,const TQString &,const TQDate &)),
202  TQ_SIGNAL(newTodoSignal(ResourceCalendar *,const TQString &,const TQDate &)) );
203 
204  connect( agenda,
205  TQ_SIGNAL(editIncidenceSignal(Incidence *,const TQDate &)),
206  TQ_SIGNAL(editIncidenceSignal(Incidence *,const TQDate &)) );
207  connect( agenda,
208  TQ_SIGNAL(deleteIncidenceSignal(Incidence *)),
209  TQ_SIGNAL(deleteIncidenceSignal(Incidence *)) );
210  connect( agenda,
211  TQ_SIGNAL(startMultiModify(const TQString &)),
212  TQ_SIGNAL(startMultiModify(const TQString &)) );
213  connect( agenda,
214  TQ_SIGNAL(endMultiModify()),
215  TQ_SIGNAL(endMultiModify()) );
216 
217  connect( agenda,
218  TQ_SIGNAL(cutIncidenceSignal(Incidence*)),
219  TQ_SIGNAL(cutIncidenceSignal(Incidence*)) );
220  connect( agenda,
221  TQ_SIGNAL(pasteIncidenceSignal()),
222  TQ_SIGNAL(pasteIncidenceSignal()) );
223  connect( agenda,
224  TQ_SIGNAL(toggleAlarmSignal(Incidence*)),
225  TQ_SIGNAL(toggleAlarmSignal(Incidence*)) );
226  connect( agenda,
227  TQ_SIGNAL(dissociateOccurrenceSignal(Incidence*, const TQDate&)),
228  TQ_SIGNAL(dissociateOccurrenceSignal(Incidence*, const TQDate&)) );
229  connect( agenda,
230  TQ_SIGNAL(dissociateFutureOccurrenceSignal(Incidence*, const TQDate&)),
231  TQ_SIGNAL(dissociateFutureOccurrenceSignal(Incidence*, const TQDate&)) );
232  }
233 
234  connect( agenda,
235  TQ_SIGNAL(copyIncidenceSignal(Incidence*)),
236  TQ_SIGNAL(copyIncidenceSignal(Incidence*)) );
237  connect( agenda,
238  TQ_SIGNAL(showIncidenceSignal(Incidence *,const TQDate &)),
239  TQ_SIGNAL(showIncidenceSignal(Incidence *,const TQDate &)) );
240  connect( agenda,
241  TQ_SIGNAL(incidenceSelected(Incidence *,const TQDate &)),
242  TQ_SIGNAL(incidenceSelected(Incidence *,const TQDate &)) );
243  connect( agenda,
244  TQ_SIGNAL(incidenceSelected(Incidence*,const TQDate &)),
245  TQ_SLOT(slotSelectionChanged()) );
246 
247  connect( agenda,
248  TQ_SIGNAL(timeSpanSelectionChanged()),
249  TQ_SLOT(slotClearTimeSpanSelection()) );
250 
251  disconnect( agenda->agenda(),
252  TQ_SIGNAL(zoomView(const int,const TQPoint&,const TQt::Orientation)),
253  agenda, 0 );
254  connect( agenda->agenda(),
255  TQ_SIGNAL(zoomView(const int,const TQPoint&,const TQt::Orientation)),
256  TQ_SLOT(zoomView(const int,const TQPoint&,const TQt::Orientation)) );
257  }
258 
259  KOAgenda *anAgenda = mAgendaViews.first()->agenda();
260  connect( anAgenda, TQ_SIGNAL(lowerYChanged(int) ), TQ_SLOT(resizeSpacers(int)) );
261 
262  FOREACH_VIEW( agenda ) {
263  agenda->readSettings();
264  }
265 
266  int minWidth = 0;
267  for ( TQValueList<TQWidget*>::ConstIterator it = mAgendaWidgets.constBegin(); it != mAgendaWidgets.constEnd(); ++it )
268  minWidth = TQMAX( minWidth, (*it)->minimumSizeHint().width() );
269  for ( TQValueList<TQWidget*>::ConstIterator it = mAgendaWidgets.constBegin(); it != mAgendaWidgets.constEnd(); ++it )
270  (*it)->setMinimumWidth( minWidth );
271 }
272 
273 MultiAgendaView::~ MultiAgendaView()
274 {
275 }
276 
278 {
279  Incidence::List list;
280  FOREACH_VIEW(agendaView) {
281  list += agendaView->selectedIncidences();
282  }
283  return list;
284 }
285 
287 {
288  DateList list;
289  FOREACH_VIEW(agendaView) {
290  list += agendaView->selectedIncidenceDates();
291  }
292  return list;
293 }
294 
296 {
297  FOREACH_VIEW( agendaView )
298  return agendaView->currentDateCount();
299  return 0;
300 }
301 
302 void MultiAgendaView::showDates(const TQDate & start, const TQDate & end)
303 {
304  mStartDate = start;
305  mEndDate = end;
306  recreateViews();
307  FOREACH_VIEW( agendaView )
308  agendaView->showDates( start, end );
309 }
310 
311 void MultiAgendaView::showIncidences(const Incidence::List & incidenceList, const TQDate &date)
312 {
313  FOREACH_VIEW( agendaView )
314  agendaView->showIncidences( incidenceList, date );
315 }
316 
317 void MultiAgendaView::updateView()
318 {
319  recreateViews();
320  FOREACH_VIEW( agendaView )
321  agendaView->updateView();
322 }
323 
324 void MultiAgendaView::changeIncidenceDisplay(Incidence * incidence, int mode)
325 {
326  FOREACH_VIEW( agendaView )
327  agendaView->changeIncidenceDisplay( incidence, mode );
328 }
329 
331 {
332  FOREACH_VIEW( agendaView )
333  return agendaView->maxDatesHint();
334  return 0;
335 }
336 
337 void MultiAgendaView::slotSelectionChanged()
338 {
339  FOREACH_VIEW( agenda ) {
340  if ( agenda != sender() )
341  agenda->clearSelection();
342  }
343 }
344 
345 bool MultiAgendaView::eventDurationHint(TQDateTime & startDt, TQDateTime & endDt, bool & allDay)
346 {
347  FOREACH_VIEW( agenda ) {
348  bool valid = agenda->eventDurationHint( startDt, endDt, allDay );
349  if ( valid )
350  return true;
351  }
352  return false;
353 }
354 
355 void MultiAgendaView::slotClearTimeSpanSelection()
356 {
357  FOREACH_VIEW( agenda ) {
358  if ( agenda != sender() )
359  agenda->clearTimeSpanSelection();
360  }
361 }
362 
363 void MultiAgendaView::setTypeAheadReceiver(TQObject * o)
364 {
365  FOREACH_VIEW( agenda )
366  agenda->setTypeAheadReceiver( o );
367 }
368 
369 void MultiAgendaView::finishTypeAhead()
370 {
371  FOREACH_VIEW( agenda )
372  agenda->finishTypeAhead();
373 }
374 
375 void MultiAgendaView::addView( const TQString &label, ResourceCalendar *res, const TQString &subRes )
376 {
377  bool readOnlyView = false;
378 
379  TQVBox *box = new TQVBox( mTopBox );
380 
381  // First, the calendar folder title
382  TQHeader *title = new TQHeader( 1, box );
383  title->setClickEnabled( false );
384  title->setStretchEnabled( true );
385  if ( res->readOnly() || !res->subresourceWritable( subRes ) ) {
386  readOnlyView = true;
387  title->setLabel( 0, TQIconSet( KOGlobals::self()->smallIcon( "readonlyevent" ) ), label );
388  } else {
389  TQColor resColor;
390  if ( subRes.isEmpty() ) {
391  resColor = *KOPrefs::instance()->resourceColor( res->identifier() );
392  } else {
393  resColor = *KOPrefs::instance()->resourceColor( subRes );
394  }
395  TQFontMetrics fm = fontMetrics();
396  TQPixmap px( fm.height(), fm.height() );
397  px.fill( resColor );
398  title->setLabel( 0, TQIconSet( px, TQIconSet::Small ), label );
399  }
400 
401  // Now, the sub agenda view
402  KOAgendaView* av = new KOAgendaView( calendar(), mCalendarView, box, 0, true );
403  av->setReadOnly( readOnlyView );
404  av->setResource( res, subRes );
405  av->setIncidenceChanger( mChanger );
406  av->agenda()->setVScrollBarMode( TQScrollView::AlwaysOff );
407  mAgendaViews.append( av );
408  mAgendaWidgets.append( box );
409  box->show();
410  mTimeLabels->setAgenda( av->agenda() );
411 
412  connect( av->agenda()->verticalScrollBar(), TQ_SIGNAL(valueChanged(int)),
413  mTimeLabels, TQ_SLOT(positionChanged(int)) );
414  connect( mTimeLabels->verticalScrollBar(), TQ_SIGNAL(valueChanged(int)),
415  av, TQ_SLOT(setContentsPos(int)) );
416 
417  av->installEventFilter( this );
418  installSplitterEventFilter( av->splitter() );
419 }
420 
421 void MultiAgendaView::resizeEvent(TQResizeEvent * ev)
422 {
423  resizeScrollView( ev->size() );
424  AgendaView::resizeEvent( ev );
425 }
426 
427 void MultiAgendaView::resizeScrollView(const TQSize & size)
428 {
429  const int widgetWidth = size.width() - mTimeLabels->width() - mScrollBar->width();
430  int width = TQMAX( mTopBox->sizeHint().width(), widgetWidth );
431  int height = size.height();
432  if ( width > widgetWidth ) {
433  const int sbHeight = mScrollView->horizontalScrollBar()->height();
434  height -= sbHeight;
435  mLeftBottomSpacer->setFixedHeight( sbHeight );
436  mRightBottomSpacer->setFixedHeight( sbHeight );
437  } else {
438  mLeftBottomSpacer->setFixedHeight( 0 );
439  mRightBottomSpacer->setFixedHeight( 0 );
440  }
441  mScrollView->resizeContents( width, height );
442  mTopBox->resize( width, height );
443 }
444 
445 void MultiAgendaView::setIncidenceChanger(IncidenceChangerBase * changer)
446 {
448  FOREACH_VIEW( agenda )
449  agenda->setIncidenceChanger( changer );
450 }
451 
452 void MultiAgendaView::updateConfig()
453 {
455  mTimeLabels->updateConfig();
456  FOREACH_VIEW( agenda )
457  agenda->updateConfig();
458 }
459 
460 bool MultiAgendaView::eventFilter(TQObject * obj, TQEvent * event)
461 {
462  if ( obj->className() == TQCString("TQSplitterHandle") ) {
463  // KDE4: not needed anymore, TQSplitter has a moved signal there
464  if ( (event->type() == TQEvent::MouseMove && TDEGlobalSettings::opaqueResize())
465  || event->type() == TQEvent::MouseButtonRelease ) {
466  FOREACH_VIEW( agenda ) {
467  if ( agenda->splitter() == obj->parent() )
468  mLastMovedSplitter = agenda->splitter();
469  }
470  if ( mLeftSplitter == obj->parent() )
471  mLastMovedSplitter = mLeftSplitter;
472  else if ( mRightSplitter == obj->parent() )
473  mLastMovedSplitter = mRightSplitter;
474  TQTimer::singleShot( 0, this, TQ_SLOT(resizeSplitters()) );
475  }
476  }
477 
478  if ( obj->className() == TQCString( "KOAgendaView" ) ) {
479  if ( event->type() == TQEvent::MouseButtonRelease ||
480  event->type() == TQEvent::MouseButtonPress ) {
481  mSelectedAgendaView = (KOAgendaView *)obj;
482  }
483  }
484 
485  return AgendaView::eventFilter( obj, event );
486 }
487 
488 KOAgendaView *MultiAgendaView::selectedAgendaView()
489 {
490  return mSelectedAgendaView;
491 }
492 
493 void MultiAgendaView::resizeSplitters()
494 {
495  if ( !mLastMovedSplitter )
496  mLastMovedSplitter = mAgendaViews.first()->splitter();
497  FOREACH_VIEW( agenda ) {
498  if ( agenda->splitter() == mLastMovedSplitter )
499  continue;
500  agenda->splitter()->setSizes( mLastMovedSplitter->sizes() );
501  }
502  if ( mLastMovedSplitter != mLeftSplitter )
503  mLeftSplitter->setSizes( mLastMovedSplitter->sizes() );
504  if ( mLastMovedSplitter != mRightSplitter )
505  mRightSplitter->setSizes( mLastMovedSplitter->sizes() );
506 }
507 
508 void MultiAgendaView::resizeSpacers( int newY )
509 {
510  // this slot is needed because the Agenda view's day labels frame height
511  // can change depending if holidays are shown. When this happens, all
512  // the widgets move down except the timelabels, so we need to change
513  // the top spacer height accordingly to move the timelabels up/down.
514  // kolab/issue2656
515  Q_UNUSED( newY );
516  TQFontMetrics fm( font() );
517  int topLabelHeight = mAgendaViews.first()->dayLabels()->height() +
518  fm.height() + mLeftSplitter->handleWidth();
519  mLeftTopSpacer->setFixedHeight( topLabelHeight );
520  mRightTopSpacer->setFixedHeight( topLabelHeight );
521 }
522 
523 void MultiAgendaView::zoomView( const int delta, const TQPoint & pos, const TQt::Orientation ori )
524 {
525  if ( ori == TQt::Vertical ) {
526  if ( delta > 0 ) {
527  if ( KOPrefs::instance()->mHourSize > 4 )
528  KOPrefs::instance()->mHourSize--;
529  } else {
530  KOPrefs::instance()->mHourSize++;
531  }
532  }
533 
534  FOREACH_VIEW( agenda )
535  agenda->zoomView( delta, pos, ori );
536 
537  mTimeLabels->updateConfig();
538  mTimeLabels->positionChanged();
539  mTimeLabels->repaint();
540 }
541 
542 // KDE4: not needed, use existing TQSplitter signals instead
543 void MultiAgendaView::installSplitterEventFilter(TQSplitter * splitter)
544 {
545  TQObjectList *objlist = splitter->queryList( "TQSplitterHandle" );
546  // HACK: when not being visible, the splitter handle is sometimes not found
547  // for unknown reasons, so trigger an update when we are shown again
548  if ( objlist->count() == 0 && !isVisible() )
549  mUpdateOnShow = true;
550  TQObjectListIt it( *objlist );
551  TQObject *obj;
552  while ( (obj = it.current()) != 0 ) {
553  obj->removeEventFilter( this );
554  obj->installEventFilter( this );
555  ++it;
556  }
557  delete objlist;
558 }
559 
560 void MultiAgendaView::slotResizeScrollView()
561 {
562  resizeScrollView( size() );
563 }
564 
565 void MultiAgendaView::show()
566 {
567  AgendaView::show();
568  if ( mUpdateOnShow ) {
569  mUpdateOnShow = false;
570  mPendingChanges = true; // force a full view recreation
571  showDates( mStartDate, mEndDate );
572  }
573 }
574 
575 void MultiAgendaView::resourcesChanged()
576 {
577  mPendingChanges = true;
578 
579  kdDebug() << "mAgendaViews.size is " << mAgendaViews.size()
580  << "; mAgendaWidgets.size is " << mAgendaWidgets.size()
581  << "; mSelectedAgendaView is " << mSelectedAgendaView
582  << endl;
583 
584  if ( mSelectedAgendaView ) {
585  ResourceCalendar *res = mSelectedAgendaView->resourceCalendar();
586  if ( res ) {
587  if ( res->canHaveSubresources() ) {
588  TQString subRes = mSelectedAgendaView->subResourceCalendar();
589  if ( !res->subresourceWritable( subRes ) ||
590  !res->subresourceActive( subRes ) ) {
591  mSelectedAgendaView = 0;
592  }
593  } else {
594  if ( res->readOnly() || !res->isActive() ) {
595  mSelectedAgendaView = 0;
596  }
597  }
598  } else {
599  mSelectedAgendaView = 0;
600  }
601  }
602 
603  FOREACH_VIEW( agenda )
604  agenda->resourcesChanged();
605 }
606 
607 void MultiAgendaView::setupScrollBar()
608 {
609  if ( !mAgendaViews.isEmpty() && mAgendaViews.first()->agenda() ) {
610  TQScrollBar *scrollBar = mAgendaViews.first()->agenda()->verticalScrollBar();
611  mScrollBar->setMinValue( scrollBar->minValue() );
612  mScrollBar->setMaxValue( scrollBar->maxValue() );
613  mScrollBar->setLineStep( scrollBar->lineStep() );
614  mScrollBar->setPageStep( scrollBar->pageStep() );
615  mScrollBar->setValue( scrollBar->value() );
616  }
617 }
618 
619 #include "multiagendaview.moc"
This is the main calendar widget.
Definition: calendarview.h:82
CalendarResourceManager * resourceManager() const
virtual bool subresourceWritable(const TQString &) const
virtual bool subresourceActive(const TQString &) const
virtual bool canHaveSubresources() const
KOAgendaView is the agenda-like view used to display events in a single one or multi-day view.
Definition: koagendaview.h:109
Base class for single/multi agenda views.
Definition: agendaview.h:28
void copyIncidenceSignal(Incidence *)
instructs the receiver to copy the incidence
void dissociateOccurrenceSignal(Incidence *, const TQDate &)
Dissociate from a recurring incidence the occurrence on the given date to a new incidence.
void toggleAlarmSignal(Incidence *)
instructs the receiver to toggle the alarms of the Incidence.
void editIncidenceSignal(Incidence *, const TQDate &)
instructs the receiver to begin editing the incidence specified in some manner.
void dissociateFutureOccurrenceSignal(Incidence *, const TQDate &)
Dissociate from a recurring incidence all occurrences after the given date to a new incidence.
ResourceCalendar * resourceCalendar()
Return resourceCalendar of this view.
Definition: baseview.h:100
void cutIncidenceSignal(Incidence *)
instructs the receiver to cut the Incidence
virtual void setIncidenceChanger(IncidenceChangerBase *changer)
Assign a new incidence change helper object.
Definition: baseview.h:181
void deleteIncidenceSignal(Incidence *)
instructs the receiver to delete the Incidence in some manner; some possibilities include automatical...
void newEventSignal(ResourceCalendar *res, const TQString &subResource)
instructs the receiver to create a new event.
void setReadOnly(bool readonly)
Flag indicating if the view is read-only.
Definition: baseview.h:82
void pasteIncidenceSignal()
instructs the receiver to paste the incidence
virtual void updateConfig()
Re-reads the KOrganizer configuration and picks up relevant changes which are applicable to the view.
Definition: baseview.h:197
TQString subResourceCalendar() const
Return subResourceCalendar of this view.
Definition: baseview.h:105
void showIncidenceSignal(Incidence *, const TQDate &)
instructs the receiver to show the incidence in read-only mode.
virtual Calendar * calendar()
Return calendar object of this view.
Definition: baseview.h:89
Incidence::List selectedIncidences()
int currentDateCount()
Return number of currently shown dates.
int maxDatesHint()
provides a hint back to the caller on the maximum number of dates that the view supports.
bool eventDurationHint(TQDateTime &startDt, TQDateTime &endDt, bool &allDay)
Set the default start/end date/time for new events.