summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2003-04-12 03:56:46 (UTC)
committer umopapisdn <umopapisdn>2003-04-12 03:56:46 (UTC)
commit8c690a7bb709773217ba3d39d3ef769a2414cc72 (patch) (unidiff)
treea34bae70ee8dc46f40f60150e1703088fbc4da36
parent212aef7fd20182fe926644af2ab10a4b49549440 (diff)
downloadopie-8c690a7bb709773217ba3d39d3ef769a2414cc72.zip
opie-8c690a7bb709773217ba3d39d3ef769a2414cc72.tar.gz
opie-8c690a7bb709773217ba3d39d3ef769a2414cc72.tar.bz2
New feature:
Added a configurable option to make the weeklist view display either no times at all, only start times, or both start and end time. Also moved the configuration of default view from the menu into the preference dialog.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp380
-rw-r--r--core/pim/datebook/datebook.h8
-rw-r--r--core/pim/datebook/datebooksettingsbase.ui628
-rw-r--r--core/pim/datebook/datebookweeklst.cpp297
-rw-r--r--core/pim/datebook/datebookweeklst.h22
5 files changed, 741 insertions, 594 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 829f8f8..4fbcb10 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,1017 +1,975 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19** $Id$ 19** $Id$
20** 20**
21**********************************************************************/ 21**********************************************************************/
22 22
23#define QTOPIA_INTERNAL_FD 23#define QTOPIA_INTERNAL_FD
24 24
25#include "datebook.h" 25#include "datebook.h"
26#include "datebookday.h" 26#include "datebookday.h"
27#include "datebooksettings.h" 27#include "datebooksettings.h"
28#include "datebookweek.h" 28#include "datebookweek.h"
29#include "datebookweeklst.h" 29#include "datebookweeklst.h"
30#include "dateentryimpl.h" 30#include "dateentryimpl.h"
31 31
32#include <qpe/datebookmonth.h> 32#include <qpe/datebookmonth.h>
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qpe/qpedebug.h> 35#include <qpe/qpedebug.h>
36#include <qpe/event.h> 36#include <qpe/event.h>
37#include <qpe/finddialog.h> 37#include <qpe/finddialog.h>
38#include <qpe/ir.h> 38#include <qpe/ir.h>
39#include <qpe/qpemenubar.h> 39#include <qpe/qpemenubar.h>
40#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42#include <qpe/sound.h> 42#include <qpe/sound.h>
43#include <qpe/timestring.h> 43#include <qpe/timestring.h>
44#include <qpe/qpetoolbar.h> 44#include <qpe/qpetoolbar.h>
45#include <qpe/tzselect.h> 45#include <qpe/tzselect.h>
46#include <qpe/xmlreader.h> 46#include <qpe/xmlreader.h>
47 47
48#include <qaction.h> 48#include <qaction.h>
49#include <qcopchannel_qws.h> 49#include <qcopchannel_qws.h>
50#include <qdatetime.h> 50#include <qdatetime.h>
51#include <qdialog.h> 51#include <qdialog.h>
52#include <qfile.h> 52#include <qfile.h>
53#include <qlabel.h> 53#include <qlabel.h>
54#include <qlayout.h> 54#include <qlayout.h>
55#include <qmessagebox.h> 55#include <qmessagebox.h>
56#include <qpopupmenu.h> 56#include <qpopupmenu.h>
57#include <qpushbutton.h> 57#include <qpushbutton.h>
58#include <qregexp.h> 58#include <qregexp.h>
59#include <qtextcodec.h> 59#include <qtextcodec.h>
60#include <qtextstream.h> 60#include <qtextstream.h>
61#include <qtimer.h> 61#include <qtimer.h>
62#include <qtl.h> 62#include <qtl.h>
63#include <qwidgetstack.h> 63#include <qwidgetstack.h>
64#include <qwindowsystem_qws.h> 64#include <qwindowsystem_qws.h>
65 65
66#include <sys/stat.h> 66#include <sys/stat.h>
67#include <sys/types.h> 67#include <sys/types.h>
68#include <fcntl.h> 68#include <fcntl.h>
69#include <unistd.h> 69#include <unistd.h>
70 70
71#include <stdlib.h> 71#include <stdlib.h>
72 72
73#define DAY 1
74#define WEEK 2
75#define WEEKLST 4
76#define MONTH 3
77
78
79DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 73DateBook::DateBook( QWidget *parent, const char *, WFlags f )
80 : QMainWindow( parent, "datebook", f ), 74 : QMainWindow( parent, "datebook", f ),
81 aPreset( FALSE ), 75 aPreset( FALSE ),
82 presetTime( -1 ), 76 presetTime( -1 ),
83 startTime( 8 ), // an acceptable default 77 startTime( 8 ), // an acceptable default
84 rowStyle( 0 ), 78 rowStyle( 0 ),
85 bJumpToCurTime(FALSE), 79 bJumpToCurTime(FALSE),
86 syncing(FALSE), 80 syncing(FALSE),
87 inSearch(FALSE), 81 inSearch(FALSE),
88 alarmCounter(0) 82 alarmCounter(0)
89{ 83{
90 bool needEvilHack= false; // if we need an Evil Hack 84 bool needEvilHack= false; // if we need an Evil Hack
91 QTime t; 85 QTime t;
92 t.start(); 86 t.start();
93 db = new DateBookDBHack; 87 db = new DateBookDBHack;
94 qDebug("loading db t=%d", t.elapsed() ); 88 qDebug("loading db t=%d", t.elapsed() );
95 loadSettings(); 89 loadSettings();
96 setCaption( tr("Calendar") ); 90 setCaption( tr("Calendar") );
97 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 91 setIcon( Resource::loadPixmap( "datebook_icon" ) );
98 92
99 setToolBarsMovable( FALSE ); 93 setToolBarsMovable( FALSE );
100 94
101 views = new QWidgetStack( this ); 95 views = new QWidgetStack( this );
102 setCentralWidget( views ); 96 setCentralWidget( views );
103 97
104 dayView = 0; 98 dayView = 0;
105 weekView = 0; 99 weekView = 0;
106 weekLstView = 0; 100 weekLstView = 0;
107 monthView = 0; 101 monthView = 0;
108 102
109 QPEToolBar *bar = new QPEToolBar( this ); 103 QPEToolBar *bar = new QPEToolBar( this );
110 bar->setHorizontalStretchable( TRUE ); 104 bar->setHorizontalStretchable( TRUE );
111 105
112 QPEMenuBar *mb = new QPEMenuBar( bar ); 106 QPEMenuBar *mb = new QPEMenuBar( bar );
113 mb->setMargin( 0 ); 107 mb->setMargin( 0 );
114 108
115 QPEToolBar *sub_bar = new QPEToolBar(this); 109 QPEToolBar *sub_bar = new QPEToolBar(this);
116 110
117 QPopupMenu *view = new QPopupMenu( this ); 111 QPopupMenu *view = new QPopupMenu( this );
118 QPopupMenu *settings = new QPopupMenu( this ); 112 QPopupMenu *settings = new QPopupMenu( this );
119 113
120 mb->insertItem( tr( "View" ), view ); 114 mb->insertItem( tr( "View" ), view );
121 mb->insertItem( tr( "Settings" ), settings ); 115 mb->insertItem( tr( "Settings" ), settings );
122 116
123 QActionGroup *g = new QActionGroup( this ); 117 QActionGroup *g = new QActionGroup( this );
124 g->setExclusive( TRUE ); 118 g->setExclusive( TRUE );
125 119
126 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 120 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
127 QString::null, 0, this, 0 ); 121 QString::null, 0, this, 0 );
128 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 122 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
129 a->addTo( sub_bar ); 123 a->addTo( sub_bar );
130 124
131 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); 125 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 );
132 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 126 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
133 a->addTo( sub_bar ); 127 a->addTo( sub_bar );
134 a->addTo( view ); 128 a->addTo( view );
135 129
136 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 );
137 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 131 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
138 a->addTo( sub_bar ); 132 a->addTo( sub_bar );
139 a->addTo( view ); 133 a->addTo( view );
140 a->setToggleAction( TRUE ); 134 a->setToggleAction( TRUE );
141 a->setOn( TRUE ); 135 a->setOn( TRUE );
142 dayAction = a; 136 dayAction = a;
143 137
144 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 );
145 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 139 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
146 a->addTo( sub_bar ); 140 a->addTo( sub_bar );
147 a->addTo( view ); 141 a->addTo( view );
148 a->setToggleAction( TRUE ); 142 a->setToggleAction( TRUE );
149 weekAction = a; 143 weekAction = a;
150 144
151 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 145 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
152 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 146 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
153 a->addTo( sub_bar ); 147 a->addTo( sub_bar );
154 a->addTo( view ); 148 a->addTo( view );
155 a->setToggleAction( TRUE ); 149 a->setToggleAction( TRUE );
156 weekLstAction = a; 150 weekLstAction = a;
157 151
158 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 );
159 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 153 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
160 a->addTo( sub_bar ); 154 a->addTo( sub_bar );
161 a->addTo( view ); 155 a->addTo( view );
162 a->setToggleAction( TRUE ); 156 a->setToggleAction( TRUE );
163 monthAction = a; 157 monthAction = a;
164 158
165 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 );
166 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 160 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
167 a->addTo( sub_bar ); 161 a->addTo( sub_bar );
168 162
169 a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); 163 a = new QAction( tr( "Edit..." ), QString::null, 0, 0 );
170 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
171 a->addTo( settings ); 165 a->addTo( settings );
172 166
173 QPopupMenu *default_view = new QPopupMenu(this); 167 if(defaultView==DAY) viewDay();
174 settings->insertItem( tr( "Default View" ),default_view ); 168 if(defaultView==WEEK) needEvilHack=true;// viewWeek();
175 default_view->setCheckable(TRUE); 169 if(defaultView==WEEKLST) viewWeekLst();
176 170 if(defaultView==MONTH) viewMonth();
177 Config config("DateBook"); 171
178 config.setGroup("Main"); 172 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
179 int current=config.readNumEntry("defaultview", DAY); 173 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
180
181 QActionGroup *ag = new QActionGroup(this);
182 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true );
183 if (current==DAY) a->setOn(true), viewDay();
184 ag->insert(a);
185 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true );
186 if (current==WEEK) a->setOn(true), /*viewWeek(),*/ needEvilHack = true;
187 ag->insert(a);
188 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true );
189 if (current==WEEKLST) a->setOn(true), viewWeekLst();
190 ag->insert(a);
191 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true );
192 if (current==MONTH) a->setOn(true), viewMonth();
193 ag->insert(a);
194
195 ag->addTo(default_view);
196 connect(ag, SIGNAL( selected ( QAction * ) ),
197 this, SLOT( newDefaultView(QAction *) )
198 );
199
200 connect( qApp, SIGNAL(clockChanged(bool)),
201 this, SLOT(changeClock(bool)) );
202 connect( qApp, SIGNAL(weekChanged(bool)),
203 this, SLOT(changeWeek(bool)) );
204 174
205#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 175#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
206 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 176 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) );
207 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
208#endif 177#endif
209 178
210 // listen on QPE/System 179 // listen on QPE/System
211#if defined(Q_WS_QWS) 180#if defined(Q_WS_QWS)
212#if !defined(QT_NO_COP) 181#if !defined(QT_NO_COP)
213 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 182 QCopChannel *channel = new QCopChannel( "QPE/System", this );
214 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 183 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
215 this, SLOT(receive(const QCString&, const QByteArray&)) );
216 channel = new QCopChannel( "QPE/Datebook", this ); 184 channel = new QCopChannel( "QPE/Datebook", this );
217 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 185 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
218 this, SLOT(receive(const QCString&, const QByteArray&)) );
219 qDebug("olle\n"); 186 qDebug("olle\n");
220#endif 187#endif
221#endif 188#endif
222 189
223 qDebug("done t=%d", t.elapsed() ); 190 qDebug("done t=%d", t.elapsed() );
224 191
225 /* 192 /*
226 * Here is a problem description: 193 * Here is a problem description:
227 * When Weekview is the default view 194 * When Weekview is the default view
228 * a DateBookWeekView get's created 195 * a DateBookWeekView get's created
229 * redraw() get's called. So what? 196 * redraw() get's called. So what?
230 * Remember that we're still in the c'tor 197 * Remember that we're still in the c'tor
231 * and no final layout has happened? Ok 198 * and no final layout has happened? Ok
232 * now all Events get arranged. Their x 199 * now all Events get arranged. Their x
233 * position get's determined by a QHeader 200 * position get's determined by a QHeader
234 * position. But the QHeader isn't layouted or 201 * position. But the QHeader isn't layouted or
235 * at the right position. redraw() is a slot 202 * at the right position. redraw() is a slot
236 * so we'll call it then via a singleShot 203 * so we'll call it then via a singleShot
237 * from view() 204 * from view()
238 */ 205 */
239 if( needEvilHack ){ 206 if( needEvilHack ){
240 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 207 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
241 } 208 }
242} 209}
243 210
244void DateBook::receive( const QCString &msg, const QByteArray &data ) 211void DateBook::receive( const QCString &msg, const QByteArray &data )
245{ 212{
246 QDataStream stream( data, IO_ReadOnly ); 213 QDataStream stream( data, IO_ReadOnly );
247 if ( msg == "timeChange(QString)" ) { 214 if ( msg == "timeChange(QString)" ) {
248 // update active view! 215 // update active view!
249 if ( dayAction->isOn() ) 216 if ( dayAction->isOn() )
250 viewDay(); 217 viewDay();
251 else if ( weekAction->isOn() ) 218 else if ( weekAction->isOn() )
252 viewWeek(); 219 viewWeek();
253 else if ( monthAction->isOn() ) 220 else if ( monthAction->isOn() )
254 viewMonth(); 221 viewMonth();
255 } 222 }
256 else if (msg == "editEvent(int)") { 223 else if (msg == "editEvent(int)") {
257 int uid; 224 int uid;
258 stream >> uid; 225 stream >> uid;
259 Event e=db->eventByUID(uid); 226 Event e=db->eventByUID(uid);
260 editEvent(e); 227 editEvent(e);
261 } 228 }
262} 229}
263 230
264DateBook::~DateBook() 231DateBook::~DateBook()
265{ 232{
266} 233}
267 234
268void DateBook::slotSettings() 235void DateBook::slotSettings()
269{ 236{
270 DateBookSettings frmSettings( ampm, this ); 237 DateBookSettings frmSettings( ampm, this );
271 frmSettings.setStartTime( startTime ); 238 frmSettings.setStartTime( startTime );
272 frmSettings.setAlarmPreset( aPreset, presetTime ); 239 frmSettings.setAlarmPreset( aPreset, presetTime );
273 frmSettings.setJumpToCurTime( bJumpToCurTime ); 240 frmSettings.setJumpToCurTime( bJumpToCurTime );
274 frmSettings.setRowStyle( rowStyle ); 241 frmSettings.setRowStyle( rowStyle );
242 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
243 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
244
275#if defined (Q_WS_QWS) || defined(_WS_QWS_) 245#if defined (Q_WS_QWS) || defined(_WS_QWS_)
276 frmSettings.showMaximized(); 246 frmSettings.showMaximized();
277#endif 247#endif
278 248
279 if ( frmSettings.exec() ) { 249 if ( frmSettings.exec() ) {
280 250
281 aPreset = frmSettings.alarmPreset(); 251 aPreset = frmSettings.alarmPreset();
282 presetTime = frmSettings.presetTime(); 252 presetTime = frmSettings.presetTime();
283 startTime = frmSettings.startTime(); 253 startTime = frmSettings.startTime();
284 bJumpToCurTime = frmSettings.jumpToCurTime(); 254 bJumpToCurTime = frmSettings.jumpToCurTime();
285 rowStyle = frmSettings.rowStyle(); 255 rowStyle = frmSettings.rowStyle();
256 defaultView=frmSettings.comboDefaultView->currentItem()+1;
257 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
286 258
287 if ( dayView ) { 259 if ( dayView ) {
288 dayView->setStartViewTime( startTime ); 260 dayView->setStartViewTime( startTime );
289 dayView->setJumpToCurTime( bJumpToCurTime ); 261 dayView->setJumpToCurTime( bJumpToCurTime );
290 dayView->setRowStyle( rowStyle ); 262 dayView->setRowStyle( rowStyle );
291 } 263 }
292 if ( weekView ) { 264 if ( weekView ) {
293 weekView->setStartViewTime( startTime ); 265 weekView->setStartViewTime( startTime );
294 } 266 }
295 saveSettings(); 267 saveSettings();
296 268
297 // make the change obvious 269 // make the change obvious
298 if ( views->visibleWidget() ) { 270 if ( views->visibleWidget() ) {
299 if ( views->visibleWidget() == dayView ) 271 if ( views->visibleWidget() == dayView )
300 dayView->redraw(); 272 dayView->redraw();
301 else if ( views->visibleWidget() == weekView ) 273 else if ( views->visibleWidget() == weekView )
302 weekView->redraw(); 274 weekView->redraw();
275 else if ( views->visibleWidget() == weekLstView )
276 weekLstView->redraw();
303 } 277 }
304 } 278 }
305} 279}
306 280
307void DateBook::fileNew() 281void DateBook::fileNew()
308{ 282{
309 slotNewEventFromKey(""); 283 slotNewEventFromKey("");
310} 284}
311 285
312QString DateBook::checkEvent(const Event &e) 286QString DateBook::checkEvent(const Event &e)
313{ 287{
314 /* check if overlaps with itself */ 288 /* check if overlaps with itself */
315 bool checkFailed = FALSE; 289 bool checkFailed = FALSE;
316 290
317 /* check the next 12 repeats. should catch most problems */ 291 /* check the next 12 repeats. should catch most problems */
318 QDate current_date = e.start().date(); 292 QDate current_date = e.start().date();
319 Event previous = e; 293 Event previous = e;
320 for(int i = 0; i < 12; i++) 294 for(int i = 0; i < 12; i++)
321 { 295 {
322 QDateTime next; 296 QDateTime next;
323 if (!nextOccurance(previous, current_date.addDays(1), next)) { 297 if (!nextOccurance(previous, current_date.addDays(1), next)) {
324 break; // no more repeats 298 break; // no more repeats
325 } 299 }
326 if(next < previous.end()) { 300 if(next < previous.end()) {
327 checkFailed = TRUE; 301 checkFailed = TRUE;
328 break; 302 break;
329 } 303 }
330 current_date = next.date(); 304 current_date = next.date();
331 } 305 }
332 306
333 if(checkFailed) 307 if(checkFailed)
334 return tr("Event duration is potentially longer\n" 308 return tr("Event duration is potentially longer\n"
335 "than interval between repeats."); 309 "than interval between repeats.");
336 310
337 return QString::null; 311 return QString::null;
338} 312}
339 313
340QDate DateBook::currentDate() 314QDate DateBook::currentDate()
341{ 315{
342 QDate d = QDate::currentDate(); 316 QDate d = QDate::currentDate();
343 317
344 if ( dayView && views->visibleWidget() == dayView ) { 318 if ( dayView && views->visibleWidget() == dayView ) {
345 d = dayView->date(); 319 d = dayView->date();
346 } else if ( weekView && views->visibleWidget() == weekView ) { 320 } else if ( weekView && views->visibleWidget() == weekView ) {
347 d = weekView->date(); 321 d = weekView->date();
348 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 322 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
349 d = weekLstView->date(); 323 d = weekLstView->date();
350 } else if ( monthView && views->visibleWidget() == monthView ) { 324 } else if ( monthView && views->visibleWidget() == monthView ) {
351 d = monthView->selectedDate(); 325 d = monthView->selectedDate();
352 } 326 }
353 327
354 return d; 328 return d;
355} 329}
356 330
357void DateBook::view(int v, const QDate &d) { 331void DateBook::view(int v, const QDate &d) {
358 if (v==DAY) { 332 if (v==DAY) {
359 initDay(); 333 initDay();
360 dayAction->setOn( TRUE ); 334 dayAction->setOn( TRUE );
361 dayView->setDate( d ); 335 dayView->setDate( d );
362 views->raiseWidget( dayView ); 336 views->raiseWidget( dayView );
363 dayView->redraw(); 337 dayView->redraw();
364 } else if (v==WEEK) { 338 } else if (v==WEEK) {
365 initWeek(); 339 initWeek();
366 weekAction->setOn( TRUE ); 340 weekAction->setOn( TRUE );
367 weekView->setDate( d ); 341 weekView->setDate( d );
368 views->raiseWidget( weekView ); 342 views->raiseWidget( weekView );
369 weekView->redraw(); 343 weekView->redraw();
370 } else if (v==WEEKLST) { 344 } else if (v==WEEKLST) {
371 initWeekLst(); 345 initWeekLst();
372 weekLstAction->setOn( TRUE ); 346 weekLstAction->setOn( TRUE );
373 weekLstView->setDate(d); 347 weekLstView->setDate(d);
374 views->raiseWidget( weekLstView ); 348 views->raiseWidget( weekLstView );
375 weekLstView->redraw(); 349 weekLstView->redraw();
376 } else if (v==MONTH) { 350 } else if (v==MONTH) {
377 initMonth(); 351 initMonth();
378 monthAction->setOn( TRUE ); 352 monthAction->setOn( TRUE );
379 monthView->setDate( d.year(), d.month(), d.day() ); 353 monthView->setDate( d.year(), d.month(), d.day() );
380 views->raiseWidget( monthView ); 354 views->raiseWidget( monthView );
381 monthView->redraw(); 355 monthView->redraw();
382 } 356 }
383} 357}
384 358
385void DateBook::viewDefault(const QDate &d) { 359void DateBook::viewDefault(const QDate &d) {
360/*
386 Config config("DateBook"); 361 Config config("DateBook");
387 config.setGroup("Main"); 362 config.setGroup("Main");
388 int current=config.readNumEntry("defaultview", DAY); 363 int current=config.readNumEntry("defaultview", DAY);
389 364
390 view(current,d); 365 view(current,d);
366*/
367 view(defaultView,d);
391} 368}
392 369
393void DateBook::viewDay() { 370void DateBook::viewDay() {
394 view(DAY,currentDate()); 371 view(DAY,currentDate());
395} 372}
396 373
397void DateBook::viewWeek() { 374void DateBook::viewWeek() {
398 view(WEEK,currentDate()); 375 view(WEEK,currentDate());
399} 376}
400 377
401void DateBook::viewWeekLst() { 378void DateBook::viewWeekLst() {
402 view(WEEKLST,currentDate()); 379 view(WEEKLST,currentDate());
403} 380}
404 381
405void DateBook::viewMonth() { 382void DateBook::viewMonth() {
406 view(MONTH,currentDate()); 383 view(MONTH,currentDate());
407} 384}
408 385
409void DateBook::duplicateEvent( const Event &e ) 386void DateBook::duplicateEvent( const Event &e )
410{ 387{
411 qWarning("Hmmm..."); 388 qWarning("Hmmm...");
412 // Alot of code duplication, as this is almost like editEvent(); 389 // Alot of code duplication, as this is almost like editEvent();
413 if (syncing) { 390 if (syncing) {
414 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 391 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
415 return; 392 return;
416 } 393 }
417 394
418 Event dupevent(e);// Make a duplicate. 395 Event dupevent(e);// Make a duplicate.
419 396
420 // workaround added for text input. 397 // workaround added for text input.
421 QDialog editDlg( this, 0, TRUE ); 398 QDialog editDlg( this, 0, TRUE );
422 DateEntry *entry; 399 DateEntry *entry;
423 editDlg.setCaption( tr("Duplicate Event") ); 400 editDlg.setCaption( tr("Duplicate Event") );
424 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 401 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
425 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 402 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
426 sv->setResizePolicy( QScrollView::AutoOneFit ); 403 sv->setResizePolicy( QScrollView::AutoOneFit );
427 // KLUDGE!!! 404 // KLUDGE!!!
428 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 405 sv->setHScrollBarMode( QScrollView::AlwaysOff );
429 vb->addWidget( sv ); 406 vb->addWidget( sv );
430 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 407 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
431 entry->timezone->setEnabled( FALSE ); 408 entry->timezone->setEnabled( FALSE );
432 sv->addChild( entry ); 409 sv->addChild( entry );
433 410
434#if defined(Q_WS_QWS) || defined(_WS_QWS_) 411#if defined(Q_WS_QWS) || defined(_WS_QWS_)
435 editDlg.showMaximized(); 412 editDlg.showMaximized();
436#endif 413#endif
437 while (editDlg.exec() ) { 414 while (editDlg.exec() ) {
438 Event newEv = entry->event(); 415 Event newEv = entry->event();
439 QString error = checkEvent(newEv); 416 QString error = checkEvent(newEv);
440 if (!error.isNull()) { 417 if (!error.isNull()) {
441 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) 418 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0)
442 continue; 419 continue;
443 } 420 }
444 db->addEvent(newEv); 421 db->addEvent(newEv);
445 emit newEvent(); 422 emit newEvent();
446 break; 423 break;
447 } 424 }
448} 425}
449 426
450void DateBook::editEvent( const Event &e ) 427void DateBook::editEvent( const Event &e )
451{ 428{
452 if (syncing) { 429 if (syncing) {
453 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 430 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
454 return; 431 return;
455 } 432 }
456 433
457 // workaround added for text input. 434 // workaround added for text input.
458 QDialog editDlg( this, 0, TRUE ); 435 QDialog editDlg( this, 0, TRUE );
459 DateEntry *entry; 436 DateEntry *entry;
460 editDlg.setCaption( tr("Edit Event") ); 437 editDlg.setCaption( tr("Edit Event") );
461 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 438 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
462 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 439 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
463 sv->setResizePolicy( QScrollView::AutoOneFit ); 440 sv->setResizePolicy( QScrollView::AutoOneFit );
464 // KLUDGE!!! 441 // KLUDGE!!!
465 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 442 sv->setHScrollBarMode( QScrollView::AlwaysOff );
466 vb->addWidget( sv ); 443 vb->addWidget( sv );
467 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 444 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
468 entry->timezone->setEnabled( FALSE ); 445 entry->timezone->setEnabled( FALSE );
469 sv->addChild( entry ); 446 sv->addChild( entry );
470 447
471#if defined(Q_WS_QWS) || defined(_WS_QWS_) 448#if defined(Q_WS_QWS) || defined(_WS_QWS_)
472 editDlg.showMaximized(); 449 editDlg.showMaximized();
473#endif 450#endif
474 while (editDlg.exec() ) { 451 while (editDlg.exec() ) {
475 Event newEv = entry->event(); 452 Event newEv = entry->event();
476 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 453 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
477 break; 454 break;
478 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 455 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
479 QString error = checkEvent(newEv); 456 QString error = checkEvent(newEv);
480 if (!error.isNull()) { 457 if (!error.isNull()) {
481 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue; 458 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue;
482 } 459 }
483 db->editEvent(e, newEv); 460 db->editEvent(e, newEv);
484 emit newEvent(); 461 emit newEvent();
485 break; 462 break;
486 } 463 }
487} 464}
488 465
489void DateBook::removeEvent( const Event &e ) 466void DateBook::removeEvent( const Event &e )
490{ 467{
491 if (syncing) { 468 if (syncing) {
492 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 469 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
493 return; 470 return;
494 } 471 }
495 472
496 QString strName = e.description(); 473 QString strName = e.description();
497 474
498 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 475 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
499 return; 476 return;
500 477
501 db->removeEvent( e ); 478 db->removeEvent( e );
502 if ( views->visibleWidget() == dayView && dayView ) 479 if ( views->visibleWidget() == dayView && dayView )
503 dayView->redraw(); 480 dayView->redraw();
504} 481}
505 482
506void DateBook::addEvent( const Event &e ) 483void DateBook::addEvent( const Event &e )
507{ 484{
508 QDate d = e.start().date(); 485 QDate d = e.start().date();
509 initDay(); 486 initDay();
510 dayView->setDate( d ); 487 dayView->setDate( d );
511} 488}
512 489
513void DateBook::showDay( int year, int month, int day ) 490void DateBook::showDay( int year, int month, int day )
514{ 491{
515 QDate d(year, month, day); 492 QDate d(year, month, day);
516 view(DAY,d); 493 view(DAY,d);
517} 494}
518 495
519void DateBook::initDay() 496void DateBook::initDay()
520{ 497{
521 if ( !dayView ) { 498 if ( !dayView ) {
522 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 499 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
523 views->addWidget( dayView, DAY ); 500 views->addWidget( dayView, DAY );
524 dayView->setStartViewTime( startTime ); 501 dayView->setStartViewTime( startTime );
525 dayView->setJumpToCurTime( bJumpToCurTime ); 502 dayView->setJumpToCurTime( bJumpToCurTime );
526 dayView->setRowStyle( rowStyle ); 503 dayView->setRowStyle( rowStyle );
527 connect( this, SIGNAL( newEvent() ), 504 connect( this, SIGNAL( newEvent() ),
528 dayView, SLOT( redraw() ) ); 505 dayView, SLOT( redraw() ) );
529 connect( dayView, SIGNAL( newEvent() ), 506 connect( dayView, SIGNAL( newEvent() ),
530 this, SLOT( fileNew() ) ); 507 this, SLOT( fileNew() ) );
531 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 508 connect( dayView, SIGNAL( removeEvent( const Event & ) ),
532 this, SLOT( removeEvent( const Event & ) ) ); 509 this, SLOT( removeEvent( const Event & ) ) );
533 connect( dayView, SIGNAL( editEvent( const Event & ) ), 510 connect( dayView, SIGNAL( editEvent( const Event & ) ),
534 this, SLOT( editEvent( const Event & ) ) ); 511 this, SLOT( editEvent( const Event & ) ) );
535 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), 512 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ),
536 this, SLOT( duplicateEvent( const Event & ) ) ); 513 this, SLOT( duplicateEvent( const Event & ) ) );
537 connect( dayView, SIGNAL( beamEvent( const Event & ) ), 514 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
538 this, SLOT( beamEvent( const Event & ) ) ); 515 this, SLOT( beamEvent( const Event & ) ) );
539 connect( dayView, SIGNAL(sigNewEvent(const QString &)), 516 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
540 this, SLOT(slotNewEventFromKey(const QString &)) ); 517 this, SLOT(slotNewEventFromKey(const QString &)) );
541 } 518 }
542} 519}
543 520
544void DateBook::initWeek() 521void DateBook::initWeek()
545{ 522{
546 if ( !weekView ) { 523 if ( !weekView ) {
547 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 524 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
548 weekView->setStartViewTime( startTime ); 525 weekView->setStartViewTime( startTime );
549 views->addWidget( weekView, WEEK ); 526 views->addWidget( weekView, WEEK );
550 connect( weekView, SIGNAL( showDate( int, int, int ) ), 527 connect( weekView, SIGNAL( showDate( int, int, int ) ),
551 this, SLOT( showDay( int, int, int ) ) ); 528 this, SLOT( showDay( int, int, int ) ) );
552 connect( this, SIGNAL( newEvent() ), 529 connect( this, SIGNAL( newEvent() ),
553 weekView, SLOT( redraw() ) ); 530 weekView, SLOT( redraw() ) );
554 } 531 }
555 532
556 //But also get it right: the year that we display can be different 533 //But also get it right: the year that we display can be different
557 //from the year of the current date. So, first find the year 534 //from the year of the current date. So, first find the year
558 //number of the current week. 535 //number of the current week.
559 int yearNumber, totWeeks; 536 int yearNumber, totWeeks;
560 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 537 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
561 538
562 QDate d = QDate( yearNumber, 12, 31 ); 539 QDate d = QDate( yearNumber, 12, 31 );
563 calcWeek( d, totWeeks, yearNumber, onMonday ); 540 calcWeek( d, totWeeks, yearNumber, onMonday );
564 541
565 while ( totWeeks == 1 ) { 542 while ( totWeeks == 1 ) {
566 d = d.addDays( -1 ); 543 d = d.addDays( -1 );
567 calcWeek( d, totWeeks, yearNumber, onMonday ); 544 calcWeek( d, totWeeks, yearNumber, onMonday );
568 } 545 }
569 if ( totWeeks != weekView->totalWeeks() ) 546 if ( totWeeks != weekView->totalWeeks() )
570 weekView->setTotalWeeks( totWeeks ); 547 weekView->setTotalWeeks( totWeeks );
571} 548}
572 549
573void DateBook::initWeekLst() { 550void DateBook::initWeekLst() {
574 if ( !weekLstView ) { 551 if ( !weekLstView ) {
575 weekLstView = new DateBookWeekLst( ampm, onMonday, db, 552 weekLstView = new DateBookWeekLst( ampm, onMonday, db,
576 views, "weeklst view" ); 553 views, "weeklst view" );
577 views->addWidget( weekLstView, WEEKLST ); 554 views->addWidget( weekLstView, WEEKLST );
578 555
579 //weekLstView->setStartViewTime( startTime ); 556 //weekLstView->setStartViewTime( startTime );
580 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), 557 connect( weekLstView, SIGNAL( showDate( int, int, int ) ),
581 this, SLOT( showDay( int, int, int ) ) ); 558 this, SLOT( showDay( int, int, int ) ) );
582 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, 559 connect( weekLstView, SIGNAL( addEvent( const QDateTime &,
583 const QDateTime &, 560 const QDateTime &,
584 const QString & , const QString &) ), 561 const QString & , const QString &) ),
585 this, SLOT( slotNewEntry( const QDateTime &, 562 this, SLOT( slotNewEntry( const QDateTime &,
586 const QDateTime &, 563 const QDateTime &,
587 const QString & , const QString &) ) ); 564 const QString & , const QString &) ) );
588 connect( this, SIGNAL( newEvent() ), 565 connect( this, SIGNAL( newEvent() ),
589 weekLstView, SLOT( redraw() ) ); 566 weekLstView, SLOT( redraw() ) );
590 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), 567 connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
591 this, SLOT( editEvent( const Event & ) ) ); 568 this, SLOT( editEvent( const Event & ) ) );
592 } 569 }
593} 570}
594 571
595 572
596void DateBook::initMonth() 573void DateBook::initMonth()
597{ 574{
598 if ( !monthView ) { 575 if ( !monthView ) {
599 monthView = new DateBookMonth( views, "month view", FALSE, db ); 576 monthView = new DateBookMonth( views, "month view", FALSE, db );
600 views->addWidget( monthView, MONTH ); 577 views->addWidget( monthView, MONTH );
601 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), 578 connect( monthView, SIGNAL( dateClicked( int, int, int ) ),
602 this, SLOT( showDay( int, int, int ) ) ); 579 this, SLOT( showDay( int, int, int ) ) );
603 connect( this, SIGNAL( newEvent() ), 580 connect( this, SIGNAL( newEvent() ),
604 monthView, SLOT( redraw() ) ); 581 monthView, SLOT( redraw() ) );
605 qApp->processEvents(); 582 qApp->processEvents();
606 } 583 }
607} 584}
608 585
609void DateBook::loadSettings() 586void DateBook::loadSettings()
610{ 587{
611 { 588 Config qpeconfig( "qpe" );
612 Config config( "qpe" ); 589 qpeconfig.setGroup("Time");
613 config.setGroup("Time"); 590 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
614 ampm = config.readBoolEntry( "AMPM", TRUE ); 591 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
615 onMonday = config.readBoolEntry( "MONDAY" );
616 }
617 592
618 {
619 Config config("DateBook"); 593 Config config("DateBook");
620 config.setGroup("Main"); 594 config.setGroup("Main");
621 startTime = config.readNumEntry("startviewtime", 8); 595 startTime = config.readNumEntry("startviewtime", 8);
622 aPreset = config.readBoolEntry("alarmpreset"); 596 aPreset = config.readBoolEntry("alarmpreset");
623 presetTime = config.readNumEntry("presettime"); 597 presetTime = config.readNumEntry("presettime");
624 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 598 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
625 rowStyle = config.readNumEntry("rowstyle"); 599 rowStyle = config.readNumEntry("rowstyle");
626 } 600 defaultView = config.readNumEntry("defaultview",DAY);
601 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
627} 602}
628 603
629void DateBook::saveSettings() 604void DateBook::saveSettings()
630{ 605{
631 Config config( "qpe" ); 606 Config config( "qpe" );
632 Config configDB( "DateBook" ); 607 Config configDB( "DateBook" );
633 configDB.setGroup( "Main" ); 608 configDB.setGroup( "Main" );
634 configDB.writeEntry("startviewtime",startTime); 609 configDB.writeEntry("startviewtime",startTime);
635 configDB.writeEntry("alarmpreset",aPreset); 610 configDB.writeEntry("alarmpreset",aPreset);
636 configDB.writeEntry("presettime",presetTime); 611 configDB.writeEntry("presettime",presetTime);
637 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 612 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
638 configDB.writeEntry("rowstyle", rowStyle); 613 configDB.writeEntry("rowstyle", rowStyle);
639} 614 configDB.writeEntry("defaultview",defaultView);
640 615 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
641void DateBook::newDefaultView(QAction *a) {
642 int val=DAY;
643 if (a->text() == "Day") val=DAY;
644 if (a->text() == "Week") val=WEEK;
645 if (a->text() == "WeekLst") val=WEEKLST;
646 if (a->text() == "Month") val=MONTH;
647
648 Config configDB( "DateBook" );
649 configDB.setGroup( "Main" );
650 configDB.writeEntry("defaultview",val);
651} 616}
652 617
653void DateBook::appMessage(const QCString& msg, const QByteArray& data) 618void DateBook::appMessage(const QCString& msg, const QByteArray& data)
654{ 619{
655 bool needShow = FALSE; 620 bool needShow = FALSE;
656 if ( msg == "alarm(QDateTime,int)" ) { 621 if ( msg == "alarm(QDateTime,int)" ) {
657 QDataStream ds(data,IO_ReadOnly); 622 QDataStream ds(data,IO_ReadOnly);
658 QDateTime when; int warn; 623 QDateTime when; int warn;
659 ds >> when >> warn; 624 ds >> when >> warn;
660 625
661 // check to make it's okay to continue, 626 // check to make it's okay to continue,
662 // this is the case that the time was set ahead, and 627 // this is the case that the time was set ahead, and
663 // we are forced given a stale alarm... 628 // we are forced given a stale alarm...
664 QDateTime current = QDateTime::currentDateTime(); 629 QDateTime current = QDateTime::currentDateTime();
665 if ( current.time().hour() != when.time().hour() 630 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
666 && current.time().minute() != when.time().minute() ) 631 return;
667 return; 632
668 633 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
669 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 634 if ( list.count() > 0 ) {
670 if ( list.count() > 0 ) { 635 QString msg;
671 QString msg; 636 bool bSound = FALSE;
672 bool bSound = FALSE; 637 int stopTimer = 0;
673 int stopTimer = 0; 638 bool found = FALSE;
674 bool found = FALSE; 639 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
675 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); 640 if ( (*it).event().hasAlarm() ) {
676 it!=list.end(); ++it ) { 641 found = TRUE;
677 if ( (*it).event().hasAlarm() ) { 642 msg += "<CENTER><B>" + (*it).description() + "</B>"
678 found = TRUE; 643 + "<BR>" + (*it).location() + "<BR>"
679 msg += "<CENTER><B>" + (*it).description() + "</B>" 644 + TimeString::dateString((*it).event().start(),ampm)
680 + "<BR>" + (*it).location() + "<BR>" 645 + (warn
681 + TimeString::dateString((*it).event().start(),ampm) 646 ? tr(" (in " + QString::number(warn)
682 + (warn 647 + tr(" minutes)"))
683 ? tr(" (in " + QString::number(warn) 648 : QString(""))
684 + tr(" minutes)")) 649 + "<BR>"
685 : QString("")) 650 + (*it).notes() + "</CENTER>";
686 + "<BR>" 651 if ( (*it).event().alarmSound() != Event::Silent ) {
687 + (*it).notes() + "</CENTER>"; 652 bSound = TRUE;
688 if ( (*it).event().alarmSound() != Event::Silent ) { 653 }
689 bSound = TRUE; 654 }
690 } 655 }
691 } 656 if ( found ) {
692 } 657 if ( bSound ) {
693 if ( found ) { 658 Sound::soundAlarm();
694 if ( bSound ) { 659 alarmCounter = 0;
695 Sound::soundAlarm(); 660 stopTimer = startTimer( 5000 );
696 alarmCounter = 0; 661 }
697 stopTimer = startTimer( 5000 ); 662 QDialog dlg( this, 0, TRUE );
698 } 663 QVBoxLayout *vb = new QVBoxLayout( &dlg );
699 664 QScrollView *view = new QScrollView( &dlg, "scrollView");
700 QDialog dlg( this, 0, TRUE ); 665 view->setResizePolicy( QScrollView::AutoOneFit );
701 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 666 vb->addWidget( view );
702 QScrollView *view = new QScrollView( &dlg, "scrollView"); 667 QLabel *lblMsg = new QLabel( msg, &dlg );
703 view->setResizePolicy( QScrollView::AutoOneFit ); 668 view->addChild( lblMsg );
704 vb->addWidget( view ); 669 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
705 QLabel *lblMsg = new QLabel( msg, &dlg ); 670 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
706 view->addChild( lblMsg ); 671 vb->addWidget( cmdOk );
707 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
708 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
709 vb->addWidget( cmdOk );
710 672
711#if defined(Q_WS_QWS) || defined(_WS_QWS_) 673#if defined(Q_WS_QWS) || defined(_WS_QWS_)
712 dlg.showMaximized(); 674 dlg.showMaximized();
713#endif 675#endif
714 needShow = dlg.exec(); 676 needShow = dlg.exec();
715 677
716 if ( bSound ) 678 if ( bSound )
717 killTimer( stopTimer ); 679 killTimer( stopTimer );
718 } 680 }
719 } 681 }
720 } else if ( msg == "nextView()" ) { 682 } else if ( msg == "nextView()" ) {
721 if ( !qApp-> activeWindow ( )) { 683 if ( !qApp-> activeWindow ( )) {
722 needShow = TRUE; 684 needShow = TRUE;
723 } 685 } else {
724 else { 686 QWidget* cur = views->visibleWidget();
725 QWidget* cur = views->visibleWidget(); 687 if ( cur ) {
726 if ( cur ) { 688 if ( cur == dayView )
727 if ( cur == dayView ) 689 viewWeek();
728 viewWeek(); 690 else if ( cur == weekView )
729 else if ( cur == weekView ) 691 viewWeekLst();
730 viewWeekLst(); 692 else if ( cur == weekLstView )
731 else if ( cur == weekLstView ) 693 viewMonth();
732 viewMonth(); 694 else if ( cur == monthView )
733 else if ( cur == monthView ) 695 viewDay();
734 viewDay(); 696 needShow = TRUE;
735 needShow = TRUE; 697 }
736 } 698 }
737 }
738 } 699 }
739 if ( needShow ) { 700 if ( needShow ) {
740#if defined(Q_WS_QWS) || defined(_WS_QWS_) 701#if defined(Q_WS_QWS) || defined(_WS_QWS_)
741 showMaximized(); 702 showMaximized();
742#else 703#else
743 show(); 704 show();
744#endif 705#endif
745 raise(); 706 raise();
746 QPEApplication::setKeepRunning(); 707 QPEApplication::setKeepRunning();
747 setActiveWindow(); 708 setActiveWindow();
748 } 709 }
749} 710}
750 711
751void DateBook::reload() 712void DateBook::reload()
752{ 713{
753 db->reload(); 714 db->reload();
754 if ( dayAction->isOn() ) 715 if ( dayAction->isOn() ) viewDay();
755 viewDay(); 716 else if ( weekAction->isOn() ) viewWeek();
756 else if ( weekAction->isOn() ) 717 else if ( monthAction->isOn() ) viewMonth();
757 viewWeek(); 718 syncing = FALSE;
758 else if ( monthAction->isOn() )
759 viewMonth();
760 syncing = FALSE;
761} 719}
762 720
763void DateBook::flush() 721void DateBook::flush()
764{ 722{
765 syncing = TRUE; 723 syncing = TRUE;
766 db->save(); 724 db->save();
767} 725}
768 726
769void DateBook::timerEvent( QTimerEvent *e ) 727void DateBook::timerEvent( QTimerEvent *e )
770{ 728{
771 if ( alarmCounter < 10 ) { 729 if ( alarmCounter < 10 ) {
772 alarmCounter++; 730 alarmCounter++;
773 Sound::soundAlarm(); 731 Sound::soundAlarm();
774 } 732 } else {
775 else 733 killTimer( e->timerId() );
776 killTimer( e->timerId() ); 734 }
777} 735}
778 736
779void DateBook::changeClock( bool newClock ) 737void DateBook::changeClock( bool newClock )
780{ 738{
781 ampm = newClock; 739 ampm = newClock;
782 // repaint the affected objects... 740 // repaint the affected objects...
783 if (dayView) dayView->redraw(); 741 if (dayView) dayView->redraw();
784 if (weekView) weekView->redraw(); 742 if (weekView) weekView->redraw();
785 if (weekLstView) weekLstView->redraw(); 743 if (weekLstView) weekLstView->redraw();
786} 744}
787 745
788void DateBook::changeWeek( bool m ) 746void DateBook::changeWeek( bool m )
789{ 747{
790 /* no need to redraw, each widget catches. Do need to 748 /* no need to redraw, each widget catches. Do need to
791 store though for widgets we haven't made yet */ 749 store though for widgets we haven't made yet */
792 onMonday = m; 750 onMonday = m;
793} 751}
794 752
795void DateBook::slotToday() 753void DateBook::slotToday()
796{ 754{
797 // we need to view today using default view 755 // we need to view today using default view
798 viewDefault(QDate::currentDate()); 756 view(defaultView,QDate::currentDate());
799} 757}
800 758
801void DateBook::closeEvent( QCloseEvent *e ) 759void DateBook::closeEvent( QCloseEvent *e )
802{ 760{
803 if(syncing) { 761 if(syncing) {
804 /* no need to save, did that at flush */ 762 /* no need to save, did that at flush */
805 e->accept(); 763 e->accept();
806 return; 764 return;
807 } 765 }
808 766
809 // save settings will generate it's own error messages, no 767 // save settings will generate it's own error messages, no
810 // need to do checking ourselves. 768 // need to do checking ourselves.
811 saveSettings(); 769 saveSettings();
812 if ( db->save() ) 770 if ( db->save() ) {
813 e->accept(); 771 e->accept();
814 else { 772 } else {
815 if ( QMessageBox::critical( this, tr( "Out of space" ), 773 if ( QMessageBox::critical( this, tr( "Out of space" ),
816 tr("Calendar was unable to save\n" 774 tr("Calendar was unable to save\n"
817 "your changes.\n" 775 "your changes.\n"
818 "Free up some space and try again.\n" 776 "Free up some space and try again.\n"
819 "\nQuit anyway?"), 777 "\nQuit anyway?"),
820 QMessageBox::Yes|QMessageBox::Escape, 778 QMessageBox::Yes|QMessageBox::Escape,
821 QMessageBox::No|QMessageBox::Default ) 779 QMessageBox::No|QMessageBox::Default )
822 != QMessageBox::No ) 780 != QMessageBox::No )
823 e->accept(); 781 e->accept();
824 else 782 else
825 e->ignore(); 783 e->ignore();
826 } 784 }
827} 785}
828 786
829// Entering directly from the "keyboard" 787// Entering directly from the "keyboard"
830void DateBook::slotNewEventFromKey( const QString &str ) 788void DateBook::slotNewEventFromKey( const QString &str )
831{ 789{
832 if (syncing) { 790 if (syncing) {
833 QMessageBox::warning( this, tr("Calendar"), 791 QMessageBox::warning( this, tr("Calendar"),
834 tr( "Can not edit data, currently syncing") ); 792 tr( "Can not edit data, currently syncing") );
835 return; 793 return;
836 } 794 }
837 795
838 // We get to here from a key pressed in the Day View 796 // We get to here from a key pressed in the Day View
839 // So we can assume some things. We want the string 797 // So we can assume some things. We want the string
840 // passed in to be part of the description. 798 // passed in to be part of the description.
841 QDateTime start, end; 799 QDateTime start, end;
842 if ( views->visibleWidget() == dayView ) { 800 if ( views->visibleWidget() == dayView ) {
843 dayView->selectedDates( start, end ); 801 dayView->selectedDates( start, end );
844 } else if ( views->visibleWidget() == monthView ) { 802 } else if ( views->visibleWidget() == monthView ) {
845 QDate d = monthView->selectedDate(); 803 QDate d = monthView->selectedDate();
846 start = end = d; 804 start = end = d;
847 start.setTime( QTime( 10, 0 ) ); 805 start.setTime( QTime( 10, 0 ) );
848 end.setTime( QTime( 12, 0 ) ); 806 end.setTime( QTime( 12, 0 ) );
849 } else if ( views->visibleWidget() == weekView ) { 807 } else if ( views->visibleWidget() == weekView ) {
850 QDate d = weekView->date(); 808 QDate d = weekView->date();
851 start = end = d; 809 start = end = d;
852 start.setTime( QTime( 10, 0 ) ); 810 start.setTime( QTime( 10, 0 ) );
853 end.setTime( QTime( 12, 0 ) ); 811 end.setTime( QTime( 12, 0 ) );
854 } else if ( views->visibleWidget() == weekLstView ) { 812 } else if ( views->visibleWidget() == weekLstView ) {
855 QDate d = weekLstView->date(); 813 QDate d = weekLstView->date();
856 start = end = d; 814 start = end = d;
857 start.setTime( QTime( 10, 0 ) ); 815 start.setTime( QTime( 10, 0 ) );
858 end.setTime( QTime( 12, 0 ) ); 816 end.setTime( QTime( 12, 0 ) );
859 } 817 }
860 slotNewEntry(start, end, str); 818 slotNewEntry(start, end, str);
861} 819}
862void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 820void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
863 // argh! This really needs to be encapsulated in a class 821 // argh! This really needs to be encapsulated in a class
864 // or function. 822 // or function.
865 QDialog newDlg( this, 0, TRUE ); 823 QDialog newDlg( this, 0, TRUE );
866 newDlg.setCaption( DateEntryBase::tr("New Event") ); 824 newDlg.setCaption( DateEntryBase::tr("New Event") );
867 DateEntry *e; 825 DateEntry *e;
868 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 826 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
869 QScrollView *sv = new QScrollView( &newDlg ); 827 QScrollView *sv = new QScrollView( &newDlg );
870 sv->setResizePolicy( QScrollView::AutoOneFit ); 828 sv->setResizePolicy( QScrollView::AutoOneFit );
871 sv->setFrameStyle( QFrame::NoFrame ); 829 sv->setFrameStyle( QFrame::NoFrame );
872 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 830 sv->setHScrollBarMode( QScrollView::AlwaysOff );
873 vb->addWidget( sv ); 831 vb->addWidget( sv );
874 832
875 Event ev; 833 Event ev;
876 ev.setDescription( str ); 834 ev.setDescription( str );
877 // When the new gui comes in, change this... 835 // When the new gui comes in, change this...
878 if(location==0) { 836 if(location==0) {
879 ev.setLocation( tr("(Unknown)") ); 837 ev.setLocation( tr("(Unknown)") );
880 } else { 838 } else {
881 ev.setLocation(location); 839 ev.setLocation(location);
882 } 840 }
883 ev.setStart( start ); 841 ev.setStart( start );
884 ev.setEnd( end ); 842 ev.setEnd( end );
885 843
886 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 844 e = new DateEntry( onMonday, ev, ampm, &newDlg );
887 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 845 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
888 sv->addChild( e ); 846 sv->addChild( e );
889#if defined(Q_WS_QWS) || defined(_WS_QWS_) 847#if defined(Q_WS_QWS) || defined(_WS_QWS_)
890 newDlg.showMaximized(); 848 newDlg.showMaximized();
891#endif 849#endif
892 while (newDlg.exec()) { 850 while (newDlg.exec()) {
893 ev = e->event(); 851 ev = e->event();
894 ev.assignUid(); 852 ev.assignUid();
895 QString error = checkEvent( ev ); 853 QString error = checkEvent( ev );
896 if ( !error.isNull() ) { 854 if ( !error.isNull() ) {
897 if ( QMessageBox::warning( this, tr("Error!"), 855 if ( QMessageBox::warning( this, tr("Error!"),
898 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 856 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
899 continue; 857 continue;
900 } 858 }
901 db->addEvent( ev ); 859 db->addEvent( ev );
902 emit newEvent(); 860 emit newEvent();
903 break; 861 break;
904 } 862 }
905} 863}
906 864
907void DateBook::setDocument( const QString &filename ) 865void DateBook::setDocument( const QString &filename )
908{ 866{
909 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 867 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
910 868
911 QValueList<Event> tl = Event::readVCalendar( filename ); 869 QValueList<Event> tl = Event::readVCalendar( filename );
912 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 870 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
913 db->addEvent( *it ); 871 db->addEvent( *it );
914 } 872 }
915} 873}
916 874
917static const char * beamfile = "/tmp/obex/event.vcs"; 875static const char * beamfile = "/tmp/obex/event.vcs";
918 876
919void DateBook::beamEvent( const Event &e ) 877void DateBook::beamEvent( const Event &e )
920{ 878{
921 qDebug("trying to beamn"); 879 qDebug("trying to beamn");
922 unlink( beamfile ); // delete if exists 880 unlink( beamfile ); // delete if exists
923 mkdir("/tmp/obex/", 0755); 881 mkdir("/tmp/obex/", 0755);
924 Event::writeVCalendar( beamfile, e ); 882 Event::writeVCalendar( beamfile, e );
925 Ir *ir = new Ir( this ); 883 Ir *ir = new Ir( this );
926 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 884 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
927 QString description = e.description(); 885 QString description = e.description();
928 ir->send( beamfile, description, "text/x-vCalendar" ); 886 ir->send( beamfile, description, "text/x-vCalendar" );
929} 887}
930 888
931void DateBook::beamDone( Ir *ir ) 889void DateBook::beamDone( Ir *ir )
932{ 890{
933 delete ir; 891 delete ir;
934 unlink( beamfile ); 892 unlink( beamfile );
935} 893}
936 894
937void DateBook::slotFind() 895void DateBook::slotFind()
938{ 896{
939 // move it to the day view... 897 // move it to the day view...
940 viewDay(); 898 viewDay();
941 FindDialog frmFind( "Calendar", this ); 899 FindDialog frmFind( "Calendar", this );
942 frmFind.setUseDate( true ); 900 frmFind.setUseDate( true );
943 frmFind.setDate( currentDate() ); 901 frmFind.setDate( currentDate() );
944 QObject::connect( &frmFind, 902 QObject::connect( &frmFind,
945 SIGNAL(signalFindClicked(const QString&, const QDate&, 903 SIGNAL(signalFindClicked(const QString&, const QDate&,
946 bool, bool, int)), 904 bool, bool, int)),
947 this, 905 this,
948 SLOT(slotDoFind(const QString&, const QDate&, 906 SLOT(slotDoFind(const QString&, const QDate&,
949 bool, bool, int)) ); 907 bool, bool, int)) );
950 QObject::connect( this, 908 QObject::connect( this,
951 SIGNAL(signalNotFound()), 909 SIGNAL(signalNotFound()),
952 &frmFind, 910 &frmFind,
953 SLOT(slotNotFound()) ); 911 SLOT(slotNotFound()) );
954 QObject::connect( this, 912 QObject::connect( this,
955 SIGNAL(signalWrapAround()), 913 SIGNAL(signalWrapAround()),
956 &frmFind, 914 &frmFind,
957 SLOT(slotWrapAround()) ); 915 SLOT(slotWrapAround()) );
958 frmFind.move(0,0); 916 frmFind.move(0,0);
959 frmFind.exec(); 917 frmFind.exec();
960 inSearch = false; 918 inSearch = false;
961} 919}
962 920
963bool catComp( QArray<int> cats, int category ) 921bool catComp( QArray<int> cats, int category )
964{ 922{
965 bool returnMe; 923 bool returnMe;
966 int i, 924 int i,
967 count; 925 count;
968 926
969 count = int(cats.count()); 927 count = int(cats.count());
970 returnMe = false; 928 returnMe = false;
971 if ( (category == -1 && count == 0) || category == -2 ) 929 if ( (category == -1 && count == 0) || category == -2 )
972 returnMe = true; 930 returnMe = true;
973 else { 931 else {
974 for ( i = 0; i < count; i++ ) { 932 for ( i = 0; i < count; i++ ) {
975 if ( category == cats[i] ) { 933 if ( category == cats[i] ) {
976 returnMe = true; 934 returnMe = true;
977 break; 935 break;
978 } 936 }
979 } 937 }
980 } 938 }
981 return returnMe; 939 return returnMe;
982} 940}
983 941
984 942
985void DateBook::slotDoFind( const QString& txt, const QDate &dt, 943void DateBook::slotDoFind( const QString& txt, const QDate &dt,
986 bool caseSensitive, bool /*backwards*/, 944 bool caseSensitive, bool /*backwards*/,
987 int category ) 945 int category )
988{ 946{
989 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 947 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
990 next; 948 next;
991 949
992 QRegExp r( txt ); 950 QRegExp r( txt );
993 r.setCaseSensitive( caseSensitive ); 951 r.setCaseSensitive( caseSensitive );
994 952
995 953
996 static Event rev, 954 static Event rev,
997 nonrev; 955 nonrev;
998 if ( !inSearch ) { 956 if ( !inSearch ) {
999 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 957 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
1000 nonrev.setStart( rev.start() ); 958 nonrev.setStart( rev.start() );
1001 inSearch = true; 959 inSearch = true;
1002 } 960 }
1003 static QDate searchDate = dt; 961 static QDate searchDate = dt;
1004 static bool wrapAround = true; 962 static bool wrapAround = true;
1005 bool candidtate; 963 bool candidtate;
1006 candidtate = false; 964 candidtate = false;
1007 965
1008 QValueList<Event> repeats = db->getRawRepeats(); 966 QValueList<Event> repeats = db->getRawRepeats();
1009 967
1010 // find the candidate for the first repeat that matches... 968 // find the candidate for the first repeat that matches...
1011 QValueListConstIterator<Event> it; 969 QValueListConstIterator<Event> it;
1012 QDate start = dt; 970 QDate start = dt;
1013 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 971 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
1014 if ( catComp( (*it).categories(), category ) ) { 972 if ( catComp( (*it).categories(), category ) ) {
1015 while ( nextOccurance( *it, start, next ) ) { 973 while ( nextOccurance( *it, start, next ) ) {
1016 if ( next < dtEnd ) { 974 if ( next < dtEnd ) {
1017 if ( (*it).match( r ) && !(next <= rev.start()) ) { 975 if ( (*it).match( r ) && !(next <= rev.start()) ) {
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index 623862b..5216770 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -1,131 +1,135 @@
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
27 enum { DAY=1,WEEK,WEEKLST,MONTH };// defaultView values
28 enum { NONE=0,NORMAL,EXTENDED };// WeekLstView's modes.
29
27class QAction; 30class QAction;
28class QWidgetStack; 31class QWidgetStack;
29class DateBookDay; 32class DateBookDay;
30class DateBookWeek; 33class DateBookWeek;
31class DateBookWeekLst; 34class DateBookWeekLst;
32class DateBookMonth; 35class DateBookMonth;
33class Event; 36class Event;
34class QDate; 37class QDate;
35class Ir; 38class Ir;
36 39
37class DateBookDBHack : public DateBookDB { 40class DateBookDBHack : public DateBookDB {
38 public: 41 public:
39 Event eventByUID(int id); 42 Event eventByUID(int id);
40}; 43};
41 44
42class DateBook : public QMainWindow 45class DateBook : public QMainWindow
43{ 46{
44 Q_OBJECT 47 Q_OBJECT
45 48
46public: 49public:
47 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 50 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
48 ~DateBook(); 51 ~DateBook();
49 52
50signals: 53signals:
51 void newEvent(); 54 void newEvent();
52 void signalNotFound(); 55 void signalNotFound();
53 void signalWrapAround(); 56 void signalWrapAround();
54 57
55protected: 58protected:
56 QDate currentDate(); 59 QDate currentDate();
57 void timerEvent( QTimerEvent *e ); 60 void timerEvent( QTimerEvent *e );
58 void closeEvent( QCloseEvent *e ); 61 void closeEvent( QCloseEvent *e );
59 62
60 void view(int v, const QDate &d); 63 void view(int v, const QDate &d);
61 64
62public slots: 65public slots:
63 void flush(); 66 void flush();
64 void reload(); 67 void reload();
65 68
66private slots: 69private slots:
67 void fileNew(); 70 void fileNew();
68 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); 71 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0);
69 void slotSettings(); 72 void slotSettings();
70 void newDefaultView(QAction *a);
71 void slotToday();// view today 73 void slotToday();// view today
72 void changeClock( bool newClock ); 74 void changeClock( bool newClock );
73 void changeWeek( bool newDay ); 75 void changeWeek( bool newDay );
74 void appMessage(const QCString& msg, const QByteArray& data); 76 void appMessage(const QCString& msg, const QByteArray& data);
75 // handle key events in the day view... 77 // handle key events in the day view...
76 void slotNewEventFromKey( const QString &str ); 78 void slotNewEventFromKey( const QString &str );
77 void slotFind(); 79 void slotFind();
78 void slotDoFind( const QString &, const QDate &, bool, bool, int ); 80 void slotDoFind( const QString &, const QDate &, bool, bool, int );
79 81
80 void viewDefault(const QDate &d); 82 void viewDefault(const QDate &d);
81 83
82 void viewDay(); 84 void viewDay();
83 void viewWeek(); 85 void viewWeek();
84 void viewWeekLst(); 86 void viewWeekLst();
85 void viewMonth(); 87 void viewMonth();
86 88
87 void showDay( int y, int m, int d ); 89 void showDay( int y, int m, int d );
88 90
89 void editEvent( const Event &e ); 91 void editEvent( const Event &e );
90 void duplicateEvent( const Event &e ); 92 void duplicateEvent( const Event &e );
91 void removeEvent( const Event &e ); 93 void removeEvent( const Event &e );
92 94
93 void receive( const QCString &msg, const QByteArray &data ); 95 void receive( const QCString &msg, const QByteArray &data );
94 void setDocument( const QString & ); 96 void setDocument( const QString & );
95 void beamEvent( const Event &e ); 97 void beamEvent( const Event &e );
96 void beamDone( Ir *ir ); 98 void beamDone( Ir *ir );
97 99
98private: 100private:
99 void addEvent( const Event &e ); 101 void addEvent( const Event &e );
100 void initDay(); 102 void initDay();
101 void initWeek(); 103 void initWeek();
102 void initWeekLst(); 104 void initWeekLst();
103 void initMonth(); 105 void initMonth();
104 void loadSettings(); 106 void loadSettings();
105 void saveSettings(); 107 void saveSettings();
106 108
107private: 109private:
108 DateBookDBHack *db; 110 DateBookDBHack *db;
109 QWidgetStack *views; 111 QWidgetStack *views;
110 DateBookDay *dayView; 112 DateBookDay *dayView;
111 DateBookWeek *weekView; 113 DateBookWeek *weekView;
112 DateBookMonth *monthView; 114 DateBookMonth *monthView;
113 DateBookWeekLst *weekLstView; 115 DateBookWeekLst *weekLstView;
114 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 116 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
117 int weeklistviewconfig;
115 bool aPreset; // have everything set to alarm? 118 bool aPreset; // have everything set to alarm?
116 int presetTime; // the standard time for the alarm 119 int presetTime; // the standard time for the alarm
117 int startTime; 120 int startTime;
118 int rowStyle; 121 int rowStyle;
119 bool bJumpToCurTime; //should jump to current time in dayview? 122 int defaultView;
123 bool bJumpToCurTime; //should jump to current time in dayview?
120 bool ampm; 124 bool ampm;
121 bool onMonday; 125 bool onMonday;
122 126
123 bool syncing; 127 bool syncing;
124 bool inSearch; 128 bool inSearch;
125 129
126 int alarmCounter; 130 int alarmCounter;
127 131
128 QString checkEvent(const Event &); 132 QString checkEvent(const Event &);
129}; 133};
130 134
131#endif 135#endif
diff --git a/core/pim/datebook/datebooksettingsbase.ui b/core/pim/datebook/datebooksettingsbase.ui
index 816a441..3836330 100644
--- a/core/pim/datebook/datebooksettingsbase.ui
+++ b/core/pim/datebook/datebooksettingsbase.ui
@@ -1,399 +1,575 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>DateBookSettingsBase</class> 2<class>DateBookSettingsBase</class>
3<comment>********************************************************************** 3<comment>**********************************************************************
4** Copyright (C) 2000 Trolltech AS. All rights reserved. 4** Copyright (C) 2000 Trolltech AS. All rights reserved.
5** 5**
6** This file is part of Qtopia Environment. 6** This file is part of Qtopia Environment.
7** 7**
8** This file may be distributed and/or modified under the terms of the 8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software 9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the 10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file. 11** packaging of this file.
12** 12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15** 15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information. 16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17** 17**
18** Contact info@trolltech.com if any conditions of this licensing are 18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you. 19** not clear to you.
20** 20**
21** $Id$ 21** $Id$
22** 22**
23**********************************************************************</comment> 23**********************************************************************</comment>
24<widget> 24<widget>
25 <class>QDialog</class> 25 <class>QDialog</class>
26 <property stdset="1"> 26 <property stdset="1">
27 <name>name</name> 27 <name>name</name>
28 <cstring>DateBookSettingsBase</cstring> 28 <cstring>DateBookSettingsBase</cstring>
29 </property> 29 </property>
30 <property stdset="1"> 30 <property stdset="1">
31 <name>geometry</name> 31 <name>geometry</name>
32 <rect> 32 <rect>
33 <x>0</x> 33 <x>0</x>
34 <y>0</y> 34 <y>0</y>
35 <width>220</width> 35 <width>273</width>
36 <height>290</height> 36 <height>303</height>
37 </rect> 37 </rect>
38 </property> 38 </property>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>caption</name> 40 <name>caption</name>
41 <string>Preferences</string> 41 <string>Preferences</string>
42 </property> 42 </property>
43 <property> 43 <property>
44 <name>layoutMargin</name> 44 <name>layoutMargin</name>
45 </property> 45 </property>
46 <property> 46 <property>
47 <name>layoutSpacing</name> 47 <name>layoutSpacing</name>
48 </property> 48 </property>
49 <grid> 49 <vbox>
50 <property stdset="1"> 50 <property stdset="1">
51 <name>margin</name> 51 <name>margin</name>
52 <number>11</number> 52 <number>11</number>
53 </property> 53 </property>
54 <property stdset="1"> 54 <property stdset="1">
55 <name>spacing</name> 55 <name>spacing</name>
56 <number>6</number> 56 <number>6</number>
57 </property> 57 </property>
58 <widget row="0" column="0" > 58 <widget>
59 <class>QGroupBox</class> 59 <class>QTabWidget</class>
60 <property stdset="1"> 60 <property stdset="1">
61 <name>name</name> 61 <name>name</name>
62 <cstring>fraStart</cstring> 62 <cstring>TabWidget2</cstring>
63 </property>
64 <property stdset="1">
65 <name>frameShape</name>
66 <enum>Box</enum>
67 </property>
68 <property stdset="1">
69 <name>frameShadow</name>
70 <enum>Sunken</enum>
71 </property>
72 <property stdset="1">
73 <name>title</name>
74 <string>Start viewing events</string>
75 </property> 63 </property>
76 <widget> 64 <widget>
77 <class>QLayoutWidget</class> 65 <class>QWidget</class>
78 <property stdset="1"> 66 <property stdset="1">
79 <name>name</name> 67 <name>name</name>
80 <cstring>Layout6</cstring> 68 <cstring>tab</cstring>
81 </property> 69 </property>
82 <property stdset="1"> 70 <attribute>
83 <name>geometry</name> 71 <name>title</name>
84 <rect> 72 <string>Views</string>
85 <x>3</x> 73 </attribute>
86 <y>21</y> 74 <vbox>
87 <width>210</width>
88 <height>53</height>
89 </rect>
90 </property>
91 <grid>
92 <property stdset="1"> 75 <property stdset="1">
93 <name>margin</name> 76 <name>margin</name>
94 <number>0</number> 77 <number>11</number>
95 </property> 78 </property>
96 <property stdset="1"> 79 <property stdset="1">
97 <name>spacing</name> 80 <name>spacing</name>
98 <number>6</number> 81 <number>6</number>
99 </property> 82 </property>
100 <spacer row="1" column="0" > 83 <widget>
101 <property>
102 <name>name</name>
103 <cstring>Spacer1</cstring>
104 </property>
105 <property stdset="1">
106 <name>orientation</name>
107 <enum>Vertical</enum>
108 </property>
109 <property stdset="1">
110 <name>sizeType</name>
111 <enum>Expanding</enum>
112 </property>
113 <property>
114 <name>sizeHint</name>
115 <size>
116 <width>20</width>
117 <height>20</height>
118 </size>
119 </property>
120 </spacer>
121 <widget row="0" column="0" >
122 <class>QLayoutWidget</class> 84 <class>QLayoutWidget</class>
123 <property stdset="1"> 85 <property stdset="1">
124 <name>name</name> 86 <name>name</name>
125 <cstring>Layout1</cstring> 87 <cstring>Layout5</cstring>
126 </property> 88 </property>
127 <hbox> 89 <hbox>
128 <property stdset="1"> 90 <property stdset="1">
129 <name>margin</name> 91 <name>margin</name>
130 <number>0</number> 92 <number>0</number>
131 </property> 93 </property>
132 <property stdset="1"> 94 <property stdset="1">
133 <name>spacing</name> 95 <name>spacing</name>
134 <number>6</number> 96 <number>6</number>
135 </property> 97 </property>
98 <spacer>
99 <property>
100 <name>name</name>
101 <cstring>Spacer1</cstring>
102 </property>
103 <property stdset="1">
104 <name>orientation</name>
105 <enum>Horizontal</enum>
106 </property>
107 <property stdset="1">
108 <name>sizeType</name>
109 <enum>Expanding</enum>
110 </property>
111 <property>
112 <name>sizeHint</name>
113 <size>
114 <width>20</width>
115 <height>20</height>
116 </size>
117 </property>
118 </spacer>
136 <widget> 119 <widget>
137 <class>QLabel</class> 120 <class>QLabel</class>
138 <property stdset="1"> 121 <property stdset="1">
139 <name>name</name> 122 <name>name</name>
140 <cstring>lblStartTime</cstring> 123 <cstring>TextLabel1_2</cstring>
141 </property> 124 </property>
142 <property stdset="1"> 125 <property stdset="1">
143 <name>text</name> 126 <name>text</name>
144 <string>Start Time:</string> 127 <string>Default view:</string>
145 </property> 128 </property>
146 </widget> 129 </widget>
147 <widget> 130 <widget>
148 <class>QSpinBox</class> 131 <class>QComboBox</class>
132 <item>
133 <property>
134 <name>text</name>
135 <string>Day</string>
136 </property>
137 </item>
138 <item>
139 <property>
140 <name>text</name>
141 <string>Week</string>
142 </property>
143 </item>
144 <item>
145 <property>
146 <name>text</name>
147 <string>Week List</string>
148 </property>
149 </item>
150 <item>
151 <property>
152 <name>text</name>
153 <string>Month</string>
154 </property>
155 </item>
149 <property stdset="1"> 156 <property stdset="1">
150 <name>name</name> 157 <name>name</name>
151 <cstring>spinStart</cstring> 158 <cstring>comboDefaultView</cstring>
152 </property> 159 </property>
153 <property stdset="1"> 160 </widget>
154 <name>suffix</name> 161 <spacer>
155 <string>:00</string> 162 <property>
163 <name>name</name>
164 <cstring>Spacer2</cstring>
156 </property> 165 </property>
157 <property stdset="1"> 166 <property stdset="1">
158 <name>wrapping</name> 167 <name>orientation</name>
159 <bool>true</bool> 168 <enum>Horizontal</enum>
160 </property> 169 </property>
161 <property stdset="1"> 170 <property stdset="1">
162 <name>maxValue</name> 171 <name>sizeType</name>
163 <number>23</number> 172 <enum>Expanding</enum>
164 </property> 173 </property>
165 </widget> 174 <property>
175 <name>sizeHint</name>
176 <size>
177 <width>20</width>
178 <height>20</height>
179 </size>
180 </property>
181 </spacer>
166 </hbox> 182 </hbox>
167 </widget> 183 </widget>
168 </grid> 184 <widget>
169 </widget> 185 <class>QGroupBox</class>
170 </widget>
171 <widget row="1" column="0" >
172 <class>QGroupBox</class>
173 <property stdset="1">
174 <name>name</name>
175 <cstring>fraAlarm</cstring>
176 </property>
177 <property stdset="1">
178 <name>title</name>
179 <string>Alarm Settings</string>
180 </property>
181 <widget>
182 <class>QLayoutWidget</class>
183 <property stdset="1">
184 <name>name</name>
185 <cstring>Layout4</cstring>
186 </property>
187 <property stdset="1">
188 <name>geometry</name>
189 <rect>
190 <x>10</x>
191 <y>20</y>
192 <width>200</width>
193 <height>53</height>
194 </rect>
195 </property>
196 <grid>
197 <property stdset="1">
198 <name>margin</name>
199 <number>0</number>
200 </property>
201 <property stdset="1">
202 <name>spacing</name>
203 <number>6</number>
204 </property>
205 <spacer row="1" column="0" >
206 <property>
207 <name>name</name>
208 <cstring>Spacer2</cstring>
209 </property>
210 <property stdset="1">
211 <name>orientation</name>
212 <enum>Vertical</enum>
213 </property>
214 <property stdset="1"> 186 <property stdset="1">
215 <name>sizeType</name> 187 <name>name</name>
216 <enum>Expanding</enum> 188 <cstring>GroupBox4</cstring>
217 </property>
218 <property>
219 <name>sizeHint</name>
220 <size>
221 <width>20</width>
222 <height>20</height>
223 </size>
224 </property> 189 </property>
225 </spacer>
226 <widget row="0" column="0" >
227 <class>QLayoutWidget</class>
228 <property stdset="1"> 190 <property stdset="1">
229 <name>name</name> 191 <name>title</name>
230 <cstring>Layout6</cstring> 192 <string>Day</string>
231 </property> 193 </property>
232 <hbox> 194 <vbox>
233 <property stdset="1"> 195 <property stdset="1">
234 <name>margin</name> 196 <name>margin</name>
235 <number>0</number> 197 <number>11</number>
236 </property> 198 </property>
237 <property stdset="1"> 199 <property stdset="1">
238 <name>spacing</name> 200 <name>spacing</name>
239 <number>6</number> 201 <number>6</number>
240 </property> 202 </property>
241 <widget> 203 <widget>
242 <class>QCheckBox</class> 204 <class>QCheckBox</class>
243 <property stdset="1"> 205 <property stdset="1">
244 <name>name</name> 206 <name>name</name>
245 <cstring>chkAlarmPreset</cstring> 207 <cstring>chkJumpToCurTime</cstring>
246 </property> 208 </property>
247 <property stdset="1"> 209 <property stdset="1">
248 <name>text</name> 210 <name>text</name>
249 <string>Alarm Preset</string> 211 <string>Jump to current time</string>
250 </property> 212 </property>
251 </widget> 213 </widget>
252 <widget> 214 <widget>
253 <class>QSpinBox</class> 215 <class>QLayoutWidget</class>
254 <property stdset="1"> 216 <property stdset="1">
255 <name>name</name> 217 <name>name</name>
256 <cstring>spinPreset</cstring> 218 <cstring>Layout5</cstring>
257 </property>
258 <property stdset="1">
259 <name>enabled</name>
260 <bool>false</bool>
261 </property>
262 <property stdset="1">
263 <name>suffix</name>
264 <string> minutes</string>
265 </property>
266 <property stdset="1">
267 <name>maxValue</name>
268 <number>180</number>
269 </property>
270 <property stdset="1">
271 <name>minValue</name>
272 <number>0</number>
273 </property>
274 <property stdset="1">
275 <name>lineStep</name>
276 <number>5</number>
277 </property> 219 </property>
220 <hbox>
221 <property stdset="1">
222 <name>margin</name>
223 <number>0</number>
224 </property>
225 <property stdset="1">
226 <name>spacing</name>
227 <number>6</number>
228 </property>
229 <widget>
230 <class>QLabel</class>
231 <property stdset="1">
232 <name>name</name>
233 <cstring>TextLabel1</cstring>
234 </property>
235 <property stdset="1">
236 <name>text</name>
237 <string>Row style:</string>
238 </property>
239 </widget>
240 <widget>
241 <class>QComboBox</class>
242 <item>
243 <property>
244 <name>text</name>
245 <string>Default</string>
246 </property>
247 </item>
248 <item>
249 <property>
250 <name>text</name>
251 <string>Medium</string>
252 </property>
253 </item>
254 <item>
255 <property>
256 <name>text</name>
257 <string>Large</string>
258 </property>
259 </item>
260 <property stdset="1">
261 <name>name</name>
262 <cstring>comboRowStyle</cstring>
263 </property>
264 </widget>
265 </hbox>
266 </widget>
267 </vbox>
268 </widget>
269 <widget>
270 <class>QGroupBox</class>
271 <property stdset="1">
272 <name>name</name>
273 <cstring>GroupBox5</cstring>
274 </property>
275 <property stdset="1">
276 <name>title</name>
277 <string>Week List</string>
278 </property>
279 <vbox>
280 <property stdset="1">
281 <name>margin</name>
282 <number>11</number>
283 </property>
284 <property stdset="1">
285 <name>spacing</name>
286 <number>6</number>
287 </property>
288 <widget>
289 <class>QLayoutWidget</class>
278 <property stdset="1"> 290 <property stdset="1">
279 <name>value</name> 291 <name>name</name>
280 <number>5</number> 292 <cstring>Layout6</cstring>
281 </property> 293 </property>
294 <hbox>
295 <property stdset="1">
296 <name>margin</name>
297 <number>0</number>
298 </property>
299 <property stdset="1">
300 <name>spacing</name>
301 <number>6</number>
302 </property>
303 <widget>
304 <class>QLabel</class>
305 <property stdset="1">
306 <name>name</name>
307 <cstring>TextLabel2</cstring>
308 </property>
309 <property stdset="1">
310 <name>text</name>
311 <string>Time display</string>
312 </property>
313 </widget>
314 <widget>
315 <class>QComboBox</class>
316 <item>
317 <property>
318 <name>text</name>
319 <string>None</string>
320 </property>
321 </item>
322 <item>
323 <property>
324 <name>text</name>
325 <string>Start</string>
326 </property>
327 </item>
328 <item>
329 <property>
330 <name>text</name>
331 <string>Start-End</string>
332 </property>
333 </item>
334 <property stdset="1">
335 <name>name</name>
336 <cstring>comboWeekListView</cstring>
337 </property>
338 </widget>
339 </hbox>
282 </widget> 340 </widget>
283 </hbox> 341 </vbox>
284 </widget> 342 </widget>
285 </grid> 343 <spacer>
344 <property>
345 <name>name</name>
346 <cstring>Spacer3_2</cstring>
347 </property>
348 <property stdset="1">
349 <name>orientation</name>
350 <enum>Vertical</enum>
351 </property>
352 <property stdset="1">
353 <name>sizeType</name>
354 <enum>Expanding</enum>
355 </property>
356 <property>
357 <name>sizeHint</name>
358 <size>
359 <width>20</width>
360 <height>20</height>
361 </size>
362 </property>
363 </spacer>
364 </vbox>
286 </widget> 365 </widget>
287 </widget>
288 <widget row="2" column="0" >
289 <class>QGroupBox</class>
290 <property stdset="1">
291 <name>name</name>
292 <cstring>fraMisc</cstring>
293 </property>
294 <property stdset="1">
295 <name>title</name>
296 <string>Misc</string>
297 </property>
298 <widget> 366 <widget>
299 <class>QLayoutWidget</class> 367 <class>QWidget</class>
300 <property stdset="1"> 368 <property stdset="1">
301 <name>name</name> 369 <name>name</name>
302 <cstring>Layout5</cstring> 370 <cstring>tab</cstring>
303 </property>
304 <property stdset="1">
305 <name>geometry</name>
306 <rect>
307 <x>10</x>
308 <y>40</y>
309 <width>170</width>
310 <height>24</height>
311 </rect>
312 </property> 371 </property>
313 <hbox> 372 <attribute>
373 <name>title</name>
374 <string>Misc</string>
375 </attribute>
376 <vbox>
314 <property stdset="1"> 377 <property stdset="1">
315 <name>margin</name> 378 <name>margin</name>
316 <number>0</number> 379 <number>11</number>
317 </property> 380 </property>
318 <property stdset="1"> 381 <property stdset="1">
319 <name>spacing</name> 382 <name>spacing</name>
320 <number>6</number> 383 <number>6</number>
321 </property> 384 </property>
322 <widget> 385 <widget>
323 <class>QLabel</class> 386 <class>QGroupBox</class>
324 <property stdset="1"> 387 <property stdset="1">
325 <name>name</name> 388 <name>name</name>
326 <cstring>TextLabel1</cstring> 389 <cstring>GroupBox6</cstring>
327 </property> 390 </property>
328 <property stdset="1"> 391 <property stdset="1">
329 <name>text</name> 392 <name>title</name>
330 <string>Row style:</string> 393 <string>Alarm Settings</string>
331 </property> 394 </property>
332 </widget> 395 <vbox>
333 <widget> 396 <property stdset="1">
334 <class>QComboBox</class> 397 <name>margin</name>
335 <item> 398 <number>11</number>
336 <property>
337 <name>text</name>
338 <string>Default</string>
339 </property>
340 </item>
341 <item>
342 <property>
343 <name>text</name>
344 <string>Medium</string>
345 </property> 399 </property>
346 </item> 400 <property stdset="1">
347 <item> 401 <name>spacing</name>
348 <property> 402 <number>6</number>
349 <name>text</name>
350 <string>Large</string>
351 </property> 403 </property>
352 </item> 404 <widget>
405 <class>QLayoutWidget</class>
406 <property stdset="1">
407 <name>name</name>
408 <cstring>Layout6</cstring>
409 </property>
410 <hbox>
411 <property stdset="1">
412 <name>margin</name>
413 <number>0</number>
414 </property>
415 <property stdset="1">
416 <name>spacing</name>
417 <number>6</number>
418 </property>
419 <widget>
420 <class>QCheckBox</class>
421 <property stdset="1">
422 <name>name</name>
423 <cstring>chkAlarmPreset</cstring>
424 </property>
425 <property stdset="1">
426 <name>text</name>
427 <string>Alarm Preset</string>
428 </property>
429 </widget>
430 <widget>
431 <class>QSpinBox</class>
432 <property stdset="1">
433 <name>name</name>
434 <cstring>spinPreset</cstring>
435 </property>
436 <property stdset="1">
437 <name>enabled</name>
438 <bool>false</bool>
439 </property>
440 <property stdset="1">
441 <name>suffix</name>
442 <string> minutes</string>
443 </property>
444 <property stdset="1">
445 <name>maxValue</name>
446 <number>180</number>
447 </property>
448 <property stdset="1">
449 <name>minValue</name>
450 <number>0</number>
451 </property>
452 <property stdset="1">
453 <name>lineStep</name>
454 <number>5</number>
455 </property>
456 <property stdset="1">
457 <name>value</name>
458 <number>5</number>
459 </property>
460 </widget>
461 </hbox>
462 </widget>
463 </vbox>
464 </widget>
465 <widget>
466 <class>QGroupBox</class>
353 <property stdset="1"> 467 <property stdset="1">
354 <name>name</name> 468 <name>name</name>
355 <cstring>comboRowStyle</cstring> 469 <cstring>GroupBox7</cstring>
356 </property> 470 </property>
471 <property stdset="1">
472 <name>title</name>
473 <string>Start viewing events</string>
474 </property>
475 <vbox>
476 <property stdset="1">
477 <name>margin</name>
478 <number>11</number>
479 </property>
480 <property stdset="1">
481 <name>spacing</name>
482 <number>6</number>
483 </property>
484 <widget>
485 <class>QLayoutWidget</class>
486 <property stdset="1">
487 <name>name</name>
488 <cstring>Layout1</cstring>
489 </property>
490 <hbox>
491 <property stdset="1">
492 <name>margin</name>
493 <number>0</number>
494 </property>
495 <property stdset="1">
496 <name>spacing</name>
497 <number>6</number>
498 </property>
499 <widget>
500 <class>QLabel</class>
501 <property stdset="1">
502 <name>name</name>
503 <cstring>lblStartTime</cstring>
504 </property>
505 <property stdset="1">
506 <name>text</name>
507 <string>Start Time:</string>
508 </property>
509 </widget>
510 <widget>
511 <class>QSpinBox</class>
512 <property stdset="1">
513 <name>name</name>
514 <cstring>spinStart</cstring>
515 </property>
516 <property stdset="1">
517 <name>suffix</name>
518 <string>:00</string>
519 </property>
520 <property stdset="1">
521 <name>wrapping</name>
522 <bool>true</bool>
523 </property>
524 <property stdset="1">
525 <name>maxValue</name>
526 <number>23</number>
527 </property>
528 </widget>
529 </hbox>
530 </widget>
531 </vbox>
357 </widget> 532 </widget>
358 </hbox> 533 <spacer>
359 </widget> 534 <property>
360 <widget> 535 <name>name</name>
361 <class>QCheckBox</class> 536 <cstring>Spacer9</cstring>
362 <property stdset="1"> 537 </property>
363 <name>name</name> 538 <property stdset="1">
364 <cstring>chkJumpToCurTime</cstring> 539 <name>orientation</name>
365 </property> 540 <enum>Vertical</enum>
366 <property stdset="1"> 541 </property>
367 <name>geometry</name> 542 <property stdset="1">
368 <rect> 543 <name>sizeType</name>
369 <x>10</x> 544 <enum>Expanding</enum>
370 <y>20</y> 545 </property>
371 <width>200</width> 546 <property>
372 <height>20</height> 547 <name>sizeHint</name>
373 </rect> 548 <size>
374 </property> 549 <width>20</width>
375 <property stdset="1"> 550 <height>20</height>
376 <name>text</name> 551 </size>
377 <string>Jump to current time (dayview)</string> 552 </property>
378 </property> 553 </spacer>
554 </vbox>
379 </widget> 555 </widget>
380 </widget> 556 </widget>
381 </grid> 557 </vbox>
382</widget> 558</widget>
383<connections> 559<connections>
384 <connection> 560 <connection>
385 <sender>chkAlarmPreset</sender> 561 <sender>chkAlarmPreset</sender>
386 <signal>toggled(bool)</signal> 562 <signal>toggled(bool)</signal>
387 <receiver>spinPreset</receiver> 563 <receiver>spinPreset</receiver>
388 <slot>setEnabled(bool)</slot> 564 <slot>setEnabled(bool)</slot>
389 </connection> 565 </connection>
390 <connection> 566 <connection>
391 <sender>spinStart</sender> 567 <sender>spinStart</sender>
392 <signal>valueChanged(int)</signal> 568 <signal>valueChanged(int)</signal>
393 <receiver>DateBookSettingsBase</receiver> 569 <receiver>DateBookSettingsBase</receiver>
394 <slot>slot12Hour( int )</slot> 570 <slot>slot12Hour( int )</slot>
395 </connection> 571 </connection>
396 <slot access="public">slotChangeClock( bool )</slot> 572 <slot access="public">slotChangeClock( bool )</slot>
397 <slot access="public">slot12Hour( int )</slot> 573 <slot access="public">slot12Hour( int )</slot>
398</connections> 574</connections>
399</UI> 575</UI>
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 3d6a029..3c8fc89 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,381 +1,390 @@
1#include "datebookweeklst.h" 1#include "datebookweeklst.h"
2 2
3#include "datebookweekheaderimpl.h" 3#include "datebookweekheaderimpl.h"
4 4
5#include "datebook.h"
6
5#include <qpe/calendar.h> 7#include <qpe/calendar.h>
6#include <qpe/datebookdb.h> 8#include <qpe/datebookdb.h>
7#include <qpe/event.h> 9#include <qpe/event.h>
8#include <qpe/qpeapplication.h> 10#include <qpe/qpeapplication.h>
9#include <qpe/timestring.h> 11#include <qpe/timestring.h>
10#include <qpe/datebookmonth.h> 12#include <qpe/datebookmonth.h>
11#include <qpe/config.h> 13#include <qpe/config.h>
12#include <qpe/resource.h> 14#include <qpe/resource.h>
13 15
14#include <qdatetime.h> 16#include <qdatetime.h>
15#include <qheader.h> 17#include <qheader.h>
16#include <qlabel.h> 18#include <qlabel.h>
17#include <qlayout.h> 19#include <qlayout.h>
18#include <qpainter.h> 20#include <qpainter.h>
19#include <qpopupmenu.h> 21#include <qpopupmenu.h>
20#include <qtimer.h> 22#include <qtimer.h>
21#include <qstyle.h> 23#include <qstyle.h>
22#include <qtoolbutton.h> 24#include <qtoolbutton.h>
23#include <qvbox.h> 25#include <qvbox.h>
24#include <qsizepolicy.h> 26#include <qsizepolicy.h>
25#include <qabstractlayout.h> 27#include <qabstractlayout.h>
26#include <qtl.h> 28#include <qtl.h>
27 29
28bool calcWeek(const QDate &d, int &week, int &year, 30bool calcWeek(const QDate &d, int &week, int &year,
29 bool startOnMonday = false); 31 bool startOnMonday = false);
30 32
31DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, 33DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
32 const char* name, WFlags fl) 34 const char* name, WFlags fl)
33 : DateBookWeekLstHeaderBase(parent, name, fl) 35 : DateBookWeekLstHeaderBase(parent, name, fl)
34{ 36{
35 setBackgroundMode( PaletteButton ); 37 setBackgroundMode( PaletteButton );
36 labelDate->setBackgroundMode( PaletteButton ); 38 labelDate->setBackgroundMode( PaletteButton );
37 labelWeek->setBackgroundMode( PaletteButton ); 39 labelWeek->setBackgroundMode( PaletteButton );
38 forward->setBackgroundMode( PaletteButton ); 40 forward->setBackgroundMode( PaletteButton );
39 forward->setPixmap( Resource::loadPixmap("forward") ); 41 forward->setPixmap( Resource::loadPixmap("forward") );
40 back->setBackgroundMode( PaletteButton ); 42 back->setBackgroundMode( PaletteButton );
41 back->setPixmap( Resource::loadPixmap("back") ); 43 back->setPixmap( Resource::loadPixmap("back") );
42 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 44 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
43 DateBookWeekLstHeaderBaseLayout->setMargin(0); 45 DateBookWeekLstHeaderBaseLayout->setMargin(0);
44 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 46 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
45 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 47 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
46 48
47 connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); 49 connect(back, SIGNAL(clicked()), this, SLOT(prevWeek()));
48 connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); 50 connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek()));
49 connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); 51 connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate()));
50 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 52 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
51 onMonday=onM; 53 onMonday=onM;
52} 54}
53DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 55DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
54void DateBookWeekLstHeader::setDate(const QDate &d) { 56void DateBookWeekLstHeader::setDate(const QDate &d) {
55 date=d; 57 date=d;
56 58
57 int year,week; 59 int year,week;
58 calcWeek(d,week,year,onMonday); 60 calcWeek(d,week,year,onMonday);
59 labelWeek->setText(tr( "W: %1" ).arg( ( QString::number(week)) ) ); 61 labelWeek->setText(tr( "W: %1" ).arg( ( QString::number(week)) ) );
60 62
61 QDate start=date; 63 QDate start=date;
62 QDate stop=start.addDays(6); 64 QDate stop=start.addDays(6);
63 labelDate->setText( QString::number(start.day()) + " " + 65 labelDate->setText( QString::number(start.day()) + " " +
64 start.monthName(start.month()) + " - " + 66 start.monthName(start.month()) + " - " +
65 QString::number(stop.day()) + " " + 67 QString::number(stop.day()) + " " +
66 start.monthName(stop.month()) ); 68 start.monthName(stop.month()) );
67 emit dateChanged(year,week); 69 emit dateChanged(year,week);
68} 70}
69void DateBookWeekLstHeader::pickDate() { 71void DateBookWeekLstHeader::pickDate() {
70 static QPopupMenu *m1 = 0; 72 static QPopupMenu *m1 = 0;
71 static DateBookMonth *picker = 0; 73 static DateBookMonth *picker = 0;
72 if ( !m1 ) { 74 if ( !m1 ) {
73 m1 = new QPopupMenu( this ); 75 m1 = new QPopupMenu( this );
74 picker = new DateBookMonth( m1, 0, TRUE ); 76 picker = new DateBookMonth( m1, 0, TRUE );
75 m1->insertItem( picker ); 77 m1->insertItem( picker );
76 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 78 connect( picker, SIGNAL( dateClicked( int, int, int ) ),
77 this, SLOT( setDate( int, int, int ) ) ); 79 this, SLOT( setDate( int, int, int ) ) );
78 //connect( m1, SIGNAL( aboutToHide() ), 80 //connect( m1, SIGNAL( aboutToHide() ),
79 //this, SLOT( gotHide() ) ); 81 //this, SLOT( gotHide() ) );
80 } 82 }
81 picker->setDate( date.year(), date.month(), date.day() ); 83 picker->setDate( date.year(), date.month(), date.day() );
82 m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height()))); 84 m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height())));
83 picker->setFocus(); 85 picker->setFocus();
84} 86}
85void DateBookWeekLstHeader::setDate(int y, int m, int d) { 87void DateBookWeekLstHeader::setDate(int y, int m, int d) {
86 QDate new_date(y,m,d); 88 QDate new_date(y,m,d);
87 setDate(new_date); 89 setDate(new_date);
88} 90}
89 91
90void DateBookWeekLstHeader::nextWeek() { 92void DateBookWeekLstHeader::nextWeek() {
91 setDate(date.addDays(7)); 93 setDate(date.addDays(7));
92} 94}
93void DateBookWeekLstHeader::prevWeek() { 95void DateBookWeekLstHeader::prevWeek() {
94 setDate(date.addDays(-7)); 96 setDate(date.addDays(-7));
95} 97}
96 98
97DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, 99DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
98 QWidget* parent, 100 QWidget* parent,
99 const char* name, 101 const char* name,
100 WFlags fl ) 102 WFlags fl )
101 : DateBookWeekLstDayHdrBase(parent, name, fl) { 103 : DateBookWeekLstDayHdrBase(parent, name, fl) {
102 104
103 date=d; 105 date=d;
104 106
105 static const char *wdays={"MTWTFSS"}; 107 static const char *wdays={"MTWTFSS"};
106 char day=wdays[d.dayOfWeek()-1]; 108 char day=wdays[d.dayOfWeek()-1];
107 109
108 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " + 110 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +
109 QString::number(d.day()) ); 111 QString::number(d.day()) );
110 add->setText("+"); 112 add->setText("+");
111 113
112 if (d == QDate::currentDate()) { 114 if (d == QDate::currentDate()) {
113 QPalette pal=label->palette(); 115 QPalette pal=label->palette();
114 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 116 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
115 label->setPalette(pal); 117 label->setPalette(pal);
116 118
117 /* 119 /*
118 QFont f=label->font(); 120 QFont f=label->font();
119 f.setItalic(true); 121 f.setItalic(true);
120 label->setFont(f); 122 label->setFont(f);
121 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 123 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
122 */ 124 */
123 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 125 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
124 QPalette pal=label->palette(); 126 QPalette pal=label->palette();
125 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 127 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
126 label->setPalette(pal); 128 label->setPalette(pal);
127 } 129 }
128 130
129 131
130 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 132 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
131 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 133 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
132} 134}
133 135
134void DateBookWeekLstDayHdr::showDay() { 136void DateBookWeekLstDayHdr::showDay() {
135 emit showDate(date.year(), date.month(), date.day()); 137 emit showDate(date.year(), date.month(), date.day());
136} 138}
137void DateBookWeekLstDayHdr::newEvent() { 139void DateBookWeekLstDayHdr::newEvent() {
138 QDateTime start, stop; 140 QDateTime start, stop;
139 start=stop=date; 141 start=stop=date;
140 start.setTime(QTime(10,0)); 142 start.setTime(QTime(10,0));
141 stop.setTime(QTime(12,0)); 143 stop.setTime(QTime(12,0));
142 144
143 emit addEvent(start,stop,"",0); 145 emit addEvent(start,stop,"",0);
144} 146}
145DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 147DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
146 QWidget* parent, 148 int weeklistviewconfig,
147 const char* name, 149 QWidget* parent,
148 WFlags fl) : 150 const char* name,
149 OClickableLabel(parent,name,fl), 151 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
150 event(ev)
151{ 152{
152 char s[10]; 153 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
153 if ( ev.startDate() != ev.date() ) { // multiday event (not first day) 154 QString s,start,middle,end,day;
154 if ( ev.endDate() == ev.date() ) { // last day 155
155 strcpy(s, "__|__"); 156 qDebug("weeklistviewconfig=%d",weeklistviewconfig);
156 } else { 157 if(weeklistviewconfig==NONE) {// No times displayed.
157 strcpy(s, " |---"); 158 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
159 // middle.sprintf("<--->");
160 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
161 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
162 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time.
163 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
164 middle.sprintf(" |---");
165 end.sprintf("__|__");
166 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
167 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
168 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
169 middle.sprintf("<--->");
170 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
171 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
172 }
173
174 if(ev.event().type() == Event::Normal) {
175 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event.
176 s=day;
177 } else if(ev.startDate()==ev.date()) {// start event.
178 s=start;
179 } else if(ev.endDate()==ev.date()) { // end event.
180 s=end;
181 } else {// middle day.
182 s=middle;
158 } 183 }
159 } else { 184 } else {
160 if(ev.event().type() == Event::Normal ) 185 s="";
161 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute());
162 else
163 sprintf(s," ");
164 } 186 }
165 setText(QString(s) + " " + ev.description()); 187 setText(QString(s) + " " + ev.description());
166 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 188 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
167 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 189 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
168} 190}
169void DateBookWeekLstEvent::editMe() { 191void DateBookWeekLstEvent::editMe() {
170 emit editEvent(event.event()); 192 emit editEvent(event.event());
171} 193}
172 194
173 195
174DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 196DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
175 const QDate &d, bool onM, 197 const QDate &d, bool onM,
176 QWidget* parent, 198 QWidget* parent,
177 const char* name, WFlags fl) 199 const char* name, WFlags fl)
178 : QWidget( parent, name, fl ) 200 : QWidget( parent, name, fl )
179{ 201{
180 onMonday=onM; 202 Config config("DateBook");
181 setPalette(white); 203 config.setGroup("Main");
182 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 204 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
205 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig);
183 206
184 QVBoxLayout *layout = new QVBoxLayout( this ); 207 onMonday=onM;
208 setPalette(white);
209 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
185 210
186 qBubbleSort(ev); 211 QVBoxLayout *layout = new QVBoxLayout( this );
187 QValueListIterator<EffectiveEvent> it;
188 it=ev.begin();
189 212
190 int dayOrder[7]; 213 qBubbleSort(ev);
191 if (onMonday) 214 QValueListIterator<EffectiveEvent> it;
192 for (int d=0; d<7; d++) dayOrder[d]=d+1; 215 it=ev.begin();
193 else { 216
194 for (int d=0; d<7; d++) dayOrder[d]=d; 217 int dayOrder[7];
195 dayOrder[0]=7; 218 if (onMonday) {
196 } 219 for (int d=0; d<7; d++) dayOrder[d]=d+1;
220 } else {
221 for (int d=0; d<7; d++) dayOrder[d]=d;
222 dayOrder[0]=7;
223 }
197 224
198 for (int i=0; i<7; i++) { 225 for (int i=0; i<7; i++) {
199 // Header 226 // Header
200 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), 227 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,this);
201 onMonday,this);
202 connect(hdr, SIGNAL(showDate(int,int,int)), 228 connect(hdr, SIGNAL(showDate(int,int,int)),
203 this, SIGNAL(showDate(int,int,int))); 229 this, SIGNAL(showDate(int,int,int)));
204 connect(hdr, SIGNAL(addEvent(const QDateTime &, 230 connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
205 const QDateTime &, 231 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
206 const QString &, const QString &)),
207 this, SIGNAL(addEvent(const QDateTime &,
208 const QDateTime &,
209 const QString &, const QString &)));
210 layout->addWidget(hdr); 232 layout->addWidget(hdr);
211 233
212 // Events 234 // Events
213 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 235 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
214 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. 236 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day.
215 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); 237 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
216 layout->addWidget(l); 238 layout->addWidget(l);
217 connect (l, SIGNAL(editEvent(const Event &)), 239 connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
218 this, SIGNAL(editEvent(const Event &)));
219 } 240 }
220 it++; 241 it++;
221 } 242 }
222 243
223 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 244 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
224 } 245 }
225} 246}
226DateBookWeekLstView::~DateBookWeekLstView(){} 247DateBookWeekLstView::~DateBookWeekLstView(){}
227void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 248void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
228 249
229DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 250DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
230 QValueList<EffectiveEvent> &ev2, 251 QValueList<EffectiveEvent> &ev2,
231 QDate &d, bool onM, 252 QDate &d, bool onM,
232 QWidget* parent, 253 QWidget* parent,
233 const char* name, WFlags fl) 254 const char* name, WFlags fl)
234 : QWidget( parent, name, fl ) 255 : QWidget( parent, name, fl )
235{ 256{
236 QHBoxLayout *layout = new QHBoxLayout( this ); 257 QHBoxLayout *layout = new QHBoxLayout( this );
237 258
238 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 259 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
239 layout->addWidget(w); 260 layout->addWidget(w);
240 connect (w, SIGNAL(editEvent(const Event &)), 261 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
241 this, SIGNAL(editEvent(const Event &))); 262 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
242 connect (w, SIGNAL(showDate(int,int,int)), 263 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)),
243 this, SIGNAL(showDate(int,int,int))); 264 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
244 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 265
245 const QString &,const QString &)), 266
246 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 267 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
247 const QString &, const QString &))); 268 layout->addWidget(w);
248 269 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
249 270 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
250 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 271 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
251 layout->addWidget(w); 272 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
252 connect (w, SIGNAL(editEvent(const Event &)),
253 this, SIGNAL(editEvent(const Event &)));
254 connect (w, SIGNAL(showDate(int,int,int)),
255 this, SIGNAL(showDate(int,int,int)));
256 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
257 const QString &, const QString &)),
258 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
259 const QString &, const QString &)));
260} 273}
261 274
262DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 275DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
263 QWidget *parent, 276 QWidget *parent,
264 const char *name ) 277 const char *name )
265 : QWidget( parent, name ), 278 : QWidget( parent, name ),
266 db( newDB ), 279 db( newDB ),
267 startTime( 0 ), 280 startTime( 0 ),
268 ampm( ap ), 281 ampm( ap ),
269 onMonday(onM) 282 onMonday(onM)
270{ 283{
271 setFocusPolicy(StrongFocus); 284 setFocusPolicy(StrongFocus);
272 layout = new QVBoxLayout( this ); 285 layout = new QVBoxLayout( this );
273 layout->setMargin(0); 286 layout->setMargin(0);
274 287
275 header=new DateBookWeekLstHeader(onM, this); 288 header=new DateBookWeekLstHeader(onM, this);
276 layout->addWidget( header ); 289 layout->addWidget( header );
277 connect(header, SIGNAL(dateChanged(int,int)), 290 connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int)));
278 this, SLOT(dateChanged(int,int))); 291 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
279 connect(header, SIGNAL(setDbl(bool)), 292
280 this, SLOT(setDbl(bool))); 293 scroll=new QScrollView(this);
281 294 //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
282 scroll=new QScrollView(this); 295 //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
283 //scroll->setVScrollBarMode(QScrollView::AlwaysOn); 296 scroll->setResizePolicy(QScrollView::AutoOneFit);
284 //scroll->setHScrollBarMode(QScrollView::AlwaysOff); 297 layout->addWidget(scroll);
285 scroll->setResizePolicy(QScrollView::AutoOneFit); 298
286 layout->addWidget(scroll); 299 view=NULL;
287 300 Config config("DateBook");
288 view=NULL; 301 config.setGroup("Main");
289 Config config("DateBook"); 302 dbl=config.readBoolEntry("weeklst_dbl", false);
290 config.setGroup("Main"); 303 header->dbl->setOn(dbl);
291 dbl=config.readBoolEntry("weeklst_dbl", false);
292 header->dbl->setOn(dbl);
293} 304}
294DateBookWeekLst::~DateBookWeekLst(){ 305DateBookWeekLst::~DateBookWeekLst(){
295 Config config("DateBook"); 306 Config config("DateBook");
296 config.setGroup("Main"); 307 config.setGroup("Main");
297 config.writeEntry("weeklst_dbl", dbl); 308 config.writeEntry("weeklst_dbl", dbl);
298} 309}
299 310
300void DateBookWeekLst::setDate(const QDate &d) { 311void DateBookWeekLst::setDate(const QDate &d) {
301 int w,y; 312 int w,y;
302 calcWeek(d,w,y,onMonday); 313 calcWeek(d,w,y,onMonday);
303 year=y; 314 year=y;
304 _week=w; 315 _week=w;
305 header->setDate(date()); 316 header->setDate(date());
306} 317}
307void DateBookWeekLst::setDbl(bool on) { 318void DateBookWeekLst::setDbl(bool on) {
308 dbl=on; 319 dbl=on;
309 redraw(); 320 redraw();
310} 321}
311void DateBookWeekLst::redraw() {getEvents();} 322void DateBookWeekLst::redraw() {getEvents();}
312 323
313QDate DateBookWeekLst::date() const { 324QDate DateBookWeekLst::date() const {
314 QDate d; 325 QDate d;
315 d.setYMD(year,1,1); 326 d.setYMD(year,1,1);
316 327
317 int dow= d.dayOfWeek(); 328 int dow= d.dayOfWeek();
318 if (!onMonday) 329 if (!onMonday)
319 if (dow==7) dow=1; 330 if (dow==7) {
320 else dow++; 331 dow=1;
332 } else {
333 dow++;
334 }
321 335
322 d=d.addDays( (_week-1)*7 - dow + 1 ); 336 d=d.addDays( (_week-1)*7 - dow + 1 );
323 return d; 337 return d;
324} 338}
325 339
326void DateBookWeekLst::getEvents() { 340void DateBookWeekLst::getEvents() {
327 QDate start = date(); 341 QDate start = date();
328 QDate stop = start.addDays(6); 342 QDate stop = start.addDays(6);
329 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 343 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
330 344
331 if (view) delete view; 345 if (view) delete view;
332 if (dbl) { 346 if (dbl) {
333 QDate start2=start.addDays(7); 347 QDate start2=start.addDays(7);
334 stop=start2.addDays(6); 348 stop=start2.addDays(6);
335 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 349 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
336 350 view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll);
337 view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); 351 } else {
338 } else { 352 view=new DateBookWeekLstView(el,start,onMonday,scroll);
339 view=new DateBookWeekLstView(el,start,onMonday,scroll); 353 }
340 } 354
355 connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
356 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
357 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
358 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
341 359
342 connect (view, SIGNAL(editEvent(const Event &)), 360 scroll->addChild(view);
343 this, SIGNAL(editEvent(const Event &))); 361 view->show();
344 connect (view, SIGNAL(showDate(int,int,int)), 362 scroll->updateScrollBars();
345 this, SIGNAL(showDate(int,int,int)));
346 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
347 const QString &, const QString &)),
348 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
349 const QString &, const QString &)));
350
351 scroll->addChild(view);
352 view->show();
353 scroll->updateScrollBars();
354} 363}
355 364
356void DateBookWeekLst::dateChanged(int y, int w) { 365void DateBookWeekLst::dateChanged(int y, int w) {
357 year=y; 366 year=y;
358 _week=w; 367 _week=w;
359 getEvents(); 368 getEvents();
360} 369}
361 370
362void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 371void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
363{ 372{
364 switch(e->key()) { 373 switch(e->key()) {
365 case Key_Up: 374 case Key_Up:
366 scroll->scrollBy(0, -20); 375 scroll->scrollBy(0, -20);
367 break; 376 break;
368 case Key_Down: 377 case Key_Down:
369 scroll->scrollBy(0, 20); 378 scroll->scrollBy(0, 20);
370 break; 379 break;
371 case Key_Left: 380 case Key_Left:
372 header->prevWeek(); 381 header->prevWeek();
373 break; 382 break;
374 case Key_Right: 383 case Key_Right:
375 header->nextWeek(); 384 header->nextWeek();
376 break; 385 break;
377 default: 386 default:
378 e->ignore(); 387 e->ignore();
379 } 388 }
380} 389}
381 390
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
index ea88f20..17dc01f 100644
--- a/core/pim/datebook/datebookweeklst.h
+++ b/core/pim/datebook/datebookweeklst.h
@@ -1,151 +1,151 @@
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 <opie/oclickablelabel.h> 13#include <opie/oclickablelabel.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(const 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);
34 void setDbl(bool on); 34 void setDbl(bool on);
35private: 35private:
36 QDate date; 36 QDate date;
37 bool onMonday; 37 bool onMonday;
38}; 38};
39 39
40class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase 40class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
41{ 41{
42 Q_OBJECT 42 Q_OBJECT
43public: 43public:
44 DateBookWeekLstDayHdr(const QDate &d, bool onM, 44 DateBookWeekLstDayHdr(const QDate &d, bool onM,
45 QWidget* parent = 0, const char* name = 0, 45 QWidget* parent = 0, const char* name = 0,
46 WFlags fl = 0 ); 46 WFlags fl = 0 );
47public slots: 47public slots:
48 void showDay(); 48 void showDay();
49 void newEvent(); 49 void newEvent();
50signals: 50signals:
51 void showDate(int y, int m, int d); 51 void showDate(int y, int m, int d);
52 void addEvent(const QDateTime &start, const QDateTime &stop, 52 void addEvent(const QDateTime &start, const QDateTime &stop,
53 const QString &str, const QString &location); 53 const QString &str, const QString &location);
54private: 54private:
55 QDate date; 55 QDate date;
56}; 56};
57 57
58class DateBookWeekLstEvent: public OClickableLabel 58class DateBookWeekLstEvent: public OClickableLabel
59{ 59{
60 Q_OBJECT 60 Q_OBJECT
61public: 61public:
62 DateBookWeekLstEvent(const EffectiveEvent &ev, 62 DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1,
63 QWidget* parent = 0, const char* name = 0, 63 QWidget* parent = 0, const char* name = 0,
64 WFlags fl = 0); 64 WFlags fl = 0);
65signals: 65signals:
66 void editEvent(const Event &e); 66 void editEvent(const Event &e);
67private slots: 67private slots:
68 void editMe(); 68 void editMe();
69private: 69private:
70 const EffectiveEvent event; 70 const EffectiveEvent event;
71}; 71};
72 72
73class DateBookWeekLstView: public QWidget 73class DateBookWeekLstView: public QWidget
74{ 74{
75 Q_OBJECT 75 Q_OBJECT
76public: 76public:
77 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, 77 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM,
78 QWidget* parent = 0, const char* name = 0, 78 QWidget* parent = 0, const char* name = 0,
79 WFlags fl = 0 ); 79 WFlags fl = 0 );
80 ~DateBookWeekLstView(); 80 ~DateBookWeekLstView();
81signals: 81signals:
82 void editEvent(const Event &e); 82 void editEvent(const Event &e);
83 void showDate(int y, int m, int d); 83 void showDate(int y, int m, int d);
84 void addEvent(const QDateTime &start, const QDateTime &stop, 84 void addEvent(const QDateTime &start, const QDateTime &stop,
85 const QString &str, const QString &location); 85 const QString &str, const QString &location);
86private: 86private:
87 bool onMonday; 87 bool onMonday;
88protected slots: 88protected slots:
89 void keyPressEvent(QKeyEvent *); 89 void keyPressEvent(QKeyEvent *);
90}; 90};
91 91
92class DateBookWeekLstDblView: public QWidget { 92class DateBookWeekLstDblView: public QWidget {
93 Q_OBJECT 93 Q_OBJECT
94public: 94public:
95 DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 95 DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
96 QValueList<EffectiveEvent> &ev2, 96 QValueList<EffectiveEvent> &ev2,
97 QDate &d, bool onM, 97 QDate &d, bool onM,
98 QWidget* parent = 0, const char* name = 0, 98 QWidget* parent = 0, const char* name = 0,
99 WFlags fl = 0 ); 99 WFlags fl = 0 );
100signals: 100signals:
101 void editEvent(const Event &e); 101 void editEvent(const Event &e);
102 void showDate(int y, int m, int d); 102 void showDate(int y, int m, int d);
103 void addEvent(const QDateTime &start, const QDateTime &stop, 103 void addEvent(const QDateTime &start, const QDateTime &stop,
104 const QString &str, const QString &location); 104 const QString &str, const QString &location);
105}; 105};
106 106
107class DateBookWeekLst : public QWidget 107class DateBookWeekLst : public QWidget
108{ 108{
109 Q_OBJECT 109 Q_OBJECT
110 110
111public: 111public:
112 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, 112 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB,
113 QWidget *parent = 0, 113 QWidget *parent = 0,
114 const char *name = 0 ); 114 const char *name = 0 );
115 ~DateBookWeekLst(); 115 ~DateBookWeekLst();
116 void setDate( int y, int w ); 116 void setDate( int y, int w );
117 void setDate(const QDate &d ); 117 void setDate(const QDate &d );
118 int week() const { return _week; }; 118 int week() const { return _week; };
119 QDate date() const; 119 QDate date() const;
120 120
121public slots: 121public slots:
122 void redraw(); 122 void redraw();
123 void dateChanged(int y, int w); 123 void dateChanged(int y, int w);
124 124
125protected slots: 125protected slots:
126 void keyPressEvent(QKeyEvent *); 126 void keyPressEvent(QKeyEvent *);
127 void setDbl(bool on); 127 void setDbl(bool on);
128 128
129signals: 129signals:
130 void showDate(int y, int m, int d); 130 void showDate(int y, int m, int d);
131 void addEvent(const QDateTime &start, const QDateTime &stop, 131 void addEvent(const QDateTime &start, const QDateTime &stop,
132 const QString &str, const QString &location); 132 const QString &str, const QString &location);
133 void editEvent(const Event &e); 133 void editEvent(const Event &e);
134 134
135private: 135private:
136 DateBookDB *db; 136 DateBookDB *db;
137 int startTime; 137 int startTime;
138 bool ampm; 138 bool ampm;
139 bool onMonday; 139 bool onMonday;
140 bool dbl; 140 bool dbl;
141 int year, _week; 141 int year, _week;
142 DateBookWeekLstHeader *header; 142 DateBookWeekLstHeader *header;
143 QWidget *view; 143 QWidget *view;
144 QVBoxLayout *layout; 144 QVBoxLayout *layout;
145 QScrollView *scroll; 145 QScrollView *scroll;
146 146
147 void getEvents(); 147 void getEvents();
148}; 148};
149 149
150#endif 150#endif
151 151