summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp14
-rw-r--r--core/pim/datebook/datebook.h2
2 files changed, 9 insertions, 7 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 8614b3f..2c2965e 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,276 +1,277 @@
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 <qtl.h> 61#include <qtl.h>
62#include <qwidgetstack.h> 62#include <qwidgetstack.h>
63#include <qwindowsystem_qws.h> 63#include <qwindowsystem_qws.h>
64 64
65#include <sys/stat.h> 65#include <sys/stat.h>
66#include <sys/types.h> 66#include <sys/types.h>
67#include <fcntl.h> 67#include <fcntl.h>
68#include <unistd.h> 68#include <unistd.h>
69 69
70#include <stdlib.h> 70#include <stdlib.h>
71 71
72#define DAY 1 72#define DAY 1
73#define WEEK 2 73#define WEEK 2
74#define WEEKLST 4 74#define WEEKLST 4
75#define MONTH 3 75#define MONTH 3
76 76
77 77
78DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 78DateBook::DateBook( QWidget *parent, const char *, WFlags f )
79 : QMainWindow( parent, "datebook", f ), 79 : QMainWindow( parent, "datebook", f ),
80 aPreset( FALSE ), 80 aPreset( FALSE ),
81 presetTime( -1 ), 81 presetTime( -1 ),
82 startTime( 8 ), // an acceptable default 82 startTime( 8 ), // an acceptable default
83 syncing(FALSE), 83 syncing(FALSE),
84 inSearch(FALSE) 84 inSearch(FALSE),
85 alarmCounter(0)
85{ 86{
86 QTime t; 87 QTime t;
87 t.start(); 88 t.start();
88 db = new DateBookDBHack; 89 db = new DateBookDBHack;
89 qDebug("loading db t=%d", t.elapsed() ); 90 qDebug("loading db t=%d", t.elapsed() );
90 loadSettings(); 91 loadSettings();
91 setCaption( tr("Calendar") ); 92 setCaption( tr("Calendar") );
92 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 93 setIcon( Resource::loadPixmap( "datebook_icon" ) );
93 94
94 setToolBarsMovable( FALSE ); 95 setToolBarsMovable( FALSE );
95 96
96 views = new QWidgetStack( this ); 97 views = new QWidgetStack( this );
97 setCentralWidget( views ); 98 setCentralWidget( views );
98 99
99 dayView = 0; 100 dayView = 0;
100 weekView = 0; 101 weekView = 0;
101 weekLstView = 0; 102 weekLstView = 0;
102 monthView = 0; 103 monthView = 0;
103 104
104 QPEToolBar *bar = new QPEToolBar( this ); 105 QPEToolBar *bar = new QPEToolBar( this );
105 bar->setHorizontalStretchable( TRUE ); 106 bar->setHorizontalStretchable( TRUE );
106 107
107 QPEMenuBar *mb = new QPEMenuBar( bar ); 108 QPEMenuBar *mb = new QPEMenuBar( bar );
108 mb->setMargin( 0 ); 109 mb->setMargin( 0 );
109 110
110 QPEToolBar *sub_bar = new QPEToolBar(this); 111 QPEToolBar *sub_bar = new QPEToolBar(this);
111 112
112 QPopupMenu *view = new QPopupMenu( this ); 113 QPopupMenu *view = new QPopupMenu( this );
113 QPopupMenu *settings = new QPopupMenu( this ); 114 QPopupMenu *settings = new QPopupMenu( this );
114 115
115 mb->insertItem( tr( "View" ), view ); 116 mb->insertItem( tr( "View" ), view );
116 mb->insertItem( tr( "Settings" ), settings ); 117 mb->insertItem( tr( "Settings" ), settings );
117 118
118 QActionGroup *g = new QActionGroup( this ); 119 QActionGroup *g = new QActionGroup( this );
119 g->setExclusive( TRUE ); 120 g->setExclusive( TRUE );
120 121
121 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 122 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
122 QString::null, 0, this, 0 ); 123 QString::null, 0, this, 0 );
123 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 124 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
124 a->addTo( sub_bar ); 125 a->addTo( sub_bar );
125 126
126 a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 ); 127 a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 );
127 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 128 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
128 a->addTo( sub_bar ); 129 a->addTo( sub_bar );
129 a->addTo( view ); 130 a->addTo( view );
130 131
131 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 132 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
132 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 133 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
133 a->addTo( sub_bar ); 134 a->addTo( sub_bar );
134 a->addTo( view ); 135 a->addTo( view );
135 a->setToggleAction( TRUE ); 136 a->setToggleAction( TRUE );
136 a->setOn( TRUE ); 137 a->setOn( TRUE );
137 dayAction = a; 138 dayAction = a;
138 139
139 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 140 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
140 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 141 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
141 a->addTo( sub_bar ); 142 a->addTo( sub_bar );
142 a->addTo( view ); 143 a->addTo( view );
143 a->setToggleAction( TRUE ); 144 a->setToggleAction( TRUE );
144 weekAction = a; 145 weekAction = a;
145 146
146 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 ); 147 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 );
147 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 148 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
148 a->addTo( sub_bar ); 149 a->addTo( sub_bar );
149 a->addTo( view ); 150 a->addTo( view );
150 a->setToggleAction( TRUE ); 151 a->setToggleAction( TRUE );
151 weekLstAction = a; 152 weekLstAction = a;
152 153
153 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 154 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
154 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 155 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
155 a->addTo( sub_bar ); 156 a->addTo( sub_bar );
156 a->addTo( view ); 157 a->addTo( view );
157 a->setToggleAction( TRUE ); 158 a->setToggleAction( TRUE );
158 monthAction = a; 159 monthAction = a;
159 160
160 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); 161 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 );
161 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 162 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
162 a->addTo( sub_bar ); 163 a->addTo( sub_bar );
163 164
164 a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); 165 a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 );
165 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 166 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
166 a->addTo( settings ); 167 a->addTo( settings );
167 168
168 QPopupMenu *default_view = new QPopupMenu(this); 169 QPopupMenu *default_view = new QPopupMenu(this);
169 settings->insertItem( tr( "Default View" ),default_view ); 170 settings->insertItem( tr( "Default View" ),default_view );
170 default_view->setCheckable(TRUE); 171 default_view->setCheckable(TRUE);
171 172
172 Config config("DateBook"); 173 Config config("DateBook");
173 config.setGroup("Main"); 174 config.setGroup("Main");
174 int current=config.readNumEntry("defaultview", DAY); 175 int current=config.readNumEntry("defaultview", DAY);
175 176
176 QActionGroup *ag = new QActionGroup(this); 177 QActionGroup *ag = new QActionGroup(this);
177 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); 178 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true );
178 if (current==DAY) a->setOn(true), viewDay(); 179 if (current==DAY) a->setOn(true), viewDay();
179 ag->insert(a); 180 ag->insert(a);
180 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); 181 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true );
181 if (current==WEEK) a->setOn(true), viewWeek(); 182 if (current==WEEK) a->setOn(true), viewWeek();
182 ag->insert(a); 183 ag->insert(a);
183 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); 184 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true );
184 if (current==WEEKLST) a->setOn(true), viewWeekLst(); 185 if (current==WEEKLST) a->setOn(true), viewWeekLst();
185 ag->insert(a); 186 ag->insert(a);
186 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); 187 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true );
187 if (current==MONTH) a->setOn(true), viewMonth(); 188 if (current==MONTH) a->setOn(true), viewMonth();
188 ag->insert(a); 189 ag->insert(a);
189 190
190 ag->addTo(default_view); 191 ag->addTo(default_view);
191 connect(ag, SIGNAL( selected ( QAction * ) ), 192 connect(ag, SIGNAL( selected ( QAction * ) ),
192 this, SLOT( newDefaultView(QAction *) ) 193 this, SLOT( newDefaultView(QAction *) )
193 ); 194 );
194 195
195 connect( qApp, SIGNAL(clockChanged(bool)), 196 connect( qApp, SIGNAL(clockChanged(bool)),
196 this, SLOT(changeClock(bool)) ); 197 this, SLOT(changeClock(bool)) );
197 connect( qApp, SIGNAL(weekChanged(bool)), 198 connect( qApp, SIGNAL(weekChanged(bool)),
198 this, SLOT(changeWeek(bool)) ); 199 this, SLOT(changeWeek(bool)) );
199 200
200#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 201#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
201 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 202 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
202 this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 203 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
203#endif 204#endif
204 205
205 // listen on QPE/System 206 // listen on QPE/System
206#if defined(Q_WS_QWS) 207#if defined(Q_WS_QWS)
207#if !defined(QT_NO_COP) 208#if !defined(QT_NO_COP)
208 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 209 QCopChannel *channel = new QCopChannel( "QPE/System", this );
209 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 210 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
210 this, SLOT(receive(const QCString&, const QByteArray&)) ); 211 this, SLOT(receive(const QCString&, const QByteArray&)) );
211 channel = new QCopChannel( "QPE/Datebook", this ); 212 channel = new QCopChannel( "QPE/Datebook", this );
212 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 213 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
213 this, SLOT(receive(const QCString&, const QByteArray&)) ); 214 this, SLOT(receive(const QCString&, const QByteArray&)) );
214 qDebug("olle\n"); 215 qDebug("olle\n");
215#endif 216#endif
216#endif 217#endif
217 218
218 qDebug("done t=%d", t.elapsed() ); 219 qDebug("done t=%d", t.elapsed() );
219 220
220} 221}
221 222
222void DateBook::receive( const QCString &msg, const QByteArray &data ) 223void DateBook::receive( const QCString &msg, const QByteArray &data )
223{ 224{
224 QDataStream stream( data, IO_ReadOnly ); 225 QDataStream stream( data, IO_ReadOnly );
225 if ( msg == "timeChange(QString)" ) { 226 if ( msg == "timeChange(QString)" ) {
226 // update active view! 227 // update active view!
227 if ( dayAction->isOn() ) 228 if ( dayAction->isOn() )
228 viewDay(); 229 viewDay();
229 else if ( weekAction->isOn() ) 230 else if ( weekAction->isOn() )
230 viewWeek(); 231 viewWeek();
231 else if ( monthAction->isOn() ) 232 else if ( monthAction->isOn() )
232 viewMonth(); 233 viewMonth();
233 } 234 }
234 else if (msg == "editEvent(int)") { 235 else if (msg == "editEvent(int)") {
235 int uid; 236 int uid;
236 stream >> uid; 237 stream >> uid;
237 Event e=db->eventByUID(uid); 238 Event e=db->eventByUID(uid);
238 editEvent(e); 239 editEvent(e);
239 } 240 }
240} 241}
241 242
242DateBook::~DateBook() 243DateBook::~DateBook()
243{ 244{
244} 245}
245 246
246void DateBook::slotSettings() 247void DateBook::slotSettings()
247{ 248{
248 DateBookSettings frmSettings( ampm, this ); 249 DateBookSettings frmSettings( ampm, this );
249 frmSettings.setStartTime( startTime ); 250 frmSettings.setStartTime( startTime );
250 frmSettings.setAlarmPreset( aPreset, presetTime ); 251 frmSettings.setAlarmPreset( aPreset, presetTime );
251#if defined (Q_WS_QWS) || defined(_WS_QWS_) 252#if defined (Q_WS_QWS) || defined(_WS_QWS_)
252 frmSettings.showMaximized(); 253 frmSettings.showMaximized();
253#endif 254#endif
254 255
255 if ( frmSettings.exec() ) { 256 if ( frmSettings.exec() ) {
256 aPreset = frmSettings.alarmPreset(); 257 aPreset = frmSettings.alarmPreset();
257 presetTime = frmSettings.presetTime(); 258 presetTime = frmSettings.presetTime();
258 startTime = frmSettings.startTime(); 259 startTime = frmSettings.startTime();
259 if ( dayView ) 260 if ( dayView )
260 dayView->setStartViewTime( startTime ); 261 dayView->setStartViewTime( startTime );
261 if ( weekView ) 262 if ( weekView )
262 weekView->setStartViewTime( startTime ); 263 weekView->setStartViewTime( startTime );
263 saveSettings(); 264 saveSettings();
264 265
265 // make the change obvious 266 // make the change obvious
266 if ( views->visibleWidget() ) { 267 if ( views->visibleWidget() ) {
267 if ( views->visibleWidget() == dayView ) 268 if ( views->visibleWidget() == dayView )
268 dayView->redraw(); 269 dayView->redraw();
269 else if ( views->visibleWidget() == weekView ) 270 else if ( views->visibleWidget() == weekView )
270 weekView->redraw(); 271 weekView->redraw();
271 } 272 }
272 } 273 }
273} 274}
274 275
275void DateBook::fileNew() 276void DateBook::fileNew()
276{ 277{
@@ -425,461 +426,460 @@ void DateBook::removeEvent( const Event &e )
425 426
426 QString strName = e.description(); 427 QString strName = e.description();
427 428
428 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 429 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
429 return; 430 return;
430 431
431 db->removeEvent( e ); 432 db->removeEvent( e );
432 if ( views->visibleWidget() == dayView && dayView ) 433 if ( views->visibleWidget() == dayView && dayView )
433 dayView->redraw(); 434 dayView->redraw();
434} 435}
435 436
436void DateBook::addEvent( const Event &e ) 437void DateBook::addEvent( const Event &e )
437{ 438{
438 QDate d = e.start().date(); 439 QDate d = e.start().date();
439 initDay(); 440 initDay();
440 dayView->setDate( d ); 441 dayView->setDate( d );
441} 442}
442 443
443void DateBook::showDay( int year, int month, int day ) 444void DateBook::showDay( int year, int month, int day )
444{ 445{
445 QDate d(year, month, day); 446 QDate d(year, month, day);
446 view(DAY,d); 447 view(DAY,d);
447} 448}
448 449
449void DateBook::initDay() 450void DateBook::initDay()
450{ 451{
451 if ( !dayView ) { 452 if ( !dayView ) {
452 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 453 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
453 views->addWidget( dayView, DAY ); 454 views->addWidget( dayView, DAY );
454 dayView->setStartViewTime( startTime ); 455 dayView->setStartViewTime( startTime );
455 connect( this, SIGNAL( newEvent() ), 456 connect( this, SIGNAL( newEvent() ),
456 dayView, SLOT( redraw() ) ); 457 dayView, SLOT( redraw() ) );
457 connect( dayView, SIGNAL( newEvent() ), 458 connect( dayView, SIGNAL( newEvent() ),
458 this, SLOT( fileNew() ) ); 459 this, SLOT( fileNew() ) );
459 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 460 connect( dayView, SIGNAL( removeEvent( const Event & ) ),
460 this, SLOT( removeEvent( const Event & ) ) ); 461 this, SLOT( removeEvent( const Event & ) ) );
461 connect( dayView, SIGNAL( editEvent( const Event & ) ), 462 connect( dayView, SIGNAL( editEvent( const Event & ) ),
462 this, SLOT( editEvent( const Event & ) ) ); 463 this, SLOT( editEvent( const Event & ) ) );
463 connect( dayView, SIGNAL( beamEvent( const Event & ) ), 464 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
464 this, SLOT( beamEvent( const Event & ) ) ); 465 this, SLOT( beamEvent( const Event & ) ) );
465 connect( dayView, SIGNAL(sigNewEvent(const QString &)), 466 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
466 this, SLOT(slotNewEventFromKey(const QString &)) ); 467 this, SLOT(slotNewEventFromKey(const QString &)) );
467 } 468 }
468} 469}
469 470
470void DateBook::initWeek() 471void DateBook::initWeek()
471{ 472{
472 if ( !weekView ) { 473 if ( !weekView ) {
473 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 474 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
474 weekView->setStartViewTime( startTime ); 475 weekView->setStartViewTime( startTime );
475 views->addWidget( weekView, WEEK ); 476 views->addWidget( weekView, WEEK );
476 connect( weekView, SIGNAL( showDate( int, int, int ) ), 477 connect( weekView, SIGNAL( showDate( int, int, int ) ),
477 this, SLOT( showDay( int, int, int ) ) ); 478 this, SLOT( showDay( int, int, int ) ) );
478 connect( this, SIGNAL( newEvent() ), 479 connect( this, SIGNAL( newEvent() ),
479 weekView, SLOT( redraw() ) ); 480 weekView, SLOT( redraw() ) );
480 } 481 }
481 //But also get it right: the year that we display can be different 482 //But also get it right: the year that we display can be different
482 //from the year of the current date. So, first find the year 483 //from the year of the current date. So, first find the year
483 //number of the current week. 484 //number of the current week.
484 485
485 int yearNumber, totWeeks; 486 int yearNumber, totWeeks;
486 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 487 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
487 488
488 QDate d = QDate( yearNumber, 12, 31 ); 489 QDate d = QDate( yearNumber, 12, 31 );
489 calcWeek( d, totWeeks, yearNumber, onMonday ); 490 calcWeek( d, totWeeks, yearNumber, onMonday );
490 491
491 while ( totWeeks == 1 ) { 492 while ( totWeeks == 1 ) {
492 d = d.addDays( -1 ); 493 d = d.addDays( -1 );
493 calcWeek( d, totWeeks, yearNumber, onMonday ); 494 calcWeek( d, totWeeks, yearNumber, onMonday );
494 } 495 }
495 if ( totWeeks != weekView->totalWeeks() ) 496 if ( totWeeks != weekView->totalWeeks() )
496 weekView->setTotalWeeks( totWeeks ); 497 weekView->setTotalWeeks( totWeeks );
497} 498}
498void DateBook::initWeekLst() { 499void DateBook::initWeekLst() {
499 if ( !weekLstView ) { 500 if ( !weekLstView ) {
500 weekLstView = new DateBookWeekLst( ampm, onMonday, db, 501 weekLstView = new DateBookWeekLst( ampm, onMonday, db,
501 views, "weeklst view" ); 502 views, "weeklst view" );
502 views->addWidget( weekLstView, WEEKLST ); 503 views->addWidget( weekLstView, WEEKLST );
503 504
504 //weekLstView->setStartViewTime( startTime ); 505 //weekLstView->setStartViewTime( startTime );
505 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), 506 connect( weekLstView, SIGNAL( showDate( int, int, int ) ),
506 this, SLOT( showDay( int, int, int ) ) ); 507 this, SLOT( showDay( int, int, int ) ) );
507 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, 508 connect( weekLstView, SIGNAL( addEvent( const QDateTime &,
508 const QDateTime &, 509 const QDateTime &,
509 const QString & ) ), 510 const QString & ) ),
510 this, SLOT( slotNewEntry( const QDateTime &, 511 this, SLOT( slotNewEntry( const QDateTime &,
511 const QDateTime &, 512 const QDateTime &,
512 const QString & ) ) ); 513 const QString & ) ) );
513 connect( this, SIGNAL( newEvent() ), 514 connect( this, SIGNAL( newEvent() ),
514 weekLstView, SLOT( redraw() ) ); 515 weekLstView, SLOT( redraw() ) );
515 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), 516 connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
516 this, SLOT( editEvent( const Event & ) ) ); 517 this, SLOT( editEvent( const Event & ) ) );
517 } 518 }
518} 519}
519 520
520 521
521void DateBook::initMonth() 522void DateBook::initMonth()
522{ 523{
523 if ( !monthView ) { 524 if ( !monthView ) {
524 monthView = new DateBookMonth( views, "month view", FALSE, db ); 525 monthView = new DateBookMonth( views, "month view", FALSE, db );
525 views->addWidget( monthView, MONTH ); 526 views->addWidget( monthView, MONTH );
526 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), 527 connect( monthView, SIGNAL( dateClicked( int, int, int ) ),
527 this, SLOT( showDay( int, int, int ) ) ); 528 this, SLOT( showDay( int, int, int ) ) );
528 connect( this, SIGNAL( newEvent() ), 529 connect( this, SIGNAL( newEvent() ),
529 monthView, SLOT( redraw() ) ); 530 monthView, SLOT( redraw() ) );
530 qApp->processEvents(); 531 qApp->processEvents();
531 } 532 }
532} 533}
533 534
534void DateBook::loadSettings() 535void DateBook::loadSettings()
535{ 536{
536 { 537 {
537 Config config( "qpe" ); 538 Config config( "qpe" );
538 config.setGroup("Time"); 539 config.setGroup("Time");
539 ampm = config.readBoolEntry( "AMPM", TRUE ); 540 ampm = config.readBoolEntry( "AMPM", TRUE );
540 onMonday = config.readBoolEntry( "MONDAY" ); 541 onMonday = config.readBoolEntry( "MONDAY" );
541 } 542 }
542 543
543 { 544 {
544 Config config("DateBook"); 545 Config config("DateBook");
545 config.setGroup("Main"); 546 config.setGroup("Main");
546 startTime = config.readNumEntry("startviewtime", 8); 547 startTime = config.readNumEntry("startviewtime", 8);
547 aPreset = config.readBoolEntry("alarmpreset"); 548 aPreset = config.readBoolEntry("alarmpreset");
548 presetTime = config.readNumEntry("presettime"); 549 presetTime = config.readNumEntry("presettime");
549 } 550 }
550} 551}
551 552
552void DateBook::saveSettings() 553void DateBook::saveSettings()
553{ 554{
554 Config config( "qpe" ); 555 Config config( "qpe" );
555 Config configDB( "DateBook" ); 556 Config configDB( "DateBook" );
556 configDB.setGroup( "Main" ); 557 configDB.setGroup( "Main" );
557 configDB.writeEntry("startviewtime",startTime); 558 configDB.writeEntry("startviewtime",startTime);
558 configDB.writeEntry("alarmpreset",aPreset); 559 configDB.writeEntry("alarmpreset",aPreset);
559 configDB.writeEntry("presettime",presetTime); 560 configDB.writeEntry("presettime",presetTime);
560} 561}
561 562
562void DateBook::newDefaultView(QAction *a) { 563void DateBook::newDefaultView(QAction *a) {
563 int val=DAY; 564 int val=DAY;
564 if (a->text() == "Day") val=DAY; 565 if (a->text() == "Day") val=DAY;
565 if (a->text() == "Week") val=WEEK; 566 if (a->text() == "Week") val=WEEK;
566 if (a->text() == "WeekLst") val=WEEKLST; 567 if (a->text() == "WeekLst") val=WEEKLST;
567 if (a->text() == "Month") val=MONTH; 568 if (a->text() == "Month") val=MONTH;
568 569
569 Config configDB( "DateBook" ); 570 Config configDB( "DateBook" );
570 configDB.setGroup( "Main" ); 571 configDB.setGroup( "Main" );
571 configDB.writeEntry("defaultview",val); 572 configDB.writeEntry("defaultview",val);
572} 573}
573 574
574void DateBook::appMessage(const QCString& msg, const QByteArray& data) 575void DateBook::appMessage(const QCString& msg, const QByteArray& data)
575{ 576{
576 bool needShow = FALSE; 577 bool needShow = FALSE;
577 if ( msg == "alarm(QDateTime,int)" ) { 578 if ( msg == "alarm(QDateTime,int)" ) {
578 QDataStream ds(data,IO_ReadOnly); 579 QDataStream ds(data,IO_ReadOnly);
579 QDateTime when; int warn; 580 QDateTime when; int warn;
580 ds >> when >> warn; 581 ds >> when >> warn;
581 582
582 // check to make it's okay to continue, 583 // check to make it's okay to continue,
583 // this is the case that the time was set ahead, and 584 // this is the case that the time was set ahead, and
584 // we are forced given a stale alarm... 585 // we are forced given a stale alarm...
585 QDateTime current = QDateTime::currentDateTime(); 586 QDateTime current = QDateTime::currentDateTime();
586 if ( current.time().hour() != when.time().hour() 587 if ( current.time().hour() != when.time().hour()
587 && current.time().minute() != when.time().minute() ) 588 && current.time().minute() != when.time().minute() )
588 return; 589 return;
589 590
590 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 591 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
591 if ( list.count() > 0 ) { 592 if ( list.count() > 0 ) {
592 QString msg; 593 QString msg;
593 bool bSound = FALSE; 594 bool bSound = FALSE;
594 int stopTimer = 0; 595 int stopTimer = 0;
595 bool found = FALSE; 596 bool found = FALSE;
596 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); 597 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin();
597 it!=list.end(); ++it ) { 598 it!=list.end(); ++it ) {
598 if ( (*it).event().hasAlarm() ) { 599 if ( (*it).event().hasAlarm() ) {
599 found = TRUE; 600 found = TRUE;
600 msg += "<CENTER><B>" + (*it).description() + "</B>" 601 msg += "<CENTER><B>" + (*it).description() + "</B>"
601 + "<BR>" + (*it).location() + "<BR>" 602 + "<BR>" + (*it).location() + "<BR>"
602 + TimeString::dateString((*it).event().start(),ampm) 603 + TimeString::dateString((*it).event().start(),ampm)
603 + (warn 604 + (warn
604 ? tr(" (in " + QString::number(warn) 605 ? tr(" (in " + QString::number(warn)
605 + tr(" minutes)")) 606 + tr(" minutes)"))
606 : QString("")) 607 : QString(""))
607 + "<BR>" 608 + "<BR>"
608 + (*it).notes() + "</CENTER>"; 609 + (*it).notes() + "</CENTER>";
609 if ( (*it).event().alarmSound() != Event::Silent ) { 610 if ( (*it).event().alarmSound() != Event::Silent ) {
610 bSound = TRUE; 611 bSound = TRUE;
611 } 612 }
612 } 613 }
613 } 614 }
614 if ( found ) { 615 if ( found ) {
615 if ( bSound ) { 616 if ( bSound ) {
616 Sound::soundAlarm(); 617 Sound::soundAlarm();
618 alarmCounter = 0;
617 stopTimer = startTimer( 5000 ); 619 stopTimer = startTimer( 5000 );
618 } 620 }
619 621
620 QDialog dlg( this, 0, TRUE ); 622 QDialog dlg( this, 0, TRUE );
621 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 623 QVBoxLayout *vb = new QVBoxLayout( &dlg );
622 QScrollView *view = new QScrollView( &dlg, "scrollView"); 624 QScrollView *view = new QScrollView( &dlg, "scrollView");
623 view->setResizePolicy( QScrollView::AutoOneFit ); 625 view->setResizePolicy( QScrollView::AutoOneFit );
624 vb->addWidget( view ); 626 vb->addWidget( view );
625 QLabel *lblMsg = new QLabel( msg, &dlg ); 627 QLabel *lblMsg = new QLabel( msg, &dlg );
626 view->addChild( lblMsg ); 628 view->addChild( lblMsg );
627 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 629 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
628 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 630 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
629 vb->addWidget( cmdOk ); 631 vb->addWidget( cmdOk );
630 632
631#if defined(Q_WS_QWS) || defined(_WS_QWS_) 633#if defined(Q_WS_QWS) || defined(_WS_QWS_)
632 dlg.showMaximized(); 634 dlg.showMaximized();
633#endif 635#endif
634 needShow = dlg.exec(); 636 needShow = dlg.exec();
635 637
636 if ( bSound ) 638 if ( bSound )
637 killTimer( stopTimer ); 639 killTimer( stopTimer );
638 } 640 }
639 } 641 }
640 } else if ( msg == "nextView()" ) { 642 } else if ( msg == "nextView()" ) {
641 QWidget* cur = views->visibleWidget(); 643 QWidget* cur = views->visibleWidget();
642 if ( cur ) { 644 if ( cur ) {
643 if ( cur == dayView ) 645 if ( cur == dayView )
644 viewWeek(); 646 viewWeek();
645 else if ( cur == weekView ) 647 else if ( cur == weekView )
646 viewWeekLst(); 648 viewWeekLst();
647 else if ( cur == weekLstView ) 649 else if ( cur == weekLstView )
648 viewMonth(); 650 viewMonth();
649 else if ( cur == monthView ) 651 else if ( cur == monthView )
650 viewDay(); 652 viewDay();
651 needShow = TRUE; 653 needShow = TRUE;
652 } 654 }
653 } 655 }
654 if ( needShow ) { 656 if ( needShow ) {
655#if defined(Q_WS_QWS) || defined(_WS_QWS_) 657#if defined(Q_WS_QWS) || defined(_WS_QWS_)
656 showMaximized(); 658 showMaximized();
657#else 659#else
658 show(); 660 show();
659#endif 661#endif
660 raise(); 662 raise();
661 QPEApplication::setKeepRunning(); 663 QPEApplication::setKeepRunning();
662 setActiveWindow(); 664 setActiveWindow();
663 } 665 }
664} 666}
665 667
666void DateBook::reload() 668void DateBook::reload()
667{ 669{
668 db->reload(); 670 db->reload();
669 if ( dayAction->isOn() ) 671 if ( dayAction->isOn() )
670 viewDay(); 672 viewDay();
671 else if ( weekAction->isOn() ) 673 else if ( weekAction->isOn() )
672 viewWeek(); 674 viewWeek();
673 else if ( monthAction->isOn() ) 675 else if ( monthAction->isOn() )
674 viewMonth(); 676 viewMonth();
675 syncing = FALSE; 677 syncing = FALSE;
676} 678}
677 679
678void DateBook::flush() 680void DateBook::flush()
679{ 681{
680 syncing = TRUE; 682 syncing = TRUE;
681 db->save(); 683 db->save();
682} 684}
683 685
684void DateBook::timerEvent( QTimerEvent *e ) 686void DateBook::timerEvent( QTimerEvent *e )
685{ 687{
686 static int stop = 0; 688 if ( alarmCounter < 10 ) {
687 if ( stop < 10 ) { 689 alarmCounter++;
688 Sound::soundAlarm(); 690 Sound::soundAlarm();
689 stop++; 691 }
690 } else { 692 else
691 stop = 0;
692 killTimer( e->timerId() ); 693 killTimer( e->timerId() );
693 }
694} 694}
695 695
696void DateBook::changeClock( bool newClock ) 696void DateBook::changeClock( bool newClock )
697{ 697{
698 ampm = newClock; 698 ampm = newClock;
699 // repaint the affected objects... 699 // repaint the affected objects...
700 if (dayView) dayView->redraw(); 700 if (dayView) dayView->redraw();
701 if (weekView) weekView->redraw(); 701 if (weekView) weekView->redraw();
702 if (weekLstView) weekLstView->redraw(); 702 if (weekLstView) weekLstView->redraw();
703} 703}
704 704
705void DateBook::changeWeek( bool m ) 705void DateBook::changeWeek( bool m )
706{ 706{
707 /* no need to redraw, each widget catches. Do need to 707 /* no need to redraw, each widget catches. Do need to
708 store though for widgets we haven't made yet */ 708 store though for widgets we haven't made yet */
709 onMonday = m; 709 onMonday = m;
710} 710}
711 711
712void DateBook::slotToday() 712void DateBook::slotToday()
713{ 713{
714 // we need to view today using default view 714 // we need to view today using default view
715 viewDefault(QDate::currentDate()); 715 viewDefault(QDate::currentDate());
716} 716}
717 717
718void DateBook::closeEvent( QCloseEvent *e ) 718void DateBook::closeEvent( QCloseEvent *e )
719{ 719{
720 if(syncing) { 720 if(syncing) {
721 /* no need to save, did that at flush */ 721 /* no need to save, did that at flush */
722 e->accept(); 722 e->accept();
723 return; 723 return;
724 } 724 }
725 725
726 // save settings will generate it's own error messages, no 726 // save settings will generate it's own error messages, no
727 // need to do checking ourselves. 727 // need to do checking ourselves.
728 saveSettings(); 728 saveSettings();
729 if ( db->save() ) 729 if ( db->save() )
730 e->accept(); 730 e->accept();
731 else { 731 else {
732 if ( QMessageBox::critical( this, tr( "Out of space" ), 732 if ( QMessageBox::critical( this, tr( "Out of space" ),
733 tr("Calendar was unable to save\n" 733 tr("Calendar was unable to save\n"
734 "your changes.\n" 734 "your changes.\n"
735 "Free up some space and try again.\n" 735 "Free up some space and try again.\n"
736 "\nQuit anyway?"), 736 "\nQuit anyway?"),
737 QMessageBox::Yes|QMessageBox::Escape, 737 QMessageBox::Yes|QMessageBox::Escape,
738 QMessageBox::No|QMessageBox::Default ) 738 QMessageBox::No|QMessageBox::Default )
739 != QMessageBox::No ) 739 != QMessageBox::No )
740 e->accept(); 740 e->accept();
741 else 741 else
742 e->ignore(); 742 e->ignore();
743 } 743 }
744} 744}
745 745
746// Entering directly from the "keyboard" 746// Entering directly from the "keyboard"
747void DateBook::slotNewEventFromKey( const QString &str ) 747void DateBook::slotNewEventFromKey( const QString &str )
748{ 748{
749 if (syncing) { 749 if (syncing) {
750 QMessageBox::warning( this, tr("Calendar"), 750 QMessageBox::warning( this, tr("Calendar"),
751 tr( "Can not edit data, currently syncing") ); 751 tr( "Can not edit data, currently syncing") );
752 return; 752 return;
753 } 753 }
754 754
755 // We get to here from a key pressed in the Day View 755 // We get to here from a key pressed in the Day View
756 // So we can assume some things. We want the string 756 // So we can assume some things. We want the string
757 // passed in to be part of the description. 757 // passed in to be part of the description.
758 QDateTime start, end; 758 QDateTime start, end;
759 if ( views->visibleWidget() == dayView ) { 759 if ( views->visibleWidget() == dayView ) {
760 dayView->selectedDates( start, end ); 760 dayView->selectedDates( start, end );
761 } else if ( views->visibleWidget() == monthView ) { 761 } else if ( views->visibleWidget() == monthView ) {
762 QDate d = monthView->selectedDate(); 762 QDate d = monthView->selectedDate();
763 start = end = d; 763 start = end = d;
764 start.setTime( QTime( 10, 0 ) ); 764 start.setTime( QTime( 10, 0 ) );
765 end.setTime( QTime( 12, 0 ) ); 765 end.setTime( QTime( 12, 0 ) );
766 } else if ( views->visibleWidget() == weekView ) { 766 } else if ( views->visibleWidget() == weekView ) {
767 QDate d = weekView->date(); 767 QDate d = weekView->date();
768 start = end = d; 768 start = end = d;
769 start.setTime( QTime( 10, 0 ) ); 769 start.setTime( QTime( 10, 0 ) );
770 end.setTime( QTime( 12, 0 ) ); 770 end.setTime( QTime( 12, 0 ) );
771 } 771 }
772 slotNewEntry(start, end, str); 772 slotNewEntry(start, end, str);
773} 773}
774void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { 774void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) {
775 // argh! This really needs to be encapsulated in a class 775 // argh! This really needs to be encapsulated in a class
776 // or function. 776 // or function.
777 QDialog newDlg( this, 0, TRUE ); 777 QDialog newDlg( this, 0, TRUE );
778 newDlg.setCaption( DateEntryBase::tr("New Event") ); 778 newDlg.setCaption( DateEntryBase::tr("New Event") );
779 DateEntry *e; 779 DateEntry *e;
780 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 780 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
781 QScrollView *sv = new QScrollView( &newDlg ); 781 QScrollView *sv = new QScrollView( &newDlg );
782 sv->setResizePolicy( QScrollView::AutoOneFit ); 782 sv->setResizePolicy( QScrollView::AutoOneFit );
783 sv->setFrameStyle( QFrame::NoFrame ); 783 sv->setFrameStyle( QFrame::NoFrame );
784 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 784 sv->setHScrollBarMode( QScrollView::AlwaysOff );
785 vb->addWidget( sv ); 785 vb->addWidget( sv );
786 786
787 Event ev; 787 Event ev;
788 ev.setDescription( str ); 788 ev.setDescription( str );
789 // When the new gui comes in, change this... 789 // When the new gui comes in, change this...
790 ev.setLocation( tr("(Unknown)") ); 790 ev.setLocation( tr("(Unknown)") );
791 ev.setStart( start ); 791 ev.setStart( start );
792 ev.setEnd( end ); 792 ev.setEnd( end );
793 793
794 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 794 e = new DateEntry( onMonday, ev, ampm, &newDlg );
795 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 795 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
796 sv->addChild( e ); 796 sv->addChild( e );
797#if defined(Q_WS_QWS) || defined(_WS_QWS_) 797#if defined(Q_WS_QWS) || defined(_WS_QWS_)
798 newDlg.showMaximized(); 798 newDlg.showMaximized();
799#endif 799#endif
800 while (newDlg.exec()) { 800 while (newDlg.exec()) {
801 ev = e->event(); 801 ev = e->event();
802 ev.assignUid(); 802 ev.assignUid();
803 QString error = checkEvent( ev ); 803 QString error = checkEvent( ev );
804 if ( !error.isNull() ) { 804 if ( !error.isNull() ) {
805 if ( QMessageBox::warning( this, tr("Error!"), 805 if ( QMessageBox::warning( this, tr("Error!"),
806 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 806 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
807 continue; 807 continue;
808 } 808 }
809 db->addEvent( ev ); 809 db->addEvent( ev );
810 emit newEvent(); 810 emit newEvent();
811 break; 811 break;
812 } 812 }
813} 813}
814 814
815void DateBook::setDocument( const QString &filename ) 815void DateBook::setDocument( const QString &filename )
816{ 816{
817 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 817 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
818 818
819 QValueList<Event> tl = Event::readVCalendar( filename ); 819 QValueList<Event> tl = Event::readVCalendar( filename );
820 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 820 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
821 db->addEvent( *it ); 821 db->addEvent( *it );
822 } 822 }
823} 823}
824 824
825static const char * beamfile = "/tmp/obex/event.vcs"; 825static const char * beamfile = "/tmp/obex/event.vcs";
826 826
827void DateBook::beamEvent( const Event &e ) 827void DateBook::beamEvent( const Event &e )
828{ 828{
829 qDebug("trying to beamn"); 829 qDebug("trying to beamn");
830 unlink( beamfile ); // delete if exists 830 unlink( beamfile ); // delete if exists
831 mkdir("/tmp/obex/", 0755); 831 mkdir("/tmp/obex/", 0755);
832 Event::writeVCalendar( beamfile, e ); 832 Event::writeVCalendar( beamfile, e );
833 Ir *ir = new Ir( this ); 833 Ir *ir = new Ir( this );
834 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 834 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
835 QString description = e.description(); 835 QString description = e.description();
836 ir->send( beamfile, description, "text/x-vCalendar" ); 836 ir->send( beamfile, description, "text/x-vCalendar" );
837} 837}
838 838
839void DateBook::beamDone( Ir *ir ) 839void DateBook::beamDone( Ir *ir )
840{ 840{
841 delete ir; 841 delete ir;
842 unlink( beamfile ); 842 unlink( beamfile );
843} 843}
844 844
845void DateBook::slotFind() 845void DateBook::slotFind()
846{ 846{
847 // move it to the day view... 847 // move it to the day view...
848 viewDay(); 848 viewDay();
849 FindDialog frmFind( "Calendar", this ); 849 FindDialog frmFind( "Calendar", this );
850 frmFind.setUseDate( true ); 850 frmFind.setUseDate( true );
851 frmFind.setDate( currentDate() ); 851 frmFind.setDate( currentDate() );
852 QObject::connect( &frmFind, 852 QObject::connect( &frmFind,
853 SIGNAL(signalFindClicked(const QString&, const QDate&, 853 SIGNAL(signalFindClicked(const QString&, const QDate&,
854 bool, bool, int)), 854 bool, bool, int)),
855 this, 855 this,
856 SLOT(slotDoFind(const QString&, const QDate&, 856 SLOT(slotDoFind(const QString&, const QDate&,
857 bool, bool, int)) ); 857 bool, bool, int)) );
858 QObject::connect( this, 858 QObject::connect( this,
859 SIGNAL(signalNotFound()), 859 SIGNAL(signalNotFound()),
860 &frmFind, 860 &frmFind,
861 SLOT(slotNotFound()) ); 861 SLOT(slotNotFound()) );
862 QObject::connect( this, 862 QObject::connect( this,
863 SIGNAL(signalWrapAround()), 863 SIGNAL(signalWrapAround()),
864 &frmFind, 864 &frmFind,
865 SLOT(slotWrapAround()) ); 865 SLOT(slotWrapAround()) );
866 frmFind.exec(); 866 frmFind.exec();
867 inSearch = false; 867 inSearch = false;
868} 868}
869 869
870bool catComp( QArray<int> cats, int category ) 870bool catComp( QArray<int> cats, int category )
871{ 871{
872 bool returnMe; 872 bool returnMe;
873 int i, 873 int i,
874 count; 874 count;
875 875
876 count = int(cats.count()); 876 count = int(cats.count());
877 returnMe = false; 877 returnMe = false;
878 if ( (category == -1 && count == 0) || category == -2 ) 878 if ( (category == -1 && count == 0) || category == -2 )
879 returnMe = true; 879 returnMe = true;
880 else { 880 else {
881 for ( i = 0; i < count; i++ ) { 881 for ( i = 0; i < count; i++ ) {
882 if ( category == cats[i] ) { 882 if ( category == cats[i] ) {
883 returnMe = true; 883 returnMe = true;
884 break; 884 break;
885 } 885 }
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index d1fe90d..e7be0dd 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -1,126 +1,128 @@
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#ifndef DATEBOOK_H 20#ifndef DATEBOOK_H
21#define DATEBOOK_H 21#define DATEBOOK_H
22 22
23#include <qpe/datebookdb.h> 23#include <qpe/datebookdb.h>
24 24
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26 26
27class QAction; 27class QAction;
28class QWidgetStack; 28class QWidgetStack;
29class DateBookDay; 29class DateBookDay;
30class DateBookWeek; 30class DateBookWeek;
31class DateBookWeekLst; 31class DateBookWeekLst;
32class DateBookMonth; 32class DateBookMonth;
33class Event; 33class Event;
34class QDate; 34class QDate;
35class Ir; 35class Ir;
36 36
37class DateBookDBHack : public DateBookDB { 37class DateBookDBHack : public DateBookDB {
38 public: 38 public:
39 Event eventByUID(int id); 39 Event eventByUID(int id);
40}; 40};
41 41
42class DateBook : public QMainWindow 42class DateBook : public QMainWindow
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46public: 46public:
47 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 47 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
48 ~DateBook(); 48 ~DateBook();
49 49
50signals: 50signals:
51 void newEvent(); 51 void newEvent();
52 void signalNotFound(); 52 void signalNotFound();
53 void signalWrapAround(); 53 void signalWrapAround();
54 54
55protected: 55protected:
56 QDate currentDate(); 56 QDate currentDate();
57 void timerEvent( QTimerEvent *e ); 57 void timerEvent( QTimerEvent *e );
58 void closeEvent( QCloseEvent *e ); 58 void closeEvent( QCloseEvent *e );
59 59
60 void view(int v, const QDate &d); 60 void view(int v, const QDate &d);
61 61
62public slots: 62public slots:
63 void flush(); 63 void flush();
64 void reload(); 64 void reload();
65 65
66private slots: 66private slots:
67 void fileNew(); 67 void fileNew();
68 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str); 68 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str);
69 void slotSettings(); 69 void slotSettings();
70 void newDefaultView(QAction *a); 70 void newDefaultView(QAction *a);
71 void slotToday();// view today 71 void slotToday();// view today
72 void changeClock( bool newClock ); 72 void changeClock( bool newClock );
73 void changeWeek( bool newDay ); 73 void changeWeek( bool newDay );
74 void appMessage(const QCString& msg, const QByteArray& data); 74 void appMessage(const QCString& msg, const QByteArray& data);
75 // handle key events in the day view... 75 // handle key events in the day view...
76 void slotNewEventFromKey( const QString &str ); 76 void slotNewEventFromKey( const QString &str );
77 void slotFind(); 77 void slotFind();
78 void slotDoFind( const QString &, const QDate &, bool, bool, int ); 78 void slotDoFind( const QString &, const QDate &, bool, bool, int );
79 79
80 void viewDefault(const QDate &d); 80 void viewDefault(const QDate &d);
81 81
82 void viewDay(); 82 void viewDay();
83 void viewWeek(); 83 void viewWeek();
84 void viewWeekLst(); 84 void viewWeekLst();
85 void viewMonth(); 85 void viewMonth();
86 86
87 void showDay( int y, int m, int d ); 87 void showDay( int y, int m, int d );
88 88
89 void editEvent( const Event &e ); 89 void editEvent( const Event &e );
90 void removeEvent( const Event &e ); 90 void removeEvent( const Event &e );
91 91
92 void receive( const QCString &msg, const QByteArray &data ); 92 void receive( const QCString &msg, const QByteArray &data );
93 void setDocument( const QString & ); 93 void setDocument( const QString & );
94 void beamEvent( const Event &e ); 94 void beamEvent( const Event &e );
95 void beamDone( Ir *ir ); 95 void beamDone( Ir *ir );
96 96
97private: 97private:
98 void addEvent( const Event &e ); 98 void addEvent( const Event &e );
99 void initDay(); 99 void initDay();
100 void initWeek(); 100 void initWeek();
101 void initWeekLst(); 101 void initWeekLst();
102 void initMonth(); 102 void initMonth();
103 void loadSettings(); 103 void loadSettings();
104 void saveSettings(); 104 void saveSettings();
105 105
106private: 106private:
107 DateBookDBHack *db; 107 DateBookDBHack *db;
108 QWidgetStack *views; 108 QWidgetStack *views;
109 DateBookDay *dayView; 109 DateBookDay *dayView;
110 DateBookWeek *weekView; 110 DateBookWeek *weekView;
111 DateBookMonth *monthView; 111 DateBookMonth *monthView;
112 DateBookWeekLst *weekLstView; 112 DateBookWeekLst *weekLstView;
113 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 113 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
114 bool aPreset; // have everything set to alarm? 114 bool aPreset; // have everything set to alarm?
115 int presetTime; // the standard time for the alarm 115 int presetTime; // the standard time for the alarm
116 int startTime; 116 int startTime;
117 bool ampm; 117 bool ampm;
118 bool onMonday; 118 bool onMonday;
119 119
120 bool syncing; 120 bool syncing;
121 bool inSearch; 121 bool inSearch;
122 122
123 int alarmCounter;
124
123 QString checkEvent(const Event &); 125 QString checkEvent(const Event &);
124}; 126};
125 127
126#endif 128#endif