summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-04-04 17:05:29 (UTC)
committer mickeyl <mickeyl>2004-04-04 17:05:29 (UTC)
commit77185b587adfa158dadab204f3c78db94af3e099 (patch) (unidiff)
treed0d7a2d3e756784ea259199d218b73c4770cdfd1
parentdaef74a7e852855f781765fad7969b6c83e2e9c6 (diff)
downloadopie-77185b587adfa158dadab204f3c78db94af3e099.zip
opie-77185b587adfa158dadab204f3c78db94af3e099.tar.gz
opie-77185b587adfa158dadab204f3c78db94af3e099.tar.bz2
fix debugging stuff (see addressbook)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp6
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp8
-rw-r--r--core/pim/datebook/datebookweeklst.cpp4
-rw-r--r--core/pim/datebook/dateentryimpl.cpp6
4 files changed, 12 insertions, 12 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 3d1bc0c..0a47bb8 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,371 +1,371 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19** $Id$ 19** $Id$
20** 20**
21**********************************************************************/ 21**********************************************************************/
22 22
23#define QTOPIA_INTERNAL_FD 23#define QTOPIA_INTERNAL_FD
24 24
25#include "datebook.h" 25#include "datebook.h"
26#include "datebookday.h" 26#include "datebookday.h"
27#include "datebooksettings.h" 27#include "datebooksettings.h"
28#include "datebookweek.h" 28#include "datebookweek.h"
29#include "datebookweeklst.h" 29#include "datebookweeklst.h"
30#include "dateentryimpl.h" 30#include "dateentryimpl.h"
31 31
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33 33
34#include <qpe/datebookmonth.h> 34#include <qpe/datebookmonth.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/finddialog.h> 37#include <qpe/finddialog.h>
38#include <qpe/ir.h> 38#include <qpe/ir.h>
39#include <qpe/qpemessagebox.h> 39#include <qpe/qpemessagebox.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/tzselect.h> 42#include <qpe/tzselect.h>
43 43
44#include <qaction.h> 44#include <qaction.h>
45#include <qcopchannel_qws.h> 45#include <qcopchannel_qws.h>
46#include <qlayout.h> 46#include <qlayout.h>
47#include <qmessagebox.h> 47#include <qmessagebox.h>
48#include <qtimer.h> 48#include <qtimer.h>
49#include <qtl.h> 49#include <qtl.h>
50#include <qtoolbar.h> 50#include <qtoolbar.h>
51#include <qwidgetstack.h> 51#include <qwidgetstack.h>
52 52
53#include <sys/stat.h> 53#include <sys/stat.h>
54#include <sys/types.h> 54#include <sys/types.h>
55#include <fcntl.h> 55#include <fcntl.h>
56#include <unistd.h> 56#include <unistd.h>
57 57
58#include <stdlib.h> 58#include <stdlib.h>
59 59
60DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 60DateBook::DateBook( QWidget *parent, const char *, WFlags f )
61 : QMainWindow( parent, "datebook", f ), 61 : QMainWindow( parent, "datebook", f ),
62 aPreset( FALSE ), 62 aPreset( FALSE ),
63 presetTime( -1 ), 63 presetTime( -1 ),
64 startTime( 8 ), // an acceptable default 64 startTime( 8 ), // an acceptable default
65 rowStyle( 0 ), 65 rowStyle( 0 ),
66 bJumpToCurTime(FALSE), 66 bJumpToCurTime(FALSE),
67 syncing(FALSE), 67 syncing(FALSE),
68 inSearch(FALSE), 68 inSearch(FALSE),
69 alarmCounter(0) 69 alarmCounter(0)
70{ 70{
71 bool needEvilHack= false; // if we need an Evil Hack 71 bool needEvilHack= false; // if we need an Evil Hack
72 QTime t; 72 QTime t;
73 t.start(); 73 t.start();
74 db = new DateBookDBHack; 74 db = new DateBookDBHack;
75 Opie::Core::odebug << "loading db t=" << t.elapsed() << oendl; 75 odebug << "loading db t=" << t.elapsed() << oendl;
76 loadSettings(); 76 loadSettings();
77 setCaption( tr("Calendar") ); 77 setCaption( tr("Calendar") );
78 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 78 setIcon( Resource::loadPixmap( "datebook_icon" ) );
79 79
80 setToolBarsMovable( FALSE ); 80 setToolBarsMovable( FALSE );
81 81
82 views = new QWidgetStack( this ); 82 views = new QWidgetStack( this );
83 setCentralWidget( views ); 83 setCentralWidget( views );
84 84
85 dayView = 0; 85 dayView = 0;
86 weekView = 0; 86 weekView = 0;
87 weekLstView = 0; 87 weekLstView = 0;
88 monthView = 0; 88 monthView = 0;
89 89
90// QToolBar *bar = new QToolBar( this ); 90// QToolBar *bar = new QToolBar( this );
91// bar->setHorizontalStretchable( TRUE ); 91// bar->setHorizontalStretchable( TRUE );
92 92
93// QMenuBar *mb = new QMenuBar( bar ); 93// QMenuBar *mb = new QMenuBar( bar );
94// mb->setMargin( 0 ); 94// mb->setMargin( 0 );
95 95
96// QPopupMenu *view = new QPopupMenu( this ); 96// QPopupMenu *view = new QPopupMenu( this );
97// mb->insertItem( tr( "View" ), view ); 97// mb->insertItem( tr( "View" ), view );
98 98
99 QToolBar *sub_bar = new QToolBar(this); 99 QToolBar *sub_bar = new QToolBar(this);
100 sub_bar->setHorizontalStretchable(TRUE); 100 sub_bar->setHorizontalStretchable(TRUE);
101 101
102 QActionGroup *g = new QActionGroup( this ); 102 QActionGroup *g = new QActionGroup( this );
103 g->setExclusive( TRUE ); 103 g->setExclusive( TRUE );
104 104
105 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 105 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
106 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 106 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
107 a->addTo( sub_bar ); 107 a->addTo( sub_bar );
108 108
109 sub_bar->addSeparator(); 109 sub_bar->addSeparator();
110 110
111 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); 111 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 );
112 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 112 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
113 a->addTo( sub_bar ); 113 a->addTo( sub_bar );
114 //a->addTo( view ); 114 //a->addTo( view );
115 115
116 sub_bar->addSeparator(); 116 sub_bar->addSeparator();
117 117
118 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 118 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
119 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 119 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
120 a->addTo( sub_bar ); 120 a->addTo( sub_bar );
121// a->addTo( view ); 121// a->addTo( view );
122 a->setToggleAction( TRUE ); 122 a->setToggleAction( TRUE );
123 a->setOn( TRUE ); 123 a->setOn( TRUE );
124 dayAction = a; 124 dayAction = a;
125 125
126 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 126 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
127 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 127 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
128 a->addTo( sub_bar ); 128 a->addTo( sub_bar );
129// a->addTo( view ); 129// a->addTo( view );
130 a->setToggleAction( TRUE ); 130 a->setToggleAction( TRUE );
131 weekAction = a; 131 weekAction = a;
132 132
133 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 133 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
134 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 134 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
135 a->addTo( sub_bar ); 135 a->addTo( sub_bar );
136// a->addTo( view ); 136// a->addTo( view );
137 a->setToggleAction( TRUE ); 137 a->setToggleAction( TRUE );
138 weekLstAction = a; 138 weekLstAction = a;
139 139
140 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 140 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
141 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 141 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
142 a->addTo( sub_bar ); 142 a->addTo( sub_bar );
143// a->addTo( view ); 143// a->addTo( view );
144 a->setToggleAction( TRUE ); 144 a->setToggleAction( TRUE );
145 monthAction = a; 145 monthAction = a;
146 146
147 sub_bar->addSeparator(); 147 sub_bar->addSeparator();
148 148
149 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 149 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
150 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 150 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
151 a->addTo( sub_bar ); 151 a->addTo( sub_bar );
152 152
153 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); 153 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 );
154 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 154 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
155 a->addTo( sub_bar ); 155 a->addTo( sub_bar );
156 156
157 if(defaultView==DAY) viewDay(); 157 if(defaultView==DAY) viewDay();
158 if(defaultView==WEEK) needEvilHack=true;// viewWeek(); 158 if(defaultView==WEEK) needEvilHack=true;// viewWeek();
159 if(defaultView==WEEKLST) viewWeekLst(); 159 if(defaultView==WEEKLST) viewWeekLst();
160 if(defaultView==MONTH) viewMonth(); 160 if(defaultView==MONTH) viewMonth();
161 161
162 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 162 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
163 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 163 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
164 164
165#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 165#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
166 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); 166 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) );
167#endif 167#endif
168 168
169 // listen on QPE/System 169 // listen on QPE/System
170#if defined(Q_WS_QWS) 170#if defined(Q_WS_QWS)
171#if !defined(QT_NO_COP) 171#if !defined(QT_NO_COP)
172 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 172 QCopChannel *channel = new QCopChannel( "QPE/System", this );
173 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 173 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
174 channel = new QCopChannel( "QPE/Datebook", this ); 174 channel = new QCopChannel( "QPE/Datebook", this );
175 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 175 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
176#endif 176#endif
177#endif 177#endif
178 178
179 Opie::Core::odebug << "done t=" << t.elapsed() << oendl; 179 odebug << "done t=" << t.elapsed() << oendl;
180 180
181 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 181 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
182 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); 182 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) );
183 /* 183 /*
184 * Here is a problem description: 184 * Here is a problem description:
185 * When Weekview is the default view 185 * When Weekview is the default view
186 * a DateBookWeekView get's created 186 * a DateBookWeekView get's created
187 * redraw() get's called. So what? 187 * redraw() get's called. So what?
188 * Remember that we're still in the c'tor 188 * Remember that we're still in the c'tor
189 * and no final layout has happened? Ok 189 * and no final layout has happened? Ok
190 * now all Events get arranged. Their x 190 * now all Events get arranged. Their x
191 * position get's determined by a QHeader 191 * position get's determined by a QHeader
192 * position. But the QHeader isn't layouted or 192 * position. But the QHeader isn't layouted or
193 * at the right position. redraw() is a slot 193 * at the right position. redraw() is a slot
194 * so we'll call it then via a singleShot 194 * so we'll call it then via a singleShot
195 * from view() 195 * from view()
196 */ 196 */
197 if( needEvilHack ){ 197 if( needEvilHack ){
198 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 198 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
199 } 199 }
200} 200}
201 201
202void DateBook::receive( const QCString &msg, const QByteArray &data ) 202void DateBook::receive( const QCString &msg, const QByteArray &data )
203{ 203{
204 QDataStream stream( data, IO_ReadOnly ); 204 QDataStream stream( data, IO_ReadOnly );
205 if ( msg == "timeChange(QString)" ) { 205 if ( msg == "timeChange(QString)" ) {
206 // update active view! 206 // update active view!
207 if ( dayAction->isOn() ) 207 if ( dayAction->isOn() )
208 viewDay(); 208 viewDay();
209 else if ( weekAction->isOn() ) 209 else if ( weekAction->isOn() )
210 viewWeek(); 210 viewWeek();
211 else if ( monthAction->isOn() ) 211 else if ( monthAction->isOn() )
212 viewMonth(); 212 viewMonth();
213 } 213 }
214 else if (msg == "editEvent(int)") { 214 else if (msg == "editEvent(int)") {
215 int uid; 215 int uid;
216 stream >> uid; 216 stream >> uid;
217 Event e=db->eventByUID(uid); 217 Event e=db->eventByUID(uid);
218 editEvent(e); 218 editEvent(e);
219 }else if (msg == "viewDefault(QDate)"){ 219 }else if (msg == "viewDefault(QDate)"){
220 QDate day; 220 QDate day;
221 stream >> day; 221 stream >> day;
222 viewDefault(day); 222 viewDefault(day);
223 } 223 }
224} 224}
225 225
226DateBook::~DateBook() 226DateBook::~DateBook()
227{ 227{
228} 228}
229 229
230void DateBook::slotSettings() 230void DateBook::slotSettings()
231{ 231{
232 DateBookSettings frmSettings( ampm, this ); 232 DateBookSettings frmSettings( ampm, this );
233 frmSettings.setStartTime( startTime ); 233 frmSettings.setStartTime( startTime );
234 frmSettings.setAlarmPreset( aPreset, presetTime ); 234 frmSettings.setAlarmPreset( aPreset, presetTime );
235 frmSettings.setJumpToCurTime( bJumpToCurTime ); 235 frmSettings.setJumpToCurTime( bJumpToCurTime );
236 frmSettings.setRowStyle( rowStyle ); 236 frmSettings.setRowStyle( rowStyle );
237 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 237 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
238 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 238 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
239 239
240 bool found=false; 240 bool found=false;
241 for (int i=0; i<(frmSettings.comboLocation->count()); i++) { 241 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
242 if ( frmSettings.comboLocation->text(i) == defaultLocation ) { 242 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
243 frmSettings.comboLocation->setCurrentItem(i); 243 frmSettings.comboLocation->setCurrentItem(i);
244 found=true; 244 found=true;
245 break; 245 break;
246 } 246 }
247 } 247 }
248 if(!found) { 248 if(!found) {
249 frmSettings.comboLocation->insertItem(defaultLocation); 249 frmSettings.comboLocation->insertItem(defaultLocation);
250 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); 250 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
251 } 251 }
252 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); 252 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
253 253
254 if ( QPEApplication::execDialog( &frmSettings ) ) { 254 if ( QPEApplication::execDialog( &frmSettings ) ) {
255 aPreset = frmSettings.alarmPreset(); 255 aPreset = frmSettings.alarmPreset();
256 presetTime = frmSettings.presetTime(); 256 presetTime = frmSettings.presetTime();
257 startTime = frmSettings.startTime(); 257 startTime = frmSettings.startTime();
258 bJumpToCurTime = frmSettings.jumpToCurTime(); 258 bJumpToCurTime = frmSettings.jumpToCurTime();
259 rowStyle = frmSettings.rowStyle(); 259 rowStyle = frmSettings.rowStyle();
260 defaultView=frmSettings.comboDefaultView->currentItem()+1; 260 defaultView=frmSettings.comboDefaultView->currentItem()+1;
261 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 261 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
262 defaultLocation=frmSettings.comboLocation->currentText(); 262 defaultLocation=frmSettings.comboLocation->currentText();
263 defaultCategories=frmSettings.comboCategory->currentCategories(); 263 defaultCategories=frmSettings.comboCategory->currentCategories();
264 264
265 if ( dayView ) { 265 if ( dayView ) {
266 dayView->setStartViewTime( startTime ); 266 dayView->setStartViewTime( startTime );
267 dayView->setJumpToCurTime( bJumpToCurTime ); 267 dayView->setJumpToCurTime( bJumpToCurTime );
268 dayView->setRowStyle( rowStyle ); 268 dayView->setRowStyle( rowStyle );
269 } 269 }
270 if ( weekView ) { 270 if ( weekView ) {
271 weekView->setStartViewTime( startTime ); 271 weekView->setStartViewTime( startTime );
272 } 272 }
273 saveSettings(); 273 saveSettings();
274 274
275 // make the change obvious 275 // make the change obvious
276 if ( views->visibleWidget() ) { 276 if ( views->visibleWidget() ) {
277 if ( views->visibleWidget() == dayView ) 277 if ( views->visibleWidget() == dayView )
278 dayView->redraw(); 278 dayView->redraw();
279 else if ( views->visibleWidget() == weekView ) 279 else if ( views->visibleWidget() == weekView )
280 weekView->redraw(); 280 weekView->redraw();
281 else if ( views->visibleWidget() == weekLstView ) 281 else if ( views->visibleWidget() == weekLstView )
282 weekLstView->redraw(); 282 weekLstView->redraw();
283 } 283 }
284 } 284 }
285} 285}
286 286
287void DateBook::fileNew() 287void DateBook::fileNew()
288{ 288{
289 slotNewEventFromKey(""); 289 slotNewEventFromKey("");
290} 290}
291 291
292QString DateBook::checkEvent(const Event &e) 292QString DateBook::checkEvent(const Event &e)
293{ 293{
294 /* check if overlaps with itself */ 294 /* check if overlaps with itself */
295 bool checkFailed = FALSE; 295 bool checkFailed = FALSE;
296 296
297 /* check the next 12 repeats. should catch most problems */ 297 /* check the next 12 repeats. should catch most problems */
298 QDate current_date = e.start().date(); 298 QDate current_date = e.start().date();
299 Event previous = e; 299 Event previous = e;
300 for(int i = 0; i < 12; i++) 300 for(int i = 0; i < 12; i++)
301 { 301 {
302 QDateTime next; 302 QDateTime next;
303 if (!nextOccurance(previous, current_date.addDays(1), next)) { 303 if (!nextOccurance(previous, current_date.addDays(1), next)) {
304 break; // no more repeats 304 break; // no more repeats
305 } 305 }
306 if(next < previous.end()) { 306 if(next < previous.end()) {
307 checkFailed = TRUE; 307 checkFailed = TRUE;
308 break; 308 break;
309 } 309 }
310 current_date = next.date(); 310 current_date = next.date();
311 } 311 }
312 312
313 if(checkFailed) 313 if(checkFailed)
314 return tr("Event duration is potentially longer\n" 314 return tr("Event duration is potentially longer\n"
315 "than interval between repeats."); 315 "than interval between repeats.");
316 316
317 return QString::null; 317 return QString::null;
318} 318}
319 319
320QDate DateBook::currentDate() 320QDate DateBook::currentDate()
321{ 321{
322 QDate d = QDate::currentDate(); 322 QDate d = QDate::currentDate();
323 323
324 if ( dayView && views->visibleWidget() == dayView ) { 324 if ( dayView && views->visibleWidget() == dayView ) {
325 d = dayView->date(); 325 d = dayView->date();
326 } else if ( weekView && views->visibleWidget() == weekView ) { 326 } else if ( weekView && views->visibleWidget() == weekView ) {
327 d = weekView->date(); 327 d = weekView->date();
328 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 328 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
329 d = weekLstView->date(); 329 d = weekLstView->date();
330 } else if ( monthView && views->visibleWidget() == monthView ) { 330 } else if ( monthView && views->visibleWidget() == monthView ) {
331 d = monthView->selectedDate(); 331 d = monthView->selectedDate();
332 } 332 }
333 333
334 return d; 334 return d;
335} 335}
336 336
337void DateBook::view(int v, const QDate &d) { 337void DateBook::view(int v, const QDate &d) {
338 if (v==DAY) { 338 if (v==DAY) {
339 initDay(); 339 initDay();
340 dayAction->setOn( TRUE ); 340 dayAction->setOn( TRUE );
341 dayView->setDate( d ); 341 dayView->setDate( d );
342 views->raiseWidget( dayView ); 342 views->raiseWidget( dayView );
343 dayView->redraw(); 343 dayView->redraw();
344 } else if (v==WEEK) { 344 } else if (v==WEEK) {
345 initWeek(); 345 initWeek();
346 weekAction->setOn( TRUE ); 346 weekAction->setOn( TRUE );
347 weekView->setDate( d ); 347 weekView->setDate( d );
348 views->raiseWidget( weekView ); 348 views->raiseWidget( weekView );
349 weekView->redraw(); 349 weekView->redraw();
350 } else if (v==WEEKLST) { 350 } else if (v==WEEKLST) {
351 initWeekLst(); 351 initWeekLst();
352 weekLstAction->setOn( TRUE ); 352 weekLstAction->setOn( TRUE );
353 weekLstView->setDate(d); 353 weekLstView->setDate(d);
354 views->raiseWidget( weekLstView ); 354 views->raiseWidget( weekLstView );
355 weekLstView->redraw(); 355 weekLstView->redraw();
356 } else if (v==MONTH) { 356 } else if (v==MONTH) {
357 initMonth(); 357 initMonth();
358 monthAction->setOn( TRUE ); 358 monthAction->setOn( TRUE );
359 monthView->setDate( d.year(), d.month(), d.day() ); 359 monthView->setDate( d.year(), d.month(), d.day() );
360 views->raiseWidget( monthView ); 360 views->raiseWidget( monthView );
361 monthView->redraw(); 361 monthView->redraw();
362 } 362 }
363} 363}
364 364
365void DateBook::viewDefault(const QDate &d) { 365void DateBook::viewDefault(const QDate &d) {
366 view(defaultView,d); 366 view(defaultView,d);
367} 367}
368 368
369void DateBook::viewDay() { 369void DateBook::viewDay() {
370 view(DAY,currentDate()); 370 view(DAY,currentDate());
371} 371}
@@ -713,360 +713,360 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data)
713 stream >> uid; 713 stream >> uid;
714 Event e=db->eventByUID(uid); 714 Event e=db->eventByUID(uid);
715 editEvent(e); 715 editEvent(e);
716 } else if (msg == "viewDefault(QDate)"){ 716 } else if (msg == "viewDefault(QDate)"){
717 /* simple copy from receive */ 717 /* simple copy from receive */
718 QDataStream stream(data,IO_ReadOnly); 718 QDataStream stream(data,IO_ReadOnly);
719 QDate day; 719 QDate day;
720 stream >> day; 720 stream >> day;
721 viewDefault(day); 721 viewDefault(day);
722 needShow = true; 722 needShow = true;
723 } 723 }
724 724
725 if ( needShow ) { 725 if ( needShow ) {
726#if defined(Q_WS_QWS) || defined(_WS_QWS_) 726#if defined(Q_WS_QWS) || defined(_WS_QWS_)
727 // showMaximized(); 727 // showMaximized();
728#else 728#else
729 // show(); 729 // show();
730#endif 730#endif
731 // raise(); 731 // raise();
732 QPEApplication::setKeepRunning(); 732 QPEApplication::setKeepRunning();
733 // setActiveWindow(); 733 // setActiveWindow();
734 } 734 }
735} 735}
736 736
737void DateBook::reload() 737void DateBook::reload()
738{ 738{
739 db->reload(); 739 db->reload();
740 if ( dayAction->isOn() ) viewDay(); 740 if ( dayAction->isOn() ) viewDay();
741 else if ( weekAction->isOn() ) viewWeek(); 741 else if ( weekAction->isOn() ) viewWeek();
742 else if ( monthAction->isOn() ) viewMonth(); 742 else if ( monthAction->isOn() ) viewMonth();
743 syncing = FALSE; 743 syncing = FALSE;
744} 744}
745 745
746void DateBook::flush() 746void DateBook::flush()
747{ 747{
748 syncing = TRUE; 748 syncing = TRUE;
749 db->save(); 749 db->save();
750} 750}
751 751
752void DateBook::timerEvent( QTimerEvent *e ) 752void DateBook::timerEvent( QTimerEvent *e )
753{ 753{
754 if ( alarmCounter < 10 ) { 754 if ( alarmCounter < 10 ) {
755 alarmCounter++; 755 alarmCounter++;
756 Sound::soundAlarm(); 756 Sound::soundAlarm();
757 } else { 757 } else {
758 killTimer( e->timerId() ); 758 killTimer( e->timerId() );
759 } 759 }
760} 760}
761 761
762void DateBook::changeClock( bool newClock ) 762void DateBook::changeClock( bool newClock )
763{ 763{
764 ampm = newClock; 764 ampm = newClock;
765 // repaint the affected objects... 765 // repaint the affected objects...
766 if (dayView) dayView->redraw(); 766 if (dayView) dayView->redraw();
767 if (weekView) weekView->redraw(); 767 if (weekView) weekView->redraw();
768 if (weekLstView) weekLstView->redraw(); 768 if (weekLstView) weekLstView->redraw();
769} 769}
770 770
771void DateBook::changeWeek( bool m ) 771void DateBook::changeWeek( bool m )
772{ 772{
773 /* no need to redraw, each widget catches. Do need to 773 /* no need to redraw, each widget catches. Do need to
774 store though for widgets we haven't made yet */ 774 store though for widgets we haven't made yet */
775 onMonday = m; 775 onMonday = m;
776} 776}
777 777
778void DateBook::slotToday() 778void DateBook::slotToday()
779{ 779{
780 // we need to view today using default view 780 // we need to view today using default view
781 view(defaultView,QDate::currentDate()); 781 view(defaultView,QDate::currentDate());
782} 782}
783 783
784void DateBook::closeEvent( QCloseEvent *e ) 784void DateBook::closeEvent( QCloseEvent *e )
785{ 785{
786 if(syncing) { 786 if(syncing) {
787 /* no need to save, did that at flush */ 787 /* no need to save, did that at flush */
788 e->accept(); 788 e->accept();
789 return; 789 return;
790 } 790 }
791 791
792 // save settings will generate it's own error messages, no 792 // save settings will generate it's own error messages, no
793 // need to do checking ourselves. 793 // need to do checking ourselves.
794 saveSettings(); 794 saveSettings();
795 if ( db->save() ) { 795 if ( db->save() ) {
796 e->accept(); 796 e->accept();
797 } else { 797 } else {
798 if ( QMessageBox::critical( this, tr( "Out of space" ), 798 if ( QMessageBox::critical( this, tr( "Out of space" ),
799 tr("Calendar was unable to save\n" 799 tr("Calendar was unable to save\n"
800 "your changes.\n" 800 "your changes.\n"
801 "Free up some space and try again.\n" 801 "Free up some space and try again.\n"
802 "\nQuit anyway?"), 802 "\nQuit anyway?"),
803 QMessageBox::Yes|QMessageBox::Escape, 803 QMessageBox::Yes|QMessageBox::Escape,
804 QMessageBox::No|QMessageBox::Default ) 804 QMessageBox::No|QMessageBox::Default )
805 != QMessageBox::No ) 805 != QMessageBox::No )
806 e->accept(); 806 e->accept();
807 else 807 else
808 e->ignore(); 808 e->ignore();
809 } 809 }
810} 810}
811 811
812// Entering directly from the "keyboard" 812// Entering directly from the "keyboard"
813void DateBook::slotNewEventFromKey( const QString &str ) 813void DateBook::slotNewEventFromKey( const QString &str )
814{ 814{
815 if (syncing) { 815 if (syncing) {
816 QMessageBox::warning( this, tr("Calendar"), 816 QMessageBox::warning( this, tr("Calendar"),
817 tr( "Can not edit data, currently syncing") ); 817 tr( "Can not edit data, currently syncing") );
818 return; 818 return;
819 } 819 }
820 820
821 // We get to here from a key pressed in the Day View 821 // We get to here from a key pressed in the Day View
822 // So we can assume some things. We want the string 822 // So we can assume some things. We want the string
823 // passed in to be part of the description. 823 // passed in to be part of the description.
824 QDateTime start, end; 824 QDateTime start, end;
825 if ( views->visibleWidget() == dayView ) { 825 if ( views->visibleWidget() == dayView ) {
826 dayView->selectedDates( start, end ); 826 dayView->selectedDates( start, end );
827 } else if ( views->visibleWidget() == monthView ) { 827 } else if ( views->visibleWidget() == monthView ) {
828 QDate d = monthView->selectedDate(); 828 QDate d = monthView->selectedDate();
829 start = end = d; 829 start = end = d;
830 start.setTime( QTime( 10, 0 ) ); 830 start.setTime( QTime( 10, 0 ) );
831 end.setTime( QTime( 12, 0 ) ); 831 end.setTime( QTime( 12, 0 ) );
832 } else if ( views->visibleWidget() == weekView ) { 832 } else if ( views->visibleWidget() == weekView ) {
833 QDate d = weekView->date(); 833 QDate d = weekView->date();
834 start = end = d; 834 start = end = d;
835 start.setTime( QTime( 10, 0 ) ); 835 start.setTime( QTime( 10, 0 ) );
836 end.setTime( QTime( 12, 0 ) ); 836 end.setTime( QTime( 12, 0 ) );
837 } else if ( views->visibleWidget() == weekLstView ) { 837 } else if ( views->visibleWidget() == weekLstView ) {
838 QDate d = weekLstView->date(); 838 QDate d = weekLstView->date();
839 start = end = d; 839 start = end = d;
840 start.setTime( QTime( 10, 0 ) ); 840 start.setTime( QTime( 10, 0 ) );
841 end.setTime( QTime( 12, 0 ) ); 841 end.setTime( QTime( 12, 0 ) );
842 } 842 }
843 slotNewEntry(start, end, str); 843 slotNewEntry(start, end, str);
844} 844}
845void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 845void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
846 // argh! This really needs to be encapsulated in a class 846 // argh! This really needs to be encapsulated in a class
847 // or function. 847 // or function.
848 QDialog newDlg( this, 0, TRUE ); 848 QDialog newDlg( this, 0, TRUE );
849 newDlg.setCaption( DateEntryBase::tr("New Event") ); 849 newDlg.setCaption( DateEntryBase::tr("New Event") );
850 DateEntry *e; 850 DateEntry *e;
851 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 851 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
852 QScrollView *sv = new QScrollView( &newDlg ); 852 QScrollView *sv = new QScrollView( &newDlg );
853 sv->setResizePolicy( QScrollView::AutoOneFit ); 853 sv->setResizePolicy( QScrollView::AutoOneFit );
854 sv->setFrameStyle( QFrame::NoFrame ); 854 sv->setFrameStyle( QFrame::NoFrame );
855 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 855 sv->setHScrollBarMode( QScrollView::AlwaysOff );
856 vb->addWidget( sv ); 856 vb->addWidget( sv );
857 857
858 Event ev; 858 Event ev;
859 ev.setDescription( str ); 859 ev.setDescription( str );
860 // When the new gui comes in, change this... 860 // When the new gui comes in, change this...
861 if(location==0) { 861 if(location==0) {
862 if(defaultLocation.isEmpty()) { 862 if(defaultLocation.isEmpty()) {
863 ev.setLocation(tr("(Unknown)")); 863 ev.setLocation(tr("(Unknown)"));
864 } else { 864 } else {
865 ev.setLocation( defaultLocation ); 865 ev.setLocation( defaultLocation );
866 } 866 }
867 } else { 867 } else {
868 ev.setLocation(location); 868 ev.setLocation(location);
869 } 869 }
870 ev.setCategories(defaultCategories); 870 ev.setCategories(defaultCategories);
871 ev.setStart( start ); 871 ev.setStart( start );
872 ev.setEnd( end ); 872 ev.setEnd( end );
873 873
874 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 874 e = new DateEntry( onMonday, ev, ampm, &newDlg );
875 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 875 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
876 sv->addChild( e ); 876 sv->addChild( e );
877 while ( QPEApplication::execDialog( &newDlg ) ) { 877 while ( QPEApplication::execDialog( &newDlg ) ) {
878 ev = e->event(); 878 ev = e->event();
879 ev.assignUid(); 879 ev.assignUid();
880 QString error = checkEvent( ev ); 880 QString error = checkEvent( ev );
881 if ( !error.isNull() ) { 881 if ( !error.isNull() ) {
882 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 882 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
883 continue; 883 continue;
884 } 884 }
885 db->addEvent( ev ); 885 db->addEvent( ev );
886 emit newEvent(); 886 emit newEvent();
887 break; 887 break;
888 } 888 }
889} 889}
890 890
891void DateBook::setDocument( const QString &filename ) 891void DateBook::setDocument( const QString &filename )
892{ 892{
893 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 893 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
894 894
895 QValueList<Event> tl = Event::readVCalendar( filename ); 895 QValueList<Event> tl = Event::readVCalendar( filename );
896 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 896 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
897 db->addEvent( *it ); 897 db->addEvent( *it );
898 } 898 }
899} 899}
900 900
901static const char * beamfile = "/tmp/obex/event.vcs"; 901static const char * beamfile = "/tmp/obex/event.vcs";
902 902
903void DateBook::beamEvent( const Event &e ) 903void DateBook::beamEvent( const Event &e )
904{ 904{
905 Opie::Core::odebug << "trying to beam" << oendl; 905 odebug << "trying to beam" << oendl;
906 unlink( beamfile ); // delete if exists 906 unlink( beamfile ); // delete if exists
907 mkdir("/tmp/obex/", 0755); 907 mkdir("/tmp/obex/", 0755);
908 Event::writeVCalendar( beamfile, e ); 908 Event::writeVCalendar( beamfile, e );
909 Ir *ir = new Ir( this ); 909 Ir *ir = new Ir( this );
910 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 910 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
911 QString description = e.description(); 911 QString description = e.description();
912 ir->send( beamfile, description, "text/x-vCalendar" ); 912 ir->send( beamfile, description, "text/x-vCalendar" );
913} 913}
914 914
915void DateBook::beamDone( Ir *ir ) 915void DateBook::beamDone( Ir *ir )
916{ 916{
917 delete ir; 917 delete ir;
918 unlink( beamfile ); 918 unlink( beamfile );
919} 919}
920 920
921void DateBook::slotFind() 921void DateBook::slotFind()
922{ 922{
923 // move it to the day view... 923 // move it to the day view...
924 viewDay(); 924 viewDay();
925 FindDialog frmFind( "Calendar", this ); // no tr needed 925 FindDialog frmFind( "Calendar", this ); // no tr needed
926 frmFind.setUseDate( true ); 926 frmFind.setUseDate( true );
927 frmFind.setDate( currentDate() ); 927 frmFind.setDate( currentDate() );
928 QObject::connect( &frmFind, 928 QObject::connect( &frmFind,
929 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)), 929 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)),
930 this, 930 this,
931 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) ); 931 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) );
932 QObject::connect( this, 932 QObject::connect( this,
933 SIGNAL(signalNotFound()), 933 SIGNAL(signalNotFound()),
934 &frmFind, 934 &frmFind,
935 SLOT(slotNotFound()) ); 935 SLOT(slotNotFound()) );
936 QObject::connect( this, 936 QObject::connect( this,
937 SIGNAL(signalWrapAround()), 937 SIGNAL(signalWrapAround()),
938 &frmFind, 938 &frmFind,
939 SLOT(slotWrapAround()) ); 939 SLOT(slotWrapAround()) );
940 frmFind.move(0,0); 940 frmFind.move(0,0);
941 frmFind.exec(); 941 frmFind.exec();
942 inSearch = false; 942 inSearch = false;
943} 943}
944 944
945bool catComp( QArray<int> cats, int category ) 945bool catComp( QArray<int> cats, int category )
946{ 946{
947 bool returnMe; 947 bool returnMe;
948 int i, 948 int i,
949 count; 949 count;
950 950
951 count = int(cats.count()); 951 count = int(cats.count());
952 returnMe = false; 952 returnMe = false;
953 if ( (category == -1 && count == 0) || category == -2 ) 953 if ( (category == -1 && count == 0) || category == -2 )
954 returnMe = true; 954 returnMe = true;
955 else { 955 else {
956 for ( i = 0; i < count; i++ ) { 956 for ( i = 0; i < count; i++ ) {
957 if ( category == cats[i] ) { 957 if ( category == cats[i] ) {
958 returnMe = true; 958 returnMe = true;
959 break; 959 break;
960 } 960 }
961 } 961 }
962 } 962 }
963 return returnMe; 963 return returnMe;
964} 964}
965 965
966 966
967void DateBook::slotDoFind( const QString& txt, const QDate &dt, 967void DateBook::slotDoFind( const QString& txt, const QDate &dt,
968 bool caseSensitive, bool /*backwards*/, 968 bool caseSensitive, bool /*backwards*/,
969 int category ) 969 int category )
970{ 970{
971 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 971 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
972 next; 972 next;
973 973
974 QRegExp r( txt ); 974 QRegExp r( txt );
975 r.setCaseSensitive( caseSensitive ); 975 r.setCaseSensitive( caseSensitive );
976 976
977 977
978 static Event rev, nonrev; 978 static Event rev, nonrev;
979 if ( !inSearch ) { 979 if ( !inSearch ) {
980 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 980 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
981 nonrev.setStart( rev.start() ); 981 nonrev.setStart( rev.start() );
982 inSearch = true; 982 inSearch = true;
983 } 983 }
984 static QDate searchDate = dt; 984 static QDate searchDate = dt;
985 // if true at the end we will start at the begin again and afterwards 985 // if true at the end we will start at the begin again and afterwards
986 // we will emit string not found 986 // we will emit string not found
987 static bool wrapAround = true; 987 static bool wrapAround = true;
988 bool candidtate; 988 bool candidtate;
989 candidtate = false; 989 candidtate = false;
990 990
991 QValueList<Event> repeats = db->getRawRepeats(); 991 QValueList<Event> repeats = db->getRawRepeats();
992 992
993 // find the candidate for the first repeat that matches... 993 // find the candidate for the first repeat that matches...
994 // first check if there can ever be a match and then compute 994 // first check if there can ever be a match and then compute
995 // the next occurence from start. See if this event is closer 995 // the next occurence from start. See if this event is closer
996 // to the beginning (start. next < dtEnd) and not smaller then the last 996 // to the beginning (start. next < dtEnd) and not smaller then the last
997 // result. If we find a canditate we set the dtEnd to the time 997 // result. If we find a canditate we set the dtEnd to the time
998 // of the ocurrence and rev to this occurence. 998 // of the ocurrence and rev to this occurence.
999 // set wrap around to true because there might be more events coming 999 // set wrap around to true because there might be more events coming
1000 // and we're not at the end. 1000 // and we're not at the end.
1001 QValueListConstIterator<Event> it; 1001 QValueListConstIterator<Event> it;
1002 QDate start = dt; 1002 QDate start = dt;
1003 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 1003 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
1004 if ( catComp( (*it).categories(), category ) ) { 1004 if ( catComp( (*it).categories(), category ) ) {
1005 if ( (*it).match( r ) ) { 1005 if ( (*it).match( r ) ) {
1006 if ( nextOccurance( *it, start, next ) ) { 1006 if ( nextOccurance( *it, start, next ) ) {
1007 if ( next < dtEnd && !(next <= rev.start() ) ) { 1007 if ( next < dtEnd && !(next <= rev.start() ) ) {
1008 rev = *it; 1008 rev = *it;
1009 dtEnd = next; 1009 dtEnd = next;
1010 rev.setStart( next ); 1010 rev.setStart( next );
1011 candidtate = true; 1011 candidtate = true;
1012 wrapAround = true; 1012 wrapAround = true;
1013 } 1013 }
1014 } 1014 }
1015 } 1015 }
1016 } 1016 }
1017 } 1017 }
1018 1018
1019 // now the for first non repeat... 1019 // now the for first non repeat...
1020 // dtEnd is set by the previous iteration of repeatingEvents 1020 // dtEnd is set by the previous iteration of repeatingEvents
1021 // check if we find a closer item. Also set dtEnd to find even 1021 // check if we find a closer item. Also set dtEnd to find even
1022 // more close occurrence 1022 // more close occurrence
1023 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); 1023 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
1024 qHeapSort( nonRepeats.begin(), nonRepeats.end() ); 1024 qHeapSort( nonRepeats.begin(), nonRepeats.end() );
1025 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { 1025 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
1026 if ( catComp( (*it).categories(), category ) ) { 1026 if ( catComp( (*it).categories(), category ) ) {
1027 if ( (*it).start() < dtEnd ) { 1027 if ( (*it).start() < dtEnd ) {
1028 if ( (*it).match( r ) && !(*it <= nonrev) ) { 1028 if ( (*it).match( r ) && !(*it <= nonrev) ) {
1029 nonrev = *it; 1029 nonrev = *it;
1030 dtEnd = nonrev.start(); 1030 dtEnd = nonrev.start();
1031 candidtate = true; 1031 candidtate = true;
1032 wrapAround = true; 1032 wrapAround = true;
1033 break; 1033 break;
1034 } 1034 }
1035 } 1035 }
1036 } 1036 }
1037 } 1037 }
1038 if ( candidtate ) { 1038 if ( candidtate ) {
1039 dayView->setStartViewTime( dtEnd.time().hour() ); 1039 dayView->setStartViewTime( dtEnd.time().hour() );
1040 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), 1040 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(),
1041 dtEnd.date().day() ); 1041 dtEnd.date().day() );
1042 } else { 1042 } else {
1043 if ( wrapAround ) { 1043 if ( wrapAround ) {
1044 emit signalWrapAround(); 1044 emit signalWrapAround();
1045 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 1045 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
1046 nonrev.setStart( rev.start() ); 1046 nonrev.setStart( rev.start() );
1047 } else 1047 } else
1048 emit signalNotFound(); 1048 emit signalNotFound();
1049 wrapAround = !wrapAround; 1049 wrapAround = !wrapAround;
1050 } 1050 }
1051} 1051}
1052 1052
1053Event DateBookDBHack::eventByUID(int uid) { 1053Event DateBookDBHack::eventByUID(int uid) {
1054 1054
1055 // FIXME: Dirty Hacks to get hold of the private event lists 1055 // FIXME: Dirty Hacks to get hold of the private event lists
1056 QDate start; 1056 QDate start;
1057 QDate end=start.addDays(-1); 1057 QDate end=start.addDays(-1);
1058 QValueList<Event> myEventList=getNonRepeatingEvents(start,end); 1058 QValueList<Event> myEventList=getNonRepeatingEvents(start,end);
1059 QValueList<Event> myRepeatEvents=getRawRepeats(); 1059 QValueList<Event> myRepeatEvents=getRawRepeats();
1060 1060
1061 QValueList<Event>::ConstIterator it; 1061 QValueList<Event>::ConstIterator it;
1062 1062
1063 for (it = myEventList.begin(); it != myEventList.end(); it++) { 1063 for (it = myEventList.begin(); it != myEventList.end(); it++) {
1064 if ((*it).uid() == uid) return *it; 1064 if ((*it).uid() == uid) return *it;
1065 } 1065 }
1066 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { 1066 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) {
1067 if ((*it).uid() == uid) return *it; 1067 if ((*it).uid() == uid) return *it;
1068 } 1068 }
1069 1069
1070 Event ev; 1070 Event ev;
1071 return ev; // return at least 1071 return ev; // return at least
1072} 1072}
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index 123a478..7462de7 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -1,123 +1,123 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "datebookweekheaderimpl.h" 20#include "datebookweekheaderimpl.h"
21#include "datebookweek.h" 21#include "datebookweek.h"
22 22
23#include <opie2/odebug.h> 23#include <opie2/odebug.h>
24 24
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/datebookmonth.h> 26#include <qpe/datebookmonth.h>
27 27
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29 29
30/* 30/*
31 * Constructs a DateBookWeekHeader which is a child of 'parent', with the 31 * Constructs a DateBookWeekHeader which is a child of 'parent', with the
32 * name 'name' and widget flags set to 'f' 32 * name 'name' and widget flags set to 'f'
33 */ 33 */
34DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) 34DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl )
35 : DateBookWeekHeaderBase( parent, name, fl ), 35 : DateBookWeekHeaderBase( parent, name, fl ),
36 bStartOnMonday( startOnMonday ) 36 bStartOnMonday( startOnMonday )
37{ 37{
38 setBackgroundMode( PaletteButton ); 38 setBackgroundMode( PaletteButton );
39 labelDate->setBackgroundMode( PaletteButton ); 39 labelDate->setBackgroundMode( PaletteButton );
40 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 40 backmonth->setPixmap( Resource::loadPixmap("fastback") );
41 backweek->setPixmap( Resource::loadPixmap("back") ); 41 backweek->setPixmap( Resource::loadPixmap("back") );
42 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 42 forwardweek->setPixmap( Resource::loadPixmap("forward") );
43 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 43 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
44} 44}
45 45
46/* 46/*
47 * Destroys the object and frees any allocated resources 47 * Destroys the object and frees any allocated resources
48 */ 48 */
49DateBookWeekHeader::~DateBookWeekHeader() 49DateBookWeekHeader::~DateBookWeekHeader()
50{ 50{
51 // no need to delete child widgets, Qt does it all for us 51 // no need to delete child widgets, Qt does it all for us
52} 52}
53 53
54void DateBookWeekHeader::pickDate() 54void DateBookWeekHeader::pickDate()
55{ 55{
56 static QPopupMenu *m1 = 0; 56 static QPopupMenu *m1 = 0;
57 static DateBookMonth *picker = 0; 57 static DateBookMonth *picker = 0;
58 if ( !m1 ) { 58 if ( !m1 ) {
59 m1 = new QPopupMenu( this ); 59 m1 = new QPopupMenu( this );
60 picker = new DateBookMonth( m1, 0, TRUE ); 60 picker = new DateBookMonth( m1, 0, TRUE );
61 m1->insertItem( picker ); 61 m1->insertItem( picker );
62 connect( picker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( setDate(int,int,int) ) ); 62 connect( picker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( setDate(int,int,int) ) );
63 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); 63 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) );
64 } 64 }
65 picker->setDate( date.year(), date.month(), date.day() ); 65 picker->setDate( date.year(), date.month(), date.day() );
66 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 66 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
67 picker->setFocus(); 67 picker->setFocus();
68} 68}
69 69
70void DateBookWeekHeader::nextMonth() 70void DateBookWeekHeader::nextMonth()
71{ 71{
72 Opie::Core::owarn << "nextMonth()" << oendl; 72 owarn << "nextMonth()" << oendl;
73 setDate(date.addDays(28)); 73 setDate(date.addDays(28));
74} 74}
75void DateBookWeekHeader::prevMonth() 75void DateBookWeekHeader::prevMonth()
76{ 76{
77 Opie::Core::owarn << "prevMonth()" << oendl; 77 owarn << "prevMonth()" << oendl;
78 setDate(date.addDays(-28)); 78 setDate(date.addDays(-28));
79} 79}
80void DateBookWeekHeader::nextWeek() 80void DateBookWeekHeader::nextWeek()
81{ 81{
82 Opie::Core::owarn << "nextWeek()" << oendl; 82 owarn << "nextWeek()" << oendl;
83 setDate(date.addDays(7)); 83 setDate(date.addDays(7));
84} 84}
85void DateBookWeekHeader::prevWeek() 85void DateBookWeekHeader::prevWeek()
86{ 86{
87 Opie::Core::owarn << "prevWeek()" << oendl; 87 owarn << "prevWeek()" << oendl;
88 setDate(date.addDays(-7)); 88 setDate(date.addDays(-7));
89} 89}
90 90
91void DateBookWeekHeader::setDate( int y, int m, int d ) 91void DateBookWeekHeader::setDate( int y, int m, int d )
92{ 92{
93 setDate(QDate(y,m,d)); 93 setDate(QDate(y,m,d));
94} 94}
95 95
96void DateBookWeekHeader::setDate(const QDate &d) { 96void DateBookWeekHeader::setDate(const QDate &d) {
97 int year,week,dayofweek; 97 int year,week,dayofweek;
98 date=d; 98 date=d;
99 dayofweek=d.dayOfWeek(); 99 dayofweek=d.dayOfWeek();
100 if(bStartOnMonday) 100 if(bStartOnMonday)
101 dayofweek--; 101 dayofweek--;
102 else if( dayofweek == 7 ) 102 else if( dayofweek == 7 )
103 // we already have the right day -7 would lead to the current week.. 103 // we already have the right day -7 would lead to the current week..
104 dayofweek = 0; 104 dayofweek = 0;
105 105
106 date=date.addDays(-dayofweek); 106 date=date.addDays(-dayofweek);
107 calcWeek(date,week,year,bStartOnMonday); 107 calcWeek(date,week,year,bStartOnMonday);
108 QDate start=date; 108 QDate start=date;
109 QDate stop=start.addDays(6); 109 QDate stop=start.addDays(6);
110 labelDate->setText( QString::number(start.day()) + "." + 110 labelDate->setText( QString::number(start.day()) + "." +
111 Calendar::nameOfMonth( start.month()) + "-" + 111 Calendar::nameOfMonth( start.month()) + "-" +
112 QString::number(stop.day()) + "." + 112 QString::number(stop.day()) + "." +
113 Calendar::nameOfMonth( stop.month()) +" ("+ 113 Calendar::nameOfMonth( stop.month()) +" ("+
114 tr("w")+":"+QString::number( week ) +")"); 114 tr("w")+":"+QString::number( week ) +")");
115 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 115 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
116 emit dateChanged(date); 116 emit dateChanged(date);
117} 117}
118 118
119void DateBookWeekHeader::setStartOfWeek( bool onMonday ) 119void DateBookWeekHeader::setStartOfWeek( bool onMonday )
120{ 120{
121 bStartOnMonday = onMonday; 121 bStartOnMonday = onMonday;
122 setDate( date ); 122 setDate( date );
123} 123}
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index de74d46..fe2ab51 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,397 +1,397 @@
1#include "namespace_hack.h" 1#include "namespace_hack.h"
2#include "datebookweeklst.h" 2#include "datebookweeklst.h"
3 3
4#include "datebook.h" 4#include "datebook.h"
5 5
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7 7
8#include <qpe/datebookmonth.h> 8#include <qpe/datebookmonth.h>
9#include <qpe/config.h> 9#include <qpe/config.h>
10#include <qpe/resource.h> 10#include <qpe/resource.h>
11 11
12#include <qlayout.h> 12#include <qlayout.h>
13#include <qtoolbutton.h> 13#include <qtoolbutton.h>
14#include <qtl.h> 14#include <qtl.h>
15 15
16bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); 16bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
17 17
18using namespace Opie::Ui; 18using namespace Opie::Ui;
19DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) 19DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
20 : DateBookWeekLstHeaderBase(parent, name, fl) 20 : DateBookWeekLstHeaderBase(parent, name, fl)
21{ 21{
22 setBackgroundMode( PaletteButton ); 22 setBackgroundMode( PaletteButton );
23 labelDate->setBackgroundMode( PaletteButton ); 23 labelDate->setBackgroundMode( PaletteButton );
24 forwardweek->setBackgroundMode( PaletteButton ); 24 forwardweek->setBackgroundMode( PaletteButton );
25 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 25 forwardweek->setPixmap( Resource::loadPixmap("forward") );
26 forwardmonth->setBackgroundMode( PaletteButton ); 26 forwardmonth->setBackgroundMode( PaletteButton );
27 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 27 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
28 backweek->setBackgroundMode( PaletteButton ); 28 backweek->setBackgroundMode( PaletteButton );
29 backweek->setPixmap( Resource::loadPixmap("back") ); 29 backweek->setPixmap( Resource::loadPixmap("back") );
30 backmonth->setBackgroundMode( PaletteButton ); 30 backmonth->setBackgroundMode( PaletteButton );
31 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 31 backmonth->setPixmap( Resource::loadPixmap("fastback") );
32 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 32 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
33 DateBookWeekLstHeaderBaseLayout->setMargin(0); 33 DateBookWeekLstHeaderBaseLayout->setMargin(0);
34 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 34 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
35 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 35 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
36 36
37 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); 37 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
38 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); 38 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
39 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); 39 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
40 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); 40 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
41 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); 41 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
42 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 42 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
43 bStartOnMonday=onM; 43 bStartOnMonday=onM;
44} 44}
45DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 45DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
46 46
47void DateBookWeekLstHeader::setDate(const QDate &d) { 47void DateBookWeekLstHeader::setDate(const QDate &d) {
48 int year,week,dayofweek; 48 int year,week,dayofweek;
49 date=d; 49 date=d;
50 dayofweek=d.dayOfWeek(); 50 dayofweek=d.dayOfWeek();
51 if(bStartOnMonday) 51 if(bStartOnMonday)
52 dayofweek--; 52 dayofweek--;
53 else if( dayofweek == 7 ) 53 else if( dayofweek == 7 )
54 /* we already have the right day -7 would lead to the same week */ 54 /* we already have the right day -7 would lead to the same week */
55 dayofweek = 0; 55 dayofweek = 0;
56 56
57 date=date.addDays(-dayofweek); 57 date=date.addDays(-dayofweek);
58 58
59 calcWeek(date,week,year,bStartOnMonday); 59 calcWeek(date,week,year,bStartOnMonday);
60 QDate start=date; 60 QDate start=date;
61 QDate stop=start.addDays(6); 61 QDate stop=start.addDays(6);
62 labelDate->setText( QString::number(start.day()) + "." + 62 labelDate->setText( QString::number(start.day()) + "." +
63 Calendar::nameOfMonth( start.month() ) + "-" + 63 Calendar::nameOfMonth( start.month() ) + "-" +
64 QString::number(stop.day()) + "." + 64 QString::number(stop.day()) + "." +
65 Calendar::nameOfMonth( stop.month()) +" ("+ 65 Calendar::nameOfMonth( stop.month()) +" ("+
66 tr("w")+":"+QString::number( week ) +")"); 66 tr("w")+":"+QString::number( week ) +")");
67 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 67 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
68 emit dateChanged(date); 68 emit dateChanged(date);
69} 69}
70 70
71void DateBookWeekLstHeader::pickDate() { 71void DateBookWeekLstHeader::pickDate() {
72 static QPopupMenu *m1 = 0; 72 static QPopupMenu *m1 = 0;
73 static DateBookMonth *picker = 0; 73 static DateBookMonth *picker = 0;
74 if ( !m1 ) { 74 if ( !m1 ) {
75 m1 = new QPopupMenu( this ); 75 m1 = new QPopupMenu( this );
76 picker = new DateBookMonth( m1, 0, TRUE ); 76 picker = new DateBookMonth( m1, 0, TRUE );
77 m1->insertItem( picker ); 77 m1->insertItem( picker );
78 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); 78 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) );
79 //connect( m1, SIGNAL( aboutToHide() ), 79 //connect( m1, SIGNAL( aboutToHide() ),
80 //this, SLOT( gotHide() ) ); 80 //this, SLOT( gotHide() ) );
81 } 81 }
82 picker->setDate( date.year(), date.month(), date.day() ); 82 picker->setDate( date.year(), date.month(), date.day() );
83 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 83 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
84 picker->setFocus(); 84 picker->setFocus();
85} 85}
86void DateBookWeekLstHeader::setDate(int y, int m, int d) { 86void DateBookWeekLstHeader::setDate(int y, int m, int d) {
87 setDate(QDate(y,m,d)); 87 setDate(QDate(y,m,d));
88} 88}
89 89
90void DateBookWeekLstHeader::nextWeek() { 90void DateBookWeekLstHeader::nextWeek() {
91 setDate(date.addDays(7)); 91 setDate(date.addDays(7));
92} 92}
93void DateBookWeekLstHeader::prevWeek() { 93void DateBookWeekLstHeader::prevWeek() {
94 setDate(date.addDays(-7)); 94 setDate(date.addDays(-7));
95} 95}
96void DateBookWeekLstHeader::nextMonth() 96void DateBookWeekLstHeader::nextMonth()
97{ 97{
98 setDate(date.addDays(28)); 98 setDate(date.addDays(28));
99} 99}
100void DateBookWeekLstHeader::prevMonth() 100void DateBookWeekLstHeader::prevMonth()
101{ 101{
102 setDate(date.addDays(-28)); 102 setDate(date.addDays(-28));
103} 103}
104 104
105DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, 105DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
106 QWidget* parent, 106 QWidget* parent,
107 const char* name, 107 const char* name,
108 WFlags fl ) 108 WFlags fl )
109 : DateBookWeekLstDayHdrBase(parent, name, fl) { 109 : DateBookWeekLstDayHdrBase(parent, name, fl) {
110 110
111 date=d; 111 date=d;
112 112
113 static const QString wdays=tr("MTWTFSSM", "Week days"); 113 static const QString wdays=tr("MTWTFSSM", "Week days");
114 char day=wdays[d.dayOfWeek()-1]; 114 char day=wdays[d.dayOfWeek()-1];
115 115
116 //dont use dayOfWeek() to save space ! 116 //dont use dayOfWeek() to save space !
117 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); 117 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
118 118
119 add->setText("+"); 119 add->setText("+");
120 120
121 if (d == QDate::currentDate()) { 121 if (d == QDate::currentDate()) {
122 QPalette pal=label->palette(); 122 QPalette pal=label->palette();
123 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 123 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
124 label->setPalette(pal); 124 label->setPalette(pal);
125 125
126 /* 126 /*
127 QFont f=label->font(); 127 QFont f=label->font();
128 f.setItalic(true); 128 f.setItalic(true);
129 label->setFont(f); 129 label->setFont(f);
130 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 130 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
131 */ 131 */
132 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 132 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
133 QPalette pal=label->palette(); 133 QPalette pal=label->palette();
134 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 134 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
135 label->setPalette(pal); 135 label->setPalette(pal);
136 } 136 }
137 137
138 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 138 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
139 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 139 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
140} 140}
141 141
142void DateBookWeekLstDayHdr::showDay() { 142void DateBookWeekLstDayHdr::showDay() {
143 emit showDate(date.year(), date.month(), date.day()); 143 emit showDate(date.year(), date.month(), date.day());
144} 144}
145 145
146void DateBookWeekLstDayHdr::newEvent() { 146void DateBookWeekLstDayHdr::newEvent() {
147 QDateTime start, stop; 147 QDateTime start, stop;
148 start=stop=date; 148 start=stop=date;
149 start.setTime(QTime(10,0)); 149 start.setTime(QTime(10,0));
150 stop.setTime(QTime(12,0)); 150 stop.setTime(QTime(12,0));
151 151
152 emit addEvent(start,stop,"",0); 152 emit addEvent(start,stop,"",0);
153} 153}
154DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 154DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
155 int weeklistviewconfig, 155 int weeklistviewconfig,
156 QWidget* parent, 156 QWidget* parent,
157 const char* name, 157 const char* name,
158 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) 158 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
159{ 159{
160 // old values... lastday = "__|__", middle=" |---", Firstday="00:00", 160 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
161 QString s,start,middle,end,day; 161 QString s,start,middle,end,day;
162 162
163 Opie::Core::odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; 163 odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl;
164 if(weeklistviewconfig==NONE) {// No times displayed. 164 if(weeklistviewconfig==NONE) {// No times displayed.
165 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 165 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
166 // middle.sprintf("<--->"); 166 // middle.sprintf("<--->");
167 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 167 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
168 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 168 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
169 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. 169 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time.
170 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 170 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
171 middle.sprintf(" |---"); 171 middle.sprintf(" |---");
172 end.sprintf("__|__"); 172 end.sprintf("__|__");
173 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 173 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
174 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. 174 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
175 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 175 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
176 middle.sprintf("<--->"); 176 middle.sprintf("<--->");
177 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 177 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
178 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 178 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
179 } 179 }
180 180
181 if(ev.event().type() == Event::Normal) { 181 if(ev.event().type() == Event::Normal) {
182 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. 182 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event.
183 s=day; 183 s=day;
184 } else if(ev.startDate()==ev.date()) {// start event. 184 } else if(ev.startDate()==ev.date()) {// start event.
185 s=start; 185 s=start;
186 } else if(ev.endDate()==ev.date()) { // end event. 186 } else if(ev.endDate()==ev.date()) { // end event.
187 s=end; 187 s=end;
188 } else {// middle day. 188 } else {// middle day.
189 s=middle; 189 s=middle;
190 } 190 }
191 } else { 191 } else {
192 s=""; 192 s="";
193 } 193 }
194 setText(QString(s) + " " + ev.description()); 194 setText(QString(s) + " " + ev.description());
195 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 195 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
196 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 196 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
197} 197}
198void DateBookWeekLstEvent::editMe() { 198void DateBookWeekLstEvent::editMe() {
199 emit editEvent(event.event()); 199 emit editEvent(event.event());
200} 200}
201 201
202 202
203DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 203DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
204 const QDate &d, bool onM, 204 const QDate &d, bool onM,
205 QWidget* parent, 205 QWidget* parent,
206 const char* name, WFlags fl) 206 const char* name, WFlags fl)
207 : QWidget( parent, name, fl ) 207 : QWidget( parent, name, fl )
208{ 208{
209 Config config("DateBook"); 209 Config config("DateBook");
210 config.setGroup("Main"); 210 config.setGroup("Main");
211 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); 211 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
212 Opie::Core::odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; 212 odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl;
213 213
214 bStartOnMonday=onM; 214 bStartOnMonday=onM;
215 setPalette(white); 215 setPalette(white);
216 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 216 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
217 217
218 QVBoxLayout *layout = new QVBoxLayout( this ); 218 QVBoxLayout *layout = new QVBoxLayout( this );
219 219
220 qBubbleSort(ev); 220 qBubbleSort(ev);
221 QValueListIterator<EffectiveEvent> it; 221 QValueListIterator<EffectiveEvent> it;
222 it=ev.begin(); 222 it=ev.begin();
223 223
224 int dayOrder[7]; 224 int dayOrder[7];
225 if (bStartOnMonday) { 225 if (bStartOnMonday) {
226 for (int d=0; d<7; d++) dayOrder[d]=d+1; 226 for (int d=0; d<7; d++) dayOrder[d]=d+1;
227 } else { 227 } else {
228 for (int d=0; d<7; d++) dayOrder[d]=d; 228 for (int d=0; d<7; d++) dayOrder[d]=d;
229 dayOrder[0]=7; 229 dayOrder[0]=7;
230 } 230 }
231 231
232 // Calculate offset to first day of week. 232 // Calculate offset to first day of week.
233 int dayoffset=d.dayOfWeek(); 233 int dayoffset=d.dayOfWeek();
234 if(bStartOnMonday) dayoffset--; 234 if(bStartOnMonday) dayoffset--;
235 else if( dayoffset == 7 ) dayoffset = 0; 235 else if( dayoffset == 7 ) dayoffset = 0;
236 236
237 for (int i=0; i<7; i++) { 237 for (int i=0; i<7; i++) {
238 // Header 238 // Header
239 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); 239 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
240 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 240 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
241 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 241 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
242 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 242 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
243 layout->addWidget(hdr); 243 layout->addWidget(hdr);
244 244
245 // Events 245 // Events
246 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 246 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
247 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. 247 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day.
248 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); 248 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
249 layout->addWidget(l); 249 layout->addWidget(l);
250 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 250 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
251 } 251 }
252 it++; 252 it++;
253 } 253 }
254 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 254 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
255 } 255 }
256} 256}
257DateBookWeekLstView::~DateBookWeekLstView(){} 257DateBookWeekLstView::~DateBookWeekLstView(){}
258void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 258void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
259 259
260DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 260DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
261 QValueList<EffectiveEvent> &ev2, 261 QValueList<EffectiveEvent> &ev2,
262 QDate &d, bool onM, 262 QDate &d, bool onM,
263 QWidget* parent, 263 QWidget* parent,
264 const char* name, WFlags fl) 264 const char* name, WFlags fl)
265 : QWidget( parent, name, fl ) 265 : QWidget( parent, name, fl )
266{ 266{
267 QHBoxLayout *layout = new QHBoxLayout( this ); 267 QHBoxLayout *layout = new QHBoxLayout( this );
268 268
269 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 269 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
270 layout->addWidget(w); 270 layout->addWidget(w);
271 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 271 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
272 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 272 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
273 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 273 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
274 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 274 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
275 275
276 276
277 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 277 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
278 layout->addWidget(w); 278 layout->addWidget(w);
279 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 279 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
280 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 280 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
281 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 281 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
282 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 282 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
283} 283}
284 284
285DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 285DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
286 QWidget *parent, 286 QWidget *parent,
287 const char *name ) 287 const char *name )
288 : QWidget( parent, name ), 288 : QWidget( parent, name ),
289 db( newDB ), 289 db( newDB ),
290 startTime( 0 ), 290 startTime( 0 ),
291 ampm( ap ), 291 ampm( ap ),
292 bStartOnMonday(onM) 292 bStartOnMonday(onM)
293{ 293{
294 setFocusPolicy(StrongFocus); 294 setFocusPolicy(StrongFocus);
295 layout = new QVBoxLayout( this ); 295 layout = new QVBoxLayout( this );
296 layout->setMargin(0); 296 layout->setMargin(0);
297 297
298 header=new DateBookWeekLstHeader(onM, this); 298 header=new DateBookWeekLstHeader(onM, this);
299 layout->addWidget( header ); 299 layout->addWidget( header );
300 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); 300 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
301 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 301 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
302 302
303 scroll=new QScrollView(this); 303 scroll=new QScrollView(this);
304 scroll->setResizePolicy(QScrollView::AutoOneFit); 304 scroll->setResizePolicy(QScrollView::AutoOneFit);
305 layout->addWidget(scroll); 305 layout->addWidget(scroll);
306 306
307 view=NULL; 307 view=NULL;
308 Config config("DateBook"); 308 Config config("DateBook");
309 config.setGroup("Main"); 309 config.setGroup("Main");
310 dbl=config.readBoolEntry("weeklst_dbl", false); 310 dbl=config.readBoolEntry("weeklst_dbl", false);
311 header->dbl->setOn(dbl); 311 header->dbl->setOn(dbl);
312} 312}
313DateBookWeekLst::~DateBookWeekLst(){ 313DateBookWeekLst::~DateBookWeekLst(){
314 Config config("DateBook"); 314 Config config("DateBook");
315 config.setGroup("Main"); 315 config.setGroup("Main");
316 config.writeEntry("weeklst_dbl", dbl); 316 config.writeEntry("weeklst_dbl", dbl);
317} 317}
318 318
319void DateBookWeekLst::setDate(const QDate &d) { 319void DateBookWeekLst::setDate(const QDate &d) {
320 bdate=d; 320 bdate=d;
321 header->setDate(d); 321 header->setDate(d);
322} 322}
323 323
324void DateBookWeekLst::setDbl(bool on) { 324void DateBookWeekLst::setDbl(bool on) {
325 dbl=on; 325 dbl=on;
326 redraw(); 326 redraw();
327} 327}
328void DateBookWeekLst::redraw() {getEvents();} 328void DateBookWeekLst::redraw() {getEvents();}
329 329
330QDate DateBookWeekLst::date() { 330QDate DateBookWeekLst::date() {
331 return bdate; 331 return bdate;
332} 332}
333 333
334// return the date at the beginning of the week... 334// return the date at the beginning of the week...
335// copied from DateBookWeek 335// copied from DateBookWeek
336QDate DateBookWeekLst::weekDate() const 336QDate DateBookWeekLst::weekDate() const
337{ 337{
338 QDate d=bdate; 338 QDate d=bdate;
339 339
340 // Calculate offset to first day of week. 340 // Calculate offset to first day of week.
341 int dayoffset=d.dayOfWeek(); 341 int dayoffset=d.dayOfWeek();
342 if(bStartOnMonday) dayoffset--; 342 if(bStartOnMonday) dayoffset--;
343 else if( dayoffset == 7 ) 343 else if( dayoffset == 7 )
344 dayoffset = 0; 344 dayoffset = 0;
345 345
346 return d.addDays(-dayoffset); 346 return d.addDays(-dayoffset);
347} 347}
348 348
349void DateBookWeekLst::getEvents() { 349void DateBookWeekLst::getEvents() {
350 QDate start = weekDate(); //date(); 350 QDate start = weekDate(); //date();
351 QDate stop = start.addDays(6); 351 QDate stop = start.addDays(6);
352 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 352 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
353 353
354 if (view) delete view; 354 if (view) delete view;
355 if (dbl) { 355 if (dbl) {
356 QDate start2=start.addDays(7); 356 QDate start2=start.addDays(7);
357 stop=start2.addDays(6); 357 stop=start2.addDays(6);
358 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 358 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
359 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 359 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
360 } else { 360 } else {
361 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); 361 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
362 } 362 }
363 363
364 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 364 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
365 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 365 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
366 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 366 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
367 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 367 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
368 368
369 scroll->addChild(view); 369 scroll->addChild(view);
370 view->show(); 370 view->show();
371 scroll->updateScrollBars(); 371 scroll->updateScrollBars();
372} 372}
373 373
374void DateBookWeekLst::dateChanged(QDate &newdate) { 374void DateBookWeekLst::dateChanged(QDate &newdate) {
375 bdate=newdate; 375 bdate=newdate;
376 getEvents(); 376 getEvents();
377} 377}
378 378
379void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 379void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
380{ 380{
381 switch(e->key()) { 381 switch(e->key()) {
382 case Key_Up: 382 case Key_Up:
383 scroll->scrollBy(0, -20); 383 scroll->scrollBy(0, -20);
384 break; 384 break;
385 case Key_Down: 385 case Key_Down:
386 scroll->scrollBy(0, 20); 386 scroll->scrollBy(0, 20);
387 break; 387 break;
388 case Key_Left: 388 case Key_Left:
389 header->prevWeek(); 389 header->prevWeek();
390 break; 390 break;
391 case Key_Right: 391 case Key_Right:
392 header->nextWeek(); 392 header->nextWeek();
393 break; 393 break;
394 default: 394 default:
395 e->ignore(); 395 e->ignore();
396 } 396 }
397} 397}
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index 42bdbe2..297da94 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -242,321 +242,321 @@ void DateEntry::slotEditNote() {
242 this,0,TRUE); 242 this,0,TRUE);
243 243
244 if ( QPEApplication::execDialog( &noteDlg ) ) { 244 if ( QPEApplication::execDialog( &noteDlg ) ) {
245 noteStr=noteDlg.note->text(); 245 noteStr=noteDlg.note->text();
246 } 246 }
247 247
248} 248}
249 249
250void DateEntry::endDateChanged( int y, int m, int d ) 250void DateEntry::endDateChanged( int y, int m, int d )
251{ 251{
252 endDate.setYMD( y, m, d ); 252 endDate.setYMD( y, m, d );
253 if ( endDate < startDate ) { 253 if ( endDate < startDate ) {
254 endDate = startDate; 254 endDate = startDate;
255 } 255 }
256 256
257 buttonEnd->setText( TimeString::shortDate( endDate ) ); 257 buttonEnd->setText( TimeString::shortDate( endDate ) );
258 258
259 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); 259 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() );
260} 260}
261 261
262static QTime parseTime( const QString& s, bool ampm ) 262static QTime parseTime( const QString& s, bool ampm )
263{ 263{
264 QTime tmpTime; 264 QTime tmpTime;
265 QStringList l = QStringList::split( ':', s ); 265 QStringList l = QStringList::split( ':', s );
266 int hour = l[0].toInt(); 266 int hour = l[0].toInt();
267 if ( ampm ) { 267 if ( ampm ) {
268 int i=0; 268 int i=0;
269 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') 269 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9')
270 i++; 270 i++;
271 QString digits = l[1].left(i); 271 QString digits = l[1].left(i);
272 if ( l[1].contains( "PM", FALSE ) ) { 272 if ( l[1].contains( "PM", FALSE ) ) {
273 if ( hour != 12 ) 273 if ( hour != 12 )
274 hour += 12; 274 hour += 12;
275 } else { 275 } else {
276 if ( hour == 12 ) 276 if ( hour == 12 )
277 hour = 0; 277 hour = 0;
278 } 278 }
279 l[1] = digits; 279 l[1] = digits;
280 } 280 }
281 int minute = l[1].toInt(); 281 int minute = l[1].toInt();
282 if ( minute > 59 ) 282 if ( minute > 59 )
283 minute = 59; 283 minute = 59;
284 else if ( minute < 0 ) 284 else if ( minute < 0 )
285 minute = 0; 285 minute = 0;
286 if ( hour > 23 ) { 286 if ( hour > 23 ) {
287 hour = 23; 287 hour = 23;
288 minute = 59; 288 minute = 59;
289 } else if ( hour < 0 ) 289 } else if ( hour < 0 )
290 hour = 0; 290 hour = 0;
291 tmpTime.setHMS( hour, minute, 0 ); 291 tmpTime.setHMS( hour, minute, 0 );
292 return tmpTime; 292 return tmpTime;
293} 293}
294 294
295/* 295/*
296 * public slot 296 * public slot
297 */ 297 */
298void DateEntry::endTimeChanged( const QString &s ) 298void DateEntry::endTimeChanged( const QString &s )
299{ 299{
300 endTimeChanged( parseTime(s,ampm) ); 300 endTimeChanged( parseTime(s,ampm) );
301} 301}
302 302
303void DateEntry::endTimeChanged( const QTime &t ) { 303void DateEntry::endTimeChanged( const QTime &t ) {
304 if ( endDate > startDate || t >= startTime ) { 304 if ( endDate > startDate || t >= startTime ) {
305 endTime = t; 305 endTime = t;
306 } else { 306 } else {
307 endTime = startTime; 307 endTime = startTime;
308 //comboEnd->setCurrentItem( comboStart->currentItem() ); 308 //comboEnd->setCurrentItem( comboStart->currentItem() );
309 } 309 }
310 timePickerStart->setHour(endTime.hour()); 310 timePickerStart->setHour(endTime.hour());
311 timePickerStart->setMinute(endTime.minute()); 311 timePickerStart->setMinute(endTime.minute());
312} 312}
313 313
314/* 314/*
315 * public slot 315 * public slot
316 */ 316 */
317void DateEntry::startDateChanged( int y, int m, int d ) 317void DateEntry::startDateChanged( int y, int m, int d )
318{ 318{
319 QDate prev = startDate; 319 QDate prev = startDate;
320 startDate.setYMD( y, m, d ); 320 startDate.setYMD( y, m, d );
321 if ( rp.type == Event::Weekly && 321 if ( rp.type == Event::Weekly &&
322 startDate.dayOfWeek() != prev.dayOfWeek() ) { 322 startDate.dayOfWeek() != prev.dayOfWeek() ) {
323 // if we change the start of a weekly repeating event 323 // if we change the start of a weekly repeating event
324 // set the repeating day appropriately 324 // set the repeating day appropriately
325 char mask = 1 << (prev.dayOfWeek()-1); 325 char mask = 1 << (prev.dayOfWeek()-1);
326 rp.days &= (~mask); 326 rp.days &= (~mask);
327 rp.days |= 1 << (startDate.dayOfWeek()-1); 327 rp.days |= 1 << (startDate.dayOfWeek()-1);
328 } 328 }
329 329
330 buttonStart->setText( TimeString::shortDate( startDate ) ); 330 buttonStart->setText( TimeString::shortDate( startDate ) );
331 331
332 // our pickers must be reset... 332 // our pickers must be reset...
333 startPicker->setDate( y, m, d ); 333 startPicker->setDate( y, m, d );
334 endPicker->setDate( y, m, d ); 334 endPicker->setDate( y, m, d );
335} 335}
336 336
337/* 337/*
338 * public slot 338 * public slot
339 */ 339 */
340void DateEntry::startTimeEdited( const QString &s ) 340void DateEntry::startTimeEdited( const QString &s )
341{ 341{
342 startTimeChanged(parseTime(s,ampm)); 342 startTimeChanged(parseTime(s,ampm));
343 updateTimeEdit(false,true); 343 updateTimeEdit(false,true);
344 timePickerStart->setHour(startTime.hour()); 344 timePickerStart->setHour(startTime.hour());
345 timePickerStart->setMinute(startTime.minute()); 345 timePickerStart->setMinute(startTime.minute());
346} 346}
347 347
348void DateEntry::startTimeChanged( const QTime &t ) 348void DateEntry::startTimeChanged( const QTime &t )
349{ 349{
350 int duration=startTime.secsTo(endTime); 350 int duration=startTime.secsTo(endTime);
351 startTime = t; 351 startTime = t;
352 endTime=t.addSecs(duration); 352 endTime=t.addSecs(duration);
353} 353}
354void DateEntry::startTimePicked( const QTime &t ) { 354void DateEntry::startTimePicked( const QTime &t ) {
355 if(m_showStart ){ 355 if(m_showStart ){
356 startTimeChanged(t); 356 startTimeChanged(t);
357 updateTimeEdit(true,true); 357 updateTimeEdit(true,true);
358 }else{ 358 }else{
359 endTimeChanged(t); 359 endTimeChanged(t);
360 updateTimeEdit(false, true ); 360 updateTimeEdit(false, true );
361 } 361 }
362} 362}
363 363
364/* 364/*
365 * public slot 365 * public slot
366 */ 366 */
367void DateEntry::typeChanged( const QString &s ) 367void DateEntry::typeChanged( const QString &s )
368{ 368{
369 bool b = s != "All Day"; 369 bool b = s != "All Day";
370 buttonStart->setEnabled( b ); 370 buttonStart->setEnabled( b );
371 comboStart->setEnabled( b ); 371 comboStart->setEnabled( b );
372 comboEnd->setEnabled( b ); 372 comboEnd->setEnabled( b );
373} 373}
374 374
375void DateEntry::slotRepeat() 375void DateEntry::slotRepeat()
376{ 376{
377 // Work around for compiler Bug.. 377 // Work around for compiler Bug..
378 RepeatEntry *e; 378 RepeatEntry *e;
379 379
380 // it is better in my opinion to just grab this from the mother, 380 // it is better in my opinion to just grab this from the mother,
381 // since, this dialog doesn't need to keep track of it... 381 // since, this dialog doesn't need to keep track of it...
382 if ( rp.type != Event::NoRepeat ) 382 if ( rp.type != Event::NoRepeat )
383 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); 383 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this);
384 else 384 else
385 e = new RepeatEntry( startWeekOnMonday, startDate, this ); 385 e = new RepeatEntry( startWeekOnMonday, startDate, this );
386 386
387 if ( QPEApplication::execDialog( e ) ) { 387 if ( QPEApplication::execDialog( e ) ) {
388 rp = e->repeatPattern(); 388 rp = e->repeatPattern();
389 setRepeatLabel(); 389 setRepeatLabel();
390 } 390 }
391 // deleting sounds like a nice idea... 391 // deleting sounds like a nice idea...
392 delete e; 392 delete e;
393} 393}
394 394
395void DateEntry::slotChangeStartOfWeek( bool onMonday ) 395void DateEntry::slotChangeStartOfWeek( bool onMonday )
396{ 396{
397 startWeekOnMonday = onMonday; 397 startWeekOnMonday = onMonday;
398} 398}
399 399
400Event DateEntry::event() 400Event DateEntry::event()
401{ 401{
402 Event ev; 402 Event ev;
403 Event::SoundTypeChoice st; 403 Event::SoundTypeChoice st;
404 ev.setDescription( comboDescription->currentText() ); 404 ev.setDescription( comboDescription->currentText() );
405 ev.setLocation( comboLocation->currentText() ); 405 ev.setLocation( comboLocation->currentText() );
406 ev.setCategories( comboCategory->currentCategories() ); 406 ev.setCategories( comboCategory->currentCategories() );
407 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); 407 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal );
408 if ( startDate > endDate ) { 408 if ( startDate > endDate ) {
409 QDate tmp = endDate; 409 QDate tmp = endDate;
410 endDate = startDate; 410 endDate = startDate;
411 startDate = tmp; 411 startDate = tmp;
412 } 412 }
413 413
414 // This is now done in the changed slots 414 // This is now done in the changed slots
415 // startTime = parseTime( comboStart->text(), ampm ); 415 // startTime = parseTime( comboStart->text(), ampm );
416 //endTime = parseTime( comboEnd->text(), ampm ); 416 //endTime = parseTime( comboEnd->text(), ampm );
417 417
418 if ( startTime > endTime && endDate == startDate ) { 418 if ( startTime > endTime && endDate == startDate ) {
419 QTime tmp = endTime; 419 QTime tmp = endTime;
420 endTime = startTime; 420 endTime = startTime;
421 startTime = tmp; 421 startTime = tmp;
422 } 422 }
423 // don't set the time if theres no need too 423 // don't set the time if theres no need too
424 if ( ev.type() == Event::AllDay ) { 424 if ( ev.type() == Event::AllDay ) {
425 startTime.setHMS( 0, 0, 0 ); 425 startTime.setHMS( 0, 0, 0 );
426 endTime.setHMS( 23, 59, 59 ); 426 endTime.setHMS( 23, 59, 59 );
427 } 427 }
428 428
429 // adjust start and end times based on timezone 429 // adjust start and end times based on timezone
430 QDateTime start( startDate, startTime ); 430 QDateTime start( startDate, startTime );
431 QDateTime end( endDate, endTime ); 431 QDateTime end( endDate, endTime );
432 time_t start_utc, end_utc; 432 time_t start_utc, end_utc;
433 433
434 //Opie::Core::odebug << "tz: " << timezone->currentZone() << oendl; 434 //odebug << "tz: " << timezone->currentZone() << oendl;
435 435
436 // get real timezone 436 // get real timezone
437 QString realTZ; 437 QString realTZ;
438 realTZ = QString::fromLocal8Bit( getenv("TZ") ); 438 realTZ = QString::fromLocal8Bit( getenv("TZ") );
439 439
440 // set timezone 440 // set timezone
441 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) 441 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 )
442 Opie::Core::owarn << "There was a problem setting the timezone." << oendl; 442 owarn << "There was a problem setting the timezone." << oendl;
443 443
444 // convert to UTC based on selected TZ (calling tzset internally) 444 // convert to UTC based on selected TZ (calling tzset internally)
445 start_utc = TimeConversion::toUTC( start ); 445 start_utc = TimeConversion::toUTC( start );
446 end_utc = TimeConversion::toUTC( end ); 446 end_utc = TimeConversion::toUTC( end );
447 447
448 // done playing around... put it all back 448 // done playing around... put it all back
449 unsetenv( "TZ" ); 449 unsetenv( "TZ" );
450 if ( !realTZ.isNull() ) 450 if ( !realTZ.isNull() )
451 if ( setenv( "TZ", realTZ, true ) != 0 ) 451 if ( setenv( "TZ", realTZ, true ) != 0 )
452 Opie::Core::owarn << "There was a problem setting the timezone." << oendl; 452 owarn << "There was a problem setting the timezone." << oendl;
453 453
454 // convert UTC to local time (calling tzset internally) 454 // convert UTC to local time (calling tzset internally)
455 ev.setStart( TimeConversion::fromUTC( start_utc ) ); 455 ev.setStart( TimeConversion::fromUTC( start_utc ) );
456 ev.setEnd( TimeConversion::fromUTC( end_utc ) ); 456 ev.setEnd( TimeConversion::fromUTC( end_utc ) );
457 457
458 // we only have one type of sound at the moment... LOUD!!! 458 // we only have one type of sound at the moment... LOUD!!!
459 if ( comboSound->currentItem() != 0 ) 459 if ( comboSound->currentItem() != 0 )
460 st = Event::Loud; 460 st = Event::Loud;
461 else 461 else
462 st = Event::Silent; 462 st = Event::Silent;
463 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st ); 463 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st );
464 if ( rp.type != Event::NoRepeat ) 464 if ( rp.type != Event::NoRepeat )
465 ev.setRepeat( TRUE, rp ); 465 ev.setRepeat( TRUE, rp );
466 ev.setNotes( noteStr ); 466 ev.setNotes( noteStr );
467 467
468 //cout << "Start: " << comboStart->currentText() << endl; 468 //cout << "Start: " << comboStart->currentText() << endl;
469 469
470 return ev; 470 return ev;
471} 471}
472 472
473void DateEntry::setRepeatLabel() 473void DateEntry::setRepeatLabel()
474{ 474{
475 475
476 switch( rp.type ) { 476 switch( rp.type ) {
477 case Event::Daily: 477 case Event::Daily:
478 cmdRepeat->setText( tr("Daily...") ); 478 cmdRepeat->setText( tr("Daily...") );
479 break; 479 break;
480 case Event::Weekly: 480 case Event::Weekly:
481 cmdRepeat->setText( tr("Weekly...") ); 481 cmdRepeat->setText( tr("Weekly...") );
482 break; 482 break;
483 case Event::MonthlyDay: 483 case Event::MonthlyDay:
484 case Event::MonthlyDate: 484 case Event::MonthlyDate:
485 cmdRepeat->setText( tr("Monthly...") ); 485 cmdRepeat->setText( tr("Monthly...") );
486 break; 486 break;
487 case Event::Yearly: 487 case Event::Yearly:
488 cmdRepeat->setText( tr("Yearly...") ); 488 cmdRepeat->setText( tr("Yearly...") );
489 break; 489 break;
490 default: 490 default:
491 cmdRepeat->setText( tr("No Repeat...") ); 491 cmdRepeat->setText( tr("No Repeat...") );
492 } 492 }
493} 493}
494 494
495void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound ) 495void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound )
496{ 496{
497 checkAlarm->setChecked( alarmPreset ); 497 checkAlarm->setChecked( alarmPreset );
498 spinAlarm->setValue( presetTime ); 498 spinAlarm->setValue( presetTime );
499 if ( sound != Event::Silent ) 499 if ( sound != Event::Silent )
500 comboSound->setCurrentItem( 1 ); 500 comboSound->setCurrentItem( 1 );
501 else 501 else
502 comboSound->setCurrentItem( 0 ); 502 comboSound->setCurrentItem( 0 );
503} 503}
504 504
505void DateEntry::initCombos() 505void DateEntry::initCombos()
506{ 506{
507 /* 507 /*
508 comboStart->clear(); 508 comboStart->clear();
509 comboEnd->clear(); 509 comboEnd->clear();
510 if ( ampm ) { 510 if ( ampm ) {
511 for ( int i = 0; i < 24; i++ ) { 511 for ( int i = 0; i < 24; i++ ) {
512 if ( i == 0 ) { 512 if ( i == 0 ) {
513 comboStart->insertItem( "12:00 AM" ); 513 comboStart->insertItem( "12:00 AM" );
514 comboStart->insertItem( "12:30 AM" ); 514 comboStart->insertItem( "12:30 AM" );
515 comboEnd->insertItem( "12:00 AM" ); 515 comboEnd->insertItem( "12:00 AM" );
516 comboEnd->insertItem( "12:30 AM" ); 516 comboEnd->insertItem( "12:30 AM" );
517 } else if ( i == 12 ) { 517 } else if ( i == 12 ) {
518 comboStart->insertItem( "12:00 PM" ); 518 comboStart->insertItem( "12:00 PM" );
519 comboStart->insertItem( "12:30 PM" ); 519 comboStart->insertItem( "12:30 PM" );
520 comboEnd->insertItem( "12:00 PM" ); 520 comboEnd->insertItem( "12:00 PM" );
521 comboEnd->insertItem( "12:30 PM" ); 521 comboEnd->insertItem( "12:30 PM" );
522 } else if ( i > 12 ) { 522 } else if ( i > 12 ) {
523 comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" ); 523 comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" );
524 comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" ); 524 comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" );
525 comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" ); 525 comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" );
526 comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" ); 526 comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" );
527 } else { 527 } else {
528 comboStart->insertItem( QString::number( i) + ":00 AM" ); 528 comboStart->insertItem( QString::number( i) + ":00 AM" );
529 comboStart->insertItem( QString::number( i ) + ":30 AM" ); 529 comboStart->insertItem( QString::number( i ) + ":30 AM" );
530 comboEnd->insertItem( QString::number( i ) + ":00 AM" ); 530 comboEnd->insertItem( QString::number( i ) + ":00 AM" );
531 comboEnd->insertItem( QString::number( i ) + ":30 AM" ); 531 comboEnd->insertItem( QString::number( i ) + ":30 AM" );
532 } 532 }
533 } 533 }
534 } else { 534 } else {
535 for ( int i = 0; i < 24; i++ ) { 535 for ( int i = 0; i < 24; i++ ) {
536 if ( i < 10 ) { 536 if ( i < 10 ) {
537 comboStart->insertItem( QString("0") 537 comboStart->insertItem( QString("0")
538 + QString::number(i) + ":00" ); 538 + QString::number(i) + ":00" );
539 comboStart->insertItem( QString("0") 539 comboStart->insertItem( QString("0")
540 + QString::number(i) + ":30" ); 540 + QString::number(i) + ":30" );
541 comboEnd->insertItem( QString("0") 541 comboEnd->insertItem( QString("0")
542 + QString::number(i) + ":00" ); 542 + QString::number(i) + ":00" );
543 comboEnd->insertItem( QString("0") 543 comboEnd->insertItem( QString("0")
544 + QString::number(i) + ":30" ); 544 + QString::number(i) + ":30" );
545 } else { 545 } else {
546 comboStart->insertItem( QString::number(i) + ":00" ); 546 comboStart->insertItem( QString::number(i) + ":00" );
547 comboStart->insertItem( QString::number(i) + ":30" ); 547 comboStart->insertItem( QString::number(i) + ":30" );
548 comboEnd->insertItem( QString::number(i) + ":00" ); 548 comboEnd->insertItem( QString::number(i) + ":00" );
549 comboEnd->insertItem( QString::number(i) + ":30" ); 549 comboEnd->insertItem( QString::number(i) + ":30" );
550 } 550 }
551 } 551 }
552 } 552 }
553 */ 553 */
554} 554}
555 555
556void DateEntry::slotChangeClock( bool whichClock ) 556void DateEntry::slotChangeClock( bool whichClock )
557{ 557{
558 ampm = whichClock; 558 ampm = whichClock;
559 initCombos(); 559 initCombos();
560 setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) ); 560 setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) );
561} 561}
562 562