summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 7dd93a6..e10842a 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,734 +1,753 @@
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 <qpe/datebookmonth.h> 32#include <qpe/datebookmonth.h>
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qpe/qpedebug.h> 35#include <qpe/qpedebug.h>
36#include <qpe/event.h> 36#include <qpe/event.h>
37#include <qpe/finddialog.h> 37#include <qpe/finddialog.h>
38#include <qpe/ir.h> 38#include <qpe/ir.h>
39#include <qpe/qpemenubar.h> 39#include <qpe/qpemenubar.h>
40#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42#include <qpe/sound.h> 42#include <qpe/sound.h>
43#include <qpe/timestring.h> 43#include <qpe/timestring.h>
44#include <qpe/qpetoolbar.h> 44#include <qpe/qpetoolbar.h>
45#include <qpe/tzselect.h> 45#include <qpe/tzselect.h>
46#include <qpe/xmlreader.h> 46#include <qpe/xmlreader.h>
47 47
48#include <qaction.h> 48#include <qaction.h>
49#include <qcopchannel_qws.h> 49#include <qcopchannel_qws.h>
50#include <qdatetime.h> 50#include <qdatetime.h>
51#include <qdialog.h> 51#include <qdialog.h>
52#include <qfile.h> 52#include <qfile.h>
53#include <qlabel.h> 53#include <qlabel.h>
54#include <qlayout.h> 54#include <qlayout.h>
55#include <qmessagebox.h> 55#include <qmessagebox.h>
56#include <qpopupmenu.h> 56#include <qpopupmenu.h>
57#include <qpushbutton.h> 57#include <qpushbutton.h>
58#include <qregexp.h> 58#include <qregexp.h>
59#include <qtextcodec.h> 59#include <qtextcodec.h>
60#include <qtextstream.h> 60#include <qtextstream.h>
61#include <qtimer.h>
61#include <qtl.h> 62#include <qtl.h>
62#include <qwidgetstack.h> 63#include <qwidgetstack.h>
63#include <qwindowsystem_qws.h> 64#include <qwindowsystem_qws.h>
64 65
65#include <sys/stat.h> 66#include <sys/stat.h>
66#include <sys/types.h> 67#include <sys/types.h>
67#include <fcntl.h> 68#include <fcntl.h>
68#include <unistd.h> 69#include <unistd.h>
69 70
70#include <stdlib.h> 71#include <stdlib.h>
71 72
72#define DAY 1 73#define DAY 1
73#define WEEK 2 74#define WEEK 2
74#define WEEKLST 4 75#define WEEKLST 4
75#define MONTH 3 76#define MONTH 3
76 77
77 78
78DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 79DateBook::DateBook( QWidget *parent, const char *, WFlags f )
79 : QMainWindow( parent, "datebook", f ), 80 : QMainWindow( parent, "datebook", f ),
80 aPreset( FALSE ), 81 aPreset( FALSE ),
81 presetTime( -1 ), 82 presetTime( -1 ),
82 startTime( 8 ), // an acceptable default 83 startTime( 8 ), // an acceptable default
83 rowStyle( 0 ), 84 rowStyle( 0 ),
84 bJumpToCurTime(FALSE), 85 bJumpToCurTime(FALSE),
85 syncing(FALSE), 86 syncing(FALSE),
86 inSearch(FALSE), 87 inSearch(FALSE),
87 alarmCounter(0) 88 alarmCounter(0)
88{ 89{
90 bool needEvilHack= false; // if we need an Evil Hack
89 QTime t; 91 QTime t;
90 t.start(); 92 t.start();
91 db = new DateBookDBHack; 93 db = new DateBookDBHack;
92 qDebug("loading db t=%d", t.elapsed() ); 94 qDebug("loading db t=%d", t.elapsed() );
93 loadSettings(); 95 loadSettings();
94 setCaption( tr("Calendar") ); 96 setCaption( tr("Calendar") );
95 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 97 setIcon( Resource::loadPixmap( "datebook_icon" ) );
96 98
97 setToolBarsMovable( FALSE ); 99 setToolBarsMovable( FALSE );
98 100
99 views = new QWidgetStack( this ); 101 views = new QWidgetStack( this );
100 setCentralWidget( views ); 102 setCentralWidget( views );
101 103
102 dayView = 0; 104 dayView = 0;
103 weekView = 0; 105 weekView = 0;
104 weekLstView = 0; 106 weekLstView = 0;
105 monthView = 0; 107 monthView = 0;
106 108
107 QPEToolBar *bar = new QPEToolBar( this ); 109 QPEToolBar *bar = new QPEToolBar( this );
108 bar->setHorizontalStretchable( TRUE ); 110 bar->setHorizontalStretchable( TRUE );
109 111
110 QPEMenuBar *mb = new QPEMenuBar( bar ); 112 QPEMenuBar *mb = new QPEMenuBar( bar );
111 mb->setMargin( 0 ); 113 mb->setMargin( 0 );
112 114
113 QPEToolBar *sub_bar = new QPEToolBar(this); 115 QPEToolBar *sub_bar = new QPEToolBar(this);
114 116
115 QPopupMenu *view = new QPopupMenu( this ); 117 QPopupMenu *view = new QPopupMenu( this );
116 QPopupMenu *settings = new QPopupMenu( this ); 118 QPopupMenu *settings = new QPopupMenu( this );
117 119
118 mb->insertItem( tr( "View" ), view ); 120 mb->insertItem( tr( "View" ), view );
119 mb->insertItem( tr( "Settings" ), settings ); 121 mb->insertItem( tr( "Settings" ), settings );
120 122
121 QActionGroup *g = new QActionGroup( this ); 123 QActionGroup *g = new QActionGroup( this );
122 g->setExclusive( TRUE ); 124 g->setExclusive( TRUE );
123 125
124 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 126 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
125 QString::null, 0, this, 0 ); 127 QString::null, 0, this, 0 );
126 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 128 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
127 a->addTo( sub_bar ); 129 a->addTo( sub_bar );
128 130
129 a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 ); 131 a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 );
130 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 132 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
131 a->addTo( sub_bar ); 133 a->addTo( sub_bar );
132 a->addTo( view ); 134 a->addTo( view );
133 135
134 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 136 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
135 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 137 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
136 a->addTo( sub_bar ); 138 a->addTo( sub_bar );
137 a->addTo( view ); 139 a->addTo( view );
138 a->setToggleAction( TRUE ); 140 a->setToggleAction( TRUE );
139 a->setOn( TRUE ); 141 a->setOn( TRUE );
140 dayAction = a; 142 dayAction = a;
141 143
142 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 144 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
143 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 145 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
144 a->addTo( sub_bar ); 146 a->addTo( sub_bar );
145 a->addTo( view ); 147 a->addTo( view );
146 a->setToggleAction( TRUE ); 148 a->setToggleAction( TRUE );
147 weekAction = a; 149 weekAction = a;
148 150
149 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 ); 151 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 );
150 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 152 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
151 a->addTo( sub_bar ); 153 a->addTo( sub_bar );
152 a->addTo( view ); 154 a->addTo( view );
153 a->setToggleAction( TRUE ); 155 a->setToggleAction( TRUE );
154 weekLstAction = a; 156 weekLstAction = a;
155 157
156 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 158 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
157 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 159 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
158 a->addTo( sub_bar ); 160 a->addTo( sub_bar );
159 a->addTo( view ); 161 a->addTo( view );
160 a->setToggleAction( TRUE ); 162 a->setToggleAction( TRUE );
161 monthAction = a; 163 monthAction = a;
162 164
163 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); 165 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 );
164 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 166 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
165 a->addTo( sub_bar ); 167 a->addTo( sub_bar );
166 168
167 a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); 169 a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 );
168 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 170 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
169 a->addTo( settings ); 171 a->addTo( settings );
170 172
171 QPopupMenu *default_view = new QPopupMenu(this); 173 QPopupMenu *default_view = new QPopupMenu(this);
172 settings->insertItem( tr( "Default View" ),default_view ); 174 settings->insertItem( tr( "Default View" ),default_view );
173 default_view->setCheckable(TRUE); 175 default_view->setCheckable(TRUE);
174 176
175 Config config("DateBook"); 177 Config config("DateBook");
176 config.setGroup("Main"); 178 config.setGroup("Main");
177 int current=config.readNumEntry("defaultview", DAY); 179 int current=config.readNumEntry("defaultview", DAY);
178 180
179 QActionGroup *ag = new QActionGroup(this); 181 QActionGroup *ag = new QActionGroup(this);
180 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); 182 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true );
181 if (current==DAY) a->setOn(true), viewDay(); 183 if (current==DAY) a->setOn(true), viewDay();
182 ag->insert(a); 184 ag->insert(a);
183 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); 185 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true );
184 if (current==WEEK) a->setOn(true), viewWeek(); 186 if (current==WEEK) a->setOn(true), /*viewWeek(),*/ needEvilHack = true;
185 ag->insert(a); 187 ag->insert(a);
186 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); 188 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true );
187 if (current==WEEKLST) a->setOn(true), viewWeekLst(); 189 if (current==WEEKLST) a->setOn(true), viewWeekLst();
188 ag->insert(a); 190 ag->insert(a);
189 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); 191 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true );
190 if (current==MONTH) a->setOn(true), viewMonth(); 192 if (current==MONTH) a->setOn(true), viewMonth();
191 ag->insert(a); 193 ag->insert(a);
192 194
193 ag->addTo(default_view); 195 ag->addTo(default_view);
194 connect(ag, SIGNAL( selected ( QAction * ) ), 196 connect(ag, SIGNAL( selected ( QAction * ) ),
195 this, SLOT( newDefaultView(QAction *) ) 197 this, SLOT( newDefaultView(QAction *) )
196 ); 198 );
197 199
198 connect( qApp, SIGNAL(clockChanged(bool)), 200 connect( qApp, SIGNAL(clockChanged(bool)),
199 this, SLOT(changeClock(bool)) ); 201 this, SLOT(changeClock(bool)) );
200 connect( qApp, SIGNAL(weekChanged(bool)), 202 connect( qApp, SIGNAL(weekChanged(bool)),
201 this, SLOT(changeWeek(bool)) ); 203 this, SLOT(changeWeek(bool)) );
202 204
203#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 205#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
204 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 206 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
205 this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 207 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
206#endif 208#endif
207 209
208 // listen on QPE/System 210 // listen on QPE/System
209#if defined(Q_WS_QWS) 211#if defined(Q_WS_QWS)
210#if !defined(QT_NO_COP) 212#if !defined(QT_NO_COP)
211 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 213 QCopChannel *channel = new QCopChannel( "QPE/System", this );
212 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 214 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
213 this, SLOT(receive(const QCString&, const QByteArray&)) ); 215 this, SLOT(receive(const QCString&, const QByteArray&)) );
214 channel = new QCopChannel( "QPE/Datebook", this ); 216 channel = new QCopChannel( "QPE/Datebook", this );
215 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 217 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
216 this, SLOT(receive(const QCString&, const QByteArray&)) ); 218 this, SLOT(receive(const QCString&, const QByteArray&)) );
217 qDebug("olle\n"); 219 qDebug("olle\n");
218#endif 220#endif
219#endif 221#endif
220 222
221 qDebug("done t=%d", t.elapsed() ); 223 qDebug("done t=%d", t.elapsed() );
222 224
225 /*
226 * Here is a problem description:
227 * When Weekview is the default view
228 * a DateBookWeekView get's created
229 * redraw() get's called. So what?
230 * Remember that we're still in the c'tor
231 * and no final layout has happened? Ok
232 * now all Events get arranged. Their x
233 * position get's determined by a QHeader
234 * position. But the QHeader isn't layouted or
235 * at the right position. redraw() is a slot
236 * so we'll call it then via a singleShot
237 * from view()
238 */
239 if( needEvilHack ){
240 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
241 }
223} 242}
224 243
225void DateBook::receive( const QCString &msg, const QByteArray &data ) 244void DateBook::receive( const QCString &msg, const QByteArray &data )
226{ 245{
227 QDataStream stream( data, IO_ReadOnly ); 246 QDataStream stream( data, IO_ReadOnly );
228 if ( msg == "timeChange(QString)" ) { 247 if ( msg == "timeChange(QString)" ) {
229 // update active view! 248 // update active view!
230 if ( dayAction->isOn() ) 249 if ( dayAction->isOn() )
231 viewDay(); 250 viewDay();
232 else if ( weekAction->isOn() ) 251 else if ( weekAction->isOn() )
233 viewWeek(); 252 viewWeek();
234 else if ( monthAction->isOn() ) 253 else if ( monthAction->isOn() )
235 viewMonth(); 254 viewMonth();
236 } 255 }
237 else if (msg == "editEvent(int)") { 256 else if (msg == "editEvent(int)") {
238 int uid; 257 int uid;
239 stream >> uid; 258 stream >> uid;
240 Event e=db->eventByUID(uid); 259 Event e=db->eventByUID(uid);
241 editEvent(e); 260 editEvent(e);
242 } 261 }
243} 262}
244 263
245DateBook::~DateBook() 264DateBook::~DateBook()
246{ 265{
247} 266}
248 267
249void DateBook::slotSettings() 268void DateBook::slotSettings()
250{ 269{
251 DateBookSettings frmSettings( ampm, this ); 270 DateBookSettings frmSettings( ampm, this );
252 frmSettings.setStartTime( startTime ); 271 frmSettings.setStartTime( startTime );
253 frmSettings.setAlarmPreset( aPreset, presetTime ); 272 frmSettings.setAlarmPreset( aPreset, presetTime );
254 frmSettings.setJumpToCurTime( bJumpToCurTime ); 273 frmSettings.setJumpToCurTime( bJumpToCurTime );
255 frmSettings.setRowStyle( rowStyle ); 274 frmSettings.setRowStyle( rowStyle );
256#if defined (Q_WS_QWS) || defined(_WS_QWS_) 275#if defined (Q_WS_QWS) || defined(_WS_QWS_)
257 frmSettings.showMaximized(); 276 frmSettings.showMaximized();
258#endif 277#endif
259 278
260 if ( frmSettings.exec() ) { 279 if ( frmSettings.exec() ) {
261 aPreset = frmSettings.alarmPreset(); 280 aPreset = frmSettings.alarmPreset();
262 presetTime = frmSettings.presetTime(); 281 presetTime = frmSettings.presetTime();
263 startTime = frmSettings.startTime(); 282 startTime = frmSettings.startTime();
264 bJumpToCurTime = frmSettings.jumpToCurTime(); 283 bJumpToCurTime = frmSettings.jumpToCurTime();
265 rowStyle = frmSettings.rowStyle(); 284 rowStyle = frmSettings.rowStyle();
266 if ( dayView ) 285 if ( dayView )
267 dayView->setStartViewTime( startTime ); 286 dayView->setStartViewTime( startTime );
268 dayView->setJumpToCurTime( bJumpToCurTime ); 287 dayView->setJumpToCurTime( bJumpToCurTime );
269 dayView->setRowStyle( rowStyle ); 288 dayView->setRowStyle( rowStyle );
270 if ( weekView ) 289 if ( weekView )
271 weekView->setStartViewTime( startTime ); 290 weekView->setStartViewTime( startTime );
272 saveSettings(); 291 saveSettings();
273 292
274 // make the change obvious 293 // make the change obvious
275 if ( views->visibleWidget() ) { 294 if ( views->visibleWidget() ) {
276 if ( views->visibleWidget() == dayView ) 295 if ( views->visibleWidget() == dayView )
277 dayView->redraw(); 296 dayView->redraw();
278 else if ( views->visibleWidget() == weekView ) 297 else if ( views->visibleWidget() == weekView )
279 weekView->redraw(); 298 weekView->redraw();
280 } 299 }
281 } 300 }
282} 301}
283 302
284void DateBook::fileNew() 303void DateBook::fileNew()
285{ 304{
286 slotNewEventFromKey(""); 305 slotNewEventFromKey("");
287} 306}
288 307
289QString DateBook::checkEvent(const Event &e) 308QString DateBook::checkEvent(const Event &e)
290{ 309{
291 /* check if overlaps with itself */ 310 /* check if overlaps with itself */
292 bool checkFailed = FALSE; 311 bool checkFailed = FALSE;
293 312
294 /* check the next 12 repeats. should catch most problems */ 313 /* check the next 12 repeats. should catch most problems */
295 QDate current_date = e.start().date(); 314 QDate current_date = e.start().date();
296 Event previous = e; 315 Event previous = e;
297 for(int i = 0; i < 12; i++) 316 for(int i = 0; i < 12; i++)
298 { 317 {
299 QDateTime next; 318 QDateTime next;
300 if (!nextOccurance(previous, current_date.addDays(1), next)) { 319 if (!nextOccurance(previous, current_date.addDays(1), next)) {
301 break; // no more repeats 320 break; // no more repeats
302 } 321 }
303 if(next < previous.end()) { 322 if(next < previous.end()) {
304 checkFailed = TRUE; 323 checkFailed = TRUE;
305 break; 324 break;
306 } 325 }
307 current_date = next.date(); 326 current_date = next.date();
308 } 327 }
309 328
310 if(checkFailed) 329 if(checkFailed)
311 return tr("Event duration is potentially longer\n" 330 return tr("Event duration is potentially longer\n"
312 "than interval between repeats."); 331 "than interval between repeats.");
313 332
314 return QString::null; 333 return QString::null;
315} 334}
316 335
317QDate DateBook::currentDate() 336QDate DateBook::currentDate()
318{ 337{
319 QDate d = QDate::currentDate(); 338 QDate d = QDate::currentDate();
320 339
321 if ( dayView && views->visibleWidget() == dayView ) { 340 if ( dayView && views->visibleWidget() == dayView ) {
322 d = dayView->date(); 341 d = dayView->date();
323 } else if ( weekView && views->visibleWidget() == weekView ) { 342 } else if ( weekView && views->visibleWidget() == weekView ) {
324 d = weekView->date(); 343 d = weekView->date();
325 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 344 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
326 d = weekLstView->date(); 345 d = weekLstView->date();
327 } else if ( monthView && views->visibleWidget() == monthView ) { 346 } else if ( monthView && views->visibleWidget() == monthView ) {
328 d = monthView->selectedDate(); 347 d = monthView->selectedDate();
329 } 348 }
330 349
331 return d; 350 return d;
332} 351}
333 352
334void DateBook::view(int v, const QDate &d) { 353void DateBook::view(int v, const QDate &d) {
335 if (v==DAY) { 354 if (v==DAY) {
336 initDay(); 355 initDay();
337 dayAction->setOn( TRUE ); 356 dayAction->setOn( TRUE );
338 dayView->setDate( d ); 357 dayView->setDate( d );
339 views->raiseWidget( dayView ); 358 views->raiseWidget( dayView );
340 dayView->redraw(); 359 dayView->redraw();
341 } else if (v==WEEK) { 360 } else if (v==WEEK) {
342 initWeek(); 361 initWeek();
343 weekAction->setOn( TRUE ); 362 weekAction->setOn( TRUE );
344 weekView->setDate( d ); 363 weekView->setDate( d );
345 views->raiseWidget( weekView ); 364 views->raiseWidget( weekView );
346 weekView->redraw(); 365 weekView->redraw();
347 } else if (v==WEEKLST) { 366 } else if (v==WEEKLST) {
348 initWeekLst(); 367 initWeekLst();
349 weekLstAction->setOn( TRUE ); 368 weekLstAction->setOn( TRUE );
350 weekLstView->setDate(d); 369 weekLstView->setDate(d);
351 views->raiseWidget( weekLstView ); 370 views->raiseWidget( weekLstView );
352 weekLstView->redraw(); 371 weekLstView->redraw();
353 } else if (v==MONTH) { 372 } else if (v==MONTH) {
354 initMonth(); 373 initMonth();
355 monthAction->setOn( TRUE ); 374 monthAction->setOn( TRUE );
356 monthView->setDate( d.year(), d.month(), d.day() ); 375 monthView->setDate( d.year(), d.month(), d.day() );
357 views->raiseWidget( monthView ); 376 views->raiseWidget( monthView );
358 monthView->redraw(); 377 monthView->redraw();
359 } 378 }
360} 379}
361 380
362void DateBook::viewDefault(const QDate &d) { 381void DateBook::viewDefault(const QDate &d) {
363 Config config("DateBook"); 382 Config config("DateBook");
364 config.setGroup("Main"); 383 config.setGroup("Main");
365 int current=config.readNumEntry("defaultview", DAY); 384 int current=config.readNumEntry("defaultview", DAY);
366 385
367 view(current,d); 386 view(current,d);
368} 387}
369 388
370void DateBook::viewDay() { 389void DateBook::viewDay() {
371 view(DAY,currentDate()); 390 view(DAY,currentDate());
372} 391}
373 392
374void DateBook::viewWeek() { 393void DateBook::viewWeek() {
375 view(WEEK,currentDate()); 394 view(WEEK,currentDate());
376} 395}
377 396
378void DateBook::viewWeekLst() { 397void DateBook::viewWeekLst() {
379 view(WEEKLST,currentDate()); 398 view(WEEKLST,currentDate());
380} 399}
381 400
382void DateBook::viewMonth() { 401void DateBook::viewMonth() {
383 view(MONTH,currentDate()); 402 view(MONTH,currentDate());
384} 403}
385 404
386void DateBook::editEvent( const Event &e ) 405void DateBook::editEvent( const Event &e )
387{ 406{
388 if (syncing) { 407 if (syncing) {
389 QMessageBox::warning( this, tr("Calendar"), 408 QMessageBox::warning( this, tr("Calendar"),
390 tr( "Can not edit data, currently syncing") ); 409 tr( "Can not edit data, currently syncing") );
391 return; 410 return;
392 } 411 }
393 412
394 // workaround added for text input. 413 // workaround added for text input.
395 QDialog editDlg( this, 0, TRUE ); 414 QDialog editDlg( this, 0, TRUE );
396 DateEntry *entry; 415 DateEntry *entry;
397 editDlg.setCaption( tr("Edit Event") ); 416 editDlg.setCaption( tr("Edit Event") );
398 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 417 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
399 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 418 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
400 sv->setResizePolicy( QScrollView::AutoOneFit ); 419 sv->setResizePolicy( QScrollView::AutoOneFit );
401 // KLUDGE!!! 420 // KLUDGE!!!
402 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 421 sv->setHScrollBarMode( QScrollView::AlwaysOff );
403 vb->addWidget( sv ); 422 vb->addWidget( sv );
404 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 423 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
405 entry->timezone->setEnabled( FALSE ); 424 entry->timezone->setEnabled( FALSE );
406 sv->addChild( entry ); 425 sv->addChild( entry );
407 426
408#if defined(Q_WS_QWS) || defined(_WS_QWS_) 427#if defined(Q_WS_QWS) || defined(_WS_QWS_)
409 editDlg.showMaximized(); 428 editDlg.showMaximized();
410#endif 429#endif
411 while (editDlg.exec() ) { 430 while (editDlg.exec() ) {
412 Event newEv = entry->event(); 431 Event newEv = entry->event();
413 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 432 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
414 QString error = checkEvent(newEv); 433 QString error = checkEvent(newEv);
415 if (!error.isNull()) { 434 if (!error.isNull()) {
416 if (QMessageBox::warning(this, "error box", 435 if (QMessageBox::warning(this, "error box",
417 error, "Fix it", "Continue", 436 error, "Fix it", "Continue",
418 0, 0, 1) == 0) 437 0, 0, 1) == 0)
419 continue; 438 continue;
420 } 439 }
421 db->editEvent(e, newEv); 440 db->editEvent(e, newEv);
422 emit newEvent(); 441 emit newEvent();
423 break; 442 break;
424 } 443 }
425} 444}
426 445
427void DateBook::removeEvent( const Event &e ) 446void DateBook::removeEvent( const Event &e )
428{ 447{
429 if (syncing) { 448 if (syncing) {
430 QMessageBox::warning( this, tr("Calendar"), 449 QMessageBox::warning( this, tr("Calendar"),
431 tr( "Can not edit data, currently syncing") ); 450 tr( "Can not edit data, currently syncing") );
432 return; 451 return;
433 } 452 }
434 453
435 QString strName = e.description(); 454 QString strName = e.description();
436 455
437 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 456 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
438 return; 457 return;
439 458
440 db->removeEvent( e ); 459 db->removeEvent( e );
441 if ( views->visibleWidget() == dayView && dayView ) 460 if ( views->visibleWidget() == dayView && dayView )
442 dayView->redraw(); 461 dayView->redraw();
443} 462}
444 463
445void DateBook::addEvent( const Event &e ) 464void DateBook::addEvent( const Event &e )
446{ 465{
447 QDate d = e.start().date(); 466 QDate d = e.start().date();
448 initDay(); 467 initDay();
449 dayView->setDate( d ); 468 dayView->setDate( d );
450} 469}
451 470
452void DateBook::showDay( int year, int month, int day ) 471void DateBook::showDay( int year, int month, int day )
453{ 472{
454 QDate d(year, month, day); 473 QDate d(year, month, day);
455 view(DAY,d); 474 view(DAY,d);
456} 475}
457 476
458void DateBook::initDay() 477void DateBook::initDay()
459{ 478{
460 if ( !dayView ) { 479 if ( !dayView ) {
461 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 480 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
462 views->addWidget( dayView, DAY ); 481 views->addWidget( dayView, DAY );
463 dayView->setStartViewTime( startTime ); 482 dayView->setStartViewTime( startTime );
464 dayView->setJumpToCurTime( bJumpToCurTime ); 483 dayView->setJumpToCurTime( bJumpToCurTime );
465 dayView->setRowStyle( rowStyle ); 484 dayView->setRowStyle( rowStyle );
466 connect( this, SIGNAL( newEvent() ), 485 connect( this, SIGNAL( newEvent() ),
467 dayView, SLOT( redraw() ) ); 486 dayView, SLOT( redraw() ) );
468 connect( dayView, SIGNAL( newEvent() ), 487 connect( dayView, SIGNAL( newEvent() ),
469 this, SLOT( fileNew() ) ); 488 this, SLOT( fileNew() ) );
470 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 489 connect( dayView, SIGNAL( removeEvent( const Event & ) ),
471 this, SLOT( removeEvent( const Event & ) ) ); 490 this, SLOT( removeEvent( const Event & ) ) );
472 connect( dayView, SIGNAL( editEvent( const Event & ) ), 491 connect( dayView, SIGNAL( editEvent( const Event & ) ),
473 this, SLOT( editEvent( const Event & ) ) ); 492 this, SLOT( editEvent( const Event & ) ) );
474 connect( dayView, SIGNAL( beamEvent( const Event & ) ), 493 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
475 this, SLOT( beamEvent( const Event & ) ) ); 494 this, SLOT( beamEvent( const Event & ) ) );
476 connect( dayView, SIGNAL(sigNewEvent(const QString &)), 495 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
477 this, SLOT(slotNewEventFromKey(const QString &)) ); 496 this, SLOT(slotNewEventFromKey(const QString &)) );
478 } 497 }
479} 498}
480 499
481void DateBook::initWeek() 500void DateBook::initWeek()
482{ 501{
483 if ( !weekView ) { 502 if ( !weekView ) {
484 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 503 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
485 weekView->setStartViewTime( startTime ); 504 weekView->setStartViewTime( startTime );
486 views->addWidget( weekView, WEEK ); 505 views->addWidget( weekView, WEEK );
487 connect( weekView, SIGNAL( showDate( int, int, int ) ), 506 connect( weekView, SIGNAL( showDate( int, int, int ) ),
488 this, SLOT( showDay( int, int, int ) ) ); 507 this, SLOT( showDay( int, int, int ) ) );
489 connect( this, SIGNAL( newEvent() ), 508 connect( this, SIGNAL( newEvent() ),
490 weekView, SLOT( redraw() ) ); 509 weekView, SLOT( redraw() ) );
491 } 510 }
492 //But also get it right: the year that we display can be different 511 //But also get it right: the year that we display can be different
493 //from the year of the current date. So, first find the year 512 //from the year of the current date. So, first find the year
494 //number of the current week. 513 //number of the current week.
495 514
496 int yearNumber, totWeeks; 515 int yearNumber, totWeeks;
497 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 516 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
498 517
499 QDate d = QDate( yearNumber, 12, 31 ); 518 QDate d = QDate( yearNumber, 12, 31 );
500 calcWeek( d, totWeeks, yearNumber, onMonday ); 519 calcWeek( d, totWeeks, yearNumber, onMonday );
501 520
502 while ( totWeeks == 1 ) { 521 while ( totWeeks == 1 ) {
503 d = d.addDays( -1 ); 522 d = d.addDays( -1 );
504 calcWeek( d, totWeeks, yearNumber, onMonday ); 523 calcWeek( d, totWeeks, yearNumber, onMonday );
505 } 524 }
506 if ( totWeeks != weekView->totalWeeks() ) 525 if ( totWeeks != weekView->totalWeeks() )
507 weekView->setTotalWeeks( totWeeks ); 526 weekView->setTotalWeeks( totWeeks );
508} 527}
509void DateBook::initWeekLst() { 528void DateBook::initWeekLst() {
510 if ( !weekLstView ) { 529 if ( !weekLstView ) {
511 weekLstView = new DateBookWeekLst( ampm, onMonday, db, 530 weekLstView = new DateBookWeekLst( ampm, onMonday, db,
512 views, "weeklst view" ); 531 views, "weeklst view" );
513 views->addWidget( weekLstView, WEEKLST ); 532 views->addWidget( weekLstView, WEEKLST );
514 533
515 //weekLstView->setStartViewTime( startTime ); 534 //weekLstView->setStartViewTime( startTime );
516 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), 535 connect( weekLstView, SIGNAL( showDate( int, int, int ) ),
517 this, SLOT( showDay( int, int, int ) ) ); 536 this, SLOT( showDay( int, int, int ) ) );
518 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, 537 connect( weekLstView, SIGNAL( addEvent( const QDateTime &,
519 const QDateTime &, 538 const QDateTime &,
520 const QString & ) ), 539 const QString & ) ),
521 this, SLOT( slotNewEntry( const QDateTime &, 540 this, SLOT( slotNewEntry( const QDateTime &,
522 const QDateTime &, 541 const QDateTime &,
523 const QString & ) ) ); 542 const QString & ) ) );
524 connect( this, SIGNAL( newEvent() ), 543 connect( this, SIGNAL( newEvent() ),
525 weekLstView, SLOT( redraw() ) ); 544 weekLstView, SLOT( redraw() ) );
526 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), 545 connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
527 this, SLOT( editEvent( const Event & ) ) ); 546 this, SLOT( editEvent( const Event & ) ) );
528 } 547 }
529} 548}
530 549
531 550
532void DateBook::initMonth() 551void DateBook::initMonth()
533{ 552{
534 if ( !monthView ) { 553 if ( !monthView ) {
535 monthView = new DateBookMonth( views, "month view", FALSE, db ); 554 monthView = new DateBookMonth( views, "month view", FALSE, db );
536 views->addWidget( monthView, MONTH ); 555 views->addWidget( monthView, MONTH );
537 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), 556 connect( monthView, SIGNAL( dateClicked( int, int, int ) ),
538 this, SLOT( showDay( int, int, int ) ) ); 557 this, SLOT( showDay( int, int, int ) ) );
539 connect( this, SIGNAL( newEvent() ), 558 connect( this, SIGNAL( newEvent() ),
540 monthView, SLOT( redraw() ) ); 559 monthView, SLOT( redraw() ) );
541 qApp->processEvents(); 560 qApp->processEvents();
542 } 561 }
543} 562}
544 563
545void DateBook::loadSettings() 564void DateBook::loadSettings()
546{ 565{
547 { 566 {
548 Config config( "qpe" ); 567 Config config( "qpe" );
549 config.setGroup("Time"); 568 config.setGroup("Time");
550 ampm = config.readBoolEntry( "AMPM", TRUE ); 569 ampm = config.readBoolEntry( "AMPM", TRUE );
551 onMonday = config.readBoolEntry( "MONDAY" ); 570 onMonday = config.readBoolEntry( "MONDAY" );
552 } 571 }
553 572
554 { 573 {
555 Config config("DateBook"); 574 Config config("DateBook");
556 config.setGroup("Main"); 575 config.setGroup("Main");
557 startTime = config.readNumEntry("startviewtime", 8); 576 startTime = config.readNumEntry("startviewtime", 8);
558 aPreset = config.readBoolEntry("alarmpreset"); 577 aPreset = config.readBoolEntry("alarmpreset");
559 presetTime = config.readNumEntry("presettime"); 578 presetTime = config.readNumEntry("presettime");
560 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 579 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
561 rowStyle = config.readNumEntry("rowstyle"); 580 rowStyle = config.readNumEntry("rowstyle");
562 } 581 }
563} 582}
564 583
565void DateBook::saveSettings() 584void DateBook::saveSettings()
566{ 585{
567 Config config( "qpe" ); 586 Config config( "qpe" );
568 Config configDB( "DateBook" ); 587 Config configDB( "DateBook" );
569 configDB.setGroup( "Main" ); 588 configDB.setGroup( "Main" );
570 configDB.writeEntry("startviewtime",startTime); 589 configDB.writeEntry("startviewtime",startTime);
571 configDB.writeEntry("alarmpreset",aPreset); 590 configDB.writeEntry("alarmpreset",aPreset);
572 configDB.writeEntry("presettime",presetTime); 591 configDB.writeEntry("presettime",presetTime);
573 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 592 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
574 configDB.writeEntry("rowstyle", rowStyle); 593 configDB.writeEntry("rowstyle", rowStyle);
575} 594}
576 595
577void DateBook::newDefaultView(QAction *a) { 596void DateBook::newDefaultView(QAction *a) {
578 int val=DAY; 597 int val=DAY;
579 if (a->text() == "Day") val=DAY; 598 if (a->text() == "Day") val=DAY;
580 if (a->text() == "Week") val=WEEK; 599 if (a->text() == "Week") val=WEEK;
581 if (a->text() == "WeekLst") val=WEEKLST; 600 if (a->text() == "WeekLst") val=WEEKLST;
582 if (a->text() == "Month") val=MONTH; 601 if (a->text() == "Month") val=MONTH;
583 602
584 Config configDB( "DateBook" ); 603 Config configDB( "DateBook" );
585 configDB.setGroup( "Main" ); 604 configDB.setGroup( "Main" );
586 configDB.writeEntry("defaultview",val); 605 configDB.writeEntry("defaultview",val);
587} 606}
588 607
589void DateBook::appMessage(const QCString& msg, const QByteArray& data) 608void DateBook::appMessage(const QCString& msg, const QByteArray& data)
590{ 609{
591 bool needShow = FALSE; 610 bool needShow = FALSE;
592 if ( msg == "alarm(QDateTime,int)" ) { 611 if ( msg == "alarm(QDateTime,int)" ) {
593 QDataStream ds(data,IO_ReadOnly); 612 QDataStream ds(data,IO_ReadOnly);
594 QDateTime when; int warn; 613 QDateTime when; int warn;
595 ds >> when >> warn; 614 ds >> when >> warn;
596 615
597 // check to make it's okay to continue, 616 // check to make it's okay to continue,
598 // this is the case that the time was set ahead, and 617 // this is the case that the time was set ahead, and
599 // we are forced given a stale alarm... 618 // we are forced given a stale alarm...
600 QDateTime current = QDateTime::currentDateTime(); 619 QDateTime current = QDateTime::currentDateTime();
601 if ( current.time().hour() != when.time().hour() 620 if ( current.time().hour() != when.time().hour()
602 && current.time().minute() != when.time().minute() ) 621 && current.time().minute() != when.time().minute() )
603 return; 622 return;
604 623
605 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 624 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
606 if ( list.count() > 0 ) { 625 if ( list.count() > 0 ) {
607 QString msg; 626 QString msg;
608 bool bSound = FALSE; 627 bool bSound = FALSE;
609 int stopTimer = 0; 628 int stopTimer = 0;
610 bool found = FALSE; 629 bool found = FALSE;
611 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); 630 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin();
612 it!=list.end(); ++it ) { 631 it!=list.end(); ++it ) {
613 if ( (*it).event().hasAlarm() ) { 632 if ( (*it).event().hasAlarm() ) {
614 found = TRUE; 633 found = TRUE;
615 msg += "<CENTER><B>" + (*it).description() + "</B>" 634 msg += "<CENTER><B>" + (*it).description() + "</B>"
616 + "<BR>" + (*it).location() + "<BR>" 635 + "<BR>" + (*it).location() + "<BR>"
617 + TimeString::dateString((*it).event().start(),ampm) 636 + TimeString::dateString((*it).event().start(),ampm)
618 + (warn 637 + (warn
619 ? tr(" (in " + QString::number(warn) 638 ? tr(" (in " + QString::number(warn)
620 + tr(" minutes)")) 639 + tr(" minutes)"))
621 : QString("")) 640 : QString(""))
622 + "<BR>" 641 + "<BR>"
623 + (*it).notes() + "</CENTER>"; 642 + (*it).notes() + "</CENTER>";
624 if ( (*it).event().alarmSound() != Event::Silent ) { 643 if ( (*it).event().alarmSound() != Event::Silent ) {
625 bSound = TRUE; 644 bSound = TRUE;
626 } 645 }
627 } 646 }
628 } 647 }
629 if ( found ) { 648 if ( found ) {
630 if ( bSound ) { 649 if ( bSound ) {
631 Sound::soundAlarm(); 650 Sound::soundAlarm();
632 alarmCounter = 0; 651 alarmCounter = 0;
633 stopTimer = startTimer( 5000 ); 652 stopTimer = startTimer( 5000 );
634 } 653 }
635 654
636 QDialog dlg( this, 0, TRUE ); 655 QDialog dlg( this, 0, TRUE );
637 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 656 QVBoxLayout *vb = new QVBoxLayout( &dlg );
638 QScrollView *view = new QScrollView( &dlg, "scrollView"); 657 QScrollView *view = new QScrollView( &dlg, "scrollView");
639 view->setResizePolicy( QScrollView::AutoOneFit ); 658 view->setResizePolicy( QScrollView::AutoOneFit );
640 vb->addWidget( view ); 659 vb->addWidget( view );
641 QLabel *lblMsg = new QLabel( msg, &dlg ); 660 QLabel *lblMsg = new QLabel( msg, &dlg );
642 view->addChild( lblMsg ); 661 view->addChild( lblMsg );
643 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 662 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
644 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 663 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
645 vb->addWidget( cmdOk ); 664 vb->addWidget( cmdOk );
646 665
647#if defined(Q_WS_QWS) || defined(_WS_QWS_) 666#if defined(Q_WS_QWS) || defined(_WS_QWS_)
648 dlg.showMaximized(); 667 dlg.showMaximized();
649#endif 668#endif
650 needShow = dlg.exec(); 669 needShow = dlg.exec();
651 670
652 if ( bSound ) 671 if ( bSound )
653 killTimer( stopTimer ); 672 killTimer( stopTimer );
654 } 673 }
655 } 674 }
656 } else if ( msg == "nextView()" ) { 675 } else if ( msg == "nextView()" ) {
657 QWidget* cur = views->visibleWidget(); 676 QWidget* cur = views->visibleWidget();
658 if ( cur ) { 677 if ( cur ) {
659 if ( cur == dayView ) 678 if ( cur == dayView )
660 viewWeek(); 679 viewWeek();
661 else if ( cur == weekView ) 680 else if ( cur == weekView )
662 viewWeekLst(); 681 viewWeekLst();
663 else if ( cur == weekLstView ) 682 else if ( cur == weekLstView )
664 viewMonth(); 683 viewMonth();
665 else if ( cur == monthView ) 684 else if ( cur == monthView )
666 viewDay(); 685 viewDay();
667 needShow = TRUE; 686 needShow = TRUE;
668 } 687 }
669 } 688 }
670 if ( needShow ) { 689 if ( needShow ) {
671#if defined(Q_WS_QWS) || defined(_WS_QWS_) 690#if defined(Q_WS_QWS) || defined(_WS_QWS_)
672 showMaximized(); 691 showMaximized();
673#else 692#else
674 show(); 693 show();
675#endif 694#endif
676 raise(); 695 raise();
677 QPEApplication::setKeepRunning(); 696 QPEApplication::setKeepRunning();
678 setActiveWindow(); 697 setActiveWindow();
679 } 698 }
680} 699}
681 700
682void DateBook::reload() 701void DateBook::reload()
683{ 702{
684 db->reload(); 703 db->reload();
685 if ( dayAction->isOn() ) 704 if ( dayAction->isOn() )
686 viewDay(); 705 viewDay();
687 else if ( weekAction->isOn() ) 706 else if ( weekAction->isOn() )
688 viewWeek(); 707 viewWeek();
689 else if ( monthAction->isOn() ) 708 else if ( monthAction->isOn() )
690 viewMonth(); 709 viewMonth();
691 syncing = FALSE; 710 syncing = FALSE;
692} 711}
693 712
694void DateBook::flush() 713void DateBook::flush()
695{ 714{
696 syncing = TRUE; 715 syncing = TRUE;
697 db->save(); 716 db->save();
698} 717}
699 718
700void DateBook::timerEvent( QTimerEvent *e ) 719void DateBook::timerEvent( QTimerEvent *e )
701{ 720{
702 if ( alarmCounter < 10 ) { 721 if ( alarmCounter < 10 ) {
703 alarmCounter++; 722 alarmCounter++;
704 Sound::soundAlarm(); 723 Sound::soundAlarm();
705 } 724 }
706 else 725 else
707 killTimer( e->timerId() ); 726 killTimer( e->timerId() );
708} 727}
709 728
710void DateBook::changeClock( bool newClock ) 729void DateBook::changeClock( bool newClock )
711{ 730{
712 ampm = newClock; 731 ampm = newClock;
713 // repaint the affected objects... 732 // repaint the affected objects...
714 if (dayView) dayView->redraw(); 733 if (dayView) dayView->redraw();
715 if (weekView) weekView->redraw(); 734 if (weekView) weekView->redraw();
716 if (weekLstView) weekLstView->redraw(); 735 if (weekLstView) weekLstView->redraw();
717} 736}
718 737
719void DateBook::changeWeek( bool m ) 738void DateBook::changeWeek( bool m )
720{ 739{
721 /* no need to redraw, each widget catches. Do need to 740 /* no need to redraw, each widget catches. Do need to
722 store though for widgets we haven't made yet */ 741 store though for widgets we haven't made yet */
723 onMonday = m; 742 onMonday = m;
724} 743}
725 744
726void DateBook::slotToday() 745void DateBook::slotToday()
727{ 746{
728 // we need to view today using default view 747 // we need to view today using default view
729 viewDefault(QDate::currentDate()); 748 viewDefault(QDate::currentDate());
730} 749}
731 750
732void DateBook::closeEvent( QCloseEvent *e ) 751void DateBook::closeEvent( QCloseEvent *e )
733{ 752{
734 if(syncing) { 753 if(syncing) {