summaryrefslogtreecommitdiff
authorhakan <hakan>2002-03-09 13:07:57 (UTC)
committer hakan <hakan>2002-03-09 13:07:57 (UTC)
commit62c21e8bdbb365a64f05dd363a98abd7fc1f0558 (patch) (unidiff)
treebde5aec77cc0c22a4240b16f0fc4acc41b2d162f
parent603e969bb8cef91534a1785e27106ba71eb03ba6 (diff)
downloadopie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.zip
opie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.tar.gz
opie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.tar.bz2
Fixed today-button to show default view
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp85
-rw-r--r--core/pim/datebook/datebook.h4
-rw-r--r--core/pim/datebook/datebookweeklst.cpp4
-rw-r--r--core/pim/datebook/datebookweeklst.h4
4 files changed, 55 insertions, 42 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 9880e2d..92dbdc8 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,886 +1,895 @@
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 <qtextcodec.h> 58#include <qtextcodec.h>
59#include <qtextstream.h> 59#include <qtextstream.h>
60#include <qtl.h> 60#include <qtl.h>
61#include <qwidgetstack.h> 61#include <qwidgetstack.h>
62#include <qwindowsystem_qws.h> 62#include <qwindowsystem_qws.h>
63 63
64#include <sys/stat.h> 64#include <sys/stat.h>
65#include <sys/types.h> 65#include <sys/types.h>
66#include <fcntl.h> 66#include <fcntl.h>
67#include <unistd.h> 67#include <unistd.h>
68 68
69#include <stdlib.h> 69#include <stdlib.h>
70 70
71#define DAY 1 71#define DAY 1
72#define WEEK 2 72#define WEEK 2
73#define WEEKLST 4 73#define WEEKLST 4
74#define MONTH 3 74#define MONTH 3
75 75
76 76
77DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 77DateBook::DateBook( QWidget *parent, const char *, WFlags f )
78 : QMainWindow( parent, "datebook", f ), 78 : QMainWindow( parent, "datebook", f ),
79 aPreset( FALSE ), 79 aPreset( FALSE ),
80 presetTime( -1 ), 80 presetTime( -1 ),
81 startTime( 8 ), // an acceptable default 81 startTime( 8 ), // an acceptable default
82 syncing(FALSE), 82 syncing(FALSE),
83 inSearch(FALSE) 83 inSearch(FALSE)
84{ 84{
85 QTime t; 85 QTime t;
86 t.start(); 86 t.start();
87 db = new DateBookDB; 87 db = new DateBookDB;
88 qDebug("loading db t=%d", t.elapsed() ); 88 qDebug("loading db t=%d", t.elapsed() );
89 loadSettings(); 89 loadSettings();
90 setCaption( tr("Calendar") ); 90 setCaption( tr("Calendar") );
91 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 91 setIcon( Resource::loadPixmap( "datebook_icon" ) );
92 92
93 setToolBarsMovable( FALSE ); 93 setToolBarsMovable( FALSE );
94 94
95 views = new QWidgetStack( this ); 95 views = new QWidgetStack( this );
96 setCentralWidget( views ); 96 setCentralWidget( views );
97 97
98 dayView = 0; 98 dayView = 0;
99 weekView = 0; 99 weekView = 0;
100 weekLstView = 0; 100 weekLstView = 0;
101 monthView = 0; 101 monthView = 0;
102 102
103 QPEToolBar *bar = new QPEToolBar( this ); 103 QPEToolBar *bar = new QPEToolBar( this );
104 bar->setHorizontalStretchable( TRUE ); 104 bar->setHorizontalStretchable( TRUE );
105 105
106 QPEMenuBar *mb = new QPEMenuBar( bar ); 106 QPEMenuBar *mb = new QPEMenuBar( bar );
107 mb->setMargin( 0 ); 107 mb->setMargin( 0 );
108 108
109 QPEToolBar *sub_bar = new QPEToolBar(this); 109 QPEToolBar *sub_bar = new QPEToolBar(this);
110 110
111 QPopupMenu *view = new QPopupMenu( this ); 111 QPopupMenu *view = new QPopupMenu( this );
112 QPopupMenu *settings = new QPopupMenu( this ); 112 QPopupMenu *settings = new QPopupMenu( this );
113 113
114 mb->insertItem( tr( "View" ), view ); 114 mb->insertItem( tr( "View" ), view );
115 mb->insertItem( tr( "Settings" ), settings ); 115 mb->insertItem( tr( "Settings" ), settings );
116 116
117 QActionGroup *g = new QActionGroup( this ); 117 QActionGroup *g = new QActionGroup( this );
118 g->setExclusive( TRUE ); 118 g->setExclusive( TRUE );
119 119
120 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 120 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
121 QString::null, 0, this, 0 ); 121 QString::null, 0, this, 0 );
122 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 122 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
123 a->addTo( sub_bar ); 123 a->addTo( sub_bar );
124 124
125 a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 ); 125 a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 );
126 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 126 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
127 a->addTo( sub_bar ); 127 a->addTo( sub_bar );
128 a->addTo( view ); 128 a->addTo( view );
129 129
130 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 130 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
131 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 131 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
132 a->addTo( sub_bar ); 132 a->addTo( sub_bar );
133 a->addTo( view ); 133 a->addTo( view );
134 a->setToggleAction( TRUE ); 134 a->setToggleAction( TRUE );
135 a->setOn( TRUE ); 135 a->setOn( TRUE );
136 dayAction = a; 136 dayAction = a;
137 137
138 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 138 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
139 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 139 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
140 a->addTo( sub_bar ); 140 a->addTo( sub_bar );
141 a->addTo( view ); 141 a->addTo( view );
142 a->setToggleAction( TRUE ); 142 a->setToggleAction( TRUE );
143 weekAction = a; 143 weekAction = a;
144 144
145 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 ); 145 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 );
146 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 146 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
147 a->addTo( sub_bar ); 147 a->addTo( sub_bar );
148 a->addTo( view ); 148 a->addTo( view );
149 a->setToggleAction( TRUE ); 149 a->setToggleAction( TRUE );
150 weekLstAction = a; 150 weekLstAction = a;
151 151
152 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 152 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
153 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 153 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
154 a->addTo( sub_bar ); 154 a->addTo( sub_bar );
155 a->addTo( view ); 155 a->addTo( view );
156 a->setToggleAction( TRUE ); 156 a->setToggleAction( TRUE );
157 monthAction = a; 157 monthAction = a;
158 158
159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); 159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 );
160 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 160 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
161 a->addTo( sub_bar ); 161 a->addTo( sub_bar );
162 162
163 a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); 163 a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 );
164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
165 a->addTo( settings ); 165 a->addTo( settings );
166 166
167 QPopupMenu *default_view = new QPopupMenu(this); 167 QPopupMenu *default_view = new QPopupMenu(this);
168 settings->insertItem( tr( "Default View" ),default_view ); 168 settings->insertItem( tr( "Default View" ),default_view );
169 default_view->setCheckable(TRUE); 169 default_view->setCheckable(TRUE);
170 170
171
172 Config config("DateBook"); 171 Config config("DateBook");
173 config.setGroup("Main"); 172 config.setGroup("Main");
174 int current=config.readNumEntry("defaultview", DAY); 173 int current=config.readNumEntry("defaultview", DAY);
175 174
176 QActionGroup *ag = new QActionGroup(this); 175 QActionGroup *ag = new QActionGroup(this);
177 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); 176 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true );
178 if (current==DAY) a->setOn(true), viewDay(); 177 if (current==DAY) a->setOn(true), viewDay();
179 ag->insert(a); 178 ag->insert(a);
180 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); 179 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true );
181 if (current==WEEK) a->setOn(true), viewWeek(); 180 if (current==WEEK) a->setOn(true), viewWeek();
182 ag->insert(a); 181 ag->insert(a);
183 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); 182 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true );
184 if (current==WEEKLST) a->setOn(true), viewWeekLst(); 183 if (current==WEEKLST) a->setOn(true), viewWeekLst();
185 ag->insert(a); 184 ag->insert(a);
186 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); 185 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true );
187 if (current==MONTH) a->setOn(true), viewMonth(); 186 if (current==MONTH) a->setOn(true), viewMonth();
188 ag->insert(a); 187 ag->insert(a);
189 188
190 ag->addTo(default_view); 189 ag->addTo(default_view);
191 connect(ag, SIGNAL( selected ( QAction * ) ), 190 connect(ag, SIGNAL( selected ( QAction * ) ),
192 this, SLOT( newDefaultView(QAction *) ) 191 this, SLOT( newDefaultView(QAction *) )
193 ); 192 );
194 193
195 connect( qApp, SIGNAL(clockChanged(bool)), 194 connect( qApp, SIGNAL(clockChanged(bool)),
196 this, SLOT(changeClock(bool)) ); 195 this, SLOT(changeClock(bool)) );
197 connect( qApp, SIGNAL(weekChanged(bool)), 196 connect( qApp, SIGNAL(weekChanged(bool)),
198 this, SLOT(changeWeek(bool)) ); 197 this, SLOT(changeWeek(bool)) );
199 198
200#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 199#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
201 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 200 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
202 this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 201 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
203#endif 202#endif
204 203
205 // listen on QPE/System 204 // listen on QPE/System
206#if defined(Q_WS_QWS) 205#if defined(Q_WS_QWS)
207#if !defined(QT_NO_COP) 206#if !defined(QT_NO_COP)
208 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 207 QCopChannel *channel = new QCopChannel( "QPE/System", this );
209 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 208 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
210 this, SLOT(receive(const QCString&, const QByteArray&)) ); 209 this, SLOT(receive(const QCString&, const QByteArray&)) );
211#endif 210#endif
212#endif 211#endif
213 212
214 qDebug("done t=%d", t.elapsed() ); 213 qDebug("done t=%d", t.elapsed() );
215 214
216} 215}
217 216
218void DateBook::receive( const QCString &msg, const QByteArray &data ) 217void DateBook::receive( const QCString &msg, const QByteArray &data )
219{ 218{
220 QDataStream stream( data, IO_ReadOnly ); 219 QDataStream stream( data, IO_ReadOnly );
221 if ( msg == "timeChange(QString)" ) { 220 if ( msg == "timeChange(QString)" ) {
222 // update active view! 221 // update active view!
223 if ( dayAction->isOn() ) 222 if ( dayAction->isOn() )
224 viewDay(); 223 viewDay();
225 else if ( weekAction->isOn() ) 224 else if ( weekAction->isOn() )
226 viewWeek(); 225 viewWeek();
227 else if ( monthAction->isOn() ) 226 else if ( monthAction->isOn() )
228 viewMonth(); 227 viewMonth();
229 } 228 }
230} 229}
231 230
232DateBook::~DateBook() 231DateBook::~DateBook()
233{ 232{
234} 233}
235 234
236void DateBook::slotSettings() 235void DateBook::slotSettings()
237{ 236{
238 DateBookSettings frmSettings( ampm, this ); 237 DateBookSettings frmSettings( ampm, this );
239 frmSettings.setStartTime( startTime ); 238 frmSettings.setStartTime( startTime );
240 frmSettings.setAlarmPreset( aPreset, presetTime ); 239 frmSettings.setAlarmPreset( aPreset, presetTime );
241#if defined (Q_WS_QWS) || defined(_WS_QWS_) 240#if defined (Q_WS_QWS) || defined(_WS_QWS_)
242 frmSettings.showMaximized(); 241 frmSettings.showMaximized();
243#endif 242#endif
244 243
245 if ( frmSettings.exec() ) { 244 if ( frmSettings.exec() ) {
246 aPreset = frmSettings.alarmPreset(); 245 aPreset = frmSettings.alarmPreset();
247 presetTime = frmSettings.presetTime(); 246 presetTime = frmSettings.presetTime();
248 startTime = frmSettings.startTime(); 247 startTime = frmSettings.startTime();
249 if ( dayView ) 248 if ( dayView )
250 dayView->setStartViewTime( startTime ); 249 dayView->setStartViewTime( startTime );
251 if ( weekView ) 250 if ( weekView )
252 weekView->setStartViewTime( startTime ); 251 weekView->setStartViewTime( startTime );
253 saveSettings(); 252 saveSettings();
254 253
255 // make the change obvious 254 // make the change obvious
256 if ( views->visibleWidget() ) { 255 if ( views->visibleWidget() ) {
257 if ( views->visibleWidget() == dayView ) 256 if ( views->visibleWidget() == dayView )
258 dayView->redraw(); 257 dayView->redraw();
259 else if ( views->visibleWidget() == weekView ) 258 else if ( views->visibleWidget() == weekView )
260 weekView->redraw(); 259 weekView->redraw();
261 } 260 }
262 } 261 }
263} 262}
264 263
265void DateBook::fileNew() 264void DateBook::fileNew()
266{ 265{
267 slotNewEventFromKey(""); 266 slotNewEventFromKey("");
268} 267}
269 268
270QString DateBook::checkEvent(const Event &e) 269QString DateBook::checkEvent(const Event &e)
271{ 270{
272 /* check if overlaps with itself */ 271 /* check if overlaps with itself */
273 bool checkFailed = FALSE; 272 bool checkFailed = FALSE;
274 273
275 /* check the next 12 repeats. should catch most problems */ 274 /* check the next 12 repeats. should catch most problems */
276 QDate current_date = e.start().date(); 275 QDate current_date = e.start().date();
277 Event previous = e; 276 Event previous = e;
278 for(int i = 0; i < 12; i++) 277 for(int i = 0; i < 12; i++)
279 { 278 {
280 QDateTime next; 279 QDateTime next;
281 if (!nextOccurance(previous, current_date.addDays(1), next)) { 280 if (!nextOccurance(previous, current_date.addDays(1), next)) {
282 break; // no more repeats 281 break; // no more repeats
283 } 282 }
284 if(next < previous.end()) { 283 if(next < previous.end()) {
285 checkFailed = TRUE; 284 checkFailed = TRUE;
286 break; 285 break;
287 } 286 }
288 current_date = next.date(); 287 current_date = next.date();
289 } 288 }
290 289
291 if(checkFailed) 290 if(checkFailed)
292 return tr("Event duration is potentially longer\n" 291 return tr("Event duration is potentially longer\n"
293 "than interval between repeats."); 292 "than interval between repeats.");
294 293
295 return QString::null; 294 return QString::null;
296} 295}
297 296
298QDate DateBook::currentDate() 297QDate DateBook::currentDate()
299{ 298{
300 QDate d = QDate::currentDate(); 299 QDate d = QDate::currentDate();
301 300
302 if ( dayView && views->visibleWidget() == dayView ) { 301 if ( dayView && views->visibleWidget() == dayView ) {
303 d = dayView->date(); 302 d = dayView->date();
304 } else if ( weekView && views->visibleWidget() == weekView ) { 303 } else if ( weekView && views->visibleWidget() == weekView ) {
305 d = weekView->date(); 304 d = weekView->date();
306 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 305 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
307 d = weekLstView->date(); 306 d = weekLstView->date();
308 } else if ( monthView && views->visibleWidget() == monthView ) { 307 } else if ( monthView && views->visibleWidget() == monthView ) {
309 d = monthView->selectedDate(); 308 d = monthView->selectedDate();
310 } 309 }
311 310
312 return d; 311 return d;
313} 312}
314 313
315void DateBook::viewDay() 314void DateBook::view(int v, const QDate &d) {
316{ 315 if (v==DAY) {
317 initDay(); 316 initDay();
318 dayAction->setOn( TRUE ); 317 dayAction->setOn( TRUE );
319 QDate d = currentDate(); 318 dayView->setDate( d );
320 dayView->setDate( d ); 319 views->raiseWidget( dayView );
321 views->raiseWidget( dayView ); 320 dayView->redraw();
322 dayView->redraw(); 321 } else if (v==WEEK) {
322 initWeek();
323 weekAction->setOn( TRUE );
324 weekView->setDate( d );
325 views->raiseWidget( weekView );
326 weekView->redraw();
327 } else if (v==WEEKLST) {
328 initWeekLst();
329 weekLstAction->setOn( TRUE );
330 weekLstView->setDate(d);
331 views->raiseWidget( weekLstView );
332 weekLstView->redraw();
333 } else if (v==MONTH) {
334 initMonth();
335 monthAction->setOn( TRUE );
336 monthView->setDate( d.year(), d.month(), d.day() );
337 views->raiseWidget( monthView );
338 monthView->redraw();
339 }
323} 340}
324 341
325void DateBook::viewWeek() 342void DateBook::viewDefault(const QDate &d) {
326{ 343 Config config("DateBook");
327 initWeek(); 344 config.setGroup("Main");
328 weekAction->setOn( TRUE ); 345 int current=config.readNumEntry("defaultview", DAY);
329 QDate d = currentDate(); 346
330 weekView->setDate( d ); 347 view(current,d);
331 views->raiseWidget( weekView ); 348}
332 weekView->redraw(); 349
350void DateBook::viewDay() {
351 view(DAY,currentDate());
352}
353
354void DateBook::viewWeek() {
355 view(WEEK,currentDate());
333} 356}
334 357
335void DateBook::viewWeekLst() { 358void DateBook::viewWeekLst() {
336 initWeekLst(); 359 view(WEEKLST,currentDate());
337 weekLstAction->setOn( TRUE );
338 QDate d=currentDate();
339 weekLstView->setDate(d);
340 views->raiseWidget( weekLstView );
341 weekLstView->redraw();
342} 360}
343 361
344void DateBook::viewMonth() 362void DateBook::viewMonth() {
345{ 363 view(MONTH,currentDate());
346 initMonth();
347 monthAction->setOn( TRUE );
348 QDate d = currentDate();
349 monthView->setDate( d.year(), d.month(), d.day() );
350 views->raiseWidget( monthView );
351 monthView->redraw();
352} 364}
353 365
354void DateBook::editEvent( const Event &e ) 366void DateBook::editEvent( const Event &e )
355{ 367{
356 if (syncing) { 368 if (syncing) {
357 QMessageBox::warning( this, tr("Calendar"), 369 QMessageBox::warning( this, tr("Calendar"),
358 tr( "Can not edit data, currently syncing") ); 370 tr( "Can not edit data, currently syncing") );
359 return; 371 return;
360 } 372 }
361 373
362 // workaround added for text input. 374 // workaround added for text input.
363 QDialog editDlg( this, 0, TRUE ); 375 QDialog editDlg( this, 0, TRUE );
364 DateEntry *entry; 376 DateEntry *entry;
365 editDlg.setCaption( tr("Edit Event") ); 377 editDlg.setCaption( tr("Edit Event") );
366 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 378 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
367 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 379 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
368 sv->setResizePolicy( QScrollView::AutoOneFit ); 380 sv->setResizePolicy( QScrollView::AutoOneFit );
369 // KLUDGE!!! 381 // KLUDGE!!!
370 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 382 sv->setHScrollBarMode( QScrollView::AlwaysOff );
371 vb->addWidget( sv ); 383 vb->addWidget( sv );
372 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 384 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
373 entry->timezone->setEnabled( FALSE ); 385 entry->timezone->setEnabled( FALSE );
374 sv->addChild( entry ); 386 sv->addChild( entry );
375 387
376#if defined(Q_WS_QWS) || defined(_WS_QWS_) 388#if defined(Q_WS_QWS) || defined(_WS_QWS_)
377 editDlg.showMaximized(); 389 editDlg.showMaximized();
378#endif 390#endif
379 while (editDlg.exec() ) { 391 while (editDlg.exec() ) {
380 Event newEv = entry->event(); 392 Event newEv = entry->event();
381 QString error = checkEvent(newEv); 393 QString error = checkEvent(newEv);
382 if (!error.isNull()) { 394 if (!error.isNull()) {
383 if (QMessageBox::warning(this, "error box", 395 if (QMessageBox::warning(this, "error box",
384 error, "Fix it", "Continue", 396 error, "Fix it", "Continue",
385 0, 0, 1) == 0) 397 0, 0, 1) == 0)
386 continue; 398 continue;
387 } 399 }
388 db->editEvent(e, newEv); 400 db->editEvent(e, newEv);
389 emit newEvent(); 401 emit newEvent();
390 break; 402 break;
391 } 403 }
392} 404}
393 405
394void DateBook::removeEvent( const Event &e ) 406void DateBook::removeEvent( const Event &e )
395{ 407{
396 if (syncing) { 408 if (syncing) {
397 QMessageBox::warning( this, tr("Calendar"), 409 QMessageBox::warning( this, tr("Calendar"),
398 tr( "Can not edit data, currently syncing") ); 410 tr( "Can not edit data, currently syncing") );
399 return; 411 return;
400 } 412 }
401 413
402 QString strName = e.description(); 414 QString strName = e.description();
403 415
404 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 416 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
405 return; 417 return;
406 418
407 db->removeEvent( e ); 419 db->removeEvent( e );
408 if ( views->visibleWidget() == dayView && dayView ) 420 if ( views->visibleWidget() == dayView && dayView )
409 dayView->redraw(); 421 dayView->redraw();
410} 422}
411 423
412void DateBook::addEvent( const Event &e ) 424void DateBook::addEvent( const Event &e )
413{ 425{
414 QDate d = e.start().date(); 426 QDate d = e.start().date();
415 initDay(); 427 initDay();
416 dayView->setDate( d ); 428 dayView->setDate( d );
417} 429}
418 430
419void DateBook::showDay( int year, int month, int day ) 431void DateBook::showDay( int year, int month, int day )
420{ 432{
421 initDay(); 433 QDate d(year, month, day);
422 dayView->setDate( year, month, day ); 434 view(DAY,d);
423 views->raiseWidget( dayView );
424 dayAction->setOn( TRUE );
425} 435}
426 436
427void DateBook::initDay() 437void DateBook::initDay()
428{ 438{
429 if ( !dayView ) { 439 if ( !dayView ) {
430 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 440 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
431 views->addWidget( dayView, DAY ); 441 views->addWidget( dayView, DAY );
432 dayView->setStartViewTime( startTime ); 442 dayView->setStartViewTime( startTime );
433 connect( this, SIGNAL( newEvent() ), 443 connect( this, SIGNAL( newEvent() ),
434 dayView, SLOT( redraw() ) ); 444 dayView, SLOT( redraw() ) );
435 connect( dayView, SIGNAL( newEvent() ), 445 connect( dayView, SIGNAL( newEvent() ),
436 this, SLOT( fileNew() ) ); 446 this, SLOT( fileNew() ) );
437 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 447 connect( dayView, SIGNAL( removeEvent( const Event & ) ),
438 this, SLOT( removeEvent( const Event & ) ) ); 448 this, SLOT( removeEvent( const Event & ) ) );
439 connect( dayView, SIGNAL( editEvent( const Event & ) ), 449 connect( dayView, SIGNAL( editEvent( const Event & ) ),
440 this, SLOT( editEvent( const Event & ) ) ); 450 this, SLOT( editEvent( const Event & ) ) );
441 connect( dayView, SIGNAL( beamEvent( const Event & ) ), 451 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
442 this, SLOT( beamEvent( const Event & ) ) ); 452 this, SLOT( beamEvent( const Event & ) ) );
443 connect( dayView, SIGNAL(sigNewEvent(const QString &)), 453 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
444 this, SLOT(slotNewEventFromKey(const QString &)) ); 454 this, SLOT(slotNewEventFromKey(const QString &)) );
445 } 455 }
446} 456}
447 457
448void DateBook::initWeek() 458void DateBook::initWeek()
449{ 459{
450 if ( !weekView ) { 460 if ( !weekView ) {
451 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 461 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
452 weekView->setStartViewTime( startTime ); 462 weekView->setStartViewTime( startTime );
453 views->addWidget( weekView, WEEK ); 463 views->addWidget( weekView, WEEK );
454 connect( weekView, SIGNAL( showDate( int, int, int ) ), 464 connect( weekView, SIGNAL( showDate( int, int, int ) ),
455 this, SLOT( showDay( int, int, int ) ) ); 465 this, SLOT( showDay( int, int, int ) ) );
456 connect( this, SIGNAL( newEvent() ), 466 connect( this, SIGNAL( newEvent() ),
457 weekView, SLOT( redraw() ) ); 467 weekView, SLOT( redraw() ) );
458 } 468 }
459 //But also get it right: the year that we display can be different 469 //But also get it right: the year that we display can be different
460 //from the year of the current date. So, first find the year 470 //from the year of the current date. So, first find the year
461 //number of the current week. 471 //number of the current week.
462 472
463 int yearNumber, totWeeks; 473 int yearNumber, totWeeks;
464 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 474 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
465 475
466 QDate d = QDate( yearNumber, 12, 31 ); 476 QDate d = QDate( yearNumber, 12, 31 );
467 calcWeek( d, totWeeks, yearNumber, onMonday ); 477 calcWeek( d, totWeeks, yearNumber, onMonday );
468 478
469 while ( totWeeks == 1 ) { 479 while ( totWeeks == 1 ) {
470 d = d.addDays( -1 ); 480 d = d.addDays( -1 );
471 calcWeek( d, totWeeks, yearNumber, onMonday ); 481 calcWeek( d, totWeeks, yearNumber, onMonday );
472 } 482 }
473 if ( totWeeks != weekView->totalWeeks() ) 483 if ( totWeeks != weekView->totalWeeks() )
474 weekView->setTotalWeeks( totWeeks ); 484 weekView->setTotalWeeks( totWeeks );
475} 485}
476void DateBook::initWeekLst() { 486void DateBook::initWeekLst() {
477 if ( !weekLstView ) { 487 if ( !weekLstView ) {
478 weekLstView = new DateBookWeekLst( ampm, onMonday, db, 488 weekLstView = new DateBookWeekLst( ampm, onMonday, db,
479 views, "weeklst view" ); 489 views, "weeklst view" );
480 views->addWidget( weekLstView, WEEKLST ); 490 views->addWidget( weekLstView, WEEKLST );
481 491
482 //weekLstView->setStartViewTime( startTime ); 492 //weekLstView->setStartViewTime( startTime );
483 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), 493 connect( weekLstView, SIGNAL( showDate( int, int, int ) ),
484 this, SLOT( showDay( int, int, int ) ) ); 494 this, SLOT( showDay( int, int, int ) ) );
485 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, 495 connect( weekLstView, SIGNAL( addEvent( const QDateTime &,
486 const QDateTime &, 496 const QDateTime &,
487 const QString & ) ), 497 const QString & ) ),
488 this, SLOT( slotNewEntry( const QDateTime &, 498 this, SLOT( slotNewEntry( const QDateTime &,
489 const QDateTime &, 499 const QDateTime &,
490 const QString & ) ) ); 500 const QString & ) ) );
491 connect( this, SIGNAL( newEvent() ), 501 connect( this, SIGNAL( newEvent() ),
492 weekLstView, SLOT( redraw() ) ); 502 weekLstView, SLOT( redraw() ) );
493 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), 503 connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
494 this, SLOT( editEvent( const Event & ) ) ); 504 this, SLOT( editEvent( const Event & ) ) );
495 } 505 }
496} 506}
497 507
498 508
499void DateBook::initMonth() 509void DateBook::initMonth()
500{ 510{
501 if ( !monthView ) { 511 if ( !monthView ) {
502 monthView = new DateBookMonth( views, "month view", FALSE, db ); 512 monthView = new DateBookMonth( views, "month view", FALSE, db );
503 views->addWidget( monthView, MONTH ); 513 views->addWidget( monthView, MONTH );
504 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), 514 connect( monthView, SIGNAL( dateClicked( int, int, int ) ),
505 this, SLOT( showDay( int, int, int ) ) ); 515 this, SLOT( showDay( int, int, int ) ) );
506 connect( this, SIGNAL( newEvent() ), 516 connect( this, SIGNAL( newEvent() ),
507 monthView, SLOT( redraw() ) ); 517 monthView, SLOT( redraw() ) );
508 qApp->processEvents(); 518 qApp->processEvents();
509 } 519 }
510} 520}
511 521
512void DateBook::loadSettings() 522void DateBook::loadSettings()
513{ 523{
514 { 524 {
515 Config config( "qpe" ); 525 Config config( "qpe" );
516 config.setGroup("Time"); 526 config.setGroup("Time");
517 ampm = config.readBoolEntry( "AMPM", TRUE ); 527 ampm = config.readBoolEntry( "AMPM", TRUE );
518 onMonday = config.readBoolEntry( "MONDAY" ); 528 onMonday = config.readBoolEntry( "MONDAY" );
519 } 529 }
520 530
521 { 531 {
522 Config config("DateBook"); 532 Config config("DateBook");
523 config.setGroup("Main"); 533 config.setGroup("Main");
524 startTime = config.readNumEntry("startviewtime", 8); 534 startTime = config.readNumEntry("startviewtime", 8);
525 aPreset = config.readBoolEntry("alarmpreset"); 535 aPreset = config.readBoolEntry("alarmpreset");
526 presetTime = config.readNumEntry("presettime"); 536 presetTime = config.readNumEntry("presettime");
527 } 537 }
528} 538}
529 539
530void DateBook::saveSettings() 540void DateBook::saveSettings()
531{ 541{
532 Config config( "qpe" ); 542 Config config( "qpe" );
533 Config configDB( "DateBook" ); 543 Config configDB( "DateBook" );
534 configDB.setGroup( "Main" ); 544 configDB.setGroup( "Main" );
535 configDB.writeEntry("startviewtime",startTime); 545 configDB.writeEntry("startviewtime",startTime);
536 configDB.writeEntry("alarmpreset",aPreset); 546 configDB.writeEntry("alarmpreset",aPreset);
537 configDB.writeEntry("presettime",presetTime); 547 configDB.writeEntry("presettime",presetTime);
538} 548}
539 549
540void DateBook::newDefaultView(QAction *a) { 550void DateBook::newDefaultView(QAction *a) {
541 int val=DAY; 551 int val=DAY;
542 if (a->text() == "Day") val=DAY; 552 if (a->text() == "Day") val=DAY;
543 if (a->text() == "Week") val=WEEK; 553 if (a->text() == "Week") val=WEEK;
544 if (a->text() == "WeekLst") val=WEEKLST; 554 if (a->text() == "WeekLst") val=WEEKLST;
545 if (a->text() == "Month") val=MONTH; 555 if (a->text() == "Month") val=MONTH;
546 556
547 Config configDB( "DateBook" ); 557 Config configDB( "DateBook" );
548 configDB.setGroup( "Main" ); 558 configDB.setGroup( "Main" );
549 configDB.writeEntry("defaultview",val); 559 configDB.writeEntry("defaultview",val);
550} 560}
551 561
552void DateBook::appMessage(const QCString& msg, const QByteArray& data) 562void DateBook::appMessage(const QCString& msg, const QByteArray& data)
553{ 563{
554 bool needShow = FALSE; 564 bool needShow = FALSE;
555 if ( msg == "alarm(QDateTime,int)" ) { 565 if ( msg == "alarm(QDateTime,int)" ) {
556 QDataStream ds(data,IO_ReadOnly); 566 QDataStream ds(data,IO_ReadOnly);
557 QDateTime when; int warn; 567 QDateTime when; int warn;
558 ds >> when >> warn; 568 ds >> when >> warn;
559 569
560 // check to make it's okay to continue, 570 // check to make it's okay to continue,
561 // this is the case that the time was set ahead, and 571 // this is the case that the time was set ahead, and
562 // we are forced given a stale alarm... 572 // we are forced given a stale alarm...
563 QDateTime current = QDateTime::currentDateTime(); 573 QDateTime current = QDateTime::currentDateTime();
564 if ( current.time().hour() != when.time().hour() 574 if ( current.time().hour() != when.time().hour()
565 && current.time().minute() != when.time().minute() ) 575 && current.time().minute() != when.time().minute() )
566 return; 576 return;
567 577
568 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 578 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
569 if ( list.count() > 0 ) { 579 if ( list.count() > 0 ) {
570 QString msg; 580 QString msg;
571 bool bSound = FALSE; 581 bool bSound = FALSE;
572 int stopTimer = 0; 582 int stopTimer = 0;
573 bool found = FALSE; 583 bool found = FALSE;
574 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); 584 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin();
575 it!=list.end(); ++it ) { 585 it!=list.end(); ++it ) {
576 if ( (*it).event().hasAlarm() ) { 586 if ( (*it).event().hasAlarm() ) {
577 found = TRUE; 587 found = TRUE;
578 msg += "<CENTER><B>" + (*it).description() + "</B>" 588 msg += "<CENTER><B>" + (*it).description() + "</B>"
579 + "<BR>" + (*it).location() + "<BR>" 589 + "<BR>" + (*it).location() + "<BR>"
580 + TimeString::dateString((*it).event().start(),ampm) 590 + TimeString::dateString((*it).event().start(),ampm)
581 + (warn 591 + (warn
582 ? tr(" (in " + QString::number(warn) 592 ? tr(" (in " + QString::number(warn)
583 + tr(" minutes)")) 593 + tr(" minutes)"))
584 : QString("")) 594 : QString(""))
585 + "<BR>" 595 + "<BR>"
586 + (*it).notes() + "</CENTER>"; 596 + (*it).notes() + "</CENTER>";
587 if ( (*it).event().alarmSound() != Event::Silent ) { 597 if ( (*it).event().alarmSound() != Event::Silent ) {
588 bSound = TRUE; 598 bSound = TRUE;
589 } 599 }
590 } 600 }
591 } 601 }
592 if ( found ) { 602 if ( found ) {
593 if ( bSound ) { 603 if ( bSound ) {
594 Sound::soundAlarm(); 604 Sound::soundAlarm();
595 stopTimer = startTimer( 5000 ); 605 stopTimer = startTimer( 5000 );
596 } 606 }
597 607
598 QDialog dlg( this, 0, TRUE ); 608 QDialog dlg( this, 0, TRUE );
599 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 609 QVBoxLayout *vb = new QVBoxLayout( &dlg );
600 QScrollView *view = new QScrollView( &dlg, "scrollView"); 610 QScrollView *view = new QScrollView( &dlg, "scrollView");
601 view->setResizePolicy( QScrollView::AutoOneFit ); 611 view->setResizePolicy( QScrollView::AutoOneFit );
602 vb->addWidget( view ); 612 vb->addWidget( view );
603 QLabel *lblMsg = new QLabel( msg, &dlg ); 613 QLabel *lblMsg = new QLabel( msg, &dlg );
604 view->addChild( lblMsg ); 614 view->addChild( lblMsg );
605 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 615 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
606 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 616 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
607 vb->addWidget( cmdOk ); 617 vb->addWidget( cmdOk );
608 618
609#if defined(Q_WS_QWS) || defined(_WS_QWS_) 619#if defined(Q_WS_QWS) || defined(_WS_QWS_)
610 dlg.showMaximized(); 620 dlg.showMaximized();
611#endif 621#endif
612 needShow = dlg.exec(); 622 needShow = dlg.exec();
613 623
614 if ( bSound ) 624 if ( bSound )
615 killTimer( stopTimer ); 625 killTimer( stopTimer );
616 } 626 }
617 } 627 }
618 } else if ( msg == "nextView()" ) { 628 } else if ( msg == "nextView()" ) {
619 QWidget* cur = views->visibleWidget(); 629 QWidget* cur = views->visibleWidget();
620 if ( cur ) { 630 if ( cur ) {
621 if ( cur == dayView ) 631 if ( cur == dayView )
622 viewWeek(); 632 viewWeek();
623 else if ( cur == weekView ) 633 else if ( cur == weekView )
624 viewWeekLst(); 634 viewWeekLst();
625 else if ( cur == weekLstView ) 635 else if ( cur == weekLstView )
626 viewMonth(); 636 viewMonth();
627 else if ( cur == monthView ) 637 else if ( cur == monthView )
628 viewDay(); 638 viewDay();
629 needShow = TRUE; 639 needShow = TRUE;
630 } 640 }
631 } 641 }
632 if ( needShow ) { 642 if ( needShow ) {
633#if defined(Q_WS_QWS) || defined(_WS_QWS_) 643#if defined(Q_WS_QWS) || defined(_WS_QWS_)
634 showMaximized(); 644 showMaximized();
635#else 645#else
636 show(); 646 show();
637#endif 647#endif
638 raise(); 648 raise();
639 QPEApplication::setKeepRunning(); 649 QPEApplication::setKeepRunning();
640 setActiveWindow(); 650 setActiveWindow();
641 } 651 }
642} 652}
643 653
644void DateBook::reload() 654void DateBook::reload()
645{ 655{
646 db->reload(); 656 db->reload();
647 if ( dayAction->isOn() ) 657 if ( dayAction->isOn() )
648 viewDay(); 658 viewDay();
649 else if ( weekAction->isOn() ) 659 else if ( weekAction->isOn() )
650 viewWeek(); 660 viewWeek();
651 else if ( monthAction->isOn() ) 661 else if ( monthAction->isOn() )
652 viewMonth(); 662 viewMonth();
653 syncing = FALSE; 663 syncing = FALSE;
654} 664}
655 665
656void DateBook::flush() 666void DateBook::flush()
657{ 667{
658 syncing = TRUE; 668 syncing = TRUE;
659 db->save(); 669 db->save();
660} 670}
661 671
662void DateBook::timerEvent( QTimerEvent *e ) 672void DateBook::timerEvent( QTimerEvent *e )
663{ 673{
664 static int stop = 0; 674 static int stop = 0;
665 if ( stop < 10 ) { 675 if ( stop < 10 ) {
666 Sound::soundAlarm(); 676 Sound::soundAlarm();
667 stop++; 677 stop++;
668 } else { 678 } else {
669 stop = 0; 679 stop = 0;
670 killTimer( e->timerId() ); 680 killTimer( e->timerId() );
671 } 681 }
672} 682}
673 683
674void DateBook::changeClock( bool newClock ) 684void DateBook::changeClock( bool newClock )
675{ 685{
676 ampm = newClock; 686 ampm = newClock;
677 // repaint the affected objects... 687 // repaint the affected objects...
678 if (dayView) dayView->redraw(); 688 if (dayView) dayView->redraw();
679 if (weekView) weekView->redraw(); 689 if (weekView) weekView->redraw();
680 if (weekLstView) weekLstView->redraw(); 690 if (weekLstView) weekLstView->redraw();
681} 691}
682 692
683void DateBook::changeWeek( bool m ) 693void DateBook::changeWeek( bool m )
684{ 694{
685 /* no need to redraw, each widget catches. Do need to 695 /* no need to redraw, each widget catches. Do need to
686 store though for widgets we haven't made yet */ 696 store though for widgets we haven't made yet */
687 onMonday = m; 697 onMonday = m;
688} 698}
689 699
690void DateBook::slotToday() 700void DateBook::slotToday()
691{ 701{
692 // we need to view today 702 // we need to view today using default view
693 QDate dt = QDate::currentDate(); 703 viewDefault(QDate::currentDate());
694 showDay( dt.year(), dt.month(), dt.day() );
695} 704}
696 705
697void DateBook::closeEvent( QCloseEvent *e ) 706void DateBook::closeEvent( QCloseEvent *e )
698{ 707{
699 if(syncing) { 708 if(syncing) {
700 /* no need to save, did that at flush */ 709 /* no need to save, did that at flush */
701 e->accept(); 710 e->accept();
702 return; 711 return;
703 } 712 }
704 713
705 // save settings will generate it's own error messages, no 714 // save settings will generate it's own error messages, no
706 // need to do checking ourselves. 715 // need to do checking ourselves.
707 saveSettings(); 716 saveSettings();
708 if ( db->save() ) 717 if ( db->save() )
709 e->accept(); 718 e->accept();
710 else { 719 else {
711 if ( QMessageBox::critical( this, tr( "Out of space" ), 720 if ( QMessageBox::critical( this, tr( "Out of space" ),
712 tr("Calendar was unable to save\n" 721 tr("Calendar was unable to save\n"
713 "your changes.\n" 722 "your changes.\n"
714 "Free up some space and try again.\n" 723 "Free up some space and try again.\n"
715 "\nQuit anyway?"), 724 "\nQuit anyway?"),
716 QMessageBox::Yes|QMessageBox::Escape, 725 QMessageBox::Yes|QMessageBox::Escape,
717 QMessageBox::No|QMessageBox::Default ) 726 QMessageBox::No|QMessageBox::Default )
718 != QMessageBox::No ) 727 != QMessageBox::No )
719 e->accept(); 728 e->accept();
720 else 729 else
721 e->ignore(); 730 e->ignore();
722 } 731 }
723} 732}
724 733
725// Entering directly from the "keyboard" 734// Entering directly from the "keyboard"
726void DateBook::slotNewEventFromKey( const QString &str ) 735void DateBook::slotNewEventFromKey( const QString &str )
727{ 736{
728 if (syncing) { 737 if (syncing) {
729 QMessageBox::warning( this, tr("Calendar"), 738 QMessageBox::warning( this, tr("Calendar"),
730 tr( "Can not edit data, currently syncing") ); 739 tr( "Can not edit data, currently syncing") );
731 return; 740 return;
732 } 741 }
733 742
734 // We get to here from a key pressed in the Day View 743 // We get to here from a key pressed in the Day View
735 // So we can assume some things. We want the string 744 // So we can assume some things. We want the string
736 // passed in to be part of the description. 745 // passed in to be part of the description.
737 QDateTime start, end; 746 QDateTime start, end;
738 if ( views->visibleWidget() == dayView ) { 747 if ( views->visibleWidget() == dayView ) {
739 dayView->selectedDates( start, end ); 748 dayView->selectedDates( start, end );
740 } else if ( views->visibleWidget() == monthView ) { 749 } else if ( views->visibleWidget() == monthView ) {
741 QDate d = monthView->selectedDate(); 750 QDate d = monthView->selectedDate();
742 start = end = d; 751 start = end = d;
743 start.setTime( QTime( 10, 0 ) ); 752 start.setTime( QTime( 10, 0 ) );
744 end.setTime( QTime( 12, 0 ) ); 753 end.setTime( QTime( 12, 0 ) );
745 } else if ( views->visibleWidget() == weekView ) { 754 } else if ( views->visibleWidget() == weekView ) {
746 QDate d = weekView->date(); 755 QDate d = weekView->date();
747 start = end = d; 756 start = end = d;
748 start.setTime( QTime( 10, 0 ) ); 757 start.setTime( QTime( 10, 0 ) );
749 end.setTime( QTime( 12, 0 ) ); 758 end.setTime( QTime( 12, 0 ) );
750 } 759 }
751 slotNewEntry(start, end, str); 760 slotNewEntry(start, end, str);
752} 761}
753void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { 762void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) {
754 // argh! This really needs to be encapsulated in a class 763 // argh! This really needs to be encapsulated in a class
755 // or function. 764 // or function.
756 QDialog newDlg( this, 0, TRUE ); 765 QDialog newDlg( this, 0, TRUE );
757 newDlg.setCaption( DateEntryBase::tr("New Event") ); 766 newDlg.setCaption( DateEntryBase::tr("New Event") );
758 DateEntry *e; 767 DateEntry *e;
759 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 768 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
760 QScrollView *sv = new QScrollView( &newDlg ); 769 QScrollView *sv = new QScrollView( &newDlg );
761 sv->setResizePolicy( QScrollView::AutoOneFit ); 770 sv->setResizePolicy( QScrollView::AutoOneFit );
762 sv->setFrameStyle( QFrame::NoFrame ); 771 sv->setFrameStyle( QFrame::NoFrame );
763 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 772 sv->setHScrollBarMode( QScrollView::AlwaysOff );
764 vb->addWidget( sv ); 773 vb->addWidget( sv );
765 774
766 Event ev; 775 Event ev;
767 ev.setDescription( str ); 776 ev.setDescription( str );
768 // When the new gui comes in, change this... 777 // When the new gui comes in, change this...
769 ev.setLocation( tr("(Unknown)") ); 778 ev.setLocation( tr("(Unknown)") );
770 ev.setStart( start ); 779 ev.setStart( start );
771 ev.setEnd( end ); 780 ev.setEnd( end );
772 781
773 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 782 e = new DateEntry( onMonday, ev, ampm, &newDlg );
774 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 783 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
775 sv->addChild( e ); 784 sv->addChild( e );
776#if defined(Q_WS_QWS) || defined(_WS_QWS_) 785#if defined(Q_WS_QWS) || defined(_WS_QWS_)
777 newDlg.showMaximized(); 786 newDlg.showMaximized();
778#endif 787#endif
779 while (newDlg.exec()) { 788 while (newDlg.exec()) {
780 ev = e->event(); 789 ev = e->event();
781 ev.assignUid(); 790 ev.assignUid();
782 QString error = checkEvent( ev ); 791 QString error = checkEvent( ev );
783 if ( !error.isNull() ) { 792 if ( !error.isNull() ) {
784 if ( QMessageBox::warning( this, tr("Error!"), 793 if ( QMessageBox::warning( this, tr("Error!"),
785 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 794 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
786 continue; 795 continue;
787 } 796 }
788 db->addEvent( ev ); 797 db->addEvent( ev );
789 emit newEvent(); 798 emit newEvent();
790 break; 799 break;
791 } 800 }
792} 801}
793 802
794void DateBook::setDocument( const QString &filename ) 803void DateBook::setDocument( const QString &filename )
795{ 804{
796 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 805 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
797 806
798 QValueList<Event> tl = Event::readVCalendar( filename ); 807 QValueList<Event> tl = Event::readVCalendar( filename );
799 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 808 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
800 db->addEvent( *it ); 809 db->addEvent( *it );
801 } 810 }
802} 811}
803 812
804static const char * beamfile = "/tmp/obex/event.vcs"; 813static const char * beamfile = "/tmp/obex/event.vcs";
805 814
806void DateBook::beamEvent( const Event &e ) 815void DateBook::beamEvent( const Event &e )
807{ 816{
808 qDebug("trying to beamn"); 817 qDebug("trying to beamn");
809 unlink( beamfile ); // delete if exists 818 unlink( beamfile ); // delete if exists
810 mkdir("/tmp/obex/", 0755); 819 mkdir("/tmp/obex/", 0755);
811 Event::writeVCalendar( beamfile, e ); 820 Event::writeVCalendar( beamfile, e );
812 Ir *ir = new Ir( this ); 821 Ir *ir = new Ir( this );
813 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 822 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
814 QString description = e.description(); 823 QString description = e.description();
815 ir->send( beamfile, description, "text/x-vCalendar" ); 824 ir->send( beamfile, description, "text/x-vCalendar" );
816} 825}
817 826
818void DateBook::beamDone( Ir *ir ) 827void DateBook::beamDone( Ir *ir )
819{ 828{
820 delete ir; 829 delete ir;
821 unlink( beamfile ); 830 unlink( beamfile );
822} 831}
823 832
824void DateBook::slotFind() 833void DateBook::slotFind()
825{ 834{
826 // move it to the day view... 835 // move it to the day view...
827 viewDay(); 836 viewDay();
828 FindDialog frmFind( "Calendar", this ); 837 FindDialog frmFind( "Calendar", this );
829 frmFind.setUseDate( true ); 838 frmFind.setUseDate( true );
830 frmFind.setDate( currentDate() ); 839 frmFind.setDate( currentDate() );
831 QObject::connect( &frmFind, 840 QObject::connect( &frmFind,
832 SIGNAL(signalFindClicked(const QString&, const QDate&, 841 SIGNAL(signalFindClicked(const QString&, const QDate&,
833 bool, bool, int)), 842 bool, bool, int)),
834 this, 843 this,
835 SLOT(slotDoFind(const QString&, const QDate&, 844 SLOT(slotDoFind(const QString&, const QDate&,
836 bool, bool, int)) ); 845 bool, bool, int)) );
837 QObject::connect( this, 846 QObject::connect( this,
838 SIGNAL(signalNotFound()), 847 SIGNAL(signalNotFound()),
839 &frmFind, 848 &frmFind,
840 SLOT(slotNotFound()) ); 849 SLOT(slotNotFound()) );
841 QObject::connect( this, 850 QObject::connect( this,
842 SIGNAL(signalWrapAround()), 851 SIGNAL(signalWrapAround()),
843 &frmFind, 852 &frmFind,
844 SLOT(slotWrapAround()) ); 853 SLOT(slotWrapAround()) );
845 frmFind.exec(); 854 frmFind.exec();
846 inSearch = false; 855 inSearch = false;
847} 856}
848 857
849bool catComp( QArray<int> cats, int category ) 858bool catComp( QArray<int> cats, int category )
850{ 859{
851 bool returnMe; 860 bool returnMe;
852 int i, 861 int i,
853 count; 862 count;
854 863
855 count = int(cats.count()); 864 count = int(cats.count());
856 returnMe = false; 865 returnMe = false;
857 if ( (category == -1 && count == 0) || category == -2 ) 866 if ( (category == -1 && count == 0) || category == -2 )
858 returnMe = true; 867 returnMe = true;
859 else { 868 else {
860 for ( i = 0; i < count; i++ ) { 869 for ( i = 0; i < count; i++ ) {
861 if ( category == cats[i] ) { 870 if ( category == cats[i] ) {
862 returnMe = true; 871 returnMe = true;
863 break; 872 break;
864 } 873 }
865 } 874 }
866 } 875 }
867 return returnMe; 876 return returnMe;
868} 877}
869 878
870 879
871void DateBook::slotDoFind( const QString& txt, const QDate &dt, 880void DateBook::slotDoFind( const QString& txt, const QDate &dt,
872 bool caseSensitive, bool /*backwards*/, 881 bool caseSensitive, bool /*backwards*/,
873 int category ) 882 int category )
874{ 883{
875 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 884 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
876 next; 885 next;
877 886
878 QRegExp r( txt ); 887 QRegExp r( txt );
879 r.setCaseSensitive( caseSensitive ); 888 r.setCaseSensitive( caseSensitive );
880 889
881 890
882 static Event rev, 891 static Event rev,
883 nonrev; 892 nonrev;
884 if ( !inSearch ) { 893 if ( !inSearch ) {
885 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 894 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
886 nonrev.setStart( rev.start() ); 895 nonrev.setStart( rev.start() );
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index fcdbfec..2ffcdbe 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -1,117 +1,121 @@
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 DateBook : public QMainWindow 37class DateBook : public QMainWindow
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40 40
41public: 41public:
42 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 42 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
43 ~DateBook(); 43 ~DateBook();
44 44
45signals: 45signals:
46 void newEvent(); 46 void newEvent();
47 void signalNotFound(); 47 void signalNotFound();
48 void signalWrapAround(); 48 void signalWrapAround();
49 49
50protected: 50protected:
51 QDate currentDate(); 51 QDate currentDate();
52 void timerEvent( QTimerEvent *e ); 52 void timerEvent( QTimerEvent *e );
53 void closeEvent( QCloseEvent *e ); 53 void closeEvent( QCloseEvent *e );
54 54
55 void view(int v, const QDate &d);
56
55public slots: 57public slots:
56 void flush(); 58 void flush();
57 void reload(); 59 void reload();
58 60
59private slots: 61private slots:
60 void fileNew(); 62 void fileNew();
61 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str); 63 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str);
62 void slotSettings(); 64 void slotSettings();
63 void newDefaultView(QAction *a); 65 void newDefaultView(QAction *a);
64 void slotToday();// view today 66 void slotToday();// view today
65 void changeClock( bool newClock ); 67 void changeClock( bool newClock );
66 void changeWeek( bool newDay ); 68 void changeWeek( bool newDay );
67 void appMessage(const QCString& msg, const QByteArray& data); 69 void appMessage(const QCString& msg, const QByteArray& data);
68 // handle key events in the day view... 70 // handle key events in the day view...
69 void slotNewEventFromKey( const QString &str ); 71 void slotNewEventFromKey( const QString &str );
70 void slotFind(); 72 void slotFind();
71 void slotDoFind( const QString &, const QDate &, bool, bool, int ); 73 void slotDoFind( const QString &, const QDate &, bool, bool, int );
72 74
75 void viewDefault(const QDate &d);
76
73 void viewDay(); 77 void viewDay();
74 void viewWeek(); 78 void viewWeek();
75 void viewWeekLst(); 79 void viewWeekLst();
76 void viewMonth(); 80 void viewMonth();
77 81
78 void showDay( int y, int m, int d ); 82 void showDay( int y, int m, int d );
79 83
80 void editEvent( const Event &e ); 84 void editEvent( const Event &e );
81 void removeEvent( const Event &e ); 85 void removeEvent( const Event &e );
82 86
83 void receive( const QCString &msg, const QByteArray &data ); 87 void receive( const QCString &msg, const QByteArray &data );
84 void setDocument( const QString & ); 88 void setDocument( const QString & );
85 void beamEvent( const Event &e ); 89 void beamEvent( const Event &e );
86 void beamDone( Ir *ir ); 90 void beamDone( Ir *ir );
87 91
88private: 92private:
89 void addEvent( const Event &e ); 93 void addEvent( const Event &e );
90 void initDay(); 94 void initDay();
91 void initWeek(); 95 void initWeek();
92 void initWeekLst(); 96 void initWeekLst();
93 void initMonth(); 97 void initMonth();
94 void loadSettings(); 98 void loadSettings();
95 void saveSettings(); 99 void saveSettings();
96 100
97private: 101private:
98 DateBookDB *db; 102 DateBookDB *db;
99 QWidgetStack *views; 103 QWidgetStack *views;
100 DateBookDay *dayView; 104 DateBookDay *dayView;
101 DateBookWeek *weekView; 105 DateBookWeek *weekView;
102 DateBookMonth *monthView; 106 DateBookMonth *monthView;
103 DateBookWeekLst *weekLstView; 107 DateBookWeekLst *weekLstView;
104 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 108 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
105 bool aPreset; // have everything set to alarm? 109 bool aPreset; // have everything set to alarm?
106 int presetTime; // the standard time for the alarm 110 int presetTime; // the standard time for the alarm
107 int startTime; 111 int startTime;
108 bool ampm; 112 bool ampm;
109 bool onMonday; 113 bool onMonday;
110 114
111 bool syncing; 115 bool syncing;
112 bool inSearch; 116 bool inSearch;
113 117
114 QString checkEvent(const Event &); 118 QString checkEvent(const Event &);
115}; 119};
116 120
117#endif 121#endif
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 05e36be..dc141c0 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,314 +1,314 @@
1#include "datebookweeklst.h" 1#include "datebookweeklst.h"
2 2
3#include "datebookweekheaderimpl.h" 3#include "datebookweekheaderimpl.h"
4 4
5#include <qpe/calendar.h> 5#include <qpe/calendar.h>
6#include <qpe/datebookdb.h> 6#include <qpe/datebookdb.h>
7#include <qpe/event.h> 7#include <qpe/event.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/timestring.h> 9#include <qpe/timestring.h>
10#include <qpe/datebookmonth.h> 10#include <qpe/datebookmonth.h>
11 11
12#include <qdatetime.h> 12#include <qdatetime.h>
13#include <qheader.h> 13#include <qheader.h>
14#include <qlabel.h> 14#include <qlabel.h>
15#include <qlayout.h> 15#include <qlayout.h>
16#include <qpainter.h> 16#include <qpainter.h>
17#include <qpopupmenu.h> 17#include <qpopupmenu.h>
18#include <qtimer.h> 18#include <qtimer.h>
19#include <qstyle.h> 19#include <qstyle.h>
20#include <qtoolbutton.h> 20#include <qtoolbutton.h>
21#include <qvbox.h> 21#include <qvbox.h>
22#include <qsizepolicy.h> 22#include <qsizepolicy.h>
23#include <qabstractlayout.h> 23#include <qabstractlayout.h>
24#include <qtl.h> 24#include <qtl.h>
25 25
26bool calcWeek(const QDate &d, int &week, int &year, 26bool calcWeek(const QDate &d, int &week, int &year,
27 bool startOnMonday = false); 27 bool startOnMonday = false);
28 28
29DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, 29DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
30 const char* name, WFlags fl) 30 const char* name, WFlags fl)
31 : DateBookWeekLstHeaderBase(parent, name, fl) 31 : DateBookWeekLstHeaderBase(parent, name, fl)
32{ 32{
33 setBackgroundMode( PaletteButton ); 33 setBackgroundMode( PaletteButton );
34 labelDate->setBackgroundMode( PaletteButton ); 34 labelDate->setBackgroundMode( PaletteButton );
35 labelWeek->setBackgroundMode( PaletteButton ); 35 labelWeek->setBackgroundMode( PaletteButton );
36 forward->setBackgroundMode( PaletteButton ); 36 forward->setBackgroundMode( PaletteButton );
37 back->setBackgroundMode( PaletteButton ); 37 back->setBackgroundMode( PaletteButton );
38 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 38 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
39 DateBookWeekLstHeaderBaseLayout->setMargin(0); 39 DateBookWeekLstHeaderBaseLayout->setMargin(0);
40 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 40 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
41 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 41 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
42 42
43 connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); 43 connect(back, SIGNAL(clicked()), this, SLOT(prevWeek()));
44 connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); 44 connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek()));
45 connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); 45 connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate()));
46 onMonday=onM; 46 onMonday=onM;
47} 47}
48DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 48DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
49void DateBookWeekLstHeader::setDate(QDate d) { 49void DateBookWeekLstHeader::setDate(const QDate &d) {
50 date=d; 50 date=d;
51 51
52 int year,week; 52 int year,week;
53 calcWeek(d,week,year,onMonday); 53 calcWeek(d,week,year,onMonday);
54 labelWeek->setText("W: " + QString::number(week)); 54 labelWeek->setText("W: " + QString::number(week));
55 55
56 QDate start=date; 56 QDate start=date;
57 QDate stop=start.addDays(6); 57 QDate stop=start.addDays(6);
58 labelDate->setText( QString::number(start.day()) + " " + 58 labelDate->setText( QString::number(start.day()) + " " +
59 start.monthName(start.month()) + " - " + 59 start.monthName(start.month()) + " - " +
60 QString::number(stop.day()) + " " + 60 QString::number(stop.day()) + " " +
61 start.monthName(stop.month()) ); 61 start.monthName(stop.month()) );
62 emit dateChanged(year,week); 62 emit dateChanged(year,week);
63} 63}
64void DateBookWeekLstHeader::pickDate() { 64void DateBookWeekLstHeader::pickDate() {
65 static QPopupMenu *m1 = 0; 65 static QPopupMenu *m1 = 0;
66 static DateBookMonth *picker = 0; 66 static DateBookMonth *picker = 0;
67 if ( !m1 ) { 67 if ( !m1 ) {
68 m1 = new QPopupMenu( this ); 68 m1 = new QPopupMenu( this );
69 picker = new DateBookMonth( m1, 0, TRUE ); 69 picker = new DateBookMonth( m1, 0, TRUE );
70 m1->insertItem( picker ); 70 m1->insertItem( picker );
71 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 71 connect( picker, SIGNAL( dateClicked( int, int, int ) ),
72 this, SLOT( setDate( int, int, int ) ) ); 72 this, SLOT( setDate( int, int, int ) ) );
73 //connect( m1, SIGNAL( aboutToHide() ), 73 //connect( m1, SIGNAL( aboutToHide() ),
74 //this, SLOT( gotHide() ) ); 74 //this, SLOT( gotHide() ) );
75 } 75 }
76 picker->setDate( date.year(), date.month(), date.day() ); 76 picker->setDate( date.year(), date.month(), date.day() );
77 m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height()))); 77 m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height())));
78 picker->setFocus(); 78 picker->setFocus();
79} 79}
80void DateBookWeekLstHeader::setDate(int y, int m, int d) { 80void DateBookWeekLstHeader::setDate(int y, int m, int d) {
81 QDate new_date(y,m,d); 81 QDate new_date(y,m,d);
82 setDate(new_date); 82 setDate(new_date);
83} 83}
84 84
85void DateBookWeekLstHeader::nextWeek() { 85void DateBookWeekLstHeader::nextWeek() {
86 setDate(date.addDays(7)); 86 setDate(date.addDays(7));
87} 87}
88void DateBookWeekLstHeader::prevWeek() { 88void DateBookWeekLstHeader::prevWeek() {
89 setDate(date.addDays(-7)); 89 setDate(date.addDays(-7));
90} 90}
91 91
92DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool onM, 92DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool onM,
93 QWidget* parent = 0, 93 QWidget* parent = 0,
94 const char* name = 0, 94 const char* name = 0,
95 WFlags fl = 0 ) 95 WFlags fl = 0 )
96 : DateBookWeekLstDayHdrBase(parent, name, fl) { 96 : DateBookWeekLstDayHdrBase(parent, name, fl) {
97 97
98 date=d; 98 date=d;
99 99
100 static const char *wdays="MTWTFSS"; 100 static const char *wdays="MTWTFSS";
101 char day=wdays[d.dayOfWeek()-1]; 101 char day=wdays[d.dayOfWeek()-1];
102 102
103 label->setText( QString(QChar(day)) + " " + 103 label->setText( QString(QChar(day)) + " " +
104 QString::number(d.day()) ); 104 QString::number(d.day()) );
105 add->setText("+"); 105 add->setText("+");
106 106
107 if (d == QDate::currentDate()) { 107 if (d == QDate::currentDate()) {
108 QPalette pal=label->palette(); 108 QPalette pal=label->palette();
109 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 109 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
110 label->setPalette(pal); 110 label->setPalette(pal);
111 111
112 /* 112 /*
113 QFont f=label->font(); 113 QFont f=label->font();
114 f.setItalic(true); 114 f.setItalic(true);
115 label->setFont(f); 115 label->setFont(f);
116 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 116 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
117 */ 117 */
118 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 118 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
119 QPalette pal=label->palette(); 119 QPalette pal=label->palette();
120 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 120 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
121 label->setPalette(pal); 121 label->setPalette(pal);
122 } 122 }
123 123
124 124
125 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 125 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
126 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 126 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
127} 127}
128 128
129void DateBookWeekLstDayHdr::showDay() { 129void DateBookWeekLstDayHdr::showDay() {
130 emit showDate(date.year(), date.month(), date.day()); 130 emit showDate(date.year(), date.month(), date.day());
131} 131}
132void DateBookWeekLstDayHdr::newEvent() { 132void DateBookWeekLstDayHdr::newEvent() {
133 QDateTime start, stop; 133 QDateTime start, stop;
134 start=stop=date; 134 start=stop=date;
135 start.setTime(QTime(10,0)); 135 start.setTime(QTime(10,0));
136 stop.setTime(QTime(12,0)); 136 stop.setTime(QTime(12,0));
137 137
138 emit addEvent(start,stop,""); 138 emit addEvent(start,stop,"");
139} 139}
140DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 140DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
141 QWidget* parent = 0, 141 QWidget* parent = 0,
142 const char* name = 0, 142 const char* name = 0,
143 WFlags fl = 0) : 143 WFlags fl = 0) :
144 ClickableLabel(parent,name,fl), 144 ClickableLabel(parent,name,fl),
145 event(ev) 145 event(ev)
146{ 146{
147 char s[10]; 147 char s[10];
148 if ( ev.startDate() != ev.date() ) { // multiday event (not first day) 148 if ( ev.startDate() != ev.date() ) { // multiday event (not first day)
149 if ( ev.endDate() == ev.date() ) { // last day 149 if ( ev.endDate() == ev.date() ) { // last day
150 strcpy(s, "__|__"); 150 strcpy(s, "__|__");
151 } else { 151 } else {
152 strcpy(s, " |---"); 152 strcpy(s, " |---");
153 } 153 }
154 } else { 154 } else {
155 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); 155 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute());
156 } 156 }
157 setText(QString(s) + " " + ev.description()); 157 setText(QString(s) + " " + ev.description());
158 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 158 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
159} 159}
160void DateBookWeekLstEvent::editMe() { 160void DateBookWeekLstEvent::editMe() {
161 emit editEvent(event.event()); 161 emit editEvent(event.event());
162} 162}
163 163
164 164
165DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 165DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
166 QDate &d, bool onM, 166 QDate &d, bool onM,
167 QWidget* parent, 167 QWidget* parent,
168 const char* name, WFlags fl) 168 const char* name, WFlags fl)
169 : QWidget( parent, name, fl ) 169 : QWidget( parent, name, fl )
170{ 170{
171 onMonday=onM; 171 onMonday=onM;
172 setPalette(white); 172 setPalette(white);
173 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 173 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
174 174
175 QVBoxLayout *layout = new QVBoxLayout( this ); 175 QVBoxLayout *layout = new QVBoxLayout( this );
176 176
177 qBubbleSort(ev); 177 qBubbleSort(ev);
178 QValueListIterator<EffectiveEvent> it; 178 QValueListIterator<EffectiveEvent> it;
179 it=ev.begin(); 179 it=ev.begin();
180 180
181 int dayOrder[7]; 181 int dayOrder[7];
182 if (onMonday) 182 if (onMonday)
183 for (int d=0; d<7; d++) dayOrder[d]=d+1; 183 for (int d=0; d<7; d++) dayOrder[d]=d+1;
184 else { 184 else {
185 for (int d=0; d<7; d++) dayOrder[d]=d; 185 for (int d=0; d<7; d++) dayOrder[d]=d;
186 dayOrder[0]=7; 186 dayOrder[0]=7;
187 } 187 }
188 188
189 for (int i=0; i<7; i++) { 189 for (int i=0; i<7; i++) {
190 // Header 190 // Header
191 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), 191 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i),
192 onMonday,this); 192 onMonday,this);
193 connect(hdr, SIGNAL(showDate(int,int,int)), 193 connect(hdr, SIGNAL(showDate(int,int,int)),
194 this, SIGNAL(showDate(int,int,int))); 194 this, SIGNAL(showDate(int,int,int)));
195 connect(hdr, SIGNAL(addEvent(const QDateTime &, 195 connect(hdr, SIGNAL(addEvent(const QDateTime &,
196 const QDateTime &, 196 const QDateTime &,
197 const QString &)), 197 const QString &)),
198 this, SIGNAL(addEvent(const QDateTime &, 198 this, SIGNAL(addEvent(const QDateTime &,
199 const QDateTime &, 199 const QDateTime &,
200 const QString &))); 200 const QString &)));
201 layout->addWidget(hdr); 201 layout->addWidget(hdr);
202 202
203 // Events 203 // Events
204 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 204 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
205 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); 205 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this);
206 layout->addWidget(l); 206 layout->addWidget(l);
207 connect (l, SIGNAL(editEvent(const Event &)), 207 connect (l, SIGNAL(editEvent(const Event &)),
208 this, SIGNAL(editEvent(const Event &))); 208 this, SIGNAL(editEvent(const Event &)));
209 it++; 209 it++;
210 } 210 }
211 211
212 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 212 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
213 } 213 }
214} 214}
215DateBookWeekLstView::~DateBookWeekLstView(){} 215DateBookWeekLstView::~DateBookWeekLstView(){}
216void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 216void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
217 217
218DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 218DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
219 QWidget *parent, 219 QWidget *parent,
220 const char *name ) 220 const char *name )
221 : QWidget( parent, name ), 221 : QWidget( parent, name ),
222 db( newDB ), 222 db( newDB ),
223 startTime( 0 ), 223 startTime( 0 ),
224 ampm( ap ), 224 ampm( ap ),
225 onMonday(onM) 225 onMonday(onM)
226{ 226{
227 setFocusPolicy(StrongFocus); 227 setFocusPolicy(StrongFocus);
228 layout = new QVBoxLayout( this ); 228 layout = new QVBoxLayout( this );
229 layout->setMargin(0); 229 layout->setMargin(0);
230 230
231 header=new DateBookWeekLstHeader(onM, this); 231 header=new DateBookWeekLstHeader(onM, this);
232 layout->addWidget( header ); 232 layout->addWidget( header );
233 connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); 233 connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int)));
234 234
235 scroll=new QScrollView(this); 235 scroll=new QScrollView(this);
236 //scroll->setVScrollBarMode(QScrollView::AlwaysOn); 236 //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
237 //scroll->setHScrollBarMode(QScrollView::AlwaysOff); 237 //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
238 scroll->setResizePolicy(QScrollView::AutoOneFit); 238 scroll->setResizePolicy(QScrollView::AutoOneFit);
239 layout->addWidget(scroll); 239 layout->addWidget(scroll);
240 240
241 view=NULL; 241 view=NULL;
242} 242}
243 243
244 244
245void DateBookWeekLst::setDate( QDate &d ) { 245void DateBookWeekLst::setDate(const QDate &d) {
246 int w,y; 246 int w,y;
247 calcWeek(d,w,y,onMonday); 247 calcWeek(d,w,y,onMonday);
248 year=y; 248 year=y;
249 _week=w; 249 _week=w;
250 header->setDate(date()); 250 header->setDate(date());
251} 251}
252void DateBookWeekLst::redraw() {getEvents();} 252void DateBookWeekLst::redraw() {getEvents();}
253 253
254QDate DateBookWeekLst::date() const { 254QDate DateBookWeekLst::date() const {
255 QDate d; 255 QDate d;
256 d.setYMD(year,1,1); 256 d.setYMD(year,1,1);
257 257
258 int dow= d.dayOfWeek(); 258 int dow= d.dayOfWeek();
259 if (!onMonday) 259 if (!onMonday)
260 if (dow==7) dow=1; 260 if (dow==7) dow=1;
261 else dow++; 261 else dow++;
262 262
263 d=d.addDays( (_week-1)*7 - dow + 1 ); 263 d=d.addDays( (_week-1)*7 - dow + 1 );
264 return d; 264 return d;
265} 265}
266 266
267void DateBookWeekLst::getEvents() { 267void DateBookWeekLst::getEvents() {
268 QDate start = date(); 268 QDate start = date();
269 QDate stop = start.addDays(6); 269 QDate stop = start.addDays(6);
270 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 270 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
271 271
272 if (view) delete view; 272 if (view) delete view;
273 view=new DateBookWeekLstView(el,start,onMonday,scroll); 273 view=new DateBookWeekLstView(el,start,onMonday,scroll);
274 274
275 connect (view, SIGNAL(editEvent(const Event &)), 275 connect (view, SIGNAL(editEvent(const Event &)),
276 this, SIGNAL(editEvent(const Event &))); 276 this, SIGNAL(editEvent(const Event &)));
277 connect (view, SIGNAL(showDate(int,int,int)), 277 connect (view, SIGNAL(showDate(int,int,int)),
278 this, SIGNAL(showDate(int,int,int))); 278 this, SIGNAL(showDate(int,int,int)));
279 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 279 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
280 const QString &)), 280 const QString &)),
281 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 281 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
282 const QString &))); 282 const QString &)));
283 283
284 scroll->addChild(view); 284 scroll->addChild(view);
285 view->show(); 285 view->show();
286 scroll->updateScrollBars(); 286 scroll->updateScrollBars();
287} 287}
288 288
289void DateBookWeekLst::dateChanged(int y, int w) { 289void DateBookWeekLst::dateChanged(int y, int w) {
290 year=y; 290 year=y;
291 _week=w; 291 _week=w;
292 getEvents(); 292 getEvents();
293} 293}
294 294
295void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 295void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
296{ 296{
297 switch(e->key()) { 297 switch(e->key()) {
298 case Key_Up: 298 case Key_Up:
299 scroll->scrollBy(0, -20); 299 scroll->scrollBy(0, -20);
300 break; 300 break;
301 case Key_Down: 301 case Key_Down:
302 scroll->scrollBy(0, 20); 302 scroll->scrollBy(0, 20);
303 break; 303 break;
304 case Key_Left: 304 case Key_Left:
305 header->prevWeek(); 305 header->prevWeek();
306 break; 306 break;
307 case Key_Right: 307 case Key_Right:
308 header->nextWeek(); 308 header->nextWeek();
309 break; 309 break;
310 default: 310 default:
311 e->ignore(); 311 e->ignore();
312 } 312 }
313} 313}
314 314
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
index d2a07cc..39c956d 100644
--- a/core/pim/datebook/datebookweeklst.h
+++ b/core/pim/datebook/datebookweeklst.h
@@ -1,131 +1,131 @@
1#ifndef DATEBOOKWEEKLST 1#ifndef DATEBOOKWEEKLST
2#define DATEBOOKWEEKLST 2#define DATEBOOKWEEKLST
3 3
4#include <qwidget.h> 4#include <qwidget.h>
5#include <qdatetime.h> 5#include <qdatetime.h>
6#include <qpe/event.h> 6#include <qpe/event.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qscrollview.h> 8#include <qscrollview.h>
9 9
10#include "datebookweeklstheader.h" 10#include "datebookweeklstheader.h"
11#include "datebookweeklstdayhdr.h" 11#include "datebookweeklstdayhdr.h"
12 12
13#include "clickablelabel.h" 13#include "clickablelabel.h"
14 14
15class QDateTime; 15class QDateTime;
16class DateBookDB; 16class DateBookDB;
17 17
18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase 18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
19{ 19{
20 Q_OBJECT 20 Q_OBJECT
21public: 21public:
22 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, 22 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
23 WFlags fl = 0 ); 23 WFlags fl = 0 );
24 ~DateBookWeekLstHeader(); 24 ~DateBookWeekLstHeader();
25 void setDate(QDate d); 25 void setDate(const QDate &d);
26 26
27public slots: 27public slots:
28 void nextWeek(); 28 void nextWeek();
29 void prevWeek(); 29 void prevWeek();
30 void pickDate(); 30 void pickDate();
31 void setDate(int y, int m, int d); 31 void setDate(int y, int m, int d);
32signals: 32signals:
33 void dateChanged(int y, int w); 33 void dateChanged(int y, int w);
34private: 34private:
35 QDate date; 35 QDate date;
36 bool onMonday; 36 bool onMonday;
37}; 37};
38 38
39class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase 39class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42public: 42public:
43 DateBookWeekLstDayHdr(const QDate &d, bool onM, 43 DateBookWeekLstDayHdr(const QDate &d, bool onM,
44 QWidget* parent = 0, const char* name = 0, 44 QWidget* parent = 0, const char* name = 0,
45 WFlags fl = 0 ); 45 WFlags fl = 0 );
46public slots: 46public slots:
47 void showDay(); 47 void showDay();
48 void newEvent(); 48 void newEvent();
49signals: 49signals:
50 void showDate(int y, int m, int d); 50 void showDate(int y, int m, int d);
51 void addEvent(const QDateTime &start, const QDateTime &stop, 51 void addEvent(const QDateTime &start, const QDateTime &stop,
52 const QString &str); 52 const QString &str);
53private: 53private:
54 QDate date; 54 QDate date;
55}; 55};
56 56
57class DateBookWeekLstEvent: public ClickableLabel 57class DateBookWeekLstEvent: public ClickableLabel
58{ 58{
59 Q_OBJECT 59 Q_OBJECT
60public: 60public:
61 DateBookWeekLstEvent(const EffectiveEvent &ev, 61 DateBookWeekLstEvent(const EffectiveEvent &ev,
62 QWidget* parent = 0, const char* name = 0, 62 QWidget* parent = 0, const char* name = 0,
63 WFlags fl = 0); 63 WFlags fl = 0);
64signals: 64signals:
65 void editEvent(const Event &e); 65 void editEvent(const Event &e);
66private slots: 66private slots:
67 void editMe(); 67 void editMe();
68private: 68private:
69 const EffectiveEvent event; 69 const EffectiveEvent event;
70}; 70};
71 71
72class DateBookWeekLstView: public QWidget 72class DateBookWeekLstView: public QWidget
73{ 73{
74 Q_OBJECT 74 Q_OBJECT
75public: 75public:
76 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, QDate &d, bool onM, 76 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, QDate &d, bool onM,
77 QWidget* parent = 0, const char* name = 0, 77 QWidget* parent = 0, const char* name = 0,
78 WFlags fl = 0 ); 78 WFlags fl = 0 );
79 ~DateBookWeekLstView(); 79 ~DateBookWeekLstView();
80signals: 80signals:
81 void editEvent(const Event &e); 81 void editEvent(const Event &e);
82 void showDate(int y, int m, int d); 82 void showDate(int y, int m, int d);
83 void addEvent(const QDateTime &start, const QDateTime &stop, 83 void addEvent(const QDateTime &start, const QDateTime &stop,
84 const QString &str); 84 const QString &str);
85private: 85private:
86 bool onMonday; 86 bool onMonday;
87protected slots: 87protected slots:
88 void keyPressEvent(QKeyEvent *); 88 void keyPressEvent(QKeyEvent *);
89}; 89};
90 90
91class DateBookWeekLst : public QWidget 91class DateBookWeekLst : public QWidget
92{ 92{
93 Q_OBJECT 93 Q_OBJECT
94 94
95public: 95public:
96 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, 96 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB,
97 QWidget *parent = 0, 97 QWidget *parent = 0,
98 const char *name = 0 ); 98 const char *name = 0 );
99 void setDate( int y, int w ); 99 void setDate( int y, int w );
100 void setDate( QDate &d ); 100 void setDate(const QDate &d );
101 int week() const { return _week; }; 101 int week() const { return _week; };
102 QDate date() const; 102 QDate date() const;
103 103
104public slots: 104public slots:
105 void redraw(); 105 void redraw();
106 void dateChanged(int y, int w); 106 void dateChanged(int y, int w);
107protected slots: 107protected slots:
108 void keyPressEvent(QKeyEvent *); 108 void keyPressEvent(QKeyEvent *);
109 109
110signals: 110signals:
111 void showDate(int y, int m, int d); 111 void showDate(int y, int m, int d);
112 void addEvent(const QDateTime &start, const QDateTime &stop, 112 void addEvent(const QDateTime &start, const QDateTime &stop,
113 const QString &str); 113 const QString &str);
114 void editEvent(const Event &e); 114 void editEvent(const Event &e);
115 115
116private: 116private:
117 DateBookDB *db; 117 DateBookDB *db;
118 int startTime; 118 int startTime;
119 bool ampm; 119 bool ampm;
120 bool onMonday; 120 bool onMonday;
121 int year, _week; 121 int year, _week;
122 DateBookWeekLstHeader *header; 122 DateBookWeekLstHeader *header;
123 DateBookWeekLstView *view; 123 DateBookWeekLstView *view;
124 QVBoxLayout *layout; 124 QVBoxLayout *layout;
125 QScrollView *scroll; 125 QScrollView *scroll;
126 126
127 void getEvents(); 127 void getEvents();
128}; 128};
129 129
130#endif 130#endif
131 131