summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kdatenavigator.cpp4
-rw-r--r--korganizer/koagendaview.cpp6
-rw-r--r--korganizer/kodaymatrix.cpp1
-rw-r--r--korganizer/koeditorgeneral.cpp2
-rw-r--r--korganizer/koeditorrecurrence.cpp10
-rw-r--r--korganizer/koeventviewer.cpp4
-rw-r--r--korganizer/koglobals.cpp31
-rw-r--r--korganizer/koglobals.h5
-rw-r--r--korganizer/koincidenceeditor.cpp1
-rw-r--r--korganizer/kolistview.cpp9
-rw-r--r--korganizer/kolistview.h2
-rw-r--r--korganizer/komonthview.cpp14
-rw-r--r--korganizer/korganizer.pro2
-rw-r--r--korganizer/korganizerE.pro2
-rw-r--r--korganizer/kotodoview.cpp31
-rw-r--r--korganizer/koviewmanager.cpp10
-rw-r--r--korganizer/kowhatsnextview.cpp2
-rw-r--r--korganizer/ktimeedit.cpp2
-rw-r--r--korganizer/mainwindow.cpp6
-rw-r--r--korganizer/mainwindow.h9
-rw-r--r--korganizer/searchdialog.cpp3
21 files changed, 29 insertions, 127 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 5aa1c9b..6697602 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -1,467 +1,465 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001,2002 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 <qstring.h> 24#include <qstring.h>
25#include <qkeycode.h> 25#include <qkeycode.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qframe.h> 28#include <qframe.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qapplication.h> 30#include <qapplication.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kglobal.h> 34#include <kglobal.h>
35 35
36#include "koglobals.h" 36#include "koglobals.h"
37#include "koprefs.h" 37#include "koprefs.h"
38#ifndef KORG_NOPLUGINS 38#ifndef KORG_NOPLUGINS
39#include "kocore.h" 39#include "kocore.h"
40#endif 40#endif
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#include "navigatorbar.h" 44#include "navigatorbar.h"
45 45
46#include "kdatenavigator.h" 46#include "kdatenavigator.h"
47 47
48KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) 48KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
49 : QFrame(parent, name), 49 : QFrame(parent, name),
50 updateTimer(0L) 50 updateTimer(0L)
51{ 51{
52 setFrameStyle(QFrame::NoFrame); 52 setFrameStyle(QFrame::NoFrame);
53 QDate startDate = QDate::currentDate(); 53 QDate startDate = QDate::currentDate();
54 QGridLayout *topLayout = new QGridLayout(this,8,8); 54 QGridLayout *topLayout = new QGridLayout(this,8,8);
55 55
56 if (! startDate.isValid()) { 56 if (! startDate.isValid()) {
57 qDebug("KDateNavigator::invalid startdate "); 57 qDebug("KDateNavigator::invalid startdate ");
58 startDate = QDate::currentDate(); 58 startDate = QDate::currentDate();
59 } 59 }
60 mMonthSignalOffset = 0; 60 mMonthSignalOffset = 0;
61 mSelectedDates.append(startDate); 61 mSelectedDates.append(startDate);
62 m_MthYr = startDate; 62 m_MthYr = startDate;
63 m_bShowWeekNums = true; 63 m_bShowWeekNums = true;
64 setFont( KOPrefs::instance()->mDateNavigatorFont ); 64 setFont( KOPrefs::instance()->mDateNavigatorFont );
65 mNavigatorBar = new NavigatorBar( startDate, this ); 65 mNavigatorBar = new NavigatorBar( startDate, this );
66 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); 66 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 );
67 //mNavigatorBar->resize( 1,1); 67 //mNavigatorBar->resize( 1,1);
68 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 68 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
69 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 69 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
70 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 70 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
71 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 71 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
72 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 72 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
73 73
74 // get the day of the week on the first day 74 // get the day of the week on the first day
75 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 75 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
76 m_fstDayOfWk = dayone.dayOfWeek(); 76 m_fstDayOfWk = dayone.dayOfWeek();
77 77
78 int i; 78 int i;
79 79
80 // Set up the heading fields. 80 // Set up the heading fields.
81 for( i = 0; i < 7; i++ ) { 81 for( i = 0; i < 7; i++ ) {
82 headings[i] = new QLabel("",this); 82 headings[i] = new QLabel("",this);
83 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); 83 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
84 headings[i]->setAlignment(AlignCenter); 84 headings[i]->setAlignment(AlignCenter);
85 headings[i]->installEventFilter(this); 85 headings[i]->installEventFilter(this);
86 86
87 topLayout->addWidget(headings[i],1,i+1); 87 topLayout->addWidget(headings[i],1,i+1);
88 } 88 }
89 89
90 // Create the weeknumber labels 90 // Create the weeknumber labels
91 for( i = 0; i < 6; i++ ) { 91 for( i = 0; i < 6; i++ ) {
92 weeknos[i] = new QLabel(this); 92 weeknos[i] = new QLabel(this);
93 weeknos[i]->setAlignment(AlignCenter ); 93 weeknos[i]->setAlignment(AlignCenter );
94 //weeknos[i]->setFont(QFont("Arial", 10)); 94 //weeknos[i]->setFont(QFont("Arial", 10));
95 if(!m_bShowWeekNums) { 95 if(!m_bShowWeekNums) {
96 weeknos[i]->hide(); 96 weeknos[i]->hide();
97 } 97 }
98 weeknos[i]->installEventFilter(this); 98 weeknos[i]->installEventFilter(this);
99 99
100 topLayout->addWidget(weeknos[i],i+2,0); 100 topLayout->addWidget(weeknos[i],i+2,0);
101 } 101 }
102 102
103 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); 103 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
104 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); 104 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
105 daymatrix->setLineWidth(1); 105 daymatrix->setLineWidth(1);
106 106
107 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), 107 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
108 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 108 SIGNAL( datesSelected( const KCal::DateList & ) ) );
109 109
110 connect( daymatrix, SIGNAL( eventDropped( Event * ) ), 110 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
111 SIGNAL( eventDropped( Event * ) ) ); 111 SIGNAL( eventDropped( Event * ) ) );
112 112
113 topLayout->addMultiCellWidget(daymatrix,2,7,1,7); 113 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
114 114
115 // read settings from configuration file. 115 // read settings from configuration file.
116 updateConfig(); 116 updateConfig();
117 enableRollover(FollowMonth); 117 enableRollover(FollowMonth);
118 mySizeHint = sizeHintTwoButtons(); 118 mySizeHint = sizeHintTwoButtons();
119 myFullSizeHint = sizeHintTwoButtons( 4 ); 119 myFullSizeHint = sizeHintTwoButtons( 4 );
120 mFontChanged = false; 120 mFontChanged = false;
121 //resize ( 3,3 ); 121 //resize ( 3,3 );
122 122
123} 123}
124void KDateNavigator::changeFont ( QFont fo ) 124void KDateNavigator::changeFont ( QFont fo )
125{ 125{
126 setFont( fo ); 126 setFont( fo );
127 mNavigatorBar->resetFont( fo ); 127 mNavigatorBar->resetFont( fo );
128} 128}
129QFont KDateNavigator::yourFontHint( QSize si , bool *b) 129QFont KDateNavigator::yourFontHint( QSize si , bool *b)
130{ 130{
131 QFont fo = KOPrefs::instance()->mDateNavigatorFont; 131 QFont fo = KOPrefs::instance()->mDateNavigatorFont;
132 *b = false; 132 *b = false;
133 int fontPoint = fo.pointSize(); 133 int fontPoint = fo.pointSize();
134 while ( fontPoint > 5 ) { 134 while ( fontPoint > 5 ) {
135 --fontPoint; 135 --fontPoint;
136 fo.setPointSize( fontPoint ); 136 fo.setPointSize( fontPoint );
137 setFont( fo ); 137 setFont( fo );
138 mFontChanged = true; 138 mFontChanged = true;
139 mNavigatorBar->resetFont( fo ); 139 mNavigatorBar->resetFont( fo );
140 QSize sh = sizeHintTwoButtons( 2 ); 140 QSize sh = sizeHintTwoButtons( 2 );
141 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); 141 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() );
142 if ( si.width() > sh.width() && si.height() > sh.height()) { 142 if ( si.width() > sh.width() && si.height() > sh.height()) {
143 if ( si.width() / sh.width() == 1 ) { 143 if ( si.width() / sh.width() == 1 ) {
144 if ( si.width() < sizeHintTwoButtons( 4 ).width()) 144 if ( si.width() < sizeHintTwoButtons( 4 ).width())
145 continue; 145 continue;
146 } 146 }
147 *b = true; 147 *b = true;
148 //qDebug("fooooooooooooooooooooooouuuuund ");
149 break; 148 break;
150 } 149 }
151 } 150 }
152 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() );
153 return fo; 151 return fo;
154} 152}
155QSize KDateNavigator::sizeHint() const 153QSize KDateNavigator::sizeHint() const
156{ 154{
157 QFontMetrics fm ( font() ); 155 QFontMetrics fm ( font() );
158 QSize day = daymatrix->sizeHint(); 156 QSize day = daymatrix->sizeHint();
159 QSize nav = mNavigatorBar->sizeHint(); 157 QSize nav = mNavigatorBar->sizeHint();
160 int wid = fm.width( "30") + day.width()+3; 158 int wid = fm.width( "30") + day.width()+3;
161 int hei = fm.height() +day.height()+nav.height()+2; 159 int hei = fm.height() +day.height()+nav.height()+2;
162 if ( wid < nav.width() ) 160 if ( wid < nav.width() )
163 wid = nav.width() ; 161 wid = nav.width() ;
164 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 162 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
165 return QSize ( wid, hei ); 163 return QSize ( wid, hei );
166} 164}
167QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const 165QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const
168{ 166{
169 QFontMetrics fm ( font() ); 167 QFontMetrics fm ( font() );
170 QSize day = daymatrix->sizeHint(); 168 QSize day = daymatrix->sizeHint();
171 QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); 169 QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum );
172 int wid = fm.width( "30") + day.width()+3; 170 int wid = fm.width( "30") + day.width()+3;
173 int hei = fm.height() +day.height()+nav.height()+2; 171 int hei = fm.height() +day.height()+nav.height()+2;
174 if ( wid < nav.width() ) 172 if ( wid < nav.width() )
175 wid = nav.width() ; 173 wid = nav.width() ;
176 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 174 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
177 return QSize ( wid, hei ); 175 return QSize ( wid, hei );
178} 176}
179void KDateNavigator::slotMonthSelected( int m ) 177void KDateNavigator::slotMonthSelected( int m )
180{ 178{
181 if ( m_MthYr.month() <= mMonthSignalOffset) 179 if ( m_MthYr.month() <= mMonthSignalOffset)
182 m += 12; 180 m += 12;
183 //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); 181 //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset);
184 emit monthSelected( m - mMonthSignalOffset ); 182 emit monthSelected( m - mMonthSignalOffset );
185 183
186} 184}
187void KDateNavigator::setCalendar( Calendar *cal ) 185void KDateNavigator::setCalendar( Calendar *cal )
188{ 186{
189 daymatrix->setCalendar( cal ); 187 daymatrix->setCalendar( cal );
190} 188}
191 189
192void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true 190void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true
193{ 191{
194 m_MthYr = date; 192 m_MthYr = date;
195 //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); 193 //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1());
196 194
197 updateDates(); 195 updateDates();
198 updateView(); 196 updateView();
199 197
200 KCal::DateList dates; 198 KCal::DateList dates;
201 dates.append( date ); 199 dates.append( date );
202 mNavigatorBar->selectDates( dates ); 200 mNavigatorBar->selectDates( dates );
203 201
204 daymatrix->clearSelection(); 202 daymatrix->clearSelection();
205 if ( doRepaint ) 203 if ( doRepaint )
206 daymatrix->repaint( false ); 204 daymatrix->repaint( false );
207} 205}
208 206
209void KDateNavigator::enableRollover(RolloverType r) 207void KDateNavigator::enableRollover(RolloverType r)
210{ 208{
211 switch(r) 209 switch(r)
212 { 210 {
213 case None : 211 case None :
214 if (updateTimer) 212 if (updateTimer)
215 { 213 {
216 updateTimer->stop(); 214 updateTimer->stop();
217 delete updateTimer; 215 delete updateTimer;
218 updateTimer=0L; 216 updateTimer=0L;
219 } 217 }
220 break; 218 break;
221 case FollowDay : 219 case FollowDay :
222 case FollowMonth : 220 case FollowMonth :
223 if (!updateTimer) 221 if (!updateTimer)
224 { 222 {
225 updateTimer = new QTimer(this); 223 updateTimer = new QTimer(this);
226 QObject::connect(updateTimer,SIGNAL(timeout()), 224 QObject::connect(updateTimer,SIGNAL(timeout()),
227 this,SLOT(possiblyPastMidnight())); 225 this,SLOT(possiblyPastMidnight()));
228 } 226 }
229 updateTimer->start(0,true); 227 updateTimer->start(0,true);
230 lastDayChecked = QDate::currentDate(); 228 lastDayChecked = QDate::currentDate();
231 } 229 }
232 updateRollover=r; 230 updateRollover=r;
233} 231}
234 232
235 233
236KDateNavigator::~KDateNavigator() 234KDateNavigator::~KDateNavigator()
237{ 235{
238} 236}
239 237
240 238
241void KDateNavigator::passedMidnight() 239void KDateNavigator::passedMidnight()
242{ 240{
243 QDate today = QDate::currentDate(); 241 QDate today = QDate::currentDate();
244 bool emitMonth = false; 242 bool emitMonth = false;
245 243
246 if (today.month() != lastDayChecked.month()) 244 if (today.month() != lastDayChecked.month())
247 { 245 {
248 if (updateRollover==FollowMonth && 246 if (updateRollover==FollowMonth &&
249 daymatrix->isEndOfMonth()) { 247 daymatrix->isEndOfMonth()) {
250 goNextMonth(); 248 goNextMonth();
251 emitMonth=true; 249 emitMonth=true;
252 } 250 }
253 } 251 }
254 daymatrix->recalculateToday(); 252 daymatrix->recalculateToday();
255 daymatrix->repaint( false ); 253 daymatrix->repaint( false );
256 emit dayPassed(today); 254 emit dayPassed(today);
257 if (emitMonth) { emit monthPassed(today); } 255 if (emitMonth) { emit monthPassed(today); }
258} 256}
259 257
260/* slot */ void KDateNavigator::possiblyPastMidnight() 258/* slot */ void KDateNavigator::possiblyPastMidnight()
261{ 259{
262 if (lastDayChecked!=QDate::currentDate()) 260 if (lastDayChecked!=QDate::currentDate())
263 { 261 {
264 passedMidnight(); 262 passedMidnight();
265 lastDayChecked=QDate::currentDate(); 263 lastDayChecked=QDate::currentDate();
266 } 264 }
267 // Set the timer to go off 1 second after midnight 265 // Set the timer to go off 1 second after midnight
268 // or after 8 minutes, whichever comes first. 266 // or after 8 minutes, whichever comes first.
269 if (updateTimer) 267 if (updateTimer)
270 { 268 {
271 QTime now = QTime::currentTime(); 269 QTime now = QTime::currentTime();
272 QTime midnight = QTime(23,59,59); 270 QTime midnight = QTime(23,59,59);
273 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); 271 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000);
274 272
275 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) 273 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait))
276 //.arg(now.toString()).arg(midnight.toString())); 274 //.arg(now.toString()).arg(midnight.toString()));
277 275
278 updateTimer->stop(); 276 updateTimer->stop();
279 updateTimer->start(msecsWait,true); 277 updateTimer->start(msecsWait,true);
280 } 278 }
281} 279}
282 280
283void KDateNavigator::updateDates() 281void KDateNavigator::updateDates()
284{ 282{
285 // Find the first day of the week of the current month. 283 // Find the first day of the week of the current month.
286 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); 284 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr );
287 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); 285 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() );
288 int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); 286 int d2 = KOGlobals::self()->calendarSystem()->day( dayone );
289 //int di = d1 - d2 + 1; 287 //int di = d1 - d2 + 1;
290 dayone = dayone.addDays( -d2 + 1 ); 288 dayone = dayone.addDays( -d2 + 1 );
291 289
292 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); 290 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone );
293 291
294 // If month begins on Monday and Monday is first day of week, 292 // If month begins on Monday and Monday is first day of week,
295 // month should begin on second line. Sunday doesn't have this problem. 293 // month should begin on second line. Sunday doesn't have this problem.
296 int nextLine = ( ( m_fstDayOfWkCalsys == 1) && 294 int nextLine = ( ( m_fstDayOfWkCalsys == 1) &&
297 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; 295 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0;
298 296
299 // update the matrix dates 297 // update the matrix dates
300 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; 298 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
301 299
302 300
303 daymatrix->updateView(dayone.addDays(index)); 301 daymatrix->updateView(dayone.addDays(index));
304//each updateDates is followed by an updateView -> repaint is issued there ! 302//each updateDates is followed by an updateView -> repaint is issued there !
305// daymatrix->repaint(); 303// daymatrix->repaint();
306} 304}
307 305
308void KDateNavigator::updateDayMatrix() 306void KDateNavigator::updateDayMatrix()
309{ 307{
310 daymatrix->updateView(); 308 daymatrix->updateView();
311 //daymatrix->repaint(); 309 //daymatrix->repaint();
312} 310}
313 311
314 312
315void KDateNavigator::updateView() 313void KDateNavigator::updateView()
316{ 314{
317 315
318 setUpdatesEnabled( false ); 316 setUpdatesEnabled( false );
319 317
320 int i; 318 int i;
321 319
322// kdDebug() << "updateView() -> daymatrix->updateView()" << endl; 320// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
323 daymatrix->updateView(); 321 daymatrix->updateView();
324 int sub = 4; 322 int sub = 4;
325 if ( ! KGlobal::locale()->weekStartsMonday() ) 323 if ( ! KGlobal::locale()->weekStartsMonday() )
326 --sub; 324 --sub;
327 // set the week numbers. 325 // set the week numbers.
328 for(i = 0; i < 6; i++) { 326 for(i = 0; i < 6; i++) {
329 // remember, according to ISO 8601, the first week of the year is the 327 // remember, according to ISO 8601, the first week of the year is the
330 // first week that contains a thursday. Thus we must subtract off 4, 328 // first week that contains a thursday. Thus we must subtract off 4,
331 // not just 1. 329 // not just 1.
332 330
333 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); 331 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
334 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub))); 332 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub)));
335 int weekNo; 333 int weekNo;
336 if (dayOfYear % 7 != 0) 334 if (dayOfYear % 7 != 0)
337 weekNo = (dayOfYear / 7 + 1); 335 weekNo = (dayOfYear / 7 + 1);
338 else 336 else
339 weekNo = (dayOfYear / 7); 337 weekNo = (dayOfYear / 7);
340 weeknos[i]->setText(QString::number( weekNo )); 338 weeknos[i]->setText(QString::number( weekNo ));
341 } 339 }
342 340
343 setUpdatesEnabled( true ); 341 setUpdatesEnabled( true );
344// kdDebug() << "updateView() -> repaint()" << endl; 342// kdDebug() << "updateView() -> repaint()" << endl;
345 repaint(); 343 repaint();
346 // daymatrix->repaint(); 344 // daymatrix->repaint();
347} 345}
348 346
349void KDateNavigator::updateConfig() 347void KDateNavigator::updateConfig()
350{ 348{
351 int day; 349 int day;
352 for(int i=0; i<7; i++) { 350 for(int i=0; i<7; i++) {
353 // take the first letter of the day name to be the abbreviation 351 // take the first letter of the day name to be the abbreviation
354 if (KGlobal::locale()->weekStartsMonday()) { 352 if (KGlobal::locale()->weekStartsMonday()) {
355 day = i+1; 353 day = i+1;
356 } else { 354 } else {
357 if (i==0) day = 7; 355 if (i==0) day = 7;
358 else day = i; 356 else day = i;
359 } 357 }
360 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, 358 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day,
361 true ); 359 true );
362 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); 360 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 );
363 headings[i]->setText( dayName ); 361 headings[i]->setText( dayName );
364 } 362 }
365 updateDates(); 363 updateDates();
366 updateView(); 364 updateView();
367} 365}
368 366
369void KDateNavigator::setShowWeekNums(bool enabled) 367void KDateNavigator::setShowWeekNums(bool enabled)
370{ 368{
371 qDebug("KDateNavigator::setShowWeekNums***************************** "); 369
372 m_bShowWeekNums = enabled; 370 m_bShowWeekNums = enabled;
373 for(int i=0; i<6; i++) { 371 for(int i=0; i<6; i++) {
374 if(enabled) 372 if(enabled)
375 weeknos[i]->show(); 373 weeknos[i]->show();
376 else 374 else
377 weeknos[i]->hide(); 375 weeknos[i]->hide();
378 } 376 }
379 resize(size()); 377 resize(size());
380} 378}
381 379
382void KDateNavigator::selectDates(const DateList& dateList) 380void KDateNavigator::selectDates(const DateList& dateList)
383{ 381{
384 382
385 if (dateList.count() > 0) { 383 if (dateList.count() > 0) {
386 mNavigatorBar->selectDates( dateList ); 384 mNavigatorBar->selectDates( dateList );
387 mSelectedDates = dateList; 385 mSelectedDates = dateList;
388 386
389 // set our record of the month and year that this datetbl is 387 // set our record of the month and year that this datetbl is
390 // displaying. 388 // displaying.
391 m_MthYr = mSelectedDates.first(); 389 m_MthYr = mSelectedDates.first();
392 390
393 391
394 // set our record of the first day of the week of the current 392 // set our record of the first day of the week of the current
395 // month. This needs to be done before calling dayToIndex, since it 393 // month. This needs to be done before calling dayToIndex, since it
396 // relies on this information being up to date. 394 // relies on this information being up to date.
397 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 395 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
398 m_fstDayOfWk = dayone.dayOfWeek(); 396 m_fstDayOfWk = dayone.dayOfWeek();
399 397
400 updateDates(); 398 updateDates();
401 399
402 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 400 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
403 401
404 updateView(); 402 updateView();
405 } 403 }
406} 404}
407 405
408int KDateNavigator::dayNum(int row, int col) 406int KDateNavigator::dayNum(int row, int col)
409{ 407{
410 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; 408 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk;
411} 409}
412 410
413int KDateNavigator::dayToIndex(int dayNum) 411int KDateNavigator::dayToIndex(int dayNum)
414{ 412{
415 int row, col; 413 int row, col;
416 414
417 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; 415 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7;
418 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) 416 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1))
419 row++; 417 row++;
420 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; 418 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7;
421 return row * 7 + col; 419 return row * 7 + col;
422} 420}
423 421
424void KDateNavigator::wheelEvent (QWheelEvent *e) 422void KDateNavigator::wheelEvent (QWheelEvent *e)
425{ 423{
426 if(e->delta()>0) emit goPrevious(); 424 if(e->delta()>0) emit goPrevious();
427 else emit goNext(); 425 else emit goNext();
428 426
429 e->accept(); 427 e->accept();
430} 428}
431 429
432bool KDateNavigator::eventFilter (QObject *o,QEvent *e) 430bool KDateNavigator::eventFilter (QObject *o,QEvent *e)
433{ 431{
434 if (e->type() == QEvent::MouseButtonPress) { 432 if (e->type() == QEvent::MouseButtonPress) {
435 int i; 433 int i;
436 for(i=0;i<6;++i) { 434 for(i=0;i<6;++i) {
437 if (o == weeknos[i]) { 435 if (o == weeknos[i]) {
438 QDate weekstart = daymatrix->getDate(i*7); 436 QDate weekstart = daymatrix->getDate(i*7);
439 emit weekClicked(weekstart); 437 emit weekClicked(weekstart);
440 break; 438 break;
441 } 439 }
442 } 440 }
443 for(i=0;i<7;++i) { 441 for(i=0;i<7;++i) {
444 if (o == headings[i]) { 442 if (o == headings[i]) {
445 KCal::DateList selDays; 443 KCal::DateList selDays;
446 QDate date = daymatrix->getDate(14); 444 QDate date = daymatrix->getDate(14);
447 emit showMonth(date ); 445 emit showMonth(date );
448#if 0 446#if 0
449 int dio = date.daysInMonth(); 447 int dio = date.daysInMonth();
450 int j; 448 int j;
451 int ye = date.year(); 449 int ye = date.year();
452 int mo = date.month(); 450 int mo = date.month();
453 for ( j = 1; j <= dio; ++j ) { 451 for ( j = 1; j <= dio; ++j ) {
454 selDays.append( QDate( ye, mo, j ) ); 452 selDays.append( QDate( ye, mo, j ) );
455 } 453 }
456 emit datesSelected( selDays ); 454 emit datesSelected( selDays );
457#endif 455#endif
458 break; 456 break;
459 } 457 }
460 } 458 }
461 return true; 459 return true;
462 } else { 460 } else {
463 return false; 461 return false;
464 } 462 }
465} 463}
466 464
467//#include "kdatenavigator.moc" 465//#include "kdatenavigator.moc"
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index b43c40e..b5a4199 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1647 +1,1647 @@
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 myPix.resize( 1, 1 ); 84 myPix.resize( 1, 1 );
85 mRows = rows; 85 mRows = rows;
86 86
87 mRedrawNeeded = true; 87 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 90
91 enableClipper(true); 91 enableClipper(true);
92 92
93 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
95 95
96 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
97 97
98 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
99} 99}
100 100
101void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
102{ 102{
103 mCellHeight = height; 103 mCellHeight = height;
104} 104}
105 105
106/* 106/*
107 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 109*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 111{
112 112
113 cx = contentsX() + frameWidth()*2; 113 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 114 cw = contentsWidth() ;
115 // end of workaround 115 // end of workaround
116 116
117 int cell = ((int)(cy/mCellHeight)); 117 int cell = ((int)(cy/mCellHeight));
118 int y = cell * mCellHeight; 118 int y = cell * mCellHeight;
119 QFontMetrics fm = fontMetrics(); 119 QFontMetrics fm = fontMetrics();
120 QString hour; 120 QString hour;
121 QString suffix = "am"; 121 QString suffix = "am";
122 int timeHeight = fm.ascent(); 122 int timeHeight = fm.ascent();
123 QFont nFont = font(); 123 QFont nFont = font();
124 p->setFont( font()); 124 p->setFont( font());
125 125
126 if (!KGlobal::locale()->use12Clock()) { 126 if (!KGlobal::locale()->use12Clock()) {
127 suffix = "00"; 127 suffix = "00";
128 } else 128 } else
129 if (cell > 11) suffix = "pm"; 129 if (cell > 11) suffix = "pm";
130 130
131 if ( timeHeight > mCellHeight ) { 131 if ( timeHeight > mCellHeight ) {
132 timeHeight = mCellHeight-1; 132 timeHeight = mCellHeight-1;
133 int pointS = nFont.pointSize(); 133 int pointS = nFont.pointSize();
134 while ( pointS > 4 ) { 134 while ( pointS > 4 ) {
135 nFont.setPointSize( pointS ); 135 nFont.setPointSize( pointS );
136 fm = QFontMetrics( nFont ); 136 fm = QFontMetrics( nFont );
137 if ( fm.ascent() < mCellHeight ) 137 if ( fm.ascent() < mCellHeight )
138 break; 138 break;
139 -- pointS; 139 -- pointS;
140 } 140 }
141 fm = QFontMetrics( nFont ); 141 fm = QFontMetrics( nFont );
142 timeHeight = fm.ascent(); 142 timeHeight = fm.ascent();
143 } 143 }
144 //timeHeight -= (timeHeight/4-2); 144 //timeHeight -= (timeHeight/4-2);
145 QFont sFont = nFont; 145 QFont sFont = nFont;
146 sFont.setPointSize( sFont.pointSize()/2 ); 146 sFont.setPointSize( sFont.pointSize()/2 );
147 QFontMetrics fmS( sFont ); 147 QFontMetrics fmS( sFont );
148 int sHei = fmS.ascent() ; 148 int sHei = fmS.ascent() ;
149 //sHei -= (sHei/4-2); 149 //sHei -= (sHei/4-2);
150 int startW = mMiniWidth - frameWidth()-2 ; 150 int startW = mMiniWidth - frameWidth()-2 ;
151 int tw2 = fmS.width(suffix); 151 int tw2 = fmS.width(suffix);
152 timeHeight = (timeHeight-1) /2 -1; 152 timeHeight = (timeHeight-1) /2 -1;
153 //testline 153 //testline
154 //p->drawLine(0,0,0,contentsHeight()); 154 //p->drawLine(0,0,0,contentsHeight());
155 while (y < cy + ch+mCellHeight) { 155 while (y < cy + ch+mCellHeight) {
156 p->drawLine(startW-tw2+1 ,y,cw+2,y); 156 p->drawLine(startW-tw2+1 ,y,cw+2,y);
157 hour.setNum(cell); 157 hour.setNum(cell);
158 // handle 24h and am/pm time formats 158 // handle 24h and am/pm time formats
159 if (KGlobal::locale()->use12Clock()) { 159 if (KGlobal::locale()->use12Clock()) {
160 if (cell == 12) suffix = "pm"; 160 if (cell == 12) suffix = "pm";
161 if (cell == 0) hour.setNum(12); 161 if (cell == 0) hour.setNum(12);
162 if (cell > 12) hour.setNum(cell - 12); 162 if (cell > 12) hour.setNum(cell - 12);
163 } 163 }
164 164
165 // center and draw the time label 165 // center and draw the time label
166 int timeWidth = fm.width(hour); 166 int timeWidth = fm.width(hour);
167 int offset = startW - timeWidth - tw2 -1 ; 167 int offset = startW - timeWidth - tw2 -1 ;
168 p->setFont( nFont ); 168 p->setFont( nFont );
169 p->drawText( offset, y+ timeHeight, hour); 169 p->drawText( offset, y+ timeHeight, hour);
170 p->setFont( sFont ); 170 p->setFont( sFont );
171 offset = startW - tw2; 171 offset = startW - tw2;
172 p->drawText( offset, y -1, suffix); 172 p->drawText( offset, y -1, suffix);
173 173
174 // increment indices 174 // increment indices
175 y += mCellHeight; 175 y += mCellHeight;
176 cell++; 176 cell++;
177 } 177 }
178 178
179 179
180 180
181 181
182} 182}
183 183
184/** 184/**
185 Calculates the minimum width. 185 Calculates the minimum width.
186*/ 186*/
187int TimeLabels::minimumWidth() const 187int TimeLabels::minimumWidth() const
188{ 188{
189 return mMiniWidth; 189 return mMiniWidth;
190} 190}
191 191
192/** updates widget's internal state */ 192/** updates widget's internal state */
193void TimeLabels::updateConfig() 193void TimeLabels::updateConfig()
194{ 194{
195 mRedrawNeeded = true; 195 mRedrawNeeded = true;
196 // set the font 196 // set the font
197 // config->setGroup("Fonts"); 197 // config->setGroup("Fonts");
198 // QFont font = config->readFontEntry("TimeBar Font"); 198 // QFont font = config->readFontEntry("TimeBar Font");
199 setFont(KOPrefs::instance()->mTimeBarFont); 199 setFont(KOPrefs::instance()->mTimeBarFont);
200 QString test = "20"; 200 QString test = "20";
201 if (KGlobal::locale()->use12Clock()) 201 if (KGlobal::locale()->use12Clock())
202 test = "12"; 202 test = "12";
203 mMiniWidth = fontMetrics().width(test); 203 mMiniWidth = fontMetrics().width(test);
204 if (KGlobal::locale()->use12Clock()) 204 if (KGlobal::locale()->use12Clock())
205 test = "pm"; 205 test = "pm";
206 else { 206 else {
207 test = "00"; 207 test = "00";
208 } 208 }
209 QFont sFont = font(); 209 QFont sFont = font();
210 sFont.setPointSize( sFont.pointSize()/2 ); 210 sFont.setPointSize( sFont.pointSize()/2 );
211 QFontMetrics fmS( sFont ); 211 QFontMetrics fmS( sFont );
212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; 212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ;
213 // update geometry restrictions based on new settings 213 // update geometry restrictions based on new settings
214 setFixedWidth( mMiniWidth ); 214 setFixedWidth( mMiniWidth );
215 215
216 // update HourSize 216 // update HourSize
217 mCellHeight = KOPrefs::instance()->mHourSize*4; 217 mCellHeight = KOPrefs::instance()->mHourSize*4;
218 resizeContents(mMiniWidth,mRows * mCellHeight+1); 218 resizeContents(mMiniWidth,mRows * mCellHeight+1);
219} 219}
220 220
221/** update time label positions */ 221/** update time label positions */
222void TimeLabels::positionChanged() 222void TimeLabels::positionChanged()
223{ 223{
224 int adjustment = mAgenda->contentsY(); 224 int adjustment = mAgenda->contentsY();
225 setContentsPos(0, adjustment); 225 setContentsPos(0, adjustment);
226} 226}
227 227
228/** */ 228/** */
229void TimeLabels::setAgenda(KOAgenda* agenda) 229void TimeLabels::setAgenda(KOAgenda* agenda)
230{ 230{
231 mAgenda = agenda; 231 mAgenda = agenda;
232} 232}
233 233
234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
235{ 235{
236 mMouseDownY = e->pos().y(); 236 mMouseDownY = e->pos().y();
237 mOrgCap = topLevelWidget()->caption(); 237 mOrgCap = topLevelWidget()->caption();
238} 238}
239 239
240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
241{ 241{
242 int diff = mMouseDownY - e->pos().y(); 242 int diff = mMouseDownY - e->pos().y();
243 if ( diff < 10 && diff > -10 ) 243 if ( diff < 10 && diff > -10 )
244 return; 244 return;
245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
246 if ( tSize < 4 ) 246 if ( tSize < 4 )
247 tSize = 4; 247 tSize = 4;
248 if ( tSize > 22 ) 248 if ( tSize > 22 )
249 tSize = 22; 249 tSize = 22;
250 tSize = (tSize-2)/2; 250 tSize = (tSize-2)/2;
251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
252 252
253} 253}
254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
255{ 255{
256 topLevelWidget()->setCaption( mOrgCap ); 256 topLevelWidget()->setCaption( mOrgCap );
257 int diff = mMouseDownY - e->pos().y(); 257 int diff = mMouseDownY - e->pos().y();
258 if ( diff < 10 && diff > -10 ) 258 if ( diff < 10 && diff > -10 )
259 return; 259 return;
260 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 260 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
261 if ( tSize < 4 ) 261 if ( tSize < 4 )
262 tSize = 4; 262 tSize = 4;
263 if ( tSize > 22 ) 263 if ( tSize > 22 )
264 tSize = 22; 264 tSize = 22;
265 tSize = (tSize/2)*2; 265 tSize = (tSize/2)*2;
266 if ( tSize == KOPrefs::instance()->mHourSize ) 266 if ( tSize == KOPrefs::instance()->mHourSize )
267 return; 267 return;
268 KOPrefs::instance()->mHourSize = tSize; 268 KOPrefs::instance()->mHourSize = tSize;
269 emit scaleChanged(); 269 emit scaleChanged();
270} 270}
271 271
272/** This is called in response to repaint() */ 272/** This is called in response to repaint() */
273void TimeLabels::paintEvent(QPaintEvent*) 273void TimeLabels::paintEvent(QPaintEvent*)
274{ 274{
275 275
276 // kdDebug() << "paintevent..." << endl; 276 // kdDebug() << "paintevent..." << endl;
277 // this is another hack! 277 // this is another hack!
278 // QPainter painter(this); 278 // QPainter painter(this);
279 //QString c 279 //QString c
280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
281} 281}
282 282
283//////////////////////////////////////////////////////////////////////////// 283////////////////////////////////////////////////////////////////////////////
284 284
285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
286 : QFrame(parent,name) 286 : QFrame(parent,name)
287{ 287{
288 mColumns = 1; 288 mColumns = 1;
289 mTopBox = 0; 289 mTopBox = 0;
290 mLocation = loc; 290 mLocation = loc;
291 mTopLayout = 0; 291 mTopLayout = 0;
292 mPaintWidget = 0; 292 mPaintWidget = 0;
293 mXOffset = 0; 293 mXOffset = 0;
294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
295 else mPixmap = SmallIcon("1downarrow"); 295 else mPixmap = SmallIcon("1downarrow");
296 mEnabled.resize(mColumns); 296 mEnabled.resize(mColumns);
297 mEnabled.fill( false ); 297 mEnabled.fill( false );
298 setMinimumHeight(mPixmap.height()); 298 setMinimumHeight(mPixmap.height());
299} 299}
300 300
301EventIndicator::~EventIndicator() 301EventIndicator::~EventIndicator()
302{ 302{
303} 303}
304 304
305void EventIndicator::drawContents(QPainter *p) 305void EventIndicator::drawContents(QPainter *p)
306{ 306{
307 307
308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
309 KDGanttSplitterHandle* han = 0; 309 KDGanttSplitterHandle* han = 0;
310 if ( mPaintWidget ) 310 if ( mPaintWidget )
311 han = mPaintWidget->firstHandle(); 311 han = mPaintWidget->firstHandle();
312 if ( ! han ) { 312 if ( ! han ) {
313 int i; 313 int i;
314 for(i=0;i<mColumns;++i) { 314 for(i=0;i<mColumns;++i) {
315 if (mEnabled[i]) { 315 if (mEnabled[i]) {
316 int cellWidth = contentsRect().right()/mColumns; 316 int cellWidth = contentsRect().right()/mColumns;
317 int xOffset = KOGlobals::self()->reverseLayout() ? 317 int xOffset = KOGlobals::self()->reverseLayout() ?
318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
319 i*cellWidth + (cellWidth -mPixmap.width()) /2; 319 i*cellWidth + (cellWidth -mPixmap.width()) /2;
320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
321 } 321 }
322 } 322 }
323 } else { 323 } else {
324 han->repaint(); 324 han->repaint();
325 //mPaintWidget->setBackgroundColor( red ); 325 //mPaintWidget->setBackgroundColor( red );
326 326
327 QPainter pa( han ); 327 QPainter pa( han );
328 int i; 328 int i;
329 bool setColor = false; 329 bool setColor = false;
330 for(i=0;i<mColumns;++i) { 330 for(i=0;i<mColumns;++i) {
331 if (mEnabled[i]) { 331 if (mEnabled[i]) {
332 setColor = true; 332 setColor = true;
333 333
334 int cellWidth = contentsRect().right()/mColumns; 334 int cellWidth = contentsRect().right()/mColumns;
335 int xOffset = KOGlobals::self()->reverseLayout() ? 335 int xOffset = KOGlobals::self()->reverseLayout() ?
336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
337 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 337 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
339 //qDebug("222draw pix %d ",xOffset ); 339 //qDebug("222draw pix %d ",xOffset );
340 340
341 } 341 }
342 342
343 } 343 }
344 pa.end(); 344 pa.end();
345 345
346 } 346 }
347} 347}
348 348
349void EventIndicator::setXOffset( int x ) 349void EventIndicator::setXOffset( int x )
350{ 350{
351 mXOffset = x; 351 mXOffset = x;
352} 352}
353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
354{ 354{
355 mPaintWidget = w; 355 mPaintWidget = w;
356 setMaximumHeight(0); 356 setMaximumHeight(0);
357 setMinimumHeight(0); 357 setMinimumHeight(0);
358} 358}
359void EventIndicator::changeColumns(int columns) 359void EventIndicator::changeColumns(int columns)
360{ 360{
361 mColumns = columns; 361 mColumns = columns;
362 mEnabled.resize(mColumns); 362 mEnabled.resize(mColumns);
363 363
364 update(); 364 update();
365} 365}
366 366
367void EventIndicator::enableColumn(int column, bool enable) 367void EventIndicator::enableColumn(int column, bool enable)
368{ 368{
369 mEnabled[column] = enable; 369 mEnabled[column] = enable;
370} 370}
371 371
372 372
373//////////////////////////////////////////////////////////////////////////// 373////////////////////////////////////////////////////////////////////////////
374//////////////////////////////////////////////////////////////////////////// 374////////////////////////////////////////////////////////////////////////////
375//////////////////////////////////////////////////////////////////////////// 375////////////////////////////////////////////////////////////////////////////
376 376
377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
378 KOEventView (cal,parent,name) 378 KOEventView (cal,parent,name)
379{ 379{
380 mBlockUpdating = true; 380 mBlockUpdating = true;
381 mStartHour = 8; 381 mStartHour = 8;
382 mSelectedDates.append(QDate::currentDate()); 382 mSelectedDates.append(QDate::currentDate());
383 383
384 mLayoutDayLabels = 0; 384 mLayoutDayLabels = 0;
385 mDayLabelsFrame = 0; 385 mDayLabelsFrame = 0;
386 mDayLabels = 0; 386 mDayLabels = 0;
387 bool isRTL = KOGlobals::self()->reverseLayout(); 387 bool isRTL = KOGlobals::self()->reverseLayout();
388 QPixmap expandPix; 388 QPixmap expandPix;
389 if ( KOPrefs::instance()->mVerticalScreen ) { 389 if ( KOPrefs::instance()->mVerticalScreen ) {
390 expandPix = SmallIcon( "1updownarrow" ); 390 expandPix = SmallIcon( "1updownarrow" );
391 } else { 391 } else {
392 expandPix = SmallIcon("1leftrightarrow" ); 392 expandPix = SmallIcon("1leftrightarrow" );
393 } 393 }
394 394
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 396
397 // Create day name labels for agenda columns 397 // Create day name labels for agenda columns
398 // Create agenda splitter 398 // Create agenda splitter
399 399
400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
402 topLayout->addWidget( mSplitterAgenda ); 402 topLayout->addWidget( mSplitterAgenda );
403 mAllDayFrame = new QHBox(mSplitterAgenda); 403 mAllDayFrame = new QHBox(mSplitterAgenda);
404 mAllDayFrame->setFocusPolicy(NoFocus); 404 mAllDayFrame->setFocusPolicy(NoFocus);
405 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 405 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
406 agendaFrame->setFocusPolicy(NoFocus); 406 agendaFrame->setFocusPolicy(NoFocus);
407 407
408 // Create all-day agenda widget 408 // Create all-day agenda widget
409 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 409 mDummyAllDayLeft = new QVBox( mAllDayFrame );
410 410
411 mExpandButton = new QPushButton(mDummyAllDayLeft); 411 mExpandButton = new QPushButton(mDummyAllDayLeft);
412 mExpandButton->setPixmap( expandPix ); 412 mExpandButton->setPixmap( expandPix );
413 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
438#endif 438#endif
439 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
440 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
441 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
442 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
444 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
445 445
446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
447 agendaFrame); 447 agendaFrame);
448 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
449 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
450 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
451 451
452 // Create time labels 452 // Create time labels
453 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
454 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
455 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
456 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
457 457
458 // Create agenda 458 // Create agenda
459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
461 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
462 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
463 // Create event context menu for agenda 463 // Create event context menu for agenda
464 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
465 465
466#if 0 466#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
470 470
471#endif 471#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477 mAgenda->setPopup( mAllAgendaPopup ); 477 mAgenda->setPopup( mAllAgendaPopup );
478 mAllDayAgenda->setPopup( mAllAgendaPopup ); 478 mAllDayAgenda->setPopup( mAllAgendaPopup );
479 // make connections between dependent widgets 479 // make connections between dependent widgets
480 mTimeLabels->setAgenda(mAgenda); 480 mTimeLabels->setAgenda(mAgenda);
481 481
482 // Update widgets to reflect user preferences 482 // Update widgets to reflect user preferences
483 // updateConfig(); 483 // updateConfig();
484 484
485 // createDayLabels(); 485 // createDayLabels();
486 486
487 // these blank widgets make the All Day Event box line up with the agenda 487 // these blank widgets make the All Day Event box line up with the agenda
488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
491 491
492 // Scrolling 492 // Scrolling
493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
494 mTimeLabels, SLOT(positionChanged())); 494 mTimeLabels, SLOT(positionChanged()));
495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
496 SLOT(setContentsPos(int))); 496 SLOT(setContentsPos(int)));
497 497
498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
500 500
501 // Create/Show/Edit/Delete Event 501 // Create/Show/Edit/Delete Event
502 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 502 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
503 SLOT(newEvent(int,int))); 503 SLOT(newEvent(int,int)));
504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
505 SLOT(newTodo(int,int))); 505 SLOT(newTodo(int,int)));
506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
507 SLOT(newEvent(int,int,int,int))); 507 SLOT(newEvent(int,int,int,int)));
508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
509 SLOT(newEventAllDay(int,int))); 509 SLOT(newEventAllDay(int,int)));
510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
511 SLOT(newTodoAllDay(int,int))); 511 SLOT(newTodoAllDay(int,int)));
512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
513 SLOT(newEventAllDay(int,int))); 513 SLOT(newEventAllDay(int,int)));
514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
515 SLOT(newTimeSpanSelected(int,int,int,int))); 515 SLOT(newTimeSpanSelected(int,int,int,int)));
516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
520 520
521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
522 SIGNAL(editIncidenceSignal(Incidence *))); 522 SIGNAL(editIncidenceSignal(Incidence *)));
523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
524 SIGNAL(editIncidenceSignal(Incidence *))); 524 SIGNAL(editIncidenceSignal(Incidence *)));
525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
526 SIGNAL(showIncidenceSignal(Incidence *))); 526 SIGNAL(showIncidenceSignal(Incidence *)));
527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
528 SIGNAL(showIncidenceSignal(Incidence *))); 528 SIGNAL(showIncidenceSignal(Incidence *)));
529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
530 SIGNAL(deleteIncidenceSignal(Incidence *))); 530 SIGNAL(deleteIncidenceSignal(Incidence *)));
531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
532 SIGNAL(deleteIncidenceSignal(Incidence *))); 532 SIGNAL(deleteIncidenceSignal(Incidence *)));
533 533
534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
535 SLOT(updateEventDates(KOAgendaItem *, int ))); 535 SLOT(updateEventDates(KOAgendaItem *, int )));
536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
537 SLOT(updateEventDates(KOAgendaItem *, int))); 537 SLOT(updateEventDates(KOAgendaItem *, int)));
538 538
539 // event indicator update 539 // event indicator update
540 connect(mAgenda,SIGNAL(lowerYChanged(int)), 540 connect(mAgenda,SIGNAL(lowerYChanged(int)),
541 SLOT(updateEventIndicatorTop(int))); 541 SLOT(updateEventIndicatorTop(int)));
542 connect(mAgenda,SIGNAL(upperYChanged(int)), 542 connect(mAgenda,SIGNAL(upperYChanged(int)),
543 SLOT(updateEventIndicatorBottom(int))); 543 SLOT(updateEventIndicatorBottom(int)));
544 // drag signals 544 // drag signals
545 /* 545 /*
546 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 546 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
547 SLOT(startDrag(Event *))); 547 SLOT(startDrag(Event *)));
548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
549 SLOT(startDrag(Event *))); 549 SLOT(startDrag(Event *)));
550 */ 550 */
551 // synchronize selections 551 // synchronize selections
552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
553 mAllDayAgenda, SLOT( deselectItem() ) ); 553 mAllDayAgenda, SLOT( deselectItem() ) );
554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
555 mAgenda, SLOT( deselectItem() ) ); 555 mAgenda, SLOT( deselectItem() ) );
556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
557 SIGNAL( incidenceSelected( Incidence * ) ) ); 557 SIGNAL( incidenceSelected( Incidence * ) ) );
558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
559 SIGNAL( incidenceSelected( Incidence * ) ) ); 559 SIGNAL( incidenceSelected( Incidence * ) ) );
560 connect( mAgenda, SIGNAL( resizedSignal() ), 560 connect( mAgenda, SIGNAL( resizedSignal() ),
561 SLOT( updateConfig( ) ) ); 561 SLOT( updateConfig( ) ) );
562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
565 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 565 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
568 568
569 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 569 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
570 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 570 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
571 571
572} 572}
573 573
574void KOAgendaView::toggleAllDay() 574void KOAgendaView::toggleAllDay()
575{ 575{
576 if ( mSplitterAgenda->firstHandle() ) 576 if ( mSplitterAgenda->firstHandle() )
577 mSplitterAgenda->firstHandle()->toggle(); 577 mSplitterAgenda->firstHandle()->toggle();
578} 578}
579void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 579void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
580{ 580{
581 calendar()->addIncidence( inc ); 581 calendar()->addIncidence( inc );
582 582
583 if ( incOld ) { 583 if ( incOld ) {
584 if ( incOld->type() == "Todo" ) 584 if ( incOld->type() == "Todo" )
585 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 585 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
586 else 586 else
587 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 587 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
588 } 588 }
589 589
590} 590}
591 591
592KOAgendaView::~KOAgendaView() 592KOAgendaView::~KOAgendaView()
593{ 593{
594 delete mAllAgendaPopup; 594 delete mAllAgendaPopup;
595 //delete mAllDayAgendaPopup; 595 //delete mAllDayAgendaPopup;
596 delete KOAgendaItem::paintPix(); 596 delete KOAgendaItem::paintPix();
597 delete KOAgendaItem::paintPixSel(); 597 delete KOAgendaItem::paintPixSel();
598} 598}
599void KOAgendaView::resizeEvent( QResizeEvent* e ) 599void KOAgendaView::resizeEvent( QResizeEvent* e )
600{ 600{
601 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 601 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
602 bool uc = false; 602 bool uc = false;
603 int ow = e->oldSize().width(); 603 int ow = e->oldSize().width();
604 int oh = e->oldSize().height(); 604 int oh = e->oldSize().height();
605 int w = e->size().width(); 605 int w = e->size().width();
606 int h = e->size().height(); 606 int h = e->size().height();
607 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 607 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
608 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 608 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
609 uc = true; 609 uc = true;
610 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 610 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
611 } 611 }
612 mUpcomingWidth = e->size().width() ; 612 mUpcomingWidth = e->size().width() ;
613 if ( mBlockUpdating || uc ) { 613 if ( mBlockUpdating || uc ) {
614 mBlockUpdating = false; 614 mBlockUpdating = false;
615 //mAgenda->setMinimumSize(800 , 600 ); 615 //mAgenda->setMinimumSize(800 , 600 );
616 //qDebug("mAgenda->resize+++++++++++++++ "); 616 //qDebug("mAgenda->resize+++++++++++++++ ");
617 updateConfig(); 617 updateConfig();
618 //qDebug("KOAgendaView::Updating now possible "); 618 //qDebug("KOAgendaView::Updating now possible ");
619 } else 619 } else
620 createDayLabels(); 620 createDayLabels();
621 //qDebug("resizeEvent end "); 621 //qDebug("resizeEvent end ");
622 622
623} 623}
624void KOAgendaView::slotDaylabelClicked( int num ) 624void KOAgendaView::slotDaylabelClicked( int num )
625{ 625{
626 626
627 QDate firstDate = mSelectedDates.first(); 627 QDate firstDate = mSelectedDates.first();
628 if ( num == -1 ) 628 if ( num == -1 )
629 emit showDateView( 6, firstDate ); 629 emit showDateView( 6, firstDate );
630 else if (num >= 0 ) { 630 else if (num >= 0 ) {
631 if ( mSelectedDates.count() == 1) 631 if ( mSelectedDates.count() == 1)
632 emit showDateView( 9, firstDate.addDays( num ) ); 632 emit showDateView( 9, firstDate.addDays( num ) );
633 else 633 else
634 emit showDateView( 3, firstDate.addDays( num ) ); 634 emit showDateView( 3, firstDate.addDays( num ) );
635 } 635 }
636 else 636 else
637 showDateView( 10, firstDate.addDays(1) ); 637 showDateView( 10, firstDate.addDays(1) );
638} 638}
639 639
640KOAgendaButton* KOAgendaView::getNewDaylabel() 640KOAgendaButton* KOAgendaView::getNewDaylabel()
641{ 641{
642 642
643 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 643 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
644 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 644 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
645 mDayLabelsList.append( dayLabel ); 645 mDayLabelsList.append( dayLabel );
646 mLayoutDayLabels->addWidget(dayLabel); 646 mLayoutDayLabels->addWidget(dayLabel);
647 return dayLabel ; 647 return dayLabel ;
648} 648}
649 649
650void KOAgendaView::createDayLabels() 650void KOAgendaView::createDayLabels()
651{ 651{
652 652
653 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 653 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
654 // qDebug(" KOAgendaView::createDayLabels() blocked "); 654 // qDebug(" KOAgendaView::createDayLabels() blocked ");
655 return; 655 return;
656 656
657 } 657 }
658 int newHight; 658 int newHight;
659 if ( !mSelectedDates.count()) 659 if ( !mSelectedDates.count())
660 return; 660 return;
661 661
662 // ### Before deleting and recreating we could check if mSelectedDates changed... 662 // ### Before deleting and recreating we could check if mSelectedDates changed...
663 // It would remove some flickering and gain speed (since this is called by 663 // It would remove some flickering and gain speed (since this is called by
664 // each updateView() call) 664 // each updateView() call)
665 665
666 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 666 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
667 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 667 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
668 if ( maxWid < 20 ) 668 if ( maxWid < 20 )
669 maxWid = 20; 669 maxWid = 20;
670 670
671 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 671 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
672 QFontMetrics fm ( dlf ); 672 QFontMetrics fm ( dlf );
673 int selCount = mSelectedDates.count(); 673 int selCount = mSelectedDates.count();
674 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 674 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
675 QString dayTest = "Mon 20"; 675 QString dayTest = "Mon 20";
676 //QString dayTest = "Mon 20"; 676 //QString dayTest = "Mon 20";
677 int wid = fm.width( dayTest ); 677 int wid = fm.width( dayTest );
678 //maxWid -= ( selCount * 3 ); //working for QLabels 678 //maxWid -= ( selCount * 3 ); //working for QLabels
679 if ( QApplication::desktop()->width() <= 320 ) 679 if ( QApplication::desktop()->width() <= 320 )
680 maxWid -= ( selCount * 3 ); //working for QPushButton 680 maxWid -= ( selCount * 3 ); //working for QPushButton
681 else 681 else
682 maxWid -= ( selCount * 3 ); //working for QPushButton 682 maxWid -= ( selCount * 3 ); //working for QPushButton
683 if ( maxWid < 0 ) 683 if ( maxWid < 0 )
684 maxWid = 20; 684 maxWid = 20;
685 int needWid = wid * selCount; 685 int needWid = wid * selCount;
686 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 686 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
687 //if ( needWid > maxWid ) 687 //if ( needWid > maxWid )
688 // qDebug("DAYLABELS TOOOOOOO BIG "); 688 // qDebug("DAYLABELS TOOOOOOO BIG ");
689 while ( needWid > maxWid ) { 689 while ( needWid > maxWid ) {
690 dayTest = dayTest.left( dayTest.length() - 1 ); 690 dayTest = dayTest.left( dayTest.length() - 1 );
691 wid = fm.width( dayTest ); 691 wid = fm.width( dayTest );
692 needWid = wid * selCount; 692 needWid = wid * selCount;
693 } 693 }
694 int maxLen = dayTest.length(); 694 int maxLen = dayTest.length();
695 int fontPoint = dlf.pointSize(); 695 int fontPoint = dlf.pointSize();
696 if ( maxLen < 2 ) { 696 if ( maxLen < 2 ) {
697 int fontPoint = dlf.pointSize(); 697 int fontPoint = dlf.pointSize();
698 while ( fontPoint > 4 ) { 698 while ( fontPoint > 4 ) {
699 --fontPoint; 699 --fontPoint;
700 dlf.setPointSize( fontPoint ); 700 dlf.setPointSize( fontPoint );
701 QFontMetrics f( dlf ); 701 QFontMetrics f( dlf );
702 wid = f.width( "30" ); 702 wid = f.width( "30" );
703 needWid = wid * selCount; 703 needWid = wid * selCount;
704 if ( needWid < maxWid ) 704 if ( needWid < maxWid )
705 break; 705 break;
706 } 706 }
707 maxLen = 2; 707 maxLen = 2;
708 } 708 }
709 //qDebug("Max len %d ", dayTest.length() ); 709 //qDebug("Max len %d ", dayTest.length() );
710 710
711 QFontMetrics tempF( dlf ); 711 QFontMetrics tempF( dlf );
712 newHight = tempF.height(); 712 newHight = tempF.height();
713 mDayLabels->setFont( dlf ); 713 mDayLabels->setFont( dlf );
714 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 714 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
715 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 715 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
716 //mLayoutDayLabels->addSpacing( 2 ); 716 //mLayoutDayLabels->addSpacing( 2 );
717 // QFont lFont = dlf; 717 // QFont lFont = dlf;
718 bool appendLabels = false; 718 bool appendLabels = false;
719 KOAgendaButton *dayLabel; 719 KOAgendaButton *dayLabel;
720 dayLabel = mDayLabelsList.first(); 720 dayLabel = mDayLabelsList.first();
721 if ( !dayLabel ) { 721 if ( !dayLabel ) {
722 appendLabels = true; 722 appendLabels = true;
723 dayLabel = getNewDaylabel(); 723 dayLabel = getNewDaylabel();
724 } 724 }
725 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 725 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
726 dayLabel->setFont( dlf ); 726 dayLabel->setFont( dlf );
727 dayLabel->setNum( -1 ); 727 dayLabel->setNum( -1 );
728 //dayLabel->setAlignment(QLabel::AlignHCenter); 728 //dayLabel->setAlignment(QLabel::AlignHCenter);
729 729
730 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 730 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
731 dayLabel->show(); 731 dayLabel->show();
732 DateList::ConstIterator dit; 732 DateList::ConstIterator dit;
733 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 733 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
734 int counter = -1; 734 int counter = -1;
735 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 735 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
736 ++counter; 736 ++counter;
737 QDate date = *dit; 737 QDate date = *dit;
738 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 738 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
739 if ( ! appendLabels ) { 739 if ( ! appendLabels ) {
740 dayLabel = mDayLabelsList.next(); 740 dayLabel = mDayLabelsList.next();
741 if ( !dayLabel ) 741 if ( !dayLabel )
742 appendLabels = true; 742 appendLabels = true;
743 } 743 }
744 if ( appendLabels ) { 744 if ( appendLabels ) {
745 dayLabel = getNewDaylabel(); 745 dayLabel = getNewDaylabel();
746 } 746 }
747 dayLabel->setMinimumWidth( 1 ); 747 dayLabel->setMinimumWidth( 1 );
748 dayLabel->setMaximumWidth( 10240 ); 748 dayLabel->setMaximumWidth( 10240 );
749 dayLabel->setFont( dlf ); 749 dayLabel->setFont( dlf );
750 dayLabel->show(); 750 dayLabel->show();
751 dayLabel->setAutoRepeat( false ); 751 dayLabel->setAutoRepeat( false );
752 dayLabel->setNum( counter ); 752 dayLabel->setNum( counter );
753 QString str; 753 QString str;
754 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 754 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
755 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 755 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
756 switch ( maxLen ) { 756 switch ( maxLen ) {
757 case 2: 757 case 2:
758 str = QString::number( date.day() ); 758 str = QString::number( date.day() );
759 break; 759 break;
760 760
761 case 3: 761 case 3:
762 str = dayName.left( 1 ) +QString::number( date.day()); 762 str = dayName.left( 1 ) +QString::number( date.day());
763 763
764 break; 764 break;
765 case 4: 765 case 4:
766 str = dayName.left( 1 ) + " " +QString::number( date.day()); 766 str = dayName.left( 1 ) + " " +QString::number( date.day());
767 767
768 break; 768 break;
769 case 5: 769 case 5:
770 str = dayName.left( 2 ) + " " +QString::number( date.day()); 770 str = dayName.left( 2 ) + " " +QString::number( date.day());
771 771
772 break; 772 break;
773 case 6: 773 case 6:
774 str = dayName.left( 3 ) + " " +QString::number( date.day()); 774 str = dayName.left( 3 ) + " " +QString::number( date.day());
775 break; 775 break;
776 776
777 default: 777 default:
778 break; 778 break;
779 } 779 }
780 if ( oneday ) { 780 if ( oneday ) {
781 QString addString; 781 QString addString;
782 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 782 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
783 addString = i18n("Today"); 783 addString = i18n("Today");
784 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 784 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
785 addString = i18n("Tomorrow"); 785 addString = i18n("Tomorrow");
786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
787 addString = i18n("Yesterday"); 787 addString = i18n("Yesterday");
788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
789 addString = i18n("Day before yesterday"); 789 addString = i18n("Day before yesterday");
790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
791 addString = i18n("Day after tomorrow"); 791 addString = i18n("Day after tomorrow");
792 if ( !addString.isEmpty() ) { 792 if ( !addString.isEmpty() ) {
793 str = addString+", " + str; 793 str = addString+", " + str;
794 } else { 794 } else {
795 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 795 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
796 } 796 }
797 } 797 }
798 dayLabel->setText(str); 798 dayLabel->setText(str);
799 //dayLabel->setAlignment(QLabel::AlignHCenter); 799 //dayLabel->setAlignment(QLabel::AlignHCenter);
800 if (date == QDate::currentDate()) { 800 if (date == QDate::currentDate()) {
801 QFont bFont = dlf; 801 QFont bFont = dlf;
802 bFont.setBold( true ); 802 bFont.setBold( true );
803 dayLabel->setFont(bFont); 803 dayLabel->setFont(bFont);
804 } 804 }
805 //dayLayout->addWidget(dayLabel); 805 //dayLayout->addWidget(dayLabel);
806 806
807#ifndef KORG_NOPLUGINS 807#ifndef KORG_NOPLUGINS
808 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 808 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
809 CalendarDecoration *it; 809 CalendarDecoration *it;
810 for(it = cds.first(); it; it = cds.next()) { 810 for(it = cds.first(); it; it = cds.next()) {
811 QString text = it->shortText( date ); 811 QString text = it->shortText( date );
812 if ( !text.isEmpty() ) { 812 if ( !text.isEmpty() ) {
813 QLabel *label = new QLabel(text,mDayLabels); 813 QLabel *label = new QLabel(text,mDayLabels);
814 label->setAlignment(AlignCenter); 814 label->setAlignment(AlignCenter);
815 dayLayout->addWidget(label); 815 dayLayout->addWidget(label);
816 } 816 }
817 } 817 }
818 818
819 for(it = cds.first(); it; it = cds.next()) { 819 for(it = cds.first(); it; it = cds.next()) {
820 QWidget *wid = it->smallWidget(mDayLabels,date); 820 QWidget *wid = it->smallWidget(mDayLabels,date);
821 if ( wid ) { 821 if ( wid ) {
822 // wid->setHeight(20); 822 // wid->setHeight(20);
823 dayLayout->addWidget(wid); 823 dayLayout->addWidget(wid);
824 } 824 }
825 } 825 }
826#endif 826#endif
827 } 827 }
828 if ( ! appendLabels ) { 828 if ( ! appendLabels ) {
829 dayLabel = mDayLabelsList.next(); 829 dayLabel = mDayLabelsList.next();
830 if ( !dayLabel ) 830 if ( !dayLabel )
831 appendLabels = true; 831 appendLabels = true;
832 } 832 }
833 if ( appendLabels ) { 833 if ( appendLabels ) {
834 dayLabel = getNewDaylabel(); 834 dayLabel = getNewDaylabel();
835 } 835 }
836 //dayLabel->hide();//test only 836 //dayLabel->hide();//test only
837 837
838 dayLabel->setText(">"); 838 dayLabel->setText(">");
839 dayLabel->setFont( dlf ); 839 dayLabel->setFont( dlf );
840 dayLabel->setAutoRepeat( true ); 840 dayLabel->setAutoRepeat( true );
841 dayLabel->show(); 841 dayLabel->show();
842 dayLabel->setNum( -2 ); 842 dayLabel->setNum( -2 );
843 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); 843 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
844 844
845 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 845 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
846 if ( !appendLabels ) { 846 if ( !appendLabels ) {
847 dayLabel = mDayLabelsList.next(); 847 dayLabel = mDayLabelsList.next();
848 while ( dayLabel ) { 848 while ( dayLabel ) {
849 //qDebug("!dayLabel %d",dayLabel ); 849 //qDebug("!dayLabel %d",dayLabel );
850 dayLabel->hide(); 850 dayLabel->hide();
851 dayLabel = mDayLabelsList.next(); 851 dayLabel = mDayLabelsList.next();
852 } 852 }
853 } 853 }
854 854
855 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 855 mDayLabelsFrame->setFixedHeight( newHight + 4 );
856} 856}
857 857
858int KOAgendaView::maxDatesHint() 858int KOAgendaView::maxDatesHint()
859{ 859{
860 // Not sure about the max number of events, so return 0 for now. 860 // Not sure about the max number of events, so return 0 for now.
861 return 0; 861 return 0;
862} 862}
863 863
864int KOAgendaView::currentDateCount() 864int KOAgendaView::currentDateCount()
865{ 865{
866 return mSelectedDates.count(); 866 return mSelectedDates.count();
867} 867}
868 868
869QPtrList<Incidence> KOAgendaView::selectedIncidences() 869QPtrList<Incidence> KOAgendaView::selectedIncidences()
870{ 870{
871 QPtrList<Incidence> selected; 871 QPtrList<Incidence> selected;
872 Incidence *incidence; 872 Incidence *incidence;
873 873
874 incidence = mAgenda->selectedIncidence(); 874 incidence = mAgenda->selectedIncidence();
875 if (incidence) selected.append(incidence); 875 if (incidence) selected.append(incidence);
876 876
877 incidence = mAllDayAgenda->selectedIncidence(); 877 incidence = mAllDayAgenda->selectedIncidence();
878 if (incidence) selected.append(incidence); 878 if (incidence) selected.append(incidence);
879 879
880 return selected; 880 return selected;
881} 881}
882 882
883DateList KOAgendaView::selectedDates() 883DateList KOAgendaView::selectedDates()
884{ 884{
885 DateList selected; 885 DateList selected;
886 QDate qd; 886 QDate qd;
887 887
888 qd = mAgenda->selectedIncidenceDate(); 888 qd = mAgenda->selectedIncidenceDate();
889 if (qd.isValid()) selected.append(qd); 889 if (qd.isValid()) selected.append(qd);
890 890
891 qd = mAllDayAgenda->selectedIncidenceDate(); 891 qd = mAllDayAgenda->selectedIncidenceDate();
892 if (qd.isValid()) selected.append(qd); 892 if (qd.isValid()) selected.append(qd);
893 893
894 return selected; 894 return selected;
895} 895}
896 896
897 897
898void KOAgendaView::updateView() 898void KOAgendaView::updateView()
899{ 899{
900 if ( mBlockUpdating ) 900 if ( mBlockUpdating )
901 return; 901 return;
902 // kdDebug() << "KOAgendaView::updateView()" << endl; 902 // kdDebug() << "KOAgendaView::updateView()" << endl;
903 fillAgenda(); 903 fillAgenda();
904 904
905} 905}
906 906
907 907
908/* 908/*
909 Update configuration settings for the agenda view. This method is not 909 Update configuration settings for the agenda view. This method is not
910 complete. 910 complete.
911*/ 911*/
912void KOAgendaView::updateConfig() 912void KOAgendaView::updateConfig()
913{ 913{
914 if ( mBlockUpdating ) 914 if ( mBlockUpdating )
915 return; 915 return;
916 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 916 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
917 int old = KOPrefs::instance()->mHourSize; 917 int old = KOPrefs::instance()->mHourSize;
918 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 918 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
919 qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 919 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
920 } 920 }
921 921
922 922
923 // update config for children 923 // update config for children
924 mTimeLabels->updateConfig(); 924 mTimeLabels->updateConfig();
925 mAgenda->storePosition(); 925 mAgenda->storePosition();
926 mAgenda->updateConfig(); 926 mAgenda->updateConfig();
927 mAllDayAgenda->updateConfig(); 927 mAllDayAgenda->updateConfig();
928 // widget synchronization 928 // widget synchronization
929 //TODO: find a better way, maybe signal/slot 929 //TODO: find a better way, maybe signal/slot
930 mTimeLabels->positionChanged(); 930 mTimeLabels->positionChanged();
931 931
932 // for some reason, this needs to be called explicitly 932 // for some reason, this needs to be called explicitly
933 mTimeLabels->repaint(); 933 mTimeLabels->repaint();
934 934
935 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 935 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
936 936
937 // ToolTips displaying summary of events 937 // ToolTips displaying summary of events
938 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 938 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
939 ->mEnableToolTips); 939 ->mEnableToolTips);
940 940
941 //setHolidayMasks(); 941 //setHolidayMasks();
942 942
943 //createDayLabels(); called by via updateView(); 943 //createDayLabels(); called by via updateView();
944 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 944 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
945 updateView(); 945 updateView();
946 mAgenda->restorePosition(); 946 mAgenda->restorePosition();
947} 947}
948 948
949 949
950void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 950void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
951{ 951{
952 952
953 953
954 int xxx = item->cellX(); 954 int xxx = item->cellX();
955 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); 955 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() );
956 if ( mMinY.at(xxx) > item->cellYTop() ) 956 if ( mMinY.at(xxx) > item->cellYTop() )
957 mMinY.at(xxx) = item->cellYTop(); 957 mMinY.at(xxx) = item->cellYTop();
958 if ( mMaxY.at(xxx) < item->cellYBottom() ) 958 if ( mMaxY.at(xxx) < item->cellYBottom() )
959 mMaxY.at(xxx) = item->cellYBottom(); 959 mMaxY.at(xxx) = item->cellYBottom();
960 960
961 QDateTime startDt,endDt; 961 QDateTime startDt,endDt;
962 QDate startDate; 962 QDate startDate;
963 int lenInSecs; 963 int lenInSecs;
964 // if ( type == KOAgenda::RESIZETOP ) 964 // if ( type == KOAgenda::RESIZETOP )
965 // qDebug("RESIZETOP "); 965 // qDebug("RESIZETOP ");
966 // if ( type == KOAgenda::RESIZEBOTTOM ) 966 // if ( type == KOAgenda::RESIZEBOTTOM )
967 // qDebug("RESIZEBOTTOM "); 967 // qDebug("RESIZEBOTTOM ");
968 // if ( type == KOAgenda::MOVE ) 968 // if ( type == KOAgenda::MOVE )
969 // qDebug("MOVE "); 969 // qDebug("MOVE ");
970 if ( item->incidence()->type() == "Event" ) { 970 if ( item->incidence()->type() == "Event" ) {
971 startDt =item->incidence()->dtStart(); 971 startDt =item->incidence()->dtStart();
972 endDt = item->incidence()->dtEnd(); 972 endDt = item->incidence()->dtEnd();
973 lenInSecs = startDt.secsTo( endDt ); 973 lenInSecs = startDt.secsTo( endDt );
974 } 974 }
975 975
976 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 976 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
977 977
978 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 978 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
979 startDate = mSelectedDates[item->mLastMoveXPos]; 979 startDate = mSelectedDates[item->mLastMoveXPos];
980 } else { 980 } else {
981 if (item->cellX() < 0) { 981 if (item->cellX() < 0) {
982 startDate = (mSelectedDates.first()).addDays(item->cellX()); 982 startDate = (mSelectedDates.first()).addDays(item->cellX());
983 } else { 983 } else {
984 startDate = mSelectedDates[item->cellX()]; 984 startDate = mSelectedDates[item->cellX()];
985 } 985 }
986 } 986 }
987 startDt.setDate(startDate); 987 startDt.setDate(startDate);
988 988
989 if (item->incidence()->doesFloat()) { 989 if (item->incidence()->doesFloat()) {
990 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 990 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
991 } else { 991 } else {
992 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 992 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
993 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 993 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
994 if ( item->incidence()->type() == "Event" ) { 994 if ( item->incidence()->type() == "Event" ) {
995 if ( type == KOAgenda::MOVE ) { 995 if ( type == KOAgenda::MOVE ) {
996 endDt = startDt.addSecs(lenInSecs); 996 endDt = startDt.addSecs(lenInSecs);
997 997
998 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 998 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
999 if (item->lastMultiItem()) { 999 if (item->lastMultiItem()) {
1000 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1000 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1001 endDt.setDate(startDate. 1001 endDt.setDate(startDate.
1002 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1002 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1003 } else { 1003 } else {
1004 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1004 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1005 endDt.setDate(startDate); 1005 endDt.setDate(startDate);
1006 } 1006 }
1007 } 1007 }
1008 } else { 1008 } else {
1009 // todo 1009 // todo
1010 if (item->lastMultiItem()) { 1010 if (item->lastMultiItem()) {
1011 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1011 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1012 endDt.setDate(startDate. 1012 endDt.setDate(startDate.
1013 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1013 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1014 } else { 1014 } else {
1015 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 1015 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
1016 if ( item->cellYBottom() > 0 ) 1016 if ( item->cellYBottom() > 0 )
1017 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1017 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1018 else 1018 else
1019 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 1019 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1020 endDt.setDate(startDate); 1020 endDt.setDate(startDate);
1021 } 1021 }
1022 } 1022 }
1023 } 1023 }
1024 if ( item->incidence()->type() == "Event" ) { 1024 if ( item->incidence()->type() == "Event" ) {
1025 item->incidence()->setDtStart(startDt); 1025 item->incidence()->setDtStart(startDt);
1026 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1026 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1027 } else if ( item->incidence()->type() == "Todo" ) { 1027 } else if ( item->incidence()->type() == "Todo" ) {
1028 Todo* to = static_cast<Todo*>(item->incidence()); 1028 Todo* to = static_cast<Todo*>(item->incidence());
1029 1029
1030 to->setDtDue(endDt); 1030 to->setDtDue(endDt);
1031 if ( to->hasStartDate() ) { 1031 if ( to->hasStartDate() ) {
1032 if (to->dtStart() >= to->dtDue() ) 1032 if (to->dtStart() >= to->dtDue() )
1033 to->setDtStart(to->dtDue().addDays( -2 )); 1033 to->setDtStart(to->dtDue().addDays( -2 ));
1034 } 1034 }
1035 1035
1036 } 1036 }
1037 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1037 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1038 item->incidence()->setRevision(item->incidence()->revision()+1); 1038 item->incidence()->setRevision(item->incidence()->revision()+1);
1039 item->setItemDate(startDt.date()); 1039 item->setItemDate(startDt.date());
1040 //item->updateItem(); 1040 //item->updateItem();
1041 if ( item->incidence()->type() == "Todo" ) { 1041 if ( item->incidence()->type() == "Todo" ) {
1042 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1042 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1043 1043
1044 } 1044 }
1045 else 1045 else
1046 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1046 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1047 item->updateItem(); 1047 item->updateItem();
1048} 1048}
1049 1049
1050void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1050void KOAgendaView::showDates( const QDate &start, const QDate &end )
1051{ 1051{
1052 // kdDebug() << "KOAgendaView::selectDates" << endl; 1052 // kdDebug() << "KOAgendaView::selectDates" << endl;
1053 1053
1054 mSelectedDates.clear(); 1054 mSelectedDates.clear();
1055 // qDebug("KOAgendaView::showDates "); 1055 // qDebug("KOAgendaView::showDates ");
1056 QDate d = start; 1056 QDate d = start;
1057 while (d <= end) { 1057 while (d <= end) {
1058 mSelectedDates.append(d); 1058 mSelectedDates.append(d);
1059 d = d.addDays( 1 ); 1059 d = d.addDays( 1 );
1060 } 1060 }
1061 1061
1062 // and update the view 1062 // and update the view
1063 fillAgenda(); 1063 fillAgenda();
1064} 1064}
1065 1065
1066 1066
1067void KOAgendaView::showEvents(QPtrList<Event>) 1067void KOAgendaView::showEvents(QPtrList<Event>)
1068{ 1068{
1069 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1069 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1070} 1070}
1071 1071
1072void KOAgendaView::changeEventDisplay(Event *, int) 1072void KOAgendaView::changeEventDisplay(Event *, int)
1073{ 1073{
1074 // qDebug("KOAgendaView::changeEventDisplay "); 1074 // qDebug("KOAgendaView::changeEventDisplay ");
1075 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1075 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1076 // this should be re-written to be MUCH smarter. Right now we 1076 // this should be re-written to be MUCH smarter. Right now we
1077 // are just playing dumb. 1077 // are just playing dumb.
1078 fillAgenda(); 1078 fillAgenda();
1079} 1079}
1080 1080
1081void KOAgendaView::fillAgenda(const QDate &) 1081void KOAgendaView::fillAgenda(const QDate &)
1082{ 1082{
1083 // qDebug("KOAgendaView::fillAgenda "); 1083 // qDebug("KOAgendaView::fillAgenda ");
1084 fillAgenda(); 1084 fillAgenda();
1085} 1085}
1086 1086
1087void KOAgendaView::fillAgenda() 1087void KOAgendaView::fillAgenda()
1088{ 1088{
1089 if ( globalFlagBlockStartup ) 1089 if ( globalFlagBlockStartup )
1090 return; 1090 return;
1091 if ( globalFlagBlockAgenda == 1 ) 1091 if ( globalFlagBlockAgenda == 1 )
1092 return; 1092 return;
1093 static bool onlyOne = false; 1093 static bool onlyOne = false;
1094 if ( onlyOne ) 1094 if ( onlyOne )
1095 return; 1095 return;
1096 onlyOne = true; 1096 onlyOne = true;
1097 //if ( globalFlagBlockAgenda == 2 ) 1097 //if ( globalFlagBlockAgenda == 2 )
1098 //globalFlagBlockAgenda = 0; 1098 //globalFlagBlockAgenda = 0;
1099 // globalFlagBlockPainting = false; 1099 // globalFlagBlockPainting = false;
1100 if ( globalFlagBlockAgenda == 0 ) 1100 if ( globalFlagBlockAgenda == 0 )
1101 globalFlagBlockAgenda = 1; 1101 globalFlagBlockAgenda = 1;
1102 // clearView(); 1102 // clearView();
1103 //qDebug("fillAgenda()++++ "); 1103 //qDebug("fillAgenda()++++ ");
1104 globalFlagBlockAgendaItemPaint = 1; 1104 globalFlagBlockAgendaItemPaint = 1;
1105 1105
1106 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1106 mAllDayAgenda->changeColumns(mSelectedDates.count());
1107 mAgenda->changeColumns(mSelectedDates.count()); 1107 mAgenda->changeColumns(mSelectedDates.count());
1108 qApp->processEvents(); 1108 qApp->processEvents();
1109 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1109 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1110 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1110 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1111 setHolidayMasks(); 1111 setHolidayMasks();
1112 1112
1113 //mAgenda->hideUnused(); 1113 //mAgenda->hideUnused();
1114 //mAllDayAgenda->hideUnused(); 1114 //mAllDayAgenda->hideUnused();
1115 1115
1116 // mAgenda->blockNextRepaint( false ); 1116 // mAgenda->blockNextRepaint( false );
1117 // mAgenda->viewport()->repaint(); 1117 // mAgenda->viewport()->repaint();
1118 // mAgenda->blockNextRepaint( true ); 1118 // mAgenda->blockNextRepaint( true );
1119 mMinY.resize(mSelectedDates.count()); 1119 mMinY.resize(mSelectedDates.count());
1120 mMaxY.resize(mSelectedDates.count()); 1120 mMaxY.resize(mSelectedDates.count());
1121 1121
1122 QPtrList<Event> dayEvents; 1122 QPtrList<Event> dayEvents;
1123 1123
1124 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1124 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1125 // Therefore, gtodoset all of them. 1125 // Therefore, gtodoset all of them.
1126 QPtrList<Todo> todos = calendar()->todos(); 1126 QPtrList<Todo> todos = calendar()->todos();
1127 1127
1128 mAgenda->setDateList(mSelectedDates); 1128 mAgenda->setDateList(mSelectedDates);
1129 1129
1130 QDate today = QDate::currentDate(); 1130 QDate today = QDate::currentDate();
1131 1131
1132 DateList::ConstIterator dit; 1132 DateList::ConstIterator dit;
1133 int curCol = 0; 1133 int curCol = 0;
1134 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1134 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1135 QDate currentDate = *dit; 1135 QDate currentDate = *dit;
1136 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1136 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1137 // << endl; 1137 // << endl;
1138 1138
1139 dayEvents = calendar()->events(currentDate,true); 1139 dayEvents = calendar()->events(currentDate,true);
1140 1140
1141 // Default values, which can never be reached 1141 // Default values, which can never be reached
1142 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1142 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1143 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1143 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1144 1144
1145 unsigned int numEvent; 1145 unsigned int numEvent;
1146 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1146 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1147 Event *event = dayEvents.at(numEvent); 1147 Event *event = dayEvents.at(numEvent);
1148 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1148 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1149 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1149 if ( event->uid().left(15) == QString("last-syncEvent-") )
1150 continue; 1150 continue;
1151 // kdDebug() << " Event: " << event->summary() << endl; 1151 // kdDebug() << " Event: " << event->summary() << endl;
1152 1152
1153 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1153 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1154 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1154 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1155 1155
1156 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1156 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1157 1157
1158 if (event->doesFloat()) { 1158 if (event->doesFloat()) {
1159 if (event->recurrence()->doesRecur()) { 1159 if (event->recurrence()->doesRecur()) {
1160 if (event->isMultiDay() ) { 1160 if (event->isMultiDay() ) {
1161 endX = endX - beginX;// endX is now number of days 1161 endX = endX - beginX;// endX is now number of days
1162 if ( event->recursOn( currentDate ) ) { 1162 if ( event->recursOn( currentDate ) ) {
1163 endX += curCol; 1163 endX += curCol;
1164 beginX = curCol; 1164 beginX = curCol;
1165 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1165 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1166 } else { 1166 } else {
1167 qDebug("days %d %s",endX , currentDate.toString().latin1()); 1167 //qDebug("days %d %s",endX , currentDate.toString().latin1());
1168 QDate dateit = currentDate.addDays( -endX ); 1168 QDate dateit = currentDate.addDays( -endX );
1169 if ( event->recursOn( dateit ) ) { 1169 if ( event->recursOn( dateit ) ) {
1170 qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); 1170 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1171 if ( curCol-endX < 0 ) { 1171 if ( curCol-endX < 0 ) {
1172 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1172 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1173 } 1173 }
1174 } 1174 }
1175 } 1175 }
1176 } else { 1176 } else {
1177 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1177 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1178 } 1178 }
1179 1179
1180 } else { 1180 } else {
1181 if (beginX <= 0 && curCol == 0) { 1181 if (beginX <= 0 && curCol == 0) {
1182 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1182 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1183 } else if (beginX == curCol) { 1183 } else if (beginX == curCol) {
1184 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1184 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1185 } 1185 }
1186 } 1186 }
1187 } else if (event->isMultiDay()) { 1187 } else if (event->isMultiDay()) {
1188 if ( event->doesRecur () ) { 1188 if ( event->doesRecur () ) {
1189 QDate dateit = currentDate; 1189 QDate dateit = currentDate;
1190 int count = 0; 1190 int count = 0;
1191 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1191 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1192 while (! event->recursOn( dateit ) && count <= max ) { 1192 while (! event->recursOn( dateit ) && count <= max ) {
1193 ++count; 1193 ++count;
1194 dateit = dateit.addDays( -1 ); 1194 dateit = dateit.addDays( -1 );
1195 } 1195 }
1196 bool ok; 1196 bool ok;
1197 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1197 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1198 if ( ok ) 1198 if ( ok )
1199 { 1199 {
1200 int secs = event->dtStart().secsTo( event->dtEnd() ); 1200 int secs = event->dtStart().secsTo( event->dtEnd() );
1201 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1201 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1202 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1202 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1203 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1203 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1204 1204
1205 } 1205 }
1206 } 1206 }
1207 int startY = mAgenda->timeToY(event->dtStart().time()); 1207 int startY = mAgenda->timeToY(event->dtStart().time());
1208 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1208 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1209 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1209 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1210 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1210 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1211 //qDebug("insert!!! "); 1211 //qDebug("insert!!! ");
1212 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1212 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1213 } 1213 }
1214 if (beginX == curCol) { 1214 if (beginX == curCol) {
1215 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1215 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1216 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1216 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1217 } else if (endX == curCol) { 1217 } else if (endX == curCol) {
1218 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1218 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1219 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1219 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1220 } else { 1220 } else {
1221 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1221 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1222 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1222 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1223 } 1223 }
1224 } else { 1224 } else {
1225 int startY = mAgenda->timeToY(event->dtStart().time()); 1225 int startY = mAgenda->timeToY(event->dtStart().time());
1226 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1226 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1227 if (endY < startY) endY = startY; 1227 if (endY < startY) endY = startY;
1228 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1228 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1229 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1229 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1230 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1230 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1231 } 1231 }
1232 } 1232 }
1233 // ---------- [display Todos -------------- 1233 // ---------- [display Todos --------------
1234 unsigned int numTodo; 1234 unsigned int numTodo;
1235 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1235 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1236 Todo *todo = todos.at(numTodo); 1236 Todo *todo = todos.at(numTodo);
1237 1237
1238 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1238 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1239 1239
1240 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1240 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1241 // Already completed items can be displayed on their original due date 1241 // Already completed items can be displayed on their original due date
1242 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1242 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1243 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1243 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1244 bool fillIn = false; 1244 bool fillIn = false;
1245 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1245 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1246 fillIn = true; 1246 fillIn = true;
1247 if ( ! fillIn && !todo->hasCompletedDate() ) 1247 if ( ! fillIn && !todo->hasCompletedDate() )
1248 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1248 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1249 if ( fillIn ) { 1249 if ( fillIn ) {
1250 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1250 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1251 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1251 if ( KOPrefs::instance()->mShowTodoInAgenda )
1252 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1252 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1253 } 1253 }
1254 else { 1254 else {
1255 QDateTime dt; 1255 QDateTime dt;
1256 if ( todo->hasCompletedDate() ) 1256 if ( todo->hasCompletedDate() )
1257 dt = todo->completed(); 1257 dt = todo->completed();
1258 else 1258 else
1259 dt = todo->dtDue();; 1259 dt = todo->dtDue();;
1260 1260
1261 1261
1262 int endY = mAgenda->timeToY(dt.time()) - 1; 1262 int endY = mAgenda->timeToY(dt.time()) - 1;
1263 int hi = (18/KOPrefs::instance()->mHourSize); 1263 int hi = (18/KOPrefs::instance()->mHourSize);
1264 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1264 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1265 int startY = endY -hi; 1265 int startY = endY -hi;
1266 1266
1267 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1267 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1268 1268
1269 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1269 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1270 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1270 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1271 } 1271 }
1272 } 1272 }
1273 } 1273 }
1274 // ---------- display Todos] -------------- 1274 // ---------- display Todos] --------------
1275 1275
1276 ++curCol; 1276 ++curCol;
1277 } 1277 }
1278 mAgenda->hideUnused(); 1278 mAgenda->hideUnused();
1279 mAllDayAgenda->hideUnused(); 1279 mAllDayAgenda->hideUnused();
1280 mAgenda->checkScrollBoundaries(); 1280 mAgenda->checkScrollBoundaries();
1281 1281
1282 deleteSelectedDateTime(); 1282 deleteSelectedDateTime();
1283 1283
1284 createDayLabels(); 1284 createDayLabels();
1285 emit incidenceSelected( 0 ); 1285 emit incidenceSelected( 0 );
1286 1286
1287 if ( globalFlagBlockAgenda == 2 ) { 1287 if ( globalFlagBlockAgenda == 2 ) {
1288 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1288 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1289 setStartHour( KOPrefs::instance()->mDayBegins ); 1289 setStartHour( KOPrefs::instance()->mDayBegins );
1290 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1290 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1291 setStartHour( QTime::currentTime ().hour() ); 1291 setStartHour( QTime::currentTime ().hour() );
1292 // qApp->processEvents(); 1292 // qApp->processEvents();
1293 } 1293 }
1294 qApp->processEvents(); 1294 qApp->processEvents();
1295 //qDebug("qApp->processEvents(); END "); 1295 //qDebug("qApp->processEvents(); END ");
1296 globalFlagBlockAgenda = 0; 1296 globalFlagBlockAgenda = 0;
1297 1297
1298 // mAgenda->hideUnused(); 1298 // mAgenda->hideUnused();
1299 //mAllDayAgenda->hideUnused(); 1299 //mAllDayAgenda->hideUnused();
1300 mAllDayAgenda->drawContentsToPainter(); 1300 mAllDayAgenda->drawContentsToPainter();
1301 mAgenda->drawContentsToPainter(); 1301 mAgenda->drawContentsToPainter();
1302 repaintAgenda(); 1302 repaintAgenda();
1303 onlyOne = false; 1303 onlyOne = false;
1304 // mAgenda->finishUpdate(); 1304 // mAgenda->finishUpdate();
1305 //mAllDayAgenda->finishUpdate(); 1305 //mAllDayAgenda->finishUpdate();
1306 1306
1307 // repaintAgenda(); 1307 // repaintAgenda();
1308 //qApp->processEvents(); 1308 //qApp->processEvents();
1309 // globalFlagBlockAgenda = 0; 1309 // globalFlagBlockAgenda = 0;
1310} 1310}
1311void KOAgendaView::repaintAgenda() 1311void KOAgendaView::repaintAgenda()
1312{ 1312{
1313 // mAllDayAgenda->drawContentsToPainter(); 1313 // mAllDayAgenda->drawContentsToPainter();
1314// mAllDayAgenda->viewport()->repaint( false ); 1314// mAllDayAgenda->viewport()->repaint( false );
1315// mAgenda->drawContentsToPainter(); 1315// mAgenda->drawContentsToPainter();
1316// mAgenda->viewport()->repaint( false ); 1316// mAgenda->viewport()->repaint( false );
1317// qApp->processEvents(); 1317// qApp->processEvents();
1318 1318
1319 //qDebug("KOAgendaView::repaintAgenda() "); 1319 //qDebug("KOAgendaView::repaintAgenda() ");
1320 //qApp->processEvents(); 1320 //qApp->processEvents();
1321 mAgenda->viewport()->repaint( false ); 1321 mAgenda->viewport()->repaint( false );
1322 mAllDayAgenda->viewport()->repaint( false ); 1322 mAllDayAgenda->viewport()->repaint( false );
1323 mAgenda->finishUpdate(); 1323 mAgenda->finishUpdate();
1324 mAllDayAgenda->finishUpdate(); 1324 mAllDayAgenda->finishUpdate();
1325} 1325}
1326 1326
1327 1327
1328void KOAgendaView::clearView() 1328void KOAgendaView::clearView()
1329{ 1329{
1330 // kdDebug() << "ClearView" << endl; 1330 // kdDebug() << "ClearView" << endl;
1331 mAllDayAgenda->clear(); 1331 mAllDayAgenda->clear();
1332 mAgenda->clear(); 1332 mAgenda->clear();
1333} 1333}
1334 1334
1335void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1335void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1336 const QDate &td) 1336 const QDate &td)
1337{ 1337{
1338#ifndef KORG_NOPRINTER 1338#ifndef KORG_NOPRINTER
1339 if (fd == td) 1339 if (fd == td)
1340 calPrinter->preview(CalPrinter::Day, fd, td); 1340 calPrinter->preview(CalPrinter::Day, fd, td);
1341 else 1341 else
1342 calPrinter->preview(CalPrinter::Week, fd, td); 1342 calPrinter->preview(CalPrinter::Week, fd, td);
1343#endif 1343#endif
1344} 1344}
1345 1345
1346// void KOAgendaView::updateMovedTodo() 1346// void KOAgendaView::updateMovedTodo()
1347// { 1347// {
1348// // updateConfig(); 1348// // updateConfig();
1349// // emit updateTodoViews(); 1349// // emit updateTodoViews();
1350// } 1350// }
1351 1351
1352void KOAgendaView::slotShowDateView( int mode , int d ) 1352void KOAgendaView::slotShowDateView( int mode , int d )
1353{ 1353{
1354 if ( d >= mSelectedDates.count() ) { 1354 if ( d >= mSelectedDates.count() ) {
1355 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); 1355 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() );
1356 1356
1357 } else { 1357 } else {
1358 QDate day = mSelectedDates[d]; 1358 QDate day = mSelectedDates[d];
1359 emit showDateView(mode , day ); 1359 emit showDateView(mode , day );
1360 } 1360 }
1361 1361
1362} 1362}
1363void KOAgendaView::newEvent(int gx, int gy) 1363void KOAgendaView::newEvent(int gx, int gy)
1364{ 1364{
1365 if (!mSelectedDates.count()) return; 1365 if (!mSelectedDates.count()) return;
1366 1366
1367 QDate day = mSelectedDates[gx]; 1367 QDate day = mSelectedDates[gx];
1368 1368
1369 QTime time = mAgenda->gyToTime(gy); 1369 QTime time = mAgenda->gyToTime(gy);
1370 QDateTime dt(day,time); 1370 QDateTime dt(day,time);
1371 // if ( dt < QDateTime::currentDateTime () ) 1371 // if ( dt < QDateTime::currentDateTime () )
1372 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1372 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1373 emit newEventSignal(dt); 1373 emit newEventSignal(dt);
1374} 1374}
1375 1375
1376void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1376void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1377{ 1377{
1378 if (!mSelectedDates.count()) return; 1378 if (!mSelectedDates.count()) return;
1379 1379
1380 QDate dayStart = mSelectedDates[gxStart]; 1380 QDate dayStart = mSelectedDates[gxStart];
1381 QDate dayEnd = mSelectedDates[gxEnd]; 1381 QDate dayEnd = mSelectedDates[gxEnd];
1382 1382
1383 QTime timeStart = mAgenda->gyToTime(gyStart); 1383 QTime timeStart = mAgenda->gyToTime(gyStart);
1384 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1384 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1385 1385
1386 QDateTime dtStart(dayStart,timeStart); 1386 QDateTime dtStart(dayStart,timeStart);
1387 QDateTime dtEnd(dayEnd,timeEnd); 1387 QDateTime dtEnd(dayEnd,timeEnd);
1388 1388
1389 emit newEventSignal(dtStart,dtEnd); 1389 emit newEventSignal(dtStart,dtEnd);
1390} 1390}
1391 1391
1392void KOAgendaView::newEventAllDay(int gx, int ) 1392void KOAgendaView::newEventAllDay(int gx, int )
1393{ 1393{
1394 if (!mSelectedDates.count()) return; 1394 if (!mSelectedDates.count()) return;
1395 1395
1396 QDate day = mSelectedDates[gx]; 1396 QDate day = mSelectedDates[gx];
1397 1397
1398 emit newEventSignal(day); 1398 emit newEventSignal(day);
1399} 1399}
1400void KOAgendaView::newTodoAllDay(int gx, int ) 1400void KOAgendaView::newTodoAllDay(int gx, int )
1401{ 1401{
1402 if (!mSelectedDates.count()) return; 1402 if (!mSelectedDates.count()) return;
1403 1403
1404 QDateTime day (mSelectedDates[gx] ); 1404 QDateTime day (mSelectedDates[gx] );
1405 emit newTodoSignal(day, true); 1405 emit newTodoSignal(day, true);
1406} 1406}
1407void KOAgendaView::newTodo(int gx, int gy ) 1407void KOAgendaView::newTodo(int gx, int gy )
1408{ 1408{
1409 if (!mSelectedDates.count()) return; 1409 if (!mSelectedDates.count()) return;
1410 QDate dayStart = mSelectedDates[gx]; 1410 QDate dayStart = mSelectedDates[gx];
1411 QTime timeStart = mAgenda->gyToTime(gy); 1411 QTime timeStart = mAgenda->gyToTime(gy);
1412 QDateTime dt (dayStart,timeStart); 1412 QDateTime dt (dayStart,timeStart);
1413 emit newTodoSignal( dt, false ); 1413 emit newTodoSignal( dt, false );
1414} 1414}
1415 1415
1416void KOAgendaView::updateEventIndicatorTop(int newY) 1416void KOAgendaView::updateEventIndicatorTop(int newY)
1417{ 1417{
1418 uint i; 1418 uint i;
1419 for(i=0;i<mMinY.size();++i) { 1419 for(i=0;i<mMinY.size();++i) {
1420 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1420 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1421 else mEventIndicatorTop->enableColumn(i,false); 1421 else mEventIndicatorTop->enableColumn(i,false);
1422 } 1422 }
1423 1423
1424 mEventIndicatorTop->update(); 1424 mEventIndicatorTop->update();
1425} 1425}
1426 1426
1427void KOAgendaView::updateEventIndicatorBottom(int newY) 1427void KOAgendaView::updateEventIndicatorBottom(int newY)
1428{ 1428{
1429 uint i; 1429 uint i;
1430 for(i=0;i<mMaxY.size();++i) { 1430 for(i=0;i<mMaxY.size();++i) {
1431 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1431 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1432 else mEventIndicatorBottom->enableColumn(i,false); 1432 else mEventIndicatorBottom->enableColumn(i,false);
1433 } 1433 }
1434 1434
1435 mEventIndicatorBottom->update(); 1435 mEventIndicatorBottom->update();
1436} 1436}
1437 1437
1438void KOAgendaView::startDrag(Event *event) 1438void KOAgendaView::startDrag(Event *event)
1439{ 1439{
1440#ifndef KORG_NODND 1440#ifndef KORG_NODND
1441 DndFactory factory( calendar() ); 1441 DndFactory factory( calendar() );
1442 ICalDrag *vd = factory.createDrag(event,this); 1442 ICalDrag *vd = factory.createDrag(event,this);
1443 if (vd->drag()) { 1443 if (vd->drag()) {
1444 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1444 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1445 } 1445 }
1446#endif 1446#endif
1447} 1447}
1448 1448
1449void KOAgendaView::readSettings() 1449void KOAgendaView::readSettings()
1450{ 1450{
1451 readSettings(KOGlobals::config()); 1451 readSettings(KOGlobals::config());
1452} 1452}
1453 1453
1454void KOAgendaView::readSettings(KConfig *config) 1454void KOAgendaView::readSettings(KConfig *config)
1455{ 1455{
1456 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1456 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1457 1457
1458 config->setGroup("Views"); 1458 config->setGroup("Views");
1459 1459
1460 //#ifndef KORG_NOSPLITTER 1460 //#ifndef KORG_NOSPLITTER
1461 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1461 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1462 if (sizes.count() == 2) { 1462 if (sizes.count() == 2) {
1463 if ( sizes[0] < 20 ) { 1463 if ( sizes[0] < 20 ) {
1464 sizes[1] = sizes[1] +20 - sizes[0]; 1464 sizes[1] = sizes[1] +20 - sizes[0];
1465 sizes[0] = 20; 1465 sizes[0] = 20;
1466 } 1466 }
1467 mSplitterAgenda->setSizes(sizes); 1467 mSplitterAgenda->setSizes(sizes);
1468 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1468 // qDebug("read %d %d ",sizes[0],sizes[1] );
1469 } 1469 }
1470 //#endif 1470 //#endif
1471 1471
1472 // updateConfig(); 1472 // updateConfig();
1473} 1473}
1474 1474
1475void KOAgendaView::writeSettings(KConfig *config) 1475void KOAgendaView::writeSettings(KConfig *config)
1476{ 1476{
1477 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1477 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1478 1478
1479 config->setGroup("Views"); 1479 config->setGroup("Views");
1480 1480
1481 //#ifndef KORG_NOSPLITTER 1481 //#ifndef KORG_NOSPLITTER
1482 QValueList<int> list = mSplitterAgenda->sizes(); 1482 QValueList<int> list = mSplitterAgenda->sizes();
1483 config->writeEntry("Separator AgendaView",list); 1483 config->writeEntry("Separator AgendaView",list);
1484 //qDebug("write %d %d ", list[0],list[1] ); 1484 //qDebug("write %d %d ", list[0],list[1] );
1485 //#endif 1485 //#endif
1486} 1486}
1487 1487
1488void KOAgendaView::setHolidayMasks() 1488void KOAgendaView::setHolidayMasks()
1489{ 1489{
1490 mHolidayMask.resize(mSelectedDates.count()); 1490 mHolidayMask.resize(mSelectedDates.count());
1491 1491
1492 uint i; 1492 uint i;
1493 for(i=0;i<mSelectedDates.count();++i) { 1493 for(i=0;i<mSelectedDates.count();++i) {
1494 QDate date = mSelectedDates[i]; 1494 QDate date = mSelectedDates[i];
1495 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1495 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1496 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1496 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1497 bool showHoliday = false; 1497 bool showHoliday = false;
1498 if ( KOPrefs::instance()->mExcludeHolidays ) { 1498 if ( KOPrefs::instance()->mExcludeHolidays ) {
1499 QPtrList<Event> events = calendar()->events( date, true ); 1499 QPtrList<Event> events = calendar()->events( date, true );
1500 Event *event; 1500 Event *event;
1501 for( event = events.first(); event; event = events.next() ) { 1501 for( event = events.first(); event; event = events.next() ) {
1502 if ( event->isHoliday()) { 1502 if ( event->isHoliday()) {
1503 showHoliday = true; 1503 showHoliday = true;
1504 break; 1504 break;
1505 } 1505 }
1506 } 1506 }
1507 1507
1508 } 1508 }
1509 1509
1510#ifndef KORG_NOPLUGINS 1510#ifndef KORG_NOPLUGINS
1511 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1511 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1512 !KOCore::self()->holiday(date).isEmpty(); 1512 !KOCore::self()->holiday(date).isEmpty();
1513#endif 1513#endif
1514 bool showDay = showSaturday || showSunday || showHoliday; 1514 bool showDay = showSaturday || showSunday || showHoliday;
1515 1515
1516 if (showDay) { 1516 if (showDay) {
1517 mHolidayMask.at(i) = true; 1517 mHolidayMask.at(i) = true;
1518 } else { 1518 } else {
1519 mHolidayMask.at(i) = false; 1519 mHolidayMask.at(i) = false;
1520 } 1520 }
1521 } 1521 }
1522 1522
1523 mAgenda->setHolidayMask(&mHolidayMask); 1523 mAgenda->setHolidayMask(&mHolidayMask);
1524 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1524 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1525} 1525}
1526 1526
1527void KOAgendaView::setContentsPos(int y) 1527void KOAgendaView::setContentsPos(int y)
1528{ 1528{
1529 mAgenda->setContentsPos(0,y); 1529 mAgenda->setContentsPos(0,y);
1530} 1530}
1531 1531
1532void KOAgendaView::clearSelection() 1532void KOAgendaView::clearSelection()
1533{ 1533{
1534 mAgenda->deselectItem(); 1534 mAgenda->deselectItem();
1535 mAllDayAgenda->deselectItem(); 1535 mAllDayAgenda->deselectItem();
1536} 1536}
1537 1537
1538void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1538void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1539 int gxEnd, int gyEnd) 1539 int gxEnd, int gyEnd)
1540{ 1540{
1541 mTimeSpanInAllDay = true; 1541 mTimeSpanInAllDay = true;
1542 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1542 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1543} 1543}
1544 1544
1545 1545
1546 1546
1547 1547
1548void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1548void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1549 int gxEnd, int gyEnd) 1549 int gxEnd, int gyEnd)
1550{ 1550{
1551 if (!mSelectedDates.count()) return; 1551 if (!mSelectedDates.count()) return;
1552 1552
1553 QDate dayStart = mSelectedDates[gxStart]; 1553 QDate dayStart = mSelectedDates[gxStart];
1554 QDate dayEnd = mSelectedDates[gxEnd]; 1554 QDate dayEnd = mSelectedDates[gxEnd];
1555 1555
1556 QTime timeStart = mAgenda->gyToTime(gyStart); 1556 QTime timeStart = mAgenda->gyToTime(gyStart);
1557 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1557 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1558 1558
1559 QDateTime dtStart(dayStart,timeStart); 1559 QDateTime dtStart(dayStart,timeStart);
1560 QDateTime dtEnd(dayEnd,timeEnd); 1560 QDateTime dtEnd(dayEnd,timeEnd);
1561 1561
1562 mTimeSpanBegin = dtStart; 1562 mTimeSpanBegin = dtStart;
1563 mTimeSpanEnd = dtEnd; 1563 mTimeSpanEnd = dtEnd;
1564 1564
1565} 1565}
1566 1566
1567void KOAgendaView::deleteSelectedDateTime() 1567void KOAgendaView::deleteSelectedDateTime()
1568{ 1568{
1569 mTimeSpanBegin.setDate(QDate()); 1569 mTimeSpanBegin.setDate(QDate());
1570 mTimeSpanEnd.setDate(QDate()); 1570 mTimeSpanEnd.setDate(QDate());
1571 mTimeSpanInAllDay = false; 1571 mTimeSpanInAllDay = false;
1572} 1572}
1573 1573
1574void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1574void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1575{ 1575{
1576 e->ignore(); 1576 e->ignore();
1577} 1577}
1578 1578
1579void KOAgendaView::scrollOneHourUp() 1579void KOAgendaView::scrollOneHourUp()
1580{ 1580{
1581 1581
1582 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1582 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1583} 1583}
1584void KOAgendaView::scrollOneHourDown() 1584void KOAgendaView::scrollOneHourDown()
1585{ 1585{
1586 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1586 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1587} 1587}
1588 1588
1589void KOAgendaView::setStartHour( int h ) 1589void KOAgendaView::setStartHour( int h )
1590{ 1590{
1591 mAgenda->setStartHour( h ); 1591 mAgenda->setStartHour( h );
1592 1592
1593} 1593}
1594void KOAgendaView::setInitStartHour() 1594void KOAgendaView::setInitStartHour()
1595{ 1595{
1596 1596
1597 if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1597 if ( KOPrefs::instance()->mCenterOnCurrentTime )
1598 setStartHour( QTime::currentTime ().hour() ); 1598 setStartHour( QTime::currentTime ().hour() );
1599 else 1599 else
1600 setStartHour( KOPrefs::instance()->mDayBegins ); 1600 setStartHour( KOPrefs::instance()->mDayBegins );
1601 1601
1602} 1602}
1603 1603
1604 1604
1605void KOAgendaView::updateTodo( Todo * t, int ) 1605void KOAgendaView::updateTodo( Todo * t, int )
1606{ 1606{
1607 if ( !isVisible() ) 1607 if ( !isVisible() )
1608 return; 1608 return;
1609 bool remove = false; 1609 bool remove = false;
1610 bool removeAD = false; 1610 bool removeAD = false;
1611 QDate da; 1611 QDate da;
1612 if ( t->hasCompletedDate() ) 1612 if ( t->hasCompletedDate() )
1613 da = t->completed().date(); 1613 da = t->completed().date();
1614 else 1614 else
1615 da = t->dtDue().date(); 1615 da = t->dtDue().date();
1616 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1616 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1617 remove = true; 1617 remove = true;
1618 removeAD = true; 1618 removeAD = true;
1619 } 1619 }
1620 else { 1620 else {
1621 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1621 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1622 if ( overdue && 1622 if ( overdue &&
1623 QDate::currentDate() >= mSelectedDates.first() && 1623 QDate::currentDate() >= mSelectedDates.first() &&
1624 QDate::currentDate() <= mSelectedDates.last()) { 1624 QDate::currentDate() <= mSelectedDates.last()) {
1625 removeAD = false; 1625 removeAD = false;
1626 remove = true; 1626 remove = true;
1627 } 1627 }
1628 else { 1628 else {
1629 1629
1630 if ( da < mSelectedDates.first() || 1630 if ( da < mSelectedDates.first() ||
1631 da > mSelectedDates.last() ) { 1631 da > mSelectedDates.last() ) {
1632 remove = true; 1632 remove = true;
1633 removeAD = true; 1633 removeAD = true;
1634 } else { 1634 } else {
1635 remove = t->doesFloat() && !t->hasCompletedDate(); 1635 remove = t->doesFloat() && !t->hasCompletedDate();
1636 removeAD = !remove; 1636 removeAD = !remove;
1637 } 1637 }
1638 } 1638 }
1639 } 1639 }
1640 int days = mSelectedDates.first().daysTo( da ); 1640 int days = mSelectedDates.first().daysTo( da );
1641 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1641 //qDebug("daysto %d %d %d", days, remove,removeAD );
1642 mAgenda->updateTodo( t , days, remove); 1642 mAgenda->updateTodo( t , days, remove);
1643 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1643 if ( KOPrefs::instance()->mShowTodoInAgenda )
1644 mAllDayAgenda->updateTodo( t , days, removeAD); 1644 mAllDayAgenda->updateTodo( t , days, removeAD);
1645 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1645 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1646 1646
1647} 1647}
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index ecca374..17a1d13 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -1,1130 +1,1129 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> 3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
4 Parts of the source code have been copied from kdpdatebutton.cpp 4 Parts of the source code have been copied from kdpdatebutton.cpp
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source ode for Qt in the source distribution. 22 without including the source ode for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qevent.h> 25#include <qevent.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qptrlist.h> 27#include <qptrlist.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#include <libkcal/vcaldrag.h> 35#include <libkcal/vcaldrag.h>
36#include <libkcal/icaldrag.h> 36#include <libkcal/icaldrag.h>
37#include <libkcal/dndfactory.h> 37#include <libkcal/dndfactory.h>
38#include <libkcal/calendarresources.h> 38#include <libkcal/calendarresources.h>
39#include <libkcal/resourcecalendar.h> 39#include <libkcal/resourcecalendar.h>
40#include <kresources/resourceselectdialog.h> 40#include <kresources/resourceselectdialog.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPLUGINS 44#ifndef KORG_NOPLUGINS
45#include "kocore.h" 45#include "kocore.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#include "koglobals.h" 48#include "koglobals.h"
49 49
50#include "kodaymatrix.h" 50#include "kodaymatrix.h"
51 51
52// ============================================================================ 52// ============================================================================
53// D Y N A M I C T I P 53// D Y N A M I C T I P
54// ============================================================================ 54// ============================================================================
55 55
56DynamicTip::DynamicTip( QWidget * parent ) 56DynamicTip::DynamicTip( QWidget * parent )
57 : QToolTip( parent ) 57 : QToolTip( parent )
58{ 58{
59 matrix = (KODayMatrix*)parent; 59 matrix = (KODayMatrix*)parent;
60} 60}
61 61
62class KODaymatrixWhatsThis :public QWhatsThis 62class KODaymatrixWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; 65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;};
66 ~KODaymatrixWhatsThis() { ; }; 66 ~KODaymatrixWhatsThis() { ; };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p ) 69 virtual QString text( const QPoint& p )
70 { 70 {
71 return _view->getWhatsThisText( p ) ; 71 return _view->getWhatsThisText( p ) ;
72 } 72 }
73private: 73private:
74 KODayMatrix * _view; 74 KODayMatrix * _view;
75}; 75};
76 76
77void DynamicTip::maybeTip( const QPoint &pos ) 77void DynamicTip::maybeTip( const QPoint &pos )
78{ 78{
79 //calculate which cell of the matrix the mouse is in 79 //calculate which cell of the matrix the mouse is in
80 QRect sz = matrix->frameRect(); 80 QRect sz = matrix->frameRect();
81 int dheight = sz.height()*7 / 42; 81 int dheight = sz.height()*7 / 42;
82 int dwidth = sz.width() / 7; 82 int dwidth = sz.width() / 7;
83 int row = pos.y()/dheight; 83 int row = pos.y()/dheight;
84 int col = pos.x()/dwidth; 84 int col = pos.x()/dwidth;
85 85
86 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 86 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
87 87
88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
89// col << "][" << row << "] => " <<(col+row*7) << endl; 89// col << "][" << row << "] => " <<(col+row*7) << endl;
90 90
91 //show holiday names only 91 //show holiday names only
92 QString str = matrix->getHolidayLabel(col+row*7); 92 QString str = matrix->getHolidayLabel(col+row*7);
93 if (str.isEmpty()) return; 93 if (str.isEmpty()) return;
94 tip(rct, str); 94 tip(rct, str);
95} 95}
96 96
97 97
98// ============================================================================ 98// ============================================================================
99// K O D A Y M A T R I X 99// K O D A Y M A T R I X
100// ============================================================================ 100// ============================================================================
101 101
102const int KODayMatrix::NOSELECTION = -1000; 102const int KODayMatrix::NOSELECTION = -1000;
103const int KODayMatrix::NUMDAYS = 42; 103const int KODayMatrix::NUMDAYS = 42;
104 104
105KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) 105KODayMatrix::KODayMatrix( QWidget *parent, const char *name )
106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) 106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 )
107 107
108#if 0 108#if 0
109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : 109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
110 QFrame(parent, name) 110 QFrame(parent, name)
111#endif 111#endif
112{ 112{
113 oldW = 0; 113 oldW = 0;
114 oldH = 0; 114 oldH = 0;
115 myPix.resize( 150, 120 ); 115 myPix.resize( 150, 120 );
116 mRedrawNeeded = true; 116 mRedrawNeeded = true;
117 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); 117 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this);
118 mPendingUpdateBeforeRepaint = false; 118 mPendingUpdateBeforeRepaint = false;
119 mouseDown = false; 119 mouseDown = false;
120 // initialize dynamic arrays 120 // initialize dynamic arrays
121 bDays.resize ( NUMDAYS ); 121 bDays.resize ( NUMDAYS );
122 pDays.resize ( NUMDAYS ); 122 pDays.resize ( NUMDAYS );
123 hDays.resize ( NUMDAYS ); 123 hDays.resize ( NUMDAYS );
124 eDays.resize ( NUMDAYS ); 124 eDays.resize ( NUMDAYS );
125 days = new QDate[NUMDAYS]; 125 days = new QDate[NUMDAYS];
126 daylbls = new QString[NUMDAYS]; 126 daylbls = new QString[NUMDAYS];
127 //events = new int[NUMDAYS]; 127 //events = new int[NUMDAYS];
128 mToolTip = new DynamicTip(this); 128 mToolTip = new DynamicTip(this);
129 129
130 // set default values used for drawing the matrix 130 // set default values used for drawing the matrix
131 mDefaultBackColor = palette().active().base(); 131 mDefaultBackColor = palette().active().base();
132 mDefaultTextColor = palette().active().foreground(); 132 mDefaultTextColor = palette().active().foreground();
133 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 133 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
134 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 134 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
135 mSelectedDaysColor = QColor("white"); 135 mSelectedDaysColor = QColor("white");
136 mTodayMarginWidth = 2; 136 mTodayMarginWidth = 2;
137 mSelEnd = mSelStart = NOSELECTION; 137 mSelEnd = mSelStart = NOSELECTION;
138 138
139 setAcceptDrops(true); 139 setAcceptDrops(true);
140 //setFont( QFont("Arial", 10) ); 140 //setFont( QFont("Arial", 10) );
141 141
142 mUpdateTimer = new QTimer( this ); 142 mUpdateTimer = new QTimer( this );
143 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 143 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
144 mRepaintTimer = new QTimer( this ); 144 mRepaintTimer = new QTimer( this );
145 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 145 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
146 mDayChanged = false; 146 mDayChanged = false;
147 updateView(); 147 updateView();
148} 148}
149QString KODayMatrix::getWhatsThisText( QPoint p ) 149QString KODayMatrix::getWhatsThisText( QPoint p )
150{ 150{
151 151
152 int tmp = getDayIndexFrom(p.x(), p.y()); 152 int tmp = getDayIndexFrom(p.x(), p.y());
153 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) 153 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar )
154 return QString(); 154 return QString();
155 QDate mDate = days[tmp]; 155 QDate mDate = days[tmp];
156 QPtrList<Event> eventlist = mCalendar->events(mDate); 156 QPtrList<Event> eventlist = mCalendar->events(mDate);
157 Event *event; 157 Event *event;
158 QStringList mToolTip; 158 QStringList mToolTip;
159 for(event=eventlist.first();event != 0;event=eventlist.next()) { 159 for(event=eventlist.first();event != 0;event=eventlist.next()) {
160 QString mToolTipText; 160 QString mToolTipText;
161 QString text; 161 QString text;
162 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 162 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
163 if (event->isMultiDay()) { 163 if (event->isMultiDay()) {
164 QString prefix = "<->";multiday = 2; 164 QString prefix = "<->";multiday = 2;
165 QString time; 165 QString time;
166 if ( event->doesRecur() ) { 166 if ( event->doesRecur() ) {
167 if ( event->recursOn( mDate) ) { 167 if ( event->recursOn( mDate) ) {
168 prefix ="->" ;multiday = 1; 168 prefix ="->" ;multiday = 1;
169 } 169 }
170 else { 170 else {
171 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 171 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
172 if ( event->recursOn( mDate.addDays( -days)) ) { 172 if ( event->recursOn( mDate.addDays( -days)) ) {
173 prefix ="<-" ;multiday = 3; 173 prefix ="<-" ;multiday = 3;
174 } 174 }
175 } 175 }
176 } else { 176 } else {
177 if (mDate == event->dtStart().date()) { 177 if (mDate == event->dtStart().date()) {
178 prefix ="->" ;multiday = 1; 178 prefix ="->" ;multiday = 1;
179 } else if (mDate == event->dtEnd().date()) { 179 } else if (mDate == event->dtEnd().date()) {
180 prefix ="<-" ;multiday = 3; 180 prefix ="<-" ;multiday = 3;
181 } 181 }
182 } 182 }
183 if ( !event->doesFloat() ) { 183 if ( !event->doesFloat() ) {
184 if ( mDate == event->dtStart().date () ) 184 if ( mDate == event->dtStart().date () )
185 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 185 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
186 else if ( mDate == event->dtEnd().date () ) 186 else if ( mDate == event->dtEnd().date () )
187 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 187 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
188 188
189 } 189 }
190 text = time + event->summary(); 190 text = time + event->summary();
191 mToolTipText += prefix + text; 191 mToolTipText += prefix + text;
192 } else { 192 } else {
193 if (event->doesFloat()) { 193 if (event->doesFloat()) {
194 text = event->summary(); 194 text = event->summary();
195 mToolTipText += text; 195 mToolTipText += text;
196 } 196 }
197 else { 197 else {
198 text = KGlobal::locale()->formatTime(event->dtStart().time()); 198 text = KGlobal::locale()->formatTime(event->dtStart().time());
199 text += " " + event->summary(); 199 text += " " + event->summary();
200 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 200 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
201 } 201 }
202 } 202 }
203 if ( !event->location().isEmpty() ) 203 if ( !event->location().isEmpty() )
204 mToolTipText += " (" + event->location() + ")"; 204 mToolTipText += " (" + event->location() + ")";
205#if QT_VERSION >= 0x030000 205#if QT_VERSION >= 0x030000
206 mToolTipText.replace( '<' , "&lt;" ); 206 mToolTipText.replace( '<' , "&lt;" );
207 mToolTipText.replace( '>' , "&gt;" ); 207 mToolTipText.replace( '>' , "&gt;" );
208#else 208#else
209 if ( mToolTipText.find ('<') >= 0 ) { 209 if ( mToolTipText.find ('<') >= 0 ) {
210 mToolTipText.replace( QRegExp("<") , "&lt;" ); 210 mToolTipText.replace( QRegExp("<") , "&lt;" );
211 } 211 }
212 if ( mToolTipText.find ('>') >= 0 ) { 212 if ( mToolTipText.find ('>') >= 0 ) {
213 mToolTipText.replace( QRegExp(">") , "&gt;" ); 213 mToolTipText.replace( QRegExp(">") , "&gt;" );
214 } 214 }
215#endif 215#endif
216 //qDebug("TTT: %s ", mToolTipText.latin1()); 216 //qDebug("TTT: %s ", mToolTipText.latin1());
217 mToolTip.append( mToolTipText ); 217 mToolTip.append( mToolTipText );
218 } 218 }
219 mToolTip.sort(); 219 mToolTip.sort();
220 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); 220 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>");
221} 221}
222void KODayMatrix::setCalendar( Calendar *cal ) 222void KODayMatrix::setCalendar( Calendar *cal )
223{ 223{
224 mCalendar = cal; 224 mCalendar = cal;
225 225
226 setAcceptDrops( mCalendar ); 226 setAcceptDrops( mCalendar );
227 227
228 updateEvents(); 228 updateEvents();
229} 229}
230 230
231QColor KODayMatrix::getShadedColor(QColor color) 231QColor KODayMatrix::getShadedColor(QColor color)
232{ 232{
233 QColor shaded; 233 QColor shaded;
234 int h=0; 234 int h=0;
235 int s=0; 235 int s=0;
236 int v=0; 236 int v=0;
237 color.hsv(&h,&s,&v); 237 color.hsv(&h,&s,&v);
238 s = s/4; 238 s = s/4;
239 v = 192+v/4; 239 v = 192+v/4;
240 shaded.setHsv(h,s,v); 240 shaded.setHsv(h,s,v);
241 241
242 return shaded; 242 return shaded;
243} 243}
244 244
245KODayMatrix::~KODayMatrix() 245KODayMatrix::~KODayMatrix()
246{ 246{
247 // delete mKODaymatrixWhatsThis; 247 // delete mKODaymatrixWhatsThis;
248 delete [] days; 248 delete [] days;
249 delete [] daylbls; 249 delete [] daylbls;
250 //delete [] events; 250 //delete [] events;
251 delete mToolTip; 251 delete mToolTip;
252} 252}
253 253
254/* 254/*
255void KODayMatrix::setStartDate(QDate start) 255void KODayMatrix::setStartDate(QDate start)
256{ 256{
257 updateView(start); 257 updateView(start);
258} 258}
259*/ 259*/
260 260
261void KODayMatrix::addSelectedDaysTo(DateList& selDays) 261void KODayMatrix::addSelectedDaysTo(DateList& selDays)
262{ 262{
263 263
264 if (mSelStart == NOSELECTION) { 264 if (mSelStart == NOSELECTION) {
265 return; 265 return;
266 } 266 }
267 267
268 //cope with selection being out of matrix limits at top (< 0) 268 //cope with selection being out of matrix limits at top (< 0)
269 int i0 = mSelStart; 269 int i0 = mSelStart;
270 if (i0 < 0) { 270 if (i0 < 0) {
271 for (int i = i0; i < 0; i++) { 271 for (int i = i0; i < 0; i++) {
272 selDays.append(days[0].addDays(i)); 272 selDays.append(days[0].addDays(i));
273 } 273 }
274 i0 = 0; 274 i0 = 0;
275 } 275 }
276 276
277 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 277 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
278 if (mSelEnd > NUMDAYS-1) { 278 if (mSelEnd > NUMDAYS-1) {
279 for (int i = i0; i <= NUMDAYS-1; i++) { 279 for (int i = i0; i <= NUMDAYS-1; i++) {
280 selDays.append(days[i]); 280 selDays.append(days[i]);
281 } 281 }
282 for (int i = NUMDAYS; i < mSelEnd; i++) { 282 for (int i = NUMDAYS; i < mSelEnd; i++) {
283 selDays.append(days[0].addDays(i)); 283 selDays.append(days[0].addDays(i));
284 } 284 }
285 285
286 // apply normal routine to selection being entirely within matrix limits 286 // apply normal routine to selection being entirely within matrix limits
287 } else { 287 } else {
288 for (int i = i0; i <= mSelEnd; i++) { 288 for (int i = i0; i <= mSelEnd; i++) {
289 selDays.append(days[i]); 289 selDays.append(days[i]);
290 } 290 }
291 } 291 }
292} 292}
293 293
294bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 294bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
295{ 295{
296 mRedrawNeeded = true; 296 mRedrawNeeded = true;
297 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); 297 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION );
298 mSelStart = startdate.daysTo(start); 298 mSelStart = startdate.daysTo(start);
299 if ( mSelStart < 0 ) 299 if ( mSelStart < 0 )
300 mSelStart = 0; 300 mSelStart = 0;
301 mSelEnd = startdate.daysTo(end); 301 mSelEnd = startdate.daysTo(end);
302 if ( mSelEnd > NUMDAYS-1 ) 302 if ( mSelEnd > NUMDAYS-1 )
303 mSelEnd = NUMDAYS-1; 303 mSelEnd = NUMDAYS-1;
304 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { 304 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) {
305 clearSelection(); 305 clearSelection();
306 if ( noSel ) 306 if ( noSel )
307 return false; 307 return false;
308 } 308 }
309 309
310 return true; 310 return true;
311} 311}
312void KODayMatrix::clearSelection() 312void KODayMatrix::clearSelection()
313{ 313{
314 mSelEnd = mSelStart = NOSELECTION; 314 mSelEnd = mSelStart = NOSELECTION;
315} 315}
316 316
317 317
318void KODayMatrix::recalculateToday() 318void KODayMatrix::recalculateToday()
319{ 319{
320 today = -1; 320 today = -1;
321 for (int i=0; i<NUMDAYS; i++) { 321 for (int i=0; i<NUMDAYS; i++) {
322 //events[i] = 0; 322 //events[i] = 0;
323 days[i] = startdate.addDays(i); 323 days[i] = startdate.addDays(i);
324 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 324 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
325 325
326 // if today is in the currently displayed month, hilight today 326 // if today is in the currently displayed month, hilight today
327 if (days[i].year() == QDate::currentDate().year() && 327 if (days[i].year() == QDate::currentDate().year() &&
328 days[i].month() == QDate::currentDate().month() && 328 days[i].month() == QDate::currentDate().month() &&
329 days[i].day() == QDate::currentDate().day()) { 329 days[i].day() == QDate::currentDate().day()) {
330 today = i; 330 today = i;
331 } 331 }
332 } 332 }
333 // qDebug(QString("Today is visible at %1.").arg(today)); 333 // qDebug(QString("Today is visible at %1.").arg(today));
334} 334}
335 335
336void KODayMatrix::updateView() 336void KODayMatrix::updateView()
337{ 337{
338 updateView(startdate); 338 updateView(startdate);
339} 339}
340void KODayMatrix::repaintViewTimed() 340void KODayMatrix::repaintViewTimed()
341{ 341{
342 mRedrawNeeded = true; 342 mRedrawNeeded = true;
343 // bDays.fill( false); 343 // bDays.fill( false);
344 //pDays.fill( false); 344 //pDays.fill( false);
345 //hDays.fill( false); 345 //hDays.fill( false);
346 //eDays.fill( false); 346 //eDays.fill( false);
347 mRepaintTimer->stop(); 347 mRepaintTimer->stop();
348 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday 348 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
349 int i; 349 int i;
350 for(i = 0; i < NUMDAYS; i++) { 350 for(i = 0; i < NUMDAYS; i++) {
351 if ( ( (i+startDay) % 7 == 0 ) ) { 351 if ( ( (i+startDay) % 7 == 0 ) ) {
352 pDays.setBit(i); 352 pDays.setBit(i);
353 } 353 }
354 } 354 }
355 repaint(false); 355 repaint(false);
356} 356}
357void KODayMatrix::computeEvent(Event *event, int i ) 357void KODayMatrix::computeEvent(Event *event, int i )
358{ 358{
359 QString holiStr = mHolidays[i]; 359 QString holiStr = mHolidays[i];
360 if ( event->isHoliday()) { 360 if ( event->isHoliday()) {
361 pDays.setBit(i); 361 pDays.setBit(i);
362 hDays.setBit(i); 362 hDays.setBit(i);
363 if ( !holiStr.isEmpty() ) 363 if ( !holiStr.isEmpty() )
364 holiStr += "\n"; 364 holiStr += "\n";
365 holiStr += event->summary(); 365 holiStr += event->summary();
366 if ( !event->location().isEmpty() ) 366 if ( !event->location().isEmpty() )
367 holiStr += " (" + event->location() + ")"; 367 holiStr += " (" + event->location() + ")";
368 mHolidays[i] =holiStr ; 368 mHolidays[i] =holiStr ;
369 } 369 }
370 if ( event->isBirthday()) { 370 if ( event->isBirthday()) {
371 pDays.setBit(i); 371 pDays.setBit(i);
372 if ( !holiStr.isEmpty() ) 372 if ( !holiStr.isEmpty() )
373 holiStr += "\n"; 373 holiStr += "\n";
374 holiStr += i18n("Birthday") + ": "+event->summary(); 374 holiStr += i18n("Birthday") + ": "+event->summary();
375 if ( !event->location().isEmpty() ) 375 if ( !event->location().isEmpty() )
376 holiStr += " (" + event->location() + ")"; 376 holiStr += " (" + event->location() + ")";
377 bDays.setBit(i); 377 bDays.setBit(i);
378 mHolidays[i] =holiStr ; 378 mHolidays[i] =holiStr ;
379 } 379 }
380 eDays.setBit(i); 380 eDays.setBit(i);
381} 381}
382void KODayMatrix::updateViewTimed() 382void KODayMatrix::updateViewTimed()
383{ 383{
384 mUpdateTimer->stop(); 384 mUpdateTimer->stop();
385 if ( !mCalendar ) { 385 if ( !mCalendar ) {
386 qDebug("NOT CAL "); 386 qDebug("NOT CAL ");
387 return; 387 return;
388 } 388 }
389#if 1 389#if 1
390 390
391 int i; 391 int i;
392 int timeSpan = NUMDAYS-1; 392 int timeSpan = NUMDAYS-1;
393 QPtrList<Event> events = mCalendar->events(); 393 QPtrList<Event> events = mCalendar->events();
394 Event *event; 394 Event *event;
395 QDateTime dt; 395 QDateTime dt;
396 bool ok; 396 bool ok;
397 bDays.fill( false); 397 bDays.fill( false);
398 pDays.fill( false); 398 pDays.fill( false);
399 hDays.fill( false); 399 hDays.fill( false);
400 eDays.fill( false); 400 eDays.fill( false);
401 mHolidays.clear(); 401 mHolidays.clear();
402 QDate mStartDate = days[0]; 402 QDate mStartDate = days[0];
403 QDate endDate = mStartDate.addDays( timeSpan ); 403 QDate endDate = mStartDate.addDays( timeSpan );
404 for( event = events.first(); event; event = events.next() ) { // for event 404 for( event = events.first(); event; event = events.next() ) { // for event
405 ushort recurType = event->recurrence()->doesRecur(); 405 ushort recurType = event->recurrence()->doesRecur();
406 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 406 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
407 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 407 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
408 continue; 408 continue;
409 } 409 }
410 if ( event->doesRecur() ) { 410 if ( event->doesRecur() ) {
411 bool last; 411 bool last;
412 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 412 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
413 QDateTime incidenceEnd; 413 QDateTime incidenceEnd;
414 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 414 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
415 bool invalid = false; 415 bool invalid = false;
416 while( true ) { 416 while( true ) {
417 if ( incidenceStart.isValid() ) { 417 if ( incidenceStart.isValid() ) {
418 incidenceEnd = incidenceStart.addDays( eventlen ); 418 incidenceEnd = incidenceStart.addDays( eventlen );
419 int st = incidenceStart.date().daysTo( endDate ); 419 int st = incidenceStart.date().daysTo( endDate );
420 if ( st >= 0 ) { // start before timeend 420 if ( st >= 0 ) { // start before timeend
421 int end = mStartDate.daysTo( incidenceEnd.date() ); 421 int end = mStartDate.daysTo( incidenceEnd.date() );
422 if ( end >= 0 ) { // end after timestart --- got one! 422 if ( end >= 0 ) { // end after timestart --- got one!
423 //normalize 423 //normalize
424 st = timeSpan - st; 424 st = timeSpan - st;
425 if ( st < 0 ) st = 0; 425 if ( st < 0 ) st = 0;
426 if ( end > timeSpan ) end = timeSpan; 426 if ( end > timeSpan ) end = timeSpan;
427 int iii; 427 int iii;
428 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 428 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
429 for ( iii = st;iii<= end;++iii) { 429 for ( iii = st;iii<= end;++iii) {
430 computeEvent( event, iii ); 430 computeEvent( event, iii );
431 } 431 }
432 } 432 }
433 } 433 }
434 } else { 434 } else {
435 if ( invalid ) 435 if ( invalid )
436 break; 436 break;
437 invalid = true; 437 invalid = true;
438 //qDebug("invalid %s", event->summary().latin1()); 438 //qDebug("invalid %s", event->summary().latin1());
439 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 439 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
440 } 440 }
441 if ( last ) 441 if ( last )
442 break; 442 break;
443 bool ok; 443 bool ok;
444 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 444 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
445 if ( ! ok ) 445 if ( ! ok )
446 break; 446 break;
447 if ( incidenceStart.date() > endDate ) 447 if ( incidenceStart.date() > endDate )
448 break; 448 break;
449 } 449 }
450 } else { // no recur 450 } else { // no recur
451 int st = event->dtStart().date().daysTo( endDate ); 451 int st = event->dtStart().date().daysTo( endDate );
452 if ( st >= 0 ) { // start before timeend 452 if ( st >= 0 ) { // start before timeend
453 int end = mStartDate.daysTo( event->dtEnd().date() ); 453 int end = mStartDate.daysTo( event->dtEnd().date() );
454 if ( end >= 0 ) { // end after timestart --- got one! 454 if ( end >= 0 ) { // end after timestart --- got one!
455 //normalize 455 //normalize
456 st = timeSpan - st; 456 st = timeSpan - st;
457 if ( st < 0 ) st = 0; 457 if ( st < 0 ) st = 0;
458 if ( end > timeSpan ) end = timeSpan; 458 if ( end > timeSpan ) end = timeSpan;
459 int iii; 459 int iii;
460 for ( iii = st;iii<= end;++iii) 460 for ( iii = st;iii<= end;++iii)
461 computeEvent( event, iii ); 461 computeEvent( event, iii );
462 } 462 }
463 } 463 }
464 } 464 }
465 } 465 }
466 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday 466 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
467 for(i = 0; i < NUMDAYS; i++) { 467 for(i = 0; i < NUMDAYS; i++) {
468 if ( ( (i+startDay) % 7 == 0 ) ) { 468 if ( ( (i+startDay) % 7 == 0 ) ) {
469 pDays.setBit(i); 469 pDays.setBit(i);
470 } 470 }
471 } 471 }
472 472
473#if 0 473#if 0
474 // insert due todos 474 // insert due todos
475 QPtrList<Todo> todos = calendar()->todos( ); 475 QPtrList<Todo> todos = calendar()->todos( );
476 Todo *todo; 476 Todo *todo;
477 for(todo = todos.first(); todo; todo = todos.next()) { 477 for(todo = todos.first(); todo; todo = todos.next()) {
478 //insertTodo( todo ); 478 //insertTodo( todo );
479 if ( todo->hasDueDate() ) { 479 if ( todo->hasDueDate() ) {
480 int day = mStartDate.daysTo( todo->dtDue().date() ); 480 int day = mStartDate.daysTo( todo->dtDue().date() );
481 if ( day >= 0 && day < timeSpan + 1) { 481 if ( day >= 0 && day < timeSpan + 1) {
482 (*cells)[day]->insertTodo( todo ); 482 (*cells)[day]->insertTodo( todo );
483 } 483 }
484 } 484 }
485 } 485 }
486#endif 486#endif
487 487
488#else 488#else
489 //qDebug("KODayMatrix::updateViewTimed "); 489 //qDebug("KODayMatrix::updateViewTimed ");
490 for(int i = 0; i < NUMDAYS; i++) { 490 for(int i = 0; i < NUMDAYS; i++) {
491 // if events are set for the day then remember to draw it bold 491 // if events are set for the day then remember to draw it bold
492 QPtrList<Event> eventlist = mCalendar->events(days[i]); 492 QPtrList<Event> eventlist = mCalendar->events(days[i]);
493 Event *event; 493 Event *event;
494 int numEvents = eventlist.count(); 494 int numEvents = eventlist.count();
495 QString holiStr = ""; 495 QString holiStr = "";
496 bDays.clearBit(i); 496 bDays.clearBit(i);
497 hDays.clearBit(i); 497 hDays.clearBit(i);
498 eDays.clearBit(i); 498 eDays.clearBit(i);
499 for(event=eventlist.first();event != 0;event=eventlist.next()) { 499 for(event=eventlist.first();event != 0;event=eventlist.next()) {
500 qDebug("FFFFFFFFFFFFFFFFFFFFFFFFF ");
501 ushort recurType = event->recurrence()->doesRecur(); 500 ushort recurType = event->recurrence()->doesRecur();
502 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 501 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
503 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 502 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
504 numEvents--; 503 numEvents--;
505 } 504 }
506 if ( event->isHoliday()) { 505 if ( event->isHoliday()) {
507 hDays.setBit(i); 506 hDays.setBit(i);
508 if ( !holiStr.isEmpty() ) 507 if ( !holiStr.isEmpty() )
509 holiStr += "\n"; 508 holiStr += "\n";
510 holiStr += event->summary(); 509 holiStr += event->summary();
511 if ( !event->location().isEmpty() ) 510 if ( !event->location().isEmpty() )
512 holiStr += " (" + event->location() + ")"; 511 holiStr += " (" + event->location() + ")";
513 } 512 }
514 if ( event->isBirthday()) { 513 if ( event->isBirthday()) {
515 if ( !holiStr.isEmpty() ) 514 if ( !holiStr.isEmpty() )
516 holiStr += "\n"; 515 holiStr += "\n";
517 holiStr += i18n("Birthday") + ": "+event->summary(); 516 holiStr += i18n("Birthday") + ": "+event->summary();
518 if ( !event->location().isEmpty() ) 517 if ( !event->location().isEmpty() )
519 holiStr += " (" + event->location() + ")"; 518 holiStr += " (" + event->location() + ")";
520 bDays.setBit(i); 519 bDays.setBit(i);
521 } 520 }
522 } 521 }
523 if ( numEvents ) 522 if ( numEvents )
524 eDays.setBit(i); 523 eDays.setBit(i);
525 //if it is a holy day then draw it red. Sundays are consider holidays, too 524 //if it is a holy day then draw it red. Sundays are consider holidays, too
526 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 525 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
527 !holiStr.isEmpty()) { 526 !holiStr.isEmpty()) {
528 mHolidays[i] = holiStr; 527 mHolidays[i] = holiStr;
529 } else { 528 } else {
530 mHolidays[i] = QString::null; 529 mHolidays[i] = QString::null;
531 } 530 }
532 } 531 }
533#endif 532#endif
534 mRedrawNeeded = true; 533 mRedrawNeeded = true;
535 if ( ! mPendingUpdateBeforeRepaint ) 534 if ( ! mPendingUpdateBeforeRepaint )
536 repaint(false); 535 repaint(false);
537} 536}
538void KODayMatrix::updateView(QDate actdate) 537void KODayMatrix::updateView(QDate actdate)
539{ 538{
540 539
541 if ( ! actdate.isValid() ) { 540 if ( ! actdate.isValid() ) {
542 //qDebug("date not valid "); 541 //qDebug("date not valid ");
543 return; 542 return;
544 } 543 }
545 mDayChanged = false; 544 mDayChanged = false;
546 //flag to indicate if the starting day of the matrix has changed by this call 545 //flag to indicate if the starting day of the matrix has changed by this call
547 //mDayChanged = false; 546 //mDayChanged = false;
548 // if a new startdate is to be set then apply Cornelius's calculation 547 // if a new startdate is to be set then apply Cornelius's calculation
549 // of the first day to be shown 548 // of the first day to be shown
550 if (actdate != startdate) { 549 if (actdate != startdate) {
551 // reset index of selection according to shift of starting date from startdate to actdate 550 // reset index of selection according to shift of starting date from startdate to actdate
552 if (mSelStart != NOSELECTION) { 551 if (mSelStart != NOSELECTION) {
553 int tmp = actdate.daysTo(startdate); 552 int tmp = actdate.daysTo(startdate);
554 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 553 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
555 // shift selection if new one would be visible at least partly ! 554 // shift selection if new one would be visible at least partly !
556 555
557 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 556 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
558 // nested if is required for next X display pushed from a different month - correction required 557 // nested if is required for next X display pushed from a different month - correction required
559 // otherwise, for month forward and backward, it must be avoided 558 // otherwise, for month forward and backward, it must be avoided
560 if( mSelStart > NUMDAYS || mSelStart < 0 ) 559 if( mSelStart > NUMDAYS || mSelStart < 0 )
561 mSelStart = mSelStart + tmp; 560 mSelStart = mSelStart + tmp;
562 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 561 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
563 mSelEnd = mSelEnd + tmp; 562 mSelEnd = mSelEnd + tmp;
564 } 563 }
565 } 564 }
566 startdate = actdate; 565 startdate = actdate;
567 mDayChanged = true; 566 mDayChanged = true;
568 recalculateToday(); 567 recalculateToday();
569 mRedrawNeeded = true; 568 mRedrawNeeded = true;
570 } 569 }
571 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 570 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
572 if ( !isVisible() ) { 571 if ( !isVisible() ) {
573 mPendingUpdateBeforeRepaint = true; 572 mPendingUpdateBeforeRepaint = true;
574 } else { 573 } else {
575#ifdef DESKTOP_VERSION 574#ifdef DESKTOP_VERSION
576 //mRepaintTimer->start( 100 ); 575 //mRepaintTimer->start( 100 );
577 //updateViewTimed(); 576 //updateViewTimed();
578 mUpdateTimer->start( 50 ); 577 mUpdateTimer->start( 50 );
579#else 578#else
580 mRepaintTimer->start( 350 ); 579 mRepaintTimer->start( 350 );
581 mUpdateTimer->start( 800 ); 580 mUpdateTimer->start( 800 );
582#endif 581#endif
583 } 582 }
584} 583}
585void KODayMatrix::updateEvents() 584void KODayMatrix::updateEvents()
586{ 585{
587 if ( !mCalendar ) return; 586 if ( !mCalendar ) return;
588 587
589 for( int i = 0; i < NUMDAYS; i++ ) { 588 for( int i = 0; i < NUMDAYS; i++ ) {
590 // if events are set for the day then remember to draw it bold 589 // if events are set for the day then remember to draw it bold
591 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 590 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
592 int numEvents = eventlist.count(); 591 int numEvents = eventlist.count();
593 Event *event; 592 Event *event;
594 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 593 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
595 ushort recurType = event->doesRecur(); 594 ushort recurType = event->doesRecur();
596 595
597 if ( ( recurType == Recurrence::rDaily && 596 if ( ( recurType == Recurrence::rDaily &&
598 !KOPrefs::instance()->mDailyRecur ) || 597 !KOPrefs::instance()->mDailyRecur ) ||
599 ( recurType == Recurrence::rWeekly && 598 ( recurType == Recurrence::rWeekly &&
600 !KOPrefs::instance()->mWeeklyRecur ) ) { 599 !KOPrefs::instance()->mWeeklyRecur ) ) {
601 numEvents--; 600 numEvents--;
602 } 601 }
603 } 602 }
604 if ( numEvents ) 603 if ( numEvents )
605 eDays.setBit(i); 604 eDays.setBit(i);
606 else 605 else
607 eDays.clearBit(i); 606 eDays.clearBit(i);
608 } 607 }
609} 608}
610 609
611const QDate& KODayMatrix::getDate(int offset) 610const QDate& KODayMatrix::getDate(int offset)
612{ 611{
613 if (offset < 0 || offset > NUMDAYS-1) { 612 if (offset < 0 || offset > NUMDAYS-1) {
614 qDebug("Wrong offset2 %d", offset); 613 qDebug("Wrong offset2 %d", offset);
615 return days[0]; 614 return days[0];
616 } 615 }
617 return days[offset]; 616 return days[offset];
618} 617}
619 618
620QString KODayMatrix::getHolidayLabel(int offset) 619QString KODayMatrix::getHolidayLabel(int offset)
621{ 620{
622 if (offset < 0 || offset > NUMDAYS-1) { 621 if (offset < 0 || offset > NUMDAYS-1) {
623 qDebug("Wrong offset1 %d", offset); 622 qDebug("Wrong offset1 %d", offset);
624 return QString(); 623 return QString();
625 } 624 }
626 return mHolidays[offset]; 625 return mHolidays[offset];
627} 626}
628 627
629int KODayMatrix::getDayIndexFrom(int x, int y) 628int KODayMatrix::getDayIndexFrom(int x, int y)
630{ 629{
631 int colModulo = (width()-2) % 7; 630 int colModulo = (width()-2) % 7;
632 int rowModulo = (height()-2) % 6; 631 int rowModulo = (height()-2) % 6;
633#if 0 632#if 0
634 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 633 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
635 6 - x/daysize.width() : x/daysize.width()); 634 6 - x/daysize.width() : x/daysize.width());
636#endif 635#endif
637 int xVal = (x-colModulo/2-2)/daysize.width(); 636 int xVal = (x-colModulo/2-2)/daysize.width();
638 int yVal = (y-rowModulo/2-2)/daysize.height(); 637 int yVal = (y-rowModulo/2-2)/daysize.height();
639 638
640 639
641 return 7*(yVal) + xVal; 640 return 7*(yVal) + xVal;
642 641
643} 642}
644 643
645// ---------------------------------------------------------------------------- 644// ----------------------------------------------------------------------------
646// M O U S E E V E N T H A N D L I N G 645// M O U S E E V E N T H A N D L I N G
647// ---------------------------------------------------------------------------- 646// ----------------------------------------------------------------------------
648 647
649void KODayMatrix::mousePressEvent (QMouseEvent* e) 648void KODayMatrix::mousePressEvent (QMouseEvent* e)
650{ 649{
651 650
652 if ( e->button() == LeftButton ) 651 if ( e->button() == LeftButton )
653 mouseDown = true; 652 mouseDown = true;
654 mSelStart = getDayIndexFrom(e->x(), e->y()); 653 mSelStart = getDayIndexFrom(e->x(), e->y());
655 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 654 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
656 mSelInit = mSelStart; 655 mSelInit = mSelStart;
657 mSelEnd = mSelStart; 656 mSelEnd = mSelStart;
658 mRedrawNeeded = true; 657 mRedrawNeeded = true;
659 repaint(false); 658 repaint(false);
660} 659}
661 660
662void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 661void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
663{ 662{
664 mRedrawNeeded = true; 663 mRedrawNeeded = true;
665 if ( e->button() == LeftButton ) 664 if ( e->button() == LeftButton )
666 if ( ! mouseDown ) { 665 if ( ! mouseDown ) {
667 return; 666 return;
668 } 667 }
669 else 668 else
670 mouseDown = false; 669 mouseDown = false;
671 int tmp = getDayIndexFrom(e->x(), e->y()); 670 int tmp = getDayIndexFrom(e->x(), e->y());
672 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 671 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
673 672
674 if (mSelInit > tmp) { 673 if (mSelInit > tmp) {
675 mSelEnd = mSelInit; 674 mSelEnd = mSelInit;
676 if (tmp != mSelStart) { 675 if (tmp != mSelStart) {
677 mSelStart = tmp; 676 mSelStart = tmp;
678 repaint(false); 677 repaint(false);
679 } 678 }
680 } else { 679 } else {
681 mSelStart = mSelInit; 680 mSelStart = mSelInit;
682 681
683 //repaint only if selection has changed 682 //repaint only if selection has changed
684 if (tmp != mSelEnd) { 683 if (tmp != mSelEnd) {
685 mSelEnd = tmp; 684 mSelEnd = tmp;
686 repaint(false); 685 repaint(false);
687 } 686 }
688 } 687 }
689 688
690 DateList daylist; 689 DateList daylist;
691 if ( mSelStart < 0 ) 690 if ( mSelStart < 0 )
692 mSelStart = 0; 691 mSelStart = 0;
693 for (int i = mSelStart; i <= mSelEnd; i++) { 692 for (int i = mSelStart; i <= mSelEnd; i++) {
694 daylist.append(days[i]); 693 daylist.append(days[i]);
695 } 694 }
696 emit selected((const DateList)daylist); 695 emit selected((const DateList)daylist);
697 696
698} 697}
699 698
700void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 699void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
701{ 700{
702 if ( ! mouseDown ) { 701 if ( ! mouseDown ) {
703 return; 702 return;
704 } 703 }
705 mRedrawNeeded = true; 704 mRedrawNeeded = true;
706 int tmp = getDayIndexFrom(e->x(), e->y()); 705 int tmp = getDayIndexFrom(e->x(), e->y());
707 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 706 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
708 707
709 if (mSelInit > tmp) { 708 if (mSelInit > tmp) {
710 mSelEnd = mSelInit; 709 mSelEnd = mSelInit;
711 if (tmp != mSelStart) { 710 if (tmp != mSelStart) {
712 mSelStart = tmp; 711 mSelStart = tmp;
713 repaint(false); 712 repaint(false);
714 } 713 }
715 } else { 714 } else {
716 mSelStart = mSelInit; 715 mSelStart = mSelInit;
717 716
718 //repaint only if selection has changed 717 //repaint only if selection has changed
719 if (tmp != mSelEnd) { 718 if (tmp != mSelEnd) {
720 mSelEnd = tmp; 719 mSelEnd = tmp;
721 repaint(false); 720 repaint(false);
722 } 721 }
723 } 722 }
724} 723}
725 724
726// ---------------------------------------------------------------------------- 725// ----------------------------------------------------------------------------
727// D R A G ' N D R O P H A N D L I N G 726// D R A G ' N D R O P H A N D L I N G
728// ---------------------------------------------------------------------------- 727// ----------------------------------------------------------------------------
729 728
730void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) 729void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
731{ 730{
732#ifndef KORG_NODND 731#ifndef KORG_NODND
733 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 732 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
734 e->ignore(); 733 e->ignore();
735 return; 734 return;
736 } 735 }
737 736
738 // some visual feedback 737 // some visual feedback
739// oldPalette = palette(); 738// oldPalette = palette();
740// setPalette(my_HilitePalette); 739// setPalette(my_HilitePalette);
741// update(); 740// update();
742#endif 741#endif
743} 742}
744 743
745void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) 744void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
746{ 745{
747#ifndef KORG_NODND 746#ifndef KORG_NODND
748 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 747 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
749 e->ignore(); 748 e->ignore();
750 return; 749 return;
751 } 750 }
752 751
753 e->accept(); 752 e->accept();
754#endif 753#endif
755} 754}
756 755
757void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 756void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
758{ 757{
759#ifndef KORG_NODND 758#ifndef KORG_NODND
760// setPalette(oldPalette); 759// setPalette(oldPalette);
761// update(); 760// update();
762#endif 761#endif
763} 762}
764 763
765void KODayMatrix::dropEvent(QDropEvent *e) 764void KODayMatrix::dropEvent(QDropEvent *e)
766{ 765{
767#ifndef KORG_NODND 766#ifndef KORG_NODND
768// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 767// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
769 768
770 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 769 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
771 e->ignore(); 770 e->ignore();
772 return; 771 return;
773 } 772 }
774 773
775 DndFactory factory( mCalendar ); 774 DndFactory factory( mCalendar );
776 Event *event = factory.createDrop(e); 775 Event *event = factory.createDrop(e);
777 776
778 if (event) { 777 if (event) {
779 e->acceptAction(); 778 e->acceptAction();
780 779
781 Event *existingEvent = mCalendar->event(event->uid()); 780 Event *existingEvent = mCalendar->event(event->uid());
782 781
783 if(existingEvent) { 782 if(existingEvent) {
784 // uniquify event 783 // uniquify event
785 event->recreate(); 784 event->recreate();
786/* 785/*
787 KMessageBox::sorry(this, 786 KMessageBox::sorry(this,
788 i18n("Event already exists in this calendar."), 787 i18n("Event already exists in this calendar."),
789 i18n("Drop Event")); 788 i18n("Drop Event"));
790 delete event; 789 delete event;
791 return; 790 return;
792*/ 791*/
793 } 792 }
794// kdDebug() << "Drop new Event" << endl; 793// kdDebug() << "Drop new Event" << endl;
795 // Adjust date 794 // Adjust date
796 QDateTime start = event->dtStart(); 795 QDateTime start = event->dtStart();
797 QDateTime end = event->dtEnd(); 796 QDateTime end = event->dtEnd();
798 int duration = start.daysTo(end); 797 int duration = start.daysTo(end);
799 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 798 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
800 799
801 start.setDate(days[idx]); 800 start.setDate(days[idx]);
802 end.setDate(days[idx].addDays(duration)); 801 end.setDate(days[idx].addDays(duration));
803 802
804 event->setDtStart(start); 803 event->setDtStart(start);
805 event->setDtEnd(end); 804 event->setDtEnd(end);
806 mCalendar->addEvent(event); 805 mCalendar->addEvent(event);
807 806
808 emit eventDropped(event); 807 emit eventDropped(event);
809 } else { 808 } else {
810// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 809// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
811 e->ignore(); 810 e->ignore();
812 } 811 }
813#endif 812#endif
814} 813}
815 814
816// ---------------------------------------------------------------------------- 815// ----------------------------------------------------------------------------
817// P A I N T E V E N T H A N D L I N G 816// P A I N T E V E N T H A N D L I N G
818// ---------------------------------------------------------------------------- 817// ----------------------------------------------------------------------------
819 818
820void KODayMatrix::paintEvent(QPaintEvent * pevent) 819void KODayMatrix::paintEvent(QPaintEvent * pevent)
821{ 820{
822 821
823 if ( width() <= 0 || height() <= 0 ) 822 if ( width() <= 0 || height() <= 0 )
824 return; 823 return;
825 if ( mPendingUpdateBeforeRepaint ) { 824 if ( mPendingUpdateBeforeRepaint ) {
826 updateViewTimed(); 825 updateViewTimed();
827 mPendingUpdateBeforeRepaint = false; 826 mPendingUpdateBeforeRepaint = false;
828 } 827 }
829#if 0 828#if 0
830 if ( myPix.width() != width() || myPix.height()!=height() ) { 829 if ( myPix.width() != width() || myPix.height()!=height() ) {
831 myPix.resize(size() ); 830 myPix.resize(size() );
832 mRedrawNeeded = true; 831 mRedrawNeeded = true;
833 } 832 }
834#endif 833#endif
835 if ( oldW != width() || oldH !=height() ) 834 if ( oldW != width() || oldH !=height() )
836 mRedrawNeeded = true; 835 mRedrawNeeded = true;
837 836
838 oldH = height() ; 837 oldH = height() ;
839 oldW = width(); 838 oldW = width();
840 if ( myPix.width() < width() || myPix.height() < height() ) { 839 if ( myPix.width() < width() || myPix.height() < height() ) {
841 myPix.resize(size() ); 840 myPix.resize(size() );
842 mRedrawNeeded = true; 841 mRedrawNeeded = true;
843 842
844 } 843 }
845 844
846 if ( mRedrawNeeded ) { 845 if ( mRedrawNeeded ) {
847 //qDebug("REDRAW "); 846 //qDebug("REDRAW ");
848 QPainter p(&myPix); 847 QPainter p(&myPix);
849 p.setFont(font()); 848 p.setFont(font());
850 849
851 850
852 int dheight = daysize.height(); 851 int dheight = daysize.height();
853 int dwidth = daysize.width(); 852 int dwidth = daysize.width();
854 int row,col; 853 int row,col;
855 int selw, selh; 854 int selw, selh;
856 int xyOff = frameWidth(); 855 int xyOff = frameWidth();
857 int colModulo = (width()-2) % 7; 856 int colModulo = (width()-2) % 7;
858 int rowModulo = (height()-2) % 6; 857 int rowModulo = (height()-2) % 6;
859 //qDebug("col %d row %d ",colModulo,rowModulo ); 858 //qDebug("col %d row %d ",colModulo,rowModulo );
860 859
861 bool isRTL = KOGlobals::self()->reverseLayout(); 860 bool isRTL = KOGlobals::self()->reverseLayout();
862 861
863 // draw background and topleft frame 862 // draw background and topleft frame
864 p.fillRect(0,0,width(),height(), mDefaultBackColor); 863 p.fillRect(0,0,width(),height(), mDefaultBackColor);
865 p.setPen(mDefaultTextColor); 864 p.setPen(mDefaultTextColor);
866 p.drawRect(0, 0, width(), height()); 865 p.drawRect(0, 0, width(), height());
867 int mSelStartT = mSelStart; 866 int mSelStartT = mSelStart;
868 int mSelEndT = mSelEnd; 867 int mSelEndT = mSelEnd;
869 if ( mSelEndT >= NUMDAYS ) 868 if ( mSelEndT >= NUMDAYS )
870 mSelEndT = NUMDAYS-1; 869 mSelEndT = NUMDAYS-1;
871 // draw selected days with highlighted background color 870 // draw selected days with highlighted background color
872 if (mSelStart != NOSELECTION) { 871 if (mSelStart != NOSELECTION) {
873 bool skip = false; 872 bool skip = false;
874 if ( ! mouseDown ) { 873 if ( ! mouseDown ) {
875 int mo = days[20].month(); 874 int mo = days[20].month();
876 //qDebug("-- %d %d ", mSelStartT, mSelEndT); 875 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
877 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); 876 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
878 int startMo = days[mSelStartT].month(); 877 int startMo = days[mSelStartT].month();
879 int endMo = days[mSelEndT].month(); 878 int endMo = days[mSelEndT].month();
880 if ( startMo == 12 && mo == 1 && endMo <= 2 ) 879 if ( startMo == 12 && mo == 1 && endMo <= 2 )
881 startMo = 1; 880 startMo = 1;
882 if ( endMo == 1 && mo == 12 ) 881 if ( endMo == 1 && mo == 12 )
883 endMo = 12; 882 endMo = 12;
884 if ( mo == 12 && startMo == 1 ) 883 if ( mo == 12 && startMo == 1 )
885 startMo = 13; 884 startMo = 13;
886 if ( (startMo > mo || endMo < mo) ) { 885 if ( (startMo > mo || endMo < mo) ) {
887 skip = true; 886 skip = true;
888 } else { 887 } else {
889 if ( days[mSelStartT].month() != mo ) { 888 if ( days[mSelStartT].month() != mo ) {
890 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); 889 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
891 mSelStartT += add +1; 890 mSelStartT += add +1;
892 } 891 }
893 if ( days[mSelEndT].month() != mo ) { 892 if ( days[mSelEndT].month() != mo ) {
894 int sub = days[mSelEndT].day(); 893 int sub = days[mSelEndT].day();
895 mSelEndT -= sub ; 894 mSelEndT -= sub ;
896 } 895 }
897 } 896 }
898 } 897 }
899 //qDebug("SKIP %d ", skip); 898 //qDebug("SKIP %d ", skip);
900 if ( ! skip ) { 899 if ( ! skip ) {
901 row = mSelStartT/7; 900 row = mSelStartT/7;
902 col = mSelStartT -row*7; 901 col = mSelStartT -row*7;
903 QColor selcol = KOPrefs::instance()->mHighlightColor; 902 QColor selcol = KOPrefs::instance()->mHighlightColor;
904 int addCol = 0; 903 int addCol = 0;
905 int addRow = 0; 904 int addRow = 0;
906 int addRow2 = 0; 905 int addRow2 = 0;
907 int addCol2 = 0; 906 int addCol2 = 0;
908 if (row == mSelEndT/7) { 907 if (row == mSelEndT/7) {
909 if ( rowModulo ) { 908 if ( rowModulo ) {
910 if ( row >= 6 - rowModulo ) 909 if ( row >= 6 - rowModulo )
911 addRow = row - 5 + rowModulo; 910 addRow = row - 5 + rowModulo;
912 } 911 }
913 if ( colModulo ) { 912 if ( colModulo ) {
914 int colt1 = mSelEndT%7; 913 int colt1 = mSelEndT%7;
915 //qDebug("colt1 %d ", colt1 ); 914 //qDebug("colt1 %d ", colt1 );
916 if ( colt1 >= 7 - colModulo ) 915 if ( colt1 >= 7 - colModulo )
917 addCol = colt1 - 7 + colModulo+1; 916 addCol = colt1 - 7 + colModulo+1;
918 int colt = mSelStartT%7; 917 int colt = mSelStartT%7;
919 if ( colt >= 7 - colModulo ) 918 if ( colt >= 7 - colModulo )
920 addCol2 = colt - 7 + colModulo; 919 addCol2 = colt - 7 + colModulo;
921 addCol -= addCol2; 920 addCol -= addCol2;
922 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); 921 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
923 } 922 }
924 // Single row selection 923 // Single row selection
925 //if ( row == 0) 924 //if ( row == 0)
926 // addRow = 1; 925 // addRow = 1;
927 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, 926 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
928 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); 927 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
929 } else { 928 } else {
930 // draw first row to the right 929 // draw first row to the right
931 if ( colModulo ) { 930 if ( colModulo ) {
932 if ( col >= 7 - colModulo ) 931 if ( col >= 7 - colModulo )
933 addCol2 = col - 7 + colModulo; 932 addCol2 = col - 7 + colModulo;
934 } 933 }
935 if ( rowModulo ) { 934 if ( rowModulo ) {
936 if ( row >= 6 - rowModulo ) 935 if ( row >= 6 - rowModulo )
937 addRow = row - 5 + rowModulo; 936 addRow = row - 5 + rowModulo;
938 } 937 }
939 //if ( row == 0) 938 //if ( row == 0)
940 // addRow = 1; 939 // addRow = 1;
941 int drawWid = width()-(col*dwidth+1+addCol2)-1; 940 int drawWid = width()-(col*dwidth+1+addCol2)-1;
942 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, 941 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid,
943 dheight+1, selcol); 942 dheight+1, selcol);
944 // draw full block till last line 943 // draw full block till last line
945 selh = mSelEndT/7-row; 944 selh = mSelEndT/7-row;
946 addRow = 0; 945 addRow = 0;
947 if ( rowModulo ) { 946 if ( rowModulo ) {
948 if ( mSelEndT/7 >= 6 - rowModulo ) 947 if ( mSelEndT/7 >= 6 - rowModulo )
949 addRow = mSelEndT/7 - 5 + rowModulo; 948 addRow = mSelEndT/7 - 5 + rowModulo;
950 } 949 }
951 //qDebug("%d %d %d ",selh, row, addRow ); 950 //qDebug("%d %d %d ",selh, row, addRow );
952 int addrow2 = addRow-selh+1; 951 int addrow2 = addRow-selh+1;
953 if ( addrow2 < 0 ) 952 if ( addrow2 < 0 )
954 addrow2 = 0; 953 addrow2 = 0;
955 if (selh > 1) { 954 if (selh > 1) {
956 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); 955 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
957 } 956 }
958 // draw last block from left to mSelEndT 957 // draw last block from left to mSelEndT
959 selw = mSelEndT-7*(mSelEndT/7)+1; 958 selw = mSelEndT-7*(mSelEndT/7)+1;
960 //qDebug("esl %d ",selw ); 959 //qDebug("esl %d ",selw );
961 int add = 0; 960 int add = 0;
962 if ( colModulo ) { 961 if ( colModulo ) {
963 add = 7 - colModulo; 962 add = 7 - colModulo;
964 if ( selw > add ) 963 if ( selw > add )
965 add = selw - add; 964 add = selw - add;
966 else 965 else
967 add = 0; 966 add = 0;
968 } 967 }
969 //qDebug("add %d ", add); 968 //qDebug("add %d ", add);
970 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, 969 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
971 selw*dwidth+add, dheight+1, selcol); 970 selw*dwidth+add, dheight+1, selcol);
972 } 971 }
973 } 972 }
974 } 973 }
975 974
976 // iterate over all days in the matrix and draw the day label in appropriate colors 975 // iterate over all days in the matrix and draw the day label in appropriate colors
977 QColor actcol = mDefaultTextColorShaded; 976 QColor actcol = mDefaultTextColorShaded;
978 p.setPen(actcol); 977 p.setPen(actcol);
979 QPen tmppen; 978 QPen tmppen;
980 for(int i = 0; i < NUMDAYS; i++) { 979 for(int i = 0; i < NUMDAYS; i++) {
981 row = i/7; 980 row = i/7;
982 col = isRTL ? 6-(i-row*7) : i-row*7; 981 col = isRTL ? 6-(i-row*7) : i-row*7;
983 982
984 // if it is the first day of a month switch color from normal to shaded and vice versa 983 // if it is the first day of a month switch color from normal to shaded and vice versa
985 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 984 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
986 if (actcol == mDefaultTextColorShaded) { 985 if (actcol == mDefaultTextColorShaded) {
987 actcol = mDefaultTextColor; 986 actcol = mDefaultTextColor;
988 } else { 987 } else {
989 actcol = mDefaultTextColorShaded; 988 actcol = mDefaultTextColorShaded;
990 } 989 }
991 p.setPen(actcol); 990 p.setPen(actcol);
992 } 991 }
993 if (actcol == mDefaultTextColorShaded) { 992 if (actcol == mDefaultTextColorShaded) {
994 if ( ! mouseDown ) { 993 if ( ! mouseDown ) {
995 continue; 994 continue;
996 } 995 }
997 } 996 }
998 //Reset pen color after selected days block 997 //Reset pen color after selected days block
999 if (i == mSelEndT+1) { 998 if (i == mSelEndT+1) {
1000 p.setPen(actcol); 999 p.setPen(actcol);
1001 } 1000 }
1002 1001
1003 // if today then draw rectangle around day 1002 // if today then draw rectangle around day
1004 if (today == i) { 1003 if (today == i) {
1005 tmppen = p.pen(); 1004 tmppen = p.pen();
1006 QPen mTodayPen(p.pen()); 1005 QPen mTodayPen(p.pen());
1007 if ( daysize.width() < 20 ) 1006 if ( daysize.width() < 20 )
1008 mTodayPen.setWidth(1); 1007 mTodayPen.setWidth(1);
1009 else 1008 else
1010 mTodayPen.setWidth(mTodayMarginWidth); 1009 mTodayPen.setWidth(mTodayMarginWidth);
1011 //draw red rectangle for holidays 1010 //draw red rectangle for holidays
1012 if (pDays.testBit(i)) { 1011 if (pDays.testBit(i)) {
1013 if (actcol == mDefaultTextColor) { 1012 if (actcol == mDefaultTextColor) {
1014 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 1013 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
1015 } else { 1014 } else {
1016 mTodayPen.setColor(mHolidayColorShaded); 1015 mTodayPen.setColor(mHolidayColorShaded);
1017 } 1016 }
1018 } 1017 }
1019 //draw gray rectangle for today if in selection 1018 //draw gray rectangle for today if in selection
1020 if (i >= mSelStartT && i <= mSelEndT) { 1019 if (i >= mSelStartT && i <= mSelEndT) {
1021 QColor grey("grey"); 1020 QColor grey("grey");
1022 mTodayPen.setColor(grey); 1021 mTodayPen.setColor(grey);
1023 } 1022 }
1024 p.setPen(mTodayPen); 1023 p.setPen(mTodayPen);
1025 1024
1026 1025
1027 int addCol = 0; 1026 int addCol = 0;
1028 int addRow = 0; 1027 int addRow = 0;
1029 if (rowModulo) { 1028 if (rowModulo) {
1030 if ( row >= 6 - rowModulo ) 1029 if ( row >= 6 - rowModulo )
1031 addRow = row - 5 + rowModulo; 1030 addRow = row - 5 + rowModulo;
1032 } 1031 }
1033 if ( colModulo ) { 1032 if ( colModulo ) {
1034 if ( col >= 7 - colModulo ) 1033 if ( col >= 7 - colModulo )
1035 addCol = col - 6 + colModulo-1; 1034 addCol = col - 6 + colModulo-1;
1036 } 1035 }
1037 1036
1038 addCol += 1; 1037 addCol += 1;
1039 if ( row == 0 ) 1038 if ( row == 0 )
1040 addRow = 1; 1039 addRow = 1;
1041 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); 1040 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1);
1042 p.setPen(tmppen); 1041 p.setPen(tmppen);
1043 } 1042 }
1044 1043
1045 // if any events are on that day then draw it using a bold font 1044 // if any events are on that day then draw it using a bold font
1046 if ( eDays.testBit(i) ) { 1045 if ( eDays.testBit(i) ) {
1047 QFont myFont = font(); 1046 QFont myFont = font();
1048 myFont.setBold(true); 1047 myFont.setBold(true);
1049 p.setFont(myFont); 1048 p.setFont(myFont);
1050 } 1049 }
1051 1050
1052 // if it is a holiday then use the default holiday color 1051 // if it is a holiday then use the default holiday color
1053 if ( pDays.testBit(i)) { 1052 if ( pDays.testBit(i)) {
1054 if ( bDays.testBit(i) ) { 1053 if ( bDays.testBit(i) ) {
1055 if ( hDays.testBit(i) ) 1054 if ( hDays.testBit(i) )
1056 p.setPen(QColor(Qt::green)); 1055 p.setPen(QColor(Qt::green));
1057 else 1056 else
1058 p.setPen(QColor(Qt::green).dark()); 1057 p.setPen(QColor(Qt::green).dark());
1059 } else { 1058 } else {
1060 if (actcol == mDefaultTextColor ) { 1059 if (actcol == mDefaultTextColor ) {
1061 p.setPen(KOPrefs::instance()->mHolidayColor); 1060 p.setPen(KOPrefs::instance()->mHolidayColor);
1062 } else { 1061 } else {
1063 p.setPen(mHolidayColorShaded); 1062 p.setPen(mHolidayColorShaded);
1064 } 1063 }
1065 } 1064 }
1066 } 1065 }
1067 1066
1068 // draw selected days with special color 1067 // draw selected days with special color
1069 // DO NOT specially highlight holidays in selection ! 1068 // DO NOT specially highlight holidays in selection !
1070 if (i >= mSelStartT && i <= mSelEndT) { 1069 if (i >= mSelStartT && i <= mSelEndT) {
1071 ;//p.setPen(mSelectedDaysColor); 1070 ;//p.setPen(mSelectedDaysColor);
1072 } 1071 }
1073 1072
1074 int addCol = 0; 1073 int addCol = 0;
1075 int addRow = 0; 1074 int addRow = 0;
1076 if ( colModulo ) { 1075 if ( colModulo ) {
1077 if ( col >= 7 - colModulo ) 1076 if ( col >= 7 - colModulo )
1078 addCol = col - 7 + colModulo; 1077 addCol = col - 7 + colModulo;
1079 } 1078 }
1080 if ( rowModulo ) { 1079 if ( rowModulo ) {
1081 if ( row >= 6 - rowModulo ) 1080 if ( row >= 6 - rowModulo )
1082 addRow = row - 5 + rowModulo; 1081 addRow = row - 5 + rowModulo;
1083 } 1082 }
1084 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 1083 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
1085 ++addCol;//++addCol; 1084 ++addCol;//++addCol;
1086 if ( row == 0) 1085 if ( row == 0)
1087 addRow = 1; 1086 addRow = 1;
1088 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 1087 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
1089 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 1088 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
1090 1089
1091 // reset color to actual color 1090 // reset color to actual color
1092 if (pDays.testBit(i)) { 1091 if (pDays.testBit(i)) {
1093 p.setPen(actcol); 1092 p.setPen(actcol);
1094 } 1093 }
1095 // reset bold font to plain font 1094 // reset bold font to plain font
1096 if ( eDays.testBit(i)) { 1095 if ( eDays.testBit(i)) {
1097 QFont myFont = font(); 1096 QFont myFont = font();
1098 myFont.setBold(false); 1097 myFont.setBold(false);
1099 p.setFont(myFont); 1098 p.setFont(myFont);
1100 } 1099 }
1101 } 1100 }
1102 } else { 1101 } else {
1103 //qDebug("NO redraw "); 1102 //qDebug("NO redraw ");
1104 } 1103 }
1105 1104
1106 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP); 1105 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP);
1107 mRedrawNeeded = false; 1106 mRedrawNeeded = false;
1108} 1107}
1109 1108
1110// ---------------------------------------------------------------------------- 1109// ----------------------------------------------------------------------------
1111// R E SI Z E E V E N T H A N D L I N G 1110// R E SI Z E E V E N T H A N D L I N G
1112// ---------------------------------------------------------------------------- 1111// ----------------------------------------------------------------------------
1113 1112
1114void KODayMatrix::resizeEvent(QResizeEvent *) 1113void KODayMatrix::resizeEvent(QResizeEvent *)
1115{ 1114{
1116 QRect sz = frameRect(); 1115 QRect sz = frameRect();
1117 daysize.setHeight(sz.height()*7 / NUMDAYS); 1116 daysize.setHeight(sz.height()*7 / NUMDAYS);
1118 daysize.setWidth(sz.width() / 7); 1117 daysize.setWidth(sz.width() / 7);
1119} 1118}
1120 1119
1121QSize KODayMatrix::sizeHint() const 1120QSize KODayMatrix::sizeHint() const
1122{ 1121{
1123 1122
1124 QFontMetrics fm ( font() ); 1123 QFontMetrics fm ( font() );
1125 int wid = fm.width( "30") *7+3; 1124 int wid = fm.width( "30") *7+3;
1126 int hei = fm.height() * 6+3; 1125 int hei = fm.height() * 6+3;
1127 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); 1126 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
1128 return QSize ( wid, hei ); 1127 return QSize ( wid, hei );
1129 1128
1130} 1129}
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index 9df76e7..0045b7f 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -1,518 +1,518 @@
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 <qwidget.h> 24#include <qwidget.h>
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qfile.h> 33#include <qfile.h>
34 34
35 35
36#include <kglobal.h> 36#include <kglobal.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kiconloader.h> 39#include <kiconloader.h>
40#include <kmessagebox.h> 40#include <kmessagebox.h>
41#include <kfiledialog.h> 41#include <kfiledialog.h>
42#include <kstandarddirs.h> 42#include <kstandarddirs.h>
43 43
44#include <libkcal/todo.h> 44#include <libkcal/todo.h>
45#include <libkcal/event.h> 45#include <libkcal/event.h>
46#include <libkdepim/categoryselectdialog.h> 46#include <libkdepim/categoryselectdialog.h>
47#include <libkdepim/kdateedit.h> 47#include <libkdepim/kdateedit.h>
48 48
49#include "koprefs.h" 49#include "koprefs.h"
50#include "koglobals.h" 50#include "koglobals.h"
51 51
52#include "koeditorgeneral.h" 52#include "koeditorgeneral.h"
53#include "kolocationbox.h" 53#include "kolocationbox.h"
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#else 56#else
57#include <qapplication.h> 57#include <qapplication.h>
58#endif 58#endif
59 59
60KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : 60KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
61 QObject( parent, name) 61 QObject( parent, name)
62{ 62{
63 mNextFocus = 0; 63 mNextFocus = 0;
64} 64}
65 65
66KOEditorGeneral::~KOEditorGeneral() 66KOEditorGeneral::~KOEditorGeneral()
67{ 67{
68} 68}
69 69
70void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) 70void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
71{ 71{
72 QGridLayout *headerLayout = new QGridLayout(topLayout); 72 QGridLayout *headerLayout = new QGridLayout(topLayout);
73 73
74#if 0 74#if 0
75 mOwnerLabel = new QLabel(i18n("Owner:"),parent); 75 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
76 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); 76 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
77#endif 77#endif
78 78
79 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); 79 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
80 headerLayout->addWidget(summaryLabel,1,0); 80 headerLayout->addWidget(summaryLabel,1,0);
81 81
82 mSummaryEdit = new KOLocationBox(TRUE,parent, 10); 82 mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
83 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 83 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
84 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); 84 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
85 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); 85 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
86 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; 86 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
87 if ( QApplication::desktop()->width() > 320 ) 87 if ( QApplication::desktop()->width() > 320 )
88 mSummaryEdit->setMaximumHeight( hei +6 ); 88 mSummaryEdit->setMaximumHeight( hei +6 );
89 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); 89 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding );
90 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } 90 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
91 // mSummaryEdit = new QLineEdit(parent); 91 // mSummaryEdit = new QLineEdit(parent);
92 headerLayout->addWidget(mSummaryEdit,1,1); 92 headerLayout->addWidget(mSummaryEdit,1,1);
93 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 93 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
94 94
95 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 95 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
96 headerLayout->addWidget(locationLabel,2,0); 96 headerLayout->addWidget(locationLabel,2,0);
97 97
98 mLocationEdit = new KOLocationBox(TRUE,parent,10); 98 mLocationEdit = new KOLocationBox(TRUE,parent,10);
99 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 99 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
100 if ( QApplication::desktop()->width() > 320 ) 100 if ( QApplication::desktop()->width() > 320 )
101 mLocationEdit->setMaximumHeight( hei + 6); 101 mLocationEdit->setMaximumHeight( hei + 6);
102 102
103 // mLocationEdit = new QLineEdit(parent); 103 // mLocationEdit = new QLineEdit(parent);
104 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 104 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
105 headerLayout->addWidget(mLocationEdit,2,1); 105 headerLayout->addWidget(mLocationEdit,2,1);
106 headerLayout->setColStretch( 1, 10); 106 headerLayout->setColStretch( 1, 10);
107} 107}
108void KOEditorGeneral::setFocusOn( int i ) 108void KOEditorGeneral::setFocusOn( int i )
109{ 109{
110 mNextFocus = i; 110 mNextFocus = i;
111 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); 111 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() ));
112} 112}
113void KOEditorGeneral::slotSetFocusOn() 113void KOEditorGeneral::slotSetFocusOn()
114{ 114{
115 mNextFocus; 115 mNextFocus;
116 if ( mNextFocus == 1 ) { 116 if ( mNextFocus == 1 ) {
117 mDescriptionEdit->setFocus(); 117 mDescriptionEdit->setFocus();
118 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); 118 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
119 } 119 }
120 if ( mNextFocus == 2 ) { 120 if ( mNextFocus == 2 ) {
121 mSummaryEdit->setFocus(); 121 mSummaryEdit->setFocus();
122 } 122 }
123} 123}
124void KOEditorGeneral::editCategories() 124void KOEditorGeneral::editCategories()
125{ 125{
126 // qDebug("KOEditorGeneral::editCategories() "); 126 // qDebug("KOEditorGeneral::editCategories() ");
127 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 127 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
128 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 128 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
129 //KOGlobals::fitDialogToScreen( csd ); 129 //KOGlobals::fitDialogToScreen( csd );
130 csd->setColorEnabled(); 130 csd->setColorEnabled();
131 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 131 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
132 csd->exec(); 132 csd->exec();
133 delete csd; 133 delete csd;
134} 134}
135void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 135void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
136{ 136{
137 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 137 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
138 138
139 mCategoriesButton = new QPushButton(parent); 139 mCategoriesButton = new QPushButton(parent);
140 mCategoriesButton->setText(i18n("Categories...")); 140 mCategoriesButton->setText(i18n("Categories..."));
141 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 141 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
142 categoriesLayout->addWidget(mCategoriesButton); 142 categoriesLayout->addWidget(mCategoriesButton);
143 143
144 mCategoriesLabel = new QLabel(parent); 144 mCategoriesLabel = new QLabel(parent);
145 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 145 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
146 categoriesLayout->addWidget(mCategoriesLabel,1); 146 categoriesLayout->addWidget(mCategoriesLabel,1);
147} 147}
148 148
149void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 149void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
150{ 150{
151 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 151 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
152 152
153 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 153 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
154 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 154 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
155 secrecyLayout->addWidget(mCancelBox); 155 secrecyLayout->addWidget(mCancelBox);
156 secrecyLayout->addWidget(secrecyLabel); 156 secrecyLayout->addWidget(secrecyLabel);
157 157
158 mSecrecyCombo = new QComboBox(parent); 158 mSecrecyCombo = new QComboBox(parent);
159 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 159 mSecrecyCombo->insertStringList(Incidence::secrecyList());
160 secrecyLayout->addWidget(mSecrecyCombo); 160 secrecyLayout->addWidget(mSecrecyCombo);
161} 161}
162 162
163void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) 163void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
164{ 164{
165 mDescriptionEdit = new KTextEdit(parent); 165 mDescriptionEdit = new KTextEdit(parent);
166 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); 166 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
167 mDescriptionEdit->append(""); 167 mDescriptionEdit->append("");
168 mDescriptionEdit->setReadOnly(false); 168 mDescriptionEdit->setReadOnly(false);
169 mDescriptionEdit->setOverwriteMode(false); 169 mDescriptionEdit->setOverwriteMode(false);
170 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 170 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
171 topLayout->addWidget(mDescriptionEdit); 171 topLayout->addWidget(mDescriptionEdit);
172#ifndef DESKTOP_VERSION 172#ifndef DESKTOP_VERSION
173 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); 173 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
174#endif 174#endif
175 175
176} 176}
177 177
178void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 178void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
179{ 179{
180 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); 180 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
181 181
182 //mAlarmBell = new QLabel(parent); 182 //mAlarmBell = new QLabel(parent);
183 //mAlarmBell->setPixmap(SmallIcon("bell")); 183 //mAlarmBell->setPixmap(SmallIcon("bell"));
184 //alarmLayout->addWidget(mAlarmBell); 184 //alarmLayout->addWidget(mAlarmBell);
185 if ( QApplication::desktop()->width() < 320 ) 185 if ( QApplication::desktop()->width() < 320 )
186 mAlarmButton = new QCheckBox(i18n("Rem."),parent); 186 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
187 else 187 else
188 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); 188 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
189 189
190 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); 190 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
191 alarmLayout->addWidget(mAlarmButton); 191 alarmLayout->addWidget(mAlarmButton);
192 192
193 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 193 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
194 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); 194 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus );
195 alarmLayout->addWidget(mAlarmTimeEdit); 195 alarmLayout->addWidget(mAlarmTimeEdit);
196 mAlarmIncrCombo = new QComboBox(false, parent); 196 mAlarmIncrCombo = new QComboBox(false, parent);
197 if ( QApplication::desktop()->width() < 320 ) { 197 if ( QApplication::desktop()->width() < 320 ) {
198 mAlarmIncrCombo->insertItem(i18n("min")); 198 mAlarmIncrCombo->insertItem(i18n("min"));
199 mAlarmIncrCombo->insertItem(i18n("hou")); 199 mAlarmIncrCombo->insertItem(i18n("hou"));
200 mAlarmIncrCombo->insertItem(i18n("day")); 200 mAlarmIncrCombo->insertItem(i18n("day"));
201 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); 201 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
202 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); 202 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
203 } else { 203 } else {
204 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 204 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
205 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 205 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
206 mAlarmIncrCombo->insertItem(i18n("day(s)")); 206 mAlarmIncrCombo->insertItem(i18n("day(s)"));
207 } 207 }
208 208
209 // mAlarmIncrCombo->setMinimumHeight(20); 209 // mAlarmIncrCombo->setMinimumHeight(20);
210 alarmLayout->addWidget(mAlarmIncrCombo); 210 alarmLayout->addWidget(mAlarmIncrCombo);
211 mAlarmSoundButton = new QPushButton(parent); 211 mAlarmSoundButton = new QPushButton(parent);
212 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 212 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
213 mAlarmSoundButton->setToggleButton(true); 213 mAlarmSoundButton->setToggleButton(true);
214 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 214 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
215 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 215 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
216 alarmLayout->addWidget(mAlarmSoundButton); 216 alarmLayout->addWidget(mAlarmSoundButton);
217 217
218 mAlarmProgramButton = new QPushButton(parent); 218 mAlarmProgramButton = new QPushButton(parent);
219 mAlarmProgramButton->setPixmap(SmallIcon("run")); 219 mAlarmProgramButton->setPixmap(SmallIcon("run"));
220 mAlarmProgramButton->setToggleButton(true); 220 mAlarmProgramButton->setToggleButton(true);
221 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 221 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
222 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 222 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
223 alarmLayout->addWidget(mAlarmProgramButton); 223 alarmLayout->addWidget(mAlarmProgramButton);
224 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 224 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
225 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 225 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
226 // if ( KOPrefs::instance()->mCompactDialogs ) { 226 // if ( KOPrefs::instance()->mCompactDialogs ) {
227 // mAlarmSoundButton->hide(); 227 // mAlarmSoundButton->hide();
228 // mAlarmProgramButton->hide(); 228 // mAlarmProgramButton->hide();
229 // } 229 // }
230} 230}
231 231
232void KOEditorGeneral::pickAlarmSound() 232void KOEditorGeneral::pickAlarmSound()
233{ 233{
234 234
235 qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); 235 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() );
236 236
237 bool oldState = mAlarmSoundButton->isOn(); 237 bool oldState = mAlarmSoundButton->isOn();
238 238
239 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 239 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
240 i18n("*.wav|Wav Files"), 0)); 240 i18n("*.wav|Wav Files"), 0));
241 if (!fileName.isEmpty()) { 241 if (!fileName.isEmpty()) {
242 mAlarmSound = fileName; 242 mAlarmSound = fileName;
243 QToolTip::remove(mAlarmSoundButton); 243 QToolTip::remove(mAlarmSoundButton);
244 QString dispStr = i18n("Playing '%1'").arg(fileName); 244 QString dispStr = i18n("Playing '%1'").arg(fileName);
245 QToolTip::add(mAlarmSoundButton, dispStr); 245 QToolTip::add(mAlarmSoundButton, dispStr);
246 mAlarmProgramButton->setOn(false); 246 mAlarmProgramButton->setOn(false);
247 mAlarmSoundButton->setOn(true); 247 mAlarmSoundButton->setOn(true);
248 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 248 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
249 } else { 249 } else {
250 mAlarmProgramButton->setOn(oldState); 250 mAlarmProgramButton->setOn(oldState);
251 mAlarmSoundButton->setOn(!oldState); 251 mAlarmSoundButton->setOn(!oldState);
252 252
253 253
254 } 254 }
255 255
256 if (mAlarmProgramButton->isOn()) 256 if (mAlarmProgramButton->isOn())
257 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 257 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
258 if ( mAlarmSoundButton->isOn()) 258 if ( mAlarmSoundButton->isOn())
259 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 259 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
260 260
261} 261}
262 262
263void KOEditorGeneral::pickAlarmProgram() 263void KOEditorGeneral::pickAlarmProgram()
264{ 264{
265 bool oldState = mAlarmProgramButton->isOn(); 265 bool oldState = mAlarmProgramButton->isOn();
266 266
267 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); 267 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0));
268 if (!fileName.isEmpty()) { 268 if (!fileName.isEmpty()) {
269 mAlarmProgram = fileName; 269 mAlarmProgram = fileName;
270 QToolTip::remove(mAlarmProgramButton); 270 QToolTip::remove(mAlarmProgramButton);
271 QString dispStr = i18n("Running '%1'").arg(fileName); 271 QString dispStr = i18n("Running '%1'").arg(fileName);
272 QToolTip::add(mAlarmProgramButton, dispStr); 272 QToolTip::add(mAlarmProgramButton, dispStr);
273 mAlarmSoundButton->setOn(false); 273 mAlarmSoundButton->setOn(false);
274 mAlarmProgramButton->setOn(true); 274 mAlarmProgramButton->setOn(true);
275 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 275 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
276 } else { 276 } else {
277 mAlarmProgramButton->setOn(!oldState); 277 mAlarmProgramButton->setOn(!oldState);
278 mAlarmSoundButton->setOn(oldState); 278 mAlarmSoundButton->setOn(oldState);
279 } 279 }
280 280
281 if (mAlarmProgramButton->isOn()) 281 if (mAlarmProgramButton->isOn())
282 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 282 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
283 if ( mAlarmSoundButton->isOn()) 283 if ( mAlarmSoundButton->isOn())
284 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 284 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
285 285
286} 286}
287 287
288 288
289QString KOEditorGeneral::getFittingPath( const QString s ) 289QString KOEditorGeneral::getFittingPath( const QString s )
290{ 290{
291 int maxlen = 50; 291 int maxlen = 50;
292 if ( QApplication::desktop()->width() < 640 ) { 292 if ( QApplication::desktop()->width() < 640 ) {
293 if ( QApplication::desktop()->width() < 320 ) 293 if ( QApplication::desktop()->width() < 320 )
294 maxlen = 22; 294 maxlen = 22;
295 else 295 else
296 maxlen = 35; 296 maxlen = 35;
297 } 297 }
298 if ( s.length() > maxlen ) { 298 if ( s.length() > maxlen ) {
299 return "..."+s.right(maxlen -3); 299 return "..."+s.right(maxlen -3);
300 } 300 }
301 return s; 301 return s;
302} 302}
303 303
304void KOEditorGeneral::enableAlarmEdit(bool enable) 304void KOEditorGeneral::enableAlarmEdit(bool enable)
305{ 305{
306 if ( enable ) { 306 if ( enable ) {
307 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { 307 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
308 mAlarmSoundButton->setOn( true ); 308 mAlarmSoundButton->setOn( true );
309 if ( mAlarmSound.isEmpty() ) 309 if ( mAlarmSound.isEmpty() )
310 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 310 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
311 else { 311 else {
312 if ( ! QFile::exists( mAlarmSound ) ) 312 if ( ! QFile::exists( mAlarmSound ) )
313 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 313 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
314 } 314 }
315 } 315 }
316 } 316 }
317 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); 317 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage);
318 mAlarmTimeEdit->setEnabled(enable); 318 mAlarmTimeEdit->setEnabled(enable);
319 mAlarmSoundButton->setEnabled(enable); 319 mAlarmSoundButton->setEnabled(enable);
320 mAlarmProgramButton->setEnabled(enable); 320 mAlarmProgramButton->setEnabled(enable);
321 mAlarmIncrCombo->setEnabled(enable); 321 mAlarmIncrCombo->setEnabled(enable);
322} 322}
323 323
324void KOEditorGeneral::disableAlarmEdit(bool disable) 324void KOEditorGeneral::disableAlarmEdit(bool disable)
325{ 325{
326 enableAlarmEdit( !disable ); 326 enableAlarmEdit( !disable );
327} 327}
328 328
329void KOEditorGeneral::enableAlarm( bool enable ) 329void KOEditorGeneral::enableAlarm( bool enable )
330{ 330{
331 enableAlarmEdit( enable ); 331 enableAlarmEdit( enable );
332} 332}
333 333
334void KOEditorGeneral::alarmDisable(bool disable) 334void KOEditorGeneral::alarmDisable(bool disable)
335{ 335{
336 if (!disable) { 336 if (!disable) {
337 //mAlarmBell->setEnabled(true); 337 //mAlarmBell->setEnabled(true);
338 mAlarmButton->setEnabled(true); 338 mAlarmButton->setEnabled(true);
339 } else { 339 } else {
340 //mAlarmBell->setEnabled(false); 340 //mAlarmBell->setEnabled(false);
341 mAlarmButton->setEnabled(false); 341 mAlarmButton->setEnabled(false);
342 mAlarmButton->setChecked(false); 342 mAlarmButton->setChecked(false);
343 mAlarmTimeEdit->setEnabled(false); 343 mAlarmTimeEdit->setEnabled(false);
344 mAlarmSoundButton->setEnabled(false); 344 mAlarmSoundButton->setEnabled(false);
345 mAlarmProgramButton->setEnabled(false); 345 mAlarmProgramButton->setEnabled(false);
346 mAlarmIncrCombo->setEnabled(false); 346 mAlarmIncrCombo->setEnabled(false);
347 } 347 }
348} 348}
349 349
350void KOEditorGeneral::setCategories(const QString &str) 350void KOEditorGeneral::setCategories(const QString &str)
351{ 351{
352 mCategoriesLabel->setText(str); 352 mCategoriesLabel->setText(str);
353} 353}
354 354
355void KOEditorGeneral::setDefaults(bool allDay) 355void KOEditorGeneral::setDefaults(bool allDay)
356{ 356{
357#if 0 357#if 0
358 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); 358 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
359#endif 359#endif
360 360
361 mAlarmMessage = i18n("Edit new item"); 361 mAlarmMessage = i18n("Edit new item");
362 enableAlarmEdit( !allDay ); 362 enableAlarmEdit( !allDay );
363 363
364 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 364 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
365 int alarmTime; 365 int alarmTime;
366 int a[] = { 1,5,10,15,30,60,180, 1440 }; 366 int a[] = { 1,5,10,15,30,60,180, 1440 };
367 int index = KOPrefs::instance()->mAlarmTime; 367 int index = KOPrefs::instance()->mAlarmTime;
368 if (index < 0 || index > 7) { 368 if (index < 0 || index > 7) {
369 alarmTime = 15; 369 alarmTime = 15;
370 } else { 370 } else {
371 alarmTime = a[index]; 371 alarmTime = a[index];
372 } 372 }
373 mAlarmButton ->setChecked( false ); 373 mAlarmButton ->setChecked( false );
374 mAlarmTimeEdit->setValue(alarmTime); 374 mAlarmTimeEdit->setValue(alarmTime);
375 mAlarmIncrCombo->setCurrentItem(0); 375 mAlarmIncrCombo->setCurrentItem(0);
376 enableAlarmEdit( false ); 376 enableAlarmEdit( false );
377 //alarmDisable (false); 377 //alarmDisable (false);
378 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); 378 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
379 mCancelBox->setChecked( false ); 379 mCancelBox->setChecked( false );
380 mSummaryEdit->setEditText(""); 380 mSummaryEdit->setEditText("");
381 mLocationEdit->setEditText(""); 381 mLocationEdit->setEditText("");
382 mDescriptionEdit->setText(""); 382 mDescriptionEdit->setText("");
383 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 383 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
384 setCategories(""); 384 setCategories("");
385} 385}
386void KOEditorGeneral::setSecrecy( int num ) 386void KOEditorGeneral::setSecrecy( int num )
387{ 387{
388 mSecrecyCombo->setCurrentItem(num); 388 mSecrecyCombo->setCurrentItem(num);
389} 389}
390void KOEditorGeneral::readIncidence(Incidence *event) 390void KOEditorGeneral::readIncidence(Incidence *event)
391{ 391{
392 392
393 mAlarmMessage = event->summary(); 393 mAlarmMessage = event->summary();
394 if ( ! event->location().isEmpty() ) 394 if ( ! event->location().isEmpty() )
395 mAlarmMessage += " ("+event->location()+")"; 395 mAlarmMessage += " ("+event->location()+")";
396 mAlarmIncrCombo->setCurrentItem(0); 396 mAlarmIncrCombo->setCurrentItem(0);
397 mSummaryEdit->setEditText(event->summary()); 397 mSummaryEdit->setEditText(event->summary());
398 mLocationEdit->setEditText(event->location()); 398 mLocationEdit->setEditText(event->location());
399 mDescriptionEdit->setText(event->description()); 399 mDescriptionEdit->setText(event->description());
400 400
401#if 0 401#if 0
402 // organizer information 402 // organizer information
403 mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); 403 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
404#endif 404#endif
405 405
406 enableAlarmEdit( event->isAlarmEnabled() ); 406 enableAlarmEdit( event->isAlarmEnabled() );
407 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); 407 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
408 if(!event->isAlarmEnabled()) { 408 if(!event->isAlarmEnabled()) {
409 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 409 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
410 int alarmTime; 410 int alarmTime;
411 int a[] = { 1,5,10,15,30,60,180, 1440 }; 411 int a[] = { 1,5,10,15,30,60,180, 1440 };
412 int index = KOPrefs::instance()->mAlarmTime; 412 int index = KOPrefs::instance()->mAlarmTime;
413 if (index < 0 || index > 7) { 413 if (index < 0 || index > 7) {
414 alarmTime = 15; 414 alarmTime = 15;
415 } else { 415 } else {
416 alarmTime = a[index]; 416 alarmTime = a[index];
417 } 417 }
418 mAlarmTimeEdit->setValue(alarmTime); 418 mAlarmTimeEdit->setValue(alarmTime);
419 } 419 }
420 mAlarmButton->setChecked( event->isAlarmEnabled() ); 420 mAlarmButton->setChecked( event->isAlarmEnabled() );
421 mSecrecyCombo->setCurrentItem(event->secrecy()); 421 mSecrecyCombo->setCurrentItem(event->secrecy());
422 mCancelBox->setChecked( event->cancelled() ); 422 mCancelBox->setChecked( event->cancelled() );
423 mAlarmProgramButton->setOn(false); 423 mAlarmProgramButton->setOn(false);
424 mAlarmSoundButton->setOn(false); 424 mAlarmSoundButton->setOn(false);
425 425
426 // set up alarm stuff 426 // set up alarm stuff
427 QPtrList<Alarm> alarms = event->alarms(); 427 QPtrList<Alarm> alarms = event->alarms();
428 Alarm* alarm; 428 Alarm* alarm;
429 mAlarmIncrCombo->setCurrentItem(0); 429 mAlarmIncrCombo->setCurrentItem(0);
430 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { 430 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
431 int offset; 431 int offset;
432 if ( alarm->hasTime() ) { 432 if ( alarm->hasTime() ) {
433 QDateTime t = alarm->time(); 433 QDateTime t = alarm->time();
434 offset = event->dtStart().secsTo( t ); 434 offset = event->dtStart().secsTo( t );
435 } else { 435 } else {
436 offset = alarm->startOffset().asSeconds(); 436 offset = alarm->startOffset().asSeconds();
437 } 437 }
438 if ( offset != 0 ) { 438 if ( offset != 0 ) {
439 offset = offset / -60; // make minutes 439 offset = offset / -60; // make minutes
440 if (offset % 60 == 0) { // divides evenly into hours? 440 if (offset % 60 == 0) { // divides evenly into hours?
441 offset = offset / 60; 441 offset = offset / 60;
442 mAlarmIncrCombo->setCurrentItem(1); 442 mAlarmIncrCombo->setCurrentItem(1);
443 if (offset % 24 == 0) { // divides evenly into days? 443 if (offset % 24 == 0) { // divides evenly into days?
444 offset = offset / 24; 444 offset = offset / 24;
445 mAlarmIncrCombo->setCurrentItem(2); 445 mAlarmIncrCombo->setCurrentItem(2);
446 } 446 }
447 } 447 }
448 } 448 }
449 mAlarmTimeEdit->setValue( offset ); 449 mAlarmTimeEdit->setValue( offset );
450 if (alarm->type() == Alarm::Procedure) { 450 if (alarm->type() == Alarm::Procedure) {
451 451
452 mAlarmProgram = alarm->programFile(); 452 mAlarmProgram = alarm->programFile();
453 mAlarmProgramButton->setOn(true); 453 mAlarmProgramButton->setOn(true);
454 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); 454 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram);
455 QToolTip::add(mAlarmProgramButton, dispStr); 455 QToolTip::add(mAlarmProgramButton, dispStr);
456 } 456 }
457 else if (alarm->type() == Alarm::Audio) { 457 else if (alarm->type() == Alarm::Audio) {
458 mAlarmSound = alarm->audioFile(); 458 mAlarmSound = alarm->audioFile();
459 if ( ! QFile::exists( mAlarmSound ) ) 459 if ( ! QFile::exists( mAlarmSound ) )
460 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 460 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
461 mAlarmSoundButton->setOn(true); 461 mAlarmSoundButton->setOn(true);
462 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); 462 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound);
463 QToolTip::add(mAlarmSoundButton, dispStr); 463 QToolTip::add(mAlarmSoundButton, dispStr);
464 } 464 }
465 mAlarmButton->setChecked(alarm->enabled()); 465 mAlarmButton->setChecked(alarm->enabled());
466 enableAlarmEdit( alarm->enabled() ); 466 enableAlarmEdit( alarm->enabled() );
467 //qDebug("nableAlarmEdit( alarm->enabled() )********* "); 467 //qDebug("nableAlarmEdit( alarm->enabled() )********* ");
468 // TODO: Deal with multiple alarms 468 // TODO: Deal with multiple alarms
469 break; // For now, stop after the first alarm 469 break; // For now, stop after the first alarm
470 } 470 }
471 471
472 setCategories(event->categoriesStr()); 472 setCategories(event->categoriesStr());
473} 473}
474 474
475void KOEditorGeneral::writeIncidence(Incidence *event) 475void KOEditorGeneral::writeIncidence(Incidence *event)
476{ 476{
477 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; 477 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
478 mLocationEdit->save(KOLocationBox::LOCATION); 478 mLocationEdit->save(KOLocationBox::LOCATION);
479 event->setSummary(mSummaryEdit->currentText()); 479 event->setSummary(mSummaryEdit->currentText());
480 event->setLocation(mLocationEdit->currentText()); 480 event->setLocation(mLocationEdit->currentText());
481 event->setDescription(mDescriptionEdit->text()); 481 event->setDescription(mDescriptionEdit->text());
482 event->setCategories(mCategoriesLabel->text()); 482 event->setCategories(mCategoriesLabel->text());
483 event->setSecrecy(mSecrecyCombo->currentItem()); 483 event->setSecrecy(mSecrecyCombo->currentItem());
484 event->setCancelled(mCancelBox->isChecked() );; 484 event->setCancelled(mCancelBox->isChecked() );;
485 // alarm stuff 485 // alarm stuff
486 if (mAlarmButton->isChecked()) { 486 if (mAlarmButton->isChecked()) {
487 if (event->alarms().count() == 0) 487 if (event->alarms().count() == 0)
488 event->newAlarm(); 488 event->newAlarm();
489 QPtrList<Alarm> alarms = event->alarms(); 489 QPtrList<Alarm> alarms = event->alarms();
490 Alarm *alarm; 490 Alarm *alarm;
491 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 491 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
492 alarm->setEnabled(true); 492 alarm->setEnabled(true);
493 int j = mAlarmTimeEdit->value()* -60; 493 int j = mAlarmTimeEdit->value()* -60;
494 if (mAlarmIncrCombo->currentItem() == 1) 494 if (mAlarmIncrCombo->currentItem() == 1)
495 j = j * 60; 495 j = j * 60;
496 else if (mAlarmIncrCombo->currentItem() == 2) 496 else if (mAlarmIncrCombo->currentItem() == 2)
497 j = j * (60 * 24); 497 j = j * (60 * 24);
498 alarm->setStartOffset( j ); 498 alarm->setStartOffset( j );
499 499
500 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { 500 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
501 alarm->setProcedureAlarm(mAlarmProgram); 501 alarm->setProcedureAlarm(mAlarmProgram);
502 } 502 }
503 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 503 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
504 alarm->setAudioAlarm(mAlarmSound); 504 alarm->setAudioAlarm(mAlarmSound);
505 else 505 else
506 alarm->setType(Alarm::Invalid); 506 alarm->setType(Alarm::Invalid);
507 //alarm->setAudioAlarm("default"); 507 //alarm->setAudioAlarm("default");
508 // TODO: Deal with multiple alarms 508 // TODO: Deal with multiple alarms
509 break; // For now, stop after the first alarm 509 break; // For now, stop after the first alarm
510 } 510 }
511 } else { 511 } else {
512 Alarm* alarm = event->alarms().first(); 512 Alarm* alarm = event->alarms().first();
513 if ( alarm ) { 513 if ( alarm ) {
514 alarm->setEnabled(false); 514 alarm->setEnabled(false);
515 alarm->setType(Alarm::Invalid); 515 alarm->setType(Alarm::Invalid);
516 } 516 }
517 } 517 }
518} 518}
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp
index 01c5773..47e73dd 100644
--- a/korganizer/koeditorrecurrence.cpp
+++ b/korganizer/koeditorrecurrence.cpp
@@ -1,1108 +1,1108 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000-2003 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 <qtooltip.h> 24#include <qtooltip.h>
25#include <qfiledialog.h> 25#include <qfiledialog.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qlistbox.h> 32#include <qlistbox.h>
33#include <qspinbox.h> 33#include <qspinbox.h>
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qapplication.h> 35#include <qapplication.h>
36 36
37#include <kdialog.h> 37#include <kdialog.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <knumvalidator.h> 42#include <knumvalidator.h>
43 43
44#include <libkcal/event.h> 44#include <libkcal/event.h>
45#include <libkcal/todo.h> 45#include <libkcal/todo.h>
46 46
47#include <libkdepim/kdateedit.h> 47#include <libkdepim/kdateedit.h>
48 48
49#include "koprefs.h" 49#include "koprefs.h"
50 50
51#include "koeditorrecurrence.h" 51#include "koeditorrecurrence.h"
52 52
53/////////////////////////// RecurBase /////////////////////////////// 53/////////////////////////// RecurBase ///////////////////////////////
54 54
55RecurBase::RecurBase( QWidget *parent, const char *name ) : 55RecurBase::RecurBase( QWidget *parent, const char *name ) :
56 QWidget( parent, name ) 56 QWidget( parent, name )
57{ 57{
58 mFrequencyEdit = new QSpinBox( 1, 9999, 1, this ); 58 mFrequencyEdit = new QSpinBox( 1, 9999, 1, this );
59 mFrequencyEdit->setValue( 1 ); 59 mFrequencyEdit->setValue( 1 );
60} 60}
61 61
62QWidget *RecurBase::frequencyEdit() 62QWidget *RecurBase::frequencyEdit()
63{ 63{
64 return mFrequencyEdit; 64 return mFrequencyEdit;
65} 65}
66 66
67void RecurBase::setFrequency( int f ) 67void RecurBase::setFrequency( int f )
68{ 68{
69 if ( f < 1 ) f = 1; 69 if ( f < 1 ) f = 1;
70 70
71 mFrequencyEdit->setValue( f ); 71 mFrequencyEdit->setValue( f );
72} 72}
73 73
74int RecurBase::frequency() 74int RecurBase::frequency()
75{ 75{
76 return mFrequencyEdit->value(); 76 return mFrequencyEdit->value();
77} 77}
78 78
79/////////////////////////// RecurDaily /////////////////////////////// 79/////////////////////////// RecurDaily ///////////////////////////////
80 80
81RecurDaily::RecurDaily( QWidget *parent, const char *name ) : 81RecurDaily::RecurDaily( QWidget *parent, const char *name ) :
82 RecurBase( parent, name ) 82 RecurBase( parent, name )
83{ 83{
84 QBoxLayout *topLayout = new QHBoxLayout( this ); 84 QBoxLayout *topLayout = new QHBoxLayout( this );
85 topLayout->setSpacing( KDialog::spacingHint() ); 85 topLayout->setSpacing( KDialog::spacingHint() );
86 topLayout->setMargin( KDialog::marginHintSmall() ); 86 topLayout->setMargin( KDialog::marginHintSmall() );
87 87
88 QLabel *preLabel = new QLabel( i18n("Recur every"), this ); 88 QLabel *preLabel = new QLabel( i18n("Recur every"), this );
89 topLayout->addWidget( preLabel ); 89 topLayout->addWidget( preLabel );
90 90
91 topLayout->addWidget( frequencyEdit() ); 91 topLayout->addWidget( frequencyEdit() );
92 92
93 QLabel *postLabel = new QLabel( i18n("day(s)"), this ); 93 QLabel *postLabel = new QLabel( i18n("day(s)"), this );
94 topLayout->addWidget( postLabel ); 94 topLayout->addWidget( postLabel );
95} 95}
96 96
97 97
98/////////////////////////// RecurWeekly /////////////////////////////// 98/////////////////////////// RecurWeekly ///////////////////////////////
99 99
100RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) : 100RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) :
101 RecurBase( parent, name ) 101 RecurBase( parent, name )
102{ 102{
103 QBoxLayout *topLayout = new QVBoxLayout( this ); 103 QBoxLayout *topLayout = new QVBoxLayout( this );
104 topLayout->setSpacing( KDialog::spacingHint() ); 104 topLayout->setSpacing( KDialog::spacingHint() );
105 topLayout->setMargin( KDialog::marginHintSmall() ); 105 topLayout->setMargin( KDialog::marginHintSmall() );
106 106
107 //topLayout->addStretch( 1 ); 107 //topLayout->addStretch( 1 );
108 108
109 QBoxLayout *weeksLayout = new QHBoxLayout( topLayout ); 109 QBoxLayout *weeksLayout = new QHBoxLayout( topLayout );
110 110
111 QLabel *preLabel = new QLabel( i18n("Recur every"), this ); 111 QLabel *preLabel = new QLabel( i18n("Recur every"), this );
112 weeksLayout->addWidget( preLabel ); 112 weeksLayout->addWidget( preLabel );
113 113
114 weeksLayout->addWidget( frequencyEdit() ); 114 weeksLayout->addWidget( frequencyEdit() );
115 115
116 QLabel *postLabel = new QLabel( i18n("week(s) on:"), this ); 116 QLabel *postLabel = new QLabel( i18n("week(s) on:"), this );
117 weeksLayout->addWidget( postLabel ); 117 weeksLayout->addWidget( postLabel );
118 118
119 QHBox *dayBox = new QHBox( this ); 119 QHBox *dayBox = new QHBox( this );
120 topLayout->addWidget( dayBox, 1, AlignVCenter ); 120 topLayout->addWidget( dayBox, 1, AlignVCenter );
121 // TODO: Respect start of week setting 121 // TODO: Respect start of week setting
122 for ( int i = 0; i < 7; ++i ) { 122 for ( int i = 0; i < 7; ++i ) {
123 QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true ); 123 QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true );
124 int left = 1; 124 int left = 1;
125 if ( QApplication::desktop()->width() > 480 ) { 125 if ( QApplication::desktop()->width() > 480 ) {
126 ++left; 126 ++left;
127 if ( QApplication::desktop()->width() > 640 ) 127 if ( QApplication::desktop()->width() > 640 )
128 ++left; 128 ++left;
129 } 129 }
130 mDayBoxes[ i ] = new QCheckBox( weekDayName.left( left ), dayBox ); 130 mDayBoxes[ i ] = new QCheckBox( weekDayName.left( left ), dayBox );
131 } 131 }
132 132
133 topLayout->addStretch( ); 133 topLayout->addStretch( );
134} 134}
135 135
136void RecurWeekly::setDays( const QBitArray &days ) 136void RecurWeekly::setDays( const QBitArray &days )
137{ 137{
138 for ( int i = 0; i < 7; ++i ) { 138 for ( int i = 0; i < 7; ++i ) {
139 mDayBoxes[ i ]->setChecked( days.testBit( i ) ); 139 mDayBoxes[ i ]->setChecked( days.testBit( i ) );
140 } 140 }
141} 141}
142 142
143QBitArray RecurWeekly::days() 143QBitArray RecurWeekly::days()
144{ 144{
145 QBitArray days( 7 ); 145 QBitArray days( 7 );
146 146
147 for ( int i = 0; i < 7; ++i ) { 147 for ( int i = 0; i < 7; ++i ) {
148 days.setBit( i, mDayBoxes[ i ]->isChecked() ); 148 days.setBit( i, mDayBoxes[ i ]->isChecked() );
149 } 149 }
150 150
151 return days; 151 return days;
152} 152}
153 153
154/////////////////////////// RecurMonthly /////////////////////////////// 154/////////////////////////// RecurMonthly ///////////////////////////////
155 155
156RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) : 156RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) :
157 RecurBase( parent, name ) 157 RecurBase( parent, name )
158{ 158{
159 QBoxLayout *topLayout = new QVBoxLayout( this ); 159 QBoxLayout *topLayout = new QVBoxLayout( this );
160 topLayout->setSpacing( KDialog::spacingHint() ); 160 topLayout->setSpacing( KDialog::spacingHint() );
161 topLayout->setMargin( KDialog::marginHintSmall() ); 161 topLayout->setMargin( KDialog::marginHintSmall() );
162 162
163 163
164 QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); 164 QBoxLayout *freqLayout = new QHBoxLayout( topLayout );
165 165
166 QLabel *preLabel = new QLabel( i18n("every"), this ); 166 QLabel *preLabel = new QLabel( i18n("every"), this );
167 freqLayout->addWidget( preLabel ); 167 freqLayout->addWidget( preLabel );
168 168
169 freqLayout->addWidget( frequencyEdit() ); 169 freqLayout->addWidget( frequencyEdit() );
170 170
171 QLabel *postLabel = new QLabel( i18n("month(s)"), this ); 171 QLabel *postLabel = new QLabel( i18n("month(s)"), this );
172 freqLayout->addWidget( postLabel ); 172 freqLayout->addWidget( postLabel );
173 173
174 174
175 QButtonGroup *buttonGroup = new QButtonGroup( this ); 175 QButtonGroup *buttonGroup = new QButtonGroup( this );
176 buttonGroup->setFrameStyle( QFrame::NoFrame ); 176 buttonGroup->setFrameStyle( QFrame::NoFrame );
177 topLayout->addWidget( buttonGroup, 1, AlignVCenter ); 177 topLayout->addWidget( buttonGroup, 1, AlignVCenter );
178 178
179 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); 179 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 );
180 buttonLayout->setSpacing( KDialog::spacingHint() ); 180 buttonLayout->setSpacing( KDialog::spacingHint() );
181 buttonLayout->setMargin( KDialog::marginHintSmall() ); 181 buttonLayout->setMargin( KDialog::marginHintSmall() );
182 182
183 183
184 QString recurOnText; 184 QString recurOnText;
185 if ( QApplication::desktop()->width() > 320 ) { 185 if ( QApplication::desktop()->width() > 320 ) {
186 recurOnText = i18n("Recur on the"); 186 recurOnText = i18n("Recur on the");
187 } 187 }
188 188
189 mByDayRadio = new QRadioButton( recurOnText, buttonGroup ); 189 mByDayRadio = new QRadioButton( recurOnText, buttonGroup );
190 buttonLayout->addWidget( mByDayRadio, 0, 0 ); 190 buttonLayout->addWidget( mByDayRadio, 0, 0 );
191 191
192 mByDayCombo = new QComboBox( buttonGroup ); 192 mByDayCombo = new QComboBox( buttonGroup );
193 mByDayCombo->setSizeLimit( 7 ); 193 mByDayCombo->setSizeLimit( 7 );
194 mByDayCombo->insertItem( i18n("1st") ); 194 mByDayCombo->insertItem( i18n("1st") );
195 mByDayCombo->insertItem( i18n("2nd") ); 195 mByDayCombo->insertItem( i18n("2nd") );
196 mByDayCombo->insertItem( i18n("3rd") ); 196 mByDayCombo->insertItem( i18n("3rd") );
197 mByDayCombo->insertItem( i18n("4th") ); 197 mByDayCombo->insertItem( i18n("4th") );
198 mByDayCombo->insertItem( i18n("5th") ); 198 mByDayCombo->insertItem( i18n("5th") );
199 mByDayCombo->insertItem( i18n("6th") ); 199 mByDayCombo->insertItem( i18n("6th") );
200 mByDayCombo->insertItem( i18n("7th") ); 200 mByDayCombo->insertItem( i18n("7th") );
201 mByDayCombo->insertItem( i18n("8th") ); 201 mByDayCombo->insertItem( i18n("8th") );
202 mByDayCombo->insertItem( i18n("9th") ); 202 mByDayCombo->insertItem( i18n("9th") );
203 mByDayCombo->insertItem( i18n("10th") ); 203 mByDayCombo->insertItem( i18n("10th") );
204 mByDayCombo->insertItem( i18n("11th") ); 204 mByDayCombo->insertItem( i18n("11th") );
205 mByDayCombo->insertItem( i18n("12th") ); 205 mByDayCombo->insertItem( i18n("12th") );
206 mByDayCombo->insertItem( i18n("13th") ); 206 mByDayCombo->insertItem( i18n("13th") );
207 mByDayCombo->insertItem( i18n("14th") ); 207 mByDayCombo->insertItem( i18n("14th") );
208 mByDayCombo->insertItem( i18n("15th") ); 208 mByDayCombo->insertItem( i18n("15th") );
209 mByDayCombo->insertItem( i18n("16th") ); 209 mByDayCombo->insertItem( i18n("16th") );
210 mByDayCombo->insertItem( i18n("17th") ); 210 mByDayCombo->insertItem( i18n("17th") );
211 mByDayCombo->insertItem( i18n("18th") ); 211 mByDayCombo->insertItem( i18n("18th") );
212 mByDayCombo->insertItem( i18n("19th") ); 212 mByDayCombo->insertItem( i18n("19th") );
213 mByDayCombo->insertItem( i18n("20th") ); 213 mByDayCombo->insertItem( i18n("20th") );
214 mByDayCombo->insertItem( i18n("21st") ); 214 mByDayCombo->insertItem( i18n("21st") );
215 mByDayCombo->insertItem( i18n("22nd") ); 215 mByDayCombo->insertItem( i18n("22nd") );
216 mByDayCombo->insertItem( i18n("23rd") ); 216 mByDayCombo->insertItem( i18n("23rd") );
217 mByDayCombo->insertItem( i18n("24th") ); 217 mByDayCombo->insertItem( i18n("24th") );
218 mByDayCombo->insertItem( i18n("25th") ); 218 mByDayCombo->insertItem( i18n("25th") );
219 mByDayCombo->insertItem( i18n("26th") ); 219 mByDayCombo->insertItem( i18n("26th") );
220 mByDayCombo->insertItem( i18n("27th") ); 220 mByDayCombo->insertItem( i18n("27th") );
221 mByDayCombo->insertItem( i18n("28th") ); 221 mByDayCombo->insertItem( i18n("28th") );
222 mByDayCombo->insertItem( i18n("29th") ); 222 mByDayCombo->insertItem( i18n("29th") );
223 mByDayCombo->insertItem( i18n("30th") ); 223 mByDayCombo->insertItem( i18n("30th") );
224 mByDayCombo->insertItem( i18n("31st") ); 224 mByDayCombo->insertItem( i18n("31st") );
225 buttonLayout->addWidget( mByDayCombo, 0, 1 ); 225 buttonLayout->addWidget( mByDayCombo, 0, 1 );
226 226
227 QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup ); 227 QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup );
228 buttonLayout->addWidget( byDayLabel, 0, 2 ); 228 buttonLayout->addWidget( byDayLabel, 0, 2 );
229 229
230 230
231 mByPosRadio = new QRadioButton( recurOnText, buttonGroup); 231 mByPosRadio = new QRadioButton( recurOnText, buttonGroup);
232 buttonLayout->addWidget( mByPosRadio, 1, 0 ); 232 buttonLayout->addWidget( mByPosRadio, 1, 0 );
233 233
234 mByPosCountCombo = new QComboBox( buttonGroup ); 234 mByPosCountCombo = new QComboBox( buttonGroup );
235 mByPosCountCombo->insertItem( i18n("1st") ); 235 mByPosCountCombo->insertItem( i18n("1st") );
236 mByPosCountCombo->insertItem( i18n("2nd") ); 236 mByPosCountCombo->insertItem( i18n("2nd") );
237 mByPosCountCombo->insertItem( i18n("3rd") ); 237 mByPosCountCombo->insertItem( i18n("3rd") );
238 mByPosCountCombo->insertItem( i18n("4th") ); 238 mByPosCountCombo->insertItem( i18n("4th") );
239 mByPosCountCombo->insertItem( i18n("5th") ); 239 mByPosCountCombo->insertItem( i18n("5th") );
240 buttonLayout->addWidget( mByPosCountCombo, 1, 1 ); 240 buttonLayout->addWidget( mByPosCountCombo, 1, 1 );
241 241
242 mByPosWeekdayCombo = new QComboBox( buttonGroup ); 242 mByPosWeekdayCombo = new QComboBox( buttonGroup );
243 mByPosWeekdayCombo->insertItem( i18n("Monday") ); 243 mByPosWeekdayCombo->insertItem( i18n("Monday") );
244 mByPosWeekdayCombo->insertItem( i18n("Tuesday") ); 244 mByPosWeekdayCombo->insertItem( i18n("Tuesday") );
245 mByPosWeekdayCombo->insertItem( i18n("Wednesday") ); 245 mByPosWeekdayCombo->insertItem( i18n("Wednesday") );
246 mByPosWeekdayCombo->insertItem( i18n("Thursday") ); 246 mByPosWeekdayCombo->insertItem( i18n("Thursday") );
247 mByPosWeekdayCombo->insertItem( i18n("Friday") ); 247 mByPosWeekdayCombo->insertItem( i18n("Friday") );
248 mByPosWeekdayCombo->insertItem( i18n("Saturday") ); 248 mByPosWeekdayCombo->insertItem( i18n("Saturday") );
249 mByPosWeekdayCombo->insertItem( i18n("Sunday") ); 249 mByPosWeekdayCombo->insertItem( i18n("Sunday") );
250 buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 ); 250 buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 );
251} 251}
252 252
253void RecurMonthly::setByDay( int day ) 253void RecurMonthly::setByDay( int day )
254{ 254{
255 mByDayRadio->setChecked( true ); 255 mByDayRadio->setChecked( true );
256 mByDayCombo->setCurrentItem( day ); 256 mByDayCombo->setCurrentItem( day );
257} 257}
258 258
259void RecurMonthly::setByPos( int count, int weekday ) 259void RecurMonthly::setByPos( int count, int weekday )
260{ 260{
261 mByPosRadio->setChecked( true ); 261 mByPosRadio->setChecked( true );
262 mByPosCountCombo->setCurrentItem( count ); 262 mByPosCountCombo->setCurrentItem( count );
263 mByPosWeekdayCombo->setCurrentItem( weekday ); 263 mByPosWeekdayCombo->setCurrentItem( weekday );
264} 264}
265 265
266bool RecurMonthly::byDay() 266bool RecurMonthly::byDay()
267{ 267{
268 return mByDayRadio->isChecked(); 268 return mByDayRadio->isChecked();
269} 269}
270 270
271bool RecurMonthly::byPos() 271bool RecurMonthly::byPos()
272{ 272{
273 return mByPosRadio->isChecked(); 273 return mByPosRadio->isChecked();
274} 274}
275 275
276int RecurMonthly::day() 276int RecurMonthly::day()
277{ 277{
278 return mByDayCombo->currentItem() + 1; 278 return mByDayCombo->currentItem() + 1;
279} 279}
280 280
281int RecurMonthly::count() 281int RecurMonthly::count()
282{ 282{
283 return mByPosCountCombo->currentItem() + 1; 283 return mByPosCountCombo->currentItem() + 1;
284} 284}
285 285
286int RecurMonthly::weekday() 286int RecurMonthly::weekday()
287{ 287{
288 return mByPosWeekdayCombo->currentItem(); 288 return mByPosWeekdayCombo->currentItem();
289} 289}
290 290
291/////////////////////////// RecurYearly /////////////////////////////// 291/////////////////////////// RecurYearly ///////////////////////////////
292 292
293RecurYearly::RecurYearly( QWidget *parent, const char *name ) : 293RecurYearly::RecurYearly( QWidget *parent, const char *name ) :
294 RecurBase( parent, name ) 294 RecurBase( parent, name )
295{ 295{
296 QBoxLayout *topLayout = new QVBoxLayout( this ); 296 QBoxLayout *topLayout = new QVBoxLayout( this );
297 topLayout->setSpacing( KDialog::spacingHint() ); 297 topLayout->setSpacing( KDialog::spacingHint() );
298 topLayout->setMargin( KDialog::marginHintSmall() ); 298 topLayout->setMargin( KDialog::marginHintSmall() );
299 299
300 300
301 QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); 301 QBoxLayout *freqLayout = new QHBoxLayout( topLayout );
302 302
303 QLabel *preLabel = new QLabel( i18n("every"), this ); 303 QLabel *preLabel = new QLabel( i18n("every"), this );
304 freqLayout->addWidget( preLabel ); 304 freqLayout->addWidget( preLabel );
305 305
306 freqLayout->addWidget( frequencyEdit() ); 306 freqLayout->addWidget( frequencyEdit() );
307 307
308 QLabel *postLabel = new QLabel( i18n("year(s)"), this ); 308 QLabel *postLabel = new QLabel( i18n("year(s)"), this );
309 freqLayout->addWidget( postLabel ); 309 freqLayout->addWidget( postLabel );
310 310
311 311
312 QButtonGroup *buttonGroup = new QButtonGroup( this ); 312 QButtonGroup *buttonGroup = new QButtonGroup( this );
313 buttonGroup->setFrameStyle( QFrame::NoFrame ); 313 buttonGroup->setFrameStyle( QFrame::NoFrame );
314 topLayout->addWidget( buttonGroup, 1, AlignVCenter ); 314 topLayout->addWidget( buttonGroup, 1, AlignVCenter );
315 315
316 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 ); 316 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 );
317 317
318 mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup); 318 mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup);
319 buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight); 319 buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight);
320 mByDayLabel = new QLabel( i18n("%1 of ").arg(1), buttonGroup ); 320 mByDayLabel = new QLabel( i18n("%1 of ").arg(1), buttonGroup );
321 321
322 buttonLayout->addWidget( mByDayLabel, 0, 1 ); 322 buttonLayout->addWidget( mByDayLabel, 0, 1 );
323 mByMonthCombo = new QComboBox( buttonGroup ); 323 mByMonthCombo = new QComboBox( buttonGroup );
324 mByMonthCombo->insertItem( i18n("January") ); 324 mByMonthCombo->insertItem( i18n("January") );
325 mByMonthCombo->insertItem( i18n("February") ); 325 mByMonthCombo->insertItem( i18n("February") );
326 mByMonthCombo->insertItem( i18n("March") ); 326 mByMonthCombo->insertItem( i18n("March") );
327 mByMonthCombo->insertItem( i18n("April") ); 327 mByMonthCombo->insertItem( i18n("April") );
328 mByMonthCombo->insertItem( i18n("May") ); 328 mByMonthCombo->insertItem( i18n("May") );
329 mByMonthCombo->insertItem( i18n("June") ); 329 mByMonthCombo->insertItem( i18n("June") );
330 mByMonthCombo->insertItem( i18n("July") ); 330 mByMonthCombo->insertItem( i18n("July") );
331 mByMonthCombo->insertItem( i18n("August") ); 331 mByMonthCombo->insertItem( i18n("August") );
332 mByMonthCombo->insertItem( i18n("September") ); 332 mByMonthCombo->insertItem( i18n("September") );
333 mByMonthCombo->insertItem( i18n("October") ); 333 mByMonthCombo->insertItem( i18n("October") );
334 mByMonthCombo->insertItem( i18n("November") ); 334 mByMonthCombo->insertItem( i18n("November") );
335 mByMonthCombo->insertItem( i18n("December") ); 335 mByMonthCombo->insertItem( i18n("December") );
336 buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft ); 336 buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft );
337 if ( QApplication::desktop()->width() <= 640 ) { 337 if ( QApplication::desktop()->width() <= 640 ) {
338 mByMonthCombo->setSizeLimit( 6 ); 338 mByMonthCombo->setSizeLimit( 6 );
339 } 339 }
340 340
341 mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup); 341 mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup);
342 buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight); 342 buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight);
343 mDayOfLabel = new QLabel( i18n("%1 of the year").arg(1), buttonGroup ); 343 mDayOfLabel = new QLabel( i18n("%1 of the year").arg(1), buttonGroup );
344 buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 ); 344 buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 );
345 345
346} 346}
347 347
348void RecurYearly::setByDay( int doy ) 348void RecurYearly::setByDay( int doy )
349{ 349{
350 mByDayRadio->setChecked( true ); 350 mByDayRadio->setChecked( true );
351 mDayOfLabel->setText(i18n("%1 of the year").arg( doy ) ); 351 mDayOfLabel->setText(i18n("%1 of the year").arg( doy ) );
352} 352}
353 353
354void RecurYearly::setByMonth( int month, int day ) 354void RecurYearly::setByMonth( int month, int day )
355{ 355{
356 mByMonthRadio->setChecked( true ); 356 mByMonthRadio->setChecked( true );
357 mByMonthCombo->setCurrentItem( month - 1 ); 357 mByMonthCombo->setCurrentItem( month - 1 );
358 mByDayLabel->setText(i18n("%1 of ").arg( day ) ); 358 mByDayLabel->setText(i18n("%1 of ").arg( day ) );
359 mDay = day; 359 mDay = day;
360} 360}
361 361
362bool RecurYearly::byMonth() 362bool RecurYearly::byMonth()
363{ 363{
364 return mByMonthRadio->isChecked(); 364 return mByMonthRadio->isChecked();
365} 365}
366 366
367bool RecurYearly::byDay() 367bool RecurYearly::byDay()
368{ 368{
369 return mByDayRadio->isChecked(); 369 return mByDayRadio->isChecked();
370} 370}
371 371
372int RecurYearly::month() 372int RecurYearly::month()
373{ 373{
374 return mByMonthCombo->currentItem() + 1; 374 return mByMonthCombo->currentItem() + 1;
375} 375}
376int RecurYearly::day() 376int RecurYearly::day()
377{ 377{
378 return mDay;//mByDayCombo->currentItem() + 1; 378 return mDay;//mByDayCombo->currentItem() + 1;
379} 379}
380 380
381//////////////////////////// ExceptionsWidget ////////////////////////// 381//////////////////////////// ExceptionsWidget //////////////////////////
382 382
383ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : 383ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) :
384 QWidget( parent, name ) 384 QWidget( parent, name )
385{ 385{
386 QBoxLayout *topLayout = new QVBoxLayout( this ); 386 QBoxLayout *topLayout = new QVBoxLayout( this );
387 387
388 QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"), 388 QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"),
389 this ); 389 this );
390 topLayout->addWidget( groupBox ); 390 topLayout->addWidget( groupBox );
391 391
392 QWidget *box = new QWidget( groupBox ); 392 QWidget *box = new QWidget( groupBox );
393 393
394 QGridLayout *boxLayout = new QGridLayout( box ); 394 QGridLayout *boxLayout = new QGridLayout( box );
395 395
396 mExceptionDateEdit = new KDateEdit( box ); 396 mExceptionDateEdit = new KDateEdit( box );
397 boxLayout->addWidget( mExceptionDateEdit, 0, 0 ); 397 boxLayout->addWidget( mExceptionDateEdit, 0, 0 );
398 398
399 QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box ); 399 QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box );
400 boxLayout->addWidget( addExceptionButton, 1, 0 ); 400 boxLayout->addWidget( addExceptionButton, 1, 0 );
401 QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box ); 401 QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box );
402 boxLayout->addWidget( changeExceptionButton, 2, 0 ); 402 boxLayout->addWidget( changeExceptionButton, 2, 0 );
403 QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box ); 403 QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box );
404 boxLayout->addWidget( deleteExceptionButton, 3, 0 ); 404 boxLayout->addWidget( deleteExceptionButton, 3, 0 );
405 405
406 mExceptionList = new QListBox( box ); 406 mExceptionList = new QListBox( box );
407 boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 ); 407 boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 );
408 408
409 boxLayout->setRowStretch( 4, 1 ); 409 boxLayout->setRowStretch( 4, 1 );
410 boxLayout->setColStretch( 1, 3 ); 410 boxLayout->setColStretch( 1, 3 );
411 411
412 connect( addExceptionButton, SIGNAL( clicked() ), 412 connect( addExceptionButton, SIGNAL( clicked() ),
413 SLOT( addException() ) ); 413 SLOT( addException() ) );
414 connect( changeExceptionButton, SIGNAL( clicked() ), 414 connect( changeExceptionButton, SIGNAL( clicked() ),
415 SLOT( changeException() ) ); 415 SLOT( changeException() ) );
416 connect( deleteExceptionButton, SIGNAL( clicked() ), 416 connect( deleteExceptionButton, SIGNAL( clicked() ),
417 SLOT( deleteException() ) ); 417 SLOT( deleteException() ) );
418 if ( QApplication::desktop()->width() < 480 ) { 418 if ( QApplication::desktop()->width() < 480 ) {
419 setMinimumWidth( 220 ); 419 setMinimumWidth( 220 );
420 } else { 420 } else {
421 setMinimumWidth( 440 ); 421 setMinimumWidth( 440 );
422 mExceptionDateEdit->setMinimumWidth( 200 ); 422 mExceptionDateEdit->setMinimumWidth( 200 );
423 } 423 }
424} 424}
425 425
426void ExceptionsWidget::setDefaults( const QDateTime &from ) 426void ExceptionsWidget::setDefaults( const QDateTime &from )
427{ 427{
428 mExceptionDateEdit->setDate( from.date() ); 428 mExceptionDateEdit->setDate( from.date() );
429} 429}
430 430
431void ExceptionsWidget::addException() 431void ExceptionsWidget::addException()
432{ 432{
433 QDate date = mExceptionDateEdit->date(); 433 QDate date = mExceptionDateEdit->date();
434 QString dateStr = KGlobal::locale()->formatDate( date ); 434 QString dateStr = KGlobal::locale()->formatDate( date );
435 if( !mExceptionList->findItem( dateStr ) ) { 435 if( !mExceptionList->findItem( dateStr ) ) {
436 mExceptionDates.append( date ); 436 mExceptionDates.append( date );
437 mExceptionList->insertItem( dateStr ); 437 mExceptionList->insertItem( dateStr );
438 } 438 }
439} 439}
440 440
441void ExceptionsWidget::changeException() 441void ExceptionsWidget::changeException()
442{ 442{
443 int pos = mExceptionList->currentItem(); 443 int pos = mExceptionList->currentItem();
444 if ( pos < 0 ) return; 444 if ( pos < 0 ) return;
445 445
446 QDate date = mExceptionDateEdit->date(); 446 QDate date = mExceptionDateEdit->date();
447 mExceptionDates[ pos ] = date; 447 mExceptionDates[ pos ] = date;
448 mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); 448 mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos );
449} 449}
450 450
451void ExceptionsWidget::deleteException() 451void ExceptionsWidget::deleteException()
452{ 452{
453 int pos = mExceptionList->currentItem(); 453 int pos = mExceptionList->currentItem();
454 if ( pos < 0 ) return; 454 if ( pos < 0 ) return;
455 455
456 mExceptionDates.remove( mExceptionDates.at( pos ) ); 456 mExceptionDates.remove( mExceptionDates.at( pos ) );
457 mExceptionList->removeItem( pos ); 457 mExceptionList->removeItem( pos );
458} 458}
459 459
460void ExceptionsWidget::setDates( const DateList &dates ) 460void ExceptionsWidget::setDates( const DateList &dates )
461{ 461{
462 mExceptionList->clear(); 462 mExceptionList->clear();
463 mExceptionDates.clear(); 463 mExceptionDates.clear();
464 DateList::ConstIterator dit; 464 DateList::ConstIterator dit;
465 for ( dit = dates.begin(); dit != dates.end(); ++dit ) { 465 for ( dit = dates.begin(); dit != dates.end(); ++dit ) {
466 mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); 466 mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) );
467 mExceptionDates.append( *dit ); 467 mExceptionDates.append( *dit );
468 } 468 }
469} 469}
470 470
471DateList ExceptionsWidget::dates() 471DateList ExceptionsWidget::dates()
472{ 472{
473 return mExceptionDates; 473 return mExceptionDates;
474} 474}
475 475
476///////////////////////// ExceptionsDialog /////////////////////////// 476///////////////////////// ExceptionsDialog ///////////////////////////
477 477
478ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : 478ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) :
479 KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) 479 KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel )
480{ 480{
481 mExceptions = new ExceptionsWidget( this ); 481 mExceptions = new ExceptionsWidget( this );
482 setMainWidget( mExceptions ); 482 setMainWidget( mExceptions );
483 resize(220,10); 483 resize(220,10);
484} 484}
485 485
486void ExceptionsDialog::setDefaults( const QDateTime &from ) 486void ExceptionsDialog::setDefaults( const QDateTime &from )
487{ 487{
488 mExceptions->setDefaults( from ); 488 mExceptions->setDefaults( from );
489} 489}
490 490
491void ExceptionsDialog::setDates( const DateList &dates ) 491void ExceptionsDialog::setDates( const DateList &dates )
492{ 492{
493 mExceptions->setDates( dates ); 493 mExceptions->setDates( dates );
494} 494}
495 495
496DateList ExceptionsDialog::dates() 496DateList ExceptionsDialog::dates()
497{ 497{
498 return mExceptions->dates(); 498 return mExceptions->dates();
499} 499}
500 500
501///////////////////////// RecurrenceRangeWidget /////////////////////////// 501///////////////////////// RecurrenceRangeWidget ///////////////////////////
502 502
503RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, 503RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent,
504 const char *name ) 504 const char *name )
505 : QWidget( parent, name ) 505 : QWidget( parent, name )
506{ 506{
507 QBoxLayout *topLayout = new QVBoxLayout( this ); 507 QBoxLayout *topLayout = new QVBoxLayout( this );
508 508
509 mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), 509 mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"),
510 this ); 510 this );
511 topLayout->addWidget( mRangeGroupBox ); 511 topLayout->addWidget( mRangeGroupBox );
512 512
513 QWidget *rangeBox = new QWidget( mRangeGroupBox ); 513 QWidget *rangeBox = new QWidget( mRangeGroupBox );
514 QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); 514 QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox );
515 rangeLayout->setSpacing( KDialog::spacingHint() ); 515 rangeLayout->setSpacing( KDialog::spacingHint() );
516 rangeLayout->setMargin( KDialog::marginHintSmall() ); 516 rangeLayout->setMargin( KDialog::marginHintSmall() );
517 517
518 mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); 518 mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox );
519 rangeLayout->addWidget( mStartDateLabel ); 519 rangeLayout->addWidget( mStartDateLabel );
520 520
521 QButtonGroup *rangeButtonGroup = new QButtonGroup; 521 QButtonGroup *rangeButtonGroup = new QButtonGroup;
522 522
523 mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); 523 mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox );
524 rangeButtonGroup->insert( mNoEndDateButton ); 524 rangeButtonGroup->insert( mNoEndDateButton );
525 rangeLayout->addWidget( mNoEndDateButton ); 525 rangeLayout->addWidget( mNoEndDateButton );
526 526
527 QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); 527 QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout );
528 durationLayout->setSpacing( KDialog::spacingHint() ); 528 durationLayout->setSpacing( KDialog::spacingHint() );
529 529
530 mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); 530 mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox );
531 rangeButtonGroup->insert( mEndDurationButton ); 531 rangeButtonGroup->insert( mEndDurationButton );
532 durationLayout->addWidget( mEndDurationButton ); 532 durationLayout->addWidget( mEndDurationButton );
533 533
534 mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); 534 mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox );
535 durationLayout->addWidget( mEndDurationEdit ); 535 durationLayout->addWidget( mEndDurationEdit );
536 536
537 QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); 537 QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox );
538 durationLayout ->addWidget( endDurationLabel ); 538 durationLayout ->addWidget( endDurationLabel );
539 539
540 QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); 540 QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout );
541 endDateLayout->setSpacing( KDialog::spacingHint() ); 541 endDateLayout->setSpacing( KDialog::spacingHint() );
542 542
543 mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); 543 mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox );
544 rangeButtonGroup->insert( mEndDateButton ); 544 rangeButtonGroup->insert( mEndDateButton );
545 endDateLayout->addWidget( mEndDateButton ); 545 endDateLayout->addWidget( mEndDateButton );
546 546
547 mEndDateEdit = new KDateEdit( rangeBox ); 547 mEndDateEdit = new KDateEdit( rangeBox );
548 endDateLayout->addWidget( mEndDateEdit ); 548 endDateLayout->addWidget( mEndDateEdit );
549 549
550 //endDateLayout->addStretch( 1 ); 550 //endDateLayout->addStretch( 1 );
551 551
552 connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), 552 connect( mNoEndDateButton, SIGNAL( toggled( bool ) ),
553 SLOT( showCurrentRange() ) ); 553 SLOT( showCurrentRange() ) );
554 connect( mEndDurationButton, SIGNAL( toggled( bool ) ), 554 connect( mEndDurationButton, SIGNAL( toggled( bool ) ),
555 SLOT( showCurrentRange() ) ); 555 SLOT( showCurrentRange() ) );
556 connect( mEndDateButton, SIGNAL( toggled( bool ) ), 556 connect( mEndDateButton, SIGNAL( toggled( bool ) ),
557 SLOT( showCurrentRange() ) ); 557 SLOT( showCurrentRange() ) );
558} 558}
559 559
560void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) 560void RecurrenceRangeWidget::setDefaults( const QDateTime &from )
561{ 561{
562 mNoEndDateButton->setChecked( true ); 562 mNoEndDateButton->setChecked( true );
563 563
564 setDateTimes( from ); 564 setDateTimes( from );
565 mEndDateEdit->setDate( from.date() ); 565 mEndDateEdit->setDate( from.date() );
566} 566}
567 567
568void RecurrenceRangeWidget::setDuration( int duration ) 568void RecurrenceRangeWidget::setDuration( int duration )
569{ 569{
570 if ( duration == -1 ) { 570 if ( duration == -1 ) {
571 mNoEndDateButton->setChecked( true ); 571 mNoEndDateButton->setChecked( true );
572 } else if ( duration == 0 ) { 572 } else if ( duration == 0 ) {
573 mEndDateButton->setChecked( true ); 573 mEndDateButton->setChecked( true );
574 } else { 574 } else {
575 mEndDurationButton->setChecked( true ); 575 mEndDurationButton->setChecked( true );
576 mEndDurationEdit->setValue( duration ); 576 mEndDurationEdit->setValue( duration );
577 } 577 }
578} 578}
579 579
580int RecurrenceRangeWidget::duration() 580int RecurrenceRangeWidget::duration()
581{ 581{
582 if ( mNoEndDateButton->isChecked() ) { 582 if ( mNoEndDateButton->isChecked() ) {
583 return -1; 583 return -1;
584 } else if ( mEndDurationButton->isChecked() ) { 584 } else if ( mEndDurationButton->isChecked() ) {
585 return mEndDurationEdit->value(); 585 return mEndDurationEdit->value();
586 } else { 586 } else {
587 return 0; 587 return 0;
588 } 588 }
589} 589}
590 590
591void RecurrenceRangeWidget::setEndDate( const QDate &date ) 591void RecurrenceRangeWidget::setEndDate( const QDate &date )
592{ 592{
593 mEndDateEdit->setDate( date ); 593 mEndDateEdit->setDate( date );
594} 594}
595 595
596QDate RecurrenceRangeWidget::endDate() 596QDate RecurrenceRangeWidget::endDate()
597{ 597{
598 return mEndDateEdit->date(); 598 return mEndDateEdit->date();
599} 599}
600 600
601void RecurrenceRangeWidget::showCurrentRange() 601void RecurrenceRangeWidget::showCurrentRange()
602{ 602{
603 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); 603 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() );
604 mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); 604 mEndDateEdit->setEnabled( mEndDateButton->isChecked() );
605} 605}
606 606
607void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, 607void RecurrenceRangeWidget::setDateTimes( const QDateTime &start,
608 const QDateTime & ) 608 const QDateTime & )
609{ 609{
610 mStartDateLabel->setText( i18n("Start date: %1") 610 mStartDateLabel->setText( i18n("Start date: %1")
611 .arg( KGlobal::locale()->formatDate( start.date() ) ) ); 611 .arg( KGlobal::locale()->formatDate( start.date() ) ) );
612 612
613 if(!mEndDateButton->isChecked()) 613 if(!mEndDateButton->isChecked())
614 mEndDateEdit->setDate( start.date() ); 614 mEndDateEdit->setDate( start.date() );
615} 615}
616 616
617///////////////////////// RecurrenceRangeDialog /////////////////////////// 617///////////////////////// RecurrenceRangeDialog ///////////////////////////
618 618
619RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, 619RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent,
620 const char *name ) : 620 const char *name ) :
621 KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) 621 KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel )
622{ 622{
623 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); 623 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this );
624 setMainWidget( mRecurrenceRangeWidget ); 624 setMainWidget( mRecurrenceRangeWidget );
625} 625}
626 626
627void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) 627void RecurrenceRangeDialog::setDefaults( const QDateTime &from )
628{ 628{
629 mRecurrenceRangeWidget->setDefaults( from ); 629 mRecurrenceRangeWidget->setDefaults( from );
630} 630}
631 631
632void RecurrenceRangeDialog::setDuration( int duration ) 632void RecurrenceRangeDialog::setDuration( int duration )
633{ 633{
634 mRecurrenceRangeWidget->setDuration( duration ); 634 mRecurrenceRangeWidget->setDuration( duration );
635} 635}
636 636
637int RecurrenceRangeDialog::duration() 637int RecurrenceRangeDialog::duration()
638{ 638{
639 return mRecurrenceRangeWidget->duration(); 639 return mRecurrenceRangeWidget->duration();
640} 640}
641 641
642void RecurrenceRangeDialog::setEndDate( const QDate &date ) 642void RecurrenceRangeDialog::setEndDate( const QDate &date )
643{ 643{
644 mRecurrenceRangeWidget->setEndDate( date ); 644 mRecurrenceRangeWidget->setEndDate( date );
645} 645}
646 646
647QDate RecurrenceRangeDialog::endDate() 647QDate RecurrenceRangeDialog::endDate()
648{ 648{
649 return mRecurrenceRangeWidget->endDate(); 649 return mRecurrenceRangeWidget->endDate();
650} 650}
651 651
652void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, 652void RecurrenceRangeDialog::setDateTimes( const QDateTime &start,
653 const QDateTime &end ) 653 const QDateTime &end )
654{ 654{
655 mRecurrenceRangeWidget->setDateTimes( start, end ); 655 mRecurrenceRangeWidget->setDateTimes( start, end );
656} 656}
657 657
658//////////////////////////// RecurrenceChooser //////////////////////// 658//////////////////////////// RecurrenceChooser ////////////////////////
659 659
660RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : 660RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) :
661 QWidget( parent, name ) 661 QWidget( parent, name )
662{ 662{
663 QBoxLayout *topLayout = new QVBoxLayout( this ); 663 QBoxLayout *topLayout = new QVBoxLayout( this );
664 664
665 mTypeCombo = new QComboBox( this ); 665 mTypeCombo = new QComboBox( this );
666 mTypeCombo->insertItem( i18n("Daily") ); 666 mTypeCombo->insertItem( i18n("Daily") );
667 mTypeCombo->insertItem( i18n("Weekly") ); 667 mTypeCombo->insertItem( i18n("Weekly") );
668 mTypeCombo->insertItem( i18n("Monthly") ); 668 mTypeCombo->insertItem( i18n("Monthly") );
669 mTypeCombo->insertItem( i18n("Yearly") ); 669 mTypeCombo->insertItem( i18n("Yearly") );
670 670
671 topLayout->addWidget( mTypeCombo ); 671 topLayout->addWidget( mTypeCombo );
672 672
673 connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); 673 connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) );
674 674
675} 675}
676 676
677int RecurrenceChooser::type() 677int RecurrenceChooser::type()
678{ 678{
679 if ( mTypeCombo ) { 679 if ( mTypeCombo ) {
680 return mTypeCombo->currentItem(); 680 return mTypeCombo->currentItem();
681 } else { 681 } else {
682 if ( mDailyButton->isChecked() ) return Daily; 682 if ( mDailyButton->isChecked() ) return Daily;
683 else if ( mWeeklyButton->isChecked() ) return Weekly; 683 else if ( mWeeklyButton->isChecked() ) return Weekly;
684 else if ( mMonthlyButton->isChecked() ) return Monthly; 684 else if ( mMonthlyButton->isChecked() ) return Monthly;
685 else return Yearly; 685 else return Yearly;
686 } 686 }
687} 687}
688 688
689void RecurrenceChooser::setType( int type ) 689void RecurrenceChooser::setType( int type )
690{ 690{
691 if ( mTypeCombo ) { 691 if ( mTypeCombo ) {
692 mTypeCombo->setCurrentItem( type ); 692 mTypeCombo->setCurrentItem( type );
693 } else { 693 } else {
694 switch ( type ) { 694 switch ( type ) {
695 case Daily: 695 case Daily:
696 mDailyButton->setChecked( true ); 696 mDailyButton->setChecked( true );
697 break; 697 break;
698 case Weekly: 698 case Weekly:
699 mWeeklyButton->setChecked( true ); 699 mWeeklyButton->setChecked( true );
700 break; 700 break;
701 case Monthly: 701 case Monthly:
702 mMonthlyButton->setChecked( true ); 702 mMonthlyButton->setChecked( true );
703 break; 703 break;
704 case Yearly: 704 case Yearly:
705 default: 705 default:
706 mYearlyButton->setChecked( true ); 706 mYearlyButton->setChecked( true );
707 break; 707 break;
708 } 708 }
709 } 709 }
710} 710}
711 711
712void RecurrenceChooser::emitChoice() 712void RecurrenceChooser::emitChoice()
713{ 713{
714 emit chosen ( type() ); 714 emit chosen ( type() );
715} 715}
716 716
717/////////////////////////////// Main Widget ///////////////////////////// 717/////////////////////////////// Main Widget /////////////////////////////
718 718
719KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : 719KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) :
720 QWidget( parent, name ) 720 QWidget( parent, name )
721{ 721{
722 QGridLayout *topLayout = new QGridLayout( this, 2,2 ); 722 QGridLayout *topLayout = new QGridLayout( this, 2,2 );
723 topLayout->setSpacing( KDialog::spacingHint() ); 723 topLayout->setSpacing( KDialog::spacingHint() );
724 topLayout->setMargin( KDialog::marginHintSmall() ); 724 topLayout->setMargin( KDialog::marginHintSmall() );
725 725
726 mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); 726 mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this );
727 connect( mEnabledCheck, SIGNAL( toggled( bool ) ), 727 connect( mEnabledCheck, SIGNAL( toggled( bool ) ),
728 SLOT( setEnabled( bool ) ) ); 728 SLOT( setEnabled( bool ) ) );
729 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); 729 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 );
730 730
731 731
732 mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), 732 mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"),
733 this ); 733 this );
734 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); 734 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 );
735 735
736 if ( QApplication::desktop()->width() <= 320) { 736 if ( QApplication::desktop()->width() <= 320) {
737 mTimeGroupBox->hide(); 737 mTimeGroupBox->hide();
738 } 738 }
739 739
740// QFrame *timeFrame = new QFrame( mTimeGroupBox ); 740// QFrame *timeFrame = new QFrame( mTimeGroupBox );
741// QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); 741// QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame );
742// layoutTimeFrame->setSpacing( KDialog::spacingHint() ); 742// layoutTimeFrame->setSpacing( KDialog::spacingHint() );
743 743
744 mDateTimeLabel = new QLabel( mTimeGroupBox ); 744 mDateTimeLabel = new QLabel( mTimeGroupBox );
745// mDateTimeLabel = new QLabel( timeFrame ); 745// mDateTimeLabel = new QLabel( timeFrame );
746// layoutTimeFrame->addWidget( mDateTimeLabel ); 746// layoutTimeFrame->addWidget( mDateTimeLabel );
747 //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); 747 //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) );
748 //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); 748 //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) );
749 mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); 749 mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this );
750 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); 750 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 );
751 mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); 751 mRecurrenceChooser = new RecurrenceChooser( mRuleBox );
752 connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), 752 connect( mRecurrenceChooser, SIGNAL( chosen( int ) ),
753 SLOT( showCurrentRule( int ) ) ); 753 SLOT( showCurrentRule( int ) ) );
754 754
755 755
756 mRuleStack = new QWidgetStack( mRuleBox ); 756 mRuleStack = new QWidgetStack( mRuleBox );
757 757
758 mDaily = new RecurDaily( mRuleStack ); 758 mDaily = new RecurDaily( mRuleStack );
759 mRuleStack->addWidget( mDaily, 0 ); 759 mRuleStack->addWidget( mDaily, 0 );
760 760
761 mWeekly = new RecurWeekly( mRuleStack ); 761 mWeekly = new RecurWeekly( mRuleStack );
762 mRuleStack->addWidget( mWeekly, 0 ); 762 mRuleStack->addWidget( mWeekly, 0 );
763 763
764 mMonthly = new RecurMonthly( mRuleStack ); 764 mMonthly = new RecurMonthly( mRuleStack );
765 mRuleStack->addWidget( mMonthly, 0 ); 765 mRuleStack->addWidget( mMonthly, 0 );
766 766
767 mYearly = new RecurYearly( mRuleStack ); 767 mYearly = new RecurYearly( mRuleStack );
768 mRuleStack->addWidget( mYearly, 0 ); 768 mRuleStack->addWidget( mYearly, 0 );
769 769
770 showCurrentRule( mRecurrenceChooser->type() ); 770 showCurrentRule( mRecurrenceChooser->type() );
771 mRecurrenceRangeWidget = 0; 771 mRecurrenceRangeWidget = 0;
772 mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); 772 mRecurrenceRangeDialog = new RecurrenceRangeDialog( this );
773 mRecurrenceRange = mRecurrenceRangeDialog; 773 mRecurrenceRange = mRecurrenceRangeDialog;
774 mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), 774 mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."),
775 this ); 775 this );
776 776
777 connect( mRecurrenceRangeButton, SIGNAL( clicked() ), 777 connect( mRecurrenceRangeButton, SIGNAL( clicked() ),
778 SLOT( showRecurrenceRangeDialog() ) ); 778 SLOT( showRecurrenceRangeDialog() ) );
779 779
780 mExceptionsWidget = 0; 780 mExceptionsWidget = 0;
781 mExceptionsDialog = new ExceptionsDialog( this ); 781 mExceptionsDialog = new ExceptionsDialog( this );
782 mExceptions = mExceptionsDialog; 782 mExceptions = mExceptionsDialog;
783 mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); 783 mExceptionsButton = new QPushButton( i18n("Exceptions..."), this );
784 if ( QApplication::desktop()->width() < 320 ) { 784 if ( QApplication::desktop()->width() < 320 ) {
785 topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); 785 topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 );
786 topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); 786 topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 );
787 } else { 787 } else {
788 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); 788 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 );
789 topLayout->addWidget( mExceptionsButton, 3, 1 ); 789 topLayout->addWidget( mExceptionsButton, 3, 1 );
790 } 790 }
791 connect( mExceptionsButton, SIGNAL( clicked() ), 791 connect( mExceptionsButton, SIGNAL( clicked() ),
792 SLOT( showExceptionsDialog() ) ); 792 SLOT( showExceptionsDialog() ) );
793} 793}
794 794
795KOEditorRecurrence::~KOEditorRecurrence() 795KOEditorRecurrence::~KOEditorRecurrence()
796{ 796{
797} 797}
798 798
799void KOEditorRecurrence::setEnabled( bool enabled ) 799void KOEditorRecurrence::setEnabled( bool enabled )
800{ 800{
801// kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; 801// kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl;
802 802
803 mTimeGroupBox->setEnabled( enabled ); 803 mTimeGroupBox->setEnabled( enabled );
804 if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); 804 if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled );
805 if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); 805 if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled );
806 if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); 806 if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled );
807 if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); 807 if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled );
808 mRuleBox->setEnabled( enabled ); 808 mRuleBox->setEnabled( enabled );
809} 809}
810 810
811void KOEditorRecurrence::showCurrentRule( int current ) 811void KOEditorRecurrence::showCurrentRule( int current )
812{ 812{
813 switch ( current ) { 813 switch ( current ) {
814 case Daily: 814 case Daily:
815 mRuleStack->raiseWidget( mDaily ); 815 mRuleStack->raiseWidget( mDaily );
816 break; 816 break;
817 case Weekly: 817 case Weekly:
818 mRuleStack->raiseWidget( mWeekly ); 818 mRuleStack->raiseWidget( mWeekly );
819 break; 819 break;
820 case Monthly: 820 case Monthly:
821 mRuleStack->raiseWidget( mMonthly ); 821 mRuleStack->raiseWidget( mMonthly );
822 break; 822 break;
823 default: 823 default:
824 case Yearly: 824 case Yearly:
825 mRuleStack->raiseWidget( mYearly ); 825 mRuleStack->raiseWidget( mYearly );
826 break; 826 break;
827 } 827 }
828} 828}
829 829
830void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) 830void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end )
831{ 831{
832// kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; 832// kdDebug() << "KOEditorRecurrence::setDateTimes" << endl;
833 833
834 mRecurrenceRange->setDateTimes( start, end ); 834 mRecurrenceRange->setDateTimes( start, end );
835 mExceptions->setDefaults( end ); 835 mExceptions->setDefaults( end );
836 836
837} 837}
838 838
839void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) 839void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool )
840{ 840{
841 841
842 // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); 842 // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() );
843 setDateTimes( from, to ); 843 setDateTimes( from, to );
844 844
845 bool enabled = false; 845 bool enabled = false;
846 mEnabledCheck->setChecked( enabled ); 846 mEnabledCheck->setChecked( enabled );
847 setEnabled( enabled ); 847 setEnabled( enabled );
848 848
849 mExceptions->setDefaults( to ); 849 mExceptions->setDefaults( to );
850 mRecurrenceRange->setDefaults( to ); 850 mRecurrenceRange->setDefaults( to );
851 851
852 mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); 852 mRecurrenceChooser->setType( RecurrenceChooser::Weekly );
853 showCurrentRule( mRecurrenceChooser->type() ); 853 showCurrentRule( mRecurrenceChooser->type() );
854 854
855 mDaily->setFrequency( 1 ); 855 mDaily->setFrequency( 1 );
856 856
857 mWeekly->setFrequency( 1 ); 857 mWeekly->setFrequency( 1 );
858 QBitArray days( 7 ); 858 QBitArray days( 7 );
859 days.fill( 0 ); 859 days.fill( 0 );
860 days.setBit( from.date().dayOfWeek()- 1); 860 days.setBit( from.date().dayOfWeek()- 1);
861 mWeekly->setDays( days ); 861 mWeekly->setDays( days );
862 mMonthly->setFrequency( 1 ); 862 mMonthly->setFrequency( 1 );
863 mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); 863 mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 );
864 mMonthly->setByDay( from.date().day()-1 ); 864 mMonthly->setByDay( from.date().day()-1 );
865 mYearly->setFrequency( 1 ); 865 mYearly->setFrequency( 1 );
866 mYearly->setByDay( from.date().dayOfYear() ); 866 mYearly->setByDay( from.date().dayOfYear() );
867 mYearly->setByMonth( from.date().month(), from.date().day() ); 867 mYearly->setByMonth( from.date().month(), from.date().day() );
868} 868}
869 869
870void KOEditorRecurrence::readEvent(Incidence *event) 870void KOEditorRecurrence::readEvent(Incidence *event)
871{ 871{
872 872
873 QDateTime dtEnd; 873 QDateTime dtEnd;
874 if ( event->type() == "Event" ) 874 if ( event->type() == "Event" )
875 dtEnd = ((Event*)event)->dtEnd(); 875 dtEnd = ((Event*)event)->dtEnd();
876 else 876 else
877 dtEnd = ((Todo*)event)->dtDue(); 877 dtEnd = ((Todo*)event)->dtDue();
878 878
879 setDefaults( event->dtStart(), dtEnd, true ); 879 setDefaults( event->dtStart(), dtEnd, true );
880 QBitArray rDays( 7 ); 880 QBitArray rDays( 7 );
881 QPtrList<Recurrence::rMonthPos> rmp; 881 QPtrList<Recurrence::rMonthPos> rmp;
882 QPtrList<int> rmd; 882 QPtrList<int> rmd;
883 int day = 0; 883 int day = 0;
884 int count = 0; 884 int count = 0;
885 int month = 0; 885 int month = 0;
886 setDateTimes( event->dtStart(), dtEnd ); 886 setDateTimes( event->dtStart(), dtEnd );
887 887
888 Recurrence *r = event->recurrence(); 888 Recurrence *r = event->recurrence();
889 int f = r->frequency(); 889 int f = r->frequency();
890 890
891 int recurs = r->doesRecur(); 891 int recurs = r->doesRecur();
892 892
893 mEnabledCheck->setChecked( recurs ); 893 mEnabledCheck->setChecked( recurs );
894 setEnabled( recurs ); 894 setEnabled( recurs );
895 895
896 int recurrenceType = RecurrenceChooser::Weekly; 896 int recurrenceType = RecurrenceChooser::Weekly;
897 897
898 switch ( recurs ) { 898 switch ( recurs ) {
899 case Recurrence::rNone: 899 case Recurrence::rNone:
900 setDefaults( event->dtStart(), dtEnd, true ); 900 setDefaults( event->dtStart(), dtEnd, true );
901 break; 901 break;
902 case Recurrence::rDaily: 902 case Recurrence::rDaily:
903 recurrenceType = RecurrenceChooser::Daily; 903 recurrenceType = RecurrenceChooser::Daily;
904 mDaily->setFrequency( f ); 904 mDaily->setFrequency( f );
905 break; 905 break;
906 case Recurrence::rWeekly: 906 case Recurrence::rWeekly:
907 recurrenceType = RecurrenceChooser::Weekly; 907 recurrenceType = RecurrenceChooser::Weekly;
908 mWeekly->setFrequency( f ); 908 mWeekly->setFrequency( f );
909 mWeekly->setDays( r->days() ); 909 mWeekly->setDays( r->days() );
910 break; 910 break;
911 case Recurrence::rMonthlyPos: 911 case Recurrence::rMonthlyPos:
912 // we only handle one possibility in the list right now, 912 // we only handle one possibility in the list right now,
913 // so I have hardcoded calls with first(). If we make the GUI 913 // so I have hardcoded calls with first(). If we make the GUI
914 // more extended, this can be changed. 914 // more extended, this can be changed.
915 recurrenceType = RecurrenceChooser::Monthly; 915 recurrenceType = RecurrenceChooser::Monthly;
916 916
917 rmp = r->monthPositions(); 917 rmp = r->monthPositions();
918 if ( rmp.first()->negative ) 918 if ( rmp.first()->negative )
919 count = 5 - rmp.first()->rPos - 1; 919 count = 5 - rmp.first()->rPos - 1;
920 else 920 else
921 count = rmp.first()->rPos - 1; 921 count = rmp.first()->rPos - 1;
922 day = 0; 922 day = 0;
923 while ( !rmp.first()->rDays.testBit( day ) ) ++day; 923 while ( !rmp.first()->rDays.testBit( day ) ) ++day;
924 mMonthly->setByPos( count, day ); 924 mMonthly->setByPos( count, day );
925 925
926 mMonthly->setFrequency( f ); 926 mMonthly->setFrequency( f );
927 927
928 break; 928 break;
929 case Recurrence::rMonthlyDay: 929 case Recurrence::rMonthlyDay:
930 recurrenceType = RecurrenceChooser::Monthly; 930 recurrenceType = RecurrenceChooser::Monthly;
931 931
932 rmd = r->monthDays(); 932 rmd = r->monthDays();
933 day = *rmd.first() - 1; 933 day = *rmd.first() - 1;
934 mMonthly->setByDay( day ); 934 mMonthly->setByDay( day );
935 935
936 mMonthly->setFrequency( f ); 936 mMonthly->setFrequency( f );
937 937
938 break; 938 break;
939 case Recurrence::rYearlyMonth: 939 case Recurrence::rYearlyMonth:
940 { 940 {
941 recurrenceType = RecurrenceChooser::Yearly; 941 recurrenceType = RecurrenceChooser::Yearly;
942 qDebug("Recurrence::rYearlyMonth: "); 942 //qDebug("Recurrence::rYearlyMonth: ");
943 day = event->dtStart().date().day(); 943 day = event->dtStart().date().day();
944 rmd = r->yearNums(); 944 rmd = r->yearNums();
945 if ( rmd.count() > 0 ) 945 if ( rmd.count() > 0 )
946 month = *rmd.first(); 946 month = *rmd.first();
947 else 947 else
948 month = event->dtStart().date().month() ; 948 month = event->dtStart().date().month() ;
949 mYearly->setByMonth( month, day ); 949 mYearly->setByMonth( month, day );
950#if 0 950#if 0
951 qDebug("2day = %d ",day ); 951 //qDebug("2day = %d ",day );
952 QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); 952 QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions();
953 int month; 953 int month;
954 if ( !monthlist.isEmpty() ) { 954 if ( !monthlist.isEmpty() ) {
955 month = monthlist.first()->rPos ; 955 month = monthlist.first()->rPos ;
956 } else { 956 } else {
957 month = event->dtStart().date().month() ; 957 month = event->dtStart().date().month() ;
958 } 958 }
959 mYearly->setByMonth( day, month ); 959 mYearly->setByMonth( day, month );
960#endif 960#endif
961 mYearly->setFrequency( f ); 961 mYearly->setFrequency( f );
962 } 962 }
963 963
964 break; 964 break;
965 case Recurrence::rYearlyDay: 965 case Recurrence::rYearlyDay:
966 qDebug("Recurrence::rYearlyDay: "); 966 //qDebug("Recurrence::rYearlyDay: ");
967 recurrenceType = RecurrenceChooser::Yearly; 967 recurrenceType = RecurrenceChooser::Yearly;
968 mYearly->setByDay( event->dtStart().date().dayOfYear() ); 968 mYearly->setByDay( event->dtStart().date().dayOfYear() );
969 mYearly->setFrequency( f ); 969 mYearly->setFrequency( f );
970 break; 970 break;
971 default: 971 default:
972 setDefaults( event->dtStart(), dtEnd, true ); 972 setDefaults( event->dtStart(), dtEnd, true );
973 break; 973 break;
974 } 974 }
975 975
976 mRecurrenceChooser->setType( recurrenceType ); 976 mRecurrenceChooser->setType( recurrenceType );
977 showCurrentRule( recurrenceType ); 977 showCurrentRule( recurrenceType );
978 978
979 mRecurrenceRange->setDateTimes( event->dtStart() ); 979 mRecurrenceRange->setDateTimes( event->dtStart() );
980 980
981 if ( r->doesRecur() ) { 981 if ( r->doesRecur() ) {
982 mRecurrenceRange->setDuration( r->duration() ); 982 mRecurrenceRange->setDuration( r->duration() );
983 if ( r->duration() == 0 ) 983 if ( r->duration() == 0 )
984 { 984 {
985 if ( r->endDate() < event->dtStart().date() ) 985 if ( r->endDate() < event->dtStart().date() )
986 mRecurrenceRange->setEndDate( event->dtStart().date() ); 986 mRecurrenceRange->setEndDate( event->dtStart().date() );
987 else 987 else
988 mRecurrenceRange->setEndDate( r->endDate() ); 988 mRecurrenceRange->setEndDate( r->endDate() );
989 } else 989 } else
990 mRecurrenceRange->setEndDate( event->dtStart().date() ); 990 mRecurrenceRange->setEndDate( event->dtStart().date() );
991 } 991 }
992 992
993 mExceptions->setDates( event->exDates() ); 993 mExceptions->setDates( event->exDates() );
994} 994}
995 995
996void KOEditorRecurrence::writeEvent( Incidence *event ) 996void KOEditorRecurrence::writeEvent( Incidence *event )
997{ 997{
998 Recurrence *r = event->recurrence(); 998 Recurrence *r = event->recurrence();
999 999
1000 // clear out any old settings; 1000 // clear out any old settings;
1001 r->unsetRecurs(); 1001 r->unsetRecurs();
1002 1002
1003 if ( mEnabledCheck->isChecked() ) { 1003 if ( mEnabledCheck->isChecked() ) {
1004 int duration = mRecurrenceRange->duration(); 1004 int duration = mRecurrenceRange->duration();
1005 QDate endDate; 1005 QDate endDate;
1006 if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); 1006 if ( duration == 0 ) endDate = mRecurrenceRange->endDate();
1007 1007
1008 int recurrenceType = mRecurrenceChooser->type(); 1008 int recurrenceType = mRecurrenceChooser->type();
1009 1009
1010 if ( recurrenceType == RecurrenceChooser::Daily ) { 1010 if ( recurrenceType == RecurrenceChooser::Daily ) {
1011 int freq = mDaily->frequency(); 1011 int freq = mDaily->frequency();
1012 if ( duration != 0 ) r->setDaily( freq, duration ); 1012 if ( duration != 0 ) r->setDaily( freq, duration );
1013 else r->setDaily( freq, endDate ); 1013 else r->setDaily( freq, endDate );
1014 } else if ( recurrenceType == RecurrenceChooser::Weekly ) { 1014 } else if ( recurrenceType == RecurrenceChooser::Weekly ) {
1015 int freq = mWeekly->frequency(); 1015 int freq = mWeekly->frequency();
1016 QBitArray days = mWeekly->days(); 1016 QBitArray days = mWeekly->days();
1017 int j; 1017 int j;
1018 bool found = false; 1018 bool found = false;
1019 for (j = 0; j < 7 ; ++j ) { 1019 for (j = 0; j < 7 ; ++j ) {
1020 found |=days.at(j); 1020 found |=days.at(j);
1021 } 1021 }
1022 if ( !found ) { 1022 if ( !found ) {
1023 days.setBit( event->dtStart().date().dayOfWeek()-1); 1023 days.setBit( event->dtStart().date().dayOfWeek()-1);
1024 qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); 1024 //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1);
1025 } 1025 }
1026 if ( duration != 0 ) r->setWeekly( freq, days, duration ); 1026 if ( duration != 0 ) r->setWeekly( freq, days, duration );
1027 else r->setWeekly( freq, days, endDate ); 1027 else r->setWeekly( freq, days, endDate );
1028 } else if ( recurrenceType == RecurrenceChooser::Monthly ) { 1028 } else if ( recurrenceType == RecurrenceChooser::Monthly ) {
1029 int freq = mMonthly->frequency(); 1029 int freq = mMonthly->frequency();
1030 if ( mMonthly->byPos() ) { 1030 if ( mMonthly->byPos() ) {
1031 int pos = mMonthly->count(); 1031 int pos = mMonthly->count();
1032 1032
1033 QBitArray days( 7 ); 1033 QBitArray days( 7 );
1034 days.fill( false ); 1034 days.fill( false );
1035 1035
1036 days.setBit( mMonthly->weekday() ); 1036 days.setBit( mMonthly->weekday() );
1037 if ( duration != 0 ) 1037 if ( duration != 0 )
1038 r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); 1038 r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
1039 else 1039 else
1040 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 1040 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
1041 r->addMonthlyPos( pos, days ); 1041 r->addMonthlyPos( pos, days );
1042 } else { 1042 } else {
1043 // it's by day 1043 // it's by day
1044 int day = mMonthly->day(); 1044 int day = mMonthly->day();
1045 1045
1046 if ( duration != 0 ) { 1046 if ( duration != 0 ) {
1047 r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); 1047 r->setMonthly( Recurrence::rMonthlyDay, freq, duration );
1048 } else { 1048 } else {
1049 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 1049 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
1050 } 1050 }
1051 r->addMonthlyDay( day ); 1051 r->addMonthlyDay( day );
1052 } 1052 }
1053 } else if ( recurrenceType == RecurrenceChooser::Yearly ) { 1053 } else if ( recurrenceType == RecurrenceChooser::Yearly ) {
1054 qDebug("RecurrenceChooser::Yearly "); 1054 //qDebug("RecurrenceChooser::Yearly ");
1055 int freq = mYearly->frequency(); 1055 int freq = mYearly->frequency();
1056 if ( mYearly->byDay() ) { 1056 if ( mYearly->byDay() ) {
1057 if ( duration != 0 ) { 1057 if ( duration != 0 ) {
1058 r->setYearly( Recurrence::rYearlyDay, freq, duration ); 1058 r->setYearly( Recurrence::rYearlyDay, freq, duration );
1059 } else { 1059 } else {
1060 r->setYearly( Recurrence::rYearlyDay, freq, endDate ); 1060 r->setYearly( Recurrence::rYearlyDay, freq, endDate );
1061 } 1061 }
1062 r->addYearlyNum( event->dtStart().date().dayOfYear() ); 1062 r->addYearlyNum( event->dtStart().date().dayOfYear() );
1063 } else { 1063 } else {
1064 if ( duration != 0 ) { 1064 if ( duration != 0 ) {
1065 r->setYearly( Recurrence::rYearlyMonth, freq, duration ); 1065 r->setYearly( Recurrence::rYearlyMonth, freq, duration );
1066 } else { 1066 } else {
1067 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 1067 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
1068 } 1068 }
1069 r->addYearlyNum( mYearly->month() ); 1069 r->addYearlyNum( mYearly->month() );
1070 } 1070 }
1071 1071
1072 } 1072 }
1073 1073
1074 event->setExDates( mExceptions->dates() ); 1074 event->setExDates( mExceptions->dates() );
1075 } 1075 }
1076} 1076}
1077 1077
1078void KOEditorRecurrence::setDateTimeStr( const QString &str ) 1078void KOEditorRecurrence::setDateTimeStr( const QString &str )
1079{ 1079{
1080 mDateTimeLabel->setText( str ); 1080 mDateTimeLabel->setText( str );
1081} 1081}
1082 1082
1083bool KOEditorRecurrence::validateInput() 1083bool KOEditorRecurrence::validateInput()
1084{ 1084{
1085 // Check input here 1085 // Check input here
1086 1086
1087 return true; 1087 return true;
1088} 1088}
1089 1089
1090void KOEditorRecurrence::showExceptionsDialog() 1090void KOEditorRecurrence::showExceptionsDialog()
1091{ 1091{
1092 DateList dates = mExceptions->dates(); 1092 DateList dates = mExceptions->dates();
1093 int result = mExceptionsDialog->exec(); 1093 int result = mExceptionsDialog->exec();
1094 if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); 1094 if ( result == QDialog::Rejected ) mExceptions->setDates( dates );
1095} 1095}
1096 1096
1097void KOEditorRecurrence::showRecurrenceRangeDialog() 1097void KOEditorRecurrence::showRecurrenceRangeDialog()
1098{ 1098{
1099 int duration = mRecurrenceRange->duration(); 1099 int duration = mRecurrenceRange->duration();
1100 QDate endDate = mRecurrenceRange->endDate(); 1100 QDate endDate = mRecurrenceRange->endDate();
1101 1101
1102 int result = mRecurrenceRangeDialog->exec(); 1102 int result = mRecurrenceRangeDialog->exec();
1103 if ( result == QDialog::Rejected ) { 1103 if ( result == QDialog::Rejected ) {
1104 mRecurrenceRange->setDuration( duration ); 1104 mRecurrenceRange->setDuration( duration );
1105 mRecurrenceRange->setEndDate( endDate ); 1105 mRecurrenceRange->setEndDate( endDate );
1106 } 1106 }
1107 1107
1108} 1108}
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index fefc778..f39b5e1 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,789 +1,785 @@
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 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <kabc/stdaddressbook.h> 38#include <kabc/stdaddressbook.h>
39 39
40#ifndef KORG_NODCOP 40#ifndef KORG_NODCOP
41#include <dcopclient.h> 41#include <dcopclient.h>
42#include "korganizer.h" 42#include "korganizer.h"
43#include "koprefs.h" 43#include "koprefs.h"
44#include "actionmanager.h" 44#include "actionmanager.h"
45#endif 45#endif
46 46
47#include "koeventviewer.h" 47#include "koeventviewer.h"
48//#ifndef KORG_NOKABC 48//#ifndef KORG_NOKABC
49//#include <kabc/stdaddressbook.h> 49//#include <kabc/stdaddressbook.h>
50//#define size count 50//#define size count
51//#endif 51//#endif
52 52
53#ifdef DESKTOP_VERSION 53#ifdef DESKTOP_VERSION
54#include <kabc/addresseedialog.h> 54#include <kabc/addresseedialog.h>
55#include <kabc/addresseeview.h> 55#include <kabc/addresseeview.h>
56#include <qprinter.h> 56#include <qprinter.h>
57#include <qpainter.h> 57#include <qpainter.h>
58#include <qpaintdevicemetrics.h> 58#include <qpaintdevicemetrics.h>
59#else //DESKTOP_VERSION 59#else //DESKTOP_VERSION
60#include <externalapphandler.h> 60#include <externalapphandler.h>
61#include <qtopia/qcopenvelope_qws.h> 61#include <qtopia/qcopenvelope_qws.h>
62#endif //DESKTOP_VERSION 62#endif //DESKTOP_VERSION
63 63
64KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 64KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
65 : QTextBrowser(parent,name) 65 : QTextBrowser(parent,name)
66{ 66{
67 mSyncMode = false; 67 mSyncMode = false;
68 mColorMode = 0; 68 mColorMode = 0;
69} 69}
70 70
71KOEventViewer::~KOEventViewer() 71KOEventViewer::~KOEventViewer()
72{ 72{
73} 73}
74 74
75void KOEventViewer::printMe() 75void KOEventViewer::printMe()
76{ 76{
77#ifdef DESKTOP_VERSION 77#ifdef DESKTOP_VERSION
78 78
79 KOPrintPrefs pp ( this ); 79 KOPrintPrefs pp ( this );
80 if (!pp.exec() ) 80 if (!pp.exec() )
81 return; 81 return;
82 int scaleval = pp.printMode() ; 82 int scaleval = pp.printMode() ;
83 83
84 QPrinter printer; 84 QPrinter printer;
85 if (!printer.setup() ) 85 if (!printer.setup() )
86 return; 86 return;
87 QPainter p; 87 QPainter p;
88 p.begin ( &printer ); 88 p.begin ( &printer );
89 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 89 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
90 float dx, dy; 90 float dx, dy;
91 int wid = (m.width() * 9)/10; 91 int wid = (m.width() * 9)/10;
92 dx = (float) wid/(float)contentsWidth (); 92 dx = (float) wid/(float)contentsWidth ();
93 dy = (float)(m.height()) / (float)contentsHeight (); 93 dy = (float)(m.height()) / (float)contentsHeight ();
94 float scale; 94 float scale;
95 // scale to fit the width or height of the paper 95 // scale to fit the width or height of the paper
96 if ( dx < dy ) 96 if ( dx < dy )
97 scale = dx; 97 scale = dx;
98 else 98 else
99 scale = dy; 99 scale = dy;
100 100
101 p.translate( m.width()/10,0 ); 101 p.translate( m.width()/10,0 );
102 qDebug("Scale: %f ", scale );
103 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 102 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
104 qDebug("SCALE ");
105 p.scale( scale, scale ); 103 p.scale( scale, scale );
106 } 104 }
107 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 105 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
108 p.end(); 106 p.end();
109#endif 107#endif
110 108
111} 109}
112void KOEventViewer::setSource(const QString& n) 110void KOEventViewer::setSource(const QString& n)
113{ 111{
114 112
115 if ( n.left(3) == "uid" ) 113 if ( n.left(3) == "uid" )
116#ifdef DESKTOP_VERSION 114#ifdef DESKTOP_VERSION
117 { 115 {
118 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 116 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
119 KABC::AddressBook::Iterator it; 117 KABC::AddressBook::Iterator it;
120 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 118 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
121 // LR I do not understand, why the uid string is different on zaurus and desktop 119 // LR I do not understand, why the uid string is different on zaurus and desktop
122 QString uid = "uid://"+(*it).uid(); 120 QString uid = "uid://"+(*it).uid();
123 121
124 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 122 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
125 if (n == uid ) { 123 if (n == uid ) {
126 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 124 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
127 QDialog dia( this,"dia123", true ); 125 QDialog dia( this,"dia123", true );
128 dia.setCaption( i18n("Details of attendee") ); 126 dia.setCaption( i18n("Details of attendee") );
129 QVBoxLayout lay ( &dia ); 127 QVBoxLayout lay ( &dia );
130 KABC::AddresseeView av ( &dia ); 128 KABC::AddresseeView av ( &dia );
131 av.setAddressee( (*it) ); 129 av.setAddressee( (*it) );
132 lay.addWidget( &av ); 130 lay.addWidget( &av );
133 if ( QApplication::desktop()->width() < 480 ) 131 if ( QApplication::desktop()->width() < 480 )
134 dia.resize( 220, 240); 132 dia.resize( 220, 240);
135 else { 133 else {
136 dia.resize( 400,400); 134 dia.resize( 400,400);
137 } 135 }
138 dia.exec(); 136 dia.exec();
139 break; 137 break;
140 } 138 }
141 } 139 }
142 return; 140 return;
143 } 141 }
144#else 142#else
145 { 143 {
146 if ( "uid:organizer" == n ) { 144 if ( "uid:organizer" == n ) {
147 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); 145 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
148 return; 146 return;
149 } 147 }
150 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 148 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
151 if (attendees.count()) { 149 if (attendees.count()) {
152 Attendee *a; 150 Attendee *a;
153 for(a=attendees.first();a;a=attendees.next()) { 151 for(a=attendees.first();a;a=attendees.next()) {
154 if ( "uid:"+a->uid() == n ) { 152 if ( "uid:"+a->uid() == n ) {
155 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 153 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
156 return; 154 return;
157 } 155 }
158 } 156 }
159 } 157 }
160 return; 158 return;
161 } 159 }
162 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 160 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
163 // the result should now arrive through method insertAttendees 161 // the result should now arrive through method insertAttendees
164 //QString uid = "uid:"+(*it).uid(); 162 //QString uid = "uid:"+(*it).uid();
165#endif 163#endif
166 if ( n.left(6) == "mailto" ) { 164 if ( n.left(6) == "mailto" ) {
167 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 165 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
168#ifndef DESKTOP_VERSION 166#ifndef DESKTOP_VERSION
169 if ( n.mid(7,3) == "ALL" ) { 167 if ( n.mid(7,3) == "ALL" ) {
170 qDebug("all ");
171 mailToAttendees( true ); 168 mailToAttendees( true );
172 } else if ( n.mid(7,4) == "RSVP" ) { 169 } else if ( n.mid(7,4) == "RSVP" ) {
173 mailToAttendees( false ); 170 mailToAttendees( false );
174 qDebug("rsvp ");
175 } else { 171 } else {
176 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 172 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
177 e << n.mid(7); 173 e << n.mid(7);
178 } 174 }
179#endif 175#endif
180 176
181 } 177 }
182 178
183 179
184#ifndef KORG_NODCOP 180#ifndef KORG_NODCOP
185 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 181 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
186 QString tmpStr; 182 QString tmpStr;
187 if (n.startsWith("mailto:")) { 183 if (n.startsWith("mailto:")) {
188 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 184 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
189 //emit showIncidence(n); 185 //emit showIncidence(n);
190 return; 186 return;
191 } else if (n.startsWith("uid:")) { 187 } else if (n.startsWith("uid:")) {
192 DCOPClient *client = KApplication::kApplication()->dcopClient(); 188 DCOPClient *client = KApplication::kApplication()->dcopClient();
193 const QByteArray noParamData; 189 const QByteArray noParamData;
194 const QByteArray paramData; 190 const QByteArray paramData;
195 QByteArray replyData; 191 QByteArray replyData;
196 QCString replyTypeStr; 192 QCString replyTypeStr;
197#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 193#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
198 bool foundAbbrowser = PING_ABBROWSER; 194 bool foundAbbrowser = PING_ABBROWSER;
199 195
200 if (foundAbbrowser) { 196 if (foundAbbrowser) {
201 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 197 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
202 //client->send("kaddressbook","KAddressBookIface", 198 //client->send("kaddressbook","KAddressBookIface",
203 QDataStream arg(paramData, IO_WriteOnly); 199 QDataStream arg(paramData, IO_WriteOnly);
204 arg << n.mid(6); 200 arg << n.mid(6);
205 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 201 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
206 return; 202 return;
207 } else { 203 } else {
208 /* 204 /*
209 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 205 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
210 We start it without its main interface 206 We start it without its main interface
211 */ 207 */
212 KIconLoader* iconLoader = new KIconLoader(); 208 KIconLoader* iconLoader = new KIconLoader();
213 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 209 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
214 ActionManager::setStartedKAddressBook(true); 210 ActionManager::setStartedKAddressBook(true);
215 tmpStr = "kaddressbook --editor-only --uid "; 211 tmpStr = "kaddressbook --editor-only --uid ";
216 tmpStr += KProcess::quote(n.mid(6)); 212 tmpStr += KProcess::quote(n.mid(6));
217 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 213 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
218 return; 214 return;
219 } 215 }
220 } else { 216 } else {
221 //QTextBrowser::setSource(n); 217 //QTextBrowser::setSource(n);
222 } 218 }
223#endif 219#endif
224} 220}
225void KOEventViewer::mailToAttendees( bool all ) 221void KOEventViewer::mailToAttendees( bool all )
226{ 222{
227 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 223 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
228 if (attendees.count() == 0) return; 224 if (attendees.count() == 0) return;
229 QStringList nameList; 225 QStringList nameList;
230 QStringList emailList; 226 QStringList emailList;
231 QStringList uidList; 227 QStringList uidList;
232 Attendee* a; 228 Attendee* a;
233 for(a=attendees.first();a;a=attendees.next()) { 229 for(a=attendees.first();a;a=attendees.next()) {
234 if ( !all && !a->RSVP() ) continue; 230 if ( !all && !a->RSVP() ) continue;
235 if (!a->email().isEmpty()) { 231 if (!a->email().isEmpty()) {
236 nameList.append (a->name() ); 232 nameList.append (a->name() );
237 emailList.append (a->email() ); 233 emailList.append (a->email() );
238 uidList.append (a->uid() ); 234 uidList.append (a->uid() );
239 } 235 }
240 } 236 }
241 QString uid = "ComposeMailUIpick2"+mMailSubject; 237 QString uid = "ComposeMailUIpick2"+mMailSubject;
242#ifndef DESKTOP_VERSION 238#ifndef DESKTOP_VERSION
243 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 239 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
244#endif 240#endif
245 241
246} 242}
247void KOEventViewer::addTag(const QString & tag,const QString & text) 243void KOEventViewer::addTag(const QString & tag,const QString & text)
248{ 244{
249 int number=text.contains("\n"); 245 int number=text.contains("\n");
250 QString str = "<" + tag + ">"; 246 QString str = "<" + tag + ">";
251 QString tmpText=text; 247 QString tmpText=text;
252 QString tmpStr=str; 248 QString tmpStr=str;
253 if(number !=-1) 249 if(number !=-1)
254 { 250 {
255 if (number > 0) { 251 if (number > 0) {
256 int pos=0; 252 int pos=0;
257 QString tmp; 253 QString tmp;
258 for(int i=0;i<=number;i++) { 254 for(int i=0;i<=number;i++) {
259 pos=tmpText.find("\n"); 255 pos=tmpText.find("\n");
260 tmp=tmpText.left(pos); 256 tmp=tmpText.left(pos);
261 tmpText=tmpText.right(tmpText.length()-pos-1); 257 tmpText=tmpText.right(tmpText.length()-pos-1);
262 tmpStr+=tmp+"<br>"; 258 tmpStr+=tmp+"<br>";
263 } 259 }
264 } 260 }
265 else tmpStr += tmpText; 261 else tmpStr += tmpText;
266 tmpStr+="</" + tag + ">"; 262 tmpStr+="</" + tag + ">";
267 mText.append(tmpStr); 263 mText.append(tmpStr);
268 } 264 }
269 else 265 else
270 { 266 {
271 str += text + "</" + tag + ">"; 267 str += text + "</" + tag + ">";
272 mText.append(str); 268 mText.append(str);
273 } 269 }
274} 270}
275 271
276void KOEventViewer::setColorMode( int m ) 272void KOEventViewer::setColorMode( int m )
277{ 273{
278 mColorMode = m; 274 mColorMode = m;
279} 275}
280void KOEventViewer::appendEvent(Event *event, int mode ) 276void KOEventViewer::appendEvent(Event *event, int mode )
281{ 277{
282 mMailSubject = ""; 278 mMailSubject = "";
283 mCurrentIncidence = event; 279 mCurrentIncidence = event;
284 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 280 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
285 topLevelWidget()->setCaption(i18n("Event Viewer")); 281 topLevelWidget()->setCaption(i18n("Event Viewer"));
286 if ( mode == 0 ) { 282 if ( mode == 0 ) {
287 addTag("h2",deTag(event->summary())); 283 addTag("h2",deTag(event->summary()));
288 } 284 }
289 else { 285 else {
290 if ( mColorMode == 1 ) { 286 if ( mColorMode == 1 ) {
291 mText +="<font color=\"#00A000\">"; 287 mText +="<font color=\"#00A000\">";
292 } 288 }
293 if ( mColorMode == 2 ) { 289 if ( mColorMode == 2 ) {
294 mText +="<font color=\"#C00000\">"; 290 mText +="<font color=\"#C00000\">";
295 } 291 }
296 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 292 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
297 if ( mode == 1 ) { 293 if ( mode == 1 ) {
298 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 294 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
299 } else { 295 } else {
300 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 296 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
301 } 297 }
302 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 298 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
303 if ( mColorMode ) 299 if ( mColorMode )
304 mText += "</font>"; 300 mText += "</font>";
305 } 301 }
306 mMailSubject += i18n( "Meeting " )+ event->summary(); 302 mMailSubject += i18n( "Meeting " )+ event->summary();
307 if (event->cancelled ()) { 303 if (event->cancelled ()) {
308 mText +="<font color=\"#B00000\">"; 304 mText +="<font color=\"#B00000\">";
309 addTag("i",i18n("This event has been cancelled!")); 305 addTag("i",i18n("This event has been cancelled!"));
310 mText.append("<br>"); 306 mText.append("<br>");
311 mText += "</font>"; 307 mText += "</font>";
312 mMailSubject += i18n("(cancelled)"); 308 mMailSubject += i18n("(cancelled)");
313 } 309 }
314 310
315 if (event->doesFloat()) { 311 if (event->doesFloat()) {
316 if (event->isMultiDay()) { 312 if (event->isMultiDay()) {
317 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 313 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
318 .arg(event->dtStartDateStr(shortDate)) 314 .arg(event->dtStartDateStr(shortDate))
319 .arg(event->dtEndDateStr(shortDate))); 315 .arg(event->dtEndDateStr(shortDate)));
320 } else { 316 } else {
321 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 317 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
322 } 318 }
323 } else { 319 } else {
324 if (event->isMultiDay()) { 320 if (event->isMultiDay()) {
325 mText.append(i18n("<p><b>From:</b> %1</p> ") 321 mText.append(i18n("<p><b>From:</b> %1</p> ")
326 .arg(event->dtStartStr( shortDate))); 322 .arg(event->dtStartStr( shortDate)));
327 mText.append(i18n("<p><b>To:</b> %1</p>") 323 mText.append(i18n("<p><b>To:</b> %1</p>")
328 .arg(event->dtEndStr(shortDate))); 324 .arg(event->dtEndStr(shortDate)));
329 } else { 325 } else {
330 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 326 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
331 .arg(event->dtStartTimeStr()) 327 .arg(event->dtStartTimeStr())
332 .arg(event->dtEndTimeStr())); 328 .arg(event->dtEndTimeStr()));
333 mText.append(i18n("<p><b>On:</b> %1</p> ") 329 mText.append(i18n("<p><b>On:</b> %1</p> ")
334 .arg(event->dtStartDateStr( shortDate ))); 330 .arg(event->dtStartDateStr( shortDate )));
335 } 331 }
336 } 332 }
337 if (!event->location().isEmpty()) { 333 if (!event->location().isEmpty()) {
338 addTag("b",i18n("Location: ")); 334 addTag("b",i18n("Location: "));
339 mText.append(deTag(event->location())+"<br>"); 335 mText.append(deTag(event->location())+"<br>");
340 mMailSubject += i18n(" at ") + event->location(); 336 mMailSubject += i18n(" at ") + event->location();
341 } 337 }
342 if (event->recurrence()->doesRecur()) { 338 if (event->recurrence()->doesRecur()) {
343 339
344 QString recurText = event->recurrence()->recurrenceText(); 340 QString recurText = event->recurrence()->recurrenceText();
345 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 341 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
346 bool ok; 342 bool ok;
347 QDate start = QDate::currentDate(); 343 QDate start = QDate::currentDate();
348 QDateTime next; 344 QDateTime next;
349 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 345 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
350 if ( ok ) { 346 if ( ok ) {
351 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 347 addTag("p",i18n("<b>Next recurrence is on:</b>") );
352 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 348 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
353 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); 349 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true );
354 350
355 } else { 351 } else {
356 bool last; 352 bool last;
357 QDate nextd; 353 QDate nextd;
358 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 354 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
359 if ( last ) { 355 if ( last ) {
360 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 356 addTag("p",i18n("<b>Last recurrence was on:</b>") );
361 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); 357 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
362 } 358 }
363 } 359 }
364 } else { 360 } else {
365 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 361 mMailSubject += i18n(" - " )+event->dtStartStr( true );
366 362
367 } 363 }
368 364
369 365
370 if (event->isAlarmEnabled()) { 366 if (event->isAlarmEnabled()) {
371 Alarm *alarm =event->alarms().first() ; 367 Alarm *alarm =event->alarms().first() ;
372 QDateTime t = alarm->time(); 368 QDateTime t = alarm->time();
373 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 369 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
374 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 370 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
375 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 371 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
376 //addTag("p",s); 372 //addTag("p",s);
377 } 373 }
378 374
379 addTag("b",i18n("Access: ")); 375 addTag("b",i18n("Access: "));
380 mText.append(event->secrecyStr()+"<br>"); 376 mText.append(event->secrecyStr()+"<br>");
381 377
382 378
383 379
384 formatCategories(event); 380 formatCategories(event);
385 381
386 formatReadOnly(event); 382 formatReadOnly(event);
387 formatAttendees(event); 383 formatAttendees(event);
388 384
389 if ( KOPrefs::instance()->mEVshowCreated ) { 385 if ( KOPrefs::instance()->mEVshowCreated ) {
390#ifdef DESKTOP_VERSION 386#ifdef DESKTOP_VERSION
391 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 387 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
392#else 388#else
393 addTag("p",i18n("<b>Created: ") +" </b>"); 389 addTag("p",i18n("<b>Created: ") +" </b>");
394 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 390 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
395#endif 391#endif
396 392
397 } 393 }
398 if ( KOPrefs::instance()->mEVshowChanged ) { 394 if ( KOPrefs::instance()->mEVshowChanged ) {
399#ifdef DESKTOP_VERSION 395#ifdef DESKTOP_VERSION
400 addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); 396 addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) );
401#else 397#else
402 addTag("p",i18n("<b>Last modified: ") +" </b>"); 398 addTag("p",i18n("<b>Last modified: ") +" </b>");
403 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 399 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
404#endif 400#endif
405 401
406 } 402 }
407 if ( KOPrefs::instance()->mEVshowDetails ) { 403 if ( KOPrefs::instance()->mEVshowDetails ) {
408 if (!event->description().isEmpty()) { 404 if (!event->description().isEmpty()) {
409 addTag("p",i18n("<b>Details: </b>")); 405 addTag("p",i18n("<b>Details: </b>"));
410 addTag("p",deTag(event->description())); 406 addTag("p",deTag(event->description()));
411 } 407 }
412 } 408 }
413 setText(mText); 409 setText(mText);
414 //QWhatsThis::add(this,mText); 410 //QWhatsThis::add(this,mText);
415 411
416} 412}
417 413
418void KOEventViewer::appendTodo(Todo *event, int mode ) 414void KOEventViewer::appendTodo(Todo *event, int mode )
419{ 415{
420 mMailSubject = ""; 416 mMailSubject = "";
421 mCurrentIncidence = event; 417 mCurrentIncidence = event;
422 topLevelWidget()->setCaption(i18n("Todo Viewer")); 418 topLevelWidget()->setCaption(i18n("Todo Viewer"));
423 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 419 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
424 if (mode == 0 ) 420 if (mode == 0 )
425 addTag("h2",deTag(event->summary())); 421 addTag("h2",deTag(event->summary()));
426 else { 422 else {
427 if ( mColorMode == 1 ) { 423 if ( mColorMode == 1 ) {
428 mText +="<font color=\"#00A000\">"; 424 mText +="<font color=\"#00A000\">";
429 } 425 }
430 if ( mColorMode == 2 ) { 426 if ( mColorMode == 2 ) {
431 mText +="<font color=\"#B00000\">"; 427 mText +="<font color=\"#B00000\">";
432 } 428 }
433 if ( mode == 1 ) { 429 if ( mode == 1 ) {
434 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 430 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
435 } else { 431 } else {
436 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 432 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
437 } 433 }
438 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 434 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
439 if ( mColorMode ) 435 if ( mColorMode )
440 mText += "</font>"; 436 mText += "</font>";
441 } 437 }
442 mMailSubject += i18n( "Todo " )+ event->summary(); 438 mMailSubject += i18n( "Todo " )+ event->summary();
443 439
444 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { 440 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
445 mText +="<font color=\"#B00000\">"; 441 mText +="<font color=\"#B00000\">";
446 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); 442 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) );
447 mText += "</font>"; 443 mText += "</font>";
448 } else { 444 } else {
449 mText.append(i18n("<p><i>%1 % completed</i></p>") 445 mText.append(i18n("<p><i>%1 % completed</i></p>")
450 .arg(event->percentComplete())); 446 .arg(event->percentComplete()));
451 } 447 }
452 448
453 if (event->cancelled ()) { 449 if (event->cancelled ()) {
454 mText +="<font color=\"#B00000\">"; 450 mText +="<font color=\"#B00000\">";
455 addTag("i",i18n("This todo has been cancelled!")); 451 addTag("i",i18n("This todo has been cancelled!"));
456 mText.append("<br>"); 452 mText.append("<br>");
457 mText += "</font>"; 453 mText += "</font>";
458 mMailSubject += i18n("(cancelled)"); 454 mMailSubject += i18n("(cancelled)");
459 } 455 }
460 456
461 457
462 458
463 if (event->recurrence()->doesRecur()) { 459 if (event->recurrence()->doesRecur()) {
464 460
465 QString recurText = event->recurrence()->recurrenceText(); 461 QString recurText = event->recurrence()->recurrenceText();
466 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); 462 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>");
467 463
468 } 464 }
469 if (event->hasStartDate()) { 465 if (event->hasStartDate()) {
470 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 466 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
471 } 467 }
472 if (event->hasDueDate()) { 468 if (event->hasDueDate()) {
473 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 469 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
474 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 470 mMailSubject += i18n(" - " )+event->dtDueStr( true );
475 } 471 }
476 if (!event->location().isEmpty()) { 472 if (!event->location().isEmpty()) {
477 addTag("b",i18n("Location: ")); 473 addTag("b",i18n("Location: "));
478 mText.append(deTag(event->location())+"<br>"); 474 mText.append(deTag(event->location())+"<br>");
479 mMailSubject += i18n(" at ") + event->location(); 475 mMailSubject += i18n(" at ") + event->location();
480 } 476 }
481 mText.append(i18n("<p><b>Priority:</b> %2</p>") 477 mText.append(i18n("<p><b>Priority:</b> %2</p>")
482 .arg(QString::number(event->priority()))); 478 .arg(QString::number(event->priority())));
483 479
484 if (event->isAlarmEnabled()) { 480 if (event->isAlarmEnabled()) {
485 Alarm *alarm =event->alarms().first() ; 481 Alarm *alarm =event->alarms().first() ;
486 QDateTime t = alarm->time(); 482 QDateTime t = alarm->time();
487 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 483 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
488 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 484 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
489 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 485 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
490 //addTag("p",s); 486 //addTag("p",s);
491 } 487 }
492 488
493 addTag("b",i18n("Access: ")); 489 addTag("b",i18n("Access: "));
494 mText.append(event->secrecyStr()+"<br>"); 490 mText.append(event->secrecyStr()+"<br>");
495 491
496 formatCategories(event); 492 formatCategories(event);
497 493
498 formatReadOnly(event); 494 formatReadOnly(event);
499 formatAttendees(event); 495 formatAttendees(event);
500 496
501 if ( KOPrefs::instance()->mEVshowCreated ) { 497 if ( KOPrefs::instance()->mEVshowCreated ) {
502#ifdef DESKTOP_VERSION 498#ifdef DESKTOP_VERSION
503 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 499 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
504#else 500#else
505 addTag("p",i18n("<b>Created: ") +" </b>"); 501 addTag("p",i18n("<b>Created: ") +" </b>");
506 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 502 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
507#endif 503#endif
508 504
509 } 505 }
510 if ( KOPrefs::instance()->mEVshowChanged ) { 506 if ( KOPrefs::instance()->mEVshowChanged ) {
511#ifdef DESKTOP_VERSION 507#ifdef DESKTOP_VERSION
512 addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); 508 addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) );
513#else 509#else
514 addTag("p",i18n("<b>Last modified: ") +" </b>"); 510 addTag("p",i18n("<b>Last modified: ") +" </b>");
515 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 511 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
516#endif 512#endif
517 513
518 } 514 }
519 if ( event->relatedTo() ) { 515 if ( event->relatedTo() ) {
520 addTag("b",i18n("Parent todo:<br>")); 516 addTag("b",i18n("Parent todo:<br>"));
521 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 517 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
522 } 518 }
523 QPtrList<Incidence> Relations = event->relations(); 519 QPtrList<Incidence> Relations = event->relations();
524 Incidence *to; 520 Incidence *to;
525 if ( Relations.first() ) 521 if ( Relations.first() )
526 addTag("b",i18n("Sub todos:<br>")); 522 addTag("b",i18n("Sub todos:<br>"));
527 for (to=Relations.first();to;to=Relations.next()) { 523 for (to=Relations.first();to;to=Relations.next()) {
528 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 524 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
529 525
530 } 526 }
531 527
532 if ( KOPrefs::instance()->mEVshowDetails ) { 528 if ( KOPrefs::instance()->mEVshowDetails ) {
533 if (!event->description().isEmpty()) { 529 if (!event->description().isEmpty()) {
534 addTag("p",i18n("<b>Details: </b>")); 530 addTag("p",i18n("<b>Details: </b>"));
535 addTag("p",deTag(event->description())); 531 addTag("p",deTag(event->description()));
536 } 532 }
537 } 533 }
538 setText(mText); 534 setText(mText);
539} 535}
540 536
541void KOEventViewer::formatCategories(Incidence *event) 537void KOEventViewer::formatCategories(Incidence *event)
542{ 538{
543 if (!event->categoriesStr().isEmpty()) { 539 if (!event->categoriesStr().isEmpty()) {
544 if (event->categories().count() == 1) { 540 if (event->categories().count() == 1) {
545 addTag("h3",i18n("Category")); 541 addTag("h3",i18n("Category"));
546 } else { 542 } else {
547 addTag("h3",i18n("Categories")); 543 addTag("h3",i18n("Categories"));
548 } 544 }
549 addTag("p",event->categoriesStr()); 545 addTag("p",event->categoriesStr());
550 } 546 }
551} 547}
552void KOEventViewer::formatAttendees(Incidence *event) 548void KOEventViewer::formatAttendees(Incidence *event)
553{ 549{
554 QPtrList<Attendee> attendees = event->attendees(); 550 QPtrList<Attendee> attendees = event->attendees();
555 if (attendees.count()) { 551 if (attendees.count()) {
556 552
557 553
558 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 554 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
559 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 555 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
560 addTag("h3",i18n("Organizer")); 556 addTag("h3",i18n("Organizer"));
561 mText.append("<ul><li>"); 557 mText.append("<ul><li>");
562#ifndef KORG_NOKABC 558#ifndef KORG_NOKABC
563 559
564#ifdef DESKTOP_VERSION 560#ifdef DESKTOP_VERSION
565 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 561 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
566 KABC::Addressee::List addressList; 562 KABC::Addressee::List addressList;
567 addressList = add_book->findByEmail(event->organizer()); 563 addressList = add_book->findByEmail(event->organizer());
568 KABC::Addressee o = addressList.first(); 564 KABC::Addressee o = addressList.first();
569 if (!o.isEmpty() && addressList.size()<2) { 565 if (!o.isEmpty() && addressList.size()<2) {
570 mText += "<a href=\"uid:" + o.uid() + "\">"; 566 mText += "<a href=\"uid:" + o.uid() + "\">";
571 mText += o.formattedName(); 567 mText += o.formattedName();
572 mText += "</a>\n"; 568 mText += "</a>\n";
573 } else { 569 } else {
574 mText.append(event->organizer()); 570 mText.append(event->organizer());
575 } 571 }
576#else //DESKTOP_VERSION 572#else //DESKTOP_VERSION
577 mText += "<a href=\"uid:organizer\">"; 573 mText += "<a href=\"uid:organizer\">";
578 mText += event->organizer(); 574 mText += event->organizer();
579 mText += "</a>\n"; 575 mText += "</a>\n";
580#endif //DESKTOP_VERSION 576#endif //DESKTOP_VERSION
581 577
582 578
583#else 579#else
584 mText.append(event->organizer()); 580 mText.append(event->organizer());
585#endif 581#endif
586 582
587 if (iconPath) { 583 if (iconPath) {
588 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 584 mText += " <a href=\"mailto:" + event->organizer() + "\">";
589 mText += "<IMG src=\"" + iconPath + "\">"; 585 mText += "<IMG src=\"" + iconPath + "\">";
590 mText += "</a>\n"; 586 mText += "</a>\n";
591 } 587 }
592 mText.append("</li></ul>"); 588 mText.append("</li></ul>");
593 589
594 addTag("h3",i18n("Attendees")); 590 addTag("h3",i18n("Attendees"));
595 Attendee *a; 591 Attendee *a;
596 mText.append("<ul>"); 592 mText.append("<ul>");
597 int a_count = 0; 593 int a_count = 0;
598 int a_count_nr = 0; 594 int a_count_nr = 0;
599 595
600 for(a=attendees.first();a;a=attendees.next()) { 596 for(a=attendees.first();a;a=attendees.next()) {
601#ifndef KORG_NOKABC 597#ifndef KORG_NOKABC
602#ifdef DESKTOP_VERSION 598#ifdef DESKTOP_VERSION
603 if (a->name().isEmpty()) { 599 if (a->name().isEmpty()) {
604 addressList = add_book->findByEmail(a->email()); 600 addressList = add_book->findByEmail(a->email());
605 KABC::Addressee o = addressList.first(); 601 KABC::Addressee o = addressList.first();
606 if (!o.isEmpty() && addressList.size()<2) { 602 if (!o.isEmpty() && addressList.size()<2) {
607 mText += "<a href=\"uid:" + o.uid() + "\">"; 603 mText += "<a href=\"uid:" + o.uid() + "\">";
608 mText += o.formattedName(); 604 mText += o.formattedName();
609 mText += "</a>\n"; 605 mText += "</a>\n";
610 } else { 606 } else {
611 mText += "<li>"; 607 mText += "<li>";
612 mText.append(a->email()); 608 mText.append(a->email());
613 mText += "\n"; 609 mText += "\n";
614 } 610 }
615 } else { 611 } else {
616 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 612 mText += "<li><a href=\"uid:" + a->uid() + "\">";
617 if (!a->name().isEmpty()) mText += a->name(); 613 if (!a->name().isEmpty()) mText += a->name();
618 else mText += a->email(); 614 else mText += a->email();
619 mText += "</a>\n"; 615 mText += "</a>\n";
620 } 616 }
621#else //DESKTOP_VERSION 617#else //DESKTOP_VERSION
622 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 618 mText += "<li><a href=\"uid:" + a->uid() + "\">";
623 if (!a->name().isEmpty()) mText += a->name(); 619 if (!a->name().isEmpty()) mText += a->name();
624 else mText += a->email(); 620 else mText += a->email();
625 mText += "</a>\n"; 621 mText += "</a>\n";
626#endif //DESKTOP_VERSION 622#endif //DESKTOP_VERSION
627#else 623#else
628 //qDebug("nokabc "); 624 //qDebug("nokabc ");
629 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 625 mText += "<li><a href=\"uid:" + a->uid() + "\">";
630 if (!a->name().isEmpty()) mText += a->name(); 626 if (!a->name().isEmpty()) mText += a->name();
631 else mText += a->email(); 627 else mText += a->email();
632 mText += "</a>\n"; 628 mText += "</a>\n";
633#endif 629#endif
634 630
635 631
636 if (!a->email().isEmpty()) { 632 if (!a->email().isEmpty()) {
637 if (iconPath) { 633 if (iconPath) {
638 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 634 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
639 if ( a->RSVP() ) { 635 if ( a->RSVP() ) {
640 ++a_count_nr; 636 ++a_count_nr;
641 mText += "<IMG src=\"" + iconPath + "\">"; 637 mText += "<IMG src=\"" + iconPath + "\">";
642 } 638 }
643 else { 639 else {
644 ++a_count; 640 ++a_count;
645 mText += "<IMG src=\"" + NOiconPath + "\">"; 641 mText += "<IMG src=\"" + NOiconPath + "\">";
646 } 642 }
647 mText += "</a>\n"; 643 mText += "</a>\n";
648 } 644 }
649 } 645 }
650 if (a->status() != Attendee::NeedsAction ) 646 if (a->status() != Attendee::NeedsAction )
651 mText +="[" + a->statusStr() + "] "; 647 mText +="[" + a->statusStr() + "] ";
652 if (a->role() == Attendee::Chair ) 648 if (a->role() == Attendee::Chair )
653 mText +="(" + a->roleStr().left(1) + ".)"; 649 mText +="(" + a->roleStr().left(1) + ".)";
654 } 650 }
655 mText.append("</li></ul>"); 651 mText.append("</li></ul>");
656 if ( (a_count+a_count_nr) > 1 ) { 652 if ( (a_count+a_count_nr) > 1 ) {
657 mText += "<a href=\"mailto:ALL\">"; 653 mText += "<a href=\"mailto:ALL\">";
658 mText += i18n( "Mail to all" ); 654 mText += i18n( "Mail to all" );
659 mText += "</a> ( "; 655 mText += "</a> ( ";
660 mText += "<IMG src=\"" + iconPath + "\">"; 656 mText += "<IMG src=\"" + iconPath + "\">";
661 mText += i18n( " and " ); 657 mText += i18n( " and " );
662 mText += "<IMG src=\"" + NOiconPath + "\"> )"; 658 mText += "<IMG src=\"" + NOiconPath + "\"> )";
663 mText += "<br>\n"; 659 mText += "<br>\n";
664 660
665 661
666 } 662 }
667 if ( a_count_nr > 1 ) { 663 if ( a_count_nr > 1 ) {
668 mText += "<a href=\"mailto:RSVP\">"; 664 mText += "<a href=\"mailto:RSVP\">";
669 mText += i18n( "Mail to selected" ); 665 mText += i18n( "Mail to selected" );
670 mText += "</a> ( "; 666 mText += "</a> ( ";
671 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); 667 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath );
672 mText += "<br>\n"; 668 mText += "<br>\n";
673 } 669 }
674 } 670 }
675 671
676} 672}
677void KOEventViewer::appendJournal(Journal *jour, int mode ) 673void KOEventViewer::appendJournal(Journal *jour, int mode )
678{ 674{
679 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 675 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
680 if (mode == 0 ) { 676 if (mode == 0 ) {
681 addTag("h2",i18n("Journal from: ")); 677 addTag("h2",i18n("Journal from: "));
682 } 678 }
683 else { 679 else {
684 if ( mode == 1 ) { 680 if ( mode == 1 ) {
685 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 681 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
686 } else { 682 } else {
687 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 683 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
688 } 684 }
689 } 685 }
690 topLevelWidget()->setCaption("Journal Viewer"); 686 topLevelWidget()->setCaption("Journal Viewer");
691 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 687 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
692 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 688 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
693 if (!jour->description().isEmpty()) { 689 if (!jour->description().isEmpty()) {
694 addTag("p",deTag(jour->description())); 690 addTag("p",deTag(jour->description()));
695 } 691 }
696 setText(mText); 692 setText(mText);
697} 693}
698 694
699void KOEventViewer::formatReadOnly(Incidence *event) 695void KOEventViewer::formatReadOnly(Incidence *event)
700{ 696{
701 if (event->isReadOnly()) { 697 if (event->isReadOnly()) {
702 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 698 addTag("p","<em>(" + i18n("read-only") + ")</em>");
703 } 699 }
704} 700}
705void KOEventViewer::setSyncMode( bool b ) 701void KOEventViewer::setSyncMode( bool b )
706{ 702{
707 mSyncMode = b; 703 mSyncMode = b;
708} 704}
709 705
710void KOEventViewer::setTodo(Todo *event, bool clearV ) 706void KOEventViewer::setTodo(Todo *event, bool clearV )
711{ 707{
712 if ( clearV ) 708 if ( clearV )
713 clearEvents(); 709 clearEvents();
714 if ( mSyncMode ) { 710 if ( mSyncMode ) {
715 if ( clearV ) 711 if ( clearV )
716 appendTodo(event,1 ); 712 appendTodo(event,1 );
717 else 713 else
718 appendTodo(event,2); 714 appendTodo(event,2);
719 } else 715 } else
720 appendTodo(event); 716 appendTodo(event);
721} 717}
722void KOEventViewer::setJournal(Journal *event, bool clearV ) 718void KOEventViewer::setJournal(Journal *event, bool clearV )
723{ 719{
724 if ( clearV ) 720 if ( clearV )
725 clearEvents(); 721 clearEvents();
726 if ( mSyncMode ) { 722 if ( mSyncMode ) {
727 if ( clearV ) 723 if ( clearV )
728 appendJournal(event, 1); 724 appendJournal(event, 1);
729 else 725 else
730 appendJournal(event, 2); 726 appendJournal(event, 2);
731 } else 727 } else
732 appendJournal(event); 728 appendJournal(event);
733} 729}
734 730
735void KOEventViewer::setEvent(Event *event) 731void KOEventViewer::setEvent(Event *event)
736{ 732{
737 clearEvents(); 733 clearEvents();
738 if ( mSyncMode ) 734 if ( mSyncMode )
739 appendEvent(event, 1); 735 appendEvent(event, 1);
740 else 736 else
741 appendEvent(event); 737 appendEvent(event);
742} 738}
743 739
744void KOEventViewer::addEvent(Event *event) 740void KOEventViewer::addEvent(Event *event)
745{ 741{
746 if ( mSyncMode ) 742 if ( mSyncMode )
747 appendEvent(event, 2); 743 appendEvent(event, 2);
748 else 744 else
749 appendEvent(event); 745 appendEvent(event);
750} 746}
751 747
752void KOEventViewer::clearEvents(bool now) 748void KOEventViewer::clearEvents(bool now)
753{ 749{
754 mText = ""; 750 mText = "";
755 if (now) setText(mText); 751 if (now) setText(mText);
756} 752}
757 753
758void KOEventViewer::addText(QString text) 754void KOEventViewer::addText(QString text)
759{ 755{
760 mText.append(text); 756 mText.append(text);
761 setText(mText); 757 setText(mText);
762} 758}
763QString KOEventViewer::deTag(QString text) 759QString KOEventViewer::deTag(QString text)
764{ 760{
765#if QT_VERSION >= 0x030000 761#if QT_VERSION >= 0x030000
766 text.replace( '<' , "&lt;" ); 762 text.replace( '<' , "&lt;" );
767 text.replace( '>' , "&gt;" ); 763 text.replace( '>' , "&gt;" );
768#else 764#else
769 if ( text.find ('<') >= 0 ) { 765 if ( text.find ('<') >= 0 ) {
770 text.replace( QRegExp("<") , "&lt;" ); 766 text.replace( QRegExp("<") , "&lt;" );
771 } 767 }
772 if ( text.find ('>') >= 0 ) { 768 if ( text.find ('>') >= 0 ) {
773 text.replace( QRegExp(">") , "&gt;" ); 769 text.replace( QRegExp(">") , "&gt;" );
774 } 770 }
775#endif 771#endif
776 return text; 772 return text;
777} 773}
778void KOEventViewer::keyPressEvent ( QKeyEvent * e ) 774void KOEventViewer::keyPressEvent ( QKeyEvent * e )
779{ 775{
780 switch ( e->key() ) { 776 switch ( e->key() ) {
781 case Qt::Key_Return: 777 case Qt::Key_Return:
782 case Qt::Key_Enter : 778 case Qt::Key_Enter :
783 e->ignore(); 779 e->ignore();
784 break; 780 break;
785 default: 781 default:
786 QTextBrowser::keyPressEvent ( e ); 782 QTextBrowser::keyPressEvent ( e );
787 break; 783 break;
788 } 784 }
789} 785}
diff --git a/korganizer/koglobals.cpp b/korganizer/koglobals.cpp
index 8016034..9ece77f 100644
--- a/korganizer/koglobals.cpp
+++ b/korganizer/koglobals.cpp
@@ -1,143 +1,114 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 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 <qapplication.h> 24#include <qapplication.h>
25 25
26#include <kdebug.h> 26#include <kdebug.h>
27#include <kglobal.h> 27#include <kglobal.h>
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kstandarddirs.h> 29#include <kstandarddirs.h>
30#include <kglobalsettings.h> 30#include <kglobalsettings.h>
31#include <klocale.h> 31#include <klocale.h>
32 32
33#include <kcalendarsystem.h> 33#include <kcalendarsystem.h>
34 34
35#ifndef KORG_NOKALARMD
36#include "kalarmdclient.h"
37#endif
38#include "simplealarmclient.h"
39 35
40#include "koglobals.h" 36#include "koglobals.h"
41#include "koprefs.h" 37#include "koprefs.h"
42 38
43class NopAlarmClient : public AlarmClient
44{
45 public:
46 void startDaemon() {}
47 bool setCalendars( const QStringList & ) { return false; }
48 bool addCalendar( const QString & ) { return false; }
49 bool removeCalendar( const QString & ) { return false; }
50 bool reloadCalendar( const QString & ) { return false; }
51};
52 39
53KOGlobals *KOGlobals::mSelf = 0; 40KOGlobals *KOGlobals::mSelf = 0;
54 41
55KOGlobals *KOGlobals::self() 42KOGlobals *KOGlobals::self()
56{ 43{
57 if (!mSelf) { 44 if (!mSelf) {
58 mSelf = new KOGlobals; 45 mSelf = new KOGlobals;
59 } 46 }
60 47
61 return mSelf; 48 return mSelf;
62} 49}
63 50
64KOGlobals::KOGlobals() 51KOGlobals::KOGlobals()
65{ 52{
66 KConfig *cfg = KOGlobals::config(); 53 KConfig *cfg = KOGlobals::config();
67 54
68 cfg->setGroup("General"); 55 cfg->setGroup("General");
69 mCalendarSystem = KGlobal::locale()->calendar(); 56 mCalendarSystem = KGlobal::locale()->calendar();
70 57
71 cfg->setGroup("AlarmDaemon");
72 QString alarmClient = cfg->readEntry( "Daemon", "kalarmd" );
73 if ( alarmClient == "simple" ) {
74 mAlarmClient = new SimpleAlarmClient;
75#ifndef KORG_NOKALARMD
76 } else if ( alarmClient == "kalarmd" ) {
77 mAlarmClient = new KalarmdClient;
78#endif
79 } else {
80 mAlarmClient = new NopAlarmClient;
81 }
82} 58}
83 59
84KConfig* KOGlobals::config() 60KConfig* KOGlobals::config()
85{ 61{
86 static KConfig *mConfig = 0; 62 static KConfig *mConfig = 0;
87 if (!mConfig) { 63 if (!mConfig) {
88 KOPrefs *p = KOPrefs::instance(); 64 KOPrefs *p = KOPrefs::instance();
89 mConfig = p->getConfig(); 65 mConfig = p->getConfig();
90 //mConfig = new KConfig( locateLocal( "config", "korganizerrc" ) ); 66 //mConfig = new KConfig( locateLocal( "config", "korganizerrc" ) );
91 } 67 }
92 return mConfig; 68 return mConfig;
93} 69}
94 70
95KOGlobals::~KOGlobals() 71KOGlobals::~KOGlobals()
96{ 72{
97 delete mAlarmClient; 73
98} 74}
99 75
100const KCalendarSystem *KOGlobals::calendarSystem() const 76const KCalendarSystem *KOGlobals::calendarSystem() const
101{ 77{
102 return mCalendarSystem; 78 return mCalendarSystem;
103} 79}
104 80
105AlarmClient *KOGlobals::alarmClient() const
106{
107 return mAlarmClient;
108}
109
110void KOGlobals::fitDialogToScreen( QWidget *wid, bool force ) 81void KOGlobals::fitDialogToScreen( QWidget *wid, bool force )
111{ 82{
112 bool resized = false; 83 bool resized = false;
113 84
114 int w = wid->frameSize().width(); 85 int w = wid->frameSize().width();
115 int h = wid->frameSize().height(); 86 int h = wid->frameSize().height();
116 87
117 QRect desk = KGlobalSettings::desktopGeometry(wid); 88 QRect desk = KGlobalSettings::desktopGeometry(wid);
118 if ( w > desk.width() ) { 89 if ( w > desk.width() ) {
119 w = desk.width(); 90 w = desk.width();
120 resized = true; 91 resized = true;
121 } 92 }
122 // Yuck this hack is ugly. Is the -30 really to circumvent the size of 93 // Yuck this hack is ugly. Is the -30 really to circumvent the size of
123 // kicker?! 94 // kicker?!
124 if ( h > desk.height() - 30 ) { 95 if ( h > desk.height() - 30 ) {
125 h = desk.height() - 30; 96 h = desk.height() - 30;
126 resized = true; 97 resized = true;
127 } 98 }
128 99
129 if ( resized || force ) { 100 if ( resized || force ) {
130 wid->resize( w, h ); 101 wid->resize( w, h );
131 wid->move( desk.x(), desk.y()+15 ); 102 wid->move( desk.x(), desk.y()+15 );
132 if ( force ) wid->setFixedSize( w, h ); 103 if ( force ) wid->setFixedSize( w, h );
133 } 104 }
134} 105}
135 106
136bool KOGlobals::reverseLayout() 107bool KOGlobals::reverseLayout()
137{ 108{
138#if QT_VERSION >= 0x030000 109#if QT_VERSION >= 0x030000
139 return QApplication::reverseLayout(); 110 return QApplication::reverseLayout();
140#else 111#else
141 return false; 112 return false;
142#endif 113#endif
143} 114}
diff --git a/korganizer/koglobals.h b/korganizer/koglobals.h
index 357ff5f..b3ff67b 100644
--- a/korganizer/koglobals.h
+++ b/korganizer/koglobals.h
@@ -1,59 +1,56 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 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#ifndef KORG_GLOBALS_H 23#ifndef KORG_GLOBALS_H
24#define KORG_GLOBALS_H 24#define KORG_GLOBALS_H
25 25
26class KCalendarSystem; 26class KCalendarSystem;
27class AlarmClient; 27class AlarmClient;
28 28
29class KConfig; 29class KConfig;
30 30
31class KOGlobals 31class KOGlobals
32{ 32{
33 public: 33 public:
34 static KOGlobals *self(); 34 static KOGlobals *self();
35 35
36 enum { EVENTADDED, EVENTEDITED, EVENTDELETED }; 36 enum { EVENTADDED, EVENTEDITED, EVENTDELETED };
37 enum { PRIORITY_MODIFIED, COMPLETION_MODIFIED, CATEGORY_MODIFIED, UNKNOWN_MODIFIED }; 37 enum { PRIORITY_MODIFIED, COMPLETION_MODIFIED, CATEGORY_MODIFIED, UNKNOWN_MODIFIED };
38 38
39 static void fitDialogToScreen( QWidget *widget, bool force=false ); 39 static void fitDialogToScreen( QWidget *widget, bool force=false );
40 static KConfig *config(); 40 static KConfig *config();
41 41
42 static bool reverseLayout(); 42 static bool reverseLayout();
43 43
44 const KCalendarSystem *calendarSystem() const; 44 const KCalendarSystem *calendarSystem() const;
45 45
46 AlarmClient *alarmClient() const;
47
48 protected: 46 protected:
49 KOGlobals(); 47 KOGlobals();
50 ~KOGlobals(); 48 ~KOGlobals();
51 49
52 private: 50 private:
53 static KOGlobals *mSelf; 51 static KOGlobals *mSelf;
54 52
55 const KCalendarSystem *mCalendarSystem; 53 const KCalendarSystem *mCalendarSystem;
56 AlarmClient *mAlarmClient;
57}; 54};
58 55
59#endif 56#endif
diff --git a/korganizer/koincidenceeditor.cpp b/korganizer/koincidenceeditor.cpp
index 51df123..9813a80 100644
--- a/korganizer/koincidenceeditor.cpp
+++ b/korganizer/koincidenceeditor.cpp
@@ -1,186 +1,185 @@
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 <qtooltip.h> 24#include <qtooltip.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qpixmap.h> 26#include <qpixmap.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qdatetime.h> 29#include <qdatetime.h>
30#include <qdir.h> 30#include <qdir.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kstandarddirs.h> 34#include <kstandarddirs.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36#include <kfiledialog.h> 36#include <kfiledialog.h>
37 37
38#include <libkdepim/categoryselectdialog.h> 38#include <libkdepim/categoryselectdialog.h>
39#include <libkdepim/kinputdialog.h> 39#include <libkdepim/kinputdialog.h>
40 40
41#include <libkcal/calendarlocal.h> 41#include <libkcal/calendarlocal.h>
42#include <libkcal/icalformat.h> 42#include <libkcal/icalformat.h>
43 43
44#include "koprefs.h" 44#include "koprefs.h"
45#include "koglobals.h"
46 45
47#include "koincidenceeditor.h" 46#include "koincidenceeditor.h"
48 47
49KOIncidenceEditor::KOIncidenceEditor( const QString &caption, 48KOIncidenceEditor::KOIncidenceEditor( const QString &caption,
50 Calendar *calendar, QWidget *parent ) : 49 Calendar *calendar, QWidget *parent ) :
51 KDialogBase( Tabbed, caption, Ok | Apply | Cancel |/* Default | */User1, Ok, 50 KDialogBase( Tabbed, caption, Ok | Apply | Cancel |/* Default | */User1, Ok,
52 parent, caption, true, false ), 51 parent, caption, true, false ),
53 mSaveTemplateDialog( 0 ) 52 mSaveTemplateDialog( 0 )
54{ 53{
55 mCalendar = calendar; 54 mCalendar = calendar;
56 55
57 setButtonText( Default, i18n("Template...") ); 56 setButtonText( Default, i18n("Template...") );
58 57
59 QString saveTemplateText; 58 QString saveTemplateText;
60 // if ( KOPrefs::instance()->mCompactDialogs ) { 59 // if ( KOPrefs::instance()->mCompactDialogs ) {
61// showButton( User1, false ); 60// showButton( User1, false );
62// showButton( Apply, false ); 61// showButton( Apply, false );
63// } else { 62// } else {
64 showButton( Apply, false ); 63 showButton( Apply, false );
65 saveTemplateText = i18n("Ok+Agenda"); 64 saveTemplateText = i18n("Ok+Agenda");
66 // } 65 // }
67 setButtonText( User1, saveTemplateText ); 66 setButtonText( User1, saveTemplateText );
68 67
69 //mCategoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), this ); 68 //mCategoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), this );
70 // KOGlobals::fitDialogToScreen( mCategoryDialog ); 69 // KOGlobals::fitDialogToScreen( mCategoryDialog );
71 70
72 //connect(mCategoryDialog,SIGNAL(editCategories()),SIGNAL(editCategories())); 71 //connect(mCategoryDialog,SIGNAL(editCategories()),SIGNAL(editCategories()));
73 72
74 //connect( this, SIGNAL( defaultClicked() ), SLOT( slotLoadTemplate() ) ); 73 //connect( this, SIGNAL( defaultClicked() ), SLOT( slotLoadTemplate() ) );
75 // connect( this, SIGNAL( user1Clicked() ), SLOT( slotSaveTemplate() ) ); 74 // connect( this, SIGNAL( user1Clicked() ), SLOT( slotSaveTemplate() ) );
76 connect( this, SIGNAL( user1Clicked() ), SLOT( slotShowIncidence() ) ); 75 connect( this, SIGNAL( user1Clicked() ), SLOT( slotShowIncidence() ) );
77} 76}
78 77
79KOIncidenceEditor::~KOIncidenceEditor() 78KOIncidenceEditor::~KOIncidenceEditor()
80{ 79{
81 //delete mCategoryDialog; 80 //delete mCategoryDialog;
82} 81}
83 82
84void KOIncidenceEditor::setupAttendeesTab() 83void KOIncidenceEditor::setupAttendeesTab()
85{ 84{
86 QFrame *topFrame = addPage(i18n("Attendees")); 85 QFrame *topFrame = addPage(i18n("Attendees"));
87 86
88 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 87 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
89 88
90 mDetails = new KOEditorDetails(spacingHint(),topFrame); 89 mDetails = new KOEditorDetails(spacingHint(),topFrame);
91 topLayout->addWidget(mDetails); 90 topLayout->addWidget(mDetails);
92} 91}
93 92
94 93
95void KOIncidenceEditor::slotApply() 94void KOIncidenceEditor::slotApply()
96{ 95{
97 processInput( false ); 96 processInput( false );
98} 97}
99void KOIncidenceEditor::accept() 98void KOIncidenceEditor::accept()
100{ 99{
101 slotOk(); 100 slotOk();
102} 101}
103void KOIncidenceEditor::slotOk() 102void KOIncidenceEditor::slotOk()
104{ 103{
105 if ( processInput( false ) ) QDialog::accept(); 104 if ( processInput( false ) ) QDialog::accept();
106} 105}
107 106
108void KOIncidenceEditor::updateCategoryConfig() 107void KOIncidenceEditor::updateCategoryConfig()
109{ 108{
110 qDebug("KOIncidenceEditor::updateCategoryConfig() is dead! "); 109 qDebug("KOIncidenceEditor::updateCategoryConfig() is dead! ");
111 //mCategoryDialog->updateCategoryConfig(); 110 //mCategoryDialog->updateCategoryConfig();
112} 111}
113 112
114void KOIncidenceEditor::slotCancel() 113void KOIncidenceEditor::slotCancel()
115{ 114{
116 reject(); 115 reject();
117} 116}
118 117
119void KOIncidenceEditor::slotLoadTemplate() 118void KOIncidenceEditor::slotLoadTemplate()
120{ 119{
121 kdDebug() << "KOIncidenceEditor::loadTemplate()" << endl; 120 kdDebug() << "KOIncidenceEditor::loadTemplate()" << endl;
122} 121}
123void KOIncidenceEditor::slotShowIncidence() 122void KOIncidenceEditor::slotShowIncidence()
124{ 123{
125 124
126 if ( processInput(true ) ) { 125 if ( processInput(true ) ) {
127 accept(); 126 accept();
128 } 127 }
129} 128}
130 129
131void KOIncidenceEditor::slotSaveTemplate() 130void KOIncidenceEditor::slotSaveTemplate()
132{ 131{
133 kdDebug() << "KOIncidenceEditor::saveTemplate()" << endl; 132 kdDebug() << "KOIncidenceEditor::saveTemplate()" << endl;
134} 133}
135 134
136void KOIncidenceEditor::createSaveTemplateDialog( SaveTemplateDialog::IncidenceType type ) 135void KOIncidenceEditor::createSaveTemplateDialog( SaveTemplateDialog::IncidenceType type )
137{ 136{
138 if ( !mSaveTemplateDialog ) { 137 if ( !mSaveTemplateDialog ) {
139 mSaveTemplateDialog = new SaveTemplateDialog( type, this ); 138 mSaveTemplateDialog = new SaveTemplateDialog( type, this );
140 connect( mSaveTemplateDialog, SIGNAL( templateSelected( const QString & ) ), 139 connect( mSaveTemplateDialog, SIGNAL( templateSelected( const QString & ) ),
141 SLOT( saveTemplate( const QString & ) ) ); 140 SLOT( saveTemplate( const QString & ) ) );
142 } 141 }
143 mSaveTemplateDialog->show(); 142 mSaveTemplateDialog->show();
144 mSaveTemplateDialog->raise(); 143 mSaveTemplateDialog->raise();
145} 144}
146 145
147void KOIncidenceEditor::saveAsTemplate( Incidence *incidence, 146void KOIncidenceEditor::saveAsTemplate( Incidence *incidence,
148 const QString &templateName ) 147 const QString &templateName )
149{ 148{
150 CalendarLocal cal; 149 CalendarLocal cal;
151 cal.addIncidence( incidence ); 150 cal.addIncidence( incidence );
152 ICalFormat format; 151 ICalFormat format;
153 format.save( &cal, templateName ); 152 format.save( &cal, templateName );
154} 153}
155 154
156QString KOIncidenceEditor::loadTemplate( Calendar *cal, const QString &type, 155QString KOIncidenceEditor::loadTemplate( Calendar *cal, const QString &type,
157 const QStringList &templates ) 156 const QStringList &templates )
158{ 157{
159 // bool ok = false; 158 // bool ok = false;
160// QString templateName = KInputDialog::getItem( i18n("Load Template"), 159// QString templateName = KInputDialog::getItem( i18n("Load Template"),
161// i18n("Select a template to load:"), templates, 0, &ok ); 160// i18n("Select a template to load:"), templates, 0, &ok );
162// if ( !ok || templateName.isEmpty() ) return QString::null; 161// if ( !ok || templateName.isEmpty() ) return QString::null;
163 162
164// QString fileName = locateLocal( "data", "korganizer/templates/" + type + "/" + 163// QString fileName = locateLocal( "data", "korganizer/templates/" + type + "/" +
165// templateName ); 164// templateName );
166// fn =KFileDialog:: getOpenFileName( fn, "Import filename(*.ics/*.vcs)", this ); 165// fn =KFileDialog:: getOpenFileName( fn, "Import filename(*.ics/*.vcs)", this );
167 166
168 // QString fileName;// =locateLocal( "templates", incidence->type() ); 167 // QString fileName;// =locateLocal( "templates", incidence->type() );
169// fileName=KFileDialog:: getOpenFileName( fileName, "Load "+incidence()->type(), this ); 168// fileName=KFileDialog:: getOpenFileName( fileName, "Load "+incidence()->type(), this );
170// if ( fileNamelength() == 0) 169// if ( fileNamelength() == 0)
171// return QString::null; 170// return QString::null;
172// if ( fileName.isEmpty() ) { 171// if ( fileName.isEmpty() ) {
173// KMessageBox::error( this, i18n("Unable to find template '%1'.") 172// KMessageBox::error( this, i18n("Unable to find template '%1'.")
174// .arg( fileName ) ); 173// .arg( fileName ) );
175// return QString::null; 174// return QString::null;
176// } else { 175// } else {
177// ICalFormat format; 176// ICalFormat format;
178// if ( !format.load( cal, fileName ) ) { 177// if ( !format.load( cal, fileName ) ) {
179// KMessageBox::error( this, i18n("Error loading template file '%1'.") 178// KMessageBox::error( this, i18n("Error loading template file '%1'.")
180// .arg( fileName ) ); 179// .arg( fileName ) );
181// return QString::null; 180// return QString::null;
182// } 181// }
183// } 182// }
184 183
185 return ""; 184 return "";
186} 185}
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 341f473..e1b393d 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1250 +1,1257 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlistview.h> 25#include <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36#include <qregexp.h> 36#include <qregexp.h>
37 37
38#include <klocale.h> 38#include <klocale.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kglobal.h> 41#include <kglobal.h>
42 42
43#include <libkdepim/kpimglobalprefs.h> 43#include <libkdepim/kpimglobalprefs.h>
44#include <libkcal/calendar.h> 44#include <libkcal/calendar.h>
45#include <libkcal/calendarlocal.h> 45#include <libkcal/calendarlocal.h>
46#include <libkcal/icalformat.h> 46#include <libkcal/icalformat.h>
47#include <libkcal/vcalformat.h> 47#include <libkcal/vcalformat.h>
48#include <libkcal/recurrence.h> 48#include <libkcal/recurrence.h>
49#include <libkcal/filestorage.h> 49#include <libkcal/filestorage.h>
50#include <libkdepim/categoryselectdialog.h> 50#include <libkdepim/categoryselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57 57
58#ifndef KORG_NOPRINTER 58#ifndef KORG_NOPRINTER
59#include "calprinter.h" 59#include "calprinter.h"
60#endif 60#endif
61#include "koglobals.h" 61#include "koglobals.h"
62#include "koprefs.h" 62#include "koprefs.h"
63#include "kfiledialog.h" 63#include "kfiledialog.h"
64 64
65#include "kolistview.h" 65#include "kolistview.h"
66 66
67 67
68 68
69 69
70class KOListViewWhatsThis :public QWhatsThis 70class KOListViewWhatsThis :public QWhatsThis
71{ 71{
72public: 72public:
73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
74 74
75protected: 75protected:
76 virtual QString text( const QPoint& p) 76 virtual QString text( const QPoint& p)
77 { 77 {
78 return _view->getWhatsThisText(p) ; 78 return _view->getWhatsThisText(p) ;
79 } 79 }
80private: 80private:
81 QWidget* _wid; 81 QWidget* _wid;
82 KOListView * _view; 82 KOListView * _view;
83}; 83};
84 84
85 85
86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
87{ 87{
88 mItem = item; 88 mItem = item;
89 mDate = date; 89 mDate = date;
90} 90}
91 91
92ListItemVisitor::~ListItemVisitor() 92ListItemVisitor::~ListItemVisitor()
93{ 93{
94} 94}
95 95
96bool ListItemVisitor::visit(Event *e) 96bool ListItemVisitor::visit(Event *e)
97{ 97{
98 98
99 bool ok = false; 99 bool ok = false;
100 QString start, end; 100 QString start, end;
101 QDate ds, de; 101 QDate ds, de;
102 if ( e->doesRecur() ) { 102 if ( e->doesRecur() ) {
103 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 103 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
104 if ( ok ) { 104 if ( ok ) {
105 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 105 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
106 start = KGlobal::locale()->formatDate(ds,true); 106 start = KGlobal::locale()->formatDate(ds,true);
107 de = ds.addDays( days); 107 de = ds.addDays( days);
108 end = KGlobal::locale()->formatDate(de,true); 108 end = KGlobal::locale()->formatDate(de,true);
109 } 109 }
110 110
111 } 111 }
112 if ( ! ok ) { 112 if ( ! ok ) {
113 start =e->dtStartDateStr(); 113 start =e->dtStartDateStr();
114 end = e->dtEndDateStr(); 114 end = e->dtEndDateStr();
115 ds = e->dtStart().date(); 115 ds = e->dtStart().date();
116 de = e->dtEnd().date(); 116 de = e->dtEnd().date();
117 } 117 }
118 mItem->setText(0,e->summary()); 118 mItem->setText(0,e->summary());
119 mItem->setText(1,start); 119 mItem->setText(1,start);
120 mItem->setText(2,e->dtStartTimeStr()); 120 mItem->setText(2,e->dtStartTimeStr());
121 mItem->setText(3,end); 121 mItem->setText(3,end);
122 mItem->setText(4,e->dtEndTimeStr()); 122 mItem->setText(4,e->dtEndTimeStr());
123 if ( e->isAlarmEnabled() ) { 123 if ( e->isAlarmEnabled() ) {
124 mItem->setText(5,e->alarms().first()->offsetText() ); 124 mItem->setText(5,e->alarms().first()->offsetText() );
125 } else { 125 } else {
126 mItem->setText(5, i18n("No")); 126 mItem->setText(5, i18n("No"));
127 } 127 }
128 mItem->setText(6, e->recurrence()->recurrenceText()); 128 mItem->setText(6, e->recurrence()->recurrenceText());
129 mItem->setText(7,"---"); 129 mItem->setText(7,"---");
130 mItem->setText(8,"---"); 130 mItem->setText(8,"---");
131 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 131 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
132 mItem->setText(10,e->categoriesStr()); 132 mItem->setText(10,e->categoriesStr());
133 133
134 QString key; 134 QString key;
135 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 135 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
136 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 136 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
137 mItem->setSortKey(1,key); 137 mItem->setSortKey(1,key);
138 138
139 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 139 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
140 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 140 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
141 mItem->setSortKey(3,key); 141 mItem->setSortKey(3,key);
142 142
143 return true; 143 return true;
144} 144}
145 145
146bool ListItemVisitor::visit(Todo *t) 146bool ListItemVisitor::visit(Todo *t)
147{ 147{
148 mItem->setText(0,i18n("Todo: %1").arg(t->summary())); 148 mItem->setText(0,i18n("Todo: %1").arg(t->summary()));
149 if (t->hasStartDate()) { 149 if (t->hasStartDate()) {
150 mItem->setText(1,t->dtStartDateStr()); 150 mItem->setText(1,t->dtStartDateStr());
151 if (t->doesFloat()) { 151 if (t->doesFloat()) {
152 mItem->setText(2,"---"); 152 mItem->setText(2,"---");
153 } else { 153 } else {
154 mItem->setText(2,t->dtStartTimeStr()); 154 mItem->setText(2,t->dtStartTimeStr());
155 } 155 }
156 } else { 156 } else {
157 mItem->setText(1,"---"); 157 mItem->setText(1,"---");
158 mItem->setText(2,"---"); 158 mItem->setText(2,"---");
159 } 159 }
160 mItem->setText(3,"---"); 160 mItem->setText(3,"---");
161 mItem->setText(4,"---"); 161 mItem->setText(4,"---");
162 if ( t->isAlarmEnabled() ) { 162 if ( t->isAlarmEnabled() ) {
163 mItem->setText(5,t->alarms().first()->offsetText() ); 163 mItem->setText(5,t->alarms().first()->offsetText() );
164 } else { 164 } else {
165 mItem->setText(5, i18n("No")); 165 mItem->setText(5, i18n("No"));
166 } 166 }
167 mItem->setText(6, t->recurrence()->recurrenceText()); 167 mItem->setText(6, t->recurrence()->recurrenceText());
168 if (t->hasDueDate()) { 168 if (t->hasDueDate()) {
169 mItem->setText(7,t->dtDueDateStr()); 169 mItem->setText(7,t->dtDueDateStr());
170 if (t->doesFloat()) { 170 if (t->doesFloat()) {
171 mItem->setText(8,"---"); 171 mItem->setText(8,"---");
172 } else { 172 } else {
173 mItem->setText(8,t->dtDueTimeStr()); 173 mItem->setText(8,t->dtDueTimeStr());
174 } 174 }
175 } else { 175 } else {
176 mItem->setText(7,"---"); 176 mItem->setText(7,"---");
177 mItem->setText(8,"---"); 177 mItem->setText(8,"---");
178 } 178 }
179 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 179 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
180 mItem->setText(10,t->categoriesStr()); 180 mItem->setText(10,t->categoriesStr());
181 181
182 QString key; 182 QString key;
183 QDate d; 183 QDate d;
184 if (t->hasDueDate()) { 184 if (t->hasDueDate()) {
185 d = t->dtDue().date(); 185 d = t->dtDue().date();
186 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 186 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
187 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 187 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
188 mItem->setSortKey(7,key); 188 mItem->setSortKey(7,key);
189 } 189 }
190 if ( t->hasStartDate() ) { 190 if ( t->hasStartDate() ) {
191 d = t->dtStart().date(); 191 d = t->dtStart().date();
192 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 192 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
193 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 193 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
194 mItem->setSortKey(1,key); 194 mItem->setSortKey(1,key);
195 } 195 }
196 return true; 196 return true;
197} 197}
198 198
199bool ListItemVisitor::visit(Journal * j) 199bool ListItemVisitor::visit(Journal * j)
200{ 200{
201 QString des = j->description().left(30); 201 QString des = j->description().left(30);
202 des = des.simplifyWhiteSpace (); 202 des = des.simplifyWhiteSpace ();
203 des.replace (QRegExp ("\\n"),"" ); 203 des.replace (QRegExp ("\\n"),"" );
204 des.replace (QRegExp ("\\r"),"" ); 204 des.replace (QRegExp ("\\r"),"" );
205 mItem->setText(0,i18n("Journal: ")+des.left(25)); 205 mItem->setText(0,i18n("Journal: ")+des.left(25));
206 mItem->setText(1,j->dtStartDateStr()); 206 mItem->setText(1,j->dtStartDateStr());
207 mItem->setText(2,"---"); 207 mItem->setText(2,"---");
208 mItem->setText(3,"---"); 208 mItem->setText(3,"---");
209 mItem->setText(4,"---"); 209 mItem->setText(4,"---");
210 mItem->setText(5,"---"); 210 mItem->setText(5,"---");
211 mItem->setText(6,"---"); 211 mItem->setText(6,"---");
212 mItem->setText(7,j->dtStartDateStr()); 212 mItem->setText(7,j->dtStartDateStr());
213 mItem->setText(8,"---"); 213 mItem->setText(8,"---");
214 mItem->setText(9,"---"); 214 mItem->setText(9,"---");
215 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 215 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
216 216
217 QString key; 217 QString key;
218 QDate d = j->dtStart().date(); 218 QDate d = j->dtStart().date();
219 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 219 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
220 mItem->setSortKey(1,key); 220 mItem->setSortKey(1,key);
221 mItem->setSortKey(7,key); 221 mItem->setSortKey(7,key);
222 222
223 return true; 223 return true;
224} 224}
225 225
226KOListView::KOListView(Calendar *calendar, QWidget *parent, 226KOListView::KOListView(Calendar *calendar, QWidget *parent,
227 const char *name) 227 const char *name)
228 : KOEventView(calendar, parent, name) 228 : KOEventView(calendar, parent, name)
229{ 229{
230 mActiveItem = 0; 230 mActiveItem = 0;
231 mListView = new KOListViewListView(this); 231 mListView = new KOListViewListView(this);
232 mListView->addColumn(i18n("Summary")); 232 mListView->addColumn(i18n("Summary"));
233 mListView->addColumn(i18n("Start Date")); 233 mListView->addColumn(i18n("Start Date"));
234 mListView->addColumn(i18n("Start Time")); 234 mListView->addColumn(i18n("Start Time"));
235 mListView->addColumn(i18n("End Date")); 235 mListView->addColumn(i18n("End Date"));
236 mListView->addColumn(i18n("End Time")); 236 mListView->addColumn(i18n("End Time"));
237 mListView->addColumn(i18n("Alarm")); // alarm set? 237 mListView->addColumn(i18n("Alarm")); // alarm set?
238 mListView->addColumn(i18n("Recurs")); // recurs? 238 mListView->addColumn(i18n("Recurs")); // recurs?
239 mListView->addColumn(i18n("Due Date")); 239 mListView->addColumn(i18n("Due Date"));
240 mListView->addColumn(i18n("Due Time")); 240 mListView->addColumn(i18n("Due Time"));
241 mListView->addColumn(i18n("Cancelled")); 241 mListView->addColumn(i18n("Cancelled"));
242 mListView->addColumn(i18n("Categories")); 242 mListView->addColumn(i18n("Categories"));
243 243
244 mListView->setColumnAlignment(0,AlignLeft); 244 mListView->setColumnAlignment(0,AlignLeft);
245 mListView->setColumnAlignment(1,AlignLeft); 245 mListView->setColumnAlignment(1,AlignLeft);
246 mListView->setColumnAlignment(2,AlignHCenter); 246 mListView->setColumnAlignment(2,AlignHCenter);
247 mListView->setColumnAlignment(3,AlignLeft); 247 mListView->setColumnAlignment(3,AlignLeft);
248 mListView->setColumnAlignment(4,AlignHCenter); 248 mListView->setColumnAlignment(4,AlignHCenter);
249 mListView->setColumnAlignment(5,AlignLeft); 249 mListView->setColumnAlignment(5,AlignLeft);
250 mListView->setColumnAlignment(6,AlignLeft); 250 mListView->setColumnAlignment(6,AlignLeft);
251 mListView->setColumnAlignment(7,AlignLeft); 251 mListView->setColumnAlignment(7,AlignLeft);
252 mListView->setColumnAlignment(8,AlignLeft); 252 mListView->setColumnAlignment(8,AlignLeft);
253 mListView->setColumnAlignment(9,AlignLeft); 253 mListView->setColumnAlignment(9,AlignLeft);
254 mListView->setColumnAlignment(10,AlignLeft); 254 mListView->setColumnAlignment(10,AlignLeft);
255 mListView->setColumnWidthMode(10, QListView::Manual); 255 mListView->setColumnWidthMode(10, QListView::Manual);
256 new KOListViewWhatsThis(mListView->viewport(),this); 256 new KOListViewWhatsThis(mListView->viewport(),this);
257 257
258 int iii = 0; 258 int iii = 0;
259 for ( iii = 0; iii< 10 ; ++iii ) 259 for ( iii = 0; iii< 10 ; ++iii )
260 mListView->setColumnWidthMode( iii, QListView::Manual ); 260 mListView->setColumnWidthMode( iii, QListView::Manual );
261 261
262 QBoxLayout *layoutTop = new QVBoxLayout(this); 262 QBoxLayout *layoutTop = new QVBoxLayout(this);
263 layoutTop->addWidget(mListView); 263 layoutTop->addWidget(mListView);
264 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 264 mListView->setFont ( KOPrefs::instance()->mListViewFont );
265 mPopupMenu = eventPopup(); 265 mPopupMenu = eventPopup();
266 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 266 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
267 i18n("Select all"),this, 267 i18n("Select all"),this,
268 SLOT(allSelection()),true); 268 SLOT(allSelection()),true);
269 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 269 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
270 i18n("Deselect all"),this, 270 i18n("Deselect all"),this,
271 SLOT(clearSelection()),true); 271 SLOT(clearSelection()),true);
272 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 272 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
273 i18n("Delete all selected"),this, 273 i18n("Delete all selected"),this,
274 SLOT(deleteAll()),true); 274 SLOT(deleteAll()),true);
275 mPopupMenu->insertSeparator(); 275 mPopupMenu->insertSeparator();
276 QPopupMenu * exportPO = new QPopupMenu ( this ); 276 QPopupMenu * exportPO = new QPopupMenu ( this );
277 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 277 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
278 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 278 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
279 SLOT(saveToFile())); 279 SLOT(saveToFile()));
280 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 280 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
281 SLOT(saveToFileVCS())); 281 SLOT(saveToFileVCS()));
282 exportPO->insertItem( i18n("Journal/Details..."),this, 282 exportPO->insertItem( i18n("Journal/Details..."),this,
283 SLOT(saveDescriptionToFile())); 283 SLOT(saveDescriptionToFile()));
284 // mPopupMenu->insertSeparator(); 284 // mPopupMenu->insertSeparator();
285 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 285 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
286 i18n("Add Categ. to selected..."),this, 286 i18n("Add Categ. to selected..."),this,
287 SLOT(addCat()),true); 287 SLOT(addCat()),true);
288 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 288 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
289 i18n("Set Categ. for selected..."),this, 289 i18n("Set Categ. for selected..."),this,
290 SLOT(setCat()),true); 290 SLOT(setCat()),true);
291 //mPopupMenu->insertSeparator(); 291 //mPopupMenu->insertSeparator();
292 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 292 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
293 i18n("Set alarm for selected..."),this, 293 i18n("Set alarm for selected..."),this,
294 SLOT(setAlarm()),true); 294 SLOT(setAlarm()),true);
295 295
296 296
297#ifndef DESKTOP_VERSION 297#ifndef DESKTOP_VERSION
298 mPopupMenu->insertSeparator(); 298 mPopupMenu->insertSeparator();
299 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 299 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
300 i18n("Beam selected via IR"),this, 300 i18n("Beam selected via IR"),this,
301 SLOT(beamSelected()),true); 301 SLOT(beamSelected()),true);
302#endif 302#endif
303 /* 303 /*
304 mPopupMenu = new QPopupMenu; 304 mPopupMenu = new QPopupMenu;
305 mPopupMenu->insertItem(i18n("Edit Event"), this, 305 mPopupMenu->insertItem(i18n("Edit Event"), this,
306 SLOT (editEvent())); 306 SLOT (editEvent()));
307 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 307 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
308 SLOT (deleteEvent())); 308 SLOT (deleteEvent()));
309 mPopupMenu->insertSeparator(); 309 mPopupMenu->insertSeparator();
310 mPopupMenu->insertItem(i18n("Show Dates"), this, 310 mPopupMenu->insertItem(i18n("Show Dates"), this,
311 SLOT(showDates())); 311 SLOT(showDates()));
312 mPopupMenu->insertItem(i18n("Hide Dates"), this, 312 mPopupMenu->insertItem(i18n("Hide Dates"), this,
313 SLOT(hideDates())); 313 SLOT(hideDates()));
314 */ 314 */
315 QObject::connect(mListView,SIGNAL( newEvent()), 315 QObject::connect(mListView,SIGNAL( newEvent()),
316 this,SIGNAL(signalNewEvent())); 316 this,SIGNAL(signalNewEvent()));
317 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 317 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
318 this,SLOT(defaultItemAction(QListViewItem *))); 318 this,SLOT(defaultItemAction(QListViewItem *)));
319 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 319 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
320 const QPoint &, int )), 320 const QPoint &, int )),
321 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 321 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
322 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 322 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
323 SLOT(processSelectionChange(QListViewItem *))); 323 SLOT(processSelectionChange(QListViewItem *)));
324 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 324 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
325 SIGNAL(showIncidenceSignal(Incidence *)) ); 325 SIGNAL(showIncidenceSignal(Incidence *)) );
326 326
327 readSettings(KOGlobals::config(),"KOListView Layout"); 327 readSettings(KOGlobals::config(),"KOListView Layout");
328} 328}
329 329
330KOListView::~KOListView() 330KOListView::~KOListView()
331{ 331{
332 delete mPopupMenu; 332 delete mPopupMenu;
333} 333}
334
334QString KOListView::getWhatsThisText(QPoint p) 335QString KOListView::getWhatsThisText(QPoint p)
335{ 336{
336 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 337 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
337 if ( item ) 338 if ( item )
338 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 339 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
339 KOPrefs::instance()->mWTshowDetails, 340 KOPrefs::instance()->mWTshowDetails,
340 KOPrefs::instance()->mWTshowCreated, 341 KOPrefs::instance()->mWTshowCreated,
341 KOPrefs::instance()->mWTshowChanged); 342 KOPrefs::instance()->mWTshowChanged);
342 return i18n("That is the list view" ); 343 return i18n("That is the list view" );
343 344
344} 345}
345 346
346void KOListView::updateList() 347void KOListView::updateList()
347{ 348{
348 // qDebug(" KOListView::updateList() "); 349 // qDebug(" KOListView::updateList() ");
349 350
350} 351}
351 352
352void KOListView::addCat( ) 353void KOListView::addCat( )
353{ 354{
354 setCategories( false ); 355 setCategories( false );
355} 356}
356void KOListView::setCat() 357void KOListView::setCat()
357{ 358{
358 setCategories( true ); 359 setCategories( true );
359} 360}
360void KOListView::setAlarm() 361void KOListView::setAlarm()
361{ 362{
362 KOAlarmPrefs kap( this); 363 KOAlarmPrefs kap( this);
363 if ( !kap.exec() ) 364 if ( !kap.exec() )
364 return; 365 return;
365 366
366 367
367 QStringList itemList; 368 QStringList itemList;
368 QPtrList<KOListViewItem> sel ; 369 QPtrList<KOListViewItem> sel ;
369 QListViewItem *qitem = mListView->firstChild (); 370 QListViewItem *qitem = mListView->firstChild ();
370 while ( qitem ) { 371 while ( qitem ) {
371 if ( qitem->isSelected() ) { 372 if ( qitem->isSelected() ) {
372 Incidence* inc = ((KOListViewItem *) qitem)->data(); 373 Incidence* inc = ((KOListViewItem *) qitem)->data();
373 if ( inc->type() != "Journal" ) { 374 if ( inc->type() != "Journal" ) {
374 if ( inc->type() == "Todo" ) { 375 if ( inc->type() == "Todo" ) {
375 if ( ((Todo*)inc)->hasDueDate() ) 376 if ( ((Todo*)inc)->hasDueDate() )
376 sel.append(((KOListViewItem *)qitem)); 377 sel.append(((KOListViewItem *)qitem));
377 } else 378 } else
378 sel.append(((KOListViewItem *)qitem)); 379 sel.append(((KOListViewItem *)qitem));
379 } 380 }
380 } 381 }
381 qitem = qitem->nextSibling(); 382 qitem = qitem->nextSibling();
382 } 383 }
383 int count = 0; 384 int count = 0;
384 KOListViewItem * item, *temp; 385 KOListViewItem * item, *temp;
385 item = sel.first(); 386 item = sel.first();
386 Incidence* inc; 387 Incidence* inc;
387 while ( item ) { 388 while ( item ) {
388 inc = item->data(); 389 inc = item->data();
389 ++count; 390 ++count;
390 if (kap.mAlarmButton->isChecked()) { 391 if (kap.mAlarmButton->isChecked()) {
391 if (inc->alarms().count() == 0) 392 if (inc->alarms().count() == 0)
392 inc->newAlarm(); 393 inc->newAlarm();
393 QPtrList<Alarm> alarms = inc->alarms(); 394 QPtrList<Alarm> alarms = inc->alarms();
394 Alarm *alarm; 395 Alarm *alarm;
395 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 396 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
396 alarm->setEnabled(true); 397 alarm->setEnabled(true);
397 int j = kap.mAlarmTimeEdit->value()* -60; 398 int j = kap.mAlarmTimeEdit->value()* -60;
398 if (kap.mAlarmIncrCombo->currentItem() == 1) 399 if (kap.mAlarmIncrCombo->currentItem() == 1)
399 j = j * 60; 400 j = j * 60;
400 else if (kap.mAlarmIncrCombo->currentItem() == 2) 401 else if (kap.mAlarmIncrCombo->currentItem() == 2)
401 j = j * (60 * 24); 402 j = j * (60 * 24);
402 alarm->setStartOffset( j ); 403 alarm->setStartOffset( j );
403 404
404 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 405 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
405 alarm->setProcedureAlarm(kap.mAlarmProgram); 406 alarm->setProcedureAlarm(kap.mAlarmProgram);
406 } 407 }
407 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 408 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
408 alarm->setAudioAlarm(kap.mAlarmSound); 409 alarm->setAudioAlarm(kap.mAlarmSound);
409 else 410 else
410 alarm->setType(Alarm::Invalid); 411 alarm->setType(Alarm::Invalid);
411 //alarm->setAudioAlarm("default"); 412 //alarm->setAudioAlarm("default");
412 // TODO: Deal with multiple alarms 413 // TODO: Deal with multiple alarms
413 break; // For now, stop after the first alarm 414 break; // For now, stop after the first alarm
414 } 415 }
415 } else { 416 } else {
416 Alarm* alarm = inc->alarms().first(); 417 Alarm* alarm = inc->alarms().first();
417 if ( alarm ) { 418 if ( alarm ) {
418 alarm->setEnabled(false); 419 alarm->setEnabled(false);
419 alarm->setType(Alarm::Invalid); 420 alarm->setType(Alarm::Invalid);
420 } 421 }
421 } 422 }
422 temp = item; 423 temp = item;
423 item = sel.next(); 424 item = sel.next();
424 mUidDict.remove( inc->uid() ); 425 mUidDict.remove( inc->uid() );
425 delete temp;; 426 delete temp;;
426 addIncidence( inc ); 427 addIncidence( inc );
427 } 428 }
428 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); 429 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) );
429 qDebug("KO: Set alarm for %d items", count); 430 qDebug("KO: Set alarm for %d items", count);
430 calendar()->reInitAlarmSettings(); 431 calendar()->reInitAlarmSettings();
432 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
431} 433}
432void KOListView::setCategories( bool removeOld ) 434void KOListView::setCategories( bool removeOld )
433{ 435{
434 436
435 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 437 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
436 if (! csd->exec()) { 438 if (! csd->exec()) {
437 delete csd; 439 delete csd;
438 return; 440 return;
439 } 441 }
440 QStringList catList = csd->selectedCategories(); 442 QStringList catList = csd->selectedCategories();
441 delete csd; 443 delete csd;
442 // if ( catList.count() == 0 ) 444 // if ( catList.count() == 0 )
443 // return; 445 // return;
444 catList.sort(); 446 catList.sort();
445 QString categoriesStr = catList.join(","); 447 QString categoriesStr = catList.join(",");
446 int i; 448 int i;
447 QStringList itemList; 449 QStringList itemList;
448 QPtrList<KOListViewItem> sel ; 450 QPtrList<KOListViewItem> sel ;
449 QListViewItem *qitem = mListView->firstChild (); 451 QListViewItem *qitem = mListView->firstChild ();
450 while ( qitem ) { 452 while ( qitem ) {
451 if ( qitem->isSelected() ) { 453 if ( qitem->isSelected() ) {
452 sel.append(((KOListViewItem *)qitem)); 454 sel.append(((KOListViewItem *)qitem));
453 } 455 }
454 qitem = qitem->nextSibling(); 456 qitem = qitem->nextSibling();
455 } 457 }
456 KOListViewItem * item, *temp; 458 KOListViewItem * item, *temp;
457 item = sel.first(); 459 item = sel.first();
458 Incidence* inc; 460 Incidence* inc;
459 while ( item ) { 461 while ( item ) {
460 inc = item->data(); 462 inc = item->data();
461 if ( removeOld ) { 463 if ( removeOld ) {
462 inc->setCategories( categoriesStr ); 464 inc->setCategories( categoriesStr );
463 } else { 465 } else {
464 itemList = QStringList::split (",", inc->categoriesStr() ); 466 itemList = QStringList::split (",", inc->categoriesStr() );
465 for( i = 0; i< catList.count(); ++i ) { 467 for( i = 0; i< catList.count(); ++i ) {
466 if ( !itemList.contains (catList[i])) 468 if ( !itemList.contains (catList[i]))
467 itemList.append( catList[i] ); 469 itemList.append( catList[i] );
468 } 470 }
469 itemList.sort(); 471 itemList.sort();
470 inc->setCategories( itemList.join(",") ); 472 inc->setCategories( itemList.join(",") );
471 } 473 }
472 temp = item; 474 temp = item;
473 item = sel.next(); 475 item = sel.next();
474 mUidDict.remove( inc->uid() ); 476 mUidDict.remove( inc->uid() );
475 delete temp;; 477 delete temp;;
476 addIncidence( inc ); 478 addIncidence( inc );
477 } 479 }
480 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
478} 481}
479 482
480void KOListView::beamSelected() 483void KOListView::beamSelected()
481{ 484{
482 int icount = 0; 485 int icount = 0;
483 QPtrList<Incidence> delSel ; 486 QPtrList<Incidence> delSel ;
484 QListViewItem *item = mListView->firstChild (); 487 QListViewItem *item = mListView->firstChild ();
485 while ( item ) { 488 while ( item ) {
486 if ( item->isSelected() ) { 489 if ( item->isSelected() ) {
487 delSel.append(((KOListViewItem *)item)->data()); 490 delSel.append(((KOListViewItem *)item)->data());
488 ++icount; 491 ++icount;
489 } 492 }
490 493
491 item = item->nextSibling(); 494 item = item->nextSibling();
492 } 495 }
493 if ( icount ) { 496 if ( icount ) {
494 emit beamIncidenceList( delSel ); 497 emit beamIncidenceList( delSel );
495 return; 498 return;
496 QString fn ; 499 QString fn ;
497 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 500 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
498 QString mes; 501 QString mes;
499 bool createbup = true; 502 bool createbup = true;
500 if ( createbup ) { 503 if ( createbup ) {
501 QString description = "\n"; 504 QString description = "\n";
502 CalendarLocal* cal = new CalendarLocal(); 505 CalendarLocal* cal = new CalendarLocal();
503 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 506 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
504 Incidence *incidence = delSel.first(); 507 Incidence *incidence = delSel.first();
505 while ( incidence ) { 508 while ( incidence ) {
506 Incidence *in = incidence->clone(); 509 Incidence *in = incidence->clone();
507 description += in->summary() + "\n"; 510 description += in->summary() + "\n";
508 cal->addIncidence( in ); 511 cal->addIncidence( in );
509 incidence = delSel.next(); 512 incidence = delSel.next();
510 } 513 }
511 FileStorage storage( cal, fn, new VCalFormat ); 514 FileStorage storage( cal, fn, new VCalFormat );
512 storage.save(); 515 storage.save();
513 delete cal; 516 delete cal;
514 mes = i18n("KO/Pi: Ready for beaming"); 517 mes = i18n("KO/Pi: Ready for beaming");
515 topLevelWidget()->setCaption(mes); 518 topLevelWidget()->setCaption(mes);
516 519
517#ifndef DESKTOP_VERSION 520#ifndef DESKTOP_VERSION
518 Ir *ir = new Ir( this ); 521 Ir *ir = new Ir( this );
519 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 522 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
520 ir->send( fn, description, "text/x-vCalendar" ); 523 ir->send( fn, description, "text/x-vCalendar" );
521#endif 524#endif
522 } 525 }
523 } 526 }
524} 527}
525void KOListView::beamDone( Ir *ir ) 528void KOListView::beamDone( Ir *ir )
526{ 529{
527#ifndef DESKTOP_VERSION 530#ifndef DESKTOP_VERSION
528 delete ir; 531 delete ir;
529#endif 532#endif
530 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 533 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
531} 534}
532 535
533void KOListView::saveDescriptionToFile() 536void KOListView::saveDescriptionToFile()
534{ 537{
535 538
536 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 539 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
537 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 540 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
538 i18n("Continue"), i18n("Cancel"), 0, 541 i18n("Continue"), i18n("Cancel"), 0,
539 0, 1 ); 542 0, 1 );
540 if ( result != 0 ) { 543 if ( result != 0 ) {
541 return; 544 return;
542 } 545 }
543 int icount = 0; 546 int icount = 0;
544 QPtrList<Incidence> delSel ; 547 QPtrList<Incidence> delSel ;
545 QListViewItem *item = mListView->firstChild (); 548 QListViewItem *item = mListView->firstChild ();
546 while ( item ) { 549 while ( item ) {
547 if ( item->isSelected() ) { 550 if ( item->isSelected() ) {
548 delSel.append(((KOListViewItem *)item)->data()); 551 delSel.append(((KOListViewItem *)item)->data());
549 ++icount; 552 ++icount;
550 } 553 }
551 554
552 item = item->nextSibling(); 555 item = item->nextSibling();
553 } 556 }
554 if ( icount ) { 557 if ( icount ) {
555 QString fn = KOPrefs::instance()->mLastSaveFile; 558 QString fn = KOPrefs::instance()->mLastSaveFile;
556 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 559 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
557 560
558 if ( fn == "" ) 561 if ( fn == "" )
559 return; 562 return;
560 QFileInfo info; 563 QFileInfo info;
561 info.setFile( fn ); 564 info.setFile( fn );
562 QString mes; 565 QString mes;
563 bool createbup = true; 566 bool createbup = true;
564 if ( info. exists() ) { 567 if ( info. exists() ) {
565 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 568 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
566 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 569 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
567 i18n("Overwrite!"), i18n("Cancel"), 0, 570 i18n("Overwrite!"), i18n("Cancel"), 0,
568 0, 1 ); 571 0, 1 );
569 if ( result != 0 ) { 572 if ( result != 0 ) {
570 createbup = false; 573 createbup = false;
571 } 574 }
572 } 575 }
573 if ( createbup ) { 576 if ( createbup ) {
574 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 577 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
575 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 578 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
576 Incidence *incidence = delSel.first(); 579 Incidence *incidence = delSel.first();
577 icount = 0; 580 icount = 0;
578 while ( incidence ) { 581 while ( incidence ) {
579 if ( incidence->type() == "Journal" ) { 582 if ( incidence->type() == "Journal" ) {
580 text += "\n************************************\n"; 583 text += "\n************************************\n";
581 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 584 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
582 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 585 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
583 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 586 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
584 ++icount; 587 ++icount;
585 588
586 } else { 589 } else {
587 if ( !incidence->description().isEmpty() ) { 590 if ( !incidence->description().isEmpty() ) {
588 text += "\n************************************\n"; 591 text += "\n************************************\n";
589 if ( incidence->type() == "Todo" ) 592 if ( incidence->type() == "Todo" )
590 text += i18n("To-Do: "); 593 text += i18n("To-Do: ");
591 text += incidence->summary(); 594 text += incidence->summary();
592 if ( incidence->hasStartDate() ) 595 if ( incidence->hasStartDate() )
593 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 596 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
594 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 597 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
595 if ( !incidence->location().isEmpty() ) 598 if ( !incidence->location().isEmpty() )
596 text += "\n" +i18n("Location: ") + incidence->location(); 599 text += "\n" +i18n("Location: ") + incidence->location();
597 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 600 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
598 ++icount; 601 ++icount;
599 602
600 } 603 }
601 } 604 }
602 incidence = delSel.next(); 605 incidence = delSel.next();
603 } 606 }
604 QFile file( fn ); 607 QFile file( fn );
605 if (!file.open( IO_WriteOnly ) ) { 608 if (!file.open( IO_WriteOnly ) ) {
606 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 609 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
607 return; 610 return;
608 } 611 }
609 QTextStream ts( &file ); 612 QTextStream ts( &file );
610 ts << text; 613 ts << text;
611 file.close(); 614 file.close();
612 //qDebug("%s ", text.latin1()); 615 //qDebug("%s ", text.latin1());
613 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 616 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
614 KOPrefs::instance()->mLastSaveFile = fn; 617 KOPrefs::instance()->mLastSaveFile = fn;
615 topLevelWidget()->setCaption(mes); 618 topLevelWidget()->setCaption(mes);
616 } 619 }
617 } 620 }
618} 621}
619void KOListView::saveToFileVCS() 622void KOListView::saveToFileVCS()
620{ 623{
621 writeToFile( false ); 624 writeToFile( false );
622} 625}
623void KOListView::saveToFile() 626void KOListView::saveToFile()
624{ 627{
625 writeToFile( true ); 628 writeToFile( true );
626} 629}
627void KOListView::writeToFile( bool iCal ) 630void KOListView::writeToFile( bool iCal )
628{ 631{
629 632
630 int icount = 0; 633 int icount = 0;
631 QPtrList<Incidence> delSel ; 634 QPtrList<Incidence> delSel ;
632 QListViewItem *item = mListView->firstChild (); 635 QListViewItem *item = mListView->firstChild ();
633 bool journal = iCal; // warn only for vCal 636 bool journal = iCal; // warn only for vCal
634 while ( item ) { 637 while ( item ) {
635 if ( item->isSelected() ) { 638 if ( item->isSelected() ) {
636 if ( !journal ) 639 if ( !journal )
637 if ( ((KOListViewItem *)item)->data()->type() == "Journal") 640 if ( ((KOListViewItem *)item)->data()->type() == "Journal")
638 journal = true; 641 journal = true;
639 delSel.append(((KOListViewItem *)item)->data()); 642 delSel.append(((KOListViewItem *)item)->data());
640 ++icount; 643 ++icount;
641 } 644 }
642 645
643 item = item->nextSibling(); 646 item = item->nextSibling();
644 } 647 }
645 if ( !iCal && journal ) { 648 if ( !iCal && journal ) {
646 int result = KMessageBox::warningContinueCancel(this, 649 int result = KMessageBox::warningContinueCancel(this,
647 i18n("The journal entries can not be\nexported to a vCalendar file."), 650 i18n("The journal entries can not be\nexported to a vCalendar file."),
648 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 651 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
649 true); 652 true);
650 if (result != KMessageBox::Continue) return; 653 if (result != KMessageBox::Continue) return;
651 } 654 }
652 if ( icount ) { 655 if ( icount ) {
653 QString fn = KOPrefs::instance()->mLastSaveFile; 656 QString fn = KOPrefs::instance()->mLastSaveFile;
654 QString extension; 657 QString extension;
655 if ( iCal ) { 658 if ( iCal ) {
656 if ( fn.right( 4 ).lower() == ".vcs" ) { 659 if ( fn.right( 4 ).lower() == ".vcs" ) {
657 fn = fn.left( fn.length() -3) + "ics"; 660 fn = fn.left( fn.length() -3) + "ics";
658 } 661 }
659 } else { 662 } else {
660 if ( fn.right( 4 ).lower() == ".ics" ) { 663 if ( fn.right( 4 ).lower() == ".ics" ) {
661 fn = fn.left( fn.length() -3) + "vcs"; 664 fn = fn.left( fn.length() -3) + "vcs";
662 } 665 }
663 } 666 }
664 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 667 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
665 668
666 if ( fn == "" ) 669 if ( fn == "" )
667 return; 670 return;
668 QFileInfo info; 671 QFileInfo info;
669 info.setFile( fn ); 672 info.setFile( fn );
670 QString mes; 673 QString mes;
671 bool createbup = true; 674 bool createbup = true;
672 if ( info. exists() ) { 675 if ( info. exists() ) {
673 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 676 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
674 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 677 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
675 i18n("Overwrite!"), i18n("Cancel"), 0, 678 i18n("Overwrite!"), i18n("Cancel"), 0,
676 0, 1 ); 679 0, 1 );
677 if ( result != 0 ) { 680 if ( result != 0 ) {
678 createbup = false; 681 createbup = false;
679 } 682 }
680 } 683 }
681 if ( createbup ) { 684 if ( createbup ) {
682 CalendarLocal cal; 685 CalendarLocal cal;
683 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 686 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
684 Incidence *incidence = delSel.first(); 687 Incidence *incidence = delSel.first();
685 while ( incidence ) { 688 while ( incidence ) {
686 cal.addIncidence( incidence->clone() ); 689 cal.addIncidence( incidence->clone() );
687 incidence = delSel.next(); 690 incidence = delSel.next();
688 } 691 }
689 if ( iCal ) { 692 if ( iCal ) {
690 ICalFormat format; 693 ICalFormat format;
691 format.save( &cal, fn ); 694 format.save( &cal, fn );
692 } else { 695 } else {
693 696
694 VCalFormat format; 697 VCalFormat format;
695 format.save( &cal, fn ); 698 format.save( &cal, fn );
696 } 699 }
697 mes = i18n("KO/Pi:Saved %1").arg(fn ); 700 mes = i18n("KO/Pi:Saved %1").arg(fn );
698 KOPrefs::instance()->mLastSaveFile = fn; 701 KOPrefs::instance()->mLastSaveFile = fn;
699 topLevelWidget()->setCaption(mes); 702 topLevelWidget()->setCaption(mes);
700 } 703 }
701 } 704 }
705 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
702} 706}
703void KOListView::deleteAll() 707void KOListView::deleteAll()
704{ 708{
705 int icount = 0; 709 int icount = 0;
706 QPtrList<Incidence> delSel ; 710 QPtrList<Incidence> delSel ;
707 QListViewItem *item = mListView->firstChild (); 711 QListViewItem *item = mListView->firstChild ();
708 while ( item ) { 712 while ( item ) {
709 if ( item->isSelected() ) { 713 if ( item->isSelected() ) {
710 delSel.append(((KOListViewItem *)item)->data()); 714 delSel.append(((KOListViewItem *)item)->data());
711 ++icount; 715 ++icount;
712 } 716 }
713 717
714 item = item->nextSibling(); 718 item = item->nextSibling();
715 } 719 }
716 if ( icount ) { 720 if ( icount ) {
717 Incidence *incidence = delSel.first(); 721 Incidence *incidence = delSel.first();
718 Incidence *toDelete; 722 Incidence *toDelete;
719 KOPrefs *p = KOPrefs::instance(); 723 KOPrefs *p = KOPrefs::instance();
720 bool confirm = p->mConfirm; 724 bool confirm = p->mConfirm;
721 QString mess; 725 QString mess;
722 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 726 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
723 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 727 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
724 p->mConfirm = false; 728 p->mConfirm = false;
725 int delCounter = 0; 729 int delCounter = 0;
726 QDialog dia ( this, "p-dialog", true ); 730 QDialog dia ( this, "p-dialog", true );
727 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 731 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
728 QVBoxLayout lay( &dia ); 732 QVBoxLayout lay( &dia );
729 lay.setMargin(7); 733 lay.setMargin(7);
730 lay.setSpacing(7); 734 lay.setSpacing(7);
731 lay.addWidget( &lab); 735 lay.addWidget( &lab);
732 QProgressBar bar( icount, &dia ); 736 QProgressBar bar( icount, &dia );
733 lay.addWidget( &bar); 737 lay.addWidget( &bar);
734 int w = 220; 738 int w = 220;
735 int h = 50; 739 int h = 50;
736 int dw = QApplication::desktop()->width(); 740 int dw = QApplication::desktop()->width();
737 int dh = QApplication::desktop()->height(); 741 int dh = QApplication::desktop()->height();
738 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 742 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
739 //dia.resize( 240,50 ); 743 //dia.resize( 240,50 );
740 dia.show(); 744 dia.show();
741 745
742 while ( incidence ) { 746 while ( incidence ) {
743 bar.setProgress( delCounter ); 747 bar.setProgress( delCounter );
744 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 748 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
745 dia.setCaption( mess ); 749 dia.setCaption( mess );
746 qApp->processEvents(); 750 qApp->processEvents();
747 toDelete = (incidence); 751 toDelete = (incidence);
748 incidence = delSel.next(); 752 incidence = delSel.next();
749 emit deleteIncidenceSignal(toDelete ); 753 emit deleteIncidenceSignal(toDelete );
750 if ( dia.result() != 0 ) 754 if ( dia.result() != 0 )
751 break; 755 break;
752 756
753 } 757 }
754 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 758 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
755 topLevelWidget ()->setCaption( mess ); 759 topLevelWidget ()->setCaption( mess );
756 p->mConfirm = confirm; 760 p->mConfirm = confirm;
757 } 761 }
758 } 762 }
759 763
760 764
761} 765}
762int KOListView::maxDatesHint() 766int KOListView::maxDatesHint()
763{ 767{
764 return 0; 768 return 0;
765} 769}
766 770
767int KOListView::currentDateCount() 771int KOListView::currentDateCount()
768{ 772{
769 return 0; 773 return 0;
770} 774}
771 775
772QPtrList<Incidence> KOListView::selectedIncidences() 776QPtrList<Incidence> KOListView::selectedIncidences()
773{ 777{
774 QPtrList<Incidence> eventList; 778 QPtrList<Incidence> eventList;
775 QListViewItem *item = mListView->firstChild (); 779 QListViewItem *item = mListView->firstChild ();
776 while ( item ) { 780 while ( item ) {
777 if ( item->isSelected() ) { 781 if ( item->isSelected() ) {
778 eventList.append(((KOListViewItem *)item)->data()); 782 eventList.append(((KOListViewItem *)item)->data());
779 } 783 }
780 784
781 item = item->nextSibling(); 785 item = item->nextSibling();
782 } 786 }
783 787
784 // // QListViewItem *item = mListView->selectedItem(); 788 // // QListViewItem *item = mListView->selectedItem();
785 //if (item) eventList.append(((KOListViewItem *)item)->data()); 789 //if (item) eventList.append(((KOListViewItem *)item)->data());
786 790
787 return eventList; 791 return eventList;
788} 792}
789 793
790DateList KOListView::selectedDates() 794DateList KOListView::selectedDates()
791{ 795{
792 DateList eventList; 796 DateList eventList;
793 return eventList; 797 return eventList;
794} 798}
795 799
796void KOListView::showDates(bool show) 800void KOListView::showDates(bool show)
797{ 801{
798 // Shouldn't we set it to a value greater 0? When showDates is called with 802 // Shouldn't we set it to a value greater 0? When showDates is called with
799 // show == true at first, then the columnwidths are set to zero. 803 // show == true at first, then the columnwidths are set to zero.
800 static int oldColWidth1 = 0; 804 static int oldColWidth1 = 0;
801 static int oldColWidth3 = 0; 805 static int oldColWidth3 = 0;
802 806
803 if (!show) { 807 if (!show) {
804 oldColWidth1 = mListView->columnWidth(1); 808 oldColWidth1 = mListView->columnWidth(1);
805 oldColWidth3 = mListView->columnWidth(3); 809 oldColWidth3 = mListView->columnWidth(3);
806 mListView->setColumnWidth(1, 0); 810 mListView->setColumnWidth(1, 0);
807 mListView->setColumnWidth(3, 0); 811 mListView->setColumnWidth(3, 0);
808 } else { 812 } else {
809 mListView->setColumnWidth(1, oldColWidth1); 813 mListView->setColumnWidth(1, oldColWidth1);
810 mListView->setColumnWidth(3, oldColWidth3); 814 mListView->setColumnWidth(3, oldColWidth3);
811 } 815 }
812 mListView->repaint(); 816 mListView->repaint();
813} 817}
814 818
815void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 819void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
816 const QDate &td) 820 const QDate &td)
817{ 821{
818#ifndef KORG_NOPRINTER 822#ifndef KORG_NOPRINTER
819 calPrinter->preview(CalPrinter::Day, fd, td); 823 calPrinter->preview(CalPrinter::Day, fd, td);
820#endif 824#endif
821} 825}
822 826
823void KOListView::showDates() 827void KOListView::showDates()
824{ 828{
825 showDates(true); 829 showDates(true);
826} 830}
827 831
828void KOListView::hideDates() 832void KOListView::hideDates()
829{ 833{
830 showDates(false); 834 showDates(false);
831} 835}
836
832void KOListView::resetFocus() 837void KOListView::resetFocus()
833{ 838{
839 topLevelWidget()->setActiveWindow();
840 topLevelWidget()->raise();
834 mListView->setFocus(); 841 mListView->setFocus();
835} 842}
836void KOListView::updateView() 843void KOListView::updateView()
837{ 844{
838 mListView->setFocus(); 845 mListView->setFocus();
839 if ( mListView->firstChild () ) 846 if ( mListView->firstChild () )
840 mListView->setCurrentItem( mListView->firstChild () ); 847 mListView->setCurrentItem( mListView->firstChild () );
841} 848}
842void KOListView::updateConfig() 849void KOListView::updateConfig()
843{ 850{
844 851
845 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 852 mListView->setFont ( KOPrefs::instance()->mListViewFont );
846 updateView(); 853 updateView();
847 854
848} 855}
849void KOListView::setStartDate(const QDate &start) 856void KOListView::setStartDate(const QDate &start)
850{ 857{
851 mStartDate = start; 858 mStartDate = start;
852} 859}
853 860
854void KOListView::showDates(const QDate &start, const QDate &end) 861void KOListView::showDates(const QDate &start, const QDate &end)
855{ 862{
856 clear(); 863 clear();
857 mStartDate = start; 864 mStartDate = start;
858 QDate date = start; 865 QDate date = start;
859 QPtrList<Journal> j_list; 866 QPtrList<Journal> j_list;
860 while( date <= end ) { 867 while( date <= end ) {
861 addEvents(calendar()->events(date)); 868 addEvents(calendar()->events(date));
862 addTodos(calendar()->todos(date)); 869 addTodos(calendar()->todos(date));
863 Journal* jo = calendar()->journal(date); 870 Journal* jo = calendar()->journal(date);
864 if ( jo ) 871 if ( jo )
865 j_list.append( jo ); 872 j_list.append( jo );
866 date = date.addDays( 1 ); 873 date = date.addDays( 1 );
867 } 874 }
868 addJournals(j_list); 875 addJournals(j_list);
869 emit incidenceSelected( 0 ); 876 emit incidenceSelected( 0 );
870 updateView(); 877 updateView();
871 878
872} 879}
873 880
874void KOListView::addEvents(QPtrList<Event> eventList) 881void KOListView::addEvents(QPtrList<Event> eventList)
875{ 882{
876 Event *ev; 883 Event *ev;
877 for(ev = eventList.first(); ev; ev = eventList.next()) { 884 for(ev = eventList.first(); ev; ev = eventList.next()) {
878 addIncidence(ev); 885 addIncidence(ev);
879 } 886 }
880 if ( !mListView->currentItem() ){ 887 if ( !mListView->currentItem() ){
881 updateView(); 888 updateView();
882 } 889 }
883} 890}
884 891
885void KOListView::addTodos(QPtrList<Todo> eventList) 892void KOListView::addTodos(QPtrList<Todo> eventList)
886{ 893{
887 Todo *ev; 894 Todo *ev;
888 for(ev = eventList.first(); ev; ev = eventList.next()) { 895 for(ev = eventList.first(); ev; ev = eventList.next()) {
889 addIncidence(ev); 896 addIncidence(ev);
890 } 897 }
891 if ( !mListView->currentItem() ){ 898 if ( !mListView->currentItem() ){
892 updateView(); 899 updateView();
893 } 900 }
894} 901}
895void KOListView::addJournals(QPtrList<Journal> eventList) 902void KOListView::addJournals(QPtrList<Journal> eventList)
896{ 903{
897 Journal *ev; 904 Journal *ev;
898 for(ev = eventList.first(); ev; ev = eventList.next()) { 905 for(ev = eventList.first(); ev; ev = eventList.next()) {
899 addIncidence(ev); 906 addIncidence(ev);
900 } 907 }
901 if ( !mListView->currentItem() ){ 908 if ( !mListView->currentItem() ){
902 updateView(); 909 updateView();
903 } 910 }
904} 911}
905 912
906void KOListView::addIncidence(Incidence *incidence) 913void KOListView::addIncidence(Incidence *incidence)
907{ 914{
908 if ( mUidDict.find( incidence->uid() ) ) return; 915 if ( mUidDict.find( incidence->uid() ) ) return;
909 916
910 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 917 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
911 mUidDict.insert( incidence->uid(), incidence ); 918 mUidDict.insert( incidence->uid(), incidence );
912 919
913 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 920 KOListViewItem *item = new KOListViewItem( incidence, mListView );
914 ListItemVisitor v(item, mStartDate ); 921 ListItemVisitor v(item, mStartDate );
915 if (incidence->accept(v)) return; 922 if (incidence->accept(v)) return;
916 else delete item; 923 else delete item;
917 //qDebug("delete item "); 924 //qDebug("delete item ");
918} 925}
919 926
920void KOListView::showEvents(QPtrList<Event> eventList) 927void KOListView::showEvents(QPtrList<Event> eventList)
921{ 928{
922 clear(); 929 clear();
923 930
924 addEvents(eventList); 931 addEvents(eventList);
925 932
926 // After new creation of list view no events are selected. 933 // After new creation of list view no events are selected.
927 emit incidenceSelected( 0 ); 934 emit incidenceSelected( 0 );
928} 935}
929int KOListView::count() 936int KOListView::count()
930{ 937{
931 return mListView->childCount(); 938 return mListView->childCount();
932} 939}
933 940
934void KOListView::changeEventDisplay(Event *event, int action) 941void KOListView::changeEventDisplay(Event *event, int action)
935{ 942{
936 KOListViewItem *item; 943 KOListViewItem *item;
937 944
938 switch(action) { 945 switch(action) {
939 case KOGlobals::EVENTADDED: 946 case KOGlobals::EVENTADDED:
940 addIncidence( event ); 947 addIncidence( event );
941 break; 948 break;
942 case KOGlobals::EVENTEDITED: 949 case KOGlobals::EVENTEDITED:
943 item = getItemForEvent(event); 950 item = getItemForEvent(event);
944 if (item) { 951 if (item) {
945 mUidDict.remove( event->uid() ); 952 mUidDict.remove( event->uid() );
946 delete item; 953 delete item;
947 addIncidence( event ); 954 addIncidence( event );
948 } 955 }
949 break; 956 break;
950 case KOGlobals::EVENTDELETED: 957 case KOGlobals::EVENTDELETED:
951 item = getItemForEvent(event); 958 item = getItemForEvent(event);
952 if (item) { 959 if (item) {
953 mUidDict.remove( event->uid() ); 960 mUidDict.remove( event->uid() );
954 delete item; 961 delete item;
955 } 962 }
956 break; 963 break;
957 default: 964 default:
958 ; 965 ;
959 } 966 }
960} 967}
961 968
962KOListViewItem *KOListView::getItemForEvent(Event *event) 969KOListViewItem *KOListView::getItemForEvent(Event *event)
963{ 970{
964 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 971 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
965 while (item) { 972 while (item) {
966 if (item->data() == event) return item; 973 if (item->data() == event) return item;
967 item = (KOListViewItem *)item->nextSibling(); 974 item = (KOListViewItem *)item->nextSibling();
968 } 975 }
969 return 0; 976 return 0;
970} 977}
971 978
972void KOListView::defaultItemAction(QListViewItem *i) 979void KOListView::defaultItemAction(QListViewItem *i)
973{ 980{
974 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 981 KOListViewItem *item = static_cast<KOListViewItem *>( i );
975 if ( item ) defaultAction( item->data() ); 982 if ( item ) defaultAction( item->data() );
976 983
977} 984}
978 985
979void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 986void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
980{ 987{
981 mActiveItem = (KOListViewItem *)item; 988 mActiveItem = (KOListViewItem *)item;
982 if (mActiveItem) { 989 if (mActiveItem) {
983 Incidence *incidence = mActiveItem->data(); 990 Incidence *incidence = mActiveItem->data();
984 mPopupMenu->showIncidencePopup(incidence); 991 mPopupMenu->showIncidencePopup(incidence);
985 992
986 /* 993 /*
987 if ( incidence && incidence->type() == "Event" ) { 994 if ( incidence && incidence->type() == "Event" ) {
988 Event *event = static_cast<Event *>( incidence ); 995 Event *event = static_cast<Event *>( incidence );
989 mPopupMenu->showEventPopup(event); 996 mPopupMenu->showEventPopup(event);
990 } 997 }
991 */ 998 */
992 } 999 }
993} 1000}
994 1001
995void KOListView::readSettings(KConfig *config, QString setting) 1002void KOListView::readSettings(KConfig *config, QString setting)
996{ 1003{
997 // qDebug("KOListView::readSettings "); 1004 // qDebug("KOListView::readSettings ");
998 mListView->restoreLayout(config,setting); 1005 mListView->restoreLayout(config,setting);
999} 1006}
1000 1007
1001void KOListView::writeSettings(KConfig *config, QString setting) 1008void KOListView::writeSettings(KConfig *config, QString setting)
1002{ 1009{
1003 // qDebug("KOListView::writeSettings "); 1010 // qDebug("KOListView::writeSettings ");
1004 mListView->saveLayout(config, setting); 1011 mListView->saveLayout(config, setting);
1005} 1012}
1006 1013
1007void KOListView::processSelectionChange(QListViewItem *) 1014void KOListView::processSelectionChange(QListViewItem *)
1008{ 1015{
1009 1016
1010 KOListViewItem *item = 1017 KOListViewItem *item =
1011 static_cast<KOListViewItem *>( mListView->currentItem() ); 1018 static_cast<KOListViewItem *>( mListView->currentItem() );
1012 1019
1013 if ( !item ) { 1020 if ( !item ) {
1014 emit incidenceSelected( 0 ); 1021 emit incidenceSelected( 0 );
1015 } else { 1022 } else {
1016 emit incidenceSelected( item->data() ); 1023 emit incidenceSelected( item->data() );
1017 } 1024 }
1018} 1025}
1019 1026
1020void KOListView::clearSelection() 1027void KOListView::clearSelection()
1021{ 1028{
1022 mListView->selectAll( false ); 1029 mListView->selectAll( false );
1023} 1030}
1024void KOListView::allSelection() 1031void KOListView::allSelection()
1025{ 1032{
1026 mListView->selectAll( true ); 1033 mListView->selectAll( true );
1027} 1034}
1028 1035
1029void KOListView::clear() 1036void KOListView::clear()
1030{ 1037{
1031 mListView->clear(); 1038 mListView->clear();
1032 mUidDict.clear(); 1039 mUidDict.clear();
1033} 1040}
1034 1041
1035Incidence* KOListView::currentItem() 1042Incidence* KOListView::currentItem()
1036{ 1043{
1037 if ( mListView->currentItem() ) 1044 if ( mListView->currentItem() )
1038 return ((KOListViewItem*) mListView->currentItem())->data(); 1045 return ((KOListViewItem*) mListView->currentItem())->data();
1039 return 0; 1046 return 0;
1040} 1047}
1041void KOListView::keyPressEvent ( QKeyEvent *e) 1048void KOListView::keyPressEvent ( QKeyEvent *e)
1042{ 1049{
1043 1050
1044 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1051 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1045 deleteAll(); 1052 deleteAll();
1046 return; 1053 return;
1047 } 1054 }
1048 1055
1049 e->ignore(); 1056 e->ignore();
1050} 1057}
1051void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1058void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1052{ 1059{
1053 1060
1054 switch ( e->key() ) { 1061 switch ( e->key() ) {
1055 case Qt::Key_Down: 1062 case Qt::Key_Down:
1056 if ( e->state() == ShiftButton ) { 1063 if ( e->state() == ShiftButton ) {
1057 QListViewItem* cn = currentItem(); 1064 QListViewItem* cn = currentItem();
1058 if ( !cn ) 1065 if ( !cn )
1059 cn = firstChild(); 1066 cn = firstChild();
1060 if ( !cn ) 1067 if ( !cn )
1061 return; 1068 return;
1062 while ( cn->nextSibling() ) 1069 while ( cn->nextSibling() )
1063 cn = cn->nextSibling(); 1070 cn = cn->nextSibling();
1064 setCurrentItem ( cn ); 1071 setCurrentItem ( cn );
1065 ensureItemVisible ( cn ); 1072 ensureItemVisible ( cn );
1066 1073
1067 e->accept(); 1074 e->accept();
1068 return; 1075 return;
1069 } 1076 }
1070 if ( e->state() == ControlButton ) { 1077 if ( e->state() == ControlButton ) {
1071 int count = childCount (); 1078 int count = childCount ();
1072 int jump = count / 5; 1079 int jump = count / 5;
1073 QListViewItem* cn; 1080 QListViewItem* cn;
1074 cn = currentItem(); 1081 cn = currentItem();
1075 if ( ! cn ) 1082 if ( ! cn )
1076 return; 1083 return;
1077 if ( jump == 0 ) 1084 if ( jump == 0 )
1078 jump = 1; 1085 jump = 1;
1079 while ( jump && cn->nextSibling() ) { 1086 while ( jump && cn->nextSibling() ) {
1080 cn = cn->nextSibling(); 1087 cn = cn->nextSibling();
1081 --jump; 1088 --jump;
1082 } 1089 }
1083 setCurrentItem ( cn ); 1090 setCurrentItem ( cn );
1084 ensureItemVisible ( cn ); 1091 ensureItemVisible ( cn );
1085 1092
1086 } else 1093 } else
1087 QListView::keyPressEvent ( e ) ; 1094 QListView::keyPressEvent ( e ) ;
1088 e->accept(); 1095 e->accept();
1089 break; 1096 break;
1090 1097
1091 case Qt::Key_Up: 1098 case Qt::Key_Up:
1092 if ( e->state() == ShiftButton ) { 1099 if ( e->state() == ShiftButton ) {
1093 QListViewItem* cn = firstChild(); 1100 QListViewItem* cn = firstChild();
1094 if ( cn ) { 1101 if ( cn ) {
1095 setCurrentItem ( cn ); 1102 setCurrentItem ( cn );
1096 ensureItemVisible ( cn ); 1103 ensureItemVisible ( cn );
1097 } 1104 }
1098 e->accept(); 1105 e->accept();
1099 return; 1106 return;
1100 } 1107 }
1101 if ( e->state() == ControlButton ) { 1108 if ( e->state() == ControlButton ) {
1102 int count = childCount (); 1109 int count = childCount ();
1103 int jump = count / 5; 1110 int jump = count / 5;
1104 QListViewItem* cn; 1111 QListViewItem* cn;
1105 cn = currentItem(); 1112 cn = currentItem();
1106 if ( ! cn ) 1113 if ( ! cn )
1107 return; 1114 return;
1108 if ( jump == 0 ) 1115 if ( jump == 0 )
1109 jump = 1; 1116 jump = 1;
1110 while ( jump && cn->itemAbove ()) { 1117 while ( jump && cn->itemAbove ()) {
1111 cn = cn->itemAbove (); 1118 cn = cn->itemAbove ();
1112 --jump; 1119 --jump;
1113 } 1120 }
1114 setCurrentItem ( cn ); 1121 setCurrentItem ( cn );
1115 ensureItemVisible ( cn ); 1122 ensureItemVisible ( cn );
1116 } else 1123 } else
1117 QListView::keyPressEvent ( e ) ; 1124 QListView::keyPressEvent ( e ) ;
1118 e->accept(); 1125 e->accept();
1119 break; 1126 break;
1120 case Qt::Key_I: { 1127 case Qt::Key_I: {
1121 QListViewItem* cn; 1128 QListViewItem* cn;
1122 cn = currentItem(); 1129 cn = currentItem();
1123 if ( cn ) { 1130 if ( cn ) {
1124 KOListViewItem* ci = (KOListViewItem*)( cn ); 1131 KOListViewItem* ci = (KOListViewItem*)( cn );
1125 if ( ci ){ 1132 if ( ci ){
1126 //emit showIncidence( ci->data()); 1133 //emit showIncidence( ci->data());
1127 cn = cn->nextSibling(); 1134 cn = cn->nextSibling();
1128 if ( cn ) { 1135 if ( cn ) {
1129 setCurrentItem ( cn ); 1136 setCurrentItem ( cn );
1130 ensureItemVisible ( cn ); 1137 ensureItemVisible ( cn );
1131 } 1138 }
1132 emit showIncidence( ci->data()); 1139 emit showIncidence( ci->data());
1133 } 1140 }
1134 } 1141 }
1135 e->accept(); 1142 e->accept();
1136 } 1143 }
1137 break; 1144 break;
1138 case Qt::Key_Return: 1145 case Qt::Key_Return:
1139 case Qt::Key_Enter: 1146 case Qt::Key_Enter:
1140 { 1147 {
1141 QListViewItem* cn; 1148 QListViewItem* cn;
1142 cn = currentItem(); 1149 cn = currentItem();
1143 if ( cn ) { 1150 if ( cn ) {
1144 KOListViewItem* ci = (KOListViewItem*)( cn ); 1151 KOListViewItem* ci = (KOListViewItem*)( cn );
1145 if ( ci ){ 1152 if ( ci ){
1146 if ( e->state() == ShiftButton ) 1153 if ( e->state() == ShiftButton )
1147 ci->setSelected( false ); 1154 ci->setSelected( false );
1148 else 1155 else
1149 ci->setSelected( true ); 1156 ci->setSelected( true );
1150 cn = cn->nextSibling(); 1157 cn = cn->nextSibling();
1151 if ( cn ) { 1158 if ( cn ) {
1152 setCurrentItem ( cn ); 1159 setCurrentItem ( cn );
1153 ensureItemVisible ( cn ); 1160 ensureItemVisible ( cn );
1154 } 1161 }
1155 } 1162 }
1156 } 1163 }
1157 e->accept(); 1164 e->accept();
1158 } 1165 }
1159 break; 1166 break;
1160 default: 1167 default:
1161 e->ignore(); 1168 e->ignore();
1162 } 1169 }
1163} 1170}
1164KOListViewListView::KOListViewListView(KOListView * lv ) 1171KOListViewListView::KOListViewListView(KOListView * lv )
1165 : KListView( lv, "kolistlistview", false ) 1172 : KListView( lv, "kolistlistview", false )
1166{ 1173{
1167 mPopupTimer = new QTimer(this); 1174 mPopupTimer = new QTimer(this);
1168 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1175 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1169#ifndef DESKTOP_VERSION 1176#ifndef DESKTOP_VERSION
1170 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1177 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1171#endif 1178#endif
1172 setSelectionMode( QListView::Multi ); 1179 setSelectionMode( QListView::Multi );
1173 setMultiSelection( true); 1180 setMultiSelection( true);
1174} 1181}
1175void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1182void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1176{ 1183{
1177 if (!e) return; 1184 if (!e) return;
1178 QPoint vp = contentsToViewport(e->pos()); 1185 QPoint vp = contentsToViewport(e->pos());
1179 QListViewItem *item = itemAt(vp); 1186 QListViewItem *item = itemAt(vp);
1180 if (!item) { 1187 if (!item) {
1181 emit newEvent(); 1188 emit newEvent();
1182 return; 1189 return;
1183 } 1190 }
1184 KListView::contentsMouseDoubleClickEvent(e); 1191 KListView::contentsMouseDoubleClickEvent(e);
1185} 1192}
1186#if 0 1193#if 0
1187void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1194void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1188{ 1195{
1189 //qDebug("contentsMousePressEvent++++ "); 1196 //qDebug("contentsMousePressEvent++++ ");
1190 KListView::contentsMousePressEvent( e ); 1197 KListView::contentsMousePressEvent( e );
1191 if ( e->button() == RightButton ) { 1198 if ( e->button() == RightButton ) {
1192 QListViewItem* ci = currentItem(); 1199 QListViewItem* ci = currentItem();
1193 clearSelection () ; 1200 clearSelection () ;
1194 if ( ci ) 1201 if ( ci )
1195 ci->setSelected( true ); 1202 ci->setSelected( true );
1196 } 1203 }
1197} 1204}
1198void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1205void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1199{ 1206{
1200 KListView::contentsMouseReleaseEvent(e); 1207 KListView::contentsMouseReleaseEvent(e);
1201} 1208}
1202void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1209void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1203{ 1210{
1204 KListView::contentsMouseMoveEvent(e); 1211 KListView::contentsMouseMoveEvent(e);
1205} 1212}
1206#endif 1213#endif
1207void KOListViewListView::popupMenu() 1214void KOListViewListView::popupMenu()
1208{ 1215{
1209 mPopupTimer->stop(); 1216 mPopupTimer->stop();
1210 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1217 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1211 QApplication::postEvent( this->viewport(), e ); 1218 QApplication::postEvent( this->viewport(), e );
1212 1219
1213} 1220}
1214void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1221void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1215{ 1222{
1216 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1223 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1217 mYMousePos = mapToGlobal( (e->pos())).y(); 1224 mYMousePos = mapToGlobal( (e->pos())).y();
1218 if ( e->button() == LeftButton ) { 1225 if ( e->button() == LeftButton ) {
1219 mPopupTimer->start( 600 ); 1226 mPopupTimer->start( 600 );
1220 mEventPos = contentsToViewport(e->pos()); 1227 mEventPos = contentsToViewport(e->pos());
1221 mEventGlobalPos = e->globalPos(); 1228 mEventGlobalPos = e->globalPos();
1222 } 1229 }
1223 KListView::contentsMousePressEvent( e ); 1230 KListView::contentsMousePressEvent( e );
1224 if ( e->button() == RightButton ) { 1231 if ( e->button() == RightButton ) {
1225 QListViewItem* ci = currentItem(); 1232 QListViewItem* ci = currentItem();
1226 //clearSelection(); 1233 //clearSelection();
1227 if ( ci ) 1234 if ( ci )
1228 ci->setSelected( true ); 1235 ci->setSelected( true );
1229 } 1236 }
1230} 1237}
1231void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1238void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1232{ 1239{
1233 mPopupTimer->stop(); 1240 mPopupTimer->stop();
1234 KListView::contentsMouseReleaseEvent(e); 1241 KListView::contentsMouseReleaseEvent(e);
1235} 1242}
1236void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1243void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1237{ 1244{
1238 // qDebug("contentsMouseMoveEv....... "); 1245 // qDebug("contentsMouseMoveEv....... ");
1239 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1246 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1240 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1247 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1241 if ( diff < 0 ) diff = -diff; 1248 if ( diff < 0 ) diff = -diff;
1242 if ( diff > 15 ) 1249 if ( diff > 15 )
1243 mPopupTimer->stop(); 1250 mPopupTimer->stop();
1244 else { 1251 else {
1245 mEventPos = contentsToViewport(e->pos()); 1252 mEventPos = contentsToViewport(e->pos());
1246 mEventGlobalPos = e->globalPos(); 1253 mEventGlobalPos = e->globalPos();
1247 } 1254 }
1248 KListView::contentsMouseMoveEvent(e); 1255 KListView::contentsMouseMoveEvent(e);
1249} 1256}
1250 1257
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index bb0e23e..eb5bb6e 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -1,311 +1,311 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef _KOLISTVIEW_H 24#ifndef _KOLISTVIEW_H
25#define _KOLISTVIEW_H 25#define _KOLISTVIEW_H
26 26
27#include <qlistview.h> 27#include <qlistview.h>
28#include <qmap.h> 28#include <qmap.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include <klistview.h> 31#include <klistview.h>
32 32
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/incidence.h> 38#include <libkcal/incidence.h>
39 39
40#include "koeventview.h" 40#include "koeventview.h"
41#include "customlistviewitem.h" 41#include "customlistviewitem.h"
42 42
43using namespace KCal; 43using namespace KCal;
44 44
45 45
46 46
47#include <qpushbutton.h> 47#include <qpushbutton.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qdialog.h> 49#include <qdialog.h>
50#include <qtimer.h> 50#include <qtimer.h>
51#include <qcombobox.h> 51#include <qcombobox.h>
52#include <qspinbox.h> 52#include <qspinbox.h>
53#include <qtooltip.h> 53#include <qtooltip.h>
54#include <qcheckbox.h> 54#include <qcheckbox.h>
55#include <qhbox.h> 55#include <qhbox.h>
56#include <qlabel.h> 56#include <qlabel.h>
57#include <kiconloader.h> 57#include <kiconloader.h>
58#include "kfiledialog.h" 58#include "kfiledialog.h"
59#include "koprefs.h" 59#include "koprefs.h"
60class KOAlarmPrefs : public QDialog 60class KOAlarmPrefs : public QDialog
61{ 61{
62 Q_OBJECT 62 Q_OBJECT
63 public: 63 public:
64 KOAlarmPrefs( QWidget *par=0, const char *name=0 ) : 64 KOAlarmPrefs( QWidget *par=0, const char *name=0 ) :
65 QDialog( par, name, true ) 65 QDialog( par, name, true )
66 { 66 {
67 setCaption( i18n("Alarm Options") ); 67 setCaption( i18n("Alarm Options") );
68 QVBoxLayout* alarmLayout = new QVBoxLayout( this ); 68 QVBoxLayout* alarmLayout = new QVBoxLayout( this );
69 alarmLayout->setSpacing( 3 ); 69 alarmLayout->setSpacing( 3 );
70 alarmLayout->setMargin( 3 ); 70 alarmLayout->setMargin( 3 );
71 QWidget *parent = this; 71 QWidget *parent = this;
72 mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); 72 mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent);
73 alarmLayout->addWidget(mAlarmButton); 73 alarmLayout->addWidget(mAlarmButton);
74 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 74 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
75 mAlarmTimeEdit->setValue( 15 ); 75 mAlarmTimeEdit->setValue( 15 );
76 alarmLayout->addWidget(mAlarmTimeEdit); 76 alarmLayout->addWidget(mAlarmTimeEdit);
77 mAlarmIncrCombo = new QComboBox(false, parent); 77 mAlarmIncrCombo = new QComboBox(false, parent);
78 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 78 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
79 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 79 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
80 mAlarmIncrCombo->insertItem(i18n("day(s)")); 80 mAlarmIncrCombo->insertItem(i18n("day(s)"));
81 alarmLayout->addWidget(mAlarmIncrCombo); 81 alarmLayout->addWidget(mAlarmIncrCombo);
82 QHBox * hb = new QHBox ( parent ); 82 QHBox * hb = new QHBox ( parent );
83 alarmLayout->addWidget(hb); 83 alarmLayout->addWidget(hb);
84 mAlarmSoundButton = new QPushButton(hb); 84 mAlarmSoundButton = new QPushButton(hb);
85 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 85 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
86 mAlarmSoundButton->setToggleButton(true); 86 mAlarmSoundButton->setToggleButton(true);
87 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 87 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
88 mAlarmProgramButton = new QPushButton(hb); 88 mAlarmProgramButton = new QPushButton(hb);
89 mAlarmProgramButton->setPixmap(SmallIcon("run")); 89 mAlarmProgramButton->setPixmap(SmallIcon("run"));
90 mAlarmProgramButton->setToggleButton(true); 90 mAlarmProgramButton->setToggleButton(true);
91 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 91 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
92 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 92 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
93 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 93 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
94 mAlarmLabel = new QLabel( this ); 94 mAlarmLabel = new QLabel( this );
95 alarmLayout->addWidget( mAlarmLabel ); 95 alarmLayout->addWidget( mAlarmLabel );
96 mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); 96 mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) );
97 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 97 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
98 mAlarmSoundButton->setOn( true ); 98 mAlarmSoundButton->setOn( true );
99 QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); 99 QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this );
100 alarmLayout->addWidget( ok ); 100 alarmLayout->addWidget( ok );
101 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 101 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
102 alarmLayout->addWidget( cancel ); 102 alarmLayout->addWidget( cancel );
103 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 103 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
104 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 104 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
105 resize( 200, 200 ); 105 resize( 200, 200 );
106 106
107 } 107 }
108 108
109 109
110 110
111 QString mAlarmSound, mAlarmProgram ; 111 QString mAlarmSound, mAlarmProgram ;
112 QCheckBox* mAlarmButton; 112 QCheckBox* mAlarmButton;
113 QSpinBox* mAlarmTimeEdit; 113 QSpinBox* mAlarmTimeEdit;
114 QLabel* mAlarmLabel; 114 QLabel* mAlarmLabel;
115 QComboBox* mAlarmIncrCombo ; 115 QComboBox* mAlarmIncrCombo ;
116 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; 116 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton;
117private slots: 117private slots:
118 118
119void pickAlarmSound() 119void pickAlarmSound()
120{ 120{
121 //QString prefix = mAlarmSound; 121 //QString prefix = mAlarmSound;
122 if (!mAlarmSoundButton->isOn()) { 122 if (!mAlarmSoundButton->isOn()) {
123 //mAlarmSound = ""; 123 //mAlarmSound = "";
124 QToolTip::remove(mAlarmSoundButton); 124 QToolTip::remove(mAlarmSoundButton);
125 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 125 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
126 mAlarmProgramButton->setOn(true); 126 mAlarmProgramButton->setOn(true);
127 mAlarmSoundButton->setOn(false); 127 mAlarmSoundButton->setOn(false);
128 } else { 128 } else {
129 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 129 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
130 i18n("*.wav|Wav Files"), 0)); 130 i18n("*.wav|Wav Files"), 0));
131 if (!fileName.isEmpty()) { 131 if (!fileName.isEmpty()) {
132 mAlarmSound = fileName; 132 mAlarmSound = fileName;
133 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 133 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
134 QToolTip::remove(mAlarmSoundButton); 134 QToolTip::remove(mAlarmSoundButton);
135 QString dispStr = i18n("Playing '%1'").arg(fileName); 135 QString dispStr = i18n("Playing '%1'").arg(fileName);
136 QToolTip::add(mAlarmSoundButton, dispStr); 136 QToolTip::add(mAlarmSoundButton, dispStr);
137 mAlarmProgramButton->setOn(false); 137 mAlarmProgramButton->setOn(false);
138 mAlarmSoundButton->setOn(true); 138 mAlarmSoundButton->setOn(true);
139 } else { 139 } else {
140 mAlarmProgramButton->setOn(true); 140 mAlarmProgramButton->setOn(true);
141 mAlarmSoundButton->setOn(false); 141 mAlarmSoundButton->setOn(false);
142 142
143 } 143 }
144 } 144 }
145}; 145};
146 146
147void pickAlarmProgram() 147void pickAlarmProgram()
148{ 148{
149 if (!mAlarmProgramButton->isOn()) { 149 if (!mAlarmProgramButton->isOn()) {
150 //mAlarmProgram = ""; 150 //mAlarmProgram = "";
151 QToolTip::remove(mAlarmProgramButton); 151 QToolTip::remove(mAlarmProgramButton);
152 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 152 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
153 mAlarmProgramButton->setOn(false); 153 mAlarmProgramButton->setOn(false);
154 mAlarmSoundButton->setOn(true); 154 mAlarmSoundButton->setOn(true);
155 } else { 155 } else {
156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); 156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
157 if (!fileName.isEmpty()) { 157 if (!fileName.isEmpty()) {
158 mAlarmProgram = fileName; 158 mAlarmProgram = fileName;
159 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 159 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
160 QToolTip::remove(mAlarmProgramButton); 160 QToolTip::remove(mAlarmProgramButton);
161 QString dispStr = i18n("Running '%1'").arg(fileName); 161 QString dispStr = i18n("Running '%1'").arg(fileName);
162 QToolTip::add(mAlarmProgramButton, dispStr); 162 QToolTip::add(mAlarmProgramButton, dispStr);
163 mAlarmSoundButton->setOn(false); 163 mAlarmSoundButton->setOn(false);
164 mAlarmProgramButton->setOn(true); 164 mAlarmProgramButton->setOn(true);
165 } else { 165 } else {
166 mAlarmProgramButton->setOn(false); 166 mAlarmProgramButton->setOn(false);
167 mAlarmSoundButton->setOn(true); 167 mAlarmSoundButton->setOn(true);
168 } 168 }
169 } 169 }
170}; 170};
171 171
172}; 172};
173 173
174 174
175 175
176 176
177 177
178 178
179 179
180typedef CustomListViewItem<Incidence *> KOListViewItem; 180typedef CustomListViewItem<Incidence *> KOListViewItem;
181 181
182/** 182/**
183 This class provides the initialisation of a KOListViewItem for calendar 183 This class provides the initialisation of a KOListViewItem for calendar
184 components using the Incidence::Visitor. 184 components using the Incidence::Visitor.
185*/ 185*/
186class ListItemVisitor : public Incidence::Visitor 186class ListItemVisitor : public Incidence::Visitor
187{ 187{
188 public: 188 public:
189 ListItemVisitor(KOListViewItem *, QDate d); 189 ListItemVisitor(KOListViewItem *, QDate d);
190 ~ListItemVisitor(); 190 ~ListItemVisitor();
191 191
192 bool visit(Event *); 192 bool visit(Event *);
193 bool visit(Todo *); 193 bool visit(Todo *);
194 bool visit(Journal *); 194 bool visit(Journal *);
195 195
196 private: 196 private:
197 KOListViewItem *mItem; 197 KOListViewItem *mItem;
198 QDate mDate; 198 QDate mDate;
199}; 199};
200 200
201/** 201/**
202 This class provides a multi-column list view of events. It can 202 This class provides a multi-column list view of events. It can
203 display events from one particular day or several days, it doesn't 203 display events from one particular day or several days, it doesn't
204 matter. To use a view that only handles one day at a time, use 204 matter. To use a view that only handles one day at a time, use
205 KODayListView. 205 KODayListView.
206 206
207 @short multi-column list view of various events. 207 @short multi-column list view of various events.
208 @author Preston Brown <pbrown@kde.org> 208 @author Preston Brown <pbrown@kde.org>
209 @see KOBaseView, KODayListView 209 @see KOBaseView, KODayListView
210*/ 210*/
211class KOListView; 211class KOListView;
212 212
213class KOListViewListView : public KListView 213class KOListViewListView : public KListView
214{ 214{
215 Q_OBJECT 215 Q_OBJECT
216 public: 216 public:
217 KOListViewListView(KOListView * lv ); 217 KOListViewListView(KOListView * lv );
218 signals: 218 signals:
219 void newEvent(); 219 void newEvent();
220 void showIncidence( Incidence* ); 220 void showIncidence( Incidence* );
221 public slots: 221 public slots:
222 void popupMenu(); 222 void popupMenu();
223 private: 223 private:
224 QPoint mEventPos; 224 QPoint mEventPos;
225 QPoint mEventGlobalPos; 225 QPoint mEventGlobalPos;
226 QTimer* mPopupTimer; 226 QTimer* mPopupTimer;
227 int mYMousePos; 227 int mYMousePos;
228 void keyPressEvent ( QKeyEvent * ) ; 228 void keyPressEvent ( QKeyEvent * ) ;
229 void contentsMouseDoubleClickEvent(QMouseEvent *e); 229 void contentsMouseDoubleClickEvent(QMouseEvent *e);
230 void contentsMousePressEvent(QMouseEvent *e); 230 void contentsMousePressEvent(QMouseEvent *e);
231 void contentsMouseReleaseEvent(QMouseEvent *e); 231 void contentsMouseReleaseEvent(QMouseEvent *e);
232 void contentsMouseMoveEvent(QMouseEvent *e); 232 void contentsMouseMoveEvent(QMouseEvent *e);
233 bool mMouseDown; 233 bool mMouseDown;
234}; 234};
235 235
236class KOListView : public KOEventView 236class KOListView : public KOEventView
237{ 237{
238 Q_OBJECT 238 Q_OBJECT
239 public: 239 public:
240 KOListView(Calendar *calendar, QWidget *parent = 0, 240 KOListView(Calendar *calendar, QWidget *parent = 0,
241 const char *name = 0); 241 const char *name = 0);
242 ~KOListView(); 242 ~KOListView();
243 243
244 virtual int maxDatesHint(); 244 virtual int maxDatesHint();
245 virtual int currentDateCount(); 245 virtual int currentDateCount();
246 virtual QPtrList<Incidence> selectedIncidences(); 246 virtual QPtrList<Incidence> selectedIncidences();
247 virtual DateList selectedDates(); 247 virtual DateList selectedDates();
248 248
249 void showDates(bool show); 249 void showDates(bool show);
250 Incidence* currentItem(); 250 Incidence* currentItem();
251 void addTodos(QPtrList<Todo> eventList); 251 void addTodos(QPtrList<Todo> eventList);
252 void addJournals(QPtrList<Journal> eventList); 252 void addJournals(QPtrList<Journal> eventList);
253 virtual void printPreview(CalPrinter *calPrinter, 253 virtual void printPreview(CalPrinter *calPrinter,
254 const QDate &, const QDate &); 254 const QDate &, const QDate &);
255 255
256 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 256 void readSettings(KConfig *config, QString setting = "KOListView Layout");
257 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 257 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
258 void updateList(); 258 void updateList();
259 void setStartDate(const QDate &start); 259 void setStartDate(const QDate &start);
260 int count(); 260 int count();
261 QString getWhatsThisText(QPoint p); 261 QString getWhatsThisText(QPoint p);
262 void resetFocus();
263 signals: 262 signals:
264 void signalNewEvent(); 263 void signalNewEvent();
265 void beamIncidenceList(QPtrList<Incidence>); 264 void beamIncidenceList(QPtrList<Incidence>);
266 265
267 public slots: 266 public slots:
267 void resetFocus();
268 virtual void updateView(); 268 virtual void updateView();
269 virtual void showDates(const QDate &start, const QDate &end); 269 virtual void showDates(const QDate &start, const QDate &end);
270 virtual void showEvents(QPtrList<Event> eventList); 270 virtual void showEvents(QPtrList<Event> eventList);
271 void clearSelection(); 271 void clearSelection();
272 void allSelection(); 272 void allSelection();
273 273
274 void clear(); 274 void clear();
275 void beamDone( Ir *ir ); 275 void beamDone( Ir *ir );
276 void showDates(); 276 void showDates();
277 void hideDates(); 277 void hideDates();
278 void deleteAll(); 278 void deleteAll();
279 void saveToFile(); 279 void saveToFile();
280 void saveToFileVCS(); 280 void saveToFileVCS();
281 void saveDescriptionToFile(); 281 void saveDescriptionToFile();
282 void beamSelected(); 282 void beamSelected();
283 void updateConfig(); 283 void updateConfig();
284 void addCat(); 284 void addCat();
285 void setCat(); 285 void setCat();
286 void setAlarm(); 286 void setAlarm();
287 void setCategories( bool removeOld ); 287 void setCategories( bool removeOld );
288 void changeEventDisplay(Event *, int); 288 void changeEventDisplay(Event *, int);
289 289
290 void defaultItemAction(QListViewItem *item); 290 void defaultItemAction(QListViewItem *item);
291 void popupMenu(QListViewItem *item,const QPoint &,int); 291 void popupMenu(QListViewItem *item,const QPoint &,int);
292 292
293 protected slots: 293 protected slots:
294 void processSelectionChange(QListViewItem *); 294 void processSelectionChange(QListViewItem *);
295 295
296 protected: 296 protected:
297 void writeToFile( bool iCal ); 297 void writeToFile( bool iCal );
298 void addEvents(QPtrList<Event> eventList); 298 void addEvents(QPtrList<Event> eventList);
299 void addIncidence(Incidence *); 299 void addIncidence(Incidence *);
300 KOListViewItem *getItemForEvent(Event *event); 300 KOListViewItem *getItemForEvent(Event *event);
301 301
302 private: 302 private:
303 KOListViewListView *mListView; 303 KOListViewListView *mListView;
304 KOEventPopupMenu *mPopupMenu; 304 KOEventPopupMenu *mPopupMenu;
305 KOListViewItem *mActiveItem; 305 KOListViewItem *mActiveItem;
306 QDict<Incidence> mUidDict; 306 QDict<Incidence> mUidDict;
307 QDate mStartDate; 307 QDate mStartDate;
308 void keyPressEvent ( QKeyEvent * ) ; 308 void keyPressEvent ( QKeyEvent * ) ;
309}; 309};
310 310
311#endif 311#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 2b7e41f..843526d 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,2091 +1,2079 @@
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#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qwhatsthis.h> 31#include <qwhatsthis.h>
32#ifndef DESKTOP_VERSION 32#ifndef DESKTOP_VERSION
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#else 34#else
35#include <qapplication.h> 35#include <qapplication.h>
36#endif 36#endif
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kconfig.h> 41#include <kconfig.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43 43
44#include <kcalendarsystem.h> 44#include <kcalendarsystem.h>
45 45
46#ifndef KORG_NOPRINTER 46#ifndef KORG_NOPRINTER
47#include "calprinter.h" 47#include "calprinter.h"
48#endif 48#endif
49#include "koprefs.h" 49#include "koprefs.h"
50#ifndef KORG_NOPLUGINS 50#ifndef KORG_NOPLUGINS
51#include "kocore.h" 51#include "kocore.h"
52#endif 52#endif
53#include "koglobals.h" 53#include "koglobals.h"
54#include <libkcal/kincidenceformatter.h> 54#include <libkcal/kincidenceformatter.h>
55 55
56#include "komonthview.h" 56#include "komonthview.h"
57 57
58#define PIXMAP_SIZE 5 58#define PIXMAP_SIZE 5
59#ifdef DESKTOP_VERSION 59#ifdef DESKTOP_VERSION
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p) 69 virtual QString text( const QPoint& p)
70 { 70 {
71 return _wid->getWhatsThisText(p) ; 71 return _wid->getWhatsThisText(p) ;
72 }; 72 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
80 : QListBox(parent, name, WRepaintNoErase) 80 : QListBox(parent, name, WRepaintNoErase)
81{ 81{
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mWT = new KNOWhatsThis(this); 85 mWT = new KNOWhatsThis(this);
86 resetOnFocusIn = true; 86 resetOnFocusIn = true;
87 setVScrollBarMode(QScrollView::AlwaysOff); 87 setVScrollBarMode(QScrollView::AlwaysOff);
88 setHScrollBarMode(QScrollView::AlwaysOff); 88 setHScrollBarMode(QScrollView::AlwaysOff);
89} 89}
90KNoScrollListBox::~KNoScrollListBox() 90KNoScrollListBox::~KNoScrollListBox()
91{ 91{
92 92
93} 93}
94 94
95 95
96void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 96void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
97{ 97{
98 QListBox::focusInEvent ( e ); 98 QListBox::focusInEvent ( e );
99 if ( count() ){ 99 if ( count() ){
100 int ci = currentItem(); 100 int ci = currentItem();
101 if ( ci < 0 ) ci = 0; 101 if ( ci < 0 ) ci = 0;
102 102
103 setCurrentItem( ci ); 103 setCurrentItem( ci );
104 setSelected ( ci, true ); 104 setSelected ( ci, true );
105 emit highlighted( item ( ci ) ); 105 emit highlighted( item ( ci ) );
106 106
107 resetOnFocusIn = true; 107 resetOnFocusIn = true;
108 108
109 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { 109 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
110 QListBoxItem *fi = firstItem (); 110 QListBoxItem *fi = firstItem ();
111 if (fi ) { 111 if (fi ) {
112 int ihei = fi->height( this ); 112 int ihei = fi->height( this );
113 int hei = numRows () * ihei; 113 int hei = numRows () * ihei;
114 if ( hei < height() - horizontalScrollBar()->height () ) { 114 if ( hei < height() - horizontalScrollBar()->height () ) {
115 setVScrollBarMode(QScrollView::AlwaysOff); 115 setVScrollBarMode(QScrollView::AlwaysOff);
116 } 116 }
117 else 117 else
118 setVScrollBarMode(QScrollView::Auto); 118 setVScrollBarMode(QScrollView::Auto);
119 if ( ihei *3 > height() ) { 119 if ( ihei *3 > height() ) {
120 setHScrollBarMode(QScrollView::AlwaysOff); 120 setHScrollBarMode(QScrollView::AlwaysOff);
121 } 121 }
122 else { 122 else {
123 setHScrollBarMode(QScrollView::Auto); 123 setHScrollBarMode(QScrollView::Auto);
124 } 124 }
125 } else { 125 } else {
126 setVScrollBarMode(QScrollView::Auto); 126 setVScrollBarMode(QScrollView::Auto);
127 setHScrollBarMode(QScrollView::Auto); 127 setHScrollBarMode(QScrollView::Auto);
128 } 128 }
129 } 129 }
130 } 130 }
131} 131}
132void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 132void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
133{ 133{
134 int i = currentItem (); 134 int i = currentItem ();
135 if ( i >= 0 ) { 135 if ( i >= 0 ) {
136 setSelected ( i, false ); 136 setSelected ( i, false );
137 } 137 }
138 QListBox::focusOutEvent ( e ); 138 QListBox::focusOutEvent ( e );
139 setVScrollBarMode(QScrollView::AlwaysOff); 139 setVScrollBarMode(QScrollView::AlwaysOff);
140 setHScrollBarMode(QScrollView::AlwaysOff); 140 setHScrollBarMode(QScrollView::AlwaysOff);
141} 141}
142 142
143QString KNoScrollListBox::getWhatsThisText(QPoint p) 143QString KNoScrollListBox::getWhatsThisText(QPoint p)
144{ 144{
145 QListBoxItem* item = itemAt ( p ); 145 QListBoxItem* item = itemAt ( p );
146 if ( ! item ) { 146 if ( ! item ) {
147 return i18n("Click in the cell\nto add an event!"); 147 return i18n("Click in the cell\nto add an event!");
148 } 148 }
149 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 149 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
150 KOPrefs::instance()->mWTshowDetails, 150 KOPrefs::instance()->mWTshowDetails,
151 KOPrefs::instance()->mWTshowCreated, 151 KOPrefs::instance()->mWTshowCreated,
152 KOPrefs::instance()->mWTshowChanged); 152 KOPrefs::instance()->mWTshowChanged);
153} 153}
154void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 154void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
155{ 155{
156 //qDebug("KNoScrollListBox::keyPressEvent "); 156 //qDebug("KNoScrollListBox::keyPressEvent ");
157 switch(e->key()) { 157 switch(e->key()) {
158 case Key_Right: 158 case Key_Right:
159 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 159 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
160 { 160 {
161 e->ignore(); 161 e->ignore();
162 return; 162 return;
163 } 163 }
164 scrollBy(10,0); 164 scrollBy(10,0);
165 break; 165 break;
166 case Key_Left: 166 case Key_Left:
167 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 167 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
168 { 168 {
169 e->ignore(); 169 e->ignore();
170 return; 170 return;
171 } 171 }
172 scrollBy(-10,0); 172 scrollBy(-10,0);
173 break; 173 break;
174 case Key_Up: 174 case Key_Up:
175 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 175 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
176 e->ignore(); 176 e->ignore();
177 break; 177 break;
178 } 178 }
179 if ( count() ) { 179 if ( count() ) {
180 if ( currentItem() == 0 ) { 180 if ( currentItem() == 0 ) {
181 emit prevCell(); 181 emit prevCell();
182 } else { 182 } else {
183 setCurrentItem((currentItem()+count()-1)%count()); 183 setCurrentItem((currentItem()+count()-1)%count());
184 if(!itemVisible(currentItem())) { 184 if(!itemVisible(currentItem())) {
185 if((unsigned int) currentItem() == (count()-1)) { 185 if((unsigned int) currentItem() == (count()-1)) {
186 setTopItem(currentItem()-numItemsVisible()+1); 186 setTopItem(currentItem()-numItemsVisible()+1);
187 } else { 187 } else {
188 setTopItem(topItem()-1); 188 setTopItem(topItem()-1);
189 } 189 }
190 } 190 }
191 } 191 }
192 } 192 }
193 break; 193 break;
194 case Key_Down: 194 case Key_Down:
195 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 195 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
196 e->ignore(); 196 e->ignore();
197 break; 197 break;
198 } 198 }
199 if ( count () ) { 199 if ( count () ) {
200 if ( currentItem()+1 == count () ) { 200 if ( currentItem()+1 == count () ) {
201 emit nextCell(); 201 emit nextCell();
202 } else { 202 } else {
203 setCurrentItem((currentItem()+1)%count()); 203 setCurrentItem((currentItem()+1)%count());
204 if(!itemVisible(currentItem())) { 204 if(!itemVisible(currentItem())) {
205 if(currentItem() == 0) { 205 if(currentItem() == 0) {
206 setTopItem(0); 206 setTopItem(0);
207 } else { 207 } else {
208 setTopItem(topItem()+1); 208 setTopItem(topItem()+1);
209 } 209 }
210 } 210 }
211 } 211 }
212 } 212 }
213 break; 213 break;
214 case Key_I: 214 case Key_I:
215 QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 215 QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
216 e->ignore(); 216 e->ignore();
217 break; 217 break;
218 case Key_Return: 218 case Key_Return:
219 case Key_Enter: 219 case Key_Enter:
220 { 220 {
221 if ( currentItem() >= 0 ) { 221 if ( currentItem() >= 0 ) {
222 emit doubleClicked( item( currentItem() ) ); 222 emit doubleClicked( item( currentItem() ) );
223 e->accept(); 223 e->accept();
224 } else { 224 } else {
225 e->ignore(); 225 e->ignore();
226 } 226 }
227 } 227 }
228 break; 228 break;
229 case Key_Shift: 229 case Key_Shift:
230 emit shiftDown(); 230 emit shiftDown();
231 break; 231 break;
232 default: 232 default:
233 e->ignore(); 233 e->ignore();
234 break; 234 break;
235 } 235 }
236} 236}
237 237
238void KNoScrollListBox::oneDown() 238void KNoScrollListBox::oneDown()
239{ 239{
240 if ( count () ) { 240 if ( count () ) {
241 if ( currentItem()+1 == count () ) { 241 if ( currentItem()+1 == count () ) {
242 emit nextCell(); 242 emit nextCell();
243 } else { 243 } else {
244 resetOnFocusIn = false; 244 resetOnFocusIn = false;
245 setCurrentItem((currentItem()+1)%count()); 245 setCurrentItem((currentItem()+1)%count());
246 if(!itemVisible(currentItem())) { 246 if(!itemVisible(currentItem())) {
247 if(currentItem() == 0) { 247 if(currentItem() == 0) {
248 setTopItem(0); 248 setTopItem(0);
249 } else { 249 } else {
250 setTopItem(topItem()+1); 250 setTopItem(topItem()+1);
251 } 251 }
252 } 252 }
253 } 253 }
254 } 254 }
255} 255}
256void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 256void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
257{ 257{
258 switch(e->key()) { 258 switch(e->key()) {
259 case Key_Shift: 259 case Key_Shift:
260 emit shiftUp(); 260 emit shiftUp();
261 break; 261 break;
262 default: 262 default:
263 break; 263 break;
264 } 264 }
265} 265}
266 266
267void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 267void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
268{ 268{
269 QListBox::mousePressEvent(e); 269 QListBox::mousePressEvent(e);
270 270
271 if(e->button() == RightButton) { 271 if(e->button() == RightButton) {
272 emit rightClick(); 272 emit rightClick();
273 } 273 }
274} 274}
275 275
276MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 276MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
277 : QListBoxItem() 277 : QListBoxItem()
278{ 278{
279 mblockRepaint = true; 279 mblockRepaint = true;
280 setText( s ); 280 setText( s );
281 mMultiday = 0; 281 mMultiday = 0;
282 mIncidence = incidence; 282 mIncidence = incidence;
283 mDate = qd; 283 mDate = qd;
284 mRecur = false; 284 mRecur = false;
285 mAlarm = false; 285 mAlarm = false;
286 mReply = false; 286 mReply = false;
287 mInfo = false; 287 mInfo = false;
288 mdayPos = 0; 288 mdayPos = 0;
289 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 289 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
290 //qDebug("NEWWWWWWWWWWWWW ");
291} 290}
292void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 291void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
293{ 292{
294 setText( s ); 293 setText( s );
295 mMultiday = 0; 294 mMultiday = 0;
296 mIncidence = incidence; 295 mIncidence = incidence;
297 mDate = qd; 296 mDate = qd;
298 mRecur = false; 297 mRecur = false;
299 mAlarm = false; 298 mAlarm = false;
300 mReply = false; 299 mReply = false;
301 mInfo = false; 300 mInfo = false;
302 mdayPos = 0; 301 mdayPos = 0;
303 //qDebug("recucleeeeeeeeeeeeeeeee ");
304} 302}
305 303
306void MonthViewItem::paint(QPainter *p) 304void MonthViewItem::paint(QPainter *p)
307{ 305{
308 if ( mblockRepaint ) { 306 if ( mblockRepaint ) {
309 //qDebug("block ");
310 return; 307 return;
311 } 308 }
312 //qDebug("NON block ");
313#if QT_VERSION >= 0x030000 309#if QT_VERSION >= 0x030000
314 bool sel = isSelected(); 310 bool sel = isSelected();
315#else 311#else
316 bool sel = selected(); 312 bool sel = selected();
317#endif 313#endif
318 314
319 315
320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 316 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
321 { 317 {
322 p->setBackgroundColor( palette().color( QPalette::Normal, \ 318 p->setBackgroundColor( palette().color( QPalette::Normal, \
323 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 319 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 320 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
325 } 321 }
326 int x = 1; 322 int x = 1;
327 //int y = 3;//(height() - mRecurPixmap.height()) /2; 323 //int y = 3;//(height() - mRecurPixmap.height()) /2;
328 int size = PIXMAP_SIZE; 324 int size = PIXMAP_SIZE;
329 if ( QApplication::desktop()->width() < 300 ) 325 if ( QApplication::desktop()->width() < 300 )
330 size = 3; 326 size = 3;
331 int heihei = height( listBox () ); 327 int heihei = height( listBox () );
332 int y = (heihei - size -1 ) /2; 328 int y = (heihei - size -1 ) /2;
333 329
334 if ( KOPrefs::instance()->mMonthShowIcons ) { 330 if ( KOPrefs::instance()->mMonthShowIcons ) {
335 if ( mInfo ) { 331 if ( mInfo ) {
336 p->fillRect ( x, y,size,size, Qt::darkGreen ); 332 p->fillRect ( x, y,size,size, Qt::darkGreen );
337 x += size + 1; 333 x += size + 1;
338 } 334 }
339 if ( mRecur ) { 335 if ( mRecur ) {
340 p->fillRect ( x, y,size,size, Qt::blue ); 336 p->fillRect ( x, y,size,size, Qt::blue );
341 x += size + 1; 337 x += size + 1;
342 } 338 }
343 if ( mAlarm ) { 339 if ( mAlarm ) {
344 p->fillRect ( x, y,size,size, Qt::red ); 340 p->fillRect ( x, y,size,size, Qt::red );
345 x += size + 1; 341 x += size + 1;
346 } 342 }
347 if ( mReply ) { 343 if ( mReply ) {
348 p->fillRect ( x, y,size,size, Qt::yellow ); 344 p->fillRect ( x, y,size,size, Qt::yellow );
349 x += size + 1; 345 x += size + 1;
350 } 346 }
351 } 347 }
352 if ( mMultiday ) { 348 if ( mMultiday ) {
353 int yyy = y+(size/2); 349 int yyy = y+(size/2);
354 int sizeM = size+2; 350 int sizeM = size+2;
355 p->setBrush( QBrush::SolidPattern ); 351 p->setBrush( QBrush::SolidPattern );
356 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 352 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
357 if ( mMultiday == 2 || mMultiday == 3 ) { 353 if ( mMultiday == 2 || mMultiday == 3 ) {
358 QPointArray pa ( 3 ); 354 QPointArray pa ( 3 );
359 pa.setPoint (0, x, yyy ); 355 pa.setPoint (0, x, yyy );
360 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 356 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
361 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 357 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
362 p->drawPolygon( pa ); 358 p->drawPolygon( pa );
363 } 359 }
364 if ( mMultiday == 2 || mMultiday == 1 ) { 360 if ( mMultiday == 2 || mMultiday == 1 ) {
365 QPointArray pa ( 3 ); 361 QPointArray pa ( 3 );
366 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 362 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
367 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 363 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
368 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 364 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
369 p->drawPolygon( pa ); 365 p->drawPolygon( pa );
370 } 366 }
371 if ( mMultiday == 1 ) { 367 if ( mMultiday == 1 ) {
372 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 368 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
373 369
374 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 370 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
375 } 371 }
376 if ( mMultiday == 3 ) { 372 if ( mMultiday == 3 ) {
377 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 373 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
378 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 374 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
379 375
380 } 376 }
381 x += sizeM/2 + 1; 377 x += sizeM/2 + 1;
382 x += sizeM + 1; 378 x += sizeM + 1;
383 } 379 }
384 380
385 if ( mIncidence->type() == "Todo" ){ 381 if ( mIncidence->type() == "Todo" ){
386 Todo* td = ( Todo* ) mIncidence; 382 Todo* td = ( Todo* ) mIncidence;
387 if ( td->isCompleted() ) { 383 if ( td->isCompleted() ) {
388 int half = size/2; 384 int half = size/2;
389 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 385 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
390 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 386 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
391 x += half+half + 4; 387 x += half+half + 4;
392 388
393 } else { 389 } else {
394 int val = td->percentComplete()/20; 390 int val = td->percentComplete()/20;
395 p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); 391 p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
396 p->drawRect ( x, y-2,7,size+4); 392 p->drawRect ( x, y-2,7,size+4);
397 x += size + 3; 393 x += size + 3;
398 } 394 }
399 } 395 }
400 QFontMetrics fm = p->fontMetrics(); 396 QFontMetrics fm = p->fontMetrics();
401 int yPos; 397 int yPos;
402 int pmheight = size; 398 int pmheight = size;
403 if( pmheight < fm.height() ) 399 if( pmheight < fm.height() )
404 yPos = fm.ascent() + fm.leading()/2; 400 yPos = fm.ascent() + fm.leading()/2;
405 else 401 else
406 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 402 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
407 p->setPen( palette().color( QPalette::Normal, sel ? \ 403 p->setPen( palette().color( QPalette::Normal, sel ? \
408 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 404 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
409 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { 405 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
410 p->drawText( x, yPos, text() ); 406 p->drawText( x, yPos, text() );
411 if ( mIncidence->cancelled() ) { 407 if ( mIncidence->cancelled() ) {
412 int wid = fm.width( text() ); 408 int wid = fm.width( text() );
413 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 409 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
414 } 410 }
415 } else { 411 } else {
416 QString pText = text(); 412 QString pText = text();
417 if( pText.mid(2,1) == ":" ) 413 if( pText.mid(2,1) == ":" )
418 pText = pText.mid( 6 ); 414 pText = pText.mid( 6 );
419 p->drawText( x, yPos, pText ); 415 p->drawText( x, yPos, pText );
420 if ( mIncidence->cancelled() ) { 416 if ( mIncidence->cancelled() ) {
421 int wid = fm.width( pText ); 417 int wid = fm.width( pText );
422 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 418 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
423 } 419 }
424 } 420 }
425} 421}
426 422
427int MonthViewItem::height(const QListBox *lb) const 423int MonthViewItem::height(const QListBox *lb) const
428{ 424{
429 int ret = 10; 425 int ret = 10;
430 if ( lb ) 426 if ( lb )
431 ret = lb->fontMetrics().lineSpacing()+1; 427 ret = lb->fontMetrics().lineSpacing()+1;
432 return ret; 428 return ret;
433} 429}
434 430
435int MonthViewItem::width(const QListBox *lb) const 431int MonthViewItem::width(const QListBox *lb) const
436{ 432{
437 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 433 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
438 int size = PIXMAP_SIZE; 434 int size = PIXMAP_SIZE;
439 if ( QApplication::desktop()->width() < 300 ) 435 if ( QApplication::desktop()->width() < 300 )
440 size = 3; 436 size = 3;
441 int x = 1; 437 int x = 1;
442 if ( KOPrefs::instance()->mMonthShowIcons ) { 438 if ( KOPrefs::instance()->mMonthShowIcons ) {
443 if ( mInfo ) { 439 if ( mInfo ) {
444 x += size + 1; 440 x += size + 1;
445 } 441 }
446 if( mRecur ) { 442 if( mRecur ) {
447 x += size+1; 443 x += size+1;
448 } 444 }
449 if( mAlarm ) { 445 if( mAlarm ) {
450 x += size+1; 446 x += size+1;
451 } 447 }
452 if( mReply ) { 448 if( mReply ) {
453 x += size+1; 449 x += size+1;
454 } 450 }
455 } 451 }
456 if( mMultiday ) { 452 if( mMultiday ) {
457 x += size+1+2+size/2; 453 x += size+1+2+size/2;
458 } 454 }
459 return( x + lb->fontMetrics().width( text() ) + 1 ); 455 return( x + lb->fontMetrics().width( text() ) + 1 );
460 } 456 }
461 if ( ! lb ) 457 if ( ! lb )
462 return 10; 458 return 10;
463 //qDebug("ret wid %d ", lb->width());
464 return lb->width(); 459 return lb->width();
465} 460}
466 461
467 462
468MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 463MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
469 : KNoScrollListBox( par ), 464 : KNoScrollListBox( par ),
470 mMonthView( parent ) 465 mMonthView( parent )
471{ 466{
472 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 467 //QVBoxLayout *topLayout = new QVBoxLayout( this );
473 currentPalette = 0; 468 currentPalette = 0;
474 // mLabel = new QLabel( this );QPushButton 469 // mLabel = new QLabel( this );QPushButton
475 mLabel = new QPushButton( this ); 470 mLabel = new QPushButton( this );
476 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 471 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
477 //mLabel->setLineWidth( 1 ); 472 //mLabel->setLineWidth( 1 );
478 //mLabel->setAlignment( AlignCenter ); 473 //mLabel->setAlignment( AlignCenter );
479 mLabel->setFlat( true ); 474 mLabel->setFlat( true );
480 mLabel->setFocusPolicy(NoFocus); 475 mLabel->setFocusPolicy(NoFocus);
481 //mItemList = new KNoScrollListBox( this ); 476 //mItemList = new KNoScrollListBox( this );
482 setMinimumSize( 10, 10 ); 477 setMinimumSize( 10, 10 );
483 setFrameStyle( QFrame::Panel | QFrame::Plain ); 478 setFrameStyle( QFrame::Panel | QFrame::Plain );
484 setLineWidth( 1 ); 479 setLineWidth( 1 );
485 //topLayout->addWidget( mItemList ); 480 //topLayout->addWidget( mItemList );
486 mLabel->raise(); 481 mLabel->raise();
487 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 482 // QColor( 0,0,255 ) QColor( 160,1600,255 )
488 mStandardPalette = palette(); 483 mStandardPalette = palette();
489 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 484 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
490 485
491 enableScrollBars( false ); 486 enableScrollBars( false );
492 updateConfig(); 487 updateConfig();
493 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 488 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
494 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 489 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
495 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 490 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
496 SLOT( defaultAction( QListBoxItem * ) ) ); 491 SLOT( defaultAction( QListBoxItem * ) ) );
497 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 492 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
498 const QPoint &) ), 493 const QPoint &) ),
499 SLOT( contextMenu( QListBoxItem * ) ) ); 494 SLOT( contextMenu( QListBoxItem * ) ) );
500 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 495 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
501 SLOT( selection( QListBoxItem * ) ) ); 496 SLOT( selection( QListBoxItem * ) ) );
502 497
503 /* 498 /*
504 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 499 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
505 SLOT( selection( QListBoxItem * ) ) ); 500 SLOT( selection( QListBoxItem * ) ) );
506 */ 501 */
507} 502}
508#ifdef DESKTOP_VERSION 503#ifdef DESKTOP_VERSION
509QToolTipGroup *MonthViewCell::toolTipGroup() 504QToolTipGroup *MonthViewCell::toolTipGroup()
510{ 505{
511 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 506 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
512 return mToolTipGroup; 507 return mToolTipGroup;
513} 508}
514#endif 509#endif
515 510
516void MonthViewCell::setDate( const QDate &date ) 511void MonthViewCell::setDate( const QDate &date )
517{ 512{
518 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 513 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
519 mDate = date; 514 mDate = date;
520 515
521 516
522 517
523 //resizeEvent( 0 ); 518 //resizeEvent( 0 );
524} 519}
525 520
526QDate MonthViewCell::date() const 521QDate MonthViewCell::date() const
527{ 522{
528 return mDate; 523 return mDate;
529} 524}
530 525
531void MonthViewCell::setPrimary( bool primary ) 526void MonthViewCell::setPrimary( bool primary )
532{ 527{
533 mPrimary = primary; 528 mPrimary = primary;
534 //setMyPalette(); 529 //setMyPalette();
535} 530}
536void MonthViewCell::setMyPalette() 531void MonthViewCell::setMyPalette()
537{ 532{
538 533
539 if ( mHoliday) { 534 if ( mHoliday) {
540 if ( currentPalette == 1 ) return; 535 if ( currentPalette == 1 ) return;
541 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 536 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
542 setPalette( mHolidayPalette ); 537 setPalette( mHolidayPalette );
543 //mLabel->setPalette( mHolidayPalette ); 538 //mLabel->setPalette( mHolidayPalette );
544 currentPalette = 1; 539 currentPalette = 1;
545 540
546 } else { 541 } else {
547 if ( mPrimary ) { 542 if ( mPrimary ) {
548 if ( currentPalette == 2 ) return; 543 if ( currentPalette == 2 ) return;
549 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 544 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
550 //mLabel->setPalette( mPrimaryPalette ); 545 //mLabel->setPalette( mPrimaryPalette );
551 setPalette( mPrimaryPalette ); 546 setPalette( mPrimaryPalette );
552 currentPalette = 2; 547 currentPalette = 2;
553 548
554 } else { 549 } else {
555 if ( currentPalette == 3 ) return; 550 if ( currentPalette == 3 ) return;
556 setPalette( mNonPrimaryPalette ); 551 setPalette( mNonPrimaryPalette );
557 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 552 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
558 //mLabel->setPalette( mNonPrimaryPalette );; 553 //mLabel->setPalette( mNonPrimaryPalette );;
559 currentPalette = 3; 554 currentPalette = 3;
560 } 555 }
561 } 556 }
562 //QPalette pal = palette(); 557 //QPalette pal = palette();
563 558
564 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 559 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
565} 560}
566QPalette MonthViewCell::getPalette () 561QPalette MonthViewCell::getPalette ()
567{ 562{
568 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 563 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
569 return mStandardPalette; 564 return mStandardPalette;
570 if ( mHoliday) { 565 if ( mHoliday) {
571 return mHolidayPalette ; 566 return mHolidayPalette ;
572 } else { 567 } else {
573 if ( mPrimary ) { 568 if ( mPrimary ) {
574 return mPrimaryPalette ; 569 return mPrimaryPalette ;
575 } 570 }
576 } 571 }
577 return mNonPrimaryPalette; 572 return mNonPrimaryPalette;
578} 573}
579bool MonthViewCell::isPrimary() const 574bool MonthViewCell::isPrimary() const
580{ 575{
581 return mPrimary; 576 return mPrimary;
582} 577}
583 578
584void MonthViewCell::setHoliday( bool holiday ) 579void MonthViewCell::setHoliday( bool holiday )
585{ 580{
586 mHoliday = holiday; 581 mHoliday = holiday;
587 //setMyPalette(); 582 //setMyPalette();
588} 583}
589 584
590void MonthViewCell::setHoliday( const QString &holiday ) 585void MonthViewCell::setHoliday( const QString &holiday )
591{ 586{
592 mHolidayString = holiday; 587 mHolidayString = holiday;
593 588
594 if ( !holiday.isEmpty() ) { 589 if ( !holiday.isEmpty() ) {
595 setHoliday( true ); 590 setHoliday( true );
596 } 591 }
597} 592}
598 593
599void MonthViewCell::startUpdateCell() 594void MonthViewCell::startUpdateCell()
600{ 595{
601 mdayCount = 0; 596 mdayCount = 0;
602 setFocusPolicy(NoFocus); 597 setFocusPolicy(NoFocus);
603 if ( !mMonthView->isUpdatePossible() ) 598 if ( !mMonthView->isUpdatePossible() )
604 return; 599 return;
605 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 600 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
606 while ( mitem ) { 601 while ( mitem ) {
607 mitem->setBlockRepaint( true ); 602 mitem->setBlockRepaint( true );
608 mitem = (MonthViewItem *)mitem->next(); 603 mitem = (MonthViewItem *)mitem->next();
609 } 604 }
610 if ( mAvailItemList.count() > 20 ) { 605 if ( mAvailItemList.count() > 20 ) {
611 mAvailItemList.setAutoDelete( true ); 606 mAvailItemList.setAutoDelete( true );
612 mAvailItemList.clear(); 607 mAvailItemList.clear();
613 mAvailItemList.setAutoDelete( false ); 608 mAvailItemList.setAutoDelete( false );
614 } 609 }
615 /* 610
616 if ( !isVisible() ){
617 return;
618 }
619 */
620 // qDebug("MonthViewCell::updateCell() ");
621 setPrimary( mDate.month()%2 ); 611 setPrimary( mDate.month()%2 );
622 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 612 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
623 if ( mDate == QDate::currentDate() ) { 613 if ( mDate == QDate::currentDate() ) {
624 setLineWidth( 3 ); 614 setLineWidth( 3 );
625 } else { 615 } else {
626 setLineWidth( 1 ); 616 setLineWidth( 1 );
627 } 617 }
628 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 618 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
629 //clear(); 619 //clear();
630 while ( CurrentAvailItem ) { 620 while ( CurrentAvailItem ) {
631 MonthViewItem *item = CurrentAvailItem; 621 MonthViewItem *item = CurrentAvailItem;
632 CurrentAvailItem = (MonthViewItem *)item->next(); 622 CurrentAvailItem = (MonthViewItem *)item->next();
633 mAvailItemList.append( item ); 623 mAvailItemList.append( item );
634 takeItem ( item ); 624 takeItem ( item );
635 } 625 }
636 626
637#ifdef DESKTOP_VERSION 627#ifdef DESKTOP_VERSION
638 QToolTip::remove(this); 628 QToolTip::remove(this);
639#endif 629#endif
640 mToolTip.clear(); 630 mToolTip.clear();
641 //qApp->processEvents(); 631 //qApp->processEvents();
642#if 0 632#if 0
643 if ( !mHolidayString.isEmpty() ) { 633 if ( !mHolidayString.isEmpty() ) {
644 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 634 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
645 item->setPalette( mHolidayPalette ); 635 item->setPalette( mHolidayPalette );
646 insertItem( item ); 636 insertItem( item );
647 mToolTip.append ( mHolidayString ); 637 mToolTip.append ( mHolidayString );
648 } 638 }
649#endif 639#endif
650} 640}
651 641
652int MonthViewCell::insertEvent(Event *event) 642int MonthViewCell::insertEvent(Event *event)
653{ 643{
654 bool useToolTips = true; 644 bool useToolTips = true;
655#ifndef DESKTOP_VERSION 645#ifndef DESKTOP_VERSION
656 useToolTips = false; 646 useToolTips = false;
657#endif 647#endif
658 QString mToolTipText; 648 QString mToolTipText;
659 setFocusPolicy(WheelFocus); 649 setFocusPolicy(WheelFocus);
660 if ( !(event->doesRecur() == Recurrence::rNone) ) { 650 if ( !(event->doesRecur() == Recurrence::rNone) ) {
661 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 651 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
662 return mdayCount; 652 return mdayCount;
663 else 653 else
664 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 654 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
665 return mdayCount; 655 return mdayCount;
666 } 656 }
667 657
668 if ( event->isHoliday()) { 658 if ( event->isHoliday()) {
669 setHoliday( true ); 659 setHoliday( true );
670 if ( mDate.dayOfWeek() == 7 ) 660 if ( mDate.dayOfWeek() == 7 )
671 setLineWidth( 3 ); 661 setLineWidth( 3 );
672 } 662 }
673 QString text; 663 QString text;
674 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 664 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
675 if (event->isMultiDay()) { 665 if (event->isMultiDay()) {
676 QString prefix = "<->";multiday = 2; 666 QString prefix = "<->";multiday = 2;
677 QString time; 667 QString time;
678 if ( event->doesRecur() ) { 668 if ( event->doesRecur() ) {
679 if ( event->recursOn( mDate) ) { 669 if ( event->recursOn( mDate) ) {
680 prefix ="->" ;multiday = 1; 670 prefix ="->" ;multiday = 1;
681 } 671 }
682 else { 672 else {
683 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 673 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
684 if ( event->recursOn( mDate.addDays( -days)) ) { 674 if ( event->recursOn( mDate.addDays( -days)) ) {
685 prefix ="<-" ;multiday = 3; 675 prefix ="<-" ;multiday = 3;
686 } 676 }
687 } 677 }
688 678
689 } else { 679 } else {
690 if (mDate == event->dtStart().date()) { 680 if (mDate == event->dtStart().date()) {
691 prefix ="->" ;multiday = 1; 681 prefix ="->" ;multiday = 1;
692 } else if (mDate == event->dtEnd().date()) { 682 } else if (mDate == event->dtEnd().date()) {
693 prefix ="<-" ;multiday = 3; 683 prefix ="<-" ;multiday = 3;
694 } 684 }
695 } 685 }
696 if ( !event->doesFloat() ) { 686 if ( !event->doesFloat() ) {
697 if ( mDate == event->dtStart().date () ) 687 if ( mDate == event->dtStart().date () )
698 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 688 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
699 else if ( mDate == event->dtEnd().date () ) 689 else if ( mDate == event->dtEnd().date () )
700 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 690 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
701 691
702 } 692 }
703 text = time + event->summary(); 693 text = time + event->summary();
704 if ( useToolTips ) 694 if ( useToolTips )
705 mToolTipText += prefix + text; 695 mToolTipText += prefix + text;
706 } else { 696 } else {
707 if (event->doesFloat()) { 697 if (event->doesFloat()) {
708 text = event->summary(); 698 text = event->summary();
709 if ( useToolTips ) 699 if ( useToolTips )
710 mToolTipText += text; 700 mToolTipText += text;
711 } 701 }
712 else { 702 else {
713 text = KGlobal::locale()->formatTime(event->dtStart().time()); 703 text = KGlobal::locale()->formatTime(event->dtStart().time());
714 text += " " + event->summary(); 704 text += " " + event->summary();
715 if ( useToolTips ) 705 if ( useToolTips )
716 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 706 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
717 } 707 }
718 } 708 }
719 if ( useToolTips && ! event->location().isEmpty() ) { 709 if ( useToolTips && ! event->location().isEmpty() ) {
720 mToolTipText += " (" + event->location() +")"; 710 mToolTipText += " (" + event->location() +")";
721 } 711 }
722 MonthViewItem *item ; 712 MonthViewItem *item ;
723 713
724 if ( mAvailItemList.count() ) { 714 if ( mAvailItemList.count() ) {
725 item = mAvailItemList.first(); 715 item = mAvailItemList.first();
726 mAvailItemList.remove( item ); 716 mAvailItemList.remove( item );
727 item->recycle( event, mDate, text ); 717 item->recycle( event, mDate, text );
728 } else { 718 } else {
729 item = new MonthViewItem( event, mDate, text ); 719 item = new MonthViewItem( event, mDate, text );
730 } 720 }
731 721
732 QPalette pal; 722 QPalette pal;
733 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 723 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
734 QStringList categories = event->categories(); 724 QStringList categories = event->categories();
735 QString cat = categories.first(); 725 QString cat = categories.first();
736 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 726 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
737 pal = getPalette(); 727 pal = getPalette();
738 if (cat.isEmpty()) { 728 if (cat.isEmpty()) {
739 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 729 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
740 } else { 730 } else {
741 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 731 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
742 } 732 }
743 733
744 } else { 734 } else {
745 if (cat.isEmpty()) { 735 if (cat.isEmpty()) {
746 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 736 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
747 } else { 737 } else {
748 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 738 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
749 } 739 }
750 } 740 }
751 741
752 } else { 742 } else {
753 pal = mStandardPalette ; 743 pal = mStandardPalette ;
754 } 744 }
755 item->setPalette( pal ); 745 item->setPalette( pal );
756 item->setRecur( event->recurrence()->doesRecur() ); 746 item->setRecur( event->recurrence()->doesRecur() );
757 item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); 747 item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
758 item->setMoreInfo( event->description().length() > 0 ); 748 item->setMoreInfo( event->description().length() > 0 );
759#ifdef DESKTOP_VERSION 749#ifdef DESKTOP_VERSION
760 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 750 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
761 KOPrefs::instance()->email()); 751 KOPrefs::instance()->email());
762 if ( me != 0 ) { 752 if ( me != 0 ) {
763 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 753 if ( me->status() == Attendee::NeedsAction && me->RSVP())
764 item->setReply(true && multiday < 2); 754 item->setReply(true && multiday < 2);
765 else 755 else
766 item->setReply(false); 756 item->setReply(false);
767 } else 757 } else
768 item->setReply(false); 758 item->setReply(false);
769#endif 759#endif
770 item->setMultiDay( multiday ); 760 item->setMultiDay( multiday );
771 if ( multiday ) { 761 if ( multiday ) {
772 insertItem( item ,mdayCount); 762 insertItem( item ,mdayCount);
773 ++mdayCount; 763 ++mdayCount;
774 } else { 764 } else {
775 uint i; 765 uint i;
776 int pos = mdayCount; 766 int pos = mdayCount;
777 for ( i = mdayCount; i < count();++i ) { 767 for ( i = mdayCount; i < count();++i ) {
778 QListBoxItem* it = this->item ( i ); 768 QListBoxItem* it = this->item ( i );
779 if ( text < it->text() ) { 769 if ( text < it->text() ) {
780 pos = i; 770 pos = i;
781 break; 771 break;
782 } 772 }
783 ++pos; 773 ++pos;
784 } 774 }
785 insertItem( item ,pos); 775 insertItem( item ,pos);
786 } 776 }
787 if ( useToolTips ) { 777 if ( useToolTips ) {
788 mToolTip.append( mToolTipText ); 778 mToolTip.append( mToolTipText );
789 } 779 }
790 return mdayCount; 780 return mdayCount;
791} 781}
792void MonthViewCell::insertTodo(Todo *todo) 782void MonthViewCell::insertTodo(Todo *todo)
793{ 783{
794 setFocusPolicy(WheelFocus); 784 setFocusPolicy(WheelFocus);
795 QString text; 785 QString text;
796 if (todo->hasDueDate()) { 786 if (todo->hasDueDate()) {
797 if (!todo->doesFloat()) { 787 if (!todo->doesFloat()) {
798 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 788 text += KGlobal::locale()->formatTime(todo->dtDue().time());
799 text += " "; 789 text += " ";
800 } 790 }
801 } 791 }
802 text += todo->summary(); 792 text += todo->summary();
803 MonthViewItem *item ; 793 MonthViewItem *item ;
804 if ( mAvailItemList.count() ) { 794 if ( mAvailItemList.count() ) {
805 item = mAvailItemList.first(); 795 item = mAvailItemList.first();
806 mAvailItemList.remove( item ); 796 mAvailItemList.remove( item );
807 item->recycle( todo, mDate, text ); 797 item->recycle( todo, mDate, text );
808 } else { 798 } else {
809 item = new MonthViewItem( todo, mDate, text ); 799 item = new MonthViewItem( todo, mDate, text );
810 } 800 }
811 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 801 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
812 //item->setPalette( mStandardPalette ); 802 //item->setPalette( mStandardPalette );
813 QPalette pal; 803 QPalette pal;
814 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 804 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
815 QStringList categories = todo->categories(); 805 QStringList categories = todo->categories();
816 QString cat = categories.first(); 806 QString cat = categories.first();
817 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 807 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
818 pal = getPalette(); 808 pal = getPalette();
819 if (cat.isEmpty()) { 809 if (cat.isEmpty()) {
820 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 810 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
821 } else { 811 } else {
822 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 812 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
823 } 813 }
824 814
825 } else { 815 } else {
826 if (cat.isEmpty()) { 816 if (cat.isEmpty()) {
827 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 817 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
828 } else { 818 } else {
829 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 819 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
830 } 820 }
831 } 821 }
832 822
833 } else { 823 } else {
834 pal = mStandardPalette ; 824 pal = mStandardPalette ;
835 } 825 }
836 item->setPalette( pal ); 826 item->setPalette( pal );
837 item->setRecur( todo->recurrence()->doesRecur() ); 827 item->setRecur( todo->recurrence()->doesRecur() );
838 item->setAlarm( todo->isAlarmEnabled() ); 828 item->setAlarm( todo->isAlarmEnabled() );
839 item->setMoreInfo( todo->description().length() > 0 ); 829 item->setMoreInfo( todo->description().length() > 0 );
840 insertItem( item , count()); 830 insertItem( item , count());
841#ifdef DESKTOP_VERSION 831#ifdef DESKTOP_VERSION
842 mToolTip.append( text ); 832 mToolTip.append( text );
843#endif 833#endif
844} 834}
845void MonthViewCell::repaintfinishUpdateCell() 835void MonthViewCell::repaintfinishUpdateCell()
846{ 836{
847 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 837 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
848 while ( mitem ) { 838 while ( mitem ) {
849 mitem->setBlockRepaint( false ); 839 mitem->setBlockRepaint( false );
850 updateItem ( mitem ); 840 updateItem ( mitem );
851 mitem = (MonthViewItem *)mitem->next(); 841 mitem = (MonthViewItem *)mitem->next();
852 } 842 }
853} 843}
854void MonthViewCell::finishUpdateCell() 844void MonthViewCell::finishUpdateCell()
855{ 845{
856 846
857 847
858 848
859#ifdef DESKTOP_VERSION 849#ifdef DESKTOP_VERSION
860 if (mToolTip.count() > 0 ) { 850 if (mToolTip.count() > 0 ) {
861 mToolTip.sort(); 851 mToolTip.sort();
862 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 852 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
863 } 853 }
864#endif 854#endif
865 //sort(); 855 //sort();
866 //setMyPalette(); 856 //setMyPalette();
867 setMyPalette(); 857 setMyPalette();
868 858
869 resizeEvent( 0 ); 859 resizeEvent( 0 );
870 860
871} 861}
872void MonthViewCell::updateCell() 862void MonthViewCell::updateCell()
873{ 863{
874 //qDebug("MonthViewCell::updateCell() ");
875 if ( !mMonthView->isUpdatePossible() ) 864 if ( !mMonthView->isUpdatePossible() )
876 return; 865 return;
877 startUpdateCell(); 866 startUpdateCell();
878 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 867 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
879 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 868 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
880 Event *event; 869 Event *event;
881 for( event = events.first(); event; event = events.next() ) { // for event 870 for( event = events.first(); event; event = events.next() ) { // for event
882 insertEvent(event); 871 insertEvent(event);
883 } 872 }
884 // insert due todos 873 // insert due todos
885 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 874 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
886 Todo *todo; 875 Todo *todo;
887 for(todo = todos.first(); todo; todo = todos.next()) { 876 for(todo = todos.first(); todo; todo = todos.next()) {
888 insertTodo( todo ); 877 insertTodo( todo );
889 } 878 }
890 finishUpdateCell(); 879 finishUpdateCell();
891 // if ( isVisible()) 880 // if ( isVisible())
892 //qApp->processEvents(); 881 //qApp->processEvents();
893} 882}
894 883
895void MonthViewCell::updateConfig( bool bigFont ) // = false 884void MonthViewCell::updateConfig( bool bigFont ) // = false
896{ 885{
897 886
898 if ( bigFont ) { 887 if ( bigFont ) {
899 QFont fo = KOPrefs::instance()->mMonthViewFont; 888 QFont fo = KOPrefs::instance()->mMonthViewFont;
900 int ps = fo.pointSize() + 2; 889 int ps = fo.pointSize() + 2;
901 if ( ps < 18 ) 890 if ( ps < 18 )
902 ps += 2; 891 ps += 2;
903 fo.setPointSize( ps ); 892 fo.setPointSize( ps );
904 setFont( fo ); 893 setFont( fo );
905 } else 894 } else
906 setFont( KOPrefs::instance()->mMonthViewFont ); 895 setFont( KOPrefs::instance()->mMonthViewFont );
907 896
908 QFontMetrics fm( font() ); 897 QFontMetrics fm( font() );
909 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 898 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
910 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 899 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
911 mHolidayPalette = mStandardPalette; 900 mHolidayPalette = mStandardPalette;
912 mPrimaryPalette = mStandardPalette; 901 mPrimaryPalette = mStandardPalette;
913 mNonPrimaryPalette = mStandardPalette; 902 mNonPrimaryPalette = mStandardPalette;
914 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 903 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
915 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 904 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
916 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 905 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
917 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 906 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
918 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 907 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
919 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 908 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
920 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 909 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
921 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 910 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
922 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 911 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
923 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 912 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
924 } 913 }
925 //updateCell(); 914 //updateCell();
926} 915}
927 916
928void MonthViewCell::enableScrollBars( bool enabled ) 917void MonthViewCell::enableScrollBars( bool enabled )
929{ 918{
930 919
931 return; 920 return;
932 if ( enabled ) { 921 if ( enabled ) {
933 QListBoxItem *fi = firstItem (); 922 QListBoxItem *fi = firstItem ();
934 if (fi ) { 923 if (fi ) {
935 int ihei = fi->height( this ); 924 int ihei = fi->height( this );
936 int hei = numRows () * ihei; 925 int hei = numRows () * ihei;
937 if ( hei < height() - horizontalScrollBar()->height () ) { 926 if ( hei < height() - horizontalScrollBar()->height () ) {
938 setVScrollBarMode(QScrollView::AlwaysOff); 927 setVScrollBarMode(QScrollView::AlwaysOff);
939 } 928 }
940 else 929 else
941 setVScrollBarMode(QScrollView::Auto); 930 setVScrollBarMode(QScrollView::Auto);
942 if ( ihei *3 > height() ) { 931 if ( ihei *3 > height() ) {
943 setHScrollBarMode(QScrollView::AlwaysOff); 932 setHScrollBarMode(QScrollView::AlwaysOff);
944 } 933 }
945 else { 934 else {
946 setHScrollBarMode(QScrollView::Auto); 935 setHScrollBarMode(QScrollView::Auto);
947 } 936 }
948 } else { 937 } else {
949 setVScrollBarMode(QScrollView::Auto); 938 setVScrollBarMode(QScrollView::Auto);
950 setHScrollBarMode(QScrollView::Auto); 939 setHScrollBarMode(QScrollView::Auto);
951 } 940 }
952 } else { 941 } else {
953 setVScrollBarMode(QScrollView::AlwaysOff); 942 setVScrollBarMode(QScrollView::AlwaysOff);
954 setHScrollBarMode(QScrollView::AlwaysOff); 943 setHScrollBarMode(QScrollView::AlwaysOff);
955 } 944 }
956} 945}
957 946
958Incidence *MonthViewCell::selectedIncidence() 947Incidence *MonthViewCell::selectedIncidence()
959{ 948{
960 int index = currentItem(); 949 int index = currentItem();
961 if ( index < 0 ) return 0; 950 if ( index < 0 ) return 0;
962 951
963 MonthViewItem *mitem = 952 MonthViewItem *mitem =
964 static_cast<MonthViewItem *>( item( index ) ); 953 static_cast<MonthViewItem *>( item( index ) );
965 954
966 if ( !mitem ) return 0; 955 if ( !mitem ) return 0;
967 956
968 return mitem->incidence(); 957 return mitem->incidence();
969} 958}
970 959
971QDate MonthViewCell::selectedIncidenceDate() 960QDate MonthViewCell::selectedIncidenceDate()
972{ 961{
973 QDate qd; 962 QDate qd;
974 int index = currentItem(); 963 int index = currentItem();
975 if ( index < 0 ) return qd; 964 if ( index < 0 ) return qd;
976 965
977 MonthViewItem *mitem = 966 MonthViewItem *mitem =
978 static_cast<MonthViewItem *>( item( index ) ); 967 static_cast<MonthViewItem *>( item( index ) );
979 968
980 if ( !mitem ) return qd; 969 if ( !mitem ) return qd;
981 970
982 return mitem->incidenceDate(); 971 return mitem->incidenceDate();
983} 972}
984 973
985void MonthViewCell::deselect() 974void MonthViewCell::deselect()
986{ 975{
987 clearSelection(); 976 clearSelection();
988 enableScrollBars( false ); 977 enableScrollBars( false );
989 // updateCell(); 978 // updateCell();
990} 979}
991void MonthViewCell::select() 980void MonthViewCell::select()
992{ 981{
993 ;// updateCell(); 982 ;// updateCell();
994} 983}
995 984
996void MonthViewCell::resizeEvent ( QResizeEvent * e ) 985void MonthViewCell::resizeEvent ( QResizeEvent * e )
997{ 986{
998 if ( !mMonthView->isUpdatePossible() ) 987 if ( !mMonthView->isUpdatePossible() )
999 return; 988 return;
1000 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 989 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
1001 deselect(); 990 deselect();
1002 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 991 mLabel->setMaximumHeight( height() - lineWidth()*2 );
1003 992
1004 QString text; 993 QString text;
1005 mLabel->setText( text ); 994 mLabel->setText( text );
1006 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 995 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
1007 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 996 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
1008 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 997 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
1009 mLabel->resize( mLabelBigSize ); 998 mLabel->resize( mLabelBigSize );
1010 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 999 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1011 } else { 1000 } else {
1012 mLabel->resize( mLabelSize ); 1001 mLabel->resize( mLabelSize );
1013 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1002 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1014 } 1003 }
1015 mLabel->setText( text ); 1004 mLabel->setText( text );
1016 1005
1017 int size = height() - mLabel->height() - lineWidth()-1; 1006 int size = height() - mLabel->height() - lineWidth()-1;
1018 //qDebug("LW %d ", lineWidth()); 1007 //qDebug("LW %d ", lineWidth());
1019 if ( size > 0 ) 1008 if ( size > 0 )
1020 verticalScrollBar()->setMaximumHeight( size ); 1009 verticalScrollBar()->setMaximumHeight( size );
1021 size = width() - mLabel->width() -lineWidth()-1; 1010 size = width() - mLabel->width() -lineWidth()-1;
1022 if ( size > 0 ) 1011 if ( size > 0 )
1023 horizontalScrollBar()->setMaximumWidth( size ); 1012 horizontalScrollBar()->setMaximumWidth( size );
1024 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1013 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1025 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1014 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1026 // mItemList->resize ( width(), height () ); 1015 // mItemList->resize ( width(), height () );
1027 if ( e ) 1016 if ( e )
1028 KNoScrollListBox::resizeEvent ( e ); 1017 KNoScrollListBox::resizeEvent ( e );
1029} 1018}
1030 1019
1031void MonthViewCell::defaultAction( QListBoxItem *item ) 1020void MonthViewCell::defaultAction( QListBoxItem *item )
1032{ 1021{
1033 1022
1034 if ( !item ) { 1023 if ( !item ) {
1035 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1024 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1036 emit newEventSignal( dt ); 1025 emit newEventSignal( dt );
1037 return; 1026 return;
1038 } 1027 }
1039 1028
1040 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1029 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1041 Incidence *incidence = eventItem->incidence(); 1030 Incidence *incidence = eventItem->incidence();
1042 if ( incidence ) mMonthView->defaultAction( incidence ); 1031 if ( incidence ) mMonthView->defaultAction( incidence );
1043} 1032}
1044void MonthViewCell::showDay() 1033void MonthViewCell::showDay()
1045{ 1034{
1046 emit showDaySignal( date() ); 1035 emit showDaySignal( date() );
1047} 1036}
1048void MonthViewCell::newEvent() 1037void MonthViewCell::newEvent()
1049{ 1038{
1050 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1039 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1051 emit newEventSignal( dt ); 1040 emit newEventSignal( dt );
1052} 1041}
1053void MonthViewCell::cellClicked( QListBoxItem *item ) 1042void MonthViewCell::cellClicked( QListBoxItem *item )
1054{ 1043{
1055 mMonthView->setSelectedCell( this ); 1044 mMonthView->setSelectedCell( this );
1056 qDebug("CELL ");
1057 if ( item == 0 ) { 1045 if ( item == 0 ) {
1058 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1046 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1059 emit newEventSignal( dt ); 1047 emit newEventSignal( dt );
1060 return; 1048 return;
1061 } 1049 }
1062 1050
1063} 1051}
1064 1052
1065void MonthViewCell::contextMenu( QListBoxItem *item ) 1053void MonthViewCell::contextMenu( QListBoxItem *item )
1066{ 1054{
1067 mMonthView->setPopupCell( this ); 1055 mMonthView->setPopupCell( this );
1068 if ( !item ) { 1056 if ( !item ) {
1069 mMonthView->showContextMenu( 0 ); 1057 mMonthView->showContextMenu( 0 );
1070 return; 1058 return;
1071 } 1059 }
1072 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1060 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1073 Incidence *incidence = eventItem->incidence(); 1061 Incidence *incidence = eventItem->incidence();
1074 if ( incidence ) mMonthView->showContextMenu( incidence ); 1062 if ( incidence ) mMonthView->showContextMenu( incidence );
1075} 1063}
1076 1064
1077void MonthViewCell::selection( QListBoxItem *item ) 1065void MonthViewCell::selection( QListBoxItem *item )
1078{ 1066{
1079 if ( !item ) return; 1067 if ( !item ) return;
1080 1068
1081 mMonthView->setSelectedCell( this ); 1069 mMonthView->setSelectedCell( this );
1082} 1070}
1083 1071
1084 1072
1085// ******************************************************************************* 1073// *******************************************************************************
1086// ******************************************************************************* 1074// *******************************************************************************
1087// ******************************************************************************* 1075// *******************************************************************************
1088 1076
1089 1077
1090KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1078KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1091 : KOEventView( calendar, parent, name ), 1079 : KOEventView( calendar, parent, name ),
1092 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1080 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1093 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1081 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1094{ 1082{
1095 mFlagKeyPressed = false; 1083 mFlagKeyPressed = false;
1096 mShortDayLabelsM = false; 1084 mShortDayLabelsM = false;
1097 mShortDayLabelsW = false; 1085 mShortDayLabelsW = false;
1098 skipResize = false; 1086 skipResize = false;
1099 clPending = true; 1087 clPending = true;
1100 mPopupCell = 0; 1088 mPopupCell = 0;
1101 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1089 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1102 mWidStack = new QWidgetStack( this ); 1090 mWidStack = new QWidgetStack( this );
1103 QVBoxLayout* hb = new QVBoxLayout( this ); 1091 QVBoxLayout* hb = new QVBoxLayout( this );
1104 mMonthView = new QWidget( mWidStack ); 1092 mMonthView = new QWidget( mWidStack );
1105 mWeekView = new QWidget( mWidStack ); 1093 mWeekView = new QWidget( mWidStack );
1106#if QT_VERSION >= 0x030000 1094#if QT_VERSION >= 0x030000
1107 mWidStack->addWidget(mMonthView ); 1095 mWidStack->addWidget(mMonthView );
1108 mWidStack->addWidget(mWeekView ); 1096 mWidStack->addWidget(mWeekView );
1109#else 1097#else
1110 mWidStack->addWidget( mMonthView, 1 ); 1098 mWidStack->addWidget( mMonthView, 1 );
1111 mWidStack->addWidget( mWeekView , 1 ); 1099 mWidStack->addWidget( mWeekView , 1 );
1112#endif 1100#endif
1113 hb->addWidget( mNavigatorBar ); 1101 hb->addWidget( mNavigatorBar );
1114 hb->addWidget( mWidStack ); 1102 hb->addWidget( mWidStack );
1115 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1103 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1116 updatePossible = false; 1104 updatePossible = false;
1117 //updatePossible = true; 1105 //updatePossible = true;
1118 mCells.setAutoDelete( true ); 1106 mCells.setAutoDelete( true );
1119 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1107 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1120 mDayLabels.resize( mDaysPerWeek ); 1108 mDayLabels.resize( mDaysPerWeek );
1121 mDayLabelsW.resize( mDaysPerWeek ); 1109 mDayLabelsW.resize( mDaysPerWeek );
1122 QFont bfont = font(); 1110 QFont bfont = font();
1123 if ( QApplication::desktop()->width() < 650 ) { 1111 if ( QApplication::desktop()->width() < 650 ) {
1124 bfont.setPointSize( bfont.pointSize() - 2 ); 1112 bfont.setPointSize( bfont.pointSize() - 2 );
1125 } 1113 }
1126 bfont.setBold( true ); 1114 bfont.setBold( true );
1127 int i; 1115 int i;
1128 1116
1129 for( i = 0; i < mDaysPerWeek; i++ ) { 1117 for( i = 0; i < mDaysPerWeek; i++ ) {
1130 QLabel *label = new QLabel( mMonthView ); 1118 QLabel *label = new QLabel( mMonthView );
1131 label->setFont(bfont); 1119 label->setFont(bfont);
1132 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1120 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1133 label->setLineWidth(1); 1121 label->setLineWidth(1);
1134 label->setAlignment(AlignCenter); 1122 label->setAlignment(AlignCenter);
1135 mDayLabels.insert( i, label ); 1123 mDayLabels.insert( i, label );
1136 label = new QLabel( mWeekView ); 1124 label = new QLabel( mWeekView );
1137 label->setFont(bfont); 1125 label->setFont(bfont);
1138 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1126 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1139 label->setLineWidth(1); 1127 label->setLineWidth(1);
1140 label->setAlignment(AlignCenter); 1128 label->setAlignment(AlignCenter);
1141 mDayLabelsW.insert( i, label ); 1129 mDayLabelsW.insert( i, label );
1142 } 1130 }
1143 1131
1144 bfont.setBold( false ); 1132 bfont.setBold( false );
1145 mWeekLabels.resize( mNumWeeks+1 ); 1133 mWeekLabels.resize( mNumWeeks+1 );
1146 mWeekLabelsW.resize( 2 ); 1134 mWeekLabelsW.resize( 2 );
1147 for( i = 0; i < mNumWeeks+1; i++ ) { 1135 for( i = 0; i < mNumWeeks+1; i++ ) {
1148 KOWeekButton *label = new KOWeekButton( mMonthView ); 1136 KOWeekButton *label = new KOWeekButton( mMonthView );
1149 label->setFocusPolicy(NoFocus); 1137 label->setFocusPolicy(NoFocus);
1150 label->setFont(bfont); 1138 label->setFont(bfont);
1151 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1139 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1152 label->setFlat(true); 1140 label->setFlat(true);
1153 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1141 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1154 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1142 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1155 //label->setLineWidth(1); 1143 //label->setLineWidth(1);
1156 //label->setAlignment(AlignCenter); 1144 //label->setAlignment(AlignCenter);
1157 mWeekLabels.insert( i, label ); 1145 mWeekLabels.insert( i, label );
1158 } 1146 }
1159 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1147 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1160 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1148 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1161 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1149 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1162 1150
1163 for( i = 0; i < 1+1; i++ ) { 1151 for( i = 0; i < 1+1; i++ ) {
1164 KOWeekButton *label = new KOWeekButton( mWeekView ); 1152 KOWeekButton *label = new KOWeekButton( mWeekView );
1165 label->setFocusPolicy(NoFocus); 1153 label->setFocusPolicy(NoFocus);
1166 label->setFont(bfont); 1154 label->setFont(bfont);
1167 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1155 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1168 label->setFlat(true); 1156 label->setFlat(true);
1169 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1157 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1170 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1158 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1171 //label->setLineWidth(1); 1159 //label->setLineWidth(1);
1172 //label->setAlignment(AlignCenter); 1160 //label->setAlignment(AlignCenter);
1173 mWeekLabelsW.insert( i, label ); 1161 mWeekLabelsW.insert( i, label );
1174 } 1162 }
1175 mWeekLabelsW[1]->setText( i18n("W")); 1163 mWeekLabelsW[1]->setText( i18n("W"));
1176 mWeekLabelsW[1]->setFocusPolicy(WheelFocus); 1164 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1177 1165
1178 1166
1179 int row, col; 1167 int row, col;
1180 mCells.resize( mNumCells ); 1168 mCells.resize( mNumCells );
1181 for( row = 0; row < mNumWeeks; ++row ) { 1169 for( row = 0; row < mNumWeeks; ++row ) {
1182 for( col = 0; col < mDaysPerWeek; ++col ) { 1170 for( col = 0; col < mDaysPerWeek; ++col ) {
1183 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1171 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1184 mCells.insert( row * mDaysPerWeek + col, cell ); 1172 mCells.insert( row * mDaysPerWeek + col, cell );
1185 1173
1186 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1174 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1187 SLOT( defaultAction( Incidence * ) ) ); 1175 SLOT( defaultAction( Incidence * ) ) );
1188 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1176 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1189 SIGNAL( newEventSignal( QDateTime ) ) ); 1177 SIGNAL( newEventSignal( QDateTime ) ) );
1190 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1178 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1191 SIGNAL( showDaySignal( QDate ) ) ); 1179 SIGNAL( showDaySignal( QDate ) ) );
1192 connect( cell, SIGNAL( nextCell() ), 1180 connect( cell, SIGNAL( nextCell() ),
1193 SLOT( nextCell() ) ); 1181 SLOT( nextCell() ) );
1194 connect( cell, SIGNAL( prevCell() ), 1182 connect( cell, SIGNAL( prevCell() ),
1195 SLOT( prevCell() ) ); 1183 SLOT( prevCell() ) );
1196 } 1184 }
1197 } 1185 }
1198 mCellsW.resize( mDaysPerWeek ); 1186 mCellsW.resize( mDaysPerWeek );
1199 for( col = 0; col < mDaysPerWeek; ++col ) { 1187 for( col = 0; col < mDaysPerWeek; ++col ) {
1200 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1188 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1201 mCellsW.insert( col, cell ); 1189 mCellsW.insert( col, cell );
1202 1190
1203 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1191 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1204 SLOT( defaultAction( Incidence * ) ) ); 1192 SLOT( defaultAction( Incidence * ) ) );
1205 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1193 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1206 SIGNAL( newEventSignal( QDateTime ) ) ); 1194 SIGNAL( newEventSignal( QDateTime ) ) );
1207 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1195 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1208 SIGNAL( showDaySignal( QDate ) ) ); 1196 SIGNAL( showDaySignal( QDate ) ) );
1209 connect( cell, SIGNAL( nextCell() ), 1197 connect( cell, SIGNAL( nextCell() ),
1210 SLOT( nextCell() ) ); 1198 SLOT( nextCell() ) );
1211 connect( cell, SIGNAL( prevCell() ), 1199 connect( cell, SIGNAL( prevCell() ),
1212 SLOT( prevCell() ) ); 1200 SLOT( prevCell() ) );
1213 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1201 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1214 } 1202 }
1215 1203
1216 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1204 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1217 mContextMenu = eventPopup(); 1205 mContextMenu = eventPopup();
1218 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1206 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1219 i18n("New Event..."),this, 1207 i18n("New Event..."),this,
1220 SLOT(slotNewEvent()),false); 1208 SLOT(slotNewEvent()),false);
1221 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1209 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1222 i18n("New Todo..."),this, 1210 i18n("New Todo..."),this,
1223 SLOT(slotNewTodo()),false); 1211 SLOT(slotNewTodo()),false);
1224 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1212 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1225 i18n("Journal"),this, 1213 i18n("Journal"),this,
1226 SLOT(slotEditJournal()),false); 1214 SLOT(slotEditJournal()),false);
1227 1215
1228 1216
1229 1217
1230 QString pathString = ""; 1218 QString pathString = "";
1231 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 1219 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
1232 if ( QApplication::desktop()->width() < 480 ) 1220 if ( QApplication::desktop()->width() < 480 )
1233 pathString += "icons16/"; 1221 pathString += "icons16/";
1234 } else 1222 } else
1235 pathString += "iconsmini/"; 1223 pathString += "iconsmini/";
1236 mNewItemMenu = new QPopupMenu( this ); 1224 mNewItemMenu = new QPopupMenu( this );
1237 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); 1225 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent()));
1238 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); 1226 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false);
1239 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); 1227 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false);
1240 1228
1241 // updateConfig(); //useless here... 1229 // updateConfig(); //useless here...
1242 // ... but we need mWidthLongDayLabel computed 1230 // ... but we need mWidthLongDayLabel computed
1243 QFontMetrics fontmetric(mDayLabels[0]->font()); 1231 QFontMetrics fontmetric(mDayLabels[0]->font());
1244 mWidthLongDayLabel = 0; 1232 mWidthLongDayLabel = 0;
1245 for (int i = 0; i < 7; i++) { 1233 for (int i = 0; i < 7; i++) {
1246 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1234 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1247 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1235 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1248 } 1236 }
1249 1237
1250 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1238 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1251 1239
1252#if 0 1240#if 0
1253 if ( mShowWeekView ) 1241 if ( mShowWeekView )
1254 mWidStack->raiseWidget( mWeekView ); 1242 mWidStack->raiseWidget( mWeekView );
1255 else 1243 else
1256 mWidStack->raiseWidget( mMonthView ); 1244 mWidStack->raiseWidget( mMonthView );
1257#endif 1245#endif
1258 1246
1259 emit incidenceSelected( 0 ); 1247 emit incidenceSelected( 0 );
1260 1248
1261 mComputeLayoutTimer = new QTimer( this ); 1249 mComputeLayoutTimer = new QTimer( this );
1262 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1250 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1263 1251
1264 1252
1265#ifndef DESKTOP_VERSION 1253#ifndef DESKTOP_VERSION
1266 resize( QApplication::desktop()->size() ); 1254 resize( QApplication::desktop()->size() );
1267#else 1255#else
1268 resize(640, 480 ); 1256 resize(640, 480 );
1269 updatePossible = true; 1257 updatePossible = true;
1270#endif 1258#endif
1271 computeLayout(); 1259 computeLayout();
1272 1260
1273 if ( mShowWeekView ) 1261 if ( mShowWeekView )
1274 mWidStack->raiseWidget( mWeekView ); 1262 mWidStack->raiseWidget( mWeekView );
1275 else 1263 else
1276 mWidStack->raiseWidget( mMonthView ); 1264 mWidStack->raiseWidget( mMonthView );
1277} 1265}
1278 1266
1279KOMonthView::~KOMonthView() 1267KOMonthView::~KOMonthView()
1280{ 1268{
1281 delete mContextMenu; 1269 delete mContextMenu;
1282} 1270}
1283 1271
1284void KOMonthView::selectInternalWeekNum ( int n ) 1272void KOMonthView::selectInternalWeekNum ( int n )
1285{ 1273{
1286 switchView(); 1274 switchView();
1287 if ( !KOPrefs::instance()->mMonthViewWeek ) 1275 if ( !KOPrefs::instance()->mMonthViewWeek )
1288 emit selectMonth (); 1276 emit selectMonth ();
1289 else 1277 else
1290 emit selectWeekNum ( n ); 1278 emit selectWeekNum ( n );
1291} 1279}
1292 1280
1293int KOMonthView::currentWeek() 1281int KOMonthView::currentWeek()
1294{ 1282{
1295 if ( mShowWeekView ) 1283 if ( mShowWeekView )
1296 return mWeekLabelsW[0]->getWeekNum(); 1284 return mWeekLabelsW[0]->getWeekNum();
1297 return mWeekLabels[0]->getWeekNum(); 1285 return mWeekLabels[0]->getWeekNum();
1298} 1286}
1299void KOMonthView::switchView() 1287void KOMonthView::switchView()
1300{ 1288{
1301 if ( selectedCell( ) ) 1289 if ( selectedCell( ) )
1302 selectedCell()->deselect(); 1290 selectedCell()->deselect();
1303 mShowWeekView = !mShowWeekView; 1291 mShowWeekView = !mShowWeekView;
1304 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1292 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1305 if ( clPending ) { 1293 if ( clPending ) {
1306 computeLayout(); 1294 computeLayout();
1307 updateConfig(); 1295 updateConfig();
1308 } 1296 }
1309 if ( mShowWeekView ) 1297 if ( mShowWeekView )
1310 mWidStack->raiseWidget( mWeekView ); 1298 mWidStack->raiseWidget( mWeekView );
1311 else 1299 else
1312 mWidStack->raiseWidget( mMonthView ); 1300 mWidStack->raiseWidget( mMonthView );
1313 clPending = false; 1301 clPending = false;
1314} 1302}
1315 1303
1316int KOMonthView::maxDatesHint() 1304int KOMonthView::maxDatesHint()
1317{ 1305{
1318 return mNumCells; 1306 return mNumCells;
1319} 1307}
1320 1308
1321int KOMonthView::currentDateCount() 1309int KOMonthView::currentDateCount()
1322{ 1310{
1323 return mNumCells; 1311 return mNumCells;
1324} 1312}
1325 1313
1326QPtrList<Incidence> KOMonthView::selectedIncidences() 1314QPtrList<Incidence> KOMonthView::selectedIncidences()
1327{ 1315{
1328 QPtrList<Incidence> selected; 1316 QPtrList<Incidence> selected;
1329 1317
1330 if ( mSelectedCell ) { 1318 if ( mSelectedCell ) {
1331 Incidence *incidence = mSelectedCell->selectedIncidence(); 1319 Incidence *incidence = mSelectedCell->selectedIncidence();
1332 if ( incidence ) selected.append( incidence ); 1320 if ( incidence ) selected.append( incidence );
1333 } 1321 }
1334 1322
1335 return selected; 1323 return selected;
1336} 1324}
1337 1325
1338DateList KOMonthView::selectedDates() 1326DateList KOMonthView::selectedDates()
1339{ 1327{
1340 DateList selected; 1328 DateList selected;
1341 1329
1342 if ( mSelectedCell ) { 1330 if ( mSelectedCell ) {
1343 QDate qd = mSelectedCell->selectedIncidenceDate(); 1331 QDate qd = mSelectedCell->selectedIncidenceDate();
1344 if ( qd.isValid() ) selected.append( qd ); 1332 if ( qd.isValid() ) selected.append( qd );
1345 } 1333 }
1346 1334
1347 return selected; 1335 return selected;
1348} 1336}
1349 1337
1350void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1338void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1351 const QDate &td) 1339 const QDate &td)
1352{ 1340{
1353#ifndef KORG_NOPRINTER 1341#ifndef KORG_NOPRINTER
1354 calPrinter->preview(CalPrinter::Month, fd, td); 1342 calPrinter->preview(CalPrinter::Month, fd, td);
1355#endif 1343#endif
1356} 1344}
1357 1345
1358void KOMonthView::updateConfig() 1346void KOMonthView::updateConfig()
1359{ 1347{
1360 1348
1361 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1349 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1362 1350
1363 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1351 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1364 mWeekStartsMonday = true; 1352 mWeekStartsMonday = true;
1365 } 1353 }
1366 QFontMetrics fontmetric(mDayLabels[0]->font()); 1354 QFontMetrics fontmetric(mDayLabels[0]->font());
1367 mWidthLongDayLabel = 0; 1355 mWidthLongDayLabel = 0;
1368 1356
1369 for (int i = 0; i < 7; i++) { 1357 for (int i = 0; i < 7; i++) {
1370 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1358 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1371 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1359 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1372 } 1360 }
1373 bool temp = mShowSatSunComp ; 1361 bool temp = mShowSatSunComp ;
1374 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1362 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1375 if ( ! mShowWeekView ) { 1363 if ( ! mShowWeekView ) {
1376 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1364 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1377 computeLayout(); 1365 computeLayout();
1378 } 1366 }
1379 updateDayLabels(); 1367 updateDayLabels();
1380 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1368 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1381 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1369 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1382 //resizeEvent( 0 ); 1370 //resizeEvent( 0 );
1383 for (uint i = 0; i < mCells.count(); ++i) { 1371 for (uint i = 0; i < mCells.count(); ++i) {
1384 mCells[i]->updateConfig(); 1372 mCells[i]->updateConfig();
1385 } 1373 }
1386 1374
1387 for (uint i = 0; i < mCellsW.count(); ++i) { 1375 for (uint i = 0; i < mCellsW.count(); ++i) {
1388 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1376 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1389 } 1377 }
1390#ifdef DESKTOP_VERSION 1378#ifdef DESKTOP_VERSION
1391 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1379 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1392#endif 1380#endif
1393 updateView(); 1381 updateView();
1394} 1382}
1395 1383
1396void KOMonthView::updateDayLabels() 1384void KOMonthView::updateDayLabels()
1397{ 1385{
1398 1386
1399 QPtrVector<QLabel> *mDayLabelsT; 1387 QPtrVector<QLabel> *mDayLabelsT;
1400 1388
1401 mDayLabelsT = &mDayLabelsW; 1389 mDayLabelsT = &mDayLabelsW;
1402 for (int i = 0; i < 7; i++) { 1390 for (int i = 0; i < 7; i++) {
1403 { 1391 {
1404 bool show = mShortDayLabelsW; 1392 bool show = mShortDayLabelsW;
1405 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1393 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1406 show = true; 1394 show = true;
1407 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1395 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1408 } 1396 }
1409 } 1397 }
1410 mDayLabelsT = &mDayLabels; 1398 mDayLabelsT = &mDayLabels;
1411 for (int i = 0; i < 7; i++) { 1399 for (int i = 0; i < 7; i++) {
1412 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { 1400 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1413 bool show = mShortDayLabelsM; 1401 bool show = mShortDayLabelsM;
1414 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1402 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1415 show = true; 1403 show = true;
1416 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1404 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1417 } else { 1405 } else {
1418 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1406 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1419 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1407 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1420 1408
1421 } 1409 }
1422 } 1410 }
1423 1411
1424} 1412}
1425 1413
1426void KOMonthView::showDates(const QDate &start, const QDate &) 1414void KOMonthView::showDates(const QDate &start, const QDate &)
1427{ 1415{
1428 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1416 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1429 1417
1430 QPtrVector<MonthViewCell> *cells; 1418 QPtrVector<MonthViewCell> *cells;
1431 QPtrVector<QLabel> *dayLabels; 1419 QPtrVector<QLabel> *dayLabels;
1432 QPtrVector<KOWeekButton> *weekLabels; 1420 QPtrVector<KOWeekButton> *weekLabels;
1433 int weekNum = 6; 1421 int weekNum = 6;
1434 mStartDate = start; 1422 mStartDate = start;
1435 if ( mShowWeekView ) { 1423 if ( mShowWeekView ) {
1436 weekNum = 1; 1424 weekNum = 1;
1437 cells = &mCellsW; 1425 cells = &mCellsW;
1438 dayLabels = &mDayLabelsW; 1426 dayLabels = &mDayLabelsW;
1439 weekLabels = &mWeekLabelsW; 1427 weekLabels = &mWeekLabelsW;
1440 if ( !KGlobal::locale()->weekStartsMonday() ) { 1428 if ( !KGlobal::locale()->weekStartsMonday() ) {
1441 mStartDate = mStartDate.addDays( 1 ); 1429 mStartDate = mStartDate.addDays( 1 );
1442 } 1430 }
1443 } else { 1431 } else {
1444 cells = &mCells; 1432 cells = &mCells;
1445 dayLabels = &mDayLabels; 1433 dayLabels = &mDayLabels;
1446 weekLabels = &mWeekLabels; 1434 weekLabels = &mWeekLabels;
1447 } 1435 }
1448 1436
1449 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1437 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1450 1438
1451 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1439 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1452 mWeekStartsMonday = true; 1440 mWeekStartsMonday = true;
1453 } 1441 }
1454 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1442 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1455 1443
1456 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1444 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1457 mStartDate = mStartDate.addDays( -1 ); 1445 mStartDate = mStartDate.addDays( -1 );
1458 } 1446 }
1459 bool primary = false; 1447 bool primary = false;
1460 uint i; 1448 uint i;
1461 for( i = 0; i < (*cells).size(); ++i ) { 1449 for( i = 0; i < (*cells).size(); ++i ) {
1462 QDate date = mStartDate.addDays( i ); 1450 QDate date = mStartDate.addDays( i );
1463 (*cells)[i]->setDate( date ); 1451 (*cells)[i]->setDate( date );
1464 1452
1465#ifndef KORG_NOPLUGINS 1453#ifndef KORG_NOPLUGINS
1466 // add holiday, if present 1454 // add holiday, if present
1467 QString hstring(KOCore::self()->holiday(date)); 1455 QString hstring(KOCore::self()->holiday(date));
1468 (*cells)[i]->setHoliday( hstring ); 1456 (*cells)[i]->setHoliday( hstring );
1469#endif 1457#endif
1470 1458
1471 } 1459 }
1472 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1460 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1473 for( i = 0; i < weekNum; ++i ) { 1461 for( i = 0; i < weekNum; ++i ) {
1474 int wno; 1462 int wno;
1475 // remember, according to ISO 8601, the first week of the year is the 1463 // remember, according to ISO 8601, the first week of the year is the
1476 // first week that contains a thursday. Thus we must subtract off 4, 1464 // first week that contains a thursday. Thus we must subtract off 4,
1477 // not just 1. 1465 // not just 1.
1478 int dayOfYear = date.dayOfYear(); 1466 int dayOfYear = date.dayOfYear();
1479 if (dayOfYear % 7 != 0) 1467 if (dayOfYear % 7 != 0)
1480 wno = dayOfYear / 7 + 1; 1468 wno = dayOfYear / 7 + 1;
1481 else 1469 else
1482 wno =dayOfYear / 7; 1470 wno =dayOfYear / 7;
1483 (*weekLabels)[i]->setWeekNum( wno ); 1471 (*weekLabels)[i]->setWeekNum( wno );
1484 date = date.addDays( 7 ); 1472 date = date.addDays( 7 );
1485 } 1473 }
1486 updateView(); 1474 updateView();
1487} 1475}
1488 1476
1489void KOMonthView::showEvents(QPtrList<Event>) 1477void KOMonthView::showEvents(QPtrList<Event>)
1490{ 1478{
1491 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1479 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1492} 1480}
1493 1481
1494void KOMonthView::changeEventDisplay(Event *, int) 1482void KOMonthView::changeEventDisplay(Event *, int)
1495{ 1483{
1496 // this should be re-written to be much more efficient, but this 1484 // this should be re-written to be much more efficient, but this
1497 // quick-and-dirty-hack gets the job done for right now. 1485 // quick-and-dirty-hack gets the job done for right now.
1498 //qDebug("KOMonthView::changeEventDisplay "); 1486 //qDebug("KOMonthView::changeEventDisplay ");
1499 updateView(); 1487 updateView();
1500} 1488}
1501 1489
1502void KOMonthView::updateView() 1490void KOMonthView::updateView()
1503{ 1491{
1504 1492
1505 if ( !updatePossible ) 1493 if ( !updatePossible )
1506 return; 1494 return;
1507 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1495 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1508 //QTime ti; 1496 //QTime ti;
1509 //ti.start(); 1497 //ti.start();
1510 clearSelection(); 1498 clearSelection();
1511 QPtrVector<MonthViewCell> *cells; 1499 QPtrVector<MonthViewCell> *cells;
1512 if ( mShowWeekView ) { 1500 if ( mShowWeekView ) {
1513 cells = &mCellsW; 1501 cells = &mCellsW;
1514 } else { 1502 } else {
1515 cells = &mCells; 1503 cells = &mCells;
1516 } 1504 }
1517#if 1 1505#if 1
1518 int i; 1506 int i;
1519 int timeSpan = (*cells).size()-1; 1507 int timeSpan = (*cells).size()-1;
1520 if ( KOPrefs::instance()->mMonthViewWeek ) 1508 if ( KOPrefs::instance()->mMonthViewWeek )
1521 timeSpan = 6; 1509 timeSpan = 6;
1522 for( i = 0; i < timeSpan + 1; ++i ) { 1510 for( i = 0; i < timeSpan + 1; ++i ) {
1523 (*cells)[i]->startUpdateCell(); 1511 (*cells)[i]->startUpdateCell();
1524 } 1512 }
1525 1513
1526 QPtrList<Event> events = calendar()->events(); 1514 QPtrList<Event> events = calendar()->events();
1527 Event *event; 1515 Event *event;
1528 QDateTime dt; 1516 QDateTime dt;
1529 bool ok; 1517 bool ok;
1530 QDate endDate = mStartDate.addDays( timeSpan ); 1518 QDate endDate = mStartDate.addDays( timeSpan );
1531 for( event = events.first(); event; event = events.next() ) { // for event 1519 for( event = events.first(); event; event = events.next() ) { // for event
1532 if ( event->doesRecur() ) { 1520 if ( event->doesRecur() ) {
1533 bool last; 1521 bool last;
1534 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1522 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1535 QDateTime incidenceEnd; 1523 QDateTime incidenceEnd;
1536 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1524 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1537 bool invalid = false; 1525 bool invalid = false;
1538 while( true ) { 1526 while( true ) {
1539 if ( incidenceStart.isValid() ) { 1527 if ( incidenceStart.isValid() ) {
1540 incidenceEnd = incidenceStart.addDays( eventlen ); 1528 incidenceEnd = incidenceStart.addDays( eventlen );
1541 int st = incidenceStart.date().daysTo( endDate ); 1529 int st = incidenceStart.date().daysTo( endDate );
1542 if ( st >= 0 ) { // start before timeend 1530 if ( st >= 0 ) { // start before timeend
1543 int end = mStartDate.daysTo( incidenceEnd.date() ); 1531 int end = mStartDate.daysTo( incidenceEnd.date() );
1544 if ( end >= 0 ) { // end after timestart --- got one! 1532 if ( end >= 0 ) { // end after timestart --- got one!
1545 //normalize 1533 //normalize
1546 st = timeSpan - st; 1534 st = timeSpan - st;
1547 if ( st < 0 ) st = 0; 1535 if ( st < 0 ) st = 0;
1548 if ( end > timeSpan ) end = timeSpan; 1536 if ( end > timeSpan ) end = timeSpan;
1549 int iii; 1537 int iii;
1550 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1538 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1551 for ( iii = st;iii<= end;++iii) 1539 for ( iii = st;iii<= end;++iii)
1552 (*cells)[iii]->insertEvent( event ); 1540 (*cells)[iii]->insertEvent( event );
1553 } 1541 }
1554 } 1542 }
1555 } else { 1543 } else {
1556 if ( invalid ) 1544 if ( invalid )
1557 break; 1545 break;
1558 invalid = true; 1546 invalid = true;
1559 //qDebug("invalid %s", event->summary().latin1()); 1547 //qDebug("invalid %s", event->summary().latin1());
1560 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1548 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1561 } 1549 }
1562 if ( last ) 1550 if ( last )
1563 break; 1551 break;
1564 bool ok; 1552 bool ok;
1565 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1553 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1566 if ( ! ok ) 1554 if ( ! ok )
1567 break; 1555 break;
1568 if ( incidenceStart.date() > endDate ) 1556 if ( incidenceStart.date() > endDate )
1569 break; 1557 break;
1570 } 1558 }
1571 } else { // no recur 1559 } else { // no recur
1572 int st = event->dtStart().date().daysTo( endDate ); 1560 int st = event->dtStart().date().daysTo( endDate );
1573 if ( st >= 0 ) { // start before timeend 1561 if ( st >= 0 ) { // start before timeend
1574 int end = mStartDate.daysTo( event->dtEnd().date() ); 1562 int end = mStartDate.daysTo( event->dtEnd().date() );
1575 if ( end >= 0 ) { // end after timestart --- got one! 1563 if ( end >= 0 ) { // end after timestart --- got one!
1576 //normalize 1564 //normalize
1577 st = timeSpan - st; 1565 st = timeSpan - st;
1578 if ( st < 0 ) st = 0; 1566 if ( st < 0 ) st = 0;
1579 if ( end > timeSpan ) end = timeSpan; 1567 if ( end > timeSpan ) end = timeSpan;
1580 int iii; 1568 int iii;
1581 for ( iii = st;iii<= end;++iii) 1569 for ( iii = st;iii<= end;++iii)
1582 (*cells)[iii]->insertEvent( event ); 1570 (*cells)[iii]->insertEvent( event );
1583 } 1571 }
1584 } 1572 }
1585 } 1573 }
1586 } 1574 }
1587 // insert due todos 1575 // insert due todos
1588 QPtrList<Todo> todos = calendar()->todos( ); 1576 QPtrList<Todo> todos = calendar()->todos( );
1589 Todo *todo; 1577 Todo *todo;
1590 for(todo = todos.first(); todo; todo = todos.next()) { 1578 for(todo = todos.first(); todo; todo = todos.next()) {
1591 //insertTodo( todo ); 1579 //insertTodo( todo );
1592 if ( todo->hasDueDate() ) { 1580 if ( todo->hasDueDate() ) {
1593 int day = mStartDate.daysTo( todo->dtDue().date() ); 1581 int day = mStartDate.daysTo( todo->dtDue().date() );
1594 if ( day >= 0 && day < timeSpan + 1) { 1582 if ( day >= 0 && day < timeSpan + 1) {
1595 (*cells)[day]->insertTodo( todo ); 1583 (*cells)[day]->insertTodo( todo );
1596 } 1584 }
1597 } 1585 }
1598 } 1586 }
1599 1587
1600 for( i = 0; i < timeSpan+1; ++i ) { 1588 for( i = 0; i < timeSpan+1; ++i ) {
1601 (*cells)[i]->finishUpdateCell(); 1589 (*cells)[i]->finishUpdateCell();
1602 } 1590 }
1603 processSelectionChange(); 1591 processSelectionChange();
1604 //qApp->processEvents(); 1592 //qApp->processEvents();
1605 for( i = 0; i < timeSpan+1; ++i ) { 1593 for( i = 0; i < timeSpan+1; ++i ) {
1606 (*cells)[i]->repaintfinishUpdateCell(); 1594 (*cells)[i]->repaintfinishUpdateCell();
1607 } 1595 }
1608 setKeyBFocus(); 1596 setKeyBFocus();
1609#else 1597#else
1610 // old code 1598 // old code
1611 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1599 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1612 int i; 1600 int i;
1613 for( i = 0; i < (*cells).count(); ++i ) { 1601 for( i = 0; i < (*cells).count(); ++i ) {
1614 (*cells)[i]->updateCell(); 1602 (*cells)[i]->updateCell();
1615 } 1603 }
1616 1604
1617 //qDebug("KOMonthView::updateView() "); 1605 //qDebug("KOMonthView::updateView() ");
1618 processSelectionChange(); 1606 processSelectionChange();
1619 // qDebug("---------------------------------------------------------------------+ "); 1607 // qDebug("---------------------------------------------------------------------+ ");
1620 (*cells)[0]->setFocus(); 1608 (*cells)[0]->setFocus();
1621#endif 1609#endif
1622 1610
1623 //qDebug("update time %d ", ti.elapsed()); 1611 //qDebug("update time %d ", ti.elapsed());
1624} 1612}
1625 1613
1626void KOMonthView::setKeyBoardFocus() 1614void KOMonthView::setKeyBoardFocus()
1627{ 1615{
1628 //qDebug("KOMonthView::setKeyBoardFocus() "); 1616 //qDebug("KOMonthView::setKeyBoardFocus() ");
1629 bool shootAgain = false; 1617 bool shootAgain = false;
1630 if ( mShowWeekView ) { 1618 if ( mShowWeekView ) {
1631 shootAgain = !mWeekLabelsW[1]->hasFocus(); 1619 shootAgain = !mWeekLabelsW[1]->hasFocus();
1632 mWeekLabelsW[1]->setFocus(); 1620 mWeekLabelsW[1]->setFocus();
1633 } 1621 }
1634 else { 1622 else {
1635 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); 1623 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1636 mWeekLabels[mNumWeeks]->setFocus(); 1624 mWeekLabels[mNumWeeks]->setFocus();
1637 } 1625 }
1638 if ( shootAgain ) { 1626 if ( shootAgain ) {
1639 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); 1627 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) );
1640 } 1628 }
1641} 1629}
1642void KOMonthView::setKeyBFocus() 1630void KOMonthView::setKeyBFocus()
1643{ 1631{
1644 //qDebug("KOMonthView::setKeyBFocus() "); 1632 //qDebug("KOMonthView::setKeyBFocus() ");
1645 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1633 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1646} 1634}
1647void KOMonthView::resizeEvent(QResizeEvent * e) 1635void KOMonthView::resizeEvent(QResizeEvent * e)
1648{ 1636{
1649 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1637 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1650 if ( isVisible() ) { 1638 if ( isVisible() ) {
1651 //qDebug("KOMonthView::isVisible "); 1639 //qDebug("KOMonthView::isVisible ");
1652 slotComputeLayout(); 1640 slotComputeLayout();
1653 } else 1641 } else
1654 mComputeLayoutTimer->start( 100 ); 1642 mComputeLayoutTimer->start( 100 );
1655} 1643}
1656 1644
1657void KOMonthView::slotComputeLayout() 1645void KOMonthView::slotComputeLayout()
1658{ 1646{
1659 mComputeLayoutTimer->stop(); 1647 mComputeLayoutTimer->stop();
1660 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); 1648 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1661 computeLayout(); 1649 computeLayout();
1662 clPending = true; 1650 clPending = true;
1663 setKeyBFocus(); 1651 setKeyBFocus();
1664} 1652}
1665void KOMonthView::computeLayoutWeek() 1653void KOMonthView::computeLayoutWeek()
1666{ 1654{
1667 static int lastWid = 0; 1655 static int lastWid = 0;
1668 static int lastHei = 0; 1656 static int lastHei = 0;
1669 int daysToShow; 1657 int daysToShow;
1670 bool combinedSatSun = false; 1658 bool combinedSatSun = false;
1671 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1659 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1672 daysToShow = 6; 1660 daysToShow = 6;
1673 combinedSatSun = true; 1661 combinedSatSun = true;
1674 } 1662 }
1675 int tWid = topLevelWidget()->size().width(); 1663 int tWid = topLevelWidget()->size().width();
1676 int tHei = topLevelWidget()->size().height(); 1664 int tHei = topLevelWidget()->size().height();
1677 1665
1678 int wid = width();//e 1666 int wid = width();//e
1679 int hei = height()-1-mNavigatorBar->height(); 1667 int hei = height()-1-mNavigatorBar->height();
1680 1668
1681 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1669 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1682 return; 1670 return;
1683 1671
1684 if ( lastWid == width() && lastHei == height() ) { 1672 if ( lastWid == width() && lastHei == height() ) {
1685 //qDebug("KOListWeekView::No compute layout needed "); 1673 //qDebug("KOListWeekView::No compute layout needed ");
1686 return; 1674 return;
1687 } 1675 }
1688 lastWid = width(); 1676 lastWid = width();
1689 lastHei = height(); 1677 lastHei = height();
1690 1678
1691 1679
1692 if ( wid < hei ) 1680 if ( wid < hei )
1693 daysToShow = 2; 1681 daysToShow = 2;
1694 else 1682 else
1695 daysToShow = 3; 1683 daysToShow = 3;
1696 mShowSatSunComp = true; 1684 mShowSatSunComp = true;
1697 combinedSatSun = true; 1685 combinedSatSun = true;
1698 1686
1699 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1687 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1700 QFontMetrics fm ( mWeekLabels[0]->font() ); 1688 QFontMetrics fm ( mWeekLabels[0]->font() );
1701 int weeklabelwid = fm.width( "888" ); 1689 int weeklabelwid = fm.width( "888" );
1702 wid -= weeklabelwid; 1690 wid -= weeklabelwid;
1703 1691
1704 int colWid = wid / daysToShow; 1692 int colWid = wid / daysToShow;
1705 int lastCol = wid - ( colWid*6 ); 1693 int lastCol = wid - ( colWid*6 );
1706 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1694 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1707 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1695 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1708 int colModulo = wid % daysToShow; 1696 int colModulo = wid % daysToShow;
1709 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1697 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1710 //qDebug("rowmod %d ", rowModulo); 1698 //qDebug("rowmod %d ", rowModulo);
1711 int i; 1699 int i;
1712 int x,y,w,h; 1700 int x,y,w,h;
1713 x= 0; 1701 x= 0;
1714 y= 0; 1702 y= 0;
1715 w = colWid; 1703 w = colWid;
1716 h = dayLabelHei ; 1704 h = dayLabelHei ;
1717 for ( i = 0; i < 7; i++) { 1705 for ( i = 0; i < 7; i++) {
1718 if ( i && !( i % daysToShow) && i < 6) { 1706 if ( i && !( i % daysToShow) && i < 6) {
1719 y += hei/(5-daysToShow); 1707 y += hei/(5-daysToShow);
1720 x = 0; 1708 x = 0;
1721 w = colWid; 1709 w = colWid;
1722 } 1710 }
1723 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1711 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1724 ++w; 1712 ++w;
1725 } 1713 }
1726 if ( i >= 5 ) { 1714 if ( i >= 5 ) {
1727 int wi = width() - x - weeklabelwid; 1715 int wi = width() - x - weeklabelwid;
1728 if ( i == 5 ) { 1716 if ( i == 5 ) {
1729 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); 1717 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h);
1730 } else { 1718 } else {
1731 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1719 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1732 } 1720 }
1733 x = x - w + wi - (wi/2 ); 1721 x = x - w + wi - (wi/2 );
1734 } 1722 }
1735 else { 1723 else {
1736 int wi = w; 1724 int wi = w;
1737 if ( !(( i+1) % daysToShow)) { 1725 if ( !(( i+1) % daysToShow)) {
1738 wi = width() - x - weeklabelwid; 1726 wi = width() - x - weeklabelwid;
1739 } 1727 }
1740 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1728 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1741 } 1729 }
1742 x += w; 1730 x += w;
1743 } 1731 }
1744 x= 0; 1732 x= 0;
1745 y= dayLabelHei; 1733 y= dayLabelHei;
1746 w = colWid; 1734 w = colWid;
1747 h = cellHei; 1735 h = cellHei;
1748 int max = 0; 1736 int max = 0;
1749 for ( i = 0; i < mCellsW.count(); ++i) { 1737 for ( i = 0; i < mCellsW.count(); ++i) {
1750 if ( i > 6 ) { 1738 if ( i > 6 ) {
1751 mCellsW[i]->hide(); 1739 mCellsW[i]->hide();
1752 continue; 1740 continue;
1753 } 1741 }
1754 1742
1755 w = colWid; 1743 w = colWid;
1756 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1744 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1757 ++w; 1745 ++w;
1758 } 1746 }
1759 if ( i == (daysToShow-1-rowModulo)*7) 1747 if ( i == (daysToShow-1-rowModulo)*7)
1760 ++h; 1748 ++h;
1761 1749
1762 if ( i >= 5 ) { 1750 if ( i >= 5 ) {
1763 if ( i ==5 ) { 1751 if ( i ==5 ) {
1764 max = h/2; 1752 max = h/2;
1765 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1753 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1766 x -= w ;y += h/2; 1754 x -= w ;y += h/2;
1767 } else { 1755 } else {
1768 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1756 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1769 ++w; 1757 ++w;
1770 } 1758 }
1771 max = h-h/2; 1759 max = h-h/2;
1772 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1760 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1773 y -= h/2; 1761 y -= h/2;
1774 } 1762 }
1775 } else { 1763 } else {
1776 max = h; 1764 max = h;
1777 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1765 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1778 } 1766 }
1779 1767
1780 1768
1781 x += w; 1769 x += w;
1782 if ( x + w/2 > wid ) { 1770 if ( x + w/2 > wid ) {
1783 x = 0; 1771 x = 0;
1784 y += h+dayLabelHei ; 1772 y += h+dayLabelHei ;
1785 } 1773 }
1786 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); 1774 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 );
1787 } 1775 }
1788 y= dayLabelHei; 1776 y= dayLabelHei;
1789 h = cellHei ; 1777 h = cellHei ;
1790 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1778 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1791 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1779 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1792 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1780 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1793 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1781 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1794 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1782 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1795 updateDayLabels(); 1783 updateDayLabels();
1796 //bool forceUpdate = !updatePossible; 1784 //bool forceUpdate = !updatePossible;
1797 updatePossible = true; 1785 updatePossible = true;
1798 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1786 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1799 //if ( forceUpdate ) 1787 //if ( forceUpdate )
1800 // updateView(); 1788 // updateView();
1801} 1789}
1802void KOMonthView::computeLayout() 1790void KOMonthView::computeLayout()
1803{ 1791{
1804 1792
1805 1793
1806 static int lastWid = 0; 1794 static int lastWid = 0;
1807 static int lastHei = 0; 1795 static int lastHei = 0;
1808 1796
1809 if ( mShowWeekView ){ 1797 if ( mShowWeekView ){
1810 computeLayoutWeek(); 1798 computeLayoutWeek();
1811 return; 1799 return;
1812 } 1800 }
1813 int daysToShow = 7; 1801 int daysToShow = 7;
1814 bool combinedSatSun = false; 1802 bool combinedSatSun = false;
1815 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1803 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1816 daysToShow = 6; 1804 daysToShow = 6;
1817 combinedSatSun = true; 1805 combinedSatSun = true;
1818 } 1806 }
1819 int tWid = topLevelWidget()->size().width(); 1807 int tWid = topLevelWidget()->size().width();
1820 int tHei = topLevelWidget()->size().height(); 1808 int tHei = topLevelWidget()->size().height();
1821 1809
1822 int wid = width();//e 1810 int wid = width();//e
1823 int hei = height()-1-mNavigatorBar->height(); 1811 int hei = height()-1-mNavigatorBar->height();
1824 1812
1825 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1813 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1826 return; 1814 return;
1827 } 1815 }
1828 if ( lastWid == width() && lastHei == height() ){ 1816 if ( lastWid == width() && lastHei == height() ){
1829 //qDebug("KOMonthview::No compute layout needed "); 1817 //qDebug("KOMonthview::No compute layout needed ");
1830 return; 1818 return;
1831 } 1819 }
1832 1820
1833 lastWid = width(); 1821 lastWid = width();
1834 lastHei = height(); 1822 lastHei = height();
1835 //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 1823 //qDebug("KOMonthView::computeLayout() MMM ------------------- ");
1836 QFontMetrics fm ( mWeekLabels[0]->font() ); 1824 QFontMetrics fm ( mWeekLabels[0]->font() );
1837 int weeklabelwid = fm.width( "888" ); 1825 int weeklabelwid = fm.width( "888" );
1838 wid -= weeklabelwid; 1826 wid -= weeklabelwid;
1839 1827
1840 int colWid = wid / daysToShow; 1828 int colWid = wid / daysToShow;
1841 int lastCol = wid - ( colWid*6 ); 1829 int lastCol = wid - ( colWid*6 );
1842 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1830 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1843 int cellHei = (hei - dayLabelHei) /6; 1831 int cellHei = (hei - dayLabelHei) /6;
1844 int colModulo = wid % daysToShow; 1832 int colModulo = wid % daysToShow;
1845 int rowModulo = (hei- dayLabelHei) % 6; 1833 int rowModulo = (hei- dayLabelHei) % 6;
1846 //qDebug("rowmod %d ", rowModulo); 1834 //qDebug("rowmod %d ", rowModulo);
1847 int i; 1835 int i;
1848 int x,y,w,h; 1836 int x,y,w,h;
1849 x= 0; 1837 x= 0;
1850 y= 0; 1838 y= 0;
1851 w = colWid; 1839 w = colWid;
1852 h = dayLabelHei ; 1840 h = dayLabelHei ;
1853 for ( i = 0; i < 7; i++) { 1841 for ( i = 0; i < 7; i++) {
1854 if ( i == daysToShow-colModulo ) 1842 if ( i == daysToShow-colModulo )
1855 ++w; 1843 ++w;
1856 if ( combinedSatSun ) { 1844 if ( combinedSatSun ) {
1857 if ( i >= daysToShow-1 ) { 1845 if ( i >= daysToShow-1 ) {
1858 1846
1859 if ( i == 6 ) 1847 if ( i == 6 )
1860 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); 1848 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h);
1861 else 1849 else
1862 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1850 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1863 x -= w/2 ; 1851 x -= w/2 ;
1864 } 1852 }
1865 else 1853 else
1866 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1854 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1867 } else 1855 } else
1868 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1856 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1869 x += w; 1857 x += w;
1870 } 1858 }
1871 x= 0; 1859 x= 0;
1872 y= dayLabelHei; 1860 y= dayLabelHei;
1873 w = colWid; 1861 w = colWid;
1874 h = cellHei ; 1862 h = cellHei ;
1875 int max = 0; 1863 int max = 0;
1876 for ( i = 0; i < mCells.count(); ++i) { 1864 for ( i = 0; i < mCells.count(); ++i) {
1877 //qDebug("iii %d ", i); 1865 //qDebug("iii %d ", i);
1878 w = colWid; 1866 w = colWid;
1879 if ( ((i) % 7) >= 7-colModulo ) { 1867 if ( ((i) % 7) >= 7-colModulo ) {
1880 ++w; 1868 ++w;
1881 } 1869 }
1882 if ( i == (6-rowModulo)*7) 1870 if ( i == (6-rowModulo)*7)
1883 ++h; 1871 ++h;
1884 if ( combinedSatSun ) { 1872 if ( combinedSatSun ) {
1885 if ( (i)%7 >= daysToShow-1 ) { 1873 if ( (i)%7 >= daysToShow-1 ) {
1886 if ( (i)%7 == daysToShow-1 ) { 1874 if ( (i)%7 == daysToShow-1 ) {
1887 w = width()-x-weeklabelwid; 1875 w = width()-x-weeklabelwid;
1888 max = h/2; 1876 max = h/2;
1889 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1877 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1890 x -= w ;y += h/2; 1878 x -= w ;y += h/2;
1891 } else { 1879 } else {
1892 w = width()-x-weeklabelwid; 1880 w = width()-x-weeklabelwid;
1893 max = h-h/2; 1881 max = h-h/2;
1894 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1882 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1895 y -= h/2; 1883 y -= h/2;
1896 } 1884 }
1897 } else { 1885 } else {
1898 max = h; 1886 max = h;
1899 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1887 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1900 } 1888 }
1901 1889
1902 } 1890 }
1903 else { 1891 else {
1904 max = h; 1892 max = h;
1905 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1893 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1906 } 1894 }
1907 x += w; 1895 x += w;
1908 if ( x + w/2 > wid ) { 1896 if ( x + w/2 > wid ) {
1909 x = 0; 1897 x = 0;
1910 y += h; 1898 y += h;
1911 } 1899 }
1912 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); 1900 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 );
1913 } 1901 }
1914 y= dayLabelHei; 1902 y= dayLabelHei;
1915 h = cellHei ; 1903 h = cellHei ;
1916 for ( i = 0; i < 6; i++) { 1904 for ( i = 0; i < 6; i++) {
1917 if ( i == (6-rowModulo)) 1905 if ( i == (6-rowModulo))
1918 ++h; 1906 ++h;
1919 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1907 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1920 y += h; 1908 y += h;
1921 } 1909 }
1922 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1910 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1923 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1911 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1924 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1912 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1925 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1913 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1926 updateDayLabels(); 1914 updateDayLabels();
1927 //bool forceUpdate = !updatePossible; 1915 //bool forceUpdate = !updatePossible;
1928 updatePossible = true; 1916 updatePossible = true;
1929 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1917 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1930} 1918}
1931 1919
1932void KOMonthView::showContextMenu( Incidence *incidence ) 1920void KOMonthView::showContextMenu( Incidence *incidence )
1933{ 1921{
1934 if( incidence ) 1922 if( incidence )
1935 mContextMenu->showIncidencePopup(incidence); 1923 mContextMenu->showIncidencePopup(incidence);
1936 else { 1924 else {
1937 //qDebug("KOMonthView::showContextMenu "); 1925 //qDebug("KOMonthView::showContextMenu ");
1938 mNewItemMenu->popup(QCursor::pos()); 1926 mNewItemMenu->popup(QCursor::pos());
1939 } 1927 }
1940 /* 1928 /*
1941 if( incidence && incidence->type() == "Event" ) { 1929 if( incidence && incidence->type() == "Event" ) {
1942 Event *event = static_cast<Event *>(incidence); 1930 Event *event = static_cast<Event *>(incidence);
1943 mContextMenu->showEventPopup(event); 1931 mContextMenu->showEventPopup(event);
1944 } else { 1932 } else {
1945 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1933 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1946 } 1934 }
1947 */ 1935 */
1948} 1936}
1949MonthViewCell * KOMonthView::selectedCell( ) 1937MonthViewCell * KOMonthView::selectedCell( )
1950{ 1938{
1951 return mSelectedCell; 1939 return mSelectedCell;
1952} 1940}
1953void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1941void KOMonthView::setSelectedCell( MonthViewCell *cell )
1954{ 1942{
1955 //qDebug("KOMonthView::setSelectedCell %d", cell); 1943 //qDebug("KOMonthView::setSelectedCell %d", cell);
1956 if ( mSelectedCell && mSelectedCell != cell ) { 1944 if ( mSelectedCell && mSelectedCell != cell ) {
1957 MonthViewCell * mvc = mSelectedCell; 1945 MonthViewCell * mvc = mSelectedCell;
1958 mSelectedCell = cell; 1946 mSelectedCell = cell;
1959 mvc->deselect(); 1947 mvc->deselect();
1960 } else 1948 } else
1961 mSelectedCell = cell; 1949 mSelectedCell = cell;
1962 // if ( mSelectedCell ) 1950 // if ( mSelectedCell )
1963 // mSelectedCell->select(); 1951 // mSelectedCell->select();
1964 if ( !mSelectedCell ) 1952 if ( !mSelectedCell )
1965 emit incidenceSelected( 0 ); 1953 emit incidenceSelected( 0 );
1966 else 1954 else
1967 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1955 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1968} 1956}
1969 1957
1970void KOMonthView::processSelectionChange() 1958void KOMonthView::processSelectionChange()
1971{ 1959{
1972 QPtrList<Incidence> incidences = selectedIncidences(); 1960 QPtrList<Incidence> incidences = selectedIncidences();
1973 if (incidences.count() > 0) { 1961 if (incidences.count() > 0) {
1974 emit incidenceSelected( incidences.first() ); 1962 emit incidenceSelected( incidences.first() );
1975 } else { 1963 } else {
1976 emit incidenceSelected( 0 ); 1964 emit incidenceSelected( 0 );
1977 clearSelection(); 1965 clearSelection();
1978 } 1966 }
1979} 1967}
1980 1968
1981void KOMonthView::clearSelection() 1969void KOMonthView::clearSelection()
1982{ 1970{
1983 if ( mSelectedCell ) { 1971 if ( mSelectedCell ) {
1984 mSelectedCell->deselect(); 1972 mSelectedCell->deselect();
1985 mSelectedCell = 0; 1973 mSelectedCell = 0;
1986 } 1974 }
1987} 1975}
1988 1976
1989void KOMonthView::keyReleaseEvent ( QKeyEvent * e) 1977void KOMonthView::keyReleaseEvent ( QKeyEvent * e)
1990{ 1978{
1991 if ( !e->isAutoRepeat() ) { 1979 if ( !e->isAutoRepeat() ) {
1992 mFlagKeyPressed = false; 1980 mFlagKeyPressed = false;
1993 } 1981 }
1994} 1982}
1995 1983
1996void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1984void KOMonthView::keyPressEvent ( QKeyEvent * e )
1997{ 1985{
1998 1986
1999 qApp->processEvents(); 1987 qApp->processEvents();
2000 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1988 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2001 //e->ignore(); 1989 //e->ignore();
2002 e->accept(); 1990 e->accept();
2003 return; 1991 return;
2004 } 1992 }
2005 if (! e->isAutoRepeat() ) 1993 if (! e->isAutoRepeat() )
2006 mFlagKeyPressed = true; 1994 mFlagKeyPressed = true;
2007 switch(e->key()) { 1995 switch(e->key()) {
2008 case Key_Up: 1996 case Key_Up:
2009 { 1997 {
2010 if ( mShowWeekView ) { 1998 if ( mShowWeekView ) {
2011 emit selectWeekNum ( currentWeek() - 1 ); 1999 emit selectWeekNum ( currentWeek() - 1 );
2012 } 2000 }
2013 else { 2001 else {
2014 emit prevMonth(); 2002 emit prevMonth();
2015 } 2003 }
2016 } 2004 }
2017 e->accept(); 2005 e->accept();
2018 break; 2006 break;
2019 case Key_Down: 2007 case Key_Down:
2020 { 2008 {
2021 if ( mShowWeekView ) { 2009 if ( mShowWeekView ) {
2022 emit selectWeekNum ( currentWeek() +1); 2010 emit selectWeekNum ( currentWeek() +1);
2023 } 2011 }
2024 else { 2012 else {
2025 emit nextMonth(); 2013 emit nextMonth();
2026 } 2014 }
2027 2015
2028 } 2016 }
2029 e->accept(); 2017 e->accept();
2030 break; 2018 break;
2031 case Key_Return: 2019 case Key_Return:
2032 case Key_Enter: 2020 case Key_Enter:
2033 { 2021 {
2034 selectInternalWeekNum ( currentWeek() ); 2022 selectInternalWeekNum ( currentWeek() );
2035 } 2023 }
2036 e->accept(); 2024 e->accept();
2037 break; 2025 break;
2038 case Key_D: 2026 case Key_D:
2039 if ( mSelectedCell ) { 2027 if ( mSelectedCell ) {
2040 mSelectedCell->showDay(); 2028 mSelectedCell->showDay();
2041 e->accept(); 2029 e->accept();
2042 } else { 2030 } else {
2043 e->ignore(); 2031 e->ignore();
2044 } 2032 }
2045 break; 2033 break;
2046 default: 2034 default:
2047 e->ignore(); 2035 e->ignore();
2048 break; 2036 break;
2049 } 2037 }
2050} 2038}
2051 2039
2052void KOMonthView::nextCell() 2040void KOMonthView::nextCell()
2053{ 2041{
2054 bool res = focusNextPrevChild ( true ); 2042 bool res = focusNextPrevChild ( true );
2055} 2043}
2056void KOMonthView::prevCell() 2044void KOMonthView::prevCell()
2057{ 2045{
2058 focusNextPrevChild ( false ); 2046 focusNextPrevChild ( false );
2059} 2047}
2060 2048
2061void KOMonthView::slotNewTodo() 2049void KOMonthView::slotNewTodo()
2062{ 2050{
2063 //qDebug("KOMonthView::slotNewTodo() "); 2051 //qDebug("KOMonthView::slotNewTodo() ");
2064 if ( mPopupCell ){ 2052 if ( mPopupCell ){
2065 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 2053 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
2066 emit newTodoSignal(dt,true); 2054 emit newTodoSignal(dt,true);
2067 } 2055 }
2068 mPopupCell = 0; 2056 mPopupCell = 0;
2069} 2057}
2070void KOMonthView::slotNewEvent() 2058void KOMonthView::slotNewEvent()
2071{ 2059{
2072 if ( mPopupCell ) { 2060 if ( mPopupCell ) {
2073 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 2061 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
2074 emit newEventSignal( dt ); 2062 emit newEventSignal( dt );
2075 } 2063 }
2076 //qDebug("KOMonthView::slotNewEvent() "); 2064 //qDebug("KOMonthView::slotNewEvent() ");
2077 mPopupCell = 0; 2065 mPopupCell = 0;
2078} 2066}
2079 2067
2080void KOMonthView::slotEditJournal() 2068void KOMonthView::slotEditJournal()
2081{ 2069{
2082 if ( mPopupCell ) 2070 if ( mPopupCell )
2083 emit showJournalSignal( 7, mPopupCell->date() ); 2071 emit showJournalSignal( 7, mPopupCell->date() );
2084 //qDebug("KOMonthView::slotEditJournal() "); 2072 //qDebug("KOMonthView::slotEditJournal() ");
2085 mPopupCell = 0; 2073 mPopupCell = 0;
2086} 2074}
2087 2075
2088void KOMonthView::setPopupCell( MonthViewCell * c) 2076void KOMonthView::setPopupCell( MonthViewCell * c)
2089{ 2077{
2090 mPopupCell = c; 2078 mPopupCell = c;
2091} 2079}
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro
index 1a81c7d..d88c300 100644
--- a/korganizer/korganizer.pro
+++ b/korganizer/korganizer.pro
@@ -1,210 +1,208 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3 TARGET = kopi 3 TARGET = kopi
4OBJECTS_DIR = _obj/ 4OBJECTS_DIR = _obj/
5MOC_DIR = _moc 5MOC_DIR = _moc
6DESTDIR= ../bin 6DESTDIR= ../bin
7 7
8include( ../variables.pri ) 8include( ../variables.pri )
9 9
10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim 10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim
11#../qtcompat 11#../qtcompat
12DEFINES += KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL 12DEFINES += KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER 13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
14#KORG_NOPRINTER KORG_NOKABC KORG_NODND 14#KORG_NOPRINTER KORG_NOKABC KORG_NODND
15DEFINES += KORG_NOLVALTERNATION 15DEFINES += KORG_NOLVALTERNATION
16DEFINES += DESKTOP_VERSION 16DEFINES += DESKTOP_VERSION
17unix : { 17unix : {
18staticlib: { 18staticlib: {
19LIBS += ../bin/libmicrokabc_qtopia.a 19LIBS += ../bin/libmicrokabc_qtopia.a
20LIBS += ../bin/libmicrokabc_file.a 20LIBS += ../bin/libmicrokabc_file.a
21LIBS += ../bin/libmicrokabc_dir.a 21LIBS += ../bin/libmicrokabc_dir.a
22LIBS += ../bin/libmicrokdepim.a 22LIBS += ../bin/libmicrokdepim.a
23LIBS += ../bin/libmicrokcal.a 23LIBS += ../bin/libmicrokcal.a
24LIBS += ../bin/libmicrokabc.a 24LIBS += ../bin/libmicrokabc.a
25LIBS += ../bin/libmicrokde.a 25LIBS += ../bin/libmicrokde.a
26LIBS += ../bin/libmicrokabc_qtopia.a 26LIBS += ../bin/libmicrokabc_qtopia.a
27LIBS += ../bin/libmicrokabc_file.a 27LIBS += ../bin/libmicrokabc_file.a
28LIBS += ../bin/libmicrokabc_dir.a 28LIBS += ../bin/libmicrokabc_dir.a
29LIBS += ../bin/libmicrokdepim.a 29LIBS += ../bin/libmicrokdepim.a
30LIBS += ../bin/libmicrokcal.a 30LIBS += ../bin/libmicrokcal.a
31LIBS += ../bin/libmicrokabc.a 31LIBS += ../bin/libmicrokabc.a
32LIBS += ../bin/libmicrokde.a 32LIBS += ../bin/libmicrokde.a
33LIBS += ../libical/lib/libical.a 33LIBS += ../libical/lib/libical.a
34LIBS += ../libical/lib/libicalss.a 34LIBS += ../libical/lib/libicalss.a
35} else { 35} else {
36LIBS += ../bin/libmicrokdepim.so 36LIBS += ../bin/libmicrokdepim.so
37LIBS += ../bin/libmicrokcal.so 37LIBS += ../bin/libmicrokcal.so
38LIBS += ../bin/libmicrokde.so 38LIBS += ../bin/libmicrokde.so
39LIBS += ../bin/libmicrokabc.so 39LIBS += ../bin/libmicrokabc.so
40#LIBS += -lbluetooth 40#LIBS += -lbluetooth
41#LIBS += -lsdp 41#LIBS += -lsdp
42 42
43#LIBS += -lldap 43#LIBS += -lldap
44} 44}
45OBJECTS_DIR = obj/unix 45OBJECTS_DIR = obj/unix
46MOC_DIR = moc/unix 46MOC_DIR = moc/unix
47} 47}
48win32: { 48win32: {
49RC_FILE = winicons.rc 49RC_FILE = winicons.rc
50DEFINES += _WIN32_ 50DEFINES += _WIN32_
51LIBS += ../bin/microkdepim.lib 51LIBS += ../bin/microkdepim.lib
52LIBS += ../bin/microkcal.lib 52LIBS += ../bin/microkcal.lib
53LIBS += ../bin/microkde.lib 53LIBS += ../bin/microkde.lib
54LIBS += ../bin/microkabc.lib 54LIBS += ../bin/microkabc.lib
55LIBS += ../libical/lib/ical.lib 55LIBS += ../libical/lib/ical.lib
56LIBS += ../libical/lib/icalss.lib 56LIBS += ../libical/lib/icalss.lib
57#LIBS += atls.lib 57#LIBS += atls.lib
58QMAKE_LINK += /NODEFAULTLIB:LIBC 58QMAKE_LINK += /NODEFAULTLIB:LIBC
59#QMAKE_LINK += /NODEFAULTLIB:MSVCRT 59#QMAKE_LINK += /NODEFAULTLIB:MSVCRT
60#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib 60#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib
61OBJECTS_DIR = obj/win 61OBJECTS_DIR = obj/win
62MOC_DIR = moc/win 62MOC_DIR = moc/win
63#olimport section 63#olimport section
64#blabla: { 64#blabla: {
65LIBS += mfc71u.lib 65LIBS += mfc71u.lib
66DEFINES += _OL_IMPORT_ 66DEFINES += _OL_IMPORT_
67 67
68HEADERS += ../outport/msoutl9.h \ 68HEADERS += ../outport/msoutl9.h \
69 koimportoldialog.h 69 koimportoldialog.h
70SOURCES += ../outport/msoutl9.cpp \ 70SOURCES += ../outport/msoutl9.cpp \
71 koimportoldialog.cpp 71 koimportoldialog.cpp
72#} 72#}
73#olimport section end 73#olimport section end
74 74
75} 75}
76 76
77 77
78INTERFACES = kofilterview_base.ui 78INTERFACES = kofilterview_base.ui
79#filteredit_base.ui 79#filteredit_base.ui
80 80
81# kdateedit.h \ 81# kdateedit.h \
82 82
83HEADERS += datenavigatorcontainer.h \ 83HEADERS += datenavigatorcontainer.h \
84 filteredit_base.h \ 84 filteredit_base.h \
85 alarmclient.h \ 85 alarmclient.h \
86 calendarview.h \ 86 calendarview.h \
87 customlistviewitem.h \ 87 customlistviewitem.h \
88 datenavigator.h \ 88 datenavigator.h \
89 docprefs.h \ 89 docprefs.h \
90 filtereditdialog.h \ 90 filtereditdialog.h \
91 incomingdialog.h \ 91 incomingdialog.h \
92 incomingdialog_base.h \ 92 incomingdialog_base.h \
93 interfaces/korganizer/baseview.h \ 93 interfaces/korganizer/baseview.h \
94 interfaces/korganizer/calendarviewbase.h \ 94 interfaces/korganizer/calendarviewbase.h \
95 journalentry.h \ 95 journalentry.h \
96 kdatenavigator.h \ 96 kdatenavigator.h \
97 koagenda.h \ 97 koagenda.h \
98 koagendaitem.h \ 98 koagendaitem.h \
99 koagendaview.h \ 99 koagendaview.h \
100 kocounterdialog.h \ 100 kocounterdialog.h \
101 kodaymatrix.h \ 101 kodaymatrix.h \
102 kodialogmanager.h \ 102 kodialogmanager.h \
103 koeditordetails.h \ 103 koeditordetails.h \
104 koeditorgeneral.h \ 104 koeditorgeneral.h \
105 koeditorgeneralevent.h \ 105 koeditorgeneralevent.h \
106 koeditorgeneraltodo.h \ 106 koeditorgeneraltodo.h \
107 koeditorrecurrence.h \ 107 koeditorrecurrence.h \
108 koeventeditor.h \ 108 koeventeditor.h \
109 koeventpopupmenu.h \ 109 koeventpopupmenu.h \
110 koeventview.h \ 110 koeventview.h \
111 koeventviewer.h \ 111 koeventviewer.h \
112 koeventviewerdialog.h \ 112 koeventviewerdialog.h \
113 kofilterview.h \ 113 kofilterview.h \
114 koglobals.h \ 114 koglobals.h \
115 koincidenceeditor.h \ 115 koincidenceeditor.h \
116 kojournalview.h \ 116 kojournalview.h \
117 kolistview.h \ 117 kolistview.h \
118 kolocationbox.h \ 118 kolocationbox.h \
119 komonthview.h \ 119 komonthview.h \
120 koprefs.h \ 120 koprefs.h \
121 koprefsdialog.h \ 121 koprefsdialog.h \
122 kotimespanview.h \ 122 kotimespanview.h \
123 kotodoeditor.h \ 123 kotodoeditor.h \
124 kotodoview.h \ 124 kotodoview.h \
125 kotodoviewitem.h \ 125 kotodoviewitem.h \
126 koviewmanager.h \ 126 koviewmanager.h \
127 kowhatsnextview.h \ 127 kowhatsnextview.h \
128 ktimeedit.h \ 128 ktimeedit.h \
129 lineview.h \ 129 lineview.h \
130 mainwindow.h \ 130 mainwindow.h \
131 navigatorbar.h \ 131 navigatorbar.h \
132 outgoingdialog.h \ 132 outgoingdialog.h \
133 outgoingdialog_base.h \ 133 outgoingdialog_base.h \
134 publishdialog.h \ 134 publishdialog.h \
135 publishdialog_base.h \ 135 publishdialog_base.h \
136 savetemplatedialog.h \ 136 savetemplatedialog.h \
137 searchdialog.h \ 137 searchdialog.h \
138 simplealarmclient.h \
139 statusdialog.h \ 138 statusdialog.h \
140 timeline.h \ 139 timeline.h \
141 timespanview.h \ 140 timespanview.h \
142 version.h \ 141 version.h \
143 ../kalarmd/alarmdialog.h \ 142 ../kalarmd/alarmdialog.h \
144 143
145 144
146SOURCES += datenavigatorcontainer.cpp \ 145SOURCES += datenavigatorcontainer.cpp \
147filteredit_base.cpp \ 146filteredit_base.cpp \
148 calendarview.cpp \ 147 calendarview.cpp \
149 datenavigator.cpp \ 148 datenavigator.cpp \
150 docprefs.cpp \ 149 docprefs.cpp \
151 filtereditdialog.cpp \ 150 filtereditdialog.cpp \
152 incomingdialog.cpp \ 151 incomingdialog.cpp \
153 incomingdialog_base.cpp \ 152 incomingdialog_base.cpp \
154 journalentry.cpp \ 153 journalentry.cpp \
155 kdatenavigator.cpp \ 154 kdatenavigator.cpp \
156 koagenda.cpp \ 155 koagenda.cpp \
157 koagendaitem.cpp \ 156 koagendaitem.cpp \
158 koagendaview.cpp \ 157 koagendaview.cpp \
159 kocounterdialog.cpp \ 158 kocounterdialog.cpp \
160 kodaymatrix.cpp \ 159 kodaymatrix.cpp \
161 kodialogmanager.cpp \ 160 kodialogmanager.cpp \
162 koeditordetails.cpp \ 161 koeditordetails.cpp \
163 koeditorgeneral.cpp \ 162 koeditorgeneral.cpp \
164 koeditorgeneralevent.cpp \ 163 koeditorgeneralevent.cpp \
165 koeditorgeneraltodo.cpp \ 164 koeditorgeneraltodo.cpp \
166 koeditorrecurrence.cpp \ 165 koeditorrecurrence.cpp \
167 koeventeditor.cpp \ 166 koeventeditor.cpp \
168 koeventpopupmenu.cpp \ 167 koeventpopupmenu.cpp \
169 koeventview.cpp \ 168 koeventview.cpp \
170 koeventviewer.cpp \ 169 koeventviewer.cpp \
171 koeventviewerdialog.cpp \ 170 koeventviewerdialog.cpp \
172 kofilterview.cpp \ 171 kofilterview.cpp \
173 koglobals.cpp \ 172 koglobals.cpp \
174 koincidenceeditor.cpp \ 173 koincidenceeditor.cpp \
175 kojournalview.cpp \ 174 kojournalview.cpp \
176 kolistview.cpp \ 175 kolistview.cpp \
177 kolocationbox.cpp \ 176 kolocationbox.cpp \
178 komonthview.cpp \ 177 komonthview.cpp \
179 koprefs.cpp \ 178 koprefs.cpp \
180 koprefsdialog.cpp \ 179 koprefsdialog.cpp \
181 kotimespanview.cpp \ 180 kotimespanview.cpp \
182 kotodoeditor.cpp \ 181 kotodoeditor.cpp \
183 kotodoview.cpp \ 182 kotodoview.cpp \
184 kotodoviewitem.cpp \ 183 kotodoviewitem.cpp \
185 koviewmanager.cpp \ 184 koviewmanager.cpp \
186 kowhatsnextview.cpp \ 185 kowhatsnextview.cpp \
187 ktimeedit.cpp \ 186 ktimeedit.cpp \
188 lineview.cpp \ 187 lineview.cpp \
189 main.cpp \ 188 main.cpp \
190 mainwindow.cpp \ 189 mainwindow.cpp \
191 navigatorbar.cpp \ 190 navigatorbar.cpp \
192 outgoingdialog.cpp \ 191 outgoingdialog.cpp \
193 outgoingdialog_base.cpp \ 192 outgoingdialog_base.cpp \
194 publishdialog.cpp \ 193 publishdialog.cpp \
195 publishdialog_base.cpp \ 194 publishdialog_base.cpp \
196 savetemplatedialog.cpp \ 195 savetemplatedialog.cpp \
197 searchdialog.cpp \ 196 searchdialog.cpp \
198 simplealarmclient.cpp \
199 statusdialog.cpp \ 197 statusdialog.cpp \
200 timeline.cpp \ 198 timeline.cpp \
201 timespanview.cpp \ 199 timespanview.cpp \
202 ../kalarmd/alarmdialog.cpp 200 ../kalarmd/alarmdialog.cpp
203 201
204HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h 202HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h
205INTERFACES += calprintdayconfig_base.ui \ 203INTERFACES += calprintdayconfig_base.ui \
206 calprintmonthconfig_base.ui \ 204 calprintmonthconfig_base.ui \
207 calprinttodoconfig_base.ui \ 205 calprinttodoconfig_base.ui \
208 calprintweekconfig_base.ui 206 calprintweekconfig_base.ui
209SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp 207SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp
210 208
diff --git a/korganizer/korganizerE.pro b/korganizer/korganizerE.pro
index 91b5a01..553c265 100644
--- a/korganizer/korganizerE.pro
+++ b/korganizer/korganizerE.pro
@@ -1,152 +1,150 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 TARGET = kopi 3 TARGET = kopi
4OBJECTS_DIR = obj/$(PLATFORM) 4OBJECTS_DIR = obj/$(PLATFORM)
5MOC_DIR = moc/$(PLATFORM) 5MOC_DIR = moc/$(PLATFORM)
6DESTDIR=$(QPEDIR)/bin 6DESTDIR=$(QPEDIR)/bin
7 7
8INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/libkdepim interfaces $(KDEPIMDIR)/kabc $(QPEDIR)/include 8INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/libkdepim interfaces $(KDEPIMDIR)/kabc $(QPEDIR)/include
9 9
10DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL 10DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
11DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER 11DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
12DEFINES += KORG_NOLVALTERNATION 12DEFINES += KORG_NOLVALTERNATION
13#KORG_NOKABC 13#KORG_NOKABC
14LIBS += -lmicrokdepim 14LIBS += -lmicrokdepim
15LIBS += -lmicrokcal 15LIBS += -lmicrokcal
16LIBS += -lmicrokde 16LIBS += -lmicrokde
17LIBS += -lmicroqtcompat 17LIBS += -lmicroqtcompat
18 18
19LIBS += $(GCC3EXTRALIB1) 19LIBS += $(GCC3EXTRALIB1)
20LIBS += $(GCC3EXTRALIB2) 20LIBS += $(GCC3EXTRALIB2)
21 21
22 22
23LIBS += -lqpe 23LIBS += -lqpe
24LIBS += -ljpeg 24LIBS += -ljpeg
25LIBS += $(QTOPIALIB) 25LIBS += $(QTOPIALIB)
26LIBS += -L$(QPEDIR)/lib 26LIBS += -L$(QPEDIR)/lib
27 27
28INTERFACES = kofilterview_base.ui 28INTERFACES = kofilterview_base.ui
29#filteredit_base.ui 29#filteredit_base.ui
30 30
31HEADERS = datenavigatorcontainer.h \ 31HEADERS = datenavigatorcontainer.h \
32 wordsgerman.h \ 32 wordsgerman.h \
33 filteredit_base.h \ 33 filteredit_base.h \
34 alarmclient.h \ 34 alarmclient.h \
35 calendarview.h \ 35 calendarview.h \
36 customlistviewitem.h \ 36 customlistviewitem.h \
37 datenavigator.h \ 37 datenavigator.h \
38 docprefs.h \ 38 docprefs.h \
39 filtereditdialog.h \ 39 filtereditdialog.h \
40 incomingdialog.h \ 40 incomingdialog.h \
41 incomingdialog_base.h \ 41 incomingdialog_base.h \
42 interfaces/korganizer/baseview.h \ 42 interfaces/korganizer/baseview.h \
43 interfaces/korganizer/calendarviewbase.h \ 43 interfaces/korganizer/calendarviewbase.h \
44 journalentry.h \ 44 journalentry.h \
45 kdateedit.h \ 45 kdateedit.h \
46 kdatenavigator.h \ 46 kdatenavigator.h \
47 koagenda.h \ 47 koagenda.h \
48 koagendaitem.h \ 48 koagendaitem.h \
49 koagendaview.h \ 49 koagendaview.h \
50 kocounterdialog.h \ 50 kocounterdialog.h \
51 kodaymatrix.h \ 51 kodaymatrix.h \
52 kodialogmanager.h \ 52 kodialogmanager.h \
53 koeditordetails.h \ 53 koeditordetails.h \
54 koeditorgeneral.h \ 54 koeditorgeneral.h \
55 koeditorgeneralevent.h \ 55 koeditorgeneralevent.h \
56 koeditorgeneraltodo.h \ 56 koeditorgeneraltodo.h \
57 koeditorrecurrence.h \ 57 koeditorrecurrence.h \
58 koeventeditor.h \ 58 koeventeditor.h \
59 koeventpopupmenu.h \ 59 koeventpopupmenu.h \
60 koeventview.h \ 60 koeventview.h \
61 koeventviewer.h \ 61 koeventviewer.h \
62 koeventviewerdialog.h \ 62 koeventviewerdialog.h \
63 kofilterview.h \ 63 kofilterview.h \
64 koglobals.h \ 64 koglobals.h \
65 koincidenceeditor.h \ 65 koincidenceeditor.h \
66 kojournalview.h \ 66 kojournalview.h \
67 kolistview.h \ 67 kolistview.h \
68 kolocationbox.h \ 68 kolocationbox.h \
69 komonthview.h \ 69 komonthview.h \
70 koprefs.h \ 70 koprefs.h \
71 koprefsdialog.h \ 71 koprefsdialog.h \
72 kotimespanview.h \ 72 kotimespanview.h \
73 kotodoeditor.h \ 73 kotodoeditor.h \
74 kotodoview.h \ 74 kotodoview.h \
75 kotodoviewitem.h \ 75 kotodoviewitem.h \
76 koviewmanager.h \ 76 koviewmanager.h \
77 kowhatsnextview.h \ 77 kowhatsnextview.h \
78 ktimeedit.h \ 78 ktimeedit.h \
79 lineview.h \ 79 lineview.h \
80 mainwindow.h \ 80 mainwindow.h \
81 navigatorbar.h \ 81 navigatorbar.h \
82 outgoingdialog.h \ 82 outgoingdialog.h \
83 outgoingdialog_base.h \ 83 outgoingdialog_base.h \
84 publishdialog.h \ 84 publishdialog.h \
85 publishdialog_base.h \ 85 publishdialog_base.h \
86 savetemplatedialog.h \ 86 savetemplatedialog.h \
87 searchdialog.h \ 87 searchdialog.h \
88 simplealarmclient.h \
89 statusdialog.h \ 88 statusdialog.h \
90 timeline.h \ 89 timeline.h \
91 timespanview.h \ 90 timespanview.h \
92 version.h \ 91 version.h \
93 ../kalarmd/alarmdialog.h 92 ../kalarmd/alarmdialog.h
94 93
95SOURCES = datenavigatorcontainer.cpp \ 94SOURCES = datenavigatorcontainer.cpp \
96 filteredit_base.cpp \ 95 filteredit_base.cpp \
97 calendarview.cpp \ 96 calendarview.cpp \
98 datenavigator.cpp \ 97 datenavigator.cpp \
99 docprefs.cpp \ 98 docprefs.cpp \
100 filtereditdialog.cpp \ 99 filtereditdialog.cpp \
101 incomingdialog.cpp \ 100 incomingdialog.cpp \
102 incomingdialog_base.cpp \ 101 incomingdialog_base.cpp \
103 journalentry.cpp \ 102 journalentry.cpp \
104 kdatenavigator.cpp \ 103 kdatenavigator.cpp \
105 koagenda.cpp \ 104 koagenda.cpp \
106 koagendaitem.cpp \ 105 koagendaitem.cpp \
107 koagendaview.cpp \ 106 koagendaview.cpp \
108 kocounterdialog.cpp \ 107 kocounterdialog.cpp \
109 kodaymatrix.cpp \ 108 kodaymatrix.cpp \
110 kodialogmanager.cpp \ 109 kodialogmanager.cpp \
111 koeditordetails.cpp \ 110 koeditordetails.cpp \
112 koeditorgeneral.cpp \ 111 koeditorgeneral.cpp \
113 koeditorgeneralevent.cpp \ 112 koeditorgeneralevent.cpp \
114 koeditorgeneraltodo.cpp \ 113 koeditorgeneraltodo.cpp \
115 koeditorrecurrence.cpp \ 114 koeditorrecurrence.cpp \
116 koeventeditor.cpp \ 115 koeventeditor.cpp \
117 koeventpopupmenu.cpp \ 116 koeventpopupmenu.cpp \
118 koeventview.cpp \ 117 koeventview.cpp \
119 koeventviewer.cpp \ 118 koeventviewer.cpp \
120 koeventviewerdialog.cpp \ 119 koeventviewerdialog.cpp \
121 kofilterview.cpp \ 120 kofilterview.cpp \
122 koglobals.cpp \ 121 koglobals.cpp \
123 koincidenceeditor.cpp \ 122 koincidenceeditor.cpp \
124 kojournalview.cpp \ 123 kojournalview.cpp \
125 kolistview.cpp \ 124 kolistview.cpp \
126 kolocationbox.cpp \ 125 kolocationbox.cpp \
127 komonthview.cpp \ 126 komonthview.cpp \
128 koprefs.cpp \ 127 koprefs.cpp \
129 koprefsdialog.cpp \ 128 koprefsdialog.cpp \
130 kotimespanview.cpp \ 129 kotimespanview.cpp \
131 kotodoeditor.cpp \ 130 kotodoeditor.cpp \
132 kotodoview.cpp \ 131 kotodoview.cpp \
133 kotodoviewitem.cpp \ 132 kotodoviewitem.cpp \
134 koviewmanager.cpp \ 133 koviewmanager.cpp \
135 kowhatsnextview.cpp \ 134 kowhatsnextview.cpp \
136 ktimeedit.cpp \ 135 ktimeedit.cpp \
137 lineview.cpp \ 136 lineview.cpp \
138 main.cpp \ 137 main.cpp \
139 mainwindow.cpp \ 138 mainwindow.cpp \
140 navigatorbar.cpp \ 139 navigatorbar.cpp \
141 outgoingdialog.cpp \ 140 outgoingdialog.cpp \
142 outgoingdialog_base.cpp \ 141 outgoingdialog_base.cpp \
143 publishdialog.cpp \ 142 publishdialog.cpp \
144 publishdialog_base.cpp \ 143 publishdialog_base.cpp \
145 savetemplatedialog.cpp \ 144 savetemplatedialog.cpp \
146 searchdialog.cpp \ 145 searchdialog.cpp \
147 simplealarmclient.cpp \
148 statusdialog.cpp \ 146 statusdialog.cpp \
149 timeline.cpp \ 147 timeline.cpp \
150 timespanview.cpp \ 148 timespanview.cpp \
151 ../kalarmd/alarmdialog.cpp 149 ../kalarmd/alarmdialog.cpp
152 150
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index dd2c081..0a608dc 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1467 +1,1442 @@
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 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 <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28 28
29#include <qvbox.h> 29#include <qvbox.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include "koprefs.h" 31#include "koprefs.h"
32#include <klocale.h> 32#include <klocale.h>
33#include <kglobal.h> 33#include <kglobal.h>
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkcal/icaldrag.h> 37#include <libkcal/icaldrag.h>
38#include <libkcal/vcaldrag.h> 38#include <libkcal/vcaldrag.h>
39#include <libkcal/calfilter.h> 39#include <libkcal/calfilter.h>
40#include <libkcal/dndfactory.h> 40#include <libkcal/dndfactory.h>
41#include <libkcal/calendarresources.h> 41#include <libkcal/calendarresources.h>
42#include <libkcal/resourcecalendar.h> 42#include <libkcal/resourcecalendar.h>
43#include <kresources/resourceselectdialog.h> 43#include <kresources/resourceselectdialog.h>
44#include <libkcal/kincidenceformatter.h> 44#include <libkcal/kincidenceformatter.h>
45#ifndef DESKTOP_VERSION 45#ifndef DESKTOP_VERSION
46#include <qpe/qpeapplication.h> 46#include <qpe/qpeapplication.h>
47#else 47#else
48#include <qapplication.h> 48#include <qapplication.h>
49#endif 49#endif
50#ifndef KORG_NOPRINTER 50#ifndef KORG_NOPRINTER
51#include "calprinter.h" 51#include "calprinter.h"
52#endif 52#endif
53#include "docprefs.h" 53#include "docprefs.h"
54 54
55#include "kotodoview.h" 55#include "kotodoview.h"
56using namespace KOrg; 56using namespace KOrg;
57 57
58 58
59class KOTodoViewWhatsThis :public QWhatsThis 59class KOTodoViewWhatsThis :public QWhatsThis
60{ 60{
61public: 61public:
62 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 62 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
63 63
64protected: 64protected:
65 virtual QString text( const QPoint& p) 65 virtual QString text( const QPoint& p)
66 { 66 {
67 return _view->getWhatsThisText(p) ; 67 return _view->getWhatsThisText(p) ;
68 } 68 }
69private: 69private:
70 QWidget* _wid; 70 QWidget* _wid;
71 KOTodoView * _view; 71 KOTodoView * _view;
72}; 72};
73 73
74KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 74KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
75 const char *name) : 75 const char *name) :
76 KListView(parent,name) 76 KListView(parent,name)
77{ 77{
78 mName = QString ( name ); 78 mName = QString ( name );
79 mCalendar = calendar; 79 mCalendar = calendar;
80#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
81 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 81 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
82#endif 82#endif
83 mOldCurrent = 0; 83 mOldCurrent = 0;
84 mMousePressed = false; 84 mMousePressed = false;
85 85
86 setAcceptDrops(true); 86 setAcceptDrops(true);
87 viewport()->setAcceptDrops(true); 87 viewport()->setAcceptDrops(true);
88 int size = 16; 88 int size = 16;
89 if (qApp->desktop()->width() < 300 ) 89 if (qApp->desktop()->width() < 300 )
90 size = 12; 90 size = 12;
91 setTreeStepSize( size + 6 ); 91 setTreeStepSize( size + 6 );
92 92
93} 93}
94 94
95void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 95void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
96{ 96{
97#ifndef KORG_NODND 97#ifndef KORG_NODND
98// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 98// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
99 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 99 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
100 !QTextDrag::canDecode( e ) ) { 100 !QTextDrag::canDecode( e ) ) {
101 e->ignore(); 101 e->ignore();
102 return; 102 return;
103 } 103 }
104 104
105 mOldCurrent = currentItem(); 105 mOldCurrent = currentItem();
106#endif 106#endif
107} 107}
108 108
109 109
110void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 110void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
111{ 111{
112#ifndef KORG_NODND 112#ifndef KORG_NODND
113// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 113// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
114 114
115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
116 !QTextDrag::canDecode( e ) ) { 116 !QTextDrag::canDecode( e ) ) {
117 e->ignore(); 117 e->ignore();
118 return; 118 return;
119 } 119 }
120 120
121 e->accept(); 121 e->accept();
122#endif 122#endif
123} 123}
124 124
125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
126{ 126{
127#ifndef KORG_NODND 127#ifndef KORG_NODND
128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
129 129
130 setCurrentItem(mOldCurrent); 130 setCurrentItem(mOldCurrent);
131 setSelected(mOldCurrent,true); 131 setSelected(mOldCurrent,true);
132#endif 132#endif
133} 133}
134 134
135void KOTodoListView::contentsDropEvent(QDropEvent *e) 135void KOTodoListView::contentsDropEvent(QDropEvent *e)
136{ 136{
137#ifndef KORG_NODND 137#ifndef KORG_NODND
138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
139 139
140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
141 !QTextDrag::canDecode( e ) ) { 141 !QTextDrag::canDecode( e ) ) {
142 e->ignore(); 142 e->ignore();
143 return; 143 return;
144 } 144 }
145 145
146 DndFactory factory( mCalendar ); 146 DndFactory factory( mCalendar );
147 Todo *todo = factory.createDropTodo(e); 147 Todo *todo = factory.createDropTodo(e);
148 148
149 if (todo) { 149 if (todo) {
150 e->acceptAction(); 150 e->acceptAction();
151 151
152 KOTodoViewItem *destination = 152 KOTodoViewItem *destination =
153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
154 Todo *destinationEvent = 0; 154 Todo *destinationEvent = 0;
155 if (destination) destinationEvent = destination->todo(); 155 if (destination) destinationEvent = destination->todo();
156 156
157 Todo *existingTodo = mCalendar->todo(todo->uid()); 157 Todo *existingTodo = mCalendar->todo(todo->uid());
158 158
159 if(existingTodo) { 159 if(existingTodo) {
160 Incidence *to = destinationEvent; 160 Incidence *to = destinationEvent;
161 while(to) { 161 while(to) {
162 if (to->uid() == todo->uid()) { 162 if (to->uid() == todo->uid()) {
163 KMessageBox::sorry(this, 163 KMessageBox::sorry(this,
164 i18n("Cannot move Todo to itself\nor a child of itself"), 164 i18n("Cannot move Todo to itself\nor a child of itself"),
165 i18n("Drop Todo")); 165 i18n("Drop Todo"));
166 delete todo; 166 delete todo;
167 return; 167 return;
168 } 168 }
169 to = to->relatedTo(); 169 to = to->relatedTo();
170 } 170 }
171 internalDrop = true; 171 internalDrop = true;
172 if ( destinationEvent ) 172 if ( destinationEvent )
173 reparentTodoSignal( destinationEvent, existingTodo ); 173 reparentTodoSignal( destinationEvent, existingTodo );
174 else 174 else
175 unparentTodoSignal(existingTodo); 175 unparentTodoSignal(existingTodo);
176 delete todo; 176 delete todo;
177 } else { 177 } else {
178 mCalendar->addTodo(todo); 178 mCalendar->addTodo(todo);
179 emit todoDropped(todo, KOGlobals::EVENTADDED); 179 emit todoDropped(todo, KOGlobals::EVENTADDED);
180 if ( destinationEvent ) 180 if ( destinationEvent )
181 reparentTodoSignal( destinationEvent, todo ); 181 reparentTodoSignal( destinationEvent, todo );
182 } 182 }
183 } 183 }
184 else { 184 else {
185 QString text; 185 QString text;
186 if (QTextDrag::decode(e,text)) { 186 if (QTextDrag::decode(e,text)) {
187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
189 qDebug("Dropped : " + text); 189 qDebug("Dropped : " + text);
190 QStringList emails = QStringList::split(",",text); 190 QStringList emails = QStringList::split(",",text);
191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
192 int pos = (*it).find("<"); 192 int pos = (*it).find("<");
193 QString name = (*it).left(pos); 193 QString name = (*it).left(pos);
194 QString email = (*it).mid(pos); 194 QString email = (*it).mid(pos);
195 if (!email.isEmpty() && todoi) { 195 if (!email.isEmpty() && todoi) {
196 todoi->todo()->addAttendee(new Attendee(name,email)); 196 todoi->todo()->addAttendee(new Attendee(name,email));
197 } 197 }
198 } 198 }
199 } 199 }
200 else { 200 else {
201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
202 e->ignore(); 202 e->ignore();
203 } 203 }
204 } 204 }
205#endif 205#endif
206} 206}
207void KOTodoListView::wheelEvent (QWheelEvent *e) 207void KOTodoListView::wheelEvent (QWheelEvent *e)
208{ 208{
209 QListView::wheelEvent (e); 209 QListView::wheelEvent (e);
210} 210}
211 211
212void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 212void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
213{ 213{
214 214
215 QPoint p(contentsToViewport(e->pos())); 215 QPoint p(contentsToViewport(e->pos()));
216 QListViewItem *i = itemAt(p); 216 QListViewItem *i = itemAt(p);
217 bool rootClicked = true; 217 bool rootClicked = true;
218 if (i) { 218 if (i) {
219 // if the user clicked into the root decoration of the item, don't 219 // if the user clicked into the root decoration of the item, don't
220 // try to start a drag! 220 // try to start a drag!
221 int X = p.x(); 221 int X = p.x();
222 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 222 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
223 if (X > header()->sectionPos(0) + 223 if (X > header()->sectionPos(0) +
224 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 224 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
225 itemMargin() +i->height()|| 225 itemMargin() +i->height()||
226 X < header()->sectionPos(0)) { 226 X < header()->sectionPos(0)) {
227 rootClicked = false; 227 rootClicked = false;
228 } 228 }
229 } else { 229 } else {
230 rootClicked = false; 230 rootClicked = false;
231 } 231 }
232#ifndef KORG_NODND 232#ifndef KORG_NODND
233 mMousePressed = false; 233 mMousePressed = false;
234 if (! rootClicked && !( e->button() == RightButton) ) { 234 if (! rootClicked && !( e->button() == RightButton) ) {
235 mPressPos = e->pos(); 235 mPressPos = e->pos();
236 mMousePressed = true; 236 mMousePressed = true;
237 } else { 237 } else {
238 mMousePressed = false; 238 mMousePressed = false;
239 } 239 }
240#endif 240#endif
241 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 241 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
242#ifndef DESKTOP_VERSION 242#ifndef DESKTOP_VERSION
243 if (!( e->button() == RightButton && rootClicked) ) 243 if (!( e->button() == RightButton && rootClicked) )
244 QListView::contentsMousePressEvent(e); 244 QListView::contentsMousePressEvent(e);
245#else 245#else
246 QListView::contentsMousePressEvent(e); 246 QListView::contentsMousePressEvent(e);
247#endif 247#endif
248} 248}
249void KOTodoListView::paintEvent(QPaintEvent* e) 249void KOTodoListView::paintEvent(QPaintEvent* e)
250{ 250{
251 emit paintNeeded(); 251 emit paintNeeded();
252 QListView::paintEvent( e); 252 QListView::paintEvent( e);
253} 253}
254void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 254void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
255{ 255{
256 256
257#ifndef KORG_NODND 257#ifndef KORG_NODND
258 //QListView::contentsMouseMoveEvent(e); 258 //QListView::contentsMouseMoveEvent(e);
259 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 259 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
260 QApplication::startDragDistance()*3) { 260 QApplication::startDragDistance()*3) {
261 mMousePressed = false; 261 mMousePressed = false;
262 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 262 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
263 if (item) { 263 if (item) {
264 DndFactory factory( mCalendar ); 264 DndFactory factory( mCalendar );
265 ICalDrag *vd = factory.createDrag( 265 ICalDrag *vd = factory.createDrag(
266 ((KOTodoViewItem *)item)->todo(),viewport()); 266 ((KOTodoViewItem *)item)->todo(),viewport());
267 internalDrop = false; 267 internalDrop = false;
268 // we cannot do any senseful here, because the DnD is still broken in Qt 268 // we cannot do any senseful here, because the DnD is still broken in Qt
269 if (vd->drag()) { 269 if (vd->drag()) {
270 if ( !internalDrop ) { 270 if ( !internalDrop ) {
271 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 271 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
272 qDebug("Dnd: External move: Delete drag source "); 272 qDebug("Dnd: External move: Delete drag source ");
273 } else 273 } else
274 qDebug("Dnd: Internal move "); 274 qDebug("Dnd: Internal move ");
275 275
276 } else { 276 } else {
277 if ( !internalDrop ) { 277 if ( !internalDrop ) {
278 qDebug("Dnd: External Copy"); 278 qDebug("Dnd: External Copy");
279 } else 279 } else
280 qDebug("DnD: Internal copy: Copy pending"); 280 qDebug("DnD: Internal copy: Copy pending");
281 } 281 }
282 } 282 }
283 } 283 }
284#endif 284#endif
285} 285}
286void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 286void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
287{ 287{
288 if ( !e->isAutoRepeat() ) { 288 if ( !e->isAutoRepeat() ) {
289 mFlagKeyPressed = false; 289 mFlagKeyPressed = false;
290 } 290 }
291} 291}
292 292
293 293
294void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 294void KOTodoListView::keyPressEvent ( QKeyEvent * e )
295{ 295{
296 qApp->processEvents(); 296 qApp->processEvents();
297 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 297 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
298 e->ignore(); 298 e->ignore();
299 // qDebug(" ignore %d",e->isAutoRepeat() ); 299 // qDebug(" ignore %d",e->isAutoRepeat() );
300 return; 300 return;
301 } 301 }
302 if (! e->isAutoRepeat() ) 302 if (! e->isAutoRepeat() )
303 mFlagKeyPressed = true; 303 mFlagKeyPressed = true;
304 QListViewItem* cn; 304 QListViewItem* cn;
305 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 305 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
306 cn = currentItem(); 306 cn = currentItem();
307 if ( cn ) { 307 if ( cn ) {
308 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 308 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
309 if ( ci ){ 309 if ( ci ){
310 if ( e->state() == ShiftButton ) 310 if ( e->state() == ShiftButton )
311 ci->setOn( false ); 311 ci->setOn( false );
312 else 312 else
313 ci->setOn( true ); 313 ci->setOn( true );
314 cn = cn->itemBelow(); 314 cn = cn->itemBelow();
315 if ( cn ) { 315 if ( cn ) {
316 setCurrentItem ( cn ); 316 setCurrentItem ( cn );
317 ensureItemVisible ( cn ); 317 ensureItemVisible ( cn );
318 } 318 }
319 319
320 } 320 }
321 } 321 }
322 322
323 return; 323 return;
324 } 324 }
325 325
326 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 326 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
327 switch ( e->key() ) { 327 switch ( e->key() ) {
328 case Qt::Key_Down: 328 case Qt::Key_Down:
329 case Qt::Key_Up: 329 case Qt::Key_Up:
330 QListView::keyPressEvent ( e ); 330 QListView::keyPressEvent ( e );
331 break; 331 break;
332 case Qt::Key_Left: 332 case Qt::Key_Left:
333 case Qt::Key_Right: 333 case Qt::Key_Right:
334 QListView::keyPressEvent ( e ); 334 QListView::keyPressEvent ( e );
335 e->accept(); 335 e->accept();
336 return; 336 return;
337 break; 337 break;
338 default: 338 default:
339 e->ignore(); 339 e->ignore();
340 break; 340 break;
341 } 341 }
342 return; 342 return;
343 } 343 }
344 e->ignore(); 344 e->ignore();
345} 345}
346void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 346void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
347{ 347{
348 QListView::contentsMouseReleaseEvent(e); 348 QListView::contentsMouseReleaseEvent(e);
349 mMousePressed = false; 349 mMousePressed = false;
350} 350}
351 351
352void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 352void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
353{ 353{
354 if (!e) return; 354 if (!e) return;
355 355
356 QPoint vp = contentsToViewport(e->pos()); 356 QPoint vp = contentsToViewport(e->pos());
357 357
358 QListViewItem *item = itemAt(vp); 358 QListViewItem *item = itemAt(vp);
359 359
360 emit double_Clicked(item); 360 emit double_Clicked(item);
361 if (!item) return; 361 if (!item) return;
362 362
363 emit doubleClicked(item,vp,0); 363 emit doubleClicked(item,vp,0);
364} 364}
365 365
366///////////////////////////////////////////////////////////////////////////// 366/////////////////////////////////////////////////////////////////////////////
367 367
368KOQuickTodo::KOQuickTodo(QWidget *parent) : 368KOQuickTodo::KOQuickTodo(QWidget *parent) :
369 QLineEdit(parent) 369 QLineEdit(parent)
370{ 370{
371 setText(i18n("Click to add a new Todo")); 371 setText(i18n("Click to add a new Todo"));
372} 372}
373 373
374void KOQuickTodo::focusInEvent(QFocusEvent *ev) 374void KOQuickTodo::focusInEvent(QFocusEvent *ev)
375{ 375{
376 if ( text()==i18n("Click to add a new Todo") ) 376 if ( text()==i18n("Click to add a new Todo") )
377 setText(""); 377 setText("");
378 QLineEdit::focusInEvent(ev); 378 QLineEdit::focusInEvent(ev);
379} 379}
380 380
381void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 381void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
382{ 382{
383 setText(i18n("Click to add a new Todo")); 383 setText(i18n("Click to add a new Todo"));
384 QLineEdit::focusOutEvent(ev); 384 QLineEdit::focusOutEvent(ev);
385} 385}
386 386
387///////////////////////////////////////////////////////////////////////////// 387/////////////////////////////////////////////////////////////////////////////
388 388
389KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 389KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
390 KOrg::BaseView(calendar,parent,name) 390 KOrg::BaseView(calendar,parent,name)
391{ 391{
392 mPendingUpdateBeforeRepaint = false; 392 mPendingUpdateBeforeRepaint = false;
393 isFlatDisplay = false; 393 isFlatDisplay = false;
394 mNavigator = 0; 394 mNavigator = 0;
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 mName = QString ( name ); 396 mName = QString ( name );
397 mBlockUpdate = false; 397 mBlockUpdate = false;
398 mQuickAdd = new KOQuickTodo(this); 398 mQuickAdd = new KOQuickTodo(this);
399 topLayout->addWidget(mQuickAdd); 399 topLayout->addWidget(mQuickAdd);
400 400
401 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 401 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
402 402
403 mTodoListView = new KOTodoListView(calendar,this, name ); 403 mTodoListView = new KOTodoListView(calendar,this, name );
404 topLayout->addWidget(mTodoListView); 404 topLayout->addWidget(mTodoListView);
405 //mTodoListView->header()->setMaximumHeight(30); 405 //mTodoListView->header()->setMaximumHeight(30);
406 mTodoListView->setRootIsDecorated(true); 406 mTodoListView->setRootIsDecorated(true);
407 mTodoListView->setAllColumnsShowFocus(true); 407 mTodoListView->setAllColumnsShowFocus(true);
408 408
409 mTodoListView->setShowSortIndicator(true); 409 mTodoListView->setShowSortIndicator(true);
410 410
411 mTodoListView->addColumn(i18n("Todo")); 411 mTodoListView->addColumn(i18n("Todo"));
412 mTodoListView->addColumn(i18n("Prio")); 412 mTodoListView->addColumn(i18n("Prio"));
413 mTodoListView->setColumnAlignment(1,AlignHCenter); 413 mTodoListView->setColumnAlignment(1,AlignHCenter);
414 mTodoListView->addColumn(i18n("Complete")); 414 mTodoListView->addColumn(i18n("Complete"));
415 mTodoListView->setColumnAlignment(2,AlignCenter); 415 mTodoListView->setColumnAlignment(2,AlignCenter);
416 416
417 mTodoListView->addColumn(i18n("Due Date")); 417 mTodoListView->addColumn(i18n("Due Date"));
418 mTodoListView->setColumnAlignment(3,AlignLeft); 418 mTodoListView->setColumnAlignment(3,AlignLeft);
419 mTodoListView->addColumn(i18n("Due Time")); 419 mTodoListView->addColumn(i18n("Due Time"));
420 mTodoListView->setColumnAlignment(4,AlignHCenter); 420 mTodoListView->setColumnAlignment(4,AlignHCenter);
421 421
422 mTodoListView->addColumn(i18n("Start Date")); 422 mTodoListView->addColumn(i18n("Start Date"));
423 mTodoListView->setColumnAlignment(5,AlignLeft); 423 mTodoListView->setColumnAlignment(5,AlignLeft);
424 mTodoListView->addColumn(i18n("Start Time")); 424 mTodoListView->addColumn(i18n("Start Time"));
425 mTodoListView->setColumnAlignment(6,AlignHCenter); 425 mTodoListView->setColumnAlignment(6,AlignHCenter);
426 426
427 mTodoListView->addColumn(i18n("Cancelled")); 427 mTodoListView->addColumn(i18n("Cancelled"));
428 mTodoListView->addColumn(i18n("Categories")); 428 mTodoListView->addColumn(i18n("Categories"));
429#if 0 429#if 0
430 mTodoListView->addColumn(i18n("Sort Id")); 430 mTodoListView->addColumn(i18n("Sort Id"));
431 mTodoListView->setColumnAlignment(4,AlignHCenter); 431 mTodoListView->setColumnAlignment(4,AlignHCenter);
432#endif 432#endif
433 433
434 mTodoListView->setMinimumHeight( 60 ); 434 mTodoListView->setMinimumHeight( 60 );
435 mTodoListView->setItemsRenameable( true ); 435 mTodoListView->setItemsRenameable( true );
436 mTodoListView->setRenameable( 0 ); 436 mTodoListView->setRenameable( 0 );
437 mTodoListView->setColumnWidth( 0, 120 ); 437 mTodoListView->setColumnWidth( 0, 120 );
438 mTodoListView->setColumnWidthMode(0, QListView::Manual); 438 mTodoListView->setColumnWidthMode(0, QListView::Manual);
439 mTodoListView->setColumnWidthMode(1, QListView::Manual); 439 mTodoListView->setColumnWidthMode(1, QListView::Manual);
440 mTodoListView->setColumnWidthMode(2, QListView::Manual); 440 mTodoListView->setColumnWidthMode(2, QListView::Manual);
441 mTodoListView->setColumnWidthMode(3, QListView::Manual); 441 mTodoListView->setColumnWidthMode(3, QListView::Manual);
442 mTodoListView->setColumnWidthMode(4, QListView::Manual); 442 mTodoListView->setColumnWidthMode(4, QListView::Manual);
443 mTodoListView->setColumnWidthMode(5, QListView::Manual); 443 mTodoListView->setColumnWidthMode(5, QListView::Manual);
444 mTodoListView->setColumnWidthMode(6, QListView::Manual); 444 mTodoListView->setColumnWidthMode(6, QListView::Manual);
445 mTodoListView->setColumnWidthMode(7, QListView::Manual); 445 mTodoListView->setColumnWidthMode(7, QListView::Manual);
446 mTodoListView->setColumnWidthMode(8, QListView::Manual); 446 mTodoListView->setColumnWidthMode(8, QListView::Manual);
447 447
448 448
449 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 449 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
450 450
451 mPriorityPopupMenu = new QPopupMenu(this); 451 mPriorityPopupMenu = new QPopupMenu(this);
452 for (int i = 1; i <= 5; i++) { 452 for (int i = 1; i <= 5; i++) {
453 QString label = QString ("%1").arg (i); 453 QString label = QString ("%1").arg (i);
454 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 454 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
455 } 455 }
456 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 456 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
457 457
458 mPercentageCompletedPopupMenu = new QPopupMenu(this); 458 mPercentageCompletedPopupMenu = new QPopupMenu(this);
459 for (int i = 0; i <= 100; i+=20) { 459 for (int i = 0; i <= 100; i+=20) {
460 QString label = QString ("%1 %").arg (i); 460 QString label = QString ("%1 %").arg (i);
461 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 461 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
462 } 462 }
463 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 463 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
464 464
465 465
466 466
467 mItemPopupMenu = new QPopupMenu(this); 467 mItemPopupMenu = new QPopupMenu(this);
468 mItemPopupMenu->insertItem(i18n("Show..."), this, 468 mItemPopupMenu->insertItem(i18n("Show..."), this,
469 SLOT (showTodo())); 469 SLOT (showTodo()));
470 mItemPopupMenu->insertItem(i18n("Edit..."), this, 470 mItemPopupMenu->insertItem(i18n("Edit..."), this,
471 SLOT (editTodo())); 471 SLOT (editTodo()));
472 mItemPopupMenu->insertItem( i18n("Delete"), this, 472 mItemPopupMenu->insertItem( i18n("Delete"), this,
473 SLOT (deleteTodo())); 473 SLOT (deleteTodo()));
474 mItemPopupMenu->insertItem( i18n("Clone..."), this, 474 mItemPopupMenu->insertItem( i18n("Clone..."), this,
475 SLOT (cloneTodo())); 475 SLOT (cloneTodo()));
476 mItemPopupMenu->insertItem( i18n("Move..."), this, 476 mItemPopupMenu->insertItem( i18n("Move..."), this,
477 SLOT (moveTodo())); 477 SLOT (moveTodo()));
478 mItemPopupMenu->insertItem( i18n("Beam..."), this, 478 mItemPopupMenu->insertItem( i18n("Beam..."), this,
479 SLOT (beamTodo())); 479 SLOT (beamTodo()));
480 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 480 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
481 SLOT (cancelTodo())); 481 SLOT (cancelTodo()));
482 mItemPopupMenu->insertSeparator(); 482 mItemPopupMenu->insertSeparator();
483 483
484 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 484 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
485 SLOT (toggleRunningItem())); 485 SLOT (toggleRunningItem()));
486 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 486 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
487 SLOT (newTodo())); 487 SLOT (newTodo()));
488 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 488 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
489 SLOT (newSubTodo())); 489 SLOT (newSubTodo()));
490 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 490 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
491 SLOT (unparentTodo()),0,21); 491 SLOT (unparentTodo()),0,21);
492 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 492 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
493 SLOT (reparentTodo()),0,22); 493 SLOT (reparentTodo()),0,22);
494 mItemPopupMenu->insertSeparator(); 494 mItemPopupMenu->insertSeparator();
495#if 0 495#if 0
496 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 496 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
497 this, SLOT( purgeCompleted() ) ); 497 this, SLOT( purgeCompleted() ) );
498 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 498 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
499 this, SLOT( toggleCompleted() ),0, 33 ); 499 this, SLOT( toggleCompleted() ),0, 33 );
500 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 500 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
501 this, SLOT( toggleQuickTodo() ),0, 34 ); 501 this, SLOT( toggleQuickTodo() ),0, 34 );
502 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 502 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
503 this, SLOT( toggleRunning() ),0, 35 ); 503 this, SLOT( toggleRunning() ),0, 35 );
504 504
505#endif 505#endif
506 mPopupMenu = new QPopupMenu(this); 506 mPopupMenu = new QPopupMenu(this);
507 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 507 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
508 SLOT (newTodo()),0,1); 508 SLOT (newTodo()),0,1);
509 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 509 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
510 this, SLOT(purgeCompleted()),0,2); 510 this, SLOT(purgeCompleted()),0,2);
511 mPopupMenu->insertItem(i18n("Show Completed"), 511 mPopupMenu->insertItem(i18n("Show Completed"),
512 this, SLOT( toggleCompleted() ),0,3 ); 512 this, SLOT( toggleCompleted() ),0,3 );
513 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 513 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
514 this, SLOT( toggleQuickTodo() ),0,4 ); 514 this, SLOT( toggleQuickTodo() ),0,4 );
515 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 515 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
516 this, SLOT( toggleRunning() ),0,5 ); 516 this, SLOT( toggleRunning() ),0,5 );
517 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 517 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
518 this, SLOT( setAllOpen() ),0,6 ); 518 this, SLOT( setAllOpen() ),0,6 );
519 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 519 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
520 this, SLOT( setAllClose() ),0,7 ); 520 this, SLOT( setAllClose() ),0,7 );
521 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 521 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
522 this, SLOT( setAllFlat() ),0,8 ); 522 this, SLOT( setAllFlat() ),0,8 );
523 mDocPrefs = new DocPrefs( name ); 523 mDocPrefs = new DocPrefs( name );
524 524
525 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 525 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
526 mPopupMenu->setCheckable( true ); 526 mPopupMenu->setCheckable( true );
527 mItemPopupMenu->setCheckable( true ); 527 mItemPopupMenu->setCheckable( true );
528 528
529 529
530 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 530 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
531 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 531 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
532 532
533 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 533 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
534 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 534 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
535 535
536 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 536 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
537 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 537 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
538 538
539 539
540 // Double clicking conflicts with opening/closing the subtree 540 // Double clicking conflicts with opening/closing the subtree
541 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 541 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
542 SLOT( editItem( QListViewItem *) ) ); 542 SLOT( editItem( QListViewItem *) ) );
543 /* 543 /*
544 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 544 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
545 const QPoint &,int ) ), 545 const QPoint &,int ) ),
546 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 546 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
547 */ 547 */
548 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 548 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
549 const QPoint &,int ) ), 549 const QPoint &,int ) ),
550 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 550 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
551 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 551 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
552 SLOT( itemClicked( QListViewItem * ) ) ); 552 SLOT( itemClicked( QListViewItem * ) ) );
553 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 553 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
554 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 554 SLOT( itemDoubleClicked( QListViewItem * ) ) );
555 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 555 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
556 SLOT( updateView() ) ); 556 SLOT( updateView() ) );
557 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 557 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
558 SLOT( todoModified(Todo *, int) ) ); 558 SLOT( todoModified(Todo *, int) ) );
559 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 559 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
560 SLOT( itemStateChanged( QListViewItem * ) ) ); 560 SLOT( itemStateChanged( QListViewItem * ) ) );
561 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 561 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
562 SLOT( itemStateChanged( QListViewItem * ) ) ); 562 SLOT( itemStateChanged( QListViewItem * ) ) );
563 connect( mTodoListView, SIGNAL( paintNeeded() ), 563 connect( mTodoListView, SIGNAL( paintNeeded() ),
564 SLOT( paintNeeded()) ); 564 SLOT( paintNeeded()) );
565 565
566#if 0 566#if 0
567 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 567 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
568 SLOT(selectionChanged(QListViewItem *))); 568 SLOT(selectionChanged(QListViewItem *)));
569 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 569 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
570 SLOT(selectionChanged(QListViewItem *))); 570 SLOT(selectionChanged(QListViewItem *)));
571 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 571 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
572 SLOT(selectionChanged(QListViewItem *))); 572 SLOT(selectionChanged(QListViewItem *)));
573#endif 573#endif
574 574
575 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 575 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
576 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 576 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
577 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 577 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
578 578
579 connect( mTodoListView, SIGNAL(selectionChanged() ), 579 connect( mTodoListView, SIGNAL(selectionChanged() ),
580 SLOT( processSelectionChange() ) ); 580 SLOT( processSelectionChange() ) );
581 connect( mQuickAdd, SIGNAL( returnPressed () ), 581 connect( mQuickAdd, SIGNAL( returnPressed () ),
582 SLOT( addQuickTodo() ) ); 582 SLOT( addQuickTodo() ) );
583 583
584} 584}
585 585
586KOTodoView::~KOTodoView() 586KOTodoView::~KOTodoView()
587{ 587{
588 // delete mKOTodoViewWhatsThis; 588 // delete mKOTodoViewWhatsThis;
589 delete mDocPrefs; 589 delete mDocPrefs;
590} 590}
591QString KOTodoView::getWhatsThisText(QPoint p) 591QString KOTodoView::getWhatsThisText(QPoint p)
592{ 592{
593 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 593 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
594 if ( item ) 594 if ( item )
595 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 595 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
596 KOPrefs::instance()->mWTshowDetails, 596 KOPrefs::instance()->mWTshowDetails,
597 KOPrefs::instance()->mWTshowCreated, 597 KOPrefs::instance()->mWTshowCreated,
598 KOPrefs::instance()->mWTshowChanged); 598 KOPrefs::instance()->mWTshowChanged);
599 return i18n("That is the todo view" ); 599 return i18n("That is the todo view" );
600 600
601} 601}
602 602
603void KOTodoView::jumpToDate () 603void KOTodoView::jumpToDate ()
604{ 604{
605 // if (mActiveItem) { 605 // if (mActiveItem) {
606// mActiveItem->todo()); 606// mActiveItem->todo());
607// if ( mActiveItem->todo()->hasDueDate() ) 607// if ( mActiveItem->todo()->hasDueDate() )
608// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 608// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
609} 609}
610void KOTodoView::paintNeeded() 610void KOTodoView::paintNeeded()
611{ 611{
612 if ( mPendingUpdateBeforeRepaint ) { 612 if ( mPendingUpdateBeforeRepaint ) {
613 updateView(); 613 updateView();
614 mPendingUpdateBeforeRepaint = false; 614 mPendingUpdateBeforeRepaint = false;
615 } 615 }
616} 616}
617void KOTodoView::paintEvent(QPaintEvent * pevent) 617void KOTodoView::paintEvent(QPaintEvent * pevent)
618{ 618{
619 if ( mPendingUpdateBeforeRepaint ) { 619 if ( mPendingUpdateBeforeRepaint ) {
620 updateView(); 620 updateView();
621 mPendingUpdateBeforeRepaint = false; 621 mPendingUpdateBeforeRepaint = false;
622 } 622 }
623 KOrg::BaseView::paintEvent( pevent); 623 KOrg::BaseView::paintEvent( pevent);
624} 624}
625 625
626void KOTodoView::updateView() 626void KOTodoView::updateView()
627{ 627{
628 pendingSubtodo = 0; 628 pendingSubtodo = 0;
629 if ( mBlockUpdate ) { 629 if ( mBlockUpdate ) {
630 return; 630 return;
631 } 631 }
632 if ( !isVisible() ) { 632 if ( !isVisible() ) {
633 mPendingUpdateBeforeRepaint = true; 633 mPendingUpdateBeforeRepaint = true;
634 return; 634 return;
635 } 635 }
636 storeCurrentItem(); 636 storeCurrentItem();
637 //qDebug("KOTodoView::updateView() %x", this); 637 //qDebug("KOTodoView::updateView() %x", this);
638 if ( isFlatDisplay ) { 638 if ( isFlatDisplay ) {
639 displayAllFlat(); 639 displayAllFlat();
640 resetCurrentItem(); 640 resetCurrentItem();
641 return; 641 return;
642 } 642 }
643 //qDebug("update "); 643 //qDebug("update ");
644// kdDebug() << "KOTodoView::updateView()" << endl; 644// kdDebug() << "KOTodoView::updateView()" << endl;
645 QFont fo = KOPrefs::instance()->mTodoViewFont; 645 QFont fo = KOPrefs::instance()->mTodoViewFont;
646 646
647 647
648 mTodoListView->clear(); 648 mTodoListView->clear();
649 if ( mName == "todolistsmall" ) { 649 if ( mName == "todolistsmall" ) {
650 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 650 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
651 int ps = fo.pointSize() -2; 651 int ps = fo.pointSize() -2;
652 if ( ps > 12 ) 652 if ( ps > 12 )
653 ps -= 2; 653 ps -= 2;
654 fo.setPointSize( ps ); 654 fo.setPointSize( ps );
655 } 655 }
656 } 656 }
657 657
658 mTodoListView->setFont( fo ); 658 mTodoListView->setFont( fo );
659 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 659 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
660 //mTodoListView->header()->setMaximumHeight(fm.height()); 660 //mTodoListView->header()->setMaximumHeight(fm.height());
661 QPtrList<Todo> todoList = calendar()->todos(); 661 QPtrList<Todo> todoList = calendar()->todos();
662 662
663/* 663/*
664 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 664 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
665 Event *t; 665 Event *t;
666 for(t = todoList.first(); t; t = todoList.next()) { 666 for(t = todoList.first(); t; t = todoList.next()) {
667 kdDebug() << " " << t->getSummary() << endl; 667 kdDebug() << " " << t->getSummary() << endl;
668 668
669 if (t->getRelatedTo()) { 669 if (t->getRelatedTo()) {
670 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 670 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
671 } 671 }
672 672
673 QPtrList<Event> l = t->getRelations(); 673 QPtrList<Event> l = t->getRelations();
674 Event *c; 674 Event *c;
675 for(c=l.first();c;c=l.next()) { 675 for(c=l.first();c;c=l.next()) {
676 kdDebug() << " - relation: " << c->getSummary() << endl; 676 kdDebug() << " - relation: " << c->getSummary() << endl;
677 } 677 }
678 } 678 }
679*/ 679*/
680 680
681 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 681 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
682 // specific order of events. That means that we have to generate parent items 682 // specific order of events. That means that we have to generate parent items
683 // recursively for proper hierarchical display of Todos. 683 // recursively for proper hierarchical display of Todos.
684 mTodoMap.clear(); 684 mTodoMap.clear();
685 Todo *todo; 685 Todo *todo;
686 todo = todoList.first();// todo; todo = todoList.next()) { 686 todo = todoList.first();// todo; todo = todoList.next()) {
687 while ( todo ) { 687 while ( todo ) {
688 bool next = true; 688 bool next = true;
689 // qDebug("todo %s ", todo->summary().latin1()); 689 // qDebug("todo %s ", todo->summary().latin1());
690 Incidence *incidence = todo->relatedTo(); 690 Incidence *incidence = todo->relatedTo();
691 while ( incidence ) { 691 while ( incidence ) {
692 if ( incidence->type() == "Todo") { 692 if ( incidence->type() == "Todo") {
693 //qDebug("related %s ",incidence->summary().latin1() ); 693 //qDebug("related %s ",incidence->summary().latin1() );
694 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 694 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
695 //qDebug("related not found "); 695 //qDebug("related not found ");
696 todoList.remove( ); 696 todoList.remove( );
697 todo = todoList.current(); 697 todo = todoList.current();
698 next = false; 698 next = false;
699 incidence = 0; 699 incidence = 0;
700 700
701 } else { 701 } else {
702 //qDebug("related found "); 702 //qDebug("related found ");
703 incidence = incidence->relatedTo(); 703 incidence = incidence->relatedTo();
704 } 704 }
705 } else 705 } else
706 incidence = 0; 706 incidence = 0;
707 } 707 }
708 if ( next ) 708 if ( next )
709 todo = todoList.next(); 709 todo = todoList.next();
710 } 710 }
711// qDebug("again .... "); 711
712// for(todo = todoList.first(); todo; todo = todoList.next()) {
713
714// qDebug("yytodo %s ", todo->summary().latin1());
715// }
716 //qDebug("for ");
717 for(todo = todoList.first(); todo; todo = todoList.next()) { 712 for(todo = todoList.first(); todo; todo = todoList.next()) {
718 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 713 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
719 { 714 {
720 insertTodoItem(todo); 715 insertTodoItem(todo);
721 } 716 }
722 } 717 }
723 //qDebug("for end ");
724 // Restore opened/closed state 718 // Restore opened/closed state
725 mTodoListView->blockSignals( true ); 719 mTodoListView->blockSignals( true );
726 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 720 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
727 mTodoListView->blockSignals( false ); 721 mTodoListView->blockSignals( false );
728 resetCurrentItem(); 722 resetCurrentItem();
729 processSelectionChange(); 723 processSelectionChange();
730} 724}
731 725
732void KOTodoView::storeCurrentItem() 726void KOTodoView::storeCurrentItem()
733{ 727{
734 mCurItem = 0; 728 mCurItem = 0;
735 mCurItemRootParent = 0; 729 mCurItemRootParent = 0;
736 mCurItemParent = 0; 730 mCurItemParent = 0;
737 mCurItemAbove = 0; 731 mCurItemAbove = 0;
738 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 732 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
739 if (mActiveItem) { 733 if (mActiveItem) {
740 mCurItem = mActiveItem->todo(); 734 mCurItem = mActiveItem->todo();
741 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 735 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
742 if ( activeItemAbove ) 736 if ( activeItemAbove )
743 mCurItemAbove = activeItemAbove->todo(); 737 mCurItemAbove = activeItemAbove->todo();
744 mCurItemRootParent = mCurItem; 738 mCurItemRootParent = mCurItem;
745 mCurItemParent = mCurItemRootParent->relatedTo(); 739 mCurItemParent = mCurItemRootParent->relatedTo();
746 while ( mCurItemRootParent->relatedTo() != 0 ) 740 while ( mCurItemRootParent->relatedTo() != 0 )
747 mCurItemRootParent = mCurItemRootParent->relatedTo(); 741 mCurItemRootParent = mCurItemRootParent->relatedTo();
748 } 742 }
749 mActiveItem = 0; 743 mActiveItem = 0;
750} 744}
751 745
752void KOTodoView::resetCurrentItem() 746void KOTodoView::resetCurrentItem()
753{ 747{
754 mTodoListView->setFocus(); 748 mTodoListView->setFocus();
755 KOTodoViewItem* foundItem = 0; 749 KOTodoViewItem* foundItem = 0;
756 KOTodoViewItem* foundItemRoot = 0; 750 KOTodoViewItem* foundItemRoot = 0;
757 KOTodoViewItem* foundItemParent = 0; 751 KOTodoViewItem* foundItemParent = 0;
758 KOTodoViewItem* foundItemAbove = 0; 752 KOTodoViewItem* foundItemAbove = 0;
759 if ( mTodoListView->firstChild () ) { 753 if ( mTodoListView->firstChild () ) {
760 if ( mCurItem ) { 754 if ( mCurItem ) {
761 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 755 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
762 while ( item ) { 756 while ( item ) {
763 if ( item->todo() == mCurItem ) { 757 if ( item->todo() == mCurItem ) {
764 foundItem = item; 758 foundItem = item;
765 break; 759 break;
766 } else if ( item->todo() == mCurItemAbove ) { 760 } else if ( item->todo() == mCurItemAbove ) {
767 foundItemAbove = item; 761 foundItemAbove = item;
768 762
769 } 763 }
770 if ( item->todo() == mCurItemRootParent ) { 764 if ( item->todo() == mCurItemRootParent ) {
771 foundItemRoot = item; 765 foundItemRoot = item;
772 } 766 }
773 if ( item->todo() == mCurItemParent ) { 767 if ( item->todo() == mCurItemParent ) {
774 foundItemParent = item; 768 foundItemParent = item;
775 } 769 }
776 item = (KOTodoViewItem*)item->itemBelow(); 770 item = (KOTodoViewItem*)item->itemBelow();
777 } 771 }
778 if ( ! foundItem ) { 772 if ( ! foundItem ) {
779 if ( foundItemParent ) { 773 if ( foundItemParent ) {
780 foundItem = foundItemParent; 774 foundItem = foundItemParent;
781 } else { 775 } else {
782 if ( foundItemRoot ) 776 if ( foundItemRoot )
783 foundItem = foundItemRoot; 777 foundItem = foundItemRoot;
784 else 778 else
785 foundItem = foundItemAbove; 779 foundItem = foundItemAbove;
786 } 780 }
787 } 781 }
788 } 782 }
789 if ( foundItem ) { 783 if ( foundItem ) {
790 mTodoListView->setCurrentItem( foundItem ); 784 mTodoListView->setCurrentItem( foundItem );
791 mTodoListView->ensureItemVisible( foundItem ); 785 mTodoListView->ensureItemVisible( foundItem );
792 } else { 786 } else {
793 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 787 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
794 } 788 }
795 } 789 }
796 mTodoListView->setFocus(); 790 mTodoListView->setFocus();
797} 791}
798//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 792//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
799bool KOTodoView::checkTodo( Todo * todo ) 793bool KOTodoView::checkTodo( Todo * todo )
800{ 794{
801 795
802 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 796 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
803 return false; 797 return false;
804 if ( !todo->isCompleted() ) { 798 if ( !todo->isCompleted() ) {
805 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 799 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
806 return true; 800 return true;
807 } 801 }
808 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 802 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
809 if ( todo->hasStartDate() ) 803 if ( todo->hasStartDate() )
810 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 804 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
811 return false; 805 return false;
812 if ( todo->hasDueDate() ) 806 if ( todo->hasDueDate() )
813 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 807 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
814 return false; 808 return false;
815 } 809 }
816 return true; 810 return true;
817} 811}
818 812
819void KOTodoView::restoreItemState( QListViewItem *item ) 813void KOTodoView::restoreItemState( QListViewItem *item )
820{ 814{
821 pendingSubtodo = 0; 815 pendingSubtodo = 0;
822 while( item ) { 816 while( item ) {
823 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 817 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
824 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 818 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
825 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 819 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
826 item = item->nextSibling(); 820 item = item->nextSibling();
827 } 821 }
828} 822}
829 823
830 824
831QMap<Todo *,KOTodoViewItem *>::ConstIterator 825QMap<Todo *,KOTodoViewItem *>::ConstIterator
832 KOTodoView::insertTodoItem(Todo *todo) 826 KOTodoView::insertTodoItem(Todo *todo)
833{ 827{
834 828
835// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 829// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
836 // TODO: Check, if dynmaic cast is necessary 830 // TODO: Check, if dynmaic cast is necessary
837 831
838 pendingSubtodo = 0; 832 pendingSubtodo = 0;
839 Incidence *incidence = todo->relatedTo(); 833 Incidence *incidence = todo->relatedTo();
840 if (incidence && incidence->type() == "Todo") { 834 if (incidence && incidence->type() == "Todo") {
841 Todo *relatedTodo = static_cast<Todo *>(incidence); 835 Todo *relatedTodo = static_cast<Todo *>(incidence);
842 836
843// kdDebug() << " has Related" << endl; 837// kdDebug() << " has Related" << endl;
844 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 838 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
845 itemIterator = mTodoMap.find(relatedTodo); 839 itemIterator = mTodoMap.find(relatedTodo);
846 if (itemIterator == mTodoMap.end()) { 840 if (itemIterator == mTodoMap.end()) {
847// kdDebug() << " related not yet in list" << endl; 841// kdDebug() << " related not yet in list" << endl;
848 itemIterator = insertTodoItem (relatedTodo); 842 itemIterator = insertTodoItem (relatedTodo);
849 } 843 }
850 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 844 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
851 // and one into the map. Sure finding is more easy but why? -zecke 845 // and one into the map. Sure finding is more easy but why? -zecke
852 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 846 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
853 return mTodoMap.insert(todo,todoItem); 847 return mTodoMap.insert(todo,todoItem);
854 } else { 848 } else {
855// kdDebug() << " no Related" << endl; 849// kdDebug() << " no Related" << endl;
856 // see above -zecke 850 // see above -zecke
857 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 851 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
858 return mTodoMap.insert(todo,todoItem); 852 return mTodoMap.insert(todo,todoItem);
859 } 853 }
860} 854}
861 855
862 856
863void KOTodoView::updateConfig() 857void KOTodoView::updateConfig()
864{ 858{
865 updateView(); 859 updateView();
866 mTodoListView->repaintContents(); 860 mTodoListView->repaintContents();
867} 861}
868 862
869QPtrList<Incidence> KOTodoView::selectedIncidences() 863QPtrList<Incidence> KOTodoView::selectedIncidences()
870{ 864{
871 QPtrList<Incidence> selected; 865 QPtrList<Incidence> selected;
872 866
873 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 867 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
874// if (!item) item = mActiveItem; 868// if (!item) item = mActiveItem;
875 if (item) selected.append(item->todo()); 869 if (item) selected.append(item->todo());
876 870
877 return selected; 871 return selected;
878} 872}
879 873
880QPtrList<Todo> KOTodoView::selectedTodos() 874QPtrList<Todo> KOTodoView::selectedTodos()
881{ 875{
882 QPtrList<Todo> selected; 876 QPtrList<Todo> selected;
883 877
884 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 878 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
885// if (!item) item = mActiveItem; 879// if (!item) item = mActiveItem;
886 if (item) selected.append(item->todo()); 880 if (item) selected.append(item->todo());
887 881
888 return selected; 882 return selected;
889} 883}
890 884
891void KOTodoView::changeEventDisplay(Event *, int) 885void KOTodoView::changeEventDisplay(Event *, int)
892{ 886{
893 updateView(); 887 updateView();
894} 888}
895 889
896void KOTodoView::showDates(const QDate &, const QDate &) 890void KOTodoView::showDates(const QDate &, const QDate &)
897{ 891{
898} 892}
899 893
900void KOTodoView::showEvents(QPtrList<Event>) 894void KOTodoView::showEvents(QPtrList<Event>)
901{ 895{
902 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 896 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
903} 897}
904 898
905void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 899void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
906 const QDate &td) 900 const QDate &td)
907{ 901{
908#ifndef KORG_NOPRINTER 902#ifndef KORG_NOPRINTER
909 calPrinter->preview(CalPrinter::Todolist, fd, td); 903 calPrinter->preview(CalPrinter::Todolist, fd, td);
910#endif 904#endif
911} 905}
912 906
913void KOTodoView::editItem(QListViewItem *item ) 907void KOTodoView::editItem(QListViewItem *item )
914{ 908{
915 // qDebug("editItem(QListViewItem *item ) ");
916 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 909 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
917} 910}
918 911
919void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 912void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
920{ 913{
921 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 914 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
922} 915}
923 916
924void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 917void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
925{ 918{
926 pendingSubtodo = 0; 919 pendingSubtodo = 0;
927 mActiveItem = (KOTodoViewItem *)item; 920 mActiveItem = (KOTodoViewItem *)item;
928 if (item) { 921 if (item) {
929 switch (column){ 922 switch (column){
930 case 1: 923 case 1:
931 mPriorityPopupMenu->popup(QCursor::pos ()); break; 924 mPriorityPopupMenu->popup(QCursor::pos ()); break;
932 case 2: 925 case 2:
933 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 926 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
934 case 3: 927 case 3:
935 moveTodo(); 928 moveTodo();
936 break; 929 break;
937 case 8: 930 case 8:
938 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 931 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
939 default: 932 default:
940 mItemPopupMenu->popup(QCursor::pos()); 933 mItemPopupMenu->popup(QCursor::pos());
941 } 934 }
942 } else mPopupMenu->popup(QCursor::pos()); 935 } else mPopupMenu->popup(QCursor::pos());
943} 936}
944void KOTodoView::newTodo() 937void KOTodoView::newTodo()
945{ 938{
946 emit newTodoSignal(); 939 emit newTodoSignal();
947} 940}
948 941
949void KOTodoView::newSubTodo() 942void KOTodoView::newSubTodo()
950{ 943{
951 if (mActiveItem) { 944 if (mActiveItem) {
952 emit newSubTodoSignal(mActiveItem->todo()); 945 emit newSubTodoSignal(mActiveItem->todo());
953 } 946 }
954} 947}
955void KOTodoView::unparentTodo() 948void KOTodoView::unparentTodo()
956{ 949{
957 if (mActiveItem) { 950 if (mActiveItem) {
958 emit unparentTodoSignal(mActiveItem->todo()); 951 emit unparentTodoSignal(mActiveItem->todo());
959 } 952 }
960} 953}
961 954
962void KOTodoView::reparentTodo() 955void KOTodoView::reparentTodo()
963{ 956{
964 if (mActiveItem) { 957 if (mActiveItem) {
965 topLevelWidget()->setCaption(i18n("Click on new parent item")); 958 topLevelWidget()->setCaption(i18n("Click on new parent item"));
966 pendingSubtodo = mActiveItem; 959 pendingSubtodo = mActiveItem;
967 } 960 }
968} 961}
969void KOTodoView::editTodo() 962void KOTodoView::editTodo()
970{ 963{
971 if (mActiveItem) { 964 if (mActiveItem) {
972 emit editTodoSignal(mActiveItem->todo()); 965 emit editTodoSignal(mActiveItem->todo());
973 } 966 }
974} 967}
975void KOTodoView::cloneTodo() 968void KOTodoView::cloneTodo()
976{ 969{
977 if (mActiveItem) { 970 if (mActiveItem) {
978 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 971 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
979 } 972 }
980} 973}
981void KOTodoView::cancelTodo() 974void KOTodoView::cancelTodo()
982{ 975{
983 if (mActiveItem) { 976 if (mActiveItem) {
984 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 977 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
985 } 978 }
986} 979}
987void KOTodoView::moveTodo() 980void KOTodoView::moveTodo()
988{ 981{
989 if (mActiveItem) { 982 if (mActiveItem) {
990 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 983 emit moveTodoSignal((Incidence*)mActiveItem->todo());
991 } 984 }
992} 985}
993void KOTodoView::beamTodo() 986void KOTodoView::beamTodo()
994{ 987{
995 if (mActiveItem) { 988 if (mActiveItem) {
996 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 989 emit beamTodoSignal((Incidence*)mActiveItem->todo());
997 } 990 }
998} 991}
999 992
1000 993
1001void KOTodoView::showTodo() 994void KOTodoView::showTodo()
1002{ 995{
1003 if (mActiveItem) { 996 if (mActiveItem) {
1004 emit showTodoSignal(mActiveItem->todo()); 997 emit showTodoSignal(mActiveItem->todo());
1005 } 998 }
1006} 999}
1007 1000
1008void KOTodoView::deleteTodo() 1001void KOTodoView::deleteTodo()
1009{ 1002{
1010 if (mActiveItem) { 1003 if (mActiveItem) {
1011 emit deleteTodoSignal(mActiveItem->todo()); 1004 emit deleteTodoSignal(mActiveItem->todo());
1012 } 1005 }
1013} 1006}
1014 1007
1015void KOTodoView::setNewPriority(int index) 1008void KOTodoView::setNewPriority(int index)
1016{ 1009{
1017 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1010 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1018 mActiveItem->todo()->setPriority(mPriority[index]); 1011 mActiveItem->todo()->setPriority(mPriority[index]);
1019 mActiveItem->construct(); 1012 mActiveItem->construct();
1020 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1013 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1021 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1014 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1022 } 1015 }
1023} 1016}
1024 1017
1025void KOTodoView::setNewPercentage(int index) 1018void KOTodoView::setNewPercentage(int index)
1026{ 1019{
1027 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1020 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1028 1021
1029 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1022 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1030 mActiveItem->setOn( true ); 1023 mActiveItem->setOn( true );
1031 return; 1024 return;
1032 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1025 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1033 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1026 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1034 if ( par && par->isOn() ) 1027 if ( par && par->isOn() )
1035 par->setOn( false ); 1028 par->setOn( false );
1036 } 1029 }
1037 if (mPercentage[index] == 100) { 1030 if (mPercentage[index] == 100) {
1038 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1031 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1039 } else { 1032 } else {
1040 mActiveItem->todo()->setCompleted(false); 1033 mActiveItem->todo()->setCompleted(false);
1041 } 1034 }
1042 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1035 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1043 mActiveItem->construct(); 1036 mActiveItem->construct();
1044 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1037 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1045 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1038 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1046 } 1039 }
1047} 1040}
1048 1041
1049 1042
1050QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 1043QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
1051{ 1044{
1052 QPopupMenu* tempMenu = new QPopupMenu (this); 1045 QPopupMenu* tempMenu = new QPopupMenu (this);
1053 QStringList checkedCategories = todoItem->todo()->categories (); 1046 QStringList checkedCategories = todoItem->todo()->categories ();
1054 1047
1055 tempMenu->setCheckable (true); 1048 tempMenu->setCheckable (true);
1056 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1049 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1057 it != KOPrefs::instance()->mCustomCategories.end (); 1050 it != KOPrefs::instance()->mCustomCategories.end ();
1058 ++it) { 1051 ++it) {
1059 int index = tempMenu->insertItem (*it); 1052 int index = tempMenu->insertItem (*it);
1060 mCategory[index] = *it; 1053 mCategory[index] = *it;
1061 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 1054 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
1062 } 1055 }
1063 1056
1064 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 1057 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
1065 return tempMenu; 1058 return tempMenu;
1066 1059
1067 1060
1068} 1061}
1069void KOTodoView::changedCategories(int index) 1062void KOTodoView::changedCategories(int index)
1070{ 1063{
1071 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1064 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1072 QStringList categories = mActiveItem->todo()->categories (); 1065 QStringList categories = mActiveItem->todo()->categories ();
1073 QString colcat = categories.first(); 1066 QString colcat = categories.first();
1074 if (categories.find (mCategory[index]) != categories.end ()) 1067 if (categories.find (mCategory[index]) != categories.end ())
1075 categories.remove (mCategory[index]); 1068 categories.remove (mCategory[index]);
1076 else 1069 else
1077 categories.insert (categories.end(), mCategory[index]); 1070 categories.insert (categories.end(), mCategory[index]);
1078 categories.sort (); 1071 categories.sort ();
1079 if ( !colcat.isEmpty() ) { 1072 if ( !colcat.isEmpty() ) {
1080 if ( categories.find ( colcat ) != categories.end () ) { 1073 if ( categories.find ( colcat ) != categories.end () ) {
1081 categories.remove( colcat ); 1074 categories.remove( colcat );
1082 categories.prepend( colcat ); 1075 categories.prepend( colcat );
1083 } 1076 }
1084 } 1077 }
1085 mActiveItem->todo()->setCategories (categories); 1078 mActiveItem->todo()->setCategories (categories);
1086 mActiveItem->construct(); 1079 mActiveItem->construct();
1087 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1080 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1088 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1081 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1089 } 1082 }
1090} 1083}
1091void KOTodoView::itemDoubleClicked(QListViewItem *item) 1084void KOTodoView::itemDoubleClicked(QListViewItem *item)
1092{ 1085{
1093 if ( pendingSubtodo != 0 ) { 1086 if ( pendingSubtodo != 0 ) {
1094 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1087 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1095 } 1088 }
1096 pendingSubtodo = 0; 1089 pendingSubtodo = 0;
1097 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1090 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1098 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1091 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1099 qDebug("ROW %d ", row); 1092 //qDebug("ROW %d ", row);
1100 if (!item) { 1093 if (!item) {
1101 newTodo(); 1094 newTodo();
1102 return; 1095 return;
1103 } else { 1096 } else {
1104 if ( row == 2 || row == 1 ) { 1097 if ( row == 2 || row == 1 ) {
1105 mActiveItem = (KOTodoViewItem *) item; 1098 mActiveItem = (KOTodoViewItem *) item;
1106 newSubTodo(); 1099 newSubTodo();
1107 return; 1100 return;
1108 } 1101 }
1109 if ( row == 5 || row == 6 ) { 1102 if ( row == 5 || row == 6 ) {
1110 mActiveItem = (KOTodoViewItem *) item; 1103 mActiveItem = (KOTodoViewItem *) item;
1111 toggleRunningItem(); 1104 toggleRunningItem();
1112 return; 1105 return;
1113 } 1106 }
1114 } 1107 }
1115 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1108 if ( KOPrefs::instance()->mEditOnDoubleClick )
1116 editItem( item ); 1109 editItem( item );
1117 else 1110 else
1118 showItem( item , QPoint(), 0 ); 1111 showItem( item , QPoint(), 0 );
1119} 1112}
1120void KOTodoView::toggleRunningItem() 1113void KOTodoView::toggleRunningItem()
1121{ 1114{
1122 // qDebug("KOTodoView::toggleRunning() "); 1115 // qDebug("KOTodoView::toggleRunning() ");
1123 if ( ! mActiveItem ) 1116 if ( ! mActiveItem )
1124 return; 1117 return;
1125 Todo * t = mActiveItem->todo(); 1118 Todo * t = mActiveItem->todo();
1126 if ( t->isRunning() ) { 1119 if ( t->isRunning() ) {
1127 int result = KMessageBox::warningContinueCancel(this, 1120 int result = KMessageBox::warningContinueCancel(this,
1128 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true); 1121 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true);
1129 if (result != KMessageBox::Continue) return; 1122 if (result != KMessageBox::Continue) return;
1130 t->setRunning( false ); 1123 t->setRunning( false );
1131 mActiveItem->construct(); 1124 mActiveItem->construct();
1132 } else { 1125 } else {
1133 int result = KMessageBox::warningContinueCancel(this, 1126 int result = KMessageBox::warningContinueCancel(this,
1134 i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); 1127 i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true);
1135 if (result != KMessageBox::Continue) return; 1128 if (result != KMessageBox::Continue) return;
1136 t->setRunning( true ); 1129 t->setRunning( true );
1137 mActiveItem->construct(); 1130 mActiveItem->construct();
1138 } 1131 }
1139} 1132}
1140 1133
1141void KOTodoView::itemClicked(QListViewItem *item) 1134void KOTodoView::itemClicked(QListViewItem *item)
1142{ 1135{
1143 //qDebug("KOTodoView::itemClicked %d", item); 1136 //qDebug("KOTodoView::itemClicked %d", item);
1144 if (!item) { 1137 if (!item) {
1145 if ( pendingSubtodo != 0 ) { 1138 if ( pendingSubtodo != 0 ) {
1146 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1139 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1147 } 1140 }
1148 pendingSubtodo = 0; 1141 pendingSubtodo = 0;
1149 return; 1142 return;
1150 } 1143 }
1151 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1144 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1152 if ( pendingSubtodo != 0 ) { 1145 if ( pendingSubtodo != 0 ) {
1153 bool allowReparent = true; 1146 bool allowReparent = true;
1154 QListViewItem *par = item; 1147 QListViewItem *par = item;
1155 while ( par ) { 1148 while ( par ) {
1156 if ( par == pendingSubtodo ) { 1149 if ( par == pendingSubtodo ) {
1157 allowReparent = false; 1150 allowReparent = false;
1158 break; 1151 break;
1159 } 1152 }
1160 par = par->parent(); 1153 par = par->parent();
1161 } 1154 }
1162 if ( !allowReparent ) { 1155 if ( !allowReparent ) {
1163 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1156 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1164 pendingSubtodo = 0; 1157 pendingSubtodo = 0;
1165 } else { 1158 } else {
1166 Todo* newParent = todoItem->todo(); 1159 Todo* newParent = todoItem->todo();
1167 Todo* newSub = pendingSubtodo->todo(); 1160 Todo* newSub = pendingSubtodo->todo();
1168 pendingSubtodo = 0; 1161 pendingSubtodo = 0;
1169 emit reparentTodoSignal( newParent,newSub ); 1162 emit reparentTodoSignal( newParent,newSub );
1170 return; 1163 return;
1171 } 1164 }
1172 } 1165 }
1173#if 0 1166
1174 // handled by the item itself
1175 bool completed = todoItem->todo()->isCompleted(); // Completed or not?
1176 qDebug("com %d ",completed );
1177 qDebug("itemclicked ");
1178 if (todoItem->isOn()) {
1179 qDebug("on ");
1180 if (!completed) {
1181 qDebug("set true ");
1182 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
1183 }
1184 } else {
1185 qDebug("not on ");
1186 if (completed) {
1187 qDebug("set false ");
1188 todoItem->todo()->setCompleted(false);
1189 }
1190 }
1191#endif
1192} 1167}
1193 1168
1194void KOTodoView::setDocumentId( const QString &id ) 1169void KOTodoView::setDocumentId( const QString &id )
1195{ 1170{
1196 1171
1197 mDocPrefs->setDoc( id ); 1172 mDocPrefs->setDoc( id );
1198} 1173}
1199 1174
1200void KOTodoView::itemStateChanged( QListViewItem *item ) 1175void KOTodoView::itemStateChanged( QListViewItem *item )
1201{ 1176{
1202 if (!item) return; 1177 if (!item) return;
1203 1178
1204 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1179 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1205 1180
1206// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1181// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1207 1182
1208 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1183 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1209} 1184}
1210 1185
1211void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1186void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1212{ 1187{
1213 mTodoListView->saveLayout(config,group); 1188 mTodoListView->saveLayout(config,group);
1214} 1189}
1215 1190
1216void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1191void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1217{ 1192{
1218 mTodoListView->restoreLayout(config,group); 1193 mTodoListView->restoreLayout(config,group);
1219} 1194}
1220 1195
1221void KOTodoView::processSelectionChange() 1196void KOTodoView::processSelectionChange()
1222{ 1197{
1223// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1198// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1224 1199
1225 KOTodoViewItem *item = 1200 KOTodoViewItem *item =
1226 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1201 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1227 1202
1228 if ( !item ) { 1203 if ( !item ) {
1229 emit incidenceSelected( 0 ); 1204 emit incidenceSelected( 0 );
1230 } else { 1205 } else {
1231 emit incidenceSelected( item->todo() ); 1206 emit incidenceSelected( item->todo() );
1232 } 1207 }
1233} 1208}
1234 1209
1235void KOTodoView::modified(bool b) 1210void KOTodoView::modified(bool b)
1236{ 1211{
1237 emit isModified(b); 1212 emit isModified(b);
1238} 1213}
1239void KOTodoView::setTodoModified( Todo* todo ) 1214void KOTodoView::setTodoModified( Todo* todo )
1240{ 1215{
1241 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1216 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1242} 1217}
1243void KOTodoView::clearSelection() 1218void KOTodoView::clearSelection()
1244{ 1219{
1245 mTodoListView->selectAll( false ); 1220 mTodoListView->selectAll( false );
1246} 1221}
1247void KOTodoView::setAllOpen() 1222void KOTodoView::setAllOpen()
1248{ 1223{
1249 if ( isFlatDisplay ) { 1224 if ( isFlatDisplay ) {
1250 isFlatDisplay = false; 1225 isFlatDisplay = false;
1251 mPopupMenu->setItemChecked( 8,false ); 1226 mPopupMenu->setItemChecked( 8,false );
1252 updateView(); 1227 updateView();
1253 } else { 1228 } else {
1254 storeCurrentItem(); 1229 storeCurrentItem();
1255 } 1230 }
1256 setOpen(mTodoListView->firstChild(), true); 1231 setOpen(mTodoListView->firstChild(), true);
1257 resetCurrentItem(); 1232 resetCurrentItem();
1258} 1233}
1259void KOTodoView::setAllClose() 1234void KOTodoView::setAllClose()
1260{ 1235{
1261 if ( isFlatDisplay ) { 1236 if ( isFlatDisplay ) {
1262 isFlatDisplay = false; 1237 isFlatDisplay = false;
1263 mPopupMenu->setItemChecked( 8,false ); 1238 mPopupMenu->setItemChecked( 8,false );
1264 updateView(); 1239 updateView();
1265 } else { 1240 } else {
1266 storeCurrentItem(); 1241 storeCurrentItem();
1267 } 1242 }
1268 setOpen(mTodoListView->firstChild(), false); 1243 setOpen(mTodoListView->firstChild(), false);
1269 resetCurrentItem(); 1244 resetCurrentItem();
1270} 1245}
1271void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1246void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1272{ 1247{
1273 1248
1274 while ( item ) { 1249 while ( item ) {
1275 setOpen( item->firstChild(), setOpenI ); 1250 setOpen( item->firstChild(), setOpenI );
1276 item->setOpen( setOpenI ); 1251 item->setOpen( setOpenI );
1277 item = item->nextSibling(); 1252 item = item->nextSibling();
1278 } 1253 }
1279} 1254}
1280 1255
1281void KOTodoView::displayAllFlat() 1256void KOTodoView::displayAllFlat()
1282{ 1257{
1283 pendingSubtodo = 0; 1258 pendingSubtodo = 0;
1284 if ( mBlockUpdate ) { 1259 if ( mBlockUpdate ) {
1285 return; 1260 return;
1286 } 1261 }
1287 mPopupMenu->setItemChecked( 8,true ); 1262 mPopupMenu->setItemChecked( 8,true );
1288 isFlatDisplay = true; 1263 isFlatDisplay = true;
1289 QPtrList<Todo> todoList = calendar()->todos(); 1264 QPtrList<Todo> todoList = calendar()->todos();
1290 mTodoMap.clear(); 1265 mTodoMap.clear();
1291 mTodoListView->clear(); 1266 mTodoListView->clear();
1292 Todo *todo; 1267 Todo *todo;
1293 for(todo = todoList.first(); todo; todo = todoList.next()) { 1268 for(todo = todoList.first(); todo; todo = todoList.next()) {
1294 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1269 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1295 mTodoMap.insert(todo,todoItem); 1270 mTodoMap.insert(todo,todoItem);
1296 } 1271 }
1297 mTodoListView->setFocus(); 1272 mTodoListView->setFocus();
1298 processSelectionChange(); 1273 processSelectionChange();
1299} 1274}
1300 1275
1301void KOTodoView::setAllFlat() 1276void KOTodoView::setAllFlat()
1302{ 1277{
1303 if ( isFlatDisplay ) { 1278 if ( isFlatDisplay ) {
1304 isFlatDisplay = false; 1279 isFlatDisplay = false;
1305 mPopupMenu->setItemChecked( 8,false ); 1280 mPopupMenu->setItemChecked( 8,false );
1306 updateView(); 1281 updateView();
1307 return; 1282 return;
1308 } 1283 }
1309 storeCurrentItem(); 1284 storeCurrentItem();
1310 displayAllFlat(); 1285 displayAllFlat();
1311 resetCurrentItem(); 1286 resetCurrentItem();
1312} 1287}
1313 1288
1314void KOTodoView::purgeCompleted() 1289void KOTodoView::purgeCompleted()
1315{ 1290{
1316 emit purgeCompletedSignal(); 1291 emit purgeCompletedSignal();
1317 1292
1318} 1293}
1319void KOTodoView::toggleQuickTodo() 1294void KOTodoView::toggleQuickTodo()
1320{ 1295{
1321 if ( mQuickAdd->isVisible() ) { 1296 if ( mQuickAdd->isVisible() ) {
1322 mQuickAdd->hide(); 1297 mQuickAdd->hide();
1323 KOPrefs::instance()->mEnableQuickTodo = false; 1298 KOPrefs::instance()->mEnableQuickTodo = false;
1324 } 1299 }
1325 else { 1300 else {
1326 mQuickAdd->show(); 1301 mQuickAdd->show();
1327 KOPrefs::instance()->mEnableQuickTodo = true; 1302 KOPrefs::instance()->mEnableQuickTodo = true;
1328 } 1303 }
1329 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1304 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1330 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1305 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1331} 1306}
1332 1307
1333void KOTodoView::toggleRunning() 1308void KOTodoView::toggleRunning()
1334{ 1309{
1335 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1310 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1336 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1311 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1337 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1312 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1338 updateView(); 1313 updateView();
1339} 1314}
1340 1315
1341void KOTodoView::toggleCompleted() 1316void KOTodoView::toggleCompleted()
1342{ 1317{
1343 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1318 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1344 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1319 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1345 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1320 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1346 updateView(); 1321 updateView();
1347} 1322}
1348 1323
1349void KOTodoView::addQuickTodo() 1324void KOTodoView::addQuickTodo()
1350{ 1325{
1351 Todo *todo = new Todo(); 1326 Todo *todo = new Todo();
1352 todo->setSummary(mQuickAdd->text()); 1327 todo->setSummary(mQuickAdd->text());
1353 todo->setOrganizer(KOPrefs::instance()->email()); 1328 todo->setOrganizer(KOPrefs::instance()->email());
1354 CalFilter * cf = mCalendar->filter(); 1329 CalFilter * cf = mCalendar->filter();
1355 if ( cf ) { 1330 if ( cf ) {
1356 if ( cf->isEnabled()&& cf->showCategories()) { 1331 if ( cf->isEnabled()&& cf->showCategories()) {
1357 todo->setCategories(cf->categoryList()); 1332 todo->setCategories(cf->categoryList());
1358 } 1333 }
1359 if ( cf->isEnabled() ) 1334 if ( cf->isEnabled() )
1360 todo->setSecrecy( cf->getSecrecy()); 1335 todo->setSecrecy( cf->getSecrecy());
1361 } 1336 }
1362 mCalendar->addTodo(todo); 1337 mCalendar->addTodo(todo);
1363 mQuickAdd->setText(""); 1338 mQuickAdd->setText("");
1364 todoModified (todo, KOGlobals::EVENTADDED ); 1339 todoModified (todo, KOGlobals::EVENTADDED );
1365 updateView(); 1340 updateView();
1366} 1341}
1367 1342
1368void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1343void KOTodoView::keyPressEvent ( QKeyEvent * e )
1369{ 1344{
1370 // e->ignore(); 1345 // e->ignore();
1371 //return; 1346 //return;
1372 //qDebug("KOTodoView::keyPressEvent "); 1347 //qDebug("KOTodoView::keyPressEvent ");
1373 switch ( e->key() ) { 1348 switch ( e->key() ) {
1374 case Qt::Key_Down: 1349 case Qt::Key_Down:
1375 case Qt::Key_Up: 1350 case Qt::Key_Up:
1376 QWidget::keyPressEvent ( e ); 1351 QWidget::keyPressEvent ( e );
1377 break; 1352 break;
1378 1353
1379 case Qt::Key_Q: 1354 case Qt::Key_Q:
1380 toggleQuickTodo(); 1355 toggleQuickTodo();
1381 break; 1356 break;
1382 case Qt::Key_U: 1357 case Qt::Key_U:
1383 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1358 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1384 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1359 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1385 unparentTodo(); 1360 unparentTodo();
1386 e->accept(); 1361 e->accept();
1387 } else 1362 } else
1388 e->ignore(); 1363 e->ignore();
1389 break; 1364 break;
1390 case Qt::Key_S: 1365 case Qt::Key_S:
1391 if ( e->state() == Qt::ControlButton ) { 1366 if ( e->state() == Qt::ControlButton ) {
1392 e->ignore(); 1367 e->ignore();
1393 break; 1368 break;
1394 } 1369 }
1395 if ( e->state() == Qt::ShiftButton ) { 1370 if ( e->state() == Qt::ShiftButton ) {
1396 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1371 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1397 reparentTodo(); 1372 reparentTodo();
1398 e->accept(); 1373 e->accept();
1399 } else 1374 } else
1400 e->ignore(); 1375 e->ignore();
1401 break; 1376 break;
1402 case Qt::Key_P: 1377 case Qt::Key_P:
1403 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1378 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1404 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1379 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1405 if ( pendingSubtodo ) 1380 if ( pendingSubtodo )
1406 itemClicked(mActiveItem); 1381 itemClicked(mActiveItem);
1407 e->accept(); 1382 e->accept();
1408 } else 1383 } else
1409 e->ignore(); 1384 e->ignore();
1410 break; 1385 break;
1411 case Qt::Key_Escape: 1386 case Qt::Key_Escape:
1412 if ( pendingSubtodo ) { 1387 if ( pendingSubtodo ) {
1413 itemClicked(0); 1388 itemClicked(0);
1414 e->accept(); 1389 e->accept();
1415 } else 1390 } else
1416 e->ignore(); 1391 e->ignore();
1417 break; 1392 break;
1418 default: 1393 default:
1419 e->ignore(); 1394 e->ignore();
1420 } 1395 }
1421 1396
1422 if ( true ) { 1397 if ( true ) {
1423 if ( e->key() == Qt::Key_I ) { 1398 if ( e->key() == Qt::Key_I ) {
1424 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1399 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1425 if ( cn ) { 1400 if ( cn ) {
1426 mActiveItem = cn; 1401 mActiveItem = cn;
1427 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1402 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1428 if ( ci ){ 1403 if ( ci ){
1429 showTodo(); 1404 showTodo();
1430 cn = (KOTodoViewItem*)cn->itemBelow(); 1405 cn = (KOTodoViewItem*)cn->itemBelow();
1431 if ( cn ) { 1406 if ( cn ) {
1432 mTodoListView->setCurrentItem ( cn ); 1407 mTodoListView->setCurrentItem ( cn );
1433 mTodoListView->ensureItemVisible ( cn ); 1408 mTodoListView->ensureItemVisible ( cn );
1434 } 1409 }
1435 1410
1436 } 1411 }
1437 } 1412 }
1438 e->accept(); 1413 e->accept();
1439 1414
1440 } 1415 }
1441 1416
1442 } 1417 }
1443 1418
1444} 1419}
1445void KOTodoView::updateTodo( Todo * t, int type ) 1420void KOTodoView::updateTodo( Todo * t, int type )
1446{ 1421{
1447 if ( mBlockUpdate) 1422 if ( mBlockUpdate)
1448 return; 1423 return;
1449 1424
1450 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1425 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1451 itemIterator = mTodoMap.find(t); 1426 itemIterator = mTodoMap.find(t);
1452 if (itemIterator != mTodoMap.end()) { 1427 if (itemIterator != mTodoMap.end()) {
1453 (*itemIterator)->construct(); 1428 (*itemIterator)->construct();
1454 } else { 1429 } else {
1455 if ( type == KOGlobals::EVENTADDED ) { 1430 if ( type == KOGlobals::EVENTADDED ) {
1456 insertTodoItem( t ); 1431 insertTodoItem( t );
1457 } 1432 }
1458 } 1433 }
1459 1434
1460} 1435}
1461 1436
1462void KOTodoView::todoModified(Todo * t , int p ) 1437void KOTodoView::todoModified(Todo * t , int p )
1463{ 1438{
1464 mBlockUpdate = true; 1439 mBlockUpdate = true;
1465 emit todoModifiedSignal ( t, p ); 1440 emit todoModifiedSignal ( t, p );
1466 mBlockUpdate = false; 1441 mBlockUpdate = false;
1467} 1442}
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index f1f2dd2..3aa9b6c 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,834 +1,826 @@
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 flagResetViewChangeDate = 0; 64 flagResetViewChangeDate = 0;
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->dateNavigator()->selectDate( date ); 131 mMainView->dateNavigator()->selectDate( date );
132 lastMode = 1; 132 lastMode = 1;
133 mCurrentAgendaView = 1 ; 133 mCurrentAgendaView = 1 ;
134 } else if (view == 4 ) { 134 } else if (view == 4 ) {
135 mCurrentAgendaView = 7 ; 135 mCurrentAgendaView = 7 ;
136 mMainView->dateNavigator()->selectDates( date, 7 ); 136 mMainView->dateNavigator()->selectDates( date, 7 );
137 } else if (view == 5 ) { 137 } else if (view == 5 ) {
138 mCurrentAgendaView = 14 ; 138 mCurrentAgendaView = 14 ;
139 mMainView->dateNavigator()->selectDates( date, 14); 139 mMainView->dateNavigator()->selectDates( date, 14);
140 } else if (view == 6 ) { 140 } else if (view == 6 ) {
141 resetDateSilent( date,1); 141 resetDateSilent( date,1);
142 showMonthView(); 142 showMonthView();
143 } else if (view == 7 ) { 143 } else if (view == 7 ) {
144 mMainView->dateNavigator()->selectDate( date ); 144 mMainView->dateNavigator()->selectDate( date );
145 showJournalView(); 145 showJournalView();
146 } else if (view == 8 ) { 146 } else if (view == 8 ) {
147 globalFlagBlockAgenda = 1; 147 globalFlagBlockAgenda = 1;
148 if ( mCurrentAgendaView != 3 ) 148 if ( mCurrentAgendaView != 3 )
149 mCurrentAgendaView = -1; 149 mCurrentAgendaView = -1;
150 showAgendaView(KOPrefs::instance()->mFullViewMonth); 150 showAgendaView(KOPrefs::instance()->mFullViewMonth);
151 globalFlagBlockAgenda = 2; 151 globalFlagBlockAgenda = 2;
152 mMainView->dateNavigator()->selectDates( date , 152 mMainView->dateNavigator()->selectDates( date ,
153 KOPrefs::instance()->mNextXDays ); 153 KOPrefs::instance()->mNextXDays );
154 mFlagShowNextxDays = true; 154 mFlagShowNextxDays = true;
155 mCurrentAgendaView = 3 ; 155 mCurrentAgendaView = 3 ;
156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
157 if ( lastMode ) { 157 if ( lastMode ) {
158 mCurrentAgendaView = lastCount ; 158 mCurrentAgendaView = lastCount ;
159 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 159 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
160 mFlagShowNextxDays = lastNDMode; 160 mFlagShowNextxDays = lastNDMode;
161 if ( mFlagShowNextxDays ) { 161 if ( mFlagShowNextxDays ) {
162 mCurrentAgendaView = 3 ; 162 mCurrentAgendaView = 3 ;
163 } 163 }
164 } else 164 } else
165 showWeekView(); 165 showWeekView();
166 } else if (view == 10) { 166 } else if (view == 10) {
167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
168 } 168 }
169} 169}
170 170
171 171
172 172
173void KOViewManager::writeSettings(KConfig *config) 173void KOViewManager::writeSettings(KConfig *config)
174{ 174{
175 config->setGroup("General"); 175 config->setGroup("General");
176 176
177 QString view; 177 QString view;
178 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 178 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
179 else if (mCurrentView == mMonthView) view = "Month"; 179 else if (mCurrentView == mMonthView) view = "Month";
180 else if (mCurrentView == mListView) view = "List"; 180 else if (mCurrentView == mListView) view = "List";
181 else if (mCurrentView == mJournalView) view = "Journal"; 181 else if (mCurrentView == mJournalView) view = "Journal";
182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
183 else if (mCurrentView == mTodoView) view = "Todo"; 183 else if (mCurrentView == mTodoView) view = "Todo";
184 else view = "Agenda"; 184 else view = "Agenda";
185 185
186 config->writeEntry("Current View",view); 186 config->writeEntry("Current View",view);
187 187
188 if (mAgendaView) { 188 if (mAgendaView) {
189 mAgendaView->writeSettings(config); 189 mAgendaView->writeSettings(config);
190 } 190 }
191 if (mTimeSpanView) { 191 if (mTimeSpanView) {
192 mTimeSpanView->writeSettings(config); 192 mTimeSpanView->writeSettings(config);
193 } 193 }
194 if (mListView) { 194 if (mListView) {
195 mListView->writeSettings(config); 195 mListView->writeSettings(config);
196 } 196 }
197 if (mTodoView) { 197 if (mTodoView) {
198 mTodoView->saveLayout(config,"Todo View"); 198 mTodoView->saveLayout(config,"Todo View");
199 } 199 }
200} 200}
201void KOViewManager::showNextView() 201void KOViewManager::showNextView()
202{ 202{
203 static int selecteddatescount = 0; 203 static int selecteddatescount = 0;
204 static QDate selecteddate = QDate ( 2000, 1, 1 ); 204 static QDate selecteddate = QDate ( 2000, 1, 1 );
205 static QDate baseCycleDate = QDate ( 2000, 1, 1 ); 205 static QDate baseCycleDate = QDate ( 2000, 1, 1 );
206 int newCount = mMainView->dateNavigator()->selectedDates().count(); 206 int newCount = mMainView->dateNavigator()->selectedDates().count();
207 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { 207 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) {
208 flagResetViewChangeDate = 1; 208 flagResetViewChangeDate = 1;
209 } 209 }
210 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) 210 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() )
211 flagResetViewChangeDate = 1; 211 flagResetViewChangeDate = 1;
212 if ( flagResetViewChangeDate > 0 ) { 212 if ( flagResetViewChangeDate > 0 ) {
213 baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); 213 baseCycleDate = mMainView->dateNavigator()->selectedDates().first();
214 //qDebug("newCycle "); 214 //qDebug("newCycle ");
215 } 215 }
216 if (mCurrentView == mWhatsNextView) goto NEXT_X; 216 if (mCurrentView == mWhatsNextView) goto NEXT_X;
217 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; 217 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL;
218 if (mCurrentView == mJournalView ) goto DAY_1; 218 if (mCurrentView == mJournalView ) goto DAY_1;
219 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; 219 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5;
220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; 220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7;
221 if (mCurrentView == mAgendaView ) goto DAY_6; 221 if (mCurrentView == mAgendaView ) goto DAY_6;
222 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; 222 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH;
223 if (mCurrentView == mMonthView ) goto LIST; 223 if (mCurrentView == mMonthView ) goto LIST;
224 if (mCurrentView == mListView ) goto TODO; 224 if (mCurrentView == mListView ) goto TODO;
225 // if (mCurrentView == mTodoView ) goto NEXT; 225 // if (mCurrentView == mTodoView ) goto NEXT;
226 NEXT: 226 NEXT:
227 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} 227 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;}
228 NEXT_X: 228 NEXT_X:
229 if ( KOPrefs::instance()->mShowIconNextDays ) { 229 if ( KOPrefs::instance()->mShowIconNextDays ) {
230 showNextXView(); 230 showNextXView();
231 goto ENTE ; 231 goto ENTE ;
232 } 232 }
233 JOURNAL: 233 JOURNAL:
234 if ( KOPrefs::instance()->mShowIconJournal ) { 234 if ( KOPrefs::instance()->mShowIconJournal ) {
235 resetDateSilent( baseCycleDate , 1 ); 235 resetDateSilent( baseCycleDate , 1 );
236 showJournalView() ;goto ENTE ;} 236 showJournalView() ;goto ENTE ;}
237 DAY_1: 237 DAY_1:
238 if ( KOPrefs::instance()->mShowIconDay1 ) { 238 if ( KOPrefs::instance()->mShowIconDay1 ) {
239 resetDateSilent( baseCycleDate , 2 ); 239 resetDateSilent( baseCycleDate , 2 );
240 showDayView() ;goto ENTE ;} 240 showDayView() ;goto ENTE ;}
241 DAY_5: 241 DAY_5:
242 if ( KOPrefs::instance()->mShowIconDay5 ) { 242 if ( KOPrefs::instance()->mShowIconDay5 ) {
243 resetDateSilent( baseCycleDate , 2 ); 243 resetDateSilent( baseCycleDate , 2 );
244 showWorkWeekView() ;goto ENTE ;} 244 showWorkWeekView() ;goto ENTE ;}
245 DAY_7: 245 DAY_7:
246 if ( KOPrefs::instance()->mShowIconDay7 ) { 246 if ( KOPrefs::instance()->mShowIconDay7 ) {
247 resetDateSilent( baseCycleDate , 2 ); 247 resetDateSilent( baseCycleDate , 2 );
248 showWeekView();goto ENTE ;} 248 showWeekView();goto ENTE ;}
249 DAY_6: 249 DAY_6:
250 if ( KOPrefs::instance()->mShowIconDay6 ) { 250 if ( KOPrefs::instance()->mShowIconDay6 ) {
251 resetDateSilent( baseCycleDate , 2 ); 251 resetDateSilent( baseCycleDate , 2 );
252 showMonthViewWeek();goto ENTE ;} 252 showMonthViewWeek();goto ENTE ;}
253 MONTH: 253 MONTH:
254 if ( KOPrefs::instance()->mShowIconMonth ) { 254 if ( KOPrefs::instance()->mShowIconMonth ) {
255 resetDateSilent( baseCycleDate , 2 ); 255 resetDateSilent( baseCycleDate , 2 );
256 showMonthView();goto ENTE ;} 256 showMonthView();goto ENTE ;}
257 LIST: 257 LIST:
258 if ( KOPrefs::instance()->mShowIconList ) { 258 if ( KOPrefs::instance()->mShowIconList ) {
259 resetDateSilent( baseCycleDate , 2 ); 259 resetDateSilent( baseCycleDate , 2 );
260 showListView() ;goto ENTE ;} 260 showListView() ;goto ENTE ;}
261 TODO: 261 TODO:
262 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 262 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
263 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;} 263 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;}
264 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;} 264 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;}
265 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;} 265 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;}
266 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;} 266 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;}
267 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;} 267 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;}
268 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;} 268 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;}
269 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;} 269 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;}
270 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;} 270 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;}
271 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;} 271 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;}
272 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 272 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
273 ENTE: 273 ENTE:
274 flagResetViewChangeDate = 0; 274 flagResetViewChangeDate = 0;
275 selecteddatescount = mMainView->dateNavigator()->selectedDates().count(); 275 selecteddatescount = mMainView->dateNavigator()->selectedDates().count();
276 selecteddate = mMainView->dateNavigator()->selectedDates().first(); 276 selecteddate = mMainView->dateNavigator()->selectedDates().first();
277 277
278} 278}
279void KOViewManager::resetDateSilent( QDate date , int days ) 279void KOViewManager::resetDateSilent( QDate date , int days )
280{ 280{
281 mMainView->dateNavigator()->blockSignals( true ); 281 mMainView->dateNavigator()->blockSignals( true );
282 mMainView->dateNavigator()->selectDates( date , days ); 282 mMainView->dateNavigator()->selectDates( date , days );
283 mMainView->dateNavigator()->blockSignals( false ); 283 mMainView->dateNavigator()->blockSignals( false );
284} 284}
285void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 285void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
286{ 286{
287 if ( flagResetViewChangeDate < 10 ) 287 if ( flagResetViewChangeDate < 10 )
288 ++flagResetViewChangeDate; 288 ++flagResetViewChangeDate;
289 //mFlagShowNextxDays = false; 289 //mFlagShowNextxDays = false;
290 //if(view == mCurrentView) return; 290 //if(view == mCurrentView) return;
291 if ( view == 0 ) { 291 if ( view == 0 ) {
292 view = mCurrentView; 292 view = mCurrentView;
293 if ( view == 0 ) 293 if ( view == 0 )
294 return; 294 return;
295 } 295 }
296 bool callupdate = !(view == mCurrentView); 296 bool callupdate = !(view == mCurrentView);
297 bool full = fullScreen; 297 bool full = fullScreen;
298 if(view == mCurrentView && view != mWhatsNextView ) { 298 if(view == mCurrentView && view != mWhatsNextView ) {
299 if ( mCurrentAgendaView < 0 ) 299 if ( mCurrentAgendaView < 0 )
300 return; 300 return;
301 if ( view != mMonthView ) 301 if ( view != mMonthView )
302 full = mMainView->leftFrame()->isVisible(); 302 full = mMainView->leftFrame()->isVisible();
303 } else { 303 } else {
304 if ( view == mMonthView && mMonthView) 304 if ( view == mMonthView && mMonthView)
305 ;//mMonthView->skipResize = true ; 305 ;//mMonthView->skipResize = true ;
306 mCurrentView = view; 306 mCurrentView = view;
307 // bool full = fullScreen; 307 // bool full = fullScreen;
308 bool isFull = !mMainView->leftFrame()->isVisible(); 308 bool isFull = !mMainView->leftFrame()->isVisible();
309 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 309 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
310 full = true; 310 full = true;
311 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 311 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
312 full = false; 312 full = false;
313 } 313 }
314 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 314 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
315 //raiseCurrentView( full ); 315 //raiseCurrentView( full );
316 mMainView->processIncidenceSelection( 0 ); 316 mMainView->processIncidenceSelection( 0 );
317 //mMainView->updateView(); 317 //mMainView->updateView();
318 raiseCurrentView( full, callupdate ); 318 raiseCurrentView( full, callupdate );
319 mMainView->adaptNavigationUnits(); 319 mMainView->adaptNavigationUnits();
320} 320}
321 321
322void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 322void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
323{ 323{
324 mCurrentAgendaView = 0; 324 mCurrentAgendaView = 0;
325 if ( fullScreen ) { 325 if ( fullScreen ) {
326 mMainView->leftFrame()->hide(); 326 mMainView->leftFrame()->hide();
327 } else { 327 } else {
328 mMainView->leftFrame()->show(); 328 mMainView->leftFrame()->show();
329 } 329 }
330 //if ( mCurrentView == mMonthView ) qApp->processEvents(); 330 //if ( mCurrentView == mMonthView ) qApp->processEvents();
331 emit signalFullScreen( !fullScreen ); 331 emit signalFullScreen( !fullScreen );
332 if ( callUpdateView ) 332 if ( callUpdateView )
333 mMainView->updateView(); 333 mMainView->updateView();
334 334
335 if ( globalFlagBlockAgenda == 5 ) { 335 if ( globalFlagBlockAgenda == 5 ) {
336 globalFlagBlockAgenda = 4; 336 globalFlagBlockAgenda = 4;
337 globalFlagBlockAgendaItemPaint = 1; 337 globalFlagBlockAgendaItemPaint = 1;
338 } 338 }
339 mMainView->viewStack()->raiseWidget(mCurrentView); 339 mMainView->viewStack()->raiseWidget(mCurrentView);
340 if ( globalFlagBlockAgenda == 4 ) { 340 if ( globalFlagBlockAgenda == 4 ) {
341 if ( mCurrentView == mAgendaView ) { 341 if ( mCurrentView == mAgendaView ) {
342 //globalFlagBlockAgenda =1 ; 342 //globalFlagBlockAgenda =1 ;
343 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 343 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
344 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 344 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
345 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 345 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
346 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 346 mAgendaView->setStartHour( QTime::currentTime ().hour() );
347 qApp->processEvents(); 347 qApp->processEvents();
348 //qDebug("qApp->processEvents() "); 348 //qDebug("qApp->processEvents() ");
349 globalFlagBlockAgenda = 0; 349 globalFlagBlockAgenda = 0;
350 mAgendaView->repaintAgenda(); 350 mAgendaView->repaintAgenda();
351 351
352 } 352 }
353 globalFlagBlockAgenda = 0; 353 globalFlagBlockAgenda = 0;
354 } 354 }
355 emit signalAgendaView( mCurrentView == mAgendaView ); 355 emit signalAgendaView( mCurrentView == mAgendaView );
356 //qDebug("raiseCurrentView ende "); 356 //qDebug("raiseCurrentView ende ");
357 357
358} 358}
359 359
360void KOViewManager::updateView() 360void KOViewManager::updateView()
361{ 361{
362 // qDebug("KOViewManager::updateView() "); 362 // qDebug("KOViewManager::updateView() ");
363 // if we are updating mTodoView, we get endless recursion 363 // if we are updating mTodoView, we get endless recursion
364 if ( mTodoView == mCurrentView ) 364 if ( mTodoView == mCurrentView )
365 return; 365 return;
366 if ( mCurrentView ) mCurrentView->updateView(); 366 if ( mCurrentView ) mCurrentView->updateView();
367 367
368} 368}
369 369
370void KOViewManager::updateView(const QDate &start, const QDate &end) 370void KOViewManager::updateView(const QDate &start, const QDate &end)
371{ 371{
372 // kdDebug() << "KOViewManager::updateView()" << endl; 372 // kdDebug() << "KOViewManager::updateView()" << endl;
373 373
374 if (mCurrentView) mCurrentView->showDates(start, end); 374 if (mCurrentView) mCurrentView->showDates(start, end);
375 375
376 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 376 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
377} 377}
378 378
379 379
380void KOViewManager::updateWNview() 380void KOViewManager::updateWNview()
381{ 381{
382 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 382 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
383 mWhatsNextView->updateView(); 383 mWhatsNextView->updateView();
384 if ( mCurrentView == mMonthView && mMonthView ) 384 if ( mCurrentView == mMonthView && mMonthView )
385 mMonthView->updateView(); 385 mMonthView->updateView();
386 386
387} 387}
388void KOViewManager::showWhatsNextView() 388void KOViewManager::showWhatsNextView()
389{ 389{
390 if (!mWhatsNextView) { 390 if (!mWhatsNextView) {
391 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 391 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
392 "KOViewManager::WhatsNextView"); 392 "KOViewManager::WhatsNextView");
393 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 393 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
394 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 394 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
395 addView(mWhatsNextView); 395 addView(mWhatsNextView);
396 connect(this, SIGNAL( printWNV() ), 396 connect(this, SIGNAL( printWNV() ),
397 mWhatsNextView, SLOT( printMe() ) ); 397 mWhatsNextView, SLOT( printMe() ) );
398 } 398 }
399 globalFlagBlockAgenda = 1; 399 globalFlagBlockAgenda = 1;
400 showView(mWhatsNextView, true ); 400 showView(mWhatsNextView, true );
401 //mWhatsNextView->updateView(); 401 //mWhatsNextView->updateView();
402 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; 402 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
403} 403}
404 404
405void KOViewManager::slotprintWNV() 405void KOViewManager::slotprintWNV()
406{ 406{
407 if (!mWhatsNextView) 407 if (!mWhatsNextView)
408 showWhatsNextView(); 408 showWhatsNextView();
409 emit printWNV(); 409 emit printWNV();
410 410
411} 411}
412void KOViewManager::showListView() 412void KOViewManager::showListView()
413{ 413{
414 if (!mListView) { 414 if (!mListView) {
415 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 415 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
416 addView(mListView); 416 addView(mListView);
417 417
418 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 418 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
419 mMainView, SLOT(showIncidence(Incidence *))); 419 mMainView, SLOT(showIncidence(Incidence *)));
420 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 420 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
421 mMainView, SLOT(editIncidence(Incidence *))); 421 mMainView, SLOT(editIncidence(Incidence *)));
422 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 422 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
423 mMainView, SLOT(deleteIncidence(Incidence *))); 423 mMainView, SLOT(deleteIncidence(Incidence *)));
424 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 424 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
425 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 425 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
426 connect( mListView, SIGNAL( signalNewEvent() ), 426 connect( mListView, SIGNAL( signalNewEvent() ),
427 mMainView, SLOT( newEvent() ) ); 427 mMainView, SLOT( newEvent() ) );
428 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 428 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
429 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 429 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
430 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 430 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
431 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 431 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
432 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 432 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
433 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 433 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
434 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 434 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
435 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 435 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
436 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 436 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
437 } 437 }
438 // bool temp = mFlagShowNextxDays; 438 // bool temp = mFlagShowNextxDays;
439 //globalFlagBlockPainting = true; 439 //globalFlagBlockPainting = true;
440 globalFlagBlockAgenda = 1; 440 globalFlagBlockAgenda = 1;
441 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 441 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
442 mMainView->setBlockShowDates( true ); 442 mMainView->setBlockShowDates( true );
443 mMainView->dateNavigator()->selectMonth(); 443 mMainView->dateNavigator()->selectMonth();
444 mMainView->setBlockShowDates( false ); 444 mMainView->setBlockShowDates( false );
445 } 445 }
446 showView(mListView, KOPrefs::instance()->mFullViewTodo); 446 showView(mListView, KOPrefs::instance()->mFullViewTodo);
447 //mFlagShowNextxDays = temp; 447 //mFlagShowNextxDays = temp;
448 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; 448 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
449} 449}
450 450
451void KOViewManager::showAgendaView( bool fullScreen ) 451void KOViewManager::showAgendaView( bool fullScreen )
452{ 452{
453 453
454 mMainView->dialogManager()->hideSearchDialog(); 454 mMainView->dialogManager()->hideSearchDialog();
455 // qDebug("KOViewManager::showAgendaView "); 455 // qDebug("KOViewManager::showAgendaView ");
456 bool full; 456 bool full;
457 full = fullScreen; 457 full = fullScreen;
458 if (!mAgendaView) { 458 if (!mAgendaView) {
459 full = false; 459 full = false;
460 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 460 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
461 addView(mAgendaView); 461 addView(mAgendaView);
462#ifndef DESKTOP_VERSION 462#ifndef DESKTOP_VERSION
463 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 463 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
464#endif 464#endif
465 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 465 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
466 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 466 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
467 467
468 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 468 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
469 469
470 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 470 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
471 471
472 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 472 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
473 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 473 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
474 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 474 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
475 mMainView, SLOT(newEvent(QDateTime))); 475 mMainView, SLOT(newEvent(QDateTime)));
476 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 476 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
477 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 477 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
478 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 478 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
479 mMainView, SLOT(newEvent(QDate))); 479 mMainView, SLOT(newEvent(QDate)));
480 480
481 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 481 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
482 mMainView, SLOT(editIncidence(Incidence *))); 482 mMainView, SLOT(editIncidence(Incidence *)));
483 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 483 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
484 mMainView, SLOT(showIncidence(Incidence *))); 484 mMainView, SLOT(showIncidence(Incidence *)));
485 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 485 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
486 mMainView, SLOT(deleteIncidence(Incidence *))); 486 mMainView, SLOT(deleteIncidence(Incidence *)));
487 487
488 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 488 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
489 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 489 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
490 490
491 connect(mAgendaView, SIGNAL( toggleExpand() ), 491 connect(mAgendaView, SIGNAL( toggleExpand() ),
492 mMainView, SLOT( toggleExpand() ) ); 492 mMainView, SLOT( toggleExpand() ) );
493 493
494 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 494 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
495 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 495 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
496 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 496 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
497 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 497 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
498 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 498 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
499 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 499 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
500 SLOT( updateTodo( Todo *, int ) ) ); 500 SLOT( updateTodo( Todo *, int ) ) );
501 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 501 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
502 mMainView, SIGNAL( todoModified( Todo *, int ))); 502 mMainView, SIGNAL( todoModified( Todo *, int )));
503 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 503 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
504 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 504 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
505 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 505 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
506 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 506 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
507 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), 507 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
508 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 508 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
509 mAgendaView->readSettings(); 509 mAgendaView->readSettings();
510 mAgendaView->updateConfig(); 510 mAgendaView->updateConfig();
511 } 511 }
512 512
513 showView( mAgendaView, full); 513 showView( mAgendaView, full);
514 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; 514 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW;
515} 515}
516 516
517void KOViewManager::showDayView() 517void KOViewManager::showDayView()
518{ 518{
519 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 519 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
520 mFlagShowNextxDays = false; 520 mFlagShowNextxDays = false;
521 globalFlagBlockLabel = 1; 521 globalFlagBlockLabel = 1;
522 globalFlagBlockAgenda = 1; 522 globalFlagBlockAgenda = 1;
523 if ( mCurrentAgendaView != 1 ) 523 if ( mCurrentAgendaView != 1 )
524 mCurrentAgendaView = -1; 524 mCurrentAgendaView = -1;
525 showAgendaView(); 525 showAgendaView();
526 qApp->processEvents(); 526 qApp->processEvents();
527 globalFlagBlockAgenda = 2; 527 globalFlagBlockAgenda = 2;
528 globalFlagBlockLabel = 0; 528 globalFlagBlockLabel = 0;
529 mMainView->dateNavigator()->selectDates( 1 ); 529 mMainView->dateNavigator()->selectDates( 1 );
530 mCurrentAgendaView = 1 ; 530 mCurrentAgendaView = 1 ;
531 531
532} 532}
533 533
534void KOViewManager::showWorkWeekView() 534void KOViewManager::showWorkWeekView()
535{ 535{
536 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 536 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
537 mFlagShowNextxDays = false; 537 mFlagShowNextxDays = false;
538 globalFlagBlockAgenda = 1; 538 globalFlagBlockAgenda = 1;
539 globalFlagBlockLabel = 1; 539 globalFlagBlockLabel = 1;
540 if ( mCurrentAgendaView != 5 ) 540 if ( mCurrentAgendaView != 5 )
541 mCurrentAgendaView = -1; 541 mCurrentAgendaView = -1;
542 showAgendaView(); 542 showAgendaView();
543 qApp->processEvents(); 543 qApp->processEvents();
544 globalFlagBlockAgenda = 2; 544 globalFlagBlockAgenda = 2;
545 globalFlagBlockLabel = 0; 545 globalFlagBlockLabel = 0;
546 mMainView->dateNavigator()->selectWorkWeek(); 546 mMainView->dateNavigator()->selectWorkWeek();
547 mCurrentAgendaView = 5 ; 547 mCurrentAgendaView = 5 ;
548 548
549} 549}
550 550
551void KOViewManager::showWeekView() 551void KOViewManager::showWeekView()
552{ 552{
553 /* 553
554 globalFlagBlockAgenda = 2;
555 qDebug("4globalFlagBlockAgenda = 2; ");
556 //globalFlagBlockPainting = true;
557 mMainView->dateNavigator()->selectWeek();
558 showAgendaView();
559 */
560
561
562 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 554 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
563 mFlagShowNextxDays = false; 555 mFlagShowNextxDays = false;
564 globalFlagBlockAgenda = 1; 556 globalFlagBlockAgenda = 1;
565 globalFlagBlockLabel = 1; 557 globalFlagBlockLabel = 1;
566 if ( mCurrentAgendaView != 7 ) 558 if ( mCurrentAgendaView != 7 )
567 mCurrentAgendaView = -1; 559 mCurrentAgendaView = -1;
568 showAgendaView(); 560 showAgendaView();
569 qApp->processEvents(); 561 qApp->processEvents();
570 globalFlagBlockAgenda = 2; 562 globalFlagBlockAgenda = 2;
571 globalFlagBlockLabel = 0; 563 globalFlagBlockLabel = 0;
572 mMainView->dateNavigator()->selectWeek(); 564 mMainView->dateNavigator()->selectWeek();
573 mCurrentAgendaView = 7 ; 565 mCurrentAgendaView = 7 ;
574} 566}
575 567
576void KOViewManager::showNextXView() 568void KOViewManager::showNextXView()
577{ 569{
578 570
579 globalFlagBlockAgenda = 1; 571 globalFlagBlockAgenda = 1;
580 if ( mCurrentAgendaView != 3 ) 572 if ( mCurrentAgendaView != 3 )
581 mCurrentAgendaView = -1; 573 mCurrentAgendaView = -1;
582 showAgendaView(KOPrefs::instance()->mFullViewMonth); 574 showAgendaView(KOPrefs::instance()->mFullViewMonth);
583 globalFlagBlockAgenda = 2; 575 globalFlagBlockAgenda = 2;
584 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 576 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
585 KOPrefs::instance()->mNextXDays ); 577 KOPrefs::instance()->mNextXDays );
586 mFlagShowNextxDays = true; 578 mFlagShowNextxDays = true;
587 mCurrentAgendaView = 3 ; 579 mCurrentAgendaView = 3 ;
588 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; 580 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW;
589} 581}
590bool KOViewManager::showsNextDays() 582bool KOViewManager::showsNextDays()
591{ 583{
592 return mFlagShowNextxDays; 584 return mFlagShowNextxDays;
593} 585}
594void KOViewManager::createMonthView() 586void KOViewManager::createMonthView()
595{ 587{
596if (!mMonthView) { 588if (!mMonthView) {
597 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 589 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
598 590
599 addView(mMonthView); 591 addView(mMonthView);
600 // mMonthView->show(); 592 // mMonthView->show();
601 // SIGNALS/SLOTS FOR MONTH VIEW 593 // SIGNALS/SLOTS FOR MONTH VIEW
602 594
603 connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate ))); 595 connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate )));
604 596
605 connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)), 597 connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)),
606 mMainView, SLOT(newTodoDateTime(QDateTime, bool))); 598 mMainView, SLOT(newTodoDateTime(QDateTime, bool)));
607 599
608 600
609 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 601 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
610 mMainView, SLOT(newEvent(QDateTime))); 602 mMainView, SLOT(newEvent(QDateTime)));
611 603
612 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 604 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
613 mMainView, SLOT(showIncidence(Incidence *))); 605 mMainView, SLOT(showIncidence(Incidence *)));
614 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 606 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
615 mMainView, SLOT(editIncidence(Incidence *))); 607 mMainView, SLOT(editIncidence(Incidence *)));
616 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 608 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
617 mMainView, SLOT(deleteIncidence(Incidence *))); 609 mMainView, SLOT(deleteIncidence(Incidence *)));
618 610
619 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 611 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
620 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 612 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
621 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 613 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
622 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 614 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
623 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 615 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
624 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 616 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
625 617
626 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 618 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
627 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 619 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
628 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 620 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
629 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 621 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
630 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 622 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
631 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); 623 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) );
632 connect( mMonthView, SIGNAL( selectMonth() ), 624 connect( mMonthView, SIGNAL( selectMonth() ),
633 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); 625 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) );
634 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 626 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
635 mMainView, SLOT ( showDay( QDate ) ) ); 627 mMainView, SLOT ( showDay( QDate ) ) );
636 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 628 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
637 connect( mMonthView, SIGNAL(nextMonth() ), 629 connect( mMonthView, SIGNAL(nextMonth() ),
638 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); 630 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
639 connect( mMonthView, SIGNAL(prevMonth() ), 631 connect( mMonthView, SIGNAL(prevMonth() ),
640 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 632 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
641 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), 633 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
642 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); 634 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
643 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), 635 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
644 mMainView->dateNavigator(), SLOT( selectNextYear() ) ); 636 mMainView->dateNavigator(), SLOT( selectNextYear() ) );
645 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), 637 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
646 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); 638 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
647 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), 639 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
648 mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); 640 mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
649 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), 641 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ),
650 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); 642 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) );
651 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), 643 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ),
652 mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); 644 mMainView->dateNavigator(), SLOT( selectNextWeek() ) );
653 645
654 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 646 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
655 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); 647 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
656 648
657 649
658 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), 650 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ),
659 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); 651 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) );
660 652
661 } 653 }
662} 654}
663void KOViewManager::showMonthViewWeek() 655void KOViewManager::showMonthViewWeek()
664{ 656{
665 createMonthView(); 657 createMonthView();
666 globalFlagBlockAgenda = 1; 658 globalFlagBlockAgenda = 1;
667 bool full = true; 659 bool full = true;
668 if ( mCurrentView == mMonthView) 660 if ( mCurrentView == mMonthView)
669 full = mMainView->leftFrame()->isVisible(); 661 full = mMainView->leftFrame()->isVisible();
670 if ( !KOPrefs::instance()->mMonthViewWeek ) { 662 if ( !KOPrefs::instance()->mMonthViewWeek ) {
671 mMonthView->switchView(); 663 mMonthView->switchView();
672 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 664 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
673 full = false; 665 full = false;
674 else 666 else
675 full = true; 667 full = true;
676 } 668 }
677 mMainView->dateNavigator()->selectWeek(); 669 mMainView->dateNavigator()->selectWeek();
678 showView(mMonthView, full ); 670 showView(mMonthView, full );
679 mMonthView->setKeyBFocus(); 671 mMonthView->setKeyBFocus();
680 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ; 672 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ;
681} 673}
682 674
683void KOViewManager::showMonth( const QDate & date ) 675void KOViewManager::showMonth( const QDate & date )
684{ 676{
685 mMainView->dateNavigator()->blockSignals( true ); 677 mMainView->dateNavigator()->blockSignals( true );
686 mMainView->dateNavigator()->selectDate( date ); 678 mMainView->dateNavigator()->selectDate( date );
687 mMainView->dateNavigator()->blockSignals( false ); 679 mMainView->dateNavigator()->blockSignals( false );
688 showMonthView(); 680 showMonthView();
689} 681}
690void KOViewManager::showMonthView() 682void KOViewManager::showMonthView()
691 { 683 {
692 684
693 createMonthView(); 685 createMonthView();
694 globalFlagBlockAgenda = 1; 686 globalFlagBlockAgenda = 1;
695 //mFlagShowNextxDays = false; 687 //mFlagShowNextxDays = false;
696 bool full = true; 688 bool full = true;
697 if ( mCurrentView == mMonthView) 689 if ( mCurrentView == mMonthView)
698 full = mMainView->leftFrame()->isVisible(); 690 full = mMainView->leftFrame()->isVisible();
699 // if(mMonthView == mCurrentView) return; 691 // if(mMonthView == mCurrentView) return;
700 if ( KOPrefs::instance()->mMonthViewWeek ) { 692 if ( KOPrefs::instance()->mMonthViewWeek ) {
701 mMonthView->switchView(); 693 mMonthView->switchView();
702 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 694 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
703 full = false; 695 full = false;
704 else 696 else
705 full = true; 697 full = true;
706 } 698 }
707 mMainView->dateNavigator()->selectMonth(); 699 mMainView->dateNavigator()->selectMonth();
708 700
709 showView(mMonthView, full ); 701 showView(mMonthView, full );
710 mMonthView->setKeyBFocus(); 702 mMonthView->setKeyBFocus();
711 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ; 703 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ;
712 704
713} 705}
714 706
715void KOViewManager::showTodoView() 707void KOViewManager::showTodoView()
716{ 708{
717 //mFlagShowNextxDays = false; 709 //mFlagShowNextxDays = false;
718 if ( !mTodoView ) { 710 if ( !mTodoView ) {
719 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 711 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
720 "KOViewManager::TodoView" ); 712 "KOViewManager::TodoView" );
721 713
722 addView( mTodoView ); 714 addView( mTodoView );
723 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 715 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
724 716
725 // SIGNALS/SLOTS FOR TODO VIEW 717 // SIGNALS/SLOTS FOR TODO VIEW
726 connect( mTodoView, SIGNAL( newTodoSignal() ), 718 connect( mTodoView, SIGNAL( newTodoSignal() ),
727 mMainView, SLOT( newTodo() ) ); 719 mMainView, SLOT( newTodo() ) );
728 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 720 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
729 mMainView, SLOT( newSubTodo( Todo *) ) ); 721 mMainView, SLOT( newSubTodo( Todo *) ) );
730 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 722 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
731 mMainView, SLOT( showTodo( Todo * ) ) ); 723 mMainView, SLOT( showTodo( Todo * ) ) );
732 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 724 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
733 mMainView, SLOT( editTodo( Todo * ) ) ); 725 mMainView, SLOT( editTodo( Todo * ) ) );
734 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 726 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
735 mMainView, SLOT( deleteTodo( Todo * ) ) ); 727 mMainView, SLOT( deleteTodo( Todo * ) ) );
736 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 728 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
737 mMainView, SLOT( purgeCompleted() ) ); 729 mMainView, SLOT( purgeCompleted() ) );
738 730
739 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 731 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
740 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 732 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
741 733
742 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 734 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
743 SLOT( updateConfig() ) ); 735 SLOT( updateConfig() ) );
744 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 736 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
745 SLOT( updateTodo( Todo *, int ) ) ); 737 SLOT( updateTodo( Todo *, int ) ) );
746 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 738 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
747 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 739 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
748 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 740 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
749 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 741 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
750 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 742 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
751 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 743 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
752 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 744 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
753 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 745 mMainView, SLOT ( todo_unsub( Todo * ) ) );
754 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 746 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
755 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 747 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
756 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 748 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
757 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 749 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
758 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 750 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
759 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 751 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
760 KConfig *config = KOGlobals::config(); 752 KConfig *config = KOGlobals::config();
761 mTodoView->restoreLayout(config,"Todo View"); 753 mTodoView->restoreLayout(config,"Todo View");
762 mTodoView->setNavigator( mMainView->dateNavigator() ); 754 mTodoView->setNavigator( mMainView->dateNavigator() );
763 } 755 }
764 756
765 globalFlagBlockAgenda = 1; 757 globalFlagBlockAgenda = 1;
766 showView( mTodoView, true ); 758 showView( mTodoView, true );
767 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ; 759 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
768 760
769} 761}
770 762
771void KOViewManager::showJournalView() 763void KOViewManager::showJournalView()
772{ 764{
773 //mFlagShowNextxDays = false; 765 //mFlagShowNextxDays = false;
774 if (!mJournalView) { 766 if (!mJournalView) {
775 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 767 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
776 "KOViewManager::JournalView"); 768 "KOViewManager::JournalView");
777 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 769 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
778 SLOT( updateConfig() ) ); 770 SLOT( updateConfig() ) );
779 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 771 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
780 addView(mJournalView); 772 addView(mJournalView);
781 } 773 }
782 774
783 showView(mJournalView); 775 showView(mJournalView);
784 mMainView->dateNavigator()->selectDates( 1 ); 776 mMainView->dateNavigator()->selectDates( 1 );
785 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ; 777 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
786} 778}
787 779
788void KOViewManager::showTimeSpanView() 780void KOViewManager::showTimeSpanView()
789{ 781{
790 //mFlagShowNextxDays = false; 782 //mFlagShowNextxDays = false;
791 if (!mTimeSpanView) { 783 if (!mTimeSpanView) {
792 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 784 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
793 "KOViewManager::TimeSpanView"); 785 "KOViewManager::TimeSpanView");
794 addView(mTimeSpanView); 786 addView(mTimeSpanView);
795 787
796 mTimeSpanView->readSettings(); 788 mTimeSpanView->readSettings();
797 } 789 }
798 790
799 showView(mTimeSpanView); 791 showView(mTimeSpanView);
800} 792}
801 793
802Incidence *KOViewManager::currentSelection() 794Incidence *KOViewManager::currentSelection()
803{ 795{
804 if (!mCurrentView) return 0; 796 if (!mCurrentView) return 0;
805 if ( mCurrentView == mListView ) { 797 if ( mCurrentView == mListView ) {
806 if ( mListView->currentItem() ) 798 if ( mListView->currentItem() )
807 return mListView->currentItem(); 799 return mListView->currentItem();
808 } 800 }
809 return mCurrentView->selectedIncidences().first(); 801 return mCurrentView->selectedIncidences().first();
810} 802}
811 803
812QDate KOViewManager::currentSelectionDate() 804QDate KOViewManager::currentSelectionDate()
813{ 805{
814 QDate qd; 806 QDate qd;
815 if (mCurrentView) { 807 if (mCurrentView) {
816 DateList qvl = mCurrentView->selectedDates(); 808 DateList qvl = mCurrentView->selectedDates();
817 if (!qvl.isEmpty()) qd = qvl.first(); 809 if (!qvl.isEmpty()) qd = qvl.first();
818 } 810 }
819 return qd; 811 return qd;
820} 812}
821 813
822void KOViewManager::addView(KOrg::BaseView *view) 814void KOViewManager::addView(KOrg::BaseView *view)
823{ 815{
824#if QT_VERSION >= 0x030000 816#if QT_VERSION >= 0x030000
825 mMainView->viewStack()->addWidget( view ); 817 mMainView->viewStack()->addWidget( view );
826#else 818#else
827 mMainView->viewStack()->addWidget( view, 1 ); 819 mMainView->viewStack()->addWidget( view, 1 );
828#endif 820#endif
829} 821}
830 822
831void KOViewManager::setDocumentId( const QString &id ) 823void KOViewManager::setDocumentId( const QString &id )
832{ 824{
833 if (mTodoView) mTodoView->setDocumentId( id ); 825 if (mTodoView) mTodoView->setDocumentId( id );
834} 826}
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 8473db9..65d8ac3 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -1,786 +1,784 @@
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 19
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qtextbrowser.h> 21#include <qtextbrowser.h>
22#include <qtextcodec.h> 22#include <qtextcodec.h>
23#include <qfileinfo.h> 23#include <qfileinfo.h>
24#include <qlabel.h> 24#include <qlabel.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27#ifdef DESKTOP_VERSION 27#ifdef DESKTOP_VERSION
28#include <qpaintdevicemetrics.h> 28#include <qpaintdevicemetrics.h>
29#endif 29#endif
30#include <kglobal.h> 30#include <kglobal.h>
31#include <klocale.h> 31#include <klocale.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <kmessagebox.h> 34#include <kmessagebox.h>
35 35
36#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
37 37
38#ifndef KORG_NOPRINTER 38#ifndef KORG_NOPRINTER
39#include "calprinter.h" 39#include "calprinter.h"
40#endif 40#endif
41#include "koglobals.h" 41#include "koglobals.h"
42#include "koprefs.h" 42#include "koprefs.h"
43#include "koeventviewerdialog.h" 43#include "koeventviewerdialog.h"
44#include "koeventviewer.h" 44#include "koeventviewer.h"
45#include <qstylesheet.h> 45#include <qstylesheet.h>
46#include "kowhatsnextview.h" 46#include "kowhatsnextview.h"
47using namespace KOrg; 47using namespace KOrg;
48 48
49void WhatsNextTextBrowser::setSource(const QString& n) 49void WhatsNextTextBrowser::setSource(const QString& n)
50{ 50{
51 51
52 if (n.startsWith("event:")) { 52 if (n.startsWith("event:")) {
53 emit showIncidence(n); 53 emit showIncidence(n);
54 return; 54 return;
55 } else if (n.startsWith("todo:")) { 55 } else if (n.startsWith("todo:")) {
56 emit showIncidence(n); 56 emit showIncidence(n);
57 return; 57 return;
58 } else { 58 } else {
59 QTextBrowser::setSource(n); 59 QTextBrowser::setSource(n);
60 } 60 }
61} 61}
62void WhatsNextTextBrowser::printMe() 62void WhatsNextTextBrowser::printMe()
63{ 63{
64#ifdef DESKTOP_VERSION 64#ifdef DESKTOP_VERSION
65 KOPrintPrefs pp ( this ); 65 KOPrintPrefs pp ( this );
66 if (!pp.exec() ) 66 if (!pp.exec() )
67 return; 67 return;
68 int scaleval = pp.printMode() ; 68 int scaleval = pp.printMode() ;
69 69
70 QPrinter printer; 70 QPrinter printer;
71 if (!printer.setup() ) 71 if (!printer.setup() )
72 return; 72 return;
73 QPainter p; 73 QPainter p;
74 p.begin ( &printer ); 74 p.begin ( &printer );
75 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 75 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
76 float dx, dy; 76 float dx, dy;
77 int wid = (m.width() * 9)/10; 77 int wid = (m.width() * 9)/10;
78 dx = (float) wid/(float)contentsWidth (); 78 dx = (float) wid/(float)contentsWidth ();
79 dy = (float)(m.height()) / (float)contentsHeight (); 79 dy = (float)(m.height()) / (float)contentsHeight ();
80 float scale; 80 float scale;
81 // scale to fit the width or height of the paper 81 // scale to fit the width or height of the paper
82 if ( dx < dy ) 82 if ( dx < dy )
83 scale = dx; 83 scale = dx;
84 else 84 else
85 scale = dy; 85 scale = dy;
86 p.translate( m.width()/10,0 ); 86 p.translate( m.width()/10,0 );
87 qDebug("Scale: %f ", scale );
88 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 87 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
89 qDebug("SCALE ");
90 p.scale( scale, scale ); 88 p.scale( scale, scale );
91 } 89 }
92 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 90 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
93 p.end(); 91 p.end();
94#endif 92#endif
95} 93}
96 94
97KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, 95KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
98 const char *name) 96 const char *name)
99 : KOrg::BaseView(calendar, parent, name) 97 : KOrg::BaseView(calendar, parent, name)
100{ 98{
101 // mDateLabel = 99 // mDateLabel =
102 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); 100 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this);
103 // mDateLabel->setMargin(2); 101 // mDateLabel->setMargin(2);
104 // mDateLabel->setAlignment(AlignCenter); 102 // mDateLabel->setAlignment(AlignCenter);
105 setFont( KOPrefs::instance()->mWhatsNextFont ); 103 setFont( KOPrefs::instance()->mWhatsNextFont );
106 mView = new WhatsNextTextBrowser(this); 104 mView = new WhatsNextTextBrowser(this);
107 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); 105 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &)));
108 QStyleSheet* stsh = mView->styleSheet(); 106 QStyleSheet* stsh = mView->styleSheet();
109 QStyleSheetItem * style ; 107 QStyleSheetItem * style ;
110 style = stsh->item ("h2" ); 108 style = stsh->item ("h2" );
111 if ( style ) { 109 if ( style ) {
112 style->setMargin(QStyleSheetItem::MarginAll,0); 110 style->setMargin(QStyleSheetItem::MarginAll,0);
113 } 111 }
114 style = stsh->item ("h3" ); 112 style = stsh->item ("h3" );
115 if ( style ) { 113 if ( style ) {
116 style->setMargin(QStyleSheetItem::MarginAll,0); 114 style->setMargin(QStyleSheetItem::MarginAll,0);
117 } 115 }
118 mEventViewer = 0; 116 mEventViewer = 0;
119 117
120 QBoxLayout *topLayout = new QVBoxLayout(this); 118 QBoxLayout *topLayout = new QVBoxLayout(this);
121 // topLayout->addWidget(mDateLabel); 119 // topLayout->addWidget(mDateLabel);
122 topLayout->addWidget(mView); 120 topLayout->addWidget(mView);
123 mTimer = new QTimer( this ); 121 mTimer = new QTimer( this );
124 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); 122 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView()));
125 123
126 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 124 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
127 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 125 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
128} 126}
129 127
130KOWhatsNextView::~KOWhatsNextView() 128KOWhatsNextView::~KOWhatsNextView()
131{ 129{
132} 130}
133 131
134int KOWhatsNextView::maxDatesHint() 132int KOWhatsNextView::maxDatesHint()
135{ 133{
136 return 0; 134 return 0;
137} 135}
138 136
139int KOWhatsNextView::currentDateCount() 137int KOWhatsNextView::currentDateCount()
140{ 138{
141 return 0; 139 return 0;
142} 140}
143 141
144QPtrList<Incidence> KOWhatsNextView::selectedIncidences() 142QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
145{ 143{
146 QPtrList<Incidence> eventList; 144 QPtrList<Incidence> eventList;
147 145
148 return eventList; 146 return eventList;
149} 147}
150 148
151void KOWhatsNextView::printMe() 149void KOWhatsNextView::printMe()
152{ 150{
153#ifdef DESKTOP_VERSION 151#ifdef DESKTOP_VERSION
154 mView->printMe(); 152 mView->printMe();
155#endif 153#endif
156} 154}
157void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, 155void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
158 const QDate &td) 156 const QDate &td)
159{ 157{
160#ifndef KORG_NOPRINTER 158#ifndef KORG_NOPRINTER
161 calPrinter->preview(CalPrinter::Day, fd, td); 159 calPrinter->preview(CalPrinter::Day, fd, td);
162#endif 160#endif
163} 161}
164void KOWhatsNextView::updateConfig() 162void KOWhatsNextView::updateConfig()
165{ 163{
166 setFont( KOPrefs::instance()->mWhatsNextFont ); 164 setFont( KOPrefs::instance()->mWhatsNextFont );
167 updateView(); 165 updateView();
168 166
169} 167}
170void KOWhatsNextView::showEvent ( QShowEvent * e ) 168void KOWhatsNextView::showEvent ( QShowEvent * e )
171{ 169{
172 //qDebug("KOWhatsNextView::showEvent "); 170 //qDebug("KOWhatsNextView::showEvent ");
173 restartTimer(); 171 restartTimer();
174 QWidget::showEvent ( e ); 172 QWidget::showEvent ( e );
175} 173}
176void KOWhatsNextView::hideEvent ( QHideEvent * e) 174void KOWhatsNextView::hideEvent ( QHideEvent * e)
177{ 175{
178 //qDebug(" KOWhatsNextView::hideEvent"); 176 //qDebug(" KOWhatsNextView::hideEvent");
179 mTimer->stop(); 177 mTimer->stop();
180 QWidget::hideEvent ( e ); 178 QWidget::hideEvent ( e );
181} 179}
182void KOWhatsNextView::restartTimer() 180void KOWhatsNextView::restartTimer()
183{ 181{
184 //qDebug("KOWhatsNextView::restartTimer() "); 182 //qDebug("KOWhatsNextView::restartTimer() ");
185 mTimer->start( 300000 ); 183 mTimer->start( 300000 );
186 //mTimer->start( 5000 ); 184 //mTimer->start( 5000 );
187} 185}
188void KOWhatsNextView::updateView() 186void KOWhatsNextView::updateView()
189{ 187{
190 //qDebug("KOWhatsNextView::updateView() "); 188 //qDebug("KOWhatsNextView::updateView() ");
191 if ( mTimer->isActive() ) 189 if ( mTimer->isActive() )
192 restartTimer(); 190 restartTimer();
193 mCurrentMaxPrio = 5; 191 mCurrentMaxPrio = 5;
194 //qDebug("KOWhatsNextView::updateView() "); 192 //qDebug("KOWhatsNextView::updateView() ");
195 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); 193 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate()));
196 KIconLoader kil("korganizer"); 194 KIconLoader kil("korganizer");
197 QString ipath;// = new QString(); 195 QString ipath;// = new QString();
198 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); 196 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath);
199 //<big><big><strong>" + date + "</strong></big></big>\n"; 197 //<big><big><strong>" + date + "</strong></big></big>\n";
200 mText = "<table width=\"100%\">\n"; 198 mText = "<table width=\"100%\">\n";
201 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 199 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
202#ifdef DESKTOP_VERSION 200#ifdef DESKTOP_VERSION
203 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; 201 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
204#else 202#else
205 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 203 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
206#endif 204#endif
207 // mText += "<img src=\""; 205 // mText += "<img src=\"";
208 // mText += ipath; 206 // mText += ipath;
209 // mText += "\">"; 207 // mText += "\">";
210 mEventDate = QDate::currentDate(); 208 mEventDate = QDate::currentDate();
211#ifdef DESKTOP_VERSION 209#ifdef DESKTOP_VERSION
212 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; 210 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>";
213#else 211#else
214 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; 212 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>";
215#endif 213#endif
216 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 214 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
217 int iii; 215 int iii;
218 mTodos.clear(); 216 mTodos.clear();
219 QPtrList<Event> events; 217 QPtrList<Event> events;
220 QPtrList<Todo> todos = calendar()->todos(); 218 QPtrList<Todo> todos = calendar()->todos();
221 Todo * todo; 219 Todo * todo;
222 //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; 220 //mText += "<h2>" + i18n("Events: ") + "</h2>\n";
223 int daysToShow = KOPrefs::instance()->mWhatsNextDays ; 221 int daysToShow = KOPrefs::instance()->mWhatsNextDays ;
224 bool itemAdded = false; 222 bool itemAdded = false;
225 for ( iii = 0; iii < daysToShow; ++iii ) { 223 for ( iii = 0; iii < daysToShow; ++iii ) {
226 QString date; 224 QString date;
227 itemAdded = false; 225 itemAdded = false;
228 events = calendar()->events( mEventDate, true ); 226 events = calendar()->events( mEventDate, true );
229 227
230 if ( iii == 0 ) { // today !!! 228 if ( iii == 0 ) { // today !!!
231 todo = todos.first(); 229 todo = todos.first();
232 while(todo) { 230 while(todo) {
233 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { 231 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) {
234 if ( ! itemAdded ) { 232 if ( ! itemAdded ) {
235 appendDay ( iii, mEventDate ); 233 appendDay ( iii, mEventDate );
236 //itemAdded = true; 234 //itemAdded = true;
237 235
238 } //bool reply=false, bool notRed = true, bool appendTable = false); 236 } //bool reply=false, bool notRed = true, bool appendTable = false);
239 appendEvent(todo, false, false, !itemAdded ); 237 appendEvent(todo, false, false, !itemAdded );
240 itemAdded = true; 238 itemAdded = true;
241 } 239 }
242 todo = todos.next(); 240 todo = todos.next();
243 } 241 }
244 } 242 }
245 243
246 244
247 if (events.count() > 0) { 245 if (events.count() > 0) {
248 // mText += "<p></p>"; 246 // mText += "<p></p>";
249 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 247 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
250 // mText += "<h2>"; 248 // mText += "<h2>";
251 //mText += " <img src=\""; 249 //mText += " <img src=\"";
252 //mText += ipath; 250 //mText += ipath;
253 //mText += "\">"; 251 //mText += "\">";
254 if ( ! itemAdded ) { 252 if ( ! itemAdded ) {
255 appendDay ( iii, mEventDate ); 253 appendDay ( iii, mEventDate );
256 254
257 } 255 }
258 // for first day (iii == 0) 256 // for first day (iii == 0)
259 // we may have syncevents, or events in the past, which maybe should not be diaplayed 257 // we may have syncevents, or events in the past, which maybe should not be diaplayed
260 // for that reason we cannot append <table> in appendDay () for iii == 0 258 // for that reason we cannot append <table> in appendDay () for iii == 0
261 // we must append it in the first successful call of appendEvent() 259 // we must append it in the first successful call of appendEvent()
262 Event *ev = events.first(); 260 Event *ev = events.first();
263 while(ev) { 261 while(ev) {
264 //qDebug("+++++event append %s", ev->summary().latin1()); 262 //qDebug("+++++event append %s", ev->summary().latin1());
265 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { 263 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) {
266 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) 264 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) )
267 itemAdded = true; 265 itemAdded = true;
268 } 266 }
269 ev = events.next(); 267 ev = events.next();
270 } 268 }
271 269
272 //mText += "</table>\n"; 270 //mText += "</table>\n";
273 } 271 }
274 272
275 todo = todos.first(); 273 todo = todos.first();
276 while(todo) { 274 while(todo) {
277 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { 275 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) {
278 if ( ! itemAdded ) { 276 if ( ! itemAdded ) {
279 appendDay ( iii, mEventDate ); 277 appendDay ( iii, mEventDate );
280 //itemAdded = true; 278 //itemAdded = true;
281 } 279 }
282 appendEvent(todo, false , iii!= 0,!itemAdded); 280 appendEvent(todo, false , iii!= 0,!itemAdded);
283 itemAdded = true; 281 itemAdded = true;
284 } 282 }
285 todo = todos.next(); 283 todo = todos.next();
286 } 284 }
287 if ( !itemAdded && iii == 0 ) { 285 if ( !itemAdded && iii == 0 ) {
288 // appendDay ( iii, mEventDate ); 286 // appendDay ( iii, mEventDate );
289 //mText += "<table>"; 287 //mText += "<table>";
290 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; 288 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n";
291 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; 289 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n";
292 //mText +="</table>"; 290 //mText +="</table>";
293 } 291 }
294 if ( itemAdded ) 292 if ( itemAdded )
295 mText += "</table>\n"; 293 mText += "</table>\n";
296 mEventDate = mEventDate.addDays( 1 ); 294 mEventDate = mEventDate.addDays( 1 );
297 } 295 }
298 296
299 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; 297 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios;
300 if (todos.count() > 0 && topmostPrios > 0 ) { 298 if (todos.count() > 0 && topmostPrios > 0 ) {
301 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 299 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
302 // mText += "<h2>"; 300 // mText += "<h2>";
303 //<img src=\""; 301 //<img src=\"";
304 // mText += ipath; 302 // mText += ipath;
305 // mText += "\">"; 303 // mText += "\">";
306 // mText += i18n("Overdue To-Do:") + "</h2>\n"; 304 // mText += i18n("Overdue To-Do:") + "</h2>\n";
307 305
308 //mText += "<ul>\n"; 306 //mText += "<ul>\n";
309 bool gotone = false; 307 bool gotone = false;
310 int priority = 1; 308 int priority = 1;
311 int priosFound = 0; 309 int priosFound = 0;
312#ifdef DESKTOP_VERSION 310#ifdef DESKTOP_VERSION
313 mText +="<p></p>"; 311 mText +="<p></p>";
314#endif 312#endif
315 313
316 mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; 314 mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n";
317 mText += "<ul>\n"; 315 mText += "<ul>\n";
318 while (!gotone && priority<6) { 316 while (!gotone && priority<6) {
319 todo = todos.first(); 317 todo = todos.first();
320 while(todo) { 318 while(todo) {
321 if (!todo->isCompleted() && (todo->priority() == priority) ) { 319 if (!todo->isCompleted() && (todo->priority() == priority) ) {
322 mCurrentMaxPrio = priority - priosFound + topmostPrios -1; 320 mCurrentMaxPrio = priority - priosFound + topmostPrios -1;
323 if ( appendTodo(todo) ) 321 if ( appendTodo(todo) )
324 gotone = true; 322 gotone = true;
325 } 323 }
326 todo = todos.next(); 324 todo = todos.next();
327 } 325 }
328 if ( gotone ) { 326 if ( gotone ) {
329 gotone = false; 327 gotone = false;
330 ++priosFound; 328 ++priosFound;
331 if ( priosFound == topmostPrios ) 329 if ( priosFound == topmostPrios )
332 break; 330 break;
333 } 331 }
334 priority++; 332 priority++;
335 // kdDebug() << "adding the todos..." << endl; 333 // kdDebug() << "adding the todos..." << endl;
336 } 334 }
337 mText += "</ul>\n"; 335 mText += "</ul>\n";
338 } 336 }
339 337
340 int replys = 0; 338 int replys = 0;
341 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); 339 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6));
342 if (events.count() > 0) { 340 if (events.count() > 0) {
343 Event *ev = events.first(); 341 Event *ev = events.first();
344 while(ev) { 342 while(ev) {
345 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 343 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
346 if (me!=0) { 344 if (me!=0) {
347 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 345 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
348 if (replys == 0) { 346 if (replys == 0) {
349 mText += "<p></p>"; 347 mText += "<p></p>";
350 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 348 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
351 //mText += "<h2>"; 349 //mText += "<h2>";
352 //<img src=\""; 350 //<img src=\"";
353 // mText += ipath; 351 // mText += ipath;
354 // mText += "\">"; 352 // mText += "\">";
355 //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; 353 //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n";
356 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; 354 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n";
357 mText += "<table>\n"; 355 mText += "<table>\n";
358 } 356 }
359 replys++; 357 replys++;
360 appendEvent(ev,true); 358 appendEvent(ev,true);
361 } 359 }
362 } 360 }
363 ev = events.next(); 361 ev = events.next();
364 } 362 }
365 } 363 }
366 todos = calendar()->todos(); 364 todos = calendar()->todos();
367 if (todos.count() > 0) { 365 if (todos.count() > 0) {
368 Todo *to = todos.first(); 366 Todo *to = todos.first();
369 while(to) { 367 while(to) {
370 if ( !to->isCompleted() ){ 368 if ( !to->isCompleted() ){
371 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 369 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
372 if (me!=0) { 370 if (me!=0) {
373 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 371 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
374 if (replys == 0) { 372 if (replys == 0) {
375 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; 373 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n";
376 mText += "<table>\n"; 374 mText += "<table>\n";
377 } 375 }
378 replys++; 376 replys++;
379 appendEvent(to, true); 377 appendEvent(to, true);
380 } 378 }
381 } 379 }
382 } 380 }
383 to = todos.next(); 381 to = todos.next();
384 } 382 }
385 } 383 }
386 if (replys > 0 ) mText += "</table>\n"; 384 if (replys > 0 ) mText += "</table>\n";
387 385
388 386
389 mText += "</td></tr>\n</table>\n"; 387 mText += "</td></tr>\n</table>\n";
390 388
391 mView->setText(mText); 389 mView->setText(mText);
392 mView->setFocus(); 390 mView->setFocus();
393 391
394 // QPixmap bPix = SmallIcon( "back" ); 392 // QPixmap bPix = SmallIcon( "back" );
395 // qDebug("xxxxxxxxxxxxxxxxxxxxx "); 393 // qDebug("xxxxxxxxxxxxxxxxxxxxx ");
396 // QWidget* test = new QWidget(); 394 // QWidget* test = new QWidget();
397 // test->setBackgroundMode(FixedPixmap ); 395 // test->setBackgroundMode(FixedPixmap );
398 // test->setBackgroundPixmap ( bPix ); 396 // test->setBackgroundPixmap ( bPix );
399 // test->resize( 300, 400 ); 397 // test->resize( 300, 400 );
400 // test->show(); 398 // test->show();
401 // mView->setBackgroundMode(FixedPixmap ); 399 // mView->setBackgroundMode(FixedPixmap );
402 // mView->setBackgroundPixmap ( bPix ); 400 // mView->setBackgroundPixmap ( bPix );
403 // qDebug("%s ",mText.latin1()); 401 // qDebug("%s ",mText.latin1());
404} 402}
405 403
406void KOWhatsNextView::appendDay( int i, QDate eventDate ) 404void KOWhatsNextView::appendDay( int i, QDate eventDate )
407{ 405{
408 QString date; 406 QString date;
409 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); 407 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer);
410 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { 408 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) {
411 if ( i == 0 ) { 409 if ( i == 0 ) {
412 //mText += "<table>\n"; 410 //mText += "<table>\n";
413 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; 411 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>";
414 } 412 }
415 else if ( i == 1 ) 413 else if ( i == 1 )
416 date = "<em><font color=\"#000080\">" + day + "</font></em>" ; 414 date = "<em><font color=\"#000080\">" + day + "</font></em>" ;
417 else date = "<em><font color=\"#000080\">" + day + "</font></em>"; 415 else date = "<em><font color=\"#000080\">" + day + "</font></em>";
418 mText += "<h2>" + date + "</h2>\n"; 416 mText += "<h2>" + date + "</h2>\n";
419 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 417 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
420 mText += "<table>\n"; 418 mText += "<table>\n";
421 419
422 420
423 421
424 } else { 422 } else {
425 if ( i == 0 ) { 423 if ( i == 0 ) {
426 //mText += "<table>\n"; 424 //mText += "<table>\n";
427 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; 425 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>";
428 } 426 }
429 427
430#ifdef DESKTOP_VERSION 428#ifdef DESKTOP_VERSION
431 else if ( i == 1 ) { 429 else if ( i == 1 ) {
432 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; 430 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ;
433 } 431 }
434 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; 432 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>";
435#else 433#else
436 else if ( i == 1 ) { 434 else if ( i == 1 ) {
437 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; 435 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ;
438 } 436 }
439 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; 437 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>";
440 438
441#endif 439#endif
442 mText += "<h2>" + date + "</h2>\n"; 440 mText += "<h2>" + date + "</h2>\n";
443 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 441 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
444 mText += "<table>\n"; 442 mText += "<table>\n";
445 } 443 }
446} 444}
447 445
448 446
449void KOWhatsNextView::showDates(const QDate &, const QDate &) 447void KOWhatsNextView::showDates(const QDate &, const QDate &)
450{ 448{
451 updateView(); 449 updateView();
452} 450}
453 451
454void KOWhatsNextView::showEvents(QPtrList<Event>) 452void KOWhatsNextView::showEvents(QPtrList<Event>)
455{ 453{
456} 454}
457 455
458void KOWhatsNextView::changeEventDisplay(Event *, int action) 456void KOWhatsNextView::changeEventDisplay(Event *, int action)
459{ 457{
460 switch(action) { 458 switch(action) {
461 case KOGlobals::EVENTADDED: 459 case KOGlobals::EVENTADDED:
462 updateView(); 460 updateView();
463 break; 461 break;
464 case KOGlobals::EVENTEDITED: 462 case KOGlobals::EVENTEDITED:
465 updateView(); 463 updateView();
466 break; 464 break;
467 case KOGlobals::EVENTDELETED: 465 case KOGlobals::EVENTDELETED:
468 updateView(); 466 updateView();
469 break; 467 break;
470 default: 468 default:
471 updateView(); 469 updateView();
472 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; 470 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl;
473 } 471 }
474} 472}
475 473
476bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) 474bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable )
477{ 475{
478 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) 476 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") )
479 return false; 477 return false;
480 QDateTime cdt = QDateTime::currentDateTime(); 478 QDateTime cdt = QDateTime::currentDateTime();
481 QDateTime noc; 479 QDateTime noc;
482 QString tempText; 480 QString tempText;
483 if ( appendTable && !notRed ) { 481 if ( appendTable && !notRed ) {
484 tempText = "<table>"; 482 tempText = "<table>";
485 } 483 }
486 bool ok = true; 484 bool ok = true;
487 if ( reply ) { 485 if ( reply ) {
488 noc = ev->getNextOccurence( cdt, &ok ); 486 noc = ev->getNextOccurence( cdt, &ok );
489 if (! ok && ev->type() == "Event") 487 if (! ok && ev->type() == "Event")
490 return false; 488 return false;
491 } 489 }
492 bool bDay = false; 490 bool bDay = false;
493 if ( ev->isBirthday() || ev->isAnniversary() ) 491 if ( ev->isBirthday() || ev->isAnniversary() )
494 bDay = true; 492 bDay = true;
495 tempText += "<tr><td><b>"; 493 tempText += "<tr><td><b>";
496 if (ev->type()=="Event") { 494 if (ev->type()=="Event") {
497 if (reply) { 495 if (reply) {
498 if (!ev->doesFloat()) 496 if (!ev->doesFloat())
499 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; 497 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": ";
500 else 498 else
501 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 499 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
502 500
503 } else { 501 } else {
504 if (!ev->doesFloat()) { 502 if (!ev->doesFloat()) {
505 Event *event = static_cast<Event *>(ev); 503 Event *event = static_cast<Event *>(ev);
506 QDateTime st,end; 504 QDateTime st,end;
507 if ( event->recurrence()->doesRecur() ) { 505 if ( event->recurrence()->doesRecur() ) {
508 QDate recDate= mEventDate; 506 QDate recDate= mEventDate;
509 int days = event->dtStart().date().daysTo (event->dtEnd().date() ); 507 int days = event->dtStart().date().daysTo (event->dtEnd().date() );
510 while ( ! event->recursOn( recDate ) ) { 508 while ( ! event->recursOn( recDate ) ) {
511 recDate = recDate.addDays( -1 ); 509 recDate = recDate.addDays( -1 );
512 510
513 } 511 }
514 st = QDateTime ( recDate, event->dtStart().time() ); 512 st = QDateTime ( recDate, event->dtStart().time() );
515 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); 513 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() );
516 } 514 }
517 else { 515 else {
518 st = event->dtStart(); 516 st = event->dtStart();
519 end = event->dtEnd(); 517 end = event->dtEnd();
520 } 518 }
521 519
522 520
523 QString dateText; 521 QString dateText;
524 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); 522 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() );
525 if ( st.date() < mEventDate ) 523 if ( st.date() < mEventDate )
526 dateText = "++:++-"; 524 dateText = "++:++-";
527 else 525 else
528 dateText = event->dtStartTimeStr() + "-"; 526 dateText = event->dtStartTimeStr() + "-";
529 if ( end.date() > mEventDate ) 527 if ( end.date() > mEventDate )
530 dateText += "++:++"; 528 dateText += "++:++";
531 else 529 else
532 dateText += event->dtEndTimeStr(); 530 dateText += event->dtEndTimeStr();
533 if ( notRed ) 531 if ( notRed )
534 tempText += dateText; 532 tempText += dateText;
535 else { 533 else {
536 if ( end < cdt ) { 534 if ( end < cdt ) {
537 if ( !KOPrefs::instance()->mWNViewShowsPast ) 535 if ( !KOPrefs::instance()->mWNViewShowsPast )
538 return false; 536 return false;
539 tempText += "<font color=\"#F00000\">" + dateText + "</font>"; 537 tempText += "<font color=\"#F00000\">" + dateText + "</font>";
540 } 538 }
541 else if ( st < cdt ) 539 else if ( st < cdt )
542 tempText += "<font color=\"#008000\">" + dateText + "</font>"; 540 tempText += "<font color=\"#008000\">" + dateText + "</font>";
543 else 541 else
544 tempText += dateText; 542 tempText += dateText;
545 543
546 } 544 }
547 545
548 } else { 546 } else {
549 if ( bDay ) { 547 if ( bDay ) {
550 548
551 if ( ev->isBirthday()) 549 if ( ev->isBirthday())
552 tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>"; 550 tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>";
553 else 551 else
554 tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>"; 552 tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>";
555 } else { 553 } else {
556 tempText += i18n("Allday:"); 554 tempText += i18n("Allday:");
557 } 555 }
558 556
559 } 557 }
560 } 558 }
561 } else { 559 } else {
562 mTodos.append( ev ); 560 mTodos.append( ev );
563 tempText += i18n("ToDo:"); 561 tempText += i18n("ToDo:");
564 if (reply) { 562 if (reply) {
565 tempText += " "; 563 tempText += " ";
566 if ( noc != cdt ) { 564 if ( noc != cdt ) {
567 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 565 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
568 } 566 }
569 } else { 567 } else {
570 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { 568 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) {
571 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 569 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
572 QString dfs = KGlobal::locale()->dateFormatShort(); 570 QString dfs = KGlobal::locale()->dateFormatShort();
573 KGlobal::locale()->setDateFormatShort("%d.%b"); 571 KGlobal::locale()->setDateFormatShort("%d.%b");
574 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; 572 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>";
575 KGlobal::locale()->setDateFormatShort(dfs); 573 KGlobal::locale()->setDateFormatShort(dfs);
576 } else { 574 } else {
577 if (!ev->doesFloat() ) 575 if (!ev->doesFloat() )
578 if( ( (Todo*)ev)->dtDue() < cdt ) { 576 if( ( (Todo*)ev)->dtDue() < cdt ) {
579 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; 577 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>";
580 578
581 579
582 } else 580 } else
583 tempText +=((Todo*)ev)->dtDueTimeStr(); 581 tempText +=((Todo*)ev)->dtDueTimeStr();
584 mTodos.append( ev ); 582 mTodos.append( ev );
585 } 583 }
586 } 584 }
587 } 585 }
588 tempText += "</b></td><td>"; 586 tempText += "</b></td><td>";
589 bool needClose = false; 587 bool needClose = false;
590 if ( ev->cancelled() ) { 588 if ( ev->cancelled() ) {
591 tempText += "<font color=\"#F00000\">[c"; 589 tempText += "<font color=\"#F00000\">[c";
592 needClose =true; 590 needClose =true;
593 591
594 } 592 }
595 if ( ev->isAlarmEnabled() ) { 593 if ( ev->isAlarmEnabled() ) {
596 if ( !needClose) 594 if ( !needClose)
597 tempText +="["; 595 tempText +="[";
598 tempText += "a"; 596 tempText += "a";
599 needClose =true; 597 needClose =true;
600 598
601 } 599 }
602 if ( ev->description().length() > 0 ) { 600 if ( ev->description().length() > 0 ) {
603 if ( !needClose) 601 if ( !needClose)
604 tempText +="["; 602 tempText +="[";
605 tempText += "i"; 603 tempText += "i";
606 needClose =true; 604 needClose =true;
607 } 605 }
608 if ( ev->recurrence()->doesRecur() ) { 606 if ( ev->recurrence()->doesRecur() ) {
609 if ( !needClose) 607 if ( !needClose)
610 tempText +="["; 608 tempText +="[";
611 tempText += "r"; 609 tempText += "r";
612 needClose =true; 610 needClose =true;
613 } 611 }
614 if ( needClose ) { 612 if ( needClose ) {
615 tempText += "] "; 613 tempText += "] ";
616 } 614 }
617 if ( ev->cancelled() ) 615 if ( ev->cancelled() )
618 tempText += "</font>"; 616 tempText += "</font>";
619 tempText += "<a "; 617 tempText += "<a ";
620 if (ev->type()=="Event") tempText += "href=\"event:"; 618 if (ev->type()=="Event") tempText += "href=\"event:";
621 if (ev->type()=="Todo") tempText += "href=\"todo:"; 619 if (ev->type()=="Todo") tempText += "href=\"todo:";
622 tempText += ev->uid() + "\">"; 620 tempText += ev->uid() + "\">";
623 if ( ev->summary().length() > 0 ) 621 if ( ev->summary().length() > 0 )
624 tempText += ev->summary(); 622 tempText += ev->summary();
625 else 623 else
626 tempText += i18n("-no summary-"); 624 tempText += i18n("-no summary-");
627 if ( bDay ) { 625 if ( bDay ) {
628 noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); 626 noc = ev->getNextOccurence( cdt.addDays(-1), &ok );
629 if ( ok ) { 627 if ( ok ) {
630 int years = 0; 628 int years = 0;
631 if ( ev->type() =="Todo" ) { 629 if ( ev->type() =="Todo" ) {
632 years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); 630 years = noc.date().year() -((Todo*)ev)->dtDue().date().year();
633 } else 631 } else
634 years = noc.date().year() - ev->dtStart().date().year(); 632 years = noc.date().year() - ev->dtStart().date().year();
635 tempText += i18n(" (%1 y.)"). arg( years ); 633 tempText += i18n(" (%1 y.)"). arg( years );
636 } 634 }
637 } 635 }
638 636
639 tempText += "</a>"; 637 tempText += "</a>";
640 if ( KOPrefs::instance()->mWNViewShowLocation ) 638 if ( KOPrefs::instance()->mWNViewShowLocation )
641 if ( !ev->location().isEmpty() ) 639 if ( !ev->location().isEmpty() )
642 tempText += " ("+ev->location() +")"; 640 tempText += " ("+ev->location() +")";
643 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) 641 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents)
644 tempText += " ["+ev->relatedTo()->summary() +"]"; 642 tempText += " ["+ev->relatedTo()->summary() +"]";
645 tempText += "</td></tr>\n"; 643 tempText += "</td></tr>\n";
646 mText += tempText; 644 mText += tempText;
647 return true; 645 return true;
648} 646}
649 647
650bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) 648bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
651{ 649{
652 if ( mTodos.find( ev ) != mTodos.end() ) return false; 650 if ( mTodos.find( ev ) != mTodos.end() ) return false;
653 651
654 mTodos.append( ev ); 652 mTodos.append( ev );
655 if ( !isSub ) 653 if ( !isSub )
656 mText += "<p>"; 654 mText += "<p>";
657 else 655 else
658 mText += "<li>"; 656 mText += "<li>";
659 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; 657 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] ";
660 658
661 659
662 mText += ind; 660 mText += ind;
663 bool needClose = false; 661 bool needClose = false;
664 if ( ev->cancelled() ) { 662 if ( ev->cancelled() ) {
665 mText += "<font color=\"#F00000\">[c"; 663 mText += "<font color=\"#F00000\">[c";
666 needClose =true; 664 needClose =true;
667 665
668 } 666 }
669 if ( ev->isAlarmEnabled() ) { 667 if ( ev->isAlarmEnabled() ) {
670 if ( !needClose) 668 if ( !needClose)
671 mText +="["; 669 mText +="[";
672 mText += "a"; 670 mText += "a";
673 needClose =true; 671 needClose =true;
674 672
675 } 673 }
676 674
677 if ( ev->description().length() > 0 ) { 675 if ( ev->description().length() > 0 ) {
678 if ( !needClose) 676 if ( !needClose)
679 mText +="["; 677 mText +="[";
680 mText += "i"; 678 mText += "i";
681 needClose =true; 679 needClose =true;
682 } 680 }
683 if ( ev->doesRecur() ) { 681 if ( ev->doesRecur() ) {
684 if ( !needClose) 682 if ( !needClose)
685 mText +="["; 683 mText +="[";
686 mText += "r"; 684 mText += "r";
687 needClose =true; 685 needClose =true;
688 } 686 }
689 // if ( ev->recurrence()->doesRecur() ) { 687 // if ( ev->recurrence()->doesRecur() ) {
690 // if ( !needClose) 688 // if ( !needClose)
691 // mText +="("; 689 // mText +="(";
692 // mText += "r"; 690 // mText += "r";
693 // needClose =true; 691 // needClose =true;
694 // } 692 // }
695 if ( needClose ) 693 if ( needClose )
696 mText += "] "; 694 mText += "] ";
697 if ( ev->cancelled() ) 695 if ( ev->cancelled() )
698 mText += "</font>"; 696 mText += "</font>";
699 mText += "<a href=\"todo:" + ev->uid() + "\">"; 697 mText += "<a href=\"todo:" + ev->uid() + "\">";
700 if ( ev->summary().length() > 0 ) 698 if ( ev->summary().length() > 0 )
701 mText += ev->summary(); 699 mText += ev->summary();
702 else 700 else
703 mText += i18n("-no summary-"); 701 mText += i18n("-no summary-");
704 mText += "</a>"; 702 mText += "</a>";
705 if ( ((Todo*)ev)->hasDueDate () ) { 703 if ( ((Todo*)ev)->hasDueDate () ) {
706 QString year = ""; 704 QString year = "";
707 int ye = ((Todo*)ev)->dtDue().date().year(); 705 int ye = ((Todo*)ev)->dtDue().date().year();
708 if ( QDateTime::currentDateTime().date().year() != ye ) 706 if ( QDateTime::currentDateTime().date().year() != ye )
709 year = QString::number( ye ); 707 year = QString::number( ye );
710 QString dfs = KGlobal::locale()->dateFormatShort(); 708 QString dfs = KGlobal::locale()->dateFormatShort();
711 KGlobal::locale()->setDateFormatShort("%d.%b"); 709 KGlobal::locale()->setDateFormatShort("%d.%b");
712 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; 710 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>";
713 KGlobal::locale()->setDateFormatShort(dfs); 711 KGlobal::locale()->setDateFormatShort(dfs);
714 } 712 }
715 if ( KOPrefs::instance()->mWNViewShowLocation ) 713 if ( KOPrefs::instance()->mWNViewShowLocation )
716 if ( !ev->location().isEmpty() ) 714 if ( !ev->location().isEmpty() )
717 mText += " ("+ev->location() +")"; 715 mText += " ("+ev->location() +")";
718 if ( !isSub ) { 716 if ( !isSub ) {
719 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) 717 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
720 mText += " ["+ev->relatedTo()->summary() +"]"; 718 mText += " ["+ev->relatedTo()->summary() +"]";
721 mText += "</p>\n"; 719 mText += "</p>\n";
722 } 720 }
723 else { 721 else {
724 ind += "-"; 722 ind += "-";
725 mText += "</li>\n"; 723 mText += "</li>\n";
726 } 724 }
727 QPtrList<Incidence> Relations = ev->relations(); 725 QPtrList<Incidence> Relations = ev->relations();
728 Incidence *to; 726 Incidence *to;
729 for (to=Relations.first();to;to=Relations.next()) { 727 for (to=Relations.first();to;to=Relations.next()) {
730 if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio ) 728 if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio )
731 appendTodo( to, ind , true ); 729 appendTodo( to, ind , true );
732 } 730 }
733 731
734 return true; 732 return true;
735} 733}
736 734
737/* 735/*
738 void KOWhatsNextView::createEventViewer() 736 void KOWhatsNextView::createEventViewer()
739 { 737 {
740 if (!mEventViewer) { 738 if (!mEventViewer) {
741 739
742 mEventViewer = new KOEventViewerDialog(this); 740 mEventViewer = new KOEventViewerDialog(this);
743 } 741 }
744 } 742 }
745*/ 743*/
746void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) 744void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
747{ 745{
748 mEventViewer = v; 746 mEventViewer = v;
749} 747}
750 748
751// TODO: Create this function in CalendarView and remove it from here 749// TODO: Create this function in CalendarView and remove it from here
752void KOWhatsNextView::showIncidence(const QString &uid) 750void KOWhatsNextView::showIncidence(const QString &uid)
753{ 751{
754 752
755 if ( !mEventViewer ) { 753 if ( !mEventViewer ) {
756 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); 754 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set ");
757 return; 755 return;
758 } 756 }
759 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; 757 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl;
760 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); 758 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1());
761 if (uid.startsWith("event:")) { 759 if (uid.startsWith("event:")) {
762#ifdef DESKTOP_VERSION 760#ifdef DESKTOP_VERSION
763 Event *event = calendar()->event(uid.mid(8)); 761 Event *event = calendar()->event(uid.mid(8));
764#else 762#else
765 Event *event = calendar()->event(uid.mid(6)); 763 Event *event = calendar()->event(uid.mid(6));
766#endif 764#endif
767 //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); 765 //qDebug("event %d uid %s ", event, uid.mid(6).latin1());
768 if (!event) return; 766 if (!event) return;
769 //createEventViewer(); 767 //createEventViewer();
770 mEventViewer->setEvent(event); 768 mEventViewer->setEvent(event);
771 } else if (uid.startsWith("todo:")) { 769 } else if (uid.startsWith("todo:")) {
772#ifdef DESKTOP_VERSION 770#ifdef DESKTOP_VERSION
773 Todo *todo = calendar()->todo(uid.mid(7)); 771 Todo *todo = calendar()->todo(uid.mid(7));
774#else 772#else
775 Todo *todo = calendar()->todo(uid.mid(5)); 773 Todo *todo = calendar()->todo(uid.mid(5));
776#endif 774#endif
777 if (!todo) return; 775 if (!todo) return;
778 //createEventViewer(); 776 //createEventViewer();
779 mEventViewer->setTodo(todo); 777 mEventViewer->setTodo(todo);
780 } else { 778 } else {
781 return; 779 return;
782 780
783 } 781 }
784 mEventViewer->showMe(); 782 mEventViewer->showMe();
785 mEventViewer->raise(); 783 mEventViewer->raise();
786} 784}
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp
index 61a0931..df9b2fc 100644
--- a/korganizer/ktimeedit.cpp
+++ b/korganizer/ktimeedit.cpp
@@ -1,476 +1,474 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown, Ian Dawes 3 Copyright (c) 1999 Preston Brown, Ian Dawes
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 <qkeycode.h> 24#include <qkeycode.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qlineedit.h> 27#include <qlineedit.h>
28#include <qlistbox.h> 28#include <qlistbox.h>
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include <kmessagebox.h> 31#include <kmessagebox.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <kdebug.h> 33#include <kdebug.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kpimglobalprefs.h> 35#include <kpimglobalprefs.h>
36 36
37#include "ktimeedit.h" 37#include "ktimeedit.h"
38#include "koprefs.h" 38#include "koprefs.h"
39#include <qvalidator.h> 39#include <qvalidator.h>
40 40
41// Validator for a time value with only hours and minutes (no seconds) 41// Validator for a time value with only hours and minutes (no seconds)
42// Mostly locale aware. Author: David Faure <faure@kde.org> 42// Mostly locale aware. Author: David Faure <faure@kde.org>
43 43
44// KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox. 44// KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox.
45// Difficult to get all in one... 45// Difficult to get all in one...
46// But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help. 46// But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help.
47KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) 47KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name)
48 : QComboBox(TRUE, parent, name) 48 : QComboBox(TRUE, parent, name)
49{ 49{
50 setInsertionPolicy(NoInsertion); 50 setInsertionPolicy(NoInsertion);
51 mFlagKeyPressed = false; 51 mFlagKeyPressed = false;
52 if ( QApplication::desktop()->height() <= 480 ) { 52 if ( QApplication::desktop()->height() <= 480 ) {
53 setSizeLimit ( 6 ); 53 setSizeLimit ( 6 );
54 } else { 54 } else {
55 setSizeLimit ( 12 ); 55 setSizeLimit ( 12 );
56 } 56 }
57 mTime = qt; 57 mTime = qt;
58 58
59// mNoTimeString = i18n("No Time"); 59// mNoTimeString = i18n("No Time");
60// insertItem( mNoTimeString ); 60// insertItem( mNoTimeString );
61 61
62 // Fill combo box with selection of times in localized format. 62 // Fill combo box with selection of times in localized format.
63 QTime timeEntry(0,0,0); 63 QTime timeEntry(0,0,0);
64 do { 64 do {
65 insertItem(KGlobal::locale()->formatTime(timeEntry)); 65 insertItem(KGlobal::locale()->formatTime(timeEntry));
66 timeEntry = timeEntry.addSecs(60*15); 66 timeEntry = timeEntry.addSecs(60*15);
67 } while (!timeEntry.isNull()); 67 } while (!timeEntry.isNull());
68 // Add end of day. 68 // Add end of day.
69 insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); 69 insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) );
70 70
71 updateText(); 71 updateText();
72 setFocusPolicy(QWidget::StrongFocus); 72 setFocusPolicy(QWidget::StrongFocus);
73 73
74 connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); 74 connect(this, SIGNAL(activated(int)), this, SLOT(activ(int)));
75 connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); 75 connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int)));
76 connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); 76 connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText()));
77 QFontMetrics fm ( font() ); 77 QFontMetrics fm ( font() );
78 QString timeString = "24:00"; 78 QString timeString = "24:00";
79 if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ) 79 if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 )
80 timeString = "02:00pm"; 80 timeString = "02:00pm";
81 int addSpace = 32; 81 int addSpace = 32;
82 if ( QApplication::desktop()->width() > 320 ) 82 if ( QApplication::desktop()->width() > 320 )
83 timeString += ":00"; 83 timeString += ":00";
84 setFixedWidth(fm.width( timeString ) + 32 ); 84 setFixedWidth(fm.width( timeString ) + 32 );
85 85
86 // Highlight Background and Textcolor change from default 86 // Highlight Background and Textcolor change from default
87 QPalette palette = QWidget::palette(); 87 QPalette palette = QWidget::palette();
88 unsigned char red, green, blue; 88 unsigned char red, green, blue;
89 red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; 89 red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10;
90 green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; 90 green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10;
91 blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; 91 blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10;
92 palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); 92 palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) );
93 palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); 93 palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) );
94 setPalette( palette ); 94 setPalette( palette );
95} 95}
96 96
97KOTimeEdit::~KOTimeEdit() 97KOTimeEdit::~KOTimeEdit()
98{ 98{
99} 99}
100 100
101bool KOTimeEdit::hasTime() const 101bool KOTimeEdit::hasTime() const
102{ 102{
103 // Can't happen 103 // Can't happen
104 if ( currentText().isEmpty() ) return false; 104 if ( currentText().isEmpty() ) return false;
105 //if ( currentText() == mNoTimeString ) return false; 105 //if ( currentText() == mNoTimeString ) return false;
106 106
107 return true; // always 107 return true; // always
108} 108}
109 109
110QTime KOTimeEdit::getTime() const 110QTime KOTimeEdit::getTime() const
111{ 111{
112 return KGlobal::locale()->readTime(currentText()); 112 return KGlobal::locale()->readTime(currentText());
113} 113}
114/* 114/*
115QSizePolicy KOTimeEdit::sizePolicy() const 115QSizePolicy KOTimeEdit::sizePolicy() const
116{ 116{
117 // Set size policy to Fixed, because edit cannot contain more text than the 117 // Set size policy to Fixed, because edit cannot contain more text than the
118 // string representing the time. It doesn't make sense to provide more space. 118 // string representing the time. It doesn't make sense to provide more space.
119 QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); 119 QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
120 120
121 return sizePolicy; 121 return sizePolicy;
122} 122}
123*/ 123*/
124void KOTimeEdit::setTime(QTime newTime) 124void KOTimeEdit::setTime(QTime newTime)
125{ 125{
126 if ( mTime != newTime ) 126 if ( mTime != newTime )
127 { 127 {
128 mTime = newTime; 128 mTime = newTime;
129 updateText(); 129 updateText();
130 } 130 }
131 131
132} 132}
133 133
134void KOTimeEdit::activ(int i) 134void KOTimeEdit::activ(int i)
135{ 135{
136 // The last entry, 23:59, is a special case 136 // The last entry, 23:59, is a special case
137 if( i == count() - 1 ) 137 if( i == count() - 1 )
138 mTime = QTime( 23, 59, 0 ); 138 mTime = QTime( 23, 59, 0 );
139 else 139 else
140 mTime = QTime(0,0,0).addSecs(i*15*60); 140 mTime = QTime(0,0,0).addSecs(i*15*60);
141 emit timeChanged(mTime); 141 emit timeChanged(mTime);
142} 142}
143 143
144void KOTimeEdit::hilit(int ) 144void KOTimeEdit::hilit(int )
145{ 145{
146 // we don't currently need to do anything here. 146 // we don't currently need to do anything here.
147} 147}
148 148
149void KOTimeEdit::addTime(QTime qt, bool update) 149void KOTimeEdit::addTime(QTime qt, bool update)
150{ 150{
151 // Calculate the new time. 151 // Calculate the new time.
152 //qDebug("add h %d min %d ", qt.hour(),qt.minute() ); 152 //qDebug("add h %d min %d ", qt.hour(),qt.minute() );
153 mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600); 153 mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600);
154 // if ( update ) 154 // if ( update )
155 updateText(); 155 updateText();
156 emit timeChanged(mTime); 156 emit timeChanged(mTime);
157} 157}
158 158
159void KOTimeEdit::subTime(QTime qt, bool update) 159void KOTimeEdit::subTime(QTime qt, bool update)
160{ 160{
161 int h, m; 161 int h, m;
162 //qDebug("sub h %d min %d ", qt.hour(),qt.minute() ); 162 //qDebug("sub h %d min %d ", qt.hour(),qt.minute() );
163 163
164 mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600)); 164 mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600));
165 // store the newly calculated time. 165 // store the newly calculated time.
166 // mTime.setHMS(h, m, 0); 166 // mTime.setHMS(h, m, 0);
167 //if ( update ) 167 //if ( update )
168 updateText(); 168 updateText();
169 emit timeChanged(mTime); 169 emit timeChanged(mTime);
170} 170}
171 171
172// void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * ) 172// void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * )
173// { 173// {
174// qDebug("mouseReleaseEvent ( QMouseEvent * ) "); 174// qDebug("mouseReleaseEvent ( QMouseEvent * ) ");
175// } 175// }
176 176
177// void KOTimeEdit::focusInEvent ( QFocusEvent * ) 177// void KOTimeEdit::focusInEvent ( QFocusEvent * )
178// { 178// {
179// qDebug("focusInEvent ( QFocusEvent * ) "); 179// qDebug("focusInEvent ( QFocusEvent * ) ");
180// } 180// }
181 181
182void KOTimeEdit::keyReleaseEvent(QKeyEvent *e) 182void KOTimeEdit::keyReleaseEvent(QKeyEvent *e)
183{ 183{
184 if ( !e->isAutoRepeat() ) { 184 if ( !e->isAutoRepeat() ) {
185 mFlagKeyPressed = false; 185 mFlagKeyPressed = false;
186 } 186 }
187 187
188} 188}
189void KOTimeEdit::setSelect( int from, int to ) 189void KOTimeEdit::setSelect( int from, int to )
190{ 190{
191 if ( KOPrefs::instance()->mHightlightDateTimeEdit) 191 if ( KOPrefs::instance()->mHightlightDateTimeEdit)
192 lineEdit()->setSelection( from , to ); 192 lineEdit()->setSelection( from , to );
193} 193}
194 194
195 195
196void KOTimeEdit::keyPressEvent(QKeyEvent *e) 196void KOTimeEdit::keyPressEvent(QKeyEvent *e)
197{ 197{
198 198
199 qApp->processEvents(); 199 qApp->processEvents();
200 bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ); 200 bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 );
201 int maxpos = hour12Format?7:5; 201 int maxpos = hour12Format?7:5;
202 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 202 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
203 e->ignore(); 203 e->ignore();
204 // qDebug(" ignore %d",e->isAutoRepeat() ); 204 // qDebug(" ignore %d",e->isAutoRepeat() );
205 return; 205 return;
206 } 206 }
207 if (! e->isAutoRepeat() ) { 207 if (! e->isAutoRepeat() ) {
208 mFlagKeyPressed = true; 208 mFlagKeyPressed = true;
209 } 209 }
210 // Tap -> Focus Next Widget 210 // Tap -> Focus Next Widget
211 if ( e->key() == Key_Tab ) { 211 if ( e->key() == Key_Tab ) {
212 QComboBox::keyPressEvent(e); 212 QComboBox::keyPressEvent(e);
213 return; 213 return;
214 } 214 }
215 215
216 // save Text from QLineEdit and CursorPosition 216 // save Text from QLineEdit and CursorPosition
217 QString text = lineEdit()->text(); 217 QString text = lineEdit()->text();
218 int cpos = lineEdit()->cursorPosition(); 218 int cpos = lineEdit()->cursorPosition();
219 // qDebug("cpos %d ", cpos); 219 // qDebug("cpos %d ", cpos);
220 220
221 // Switch for arrows, backspace and escape 221 // Switch for arrows, backspace and escape
222 switch(e->key()) { 222 switch(e->key()) {
223 case Key_Escape: 223 case Key_Escape:
224 lineEdit()->deselect(); 224 lineEdit()->deselect();
225 case Key_Tab: 225 case Key_Tab:
226 QComboBox::keyPressEvent(e); 226 QComboBox::keyPressEvent(e);
227 break; 227 break;
228 case Key_Up: 228 case Key_Up:
229 if ( e->state () == Qt::ControlButton ) { 229 if ( e->state () == Qt::ControlButton ) {
230 addTime(QTime(0,15,0), false ); 230 addTime(QTime(0,15,0), false );
231 lineEdit()->setCursorPosition(3); 231 lineEdit()->setCursorPosition(3);
232 setSelect( 3 , 2 ); 232 setSelect( 3 , 2 );
233 } 233 }
234 else 234 else
235 if ( e->state () == Qt::ShiftButton ) { 235 if ( e->state () == Qt::ShiftButton ) {
236 addTime(QTime(1,0,0), false ); 236 addTime(QTime(1,0,0), false );
237 lineEdit()->setCursorPosition(0); 237 lineEdit()->setCursorPosition(0);
238 setSelect( 0 , 2 ); 238 setSelect( 0 , 2 );
239 } 239 }
240 else 240 else
241 // switch time up, cursor location depend 241 // switch time up, cursor location depend
242 switch (cpos) { 242 switch (cpos) {
243 case 7: 243 case 7:
244 case 6: 244 case 6:
245 case 5: 245 case 5:
246 if(!hour12Format) { 246 if(!hour12Format) {
247 lineEdit()->setCursorPosition(cpos = 4); 247 lineEdit()->setCursorPosition(cpos = 4);
248 } else { 248 } else {
249 addTime(QTime(12,0,0), false ); 249 addTime(QTime(12,0,0), false );
250 setSelect ( 5 , 2 ); 250 setSelect ( 5 , 2 );
251 break; 251 break;
252 } 252 }
253 case 4: 253 case 4:
254 addTime(QTime(0,1,0), false ); 254 addTime(QTime(0,1,0), false );
255 setSelect ( cpos , 1 ); 255 setSelect ( cpos , 1 );
256 break; 256 break;
257 case 3: 257 case 3:
258 addTime(QTime(0,10,0), false ); 258 addTime(QTime(0,10,0), false );
259 setSelect ( cpos , 1 ); 259 setSelect ( cpos , 1 );
260 break; 260 break;
261 case 2: 261 case 2:
262 lineEdit()->setCursorPosition(--cpos); 262 lineEdit()->setCursorPosition(--cpos);
263 case 1: 263 case 1:
264 case 0: 264 case 0:
265 addTime(QTime(1,0,0), false ); 265 addTime(QTime(1,0,0), false );
266 setSelect ( 0, 2 ); 266 setSelect ( 0, 2 );
267 break; 267 break;
268 } 268 }
269 break; 269 break;
270 case Key_Down: 270 case Key_Down:
271 if ( e->state () == Qt::ControlButton ) { 271 if ( e->state () == Qt::ControlButton ) {
272 subTime(QTime(0,15,0), false ); 272 subTime(QTime(0,15,0), false );
273 lineEdit()->setCursorPosition(3); 273 lineEdit()->setCursorPosition(3);
274 setSelect( 3 , 2 ); 274 setSelect( 3 , 2 );
275 } 275 }
276 else 276 else
277 if ( e->state () == Qt::ShiftButton ) { 277 if ( e->state () == Qt::ShiftButton ) {
278 subTime(QTime(1,0,0), false ); 278 subTime(QTime(1,0,0), false );
279 lineEdit()->setCursorPosition(0); 279 lineEdit()->setCursorPosition(0);
280 setSelect( 0 , 2 ); 280 setSelect( 0 , 2 );
281 } 281 }
282 else 282 else
283 // switch time down, cursor location depend 283 // switch time down, cursor location depend
284 switch (cpos) { 284 switch (cpos) {
285 case 7: 285 case 7:
286 case 6: 286 case 6:
287 case 5: 287 case 5:
288 if(!hour12Format) { 288 if(!hour12Format) {
289 lineEdit()->setCursorPosition(cpos = 4); 289 lineEdit()->setCursorPosition(cpos = 4);
290 } else { 290 } else {
291 subTime(QTime(12,0,0), false ); 291 subTime(QTime(12,0,0), false );
292 setSelect ( 5 , 2 ); 292 setSelect ( 5 , 2 );
293 break; 293 break;
294 } 294 }
295 case 4: 295 case 4:
296 subTime(QTime(0,1,0), false ); 296 subTime(QTime(0,1,0), false );
297 setSelect ( cpos , 1 ); 297 setSelect ( cpos , 1 );
298 break; 298 break;
299 case 3: 299 case 3:
300 subTime(QTime(0,10,0), false ); 300 subTime(QTime(0,10,0), false );
301 setSelect ( cpos , 1 ); 301 setSelect ( cpos , 1 );
302 break; 302 break;
303 case 2: 303 case 2:
304 lineEdit()->setCursorPosition(--cpos); 304 lineEdit()->setCursorPosition(--cpos);
305 case 1: 305 case 1:
306 case 0: 306 case 0:
307 subTime(QTime(1,0,0), false ); 307 subTime(QTime(1,0,0), false );
308 setSelect ( 0 , 2 ); 308 setSelect ( 0 , 2 );
309 break; 309 break;
310 } 310 }
311 break; 311 break;
312 // set cursor to correct place 312 // set cursor to correct place
313 case Key_Left: 313 case Key_Left:
314 if ( cpos == 3 ) 314 if ( cpos == 3 )
315 --cpos; 315 --cpos;
316 if ( cpos > 0) { 316 if ( cpos > 0) {
317 lineEdit()->setCursorPosition(--cpos); 317 lineEdit()->setCursorPosition(--cpos);
318 setSelect ( cpos , 1 ); 318 setSelect ( cpos , 1 );
319 } 319 }
320 else 320 else
321 setSelect ( 0 , 1 ); 321 setSelect ( 0 , 1 );
322 break; 322 break;
323 // set cursor to correct place 323 // set cursor to correct place
324 case Key_Right: 324 case Key_Right:
325 if ( cpos == 1 ) 325 if ( cpos == 1 )
326 ++cpos; 326 ++cpos;
327 if ( cpos < maxpos ) { 327 if ( cpos < maxpos ) {
328 lineEdit()->setCursorPosition(++cpos); 328 lineEdit()->setCursorPosition(++cpos);
329 setSelect ( cpos , 1 ); 329 setSelect ( cpos , 1 );
330 } 330 }
331 break; 331 break;
332 // rest 332 // rest
333 case Key_Prior: 333 case Key_Prior:
334 subTime(QTime(1,0,0)); 334 subTime(QTime(1,0,0));
335 break; 335 break;
336 case Key_Next: 336 case Key_Next:
337 addTime(QTime(1,0,0)); 337 addTime(QTime(1,0,0));
338 break; 338 break;
339 case Key_Backspace: 339 case Key_Backspace:
340 qDebug("+++++++++++back ");
341 if ( cpos > 0) { 340 if ( cpos > 0) {
342 if ( cpos == 3 ) 341 if ( cpos == 3 )
343 --cpos; 342 --cpos;
344 if ( cpos > 5) 343 if ( cpos > 5)
345 cpos = 5; 344 cpos = 5;
346 text.at( cpos-1 ) = '0'; 345 text.at( cpos-1 ) = '0';
347 lineEdit()->setText( text ); 346 lineEdit()->setText( text );
348 lineEdit()->setCursorPosition(--cpos); 347 lineEdit()->setCursorPosition(--cpos);
349 setSelect ( cpos , 1 ); 348 setSelect ( cpos , 1 );
350 changedText(); 349 changedText();
351 qDebug("---------back ");
352 } 350 }
353 break; 351 break;
354 } // switch arrows 352 } // switch arrows
355 353
356 // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos 354 // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos
357 if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) { 355 if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) {
358 lineEdit()->deselect(); 356 lineEdit()->deselect();
359 cpos = 0; 357 cpos = 0;
360 lineEdit()->setCursorPosition(cpos); 358 lineEdit()->setCursorPosition(cpos);
361 setSelect(cpos , 1); 359 setSelect(cpos , 1);
362 } 360 }
363 361
364 if ( cpos == 2 ) { 362 if ( cpos == 2 ) {
365 lineEdit()->setCursorPosition(++cpos); 363 lineEdit()->setCursorPosition(++cpos);
366 } 364 }
367 365
368 // num keys when cursorPos preEnd 366 // num keys when cursorPos preEnd
369 if ( cpos < 5 ) { 367 if ( cpos < 5 ) {
370 // switch another keys 368 // switch another keys
371 switch(e->key()) { 369 switch(e->key()) {
372 case Key_Delete: 370 case Key_Delete:
373 text.at( cpos ) = '0'; 371 text.at( cpos ) = '0';
374 lineEdit()->setText( text ); 372 lineEdit()->setText( text );
375 lineEdit()->setCursorPosition(cpos); 373 lineEdit()->setCursorPosition(cpos);
376 setSelect ( cpos , 1 ); 374 setSelect ( cpos , 1 );
377 changedText(); 375 changedText();
378 break; 376 break;
379 case Key_9: 377 case Key_9:
380 case Key_8: 378 case Key_8:
381 case Key_7: 379 case Key_7:
382 case Key_6: 380 case Key_6:
383 if ( !(cpos == 1 || cpos == 4) ) 381 if ( !(cpos == 1 || cpos == 4) )
384 return; 382 return;
385 if ( cpos == 1 && text.at( 0 ) > '1') 383 if ( cpos == 1 && text.at( 0 ) > '1')
386 text.at( 0 ) = '1'; 384 text.at( 0 ) = '1';
387 case Key_5: 385 case Key_5:
388 case Key_4: 386 case Key_4:
389 case Key_3: 387 case Key_3:
390 if ( cpos < 1 ) 388 if ( cpos < 1 )
391 return; 389 return;
392 if ( hour12Format && cpos == 1 ) 390 if ( hour12Format && cpos == 1 )
393 return; 391 return;
394 case Key_2: 392 case Key_2:
395 if ( hour12Format && cpos == 0 ) 393 if ( hour12Format && cpos == 0 )
396 return; 394 return;
397 if ( cpos == 0 && text.at( 1 ) > '3') 395 if ( cpos == 0 && text.at( 1 ) > '3')
398 text.at( 1 ) = '3'; 396 text.at( 1 ) = '3';
399 case Key_1: 397 case Key_1:
400 case Key_0: 398 case Key_0:
401 if ( hour12Format ) { 399 if ( hour12Format ) {
402 if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' ) 400 if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' )
403 return; 401 return;
404 if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' ) 402 if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' )
405 text.at( 1 ) = '1'; 403 text.at( 1 ) = '1';
406 } 404 }
407 text.at( cpos ) = QChar ( e->key() ); 405 text.at( cpos ) = QChar ( e->key() );
408 lineEdit()->setText( text ); 406 lineEdit()->setText( text );
409 if ( cpos == 1 ) 407 if ( cpos == 1 )
410 ++cpos; 408 ++cpos;
411 if ( cpos < 5) 409 if ( cpos < 5)
412 lineEdit()->setCursorPosition(++cpos); 410 lineEdit()->setCursorPosition(++cpos);
413 setSelect( cpos , 1 ); 411 setSelect( cpos , 1 );
414 changedText(); 412 changedText();
415 break; 413 break;
416 case Key_Home: 414 case Key_Home:
417 lineEdit()->setCursorPosition(0); 415 lineEdit()->setCursorPosition(0);
418 setSelect( cpos , 1 ); 416 setSelect( cpos , 1 );
419 break; 417 break;
420 case Key_End: 418 case Key_End:
421 lineEdit()->setCursorPosition(5); 419 lineEdit()->setCursorPosition(5);
422 lineEdit()->deselect(); 420 lineEdit()->deselect();
423 break; 421 break;
424 default: 422 default:
425// QComboBox::keyPressEvent(e); 423// QComboBox::keyPressEvent(e);
426 break; 424 break;
427 } // switch num keys 425 } // switch num keys
428 } else if ( cpos == 5 ) {// if cpos < 5 426 } else if ( cpos == 5 ) {// if cpos < 5
429 if ( hour12Format ) { 427 if ( hour12Format ) {
430 if ( e->key() == Key_A ) { 428 if ( e->key() == Key_A ) {
431 text.at( 5 ) = 'a'; 429 text.at( 5 ) = 'a';
432 lineEdit()->setText( text ); 430 lineEdit()->setText( text );
433 lineEdit()->setCursorPosition(5); 431 lineEdit()->setCursorPosition(5);
434 432
435 } else if ( e->key() == Key_P ) { 433 } else if ( e->key() == Key_P ) {
436 text.at( 5 ) = 'p'; 434 text.at( 5 ) = 'p';
437 lineEdit()->setText( text ); 435 lineEdit()->setText( text );
438 lineEdit()->setCursorPosition(5); 436 lineEdit()->setCursorPosition(5);
439 437
440 } 438 }
441 } 439 }
442 } 440 }
443 441
444 442
445} 443}
446 444
447void KOTimeEdit::updateText() 445void KOTimeEdit::updateText()
448{ 446{
449 listBox()->blockSignals( true ); 447 listBox()->blockSignals( true );
450 blockSignals( true ); 448 blockSignals( true );
451 QString s = KGlobal::locale()->formatTime(mTime); 449 QString s = KGlobal::locale()->formatTime(mTime);
452 // Set the text but without emitting signals, nor losing the cursor position 450 // Set the text but without emitting signals, nor losing the cursor position
453 QLineEdit *line = lineEdit(); 451 QLineEdit *line = lineEdit();
454 line->blockSignals(true); 452 line->blockSignals(true);
455 int pos = line->cursorPosition(); 453 int pos = line->cursorPosition();
456 setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); 454 setCurrentItem((mTime.hour()*4)+(mTime.minute()/15));
457 line->setText(s); 455 line->setText(s);
458 line->setCursorPosition(pos); 456 line->setCursorPosition(pos);
459 line->blockSignals(false); 457 line->blockSignals(false);
460 blockSignals( false ); 458 blockSignals( false );
461 listBox()->blockSignals( false ); 459 listBox()->blockSignals( false );
462 460
463} 461}
464 462
465void KOTimeEdit::changedText() 463void KOTimeEdit::changedText()
466{ 464{
467 int pos = lineEdit()->cursorPosition(); 465 int pos = lineEdit()->cursorPosition();
468 mTime = getTime(); 466 mTime = getTime();
469 blockSignals( true ); 467 blockSignals( true );
470 QString text = lineEdit()->text(); 468 QString text = lineEdit()->text();
471 setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); 469 setCurrentItem((mTime.hour()*4)+(mTime.minute()/15));
472 lineEdit()->setText(text); 470 lineEdit()->setText(text);
473 blockSignals( false ); 471 blockSignals( false );
474 emit timeChanged(mTime); 472 emit timeChanged(mTime);
475 lineEdit()->setCursorPosition(pos); 473 lineEdit()->setCursorPosition(pos);
476} 474}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 8e5d108..95bef66 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1963 +1,1961 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "ktoolbar.h" 60#include "ktoolbar.h"
61#include "klocale.h" 61#include "klocale.h"
62#include "kconfig.h" 62#include "kconfig.h"
63#include "simplealarmclient.h"
64#include "externalapphandler.h" 63#include "externalapphandler.h"
65 64
66using namespace KCal; 65using namespace KCal;
67#ifndef _WIN32_ 66#ifndef _WIN32_
68#include <unistd.h> 67#include <unistd.h>
69#else 68#else
70#ifdef _OL_IMPORT_ 69#ifdef _OL_IMPORT_
71#include "koimportoldialog.h" 70#include "koimportoldialog.h"
72#endif 71#endif
73#endif 72#endif
74#include "mainwindow.h" 73#include "mainwindow.h"
75 74
76 75
77class KOex2phonePrefs : public QDialog 76class KOex2phonePrefs : public QDialog
78{ 77{
79 public: 78 public:
80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
81 QDialog( parent, name, true ) 80 QDialog( parent, name, true )
82 { 81 {
83 setCaption( i18n("Export to phone options") ); 82 setCaption( i18n("Export to phone options") );
84 QVBoxLayout* lay = new QVBoxLayout( this ); 83 QVBoxLayout* lay = new QVBoxLayout( this );
85 lay->setSpacing( 3 ); 84 lay->setSpacing( 3 );
86 lay->setMargin( 3 ); 85 lay->setMargin( 3 );
87 QLabel *lab; 86 QLabel *lab;
88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
89 lab->setAlignment (AlignHCenter ); 88 lab->setAlignment (AlignHCenter );
90 QHBox* temphb; 89 QHBox* temphb;
91 temphb = new QHBox( this ); 90 temphb = new QHBox( this );
92 new QLabel( i18n("I/O device: "), temphb ); 91 new QLabel( i18n("I/O device: "), temphb );
93 mPhoneDevice = new QLineEdit( temphb); 92 mPhoneDevice = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 93 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 94 temphb = new QHBox( this );
96 new QLabel( i18n("Connection: "), temphb ); 95 new QLabel( i18n("Connection: "), temphb );
97 mPhoneConnection = new QLineEdit( temphb); 96 mPhoneConnection = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 97 lay->addWidget( temphb );
99 temphb = new QHBox( this ); 98 temphb = new QHBox( this );
100 new QLabel( i18n("Model(opt.): "), temphb ); 99 new QLabel( i18n("Model(opt.): "), temphb );
101 mPhoneModel = new QLineEdit( temphb); 100 mPhoneModel = new QLineEdit( temphb);
102 lay->addWidget( temphb ); 101 lay->addWidget( temphb );
103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
104 mWriteBackFuture->setChecked( true ); 103 mWriteBackFuture->setChecked( true );
105 lay->addWidget( mWriteBackFuture ); 104 lay->addWidget( mWriteBackFuture );
106 temphb = new QHBox( this ); 105 temphb = new QHBox( this );
107 new QLabel( i18n("Max. weeks in future: ") , temphb ); 106 new QLabel( i18n("Max. weeks in future: ") , temphb );
108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
109 mWriteBackFutureWeeks->setValue( 8 ); 108 mWriteBackFutureWeeks->setValue( 8 );
110 lay->addWidget( temphb ); 109 lay->addWidget( temphb );
111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
112 lab->setAlignment (AlignHCenter ); 111 lab->setAlignment (AlignHCenter );
113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
114 lay->addWidget( ok ); 113 lay->addWidget( ok );
115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
116 lay->addWidget( cancel ); 115 lay->addWidget( cancel );
117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
119 resize( 220, 240 ); 118 resize( 220, 240 );
120 qApp->processEvents(); 119 qApp->processEvents();
121 int dw = QApplication::desktop()->width(); 120 int dw = QApplication::desktop()->width();
122 int dh = QApplication::desktop()->height(); 121 int dh = QApplication::desktop()->height();
123 move( (dw-width())/2, (dh - height() )/2 ); 122 move( (dw-width())/2, (dh - height() )/2 );
124 } 123 }
125 124
126public: 125public:
127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
128 QCheckBox* mWriteBackFuture; 127 QCheckBox* mWriteBackFuture;
129 QSpinBox* mWriteBackFutureWeeks; 128 QSpinBox* mWriteBackFutureWeeks;
130}; 129};
131 130
132int globalFlagBlockStartup; 131int globalFlagBlockStartup;
133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 132MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
134 QMainWindow( parent, name ) 133 QMainWindow( parent, name )
135{ 134{
136 135
137 mClosed = false; 136 mClosed = false;
138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 137 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
139 QString confFile = locateLocal("config","korganizerrc"); 138 QString confFile = locateLocal("config","korganizerrc");
140 QFileInfo finf ( confFile ); 139 QFileInfo finf ( confFile );
141 bool showWarning = !finf.exists(); 140 bool showWarning = !finf.exists();
142 setIcon(SmallIcon( "ko24" ) ); 141 setIcon(SmallIcon( "ko24" ) );
143 mBlockAtStartup = true; 142 mBlockAtStartup = true;
144 mFlagKeyPressed = false; 143 mFlagKeyPressed = false;
145 setCaption("KO/Pi"); 144 setCaption("KO/Pi");
146 KOPrefs *p = KOPrefs::instance(); 145 KOPrefs *p = KOPrefs::instance();
147 KPimGlobalPrefs::instance()->setGlobalConfig(); 146 KPimGlobalPrefs::instance()->setGlobalConfig();
148 p->mCurrentDisplayedView = 0; 147 p->mCurrentDisplayedView = 0;
149 if ( p->mHourSize > 22 ) 148 if ( p->mHourSize > 22 )
150 p->mHourSize = 22; 149 p->mHourSize = 22;
151 QMainWindow::ToolBarDock tbd; 150 QMainWindow::ToolBarDock tbd;
152 if ( p->mToolBarHor ) { 151 if ( p->mToolBarHor ) {
153 if ( p->mToolBarUp ) 152 if ( p->mToolBarUp )
154 tbd = Bottom; 153 tbd = Bottom;
155 else 154 else
156 tbd = Top; 155 tbd = Top;
157 } 156 }
158 else { 157 else {
159 if ( p->mToolBarUp ) 158 if ( p->mToolBarUp )
160 tbd = Right; 159 tbd = Right;
161 else 160 else
162 tbd = Left; 161 tbd = Left;
163 } 162 }
164 if ( KOPrefs::instance()->mUseAppColors ) 163 if ( KOPrefs::instance()->mUseAppColors )
165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 164 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
166 globalFlagBlockStartup = 1; 165 globalFlagBlockStartup = 1;
167 iconToolBar = new QPEToolBar( this ); 166 iconToolBar = new QPEToolBar( this );
168 addToolBar (iconToolBar , tbd ); 167 addToolBar (iconToolBar , tbd );
169 168
170#ifdef DESKTOP_VERSION 169#ifdef DESKTOP_VERSION
171 if ( KOPrefs::instance()->mShowIconFilter ) 170 if ( KOPrefs::instance()->mShowIconFilter )
172#else 171#else
173 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) 172 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar )
174#endif 173#endif
175 174
176{ 175{
177 if ( p->mToolBarHorF ) { 176 if ( p->mToolBarHorF ) {
178 if ( p->mToolBarUpF ) 177 if ( p->mToolBarUpF )
179 tbd = Bottom; 178 tbd = Bottom;
180 else 179 else
181 tbd = Top; 180 tbd = Top;
182 } 181 }
183 else { 182 else {
184 if ( p->mToolBarUpF ) 183 if ( p->mToolBarUpF )
185 tbd = Right; 184 tbd = Right;
186 else 185 else
187 tbd = Left; 186 tbd = Left;
188 } 187 }
189 filterToolBar = new QPEToolBar ( this ); 188 filterToolBar = new QPEToolBar ( this );
190 filterMenubar = new QPEMenuBar( filterToolBar ); 189 filterMenubar = new QPEMenuBar( filterToolBar );
191 QFontMetrics fm ( filterMenubar->font() ); 190 QFontMetrics fm ( filterMenubar->font() );
192 191
193 filterPopupMenu = new QPopupMenu( this ); 192 filterPopupMenu = new QPopupMenu( this );
194 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 193 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
195 QString addTest = "Ax"; 194 QString addTest = "Ax";
196#ifdef DESKTOP_VERSION 195#ifdef DESKTOP_VERSION
197 addTest = "AAAx"; 196 addTest = "AAAx";
198#endif 197#endif
199 filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) ); 198 filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) );
200 addToolBar (filterToolBar , tbd ); 199 addToolBar (filterToolBar , tbd );
201 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 200 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
202 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 201 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
203 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 202 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
204 filterToolBar->hide(); 203 filterToolBar->hide();
205 } else { 204 } else {
206 filterToolBar = 0; 205 filterToolBar = 0;
207 filterMenubar = 0; 206 filterMenubar = 0;
208 filterPopupMenu = 0; 207 filterPopupMenu = 0;
209 } 208 }
210 if ( p->mShowIconOnetoolbar ) { 209 if ( p->mShowIconOnetoolbar ) {
211 viewToolBar = iconToolBar ; 210 viewToolBar = iconToolBar ;
212 navigatorToolBar = iconToolBar ; 211 navigatorToolBar = iconToolBar ;
213 } else { 212 } else {
214#ifndef DESKTOP_VERSION 213#ifndef DESKTOP_VERSION
215 setToolBarsMovable( false ); 214 setToolBarsMovable( false );
216#endif 215#endif
217 if ( p->mToolBarHorV ) { 216 if ( p->mToolBarHorV ) {
218 if ( p->mToolBarUpV ) 217 if ( p->mToolBarUpV )
219 tbd = Bottom; 218 tbd = Bottom;
220 else 219 else
221 tbd = Top; 220 tbd = Top;
222 } 221 }
223 else { 222 else {
224 if ( p->mToolBarUpV ) 223 if ( p->mToolBarUpV )
225 tbd = Right; 224 tbd = Right;
226 else 225 else
227 tbd = Left; 226 tbd = Left;
228 } 227 }
229 viewToolBar = new QPEToolBar( this ); 228 viewToolBar = new QPEToolBar( this );
230 addToolBar (viewToolBar , tbd ); 229 addToolBar (viewToolBar , tbd );
231 if ( p->mToolBarHorN ) { 230 if ( p->mToolBarHorN ) {
232 if ( p->mToolBarUpN ) 231 if ( p->mToolBarUpN )
233 tbd = Bottom; 232 tbd = Bottom;
234 else 233 else
235 tbd = Top; 234 tbd = Top;
236 } 235 }
237 else { 236 else {
238 if ( p->mToolBarUpN ) 237 if ( p->mToolBarUpN )
239 tbd = Right; 238 tbd = Right;
240 else 239 else
241 tbd = Left; 240 tbd = Left;
242 } 241 }
243 navigatorToolBar = new QPEToolBar( this ); 242 navigatorToolBar = new QPEToolBar( this );
244 addToolBar (navigatorToolBar , tbd ); 243 addToolBar (navigatorToolBar , tbd );
245 } 244 }
246 245
247 246
248 247
249 mCalendarModifiedFlag = false; 248 mCalendarModifiedFlag = false;
250 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 249 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
251 splash->setAlignment ( AlignCenter ); 250 splash->setAlignment ( AlignCenter );
252 setCentralWidget( splash ); 251 setCentralWidget( splash );
253#ifndef DESKTOP_VERSION 252#ifndef DESKTOP_VERSION
254 showMaximized(); 253 showMaximized();
255#endif 254#endif
256 255
257 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 256 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
258 setDefaultPreferences(); 257 setDefaultPreferences();
259 mCalendar = new CalendarLocal(); 258 mCalendar = new CalendarLocal();
260 mView = new CalendarView( mCalendar, this,"mCalendar " ); 259 mView = new CalendarView( mCalendar, this,"mCalendar " );
261 mView->hide(); 260 mView->hide();
262 //mView->resize(splash->size() ); 261 //mView->resize(splash->size() );
263 initActions(); 262 initActions();
264 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 263 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
265 mSyncManager->setBlockSave(false); 264 mSyncManager->setBlockSave(false);
266 mView->setSyncManager(mSyncManager); 265 mView->setSyncManager(mSyncManager);
267#ifndef DESKTOP_VERSION 266#ifndef DESKTOP_VERSION
268 iconToolBar->show(); 267 iconToolBar->show();
269 qApp->processEvents(); 268 qApp->processEvents();
270#endif 269#endif
271 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 270 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
272 int vh = height() ; 271 int vh = height() ;
273 int vw = width(); 272 int vw = width();
274 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 273 //qDebug("Toolbar hei %d ",iconToolBar->height() );
275 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 274 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
276 vh -= iconToolBar->height(); 275 vh -= iconToolBar->height();
277 } else { 276 } else {
278 vw -= iconToolBar->height(); 277 vw -= iconToolBar->height();
279 } 278 }
280 //mView->setMaximumSize( splash->size() ); 279 //mView->setMaximumSize( splash->size() );
281 //mView->resize( splash->size() ); 280 //mView->resize( splash->size() );
282 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 281 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
283 mView->readSettings(); 282 mView->readSettings();
284 bool newFile = false; 283 bool newFile = false;
285 if( !QFile::exists( defaultFileName() ) ) { 284 if( !QFile::exists( defaultFileName() ) ) {
286 QFileInfo finfo ( defaultFileName() ); 285 QFileInfo finfo ( defaultFileName() );
287 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 286 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
288 qDebug("oldfile %s ", oldFile.latin1());
289 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 287 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
290 finfo.setFile( oldFile ); 288 finfo.setFile( oldFile );
291 if (finfo.exists() ) { 289 if (finfo.exists() ) {
292 KMessageBox::information( this, message); 290 KMessageBox::information( this, message);
293 mView->openCalendar( oldFile ); 291 mView->openCalendar( oldFile );
294 qApp->processEvents(); 292 qApp->processEvents();
295 } else { 293 } else {
296 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 294 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
297 finfo.setFile( oldFile ); 295 finfo.setFile( oldFile );
298 if (finfo.exists() ) { 296 if (finfo.exists() ) {
299 KMessageBox::information( this, message); 297 KMessageBox::information( this, message);
300 mView->openCalendar( oldFile ); 298 mView->openCalendar( oldFile );
301 qApp->processEvents(); 299 qApp->processEvents();
302 } 300 }
303 } 301 }
304 mView->saveCalendar( defaultFileName() ); 302 mView->saveCalendar( defaultFileName() );
305 newFile = true; 303 newFile = true;
306 } 304 }
307 305
308 QTime neededSaveTime = QDateTime::currentDateTime().time(); 306 QTime neededSaveTime = QDateTime::currentDateTime().time();
309 mView->openCalendar( defaultFileName() ); 307 mView->openCalendar( defaultFileName() );
310 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 308 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
311 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 309 qDebug("KO: Calendar loading time: %d ms",msNeeded );
312 310
313 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 311 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
314 KOPrefs::instance()->setAllDefaults(); 312 KOPrefs::instance()->setAllDefaults();
315 int count = mView->addCategories(); 313 int count = mView->addCategories();
316 } 314 }
317 processIncidenceSelection( 0 ); 315 processIncidenceSelection( 0 );
318 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 316 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
319 SLOT( processIncidenceSelection( Incidence * ) ) ); 317 SLOT( processIncidenceSelection( Incidence * ) ) );
320 connect( mView, SIGNAL( modifiedChanged( bool ) ), 318 connect( mView, SIGNAL( modifiedChanged( bool ) ),
321 SLOT( slotModifiedChanged( bool ) ) ); 319 SLOT( slotModifiedChanged( bool ) ) );
322 320
323 321
324 connect( mView, SIGNAL( tempDisableBR(bool) ), 322 connect( mView, SIGNAL( tempDisableBR(bool) ),
325 SLOT( disableBR(bool) ) ); 323 SLOT( disableBR(bool) ) );
326 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 324 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
327 mView->setModified( false ); 325 mView->setModified( false );
328 mBlockAtStartup = false; 326 mBlockAtStartup = false;
329 mView->setModified( false ); 327 mView->setModified( false );
330 setCentralWidget( mView ); 328 setCentralWidget( mView );
331 globalFlagBlockStartup = 0; 329 globalFlagBlockStartup = 0;
332 mView->show(); 330 mView->show();
333 delete splash; 331 delete splash;
334 if ( newFile ) 332 if ( newFile )
335 mView->updateConfig(); 333 mView->updateConfig();
336 // qApp->processEvents(); 334 // qApp->processEvents();
337 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 335 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
338 //fillSyncMenu(); 336 //fillSyncMenu();
339 337
340 338
341 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 339 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
342 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 340 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
343 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 341 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
344 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 342 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
345 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 343 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
346 mSyncManager->setDefaultFileName( sentSyncFile()); 344 mSyncManager->setDefaultFileName( sentSyncFile());
347 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 345 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
348 mSyncManager->fillSyncMenu(); 346 mSyncManager->fillSyncMenu();
349 347
350 348
351 349
352 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 350 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
353 if ( showWarning ) { 351 if ( showWarning ) {
354 KMessageBox::information( this, 352 KMessageBox::information( this,
355 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 353 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
356 qApp->processEvents(); 354 qApp->processEvents();
357 mView->dialogManager()->showSyncOptions(); 355 mView->dialogManager()->showSyncOptions();
358 } 356 }
359 357
360 //US listen for result adressed from Ka/Pi 358 //US listen for result adressed from Ka/Pi
361#ifndef DESKTOP_VERSION 359#ifndef DESKTOP_VERSION
362 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 360 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
363#endif 361#endif
364#ifndef DESKTOP_VERSION 362#ifndef DESKTOP_VERSION
365 infrared = 0; 363 infrared = 0;
366#endif 364#endif
367 updateFilterToolbar(); 365 updateFilterToolbar();
368 updateWeek( mView->startDate() ); 366 updateWeek( mView->startDate() );
369 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 367 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
370 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 368 SLOT( updateWeekNum( const KCal::DateList & ) ) );
371 mBRdisabled = false; 369 mBRdisabled = false;
372 //toggleBeamReceive(); 370 //toggleBeamReceive();
373} 371}
374MainWindow::~MainWindow() 372MainWindow::~MainWindow()
375{ 373{
376 //qDebug("MainWindow::~MainWindow() "); 374 //qDebug("MainWindow::~MainWindow() ");
377 //save toolbar location 375 //save toolbar location
378 delete mCalendar; 376 delete mCalendar;
379 delete mSyncManager; 377 delete mSyncManager;
380#ifndef DESKTOP_VERSION 378#ifndef DESKTOP_VERSION
381 if ( infrared ) 379 if ( infrared )
382 delete infrared; 380 delete infrared;
383#endif 381#endif
384 382
385 383
386} 384}
387 385
388void MainWindow::disableBR(bool b) 386void MainWindow::disableBR(bool b)
389{ 387{
390#ifndef DESKTOP_VERSION 388#ifndef DESKTOP_VERSION
391 if ( b ) { 389 if ( b ) {
392 if ( infrared ) { 390 if ( infrared ) {
393 toggleBeamReceive(); 391 toggleBeamReceive();
394 mBRdisabled = true; 392 mBRdisabled = true;
395 } 393 }
396 mBRdisabled = true; 394 mBRdisabled = true;
397 } else { 395 } else {
398 if ( mBRdisabled ) { 396 if ( mBRdisabled ) {
399 mBRdisabled = false; 397 mBRdisabled = false;
400 //makes no sense,because other cal ap is probably running 398 //makes no sense,because other cal ap is probably running
401 // toggleBeamReceive(); 399 // toggleBeamReceive();
402 } 400 }
403 } 401 }
404#endif 402#endif
405 403
406} 404}
407bool MainWindow::beamReceiveEnabled() 405bool MainWindow::beamReceiveEnabled()
408{ 406{
409#ifndef DESKTOP_VERSION 407#ifndef DESKTOP_VERSION
410 return ( infrared != 0 ); 408 return ( infrared != 0 );
411#endif 409#endif
412 return false; 410 return false;
413} 411}
414 412
415void MainWindow::toggleBeamReceive() 413void MainWindow::toggleBeamReceive()
416{ 414{
417 if ( mBRdisabled ) 415 if ( mBRdisabled )
418 return; 416 return;
419#ifndef DESKTOP_VERSION 417#ifndef DESKTOP_VERSION
420 if ( infrared ) { 418 if ( infrared ) {
421 qDebug("disable BeamReceive "); 419 qDebug("KO: Disable BeamReceive ");
422 delete infrared; 420 delete infrared;
423 infrared = 0; 421 infrared = 0;
424 brAction->setOn(false); 422 brAction->setOn(false);
425 return; 423 return;
426 } 424 }
427 qDebug("enable BeamReceive "); 425 qDebug("KO: Enable BeamReceive ");
428 brAction->setOn(true); 426 brAction->setOn(true);
429 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 427 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
430 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 428 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
431#endif 429#endif
432} 430}
433void MainWindow::showMaximized () 431void MainWindow::showMaximized ()
434{ 432{
435#ifndef DESKTOP_VERSION 433#ifndef DESKTOP_VERSION
436 if ( ! globalFlagBlockStartup ) 434 if ( ! globalFlagBlockStartup )
437 if ( mClosed ) 435 if ( mClosed )
438 mView->goToday(); 436 mView->goToday();
439#endif 437#endif
440 QWidget::showMaximized () ; 438 QWidget::showMaximized () ;
441 mClosed = false; 439 mClosed = false;
442} 440}
443void MainWindow::closeEvent( QCloseEvent* ce ) 441void MainWindow::closeEvent( QCloseEvent* ce )
444{ 442{
445 443
446 444
447 445
448 if ( ! KOPrefs::instance()->mAskForQuit ) { 446 if ( ! KOPrefs::instance()->mAskForQuit ) {
449 saveOnClose(); 447 saveOnClose();
450 mClosed = true; 448 mClosed = true;
451 ce->accept(); 449 ce->accept();
452 return; 450 return;
453 451
454 } 452 }
455 453
456 switch( QMessageBox::information( this, "KO/Pi", 454 switch( QMessageBox::information( this, "KO/Pi",
457 i18n("Do you really want\nto close KO/Pi?"), 455 i18n("Do you really want\nto close KO/Pi?"),
458 i18n("Close"), i18n("No"), 456 i18n("Close"), i18n("No"),
459 0, 0 ) ) { 457 0, 0 ) ) {
460 case 0: 458 case 0:
461 saveOnClose(); 459 saveOnClose();
462 mClosed = true; 460 mClosed = true;
463 ce->accept(); 461 ce->accept();
464 break; 462 break;
465 case 1: 463 case 1:
466 ce->ignore(); 464 ce->ignore();
467 break; 465 break;
468 case 2: 466 case 2:
469 467
470 default: 468 default:
471 break; 469 break;
472 } 470 }
473 471
474 472
475} 473}
476 474
477void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 475void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
478{ 476{
479 QDataStream stream( data, IO_ReadOnly ); 477 QDataStream stream( data, IO_ReadOnly );
480 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 478 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
481 //QString datamess; 479 //QString datamess;
482 //qDebug("message "); 480 //qDebug("message ");
483 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 481 qDebug("KO: QCOP message received: %s ", cmsg.data() );
484 482
485 if ( cmsg == "setDocument(QString)" ) { 483 if ( cmsg == "setDocument(QString)" ) {
486 QDataStream stream( data, IO_ReadOnly ); 484 QDataStream stream( data, IO_ReadOnly );
487 QString fileName; 485 QString fileName;
488 stream >> fileName; 486 stream >> fileName;
489 //qDebug("filename %s ", fileName.latin1()); 487 //qDebug("filename %s ", fileName.latin1());
490 showMaximized(); 488 showMaximized();
491 raise(); 489 raise();
492 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 490 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
493 mSyncManager->slotSyncMenu( 1002 ); 491 mSyncManager->slotSyncMenu( 1002 );
494 return; 492 return;
495 } 493 }
496 494
497 if ( cmsg == "-writeFile" ) { 495 if ( cmsg == "-writeFile" ) {
498 // I made from the "-writeFile" an "-writeAlarm" 496 // I made from the "-writeFile" an "-writeAlarm"
499 mView->viewManager()->showWhatsNextView(); 497 mView->viewManager()->showWhatsNextView();
500 mCalendar->checkAlarmForIncidence( 0, true); 498 mCalendar->checkAlarmForIncidence( 0, true);
501 showMaximized(); 499 showMaximized();
502 raise(); 500 raise();
503 return; 501 return;
504 502
505 } 503 }
506 if ( cmsg == "-writeFileSilent" ) { 504 if ( cmsg == "-writeFileSilent" ) {
507 // I made from the "-writeFile" an "-writeAlarm" 505 // I made from the "-writeFile" an "-writeAlarm"
508 // mView->viewManager()->showWhatsNextView(); 506 // mView->viewManager()->showWhatsNextView();
509 mCalendar->checkAlarmForIncidence( 0, true); 507 mCalendar->checkAlarmForIncidence( 0, true);
510 //showMaximized(); 508 //showMaximized();
511 //raise(); 509 //raise();
512 hide(); 510 hide();
513 return; 511 return;
514 } 512 }
515 if ( cmsg == "-newCountdown" ) { 513 if ( cmsg == "-newCountdown" ) {
516 qDebug("newCountdown "); 514 qDebug("newCountdown ");
517 515
518 } 516 }
519 QString msg ; 517 QString msg ;
520 QString allmsg = cmsg; 518 QString allmsg = cmsg;
521 while ( allmsg.length() > 0 ) { 519 while ( allmsg.length() > 0 ) {
522 int nextC = allmsg.find( "-", 1 ); 520 int nextC = allmsg.find( "-", 1 );
523 if ( nextC == -1 ) { 521 if ( nextC == -1 ) {
524 msg = allmsg; 522 msg = allmsg;
525 allmsg = ""; 523 allmsg = "";
526 } else{ 524 } else{
527 msg = allmsg.left( nextC ); 525 msg = allmsg.left( nextC );
528 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 526 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
529 } 527 }
530 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 528 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
531 if ( msg == "-newEvent" ) { 529 if ( msg == "-newEvent" ) {
532 mView->newEvent(); 530 mView->newEvent();
533 } 531 }
534 if ( msg == "-newTodo" ) { 532 if ( msg == "-newTodo" ) {
535 mView->newTodo(); 533 mView->newTodo();
536 534
537 } 535 }
538 if ( msg == "-showWN" ) { 536 if ( msg == "-showWN" ) {
539 mView->viewManager()->showWhatsNextView(); 537 mView->viewManager()->showWhatsNextView();
540 } 538 }
541 if ( msg == "-showTodo" ) { 539 if ( msg == "-showTodo" ) {
542 mView->viewManager()->showTodoView(); 540 mView->viewManager()->showTodoView();
543 } 541 }
544 if ( msg == "-showList" ) { 542 if ( msg == "-showList" ) {
545 mView->viewManager()->showListView(); 543 mView->viewManager()->showListView();
546 } 544 }
547 else if ( msg == "-showDay" ) { 545 else if ( msg == "-showDay" ) {
548 mView->viewManager()->showDayView(); 546 mView->viewManager()->showDayView();
549 } 547 }
550 else if ( msg == "-showWWeek" ) { 548 else if ( msg == "-showWWeek" ) {
551 mView->viewManager()->showWorkWeekView(); 549 mView->viewManager()->showWorkWeekView();
552 } 550 }
553 else if ( msg == "-ringSync" ) { 551 else if ( msg == "-ringSync" ) {
554 mSyncManager->multiSync( false ); 552 mSyncManager->multiSync( false );
555 } 553 }
556 else if ( msg == "-showWeek" ) { 554 else if ( msg == "-showWeek" ) {
557 mView->viewManager()->showWeekView(); 555 mView->viewManager()->showWeekView();
558 } 556 }
559 else if ( msg == "-showTodo" ) { 557 else if ( msg == "-showTodo" ) {
560 mView->viewManager()->showTodoView(); 558 mView->viewManager()->showTodoView();
561 } 559 }
562 else if ( msg == "-showJournal" ) { 560 else if ( msg == "-showJournal" ) {
563 mView->dateNavigator()->selectDates( 1 ); 561 mView->dateNavigator()->selectDates( 1 );
564 mView->dateNavigator()->selectToday(); 562 mView->dateNavigator()->selectToday();
565 mView->viewManager()->showJournalView(); 563 mView->viewManager()->showJournalView();
566 } 564 }
567 else if ( msg == "-showKO" ) { 565 else if ( msg == "-showKO" ) {
568 mView->viewManager()->showNextXView(); 566 mView->viewManager()->showNextXView();
569 } 567 }
570 else if ( msg == "-showWNext" ) { 568 else if ( msg == "-showWNext" ) {
571 mView->viewManager()->showWhatsNextView(); 569 mView->viewManager()->showWhatsNextView();
572 } 570 }
573 else if ( msg == "nextView()" ) { 571 else if ( msg == "nextView()" ) {
574 mView->viewManager()->showNextView(); 572 mView->viewManager()->showNextView();
575 } 573 }
576 else if ( msg == "-showNextXView" ) { 574 else if ( msg == "-showNextXView" ) {
577 mView->viewManager()->showNextXView(); 575 mView->viewManager()->showNextXView();
578 } 576 }
579 577
580 578
581 } 579 }
582 580
583 showMaximized(); 581 showMaximized();
584 raise(); 582 raise();
585} 583}
586 584
587QPixmap MainWindow::loadPixmap( QString name ) 585QPixmap MainWindow::loadPixmap( QString name )
588{ 586{
589 return SmallIcon( name ); 587 return SmallIcon( name );
590 588
591} 589}
592void MainWindow::initActions() 590void MainWindow::initActions()
593{ 591{
594 //KOPrefs::instance()->mShowFullMenu 592 //KOPrefs::instance()->mShowFullMenu
595 iconToolBar->clear(); 593 iconToolBar->clear();
596 KOPrefs *p = KOPrefs::instance(); 594 KOPrefs *p = KOPrefs::instance();
597 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 595 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
598 596
599 QPopupMenu *viewMenu = new QPopupMenu( this ); 597 QPopupMenu *viewMenu = new QPopupMenu( this );
600 QPopupMenu *actionMenu = new QPopupMenu( this ); 598 QPopupMenu *actionMenu = new QPopupMenu( this );
601 QPopupMenu *importMenu = new QPopupMenu( this ); 599 QPopupMenu *importMenu = new QPopupMenu( this );
602 QPopupMenu *importMenu_X = new QPopupMenu( this ); 600 QPopupMenu *importMenu_X = new QPopupMenu( this );
603 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 601 QPopupMenu *exportMenu_X = new QPopupMenu( this );
604 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 602 QPopupMenu *beamMenu_X = new QPopupMenu( this );
605 selectFilterMenu = new QPopupMenu( this ); 603 selectFilterMenu = new QPopupMenu( this );
606 selectFilterMenu->setCheckable( true ); 604 selectFilterMenu->setCheckable( true );
607 syncMenu = new QPopupMenu( this ); 605 syncMenu = new QPopupMenu( this );
608 configureAgendaMenu = new QPopupMenu( this ); 606 configureAgendaMenu = new QPopupMenu( this );
609 configureToolBarMenu = new QPopupMenu( this ); 607 configureToolBarMenu = new QPopupMenu( this );
610 QPopupMenu *helpMenu = new QPopupMenu( this ); 608 QPopupMenu *helpMenu = new QPopupMenu( this );
611 QIconSet icon; 609 QIconSet icon;
612 int pixWid = 22, pixHei = 22; 610 int pixWid = 22, pixHei = 22;
613 QString pathString = ""; 611 QString pathString = "";
614 if ( !p->mToolBarMiniIcons ) { 612 if ( !p->mToolBarMiniIcons ) {
615 if ( QApplication::desktop()->width() < 480 ) { 613 if ( QApplication::desktop()->width() < 480 ) {
616 pathString += "icons16/"; 614 pathString += "icons16/";
617 pixWid = 18; pixHei = 16; 615 pixWid = 18; pixHei = 16;
618 } 616 }
619 } else { 617 } else {
620 pathString += "iconsmini/"; 618 pathString += "iconsmini/";
621 pixWid = 18; pixHei = 16; 619 pixWid = 18; pixHei = 16;
622 } 620 }
623 if ( KOPrefs::instance()->mShowFullMenu ) { 621 if ( KOPrefs::instance()->mShowFullMenu ) {
624 QMenuBar *menuBar1; 622 QMenuBar *menuBar1;
625 menuBar1 = menuBar(); 623 menuBar1 = menuBar();
626 menuBar1->insertItem( i18n("File"), importMenu ); 624 menuBar1->insertItem( i18n("File"), importMenu );
627 menuBar1->insertItem( i18n("View"), viewMenu ); 625 menuBar1->insertItem( i18n("View"), viewMenu );
628 menuBar1->insertItem( i18n("Actions"), actionMenu ); 626 menuBar1->insertItem( i18n("Actions"), actionMenu );
629#ifdef DESKTOP_VERSION 627#ifdef DESKTOP_VERSION
630 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 628 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
631 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 629 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
632#else 630#else
633 menuBar1->insertItem( i18n("Sync"), syncMenu ); 631 menuBar1->insertItem( i18n("Sync"), syncMenu );
634 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 632 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
635#endif 633#endif
636 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 634 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
637 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 635 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
638 menuBar1->insertItem( i18n("Help"), helpMenu ); 636 menuBar1->insertItem( i18n("Help"), helpMenu );
639 } else { 637 } else {
640 QPEMenuBar *menuBar1; 638 QPEMenuBar *menuBar1;
641 menuBar1 = new QPEMenuBar( iconToolBar ); 639 menuBar1 = new QPEMenuBar( iconToolBar );
642 QPopupMenu *menuBar = new QPopupMenu( this ); 640 QPopupMenu *menuBar = new QPopupMenu( this );
643 icon = loadPixmap( pathString + "z_menu" ); 641 icon = loadPixmap( pathString + "z_menu" );
644 menuBar1->insertItem( icon.pixmap(), menuBar); 642 menuBar1->insertItem( icon.pixmap(), menuBar);
645 //menuBar1->insertItem( i18n("ME"), menuBar); 643 //menuBar1->insertItem( i18n("ME"), menuBar);
646 menuBar->insertItem( i18n("File"), importMenu ); 644 menuBar->insertItem( i18n("File"), importMenu );
647 menuBar->insertItem( i18n("View"), viewMenu ); 645 menuBar->insertItem( i18n("View"), viewMenu );
648 menuBar->insertItem( i18n("Actions"), actionMenu ); 646 menuBar->insertItem( i18n("Actions"), actionMenu );
649 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 647 menuBar->insertItem( i18n("Synchronize"), syncMenu );
650 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 648 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
651 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 649 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
652 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 650 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
653 menuBar->insertItem( i18n("Help"), helpMenu ); 651 menuBar->insertItem( i18n("Help"), helpMenu );
654 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 652 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
655 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 653 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
656 } 654 }
657 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 655 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
658 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 656 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
659 657
660 658
661 mWeekBgColor = iconToolBar->backgroundColor(); 659 mWeekBgColor = iconToolBar->backgroundColor();
662 mWeekPixmap.resize( pixWid , pixHei ); 660 mWeekPixmap.resize( pixWid , pixHei );
663 mWeekPixmap.fill( mWeekBgColor ); 661 mWeekPixmap.fill( mWeekBgColor );
664 icon = mWeekPixmap; 662 icon = mWeekPixmap;
665 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 663 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
666 if ( p-> mShowIconWeekNum ) 664 if ( p-> mShowIconWeekNum )
667 mWeekAction->addTo( iconToolBar ); 665 mWeekAction->addTo( iconToolBar );
668 mWeekFont = font(); 666 mWeekFont = font();
669 667
670 int fontPoint = mWeekFont.pointSize(); 668 int fontPoint = mWeekFont.pointSize();
671 QFontMetrics f( mWeekFont ); 669 QFontMetrics f( mWeekFont );
672 int fontWid = f.width( "30" ); 670 int fontWid = f.width( "30" );
673 while ( fontWid > pixWid ) { 671 while ( fontWid > pixWid ) {
674 --fontPoint; 672 --fontPoint;
675 mWeekFont.setPointSize( fontPoint ); 673 mWeekFont.setPointSize( fontPoint );
676 QFontMetrics f( mWeekFont ); 674 QFontMetrics f( mWeekFont );
677 fontWid = f.width( "30" ); 675 fontWid = f.width( "30" );
678 //qDebug("dec-- "); 676 //qDebug("dec-- ");
679 } 677 }
680 678
681 connect( mWeekAction, SIGNAL( activated() ), 679 connect( mWeekAction, SIGNAL( activated() ),
682 this, SLOT( weekAction() ) ); 680 this, SLOT( weekAction() ) );
683 681
684 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 682 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
685 if ( p->mShowIconFilterview ) { 683 if ( p->mShowIconFilterview ) {
686 icon = loadPixmap( pathString + "filter" ); 684 icon = loadPixmap( pathString + "filter" );
687 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 685 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
688 connect( actionFilterMenuTB, SIGNAL( activated() ), 686 connect( actionFilterMenuTB, SIGNAL( activated() ),
689 this, SLOT( fillFilterMenuTB() ) ); 687 this, SLOT( fillFilterMenuTB() ) );
690 actionFilterMenuTB->addTo( iconToolBar ); 688 actionFilterMenuTB->addTo( iconToolBar );
691 selectFilterMenuTB = new QPopupMenu( this ); 689 selectFilterMenuTB = new QPopupMenu( this );
692 selectFilterMenuTB->setCheckable( true ); 690 selectFilterMenuTB->setCheckable( true );
693 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 691 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
694 } 692 }
695 693
696 //#endif 694 //#endif
697 // ****************** 695 // ******************
698 QAction *action; 696 QAction *action;
699 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 697 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
700 configureToolBarMenu->setCheckable( true ); 698 configureToolBarMenu->setCheckable( true );
701 699
702 700
703 configureAgendaMenu->setCheckable( true ); 701 configureAgendaMenu->setCheckable( true );
704 int iii ; 702 int iii ;
705 for ( iii = 1;iii<= 10 ;++iii ){ 703 for ( iii = 1;iii<= 10 ;++iii ){
706 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 704 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
707 } 705 }
708 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 706 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
709 707
710 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 708 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
711 this, SLOT( showConfigureAgenda( ) ) ); 709 this, SLOT( showConfigureAgenda( ) ) );
712 710
713 icon = loadPixmap( pathString + "configure" ); 711 icon = loadPixmap( pathString + "configure" );
714 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 712 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
715 action->addTo( actionMenu ); 713 action->addTo( actionMenu );
716 connect( action, SIGNAL( activated() ), 714 connect( action, SIGNAL( activated() ),
717 mView, SLOT( edit_options() ) ); 715 mView, SLOT( edit_options() ) );
718 actionMenu->insertSeparator(); 716 actionMenu->insertSeparator();
719 717
720 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 718 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
721 action->addTo( actionMenu ); 719 action->addTo( actionMenu );
722 connect( action, SIGNAL( activated() ), 720 connect( action, SIGNAL( activated() ),
723 mView, SLOT( undo_delete() ) ); 721 mView, SLOT( undo_delete() ) );
724 actionMenu->insertSeparator(); 722 actionMenu->insertSeparator();
725 723
726 icon = loadPixmap( pathString + "newevent" ); 724 icon = loadPixmap( pathString + "newevent" );
727 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 725 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
728 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 726 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
729 configureToolBarMenu->insertSeparator(); 727 configureToolBarMenu->insertSeparator();
730 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 728 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
731 configureToolBarMenu->insertSeparator(); 729 configureToolBarMenu->insertSeparator();
732 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 730 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
733 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 731 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
734 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 732 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
735 ne_action->addTo( actionMenu ); 733 ne_action->addTo( actionMenu );
736 connect( ne_action, SIGNAL( activated() ), 734 connect( ne_action, SIGNAL( activated() ),
737 mView, SLOT( newEvent() ) ); 735 mView, SLOT( newEvent() ) );
738 icon = loadPixmap( pathString + "newtodo" ); 736 icon = loadPixmap( pathString + "newtodo" );
739 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 737 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
740 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 738 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
741 nt_action->addTo( actionMenu ); 739 nt_action->addTo( actionMenu );
742 connect( nt_action, SIGNAL( activated() ), 740 connect( nt_action, SIGNAL( activated() ),
743 mView, SLOT( newTodo() ) ); 741 mView, SLOT( newTodo() ) );
744 742
745 icon = loadPixmap( pathString + "today" ); 743 icon = loadPixmap( pathString + "today" );
746 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 744 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
747 today_action->addTo( viewMenu ); 745 today_action->addTo( viewMenu );
748 connect( today_action, SIGNAL( activated() ), 746 connect( today_action, SIGNAL( activated() ),
749 mView, SLOT( goToday() ) ); 747 mView, SLOT( goToday() ) );
750 viewMenu->insertSeparator(); 748 viewMenu->insertSeparator();
751 749
752 // *********************** 750 // ***********************
753 if ( KOPrefs::instance()->mVerticalScreen ) { 751 if ( KOPrefs::instance()->mVerticalScreen ) {
754 icon = SmallIcon( "1updownarrow" ); 752 icon = SmallIcon( "1updownarrow" );
755 } else { 753 } else {
756 icon = SmallIcon("1leftrightarrow" ); 754 icon = SmallIcon("1leftrightarrow" );
757 } 755 }
758 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 756 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
759 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 757 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
760 FSaction->addTo( viewMenu ); 758 FSaction->addTo( viewMenu );
761 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 759 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
762 760
763 icon = loadPixmap( pathString + "navi" ); 761 icon = loadPixmap( pathString + "navi" );
764 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 762 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
765 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 763 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
766 action->addTo( viewMenu ); 764 action->addTo( viewMenu );
767 connect( action, SIGNAL( activated() ), 765 connect( action, SIGNAL( activated() ),
768 mView, SLOT( toggleDateNavigatorWidget() ) ); 766 mView, SLOT( toggleDateNavigatorWidget() ) );
769 mToggleNav = action ; 767 mToggleNav = action ;
770 icon = loadPixmap( pathString + "filter" ); 768 icon = loadPixmap( pathString + "filter" );
771 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 769 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
772 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 770 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
773 action->addTo( viewMenu ); 771 action->addTo( viewMenu );
774 connect( action, SIGNAL( activated() ), 772 connect( action, SIGNAL( activated() ),
775 mView, SLOT( toggleFilter() ) ); 773 mView, SLOT( toggleFilter() ) );
776 mToggleFilter = action; 774 mToggleFilter = action;
777 icon = loadPixmap( pathString + "allday" ); 775 icon = loadPixmap( pathString + "allday" );
778 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 776 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
779 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 777 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
780 action->addTo( viewMenu ); 778 action->addTo( viewMenu );
781 connect( action, SIGNAL( activated() ), 779 connect( action, SIGNAL( activated() ),
782 mView, SLOT( toggleAllDaySize() ) ); 780 mView, SLOT( toggleAllDaySize() ) );
783 mToggleAllday = action; 781 mToggleAllday = action;
784 782
785 783
786 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 784 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
787 mToggleNav, SLOT( setEnabled ( bool ) ) ); 785 mToggleNav, SLOT( setEnabled ( bool ) ) );
788 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 786 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
789 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 787 mToggleFilter, SLOT( setEnabled ( bool ) ) );
790 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 788 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
791 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 789 mToggleAllday, SLOT( setEnabled ( bool ) ) );
792 790
793 viewMenu->insertSeparator(); 791 viewMenu->insertSeparator();
794 icon = loadPixmap( pathString + "picker" ); 792 icon = loadPixmap( pathString + "picker" );
795 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 793 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
796 action->addTo( viewMenu ); 794 action->addTo( viewMenu );
797 connect( action, SIGNAL( activated() ), 795 connect( action, SIGNAL( activated() ),
798 mView, SLOT( showDatePicker() ) ); 796 mView, SLOT( showDatePicker() ) );
799 action->addTo( iconToolBar ); 797 action->addTo( iconToolBar );
800 viewMenu->insertSeparator(); 798 viewMenu->insertSeparator();
801 799
802 if ( p-> mShowIconToggleFull ) 800 if ( p-> mShowIconToggleFull )
803 FSaction->addTo( iconToolBar ); 801 FSaction->addTo( iconToolBar );
804 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 802 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
805 803
806 //******************** 804 //********************
807 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 805 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
808 806
809 807
810 icon = loadPixmap( pathString + "whatsnext" ); 808 icon = loadPixmap( pathString + "whatsnext" );
811 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 809 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
812 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 810 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
813 whatsnext_action->addTo( viewMenu ); 811 whatsnext_action->addTo( viewMenu );
814 connect( whatsnext_action, SIGNAL( activated() ), 812 connect( whatsnext_action, SIGNAL( activated() ),
815 mView->viewManager(), SLOT( showWhatsNextView() ) ); 813 mView->viewManager(), SLOT( showWhatsNextView() ) );
816 814
817 icon = loadPixmap( pathString + "xdays" ); 815 icon = loadPixmap( pathString + "xdays" );
818 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 816 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
819 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 817 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
820 xdays_action->addTo( viewMenu ); 818 xdays_action->addTo( viewMenu );
821 connect( xdays_action, SIGNAL( activated() ), 819 connect( xdays_action, SIGNAL( activated() ),
822 mView->viewManager(), SLOT( showNextXView() ) ); 820 mView->viewManager(), SLOT( showNextXView() ) );
823 821
824 822
825 icon = loadPixmap( pathString + "journal" ); 823 icon = loadPixmap( pathString + "journal" );
826 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 824 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
827 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 825 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
828 viewjournal_action->addTo( viewMenu ); 826 viewjournal_action->addTo( viewMenu );
829 connect( viewjournal_action, SIGNAL( activated() ), 827 connect( viewjournal_action, SIGNAL( activated() ),
830 mView->viewManager(), SLOT( showJournalView() ) ); 828 mView->viewManager(), SLOT( showJournalView() ) );
831 829
832 830
833 icon = loadPixmap( pathString + "day" ); 831 icon = loadPixmap( pathString + "day" );
834 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 832 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
835 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 833 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
836 day1_action->addTo( viewMenu ); 834 day1_action->addTo( viewMenu );
837 // action->addTo( toolBar ); 835 // action->addTo( toolBar );
838 connect( day1_action, SIGNAL( activated() ), 836 connect( day1_action, SIGNAL( activated() ),
839 mView->viewManager(), SLOT( showDayView() ) ); 837 mView->viewManager(), SLOT( showDayView() ) );
840 838
841 icon = loadPixmap( pathString + "workweek" ); 839 icon = loadPixmap( pathString + "workweek" );
842 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 840 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
843 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 841 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
844 day5_action->addTo( viewMenu ); 842 day5_action->addTo( viewMenu );
845 connect( day5_action, SIGNAL( activated() ), 843 connect( day5_action, SIGNAL( activated() ),
846 mView->viewManager(), SLOT( showWorkWeekView() ) ); 844 mView->viewManager(), SLOT( showWorkWeekView() ) );
847 845
848 icon = loadPixmap( pathString + "week" ); 846 icon = loadPixmap( pathString + "week" );
849 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 847 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
850 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 848 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
851 day7_action->addTo( viewMenu ); 849 day7_action->addTo( viewMenu );
852 connect( day7_action, SIGNAL( activated() ), 850 connect( day7_action, SIGNAL( activated() ),
853 mView->viewManager(), SLOT( showWeekView() ) ); 851 mView->viewManager(), SLOT( showWeekView() ) );
854 852
855 icon = loadPixmap( pathString + "workweek2" ); 853 icon = loadPixmap( pathString + "workweek2" );
856 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 854 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
857 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 855 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
858 day6_action->addTo( viewMenu ); 856 day6_action->addTo( viewMenu );
859 connect( day6_action, SIGNAL( activated() ), 857 connect( day6_action, SIGNAL( activated() ),
860 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 858 mView->viewManager(), SLOT( showMonthViewWeek() ) );
861 859
862 icon = loadPixmap( pathString + "month" ); 860 icon = loadPixmap( pathString + "month" );
863 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 861 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
864 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 862 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
865 month_action->addTo( viewMenu ); 863 month_action->addTo( viewMenu );
866 connect( month_action, SIGNAL( activated() ), 864 connect( month_action, SIGNAL( activated() ),
867 mView->viewManager(), SLOT( showMonthView() ) ); 865 mView->viewManager(), SLOT( showMonthView() ) );
868 866
869 icon = loadPixmap( pathString + "list" ); 867 icon = loadPixmap( pathString + "list" );
870 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 868 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
871 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 869 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
872 showlist_action->addTo( viewMenu ); 870 showlist_action->addTo( viewMenu );
873 connect( showlist_action, SIGNAL( activated() ), 871 connect( showlist_action, SIGNAL( activated() ),
874 mView->viewManager(), SLOT( showListView() ) ); 872 mView->viewManager(), SLOT( showListView() ) );
875 873
876 icon = loadPixmap( pathString + "todo" ); 874 icon = loadPixmap( pathString + "todo" );
877 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 875 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
878 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 876 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
879 todoview_action->addTo( viewMenu ); 877 todoview_action->addTo( viewMenu );
880 connect( todoview_action, SIGNAL( activated() ), 878 connect( todoview_action, SIGNAL( activated() ),
881 mView->viewManager(), SLOT( showTodoView() ) ); 879 mView->viewManager(), SLOT( showTodoView() ) );
882 880
883 881
884 882
885#if 0 883#if 0
886 action = new QAction( "view_timespan", "Time Span", 0, this ); 884 action = new QAction( "view_timespan", "Time Span", 0, this );
887 action->addTo( viewMenu ); 885 action->addTo( viewMenu );
888 connect( action, SIGNAL( activated() ), 886 connect( action, SIGNAL( activated() ),
889 mView->viewManager(), SLOT( showTimeSpanView() ) ); 887 mView->viewManager(), SLOT( showTimeSpanView() ) );
890#endif 888#endif
891 889
892 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 890 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
893 this ); 891 this );
894 mNewSubTodoAction->addTo( actionMenu ); 892 mNewSubTodoAction->addTo( actionMenu );
895 connect( mNewSubTodoAction, SIGNAL( activated() ), 893 connect( mNewSubTodoAction, SIGNAL( activated() ),
896 mView, SLOT( newSubTodo() ) ); 894 mView, SLOT( newSubTodo() ) );
897 895
898 actionMenu->insertSeparator(); 896 actionMenu->insertSeparator();
899 897
900 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 898 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
901 mShowAction->addTo( actionMenu ); 899 mShowAction->addTo( actionMenu );
902 connect( mShowAction, SIGNAL( activated() ), 900 connect( mShowAction, SIGNAL( activated() ),
903 mView, SLOT( showIncidence() ) ); 901 mView, SLOT( showIncidence() ) );
904 902
905 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 903 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
906 mEditAction->addTo( actionMenu ); 904 mEditAction->addTo( actionMenu );
907 connect( mEditAction, SIGNAL( activated() ), 905 connect( mEditAction, SIGNAL( activated() ),
908 mView, SLOT( editIncidence() ) ); 906 mView, SLOT( editIncidence() ) );
909 907
910 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 908 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
911 mDeleteAction->addTo( actionMenu ); 909 mDeleteAction->addTo( actionMenu );
912 connect( mDeleteAction, SIGNAL( activated() ), 910 connect( mDeleteAction, SIGNAL( activated() ),
913 mView, SLOT( deleteIncidence() ) ); 911 mView, SLOT( deleteIncidence() ) );
914 912
915 913
916 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 914 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
917 mCloneAction->addTo( actionMenu ); 915 mCloneAction->addTo( actionMenu );
918 connect( mCloneAction, SIGNAL( activated() ), 916 connect( mCloneAction, SIGNAL( activated() ),
919 mView, SLOT( cloneIncidence() ) ); 917 mView, SLOT( cloneIncidence() ) );
920 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 918 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
921 mMoveAction->addTo( actionMenu ); 919 mMoveAction->addTo( actionMenu );
922 connect( mMoveAction, SIGNAL( activated() ), 920 connect( mMoveAction, SIGNAL( activated() ),
923 mView, SLOT( moveIncidence() ) ); 921 mView, SLOT( moveIncidence() ) );
924 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 922 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
925 mBeamAction->addTo( actionMenu ); 923 mBeamAction->addTo( actionMenu );
926 connect( mBeamAction, SIGNAL( activated() ), 924 connect( mBeamAction, SIGNAL( activated() ),
927 mView, SLOT( beamIncidence() ) ); 925 mView, SLOT( beamIncidence() ) );
928 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 926 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
929 mCancelAction->addTo( actionMenu ); 927 mCancelAction->addTo( actionMenu );
930 connect( mCancelAction, SIGNAL( activated() ), 928 connect( mCancelAction, SIGNAL( activated() ),
931 mView, SLOT( toggleCancelIncidence() ) ); 929 mView, SLOT( toggleCancelIncidence() ) );
932 930
933 actionMenu->insertSeparator(); 931 actionMenu->insertSeparator();
934 932
935 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 933 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
936 this ); 934 this );
937 action->addTo( actionMenu ); 935 action->addTo( actionMenu );
938 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 936 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
939 937
940 icon = loadPixmap( pathString + "search" ); 938 icon = loadPixmap( pathString + "search" );
941 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 939 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
942 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 940 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
943 search_action->addTo( actionMenu ); 941 search_action->addTo( actionMenu );
944 connect( search_action, SIGNAL( activated() ), 942 connect( search_action, SIGNAL( activated() ),
945 mView->dialogManager(), SLOT( showSearchDialog() ) ); 943 mView->dialogManager(), SLOT( showSearchDialog() ) );
946 944
947 945
948 946
949 if ( KOPrefs::instance()->mShowFullMenu ) { 947 if ( KOPrefs::instance()->mShowFullMenu ) {
950 actionMenu->insertSeparator(); 948 actionMenu->insertSeparator();
951 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 949 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
952 950
953 } 951 }
954 // actionMenu->insertSeparator(); 952 // actionMenu->insertSeparator();
955 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 953 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
956 this ); 954 this );
957 action->addTo( importMenu_X ); 955 action->addTo( importMenu_X );
958 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 956 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
959 action = new QAction( "import_quick", i18n("Import last file"), 0, 957 action = new QAction( "import_quick", i18n("Import last file"), 0,
960 this ); 958 this );
961 action->addTo( importMenu_X ); 959 action->addTo( importMenu_X );
962 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 960 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
963 importMenu_X->insertSeparator(); 961 importMenu_X->insertSeparator();
964 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 962 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
965 this ); 963 this );
966 action->addTo( importMenu_X ); 964 action->addTo( importMenu_X );
967 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 965 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
968 //#ifndef DESKTOP_VERSION 966 //#ifndef DESKTOP_VERSION
969 importMenu_X->insertSeparator(); 967 importMenu_X->insertSeparator();
970 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 968 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
971 this ); 969 this );
972 action->addTo( importMenu_X ); 970 action->addTo( importMenu_X );
973 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 971 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
974 //#else 972 //#else
975#ifdef _OL_IMPORT_ 973#ifdef _OL_IMPORT_
976 importMenu_X->insertSeparator(); 974 importMenu_X->insertSeparator();
977 action = new QAction( "import_ol", i18n("Import from OL"), 0, 975 action = new QAction( "import_ol", i18n("Import from OL"), 0,
978 this ); 976 this );
979 action->addTo( importMenu_X ); 977 action->addTo( importMenu_X );
980 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 978 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
981#endif 979#endif
982 //#endif 980 //#endif
983 981
984 //importMenu->insertSeparator(); 982 //importMenu->insertSeparator();
985 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 983 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
986 this ); 984 this );
987 action->addTo( importMenu ); 985 action->addTo( importMenu );
988 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 986 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
989 987
990 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 988 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
991 this ); 989 this );
992 action->addTo( importMenu ); 990 action->addTo( importMenu );
993 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 991 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
994 importMenu->insertSeparator(); 992 importMenu->insertSeparator();
995 importMenu->insertItem( i18n("Import"), importMenu_X ); 993 importMenu->insertItem( i18n("Import"), importMenu_X );
996 //importMenu->insertSeparator(); 994 //importMenu->insertSeparator();
997 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 995 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
998 this ); 996 this );
999 action->addTo( exportMenu_X ); 997 action->addTo( exportMenu_X );
1000 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 998 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1001 999
1002 1000
1003 //LR 1001 //LR
1004 QPopupMenu *ex2phone = new QPopupMenu( this ); 1002 QPopupMenu *ex2phone = new QPopupMenu( this );
1005 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1003 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1006 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1004 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1007 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1005 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1008 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1006 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1009 1007
1010 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1008 importMenu->insertItem( i18n("Export"), exportMenu_X );
1011#ifndef DESKTOP_VERSION 1009#ifndef DESKTOP_VERSION
1012 //importMenu->insertSeparator(); 1010 //importMenu->insertSeparator();
1013 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1011 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1014 this ); 1012 this );
1015 brAction->addTo( beamMenu_X ); 1013 brAction->addTo( beamMenu_X );
1016 brAction->setToggleAction (true ) ; 1014 brAction->setToggleAction (true ) ;
1017 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1015 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1018 1016
1019 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1017 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1020 this ); 1018 this );
1021 action->addTo( beamMenu_X ); 1019 action->addTo( beamMenu_X );
1022 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1020 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1023 1021
1024 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1022 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1025 this ); 1023 this );
1026 action->addTo( beamMenu_X ); 1024 action->addTo( beamMenu_X );
1027 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1025 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1028 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1026 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1029#else 1027#else
1030 //importMenu->insertSeparator(); 1028 //importMenu->insertSeparator();
1031 icon = loadPixmap( pathString + "print" ); 1029 icon = loadPixmap( pathString + "print" );
1032 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1030 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1033 action->addTo( beamMenu_X ); 1031 action->addTo( beamMenu_X );
1034 connect( action, SIGNAL( activated() ), 1032 connect( action, SIGNAL( activated() ),
1035 this, SLOT( printCal() ) ); 1033 this, SLOT( printCal() ) );
1036 1034
1037 icon = loadPixmap( pathString + "print" ); 1035 icon = loadPixmap( pathString + "print" );
1038 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1036 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1039 action->addTo( beamMenu_X ); 1037 action->addTo( beamMenu_X );
1040 connect( action, SIGNAL( activated() ), 1038 connect( action, SIGNAL( activated() ),
1041 this, SLOT( printSel() ) ); 1039 this, SLOT( printSel() ) );
1042 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1040 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1043 action->addTo( beamMenu_X ); 1041 action->addTo( beamMenu_X );
1044 connect( action, SIGNAL( activated() ), 1042 connect( action, SIGNAL( activated() ),
1045 mView->viewManager(), SLOT( slotprintWNV() ) ); 1043 mView->viewManager(), SLOT( slotprintWNV() ) );
1046 1044
1047 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1045 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1048 action->addTo( beamMenu_X ); 1046 action->addTo( beamMenu_X );
1049 connect( action, SIGNAL( activated() ), 1047 connect( action, SIGNAL( activated() ),
1050 mView, SLOT( slotprintSelInc() ) ); 1048 mView, SLOT( slotprintSelInc() ) );
1051 1049
1052 1050
1053 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1051 importMenu->insertItem( i18n("Print"), beamMenu_X );
1054#endif 1052#endif
1055 importMenu->insertSeparator(); 1053 importMenu->insertSeparator();
1056 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1054 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1057 this ); 1055 this );
1058 action->addTo( importMenu ); 1056 action->addTo( importMenu );
1059 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1057 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1060 importMenu->insertSeparator(); 1058 importMenu->insertSeparator();
1061 action = new QAction( "beam all", i18n("Save"), 0, 1059 action = new QAction( "beam all", i18n("Save"), 0,
1062 this ); 1060 this );
1063 action->addTo( importMenu ); 1061 action->addTo( importMenu );
1064 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1062 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1065 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1063 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1066 this ); 1064 this );
1067 action->addTo( importMenu ); 1065 action->addTo( importMenu );
1068 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1066 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1069 1067
1070 //menuBar->insertItem( "Configure",configureMenu ); 1068 //menuBar->insertItem( "Configure",configureMenu );
1071 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1069 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1072 icon = loadPixmap( "korganizer/korganizer" ); 1070 icon = loadPixmap( "korganizer/korganizer" );
1073 1071
1074 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1072 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1075 action->addTo( helpMenu ); 1073 action->addTo( helpMenu );
1076 connect( action, SIGNAL( activated() ), 1074 connect( action, SIGNAL( activated() ),
1077 SLOT( whatsNew() ) ); 1075 SLOT( whatsNew() ) );
1078 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1076 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1079 action->addTo( helpMenu ); 1077 action->addTo( helpMenu );
1080 connect( action, SIGNAL( activated() ), 1078 connect( action, SIGNAL( activated() ),
1081 SLOT( features() ) ); 1079 SLOT( features() ) );
1082 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1080 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1083 action->addTo( helpMenu ); 1081 action->addTo( helpMenu );
1084 connect( action, SIGNAL( activated() ), 1082 connect( action, SIGNAL( activated() ),
1085 SLOT( keyBindings() ) ); 1083 SLOT( keyBindings() ) );
1086 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); 1084 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this );
1087 action->addTo( helpMenu ); 1085 action->addTo( helpMenu );
1088 connect( action, SIGNAL( activated() ), 1086 connect( action, SIGNAL( activated() ),
1089 SLOT( storagehowto() ) ); 1087 SLOT( storagehowto() ) );
1090 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); 1088 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this );
1091 action->addTo( helpMenu ); 1089 action->addTo( helpMenu );
1092 connect( action, SIGNAL( activated() ), 1090 connect( action, SIGNAL( activated() ),
1093 SLOT( timetrackinghowto() ) ); 1091 SLOT( timetrackinghowto() ) );
1094 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1092 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1095 action->addTo( helpMenu ); 1093 action->addTo( helpMenu );
1096 connect( action, SIGNAL( activated() ), 1094 connect( action, SIGNAL( activated() ),
1097 SLOT( synchowto() ) ); 1095 SLOT( synchowto() ) );
1098 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1096 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1099 action->addTo( helpMenu ); 1097 action->addTo( helpMenu );
1100 connect( action, SIGNAL( activated() ), 1098 connect( action, SIGNAL( activated() ),
1101 SLOT( kdesynchowto() ) ); 1099 SLOT( kdesynchowto() ) );
1102 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1100 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1103 action->addTo( helpMenu ); 1101 action->addTo( helpMenu );
1104 connect( action, SIGNAL( activated() ), 1102 connect( action, SIGNAL( activated() ),
1105 SLOT( multisynchowto() ) ); 1103 SLOT( multisynchowto() ) );
1106 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1104 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1107 action->addTo( helpMenu ); 1105 action->addTo( helpMenu );
1108 connect( action, SIGNAL( activated() ), 1106 connect( action, SIGNAL( activated() ),
1109 SLOT( aboutAutoSaving() ) ); 1107 SLOT( aboutAutoSaving() ) );
1110 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1108 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1111 action->addTo( helpMenu ); 1109 action->addTo( helpMenu );
1112 connect( action, SIGNAL( activated() ), 1110 connect( action, SIGNAL( activated() ),
1113 SLOT( aboutKnownBugs() ) ); 1111 SLOT( aboutKnownBugs() ) );
1114 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1112 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1115 action->addTo( helpMenu ); 1113 action->addTo( helpMenu );
1116 connect( action, SIGNAL( activated() ), 1114 connect( action, SIGNAL( activated() ),
1117 SLOT( usertrans() ) ); 1115 SLOT( usertrans() ) );
1118 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1116 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1119 action->addTo( helpMenu ); 1117 action->addTo( helpMenu );
1120 connect( action, SIGNAL( activated() ), 1118 connect( action, SIGNAL( activated() ),
1121 SLOT( faq() ) ); 1119 SLOT( faq() ) );
1122 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1120 action = new QAction( "licence", i18n("Licence..."), 0, this );
1123 action->addTo( helpMenu ); 1121 action->addTo( helpMenu );
1124 connect( action, SIGNAL( activated() ), 1122 connect( action, SIGNAL( activated() ),
1125 SLOT( licence() ) ); 1123 SLOT( licence() ) );
1126 action = new QAction( "about", i18n("About..."), 0, this ); 1124 action = new QAction( "about", i18n("About..."), 0, this );
1127 action->addTo( helpMenu ); 1125 action->addTo( helpMenu );
1128 connect( action, SIGNAL( activated() ), 1126 connect( action, SIGNAL( activated() ),
1129 SLOT( about() ) ); 1127 SLOT( about() ) );
1130 //menuBar->insertSeparator(); 1128 //menuBar->insertSeparator();
1131 1129
1132 // ****************************************************** 1130 // ******************************************************
1133 // menubar icons 1131 // menubar icons
1134 1132
1135 1133
1136 1134
1137 //menuBar->insertItem( iconToolBar ); 1135 //menuBar->insertItem( iconToolBar );
1138 //xdays_action 1136 //xdays_action
1139 if (p-> mShowIconNewEvent) 1137 if (p-> mShowIconNewEvent)
1140 ne_action->addTo( iconToolBar ); 1138 ne_action->addTo( iconToolBar );
1141 if (p->mShowIconNewTodo ) 1139 if (p->mShowIconNewTodo )
1142 nt_action->addTo( iconToolBar ); 1140 nt_action->addTo( iconToolBar );
1143 if (p-> mShowIconSearch) 1141 if (p-> mShowIconSearch)
1144 search_action->addTo( iconToolBar ); 1142 search_action->addTo( iconToolBar );
1145 if (p-> mShowIconWhatsThis) 1143 if (p-> mShowIconWhatsThis)
1146 QWhatsThis::whatsThisButton ( iconToolBar ); 1144 QWhatsThis::whatsThisButton ( iconToolBar );
1147 if (p-> mShowIconNext) 1145 if (p-> mShowIconNext)
1148 whatsnext_action->addTo( viewToolBar ); 1146 whatsnext_action->addTo( viewToolBar );
1149 if (p-> mShowIconNextDays) 1147 if (p-> mShowIconNextDays)
1150 xdays_action->addTo( viewToolBar ); 1148 xdays_action->addTo( viewToolBar );
1151 if (p-> mShowIconJournal) 1149 if (p-> mShowIconJournal)
1152 viewjournal_action->addTo( viewToolBar ); 1150 viewjournal_action->addTo( viewToolBar );
1153 if (p-> mShowIconDay1) 1151 if (p-> mShowIconDay1)
1154 day1_action->addTo( viewToolBar ); 1152 day1_action->addTo( viewToolBar );
1155 if (p-> mShowIconDay5) 1153 if (p-> mShowIconDay5)
1156 day5_action->addTo( viewToolBar ); 1154 day5_action->addTo( viewToolBar );
1157 if (p-> mShowIconDay7) 1155 if (p-> mShowIconDay7)
1158 day7_action->addTo( viewToolBar ); 1156 day7_action->addTo( viewToolBar );
1159 if (p-> mShowIconDay6) 1157 if (p-> mShowIconDay6)
1160 day6_action->addTo( viewToolBar ); 1158 day6_action->addTo( viewToolBar );
1161 if (p-> mShowIconMonth) 1159 if (p-> mShowIconMonth)
1162 month_action->addTo( viewToolBar ); 1160 month_action->addTo( viewToolBar );
1163 if (p-> mShowIconList) 1161 if (p-> mShowIconList)
1164 showlist_action->addTo( viewToolBar ); 1162 showlist_action->addTo( viewToolBar );
1165 if (p-> mShowIconTodoview) 1163 if (p-> mShowIconTodoview)
1166 todoview_action->addTo( viewToolBar ); 1164 todoview_action->addTo( viewToolBar );
1167 1165
1168 icon = loadPixmap( pathString + "2leftarrowB" ); 1166 icon = loadPixmap( pathString + "2leftarrowB" );
1169 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1167 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1170 if (p-> mShowIconBackFast) { 1168 if (p-> mShowIconBackFast) {
1171 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1169 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1172 connect( action, SIGNAL( activated() ), 1170 connect( action, SIGNAL( activated() ),
1173 mView, SLOT( goPreviousMonth() ) ); 1171 mView, SLOT( goPreviousMonth() ) );
1174 action->addTo( navigatorToolBar ); 1172 action->addTo( navigatorToolBar );
1175 } 1173 }
1176 icon = loadPixmap( pathString + "1leftarrowB" ); 1174 icon = loadPixmap( pathString + "1leftarrowB" );
1177 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1175 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1178 if (p-> mShowIconBack) { 1176 if (p-> mShowIconBack) {
1179 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1177 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1180 connect( action, SIGNAL( activated() ), 1178 connect( action, SIGNAL( activated() ),
1181 mView, SLOT( goPrevious() ) ); 1179 mView, SLOT( goPrevious() ) );
1182 action->addTo( navigatorToolBar ); 1180 action->addTo( navigatorToolBar );
1183 } 1181 }
1184 icon = loadPixmap( pathString + "today" ); 1182 icon = loadPixmap( pathString + "today" );
1185 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1183 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1186 if (p-> mShowIconToday) 1184 if (p-> mShowIconToday)
1187 today_action->addTo( navigatorToolBar ); 1185 today_action->addTo( navigatorToolBar );
1188 icon = loadPixmap( pathString + "1rightarrowB" ); 1186 icon = loadPixmap( pathString + "1rightarrowB" );
1189 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1187 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1190 if (p-> mShowIconForward) { 1188 if (p-> mShowIconForward) {
1191 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1189 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1192 connect( action, SIGNAL( activated() ), 1190 connect( action, SIGNAL( activated() ),
1193 mView, SLOT( goNext() ) ); 1191 mView, SLOT( goNext() ) );
1194 action->addTo( navigatorToolBar ); 1192 action->addTo( navigatorToolBar );
1195 } 1193 }
1196 icon = loadPixmap( pathString + "2rightarrowB" ); 1194 icon = loadPixmap( pathString + "2rightarrowB" );
1197 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1195 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1198 if (p-> mShowIconForwardFast) { 1196 if (p-> mShowIconForwardFast) {
1199 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1197 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1200 connect( action, SIGNAL( activated() ), 1198 connect( action, SIGNAL( activated() ),
1201 mView, SLOT( goNextMonth() ) ); 1199 mView, SLOT( goNextMonth() ) );
1202 action->addTo( navigatorToolBar ); 1200 action->addTo( navigatorToolBar );
1203 } 1201 }
1204 1202
1205 1203
1206 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1204 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1207 1205
1208 1206
1209 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1207 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1210 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1208 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1211 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1209 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1212 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1210 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1213 1211
1214 if (p-> mShowIconNewEvent) 1212 if (p-> mShowIconNewEvent)
1215 configureToolBarMenu->setItemChecked( 10, true ); 1213 configureToolBarMenu->setItemChecked( 10, true );
1216 if (p->mShowIconNewTodo ) 1214 if (p->mShowIconNewTodo )
1217 configureToolBarMenu->setItemChecked( 20, true ); 1215 configureToolBarMenu->setItemChecked( 20, true );
1218 if (p-> mShowIconSearch) 1216 if (p-> mShowIconSearch)
1219 configureToolBarMenu->setItemChecked( 120, true ); 1217 configureToolBarMenu->setItemChecked( 120, true );
1220 if (p-> mShowIconList) 1218 if (p-> mShowIconList)
1221 configureToolBarMenu->setItemChecked( 30, true ); 1219 configureToolBarMenu->setItemChecked( 30, true );
1222 if (p-> mShowIconDay1) 1220 if (p-> mShowIconDay1)
1223 configureToolBarMenu->setItemChecked( 40, true ); 1221 configureToolBarMenu->setItemChecked( 40, true );
1224 if (p-> mShowIconDay5) 1222 if (p-> mShowIconDay5)
1225 configureToolBarMenu->setItemChecked( 50, true ); 1223 configureToolBarMenu->setItemChecked( 50, true );
1226 if (p-> mShowIconDay6) 1224 if (p-> mShowIconDay6)
1227 configureToolBarMenu->setItemChecked( 75, true ); 1225 configureToolBarMenu->setItemChecked( 75, true );
1228 if (p-> mShowIconDay7) 1226 if (p-> mShowIconDay7)
1229 configureToolBarMenu->setItemChecked( 60, true ); 1227 configureToolBarMenu->setItemChecked( 60, true );
1230 if (p-> mShowIconMonth) 1228 if (p-> mShowIconMonth)
1231 configureToolBarMenu->setItemChecked( 70, true ); 1229 configureToolBarMenu->setItemChecked( 70, true );
1232 if (p-> mShowIconTodoview) 1230 if (p-> mShowIconTodoview)
1233 configureToolBarMenu->setItemChecked( 80, true ); 1231 configureToolBarMenu->setItemChecked( 80, true );
1234 if (p-> mShowIconBackFast) 1232 if (p-> mShowIconBackFast)
1235 configureToolBarMenu->setItemChecked( 200, true ); 1233 configureToolBarMenu->setItemChecked( 200, true );
1236 if (p-> mShowIconBack) 1234 if (p-> mShowIconBack)
1237 configureToolBarMenu->setItemChecked( 210, true ); 1235 configureToolBarMenu->setItemChecked( 210, true );
1238 if (p-> mShowIconToday) 1236 if (p-> mShowIconToday)
1239 configureToolBarMenu->setItemChecked( 130, true ); 1237 configureToolBarMenu->setItemChecked( 130, true );
1240 if (p-> mShowIconForward) 1238 if (p-> mShowIconForward)
1241 configureToolBarMenu->setItemChecked( 220, true ); 1239 configureToolBarMenu->setItemChecked( 220, true );
1242 if (p-> mShowIconForwardFast) 1240 if (p-> mShowIconForwardFast)
1243 configureToolBarMenu->setItemChecked( 230, true ); 1241 configureToolBarMenu->setItemChecked( 230, true );
1244 if (p-> mShowIconNextDays) 1242 if (p-> mShowIconNextDays)
1245 configureToolBarMenu->setItemChecked( 100, true ); 1243 configureToolBarMenu->setItemChecked( 100, true );
1246 if (p-> mShowIconNext) 1244 if (p-> mShowIconNext)
1247 configureToolBarMenu->setItemChecked( 110, true ); 1245 configureToolBarMenu->setItemChecked( 110, true );
1248 if (p-> mShowIconJournal) 1246 if (p-> mShowIconJournal)
1249 configureToolBarMenu->setItemChecked( 90, true ); 1247 configureToolBarMenu->setItemChecked( 90, true );
1250 if (p-> mShowIconWhatsThis) 1248 if (p-> mShowIconWhatsThis)
1251 configureToolBarMenu->setItemChecked( 300, true ); 1249 configureToolBarMenu->setItemChecked( 300, true );
1252 if (p-> mShowIconWeekNum) 1250 if (p-> mShowIconWeekNum)
1253 configureToolBarMenu->setItemChecked( 400, true ); 1251 configureToolBarMenu->setItemChecked( 400, true );
1254 if (!p-> mShowIconStretch) { 1252 if (!p-> mShowIconStretch) {
1255 QLabel* dummy = new QLabel( iconToolBar ); 1253 QLabel* dummy = new QLabel( iconToolBar );
1256 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1254 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1257 dummy->setMinimumWidth( 0 ); 1255 dummy->setMinimumWidth( 0 );
1258 iconToolBar->setStretchableWidget ( dummy ) ; 1256 iconToolBar->setStretchableWidget ( dummy ) ;
1259 } 1257 }
1260 else { 1258 else {
1261 iconToolBar->setHorizontalStretchable (true ); 1259 iconToolBar->setHorizontalStretchable (true );
1262 viewToolBar->setHorizontalStretchable (true ); 1260 viewToolBar->setHorizontalStretchable (true );
1263 navigatorToolBar->setHorizontalStretchable (true ); 1261 navigatorToolBar->setHorizontalStretchable (true );
1264 iconToolBar->setVerticalStretchable (true ); 1262 iconToolBar->setVerticalStretchable (true );
1265 viewToolBar->setVerticalStretchable (true ); 1263 viewToolBar->setVerticalStretchable (true );
1266 navigatorToolBar->setVerticalStretchable (true ); 1264 navigatorToolBar->setVerticalStretchable (true );
1267 configureToolBarMenu->setItemChecked( 5, true ); 1265 configureToolBarMenu->setItemChecked( 5, true );
1268 } 1266 }
1269 if (p-> mShowIconFilter) 1267 if (p-> mShowIconFilter)
1270 configureToolBarMenu->setItemChecked( 7, true ); 1268 configureToolBarMenu->setItemChecked( 7, true );
1271 if (p-> mShowIconOnetoolbar) 1269 if (p-> mShowIconOnetoolbar)
1272 configureToolBarMenu->setItemChecked( 6, true ); 1270 configureToolBarMenu->setItemChecked( 6, true );
1273 1271
1274 1272
1275 if ( filterMenubar ) 1273 if ( filterMenubar )
1276 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); 1274 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) );
1277 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1275 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1278 configureAgenda( p->mHourSize ); 1276 configureAgenda( p->mHourSize );
1279 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1277 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1280} 1278}
1281 1279
1282void MainWindow::exportToPhone( int mode ) 1280void MainWindow::exportToPhone( int mode )
1283{ 1281{
1284 1282
1285 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1283 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1286 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1284 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1287 KOex2phonePrefs ex2phone; 1285 KOex2phonePrefs ex2phone;
1288 1286
1289 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1287 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1290 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1288 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1291 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1289 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1292 if ( mode == 1 ) 1290 if ( mode == 1 )
1293 ex2phone.setCaption(i18n("Export complete calendar")); 1291 ex2phone.setCaption(i18n("Export complete calendar"));
1294 if ( mode == 2 ) 1292 if ( mode == 2 )
1295 ex2phone.setCaption(i18n("Export filtered calendar")); 1293 ex2phone.setCaption(i18n("Export filtered calendar"));
1296 1294
1297 if ( !ex2phone.exec() ) { 1295 if ( !ex2phone.exec() ) {
1298 return; 1296 return;
1299 } 1297 }
1300 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1298 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1301 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1299 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1302 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1300 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1303 1301
1304 int inFuture = 0; 1302 int inFuture = 0;
1305 if ( ex2phone.mWriteBackFuture->isChecked() ) 1303 if ( ex2phone.mWriteBackFuture->isChecked() )
1306 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1304 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1307 QPtrList<Incidence> delSel; 1305 QPtrList<Incidence> delSel;
1308 if ( mode == 1 ) 1306 if ( mode == 1 )
1309 delSel = mCalendar->rawIncidences(); 1307 delSel = mCalendar->rawIncidences();
1310 if ( mode == 2 ) 1308 if ( mode == 2 )
1311 delSel = mCalendar->incidences(); 1309 delSel = mCalendar->incidences();
1312 CalendarLocal* cal = new CalendarLocal(); 1310 CalendarLocal* cal = new CalendarLocal();
1313 cal->setLocalTime(); 1311 cal->setLocalTime();
1314 Incidence *incidence = delSel.first(); 1312 Incidence *incidence = delSel.first();
1315 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1313 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1316 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1314 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1317 while ( incidence ) { 1315 while ( incidence ) {
1318 if ( incidence->type() != "Journal" ) { 1316 if ( incidence->type() != "Journal" ) {
1319 bool add = true; 1317 bool add = true;
1320 if ( inFuture ) { 1318 if ( inFuture ) {
1321 QDateTime dt; 1319 QDateTime dt;
1322 if ( incidence->type() == "Todo" ) { 1320 if ( incidence->type() == "Todo" ) {
1323 Todo * t = (Todo*)incidence; 1321 Todo * t = (Todo*)incidence;
1324 if ( t->hasDueDate() ) 1322 if ( t->hasDueDate() )
1325 dt = t->dtDue(); 1323 dt = t->dtDue();
1326 else 1324 else
1327 dt = cur.addSecs( 62 ); 1325 dt = cur.addSecs( 62 );
1328 } 1326 }
1329 else { 1327 else {
1330 bool ok; 1328 bool ok;
1331 dt = incidence->getNextOccurence( cur, &ok ); 1329 dt = incidence->getNextOccurence( cur, &ok );
1332 if ( !ok ) 1330 if ( !ok )
1333 dt = cur.addSecs( -62 ); 1331 dt = cur.addSecs( -62 );
1334 } 1332 }
1335 if ( dt < cur || dt > end ) { 1333 if ( dt < cur || dt > end ) {
1336 add = false; 1334 add = false;
1337 } 1335 }
1338 } 1336 }
1339 if ( add ) { 1337 if ( add ) {
1340 Incidence *in = incidence->clone(); 1338 Incidence *in = incidence->clone();
1341 cal->addIncidence( in ); 1339 cal->addIncidence( in );
1342 } 1340 }
1343 } 1341 }
1344 incidence = delSel.next(); 1342 incidence = delSel.next();
1345 } 1343 }
1346 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1344 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1347 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1345 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1348 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1346 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1349 1347
1350 setCaption( i18n("Writing to phone...")); 1348 setCaption( i18n("Writing to phone..."));
1351 if ( PhoneFormat::writeToPhone( cal ) ) 1349 if ( PhoneFormat::writeToPhone( cal ) )
1352 setCaption( i18n("Export to phone successful!")); 1350 setCaption( i18n("Export to phone successful!"));
1353 else 1351 else
1354 setCaption( i18n("Error exporting to phone!")); 1352 setCaption( i18n("Error exporting to phone!"));
1355 delete cal; 1353 delete cal;
1356} 1354}
1357 1355
1358 1356
1359void MainWindow::setDefaultPreferences() 1357void MainWindow::setDefaultPreferences()
1360{ 1358{
1361 KOPrefs *p = KOPrefs::instance(); 1359 KOPrefs *p = KOPrefs::instance();
1362 1360
1363 p->mCompactDialogs = true; 1361 p->mCompactDialogs = true;
1364 p->mConfirm = true; 1362 p->mConfirm = true;
1365 // p->mEnableQuickTodo = false; 1363 // p->mEnableQuickTodo = false;
1366 1364
1367} 1365}
1368 1366
1369QString MainWindow::resourcePath() 1367QString MainWindow::resourcePath()
1370{ 1368{
1371 return KGlobal::iconLoader()->iconPath(); 1369 return KGlobal::iconLoader()->iconPath();
1372} 1370}
1373 1371
1374void MainWindow::displayText( QString text ,QString cap ) 1372void MainWindow::displayText( QString text ,QString cap )
1375{ 1373{
1376 QDialog dia( this, "name", true ); ; 1374 QDialog dia( this, "name", true ); ;
1377 dia.setCaption( cap ); 1375 dia.setCaption( cap );
1378 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1376 QVBoxLayout* lay = new QVBoxLayout( &dia );
1379 lay->setSpacing( 3 ); 1377 lay->setSpacing( 3 );
1380 lay->setMargin( 3 ); 1378 lay->setMargin( 3 );
1381 QTextBrowser tb ( &dia ); 1379 QTextBrowser tb ( &dia );
1382 lay->addWidget( &tb ); 1380 lay->addWidget( &tb );
1383 tb.setText( text ); 1381 tb.setText( text );
1384#ifdef DESKTOP_VERSION 1382#ifdef DESKTOP_VERSION
1385 dia.resize( 640, 480); 1383 dia.resize( 640, 480);
1386#else 1384#else
1387 dia.showMaximized(); 1385 dia.showMaximized();
1388#endif 1386#endif
1389 dia.exec(); 1387 dia.exec();
1390} 1388}
1391 1389
1392void MainWindow::features() 1390void MainWindow::features()
1393{ 1391{
1394 1392
1395 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1393 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1396} 1394}
1397 1395
1398void MainWindow::usertrans() 1396void MainWindow::usertrans()
1399{ 1397{
1400 1398
1401 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1399 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1402} 1400}
1403 1401
1404void MainWindow::storagehowto() 1402void MainWindow::storagehowto()
1405{ 1403{
1406 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1404 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1407} 1405}
1408void MainWindow::timetrackinghowto() 1406void MainWindow::timetrackinghowto()
1409{ 1407{
1410 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1408 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1411} 1409}
1412void MainWindow::kdesynchowto() 1410void MainWindow::kdesynchowto()
1413{ 1411{
1414 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1412 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1415} 1413}
1416void MainWindow::multisynchowto() 1414void MainWindow::multisynchowto()
1417{ 1415{
1418 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1416 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1419} 1417}
1420void MainWindow::synchowto() 1418void MainWindow::synchowto()
1421{ 1419{
1422 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1420 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1423} 1421}
1424void MainWindow::faq() 1422void MainWindow::faq()
1425{ 1423{
1426 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1424 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1427 1425
1428} 1426}
1429void MainWindow::whatsNew() 1427void MainWindow::whatsNew()
1430{ 1428{
1431 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1429 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1432 1430
1433} 1431}
1434void MainWindow::licence() 1432void MainWindow::licence()
1435{ 1433{
1436 KApplication::showLicence(); 1434 KApplication::showLicence();
1437 1435
1438} 1436}
1439void MainWindow::about() 1437void MainWindow::about()
1440{ 1438{
1441 QString version; 1439 QString version;
1442#include <../version> 1440#include <../version>
1443 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1441 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1444 i18n("KOrganizer/Platform-independent\n") + 1442 i18n("KOrganizer/Platform-independent\n") +
1445 "(KO/Pi) " + version + " - " + 1443 "(KO/Pi) " + version + " - " +
1446 1444
1447#ifdef DESKTOP_VERSION 1445#ifdef DESKTOP_VERSION
1448 i18n("Desktop Edition\n") + 1446 i18n("Desktop Edition\n") +
1449#else 1447#else
1450 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1448 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1451#endif 1449#endif
1452 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1450 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1453} 1451}
1454void MainWindow::keyBindings() 1452void MainWindow::keyBindings()
1455{ 1453{
1456 QString cap = i18n("KO/Pi Keys + Colors"); 1454 QString cap = i18n("KO/Pi Keys + Colors");
1457 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1455 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1458 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1456 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1459 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1457 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1460 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1458 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1461 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1459 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1462 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1460 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1463 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1461 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1464 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1462 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1465 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1463 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1466 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1464 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1467 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1465 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1468 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1466 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1469 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1467 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1470 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1468 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1471 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1469 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1472 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1470 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1473 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1471 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1474 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1472 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1475 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1473 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1476 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1474 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1477 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1475 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1478 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1476 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1479 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1477 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1480 i18n("<p><h3>In agenda view:</h3></p>\n") + 1478 i18n("<p><h3>In agenda view:</h3></p>\n") +
1481 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1479 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1482 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1480 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1483 i18n("<p><h3>In todo view:</h3></p>\n") + 1481 i18n("<p><h3>In todo view:</h3></p>\n") +
1484 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1482 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1485 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1483 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1486 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1484 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1487 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1485 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1488 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1486 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1489 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1487 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1490 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1488 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1491 i18n("<p><h3>In list view:</h3></p>\n") + 1489 i18n("<p><h3>In list view:</h3></p>\n") +
1492 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1490 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1493 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1491 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1494 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1492 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1495 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1493 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1496 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1494 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1497 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1495 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1498 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1496 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1499 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1497 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1500 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1498 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1501 i18n("<p><b>E</b>: Edit item</p>\n") + 1499 i18n("<p><b>E</b>: Edit item</p>\n") +
1502 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1500 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1503 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1501 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1504 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1502 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1505 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1503 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1506 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1504 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1507 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1505 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1508 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1506 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1509 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1507 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1510 i18n("<p><b>White</b>: Item readonly</p>\n"); 1508 i18n("<p><b>White</b>: Item readonly</p>\n");
1511 displayText( text, cap); 1509 displayText( text, cap);
1512} 1510}
1513void MainWindow::aboutAutoSaving() 1511void MainWindow::aboutAutoSaving()
1514{ 1512{
1515 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1513 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1516 1514
1517 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1515 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1518 1516
1519} 1517}
1520void MainWindow::aboutKnownBugs() 1518void MainWindow::aboutKnownBugs()
1521{ 1519{
1522 QMessageBox* msg; 1520 QMessageBox* msg;
1523 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1521 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1524 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1522 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1525 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1523 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1526 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1524 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1527 i18n("\nor report them in the bugtracker on\n") + 1525 i18n("\nor report them in the bugtracker on\n") +
1528 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1526 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1529 QMessageBox::NoIcon, 1527 QMessageBox::NoIcon,
1530 QMessageBox::Ok, 1528 QMessageBox::Ok,
1531 QMessageBox::NoButton, 1529 QMessageBox::NoButton,
1532 QMessageBox::NoButton); 1530 QMessageBox::NoButton);
1533 msg->exec(); 1531 msg->exec();
1534 delete msg; 1532 delete msg;
1535 1533
1536} 1534}
1537 1535
1538QString MainWindow::defaultFileName() 1536QString MainWindow::defaultFileName()
1539{ 1537{
1540 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1538 return locateLocal( "data", "korganizer/mycalendar.ics" );
1541} 1539}
1542QString MainWindow::syncFileName() 1540QString MainWindow::syncFileName()
1543{ 1541{
1544#ifdef DESKTOP_VERSION 1542#ifdef DESKTOP_VERSION
1545 return locateLocal( "tmp", "synccalendar.ics" ); 1543 return locateLocal( "tmp", "synccalendar.ics" );
1546#else 1544#else
1547 return QString( "/tmp/synccalendar.ics" ); 1545 return QString( "/tmp/synccalendar.ics" );
1548#endif 1546#endif
1549} 1547}
1550#include "koglobals.h" 1548#include "koglobals.h"
1551#include <kcalendarsystem.h> 1549#include <kcalendarsystem.h>
1552void MainWindow::updateWeek(QDate seda) 1550void MainWindow::updateWeek(QDate seda)
1553{ 1551{
1554 int weekNum = KGlobal::locale()->weekNum ( seda ); 1552 int weekNum = KGlobal::locale()->weekNum ( seda );
1555 mWeekPixmap.fill( mWeekBgColor ); 1553 mWeekPixmap.fill( mWeekBgColor );
1556 QPainter p ( &mWeekPixmap ); 1554 QPainter p ( &mWeekPixmap );
1557 p.setFont( mWeekFont ); 1555 p.setFont( mWeekFont );
1558 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1556 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1559 p.end(); 1557 p.end();
1560 QIconSet icon3 ( mWeekPixmap ); 1558 QIconSet icon3 ( mWeekPixmap );
1561 mWeekAction->setIconSet ( icon3 ); 1559 mWeekAction->setIconSet ( icon3 );
1562 1560
1563} 1561}
1564void MainWindow::updateWeekNum(const DateList &selectedDates) 1562void MainWindow::updateWeekNum(const DateList &selectedDates)
1565{ 1563{
1566 updateWeek( selectedDates.first() ); 1564 updateWeek( selectedDates.first() );
1567} 1565}
1568void MainWindow::processIncidenceSelection( Incidence *incidence ) 1566void MainWindow::processIncidenceSelection( Incidence *incidence )
1569{ 1567{
1570 1568
1571 if ( !incidence ) { 1569 if ( !incidence ) {
1572 enableIncidenceActions( false ); 1570 enableIncidenceActions( false );
1573 1571
1574 mNewSubTodoAction->setEnabled( false ); 1572 mNewSubTodoAction->setEnabled( false );
1575 setCaptionToDates(); 1573 setCaptionToDates();
1576 return; 1574 return;
1577 1575
1578 } 1576 }
1579 1577
1580 //KGlobal::locale()->formatDateTime(nextA, true); 1578 //KGlobal::locale()->formatDateTime(nextA, true);
1581 QString startString = ""; 1579 QString startString = "";
1582 if ( incidence->type() != "Todo" ) { 1580 if ( incidence->type() != "Todo" ) {
1583 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1581 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1584 if ( incidence->doesFloat() ) { 1582 if ( incidence->doesFloat() ) {
1585 startString += ": "+incidence->dtStartDateStr( true ); 1583 startString += ": "+incidence->dtStartDateStr( true );
1586 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1584 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1587 1585
1588 } else { 1586 } else {
1589 startString = ": "+incidence->dtStartStr(true); 1587 startString = ": "+incidence->dtStartStr(true);
1590 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1588 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1591 1589
1592 } 1590 }
1593 1591
1594 } else { 1592 } else {
1595 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1593 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1596 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1594 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1597 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1595 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1598 1596
1599 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1597 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1600 bool ok; 1598 bool ok;
1601 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1599 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1602 if ( ok ) { 1600 if ( ok ) {
1603 int years = noc.date().year() - incidence->dtStart().date().year(); 1601 int years = noc.date().year() - incidence->dtStart().date().year();
1604 startString += i18n(" (%1 y.)"). arg( years ); 1602 startString += i18n(" (%1 y.)"). arg( years );
1605 } 1603 }
1606 } 1604 }
1607 else 1605 else
1608 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1606 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1609 } 1607 }
1610 1608
1611 } 1609 }
1612 else 1610 else
1613 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1611 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1614 if ( !incidence->location().isEmpty() ) 1612 if ( !incidence->location().isEmpty() )
1615 startString += " (" +incidence->location()+")"; 1613 startString += " (" +incidence->location()+")";
1616 setCaption( incidence->summary()+startString); 1614 setCaption( incidence->summary()+startString);
1617 1615
1618 enableIncidenceActions( true ); 1616 enableIncidenceActions( true );
1619 1617
1620 if ( incidence->type() == "Event" ) { 1618 if ( incidence->type() == "Event" ) {
1621 mShowAction->setText( i18n("Show Event...") ); 1619 mShowAction->setText( i18n("Show Event...") );
1622 mEditAction->setText( i18n("Edit Event...") ); 1620 mEditAction->setText( i18n("Edit Event...") );
1623 mDeleteAction->setText( i18n("Delete Event...") ); 1621 mDeleteAction->setText( i18n("Delete Event...") );
1624 1622
1625 mNewSubTodoAction->setEnabled( false ); 1623 mNewSubTodoAction->setEnabled( false );
1626 } else if ( incidence->type() == "Todo" ) { 1624 } else if ( incidence->type() == "Todo" ) {
1627 mShowAction->setText( i18n("Show Todo...") ); 1625 mShowAction->setText( i18n("Show Todo...") );
1628 mEditAction->setText( i18n("Edit Todo...") ); 1626 mEditAction->setText( i18n("Edit Todo...") );
1629 mDeleteAction->setText( i18n("Delete Todo...") ); 1627 mDeleteAction->setText( i18n("Delete Todo...") );
1630 1628
1631 mNewSubTodoAction->setEnabled( true ); 1629 mNewSubTodoAction->setEnabled( true );
1632 } else { 1630 } else {
1633 mShowAction->setText( i18n("Show...") ); 1631 mShowAction->setText( i18n("Show...") );
1634 mShowAction->setText( i18n("Edit...") ); 1632 mShowAction->setText( i18n("Edit...") );
1635 mShowAction->setText( i18n("Delete...") ); 1633 mShowAction->setText( i18n("Delete...") );
1636 1634
1637 mNewSubTodoAction->setEnabled( false ); 1635 mNewSubTodoAction->setEnabled( false );
1638 } 1636 }
1639} 1637}
1640 1638
1641void MainWindow::enableIncidenceActions( bool enabled ) 1639void MainWindow::enableIncidenceActions( bool enabled )
1642{ 1640{
1643 mShowAction->setEnabled( enabled ); 1641 mShowAction->setEnabled( enabled );
1644 mEditAction->setEnabled( enabled ); 1642 mEditAction->setEnabled( enabled );
1645 mDeleteAction->setEnabled( enabled ); 1643 mDeleteAction->setEnabled( enabled );
1646 1644
1647 mCloneAction->setEnabled( enabled ); 1645 mCloneAction->setEnabled( enabled );
1648 mMoveAction->setEnabled( enabled ); 1646 mMoveAction->setEnabled( enabled );
1649 mBeamAction->setEnabled( enabled ); 1647 mBeamAction->setEnabled( enabled );
1650 mCancelAction->setEnabled( enabled ); 1648 mCancelAction->setEnabled( enabled );
1651} 1649}
1652 1650
1653void MainWindow::importOL() 1651void MainWindow::importOL()
1654{ 1652{
1655#ifdef _OL_IMPORT_ 1653#ifdef _OL_IMPORT_
1656 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1654 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1657 id->exec(); 1655 id->exec();
1658 delete id; 1656 delete id;
1659 mView->updateView(); 1657 mView->updateView();
1660#endif 1658#endif
1661} 1659}
1662void MainWindow::importBday() 1660void MainWindow::importBday()
1663{ 1661{
1664 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1662 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1665 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1663 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1666 i18n("Import!"), i18n("Cancel"), 0, 1664 i18n("Import!"), i18n("Cancel"), 0,
1667 0, 1 ); 1665 0, 1 );
1668 if ( result == 0 ) { 1666 if ( result == 0 ) {
1669 mView->importBday(); 1667 mView->importBday();
1670 1668
1671 } 1669 }
1672 1670
1673 1671
1674} 1672}
1675void MainWindow::importQtopia() 1673void MainWindow::importQtopia()
1676{ 1674{
1677 //#ifndef DESKTOP_VERSION 1675 //#ifndef DESKTOP_VERSION
1678 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); 1676 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing");
1679#ifdef DESKTOP_VERSION 1677#ifdef DESKTOP_VERSION
1680 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1678 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1681#endif 1679#endif
1682 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1680 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1683 i18n("Import!"), i18n("Cancel"), 0, 1681 i18n("Import!"), i18n("Cancel"), 0,
1684 0, 1 ); 1682 0, 1 );
1685 if ( result == 0 ) { 1683 if ( result == 0 ) {
1686#ifndef DESKTOP_VERSION 1684#ifndef DESKTOP_VERSION
1687 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1685 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1688 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1686 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1689 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1687 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1690#else 1688#else
1691 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1689 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1692 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1690 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1693 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1691 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1694#endif 1692#endif
1695 mView->importQtopia( categories, datebook, todolist ); 1693 mView->importQtopia( categories, datebook, todolist );
1696 } 1694 }
1697#if 0 1695#if 0
1698 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1696 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1699 i18n("Not supported \non desktop!\n"), 1697 i18n("Not supported \non desktop!\n"),
1700 i18n("Ok"), i18n("Cancel"), 0, 1698 i18n("Ok"), i18n("Cancel"), 0,
1701 0, 1 ); 1699 0, 1 );
1702 1700
1703#endif 1701#endif
1704} 1702}
1705 1703
1706void MainWindow::saveOnClose() 1704void MainWindow::saveOnClose()
1707{ 1705{
1708 KOPrefs *p = KOPrefs::instance(); 1706 KOPrefs *p = KOPrefs::instance();
1709 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1707 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1710 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1708 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1711 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1709 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1712 if ( filterToolBar ) { 1710 if ( filterToolBar ) {
1713 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1711 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1714 } 1712 }
1715#ifdef DESKTOP_VERSION 1713#ifdef DESKTOP_VERSION
1716 1714
1717 QPoint myP; 1715 QPoint myP;
1718 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1716 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1719 if ( p->mToolBarHor ) 1717 if ( p->mToolBarHor )
1720 p->mToolBarUp = myP.y() > height()/2; 1718 p->mToolBarUp = myP.y() > height()/2;
1721 else 1719 else
1722 p->mToolBarUp = myP.x() > width()/2; 1720 p->mToolBarUp = myP.x() > width()/2;
1723 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1721 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1724 if ( p->mToolBarHorV ) 1722 if ( p->mToolBarHorV )
1725 p->mToolBarUpV = myP.y() > height()/2; 1723 p->mToolBarUpV = myP.y() > height()/2;
1726 else 1724 else
1727 p->mToolBarUpV = myP.x() > width()/2 ; 1725 p->mToolBarUpV = myP.x() > width()/2 ;
1728 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1726 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1729 if ( p->mToolBarHorN ) 1727 if ( p->mToolBarHorN )
1730 p->mToolBarUpN = myP.y() > height()/2; 1728 p->mToolBarUpN = myP.y() > height()/2;
1731 else 1729 else
1732 p->mToolBarUpN = myP.x() > width()/2 ; 1730 p->mToolBarUpN = myP.x() > width()/2 ;
1733 if ( filterToolBar ) { 1731 if ( filterToolBar ) {
1734 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1732 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1735 if ( p->mToolBarHorF ) 1733 if ( p->mToolBarHorF )
1736 p->mToolBarUpF = myP.y() > height()/2; 1734 p->mToolBarUpF = myP.y() > height()/2;
1737 else 1735 else
1738 p->mToolBarUpF = myP.x() > width()/2 ; 1736 p->mToolBarUpF = myP.x() > width()/2 ;
1739 } 1737 }
1740#else 1738#else
1741 if ( p->mToolBarHor ) 1739 if ( p->mToolBarHor )
1742 p->mToolBarUp = iconToolBar->y() > height()/2; 1740 p->mToolBarUp = iconToolBar->y() > height()/2;
1743 else 1741 else
1744 p->mToolBarUp = iconToolBar->x() > width()/2; 1742 p->mToolBarUp = iconToolBar->x() > width()/2;
1745 if ( p->mToolBarHorV ) 1743 if ( p->mToolBarHorV )
1746 p->mToolBarUpV = viewToolBar->y() > height()/2; 1744 p->mToolBarUpV = viewToolBar->y() > height()/2;
1747 else 1745 else
1748 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1746 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1749 1747
1750 if ( p->mToolBarHorN ) 1748 if ( p->mToolBarHorN )
1751 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1749 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1752 else 1750 else
1753 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1751 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1754 if ( filterToolBar ) { 1752 if ( filterToolBar ) {
1755 if ( p->mToolBarHorF ) 1753 if ( p->mToolBarHorF )
1756 p->mToolBarUpF = filterToolBar->y() > height()/2; 1754 p->mToolBarUpF = filterToolBar->y() > height()/2;
1757 else 1755 else
1758 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1756 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1759 } 1757 }
1760#endif 1758#endif
1761 1759
1762 1760
1763 mView->writeSettings(); 1761 mView->writeSettings();
1764 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1762 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1765 save(); 1763 save();
1766} 1764}
1767void MainWindow::slotModifiedChanged( bool changed ) 1765void MainWindow::slotModifiedChanged( bool changed )
1768{ 1766{
1769 if ( mBlockAtStartup ) 1767 if ( mBlockAtStartup )
1770 return; 1768 return;
1771 1769
1772 int msec; 1770 int msec;
1773 // we store the changes after 1 minute, 1771 // we store the changes after 1 minute,
1774 // and for safety reasons after 10 minutes again 1772 // and for safety reasons after 10 minutes again
1775 if ( !mSyncManager->blockSave() ) 1773 if ( !mSyncManager->blockSave() )
1776 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1774 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1777 else 1775 else
1778 msec = 1000 * 600; 1776 msec = 1000 * 600;
1779 mSaveTimer.start( msec, true ); // 1 minute 1777 mSaveTimer.start( msec, true ); // 1 minute
1780 qDebug("KO: Saving File in %d secs!", msec/1000); 1778 qDebug("KO: Saving File in %d secs!", msec/1000);
1781 mCalendarModifiedFlag = true; 1779 mCalendarModifiedFlag = true;
1782} 1780}
1783void MainWindow::saveStopTimer() 1781void MainWindow::saveStopTimer()
1784{ 1782{
1785 mSaveTimer.stop(); 1783 mSaveTimer.stop();
1786} 1784}
1787void MainWindow::save() 1785void MainWindow::save()
1788{ 1786{
1789 if ( !mCalendarModifiedFlag ) { 1787 if ( !mCalendarModifiedFlag ) {
1790 qDebug("KO: Calendar not modified. Nothing saved."); 1788 qDebug("KO: Calendar not modified. Nothing saved.");
1791 return; 1789 return;
1792 } 1790 }
1793 if ( mSyncManager->blockSave() ) 1791 if ( mSyncManager->blockSave() )
1794 return; 1792 return;
1795 mSyncManager->setBlockSave(true); 1793 mSyncManager->setBlockSave(true);
1796 if ( mView->checkFileVersion( defaultFileName()) ) { 1794 if ( mView->checkFileVersion( defaultFileName()) ) {
1797 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1795 QTime neededSaveTime = QDateTime::currentDateTime().time();
1798 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1796 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1799 qDebug("KO: Start saving data to file!"); 1797 qDebug("KO: Start saving data to file!");
1800 mView->saveCalendar( defaultFileName() ); 1798 mView->saveCalendar( defaultFileName() );
1801 mCalendarModifiedFlag = false; 1799 mCalendarModifiedFlag = false;
1802 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1800 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1803 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1801 qDebug("KO: Needed %d ms for saving.",msNeeded );
1804 QString savemes; 1802 QString savemes;
1805 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1803 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1806 setCaption(savemes); 1804 setCaption(savemes);
1807 } else 1805 } else
1808 setCaption(i18n("Saving cancelled!")); 1806 setCaption(i18n("Saving cancelled!"));
1809 mSyncManager->setBlockSave( false ); 1807 mSyncManager->setBlockSave( false );
1810} 1808}
1811 1809
1812void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1810void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1813{ 1811{
1814 if ( !e->isAutoRepeat() ) { 1812 if ( !e->isAutoRepeat() ) {
1815 mFlagKeyPressed = false; 1813 mFlagKeyPressed = false;
1816 } 1814 }
1817} 1815}
1818void MainWindow::keyPressEvent ( QKeyEvent * e ) 1816void MainWindow::keyPressEvent ( QKeyEvent * e )
1819{ 1817{
1820 qApp->processEvents(); 1818 qApp->processEvents();
1821 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1819 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1822 e->ignore(); 1820 e->ignore();
1823 // qDebug(" ignore %d",e->isAutoRepeat() ); 1821 // qDebug(" ignore %d",e->isAutoRepeat() );
1824 return; 1822 return;
1825 } 1823 }
1826 if (! e->isAutoRepeat() ) 1824 if (! e->isAutoRepeat() )
1827 mFlagKeyPressed = true; 1825 mFlagKeyPressed = true;
1828 KOPrefs *p = KOPrefs::instance(); 1826 KOPrefs *p = KOPrefs::instance();
1829 bool showSelectedDates = false; 1827 bool showSelectedDates = false;
1830 int size; 1828 int size;
1831 int pro = 0; 1829 int pro = 0;
1832 //qDebug("MainWindow::keyPressEvent "); 1830 //qDebug("MainWindow::keyPressEvent ");
1833 switch ( e->key() ) { 1831 switch ( e->key() ) {
1834 case Qt::Key_Right: 1832 case Qt::Key_Right:
1835 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1833 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1836 mView->goNextMonth(); 1834 mView->goNextMonth();
1837 else 1835 else
1838 mView->goNext(); 1836 mView->goNext();
1839 showSelectedDates = true; 1837 showSelectedDates = true;
1840 break; 1838 break;
1841 case Qt::Key_Left: 1839 case Qt::Key_Left:
1842 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1840 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1843 mView->goPreviousMonth(); 1841 mView->goPreviousMonth();
1844 else 1842 else
1845 mView->goPrevious(); 1843 mView->goPrevious();
1846 showSelectedDates = true; 1844 showSelectedDates = true;
1847 break; 1845 break;
1848 case Qt::Key_Down: 1846 case Qt::Key_Down:
1849 mView->viewManager()->agendaView()->scrollOneHourDown(); 1847 mView->viewManager()->agendaView()->scrollOneHourDown();
1850 break; 1848 break;
1851 case Qt::Key_Up: 1849 case Qt::Key_Up:
1852 mView->viewManager()->agendaView()->scrollOneHourUp(); 1850 mView->viewManager()->agendaView()->scrollOneHourUp();
1853 break; 1851 break;
1854 case Qt::Key_K: 1852 case Qt::Key_K:
1855 mView->viewManager()->showMonthViewWeek(); 1853 mView->viewManager()->showMonthViewWeek();
1856 break; 1854 break;
1857 case Qt::Key_I: 1855 case Qt::Key_I:
1858 mView->showIncidence(); 1856 mView->showIncidence();
1859 break; 1857 break;
1860 case Qt::Key_Delete: 1858 case Qt::Key_Delete:
1861 case Qt::Key_Backspace: 1859 case Qt::Key_Backspace:
1862 mView->deleteIncidence(); 1860 mView->deleteIncidence();
1863 break; 1861 break;
1864 case Qt::Key_D: 1862 case Qt::Key_D:
1865 mView->viewManager()->showDayView(); 1863 mView->viewManager()->showDayView();
1866 showSelectedDates = true; 1864 showSelectedDates = true;
1867 break; 1865 break;
1868 case Qt::Key_O: 1866 case Qt::Key_O:
1869 mView->toggleFilerEnabled( ); 1867 mView->toggleFilerEnabled( );
1870 break; 1868 break;
1871 case Qt::Key_0: 1869 case Qt::Key_0:
1872 case Qt::Key_1: 1870 case Qt::Key_1:
1873 case Qt::Key_2: 1871 case Qt::Key_2:
1874 case Qt::Key_3: 1872 case Qt::Key_3:
1875 case Qt::Key_4: 1873 case Qt::Key_4:
1876 case Qt::Key_5: 1874 case Qt::Key_5:
1877 case Qt::Key_6: 1875 case Qt::Key_6:
1878 case Qt::Key_7: 1876 case Qt::Key_7:
1879 case Qt::Key_8: 1877 case Qt::Key_8:
1880 case Qt::Key_9: 1878 case Qt::Key_9:
1881 pro = e->key()-48; 1879 pro = e->key()-48;
1882 if ( pro == 0 ) 1880 if ( pro == 0 )
1883 pro = 10; 1881 pro = 10;
1884 if ( e->state() == Qt::ControlButton) 1882 if ( e->state() == Qt::ControlButton)
1885 pro += 10; 1883 pro += 10;
1886 break; 1884 break;
1887 case Qt::Key_M: 1885 case Qt::Key_M:
1888 mView->viewManager()->showMonthView(); 1886 mView->viewManager()->showMonthView();
1889 showSelectedDates = true; 1887 showSelectedDates = true;
1890 break; 1888 break;
1891 case Qt::Key_Insert: 1889 case Qt::Key_Insert:
1892 mView->newEvent(); 1890 mView->newEvent();
1893 break; 1891 break;
1894 case Qt::Key_S : 1892 case Qt::Key_S :
1895 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1893 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1896 mView->newSubTodo(); 1894 mView->newSubTodo();
1897 else 1895 else
1898 mView->dialogManager()->showSearchDialog(); 1896 mView->dialogManager()->showSearchDialog();
1899 break; 1897 break;
1900 case Qt::Key_Y : 1898 case Qt::Key_Y :
1901 case Qt::Key_Z : 1899 case Qt::Key_Z :
1902 mView->viewManager()->showWorkWeekView(); 1900 mView->viewManager()->showWorkWeekView();
1903 showSelectedDates = true; 1901 showSelectedDates = true;
1904 break; 1902 break;
1905 case Qt::Key_U : 1903 case Qt::Key_U :
1906 mView->viewManager()->showWeekView(); 1904 mView->viewManager()->showWeekView();
1907 showSelectedDates = true; 1905 showSelectedDates = true;
1908 break; 1906 break;
1909 case Qt::Key_H : 1907 case Qt::Key_H :
1910 keyBindings(); 1908 keyBindings();
1911 break; 1909 break;
1912 case Qt::Key_W: 1910 case Qt::Key_W:
1913 mView->viewManager()->showWhatsNextView(); 1911 mView->viewManager()->showWhatsNextView();
1914 break; 1912 break;
1915 case Qt::Key_L: 1913 case Qt::Key_L:
1916 mView->viewManager()->showListView(); 1914 mView->viewManager()->showListView();
1917 break; 1915 break;
1918 case Qt::Key_N: 1916 case Qt::Key_N:
1919 mView->viewManager()->showNextView(); 1917 mView->viewManager()->showNextView();
1920 break; 1918 break;
1921 case Qt::Key_V: 1919 case Qt::Key_V:
1922 mView->viewManager()->showTodoView(); 1920 mView->viewManager()->showTodoView();
1923 break; 1921 break;
1924 case Qt::Key_C: 1922 case Qt::Key_C:
1925 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1923 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1926 break; 1924 break;
1927 case Qt::Key_P: 1925 case Qt::Key_P:
1928 mView->showDatePicker( ); 1926 mView->showDatePicker( );
1929 break; 1927 break;
1930 case Qt::Key_F: 1928 case Qt::Key_F:
1931 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1929 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1932 mView->editFilters(); 1930 mView->editFilters();
1933 else 1931 else
1934 mView->toggleFilter(); 1932 mView->toggleFilter();
1935 break; 1933 break;
1936 case Qt::Key_X: 1934 case Qt::Key_X:
1937 if ( e->state() == Qt::ControlButton ) 1935 if ( e->state() == Qt::ControlButton )
1938 mView->toggleDateNavigatorWidget(); 1936 mView->toggleDateNavigatorWidget();
1939 else { 1937 else {
1940 mView->viewManager()->showNextXView(); 1938 mView->viewManager()->showNextXView();
1941 showSelectedDates = true; 1939 showSelectedDates = true;
1942 } 1940 }
1943 break; 1941 break;
1944 case Qt::Key_Space: 1942 case Qt::Key_Space:
1945 mView->toggleExpand(); 1943 mView->toggleExpand();
1946 break; 1944 break;
1947 case Qt::Key_A: 1945 case Qt::Key_A:
1948 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 1946 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
1949 mView->showNextAlarms(); 1947 mView->showNextAlarms();
1950 else 1948 else
1951 mView->toggleAllDaySize(); 1949 mView->toggleAllDaySize();
1952 break; 1950 break;
1953 case Qt::Key_T: 1951 case Qt::Key_T:
1954 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1952 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1955 mView->newTodo(); 1953 mView->newTodo();
1956 else { 1954 else {
1957 mView->goToday(); 1955 mView->goToday();
1958 showSelectedDates = true; 1956 showSelectedDates = true;
1959 } 1957 }
1960 break; 1958 break;
1961 case Qt::Key_J: 1959 case Qt::Key_J:
1962 mView->viewManager()->showJournalView(); 1960 mView->viewManager()->showJournalView();
1963 break; 1961 break;
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index f2a6c60..45ed04d 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,175 +1,166 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qmenubar.h> 8#include <qmenubar.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include "simplealarmclient.h"
14#include <ksyncmanager.h> 13#include <ksyncmanager.h>
15#ifndef DESKTOP_VERSION 14#ifndef DESKTOP_VERSION
16#include <qcopchannel_qws.h> 15#include <qcopchannel_qws.h>
17#endif 16#endif
18class QAction; 17class QAction;
19class CalendarView; 18class CalendarView;
20class KSyncProfile; 19class KSyncProfile;
21#ifdef DESKTOP_VERSION 20#ifdef DESKTOP_VERSION
22 21
23#define QPEToolBar QToolBar 22#define QPEToolBar QToolBar
24#define QPEMenuBar QMenuBar 23#define QPEMenuBar QMenuBar
25#endif 24#endif
26class QPEToolBar; 25class QPEToolBar;
27class QPEMenuBar; 26class QPEMenuBar;
28 27
29 28
30namespace KCal { 29namespace KCal {
31class CalendarLocal; 30class CalendarLocal;
32} 31}
33 32
34class KOMenuBar : public QMenuBar
35{
36 public:
37 KOMenuBar( QWidget *parent=0 ): QMenuBar (parent ) {;}
38 QSize sizeHint () const{ qDebug("sizejint ");return QSize ( 40,25 );}
39};
40
41using namespace KCal; 33using namespace KCal;
42 34
43class MainWindow : public QMainWindow 35class MainWindow : public QMainWindow
44{ 36{
45 Q_OBJECT 37 Q_OBJECT
46 public: 38 public:
47 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 39 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
48 ~MainWindow(); 40 ~MainWindow();
49 bool beamReceiveEnabled(); 41 bool beamReceiveEnabled();
50 static QString defaultFileName(); 42 static QString defaultFileName();
51 static QString syncFileName(); 43 static QString syncFileName();
52 static QString resourcePath(); 44 static QString resourcePath();
53 public slots: 45 public slots:
54 void setCaption ( const QString & ); 46 void setCaption ( const QString & );
55 void updateWeekNum(const KCal::DateList &); 47 void updateWeekNum(const KCal::DateList &);
56 void updateWeek(QDate); 48 void updateWeek(QDate);
57 void updateFilterToolbar(); 49 void updateFilterToolbar();
58 virtual void showMaximized (); 50 virtual void showMaximized ();
59 void configureAgenda( int ); 51 void configureAgenda( int );
60 void recieve( const QCString& msg, const QByteArray& data ); 52 void recieve( const QCString& msg, const QByteArray& data );
61 protected slots: 53 protected slots:
62 void setCaptionToDates(); 54 void setCaptionToDates();
63 void weekAction(); 55 void weekAction();
64 void about(); 56 void about();
65 void licence(); 57 void licence();
66 void faq(); 58 void faq();
67 void usertrans(); 59 void usertrans();
68 void features(); 60 void features();
69 void synchowto(); 61 void synchowto();
70 void storagehowto(); 62 void storagehowto();
71 void timetrackinghowto(); 63 void timetrackinghowto();
72 void kdesynchowto(); 64 void kdesynchowto();
73 void multisynchowto(); 65 void multisynchowto();
74 void whatsNew(); 66 void whatsNew();
75 void keyBindings(); 67 void keyBindings();
76 void aboutAutoSaving();; 68 void aboutAutoSaving();;
77 void aboutKnownBugs(); 69 void aboutKnownBugs();
78 70
79 void processIncidenceSelection( Incidence * ); 71 void processIncidenceSelection( Incidence * );
80 72
81 void importQtopia(); 73 void importQtopia();
82 void importBday(); 74 void importBday();
83 void importOL(); 75 void importOL();
84 void importIcal(); 76 void importIcal();
85 void importFile( QString, bool ); 77 void importFile( QString, bool );
86 void quickImportIcal(); 78 void quickImportIcal();
87 79
88 void slotModifiedChanged( bool ); 80 void slotModifiedChanged( bool );
89 81
90 void save(); 82 void save();
91 void saveStopTimer(); 83 void saveStopTimer();
92 void configureToolBar( int ); 84 void configureToolBar( int );
93 void printSel(); 85 void printSel();
94 void printCal(); 86 void printCal();
95 void saveCalendar(); 87 void saveCalendar();
96 void loadCalendar(); 88 void loadCalendar();
97 void exportVCalendar(); 89 void exportVCalendar();
98 void fillFilterMenu(); 90 void fillFilterMenu();
99 void fillFilterMenuTB(); 91 void fillFilterMenuTB();
100 void selectFilter( int ); 92 void selectFilter( int );
101 void fillFilterMenuPopup(); 93 void fillFilterMenuPopup();
102 void selectFilterPopup( int ); 94 void selectFilterPopup( int );
103 void exportToPhone( int ); 95 void exportToPhone( int );
104 void toggleBeamReceive(); 96 void toggleBeamReceive();
105 void disableBR(bool); 97 void disableBR(bool);
106 signals: 98 signals:
107 void selectWeek ( int ); 99 void selectWeek ( int );
108 private slots: 100 private slots:
109 void showConfigureAgenda(); 101 void showConfigureAgenda();
110 void getFile( bool ); 102 void getFile( bool );
111 void syncFileRequest(); 103 void syncFileRequest();
112 104
113 protected: 105 protected:
114 void hideEvent ( QHideEvent * ); 106 void hideEvent ( QHideEvent * );
115 QString sentSyncFile(); 107 QString sentSyncFile();
116 void displayText( QString, QString); 108 void displayText( QString, QString);
117 void enableIncidenceActions( bool ); 109 void enableIncidenceActions( bool );
118 110
119 private: 111 private:
120 bool mBRdisabled; 112 bool mBRdisabled;
121#ifndef DESKTOP_VERSION 113#ifndef DESKTOP_VERSION
122 QCopChannel* infrared; 114 QCopChannel* infrared;
123#endif 115#endif
124 QAction* brAction; 116 QAction* brAction;
125 KSyncManager* mSyncManager; 117 KSyncManager* mSyncManager;
126 bool mClosed; 118 bool mClosed;
127 void saveOnClose(); 119 void saveOnClose();
128 bool mFlagKeyPressed; 120 bool mFlagKeyPressed;
129 bool mBlockAtStartup; 121 bool mBlockAtStartup;
130 QPEToolBar *iconToolBar; 122 QPEToolBar *iconToolBar;
131 QPEToolBar *viewToolBar; 123 QPEToolBar *viewToolBar;
132 QPEToolBar *navigatorToolBar; 124 QPEToolBar *navigatorToolBar;
133 QPEToolBar *filterToolBar; 125 QPEToolBar *filterToolBar;
134 QPEMenuBar *filterMenubar; 126 QPEMenuBar *filterMenubar;
135 QPopupMenu * filterPopupMenu; 127 QPopupMenu * filterPopupMenu;
136 void initActions(); 128 void initActions();
137 void setDefaultPreferences(); 129 void setDefaultPreferences();
138 void resizeEvent( QResizeEvent* e); 130 void resizeEvent( QResizeEvent* e);
139 void keyPressEvent ( QKeyEvent * ) ; 131 void keyPressEvent ( QKeyEvent * ) ;
140 void keyReleaseEvent ( QKeyEvent * ) ; 132 void keyReleaseEvent ( QKeyEvent * ) ;
141 QPopupMenu *configureToolBarMenu; 133 QPopupMenu *configureToolBarMenu;
142 QPopupMenu *selectFilterMenu; 134 QPopupMenu *selectFilterMenu;
143 QPopupMenu *selectFilterMenuTB; 135 QPopupMenu *selectFilterMenuTB;
144 QPopupMenu *configureAgendaMenu, *syncMenu; 136 QPopupMenu *configureAgendaMenu, *syncMenu;
145 CalendarLocal *mCalendar; 137 CalendarLocal *mCalendar;
146 CalendarView *mView; 138 CalendarView *mView;
147 QAction *mNewSubTodoAction; 139 QAction *mNewSubTodoAction;
148 QAction *mWeekAction; 140 QAction *mWeekAction;
149 QFont mWeekFont; 141 QFont mWeekFont;
150 QPixmap mWeekPixmap; 142 QPixmap mWeekPixmap;
151 QColor mWeekBgColor; 143 QColor mWeekBgColor;
152 144
153 QAction *mShowAction; 145 QAction *mShowAction;
154 QAction *mEditAction; 146 QAction *mEditAction;
155 QAction *mDeleteAction; 147 QAction *mDeleteAction;
156 QAction *mCloneAction; 148 QAction *mCloneAction;
157 QAction *mMoveAction; 149 QAction *mMoveAction;
158 QAction *mBeamAction; 150 QAction *mBeamAction;
159 QAction *mCancelAction; 151 QAction *mCancelAction;
160 152
161 QAction *mToggleNav; 153 QAction *mToggleNav;
162 QAction *mToggleFilter; 154 QAction *mToggleFilter;
163 QAction *mToggleAllday; 155 QAction *mToggleAllday;
164 QAction *actionFilterMenuTB; 156 QAction *actionFilterMenuTB;
165 157
166 void closeEvent( QCloseEvent* ce ); 158 void closeEvent( QCloseEvent* ce );
167 SimpleAlarmClient mAlarmClient;
168 QTimer mSaveTimer; 159 QTimer mSaveTimer;
169 //bool mBlockSaveFlag; 160 //bool mBlockSaveFlag;
170 bool mCalendarModifiedFlag; 161 bool mCalendarModifiedFlag;
171 QPixmap loadPixmap( QString ); 162 QPixmap loadPixmap( QString );
172}; 163};
173 164
174 165
175#endif 166#endif
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 7a945e3..de65b53 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -1,466 +1,465 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qgroupbox.h> 27#include <qgroupbox.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlistview.h> 29#include <qlistview.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33 33
34#include <klocale.h> 34#include <klocale.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkdepim/kdateedit.h> 37#include <libkdepim/kdateedit.h>
38 38
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "klineedit.h" 41#include "klineedit.h"
42 42
43#include "calendarview.h" 43#include "calendarview.h"
44#include "koviewmanager.h" 44#include "koviewmanager.h"
45#include "searchdialog.h" 45#include "searchdialog.h"
46 46
47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
48 : QVBox( 0 ) 48 : QVBox( 0 )
49 49
50{ 50{
51 mCalendar = calendar; 51 mCalendar = calendar;
52 QFrame *topFrame = new QFrame( this ) ;//plainPage(); 52 QFrame *topFrame = new QFrame( this ) ;//plainPage();
53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); 53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
54 54
55 // Search expression 55 // Search expression
56 QHBoxLayout *subLayout = new QHBoxLayout(); 56 QHBoxLayout *subLayout = new QHBoxLayout();
57 layout->addLayout(subLayout); 57 layout->addLayout(subLayout);
58 searchLabel = new QLabel(topFrame); 58 searchLabel = new QLabel(topFrame);
59 searchLabel->setText(i18n("Search for:")); 59 searchLabel->setText(i18n("Search for:"));
60 subLayout->addWidget(searchLabel); 60 subLayout->addWidget(searchLabel);
61 61
62 searchEdit = new KLineEdit(topFrame); 62 searchEdit = new KLineEdit(topFrame);
63 subLayout->addWidget(searchEdit); 63 subLayout->addWidget(searchEdit);
64 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame ); 64 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame );
65 //OkButton->setDefault( true ); 65 //OkButton->setDefault( true );
66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); 66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
67 subLayout->addWidget(OkButton); 67 subLayout->addWidget(OkButton);
68 searchEdit->setText("*"); // Find all events by default 68 searchEdit->setText("*"); // Find all events by default
69 searchEdit->setFocus(); 69 searchEdit->setFocus();
70 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 70 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
71 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 71 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
72 // Subjects to search 72 // Subjects to search
73 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 73 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
74 // topFrame); 74 // topFrame);
75 75
76 QHBox *incidenceGroup = new QHBox( topFrame ); 76 QHBox *incidenceGroup = new QHBox( topFrame );
77 layout->addWidget(incidenceGroup); 77 layout->addWidget(incidenceGroup);
78 78
79 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 79 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
80 //mSearchEvent->setChecked(true); 80 //mSearchEvent->setChecked(true);
81 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 81 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
82 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 82 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
83 83
84 QHBox *subjectGroup = new QHBox( topFrame ); 84 QHBox *subjectGroup = new QHBox( topFrame );
85 layout->addWidget(subjectGroup); 85 layout->addWidget(subjectGroup);
86 86
87 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 87 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
88 mSummaryCheck->setChecked(true); 88 mSummaryCheck->setChecked(true);
89 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); 89 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup);
90 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 90 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
91 91
92 QHBox *attendeeGroup = new QHBox( topFrame ); 92 QHBox *attendeeGroup = new QHBox( topFrame );
93 layout->addWidget(attendeeGroup ); 93 layout->addWidget(attendeeGroup );
94 new QLabel( i18n("Attendee:"),attendeeGroup ); 94 new QLabel( i18n("Attendee:"),attendeeGroup );
95 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 95 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
96 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 96 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
97 // Date range 97 // Date range
98 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 98 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
99 // topFrame); 99 // topFrame);
100 // layout->addWidget(rangeGroup); 100 // layout->addWidget(rangeGroup);
101 101
102 QWidget *rangeWidget = new QWidget(topFrame); 102 QWidget *rangeWidget = new QWidget(topFrame);
103 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); 103 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint());
104 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 104 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
105 mStartDate = new KDateEdit(rangeWidget); 105 mStartDate = new KDateEdit(rangeWidget);
106 rangeLayout->addWidget(mStartDate); 106 rangeLayout->addWidget(mStartDate);
107 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 107 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
108 mEndDate = new KDateEdit(rangeWidget); 108 mEndDate = new KDateEdit(rangeWidget);
109 mEndDate->setDate(QDate::currentDate().addDays(365)); 109 mEndDate->setDate(QDate::currentDate().addDays(365));
110 rangeLayout->addWidget(mEndDate); 110 rangeLayout->addWidget(mEndDate);
111 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); 111 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget );
112 rangeLayout->addWidget( (QWidget*)wt ); 112 rangeLayout->addWidget( (QWidget*)wt );
113 layout->addWidget(rangeWidget); 113 layout->addWidget(rangeWidget);
114 // Results list view 114 // Results list view
115 listView = new KOListView(mCalendar,topFrame); 115 listView = new KOListView(mCalendar,topFrame);
116 layout->addWidget(listView); 116 layout->addWidget(listView);
117 117
118 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 118 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
119 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); 119 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList()));
120 120
121 setCaption( i18n("KO/Pi Find: ")); 121 setCaption( i18n("KO/Pi Find: "));
122#ifdef DESKTOP_VERSION 122#ifdef DESKTOP_VERSION
123 OkButton = new QPushButton( i18n("Close"), this ); 123 OkButton = new QPushButton( i18n("Close"), this );
124 connect(OkButton,SIGNAL(clicked()),SLOT(hide())); 124 connect(OkButton,SIGNAL(clicked()),SLOT(hide()));
125#endif 125#endif
126} 126}
127 127
128SearchDialog::~SearchDialog() 128SearchDialog::~SearchDialog()
129{ 129{
130 130
131} 131}
132void SearchDialog::raiseAndSelect() 132void SearchDialog::raiseAndSelect()
133{ 133{
134 134
135 static int currentState = 0; 135 static int currentState = 0;
136 136
137 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) 137 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() )
138 currentState = 0; 138 currentState = 0;
139 int newState = 0; 139 int newState = 0;
140 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 140 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
141 newState = VIEW_J_VIEW; 141 newState = VIEW_J_VIEW;
142 } 142 }
143 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 143 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
144 newState = VIEW_T_VIEW; 144 newState = VIEW_T_VIEW;
145 } 145 }
146 else { 146 else {
147 newState = VIEW_A_VIEW; 147 newState = VIEW_A_VIEW;
148 } 148 }
149 if ( newState != currentState ) { 149 if ( newState != currentState ) {
150 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 150 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
151 if ( ! mSearchJournal->isChecked() ) { 151 if ( ! mSearchJournal->isChecked() ) {
152 mSearchJournal->setChecked( true ); 152 mSearchJournal->setChecked( true );
153 mSearchTodo->setChecked( false ); 153 mSearchTodo->setChecked( false );
154 mSearchEvent->setChecked( false ); 154 mSearchEvent->setChecked( false );
155 } 155 }
156 } 156 }
157 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 157 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
158 if ( ! mSearchTodo->isChecked() ) { 158 if ( ! mSearchTodo->isChecked() ) {
159 mSearchTodo->setChecked( true ); 159 mSearchTodo->setChecked( true );
160 mSearchJournal->setChecked( false ); 160 mSearchJournal->setChecked( false );
161 mSearchEvent->setChecked( false ); 161 mSearchEvent->setChecked( false );
162 } 162 }
163 } 163 }
164 else { 164 else {
165 if ( ! mSearchEvent->isChecked() ) { 165 if ( ! mSearchEvent->isChecked() ) {
166 mSearchEvent->setChecked( true ); 166 mSearchEvent->setChecked( true );
167 mSearchJournal->setChecked( false ); 167 mSearchJournal->setChecked( false );
168 mSearchTodo->setChecked( false ); 168 mSearchTodo->setChecked( false );
169 } 169 }
170 } 170 }
171 } 171 }
172 currentState = newState; 172 currentState = newState;
173 raise(); 173 raise();
174} 174}
175void SearchDialog::setFocusToList() 175void SearchDialog::setFocusToList()
176{ 176{
177 listView->resetFocus(); 177 listView->resetFocus();
178} 178}
179void SearchDialog::accept() 179void SearchDialog::accept()
180{ 180{
181 doSearch(); 181 doSearch();
182} 182}
183void SearchDialog::updateList() 183void SearchDialog::updateList()
184{ 184{
185 //listView->updateList(); 185 //listView->updateList();
186 if ( isVisible() ) { 186 if ( isVisible() ) {
187 updateView(); 187 updateView();
188 //qDebug("SearchDialog::updated "); 188 //qDebug("SearchDialog::updated ");
189 } 189 }
190 else { 190 else {
191 listView->clear(); 191 listView->clear();
192 //qDebug("SearchDialog::cleared "); 192 //qDebug("SearchDialog::cleared ");
193 193
194 } 194 }
195} 195}
196void SearchDialog::searchTextChanged( const QString &_text ) 196void SearchDialog::searchTextChanged( const QString &_text )
197{ 197{
198#if 0 198#if 0
199 enableButton( KDialogBase::User1, !_text.isEmpty() ); 199 enableButton( KDialogBase::User1, !_text.isEmpty() );
200#endif 200#endif
201} 201}
202 202
203void SearchDialog::doSearch() 203void SearchDialog::doSearch()
204{ 204{
205 QRegExp re; 205 QRegExp re;
206 206
207 re.setWildcard(true); // most people understand these better. 207 re.setWildcard(true); // most people understand these better.
208 re.setCaseSensitive(false); 208 re.setCaseSensitive(false);
209 QString st = searchEdit->text(); 209 QString st = searchEdit->text();
210 if ( st.right(1) != "*") 210 if ( st.right(1) != "*")
211 st += "*"; 211 st += "*";
212 re.setPattern(st); 212 re.setPattern(st);
213 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { 213 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) {
214 KMessageBox::sorry(this, 214 KMessageBox::sorry(this,
215 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); 215 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals"));
216 return; 216 return;
217 } 217 }
218 if (!re.isValid() ) { 218 if (!re.isValid() ) {
219 KMessageBox::sorry(this, 219 KMessageBox::sorry(this,
220 i18n("Invalid search expression,\ncannot perform " 220 i18n("Invalid search expression,\ncannot perform "
221 "the search.\nPlease enter a search expression\n" 221 "the search.\nPlease enter a search expression\n"
222 "using the wildcard characters\n '*' and '?'" 222 "using the wildcard characters\n '*' and '?'"
223 "where needed.")); 223 "where needed."));
224 return; 224 return;
225 } 225 }
226 226
227 search(re); 227 search(re);
228 228
229 listView->setStartDate( mStartDate->date() ); 229 listView->setStartDate( mStartDate->date() );
230 listView->showEvents(mMatchedEvents); 230 listView->showEvents(mMatchedEvents);
231 listView->addTodos(mMatchedTodos); 231 listView->addTodos(mMatchedTodos);
232 listView->addJournals(mMatchedJournals); 232 listView->addJournals(mMatchedJournals);
233 233
234 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 234 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
235 setCaption(i18n("No items found. Use '*' and '?' where needed.")); 235 setCaption(i18n("No items found. Use '*' and '?' where needed."));
236 } else { 236 } else {
237 QString mess; 237 QString mess;
238 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 238 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
239 setCaption( i18n("KO/Pi Find: ") + mess); 239 setCaption( i18n("KO/Pi Find: ") + mess);
240 240
241 } 241 }
242 searchEdit->setFocus(); 242 searchEdit->setFocus();
243} 243}
244void SearchDialog::updateConfig() 244void SearchDialog::updateConfig()
245{ 245{
246 listView->updateConfig(); 246 listView->updateConfig();
247} 247}
248void SearchDialog::updateView() 248void SearchDialog::updateView()
249{ 249{
250 //qDebug("SearchDialog::updateView() %d ", isVisible()); 250 //qDebug("SearchDialog::updateView() %d ", isVisible());
251 QRegExp re; 251 QRegExp re;
252 re.setWildcard(true); // most people understand these better. 252 re.setWildcard(true); // most people understand these better.
253 re.setCaseSensitive(false); 253 re.setCaseSensitive(false);
254 QString st = searchEdit->text(); 254 QString st = searchEdit->text();
255 if ( st.right(1) != "*") 255 if ( st.right(1) != "*")
256 st += "*"; 256 st += "*";
257 re.setPattern(st); 257 re.setPattern(st);
258 if (re.isValid()) { 258 if (re.isValid()) {
259 search(re); 259 search(re);
260 } else { 260 } else {
261 mMatchedEvents.clear(); 261 mMatchedEvents.clear();
262 mMatchedTodos.clear(); 262 mMatchedTodos.clear();
263 mMatchedJournals.clear(); 263 mMatchedJournals.clear();
264 } 264 }
265 listView->setStartDate( mStartDate->date() ); 265 listView->setStartDate( mStartDate->date() );
266 listView->showEvents(mMatchedEvents); 266 listView->showEvents(mMatchedEvents);
267 listView->addTodos(mMatchedTodos); 267 listView->addTodos(mMatchedTodos);
268 listView->addJournals(mMatchedJournals); 268 listView->addJournals(mMatchedJournals);
269} 269}
270 270
271void SearchDialog::search(const QRegExp &re) 271void SearchDialog::search(const QRegExp &re)
272{ 272{
273 QPtrList<Event> events = mCalendar->events( mStartDate->date(), 273 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
274 mEndDate->date(), 274 mEndDate->date(),
275 false /*mInclusiveCheck->isChecked()*/ ); 275 false /*mInclusiveCheck->isChecked()*/ );
276 276
277 mMatchedEvents.clear(); 277 mMatchedEvents.clear();
278 if ( mSearchEvent->isChecked() ) { 278 if ( mSearchEvent->isChecked() ) {
279 Event *ev; 279 Event *ev;
280 for(ev=events.first();ev;ev=events.next()) { 280 for(ev=events.first();ev;ev=events.next()) {
281 if (mSummaryCheck->isChecked()) { 281 if (mSummaryCheck->isChecked()) {
282#if QT_VERSION >= 0x030000 282#if QT_VERSION >= 0x030000
283 if (re.search(ev->summary()) != -1) 283 if (re.search(ev->summary()) != -1)
284#else 284#else
285 if (re.match(ev->summary()) != -1) 285 if (re.match(ev->summary()) != -1)
286#endif 286#endif
287 { 287 {
288 mMatchedEvents.append(ev); 288 mMatchedEvents.append(ev);
289 continue; 289 continue;
290 } 290 }
291#if QT_VERSION >= 0x030000 291#if QT_VERSION >= 0x030000
292 if (re.search(ev->location()) != -1) 292 if (re.search(ev->location()) != -1)
293#else 293#else
294 if (re.match(ev->location()) != -1) 294 if (re.match(ev->location()) != -1)
295#endif 295#endif
296 { 296 {
297 mMatchedEvents.append(ev); 297 mMatchedEvents.append(ev);
298 continue; 298 continue;
299 } 299 }
300 } 300 }
301 if (mDescriptionCheck->isChecked()) { 301 if (mDescriptionCheck->isChecked()) {
302#if QT_VERSION >= 0x030000 302#if QT_VERSION >= 0x030000
303 if (re.search(ev->description()) != -1) 303 if (re.search(ev->description()) != -1)
304#else 304#else
305 if (re.match(ev->description()) != -1) 305 if (re.match(ev->description()) != -1)
306#endif 306#endif
307 { 307 {
308 mMatchedEvents.append(ev); 308 mMatchedEvents.append(ev);
309 continue; 309 continue;
310 } 310 }
311 } 311 }
312 if (mCategoryCheck->isChecked()) { 312 if (mCategoryCheck->isChecked()) {
313#if QT_VERSION >= 0x030000 313#if QT_VERSION >= 0x030000
314 if (re.search(ev->categoriesStr()) != -1) 314 if (re.search(ev->categoriesStr()) != -1)
315#else 315#else
316 if (re.match(ev->categoriesStr()) != -1) 316 if (re.match(ev->categoriesStr()) != -1)
317#endif 317#endif
318 { 318 {
319 mMatchedEvents.append(ev); 319 mMatchedEvents.append(ev);
320 continue; 320 continue;
321 } 321 }
322 } 322 }
323 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 323 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
324 QPtrList<Attendee> tmpAList = ev->attendees(); 324 QPtrList<Attendee> tmpAList = ev->attendees();
325 Attendee *a; 325 Attendee *a;
326 for (a = tmpAList.first(); a; a = tmpAList.next()) { 326 for (a = tmpAList.first(); a; a = tmpAList.next()) {
327 if (mSearchAName->isChecked()) { 327 if (mSearchAName->isChecked()) {
328#if QT_VERSION >= 0x030000 328#if QT_VERSION >= 0x030000
329 if (re.search(a->name()) != -1) 329 if (re.search(a->name()) != -1)
330#else 330#else
331 if (re.match(a->name()) != -1) 331 if (re.match(a->name()) != -1)
332#endif 332#endif
333 { 333 {
334 mMatchedEvents.append(ev); 334 mMatchedEvents.append(ev);
335 break; 335 break;
336 } 336 }
337 } 337 }
338 if (mSearchAEmail->isChecked()) { 338 if (mSearchAEmail->isChecked()) {
339#if QT_VERSION >= 0x030000 339#if QT_VERSION >= 0x030000
340 if (re.search(a->email()) != -1) 340 if (re.search(a->email()) != -1)
341#else 341#else
342 if (re.match(a->email()) != -1) 342 if (re.match(a->email()) != -1)
343#endif 343#endif
344 { 344 {
345 mMatchedEvents.append(ev); 345 mMatchedEvents.append(ev);
346 break; 346 break;
347 } 347 }
348 } 348 }
349 } 349 }
350 } 350 }
351 } 351 }
352 } 352 }
353 QPtrList<Todo> todos = mCalendar->todos( ); 353 QPtrList<Todo> todos = mCalendar->todos( );
354 mMatchedTodos.clear(); 354 mMatchedTodos.clear();
355 if ( mSearchTodo->isChecked() ) { 355 if ( mSearchTodo->isChecked() ) {
356 Todo *tod; 356 Todo *tod;
357 for(tod=todos.first();tod;tod=todos.next()) { 357 for(tod=todos.first();tod;tod=todos.next()) {
358 if (mSummaryCheck->isChecked()) { 358 if (mSummaryCheck->isChecked()) {
359#if QT_VERSION >= 0x030000 359#if QT_VERSION >= 0x030000
360 if (re.search(tod->summary()) != -1) 360 if (re.search(tod->summary()) != -1)
361#else 361#else
362 if (re.match(tod->summary()) != -1) 362 if (re.match(tod->summary()) != -1)
363#endif 363#endif
364 { 364 {
365 mMatchedTodos.append(tod); 365 mMatchedTodos.append(tod);
366 continue; 366 continue;
367 } 367 }
368 } 368 }
369 if (mDescriptionCheck->isChecked()) { 369 if (mDescriptionCheck->isChecked()) {
370#if QT_VERSION >= 0x030000 370#if QT_VERSION >= 0x030000
371 if (re.search(tod->description()) != -1) 371 if (re.search(tod->description()) != -1)
372#else 372#else
373 if (re.match(tod->description()) != -1) 373 if (re.match(tod->description()) != -1)
374#endif 374#endif
375 { 375 {
376 mMatchedTodos.append(tod); 376 mMatchedTodos.append(tod);
377 continue; 377 continue;
378 } 378 }
379 } 379 }
380 if (mCategoryCheck->isChecked()) { 380 if (mCategoryCheck->isChecked()) {
381#if QT_VERSION >= 0x030000 381#if QT_VERSION >= 0x030000
382 if (re.search(tod->categoriesStr()) != -1) 382 if (re.search(tod->categoriesStr()) != -1)
383#else 383#else
384 if (re.match(tod->categoriesStr()) != -1) 384 if (re.match(tod->categoriesStr()) != -1)
385#endif 385#endif
386 { 386 {
387 mMatchedTodos.append(tod); 387 mMatchedTodos.append(tod);
388 continue; 388 continue;
389 } 389 }
390 } 390 }
391 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 391 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
392 QPtrList<Attendee> tmpAList = tod->attendees(); 392 QPtrList<Attendee> tmpAList = tod->attendees();
393 Attendee *a; 393 Attendee *a;
394 for (a = tmpAList.first(); a; a = tmpAList.next()) { 394 for (a = tmpAList.first(); a; a = tmpAList.next()) {
395 if (mSearchAName->isChecked()) { 395 if (mSearchAName->isChecked()) {
396#if QT_VERSION >= 0x030000 396#if QT_VERSION >= 0x030000
397 if (re.search(a->name()) != -1) 397 if (re.search(a->name()) != -1)
398#else 398#else
399 if (re.match(a->name()) != -1) 399 if (re.match(a->name()) != -1)
400#endif 400#endif
401 { 401 {
402 mMatchedTodos.append(tod); 402 mMatchedTodos.append(tod);
403 break; 403 break;
404 } 404 }
405 } 405 }
406 if (mSearchAEmail->isChecked()) { 406 if (mSearchAEmail->isChecked()) {
407#if QT_VERSION >= 0x030000 407#if QT_VERSION >= 0x030000
408 if (re.search(a->email()) != -1) 408 if (re.search(a->email()) != -1)
409#else 409#else
410 if (re.match(a->email()) != -1) 410 if (re.match(a->email()) != -1)
411#endif 411#endif
412 { 412 {
413 mMatchedTodos.append(tod); 413 mMatchedTodos.append(tod);
414 break; 414 break;
415 } 415 }
416 } 416 }
417 } 417 }
418 } 418 }
419 } 419 }
420 } 420 }
421 mMatchedJournals.clear(); 421 mMatchedJournals.clear();
422 if (mSearchJournal->isChecked() ) { 422 if (mSearchJournal->isChecked() ) {
423 QPtrList<Journal> journals = mCalendar->journals( ); 423 QPtrList<Journal> journals = mCalendar->journals( );
424 Journal* journ; 424 Journal* journ;
425 425
426 for(journ=journals.first();journ;journ=journals.next()) { 426 for(journ=journals.first();journ;journ=journals.next()) {
427 if ( journ->dtStart().date() <= mEndDate->date() 427 if ( journ->dtStart().date() <= mEndDate->date()
428 &&journ->dtStart().date() >= mStartDate->date()) { 428 &&journ->dtStart().date() >= mStartDate->date()) {
429#if QT_VERSION >= 0x030000 429#if QT_VERSION >= 0x030000
430 if (re.search(journ->description()) != -1) 430 if (re.search(journ->description()) != -1)
431#else 431#else
432 if (re.match(journ->description()) != -1) 432 if (re.match(journ->description()) != -1)
433#endif 433#endif
434 { 434 {
435 mMatchedJournals.append(journ); 435 mMatchedJournals.append(journ);
436 continue; 436 continue;
437 } 437 }
438 } 438 }
439 } 439 }
440 } 440 }
441 441
442} 442}
443 443
444void SearchDialog::keyPressEvent ( QKeyEvent *e) 444void SearchDialog::keyPressEvent ( QKeyEvent *e)
445{ 445{
446 switch ( e->key() ) { 446 switch ( e->key() ) {
447 case Qt::Key_Escape: 447 case Qt::Key_Escape:
448 hide(); 448 close();
449 break; 449 break;
450 case Qt::Key_F: 450 case Qt::Key_F:
451 if ( e->state() == Qt::ControlButton ) { 451 if ( e->state() == Qt::ControlButton ) {
452 qDebug("full ");
453 452
454 } 453 }
455 break; 454 break;
456 case Qt::Key_Return: 455 case Qt::Key_Return:
457 case Qt::Key_Enter: 456 case Qt::Key_Enter:
458 doSearch(); 457 doSearch();
459 break; 458 break;
460 459
461 default: 460 default:
462 e->ignore(); 461 e->ignore();
463 } 462 }
464} 463}
465 464
466//mMatchedJournals; 465//mMatchedJournals;