kotimespanview.cpp
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, permission is given to link this program
21  with any edition of TQt, and distribute the resulting executable,
22  without including the source code for TQt in the source distribution.
23 */
24 
25 #include <tqlayout.h>
26 
27 #include <tdeconfig.h>
28 #include <kstandarddirs.h>
29 #include <tdeconfig.h>
30 #include <libkcal/calendar.h>
31 
32 #include "timespanwidget.h"
33 #include "koglobals.h"
34 
35 #include "kotimespanview.h"
36 #include "kotimespanview.moc"
37 
38 KOTimeSpanView::KOTimeSpanView(Calendar *calendar, TQWidget *parent,
39  const char *name) :
40  KOEventView( calendar, parent, name )
41 {
42  TQBoxLayout *topLayout = new TQVBoxLayout( this );
43 
44  mTimeSpanWidget = new TimeSpanWidget( this );
45  topLayout->addWidget( mTimeSpanWidget );
46 
47  connect( mTimeSpanWidget, TQ_SIGNAL( dateRangeChanged() ), TQ_SLOT( updateView() ) );
48 }
49 
50 KOTimeSpanView::~KOTimeSpanView()
51 {
52 }
53 
54 void KOTimeSpanView::readSettings()
55 {
56  kdDebug(5850) << "KOTimeSpanView::readSettings()" << endl;
57 
58  TDEConfig config( "korganizerrc", true, false); // Open read-only, no kdeglobals
59  config.setGroup("Views");
60 
61  TQValueList<int> sizes = config.readIntListEntry("Separator TimeSpanView");
62  if (sizes.count() == 2) {
63  mTimeSpanWidget->setSplitterSizes(sizes);
64  }
65 }
66 
67 void KOTimeSpanView::writeSettings(TDEConfig *config)
68 {
69 // kdDebug(5850) << "KOTimeSpanView::writeSettings()" << endl;
70 
71  config->setGroup("Views");
72 
73  TQValueList<int> list = mTimeSpanWidget->splitterSizes();
74  config->writeEntry("Separator TimeSpanView",list);
75 }
76 
77 int KOTimeSpanView::maxDatesHint()
78 {
79  return 0;
80 }
81 
82 int KOTimeSpanView::currentDateCount()
83 {
84  return 0;
85 }
86 
87 Incidence::List KOTimeSpanView::selectedIncidences()
88 {
89  Incidence::List selected;
90 
91  return selected;
92 }
93 
94 void KOTimeSpanView::updateView()
95 {
96  insertItems( mTimeSpanWidget->startDateTime().date(),
97  mTimeSpanWidget->endDateTime().date() );
98 }
99 
100 void KOTimeSpanView::showDates(const TQDate &start, const TQDate &end)
101 {
102  TQDate s = start.addDays( -2 );
103  TQDate e = end.addDays( 2 );
104 
105  insertItems( s, e );
106 }
107 
108 void KOTimeSpanView::insertItems(const TQDate &start, const TQDate &end)
109 {
110  mTimeSpanWidget->clear();
111  mTimeSpanWidget->setDateRange( start, end );
112 
113  Event::List events = calendar()->events( start, end );
114  Event::List::ConstIterator it;
115  for( it = events.begin(); it != events.end(); ++it ) {
116  mTimeSpanWidget->addItem( *it );
117  }
118 
119  mTimeSpanWidget->updateView();
120 }
121 
122 void KOTimeSpanView::showIncidences( const Incidence::List & )
123 {
124 }
125 
126 void KOTimeSpanView::changeIncidenceDisplay(Incidence *, int)
127 {
128 }
virtual Event::List events(EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
KOEventView is the abstract base class from which all other calendar views for event data are derived...
Definition: koeventview.h:56
virtual void showIncidences(const Incidence::List &incidenceList, const TQDate &date)=0
Show given incidences.