summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp6
-rw-r--r--korganizer/koagendaitem.cpp8
-rw-r--r--korganizer/koagendaview.cpp1
-rw-r--r--korganizer/komonthview.cpp26
-rw-r--r--korganizer/komonthview.h3
-rw-r--r--korganizer/koviewmanager.cpp1
6 files changed, 36 insertions, 9 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 548c364..d1caff3 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -1,399 +1,401 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <kdebug.h> 26#include <kdebug.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29//#include "koglobals.h" 29//#include "koglobals.h"
30#include "navigatorbar.h" 30#include "navigatorbar.h"
31#include "kdatenavigator.h" 31#include "kdatenavigator.h"
32 32
33#include <kcalendarsystem.h> 33#include <kcalendarsystem.h>
34 34
35#include "datenavigatorcontainer.h" 35#include "datenavigatorcontainer.h"
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, 38DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
39 const char *name ) 39 const char *name )
40 : QWidget( parent, name ), mCalendar( 0 ), 40 : QWidget( parent, name ), mCalendar( 0 ),
41 mHorizontalCount( 1 ), mVerticalCount( 1 ) 41 mHorizontalCount( 1 ), mVerticalCount( 1 )
42{ 42{
43 mExtraViews.setAutoDelete( true ); 43 mExtraViews.setAutoDelete( true );
44 44
45 mNavigatorView = new KDateNavigator( this, name ); 45 mNavigatorView = new KDateNavigator( this, name );
46 46
47 connectNavigatorView( mNavigatorView ); 47 connectNavigatorView( mNavigatorView );
48 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 48 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
49 mLastDisplayedDN = 0; 49 mLastDisplayedDN = 0;
50 mUpdateTimer; 50 mUpdateTimer;
51 mUpdateTimer = new QTimer( this ); 51 mUpdateTimer = new QTimer( this );
52 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); 52 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() ));
53 mFirstSelectedDate = QDate::currentDate();
54 mSelectedDateCount = 1;
53} 55}
54 56
55DateNavigatorContainer::~DateNavigatorContainer() 57DateNavigatorContainer::~DateNavigatorContainer()
56{ 58{
57} 59}
58 60
59void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) 61void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
60{ 62{
61 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), 63 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ),
62 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 64 SIGNAL( datesSelected( const KCal::DateList & ) ) );
63#if 0 65#if 0
64 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), 66 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ),
65 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); 67 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) );
66 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), 68 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ),
67 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); 69 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) );
68#endif 70#endif
69 connect( v, SIGNAL( weekClicked( const QDate & ) ), 71 connect( v, SIGNAL( weekClicked( const QDate & ) ),
70 SIGNAL( weekClicked( const QDate & ) ) ); 72 SIGNAL( weekClicked( const QDate & ) ) );
71 73
72 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); 74 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
73 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); 75 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
74 76
75 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 77 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
76 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 78 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
77 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 79 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
78 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 80 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
79 81
80 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 82 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
81} 83}
82 84
83void DateNavigatorContainer::slotMonthSelected( int month ) 85void DateNavigatorContainer::slotMonthSelected( int month )
84{ 86{
85 //qDebug("slotMonthSelected %d ", month); 87 //qDebug("slotMonthSelected %d ", month);
86 QDate baseDate = mNavigatorView->baseDate(); 88 QDate baseDate = mNavigatorView->baseDate();
87 if ( baseDate.month() == month ) 89 if ( baseDate.month() == month )
88 return; 90 return;
89 //qDebug("month %d %d ",baseDate.month(),month); 91 //qDebug("month %d %d ",baseDate.month(),month);
90 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); 92 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 );
91 date = date.addDays( -(baseDate.month()-month ) *30 ); 93 date = date.addDays( -(baseDate.month()-month ) *30 );
92 QDate newBase = QDate ( date.year(), date.month() , baseDate.day() ); 94 QDate newBase = QDate ( date.year(), date.month() , baseDate.day() );
93 95
94#if 0 96#if 0
95 mFirstSelectedDate = dateList.first() ; 97 mFirstSelectedDate = dateList.first() ;
96 mSelectedDateCount = dateList.count() ; 98 mSelectedDateCount = dateList.count() ;
97 99
98 KDateNavigator *view = mExtraViews.at( 0 ); 100 KDateNavigator *view = mExtraViews.at( 0 );
99 QDate date = view->baseDate(); 101 QDate date = view->baseDate();
100 102
101 QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7); 103 QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7);
102 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); 104 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
103 if ( lDate < curEnd && date.addDays( -30 ) < fDate) { 105 if ( lDate < curEnd && date.addDays( -30 ) < fDate) {
104 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); 106 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
105 mNavigatorView->dayMatrix()->repaint( false ); 107 mNavigatorView->dayMatrix()->repaint( false );
106 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 108 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
107 KDateNavigator *n = mExtraViews.at( i ); 109 KDateNavigator *n = mExtraViews.at( i );
108 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { 110 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
109 n->dayMatrix()->repaint( false ); 111 n->dayMatrix()->repaint( false );
110 } 112 }
111 } 113 }
112 return; 114 return;
113 } 115 }
114#endif 116#endif
115 //qDebug("NEW BASE %s", newBase.toString().latin1()); 117 //qDebug("NEW BASE %s", newBase.toString().latin1());
116 mNavigatorView->setBaseDate( newBase ); 118 mNavigatorView->setBaseDate( newBase );
117 QDate last = lastAvailableDate(); 119 QDate last = lastAvailableDate();
118 QDate first = firstAvailableDate(); 120 QDate first = firstAvailableDate();
119 121
120 QDate selFirst = mFirstSelectedDate; 122 QDate selFirst = mFirstSelectedDate;
121 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 123 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
122 if ( selFirst >= first && selLast <= last ) { 124 if ( selFirst >= first && selLast <= last ) {
123 setBaseDates(); 125 setBaseDates();
124 updateDayMatrixDates(); 126 updateDayMatrixDates();
125 } 127 }
126 else { 128 else {
127 setBaseDates(); 129 setBaseDates();
128 updateDayMatrixDates(); 130 updateDayMatrixDates();
129 emit monthSelected( month ); 131 emit monthSelected( month );
130 } 132 }
131} 133}
132void DateNavigatorContainer::setCalendar( Calendar *cal ) 134void DateNavigatorContainer::setCalendar( Calendar *cal )
133{ 135{
134 mCalendar = cal; 136 mCalendar = cal;
135 mNavigatorView->setCalendar( cal ); 137 mNavigatorView->setCalendar( cal );
136 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 138 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
137 KDateNavigator *n = mExtraViews.at( i ); 139 KDateNavigator *n = mExtraViews.at( i );
138 n->setCalendar( cal ); 140 n->setCalendar( cal );
139 } 141 }
140} 142}
141void DateNavigatorContainer::checkUpdateDayMatrixDates() 143void DateNavigatorContainer::checkUpdateDayMatrixDates()
142{ 144{
143 qDebug("wid %d hei %d ", width(), height()); 145 //qDebug("KODNC: wid %d hei %d ", width(), height());
144 mUpdateTimer->stop(); 146 mUpdateTimer->stop();
145 //return; 147 //return;
146 if ( width() < 3 || height() < 3 ) 148 if ( width() < 3 || height() < 3 )
147 return; 149 return;
148 static int lastWid = 0; 150 static int lastWid = 0;
149 static int lastHei = 0; 151 static int lastHei = 0;
150 if ( lastWid == width() && height() == lastHei ) { 152 if ( lastWid == width() && height() == lastHei ) {
151 qDebug("no layout computing needed. "); 153 qDebug("KODNC: No layout computing needed. ");
152 } else { 154 } else {
153 lastWid = width(); 155 lastWid = width();
154 lastHei = height(); 156 lastHei = height();
155 157
156 QSize minSize = mNavigatorView->yourSizeHint(); 158 QSize minSize = mNavigatorView->yourSizeHint();
157 159
158 int verticalCount = size().height() / minSize.height(); 160 int verticalCount = size().height() / minSize.height();
159 int horizontalCount = size().width() / minSize.width(); 161 int horizontalCount = size().width() / minSize.width();
160 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); 162 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
161 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); 163 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
162 bool fontchange = false; 164 bool fontchange = false;
163 if ( horizontalCount == 1) 165 if ( horizontalCount == 1)
164 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); 166 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
165 QFont fo; 167 QFont fo;
166 if ( horizontalCount != mHorizontalCount || 168 if ( horizontalCount != mHorizontalCount ||
167 verticalCount != mVerticalCount ) { 169 verticalCount != mVerticalCount ) {
168 uint count = horizontalCount * verticalCount; 170 uint count = horizontalCount * verticalCount;
169 if ( count == 0 ) { 171 if ( count == 0 ) {
170 bool ok; 172 bool ok;
171 fo = mNavigatorView->yourFontHint( size() , &ok ); 173 fo = mNavigatorView->yourFontHint( size() , &ok );
172 //mNavigatorView->resize( size() ); 174 //mNavigatorView->resize( size() );
173 //if ( ! ok ) 175 //if ( ! ok )
174 // return; 176 // return;
175 int butt = 2; 177 int butt = 2;
176 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); 178 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
177 if ( horizontalCount <= 1 ) 179 if ( horizontalCount <= 1 )
178 minSize = mNavigatorView->sizeHintTwoButtons( 4 ); 180 minSize = mNavigatorView->sizeHintTwoButtons( 4 );
179 else 181 else
180 minSize = mNavigatorView->sizeHintTwoButtons(); 182 minSize = mNavigatorView->sizeHintTwoButtons();
181 verticalCount = size().height() / minSize.height(); 183 verticalCount = size().height() / minSize.height();
182 horizontalCount = size().width() / minSize.width(); 184 horizontalCount = size().width() / minSize.width();
183 if ( horizontalCount == 0 ) 185 if ( horizontalCount == 0 )
184 horizontalCount = 1; 186 horizontalCount = 1;
185 if ( verticalCount == 0 ) 187 if ( verticalCount == 0 )
186 verticalCount = 1; 188 verticalCount = 1;
187 fontchange = true; 189 fontchange = true;
188 count = horizontalCount * verticalCount; 190 count = horizontalCount * verticalCount;
189 } else { 191 } else {
190 if ( mNavigatorView->fontChanged() ) { 192 if ( mNavigatorView->fontChanged() ) {
191 fontchange = true; 193 fontchange = true;
192 fo = KOPrefs::instance()->mDateNavigatorFont; 194 fo = KOPrefs::instance()->mDateNavigatorFont;
193 mNavigatorView->changeFont( fo ); 195 mNavigatorView->changeFont( fo );
194 mNavigatorView->unsetFontChanged(); 196 mNavigatorView->unsetFontChanged();
195 } 197 }
196 } 198 }
197 199
198 mLastDisplayedDN = horizontalCount*verticalCount-1; 200 mLastDisplayedDN = horizontalCount*verticalCount-1;
199 while ( count > ( mExtraViews.count() + 1 ) ) { 201 while ( count > ( mExtraViews.count() + 1 ) ) {
200 KDateNavigator *n = new KDateNavigator( this ); 202 KDateNavigator *n = new KDateNavigator( this );
201 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 203 n->setMonthSignalOffset ( mExtraViews.count()+1 );
202 mExtraViews.append( n ); 204 mExtraViews.append( n );
203 n->setCalendar( mCalendar ); 205 n->setCalendar( mCalendar );
204 connectNavigatorView( n ); 206 connectNavigatorView( n );
205 n->show(); 207 n->show();
206 } 208 }
207 int iii = 0; 209 int iii = 0;
208 while ( iii < ( mExtraViews.count() ) ) { 210 while ( iii < ( mExtraViews.count() ) ) {
209 if ( iii < count-1 ) 211 if ( iii < count-1 )
210 mExtraViews.at( iii )->show(); 212 mExtraViews.at( iii )->show();
211 else 213 else
212 mExtraViews.at( iii )->hide(); 214 mExtraViews.at( iii )->hide();
213 ++iii; 215 ++iii;
214 } 216 }
215 217
216 setBaseDates(); 218 setBaseDates();
217 if ( fontchange ) { 219 if ( fontchange ) {
218 //mNavigatorView->changeFont( fo ); 220 //mNavigatorView->changeFont( fo );
219 uint i; 221 uint i;
220 for( i = 0; i < mExtraViews.count(); ++i ) { 222 for( i = 0; i < mExtraViews.count(); ++i ) {
221 KDateNavigator *view = mExtraViews.at( i ); 223 KDateNavigator *view = mExtraViews.at( i );
222 view->changeFont( fo ); 224 view->changeFont( fo );
223 } 225 }
224 } 226 }
225 mHorizontalCount = horizontalCount; 227 mHorizontalCount = horizontalCount;
226 mVerticalCount = verticalCount; 228 mVerticalCount = verticalCount;
227 229
228 } 230 }
229 231
230 int theight = height() / mVerticalCount; 232 int theight = height() / mVerticalCount;
231 int twidth = width() / mHorizontalCount; 233 int twidth = width() / mHorizontalCount;
232 234
233 NavigatorBar *bar = mNavigatorView->navigatorBar(); 235 NavigatorBar *bar = mNavigatorView->navigatorBar();
234 if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); 236 if ( mHorizontalCount > 1 ) bar->showButtons( true, false );
235 else bar->showButtons( true, true ); 237 else bar->showButtons( true, true );
236 238
237 mNavigatorView->setGeometry(0, 239 mNavigatorView->setGeometry(0,
238 0, twidth, theight ); 240 0, twidth, theight );
239 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 241 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
240 int x = ( i + 1 ) % mHorizontalCount; 242 int x = ( i + 1 ) % mHorizontalCount;
241 int y = ( i + 1 ) / mHorizontalCount; 243 int y = ( i + 1 ) / mHorizontalCount;
242 244
243 KDateNavigator *view = mExtraViews.at( i ); 245 KDateNavigator *view = mExtraViews.at( i );
244 bar = view->navigatorBar(); 246 bar = view->navigatorBar();
245 if ( y > 0 ) bar->showButtons( false, false ); 247 if ( y > 0 ) bar->showButtons( false, false );
246 else { 248 else {
247 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); 249 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true );
248 else bar->showButtons( false, false ); 250 else bar->showButtons( false, false );
249 } 251 }
250 view->setGeometry( x * twidth, 252 view->setGeometry( x * twidth,
251 y * theight, twidth, theight ); 253 y * theight, twidth, theight );
252 } 254 }
253 } 255 }
254 256
255 QDate last = lastAvailableDate(); 257 QDate last = lastAvailableDate();
256 QDate first = firstAvailableDate(); 258 QDate first = firstAvailableDate();
257 259
258 QDate selFirst = mFirstSelectedDate; 260 QDate selFirst = mFirstSelectedDate;
259 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 261 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
260 if ( selFirst >= first && selLast <= last ) { 262 if ( selFirst >= first && selLast <= last ) {
261 updateDayMatrixDates(); 263 updateDayMatrixDates();
262 } 264 }
263 else { 265 else {
264 updateDayMatrixDates(); 266 updateDayMatrixDates();
265 emit monthSelected( mFirstSelectedDate.month() ); 267 emit monthSelected( mFirstSelectedDate.month() );
266 } 268 }
267} 269}
268void DateNavigatorContainer::updateDayMatrixDates() 270void DateNavigatorContainer::updateDayMatrixDates()
269{ 271{
270 QDate fDate = mFirstSelectedDate; 272 QDate fDate = mFirstSelectedDate;
271 QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); 273 QDate lDate = fDate.addDays( mSelectedDateCount - 1 );
272 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); 274 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
273 mNavigatorView->dayMatrix()->repaint( false ); 275 mNavigatorView->dayMatrix()->repaint( false );
274 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 276 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
275 KDateNavigator *n = mExtraViews.at( i ); 277 KDateNavigator *n = mExtraViews.at( i );
276 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { 278 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
277 n->dayMatrix()->repaint( false ); 279 n->dayMatrix()->repaint( false );
278 } 280 }
279 } 281 }
280} 282}
281 283
282void DateNavigatorContainer::updateDayMatrix() 284void DateNavigatorContainer::updateDayMatrix()
283{ 285{
284 mNavigatorView->updateDayMatrix(); 286 mNavigatorView->updateDayMatrix();
285 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 287 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
286 KDateNavigator *n = mExtraViews.at( i ); 288 KDateNavigator *n = mExtraViews.at( i );
287 n->updateDayMatrix(); 289 n->updateDayMatrix();
288 } 290 }
289} 291}
290 292
291void DateNavigatorContainer::updateToday() 293void DateNavigatorContainer::updateToday()
292{ 294{
293 qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); 295 qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
294#if 0 296#if 0
295 mNavigatorView->updateToday(); 297 mNavigatorView->updateToday();
296 KDateNavigator *n; 298 KDateNavigator *n;
297 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 299 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
298 n->updateToday(); 300 n->updateToday();
299 } 301 }
300#endif 302#endif
301} 303}
302 304
303void DateNavigatorContainer::updateView() 305void DateNavigatorContainer::updateView()
304{ 306{
305 mNavigatorView->updateView(); 307 mNavigatorView->updateView();
306 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 308 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
307 KDateNavigator *n = mExtraViews.at( i ); 309 KDateNavigator *n = mExtraViews.at( i );
308 n->updateView(); 310 n->updateView();
309 } 311 }
310} 312}
311 313
312void DateNavigatorContainer::updateConfig() 314void DateNavigatorContainer::updateConfig()
313{ 315{
314 mNavigatorView->updateConfig(); 316 mNavigatorView->updateConfig();
315 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 317 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
316 KDateNavigator *n = mExtraViews.at( i ); 318 KDateNavigator *n = mExtraViews.at( i );
317 n->updateConfig(); 319 n->updateConfig();
318 } 320 }
319} 321}
320QDate DateNavigatorContainer::lastAvailableDate() const 322QDate DateNavigatorContainer::lastAvailableDate() const
321{ 323{
322 QDate date = mNavigatorView->baseDate(); 324 QDate date = mNavigatorView->baseDate();
323 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); 325 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() );
324 int iii = mLastDisplayedDN; 326 int iii = mLastDisplayedDN;
325 if ( mLastDisplayedDN ) 327 if ( mLastDisplayedDN )
326 last = last.addDays( 1); 328 last = last.addDays( 1);
327 while ( iii ) { 329 while ( iii ) {
328 last = last.addDays( last.daysInMonth ()); 330 last = last.addDays( last.daysInMonth ());
329 //qDebug("DATE %s ", last.toString().latin1() ); 331 //qDebug("DATE %s ", last.toString().latin1() );
330 --iii; 332 --iii;
331 } 333 }
332 if ( mLastDisplayedDN ) 334 if ( mLastDisplayedDN )
333 last = last.addDays( -1); 335 last = last.addDays( -1);
334 return last; 336 return last;
335} 337}
336QDate DateNavigatorContainer::firstAvailableDate() const 338QDate DateNavigatorContainer::firstAvailableDate() const
337{ 339{
338 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); 340 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 );
339} 341}
340void DateNavigatorContainer::selectDates( const DateList &dateList ) 342void DateNavigatorContainer::selectDates( const DateList &dateList )
341{ 343{
342 mFirstSelectedDate = dateList.first() ; 344 mFirstSelectedDate = dateList.first() ;
343 mSelectedDateCount = dateList.count() ; 345 mSelectedDateCount = dateList.count() ;
344 if ( !mLastDisplayedDN ) { 346 if ( !mLastDisplayedDN ) {
345 mNavigatorView->selectDates( dateList ); 347 mNavigatorView->selectDates( dateList );
346 return; 348 return;
347 } 349 }
348 QDate fDate = dateList.first(); 350 QDate fDate = dateList.first();
349 QDate lDate = dateList.last(); 351 QDate lDate = dateList.last();
350 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); 352 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() );
351 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); 353 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
352 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { 354 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) {
353 updateDayMatrixDates(); 355 updateDayMatrixDates();
354 return; 356 return;
355 } 357 }
356 mNavigatorView->selectDates( dateList ); 358 mNavigatorView->selectDates( dateList );
357 setBaseDates(); 359 setBaseDates();
358 if ( mLastDisplayedDN ) { 360 if ( mLastDisplayedDN ) {
359 KDateNavigator *view = mExtraViews.at( 0 ); 361 KDateNavigator *view = mExtraViews.at( 0 );
360 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 362 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
361 view->dayMatrix()->repaint( false ); 363 view->dayMatrix()->repaint( false );
362 if ( mLastDisplayedDN > 1 ) { 364 if ( mLastDisplayedDN > 1 ) {
363 KDateNavigator *view = mExtraViews.at( 1 ); 365 KDateNavigator *view = mExtraViews.at( 1 );
364 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 366 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
365 view->dayMatrix()->repaint( false ); 367 view->dayMatrix()->repaint( false );
366 } 368 }
367 } 369 }
368} 370}
369 371
370void DateNavigatorContainer::setBaseDates() 372void DateNavigatorContainer::setBaseDates()
371{ 373{
372 QDate baseDate = mNavigatorView->baseDate(); 374 QDate baseDate = mNavigatorView->baseDate();
373 bool doRepaint = true; 375 bool doRepaint = true;
374 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 376 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
375 KDateNavigator *n = mExtraViews.at( i ); 377 KDateNavigator *n = mExtraViews.at( i );
376 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 378 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
377 n->setBaseDate( baseDate, doRepaint ); 379 n->setBaseDate( baseDate, doRepaint );
378 } 380 }
379} 381}
380 382
381void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 383void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
382{ 384{
383 385
384 386
385 //qDebug("COUNT %d ", mExtraViews.count()); 387 //qDebug("COUNT %d ", mExtraViews.count());
386 388
387 mUpdateTimer->start( 250 ); 389 mUpdateTimer->start( 250 );
388 //updateDayMatrixDates(); 390 //updateDayMatrixDates();
389} 391}
390 392
391QSize DateNavigatorContainer::minimumSizeHint() const 393QSize DateNavigatorContainer::minimumSizeHint() const
392{ 394{
393 return mNavigatorView->minimumSizeHint(); 395 return mNavigatorView->minimumSizeHint();
394} 396}
395 397
396QSize DateNavigatorContainer::sizeHint() const 398QSize DateNavigatorContainer::sizeHint() const
397{ 399{
398 return mNavigatorView->yourSizeHint(); 400 return mNavigatorView->yourSizeHint();
399} 401}
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 7e6fa48..82d1eab 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -123,682 +123,682 @@ void KOAgendaItem::init ( Incidence *incidence, QDate qd )
123 mBackgroundColor =KOPrefs::instance()->mEventColor; 123 mBackgroundColor =KOPrefs::instance()->mEventColor;
124 } else { 124 } else {
125 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 125 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
126 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 126 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) {
127 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 127 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
128 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 128 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
129 } 129 }
130 } 130 }
131 131
132 } 132 }
133 mColorGroup = QColorGroup( mBackgroundColor.light(), 133 mColorGroup = QColorGroup( mBackgroundColor.light(),
134 mBackgroundColor.dark(),mBackgroundColor.light(), 134 mBackgroundColor.dark(),mBackgroundColor.light(),
135 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 135 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
136 setBackgroundColor( mBackgroundColor ); 136 setBackgroundColor( mBackgroundColor );
137 137
138 mConflictItems.clear(); 138 mConflictItems.clear();
139 setCellXY(0,0,1); 139 setCellXY(0,0,1);
140 setCellXWidth(0); 140 setCellXWidth(0);
141 setSubCell(0); 141 setSubCell(0);
142 setSubCells(1); 142 setSubCells(1);
143 setMultiItem(0,0,0); 143 setMultiItem(0,0,0);
144 startMove(); 144 startMove();
145 mSelected = true; 145 mSelected = true;
146 select(false); 146 select(false);
147 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 147 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
148 mFontPixelSize = fontinf.height();; 148 mFontPixelSize = fontinf.height();;
149 hide(); 149 hide();
150 xPaintCoord = -1; 150 xPaintCoord = -1;
151 yPaintCoord = -1; 151 yPaintCoord = -1;
152} 152}
153 153
154 154
155KOAgendaItem::~KOAgendaItem() 155KOAgendaItem::~KOAgendaItem()
156{ 156{
157 // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); 157 // qDebug("deleteKOAgendaItem::~KOAgendaItem( ");
158 // delete mKOAgendaItemWhatsThis; 158 // delete mKOAgendaItemWhatsThis;
159} 159}
160 160
161void KOAgendaItem::recreateIncidence() 161void KOAgendaItem::recreateIncidence()
162{ 162{
163#if 0 163#if 0
164 Incidence* newInc = mIncidence->clone(); 164 Incidence* newInc = mIncidence->clone();
165 newInc->recreate(); 165 newInc->recreate();
166 if ( mIncidence->doesRecur() ) { 166 if ( mIncidence->doesRecur() ) {
167 mIncidence->addExDate( mDate ); 167 mIncidence->addExDate( mDate );
168 newInc->recurrence()->unsetRecurs(); 168 newInc->recurrence()->unsetRecurs();
169 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 169 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
170 QTime tim = mIncidence->dtStart().time(); 170 QTime tim = mIncidence->dtStart().time();
171 newInc->setDtStart( QDateTime(mDate, tim) ); 171 newInc->setDtStart( QDateTime(mDate, tim) );
172 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 172 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
173 } 173 }
174#endif 174#endif
175 mIncidence = mIncidence->recreateCloneException( mDate ); 175 mIncidence = mIncidence->recreateCloneException( mDate );
176} 176}
177bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 177bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
178{ 178{
179 int size = AGENDA_ICON_SIZE; 179 int size = AGENDA_ICON_SIZE;
180 180
181 int yOff = 0; 181 int yOff = 0;
182 int xOff = 0; 182 int xOff = 0;
183 int x = pos().x() +3; 183 int x = pos().x() +3;
184 int y; 184 int y;
185 if ( mAllDay ) 185 if ( mAllDay )
186 y = pos().y()+3; 186 y = pos().y()+3;
187 else 187 else
188 y = mCellYTop * ( height() / cellHeight() ) +3; 188 y = mCellYTop * ( height() / cellHeight() ) +3;
189 if (mIncidence->cancelled()) { 189 if (mIncidence->cancelled()) {
190 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 190 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
191 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 191 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
192 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 192 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
193 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 193 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
194 if ( horLayout ) 194 if ( horLayout )
195 ++xOff; 195 ++xOff;
196 else 196 else
197 ++yOff; 197 ++yOff;
198 } 198 }
199 if (mIncidence->isAlarmEnabled()) { 199 if (mIncidence->isAlarmEnabled()) {
200 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 200 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
201 if ( horLayout ) 201 if ( horLayout )
202 ++xOff; 202 ++xOff;
203 else 203 else
204 ++yOff; 204 ++yOff;
205 } 205 }
206 if (mIncidence->recurrence()->doesRecur()) { 206 if (mIncidence->recurrence()->doesRecur()) {
207 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 207 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
208 if ( horLayout ) 208 if ( horLayout )
209 ++xOff; 209 ++xOff;
210 else 210 else
211 ++yOff; 211 ++yOff;
212 } 212 }
213 if (mIncidence->description().length() > 0) { 213 if (mIncidence->description().length() > 0) {
214 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 214 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
215 if ( horLayout ) 215 if ( horLayout )
216 ++xOff; 216 ++xOff;
217 else 217 else
218 ++yOff; 218 ++yOff;
219 } 219 }
220 if (mIncidence->isReadOnly()) { 220 if (mIncidence->isReadOnly()) {
221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
222 if ( horLayout ) 222 if ( horLayout )
223 ++xOff; 223 ++xOff;
224 else 224 else
225 ++yOff; 225 ++yOff;
226 } 226 }
227 227
228 if (mIncidence->attendeeCount()>0) { 228 if (mIncidence->attendeeCount()>0) {
229 229
230 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 230 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
232 if ( horLayout ) 232 if ( horLayout )
233 ++xOff; 233 ++xOff;
234 else 234 else
235 ++yOff; 235 ++yOff;
236 } else { 236 } else {
237 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 237 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
238 if (me!=0) { 238 if (me!=0) {
239 239
240 240
241 } else { 241 } else {
242 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 242 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
243 if ( horLayout ) 243 if ( horLayout )
244 ++xOff; 244 ++xOff;
245 else 245 else
246 ++yOff; 246 ++yOff;
247 247
248 } 248 }
249 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 249 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
250 if ( horLayout ) 250 if ( horLayout )
251 ++xOff; 251 ++xOff;
252 else 252 else
253 ++yOff; 253 ++yOff;
254 254
255 } 255 }
256 256
257 } 257 }
258 return ( yOff || xOff ); 258 return ( yOff || xOff );
259} 259}
260 260
261 261
262void KOAgendaItem::select(bool selected) 262void KOAgendaItem::select(bool selected)
263{ 263{
264 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 264 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
265 if (mSelected == selected) return; 265 if (mSelected == selected) return;
266 mSelected = selected; 266 mSelected = selected;
267 if ( ! isVisible() ) 267 if ( ! isVisible() )
268 return; 268 return;
269 if ( firstMultiItem() ) 269 if ( firstMultiItem() )
270 firstMultiItem()->select( selected ); 270 firstMultiItem()->select( selected );
271 if ( !firstMultiItem() && nextMultiItem() ) { 271 if ( !firstMultiItem() && nextMultiItem() ) {
272 KOAgendaItem * placeItem = nextMultiItem(); 272 KOAgendaItem * placeItem = nextMultiItem();
273 while ( placeItem ) { 273 while ( placeItem ) {
274 placeItem->select( selected ); 274 placeItem->select( selected );
275 placeItem = placeItem->nextMultiItem(); 275 placeItem = placeItem->nextMultiItem();
276 } 276 }
277 } 277 }
278 globalFlagBlockAgendaItemUpdate = 0; 278 globalFlagBlockAgendaItemUpdate = 0;
279 paintMe( selected ); 279 paintMe( selected );
280 globalFlagBlockAgendaItemUpdate = 1; 280 globalFlagBlockAgendaItemUpdate = 1;
281 repaint( false ); 281 repaint( false );
282} 282}
283 283
284 284
285/* 285/*
286 The eventFilter has to filter the mouse events of the agenda item childs. The 286 The eventFilter has to filter the mouse events of the agenda item childs. The
287 events are fed into the event handling method of KOAgendaItem. This allows the 287 events are fed into the event handling method of KOAgendaItem. This allows the
288 KOAgenda to handle the KOAgendaItems by using an eventFilter. 288 KOAgenda to handle the KOAgendaItems by using an eventFilter.
289*/ 289*/
290bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 290bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
291{ 291{
292 if (e->type() == QEvent::MouseButtonPress || 292 if (e->type() == QEvent::MouseButtonPress ||
293 e->type() == QEvent::MouseButtonDblClick || 293 e->type() == QEvent::MouseButtonDblClick ||
294 e->type() == QEvent::MouseButtonRelease || 294 e->type() == QEvent::MouseButtonRelease ||
295 e->type() == QEvent::MouseMove) { 295 e->type() == QEvent::MouseMove) {
296 QMouseEvent *me = (QMouseEvent *)e; 296 QMouseEvent *me = (QMouseEvent *)e;
297 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 297 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
298 mapToGlobal(me->pos())); 298 mapToGlobal(me->pos()));
299 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 299 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
300 return event(&returnEvent); 300 return event(&returnEvent);
301 } else { 301 } else {
302 return false; 302 return false;
303 } 303 }
304} 304}
305void KOAgendaItem::repaintMe( ) 305void KOAgendaItem::repaintMe( )
306{ 306{
307 paintMe ( mSelected ); 307 paintMe ( mSelected );
308} 308}
309void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 309void KOAgendaItem::paintMe( bool selected, QPainter* paint )
310{ 310{
311 if ( globalFlagBlockAgendaItemUpdate && ! selected) 311 if ( globalFlagBlockAgendaItemUpdate && ! selected)
312 return; 312 return;
313 QPainter pa; 313 QPainter pa;
314 314
315 if ( mSelected ) { 315 if ( mSelected ) {
316 pa.begin( paintPixSel() ); 316 pa.begin( paintPixSel() );
317 } else { 317 } else {
318 if ( mAllDay ) 318 if ( mAllDay )
319 pa.begin( paintPixAllday() ); 319 pa.begin( paintPixAllday() );
320 else 320 else
321 pa.begin( paintPix() ); 321 pa.begin( paintPix() );
322 } 322 }
323 int x, yy, w, h; 323 int x, yy, w, h;
324 float nfh = 7.0; 324 float nfh = 7.0;
325 x = pos().x(); w = width(); h = height (); 325 x = pos().x(); w = width(); h = height ();
326 if ( mAllDay ) 326 if ( mAllDay )
327 yy = y(); 327 yy = y();
328 else 328 else
329 yy = mCellYTop * ( height() / cellHeight() ); 329 yy = mCellYTop * ( height() / cellHeight() );
330 xPaintCoord= x; 330 xPaintCoord= x;
331 yPaintCoord = yy; 331 yPaintCoord = yy;
332 wPaintCoord = width(); 332 wPaintCoord = width();
333 hPaintCoord = height(); 333 hPaintCoord = height();
334 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 334 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
335 if ( paint == 0 ) 335 if ( paint == 0 )
336 paint = &pa; 336 paint = &pa;
337 bool horLayout = ( w < h ); 337 bool horLayout = ( w < h );
338 int maxhei = mFontPixelSize+4; 338 int maxhei = mFontPixelSize+4;
339 if ( horLayout ) 339 if ( horLayout )
340 maxhei += AGENDA_ICON_SIZE -4; 340 maxhei += AGENDA_ICON_SIZE -4;
341 bool small = ( h < maxhei ); 341 bool small = ( h < maxhei );
342 if ( ! small ) 342 if ( ! small )
343 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 343 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
344 else { 344 else {
345 QFont f = KOPrefs::instance()->mAgendaViewFont; 345 QFont f = KOPrefs::instance()->mAgendaViewFont;
346 f.setBold( false ); 346 f.setBold( false );
347 int fh = f.pointSize(); 347 int fh = f.pointSize();
348 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 348 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
349 if ( nfh < 6 ) 349 if ( nfh < 6 )
350 nfh = 6; 350 nfh = 6;
351 f.setPointSize( nfh ); 351 f.setPointSize( nfh );
352 paint->setFont(f); 352 paint->setFont(f);
353 } 353 }
354 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 354 paint->fillRect ( x, yy, w, h, mBackgroundColor );
355 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 355 static const QPixmap completedPxmp = SmallIcon("greenhook16");
356 static const QPixmap overduePxmp = SmallIcon("redcross16"); 356 static const QPixmap overduePxmp = SmallIcon("redcross16");
357 if ( mIncidence->type() == "Todo" ) { 357 if ( mIncidence->type() == "Todo" ) {
358 Todo* tempTodo = static_cast<Todo*>(mIncidence); 358 Todo* tempTodo = static_cast<Todo*>(mIncidence);
359 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 359 int xx = pos().x()+(width()-completedPxmp.width()-3 );
360 int yyy = yy+3; 360 int yyy = yy+3;
361 if ( tempTodo->isCompleted() ) 361 if ( tempTodo->isCompleted() )
362 paint->drawPixmap ( xx, yyy, completedPxmp ); 362 paint->drawPixmap ( xx, yyy, completedPxmp );
363 else { 363 else {
364 paint->drawPixmap ( xx, yyy, overduePxmp ); 364 paint->drawPixmap ( xx, yyy, overduePxmp );
365 365
366 } 366 }
367 } 367 }
368 bool addIcon = false; 368 bool addIcon = false;
369 if ( ! small || w > 3 * h || h > 3* w ) 369 if ( ! small || w > 3 * h || h > 3* w )
370 addIcon = updateIcons( paint, horLayout ); 370 addIcon = updateIcons( paint, horLayout );
371 371
372 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 372 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
373 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 373 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
374 if ( ! small ) { 374 if ( ! small ) {
375 x += 3; yy += 3;w -= 6; h-= 5; 375 x += 3; yy += 3;w -= 6; h-= 5;
376 } else { 376 } else {
377 x += 2; yy += 1;w -= 4; h-= 4; 377 x += 2; yy += 1;w -= 4; h-= 4;
378 if ( nfh < 6.01 ) { 378 if ( nfh < 6.01 ) {
379 yy -= 2; 379 yy -= 2;
380 h += 4; 380 h += 4;
381 } 381 }
382 else 382 else
383 if ( nfh < h -2 ) 383 if ( nfh < h -2 )
384 ++yy; 384 ++yy;
385 } 385 }
386 int align; 386 int align;
387#ifndef DESKTOP_VERSION 387#ifndef DESKTOP_VERSION
388 align = ( AlignLeft|WordBreak|AlignTop); 388 align = ( AlignLeft|WordBreak|AlignTop);
389#else 389#else
390 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 390 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
391#endif 391#endif
392 if ( addIcon ) { 392 if ( addIcon ) {
393 if ( ! horLayout ) { 393 if ( ! horLayout ) {
394 x += AGENDA_ICON_SIZE+3; 394 x += AGENDA_ICON_SIZE+3;
395 w -= (AGENDA_ICON_SIZE+3); 395 w -= (AGENDA_ICON_SIZE+3);
396 } 396 }
397 else { 397 else {
398 yy+= AGENDA_ICON_SIZE+2; 398 yy+= AGENDA_ICON_SIZE+2;
399 h -=(AGENDA_ICON_SIZE+3); 399 h -=(AGENDA_ICON_SIZE+3);
400 } 400 }
401 } 401 }
402 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 402 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
403 if ( colsum < 250 ) 403 if ( colsum < 250 )
404 paint->setPen ( white); 404 paint->setPen ( white);
405 if ( x < 0 ) { 405 if ( x < 0 ) {
406 w = w+x-3; 406 w = w+x-3;
407 x = 3; 407 x = 3;
408 if ( w > parentWidget()->width() ){ 408 if ( w > parentWidget()->width() ){
409 w = parentWidget()->width() - 6; 409 w = parentWidget()->width() - 6;
410#ifndef DESKTOP_VERSION 410#ifndef DESKTOP_VERSION
411 align = ( AlignHCenter|WordBreak|AlignTop); 411 align = ( AlignHCenter|WordBreak|AlignTop);
412#else 412#else
413 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 413 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
414#endif 414#endif
415 415
416 } 416 }
417 } 417 }
418 QRect dr; 418 QRect dr;
419 if ( w + x > parentWidget()->width() ) 419 if ( w + x > parentWidget()->width() )
420 w = parentWidget()->width()-x; 420 w = parentWidget()->width()-x;
421 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 421 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
422 //qDebug("%d %d %d %d ", x, yy, w, h ); 422 //qDebug("%d %d %d %d ", x, yy, w, h );
423 if ( mIncidence->cancelled() ){ 423 if ( mIncidence->cancelled() ){
424 if ( ! small ) { 424 if ( ! small ) {
425 QFontMetrics fm ( paint->font() ); 425 QFontMetrics fm ( paint->font() );
426 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 426 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
427 } 427 }
428 428
429 } 429 }
430 pa.end(); 430 pa.end();
431 431
432} 432}
433void KOAgendaItem::resizePixmap( int w , int h ) 433void KOAgendaItem::resizePixmap( int w , int h )
434{ 434{
435 paintPix()->resize( w, h ); 435 paintPix()->resize( w, h );
436 paintPixSel()->resize( w, h ); 436 paintPixSel()->resize( w, h );
437 437
438} 438}
439QPixmap * KOAgendaItem::paintPix() 439QPixmap * KOAgendaItem::paintPix()
440{ 440{
441 static QPixmap* mPaintPix = 0; 441 static QPixmap* mPaintPix = 0;
442 if ( ! mPaintPix ) 442 if ( ! mPaintPix )
443 mPaintPix = new QPixmap(1,1); 443 mPaintPix = new QPixmap(1,1);
444 return mPaintPix ; 444 return mPaintPix ;
445} 445}
446QPixmap * KOAgendaItem::paintPixAllday() 446QPixmap * KOAgendaItem::paintPixAllday()
447{ 447{
448 static QPixmap* mPaintPixA = 0; 448 static QPixmap* mPaintPixA = 0;
449 if ( ! mPaintPixA ) 449 if ( ! mPaintPixA )
450 mPaintPixA = new QPixmap(1,1); 450 mPaintPixA = new QPixmap(1,1);
451 return mPaintPixA ; 451 return mPaintPixA ;
452} 452}
453QPixmap * KOAgendaItem::paintPixSel() 453QPixmap * KOAgendaItem::paintPixSel()
454{ 454{
455 static QPixmap* mPaintPixSel = 0; 455 static QPixmap* mPaintPixSel = 0;
456 if ( ! mPaintPixSel ) 456 if ( ! mPaintPixSel )
457 mPaintPixSel = new QPixmap(1,1); 457 mPaintPixSel = new QPixmap(1,1);
458 return mPaintPixSel ; 458 return mPaintPixSel ;
459} 459}
460void KOAgendaItem::paintEvent ( QPaintEvent *e ) 460void KOAgendaItem::paintEvent ( QPaintEvent *e )
461{ 461{
462 462
463 if ( globalFlagBlockAgendaItemPaint ) 463 if ( globalFlagBlockAgendaItemPaint )
464 return; 464 return;
465 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 465 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
466 return; 466 return;
467 int yy; 467 int yy;
468 if ( mAllDay ) 468 if ( mAllDay )
469 yy = y(); 469 yy = y();
470 else 470 else
471 yy = mCellYTop * ( height() / cellHeight() ); 471 yy = mCellYTop * ( height() / cellHeight() );
472 int xx = x(); 472 int xx = x();
473 473
474 if ( xPaintCoord != xx || yPaintCoord != yy || 474 if ( xPaintCoord != xx || yPaintCoord != yy ||
475 wPaintCoord != width() || hPaintCoord != height()) { 475 wPaintCoord != width() || hPaintCoord != height()) {
476 xPaintCoord= xx; 476 xPaintCoord= xx;
477 yPaintCoord = yy; 477 yPaintCoord = yy;
478 wPaintCoord = width(); 478 wPaintCoord = width();
479 hPaintCoord = height(); 479 hPaintCoord = height();
480 globalFlagBlockAgendaItemUpdate = 0; 480 globalFlagBlockAgendaItemUpdate = 0;
481 paintMe( mSelected ); 481 paintMe( mSelected );
482 //qDebug("calling paintMe "); 482 //qDebug("calling paintMe ");
483 globalFlagBlockAgendaItemUpdate = 1; 483 globalFlagBlockAgendaItemUpdate = 1;
484 } 484 }
485 int rx, ry, rw, rh; 485 int rx, ry, rw, rh;
486 rx = e->rect().x(); 486 rx = e->rect().x();
487 ry = e->rect().y(); 487 ry = e->rect().y();
488 rw = e->rect().width(); 488 rw = e->rect().width();
489 rh = e->rect().height(); 489 rh = e->rect().height();
490 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 490 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
491 491
492 QPixmap* paintFrom ; 492 QPixmap* paintFrom ;
493 if ( mSelected ) { 493 if ( mSelected ) {
494 paintFrom = paintPixSel(); 494 paintFrom = paintPixSel();
495 } else { 495 } else {
496 if ( mAllDay ) 496 if ( mAllDay )
497 paintFrom = paintPixAllday(); 497 paintFrom = paintPixAllday();
498 else 498 else
499 paintFrom = paintPix(); 499 paintFrom = paintPix();
500 } 500 }
501 xx += rx; 501 xx += rx;
502 502
503 if ( xx < 0 ) { 503 if ( xx < 0 ) {
504 rw = rw + xx; 504 rw = rw + xx;
505 rx -= xx; 505 rx -= xx;
506 xx = 0; 506 xx = 0;
507 if ( rw < 0 ) { 507 if ( rw <= 1 ) {
508 qDebug("KOAgendaItem::Width1 < 0. Returning "); 508 qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
509 return; 509 return;
510 } 510 }
511 } 511 }
512 if ( paintFrom->width() < xx+rw ) { 512 if ( paintFrom->width() < xx+rw ) {
513 rw = paintFrom->width() - xx; 513 rw = paintFrom->width() - xx;
514 if ( rw < 0 ) { 514 if ( rw <= 1 ) {
515 qDebug("KOAgendaItem::Width2 < 0. Returning "); 515 qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
516 return; 516 return;
517 } 517 }
518 } 518 }
519 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 519 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
520 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 520 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
521} 521}
522void KOAgendaItem::computeText() 522void KOAgendaItem::computeText()
523{ 523{
524 524
525 mDisplayedText = mIncidence->summary(); 525 mDisplayedText = mIncidence->summary();
526 if ( (mIncidence->type() == "Todo") ) { 526 if ( (mIncidence->type() == "Todo") ) {
527 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 527 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
528 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 528 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
529 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 529 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
530 else if ( !(mIncidence->doesFloat())) 530 else if ( !(mIncidence->doesFloat()))
531 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 531 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
532 } 532 }
533 } else { 533 } else {
534 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 534 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
535 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 535 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
536 536
537 if ( mAllDay ) { 537 if ( mAllDay ) {
538 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 538 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
539 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 539 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
540 } 540 }
541 } 541 }
542 542
543 } 543 }
544 544
545 if ( !mIncidence->location().isEmpty() ) { 545 if ( !mIncidence->location().isEmpty() ) {
546 if ( mAllDay ) 546 if ( mAllDay )
547 mDisplayedText += " ("; 547 mDisplayedText += " (";
548 else 548 else
549 mDisplayedText += "\n("; 549 mDisplayedText += "\n(";
550 mDisplayedText += mIncidence->location() +")"; 550 mDisplayedText += mIncidence->location() +")";
551 } 551 }
552 552
553 QString tipText = mIncidence->summary(); 553 QString tipText = mIncidence->summary();
554 if ( !mIncidence->doesFloat() ) { 554 if ( !mIncidence->doesFloat() ) {
555 if ( mIncidence->type() == "Event" ) { 555 if ( mIncidence->type() == "Event" ) {
556 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 556 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
557 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 557 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
558 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 558 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
559 } 559 }
560 else { 560 else {
561 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 561 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
562 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 562 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
563 } 563 }
564 } 564 }
565 else if ( mIncidence->type() == "Todo" ) { 565 else if ( mIncidence->type() == "Todo" ) {
566 if (mIncidence->hasStartDate()) 566 if (mIncidence->hasStartDate())
567 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 567 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
568 if (((Todo*)mIncidence)->hasDueDate()) 568 if (((Todo*)mIncidence)->hasDueDate())
569 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 569 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
570 } 570 }
571 } else if ( mIncidence->type() == "Todo" ) { 571 } else if ( mIncidence->type() == "Todo" ) {
572 if (mIncidence->hasStartDate()) 572 if (mIncidence->hasStartDate())
573 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 573 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
574 if (((Todo*)mIncidence)->hasDueDate()) 574 if (((Todo*)mIncidence)->hasDueDate())
575 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 575 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
576 } 576 }
577 577
578 if (!mIncidence->location().isEmpty()) { 578 if (!mIncidence->location().isEmpty()) {
579 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 579 tipText += "\n"+i18n("Location: ")+mIncidence->location();
580 } 580 }
581 QToolTip::add(this,tipText,toolTipGroup(),""); 581 QToolTip::add(this,tipText,toolTipGroup(),"");
582 582
583} 583}
584void KOAgendaItem::updateItem() 584void KOAgendaItem::updateItem()
585{ 585{
586 computeText(); 586 computeText();
587 587
588 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 588 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
589 paintMe( mSelected ); 589 paintMe( mSelected );
590 repaint( false); 590 repaint( false);
591} 591}
592 592
593void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 593void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
594{ 594{
595 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 595 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
596 paintMe( mSelected ); 596 paintMe( mSelected );
597 repaint( false ); 597 repaint( false );
598} 598}
599 599
600/* 600/*
601 Return height of item in units of agenda cells 601 Return height of item in units of agenda cells
602*/ 602*/
603int KOAgendaItem::cellHeight() 603int KOAgendaItem::cellHeight()
604{ 604{
605 int ret = mCellYBottom - mCellYTop + 1; 605 int ret = mCellYBottom - mCellYTop + 1;
606 if ( ret <= 0 ) { 606 if ( ret <= 0 ) {
607 ret = 1; 607 ret = 1;
608 mCellYBottom = 0; 608 mCellYBottom = 0;
609 mCellYTop = 0; 609 mCellYTop = 0;
610 } 610 }
611 return ret; 611 return ret;
612} 612}
613 613
614/* 614/*
615 Return height of item in units of agenda cells 615 Return height of item in units of agenda cells
616*/ 616*/
617int KOAgendaItem::cellWidth() 617int KOAgendaItem::cellWidth()
618{ 618{
619 return mCellXWidth - mCellX + 1; 619 return mCellXWidth - mCellX + 1;
620} 620}
621 621
622void KOAgendaItem::setItemDate(QDate qd) 622void KOAgendaItem::setItemDate(QDate qd)
623{ 623{
624 mDate = qd; 624 mDate = qd;
625} 625}
626 626
627void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 627void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
628{ 628{
629 mCellX = X; 629 mCellX = X;
630 mCellYTop = YTop; 630 mCellYTop = YTop;
631 mCellYBottom = YBottom; 631 mCellYBottom = YBottom;
632} 632}
633 633
634void KOAgendaItem::setCellXWidth(int xwidth) 634void KOAgendaItem::setCellXWidth(int xwidth)
635{ 635{
636 mCellXWidth = xwidth; 636 mCellXWidth = xwidth;
637} 637}
638 638
639void KOAgendaItem::setCellX(int XLeft, int XRight) 639void KOAgendaItem::setCellX(int XLeft, int XRight)
640{ 640{
641 mCellX = XLeft; 641 mCellX = XLeft;
642 mCellXWidth = XRight; 642 mCellXWidth = XRight;
643} 643}
644 644
645void KOAgendaItem::setCellY(int YTop, int YBottom) 645void KOAgendaItem::setCellY(int YTop, int YBottom)
646{ 646{
647 mCellYTop = YTop; 647 mCellYTop = YTop;
648 mCellYBottom = YBottom; 648 mCellYBottom = YBottom;
649} 649}
650 650
651void KOAgendaItem::setSubCell(int subCell) 651void KOAgendaItem::setSubCell(int subCell)
652{ 652{
653 mSubCell = subCell; 653 mSubCell = subCell;
654} 654}
655 655
656void KOAgendaItem::setSubCells(int subCells) 656void KOAgendaItem::setSubCells(int subCells)
657{ 657{
658 mSubCells = subCells; 658 mSubCells = subCells;
659} 659}
660 660
661void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 661void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
662 KOAgendaItem *last) 662 KOAgendaItem *last)
663{ 663{
664 mFirstMultiItem = first; 664 mFirstMultiItem = first;
665 mNextMultiItem = next; 665 mNextMultiItem = next;
666 mLastMultiItem = last; 666 mLastMultiItem = last;
667} 667}
668 668
669void KOAgendaItem::startMove() 669void KOAgendaItem::startMove()
670{ 670{
671 mStartCellX = mCellX; 671 mStartCellX = mCellX;
672 mStartCellXWidth = mCellXWidth; 672 mStartCellXWidth = mCellXWidth;
673 mStartCellYTop = mCellYTop; 673 mStartCellYTop = mCellYTop;
674 mStartCellYBottom = mCellYBottom; 674 mStartCellYBottom = mCellYBottom;
675} 675}
676 676
677void KOAgendaItem::resetMove() 677void KOAgendaItem::resetMove()
678{ 678{
679 mCellX = mStartCellX; 679 mCellX = mStartCellX;
680 mCellXWidth = mStartCellXWidth; 680 mCellXWidth = mStartCellXWidth;
681 mCellYTop = mStartCellYTop; 681 mCellYTop = mStartCellYTop;
682 mCellYBottom = mStartCellYBottom; 682 mCellYBottom = mStartCellYBottom;
683} 683}
684 684
685void KOAgendaItem::moveRelative(int dx, int dy) 685void KOAgendaItem::moveRelative(int dx, int dy)
686{ 686{
687 int newX = cellX() + dx; 687 int newX = cellX() + dx;
688 int newXWidth = cellXWidth() + dx; 688 int newXWidth = cellXWidth() + dx;
689 int newYTop = cellYTop() + dy; 689 int newYTop = cellYTop() + dy;
690 int newYBottom = cellYBottom() + dy; 690 int newYBottom = cellYBottom() + dy;
691 setCellXY(newX,newYTop,newYBottom); 691 setCellXY(newX,newYTop,newYBottom);
692 setCellXWidth(newXWidth); 692 setCellXWidth(newXWidth);
693} 693}
694 694
695void KOAgendaItem::expandTop(int dy) 695void KOAgendaItem::expandTop(int dy)
696{ 696{
697 int newYTop = cellYTop() + dy; 697 int newYTop = cellYTop() + dy;
698 int newYBottom = cellYBottom(); 698 int newYBottom = cellYBottom();
699 if (newYTop > newYBottom) newYTop = newYBottom; 699 if (newYTop > newYBottom) newYTop = newYBottom;
700 setCellY(newYTop, newYBottom); 700 setCellY(newYTop, newYBottom);
701} 701}
702 702
703void KOAgendaItem::expandBottom(int dy) 703void KOAgendaItem::expandBottom(int dy)
704{ 704{
705 int newYTop = cellYTop(); 705 int newYTop = cellYTop();
706 int newYBottom = cellYBottom() + dy; 706 int newYBottom = cellYBottom() + dy;
707 if (newYBottom < newYTop) newYBottom = newYTop; 707 if (newYBottom < newYTop) newYBottom = newYTop;
708 setCellY(newYTop, newYBottom); 708 setCellY(newYTop, newYBottom);
709} 709}
710 710
711void KOAgendaItem::expandLeft(int dx) 711void KOAgendaItem::expandLeft(int dx)
712{ 712{
713 int newX = cellX() + dx; 713 int newX = cellX() + dx;
714 int newXWidth = cellXWidth(); 714 int newXWidth = cellXWidth();
715 if (newX > newXWidth) newX = newXWidth; 715 if (newX > newXWidth) newX = newXWidth;
716 setCellX(newX,newXWidth); 716 setCellX(newX,newXWidth);
717} 717}
718 718
719void KOAgendaItem::expandRight(int dx) 719void KOAgendaItem::expandRight(int dx)
720{ 720{
721 int newX = cellX(); 721 int newX = cellX();
722 int newXWidth = cellXWidth() + dx; 722 int newXWidth = cellXWidth() + dx;
723 if (newXWidth < newX) newXWidth = newX; 723 if (newXWidth < newX) newXWidth = newX;
724 setCellX(newX,newXWidth); 724 setCellX(newX,newXWidth);
725} 725}
726 726
727QToolTipGroup *KOAgendaItem::toolTipGroup() 727QToolTipGroup *KOAgendaItem::toolTipGroup()
728{ 728{
729 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 729 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
730 return mToolTipGroup; 730 return mToolTipGroup;
731} 731}
732 732
733void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 733void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
734{ 734{
735#ifndef KORG_NODND 735#ifndef KORG_NODND
736 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 736 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
737 !QTextDrag::canDecode( e ) ) { 737 !QTextDrag::canDecode( e ) ) {
738 e->ignore(); 738 e->ignore();
739 return; 739 return;
740 } 740 }
741 e->accept(); 741 e->accept();
742#endif 742#endif
743} 743}
744 744
745void KOAgendaItem::dropEvent( QDropEvent *e ) 745void KOAgendaItem::dropEvent( QDropEvent *e )
746{ 746{
747#ifndef KORG_NODND 747#ifndef KORG_NODND
748 QString text; 748 QString text;
749 if(QTextDrag::decode(e,text)) 749 if(QTextDrag::decode(e,text))
750 { 750 {
751 kdDebug() << "Dropped : " << text << endl; 751 kdDebug() << "Dropped : " << text << endl;
752 QStringList emails = QStringList::split(",",text); 752 QStringList emails = QStringList::split(",",text);
753 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 753 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
754 kdDebug() << " Email: " << (*it) << endl; 754 kdDebug() << " Email: " << (*it) << endl;
755 int pos = (*it).find("<"); 755 int pos = (*it).find("<");
756 QString name = (*it).left(pos); 756 QString name = (*it).left(pos);
757 QString email = (*it).mid(pos); 757 QString email = (*it).mid(pos);
758 if (!email.isEmpty()) { 758 if (!email.isEmpty()) {
759 mIncidence->addAttendee(new Attendee(name,email)); 759 mIncidence->addAttendee(new Attendee(name,email));
760 } 760 }
761 } 761 }
762 } 762 }
763#endif 763#endif
764} 764}
765 765
766 766
767QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 767QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
768{ 768{
769 return mConflictItems; 769 return mConflictItems;
770} 770}
771 771
772void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 772void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
773{ 773{
774 mConflictItems = ci; 774 mConflictItems = ci;
775 KOAgendaItem *item; 775 KOAgendaItem *item;
776 for ( item=mConflictItems.first(); item != 0; 776 for ( item=mConflictItems.first(); item != 0;
777 item=mConflictItems.next() ) { 777 item=mConflictItems.next() ) {
778 item->addConflictItem(this); 778 item->addConflictItem(this);
779 } 779 }
780} 780}
781 781
782void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 782void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
783{ 783{
784 if (mConflictItems.find(ci)<0) 784 if (mConflictItems.find(ci)<0)
785 mConflictItems.append(ci); 785 mConflictItems.append(ci);
786} 786}
787 787
788bool KOAgendaItem::checkLayout() 788bool KOAgendaItem::checkLayout()
789{ 789{
790 if ( !mConflictItems.count() ) 790 if ( !mConflictItems.count() )
791 return true; 791 return true;
792 int max = 0; 792 int max = 0;
793 KOAgendaItem *item; 793 KOAgendaItem *item;
794 for ( item=mConflictItems.first(); item != 0; 794 for ( item=mConflictItems.first(); item != 0;
795 item=mConflictItems.next() ) { 795 item=mConflictItems.next() ) {
796 if ( item->subCells() > max ) 796 if ( item->subCells() > max )
797 max = item->subCells(); 797 max = item->subCells();
798 } 798 }
799 if ( max > subCells() ) { 799 if ( max > subCells() ) {
800 setSubCells( max ); 800 setSubCells( max );
801 return false; 801 return false;
802 } 802 }
803 return true; 803 return true;
804} 804}
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index eb3a6cd..5508210 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,653 +1,654 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 mRows = rows; 84 mRows = rows;
85 85
86 setMinimumHeight( 20 ); 86 setMinimumHeight( 20 );
87 mCellHeight = KOPrefs::instance()->mHourSize*4; 87 mCellHeight = KOPrefs::instance()->mHourSize*4;
88 88
89 enableClipper(true); 89 enableClipper(true);
90 90
91 setHScrollBarMode(AlwaysOff); 91 setHScrollBarMode(AlwaysOff);
92 setVScrollBarMode(AlwaysOff); 92 setVScrollBarMode(AlwaysOff);
93 93
94 resizeContents(50,mRows * mCellHeight); 94 resizeContents(50,mRows * mCellHeight);
95 95
96 viewport()->setBackgroundMode( PaletteBackground ); 96 viewport()->setBackgroundMode( PaletteBackground );
97} 97}
98 98
99void TimeLabels::setCellHeight(int height) 99void TimeLabels::setCellHeight(int height)
100{ 100{
101 mCellHeight = height; 101 mCellHeight = height;
102} 102}
103 103
104/* 104/*
105 Optimization so that only the "dirty" portion of the scroll view 105 Optimization so that only the "dirty" portion of the scroll view
106 is redrawn. Unfortunately, this is not called by default paintEvent() method. 106 is redrawn. Unfortunately, this is not called by default paintEvent() method.
107*/ 107*/
108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
109{ 109{
110 110
111 // if ( globalFlagBlockAgenda ) 111 // if ( globalFlagBlockAgenda )
112 // return; 112 // return;
113 // bug: the parameters cx, cy, cw, ch are the areas that need to be 113 // bug: the parameters cx, cy, cw, ch are the areas that need to be
114 // redrawn, not the area of the widget. unfortunately, this 114 // redrawn, not the area of the widget. unfortunately, this
115 // code assumes the latter... 115 // code assumes the latter...
116 116
117 // now, for a workaround... 117 // now, for a workaround...
118 // these two assignments fix the weird redraw bug 118 // these two assignments fix the weird redraw bug
119 cx = contentsX() + 2; 119 cx = contentsX() + 2;
120 cw = contentsWidth() - 2; 120 cw = contentsWidth() - 2;
121 // end of workaround 121 // end of workaround
122 122
123 int cell = ((int)(cy/mCellHeight)); 123 int cell = ((int)(cy/mCellHeight));
124 int y = cell * mCellHeight; 124 int y = cell * mCellHeight;
125 QFontMetrics fm = fontMetrics(); 125 QFontMetrics fm = fontMetrics();
126 QString hour; 126 QString hour;
127 QString suffix; 127 QString suffix;
128 QString fullTime; 128 QString fullTime;
129 int tW = fm.width("24:00i"); 129 int tW = fm.width("24:00i");
130 130
131 while (y < cy + ch) { 131 while (y < cy + ch) {
132 p->drawLine(cx,y,cx+tW,y); 132 p->drawLine(cx,y,cx+tW,y);
133 hour.setNum(cell); 133 hour.setNum(cell);
134 suffix = "am"; 134 suffix = "am";
135 135
136 // handle 24h and am/pm time formats 136 // handle 24h and am/pm time formats
137 if (KGlobal::locale()->use12Clock()) { 137 if (KGlobal::locale()->use12Clock()) {
138 if (cell > 11) suffix = "pm"; 138 if (cell > 11) suffix = "pm";
139 if (cell == 0) hour.setNum(12); 139 if (cell == 0) hour.setNum(12);
140 if (cell > 12) hour.setNum(cell - 12); 140 if (cell > 12) hour.setNum(cell - 12);
141 } else { 141 } else {
142 suffix = ":00"; 142 suffix = ":00";
143 } 143 }
144 144
145 // create string in format of "XX:XX" or "XXpm/am" 145 // create string in format of "XX:XX" or "XXpm/am"
146 fullTime = hour + suffix; 146 fullTime = hour + suffix;
147 147
148 // center and draw the time label 148 // center and draw the time label
149 int timeWidth = fm.width(fullTime+"i"); 149 int timeWidth = fm.width(fullTime+"i");
150 int offset = this->width() - timeWidth; 150 int offset = this->width() - timeWidth;
151 int borderWidth = 5; 151 int borderWidth = 5;
152 int timeHeight = fm.height(); 152 int timeHeight = fm.height();
153 timeHeight = timeHeight + 2 - ( timeHeight / 4 ); 153 timeHeight = timeHeight + 2 - ( timeHeight / 4 );
154 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); 154 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime);
155 155
156 // increment indices 156 // increment indices
157 y += mCellHeight; 157 y += mCellHeight;
158 cell++; 158 cell++;
159 } 159 }
160} 160}
161 161
162/** 162/**
163 Calculates the minimum width. 163 Calculates the minimum width.
164*/ 164*/
165int TimeLabels::minimumWidth() const 165int TimeLabels::minimumWidth() const
166{ 166{
167 QFontMetrics fm = fontMetrics(); 167 QFontMetrics fm = fontMetrics();
168 168
169 //TODO: calculate this value 169 //TODO: calculate this value
170 int borderWidth = 4; 170 int borderWidth = 4;
171 171
172 // the maximum width possible 172 // the maximum width possible
173 int width = fm.width("88:88x") + borderWidth; 173 int width = fm.width("88:88x") + borderWidth;
174 174
175 return width; 175 return width;
176} 176}
177 177
178/** updates widget's internal state */ 178/** updates widget's internal state */
179void TimeLabels::updateConfig() 179void TimeLabels::updateConfig()
180{ 180{
181 // set the font 181 // set the font
182 // config->setGroup("Fonts"); 182 // config->setGroup("Fonts");
183 // QFont font = config->readFontEntry("TimeBar Font"); 183 // QFont font = config->readFontEntry("TimeBar Font");
184 setFont(KOPrefs::instance()->mTimeBarFont); 184 setFont(KOPrefs::instance()->mTimeBarFont);
185 185
186 // update geometry restrictions based on new settings 186 // update geometry restrictions based on new settings
187 setFixedWidth(minimumWidth()); 187 setFixedWidth(minimumWidth());
188 188
189 // update HourSize 189 // update HourSize
190 mCellHeight = KOPrefs::instance()->mHourSize*4; 190 mCellHeight = KOPrefs::instance()->mHourSize*4;
191 resizeContents(50,mRows * mCellHeight); 191 resizeContents(50,mRows * mCellHeight);
192} 192}
193 193
194/** update time label positions */ 194/** update time label positions */
195void TimeLabels::positionChanged() 195void TimeLabels::positionChanged()
196{ 196{
197 int adjustment = mAgenda->contentsY(); 197 int adjustment = mAgenda->contentsY();
198 setContentsPos(0, adjustment); 198 setContentsPos(0, adjustment);
199} 199}
200 200
201/** */ 201/** */
202void TimeLabels::setAgenda(KOAgenda* agenda) 202void TimeLabels::setAgenda(KOAgenda* agenda)
203{ 203{
204 mAgenda = agenda; 204 mAgenda = agenda;
205} 205}
206 206
207void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 207void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
208{ 208{
209 mMouseDownY = e->pos().y(); 209 mMouseDownY = e->pos().y();
210 mOrgCap = topLevelWidget()->caption(); 210 mOrgCap = topLevelWidget()->caption();
211} 211}
212 212
213void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 213void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
214{ 214{
215 int diff = mMouseDownY - e->pos().y(); 215 int diff = mMouseDownY - e->pos().y();
216 if ( diff < 10 && diff > -10 ) 216 if ( diff < 10 && diff > -10 )
217 return; 217 return;
218 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 218 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
219 if ( tSize < 4 ) 219 if ( tSize < 4 )
220 tSize = 4; 220 tSize = 4;
221 if ( tSize > 22 ) 221 if ( tSize > 22 )
222 tSize = 22; 222 tSize = 22;
223 tSize = (tSize-2)/2; 223 tSize = (tSize-2)/2;
224 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 224 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
225 225
226} 226}
227void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 227void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
228{ 228{
229 topLevelWidget()->setCaption( mOrgCap ); 229 topLevelWidget()->setCaption( mOrgCap );
230 int diff = mMouseDownY - e->pos().y(); 230 int diff = mMouseDownY - e->pos().y();
231 if ( diff < 10 && diff > -10 ) 231 if ( diff < 10 && diff > -10 )
232 return; 232 return;
233 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 233 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
234 if ( tSize < 4 ) 234 if ( tSize < 4 )
235 tSize = 4; 235 tSize = 4;
236 if ( tSize > 22 ) 236 if ( tSize > 22 )
237 tSize = 22; 237 tSize = 22;
238 tSize = (tSize/2)*2; 238 tSize = (tSize/2)*2;
239 if ( tSize == KOPrefs::instance()->mHourSize ) 239 if ( tSize == KOPrefs::instance()->mHourSize )
240 return; 240 return;
241 KOPrefs::instance()->mHourSize = tSize; 241 KOPrefs::instance()->mHourSize = tSize;
242 emit scaleChanged(); 242 emit scaleChanged();
243} 243}
244 244
245/** This is called in response to repaint() */ 245/** This is called in response to repaint() */
246void TimeLabels::paintEvent(QPaintEvent*) 246void TimeLabels::paintEvent(QPaintEvent*)
247{ 247{
248 248
249 // kdDebug() << "paintevent..." << endl; 249 // kdDebug() << "paintevent..." << endl;
250 // this is another hack! 250 // this is another hack!
251 // QPainter painter(this); 251 // QPainter painter(this);
252 //QString c 252 //QString c
253 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 253 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
254} 254}
255 255
256//////////////////////////////////////////////////////////////////////////// 256////////////////////////////////////////////////////////////////////////////
257 257
258EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 258EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
259 : QFrame(parent,name) 259 : QFrame(parent,name)
260{ 260{
261 mColumns = 1; 261 mColumns = 1;
262 mTopBox = 0; 262 mTopBox = 0;
263 mLocation = loc; 263 mLocation = loc;
264 mTopLayout = 0; 264 mTopLayout = 0;
265 mPaintWidget = 0; 265 mPaintWidget = 0;
266 mXOffset = 0; 266 mXOffset = 0;
267 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 267 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
268 else mPixmap = SmallIcon("1downarrow"); 268 else mPixmap = SmallIcon("1downarrow");
269 mEnabled.resize(mColumns); 269 mEnabled.resize(mColumns);
270 mEnabled.fill( false );
270 setMinimumHeight(mPixmap.height()); 271 setMinimumHeight(mPixmap.height());
271} 272}
272 273
273EventIndicator::~EventIndicator() 274EventIndicator::~EventIndicator()
274{ 275{
275} 276}
276 277
277void EventIndicator::drawContents(QPainter *p) 278void EventIndicator::drawContents(QPainter *p)
278{ 279{
279 280
280 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 281 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
281 KDGanttSplitterHandle* han = 0; 282 KDGanttSplitterHandle* han = 0;
282 if ( mPaintWidget ) 283 if ( mPaintWidget )
283 han = mPaintWidget->firstHandle(); 284 han = mPaintWidget->firstHandle();
284 if ( ! han ) { 285 if ( ! han ) {
285 int i; 286 int i;
286 for(i=0;i<mColumns;++i) { 287 for(i=0;i<mColumns;++i) {
287 if (mEnabled[i]) { 288 if (mEnabled[i]) {
288 int cellWidth = contentsRect().right()/mColumns; 289 int cellWidth = contentsRect().right()/mColumns;
289 int xOffset = KOGlobals::self()->reverseLayout() ? 290 int xOffset = KOGlobals::self()->reverseLayout() ?
290 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 291 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
291 i*cellWidth + (cellWidth -mPixmap.width()) /2; 292 i*cellWidth + (cellWidth -mPixmap.width()) /2;
292 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 293 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
293 } 294 }
294 } 295 }
295 } else { 296 } else {
296 han->repaint(); 297 han->repaint();
297 //mPaintWidget->setBackgroundColor( red ); 298 //mPaintWidget->setBackgroundColor( red );
298 299
299 QPainter pa( han ); 300 QPainter pa( han );
300 int i; 301 int i;
301 bool setColor = false; 302 bool setColor = false;
302 for(i=0;i<mColumns;++i) { 303 for(i=0;i<mColumns;++i) {
303 if (mEnabled[i]) { 304 if (mEnabled[i]) {
304 setColor = true; 305 setColor = true;
305 306
306 int cellWidth = contentsRect().right()/mColumns; 307 int cellWidth = contentsRect().right()/mColumns;
307 int xOffset = KOGlobals::self()->reverseLayout() ? 308 int xOffset = KOGlobals::self()->reverseLayout() ?
308 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 309 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
309 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 310 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
310 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 311 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
311 //qDebug("222draw pix %d ",xOffset ); 312 //qDebug("222draw pix %d ",xOffset );
312 313
313 } 314 }
314 315
315 } 316 }
316 pa.end(); 317 pa.end();
317 318
318 } 319 }
319} 320}
320 321
321void EventIndicator::setXOffset( int x ) 322void EventIndicator::setXOffset( int x )
322{ 323{
323 mXOffset = x; 324 mXOffset = x;
324} 325}
325void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 326void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
326{ 327{
327 mPaintWidget = w; 328 mPaintWidget = w;
328 setMaximumHeight(0); 329 setMaximumHeight(0);
329 setMinimumHeight(0); 330 setMinimumHeight(0);
330} 331}
331void EventIndicator::changeColumns(int columns) 332void EventIndicator::changeColumns(int columns)
332{ 333{
333 mColumns = columns; 334 mColumns = columns;
334 mEnabled.resize(mColumns); 335 mEnabled.resize(mColumns);
335 336
336 update(); 337 update();
337} 338}
338 339
339void EventIndicator::enableColumn(int column, bool enable) 340void EventIndicator::enableColumn(int column, bool enable)
340{ 341{
341 mEnabled[column] = enable; 342 mEnabled[column] = enable;
342} 343}
343 344
344 345
345//////////////////////////////////////////////////////////////////////////// 346////////////////////////////////////////////////////////////////////////////
346//////////////////////////////////////////////////////////////////////////// 347////////////////////////////////////////////////////////////////////////////
347//////////////////////////////////////////////////////////////////////////// 348////////////////////////////////////////////////////////////////////////////
348 349
349KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 350KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
350 KOEventView (cal,parent,name) 351 KOEventView (cal,parent,name)
351{ 352{
352 mBlockUpdating = true; 353 mBlockUpdating = true;
353 mStartHour = 8; 354 mStartHour = 8;
354 mSelectedDates.append(QDate::currentDate()); 355 mSelectedDates.append(QDate::currentDate());
355 356
356 mLayoutDayLabels = 0; 357 mLayoutDayLabels = 0;
357 mDayLabelsFrame = 0; 358 mDayLabelsFrame = 0;
358 mDayLabels = 0; 359 mDayLabels = 0;
359 bool isRTL = KOGlobals::self()->reverseLayout(); 360 bool isRTL = KOGlobals::self()->reverseLayout();
360 361
361 if ( KOPrefs::instance()->mVerticalScreen ) { 362 if ( KOPrefs::instance()->mVerticalScreen ) {
362 mExpandedPixmap = SmallIcon( "1downarrow" ); 363 mExpandedPixmap = SmallIcon( "1downarrow" );
363 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 364 mNotExpandedPixmap = SmallIcon( "1uparrow" );
364 } else { 365 } else {
365 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 366 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
366 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 367 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
367 } 368 }
368 369
369 QBoxLayout *topLayout = new QVBoxLayout(this); 370 QBoxLayout *topLayout = new QVBoxLayout(this);
370 371
371 // Create day name labels for agenda columns 372 // Create day name labels for agenda columns
372 // Create agenda splitter 373 // Create agenda splitter
373 374
374 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 375 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
375 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 376 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
376 topLayout->addWidget( mSplitterAgenda ); 377 topLayout->addWidget( mSplitterAgenda );
377 mAllDayFrame = new QHBox(mSplitterAgenda); 378 mAllDayFrame = new QHBox(mSplitterAgenda);
378 mAllDayFrame->setFocusPolicy(NoFocus); 379 mAllDayFrame->setFocusPolicy(NoFocus);
379 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 380 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
380 agendaFrame->setFocusPolicy(NoFocus); 381 agendaFrame->setFocusPolicy(NoFocus);
381 382
382 // Create all-day agenda widget 383 // Create all-day agenda widget
383 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 384 mDummyAllDayLeft = new QVBox( mAllDayFrame );
384 385
385 mExpandButton = new QPushButton(mDummyAllDayLeft); 386 mExpandButton = new QPushButton(mDummyAllDayLeft);
386 mExpandButton->setPixmap( mNotExpandedPixmap ); 387 mExpandButton->setPixmap( mNotExpandedPixmap );
387 int widebut = mExpandButton->sizeHint().width(); 388 int widebut = mExpandButton->sizeHint().width();
388 if ( QApplication::desktop()->width() < 480 ) 389 if ( QApplication::desktop()->width() < 480 )
389 widebut = widebut*2; 390 widebut = widebut*2;
390 else 391 else
391 widebut = (widebut*3) / 2; 392 widebut = (widebut*3) / 2;
392 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 393 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
393 // QSizePolicy::Fixed ) ); 394 // QSizePolicy::Fixed ) );
394 mExpandButton->setFixedSize( widebut, widebut); 395 mExpandButton->setFixedSize( widebut, widebut);
395 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 396 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
396 mExpandButton->setFocusPolicy(NoFocus); 397 mExpandButton->setFocusPolicy(NoFocus);
397 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 398 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
398 mAllDayAgenda->setFocusPolicy(NoFocus); 399 mAllDayAgenda->setFocusPolicy(NoFocus);
399 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 400 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
400 401
401 // Create event context menu for all day agenda 402 // Create event context menu for all day agenda
402 mAllDayAgendaPopup = eventPopup(); 403 mAllDayAgendaPopup = eventPopup();
403 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 404 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
404 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 405 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
405 406
406 // Create agenda frame 407 // Create agenda frame
407 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 408 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
408 // QHBox *agendaFrame = new QHBox(splitterAgenda); 409 // QHBox *agendaFrame = new QHBox(splitterAgenda);
409 410
410 // create event indicator bars 411 // create event indicator bars
411 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 412 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
412#ifndef DESKTOP_VERSION 413#ifndef DESKTOP_VERSION
413 // FIX 414 // FIX
414 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 415 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
415#endif 416#endif
416 mDayLabelsFrame = new QHBox(agendaFrame); 417 mDayLabelsFrame = new QHBox(agendaFrame);
417 //topLayout->addWidget(mDayLabelsFrame); 418 //topLayout->addWidget(mDayLabelsFrame);
418 mDayLabels = new QFrame (mDayLabelsFrame); 419 mDayLabels = new QFrame (mDayLabelsFrame);
419 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 420 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
420 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 421 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
421 agendaLayout->addWidget(mEventIndicatorTop,1,1); 422 agendaLayout->addWidget(mEventIndicatorTop,1,1);
422 423
423 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 424 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
424 agendaFrame); 425 agendaFrame);
425 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 426 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
426 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 427 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
427 agendaLayout->addWidget(dummyAgendaRight,1,2); 428 agendaLayout->addWidget(dummyAgendaRight,1,2);
428 429
429 // Create time labels 430 // Create time labels
430 mTimeLabels = new TimeLabels(24,agendaFrame); 431 mTimeLabels = new TimeLabels(24,agendaFrame);
431 agendaLayout->addWidget(mTimeLabels,2,0); 432 agendaLayout->addWidget(mTimeLabels,2,0);
432 connect(mTimeLabels,SIGNAL( scaleChanged()), 433 connect(mTimeLabels,SIGNAL( scaleChanged()),
433 this,SLOT(updateConfig())); 434 this,SLOT(updateConfig()));
434 435
435 // Create agenda 436 // Create agenda
436 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 437 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
437 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 438 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
438 agendaLayout->setColStretch(1,1); 439 agendaLayout->setColStretch(1,1);
439 mAgenda->setFocusPolicy(NoFocus); 440 mAgenda->setFocusPolicy(NoFocus);
440 // Create event context menu for agenda 441 // Create event context menu for agenda
441 mAgendaPopup = eventPopup(); 442 mAgendaPopup = eventPopup();
442 443
443 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 444 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
444 i18n("Toggle Alarm"),mAgenda, 445 i18n("Toggle Alarm"),mAgenda,
445 SLOT(popupAlarm()),true); 446 SLOT(popupAlarm()),true);
446 447
447 448
448 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 449 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
449 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 450 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
450 451
451 // make connections between dependent widgets 452 // make connections between dependent widgets
452 mTimeLabels->setAgenda(mAgenda); 453 mTimeLabels->setAgenda(mAgenda);
453 454
454 // Update widgets to reflect user preferences 455 // Update widgets to reflect user preferences
455 // updateConfig(); 456 // updateConfig();
456 457
457 // createDayLabels(); 458 // createDayLabels();
458 459
459 // these blank widgets make the All Day Event box line up with the agenda 460 // these blank widgets make the All Day Event box line up with the agenda
460 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 461 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
461 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 462 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
462 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 463 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
463 464
464 // Scrolling 465 // Scrolling
465 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 466 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
466 mTimeLabels, SLOT(positionChanged())); 467 mTimeLabels, SLOT(positionChanged()));
467 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 468 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
468 SLOT(setContentsPos(int))); 469 SLOT(setContentsPos(int)));
469 470
470 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 471 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
471 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 472 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
472 473
473 // Create/Show/Edit/Delete Event 474 // Create/Show/Edit/Delete Event
474 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 475 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
475 SLOT(newEvent(int,int))); 476 SLOT(newEvent(int,int)));
476 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 477 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
477 SLOT(newTodo(int,int))); 478 SLOT(newTodo(int,int)));
478 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 479 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
479 SLOT(newEvent(int,int,int,int))); 480 SLOT(newEvent(int,int,int,int)));
480 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 481 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
481 SLOT(newEventAllDay(int,int))); 482 SLOT(newEventAllDay(int,int)));
482 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 483 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
483 SLOT(newTodoAllDay(int,int))); 484 SLOT(newTodoAllDay(int,int)));
484 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 485 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
485 SLOT(newEventAllDay(int,int))); 486 SLOT(newEventAllDay(int,int)));
486 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 487 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
487 SLOT(newTimeSpanSelected(int,int,int,int))); 488 SLOT(newTimeSpanSelected(int,int,int,int)));
488 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 489 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
489 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 490 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
490 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 491 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
491 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 492 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
492 493
493 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 494 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
494 SIGNAL(editIncidenceSignal(Incidence *))); 495 SIGNAL(editIncidenceSignal(Incidence *)));
495 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 496 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
496 SIGNAL(editIncidenceSignal(Incidence *))); 497 SIGNAL(editIncidenceSignal(Incidence *)));
497 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 498 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
498 SIGNAL(showIncidenceSignal(Incidence *))); 499 SIGNAL(showIncidenceSignal(Incidence *)));
499 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 500 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
500 SIGNAL(showIncidenceSignal(Incidence *))); 501 SIGNAL(showIncidenceSignal(Incidence *)));
501 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 502 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
502 SIGNAL(deleteIncidenceSignal(Incidence *))); 503 SIGNAL(deleteIncidenceSignal(Incidence *)));
503 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 504 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
504 SIGNAL(deleteIncidenceSignal(Incidence *))); 505 SIGNAL(deleteIncidenceSignal(Incidence *)));
505 506
506 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 507 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
507 SLOT(updateEventDates(KOAgendaItem *, int ))); 508 SLOT(updateEventDates(KOAgendaItem *, int )));
508 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 509 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
509 SLOT(updateEventDates(KOAgendaItem *, int))); 510 SLOT(updateEventDates(KOAgendaItem *, int)));
510 511
511 // event indicator update 512 // event indicator update
512 connect(mAgenda,SIGNAL(lowerYChanged(int)), 513 connect(mAgenda,SIGNAL(lowerYChanged(int)),
513 SLOT(updateEventIndicatorTop(int))); 514 SLOT(updateEventIndicatorTop(int)));
514 connect(mAgenda,SIGNAL(upperYChanged(int)), 515 connect(mAgenda,SIGNAL(upperYChanged(int)),
515 SLOT(updateEventIndicatorBottom(int))); 516 SLOT(updateEventIndicatorBottom(int)));
516 // drag signals 517 // drag signals
517 /* 518 /*
518 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 519 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
519 SLOT(startDrag(Event *))); 520 SLOT(startDrag(Event *)));
520 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 521 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
521 SLOT(startDrag(Event *))); 522 SLOT(startDrag(Event *)));
522 */ 523 */
523 // synchronize selections 524 // synchronize selections
524 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 525 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
525 mAllDayAgenda, SLOT( deselectItem() ) ); 526 mAllDayAgenda, SLOT( deselectItem() ) );
526 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 527 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
527 mAgenda, SLOT( deselectItem() ) ); 528 mAgenda, SLOT( deselectItem() ) );
528 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 529 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
529 SIGNAL( incidenceSelected( Incidence * ) ) ); 530 SIGNAL( incidenceSelected( Incidence * ) ) );
530 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 531 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
531 SIGNAL( incidenceSelected( Incidence * ) ) ); 532 SIGNAL( incidenceSelected( Incidence * ) ) );
532 connect( mAgenda, SIGNAL( resizedSignal() ), 533 connect( mAgenda, SIGNAL( resizedSignal() ),
533 SLOT( updateConfig( ) ) ); 534 SLOT( updateConfig( ) ) );
534 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 535 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
535 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 536 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
536 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 537 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
537 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 538 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
538 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 539 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
539 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 540 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
540 541
541 542
542} 543}
543 544
544void KOAgendaView::toggleAllDay() 545void KOAgendaView::toggleAllDay()
545{ 546{
546 if ( mSplitterAgenda->firstHandle() ) 547 if ( mSplitterAgenda->firstHandle() )
547 mSplitterAgenda->firstHandle()->toggle(); 548 mSplitterAgenda->firstHandle()->toggle();
548} 549}
549void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 550void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
550{ 551{
551 calendar()->addIncidence( inc ); 552 calendar()->addIncidence( inc );
552 553
553 if ( incOld ) { 554 if ( incOld ) {
554 if ( incOld->type() == "Todo" ) 555 if ( incOld->type() == "Todo" )
555 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 556 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
556 else 557 else
557 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 558 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
558 } 559 }
559 560
560} 561}
561 562
562KOAgendaView::~KOAgendaView() 563KOAgendaView::~KOAgendaView()
563{ 564{
564 delete mAgendaPopup; 565 delete mAgendaPopup;
565 delete mAllDayAgendaPopup; 566 delete mAllDayAgendaPopup;
566 delete KOAgendaItem::paintPix(); 567 delete KOAgendaItem::paintPix();
567 delete KOAgendaItem::paintPixSel(); 568 delete KOAgendaItem::paintPixSel();
568} 569}
569void KOAgendaView::resizeEvent( QResizeEvent* e ) 570void KOAgendaView::resizeEvent( QResizeEvent* e )
570{ 571{
571 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 572 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
572 bool uc = false; 573 bool uc = false;
573 int ow = e->oldSize().width(); 574 int ow = e->oldSize().width();
574 int oh = e->oldSize().height(); 575 int oh = e->oldSize().height();
575 int w = e->size().width(); 576 int w = e->size().width();
576 int h = e->size().height(); 577 int h = e->size().height();
577 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 578 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
578 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 579 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
579 uc = true; 580 uc = true;
580 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 581 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
581 } 582 }
582 mUpcomingWidth = e->size().width() ; 583 mUpcomingWidth = e->size().width() ;
583 if ( mBlockUpdating || uc ) { 584 if ( mBlockUpdating || uc ) {
584 mBlockUpdating = false; 585 mBlockUpdating = false;
585 //mAgenda->setMinimumSize(800 , 600 ); 586 //mAgenda->setMinimumSize(800 , 600 );
586 //qDebug("mAgenda->resize+++++++++++++++ "); 587 //qDebug("mAgenda->resize+++++++++++++++ ");
587 updateConfig(); 588 updateConfig();
588 //qDebug("KOAgendaView::Updating now possible "); 589 //qDebug("KOAgendaView::Updating now possible ");
589 } else 590 } else
590 createDayLabels(); 591 createDayLabels();
591 //qDebug("resizeEvent end "); 592 //qDebug("resizeEvent end ");
592 593
593} 594}
594void KOAgendaView::slotDaylabelClicked( int num ) 595void KOAgendaView::slotDaylabelClicked( int num )
595{ 596{
596 597
597 QDate firstDate = mSelectedDates.first(); 598 QDate firstDate = mSelectedDates.first();
598 if ( num == -1 ) 599 if ( num == -1 )
599 emit showDateView( 6, firstDate ); 600 emit showDateView( 6, firstDate );
600 else if (num >= 0 ) { 601 else if (num >= 0 ) {
601 if ( mSelectedDates.count() == 1) 602 if ( mSelectedDates.count() == 1)
602 emit showDateView( 9, firstDate.addDays( num ) ); 603 emit showDateView( 9, firstDate.addDays( num ) );
603 else 604 else
604 emit showDateView( 3, firstDate.addDays( num ) ); 605 emit showDateView( 3, firstDate.addDays( num ) );
605 } 606 }
606 else 607 else
607 showDateView( 10, firstDate.addDays(1) ); 608 showDateView( 10, firstDate.addDays(1) );
608} 609}
609 610
610KOAgendaButton* KOAgendaView::getNewDaylabel() 611KOAgendaButton* KOAgendaView::getNewDaylabel()
611{ 612{
612 613
613 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 614 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
614 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 615 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
615 mDayLabelsList.append( dayLabel ); 616 mDayLabelsList.append( dayLabel );
616 mLayoutDayLabels->addWidget(dayLabel); 617 mLayoutDayLabels->addWidget(dayLabel);
617 return dayLabel ; 618 return dayLabel ;
618} 619}
619 620
620void KOAgendaView::createDayLabels() 621void KOAgendaView::createDayLabels()
621{ 622{
622 623
623 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 624 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
624 // qDebug(" KOAgendaView::createDayLabels() blocked "); 625 // qDebug(" KOAgendaView::createDayLabels() blocked ");
625 return; 626 return;
626 627
627 } 628 }
628 int newHight; 629 int newHight;
629 630
630 // ### Before deleting and recreating we could check if mSelectedDates changed... 631 // ### Before deleting and recreating we could check if mSelectedDates changed...
631 // It would remove some flickering and gain speed (since this is called by 632 // It would remove some flickering and gain speed (since this is called by
632 // each updateView() call) 633 // each updateView() call)
633 634
634 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 635 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
635 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 636 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
636 if ( maxWid < 0 ) 637 if ( maxWid < 0 )
637 maxWid = 20; 638 maxWid = 20;
638 639
639 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 640 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
640 QFontMetrics fm ( dlf ); 641 QFontMetrics fm ( dlf );
641 int selCount = mSelectedDates.count(); 642 int selCount = mSelectedDates.count();
642 QString dayTest = "Mon 20"; 643 QString dayTest = "Mon 20";
643 //QString dayTest = "Mon 20"; 644 //QString dayTest = "Mon 20";
644 int wid = fm.width( dayTest ); 645 int wid = fm.width( dayTest );
645 //maxWid -= ( selCount * 3 ); //working for QLabels 646 //maxWid -= ( selCount * 3 ); //working for QLabels
646 maxWid -= ( selCount * 3 ); //working for QPushButton 647 maxWid -= ( selCount * 3 ); //working for QPushButton
647 if ( maxWid < 0 ) 648 if ( maxWid < 0 )
648 maxWid = 20; 649 maxWid = 20;
649 int needWid = wid * selCount; 650 int needWid = wid * selCount;
650 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 651 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
651 //if ( needWid > maxWid ) 652 //if ( needWid > maxWid )
652 // qDebug("DAYLABELS TOOOOOOO BIG "); 653 // qDebug("DAYLABELS TOOOOOOO BIG ");
653 while ( needWid > maxWid ) { 654 while ( needWid > maxWid ) {
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9fd1f68..8ee5bc3 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -613,1085 +613,1105 @@ void MonthViewCell::insertTodo(Todo *todo)
613 QString text; 613 QString text;
614 if (todo->hasDueDate()) { 614 if (todo->hasDueDate()) {
615 if (!todo->doesFloat()) { 615 if (!todo->doesFloat()) {
616 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 616 text += KGlobal::locale()->formatTime(todo->dtDue().time());
617 text += " "; 617 text += " ";
618 } 618 }
619 } 619 }
620 text += todo->summary(); 620 text += todo->summary();
621 621
622 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 622 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
623 //item->setPalette( mStandardPalette ); 623 //item->setPalette( mStandardPalette );
624 QPalette pal; 624 QPalette pal;
625 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 625 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
626 QStringList categories = todo->categories(); 626 QStringList categories = todo->categories();
627 QString cat = categories.first(); 627 QString cat = categories.first();
628 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 628 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
629 pal = getPalette(); 629 pal = getPalette();
630 if (cat.isEmpty()) { 630 if (cat.isEmpty()) {
631 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 631 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
632 } else { 632 } else {
633 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 633 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
634 } 634 }
635 635
636 } else { 636 } else {
637 if (cat.isEmpty()) { 637 if (cat.isEmpty()) {
638 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 638 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
639 } else { 639 } else {
640 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 640 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
641 } 641 }
642 } 642 }
643 643
644 } else { 644 } else {
645 pal = mStandardPalette ; 645 pal = mStandardPalette ;
646 } 646 }
647 item->setPalette( pal ); 647 item->setPalette( pal );
648 item->setRecur( todo->recurrence()->doesRecur() ); 648 item->setRecur( todo->recurrence()->doesRecur() );
649 item->setAlarm( todo->isAlarmEnabled() ); 649 item->setAlarm( todo->isAlarmEnabled() );
650 item->setMoreInfo( todo->description().length() > 0 ); 650 item->setMoreInfo( todo->description().length() > 0 );
651 mItemList->insertItem( item ); 651 mItemList->insertItem( item );
652 mToolTip.append( text ); 652 mToolTip.append( text );
653} 653}
654void MonthViewCell::finishUpdateCell() 654void MonthViewCell::finishUpdateCell()
655{ 655{
656#ifdef DESKTOP_VERSION 656#ifdef DESKTOP_VERSION
657 if (mToolTip.count() > 0 ) { 657 if (mToolTip.count() > 0 ) {
658 mToolTip.sort(); 658 mToolTip.sort();
659 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 659 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
660 } 660 }
661#endif 661#endif
662 mItemList->sort(); 662 mItemList->sort();
663 //setMyPalette(); 663 //setMyPalette();
664 setMyPalette(); 664 setMyPalette();
665 QString text; 665 QString text;
666 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 666 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
667 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 667 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
668 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 668 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
669 mLabel->resize( mLabelBigSize ); 669 mLabel->resize( mLabelBigSize );
670 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 670 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
671 } else { 671 } else {
672 mLabel->resize( mLabelSize ); 672 mLabel->resize( mLabelSize );
673 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 673 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
674 } 674 }
675 675
676 mLabel->setText( text ); 676 mLabel->setText( text );
677 resizeEvent( 0 ); 677 resizeEvent( 0 );
678} 678}
679void MonthViewCell::updateCell() 679void MonthViewCell::updateCell()
680{ 680{
681 //qDebug("MonthViewCell::updateCell() "); 681 //qDebug("MonthViewCell::updateCell() ");
682 if ( !mMonthView->isUpdatePossible() ) 682 if ( !mMonthView->isUpdatePossible() )
683 return; 683 return;
684 startUpdateCell(); 684 startUpdateCell();
685 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 685 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
686 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 686 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
687 Event *event; 687 Event *event;
688 for( event = events.first(); event; event = events.next() ) { // for event 688 for( event = events.first(); event; event = events.next() ) { // for event
689 insertEvent(event); 689 insertEvent(event);
690 } 690 }
691 // insert due todos 691 // insert due todos
692 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 692 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
693 Todo *todo; 693 Todo *todo;
694 for(todo = todos.first(); todo; todo = todos.next()) { 694 for(todo = todos.first(); todo; todo = todos.next()) {
695 insertTodo( todo ); 695 insertTodo( todo );
696 } 696 }
697 finishUpdateCell(); 697 finishUpdateCell();
698 // if ( isVisible()) 698 // if ( isVisible())
699 //qApp->processEvents(); 699 //qApp->processEvents();
700} 700}
701 701
702void MonthViewCell::updateConfig( bool bigFont ) // = false 702void MonthViewCell::updateConfig( bool bigFont ) // = false
703{ 703{
704 704
705 if ( bigFont ) { 705 if ( bigFont ) {
706 QFont fo = KOPrefs::instance()->mMonthViewFont; 706 QFont fo = KOPrefs::instance()->mMonthViewFont;
707 int ps = fo.pointSize() + 2; 707 int ps = fo.pointSize() + 2;
708 if ( ps < 18 ) 708 if ( ps < 18 )
709 ps += 2; 709 ps += 2;
710 fo.setPointSize( ps ); 710 fo.setPointSize( ps );
711 setFont( fo ); 711 setFont( fo );
712 } else 712 } else
713 setFont( KOPrefs::instance()->mMonthViewFont ); 713 setFont( KOPrefs::instance()->mMonthViewFont );
714 714
715 QFontMetrics fm( font() ); 715 QFontMetrics fm( font() );
716 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 716 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
717 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 717 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
718 mHolidayPalette = mStandardPalette; 718 mHolidayPalette = mStandardPalette;
719 mPrimaryPalette = mStandardPalette; 719 mPrimaryPalette = mStandardPalette;
720 mNonPrimaryPalette = mStandardPalette; 720 mNonPrimaryPalette = mStandardPalette;
721 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 721 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
722 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 722 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
723 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 723 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
724 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 724 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
725 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 725 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
726 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 726 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
727 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 727 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
728 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 728 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
729 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 729 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
730 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 730 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
731 } 731 }
732 //updateCell(); 732 //updateCell();
733} 733}
734 734
735void MonthViewCell::enableScrollBars( bool enabled ) 735void MonthViewCell::enableScrollBars( bool enabled )
736{ 736{
737 if ( enabled ) { 737 if ( enabled ) {
738 mItemList->setVScrollBarMode(QScrollView::Auto); 738 mItemList->setVScrollBarMode(QScrollView::Auto);
739 mItemList->setHScrollBarMode(QScrollView::Auto); 739 mItemList->setHScrollBarMode(QScrollView::Auto);
740 } else { 740 } else {
741 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 741 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
742 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 742 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
743 } 743 }
744} 744}
745 745
746Incidence *MonthViewCell::selectedIncidence() 746Incidence *MonthViewCell::selectedIncidence()
747{ 747{
748 int index = mItemList->currentItem(); 748 int index = mItemList->currentItem();
749 if ( index < 0 ) return 0; 749 if ( index < 0 ) return 0;
750 750
751 MonthViewItem *item = 751 MonthViewItem *item =
752 static_cast<MonthViewItem *>( mItemList->item( index ) ); 752 static_cast<MonthViewItem *>( mItemList->item( index ) );
753 753
754 if ( !item ) return 0; 754 if ( !item ) return 0;
755 755
756 return item->incidence(); 756 return item->incidence();
757} 757}
758 758
759QDate MonthViewCell::selectedIncidenceDate() 759QDate MonthViewCell::selectedIncidenceDate()
760{ 760{
761 QDate qd; 761 QDate qd;
762 int index = mItemList->currentItem(); 762 int index = mItemList->currentItem();
763 if ( index < 0 ) return qd; 763 if ( index < 0 ) return qd;
764 764
765 MonthViewItem *item = 765 MonthViewItem *item =
766 static_cast<MonthViewItem *>( mItemList->item( index ) ); 766 static_cast<MonthViewItem *>( mItemList->item( index ) );
767 767
768 if ( !item ) return qd; 768 if ( !item ) return qd;
769 769
770 return item->incidenceDate(); 770 return item->incidenceDate();
771} 771}
772 772
773void MonthViewCell::deselect() 773void MonthViewCell::deselect()
774{ 774{
775 mItemList->clearSelection(); 775 mItemList->clearSelection();
776 enableScrollBars( false ); 776 enableScrollBars( false );
777 // updateCell(); 777 // updateCell();
778} 778}
779void MonthViewCell::select() 779void MonthViewCell::select()
780{ 780{
781 ;// updateCell(); 781 ;// updateCell();
782} 782}
783 783
784void MonthViewCell::resizeEvent ( QResizeEvent * ) 784void MonthViewCell::resizeEvent ( QResizeEvent * )
785{ 785{
786 if ( !mMonthView->isUpdatePossible() ) 786 if ( !mMonthView->isUpdatePossible() )
787 return; 787 return;
788 788
789 int size = height() - mLabel->height() - 2; 789 int size = height() - mLabel->height() - 2;
790 if ( size > 0 ) 790 if ( size > 0 )
791 mItemList->verticalScrollBar()->setMaximumHeight( size ); 791 mItemList->verticalScrollBar()->setMaximumHeight( size );
792 size = width() - mLabel->width() -2; 792 size = width() - mLabel->width() -2;
793 if ( size > 0 ) 793 if ( size > 0 )
794 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 794 mItemList->horizontalScrollBar()->setMaximumWidth( size );
795 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 795 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
796 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 796 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
797} 797}
798 798
799void MonthViewCell::defaultAction( QListBoxItem *item ) 799void MonthViewCell::defaultAction( QListBoxItem *item )
800{ 800{
801 if ( !item ) return; 801 if ( !item ) return;
802 802
803 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 803 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
804 Incidence *incidence = eventItem->incidence(); 804 Incidence *incidence = eventItem->incidence();
805 if ( incidence ) mMonthView->defaultAction( incidence ); 805 if ( incidence ) mMonthView->defaultAction( incidence );
806} 806}
807void MonthViewCell::showDay() 807void MonthViewCell::showDay()
808{ 808{
809 emit showDaySignal( date() ); 809 emit showDaySignal( date() );
810} 810}
811void MonthViewCell::newEvent() 811void MonthViewCell::newEvent()
812{ 812{
813 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 813 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
814 emit newEventSignal( dt ); 814 emit newEventSignal( dt );
815} 815}
816void MonthViewCell::cellClicked( QListBoxItem *item ) 816void MonthViewCell::cellClicked( QListBoxItem *item )
817{ 817{
818 static QListBoxItem * lastClicked = 0; 818 static QListBoxItem * lastClicked = 0;
819 if ( item == 0 ) { 819 if ( item == 0 ) {
820 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 820 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
821 emit newEventSignal( dt ); 821 emit newEventSignal( dt );
822 return; 822 return;
823 } 823 }
824 /* 824 /*
825 if ( lastClicked ) 825 if ( lastClicked )
826 if ( ! item ) { 826 if ( ! item ) {
827 if ( lastClicked->listBox() != item->listBox() ) 827 if ( lastClicked->listBox() != item->listBox() )
828 lastClicked->listBox()->clearSelection(); 828 lastClicked->listBox()->clearSelection();
829 } 829 }
830 */ 830 */
831 831
832 mMonthView->setSelectedCell( this ); 832 mMonthView->setSelectedCell( this );
833 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 833 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
834 select(); 834 select();
835} 835}
836 836
837void MonthViewCell::contextMenu( QListBoxItem *item ) 837void MonthViewCell::contextMenu( QListBoxItem *item )
838{ 838{
839 if ( !item ) return; 839 if ( !item ) return;
840 840
841 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 841 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
842 Incidence *incidence = eventItem->incidence(); 842 Incidence *incidence = eventItem->incidence();
843 if ( incidence ) mMonthView->showContextMenu( incidence ); 843 if ( incidence ) mMonthView->showContextMenu( incidence );
844} 844}
845 845
846void MonthViewCell::selection( QListBoxItem *item ) 846void MonthViewCell::selection( QListBoxItem *item )
847{ 847{
848 if ( !item ) return; 848 if ( !item ) return;
849 849
850 mMonthView->setSelectedCell( this ); 850 mMonthView->setSelectedCell( this );
851} 851}
852 852
853 853
854// ******************************************************************************* 854// *******************************************************************************
855// ******************************************************************************* 855// *******************************************************************************
856// ******************************************************************************* 856// *******************************************************************************
857 857
858 858
859KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 859KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
860 : KOEventView( calendar, parent, name ), 860 : KOEventView( calendar, parent, name ),
861 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 861 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
862 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 862 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
863{ 863{
864 mShortDayLabelsM = false; 864 mShortDayLabelsM = false;
865 mShortDayLabelsW = false; 865 mShortDayLabelsW = false;
866 skipResize = false; 866 skipResize = false;
867 clPending = true; 867 clPending = true;
868 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 868 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
869 mWidStack = new QWidgetStack( this ); 869 mWidStack = new QWidgetStack( this );
870 QVBoxLayout* hb = new QVBoxLayout( this ); 870 QVBoxLayout* hb = new QVBoxLayout( this );
871 mMonthView = new QWidget( mWidStack ); 871 mMonthView = new QWidget( mWidStack );
872 mWeekView = new QWidget( mWidStack ); 872 mWeekView = new QWidget( mWidStack );
873#if QT_VERSION >= 0x030000 873#if QT_VERSION >= 0x030000
874 mWidStack->addWidget(mMonthView ); 874 mWidStack->addWidget(mMonthView );
875 mWidStack->addWidget(mWeekView ); 875 mWidStack->addWidget(mWeekView );
876#else 876#else
877 mWidStack->addWidget( mMonthView, 1 ); 877 mWidStack->addWidget( mMonthView, 1 );
878 mWidStack->addWidget( mWeekView , 1 ); 878 mWidStack->addWidget( mWeekView , 1 );
879#endif 879#endif
880 hb->addWidget( mNavigatorBar ); 880 hb->addWidget( mNavigatorBar );
881 hb->addWidget( mWidStack ); 881 hb->addWidget( mWidStack );
882 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 882 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
883 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 883 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
884 if ( mShowWeekView ) 884 if ( mShowWeekView )
885 mWeekStartsMonday = true; 885 mWeekStartsMonday = true;
886 updatePossible = false; 886 updatePossible = false;
887 //updatePossible = true; 887 //updatePossible = true;
888 mCells.setAutoDelete( true ); 888 mCells.setAutoDelete( true );
889 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 889 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
890 mDayLabels.resize( mDaysPerWeek ); 890 mDayLabels.resize( mDaysPerWeek );
891 mDayLabelsW.resize( mDaysPerWeek ); 891 mDayLabelsW.resize( mDaysPerWeek );
892 QFont bfont = font(); 892 QFont bfont = font();
893 if ( QApplication::desktop()->width() < 650 ) { 893 if ( QApplication::desktop()->width() < 650 ) {
894 bfont.setPointSize( bfont.pointSize() - 2 ); 894 bfont.setPointSize( bfont.pointSize() - 2 );
895 } 895 }
896 bfont.setBold( true ); 896 bfont.setBold( true );
897 int i; 897 int i;
898 898
899 for( i = 0; i < mDaysPerWeek; i++ ) { 899 for( i = 0; i < mDaysPerWeek; i++ ) {
900 QLabel *label = new QLabel( mMonthView ); 900 QLabel *label = new QLabel( mMonthView );
901 label->setFont(bfont); 901 label->setFont(bfont);
902 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 902 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
903 label->setLineWidth(1); 903 label->setLineWidth(1);
904 label->setAlignment(AlignCenter); 904 label->setAlignment(AlignCenter);
905 mDayLabels.insert( i, label ); 905 mDayLabels.insert( i, label );
906 label = new QLabel( mWeekView ); 906 label = new QLabel( mWeekView );
907 label->setFont(bfont); 907 label->setFont(bfont);
908 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 908 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
909 label->setLineWidth(1); 909 label->setLineWidth(1);
910 label->setAlignment(AlignCenter); 910 label->setAlignment(AlignCenter);
911 mDayLabelsW.insert( i, label ); 911 mDayLabelsW.insert( i, label );
912 } 912 }
913 913
914 bfont.setBold( false ); 914 bfont.setBold( false );
915 mWeekLabels.resize( mNumWeeks+1 ); 915 mWeekLabels.resize( mNumWeeks+1 );
916 mWeekLabelsW.resize( 2 ); 916 mWeekLabelsW.resize( 2 );
917 for( i = 0; i < mNumWeeks+1; i++ ) { 917 for( i = 0; i < mNumWeeks+1; i++ ) {
918 KOWeekButton *label = new KOWeekButton( mMonthView ); 918 KOWeekButton *label = new KOWeekButton( mMonthView );
919 label->setFocusPolicy(NoFocus); 919 label->setFocusPolicy(NoFocus);
920 label->setFont(bfont); 920 label->setFont(bfont);
921 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 921 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
922 label->setFlat(true); 922 label->setFlat(true);
923 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 923 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
924 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 924 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
925 //label->setLineWidth(1); 925 //label->setLineWidth(1);
926 //label->setAlignment(AlignCenter); 926 //label->setAlignment(AlignCenter);
927 mWeekLabels.insert( i, label ); 927 mWeekLabels.insert( i, label );
928 } 928 }
929 mWeekLabels[mNumWeeks]->setText( i18n("W")); 929 mWeekLabels[mNumWeeks]->setText( i18n("W"));
930 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 930 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
931 931
932 for( i = 0; i < 1+1; i++ ) { 932 for( i = 0; i < 1+1; i++ ) {
933 KOWeekButton *label = new KOWeekButton( mWeekView ); 933 KOWeekButton *label = new KOWeekButton( mWeekView );
934 label->setFocusPolicy(NoFocus); 934 label->setFocusPolicy(NoFocus);
935 label->setFont(bfont); 935 label->setFont(bfont);
936 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 936 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
937 label->setFlat(true); 937 label->setFlat(true);
938 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 938 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
939 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 939 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
940 //label->setLineWidth(1); 940 //label->setLineWidth(1);
941 //label->setAlignment(AlignCenter); 941 //label->setAlignment(AlignCenter);
942 mWeekLabelsW.insert( i, label ); 942 mWeekLabelsW.insert( i, label );
943 } 943 }
944 mWeekLabelsW[1]->setText( i18n("W")); 944 mWeekLabelsW[1]->setText( i18n("W"));
945 945
946 946
947 int row, col; 947 int row, col;
948 mCells.resize( mNumCells ); 948 mCells.resize( mNumCells );
949 for( row = 0; row < mNumWeeks; ++row ) { 949 for( row = 0; row < mNumWeeks; ++row ) {
950 for( col = 0; col < mDaysPerWeek; ++col ) { 950 for( col = 0; col < mDaysPerWeek; ++col ) {
951 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 951 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
952 mCells.insert( row * mDaysPerWeek + col, cell ); 952 mCells.insert( row * mDaysPerWeek + col, cell );
953 953
954 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 954 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
955 SLOT( defaultAction( Incidence * ) ) ); 955 SLOT( defaultAction( Incidence * ) ) );
956 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 956 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
957 SIGNAL( newEventSignal( QDateTime ) ) ); 957 SIGNAL( newEventSignal( QDateTime ) ) );
958 connect( cell, SIGNAL( showDaySignal( QDate ) ), 958 connect( cell, SIGNAL( showDaySignal( QDate ) ),
959 SIGNAL( showDaySignal( QDate ) ) ); 959 SIGNAL( showDaySignal( QDate ) ) );
960 } 960 }
961 } 961 }
962 mCellsW.resize( mDaysPerWeek ); 962 mCellsW.resize( mDaysPerWeek );
963 for( col = 0; col < mDaysPerWeek; ++col ) { 963 for( col = 0; col < mDaysPerWeek; ++col ) {
964 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 964 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
965 mCellsW.insert( col, cell ); 965 mCellsW.insert( col, cell );
966 966
967 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 967 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
968 SLOT( defaultAction( Incidence * ) ) ); 968 SLOT( defaultAction( Incidence * ) ) );
969 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 969 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
970 SIGNAL( newEventSignal( QDateTime ) ) ); 970 SIGNAL( newEventSignal( QDateTime ) ) );
971 connect( cell, SIGNAL( showDaySignal( QDate ) ), 971 connect( cell, SIGNAL( showDaySignal( QDate ) ),
972 SIGNAL( showDaySignal( QDate ) ) ); 972 SIGNAL( showDaySignal( QDate ) ) );
973 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 973 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
974 } 974 }
975 975
976 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 976 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
977 mContextMenu = eventPopup(); 977 mContextMenu = eventPopup();
978 // updateConfig(); //useless here... 978 // updateConfig(); //useless here...
979 // ... but we need mWidthLongDayLabel computed 979 // ... but we need mWidthLongDayLabel computed
980 QFontMetrics fontmetric(mDayLabels[0]->font()); 980 QFontMetrics fontmetric(mDayLabels[0]->font());
981 mWidthLongDayLabel = 0; 981 mWidthLongDayLabel = 0;
982 for (int i = 0; i < 7; i++) { 982 for (int i = 0; i < 7; i++) {
983 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 983 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
984 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 984 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
985 } 985 }
986 986
987 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 987 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
988 988
989#if 0 989#if 0
990 if ( mShowWeekView ) 990 if ( mShowWeekView )
991 mWidStack->raiseWidget( mWeekView ); 991 mWidStack->raiseWidget( mWeekView );
992 else 992 else
993 mWidStack->raiseWidget( mMonthView ); 993 mWidStack->raiseWidget( mMonthView );
994#endif 994#endif
995 995
996 emit incidenceSelected( 0 ); 996 emit incidenceSelected( 0 );
997
998 mComputeLayoutTimer = new QTimer( this );
999 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1000
1001
997#ifndef DESKTOP_VERSION 1002#ifndef DESKTOP_VERSION
998 resize( QApplication::desktop()->size() ); 1003 resize( QApplication::desktop()->size() );
999#else 1004#else
1000 resize(640, 480 ); 1005 resize(640, 480 );
1001 updatePossible = true; 1006 updatePossible = true;
1002#endif 1007#endif
1003 computeLayout(); 1008 computeLayout();
1004 1009
1005 if ( mShowWeekView ) 1010 if ( mShowWeekView )
1006 mWidStack->raiseWidget( mWeekView ); 1011 mWidStack->raiseWidget( mWeekView );
1007 else 1012 else
1008 mWidStack->raiseWidget( mMonthView ); 1013 mWidStack->raiseWidget( mMonthView );
1009} 1014}
1010 1015
1011KOMonthView::~KOMonthView() 1016KOMonthView::~KOMonthView()
1012{ 1017{
1013 delete mContextMenu; 1018 delete mContextMenu;
1014} 1019}
1015 1020
1016void KOMonthView::selectInternalWeekNum ( int n ) 1021void KOMonthView::selectInternalWeekNum ( int n )
1017{ 1022{
1018 switchView(); 1023 switchView();
1019 if ( !KOPrefs::instance()->mMonthViewWeek ) 1024 if ( !KOPrefs::instance()->mMonthViewWeek )
1020 emit selectMonth (); 1025 emit selectMonth ();
1021 else 1026 else
1022 emit selectWeekNum ( n ); 1027 emit selectWeekNum ( n );
1023} 1028}
1024 1029
1025int KOMonthView::currentWeek() 1030int KOMonthView::currentWeek()
1026{ 1031{
1027 if ( mShowWeekView ) 1032 if ( mShowWeekView )
1028 return mWeekLabelsW[0]->getWeekNum(); 1033 return mWeekLabelsW[0]->getWeekNum();
1029 return mWeekLabels[0]->getWeekNum(); 1034 return mWeekLabels[0]->getWeekNum();
1030} 1035}
1031void KOMonthView::switchView() 1036void KOMonthView::switchView()
1032{ 1037{
1033 if ( selectedCell( ) ) 1038 if ( selectedCell( ) )
1034 selectedCell()->deselect(); 1039 selectedCell()->deselect();
1035 mShowWeekView = !mShowWeekView; 1040 mShowWeekView = !mShowWeekView;
1036 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1041 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1037 if ( clPending ) { 1042 if ( clPending ) {
1038 computeLayout(); 1043 computeLayout();
1039 updateConfig(); 1044 updateConfig();
1040 } 1045 }
1041 if ( mShowWeekView ) 1046 if ( mShowWeekView )
1042 mWidStack->raiseWidget( mWeekView ); 1047 mWidStack->raiseWidget( mWeekView );
1043 else 1048 else
1044 mWidStack->raiseWidget( mMonthView ); 1049 mWidStack->raiseWidget( mMonthView );
1045 clPending = false; 1050 clPending = false;
1046} 1051}
1047 1052
1048int KOMonthView::maxDatesHint() 1053int KOMonthView::maxDatesHint()
1049{ 1054{
1050 return mNumCells; 1055 return mNumCells;
1051} 1056}
1052 1057
1053int KOMonthView::currentDateCount() 1058int KOMonthView::currentDateCount()
1054{ 1059{
1055 return mNumCells; 1060 return mNumCells;
1056} 1061}
1057 1062
1058QPtrList<Incidence> KOMonthView::selectedIncidences() 1063QPtrList<Incidence> KOMonthView::selectedIncidences()
1059{ 1064{
1060 QPtrList<Incidence> selected; 1065 QPtrList<Incidence> selected;
1061 1066
1062 if ( mSelectedCell ) { 1067 if ( mSelectedCell ) {
1063 Incidence *incidence = mSelectedCell->selectedIncidence(); 1068 Incidence *incidence = mSelectedCell->selectedIncidence();
1064 if ( incidence ) selected.append( incidence ); 1069 if ( incidence ) selected.append( incidence );
1065 } 1070 }
1066 1071
1067 return selected; 1072 return selected;
1068} 1073}
1069 1074
1070DateList KOMonthView::selectedDates() 1075DateList KOMonthView::selectedDates()
1071{ 1076{
1072 DateList selected; 1077 DateList selected;
1073 1078
1074 if ( mSelectedCell ) { 1079 if ( mSelectedCell ) {
1075 QDate qd = mSelectedCell->selectedIncidenceDate(); 1080 QDate qd = mSelectedCell->selectedIncidenceDate();
1076 if ( qd.isValid() ) selected.append( qd ); 1081 if ( qd.isValid() ) selected.append( qd );
1077 } 1082 }
1078 1083
1079 return selected; 1084 return selected;
1080} 1085}
1081 1086
1082void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1087void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1083 const QDate &td) 1088 const QDate &td)
1084{ 1089{
1085#ifndef KORG_NOPRINTER 1090#ifndef KORG_NOPRINTER
1086 calPrinter->preview(CalPrinter::Month, fd, td); 1091 calPrinter->preview(CalPrinter::Month, fd, td);
1087#endif 1092#endif
1088} 1093}
1089 1094
1090void KOMonthView::updateConfig() 1095void KOMonthView::updateConfig()
1091{ 1096{
1092 1097
1093 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1098 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1094 1099
1095 if ( mShowWeekView ) { 1100 if ( mShowWeekView ) {
1096 mWeekStartsMonday = true; 1101 mWeekStartsMonday = true;
1097 } 1102 }
1098 QFontMetrics fontmetric(mDayLabels[0]->font()); 1103 QFontMetrics fontmetric(mDayLabels[0]->font());
1099 mWidthLongDayLabel = 0; 1104 mWidthLongDayLabel = 0;
1100 1105
1101 for (int i = 0; i < 7; i++) { 1106 for (int i = 0; i < 7; i++) {
1102 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1107 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1103 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1108 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1104 } 1109 }
1105 bool temp = mShowSatSunComp ; 1110 bool temp = mShowSatSunComp ;
1106 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1111 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1107 if ( ! mShowWeekView ) { 1112 if ( ! mShowWeekView ) {
1108 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1113 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1109 computeLayout(); 1114 computeLayout();
1110 } 1115 }
1111 updateDayLabels(); 1116 updateDayLabels();
1112 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1117 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1113 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1118 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1114 //resizeEvent( 0 ); 1119 //resizeEvent( 0 );
1115 for (uint i = 0; i < mCells.count(); ++i) { 1120 for (uint i = 0; i < mCells.count(); ++i) {
1116 mCells[i]->updateConfig(); 1121 mCells[i]->updateConfig();
1117 } 1122 }
1118 1123
1119 for (uint i = 0; i < mCellsW.count(); ++i) { 1124 for (uint i = 0; i < mCellsW.count(); ++i) {
1120 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1125 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1121 } 1126 }
1122#ifdef DESKTOP_VERSION 1127#ifdef DESKTOP_VERSION
1123 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1128 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1124#endif 1129#endif
1125 updateView(); 1130 updateView();
1126} 1131}
1127 1132
1128void KOMonthView::updateDayLabels() 1133void KOMonthView::updateDayLabels()
1129{ 1134{
1130 1135
1131 QPtrVector<QLabel> *mDayLabelsT; 1136 QPtrVector<QLabel> *mDayLabelsT;
1132 1137
1133 mDayLabelsT = &mDayLabelsW; 1138 mDayLabelsT = &mDayLabelsW;
1134 for (int i = 0; i < 7; i++) { 1139 for (int i = 0; i < 7; i++) {
1135 if (mWeekStartsMonday) { 1140 if (mWeekStartsMonday) {
1136 bool show = mShortDayLabelsW; 1141 bool show = mShortDayLabelsW;
1137 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1142 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1138 show = true; 1143 show = true;
1139 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1144 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1140 } else { 1145 } else {
1141 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); 1146 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW));
1142 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); 1147 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW));
1143 1148
1144 } 1149 }
1145 } 1150 }
1146 mDayLabelsT = &mDayLabels; 1151 mDayLabelsT = &mDayLabels;
1147 for (int i = 0; i < 7; i++) { 1152 for (int i = 0; i < 7; i++) {
1148 if (mWeekStartsMonday) { 1153 if (mWeekStartsMonday) {
1149 bool show = mShortDayLabelsM; 1154 bool show = mShortDayLabelsM;
1150 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1155 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1151 show = true; 1156 show = true;
1152 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1157 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1153 } else { 1158 } else {
1154 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1159 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1155 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1160 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1156 1161
1157 } 1162 }
1158 } 1163 }
1159 1164
1160} 1165}
1161 1166
1162void KOMonthView::showDates(const QDate &start, const QDate &) 1167void KOMonthView::showDates(const QDate &start, const QDate &)
1163{ 1168{
1164 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1169 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1165 1170
1166 QPtrVector<MonthViewCell> *cells; 1171 QPtrVector<MonthViewCell> *cells;
1167 QPtrVector<QLabel> *dayLabels; 1172 QPtrVector<QLabel> *dayLabels;
1168 QPtrVector<KOWeekButton> *weekLabels; 1173 QPtrVector<KOWeekButton> *weekLabels;
1169 int weekNum = 6; 1174 int weekNum = 6;
1170 if ( mShowWeekView ) { 1175 if ( mShowWeekView ) {
1171 weekNum = 1; 1176 weekNum = 1;
1172 cells = &mCellsW; 1177 cells = &mCellsW;
1173 dayLabels = &mDayLabelsW; 1178 dayLabels = &mDayLabelsW;
1174 weekLabels = &mWeekLabelsW; 1179 weekLabels = &mWeekLabelsW;
1175 } else { 1180 } else {
1176 cells = &mCells; 1181 cells = &mCells;
1177 dayLabels = &mDayLabels; 1182 dayLabels = &mDayLabels;
1178 weekLabels = &mWeekLabels; 1183 weekLabels = &mWeekLabels;
1179 } 1184 }
1180 1185
1181 mStartDate = start; 1186 mStartDate = start;
1182 1187
1183 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1188 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1184 1189
1185 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1190 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1186 mStartDate = mStartDate.addDays( -1 ); 1191 mStartDate = mStartDate.addDays( -1 );
1187 } 1192 }
1188 1193
1189 bool primary = false; 1194 bool primary = false;
1190 uint i; 1195 uint i;
1191 for( i = 0; i < (*cells).size(); ++i ) { 1196 for( i = 0; i < (*cells).size(); ++i ) {
1192 QDate date = mStartDate.addDays( i ); 1197 QDate date = mStartDate.addDays( i );
1193 (*cells)[i]->setDate( date ); 1198 (*cells)[i]->setDate( date );
1194 1199
1195#ifndef KORG_NOPLUGINS 1200#ifndef KORG_NOPLUGINS
1196 // add holiday, if present 1201 // add holiday, if present
1197 QString hstring(KOCore::self()->holiday(date)); 1202 QString hstring(KOCore::self()->holiday(date));
1198 (*cells)[i]->setHoliday( hstring ); 1203 (*cells)[i]->setHoliday( hstring );
1199#endif 1204#endif
1200 1205
1201 } 1206 }
1202 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1207 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1203 for( i = 0; i < weekNum; ++i ) { 1208 for( i = 0; i < weekNum; ++i ) {
1204 int wno; 1209 int wno;
1205 // remember, according to ISO 8601, the first week of the year is the 1210 // remember, according to ISO 8601, the first week of the year is the
1206 // first week that contains a thursday. Thus we must subtract off 4, 1211 // first week that contains a thursday. Thus we must subtract off 4,
1207 // not just 1. 1212 // not just 1.
1208 int dayOfYear = date.dayOfYear(); 1213 int dayOfYear = date.dayOfYear();
1209 if (dayOfYear % 7 != 0) 1214 if (dayOfYear % 7 != 0)
1210 wno = dayOfYear / 7 + 1; 1215 wno = dayOfYear / 7 + 1;
1211 else 1216 else
1212 wno =dayOfYear / 7; 1217 wno =dayOfYear / 7;
1213 (*weekLabels)[i]->setWeekNum( wno ); 1218 (*weekLabels)[i]->setWeekNum( wno );
1214 date = date.addDays( 7 ); 1219 date = date.addDays( 7 );
1215 } 1220 }
1216 updateView(); 1221 updateView();
1217} 1222}
1218 1223
1219void KOMonthView::showEvents(QPtrList<Event>) 1224void KOMonthView::showEvents(QPtrList<Event>)
1220{ 1225{
1221 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1226 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1222} 1227}
1223 1228
1224void KOMonthView::changeEventDisplay(Event *, int) 1229void KOMonthView::changeEventDisplay(Event *, int)
1225{ 1230{
1226 // this should be re-written to be much more efficient, but this 1231 // this should be re-written to be much more efficient, but this
1227 // quick-and-dirty-hack gets the job done for right now. 1232 // quick-and-dirty-hack gets the job done for right now.
1228 updateView(); 1233 updateView();
1229} 1234}
1230 1235
1231void KOMonthView::updateView() 1236void KOMonthView::updateView()
1232{ 1237{
1233 1238
1234 if ( !updatePossible ) 1239 if ( !updatePossible )
1235 return; 1240 return;
1236 //QTime ti; 1241 //QTime ti;
1237 //ti.start(); 1242 //ti.start();
1238 clearSelection(); 1243 clearSelection();
1239 QPtrVector<MonthViewCell> *cells; 1244 QPtrVector<MonthViewCell> *cells;
1240 if ( mShowWeekView ) { 1245 if ( mShowWeekView ) {
1241 cells = &mCellsW; 1246 cells = &mCellsW;
1242 } else { 1247 } else {
1243 cells = &mCells; 1248 cells = &mCells;
1244 } 1249 }
1245#if 1 1250#if 1
1246 int i; 1251 int i;
1247 int timeSpan = (*cells).size()-1; 1252 int timeSpan = (*cells).size()-1;
1248 if ( KOPrefs::instance()->mMonthViewWeek ) 1253 if ( KOPrefs::instance()->mMonthViewWeek )
1249 timeSpan = 6; 1254 timeSpan = 6;
1250 for( i = 0; i < timeSpan + 1; ++i ) { 1255 for( i = 0; i < timeSpan + 1; ++i ) {
1251 (*cells)[i]->startUpdateCell(); 1256 (*cells)[i]->startUpdateCell();
1252 } 1257 }
1253 1258
1254 QPtrList<Event> events = calendar()->events(); 1259 QPtrList<Event> events = calendar()->events();
1255 Event *event; 1260 Event *event;
1256 QDateTime dt; 1261 QDateTime dt;
1257 bool ok; 1262 bool ok;
1258 QDate endDate = mStartDate.addDays( timeSpan ); 1263 QDate endDate = mStartDate.addDays( timeSpan );
1259 for( event = events.first(); event; event = events.next() ) { // for event 1264 for( event = events.first(); event; event = events.next() ) { // for event
1260 if ( event->doesRecur() ) { 1265 if ( event->doesRecur() ) {
1261 bool last; 1266 bool last;
1262 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1267 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1263 QDateTime incidenceEnd; 1268 QDateTime incidenceEnd;
1264 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1269 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1265 bool invalid = false; 1270 bool invalid = false;
1266 while( true ) { 1271 while( true ) {
1267 if ( incidenceStart.isValid() ) { 1272 if ( incidenceStart.isValid() ) {
1268 incidenceEnd = incidenceStart.addDays( eventlen ); 1273 incidenceEnd = incidenceStart.addDays( eventlen );
1269 int st = incidenceStart.date().daysTo( endDate ); 1274 int st = incidenceStart.date().daysTo( endDate );
1270 if ( st >= 0 ) { // start before timeend 1275 if ( st >= 0 ) { // start before timeend
1271 int end = mStartDate.daysTo( incidenceEnd.date() ); 1276 int end = mStartDate.daysTo( incidenceEnd.date() );
1272 if ( end >= 0 ) { // end after timestart --- got one! 1277 if ( end >= 0 ) { // end after timestart --- got one!
1273 //normalize 1278 //normalize
1274 st = timeSpan - st; 1279 st = timeSpan - st;
1275 if ( st < 0 ) st = 0; 1280 if ( st < 0 ) st = 0;
1276 if ( end > timeSpan ) end = timeSpan; 1281 if ( end > timeSpan ) end = timeSpan;
1277 int iii; 1282 int iii;
1278 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1283 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1279 for ( iii = st;iii<= end;++iii) 1284 for ( iii = st;iii<= end;++iii)
1280 (*cells)[iii]->insertEvent( event ); 1285 (*cells)[iii]->insertEvent( event );
1281 } 1286 }
1282 } 1287 }
1283 } else { 1288 } else {
1284 if ( invalid ) 1289 if ( invalid )
1285 break; 1290 break;
1286 invalid = true; 1291 invalid = true;
1287 //qDebug("invalid %s", event->summary().latin1()); 1292 //qDebug("invalid %s", event->summary().latin1());
1288 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1293 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1289 } 1294 }
1290 if ( last ) 1295 if ( last )
1291 break; 1296 break;
1292 bool ok; 1297 bool ok;
1293 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1298 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1294 if ( ! ok ) 1299 if ( ! ok )
1295 break; 1300 break;
1296 if ( incidenceStart.date() > endDate ) 1301 if ( incidenceStart.date() > endDate )
1297 break; 1302 break;
1298 } 1303 }
1299 } else { // no recur 1304 } else { // no recur
1300 int st = event->dtStart().date().daysTo( endDate ); 1305 int st = event->dtStart().date().daysTo( endDate );
1301 if ( st >= 0 ) { // start before timeend 1306 if ( st >= 0 ) { // start before timeend
1302 int end = mStartDate.daysTo( event->dtEnd().date() ); 1307 int end = mStartDate.daysTo( event->dtEnd().date() );
1303 if ( end >= 0 ) { // end after timestart --- got one! 1308 if ( end >= 0 ) { // end after timestart --- got one!
1304 //normalize 1309 //normalize
1305 st = timeSpan - st; 1310 st = timeSpan - st;
1306 if ( st < 0 ) st = 0; 1311 if ( st < 0 ) st = 0;
1307 if ( end > timeSpan ) end = timeSpan; 1312 if ( end > timeSpan ) end = timeSpan;
1308 int iii; 1313 int iii;
1309 for ( iii = st;iii<= end;++iii) 1314 for ( iii = st;iii<= end;++iii)
1310 (*cells)[iii]->insertEvent( event ); 1315 (*cells)[iii]->insertEvent( event );
1311 } 1316 }
1312 } 1317 }
1313 } 1318 }
1314 } 1319 }
1315 // insert due todos 1320 // insert due todos
1316 QPtrList<Todo> todos = calendar()->todos( ); 1321 QPtrList<Todo> todos = calendar()->todos( );
1317 Todo *todo; 1322 Todo *todo;
1318 for(todo = todos.first(); todo; todo = todos.next()) { 1323 for(todo = todos.first(); todo; todo = todos.next()) {
1319 //insertTodo( todo ); 1324 //insertTodo( todo );
1320 if ( todo->hasDueDate() ) { 1325 if ( todo->hasDueDate() ) {
1321 int day = mStartDate.daysTo( todo->dtDue().date() ); 1326 int day = mStartDate.daysTo( todo->dtDue().date() );
1322 if ( day >= 0 && day < timeSpan + 1) { 1327 if ( day >= 0 && day < timeSpan + 1) {
1323 (*cells)[day]->insertTodo( todo ); 1328 (*cells)[day]->insertTodo( todo );
1324 } 1329 }
1325 } 1330 }
1326 } 1331 }
1327 1332
1328 for( i = 0; i < timeSpan+1; ++i ) { 1333 for( i = 0; i < timeSpan+1; ++i ) {
1329 (*cells)[i]->finishUpdateCell(); 1334 (*cells)[i]->finishUpdateCell();
1330 } 1335 }
1331 processSelectionChange(); 1336 processSelectionChange();
1332 (*cells)[0]->setFocus(); 1337 (*cells)[0]->setFocus();
1333 1338
1334 1339
1335#else 1340#else
1336 // old code 1341 // old code
1337 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1342 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1338 int i; 1343 int i;
1339 for( i = 0; i < (*cells).count(); ++i ) { 1344 for( i = 0; i < (*cells).count(); ++i ) {
1340 (*cells)[i]->updateCell(); 1345 (*cells)[i]->updateCell();
1341 } 1346 }
1342 1347
1343 //qDebug("KOMonthView::updateView() "); 1348 //qDebug("KOMonthView::updateView() ");
1344 processSelectionChange(); 1349 processSelectionChange();
1345 // qDebug("---------------------------------------------------------------------+ "); 1350 // qDebug("---------------------------------------------------------------------+ ");
1346 (*cells)[0]->setFocus(); 1351 (*cells)[0]->setFocus();
1347#endif 1352#endif
1348 1353
1349 //qDebug("update time %d ", ti.elapsed()); 1354 //qDebug("update time %d ", ti.elapsed());
1350} 1355}
1351 1356
1352void KOMonthView::resizeEvent(QResizeEvent * e) 1357void KOMonthView::resizeEvent(QResizeEvent * e)
1353{ 1358{
1354 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1359 qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1360 if ( isVisible() ) {
1361 qDebug("KOMonthView::isVisible ");
1362 slotComputeLayout();
1363 } else
1364 mComputeLayoutTimer->start( 100 );
1365}
1366
1367void KOMonthView::slotComputeLayout()
1368{
1369 mComputeLayoutTimer->stop();
1370 qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1355 computeLayout(); 1371 computeLayout();
1356 clPending = true; 1372 clPending = true;
1357 if ( mShowWeekView ) 1373 if ( mShowWeekView )
1358 mCellsW[0]->setFocus(); 1374 mCellsW[0]->setFocus();
1359 else 1375 else
1360 mCells[0]->setFocus(); 1376 mCells[0]->setFocus();
1377
1361} 1378}
1362void KOMonthView::computeLayoutWeek() 1379void KOMonthView::computeLayoutWeek()
1363{ 1380{
1364 static int lastWid = 0; 1381 static int lastWid = 0;
1365 static int lastHei = 0; 1382 static int lastHei = 0;
1366 int daysToShow; 1383 int daysToShow;
1367 bool combinedSatSun = false; 1384 bool combinedSatSun = false;
1368 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1385 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1369 daysToShow = 6; 1386 daysToShow = 6;
1370 combinedSatSun = true; 1387 combinedSatSun = true;
1371 } 1388 }
1372 int tWid = topLevelWidget()->size().width(); 1389 int tWid = topLevelWidget()->size().width();
1373 int tHei = topLevelWidget()->size().height(); 1390 int tHei = topLevelWidget()->size().height();
1374 1391
1375 int wid = width();//e 1392 int wid = width();//e
1376 int hei = height()-1-mNavigatorBar->height(); 1393 int hei = height()-1-mNavigatorBar->height();
1377 1394
1378 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1395 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1379 return; 1396 return;
1380 1397
1381 if ( lastWid == width() && lastHei == height() ) 1398 if ( lastWid == width() && lastHei == height() ) {
1399 qDebug("KOListWeekView::No compute layout needed ");
1382 return; 1400 return;
1401 }
1383 lastWid = width(); 1402 lastWid = width();
1384 lastHei = height(); 1403 lastHei = height();
1385 1404
1386 1405
1387 if ( wid < hei ) 1406 if ( wid < hei )
1388 daysToShow = 2; 1407 daysToShow = 2;
1389 else 1408 else
1390 daysToShow = 3; 1409 daysToShow = 3;
1391 mShowSatSunComp = true; 1410 mShowSatSunComp = true;
1392 combinedSatSun = true; 1411 combinedSatSun = true;
1393 1412
1394 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1413 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1395 QFontMetrics fm ( mWeekLabels[0]->font() ); 1414 QFontMetrics fm ( mWeekLabels[0]->font() );
1396 int weeklabelwid = fm.width( "888" ); 1415 int weeklabelwid = fm.width( "888" );
1397 wid -= weeklabelwid; 1416 wid -= weeklabelwid;
1398 1417
1399 int colWid = wid / daysToShow; 1418 int colWid = wid / daysToShow;
1400 int lastCol = wid - ( colWid*6 ); 1419 int lastCol = wid - ( colWid*6 );
1401 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1420 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1402 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1421 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1403 int colModulo = wid % daysToShow; 1422 int colModulo = wid % daysToShow;
1404 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1423 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1405 //qDebug("rowmod %d ", rowModulo); 1424 //qDebug("rowmod %d ", rowModulo);
1406 int i; 1425 int i;
1407 int x,y,w,h; 1426 int x,y,w,h;
1408 x= 0; 1427 x= 0;
1409 y= 0; 1428 y= 0;
1410 w = colWid; 1429 w = colWid;
1411 h = dayLabelHei ; 1430 h = dayLabelHei ;
1412 for ( i = 0; i < 7; i++) { 1431 for ( i = 0; i < 7; i++) {
1413 if ( i && !( i % daysToShow) && i < 6) { 1432 if ( i && !( i % daysToShow) && i < 6) {
1414 y += hei/(5-daysToShow); 1433 y += hei/(5-daysToShow);
1415 x = 0; 1434 x = 0;
1416 w = colWid; 1435 w = colWid;
1417 } 1436 }
1418 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1437 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1419 ++w; 1438 ++w;
1420 } 1439 }
1421 if ( i >= 5 ) { 1440 if ( i >= 5 ) {
1422 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); 1441 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1423 x -= (w/2 ); 1442 x -= (w/2 );
1424 } 1443 }
1425 else 1444 else
1426 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); 1445 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h);
1427 x += w; 1446 x += w;
1428 } 1447 }
1429 x= 0; 1448 x= 0;
1430 y= dayLabelHei; 1449 y= dayLabelHei;
1431 w = colWid; 1450 w = colWid;
1432 h = cellHei; 1451 h = cellHei;
1433 for ( i = 0; i < mCellsW.count(); ++i) { 1452 for ( i = 0; i < mCellsW.count(); ++i) {
1434 if ( i > 6 ) { 1453 if ( i > 6 ) {
1435 mCellsW[i]->hide(); 1454 mCellsW[i]->hide();
1436 continue; 1455 continue;
1437 } 1456 }
1438 1457
1439 w = colWid; 1458 w = colWid;
1440 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1459 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1441 ++w; 1460 ++w;
1442 } 1461 }
1443 if ( i == (daysToShow-1-rowModulo)*7) 1462 if ( i == (daysToShow-1-rowModulo)*7)
1444 ++h; 1463 ++h;
1445 1464
1446 if ( i >= 5 ) { 1465 if ( i >= 5 ) {
1447 if ( i ==5 ) { 1466 if ( i ==5 ) {
1448 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1467 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1449 x -= w ;y += h/2; 1468 x -= w ;y += h/2;
1450 } else { 1469 } else {
1451 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1470 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1452 ++w; 1471 ++w;
1453 } 1472 }
1454 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1473 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1455 y -= h/2; 1474 y -= h/2;
1456 } 1475 }
1457 } else 1476 } else
1458 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1477 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1459 1478
1460 1479
1461 x += w; 1480 x += w;
1462 if ( x + w/2 > wid ) { 1481 if ( x + w/2 > wid ) {
1463 x = 0; 1482 x = 0;
1464 y += h+dayLabelHei ; 1483 y += h+dayLabelHei ;
1465 } 1484 }
1466 } 1485 }
1467 y= dayLabelHei; 1486 y= dayLabelHei;
1468 h = cellHei ; 1487 h = cellHei ;
1469 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1488 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1470 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1489 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1471 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1490 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1472 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1491 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1473 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1492 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1474 updateDayLabels(); 1493 updateDayLabels();
1475 //bool forceUpdate = !updatePossible; 1494 //bool forceUpdate = !updatePossible;
1476 updatePossible = true; 1495 updatePossible = true;
1477 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1496 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1478 //if ( forceUpdate ) 1497 //if ( forceUpdate )
1479 // updateView(); 1498 // updateView();
1480} 1499}
1481void KOMonthView::computeLayout() 1500void KOMonthView::computeLayout()
1482{ 1501{
1483 1502
1484 1503
1485 static int lastWid = 0; 1504 static int lastWid = 0;
1486 static int lastHei = 0; 1505 static int lastHei = 0;
1487 1506
1488 if ( mShowWeekView ){ 1507 if ( mShowWeekView ){
1489 computeLayoutWeek(); 1508 computeLayoutWeek();
1490 return; 1509 return;
1491 } 1510 }
1492 int daysToShow = 7; 1511 int daysToShow = 7;
1493 bool combinedSatSun = false; 1512 bool combinedSatSun = false;
1494 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1513 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1495 daysToShow = 6; 1514 daysToShow = 6;
1496 combinedSatSun = true; 1515 combinedSatSun = true;
1497 } 1516 }
1498 int tWid = topLevelWidget()->size().width(); 1517 int tWid = topLevelWidget()->size().width();
1499 int tHei = topLevelWidget()->size().height(); 1518 int tHei = topLevelWidget()->size().height();
1500 1519
1501 int wid = width();//e 1520 int wid = width();//e
1502 int hei = height()-1-mNavigatorBar->height(); 1521 int hei = height()-1-mNavigatorBar->height();
1503 1522
1504 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1523 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1505 return; 1524 return;
1506 } 1525 }
1507 if ( lastWid == width() && lastHei == height() ){ 1526 if ( lastWid == width() && lastHei == height() ){
1527 qDebug("KOMonthview::No compute layout needed ");
1508 return; 1528 return;
1509 } 1529 }
1510 1530
1511 lastWid = width(); 1531 lastWid = width();
1512 lastHei = height(); 1532 lastHei = height();
1513 //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); 1533 qDebug("KOMonthView::computeLayout() MMM ------------------- ");
1514 QFontMetrics fm ( mWeekLabels[0]->font() ); 1534 QFontMetrics fm ( mWeekLabels[0]->font() );
1515 int weeklabelwid = fm.width( "888" ); 1535 int weeklabelwid = fm.width( "888" );
1516 wid -= weeklabelwid; 1536 wid -= weeklabelwid;
1517 1537
1518 int colWid = wid / daysToShow; 1538 int colWid = wid / daysToShow;
1519 int lastCol = wid - ( colWid*6 ); 1539 int lastCol = wid - ( colWid*6 );
1520 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1540 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1521 int cellHei = (hei - dayLabelHei) /6; 1541 int cellHei = (hei - dayLabelHei) /6;
1522 int colModulo = wid % daysToShow; 1542 int colModulo = wid % daysToShow;
1523 int rowModulo = (hei- dayLabelHei) % 6; 1543 int rowModulo = (hei- dayLabelHei) % 6;
1524 //qDebug("rowmod %d ", rowModulo); 1544 //qDebug("rowmod %d ", rowModulo);
1525 int i; 1545 int i;
1526 int x,y,w,h; 1546 int x,y,w,h;
1527 x= 0; 1547 x= 0;
1528 y= 0; 1548 y= 0;
1529 w = colWid; 1549 w = colWid;
1530 h = dayLabelHei ; 1550 h = dayLabelHei ;
1531 for ( i = 0; i < 7; i++) { 1551 for ( i = 0; i < 7; i++) {
1532 if ( i == daysToShow-colModulo ) 1552 if ( i == daysToShow-colModulo )
1533 ++w; 1553 ++w;
1534 if ( combinedSatSun ) { 1554 if ( combinedSatSun ) {
1535 if ( i >= daysToShow-1 ) { 1555 if ( i >= daysToShow-1 ) {
1536 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1556 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1537 x -= w/2 ; 1557 x -= w/2 ;
1538 } 1558 }
1539 else 1559 else
1540 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1560 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1541 } else 1561 } else
1542 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1562 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1543 x += w; 1563 x += w;
1544 } 1564 }
1545 x= 0; 1565 x= 0;
1546 y= dayLabelHei; 1566 y= dayLabelHei;
1547 w = colWid; 1567 w = colWid;
1548 h = cellHei ; 1568 h = cellHei ;
1549 for ( i = 0; i < mCells.count(); ++i) { 1569 for ( i = 0; i < mCells.count(); ++i) {
1550 //qDebug("iii %d ", i); 1570 //qDebug("iii %d ", i);
1551 w = colWid; 1571 w = colWid;
1552 if ( ((i) % 7) >= 7-colModulo ) { 1572 if ( ((i) % 7) >= 7-colModulo ) {
1553 ++w; 1573 ++w;
1554 } 1574 }
1555 if ( i == (6-rowModulo)*7) 1575 if ( i == (6-rowModulo)*7)
1556 ++h; 1576 ++h;
1557 if ( combinedSatSun ) { 1577 if ( combinedSatSun ) {
1558 if ( (i)%7 >= daysToShow-1 ) { 1578 if ( (i)%7 >= daysToShow-1 ) {
1559 if ( (i)%7 == daysToShow-1 ) { 1579 if ( (i)%7 == daysToShow-1 ) {
1560 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1580 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1561 x -= w ;y += h/2; 1581 x -= w ;y += h/2;
1562 } else { 1582 } else {
1563 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1583 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1564 y -= h/2; 1584 y -= h/2;
1565 } 1585 }
1566 } else 1586 } else
1567 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1587 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1568 1588
1569 } 1589 }
1570 else 1590 else
1571 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1591 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1572 x += w; 1592 x += w;
1573 if ( x + w/2 > wid ) { 1593 if ( x + w/2 > wid ) {
1574 x = 0; 1594 x = 0;
1575 y += h; 1595 y += h;
1576 } 1596 }
1577 } 1597 }
1578 y= dayLabelHei; 1598 y= dayLabelHei;
1579 h = cellHei ; 1599 h = cellHei ;
1580 for ( i = 0; i < 6; i++) { 1600 for ( i = 0; i < 6; i++) {
1581 if ( i == (6-rowModulo)) 1601 if ( i == (6-rowModulo))
1582 ++h; 1602 ++h;
1583 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1603 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1584 y += h; 1604 y += h;
1585 } 1605 }
1586 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1606 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1587 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1607 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1588 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1608 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1589 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1609 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1590 updateDayLabels(); 1610 updateDayLabels();
1591 //bool forceUpdate = !updatePossible; 1611 //bool forceUpdate = !updatePossible;
1592 updatePossible = true; 1612 updatePossible = true;
1593 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1613 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1594} 1614}
1595 1615
1596void KOMonthView::showContextMenu( Incidence *incidence ) 1616void KOMonthView::showContextMenu( Incidence *incidence )
1597{ 1617{
1598 mContextMenu->showIncidencePopup(incidence); 1618 mContextMenu->showIncidencePopup(incidence);
1599 /* 1619 /*
1600 if( incidence && incidence->type() == "Event" ) { 1620 if( incidence && incidence->type() == "Event" ) {
1601 Event *event = static_cast<Event *>(incidence); 1621 Event *event = static_cast<Event *>(incidence);
1602 mContextMenu->showEventPopup(event); 1622 mContextMenu->showEventPopup(event);
1603 } else { 1623 } else {
1604 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1624 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1605 } 1625 }
1606 */ 1626 */
1607} 1627}
1608MonthViewCell * KOMonthView::selectedCell( ) 1628MonthViewCell * KOMonthView::selectedCell( )
1609{ 1629{
1610 return mSelectedCell; 1630 return mSelectedCell;
1611} 1631}
1612void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1632void KOMonthView::setSelectedCell( MonthViewCell *cell )
1613{ 1633{
1614 //qDebug("KOMonthView::setSelectedCell "); 1634 //qDebug("KOMonthView::setSelectedCell ");
1615 if ( mSelectedCell && mSelectedCell != cell ) { 1635 if ( mSelectedCell && mSelectedCell != cell ) {
1616 MonthViewCell * mvc = mSelectedCell; 1636 MonthViewCell * mvc = mSelectedCell;
1617 mSelectedCell = cell; 1637 mSelectedCell = cell;
1618 mvc->deselect(); 1638 mvc->deselect();
1619 } else 1639 } else
1620 mSelectedCell = cell; 1640 mSelectedCell = cell;
1621 // if ( mSelectedCell ) 1641 // if ( mSelectedCell )
1622 // mSelectedCell->select(); 1642 // mSelectedCell->select();
1623 if ( !mSelectedCell ) 1643 if ( !mSelectedCell )
1624 emit incidenceSelected( 0 ); 1644 emit incidenceSelected( 0 );
1625 else 1645 else
1626 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1646 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1627} 1647}
1628 1648
1629void KOMonthView::processSelectionChange() 1649void KOMonthView::processSelectionChange()
1630{ 1650{
1631 QPtrList<Incidence> incidences = selectedIncidences(); 1651 QPtrList<Incidence> incidences = selectedIncidences();
1632 if (incidences.count() > 0) { 1652 if (incidences.count() > 0) {
1633 emit incidenceSelected( incidences.first() ); 1653 emit incidenceSelected( incidences.first() );
1634 } else { 1654 } else {
1635 emit incidenceSelected( 0 ); 1655 emit incidenceSelected( 0 );
1636 clearSelection(); 1656 clearSelection();
1637 } 1657 }
1638} 1658}
1639 1659
1640void KOMonthView::clearSelection() 1660void KOMonthView::clearSelection()
1641{ 1661{
1642 if ( mSelectedCell ) { 1662 if ( mSelectedCell ) {
1643 mSelectedCell->deselect(); 1663 mSelectedCell->deselect();
1644 mSelectedCell = 0; 1664 mSelectedCell = 0;
1645 } 1665 }
1646} 1666}
1647void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1667void KOMonthView::keyPressEvent ( QKeyEvent * e )
1648{ 1668{
1649 //qDebug("KOMonthView::keyPressEvent "); 1669 //qDebug("KOMonthView::keyPressEvent ");
1650 switch(e->key()) { 1670 switch(e->key()) {
1651 case Key_Up: 1671 case Key_Up:
1652 { 1672 {
1653 if ( mShowWeekView ) { 1673 if ( mShowWeekView ) {
1654 mCellsW[0]->setFocus(); 1674 mCellsW[0]->setFocus();
1655 emit selectWeekNum ( currentWeek() - 1 ); 1675 emit selectWeekNum ( currentWeek() - 1 );
1656 } 1676 }
1657 else { 1677 else {
1658 mCells[0]->setFocus(); 1678 mCells[0]->setFocus();
1659 emit prevMonth(); 1679 emit prevMonth();
1660 } 1680 }
1661 } 1681 }
1662 e->accept(); 1682 e->accept();
1663 break; 1683 break;
1664 case Key_Down: 1684 case Key_Down:
1665 { 1685 {
1666 if ( mShowWeekView ) { 1686 if ( mShowWeekView ) {
1667 mCellsW[0]->setFocus(); 1687 mCellsW[0]->setFocus();
1668 emit selectWeekNum ( currentWeek() +1); 1688 emit selectWeekNum ( currentWeek() +1);
1669 } 1689 }
1670 else { 1690 else {
1671 mCells[0]->setFocus(); 1691 mCells[0]->setFocus();
1672 emit nextMonth(); 1692 emit nextMonth();
1673 } 1693 }
1674 1694
1675 } 1695 }
1676 e->accept(); 1696 e->accept();
1677 break; 1697 break;
1678 case Key_Return: 1698 case Key_Return:
1679 case Key_Enter: 1699 case Key_Enter:
1680 { 1700 {
1681 selectInternalWeekNum ( currentWeek() ); 1701 selectInternalWeekNum ( currentWeek() );
1682 } 1702 }
1683 e->accept(); 1703 e->accept();
1684 break; 1704 break;
1685 case Key_D: 1705 case Key_D:
1686 if ( mSelectedCell ) { 1706 if ( mSelectedCell ) {
1687 mSelectedCell->showDay(); 1707 mSelectedCell->showDay();
1688 e->accept(); 1708 e->accept();
1689 } else { 1709 } else {
1690 e->ignore(); 1710 e->ignore();
1691 } 1711 }
1692 break; 1712 break;
1693 default: 1713 default:
1694 e->ignore(); 1714 e->ignore();
1695 break; 1715 break;
1696 } 1716 }
1697} 1717}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index a92421b..89912e0 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,304 +1,307 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qtimer.h>
30#include <qintdict.h> 31#include <qintdict.h>
31#include <qpushbutton.h> 32#include <qpushbutton.h>
32#include <qvaluelist.h> 33#include <qvaluelist.h>
33#include <qptrvector.h> 34#include <qptrvector.h>
34 35
35#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
36#include <libkcal/event.h> 37#include <libkcal/event.h>
37 38
38#include "koeventview.h" 39#include "koeventview.h"
39#include "navigatorbar.h" 40#include "navigatorbar.h"
40 41
41#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
42class QToolTipGroup; 43class QToolTipGroup;
43#endif 44#endif
44 45
45class KNOWhatsThis; 46class KNOWhatsThis;
46class KOWeekButton : public QPushButton 47class KOWeekButton : public QPushButton
47{ 48{
48 Q_OBJECT 49 Q_OBJECT
49 public: 50 public:
50 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 51 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
51 QPushButton( parent, name) 52 QPushButton( parent, name)
52 { 53 {
53 connect( this, SIGNAL( clicked() ), 54 connect( this, SIGNAL( clicked() ),
54 SLOT( bottonClicked() )); 55 SLOT( bottonClicked() ));
55 mNumber = -1; 56 mNumber = -1;
56 } 57 }
57 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 58 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
58 int getWeekNum() { return mNumber;} 59 int getWeekNum() { return mNumber;}
59 signals: 60 signals:
60 void selectWeekNum ( int ); 61 void selectWeekNum ( int );
61private: 62private:
62 int mNumber; 63 int mNumber;
63private slots : 64private slots :
64 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 65 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
65}; 66};
66 67
67class KNoScrollListBox: public QListBox 68class KNoScrollListBox: public QListBox
68{ 69{
69 Q_OBJECT 70 Q_OBJECT
70 public: 71 public:
71 KNoScrollListBox(QWidget *parent=0, const char *name=0); 72 KNoScrollListBox(QWidget *parent=0, const char *name=0);
72 ~KNoScrollListBox(); 73 ~KNoScrollListBox();
73 QString getWhatsThisText(QPoint p) ; 74 QString getWhatsThisText(QPoint p) ;
74 75
75 signals: 76 signals:
76 void shiftDown(); 77 void shiftDown();
77 void shiftUp(); 78 void shiftUp();
78 void rightClick(); 79 void rightClick();
79 80
80 protected slots: 81 protected slots:
81 void oneDown(); 82 void oneDown();
82 void keyPressEvent(QKeyEvent *); 83 void keyPressEvent(QKeyEvent *);
83 void keyReleaseEvent(QKeyEvent *); 84 void keyReleaseEvent(QKeyEvent *);
84 void mousePressEvent(QMouseEvent *); 85 void mousePressEvent(QMouseEvent *);
85 86
86 private: 87 private:
87 KNOWhatsThis * mWT; 88 KNOWhatsThis * mWT;
88}; 89};
89 90
90 91
91class MonthViewItem: public QListBoxItem 92class MonthViewItem: public QListBoxItem
92{ 93{
93 public: 94 public:
94 MonthViewItem( Incidence *, QDate qd, const QString & title ); 95 MonthViewItem( Incidence *, QDate qd, const QString & title );
95 96
96 void setRecur(bool on) { mRecur = on; } 97 void setRecur(bool on) { mRecur = on; }
97 void setAlarm(bool on) { mAlarm = on; } 98 void setAlarm(bool on) { mAlarm = on; }
98 void setReply(bool on) { mReply = on; } 99 void setReply(bool on) { mReply = on; }
99 void setMoreInfo(bool on) { mInfo = on; } 100 void setMoreInfo(bool on) { mInfo = on; }
100 void setMultiDay(int type) { mMultiday = type; } 101 void setMultiDay(int type) { mMultiday = type; }
101 102
102 103
103 void setPalette(const QPalette &p) { mPalette = p; } 104 void setPalette(const QPalette &p) { mPalette = p; }
104 QPalette palette() const { return mPalette; } 105 QPalette palette() const { return mPalette; }
105 106
106 Incidence *incidence() const { return mIncidence; } 107 Incidence *incidence() const { return mIncidence; }
107 QDate incidenceDate() { return mDate; } 108 QDate incidenceDate() { return mDate; }
108 109
109 protected: 110 protected:
110 virtual void paint(QPainter *); 111 virtual void paint(QPainter *);
111 virtual int height(const QListBox *) const; 112 virtual int height(const QListBox *) const;
112 virtual int width(const QListBox *) const; 113 virtual int width(const QListBox *) const;
113 114
114 private: 115 private:
115 int mMultiday; 116 int mMultiday;
116 bool mRecur; 117 bool mRecur;
117 bool mAlarm; 118 bool mAlarm;
118 bool mReply; 119 bool mReply;
119 bool mInfo; 120 bool mInfo;
120 121
121 QPalette mPalette; 122 QPalette mPalette;
122 QDate mDate; 123 QDate mDate;
123 124
124 Incidence *mIncidence; 125 Incidence *mIncidence;
125}; 126};
126 127
127 128
128class KOMonthView; 129class KOMonthView;
129 130
130class MonthViewCell : public QWidget 131class MonthViewCell : public QWidget
131{ 132{
132 Q_OBJECT 133 Q_OBJECT
133 public: 134 public:
134 MonthViewCell(KOMonthView *,QWidget* ); 135 MonthViewCell(KOMonthView *,QWidget* );
135 136
136 void setDate( const QDate & ); 137 void setDate( const QDate & );
137 QDate date() const; 138 QDate date() const;
138 139
139 void setPrimary( bool ); 140 void setPrimary( bool );
140 bool isPrimary() const; 141 bool isPrimary() const;
141 142
142 void setHoliday( bool ); 143 void setHoliday( bool );
143 void setHoliday( const QString & ); 144 void setHoliday( const QString & );
144 145
145 void updateCell(); 146 void updateCell();
146 void startUpdateCell(); 147 void startUpdateCell();
147 void finishUpdateCell(); 148 void finishUpdateCell();
148 void insertEvent(Event *); 149 void insertEvent(Event *);
149 void insertTodo(Todo *); 150 void insertTodo(Todo *);
150 151
151 void updateConfig( bool bigFont = false ); 152 void updateConfig( bool bigFont = false );
152 153
153 void enableScrollBars( bool ); 154 void enableScrollBars( bool );
154 155
155 Incidence *selectedIncidence(); 156 Incidence *selectedIncidence();
156 QDate selectedIncidenceDate(); 157 QDate selectedIncidenceDate();
157 158
158 void deselect(); 159 void deselect();
159 void select(); 160 void select();
160 161
161#ifdef DESKTOP_VERSION 162#ifdef DESKTOP_VERSION
162 static QToolTipGroup *toolTipGroup(); 163 static QToolTipGroup *toolTipGroup();
163#endif 164#endif
164 signals: 165 signals:
165 void defaultAction( Incidence * ); 166 void defaultAction( Incidence * );
166 void newEventSignal( QDateTime ); 167 void newEventSignal( QDateTime );
167 void showDaySignal( QDate ); 168 void showDaySignal( QDate );
168 169
169 protected: 170 protected:
170 QStringList mToolTip; 171 QStringList mToolTip;
171 void resizeEvent( QResizeEvent * ); 172 void resizeEvent( QResizeEvent * );
172 173
173 174
174public slots: 175public slots:
175 void showDay(); 176 void showDay();
176 177
177 protected slots: 178 protected slots:
178 void defaultAction( QListBoxItem * ); 179 void defaultAction( QListBoxItem * );
179 void contextMenu( QListBoxItem * ); 180 void contextMenu( QListBoxItem * );
180 void selection( QListBoxItem * ); 181 void selection( QListBoxItem * );
181 void cellClicked( QListBoxItem * ); 182 void cellClicked( QListBoxItem * );
182 void newEvent(); 183 void newEvent();
183 184
184 private: 185 private:
185 KOMonthView *mMonthView; 186 KOMonthView *mMonthView;
186 187
187 QDate mDate; 188 QDate mDate;
188 bool mPrimary; 189 bool mPrimary;
189 bool mHoliday; 190 bool mHoliday;
190 QString mHolidayString; 191 QString mHolidayString;
191 192
192 //QLabel *mLabel; 193 //QLabel *mLabel;
193 QPushButton *mLabel; 194 QPushButton *mLabel;
194 QListBox *mItemList; 195 QListBox *mItemList;
195#ifdef DESKTOP_VERSION 196#ifdef DESKTOP_VERSION
196 static QToolTipGroup *mToolTipGroup; 197 static QToolTipGroup *mToolTipGroup;
197#endif 198#endif
198 QSize mLabelSize; 199 QSize mLabelSize;
199 QSize mLabelBigSize; 200 QSize mLabelBigSize;
200 QPalette mHolidayPalette; 201 QPalette mHolidayPalette;
201 QPalette mStandardPalette; 202 QPalette mStandardPalette;
202 QPalette mPrimaryPalette; 203 QPalette mPrimaryPalette;
203 QPalette mNonPrimaryPalette; 204 QPalette mNonPrimaryPalette;
204 void setMyPalette(); 205 void setMyPalette();
205 QPalette getPalette (); 206 QPalette getPalette ();
206 void keyPressEvent ( QKeyEvent * ) ; 207 void keyPressEvent ( QKeyEvent * ) ;
207 208
208}; 209};
209 210
210 211
211class KOMonthView: public KOEventView 212class KOMonthView: public KOEventView
212{ 213{
213 Q_OBJECT 214 Q_OBJECT
214 public: 215 public:
215 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 216 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
216 ~KOMonthView(); 217 ~KOMonthView();
217 218
218 /** Returns maximum number of days supported by the komonthview */ 219 /** Returns maximum number of days supported by the komonthview */
219 virtual int maxDatesHint(); 220 virtual int maxDatesHint();
220 221
221 /** Returns number of currently shown dates. */ 222 /** Returns number of currently shown dates. */
222 virtual int currentDateCount(); 223 virtual int currentDateCount();
223 224
224 /** returns the currently selected events */ 225 /** returns the currently selected events */
225 virtual QPtrList<Incidence> selectedIncidences(); 226 virtual QPtrList<Incidence> selectedIncidences();
226 227
227 /** returns dates of the currently selected events */ 228 /** returns dates of the currently selected events */
228 virtual DateList selectedDates(); 229 virtual DateList selectedDates();
229 230
230 virtual void printPreview(CalPrinter *calPrinter, 231 virtual void printPreview(CalPrinter *calPrinter,
231 const QDate &, const QDate &); 232 const QDate &, const QDate &);
232 bool isMonthView() { return !mShowWeekView; } 233 bool isMonthView() { return !mShowWeekView; }
233 bool isUpdatePossible() { return updatePossible; } 234 bool isUpdatePossible() { return updatePossible; }
234 235
235 MonthViewCell * selectedCell(); 236 MonthViewCell * selectedCell();
236 bool skipResize; 237 bool skipResize;
237 NavigatorBar* navigatorBar() { return mNavigatorBar ;} 238 NavigatorBar* navigatorBar() { return mNavigatorBar ;}
238 public slots: 239 public slots:
239 virtual void updateView(); 240 virtual void updateView();
240 virtual void updateConfig(); 241 virtual void updateConfig();
241 virtual void showDates(const QDate &start, const QDate &end); 242 virtual void showDates(const QDate &start, const QDate &end);
242 virtual void showEvents(QPtrList<Event> eventList); 243 virtual void showEvents(QPtrList<Event> eventList);
243 244
244 void changeEventDisplay(Event *, int); 245 void changeEventDisplay(Event *, int);
245 246
246 void clearSelection(); 247 void clearSelection();
247 248
248 void showContextMenu( Incidence * ); 249 void showContextMenu( Incidence * );
249 250
250 void setSelectedCell( MonthViewCell * ); 251 void setSelectedCell( MonthViewCell * );
251 void switchView(); 252 void switchView();
252 253
253 protected slots: 254 protected slots:
255 void slotComputeLayout();
254 void selectInternalWeekNum ( int ); 256 void selectInternalWeekNum ( int );
255 void processSelectionChange(); 257 void processSelectionChange();
256 signals: 258 signals:
257 void nextMonth(); 259 void nextMonth();
258 void prevMonth(); 260 void prevMonth();
259 void selectWeekNum ( int ); 261 void selectWeekNum ( int );
260 void selectMonth (); 262 void selectMonth ();
261 void showDaySignal( QDate ); 263 void showDaySignal( QDate );
262 protected: 264 protected:
263 void resizeEvent(QResizeEvent *); 265 void resizeEvent(QResizeEvent *);
264 void viewChanged(); 266 void viewChanged();
265 void updateDayLabels(); 267 void updateDayLabels();
266 268
267 private: 269 private:
270 QTimer* mComputeLayoutTimer;
268 NavigatorBar* mNavigatorBar; 271 NavigatorBar* mNavigatorBar;
269 int currentWeek(); 272 int currentWeek();
270 bool clPending; 273 bool clPending;
271 QWidgetStack * mWidStack; 274 QWidgetStack * mWidStack;
272 QWidget* mMonthView; 275 QWidget* mMonthView;
273 QWidget* mWeekView; 276 QWidget* mWeekView;
274 bool mShowWeekView; 277 bool mShowWeekView;
275 bool updatePossible; 278 bool updatePossible;
276 int mDaysPerWeek; 279 int mDaysPerWeek;
277 int mNumWeeks; 280 int mNumWeeks;
278 int mNumCells; 281 int mNumCells;
279 bool mWeekStartsMonday; 282 bool mWeekStartsMonday;
280 bool mShowSatSunComp; 283 bool mShowSatSunComp;
281 void computeLayout(); 284 void computeLayout();
282 void computeLayoutWeek(); 285 void computeLayoutWeek();
283 286
284 QPtrVector<MonthViewCell> mCells; 287 QPtrVector<MonthViewCell> mCells;
285 QPtrVector<QLabel> mDayLabels; 288 QPtrVector<QLabel> mDayLabels;
286 QPtrVector<KOWeekButton> mWeekLabels; 289 QPtrVector<KOWeekButton> mWeekLabels;
287 QPtrVector<MonthViewCell> mCellsW; 290 QPtrVector<MonthViewCell> mCellsW;
288 QPtrVector<QLabel> mDayLabelsW; 291 QPtrVector<QLabel> mDayLabelsW;
289 QPtrVector<KOWeekButton> mWeekLabelsW; 292 QPtrVector<KOWeekButton> mWeekLabelsW;
290 293
291 bool mShortDayLabelsM; 294 bool mShortDayLabelsM;
292 bool mShortDayLabelsW; 295 bool mShortDayLabelsW;
293 int mWidthLongDayLabel; 296 int mWidthLongDayLabel;
294 297
295 QDate mStartDate; 298 QDate mStartDate;
296 299
297 MonthViewCell *mSelectedCell; 300 MonthViewCell *mSelectedCell;
298 301
299 KOEventPopupMenu *mContextMenu; 302 KOEventPopupMenu *mContextMenu;
300 void keyPressEvent ( QKeyEvent * ) ; 303 void keyPressEvent ( QKeyEvent * ) ;
301 304
302}; 305};
303 306
304#endif 307#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index cc0ce9b..94d74f1 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,627 +1,628 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 64
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") { 91 else if (view == "Month") {
92 if ( !KOPrefs::instance()->mMonthViewWeek ) 92 if ( !KOPrefs::instance()->mMonthViewWeek )
93 showMonthView(); 93 showMonthView();
94 else 94 else
95 showMonthViewWeek(); 95 showMonthViewWeek();
96 } 96 }
97 else if (view == "List") showListView(); 97 else if (view == "List") showListView();
98 else if (view == "Journal") showJournalView(); 98 else if (view == "Journal") showJournalView();
99 else if (view == "TimeSpan") showTimeSpanView(); 99 else if (view == "TimeSpan") showTimeSpanView();
100 else if (view == "Todo") showTodoView(); 100 else if (view == "Todo") showTodoView();
101 else { 101 else {
102 config->setGroup( "Views" ); 102 config->setGroup( "Views" );
103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
104 mCurrentAgendaView = dateCount; 104 mCurrentAgendaView = dateCount;
105 showAgendaView(); 105 showAgendaView();
106 mCurrentAgendaView = dateCount; 106 mCurrentAgendaView = dateCount;
107#ifdef DESKTOP_VERSION 107#ifdef DESKTOP_VERSION
108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); 108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
109#endif 109#endif
110 } 110 }
111} 111}
112 112
113void KOViewManager::showDateView( int view, QDate date) 113void KOViewManager::showDateView( int view, QDate date)
114{ 114{
115 static int lastMode = 0; 115 static int lastMode = 0;
116 static int lastCount = 0; 116 static int lastCount = 0;
117 static bool lastNDMode = false; 117 static bool lastNDMode = false;
118 static QDate lastDate; 118 static QDate lastDate;
119 //qDebug("date %d %s", view, date.toString().latin1()); 119 //qDebug("date %d %s", view, date.toString().latin1());
120 120
121 if (view != 9) 121 if (view != 9)
122 lastMode = 0; 122 lastMode = 0;
123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
124 bool savemFlagShowNextxDays = mFlagShowNextxDays; 124 bool savemFlagShowNextxDays = mFlagShowNextxDays;
125 mFlagShowNextxDays = false; 125 mFlagShowNextxDays = false;
126 if ( view == 3 ) { 126 if ( view == 3 ) {
127 //mCurrentAgendaView = 1 ; 127 //mCurrentAgendaView = 1 ;
128 lastDate = mMainView->dateNavigator()->selectedDates().first(); 128 lastDate = mMainView->dateNavigator()->selectedDates().first();
129 lastCount = mMainView->dateNavigator()->selectedDates().count(); 129 lastCount = mMainView->dateNavigator()->selectedDates().count();
130 lastNDMode = savemFlagShowNextxDays; 130 lastNDMode = savemFlagShowNextxDays;
131 mMainView->showDay( date ); 131 mMainView->showDay( date );
132 lastMode = 1; 132 lastMode = 1;
133 } else if (view == 4 ) { 133 } else if (view == 4 ) {
134 mCurrentAgendaView = 7 ; 134 mCurrentAgendaView = 7 ;
135 mMainView->dateNavigator()->selectDates( date, 7 ); 135 mMainView->dateNavigator()->selectDates( date, 7 );
136 } else if (view == 5 ) { 136 } else if (view == 5 ) {
137 mCurrentAgendaView = 14 ; 137 mCurrentAgendaView = 14 ;
138 mMainView->dateNavigator()->selectDates( date, 14); 138 mMainView->dateNavigator()->selectDates( date, 14);
139 } else if (view == 6 ) { 139 } else if (view == 6 ) {
140 //mMainView->dateNavigator()->selectDates( date, 7 ); 140 //mMainView->dateNavigator()->selectDates( date, 7 );
141 showMonthView(); 141 showMonthView();
142 } else if (view == 7 ) { 142 } else if (view == 7 ) {
143 mMainView->dateNavigator()->selectDate( date ); 143 mMainView->dateNavigator()->selectDate( date );
144 showJournalView(); 144 showJournalView();
145 } else if (view == 8 ) { 145 } else if (view == 8 ) {
146 globalFlagBlockAgenda = 1; 146 globalFlagBlockAgenda = 1;
147 if ( mCurrentAgendaView != 3 ) 147 if ( mCurrentAgendaView != 3 )
148 mCurrentAgendaView = -1; 148 mCurrentAgendaView = -1;
149 showAgendaView(KOPrefs::instance()->mFullViewMonth); 149 showAgendaView(KOPrefs::instance()->mFullViewMonth);
150 globalFlagBlockAgenda = 2; 150 globalFlagBlockAgenda = 2;
151 mMainView->dateNavigator()->selectDates( date , 151 mMainView->dateNavigator()->selectDates( date ,
152 KOPrefs::instance()->mNextXDays ); 152 KOPrefs::instance()->mNextXDays );
153 mFlagShowNextxDays = true; 153 mFlagShowNextxDays = true;
154 mCurrentAgendaView = 3 ; 154 mCurrentAgendaView = 3 ;
155 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 155 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
156 if ( lastMode ) { 156 if ( lastMode ) {
157 mCurrentAgendaView = lastCount ; 157 mCurrentAgendaView = lastCount ;
158 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 158 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
159 mFlagShowNextxDays = lastNDMode; 159 mFlagShowNextxDays = lastNDMode;
160 if ( mFlagShowNextxDays ) { 160 if ( mFlagShowNextxDays ) {
161 mCurrentAgendaView = 3 ; 161 mCurrentAgendaView = 3 ;
162 } 162 }
163 } else 163 } else
164 showWeekView(); 164 showWeekView();
165 } else if (view == 10) { 165 } else if (view == 10) {
166 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 166 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
167 } 167 }
168} 168}
169 169
170 170
171 171
172void KOViewManager::writeSettings(KConfig *config) 172void KOViewManager::writeSettings(KConfig *config)
173{ 173{
174 config->setGroup("General"); 174 config->setGroup("General");
175 175
176 QString view; 176 QString view;
177 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 177 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
178 else if (mCurrentView == mMonthView) view = "Month"; 178 else if (mCurrentView == mMonthView) view = "Month";
179 else if (mCurrentView == mListView) view = "List"; 179 else if (mCurrentView == mListView) view = "List";
180 else if (mCurrentView == mJournalView) view = "Journal"; 180 else if (mCurrentView == mJournalView) view = "Journal";
181 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 181 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
182 else if (mCurrentView == mTodoView) view = "Todo"; 182 else if (mCurrentView == mTodoView) view = "Todo";
183 else view = "Agenda"; 183 else view = "Agenda";
184 184
185 config->writeEntry("Current View",view); 185 config->writeEntry("Current View",view);
186 186
187 if (mAgendaView) { 187 if (mAgendaView) {
188 mAgendaView->writeSettings(config); 188 mAgendaView->writeSettings(config);
189 } 189 }
190 if (mTimeSpanView) { 190 if (mTimeSpanView) {
191 mTimeSpanView->writeSettings(config); 191 mTimeSpanView->writeSettings(config);
192 } 192 }
193 if (mListView) { 193 if (mListView) {
194 mListView->writeSettings(config); 194 mListView->writeSettings(config);
195 } 195 }
196 if (mTodoView) { 196 if (mTodoView) {
197 mTodoView->saveLayout(config,"Todo View"); 197 mTodoView->saveLayout(config,"Todo View");
198 } 198 }
199} 199}
200 200
201void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 201void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
202{ 202{
203 203
204 //mFlagShowNextxDays = false; 204 //mFlagShowNextxDays = false;
205 //if(view == mCurrentView) return; 205 //if(view == mCurrentView) return;
206 if ( view == 0 ) { 206 if ( view == 0 ) {
207 view = mCurrentView; 207 view = mCurrentView;
208 if ( view == 0 ) 208 if ( view == 0 )
209 return; 209 return;
210 } 210 }
211 bool full = fullScreen; 211 bool full = fullScreen;
212 if(view == mCurrentView && view != mWhatsNextView ) { 212 if(view == mCurrentView && view != mWhatsNextView ) {
213 if ( mCurrentAgendaView < 0 ) 213 if ( mCurrentAgendaView < 0 )
214 return; 214 return;
215 if ( view != mMonthView ) 215 if ( view != mMonthView )
216 full = mMainView->leftFrame()->isVisible(); 216 full = mMainView->leftFrame()->isVisible();
217 } else { 217 } else {
218 if ( view == mMonthView && mMonthView) 218 if ( view == mMonthView && mMonthView)
219 ;//mMonthView->skipResize = true ; 219 ;//mMonthView->skipResize = true ;
220 mCurrentView = view; 220 mCurrentView = view;
221 // bool full = fullScreen; 221 // bool full = fullScreen;
222 bool isFull = !mMainView->leftFrame()->isVisible(); 222 bool isFull = !mMainView->leftFrame()->isVisible();
223 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 223 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
224 full = true; 224 full = true;
225 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 225 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
226 full = false; 226 full = false;
227 } 227 }
228 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 228 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
229 //raiseCurrentView( full ); 229 //raiseCurrentView( full );
230 mMainView->processIncidenceSelection( 0 ); 230 mMainView->processIncidenceSelection( 0 );
231 //mMainView->updateView(); 231 //mMainView->updateView();
232 raiseCurrentView( full, true ); 232 raiseCurrentView( full, true );
233 mMainView->adaptNavigationUnits(); 233 mMainView->adaptNavigationUnits();
234} 234}
235 235
236void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 236void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
237{ 237{
238 mCurrentAgendaView = 0; 238 mCurrentAgendaView = 0;
239 if ( fullScreen ) { 239 if ( fullScreen ) {
240 mMainView->leftFrame()->hide(); 240 mMainView->leftFrame()->hide();
241 } else { 241 } else {
242 mMainView->leftFrame()->show(); 242 mMainView->leftFrame()->show();
243 } 243 }
244 //if ( mCurrentView == mMonthView ) qApp->processEvents();
244 emit signalFullScreen( !fullScreen ); 245 emit signalFullScreen( !fullScreen );
245 if ( callUpdateView ) 246 if ( callUpdateView )
246 mMainView->updateView(); 247 mMainView->updateView();
247 248
248 if ( globalFlagBlockAgenda == 5 ) { 249 if ( globalFlagBlockAgenda == 5 ) {
249 globalFlagBlockAgenda = 4; 250 globalFlagBlockAgenda = 4;
250 globalFlagBlockAgendaItemPaint = 1; 251 globalFlagBlockAgendaItemPaint = 1;
251 } 252 }
252 mMainView->viewStack()->raiseWidget(mCurrentView); 253 mMainView->viewStack()->raiseWidget(mCurrentView);
253 if ( globalFlagBlockAgenda == 4 ) { 254 if ( globalFlagBlockAgenda == 4 ) {
254 if ( mCurrentView == mAgendaView ) { 255 if ( mCurrentView == mAgendaView ) {
255 //globalFlagBlockAgenda =1 ; 256 //globalFlagBlockAgenda =1 ;
256 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 257 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
257 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 258 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
258 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 259 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
259 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 260 mAgendaView->setStartHour( QTime::currentTime ().hour() );
260 qApp->processEvents(); 261 qApp->processEvents();
261 //qDebug("qApp->processEvents() "); 262 //qDebug("qApp->processEvents() ");
262 globalFlagBlockAgenda = 0; 263 globalFlagBlockAgenda = 0;
263 mAgendaView->repaintAgenda(); 264 mAgendaView->repaintAgenda();
264 265
265 } 266 }
266 globalFlagBlockAgenda = 0; 267 globalFlagBlockAgenda = 0;
267 } 268 }
268 emit signalAgendaView( mCurrentView == mAgendaView ); 269 emit signalAgendaView( mCurrentView == mAgendaView );
269 //qDebug("raiseCurrentView ende "); 270 //qDebug("raiseCurrentView ende ");
270 271
271} 272}
272 273
273void KOViewManager::updateView() 274void KOViewManager::updateView()
274{ 275{
275 // qDebug("KOViewManager::updateView() "); 276 // qDebug("KOViewManager::updateView() ");
276 // if we are updating mTodoView, we get endless recursion 277 // if we are updating mTodoView, we get endless recursion
277 if ( mTodoView == mCurrentView ) 278 if ( mTodoView == mCurrentView )
278 return; 279 return;
279 if ( mCurrentView ) mCurrentView->updateView(); 280 if ( mCurrentView ) mCurrentView->updateView();
280 281
281} 282}
282 283
283void KOViewManager::updateView(const QDate &start, const QDate &end) 284void KOViewManager::updateView(const QDate &start, const QDate &end)
284{ 285{
285 // kdDebug() << "KOViewManager::updateView()" << endl; 286 // kdDebug() << "KOViewManager::updateView()" << endl;
286 287
287 if (mCurrentView) mCurrentView->showDates(start, end); 288 if (mCurrentView) mCurrentView->showDates(start, end);
288 289
289 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 290 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
290} 291}
291 292
292 293
293void KOViewManager::updateWNview() 294void KOViewManager::updateWNview()
294{ 295{
295 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 296 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
296 mWhatsNextView->updateView(); 297 mWhatsNextView->updateView();
297 298
298} 299}
299void KOViewManager::showWhatsNextView() 300void KOViewManager::showWhatsNextView()
300{ 301{
301 if (!mWhatsNextView) { 302 if (!mWhatsNextView) {
302 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 303 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
303 "KOViewManager::WhatsNextView"); 304 "KOViewManager::WhatsNextView");
304 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 305 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
305 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 306 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
306 addView(mWhatsNextView); 307 addView(mWhatsNextView);
307 connect(this, SIGNAL( printWNV() ), 308 connect(this, SIGNAL( printWNV() ),
308 mWhatsNextView, SLOT( printMe() ) ); 309 mWhatsNextView, SLOT( printMe() ) );
309 } 310 }
310 globalFlagBlockAgenda = 1; 311 globalFlagBlockAgenda = 1;
311 showView(mWhatsNextView, true ); 312 showView(mWhatsNextView, true );
312 //mWhatsNextView->updateView(); 313 //mWhatsNextView->updateView();
313 314
314} 315}
315 316
316void KOViewManager::showListView() 317void KOViewManager::showListView()
317{ 318{
318 if (!mListView) { 319 if (!mListView) {
319 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 320 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
320 addView(mListView); 321 addView(mListView);
321 322
322 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 323 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
323 mMainView, SLOT(showIncidence(Incidence *))); 324 mMainView, SLOT(showIncidence(Incidence *)));
324 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 325 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
325 mMainView, SLOT(editIncidence(Incidence *))); 326 mMainView, SLOT(editIncidence(Incidence *)));
326 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 327 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
327 mMainView, SLOT(deleteIncidence(Incidence *))); 328 mMainView, SLOT(deleteIncidence(Incidence *)));
328 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 329 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
329 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 330 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
330 connect( mListView, SIGNAL( signalNewEvent() ), 331 connect( mListView, SIGNAL( signalNewEvent() ),
331 mMainView, SLOT( newEvent() ) ); 332 mMainView, SLOT( newEvent() ) );
332 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 333 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
333 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 334 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
334 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 335 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
335 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 336 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
336 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 337 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
337 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 338 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
338 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 339 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
339 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 340 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
340 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 341 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
341 } 342 }
342 // bool temp = mFlagShowNextxDays; 343 // bool temp = mFlagShowNextxDays;
343 //globalFlagBlockPainting = true; 344 //globalFlagBlockPainting = true;
344 globalFlagBlockAgenda = 1; 345 globalFlagBlockAgenda = 1;
345 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 346 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
346 mMainView->setBlockShowDates( true ); 347 mMainView->setBlockShowDates( true );
347 mMainView->dateNavigator()->selectMonth(); 348 mMainView->dateNavigator()->selectMonth();
348 mMainView->setBlockShowDates( false ); 349 mMainView->setBlockShowDates( false );
349 } 350 }
350 showView(mListView, KOPrefs::instance()->mFullViewTodo); 351 showView(mListView, KOPrefs::instance()->mFullViewTodo);
351 //mFlagShowNextxDays = temp; 352 //mFlagShowNextxDays = temp;
352} 353}
353 354
354void KOViewManager::showAgendaView( bool fullScreen ) 355void KOViewManager::showAgendaView( bool fullScreen )
355{ 356{
356 357
357 mMainView->dialogManager()->hideSearchDialog(); 358 mMainView->dialogManager()->hideSearchDialog();
358 // qDebug("KOViewManager::showAgendaView "); 359 // qDebug("KOViewManager::showAgendaView ");
359 bool full; 360 bool full;
360 full = fullScreen; 361 full = fullScreen;
361 if (!mAgendaView) { 362 if (!mAgendaView) {
362 full = false; 363 full = false;
363 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 364 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
364 addView(mAgendaView); 365 addView(mAgendaView);
365#ifndef DESKTOP_VERSION 366#ifndef DESKTOP_VERSION
366 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 367 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
367#endif 368#endif
368 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 369 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
369 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 370 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
370 371
371 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 372 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
372 373
373 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 374 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
374 375
375 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 376 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
376 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 377 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
377 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 378 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
378 mMainView, SLOT(newEvent(QDateTime))); 379 mMainView, SLOT(newEvent(QDateTime)));
379 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 380 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
380 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 381 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
381 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 382 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
382 mMainView, SLOT(newEvent(QDate))); 383 mMainView, SLOT(newEvent(QDate)));
383 384
384 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 385 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
385 mMainView, SLOT(editIncidence(Incidence *))); 386 mMainView, SLOT(editIncidence(Incidence *)));
386 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 387 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
387 mMainView, SLOT(showIncidence(Incidence *))); 388 mMainView, SLOT(showIncidence(Incidence *)));
388 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 389 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
389 mMainView, SLOT(deleteIncidence(Incidence *))); 390 mMainView, SLOT(deleteIncidence(Incidence *)));
390 391
391 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 392 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
392 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 393 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
393 394
394 connect(mAgendaView, SIGNAL( toggleExpand() ), 395 connect(mAgendaView, SIGNAL( toggleExpand() ),
395 mMainView, SLOT( toggleExpand() ) ); 396 mMainView, SLOT( toggleExpand() ) );
396 397
397 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 398 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
398 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 399 mAgendaView, SLOT( setExpandedButton( bool ) ) );
399 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 400 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
400 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 401 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
401 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 402 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
402 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 403 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
403 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 404 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
404 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 405 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
405 SLOT( updateTodo( Todo *, int ) ) ); 406 SLOT( updateTodo( Todo *, int ) ) );
406 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 407 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
407 mMainView, SIGNAL( todoModified( Todo *, int ))); 408 mMainView, SIGNAL( todoModified( Todo *, int )));
408 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 409 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
409 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 410 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
410 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 411 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
411 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 412 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
412 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), 413 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
413 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 414 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
414 mAgendaView->readSettings(); 415 mAgendaView->readSettings();
415 mAgendaView->updateConfig(); 416 mAgendaView->updateConfig();
416 } 417 }
417 418
418 showView( mAgendaView, full); 419 showView( mAgendaView, full);
419 420
420} 421}
421 422
422void KOViewManager::showDayView() 423void KOViewManager::showDayView()
423{ 424{
424 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 425 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
425 mFlagShowNextxDays = false; 426 mFlagShowNextxDays = false;
426 globalFlagBlockLabel = 1; 427 globalFlagBlockLabel = 1;
427 globalFlagBlockAgenda = 1; 428 globalFlagBlockAgenda = 1;
428 if ( mCurrentAgendaView != 1 ) 429 if ( mCurrentAgendaView != 1 )
429 mCurrentAgendaView = -1; 430 mCurrentAgendaView = -1;
430 showAgendaView(); 431 showAgendaView();
431 qApp->processEvents(); 432 qApp->processEvents();
432 globalFlagBlockAgenda = 2; 433 globalFlagBlockAgenda = 2;
433 globalFlagBlockLabel = 0; 434 globalFlagBlockLabel = 0;
434 mMainView->dateNavigator()->selectDates( 1 ); 435 mMainView->dateNavigator()->selectDates( 1 );
435 mCurrentAgendaView = 1 ; 436 mCurrentAgendaView = 1 ;
436 437
437} 438}
438 439
439void KOViewManager::showWorkWeekView() 440void KOViewManager::showWorkWeekView()
440{ 441{
441 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 442 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
442 mFlagShowNextxDays = false; 443 mFlagShowNextxDays = false;
443 globalFlagBlockAgenda = 1; 444 globalFlagBlockAgenda = 1;
444 globalFlagBlockLabel = 1; 445 globalFlagBlockLabel = 1;
445 if ( mCurrentAgendaView != 5 ) 446 if ( mCurrentAgendaView != 5 )
446 mCurrentAgendaView = -1; 447 mCurrentAgendaView = -1;
447 showAgendaView(); 448 showAgendaView();
448 qApp->processEvents(); 449 qApp->processEvents();
449 globalFlagBlockAgenda = 2; 450 globalFlagBlockAgenda = 2;
450 globalFlagBlockLabel = 0; 451 globalFlagBlockLabel = 0;
451 mMainView->dateNavigator()->selectWorkWeek(); 452 mMainView->dateNavigator()->selectWorkWeek();
452 mCurrentAgendaView = 5 ; 453 mCurrentAgendaView = 5 ;
453 454
454} 455}
455 456
456void KOViewManager::showWeekView() 457void KOViewManager::showWeekView()
457{ 458{
458 /* 459 /*
459 globalFlagBlockAgenda = 2; 460 globalFlagBlockAgenda = 2;
460 qDebug("4globalFlagBlockAgenda = 2; "); 461 qDebug("4globalFlagBlockAgenda = 2; ");
461 //globalFlagBlockPainting = true; 462 //globalFlagBlockPainting = true;
462 mMainView->dateNavigator()->selectWeek(); 463 mMainView->dateNavigator()->selectWeek();
463 showAgendaView(); 464 showAgendaView();
464 */ 465 */
465 466
466 467
467 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 468 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
468 mFlagShowNextxDays = false; 469 mFlagShowNextxDays = false;
469 globalFlagBlockAgenda = 1; 470 globalFlagBlockAgenda = 1;
470 globalFlagBlockLabel = 1; 471 globalFlagBlockLabel = 1;
471 if ( mCurrentAgendaView != 7 ) 472 if ( mCurrentAgendaView != 7 )
472 mCurrentAgendaView = -1; 473 mCurrentAgendaView = -1;
473 showAgendaView(); 474 showAgendaView();
474 qApp->processEvents(); 475 qApp->processEvents();
475 globalFlagBlockAgenda = 2; 476 globalFlagBlockAgenda = 2;
476 globalFlagBlockLabel = 0; 477 globalFlagBlockLabel = 0;
477 mMainView->dateNavigator()->selectWeek(); 478 mMainView->dateNavigator()->selectWeek();
478 mCurrentAgendaView = 7 ; 479 mCurrentAgendaView = 7 ;
479} 480}
480 481
481void KOViewManager::showNextXView() 482void KOViewManager::showNextXView()
482{ 483{
483 484
484 globalFlagBlockAgenda = 1; 485 globalFlagBlockAgenda = 1;
485 if ( mCurrentAgendaView != 3 ) 486 if ( mCurrentAgendaView != 3 )
486 mCurrentAgendaView = -1; 487 mCurrentAgendaView = -1;
487 showAgendaView(KOPrefs::instance()->mFullViewMonth); 488 showAgendaView(KOPrefs::instance()->mFullViewMonth);
488 globalFlagBlockAgenda = 2; 489 globalFlagBlockAgenda = 2;
489 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 490 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
490 KOPrefs::instance()->mNextXDays ); 491 KOPrefs::instance()->mNextXDays );
491 mFlagShowNextxDays = true; 492 mFlagShowNextxDays = true;
492 mCurrentAgendaView = 3 ; 493 mCurrentAgendaView = 3 ;
493} 494}
494bool KOViewManager::showsNextDays() 495bool KOViewManager::showsNextDays()
495{ 496{
496 return mFlagShowNextxDays; 497 return mFlagShowNextxDays;
497} 498}
498void KOViewManager::createMonthView() 499void KOViewManager::createMonthView()
499{ 500{
500if (!mMonthView) { 501if (!mMonthView) {
501 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 502 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
502 503
503 addView(mMonthView); 504 addView(mMonthView);
504 // mMonthView->show(); 505 // mMonthView->show();
505 // SIGNALS/SLOTS FOR MONTH VIEW 506 // SIGNALS/SLOTS FOR MONTH VIEW
506 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 507 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
507 mMainView, SLOT(newEvent(QDateTime))); 508 mMainView, SLOT(newEvent(QDateTime)));
508 509
509 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 510 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
510 mMainView, SLOT(showIncidence(Incidence *))); 511 mMainView, SLOT(showIncidence(Incidence *)));
511 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 512 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
512 mMainView, SLOT(editIncidence(Incidence *))); 513 mMainView, SLOT(editIncidence(Incidence *)));
513 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 514 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
514 mMainView, SLOT(deleteIncidence(Incidence *))); 515 mMainView, SLOT(deleteIncidence(Incidence *)));
515 516
516 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 517 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
517 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 518 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
518 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 519 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
519 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 520 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
520 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 521 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
521 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 522 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
522 523
523 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 524 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
524 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 525 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
525 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 526 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
526 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 527 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
527 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 528 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
528 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); 529 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) );
529 connect( mMonthView, SIGNAL( selectMonth() ), 530 connect( mMonthView, SIGNAL( selectMonth() ),
530 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); 531 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) );
531 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 532 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
532 mMainView, SLOT ( showDay( QDate ) ) ); 533 mMainView, SLOT ( showDay( QDate ) ) );
533 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 534 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
534 connect( mMonthView, SIGNAL(nextMonth() ), 535 connect( mMonthView, SIGNAL(nextMonth() ),
535 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); 536 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
536 connect( mMonthView, SIGNAL(prevMonth() ), 537 connect( mMonthView, SIGNAL(prevMonth() ),
537 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 538 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
538 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), 539 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
539 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); 540 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
540 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), 541 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
541 mMainView->dateNavigator(), SLOT( selectNextYear() ) ); 542 mMainView->dateNavigator(), SLOT( selectNextYear() ) );
542 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), 543 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
543 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); 544 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
544 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), 545 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
545 mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); 546 mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
546 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), 547 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ),
547 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); 548 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) );
548 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), 549 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ),
549 mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); 550 mMainView->dateNavigator(), SLOT( selectNextWeek() ) );
550 551
551 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 552 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
552 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); 553 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
553 554
554 555
555 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), 556 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ),
556 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); 557 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) );
557 558
558 } 559 }
559} 560}
560void KOViewManager::showMonthViewWeek() 561void KOViewManager::showMonthViewWeek()
561{ 562{
562 createMonthView(); 563 createMonthView();
563 globalFlagBlockAgenda = 1; 564 globalFlagBlockAgenda = 1;
564 bool full = true; 565 bool full = true;
565 if ( mCurrentView == mMonthView) 566 if ( mCurrentView == mMonthView)
566 full = mMainView->leftFrame()->isVisible(); 567 full = mMainView->leftFrame()->isVisible();
567 if ( !KOPrefs::instance()->mMonthViewWeek ) { 568 if ( !KOPrefs::instance()->mMonthViewWeek ) {
568 mMonthView->switchView(); 569 mMonthView->switchView();
569 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 570 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
570 full = false; 571 full = false;
571 else 572 else
572 full = true; 573 full = true;
573 } 574 }
574 mMainView->dateNavigator()->selectWeek(); 575 mMainView->dateNavigator()->selectWeek();
575 showView(mMonthView, full ); 576 showView(mMonthView, full );
576} 577}
577 578
578void KOViewManager::showMonthView() 579void KOViewManager::showMonthView()
579 { 580 {
580 581
581 createMonthView(); 582 createMonthView();
582 globalFlagBlockAgenda = 1; 583 globalFlagBlockAgenda = 1;
583 //mFlagShowNextxDays = false; 584 //mFlagShowNextxDays = false;
584 bool full = true; 585 bool full = true;
585 if ( mCurrentView == mMonthView) 586 if ( mCurrentView == mMonthView)
586 full = mMainView->leftFrame()->isVisible(); 587 full = mMainView->leftFrame()->isVisible();
587 // if(mMonthView == mCurrentView) return; 588 // if(mMonthView == mCurrentView) return;
588 if ( KOPrefs::instance()->mMonthViewWeek ) { 589 if ( KOPrefs::instance()->mMonthViewWeek ) {
589 mMonthView->switchView(); 590 mMonthView->switchView();
590 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 591 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
591 full = false; 592 full = false;
592 else 593 else
593 full = true; 594 full = true;
594 } 595 }
595 mMainView->dateNavigator()->selectMonth(); 596 mMainView->dateNavigator()->selectMonth();
596 597
597 showView(mMonthView, full ); 598 showView(mMonthView, full );
598 599
599} 600}
600 601
601void KOViewManager::showTodoView() 602void KOViewManager::showTodoView()
602{ 603{
603 //mFlagShowNextxDays = false; 604 //mFlagShowNextxDays = false;
604 if ( !mTodoView ) { 605 if ( !mTodoView ) {
605 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 606 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
606 "KOViewManager::TodoView" ); 607 "KOViewManager::TodoView" );
607 608
608 addView( mTodoView ); 609 addView( mTodoView );
609 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 610 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
610 611
611 // SIGNALS/SLOTS FOR TODO VIEW 612 // SIGNALS/SLOTS FOR TODO VIEW
612 connect( mTodoView, SIGNAL( newTodoSignal() ), 613 connect( mTodoView, SIGNAL( newTodoSignal() ),
613 mMainView, SLOT( newTodo() ) ); 614 mMainView, SLOT( newTodo() ) );
614 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 615 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
615 mMainView, SLOT( newSubTodo( Todo *) ) ); 616 mMainView, SLOT( newSubTodo( Todo *) ) );
616 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 617 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
617 mMainView, SLOT( showTodo( Todo * ) ) ); 618 mMainView, SLOT( showTodo( Todo * ) ) );
618 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 619 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
619 mMainView, SLOT( editTodo( Todo * ) ) ); 620 mMainView, SLOT( editTodo( Todo * ) ) );
620 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 621 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
621 mMainView, SLOT( deleteTodo( Todo * ) ) ); 622 mMainView, SLOT( deleteTodo( Todo * ) ) );
622 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 623 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
623 mMainView, SLOT( purgeCompleted() ) ); 624 mMainView, SLOT( purgeCompleted() ) );
624 625
625 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 626 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
626 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 627 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
627 628