summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp14
-rw-r--r--core/pim/datebook/datebook.h2
-rw-r--r--core/pim/datebook/datebook.pro3
-rw-r--r--core/pim/datebook/datebookday.cpp65
-rw-r--r--core/pim/datebook/datebookday.h6
-rw-r--r--core/pim/datebook/datebooksettings.cpp20
-rw-r--r--core/pim/datebook/datebooksettings.h7
-rw-r--r--core/pim/datebook/datebooksettingsbase.ui371
-rw-r--r--core/pim/datebook/datebookweeklst.cpp64
9 files changed, 406 insertions, 146 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index c0d45c9..7dd93a6 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,752 +1,766 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19** $Id$ 19** $Id$
20** 20**
21**********************************************************************/ 21**********************************************************************/
22 22
23#define QTOPIA_INTERNAL_FD 23#define QTOPIA_INTERNAL_FD
24 24
25#include "datebook.h" 25#include "datebook.h"
26#include "datebookday.h" 26#include "datebookday.h"
27#include "datebooksettings.h" 27#include "datebooksettings.h"
28#include "datebookweek.h" 28#include "datebookweek.h"
29#include "datebookweeklst.h" 29#include "datebookweeklst.h"
30#include "dateentryimpl.h" 30#include "dateentryimpl.h"
31 31
32#include <qpe/datebookmonth.h> 32#include <qpe/datebookmonth.h>
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qpe/qpedebug.h> 35#include <qpe/qpedebug.h>
36#include <qpe/event.h> 36#include <qpe/event.h>
37#include <qpe/finddialog.h> 37#include <qpe/finddialog.h>
38#include <qpe/ir.h> 38#include <qpe/ir.h>
39#include <qpe/qpemenubar.h> 39#include <qpe/qpemenubar.h>
40#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42#include <qpe/sound.h> 42#include <qpe/sound.h>
43#include <qpe/timestring.h> 43#include <qpe/timestring.h>
44#include <qpe/qpetoolbar.h> 44#include <qpe/qpetoolbar.h>
45#include <qpe/tzselect.h> 45#include <qpe/tzselect.h>
46#include <qpe/xmlreader.h> 46#include <qpe/xmlreader.h>
47 47
48#include <qaction.h> 48#include <qaction.h>
49#include <qcopchannel_qws.h> 49#include <qcopchannel_qws.h>
50#include <qdatetime.h> 50#include <qdatetime.h>
51#include <qdialog.h> 51#include <qdialog.h>
52#include <qfile.h> 52#include <qfile.h>
53#include <qlabel.h> 53#include <qlabel.h>
54#include <qlayout.h> 54#include <qlayout.h>
55#include <qmessagebox.h> 55#include <qmessagebox.h>
56#include <qpopupmenu.h> 56#include <qpopupmenu.h>
57#include <qpushbutton.h> 57#include <qpushbutton.h>
58#include <qregexp.h> 58#include <qregexp.h>
59#include <qtextcodec.h> 59#include <qtextcodec.h>
60#include <qtextstream.h> 60#include <qtextstream.h>
61#include <qtl.h> 61#include <qtl.h>
62#include <qwidgetstack.h> 62#include <qwidgetstack.h>
63#include <qwindowsystem_qws.h> 63#include <qwindowsystem_qws.h>
64 64
65#include <sys/stat.h> 65#include <sys/stat.h>
66#include <sys/types.h> 66#include <sys/types.h>
67#include <fcntl.h> 67#include <fcntl.h>
68#include <unistd.h> 68#include <unistd.h>
69 69
70#include <stdlib.h> 70#include <stdlib.h>
71 71
72#define DAY 1 72#define DAY 1
73#define WEEK 2 73#define WEEK 2
74#define WEEKLST 4 74#define WEEKLST 4
75#define MONTH 3 75#define MONTH 3
76 76
77 77
78DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 78DateBook::DateBook( QWidget *parent, const char *, WFlags f )
79 : QMainWindow( parent, "datebook", f ), 79 : QMainWindow( parent, "datebook", f ),
80 aPreset( FALSE ), 80 aPreset( FALSE ),
81 presetTime( -1 ), 81 presetTime( -1 ),
82 startTime( 8 ), // an acceptable default 82 startTime( 8 ), // an acceptable default
83 rowStyle( 0 ),
84 bJumpToCurTime(FALSE),
83 syncing(FALSE), 85 syncing(FALSE),
84 inSearch(FALSE), 86 inSearch(FALSE),
85 alarmCounter(0) 87 alarmCounter(0)
86{ 88{
87 QTime t; 89 QTime t;
88 t.start(); 90 t.start();
89 db = new DateBookDBHack; 91 db = new DateBookDBHack;
90 qDebug("loading db t=%d", t.elapsed() ); 92 qDebug("loading db t=%d", t.elapsed() );
91 loadSettings(); 93 loadSettings();
92 setCaption( tr("Calendar") ); 94 setCaption( tr("Calendar") );
93 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 95 setIcon( Resource::loadPixmap( "datebook_icon" ) );
94 96
95 setToolBarsMovable( FALSE ); 97 setToolBarsMovable( FALSE );
96 98
97 views = new QWidgetStack( this ); 99 views = new QWidgetStack( this );
98 setCentralWidget( views ); 100 setCentralWidget( views );
99 101
100 dayView = 0; 102 dayView = 0;
101 weekView = 0; 103 weekView = 0;
102 weekLstView = 0; 104 weekLstView = 0;
103 monthView = 0; 105 monthView = 0;
104 106
105 QPEToolBar *bar = new QPEToolBar( this ); 107 QPEToolBar *bar = new QPEToolBar( this );
106 bar->setHorizontalStretchable( TRUE ); 108 bar->setHorizontalStretchable( TRUE );
107 109
108 QPEMenuBar *mb = new QPEMenuBar( bar ); 110 QPEMenuBar *mb = new QPEMenuBar( bar );
109 mb->setMargin( 0 ); 111 mb->setMargin( 0 );
110 112
111 QPEToolBar *sub_bar = new QPEToolBar(this); 113 QPEToolBar *sub_bar = new QPEToolBar(this);
112 114
113 QPopupMenu *view = new QPopupMenu( this ); 115 QPopupMenu *view = new QPopupMenu( this );
114 QPopupMenu *settings = new QPopupMenu( this ); 116 QPopupMenu *settings = new QPopupMenu( this );
115 117
116 mb->insertItem( tr( "View" ), view ); 118 mb->insertItem( tr( "View" ), view );
117 mb->insertItem( tr( "Settings" ), settings ); 119 mb->insertItem( tr( "Settings" ), settings );
118 120
119 QActionGroup *g = new QActionGroup( this ); 121 QActionGroup *g = new QActionGroup( this );
120 g->setExclusive( TRUE ); 122 g->setExclusive( TRUE );
121 123
122 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 124 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
123 QString::null, 0, this, 0 ); 125 QString::null, 0, this, 0 );
124 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 126 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
125 a->addTo( sub_bar ); 127 a->addTo( sub_bar );
126 128
127 a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 ); 129 a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 );
128 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 130 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
129 a->addTo( sub_bar ); 131 a->addTo( sub_bar );
130 a->addTo( view ); 132 a->addTo( view );
131 133
132 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 134 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
133 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 135 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
134 a->addTo( sub_bar ); 136 a->addTo( sub_bar );
135 a->addTo( view ); 137 a->addTo( view );
136 a->setToggleAction( TRUE ); 138 a->setToggleAction( TRUE );
137 a->setOn( TRUE ); 139 a->setOn( TRUE );
138 dayAction = a; 140 dayAction = a;
139 141
140 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 142 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
141 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 143 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
142 a->addTo( sub_bar ); 144 a->addTo( sub_bar );
143 a->addTo( view ); 145 a->addTo( view );
144 a->setToggleAction( TRUE ); 146 a->setToggleAction( TRUE );
145 weekAction = a; 147 weekAction = a;
146 148
147 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 ); 149 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 );
148 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 150 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
149 a->addTo( sub_bar ); 151 a->addTo( sub_bar );
150 a->addTo( view ); 152 a->addTo( view );
151 a->setToggleAction( TRUE ); 153 a->setToggleAction( TRUE );
152 weekLstAction = a; 154 weekLstAction = a;
153 155
154 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 156 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
155 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 157 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
156 a->addTo( sub_bar ); 158 a->addTo( sub_bar );
157 a->addTo( view ); 159 a->addTo( view );
158 a->setToggleAction( TRUE ); 160 a->setToggleAction( TRUE );
159 monthAction = a; 161 monthAction = a;
160 162
161 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); 163 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 );
162 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 164 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
163 a->addTo( sub_bar ); 165 a->addTo( sub_bar );
164 166
165 a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); 167 a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 );
166 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 168 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
167 a->addTo( settings ); 169 a->addTo( settings );
168 170
169 QPopupMenu *default_view = new QPopupMenu(this); 171 QPopupMenu *default_view = new QPopupMenu(this);
170 settings->insertItem( tr( "Default View" ),default_view ); 172 settings->insertItem( tr( "Default View" ),default_view );
171 default_view->setCheckable(TRUE); 173 default_view->setCheckable(TRUE);
172 174
173 Config config("DateBook"); 175 Config config("DateBook");
174 config.setGroup("Main"); 176 config.setGroup("Main");
175 int current=config.readNumEntry("defaultview", DAY); 177 int current=config.readNumEntry("defaultview", DAY);
176 178
177 QActionGroup *ag = new QActionGroup(this); 179 QActionGroup *ag = new QActionGroup(this);
178 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); 180 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true );
179 if (current==DAY) a->setOn(true), viewDay(); 181 if (current==DAY) a->setOn(true), viewDay();
180 ag->insert(a); 182 ag->insert(a);
181 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); 183 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true );
182 if (current==WEEK) a->setOn(true), viewWeek(); 184 if (current==WEEK) a->setOn(true), viewWeek();
183 ag->insert(a); 185 ag->insert(a);
184 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); 186 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true );
185 if (current==WEEKLST) a->setOn(true), viewWeekLst(); 187 if (current==WEEKLST) a->setOn(true), viewWeekLst();
186 ag->insert(a); 188 ag->insert(a);
187 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); 189 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true );
188 if (current==MONTH) a->setOn(true), viewMonth(); 190 if (current==MONTH) a->setOn(true), viewMonth();
189 ag->insert(a); 191 ag->insert(a);
190 192
191 ag->addTo(default_view); 193 ag->addTo(default_view);
192 connect(ag, SIGNAL( selected ( QAction * ) ), 194 connect(ag, SIGNAL( selected ( QAction * ) ),
193 this, SLOT( newDefaultView(QAction *) ) 195 this, SLOT( newDefaultView(QAction *) )
194 ); 196 );
195 197
196 connect( qApp, SIGNAL(clockChanged(bool)), 198 connect( qApp, SIGNAL(clockChanged(bool)),
197 this, SLOT(changeClock(bool)) ); 199 this, SLOT(changeClock(bool)) );
198 connect( qApp, SIGNAL(weekChanged(bool)), 200 connect( qApp, SIGNAL(weekChanged(bool)),
199 this, SLOT(changeWeek(bool)) ); 201 this, SLOT(changeWeek(bool)) );
200 202
201#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 203#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
202 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 204 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
203 this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 205 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
204#endif 206#endif
205 207
206 // listen on QPE/System 208 // listen on QPE/System
207#if defined(Q_WS_QWS) 209#if defined(Q_WS_QWS)
208#if !defined(QT_NO_COP) 210#if !defined(QT_NO_COP)
209 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 211 QCopChannel *channel = new QCopChannel( "QPE/System", this );
210 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 212 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
211 this, SLOT(receive(const QCString&, const QByteArray&)) ); 213 this, SLOT(receive(const QCString&, const QByteArray&)) );
212 channel = new QCopChannel( "QPE/Datebook", this ); 214 channel = new QCopChannel( "QPE/Datebook", this );
213 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 215 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
214 this, SLOT(receive(const QCString&, const QByteArray&)) ); 216 this, SLOT(receive(const QCString&, const QByteArray&)) );
215 qDebug("olle\n"); 217 qDebug("olle\n");
216#endif 218#endif
217#endif 219#endif
218 220
219 qDebug("done t=%d", t.elapsed() ); 221 qDebug("done t=%d", t.elapsed() );
220 222
221} 223}
222 224
223void DateBook::receive( const QCString &msg, const QByteArray &data ) 225void DateBook::receive( const QCString &msg, const QByteArray &data )
224{ 226{
225 QDataStream stream( data, IO_ReadOnly ); 227 QDataStream stream( data, IO_ReadOnly );
226 if ( msg == "timeChange(QString)" ) { 228 if ( msg == "timeChange(QString)" ) {
227 // update active view! 229 // update active view!
228 if ( dayAction->isOn() ) 230 if ( dayAction->isOn() )
229 viewDay(); 231 viewDay();
230 else if ( weekAction->isOn() ) 232 else if ( weekAction->isOn() )
231 viewWeek(); 233 viewWeek();
232 else if ( monthAction->isOn() ) 234 else if ( monthAction->isOn() )
233 viewMonth(); 235 viewMonth();
234 } 236 }
235 else if (msg == "editEvent(int)") { 237 else if (msg == "editEvent(int)") {
236 int uid; 238 int uid;
237 stream >> uid; 239 stream >> uid;
238 Event e=db->eventByUID(uid); 240 Event e=db->eventByUID(uid);
239 editEvent(e); 241 editEvent(e);
240 } 242 }
241} 243}
242 244
243DateBook::~DateBook() 245DateBook::~DateBook()
244{ 246{
245} 247}
246 248
247void DateBook::slotSettings() 249void DateBook::slotSettings()
248{ 250{
249 DateBookSettings frmSettings( ampm, this ); 251 DateBookSettings frmSettings( ampm, this );
250 frmSettings.setStartTime( startTime ); 252 frmSettings.setStartTime( startTime );
251 frmSettings.setAlarmPreset( aPreset, presetTime ); 253 frmSettings.setAlarmPreset( aPreset, presetTime );
254 frmSettings.setJumpToCurTime( bJumpToCurTime );
255 frmSettings.setRowStyle( rowStyle );
252#if defined (Q_WS_QWS) || defined(_WS_QWS_) 256#if defined (Q_WS_QWS) || defined(_WS_QWS_)
253 frmSettings.showMaximized(); 257 frmSettings.showMaximized();
254#endif 258#endif
255 259
256 if ( frmSettings.exec() ) { 260 if ( frmSettings.exec() ) {
257 aPreset = frmSettings.alarmPreset(); 261 aPreset = frmSettings.alarmPreset();
258 presetTime = frmSettings.presetTime(); 262 presetTime = frmSettings.presetTime();
259 startTime = frmSettings.startTime(); 263 startTime = frmSettings.startTime();
264 bJumpToCurTime = frmSettings.jumpToCurTime();
265 rowStyle = frmSettings.rowStyle();
260 if ( dayView ) 266 if ( dayView )
261 dayView->setStartViewTime( startTime ); 267 dayView->setStartViewTime( startTime );
268 dayView->setJumpToCurTime( bJumpToCurTime );
269 dayView->setRowStyle( rowStyle );
262 if ( weekView ) 270 if ( weekView )
263 weekView->setStartViewTime( startTime ); 271 weekView->setStartViewTime( startTime );
264 saveSettings(); 272 saveSettings();
265 273
266 // make the change obvious 274 // make the change obvious
267 if ( views->visibleWidget() ) { 275 if ( views->visibleWidget() ) {
268 if ( views->visibleWidget() == dayView ) 276 if ( views->visibleWidget() == dayView )
269 dayView->redraw(); 277 dayView->redraw();
270 else if ( views->visibleWidget() == weekView ) 278 else if ( views->visibleWidget() == weekView )
271 weekView->redraw(); 279 weekView->redraw();
272 } 280 }
273 } 281 }
274} 282}
275 283
276void DateBook::fileNew() 284void DateBook::fileNew()
277{ 285{
278 slotNewEventFromKey(""); 286 slotNewEventFromKey("");
279} 287}
280 288
281QString DateBook::checkEvent(const Event &e) 289QString DateBook::checkEvent(const Event &e)
282{ 290{
283 /* check if overlaps with itself */ 291 /* check if overlaps with itself */
284 bool checkFailed = FALSE; 292 bool checkFailed = FALSE;
285 293
286 /* check the next 12 repeats. should catch most problems */ 294 /* check the next 12 repeats. should catch most problems */
287 QDate current_date = e.start().date(); 295 QDate current_date = e.start().date();
288 Event previous = e; 296 Event previous = e;
289 for(int i = 0; i < 12; i++) 297 for(int i = 0; i < 12; i++)
290 { 298 {
291 QDateTime next; 299 QDateTime next;
292 if (!nextOccurance(previous, current_date.addDays(1), next)) { 300 if (!nextOccurance(previous, current_date.addDays(1), next)) {
293 break; // no more repeats 301 break; // no more repeats
294 } 302 }
295 if(next < previous.end()) { 303 if(next < previous.end()) {
296 checkFailed = TRUE; 304 checkFailed = TRUE;
297 break; 305 break;
298 } 306 }
299 current_date = next.date(); 307 current_date = next.date();
300 } 308 }
301 309
302 if(checkFailed) 310 if(checkFailed)
303 return tr("Event duration is potentially longer\n" 311 return tr("Event duration is potentially longer\n"
304 "than interval between repeats."); 312 "than interval between repeats.");
305 313
306 return QString::null; 314 return QString::null;
307} 315}
308 316
309QDate DateBook::currentDate() 317QDate DateBook::currentDate()
310{ 318{
311 QDate d = QDate::currentDate(); 319 QDate d = QDate::currentDate();
312 320
313 if ( dayView && views->visibleWidget() == dayView ) { 321 if ( dayView && views->visibleWidget() == dayView ) {
314 d = dayView->date(); 322 d = dayView->date();
315 } else if ( weekView && views->visibleWidget() == weekView ) { 323 } else if ( weekView && views->visibleWidget() == weekView ) {
316 d = weekView->date(); 324 d = weekView->date();
317 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 325 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
318 d = weekLstView->date(); 326 d = weekLstView->date();
319 } else if ( monthView && views->visibleWidget() == monthView ) { 327 } else if ( monthView && views->visibleWidget() == monthView ) {
320 d = monthView->selectedDate(); 328 d = monthView->selectedDate();
321 } 329 }
322 330
323 return d; 331 return d;
324} 332}
325 333
326void DateBook::view(int v, const QDate &d) { 334void DateBook::view(int v, const QDate &d) {
327 if (v==DAY) { 335 if (v==DAY) {
328 initDay(); 336 initDay();
329 dayAction->setOn( TRUE ); 337 dayAction->setOn( TRUE );
330 dayView->setDate( d ); 338 dayView->setDate( d );
331 views->raiseWidget( dayView ); 339 views->raiseWidget( dayView );
332 dayView->redraw(); 340 dayView->redraw();
333 } else if (v==WEEK) { 341 } else if (v==WEEK) {
334 initWeek(); 342 initWeek();
335 weekAction->setOn( TRUE ); 343 weekAction->setOn( TRUE );
336 weekView->setDate( d ); 344 weekView->setDate( d );
337 views->raiseWidget( weekView ); 345 views->raiseWidget( weekView );
338 weekView->redraw(); 346 weekView->redraw();
339 } else if (v==WEEKLST) { 347 } else if (v==WEEKLST) {
340 initWeekLst(); 348 initWeekLst();
341 weekLstAction->setOn( TRUE ); 349 weekLstAction->setOn( TRUE );
342 weekLstView->setDate(d); 350 weekLstView->setDate(d);
343 views->raiseWidget( weekLstView ); 351 views->raiseWidget( weekLstView );
344 weekLstView->redraw(); 352 weekLstView->redraw();
345 } else if (v==MONTH) { 353 } else if (v==MONTH) {
346 initMonth(); 354 initMonth();
347 monthAction->setOn( TRUE ); 355 monthAction->setOn( TRUE );
348 monthView->setDate( d.year(), d.month(), d.day() ); 356 monthView->setDate( d.year(), d.month(), d.day() );
349 views->raiseWidget( monthView ); 357 views->raiseWidget( monthView );
350 monthView->redraw(); 358 monthView->redraw();
351 } 359 }
352} 360}
353 361
354void DateBook::viewDefault(const QDate &d) { 362void DateBook::viewDefault(const QDate &d) {
355 Config config("DateBook"); 363 Config config("DateBook");
356 config.setGroup("Main"); 364 config.setGroup("Main");
357 int current=config.readNumEntry("defaultview", DAY); 365 int current=config.readNumEntry("defaultview", DAY);
358 366
359 view(current,d); 367 view(current,d);
360} 368}
361 369
362void DateBook::viewDay() { 370void DateBook::viewDay() {
363 view(DAY,currentDate()); 371 view(DAY,currentDate());
364} 372}
365 373
366void DateBook::viewWeek() { 374void DateBook::viewWeek() {
367 view(WEEK,currentDate()); 375 view(WEEK,currentDate());
368} 376}
369 377
370void DateBook::viewWeekLst() { 378void DateBook::viewWeekLst() {
371 view(WEEKLST,currentDate()); 379 view(WEEKLST,currentDate());
372} 380}
373 381
374void DateBook::viewMonth() { 382void DateBook::viewMonth() {
375 view(MONTH,currentDate()); 383 view(MONTH,currentDate());
376} 384}
377 385
378void DateBook::editEvent( const Event &e ) 386void DateBook::editEvent( const Event &e )
379{ 387{
380 if (syncing) { 388 if (syncing) {
381 QMessageBox::warning( this, tr("Calendar"), 389 QMessageBox::warning( this, tr("Calendar"),
382 tr( "Can not edit data, currently syncing") ); 390 tr( "Can not edit data, currently syncing") );
383 return; 391 return;
384 } 392 }
385 393
386 // workaround added for text input. 394 // workaround added for text input.
387 QDialog editDlg( this, 0, TRUE ); 395 QDialog editDlg( this, 0, TRUE );
388 DateEntry *entry; 396 DateEntry *entry;
389 editDlg.setCaption( tr("Edit Event") ); 397 editDlg.setCaption( tr("Edit Event") );
390 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 398 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
391 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 399 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
392 sv->setResizePolicy( QScrollView::AutoOneFit ); 400 sv->setResizePolicy( QScrollView::AutoOneFit );
393 // KLUDGE!!! 401 // KLUDGE!!!
394 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 402 sv->setHScrollBarMode( QScrollView::AlwaysOff );
395 vb->addWidget( sv ); 403 vb->addWidget( sv );
396 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 404 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
397 entry->timezone->setEnabled( FALSE ); 405 entry->timezone->setEnabled( FALSE );
398 sv->addChild( entry ); 406 sv->addChild( entry );
399 407
400#if defined(Q_WS_QWS) || defined(_WS_QWS_) 408#if defined(Q_WS_QWS) || defined(_WS_QWS_)
401 editDlg.showMaximized(); 409 editDlg.showMaximized();
402#endif 410#endif
403 while (editDlg.exec() ) { 411 while (editDlg.exec() ) {
404 Event newEv = entry->event(); 412 Event newEv = entry->event();
405 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 413 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
406 QString error = checkEvent(newEv); 414 QString error = checkEvent(newEv);
407 if (!error.isNull()) { 415 if (!error.isNull()) {
408 if (QMessageBox::warning(this, "error box", 416 if (QMessageBox::warning(this, "error box",
409 error, "Fix it", "Continue", 417 error, "Fix it", "Continue",
410 0, 0, 1) == 0) 418 0, 0, 1) == 0)
411 continue; 419 continue;
412 } 420 }
413 db->editEvent(e, newEv); 421 db->editEvent(e, newEv);
414 emit newEvent(); 422 emit newEvent();
415 break; 423 break;
416 } 424 }
417} 425}
418 426
419void DateBook::removeEvent( const Event &e ) 427void DateBook::removeEvent( const Event &e )
420{ 428{
421 if (syncing) { 429 if (syncing) {
422 QMessageBox::warning( this, tr("Calendar"), 430 QMessageBox::warning( this, tr("Calendar"),
423 tr( "Can not edit data, currently syncing") ); 431 tr( "Can not edit data, currently syncing") );
424 return; 432 return;
425 } 433 }
426 434
427 QString strName = e.description(); 435 QString strName = e.description();
428 436
429 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 437 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
430 return; 438 return;
431 439
432 db->removeEvent( e ); 440 db->removeEvent( e );
433 if ( views->visibleWidget() == dayView && dayView ) 441 if ( views->visibleWidget() == dayView && dayView )
434 dayView->redraw(); 442 dayView->redraw();
435} 443}
436 444
437void DateBook::addEvent( const Event &e ) 445void DateBook::addEvent( const Event &e )
438{ 446{
439 QDate d = e.start().date(); 447 QDate d = e.start().date();
440 initDay(); 448 initDay();
441 dayView->setDate( d ); 449 dayView->setDate( d );
442} 450}
443 451
444void DateBook::showDay( int year, int month, int day ) 452void DateBook::showDay( int year, int month, int day )
445{ 453{
446 QDate d(year, month, day); 454 QDate d(year, month, day);
447 view(DAY,d); 455 view(DAY,d);
448} 456}
449 457
450void DateBook::initDay() 458void DateBook::initDay()
451{ 459{
452 if ( !dayView ) { 460 if ( !dayView ) {
453 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 461 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
454 views->addWidget( dayView, DAY ); 462 views->addWidget( dayView, DAY );
455 dayView->setStartViewTime( startTime ); 463 dayView->setStartViewTime( startTime );
464 dayView->setJumpToCurTime( bJumpToCurTime );
465 dayView->setRowStyle( rowStyle );
456 connect( this, SIGNAL( newEvent() ), 466 connect( this, SIGNAL( newEvent() ),
457 dayView, SLOT( redraw() ) ); 467 dayView, SLOT( redraw() ) );
458 connect( dayView, SIGNAL( newEvent() ), 468 connect( dayView, SIGNAL( newEvent() ),
459 this, SLOT( fileNew() ) ); 469 this, SLOT( fileNew() ) );
460 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 470 connect( dayView, SIGNAL( removeEvent( const Event & ) ),
461 this, SLOT( removeEvent( const Event & ) ) ); 471 this, SLOT( removeEvent( const Event & ) ) );
462 connect( dayView, SIGNAL( editEvent( const Event & ) ), 472 connect( dayView, SIGNAL( editEvent( const Event & ) ),
463 this, SLOT( editEvent( const Event & ) ) ); 473 this, SLOT( editEvent( const Event & ) ) );
464 connect( dayView, SIGNAL( beamEvent( const Event & ) ), 474 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
465 this, SLOT( beamEvent( const Event & ) ) ); 475 this, SLOT( beamEvent( const Event & ) ) );
466 connect( dayView, SIGNAL(sigNewEvent(const QString &)), 476 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
467 this, SLOT(slotNewEventFromKey(const QString &)) ); 477 this, SLOT(slotNewEventFromKey(const QString &)) );
468 } 478 }
469} 479}
470 480
471void DateBook::initWeek() 481void DateBook::initWeek()
472{ 482{
473 if ( !weekView ) { 483 if ( !weekView ) {
474 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 484 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
475 weekView->setStartViewTime( startTime ); 485 weekView->setStartViewTime( startTime );
476 views->addWidget( weekView, WEEK ); 486 views->addWidget( weekView, WEEK );
477 connect( weekView, SIGNAL( showDate( int, int, int ) ), 487 connect( weekView, SIGNAL( showDate( int, int, int ) ),
478 this, SLOT( showDay( int, int, int ) ) ); 488 this, SLOT( showDay( int, int, int ) ) );
479 connect( this, SIGNAL( newEvent() ), 489 connect( this, SIGNAL( newEvent() ),
480 weekView, SLOT( redraw() ) ); 490 weekView, SLOT( redraw() ) );
481 } 491 }
482 //But also get it right: the year that we display can be different 492 //But also get it right: the year that we display can be different
483 //from the year of the current date. So, first find the year 493 //from the year of the current date. So, first find the year
484 //number of the current week. 494 //number of the current week.
485 495
486 int yearNumber, totWeeks; 496 int yearNumber, totWeeks;
487 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 497 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
488 498
489 QDate d = QDate( yearNumber, 12, 31 ); 499 QDate d = QDate( yearNumber, 12, 31 );
490 calcWeek( d, totWeeks, yearNumber, onMonday ); 500 calcWeek( d, totWeeks, yearNumber, onMonday );
491 501
492 while ( totWeeks == 1 ) { 502 while ( totWeeks == 1 ) {
493 d = d.addDays( -1 ); 503 d = d.addDays( -1 );
494 calcWeek( d, totWeeks, yearNumber, onMonday ); 504 calcWeek( d, totWeeks, yearNumber, onMonday );
495 } 505 }
496 if ( totWeeks != weekView->totalWeeks() ) 506 if ( totWeeks != weekView->totalWeeks() )
497 weekView->setTotalWeeks( totWeeks ); 507 weekView->setTotalWeeks( totWeeks );
498} 508}
499void DateBook::initWeekLst() { 509void DateBook::initWeekLst() {
500 if ( !weekLstView ) { 510 if ( !weekLstView ) {
501 weekLstView = new DateBookWeekLst( ampm, onMonday, db, 511 weekLstView = new DateBookWeekLst( ampm, onMonday, db,
502 views, "weeklst view" ); 512 views, "weeklst view" );
503 views->addWidget( weekLstView, WEEKLST ); 513 views->addWidget( weekLstView, WEEKLST );
504 514
505 //weekLstView->setStartViewTime( startTime ); 515 //weekLstView->setStartViewTime( startTime );
506 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), 516 connect( weekLstView, SIGNAL( showDate( int, int, int ) ),
507 this, SLOT( showDay( int, int, int ) ) ); 517 this, SLOT( showDay( int, int, int ) ) );
508 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, 518 connect( weekLstView, SIGNAL( addEvent( const QDateTime &,
509 const QDateTime &, 519 const QDateTime &,
510 const QString & ) ), 520 const QString & ) ),
511 this, SLOT( slotNewEntry( const QDateTime &, 521 this, SLOT( slotNewEntry( const QDateTime &,
512 const QDateTime &, 522 const QDateTime &,
513 const QString & ) ) ); 523 const QString & ) ) );
514 connect( this, SIGNAL( newEvent() ), 524 connect( this, SIGNAL( newEvent() ),
515 weekLstView, SLOT( redraw() ) ); 525 weekLstView, SLOT( redraw() ) );
516 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), 526 connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
517 this, SLOT( editEvent( const Event & ) ) ); 527 this, SLOT( editEvent( const Event & ) ) );
518 } 528 }
519} 529}
520 530
521 531
522void DateBook::initMonth() 532void DateBook::initMonth()
523{ 533{
524 if ( !monthView ) { 534 if ( !monthView ) {
525 monthView = new DateBookMonth( views, "month view", FALSE, db ); 535 monthView = new DateBookMonth( views, "month view", FALSE, db );
526 views->addWidget( monthView, MONTH ); 536 views->addWidget( monthView, MONTH );
527 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), 537 connect( monthView, SIGNAL( dateClicked( int, int, int ) ),
528 this, SLOT( showDay( int, int, int ) ) ); 538 this, SLOT( showDay( int, int, int ) ) );
529 connect( this, SIGNAL( newEvent() ), 539 connect( this, SIGNAL( newEvent() ),
530 monthView, SLOT( redraw() ) ); 540 monthView, SLOT( redraw() ) );
531 qApp->processEvents(); 541 qApp->processEvents();
532 } 542 }
533} 543}
534 544
535void DateBook::loadSettings() 545void DateBook::loadSettings()
536{ 546{
537 { 547 {
538 Config config( "qpe" ); 548 Config config( "qpe" );
539 config.setGroup("Time"); 549 config.setGroup("Time");
540 ampm = config.readBoolEntry( "AMPM", TRUE ); 550 ampm = config.readBoolEntry( "AMPM", TRUE );
541 onMonday = config.readBoolEntry( "MONDAY" ); 551 onMonday = config.readBoolEntry( "MONDAY" );
542 } 552 }
543 553
544 { 554 {
545 Config config("DateBook"); 555 Config config("DateBook");
546 config.setGroup("Main"); 556 config.setGroup("Main");
547 startTime = config.readNumEntry("startviewtime", 8); 557 startTime = config.readNumEntry("startviewtime", 8);
548 aPreset = config.readBoolEntry("alarmpreset"); 558 aPreset = config.readBoolEntry("alarmpreset");
549 presetTime = config.readNumEntry("presettime"); 559 presetTime = config.readNumEntry("presettime");
560 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
561 rowStyle = config.readNumEntry("rowstyle");
550 } 562 }
551} 563}
552 564
553void DateBook::saveSettings() 565void DateBook::saveSettings()
554{ 566{
555 Config config( "qpe" ); 567 Config config( "qpe" );
556 Config configDB( "DateBook" ); 568 Config configDB( "DateBook" );
557 configDB.setGroup( "Main" ); 569 configDB.setGroup( "Main" );
558 configDB.writeEntry("startviewtime",startTime); 570 configDB.writeEntry("startviewtime",startTime);
559 configDB.writeEntry("alarmpreset",aPreset); 571 configDB.writeEntry("alarmpreset",aPreset);
560 configDB.writeEntry("presettime",presetTime); 572 configDB.writeEntry("presettime",presetTime);
573 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
574 configDB.writeEntry("rowstyle", rowStyle);
561} 575}
562 576
563void DateBook::newDefaultView(QAction *a) { 577void DateBook::newDefaultView(QAction *a) {
564 int val=DAY; 578 int val=DAY;
565 if (a->text() == "Day") val=DAY; 579 if (a->text() == "Day") val=DAY;
566 if (a->text() == "Week") val=WEEK; 580 if (a->text() == "Week") val=WEEK;
567 if (a->text() == "WeekLst") val=WEEKLST; 581 if (a->text() == "WeekLst") val=WEEKLST;
568 if (a->text() == "Month") val=MONTH; 582 if (a->text() == "Month") val=MONTH;
569 583
570 Config configDB( "DateBook" ); 584 Config configDB( "DateBook" );
571 configDB.setGroup( "Main" ); 585 configDB.setGroup( "Main" );
572 configDB.writeEntry("defaultview",val); 586 configDB.writeEntry("defaultview",val);
573} 587}
574 588
575void DateBook::appMessage(const QCString& msg, const QByteArray& data) 589void DateBook::appMessage(const QCString& msg, const QByteArray& data)
576{ 590{
577 bool needShow = FALSE; 591 bool needShow = FALSE;
578 if ( msg == "alarm(QDateTime,int)" ) { 592 if ( msg == "alarm(QDateTime,int)" ) {
579 QDataStream ds(data,IO_ReadOnly); 593 QDataStream ds(data,IO_ReadOnly);
580 QDateTime when; int warn; 594 QDateTime when; int warn;
581 ds >> when >> warn; 595 ds >> when >> warn;
582 596
583 // check to make it's okay to continue, 597 // check to make it's okay to continue,
584 // this is the case that the time was set ahead, and 598 // this is the case that the time was set ahead, and
585 // we are forced given a stale alarm... 599 // we are forced given a stale alarm...
586 QDateTime current = QDateTime::currentDateTime(); 600 QDateTime current = QDateTime::currentDateTime();
587 if ( current.time().hour() != when.time().hour() 601 if ( current.time().hour() != when.time().hour()
588 && current.time().minute() != when.time().minute() ) 602 && current.time().minute() != when.time().minute() )
589 return; 603 return;
590 604
591 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 605 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
592 if ( list.count() > 0 ) { 606 if ( list.count() > 0 ) {
593 QString msg; 607 QString msg;
594 bool bSound = FALSE; 608 bool bSound = FALSE;
595 int stopTimer = 0; 609 int stopTimer = 0;
596 bool found = FALSE; 610 bool found = FALSE;
597 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); 611 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin();
598 it!=list.end(); ++it ) { 612 it!=list.end(); ++it ) {
599 if ( (*it).event().hasAlarm() ) { 613 if ( (*it).event().hasAlarm() ) {
600 found = TRUE; 614 found = TRUE;
601 msg += "<CENTER><B>" + (*it).description() + "</B>" 615 msg += "<CENTER><B>" + (*it).description() + "</B>"
602 + "<BR>" + (*it).location() + "<BR>" 616 + "<BR>" + (*it).location() + "<BR>"
603 + TimeString::dateString((*it).event().start(),ampm) 617 + TimeString::dateString((*it).event().start(),ampm)
604 + (warn 618 + (warn
605 ? tr(" (in " + QString::number(warn) 619 ? tr(" (in " + QString::number(warn)
606 + tr(" minutes)")) 620 + tr(" minutes)"))
607 : QString("")) 621 : QString(""))
608 + "<BR>" 622 + "<BR>"
609 + (*it).notes() + "</CENTER>"; 623 + (*it).notes() + "</CENTER>";
610 if ( (*it).event().alarmSound() != Event::Silent ) { 624 if ( (*it).event().alarmSound() != Event::Silent ) {
611 bSound = TRUE; 625 bSound = TRUE;
612 } 626 }
613 } 627 }
614 } 628 }
615 if ( found ) { 629 if ( found ) {
616 if ( bSound ) { 630 if ( bSound ) {
617 Sound::soundAlarm(); 631 Sound::soundAlarm();
618 alarmCounter = 0; 632 alarmCounter = 0;
619 stopTimer = startTimer( 5000 ); 633 stopTimer = startTimer( 5000 );
620 } 634 }
621 635
622 QDialog dlg( this, 0, TRUE ); 636 QDialog dlg( this, 0, TRUE );
623 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 637 QVBoxLayout *vb = new QVBoxLayout( &dlg );
624 QScrollView *view = new QScrollView( &dlg, "scrollView"); 638 QScrollView *view = new QScrollView( &dlg, "scrollView");
625 view->setResizePolicy( QScrollView::AutoOneFit ); 639 view->setResizePolicy( QScrollView::AutoOneFit );
626 vb->addWidget( view ); 640 vb->addWidget( view );
627 QLabel *lblMsg = new QLabel( msg, &dlg ); 641 QLabel *lblMsg = new QLabel( msg, &dlg );
628 view->addChild( lblMsg ); 642 view->addChild( lblMsg );
629 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 643 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
630 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 644 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
631 vb->addWidget( cmdOk ); 645 vb->addWidget( cmdOk );
632 646
633#if defined(Q_WS_QWS) || defined(_WS_QWS_) 647#if defined(Q_WS_QWS) || defined(_WS_QWS_)
634 dlg.showMaximized(); 648 dlg.showMaximized();
635#endif 649#endif
636 needShow = dlg.exec(); 650 needShow = dlg.exec();
637 651
638 if ( bSound ) 652 if ( bSound )
639 killTimer( stopTimer ); 653 killTimer( stopTimer );
640 } 654 }
641 } 655 }
642 } else if ( msg == "nextView()" ) { 656 } else if ( msg == "nextView()" ) {
643 QWidget* cur = views->visibleWidget(); 657 QWidget* cur = views->visibleWidget();
644 if ( cur ) { 658 if ( cur ) {
645 if ( cur == dayView ) 659 if ( cur == dayView )
646 viewWeek(); 660 viewWeek();
647 else if ( cur == weekView ) 661 else if ( cur == weekView )
648 viewWeekLst(); 662 viewWeekLst();
649 else if ( cur == weekLstView ) 663 else if ( cur == weekLstView )
650 viewMonth(); 664 viewMonth();
651 else if ( cur == monthView ) 665 else if ( cur == monthView )
652 viewDay(); 666 viewDay();
653 needShow = TRUE; 667 needShow = TRUE;
654 } 668 }
655 } 669 }
656 if ( needShow ) { 670 if ( needShow ) {
657#if defined(Q_WS_QWS) || defined(_WS_QWS_) 671#if defined(Q_WS_QWS) || defined(_WS_QWS_)
658 showMaximized(); 672 showMaximized();
659#else 673#else
660 show(); 674 show();
661#endif 675#endif
662 raise(); 676 raise();
663 QPEApplication::setKeepRunning(); 677 QPEApplication::setKeepRunning();
664 setActiveWindow(); 678 setActiveWindow();
665 } 679 }
666} 680}
667 681
668void DateBook::reload() 682void DateBook::reload()
669{ 683{
670 db->reload(); 684 db->reload();
671 if ( dayAction->isOn() ) 685 if ( dayAction->isOn() )
672 viewDay(); 686 viewDay();
673 else if ( weekAction->isOn() ) 687 else if ( weekAction->isOn() )
674 viewWeek(); 688 viewWeek();
675 else if ( monthAction->isOn() ) 689 else if ( monthAction->isOn() )
676 viewMonth(); 690 viewMonth();
677 syncing = FALSE; 691 syncing = FALSE;
678} 692}
679 693
680void DateBook::flush() 694void DateBook::flush()
681{ 695{
682 syncing = TRUE; 696 syncing = TRUE;
683 db->save(); 697 db->save();
684} 698}
685 699
686void DateBook::timerEvent( QTimerEvent *e ) 700void DateBook::timerEvent( QTimerEvent *e )
687{ 701{
688 if ( alarmCounter < 10 ) { 702 if ( alarmCounter < 10 ) {
689 alarmCounter++; 703 alarmCounter++;
690 Sound::soundAlarm(); 704 Sound::soundAlarm();
691 } 705 }
692 else 706 else
693 killTimer( e->timerId() ); 707 killTimer( e->timerId() );
694} 708}
695 709
696void DateBook::changeClock( bool newClock ) 710void DateBook::changeClock( bool newClock )
697{ 711{
698 ampm = newClock; 712 ampm = newClock;
699 // repaint the affected objects... 713 // repaint the affected objects...
700 if (dayView) dayView->redraw(); 714 if (dayView) dayView->redraw();
701 if (weekView) weekView->redraw(); 715 if (weekView) weekView->redraw();
702 if (weekLstView) weekLstView->redraw(); 716 if (weekLstView) weekLstView->redraw();
703} 717}
704 718
705void DateBook::changeWeek( bool m ) 719void DateBook::changeWeek( bool m )
706{ 720{
707 /* no need to redraw, each widget catches. Do need to 721 /* no need to redraw, each widget catches. Do need to
708 store though for widgets we haven't made yet */ 722 store though for widgets we haven't made yet */
709 onMonday = m; 723 onMonday = m;
710} 724}
711 725
712void DateBook::slotToday() 726void DateBook::slotToday()
713{ 727{
714 // we need to view today using default view 728 // we need to view today using default view
715 viewDefault(QDate::currentDate()); 729 viewDefault(QDate::currentDate());
716} 730}
717 731
718void DateBook::closeEvent( QCloseEvent *e ) 732void DateBook::closeEvent( QCloseEvent *e )
719{ 733{
720 if(syncing) { 734 if(syncing) {
721 /* no need to save, did that at flush */ 735 /* no need to save, did that at flush */
722 e->accept(); 736 e->accept();
723 return; 737 return;
724 } 738 }
725 739
726 // save settings will generate it's own error messages, no 740 // save settings will generate it's own error messages, no
727 // need to do checking ourselves. 741 // need to do checking ourselves.
728 saveSettings(); 742 saveSettings();
729 if ( db->save() ) 743 if ( db->save() )
730 e->accept(); 744 e->accept();
731 else { 745 else {
732 if ( QMessageBox::critical( this, tr( "Out of space" ), 746 if ( QMessageBox::critical( this, tr( "Out of space" ),
733 tr("Calendar was unable to save\n" 747 tr("Calendar was unable to save\n"
734 "your changes.\n" 748 "your changes.\n"
735 "Free up some space and try again.\n" 749 "Free up some space and try again.\n"
736 "\nQuit anyway?"), 750 "\nQuit anyway?"),
737 QMessageBox::Yes|QMessageBox::Escape, 751 QMessageBox::Yes|QMessageBox::Escape,
738 QMessageBox::No|QMessageBox::Default ) 752 QMessageBox::No|QMessageBox::Default )
739 != QMessageBox::No ) 753 != QMessageBox::No )
740 e->accept(); 754 e->accept();
741 else 755 else
742 e->ignore(); 756 e->ignore();
743 } 757 }
744} 758}
745 759
746// Entering directly from the "keyboard" 760// Entering directly from the "keyboard"
747void DateBook::slotNewEventFromKey( const QString &str ) 761void DateBook::slotNewEventFromKey( const QString &str )
748{ 762{
749 if (syncing) { 763 if (syncing) {
750 QMessageBox::warning( this, tr("Calendar"), 764 QMessageBox::warning( this, tr("Calendar"),
751 tr( "Can not edit data, currently syncing") ); 765 tr( "Can not edit data, currently syncing") );
752 return; 766 return;
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index e7be0dd..ba8f97e 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -1,128 +1,130 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef DATEBOOK_H 20#ifndef DATEBOOK_H
21#define DATEBOOK_H 21#define DATEBOOK_H
22 22
23#include <qpe/datebookdb.h> 23#include <qpe/datebookdb.h>
24 24
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26 26
27class QAction; 27class QAction;
28class QWidgetStack; 28class QWidgetStack;
29class DateBookDay; 29class DateBookDay;
30class DateBookWeek; 30class DateBookWeek;
31class DateBookWeekLst; 31class DateBookWeekLst;
32class DateBookMonth; 32class DateBookMonth;
33class Event; 33class Event;
34class QDate; 34class QDate;
35class Ir; 35class Ir;
36 36
37class DateBookDBHack : public DateBookDB { 37class DateBookDBHack : public DateBookDB {
38 public: 38 public:
39 Event eventByUID(int id); 39 Event eventByUID(int id);
40}; 40};
41 41
42class DateBook : public QMainWindow 42class DateBook : public QMainWindow
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46public: 46public:
47 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 47 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
48 ~DateBook(); 48 ~DateBook();
49 49
50signals: 50signals:
51 void newEvent(); 51 void newEvent();
52 void signalNotFound(); 52 void signalNotFound();
53 void signalWrapAround(); 53 void signalWrapAround();
54 54
55protected: 55protected:
56 QDate currentDate(); 56 QDate currentDate();
57 void timerEvent( QTimerEvent *e ); 57 void timerEvent( QTimerEvent *e );
58 void closeEvent( QCloseEvent *e ); 58 void closeEvent( QCloseEvent *e );
59 59
60 void view(int v, const QDate &d); 60 void view(int v, const QDate &d);
61 61
62public slots: 62public slots:
63 void flush(); 63 void flush();
64 void reload(); 64 void reload();
65 65
66private slots: 66private slots:
67 void fileNew(); 67 void fileNew();
68 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str); 68 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str);
69 void slotSettings(); 69 void slotSettings();
70 void newDefaultView(QAction *a); 70 void newDefaultView(QAction *a);
71 void slotToday();// view today 71 void slotToday();// view today
72 void changeClock( bool newClock ); 72 void changeClock( bool newClock );
73 void changeWeek( bool newDay ); 73 void changeWeek( bool newDay );
74 void appMessage(const QCString& msg, const QByteArray& data); 74 void appMessage(const QCString& msg, const QByteArray& data);
75 // handle key events in the day view... 75 // handle key events in the day view...
76 void slotNewEventFromKey( const QString &str ); 76 void slotNewEventFromKey( const QString &str );
77 void slotFind(); 77 void slotFind();
78 void slotDoFind( const QString &, const QDate &, bool, bool, int ); 78 void slotDoFind( const QString &, const QDate &, bool, bool, int );
79 79
80 void viewDefault(const QDate &d); 80 void viewDefault(const QDate &d);
81 81
82 void viewDay(); 82 void viewDay();
83 void viewWeek(); 83 void viewWeek();
84 void viewWeekLst(); 84 void viewWeekLst();
85 void viewMonth(); 85 void viewMonth();
86 86
87 void showDay( int y, int m, int d ); 87 void showDay( int y, int m, int d );
88 88
89 void editEvent( const Event &e ); 89 void editEvent( const Event &e );
90 void removeEvent( const Event &e ); 90 void removeEvent( const Event &e );
91 91
92 void receive( const QCString &msg, const QByteArray &data ); 92 void receive( const QCString &msg, const QByteArray &data );
93 void setDocument( const QString & ); 93 void setDocument( const QString & );
94 void beamEvent( const Event &e ); 94 void beamEvent( const Event &e );
95 void beamDone( Ir *ir ); 95 void beamDone( Ir *ir );
96 96
97private: 97private:
98 void addEvent( const Event &e ); 98 void addEvent( const Event &e );
99 void initDay(); 99 void initDay();
100 void initWeek(); 100 void initWeek();
101 void initWeekLst(); 101 void initWeekLst();
102 void initMonth(); 102 void initMonth();
103 void loadSettings(); 103 void loadSettings();
104 void saveSettings(); 104 void saveSettings();
105 105
106private: 106private:
107 DateBookDBHack *db; 107 DateBookDBHack *db;
108 QWidgetStack *views; 108 QWidgetStack *views;
109 DateBookDay *dayView; 109 DateBookDay *dayView;
110 DateBookWeek *weekView; 110 DateBookWeek *weekView;
111 DateBookMonth *monthView; 111 DateBookMonth *monthView;
112 DateBookWeekLst *weekLstView; 112 DateBookWeekLst *weekLstView;
113 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 113 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
114 bool aPreset; // have everything set to alarm? 114 bool aPreset; // have everything set to alarm?
115 int presetTime; // the standard time for the alarm 115 int presetTime; // the standard time for the alarm
116 int startTime; 116 int startTime;
117 int rowStyle;
118 bool bJumpToCurTime; //should jump to current time in dayview?
117 bool ampm; 119 bool ampm;
118 bool onMonday; 120 bool onMonday;
119 121
120 bool syncing; 122 bool syncing;
121 bool inSearch; 123 bool inSearch;
122 124
123 int alarmCounter; 125 int alarmCounter;
124 126
125 QString checkEvent(const Event &); 127 QString checkEvent(const Event &);
126}; 128};
127 129
128#endif 130#endif
diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro
index 609b7dc..1db3e3a 100644
--- a/core/pim/datebook/datebook.pro
+++ b/core/pim/datebook/datebook.pro
@@ -1,60 +1,61 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_on release 2 CONFIG += qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 4
5 HEADERS= datebookday.h \ 5 HEADERS= datebookday.h \
6 datebook.h \ 6 datebook.h \
7 dateentryimpl.h \ 7 dateentryimpl.h \
8 datebookdayheaderimpl.h \ 8 datebookdayheaderimpl.h \
9 datebooksettings.h \ 9 datebooksettings.h \
10 datebooksettingsbase.h \
10 datebookweek.h \ 11 datebookweek.h \
11 datebookweeklst.h \ 12 datebookweeklst.h \
12 datebookweekheaderimpl.h \ 13 datebookweekheaderimpl.h \
13 repeatentry.h \ 14 repeatentry.h \
14 timepicker.h \ 15 timepicker.h \
15 noteentryimpl.h \ 16 noteentryimpl.h \
16 onoteedit.h 17 onoteedit.h
17 18
18 SOURCES= main.cpp \ 19 SOURCES= main.cpp \
19 datebookday.cpp \ 20 datebookday.cpp \
20 datebook.cpp \ 21 datebook.cpp \
21 dateentryimpl.cpp \ 22 dateentryimpl.cpp \
22 datebookdayheaderimpl.cpp \ 23 datebookdayheaderimpl.cpp \
24 datebooksettingsbase.cpp \
23 datebooksettings.cpp \ 25 datebooksettings.cpp \
24 datebookweek.cpp \ 26 datebookweek.cpp \
25 datebookweeklst.cpp \ 27 datebookweeklst.cpp \
26 datebookweekheaderimpl.cpp \ 28 datebookweekheaderimpl.cpp \
27 repeatentry.cpp \ 29 repeatentry.cpp \
28 timepicker.cpp \ 30 timepicker.cpp \
29 noteentryimpl.cpp \ 31 noteentryimpl.cpp \
30 onoteedit.cpp 32 onoteedit.cpp
31 33
32 INTERFACES= dateentry.ui \ 34 INTERFACES= dateentry.ui \
33 datebookdayheader.ui \ 35 datebookdayheader.ui \
34 datebooksettingsbase.ui \
35 datebookweekheader.ui \ 36 datebookweekheader.ui \
36 datebookweeklstheader.ui \ 37 datebookweeklstheader.ui \
37 datebookweeklstdayhdr.ui \ 38 datebookweeklstdayhdr.ui \
38 repeatentrybase.ui \ 39 repeatentrybase.ui \
39 noteentry.ui 40 noteentry.ui
40 41
41INCLUDEPATH += $(OPIEDIR)/include 42INCLUDEPATH += $(OPIEDIR)/include
42 DEPENDPATH+= $(OPIEDIR)/include 43 DEPENDPATH+= $(OPIEDIR)/include
43LIBS += -lqpe -lopie 44LIBS += -lqpe -lopie
44 45
45 TARGET = datebook 46 TARGET = datebook
46 47
47TRANSLATIONS = ../i18n/pt_BR/datebook.ts 48TRANSLATIONS = ../i18n/pt_BR/datebook.ts
48TRANSLATIONS += ../i18n/pt/datebook.ts 49TRANSLATIONS += ../i18n/pt/datebook.ts
49TRANSLATIONS += ../i18n/de/datebook.ts 50TRANSLATIONS += ../i18n/de/datebook.ts
50TRANSLATIONS += ../i18n/en/datebook.ts 51TRANSLATIONS += ../i18n/en/datebook.ts
51TRANSLATIONS += ../i18n/hu/datebook.ts 52TRANSLATIONS += ../i18n/hu/datebook.ts
52TRANSLATIONS += ../i18n/pl/datebook.ts 53TRANSLATIONS += ../i18n/pl/datebook.ts
53TRANSLATIONS += ../i18n/sl/datebook.ts 54TRANSLATIONS += ../i18n/sl/datebook.ts
54TRANSLATIONS += ../i18n/ja/datebook.ts 55TRANSLATIONS += ../i18n/ja/datebook.ts
55TRANSLATIONS += ../i18n/ko/datebook.ts 56TRANSLATIONS += ../i18n/ko/datebook.ts
56TRANSLATIONS += ../i18n/no/datebook.ts 57TRANSLATIONS += ../i18n/no/datebook.ts
57TRANSLATIONS += ../i18n/zh_CN/datebook.ts 58TRANSLATIONS += ../i18n/zh_CN/datebook.ts
58TRANSLATIONS += ../i18n/zh_TW/datebook.ts 59TRANSLATIONS += ../i18n/zh_TW/datebook.ts
59TRANSLATIONS += ../i18n/fr/datebook.ts 60TRANSLATIONS += ../i18n/fr/datebook.ts
60TRANSLATIONS += ../i18n/es/datebook.ts 61TRANSLATIONS += ../i18n/es/datebook.ts
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index c15ccef..9cc5fcd 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -1,675 +1,720 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21 21
22#include "datebookday.h" 22#include "datebookday.h"
23#include "datebookdayheaderimpl.h" 23#include "datebookdayheaderimpl.h"
24 24
25#include <qpe/datebookdb.h> 25#include <qpe/datebookdb.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/event.h> 27#include <qpe/event.h>
28#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29#include <qpe/timestring.h> 29#include <qpe/timestring.h>
30#include <qpe/qpedebug.h> 30#include <qpe/qpedebug.h>
31 31
32#include <qheader.h> 32#include <qheader.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qpainter.h> 34#include <qpainter.h>
35#include <qsimplerichtext.h> 35#include <qsimplerichtext.h>
36#include <qpopupmenu.h> 36#include <qpopupmenu.h>
37#include <qtextcodec.h> 37#include <qtextcodec.h>
38#include <qpalette.h> 38#include <qpalette.h>
39 39
40#include <qtimer.h> 40#include <qtimer.h>
41 41
42DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, 42DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent,
43 const char *name ) 43 const char *name )
44 : QTable( 24, 1, parent, name ), 44 : QTable( 24, 1, parent, name ),
45 ampm( whichClock ) 45 ampm( whichClock )
46{ 46{
47 enableClipper(TRUE); 47 enableClipper(TRUE);
48 setTopMargin( 0 ); 48 setTopMargin( 0 );
49 horizontalHeader()->hide(); 49 horizontalHeader()->hide();
50 setLeftMargin(38); 50 setLeftMargin(38);
51 setColumnStretchable( 0, TRUE ); 51 setColumnStretchable( 0, TRUE );
52 setHScrollBarMode( QScrollView::AlwaysOff ); 52 setHScrollBarMode( QScrollView::AlwaysOff );
53 verticalHeader()->setPalette(white); 53 verticalHeader()->setPalette(white);
54 verticalHeader()->setResizeEnabled(FALSE); 54 verticalHeader()->setResizeEnabled(FALSE);
55 setSelectionMode( Single ); 55 setSelectionMode( Single );
56 56
57 // get rid of being able to edit things... 57 // get rid of being able to edit things...
58 QTableItem *tmp; 58 QTableItem *tmp;
59 int row; 59 int row;
60 for ( row = 0; row < numRows(); row++ ) { 60 for ( row = 0; row < numRows(); row++ ) {
61 tmp = new QTableItem( this, QTableItem::Never, QString::null); 61 tmp = new QTableItem( this, QTableItem::Never, QString::null);
62 setItem( row, 0, tmp ); 62 setItem( row, 0, tmp );
63 setRowHeight( row, 40); 63 //setRowHeight( row, 40);
64 } 64 }
65 initHeader(); 65 initHeader();
66 QObject::connect( qApp, SIGNAL(clockChanged(bool)), 66 QObject::connect( qApp, SIGNAL(clockChanged(bool)),
67 this, SLOT(slotChangeClock(bool)) ); 67 this, SLOT(slotChangeClock(bool)) );
68} 68}
69 69
70void DateBookDayView::initHeader() 70void DateBookDayView::initHeader()
71{ 71{
72 QString strTmp; 72 QString strTmp;
73 for ( int i = 0; i < 24; ++i ) { 73 for ( int i = 0; i < 24; ++i ) {
74 if ( ampm ) { 74 if ( ampm ) {
75 if ( i == 0 ) 75 if ( i == 0 )
76 strTmp = QString::number(12) + ":00"; 76 strTmp = QString::number(12) + ":00";
77 else if ( i == 12 ) 77 else if ( i == 12 )
78 strTmp = QString::number(12) + tr(":00p"); 78 strTmp = QString::number(12) + tr(":00p");
79 else if ( i > 12 ) 79 else if ( i > 12 )
80 strTmp = QString::number( i - 12 ) + tr(":00p"); 80 strTmp = QString::number( i - 12 ) + tr(":00p");
81 else 81 else
82 strTmp = QString::number(i) + ":00"; 82 strTmp = QString::number(i) + ":00";
83 } else { 83 } else {
84 if ( i < 10 ) 84 if ( i < 10 )
85 strTmp = "0" + QString::number(i) + ":00"; 85 strTmp = "0" + QString::number(i) + ":00";
86 else 86 else
87 strTmp = QString::number(i) + ":00"; 87 strTmp = QString::number(i) + ":00";
88 } 88 }
89 strTmp = strTmp.rightJustify( 6, ' ' ); 89 strTmp = strTmp.rightJustify( 6, ' ' );
90 verticalHeader()->setLabel( i, strTmp ); 90 verticalHeader()->setLabel( i, strTmp );
91 setRowStretchable( i, FALSE ); 91 setRowStretchable( i, FALSE );
92 } 92 }
93} 93}
94 94
95void DateBookDayView::slotChangeClock( bool newClock ) 95void DateBookDayView::slotChangeClock( bool newClock )
96{ 96{
97 ampm = newClock; 97 ampm = newClock;
98 initHeader(); 98 initHeader();
99} 99}
100 100
101bool DateBookDayView::whichClock() const 101bool DateBookDayView::whichClock() const
102{ 102{
103 return ampm; 103 return ampm;
104} 104}
105 105
106void DateBookDayView::moveUp() 106void DateBookDayView::moveUp()
107{ 107{
108 scrollBy(0, -20); 108 scrollBy(0, -20);
109} 109}
110 110
111void DateBookDayView::moveDown() 111void DateBookDayView::moveDown()
112{ 112{
113 scrollBy(0, 20); 113 scrollBy(0, 20);
114} 114}
115 115
116void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) 116void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool )
117{ 117{
118 int w = cr.width(); 118 int w = cr.width();
119 int h = cr.height(); 119 int h = cr.height();
120 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); 120 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) );
121 if ( showGrid() ) { 121 if ( showGrid() ) {
122 // Draw our lines 122 // Draw our lines
123 int x2 = w - 1; 123 int x2 = w - 1;
124 int y2 = h - 1; 124 int y2 = h - 1;
125 QPen pen( p->pen() ); 125 QPen pen( p->pen() );
126 p->setPen( colorGroup().dark() ); 126 p->setPen( colorGroup().dark() );
127 p->drawLine( x2, 0, x2, y2 ); 127 p->drawLine( x2, 0, x2, y2 );
128 p->drawLine( 0, y2, x2, y2 ); 128 p->drawLine( 0, y2, x2, y2 );
129 129
130 p->setPen( colorGroup().midlight() ); 130 p->setPen( colorGroup().midlight() );
131 p->drawLine( 0, y2 - h/2, x2, y2 - h/2); 131 p->drawLine( 0, y2 - h/2, x2, y2 - h/2);
132 132
133 p->setPen( pen ); 133 p->setPen( pen );
134 } 134 }
135} 135}
136 136
137void DateBookDayView::paintFocus( QPainter *, const QRect & ) 137void DateBookDayView::paintFocus( QPainter *, const QRect & )
138{ 138{
139} 139}
140 140
141 141
142void DateBookDayView::resizeEvent( QResizeEvent *e ) 142void DateBookDayView::resizeEvent( QResizeEvent *e )
143{ 143{
144 QTable::resizeEvent( e ); 144 QTable::resizeEvent( e );
145 columnWidthChanged( 0 ); 145 columnWidthChanged( 0 );
146 emit sigColWidthChanged(); 146 emit sigColWidthChanged();
147} 147}
148 148
149void DateBookDayView::keyPressEvent( QKeyEvent *e ) 149void DateBookDayView::keyPressEvent( QKeyEvent *e )
150{ 150{
151 QString txt = e->text(); 151 QString txt = e->text();
152 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { 152 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) {
153 // we this is some sort of thing we know about... 153 // we this is some sort of thing we know about...
154 e->accept(); 154 e->accept();
155 emit sigCapturedKey( txt ); 155 emit sigCapturedKey( txt );
156 } else { 156 } else {
157 // I don't know what this key is, do you? 157 // I don't know what this key is, do you?
158 e->ignore(); 158 e->ignore();
159 } 159 }
160} 160}
161 161
162void DateBookDayView::setRowStyle( int style )
163{
164 if (style<0) style = 0;
165
166 for (int i=0; i<numRows(); i++)
167 setRowHeight(i, style*10+20);
168}
162 169
163//=========================================================================== 170//===========================================================================
164 171
165DateBookDay::DateBookDay( bool ampm, bool startOnMonday, 172DateBookDay::DateBookDay( bool ampm, bool startOnMonday,
166 DateBookDB *newDb, QWidget *parent, 173 DateBookDB *newDb, QWidget *parent,
167 const char *name ) 174 const char *name )
168 : QVBox( parent, name ), 175 : QVBox( parent, name ),
169 currDate( QDate::currentDate() ), 176 currDate( QDate::currentDate() ),
170 db( newDb ), 177 db( newDb ),
171 startTime( 0 ) 178 startTime( 0 )
172{ 179{
173 widgetList.setAutoDelete( true ); 180 widgetList.setAutoDelete( true );
174 header = new DateBookDayHeader( startOnMonday, this, "day header" ); 181 header = new DateBookDayHeader( startOnMonday, this, "day header" );
175 header->setDate( currDate.year(), currDate.month(), currDate.day() ); 182 header->setDate( currDate.year(), currDate.month(), currDate.day() );
176 view = new DateBookDayView( ampm, this, "day view" ); 183 view = new DateBookDayView( ampm, this, "day view" );
184
177 connect( header, SIGNAL( dateChanged( int, int, int ) ), 185 connect( header, SIGNAL( dateChanged( int, int, int ) ),
178 this, SLOT( dateChanged( int, int, int ) ) ); 186 this, SLOT( dateChanged( int, int, int ) ) );
179 connect( view, SIGNAL( sigColWidthChanged() ), 187 connect( view, SIGNAL( sigColWidthChanged() ),
180 this, SLOT( slotColWidthChanged() ) ); 188 this, SLOT( slotColWidthChanged() ) );
181 connect( qApp, SIGNAL(weekChanged(bool)), 189 connect( qApp, SIGNAL(weekChanged(bool)),
182 this, SLOT(slotWeekChanged(bool)) ); 190 this, SLOT(slotWeekChanged(bool)) );
183 connect( view, SIGNAL(sigCapturedKey(const QString &)), 191 connect( view, SIGNAL(sigCapturedKey(const QString &)),
184 this, SIGNAL(sigNewEvent(const QString&)) ); 192 this, SIGNAL(sigNewEvent(const QString&)) );
185 193
186 QTimer *timer = new QTimer( this ); 194 QTimer *timer = new QTimer( this );
187 195
188 connect( timer, SIGNAL(timeout()), 196 connect( timer, SIGNAL(timeout()),
189 this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors 197 this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors
190 timer->start( 1000*60*5, FALSE ); //update every 5min 198 timer->start( 1000*60*5, FALSE ); //update every 5min
191 199
192 selectedWidget = 0; 200 selectedWidget = 0;
193 201
194 timeMarker = new DateBookDayTimeMarker( this ); 202 timeMarker = new DateBookDayTimeMarker( this );
195 timeMarker->setTime( QTime::currentTime() ); 203 timeMarker->setTime( QTime::currentTime() );
204 rowStyle = -1; // initialize with bogus values
205}
206
207void DateBookDay::setJumpToCurTime( bool bJump )
208{
209 jumpToCurTime = bJump;
210}
211
212void DateBookDay::setRowStyle( int style )
213{
214 if (rowStyle != style) view->setRowStyle( style );
215 rowStyle = style;
196} 216}
197 217
198void DateBookDay::updateView( void ) 218void DateBookDay::updateView( void )
199{ 219{
200 timeMarker->setTime( QTime::currentTime() ); 220 timeMarker->setTime( QTime::currentTime() );
201 //need to find a way to update all DateBookDayWidgets 221 //need to find a way to update all DateBookDayWidgets
202} 222}
203 223
204void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) 224void DateBookDay::setSelectedWidget( DateBookDayWidget *w )
205{ 225{
206 selectedWidget = w; 226 selectedWidget = w;
207} 227}
208 228
209DateBookDayWidget * DateBookDay::getSelectedWidget( void ) 229DateBookDayWidget * DateBookDay::getSelectedWidget( void )
210{ 230{
211 return selectedWidget; 231 return selectedWidget;
212} 232}
213 233
214void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) 234void DateBookDay::selectedDates( QDateTime &start, QDateTime &end )
215{ 235{
216 start.setDate( currDate ); 236 start.setDate( currDate );
217 end.setDate( currDate ); 237 end.setDate( currDate );
218 238
219 int sh=99,eh=-1; 239 int sh=99,eh=-1;
220 240
221 int n = dayView()->numSelections(); 241 int n = dayView()->numSelections();
222 242
223 for (int i=0; i<n; i++) { 243 for (int i=0; i<n; i++) {
224 QTableSelection sel = dayView()->selection( i ); 244 QTableSelection sel = dayView()->selection( i );
225 sh = QMIN(sh,sel.topRow()); 245 sh = QMIN(sh,sel.topRow());
226 eh = QMAX(sh,sel.bottomRow()+1); 246 eh = QMAX(sh,sel.bottomRow()+1);
227 } 247 }
228 if (sh > 23 || eh < 1) { 248 if (sh > 23 || eh < 1) {
229 sh=8; 249 sh=8;
230 eh=9; 250 eh=9;
231 } 251 }
232 252
233 start.setTime( QTime( sh, 0, 0 ) ); 253 start.setTime( QTime( sh, 0, 0 ) );
234 end.setTime( QTime( eh, 0, 0 ) ); 254 end.setTime( QTime( eh, 0, 0 ) );
235} 255}
236 256
237void DateBookDay::setDate( int y, int m, int d ) 257void DateBookDay::setDate( int y, int m, int d )
238{ 258{
239 header->setDate( y, m, d ); 259 header->setDate( y, m, d );
240 260
241 selectedWidget = 0; 261 selectedWidget = 0;
242} 262}
243 263
244void DateBookDay::setDate( QDate d) 264void DateBookDay::setDate( QDate d)
245{ 265{
246 header->setDate( d.year(), d.month(), d.day() ); 266 header->setDate( d.year(), d.month(), d.day() );
247 267
248 selectedWidget = 0; 268 selectedWidget = 0;
249} 269}
250 270
251void DateBookDay::dateChanged( int y, int m, int d ) 271void DateBookDay::dateChanged( int y, int m, int d )
252{ 272{
253 QDate date( y, m, d ); 273 QDate date( y, m, d );
254 if ( currDate == date ) 274 if ( currDate == date )
255 return; 275 return;
256 currDate.setYMD( y, m, d ); 276 currDate.setYMD( y, m, d );
257 relayoutPage(); 277 relayoutPage();
258 dayView()->clearSelection(); 278 dayView()->clearSelection();
259 QTableSelection ts; 279 QTableSelection ts;
260 ts.init( startTime, 0 ); 280
261 ts.expandTo( startTime, 0 ); 281 if (jumpToCurTime && this->date() == QDate::currentDate())
282 {
283 ts.init( QTime::currentTime().hour(), 0);
284 ts.expandTo( QTime::currentTime().hour(), 0);
285 } else
286 {
287 ts.init( startTime, 0 );
288 ts.expandTo( startTime, 0 );
289 }
290
262 dayView()->addSelection( ts ); 291 dayView()->addSelection( ts );
263 292
264 selectedWidget = 0; 293 selectedWidget = 0;
265 294
266 if (this->date() == QDate::currentDate())
267 timeMarker->show(); else timeMarker->hide();
268
269} 295}
270 296
271void DateBookDay::redraw() 297void DateBookDay::redraw()
272{ 298{
273 if ( isUpdatesEnabled() ) 299 if ( isUpdatesEnabled() )
274 relayoutPage(); 300 relayoutPage();
275} 301}
276 302
277void DateBookDay::getEvents() 303void DateBookDay::getEvents()
278{ 304{
279 widgetList.clear(); 305 widgetList.clear();
280 306
281 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, 307 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate,
282 currDate ); 308 currDate );
283 QValueListIterator<EffectiveEvent> it; 309 QValueListIterator<EffectiveEvent> it;
284 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 310 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
285 DateBookDayWidget* w = new DateBookDayWidget( *it, this ); 311 DateBookDayWidget* w = new DateBookDayWidget( *it, this );
286 connect( w, SIGNAL( deleteMe( const Event & ) ), 312 connect( w, SIGNAL( deleteMe( const Event & ) ),
287 this, SIGNAL( removeEvent( const Event & ) ) ); 313 this, SIGNAL( removeEvent( const Event & ) ) );
288 connect( w, SIGNAL( editMe( const Event & ) ), 314 connect( w, SIGNAL( editMe( const Event & ) ),
289 this, SIGNAL( editEvent( const Event & ) ) ); 315 this, SIGNAL( editEvent( const Event & ) ) );
290 connect( w, SIGNAL( beamMe( const Event & ) ), 316 connect( w, SIGNAL( beamMe( const Event & ) ),
291 this, SIGNAL( beamEvent( const Event & ) ) ); 317 this, SIGNAL( beamEvent( const Event & ) ) );
292 widgetList.append( w ); 318 widgetList.append( w );
293 } 319 }
294 320
295} 321}
296 322
297static int place( const DateBookDayWidget *item, bool *used, int maxn ) 323static int place( const DateBookDayWidget *item, bool *used, int maxn )
298{ 324{
299 int place = 0; 325 int place = 0;
300 int start = item->event().start().hour(); 326 int start = item->event().start().hour();
301 QTime e = item->event().end(); 327 QTime e = item->event().end();
302 int end = e.hour(); 328 int end = e.hour();
303 if ( e.minute() < 5 ) 329 if ( e.minute() < 5 )
304 end--; 330 end--;
305 if ( end < start ) 331 if ( end < start )
306 end = start; 332 end = start;
307 while ( place < maxn ) { 333 while ( place < maxn ) {
308 bool free = TRUE; 334 bool free = TRUE;
309 int s = start; 335 int s = start;
310 while( s <= end ) { 336 while( s <= end ) {
311 if ( used[10*s+place] ) { 337 if ( used[10*s+place] ) {
312 free = FALSE; 338 free = FALSE;
313 break; 339 break;
314 } 340 }
315 s++; 341 s++;
316 } 342 }
317 if ( free ) break; 343 if ( free ) break;
318 place++; 344 place++;
319 } 345 }
320 if ( place == maxn ) { 346 if ( place == maxn ) {
321 return -1; 347 return -1;
322 } 348 }
323 while( start <= end ) { 349 while( start <= end ) {
324 used[10*start+place] = TRUE; 350 used[10*start+place] = TRUE;
325 start++; 351 start++;
326 } 352 }
327 return place; 353 return place;
328} 354}
329 355
330 356
331void DateBookDay::relayoutPage( bool fromResize ) 357void DateBookDay::relayoutPage( bool fromResize )
332{ 358{
333 setUpdatesEnabled( FALSE ); 359 setUpdatesEnabled( FALSE );
334 if ( !fromResize ) 360 if ( !fromResize )
335 getEvents(); // no need we already have them! 361 getEvents(); // no need we already have them!
336 362
337 widgetList.sort(); 363 widgetList.sort();
338 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning 364 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning
339 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view 365 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view
340 366
341 int wCount = widgetList.count(); 367 int wCount = widgetList.count();
342 int wid = view->columnWidth(0)-1; 368 int wid = view->columnWidth(0)-1;
343 int wd; 369 int wd;
344 int n = 1; 370 int n = 1;
345 371
346 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget 372 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget
347 373
348 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); 374 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++);
349 375
350 if ( wCount < 20 ) { 376 if ( wCount < 20 ) {
351 377
352 QArray<QRect> geometries(wCount); 378 QArray<QRect> geometries(wCount);
353 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector 379 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector
354 380
355 for ( int i = 0; i < wCount; i++) 381 for ( int i = 0; i < wCount; i++)
356 { 382 {
357 QValueList<int> intersectedWidgets; 383 QValueList<int> intersectedWidgets;
358 384
359 //find all widgets intersecting with widgetList.at(i) 385 //find all widgets intersecting with widgetList.at(i)
360 for ( int j = 0; j < wCount; j++) 386 for ( int j = 0; j < wCount; j++)
361 if (i != j) 387 if (i != j)
362 if (geometries[j].intersects(geometries[i])) 388 if (geometries[j].intersects(geometries[i]))
363 intersectedWidgets.append(j); 389 intersectedWidgets.append(j);
364 390
365 //for each of these intersecting widgets find out how many widgets are they intersecting with 391 //for each of these intersecting widgets find out how many widgets are they intersecting with
366 for ( uint j = 0; j < intersectedWidgets.count(); j++) 392 for ( uint j = 0; j < intersectedWidgets.count(); j++)
367 { 393 {
368 QArray<int> inter(wCount); 394 QArray<int> inter(wCount);
369 inter[j]=1; 395 inter[j]=1;
370 396
371 if (intersectedWidgets[j] != -1) 397 if (intersectedWidgets[j] != -1)
372 for ( uint k = j; k < intersectedWidgets.count(); k++) 398 for ( uint k = j; k < intersectedWidgets.count(); k++)
373 if (j != k && intersectedWidgets[k] != -1) 399 if (j != k && intersectedWidgets[k] != -1)
374 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) 400 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]]))
375 { 401 {
376 inter[j]++; 402 inter[j]++;
377 intersectedWidgets[k] = -1; 403 intersectedWidgets[k] = -1;
378 } 404 }
379 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; 405 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1;
380 } 406 }
381 407
382 if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; 408 if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++;
383 } 409 }
384 410
385 411
386 for ( int i = 0; i < wCount; i++) { 412 for ( int i = 0; i < wCount; i++) {
387 DateBookDayWidget *w = widgetList.at(i); 413 DateBookDayWidget *w = widgetList.at(i);
388 QRect geom = w->geometry(); 414 QRect geom = w->geometry();
389 415
390 geom.setX( 0 ); 416 geom.setX( 0 );
391 417
392 wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); 418 wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0);
393 419
394 geom.setWidth( wd ); 420 geom.setWidth( wd );
395 421
396 while ( intersects( w, geom ) ) { 422 while ( intersects( w, geom ) ) {
397 geom.moveBy( wd + 2 + 1, 0 ); 423 geom.moveBy( wd + 2 + 1, 0 );
398 } 424 }
399 w->setGeometry( geom ); 425 w->setGeometry( geom );
400 } 426 }
401 427
402 view->setContentsPos( 0, startTime * view->rowHeight(0) ); 428 if (jumpToCurTime && this->date() == QDate::currentDate())
429 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour
430 else
431 view->setContentsPos( 0, startTime * view->rowHeight(0) );
403 432
404 433
405 } else { 434 } else {
406 435
407 436
408 int hours[24]; 437 int hours[24];
409 memset( hours, 0, 24*sizeof( int ) ); 438 memset( hours, 0, 24*sizeof( int ) );
410 bool overFlow = FALSE; 439 bool overFlow = FALSE;
411 for ( int i = 0; i < wCount; i++ ) { 440 for ( int i = 0; i < wCount; i++ ) {
412 DateBookDayWidget *w = widgetList.at(i); 441 DateBookDayWidget *w = widgetList.at(i);
413 int start = w->event().start().hour(); 442 int start = w->event().start().hour();
414 QTime e = w->event().end(); 443 QTime e = w->event().end();
415 int end = e.hour(); 444 int end = e.hour();
416 if ( e.minute() < 5 ) 445 if ( e.minute() < 5 )
417 end--; 446 end--;
418 if ( end < start ) 447 if ( end < start )
419 end = start; 448 end = start;
420 while( start <= end ) { 449 while( start <= end ) {
421 hours[start]++; 450 hours[start]++;
422 if ( hours[start] >= 10 ) 451 if ( hours[start] >= 10 )
423 overFlow = TRUE; 452 overFlow = TRUE;
424 ++start; 453 ++start;
425 } 454 }
426 if ( overFlow ) 455 if ( overFlow )
427 break; 456 break;
428 } 457 }
429 for ( int i = 0; i < 24; i++ ) { 458 for ( int i = 0; i < 24; i++ ) {
430 n = QMAX( n, hours[i] ); 459 n = QMAX( n, hours[i] );
431 } 460 }
432 wid = ( view->columnWidth(0)-1 ) / n; 461 wid = ( view->columnWidth(0)-1 ) / n;
433 462
434 bool used[24*10]; 463 bool used[24*10];
435 memset( used, FALSE, 24*10*sizeof( bool ) ); 464 memset( used, FALSE, 24*10*sizeof( bool ) );
436 465
437 for ( int i = 0; i < wCount; i++ ) { 466 for ( int i = 0; i < wCount; i++ ) {
438 DateBookDayWidget *w = widgetList.at(i); 467 DateBookDayWidget *w = widgetList.at(i);
439 int xp = place( w, used, n ); 468 int xp = place( w, used, n );
440 if ( xp != -1 ) { 469 if ( xp != -1 ) {
441 QRect geom = w->geometry(); 470 QRect geom = w->geometry();
442 geom.setX( xp*(wid+2) ); 471 geom.setX( xp*(wid+2) );
443 geom.setWidth( wid ); 472 geom.setWidth( wid );
444 w->setGeometry( geom ); 473 w->setGeometry( geom );
445 } 474 }
446 } 475 }
447 view->setContentsPos( 0, startTime * view->rowHeight(0) ); 476
477 if (jumpToCurTime && this->date() == QDate::currentDate())
478 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour
479 else
480 view->setContentsPos( 0, startTime * view->rowHeight(0) );
448 } 481 }
449 482
450 timeMarker->setTime( QTime::currentTime() );//display timeMarker 483 timeMarker->setTime( QTime::currentTime() );//display timeMarker
451 timeMarker->raise(); //on top of all widgets 484 timeMarker->raise(); //on top of all widgets
485 if (this->date() == QDate::currentDate()) //only show timeMarker on current day
486 timeMarker->show(); else timeMarker->hide();
487
452 setUpdatesEnabled( TRUE ); 488 setUpdatesEnabled( TRUE );
453 return; 489 return;
454} 490}
455 491
456DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) 492DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom )
457{ 493{
458 int i = 0; 494 int i = 0;
459 DateBookDayWidget *w = widgetList.at(i); 495 DateBookDayWidget *w = widgetList.at(i);
460 int wCount = widgetList.count(); 496 int wCount = widgetList.count();
461 while ( i < wCount && w != item ) { 497 while ( i < wCount && w != item ) {
462 if ( w->geometry().intersects( geom ) ) { 498 if ( w->geometry().intersects( geom ) ) {
463 return w; 499 return w;
464 } 500 }
465 w = widgetList.at(++i); 501 w = widgetList.at(++i);
466 } 502 }
467 503
468 return 0; 504 return 0;
469} 505}
470 506
471 507
472QDate DateBookDay::date() const 508QDate DateBookDay::date() const
473{ 509{
474 return currDate; 510 return currDate;
475} 511}
476 512
477void DateBookDay::setStartViewTime( int startHere ) 513void DateBookDay::setStartViewTime( int startHere )
478{ 514{
479 startTime = startHere; 515 startTime = startHere;
480 dayView()->clearSelection(); 516 dayView()->clearSelection();
481 QTableSelection ts; 517 QTableSelection ts;
482 ts.init( startTime, 0 ); 518
483 ts.expandTo( startTime, 0 ); 519 if (jumpToCurTime && this->date() == QDate::currentDate())//this should probably be in datebook.cpp where it's called?
520 {
521 ts.init( QTime::currentTime().hour(), 0);
522 ts.expandTo( QTime::currentTime().hour(), 0);
523 } else
524 {
525 ts.init( startTime, 0 );
526 ts.expandTo( startTime, 0 );
527 }
528
484 dayView()->addSelection( ts ); 529 dayView()->addSelection( ts );
485} 530}
486 531
487int DateBookDay::startViewTime() const 532int DateBookDay::startViewTime() const
488{ 533{
489 return startTime; 534 return startTime;
490} 535}
491 536
492void DateBookDay::slotWeekChanged( bool bStartOnMonday ) 537void DateBookDay::slotWeekChanged( bool bStartOnMonday )
493{ 538{
494 header->setStartOfWeek( bStartOnMonday ); 539 header->setStartOfWeek( bStartOnMonday );
495 // redraw(); 540 // redraw();
496} 541}
497 542
498void DateBookDay::keyPressEvent(QKeyEvent *e) 543void DateBookDay::keyPressEvent(QKeyEvent *e)
499{ 544{
500 switch(e->key()) { 545 switch(e->key()) {
501 case Key_Up: 546 case Key_Up:
502 view->moveUp(); 547 view->moveUp();
503 break; 548 break;
504 case Key_Down: 549 case Key_Down:
505 view->moveDown(); 550 view->moveDown();
506 break; 551 break;
507 case Key_Left: 552 case Key_Left:
508 setDate(QDate(currDate).addDays(-1)); 553 setDate(QDate(currDate).addDays(-1));
509 break; 554 break;
510 case Key_Right: 555 case Key_Right:
511 setDate(QDate(currDate).addDays(1)); 556 setDate(QDate(currDate).addDays(1));
512 break; 557 break;
513 default: 558 default:
514 e->ignore(); 559 e->ignore();
515 } 560 }
516} 561}
517 562
518//=========================================================================== 563//===========================================================================
519 564
520DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, 565DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e,
521 DateBookDay *db ) 566 DateBookDay *db )
522 : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) 567 : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db )
523{ 568{
524 bool whichClock = db->dayView()->whichClock(); 569 bool whichClock = db->dayView()->whichClock();
525 570
526 // why would someone use "<"? Oh well, fix it up... 571 // why would someone use "<"? Oh well, fix it up...
527 // I wonder what other things may be messed up... 572 // I wonder what other things may be messed up...
528 QString strDesc = ev.description(); 573 QString strDesc = ev.description();
529 int where = strDesc.find( "<" ); 574 int where = strDesc.find( "<" );
530 while ( where != -1 ) { 575 while ( where != -1 ) {
531 strDesc.remove( where, 1 ); 576 strDesc.remove( where, 1 );
532 strDesc.insert( where, "&#60;" ); 577 strDesc.insert( where, "&#60;" );
533 where = strDesc.find( "<", where ); 578 where = strDesc.find( "<", where );
534 } 579 }
535 580
536 QString strCat; 581 QString strCat;
537 // ### Fix later... 582 // ### Fix later...
538// QString strCat = ev.category(); 583// QString strCat = ev.category();
539// where = strCat.find( "<" ); 584// where = strCat.find( "<" );
540// while ( where != -1 ) { 585// while ( where != -1 ) {
541 // strCat.remove( where, 1 ); 586 // strCat.remove( where, 1 );
542 // strCat.insert( where, "&#60;" ); 587 // strCat.insert( where, "&#60;" );
543 // where = strCat.find( "<", where ); 588 // where = strCat.find( "<", where );
544// } 589// }
545 590
546 QString strNote = ev.notes(); 591 QString strNote = ev.notes();
547 where = strNote.find( "<" ); 592 where = strNote.find( "<" );
548 while ( where != -1 ) { 593 while ( where != -1 ) {
549 strNote.remove( where, 1 ); 594 strNote.remove( where, 1 );
550 strNote.insert( where, "&#60;" ); 595 strNote.insert( where, "&#60;" );
551 where = strNote.find( "<", where ); 596 where = strNote.find( "<", where );
552 } 597 }
553 598
554 text = "<b>" + strDesc + "</b><br>" + "<i>" 599 text = "<b>" + strDesc + "</b><br>" + "<i>"
555 + strCat + "</i>" 600 + strCat + "</i>"
556 + "<br><b>" + tr("Start") + "</b>: "; 601 + "<br><b>" + tr("Start") + "</b>: ";
557 602
558 603
559 if ( e.startDate() != ev.date() ) { 604 if ( e.startDate() != ev.date() ) {
560 // multi-day event. Show start date 605 // multi-day event. Show start date
561 text += TimeString::longDateString( e.startDate() ); 606 text += TimeString::longDateString( e.startDate() );
562 } else { 607 } else {
563 // Show start time. 608 // Show start time.
564 text += TimeString::timeString( ev.start(), whichClock, FALSE ); 609 text += TimeString::timeString( ev.start(), whichClock, FALSE );
565 } 610 }
566 611
567 text += "<br><b>" + tr("End") + "</b>: "; 612 text += "<br><b>" + tr("End") + "</b>: ";
568 if ( e.endDate() != ev.date() ) { 613 if ( e.endDate() != ev.date() ) {
569 // multi-day event. Show end date 614 // multi-day event. Show end date
570 text += TimeString::longDateString( e.endDate() ); 615 text += TimeString::longDateString( e.endDate() );
571 } else { 616 } else {
572 // Show end time. 617 // Show end time.
573 text += TimeString::timeString( ev.end(), whichClock, FALSE ); 618 text += TimeString::timeString( ev.end(), whichClock, FALSE );
574 } 619 }
575 text += "<br><br>" + strNote; 620 text += "<br><br>" + strNote;
576 setBackgroundMode( PaletteBase ); 621 setBackgroundMode( PaletteBase );
577 622
578 QTime start = ev.start(); 623 QTime start = ev.start();
579 QTime end = ev.end(); 624 QTime end = ev.end();
580 int y = start.hour()*60+start.minute(); 625 int y = start.hour()*60+start.minute();
581 int h = end.hour()*60+end.minute()-y; 626 int h = end.hour()*60+end.minute()-y;
582 int rh = dateBook->dayView()->rowHeight(0); 627 int rh = dateBook->dayView()->rowHeight(0);
583 y = y*rh/60; 628 y = y*rh/60;
584 h = h*rh/60; 629 h = h*rh/60;
585 if ( h < 3 ) 630 if ( h < 3 )
586 h = 3; 631 h = 3;
587 geom.setY( y ); 632 geom.setY( y );
588 geom.setHeight( h ); 633 geom.setHeight( h );
589 geom.setX( 0 ); 634 geom.setX( 0 );
590 geom.setWidth(dateBook->dayView()->columnWidth(0)-1); 635 geom.setWidth(dateBook->dayView()->columnWidth(0)-1);
591 636
592} 637}
593 638
594DateBookDayWidget::~DateBookDayWidget() 639DateBookDayWidget::~DateBookDayWidget()
595{ 640{
596} 641}
597 642
598void DateBookDayWidget::paintEvent( QPaintEvent *e ) 643void DateBookDayWidget::paintEvent( QPaintEvent *e )
599{ 644{
600 QPainter p( this ); 645 QPainter p( this );
601 646
602 if (dateBook->getSelectedWidget() == this) 647 if (dateBook->getSelectedWidget() == this)
603 { 648 {
604 p.setBrush( QColor( 155, 240, 230 ) ); // selected item 649 p.setBrush( QColor( 155, 240, 230 ) ); // selected item
605 } else 650 } else
606 { 651 {
607 if (dateBook->date() == QDate::currentDate()) 652 if (dateBook->date() == QDate::currentDate())
608 { 653 {
609 QTime curTime = QTime::currentTime(); 654 QTime curTime = QTime::currentTime();
610 655
611 if (ev.end() < curTime) 656 if (ev.end() < curTime)
612 { 657 {
613 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive 658 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive
614 } else 659 } else
615 { 660 {
616 //change color in dependence of the time till the event starts 661 //change color in dependence of the time till the event starts
617 int duration = curTime.secsTo(ev.start()); 662 int duration = curTime.secsTo(ev.start());
618 if (duration < 0) duration = 0; 663 if (duration < 0) duration = 0;
619 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift 664 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift
620 665
621 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue 666 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue
622 } 667 }
623 } else 668 } else
624 { 669 {
625 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) 670 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date)
626 //perhaps make a distinction between future/past dates 671 //perhaps make a distinction between future/past dates
627 } 672 }
628 } 673 }
629 674
630 p.setPen( QColor(100, 100, 100) ); 675 p.setPen( QColor(100, 100, 100) );
631 p.drawRect(rect()); 676 p.drawRect(rect());
632 677
633 // p.drawRect(0,0, 5, height()); 678 // p.drawRect(0,0, 5, height());
634 679
635 int y = 0; 680 int y = 0;
636 int d = 0; 681 int d = 0;
637 682
638 if ( ev.event().hasAlarm() ) { 683 if ( ev.event().hasAlarm() ) {
639 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); 684 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) );
640 y = 20; 685 y = 20;
641 d = 20; 686 d = 20;
642 } 687 }
643 688
644 if ( ev.event().hasRepeat() ) { 689 if ( ev.event().hasRepeat() ) {
645 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); 690 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) );
646 d = 20; 691 d = 20;
647 } 692 }
648 693
649 QSimpleRichText rt( text, font() ); 694 QSimpleRichText rt( text, font() );
650 rt.setWidth( geom.width() - d - 6 ); 695 rt.setWidth( geom.width() - d - 6 );
651 rt.draw( &p, 7, 0, e->region(), colorGroup() ); 696 rt.draw( &p, 7, 0, e->region(), colorGroup() );
652} 697}
653 698
654void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) 699void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
655{ 700{
656 DateBookDayWidget *item; 701 DateBookDayWidget *item;
657 702
658 item = dateBook->getSelectedWidget(); 703 item = dateBook->getSelectedWidget();
659 if (item) item->update(); 704 if (item) item->update();
660 705
661 dateBook->setSelectedWidget(this); 706 dateBook->setSelectedWidget(this);
662 update(); 707 update();
663 dateBook->repaint(); 708 dateBook->repaint();
664 709
665 QPopupMenu m; 710 QPopupMenu m;
666 m.insertItem( tr( "Edit" ), 1 ); 711 m.insertItem( tr( "Edit" ), 1 );
667 m.insertItem( tr( "Delete" ), 2 ); 712 m.insertItem( tr( "Delete" ), 2 );
668 m.insertItem( tr( "Beam" ), 3 ); 713 m.insertItem( tr( "Beam" ), 3 );
669 int r = m.exec( e->globalPos() ); 714 int r = m.exec( e->globalPos() );
670 if ( r == 1 ) { 715 if ( r == 1 ) {
671 emit editMe( ev.event() ); 716 emit editMe( ev.event() );
672 } else if ( r == 2 ) { 717 } else if ( r == 2 ) {
673 emit deleteMe( ev.event() ); 718 emit deleteMe( ev.event() );
674 } else if ( r == 3 ) { 719 } else if ( r == 3 ) {
675 emit beamMe( ev.event() ); 720 emit beamMe( ev.event() );
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h
index db0f3b6..be7cc45 100644
--- a/core/pim/datebook/datebookday.h
+++ b/core/pim/datebook/datebookday.h
@@ -1,188 +1,194 @@
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 DATEBOOKDAY_H 20#ifndef DATEBOOKDAY_H
21#define DATEBOOKDAY_H 21#define DATEBOOKDAY_H
22 22
23#include <qpe/event.h> 23#include <qpe/event.h>
24 24
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qtable.h> 26#include <qtable.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qlist.h> 28#include <qlist.h>
29 29
30class DateBookDayHeader; 30class DateBookDayHeader;
31class DateBookDB; 31class DateBookDB;
32class QDateTime; 32class QDateTime;
33class QMouseEvent; 33class QMouseEvent;
34class QPaintEvent; 34class QPaintEvent;
35class QResizeEvent; 35class QResizeEvent;
36 36
37class DateBookDayView : public QTable 37class DateBookDayView : public QTable
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40public: 40public:
41 DateBookDayView( bool hourClock, QWidget *parent, const char *name ); 41 DateBookDayView( bool hourClock, QWidget *parent, const char *name );
42 bool whichClock() const; 42 bool whichClock() const;
43
44 void setRowStyle( int style );
43 45
44public slots: 46public slots:
45 void moveUp(); 47 void moveUp();
46 void moveDown(); 48 void moveDown();
47 49
48signals: 50signals:
49 void sigColWidthChanged(); 51 void sigColWidthChanged();
50 void sigCapturedKey( const QString &txt ); 52 void sigCapturedKey( const QString &txt );
51protected slots: 53protected slots:
52 void slotChangeClock( bool ); 54 void slotChangeClock( bool );
53protected: 55protected:
54 virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); 56 virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected );
55 virtual void paintFocus( QPainter *p, const QRect &cr ); 57 virtual void paintFocus( QPainter *p, const QRect &cr );
56 58
57 virtual void resizeEvent( QResizeEvent *e ); 59 virtual void resizeEvent( QResizeEvent *e );
58 void keyPressEvent( QKeyEvent *e ); 60 void keyPressEvent( QKeyEvent *e );
59 void initHeader(); 61 void initHeader();
60private: 62private:
61 bool ampm; 63 bool ampm;
62}; 64};
63 65
64class DateBookDay; 66class DateBookDay;
65class DateBookDayWidget : public QWidget 67class DateBookDayWidget : public QWidget
66{ 68{
67 Q_OBJECT 69 Q_OBJECT
68 70
69public: 71public:
70 DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ); 72 DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db );
71 ~DateBookDayWidget(); 73 ~DateBookDayWidget();
72 74
73 const QRect &geometry() { return geom; } 75 const QRect &geometry() { return geom; }
74 void setGeometry( const QRect &r ); 76 void setGeometry( const QRect &r );
75 77
76 const EffectiveEvent &event() const { return ev; } 78 const EffectiveEvent &event() const { return ev; }
77 79
78signals: 80signals:
79 void deleteMe( const Event &e ); 81 void deleteMe( const Event &e );
80 void editMe( const Event &e ); 82 void editMe( const Event &e );
81 void beamMe( const Event &e ); 83 void beamMe( const Event &e );
82 84
83protected: 85protected:
84 void paintEvent( QPaintEvent *e ); 86 void paintEvent( QPaintEvent *e );
85 void mousePressEvent( QMouseEvent *e ); 87 void mousePressEvent( QMouseEvent *e );
86 88
87private: 89private:
88 const EffectiveEvent ev; 90 const EffectiveEvent ev;
89 DateBookDay *dateBook; 91 DateBookDay *dateBook;
90 QString text; 92 QString text;
91 QRect geom; 93 QRect geom;
92}; 94};
93 95
94//Marker for current time in the dayview 96//Marker for current time in the dayview
95class DateBookDayTimeMarker : public QWidget 97class DateBookDayTimeMarker : public QWidget
96{ 98{
97 Q_OBJECT 99 Q_OBJECT
98 100
99public: 101public:
100 DateBookDayTimeMarker( DateBookDay *db ); 102 DateBookDayTimeMarker( DateBookDay *db );
101 ~DateBookDayTimeMarker(); 103 ~DateBookDayTimeMarker();
102 104
103 const QRect &geometry() { return geom; } 105 const QRect &geometry() { return geom; }
104 void setGeometry( const QRect &r ); 106 void setGeometry( const QRect &r );
105 void setTime( const QTime &t ); 107 void setTime( const QTime &t );
106 108
107signals: 109signals:
108 110
109protected: 111protected:
110 void paintEvent( QPaintEvent *e ); 112 void paintEvent( QPaintEvent *e );
111 113
112private: 114private:
113 QRect geom; 115 QRect geom;
114 QTime time; 116 QTime time;
115 DateBookDay *dateBook; 117 DateBookDay *dateBook;
116}; 118};
117 119
118//reimplemented the compareItems function so that it sorts DayWidgets by geometry heights 120//reimplemented the compareItems function so that it sorts DayWidgets by geometry heights
119class WidgetListClass : public QList<DateBookDayWidget> 121class WidgetListClass : public QList<DateBookDayWidget>
120 { 122 {
121 private: 123 private:
122 124
123 int compareItems( QCollection::Item s1, QCollection::Item s2 ) 125 int compareItems( QCollection::Item s1, QCollection::Item s2 )
124 { 126 {
125 //hmm, don't punish me for that ;) 127 //hmm, don't punish me for that ;)
126 if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) 128 if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height())
127 { 129 {
128 return -1; 130 return -1;
129 } else 131 } else
130 { 132 {
131 return 1; 133 return 1;
132 } 134 }
133 } 135 }
134 136
135 137
136}; 138};
137 139
138class DateBookDay : public QVBox 140class DateBookDay : public QVBox
139{ 141{
140 Q_OBJECT 142 Q_OBJECT
141 143
142public: 144public:
143 DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, 145 DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,
144 QWidget *parent, const char *name ); 146 QWidget *parent, const char *name );
145 void selectedDates( QDateTime &start, QDateTime &end ); 147 void selectedDates( QDateTime &start, QDateTime &end );
146 QDate date() const; 148 QDate date() const;
147 DateBookDayView *dayView() const { return view; } 149 DateBookDayView *dayView() const { return view; }
148 void setStartViewTime( int startHere ); 150 void setStartViewTime( int startHere );
149 int startViewTime() const; 151 int startViewTime() const;
150 void setSelectedWidget( DateBookDayWidget * ); 152 void setSelectedWidget( DateBookDayWidget * );
151 DateBookDayWidget * getSelectedWidget( void ); 153 DateBookDayWidget * getSelectedWidget( void );
154 void setJumpToCurTime( bool bJump );
155 void setRowStyle( int style );
152 156
153public slots: 157public slots:
154 void setDate( int y, int m, int d ); 158 void setDate( int y, int m, int d );
155 void setDate( QDate ); 159 void setDate( QDate );
156 void redraw(); 160 void redraw();
157 void slotWeekChanged( bool bStartOnMonday ); 161 void slotWeekChanged( bool bStartOnMonday );
158 void updateView();//updates TimeMarker and DayWidget-colors 162 void updateView();//updates TimeMarker and DayWidget-colors
159 163
160signals: 164signals:
161 void removeEvent( const Event& ); 165 void removeEvent( const Event& );
162 void editEvent( const Event& ); 166 void editEvent( const Event& );
163 void beamEvent( const Event& ); 167 void beamEvent( const Event& );
164 void newEvent(); 168 void newEvent();
165 void sigNewEvent( const QString & ); 169 void sigNewEvent( const QString & );
166 170
167protected slots: 171protected slots:
168 void keyPressEvent(QKeyEvent *); 172 void keyPressEvent(QKeyEvent *);
169 173
170private slots: 174private slots:
171 void dateChanged( int y, int m, int d ); 175 void dateChanged( int y, int m, int d );
172 void slotColWidthChanged() { relayoutPage(); }; 176 void slotColWidthChanged() { relayoutPage(); };
173 177
174private: 178private:
175 void getEvents(); 179 void getEvents();
176 void relayoutPage( bool fromResize = false ); 180 void relayoutPage( bool fromResize = false );
177 DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom ); 181 DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom );
178 QDate currDate; 182 QDate currDate;
179 DateBookDayView *view; 183 DateBookDayView *view;
180 DateBookDayHeader *header; 184 DateBookDayHeader *header;
181 DateBookDB *db; 185 DateBookDB *db;
182 WidgetListClass widgetList;//reimplemented QList for sorting widgets by height 186 WidgetListClass widgetList;//reimplemented QList for sorting widgets by height
183 int startTime; 187 int startTime;
188 bool jumpToCurTime;//should we jump to current time in dayview?
189 int rowStyle;
184 DateBookDayWidget *selectedWidget; //actual selected widget (obviously) 190 DateBookDayWidget *selectedWidget; //actual selected widget (obviously)
185 DateBookDayTimeMarker *timeMarker;//marker for current time 191 DateBookDayTimeMarker *timeMarker;//marker for current time
186}; 192};
187 193
188#endif 194#endif
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp
index c5d8ac1..49fcd17 100644
--- a/core/pim/datebook/datebooksettings.cpp
+++ b/core/pim/datebook/datebooksettings.cpp
@@ -1,135 +1,155 @@
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 20
21#include "datebooksettings.h" 21#include "datebooksettings.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25#include <qspinbox.h> 25#include <qspinbox.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qcombobox.h> 27#include <qcombobox.h>
28 28
29DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, 29DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent,
30 const char *name, bool modal, WFlags fl ) 30 const char *name, bool modal, WFlags fl )
31 : DateBookSettingsBase( parent, name, modal, fl ), 31 : DateBookSettingsBase( parent, name, modal, fl ),
32 ampm( whichClock ) 32 ampm( whichClock )
33{ 33{
34 init(); 34 init();
35 QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), 35 QObject::connect( qApp, SIGNAL( clockChanged( bool ) ),
36 this, SLOT( slotChangeClock( bool ) ) ); 36 this, SLOT( slotChangeClock( bool ) ) );
37} 37}
38 38
39DateBookSettings::~DateBookSettings() 39DateBookSettings::~DateBookSettings()
40{ 40{
41} 41}
42 42
43void DateBookSettings::setStartTime( int newStartViewTime ) 43void DateBookSettings::setStartTime( int newStartViewTime )
44{ 44{
45 if ( ampm ) { 45 if ( ampm ) {
46 if ( newStartViewTime >= 12 ) { 46 if ( newStartViewTime >= 12 ) {
47 newStartViewTime %= 12; 47 newStartViewTime %= 12;
48 if ( newStartViewTime == 0 ) 48 if ( newStartViewTime == 0 )
49 newStartViewTime = 12; 49 newStartViewTime = 12;
50 spinStart->setSuffix( tr(":00 PM") ); 50 spinStart->setSuffix( tr(":00 PM") );
51 } 51 }
52 else if ( newStartViewTime == 0 ) { 52 else if ( newStartViewTime == 0 ) {
53 newStartViewTime = 12; 53 newStartViewTime = 12;
54 spinStart->setSuffix( tr(":00 AM") ); 54 spinStart->setSuffix( tr(":00 AM") );
55 } 55 }
56 oldtime = newStartViewTime; 56 oldtime = newStartViewTime;
57 } 57 }
58 spinStart->setValue( newStartViewTime ); 58 spinStart->setValue( newStartViewTime );
59} 59}
60 60
61int DateBookSettings::startTime() const 61int DateBookSettings::startTime() const
62{ 62{
63 int returnMe = spinStart->value(); 63 int returnMe = spinStart->value();
64 if ( ampm ) { 64 if ( ampm ) {
65 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) 65 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) )
66 returnMe += 12; 66 returnMe += 12;
67 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) 67 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE))
68 returnMe = 0; 68 returnMe = 0;
69 } 69 }
70 return returnMe; 70 return returnMe;
71} 71}
72 72
73 73
74void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) 74void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime )
75{ 75{
76 chkAlarmPreset->setChecked( bAlarm ); 76 chkAlarmPreset->setChecked( bAlarm );
77 if ( presetTime >=5 ) 77 if ( presetTime >=5 )
78 spinPreset->setValue( presetTime ); 78 spinPreset->setValue( presetTime );
79} 79}
80 80
81bool DateBookSettings::alarmPreset() const 81bool DateBookSettings::alarmPreset() const
82{ 82{
83 return chkAlarmPreset->isChecked(); 83 return chkAlarmPreset->isChecked();
84} 84}
85 85
86int DateBookSettings::presetTime() const 86int DateBookSettings::presetTime() const
87{ 87{
88 return spinPreset->value(); 88 return spinPreset->value();
89} 89}
90 90
91 91
92void DateBookSettings::slot12Hour( int i ) 92void DateBookSettings::slot12Hour( int i )
93{ 93{
94 if ( ampm ) { 94 if ( ampm ) {
95 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { 95 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) {
96 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 96 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
97 spinStart->setSuffix( tr(":00 PM") ); 97 spinStart->setSuffix( tr(":00 PM") );
98 } else { 98 } else {
99 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 99 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
100 spinStart->setSuffix( tr(":00 AM") ); 100 spinStart->setSuffix( tr(":00 AM") );
101 } 101 }
102 oldtime = i; 102 oldtime = i;
103 } 103 }
104} 104}
105 105
106void DateBookSettings::init() 106void DateBookSettings::init()
107{ 107{
108 if ( ampm ) { 108 if ( ampm ) {
109 spinStart->setMinValue( 1 ); 109 spinStart->setMinValue( 1 );
110 spinStart->setMaxValue( 12 ); 110 spinStart->setMaxValue( 12 );
111 spinStart->setValue( 12 ); 111 spinStart->setValue( 12 );
112 spinStart->setSuffix( tr(":00 AM") ); 112 spinStart->setSuffix( tr(":00 AM") );
113 oldtime = 12; 113 oldtime = 12;
114 } else { 114 } else {
115 spinStart->setMinValue( 0 ); 115 spinStart->setMinValue( 0 );
116 spinStart->setMaxValue( 23 ); 116 spinStart->setMaxValue( 23 );
117 spinStart->setSuffix( tr(":00") ); 117 spinStart->setSuffix( tr(":00") );
118 } 118 }
119} 119}
120 120
121void DateBookSettings::slotChangeClock( bool whichClock ) 121void DateBookSettings::slotChangeClock( bool whichClock )
122{ 122{
123 int saveMe; 123 int saveMe;
124 saveMe = spinStart->value(); 124 saveMe = spinStart->value();
125 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { 125 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) {
126 if ( saveMe == 12 ) 126 if ( saveMe == 12 )
127 saveMe = 0; 127 saveMe = 0;
128 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { 128 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) {
129 if ( saveMe != 12 ) 129 if ( saveMe != 12 )
130 saveMe += 12; 130 saveMe += 12;
131 } 131 }
132 ampm = whichClock; 132 ampm = whichClock;
133 init(); 133 init();
134 setStartTime( saveMe ); 134 setStartTime( saveMe );
135} 135}
136
137void DateBookSettings::setJumpToCurTime( bool bJump )
138{
139 chkJumpToCurTime->setChecked( bJump );
140}
141
142bool DateBookSettings::jumpToCurTime() const
143{
144 return chkJumpToCurTime->isChecked();
145}
146
147void DateBookSettings::setRowStyle( int style )
148{
149 comboRowStyle->setCurrentItem( style );
150}
151
152int DateBookSettings::rowStyle() const
153{
154 return comboRowStyle->currentItem();
155}
diff --git a/core/pim/datebook/datebooksettings.h b/core/pim/datebook/datebooksettings.h
index ee9f39c..90a07f9 100644
--- a/core/pim/datebook/datebooksettings.h
+++ b/core/pim/datebook/datebooksettings.h
@@ -1,48 +1,53 @@
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 20
21#ifndef DATEBOOKSETTINGS_H 21#ifndef DATEBOOKSETTINGS_H
22#define DATEBOOKSETTINGS_H 22#define DATEBOOKSETTINGS_H
23#include "datebooksettingsbase.h" 23#include "datebooksettingsbase.h"
24 24
25class DateBookSettings : public DateBookSettingsBase 25class DateBookSettings : public DateBookSettingsBase
26{ 26{
27public: 27public:
28 DateBookSettings( bool whichClock, QWidget *parent = 0, 28 DateBookSettings( bool whichClock, QWidget *parent = 0,
29 const char *name = 0, bool modal = TRUE, WFlags = 0 ); 29 const char *name = 0, bool modal = TRUE, WFlags = 0 );
30 ~DateBookSettings(); 30 ~DateBookSettings();
31 void setStartTime( int newStartViewTime ); 31 void setStartTime( int newStartViewTime );
32 int startTime() const; 32 int startTime() const;
33 void setAlarmPreset( bool bAlarm, int presetTime ); 33 void setAlarmPreset( bool bAlarm, int presetTime );
34 bool alarmPreset() const; 34 bool alarmPreset() const;
35 int presetTime() const; 35 int presetTime() const;
36 void setAlarmType( int alarmType ); 36 void setAlarmType( int alarmType );
37 int alarmType() const; 37 int alarmType() const;
38 38
39 void setJumpToCurTime( bool bJump );
40 bool jumpToCurTime() const;
41 void setRowStyle( int style );
42 int rowStyle() const;
43
39private slots: 44private slots:
40 void slot12Hour( int ); 45 void slot12Hour( int );
41 void slotChangeClock( bool ); 46 void slotChangeClock( bool );
42 47
43private: 48private:
44 void init(); 49 void init();
45 bool ampm; 50 bool ampm;
46 int oldtime; 51 int oldtime;
47}; 52};
48#endif 53#endif
diff --git a/core/pim/datebook/datebooksettingsbase.ui b/core/pim/datebook/datebooksettingsbase.ui
index 0f40773..816a441 100644
--- a/core/pim/datebook/datebooksettingsbase.ui
+++ b/core/pim/datebook/datebooksettingsbase.ui
@@ -1,232 +1,399 @@
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>232</width> 35 <width>220</width>
36 <height>290</height> 36 <height>290</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 <vbox> 49 <grid>
50 <property stdset="1"> 50 <property stdset="1">
51 <name>margin</name> 51 <name>margin</name>
52 <number>5</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>1</number> 56 <number>6</number>
57 </property> 57 </property>
58 <widget> 58 <widget row="0" column="0" >
59 <class>QGroupBox</class> 59 <class>QGroupBox</class>
60 <property stdset="1"> 60 <property stdset="1">
61 <name>name</name> 61 <name>name</name>
62 <cstring>fraStart</cstring> 62 <cstring>fraStart</cstring>
63 </property> 63 </property>
64 <property stdset="1"> 64 <property stdset="1">
65 <name>frameShape</name> 65 <name>frameShape</name>
66 <enum>Box</enum> 66 <enum>Box</enum>
67 </property> 67 </property>
68 <property stdset="1"> 68 <property stdset="1">
69 <name>frameShadow</name> 69 <name>frameShadow</name>
70 <enum>Sunken</enum> 70 <enum>Sunken</enum>
71 </property> 71 </property>
72 <property stdset="1"> 72 <property stdset="1">
73 <name>title</name> 73 <name>title</name>
74 <string>Start viewing events</string> 74 <string>Start viewing events</string>
75 </property> 75 </property>
76 <vbox> 76 <widget>
77 <class>QLayoutWidget</class>
77 <property stdset="1"> 78 <property stdset="1">
78 <name>margin</name> 79 <name>name</name>
79 <number>11</number> 80 <cstring>Layout6</cstring>
80 </property> 81 </property>
81 <property stdset="1"> 82 <property stdset="1">
82 <name>spacing</name> 83 <name>geometry</name>
83 <number>6</number> 84 <rect>
85 <x>3</x>
86 <y>21</y>
87 <width>210</width>
88 <height>53</height>
89 </rect>
84 </property> 90 </property>
85 <widget> 91 <grid>
86 <class>QLayoutWidget</class>
87 <property stdset="1"> 92 <property stdset="1">
88 <name>name</name> 93 <name>margin</name>
89 <cstring>Layout1</cstring> 94 <number>0</number>
90 </property> 95 </property>
91 <hbox> 96 <property stdset="1">
97 <name>spacing</name>
98 <number>6</number>
99 </property>
100 <spacer row="1" column="0" >
101 <property>
102 <name>name</name>
103 <cstring>Spacer1</cstring>
104 </property>
92 <property stdset="1"> 105 <property stdset="1">
93 <name>margin</name> 106 <name>orientation</name>
94 <number>0</number> 107 <enum>Vertical</enum>
95 </property> 108 </property>
96 <property stdset="1"> 109 <property stdset="1">
97 <name>spacing</name> 110 <name>sizeType</name>
98 <number>6</number> 111 <enum>Expanding</enum>
99 </property> 112 </property>
100 <widget> 113 <property>
101 <class>QLabel</class> 114 <name>sizeHint</name>
102 <property stdset="1"> 115 <size>
103 <name>name</name> 116 <width>20</width>
104 <cstring>lblStartTime</cstring> 117 <height>20</height>
105 </property> 118 </size>
106 <property stdset="1"> 119 </property>
107 <name>text</name> 120 </spacer>
108 <string>Start Time:</string> 121 <widget row="0" column="0" >
109 </property> 122 <class>QLayoutWidget</class>
110 </widget> 123 <property stdset="1">
111 <widget> 124 <name>name</name>
112 <class>QSpinBox</class> 125 <cstring>Layout1</cstring>
113 <property stdset="1"> 126 </property>
114 <name>name</name> 127 <hbox>
115 <cstring>spinStart</cstring>
116 </property>
117 <property stdset="1">
118 <name>suffix</name>
119 <string>:00</string>
120 </property>
121 <property stdset="1"> 128 <property stdset="1">
122 <name>wrapping</name> 129 <name>margin</name>
123 <bool>true</bool> 130 <number>0</number>
124 </property> 131 </property>
125 <property stdset="1"> 132 <property stdset="1">
126 <name>maxValue</name> 133 <name>spacing</name>
127 <number>23</number> 134 <number>6</number>
128 </property> 135 </property>
129 </widget> 136 <widget>
130 </hbox> 137 <class>QLabel</class>
131 </widget> 138 <property stdset="1">
132 </vbox> 139 <name>name</name>
140 <cstring>lblStartTime</cstring>
141 </property>
142 <property stdset="1">
143 <name>text</name>
144 <string>Start Time:</string>
145 </property>
146 </widget>
147 <widget>
148 <class>QSpinBox</class>
149 <property stdset="1">
150 <name>name</name>
151 <cstring>spinStart</cstring>
152 </property>
153 <property stdset="1">
154 <name>suffix</name>
155 <string>:00</string>
156 </property>
157 <property stdset="1">
158 <name>wrapping</name>
159 <bool>true</bool>
160 </property>
161 <property stdset="1">
162 <name>maxValue</name>
163 <number>23</number>
164 </property>
165 </widget>
166 </hbox>
167 </widget>
168 </grid>
169 </widget>
133 </widget> 170 </widget>
134 <widget> 171 <widget row="1" column="0" >
135 <class>QGroupBox</class> 172 <class>QGroupBox</class>
136 <property stdset="1"> 173 <property stdset="1">
137 <name>name</name> 174 <name>name</name>
138 <cstring>fraAlarm</cstring> 175 <cstring>fraAlarm</cstring>
139 </property> 176 </property>
140 <property stdset="1"> 177 <property stdset="1">
141 <name>title</name> 178 <name>title</name>
142 <string>Alarm Settings</string> 179 <string>Alarm Settings</string>
143 </property> 180 </property>
144 <vbox> 181 <widget>
182 <class>QLayoutWidget</class>
145 <property stdset="1"> 183 <property stdset="1">
146 <name>margin</name> 184 <name>name</name>
147 <number>11</number> 185 <cstring>Layout4</cstring>
148 </property> 186 </property>
149 <property stdset="1"> 187 <property stdset="1">
150 <name>spacing</name> 188 <name>geometry</name>
151 <number>6</number> 189 <rect>
190 <x>10</x>
191 <y>20</y>
192 <width>200</width>
193 <height>53</height>
194 </rect>
152 </property> 195 </property>
153 <widget> 196 <grid>
154 <class>QLayoutWidget</class> 197 <property stdset="1">
198 <name>margin</name>
199 <number>0</number>
200 </property>
155 <property stdset="1"> 201 <property stdset="1">
156 <name>name</name> 202 <name>spacing</name>
157 <cstring>Layout6</cstring> 203 <number>6</number>
158 </property> 204 </property>
159 <hbox> 205 <spacer row="1" column="0" >
206 <property>
207 <name>name</name>
208 <cstring>Spacer2</cstring>
209 </property>
160 <property stdset="1"> 210 <property stdset="1">
161 <name>margin</name> 211 <name>orientation</name>
162 <number>0</number> 212 <enum>Vertical</enum>
163 </property> 213 </property>
164 <property stdset="1"> 214 <property stdset="1">
165 <name>spacing</name> 215 <name>sizeType</name>
166 <number>6</number> 216 <enum>Expanding</enum>
167 </property> 217 </property>
168 <widget> 218 <property>
169 <class>QCheckBox</class> 219 <name>sizeHint</name>
170 <property stdset="1"> 220 <size>
171 <name>name</name> 221 <width>20</width>
172 <cstring>chkAlarmPreset</cstring> 222 <height>20</height>
173 </property> 223 </size>
174 <property stdset="1"> 224 </property>
175 <name>text</name> 225 </spacer>
176 <string>Alarm Preset</string> 226 <widget row="0" column="0" >
177 </property> 227 <class>QLayoutWidget</class>
178 </widget> 228 <property stdset="1">
179 <widget> 229 <name>name</name>
180 <class>QSpinBox</class> 230 <cstring>Layout6</cstring>
181 <property stdset="1"> 231 </property>
182 <name>name</name> 232 <hbox>
183 <cstring>spinPreset</cstring>
184 </property>
185 <property stdset="1">
186 <name>enabled</name>
187 <bool>false</bool>
188 </property>
189 <property stdset="1"> 233 <property stdset="1">
190 <name>suffix</name> 234 <name>margin</name>
191 <string> minutes</string> 235 <number>0</number>
192 </property> 236 </property>
193 <property stdset="1"> 237 <property stdset="1">
194 <name>maxValue</name> 238 <name>spacing</name>
195 <number>180</number> 239 <number>6</number>
196 </property> 240 </property>
197 <property stdset="1"> 241 <widget>
198 <name>minValue</name> 242 <class>QCheckBox</class>
199 <number>0</number> 243 <property stdset="1">
244 <name>name</name>
245 <cstring>chkAlarmPreset</cstring>
246 </property>
247 <property stdset="1">
248 <name>text</name>
249 <string>Alarm Preset</string>
250 </property>
251 </widget>
252 <widget>
253 <class>QSpinBox</class>
254 <property stdset="1">
255 <name>name</name>
256 <cstring>spinPreset</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>
278 <property stdset="1">
279 <name>value</name>
280 <number>5</number>
281 </property>
282 </widget>
283 </hbox>
284 </widget>
285 </grid>
286 </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>
299 <class>QLayoutWidget</class>
300 <property stdset="1">
301 <name>name</name>
302 <cstring>Layout5</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>
313 <hbox>
314 <property stdset="1">
315 <name>margin</name>
316 <number>0</number>
317 </property>
318 <property stdset="1">
319 <name>spacing</name>
320 <number>6</number>
321 </property>
322 <widget>
323 <class>QLabel</class>
324 <property stdset="1">
325 <name>name</name>
326 <cstring>TextLabel1</cstring>
327 </property>
328 <property stdset="1">
329 <name>text</name>
330 <string>Row style:</string>
331 </property>
332 </widget>
333 <widget>
334 <class>QComboBox</class>
335 <item>
336 <property>
337 <name>text</name>
338 <string>Default</string>
200 </property> 339 </property>
201 <property stdset="1"> 340 </item>
202 <name>lineStep</name> 341 <item>
203 <number>5</number> 342 <property>
343 <name>text</name>
344 <string>Medium</string>
204 </property> 345 </property>
205 <property stdset="1"> 346 </item>
206 <name>value</name> 347 <item>
207 <number>5</number> 348 <property>
349 <name>text</name>
350 <string>Large</string>
208 </property> 351 </property>
209 </widget> 352 </item>
210 </hbox> 353 <property stdset="1">
211 </widget> 354 <name>name</name>
212 </vbox> 355 <cstring>comboRowStyle</cstring>
356 </property>
357 </widget>
358 </hbox>
359 </widget>
360 <widget>
361 <class>QCheckBox</class>
362 <property stdset="1">
363 <name>name</name>
364 <cstring>chkJumpToCurTime</cstring>
365 </property>
366 <property stdset="1">
367 <name>geometry</name>
368 <rect>
369 <x>10</x>
370 <y>20</y>
371 <width>200</width>
372 <height>20</height>
373 </rect>
374 </property>
375 <property stdset="1">
376 <name>text</name>
377 <string>Jump to current time (dayview)</string>
378 </property>
379 </widget>
213 </widget> 380 </widget>
214 </vbox> 381 </grid>
215</widget> 382</widget>
216<connections> 383<connections>
217 <connection> 384 <connection>
218 <sender>chkAlarmPreset</sender> 385 <sender>chkAlarmPreset</sender>
219 <signal>toggled(bool)</signal> 386 <signal>toggled(bool)</signal>
220 <receiver>spinPreset</receiver> 387 <receiver>spinPreset</receiver>
221 <slot>setEnabled(bool)</slot> 388 <slot>setEnabled(bool)</slot>
222 </connection> 389 </connection>
223 <connection> 390 <connection>
224 <sender>spinStart</sender> 391 <sender>spinStart</sender>
225 <signal>valueChanged(int)</signal> 392 <signal>valueChanged(int)</signal>
226 <receiver>DateBookSettingsBase</receiver> 393 <receiver>DateBookSettingsBase</receiver>
227 <slot>slot12Hour( int )</slot> 394 <slot>slot12Hour( int )</slot>
228 </connection> 395 </connection>
229 <slot access="public">slotChangeClock( bool )</slot> 396 <slot access="public">slotChangeClock( bool )</slot>
230 <slot access="public">slot12Hour( int )</slot> 397 <slot access="public">slot12Hour( int )</slot>
231</connections> 398</connections>
232</UI> 399</UI>
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 8e88377..58a9c53 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,373 +1,373 @@
1#include "datebookweeklst.h" 1#include "datebookweeklst.h"
2 2
3#include "datebookweekheaderimpl.h" 3#include "datebookweekheaderimpl.h"
4 4
5#include <qpe/calendar.h> 5#include <qpe/calendar.h>
6#include <qpe/datebookdb.h> 6#include <qpe/datebookdb.h>
7#include <qpe/event.h> 7#include <qpe/event.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/timestring.h> 9#include <qpe/timestring.h>
10#include <qpe/datebookmonth.h> 10#include <qpe/datebookmonth.h>
11#include <qpe/config.h> 11#include <qpe/config.h>
12 12
13#include <qdatetime.h> 13#include <qdatetime.h>
14#include <qheader.h> 14#include <qheader.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qlayout.h> 16#include <qlayout.h>
17#include <qpainter.h> 17#include <qpainter.h>
18#include <qpopupmenu.h> 18#include <qpopupmenu.h>
19#include <qtimer.h> 19#include <qtimer.h>
20#include <qstyle.h> 20#include <qstyle.h>
21#include <qtoolbutton.h> 21#include <qtoolbutton.h>
22#include <qvbox.h> 22#include <qvbox.h>
23#include <qsizepolicy.h> 23#include <qsizepolicy.h>
24#include <qabstractlayout.h> 24#include <qabstractlayout.h>
25#include <qtl.h> 25#include <qtl.h>
26 26
27bool calcWeek(const QDate &d, int &week, int &year, 27bool calcWeek(const QDate &d, int &week, int &year,
28 bool startOnMonday = false); 28 bool startOnMonday = false);
29 29
30DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, 30DateBookWeekLstHeader::DateBookWeekLstHeader(bool /*onM*/, QWidget* parent,
31 const char* name, WFlags fl) 31 const char* name, WFlags fl)
32 : DateBookWeekLstHeaderBase(parent, name, fl) 32 : DateBookWeekLstHeaderBase(parent, name, fl)
33{ 33{
34 setBackgroundMode( PaletteButton ); 34 setBackgroundMode( PaletteButton );
35 labelDate->setBackgroundMode( PaletteButton ); 35 labelDate->setBackgroundMode( PaletteButton );
36 labelWeek->setBackgroundMode( PaletteButton ); 36 labelWeek->setBackgroundMode( PaletteButton );
37 forward->setBackgroundMode( PaletteButton ); 37 forward->setBackgroundMode( PaletteButton );
38 back->setBackgroundMode( PaletteButton ); 38 back->setBackgroundMode( PaletteButton );
39 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 39 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
40 DateBookWeekLstHeaderBaseLayout->setMargin(0); 40 DateBookWeekLstHeaderBaseLayout->setMargin(0);
41 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 41 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
42 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 42 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
43 43
44 connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); 44 connect(back, SIGNAL(clicked()), this, SLOT(prevWeek()));
45 connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); 45 connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek()));
46 connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); 46 connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate()));
47 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 47 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
48 onMonday=onM; 48 onMonday=onM;
49} 49}
50DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 50DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
51void DateBookWeekLstHeader::setDate(const QDate &d) { 51void DateBookWeekLstHeader::setDate(const QDate &d) {
52 date=d; 52 date=d;
53 53
54 int year,week; 54 int year,week;
55 calcWeek(d,week,year,onMonday); 55 calcWeek(d,week,year,onMonday);
56 labelWeek->setText("W: " + QString::number(week)); 56 labelWeek->setText("W: " + QString::number(week));
57 57
58 QDate start=date; 58 QDate start=date;
59 QDate stop=start.addDays(6); 59 QDate stop=start.addDays(6);
60 labelDate->setText( QString::number(start.day()) + " " + 60 labelDate->setText( QString::number(start.day()) + " " +
61 start.monthName(start.month()) + " - " + 61 start.monthName(start.month()) + " - " +
62 QString::number(stop.day()) + " " + 62 QString::number(stop.day()) + " " +
63 start.monthName(stop.month()) ); 63 start.monthName(stop.month()) );
64 emit dateChanged(year,week); 64 emit dateChanged(year,week);
65} 65}
66void DateBookWeekLstHeader::pickDate() { 66void DateBookWeekLstHeader::pickDate() {
67 static QPopupMenu *m1 = 0; 67 static QPopupMenu *m1 = 0;
68 static DateBookMonth *picker = 0; 68 static DateBookMonth *picker = 0;
69 if ( !m1 ) { 69 if ( !m1 ) {
70 m1 = new QPopupMenu( this ); 70 m1 = new QPopupMenu( this );
71 picker = new DateBookMonth( m1, 0, TRUE ); 71 picker = new DateBookMonth( m1, 0, TRUE );
72 m1->insertItem( picker ); 72 m1->insertItem( picker );
73 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 73 connect( picker, SIGNAL( dateClicked( int, int, int ) ),
74 this, SLOT( setDate( int, int, int ) ) ); 74 this, SLOT( setDate( int, int, int ) ) );
75 //connect( m1, SIGNAL( aboutToHide() ), 75 //connect( m1, SIGNAL( aboutToHide() ),
76 //this, SLOT( gotHide() ) ); 76 //this, SLOT( gotHide() ) );
77 } 77 }
78 picker->setDate( date.year(), date.month(), date.day() ); 78 picker->setDate( date.year(), date.month(), date.day() );
79 m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height()))); 79 m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height())));
80 picker->setFocus(); 80 picker->setFocus();
81} 81}
82void DateBookWeekLstHeader::setDate(int y, int m, int d) { 82void DateBookWeekLstHeader::setDate(int y, int m, int d) {
83 QDate new_date(y,m,d); 83 QDate new_date(y,m,d);
84 setDate(new_date); 84 setDate(new_date);
85} 85}
86 86
87void DateBookWeekLstHeader::nextWeek() { 87void DateBookWeekLstHeader::nextWeek() {
88 setDate(date.addDays(7)); 88 setDate(date.addDays(7));
89} 89}
90void DateBookWeekLstHeader::prevWeek() { 90void DateBookWeekLstHeader::prevWeek() {
91 setDate(date.addDays(-7)); 91 setDate(date.addDays(-7));
92} 92}
93 93
94DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool onM, 94DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool onM,
95 QWidget* parent, 95 QWidget* parent,
96 const char* name, 96 const char* name,
97 WFlags fl ) 97 WFlags fl )
98 : DateBookWeekLstDayHdrBase(parent, name, fl) { 98 : DateBookWeekLstDayHdrBase(parent, name, fl) {
99 99
100 date=d; 100 date=d;
101 101
102 static const char *wdays="MTWTFSS"; 102 static const char *wdays="MTWTFSS";
103 char day=wdays[d.dayOfWeek()-1]; 103 char day=wdays[d.dayOfWeek()-1];
104 104
105 label->setText( QString(QChar(day)) + " " + 105 label->setText( QString(QChar(day)) + " " +
106 QString::number(d.day()) ); 106 QString::number(d.day()) );
107 add->setText("+"); 107 add->setText("+");
108 108
109 if (d == QDate::currentDate()) { 109 if (d == QDate::currentDate()) {
110 QPalette pal=label->palette(); 110 QPalette pal=label->palette();
111 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 111 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
112 label->setPalette(pal); 112 label->setPalette(pal);
113 113
114 /* 114 /*
115 QFont f=label->font(); 115 QFont f=label->font();
116 f.setItalic(true); 116 f.setItalic(true);
117 label->setFont(f); 117 label->setFont(f);
118 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 118 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
119 */ 119 */
120 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 120 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
121 QPalette pal=label->palette(); 121 QPalette pal=label->palette();
122 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 122 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
123 label->setPalette(pal); 123 label->setPalette(pal);
124 } 124 }
125 125
126 126
127 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 127 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
128 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 128 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
129} 129}
130 130
131void DateBookWeekLstDayHdr::showDay() { 131void DateBookWeekLstDayHdr::showDay() {
132 emit showDate(date.year(), date.month(), date.day()); 132 emit showDate(date.year(), date.month(), date.day());
133} 133}
134void DateBookWeekLstDayHdr::newEvent() { 134void DateBookWeekLstDayHdr::newEvent() {
135 QDateTime start, stop; 135 QDateTime start, stop;
136 start=stop=date; 136 start=stop=date;
137 start.setTime(QTime(10,0)); 137 start.setTime(QTime(10,0));
138 stop.setTime(QTime(12,0)); 138 stop.setTime(QTime(12,0));
139 139
140 emit addEvent(start,stop,""); 140 emit addEvent(start,stop,"");
141} 141}
142DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 142DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
143 QWidget* parent, 143 QWidget* parent,
144 const char* name, 144 const char* name,
145 WFlags fl) : 145 WFlags fl) :
146 OClickableLabel(parent,name,fl), 146 OClickableLabel(parent,name,fl),
147 event(ev) 147 event(ev)
148{ 148{
149 char s[10]; 149 char s[10];
150 if ( ev.startDate() != ev.date() ) { // multiday event (not first day) 150 if ( ev.startDate() != ev.date() ) { // multiday event (not first day)
151 if ( ev.endDate() == ev.date() ) { // last day 151 if ( ev.endDate() == ev.date() ) { // last day
152 strcpy(s, "__|__"); 152 strcpy(s, "__|__");
153 } else { 153 } else {
154 strcpy(s, " |---"); 154 strcpy(s, " |---");
155 } 155 }
156 } else { 156 } else {
157 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); 157 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute());
158 } 158 }
159 setText(QString(s) + " " + ev.description()); 159 setText(QString(s) + " " + ev.description());
160 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 160 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
161 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 161 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
162} 162}
163void DateBookWeekLstEvent::editMe() { 163void DateBookWeekLstEvent::editMe() {
164 emit editEvent(event.event()); 164 emit editEvent(event.event());
165} 165}
166 166
167 167
168DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 168DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
169 const QDate &d, bool onM, 169 const QDate &d, bool onM,
170 QWidget* parent, 170 QWidget* parent,
171 const char* name, WFlags fl) 171 const char* name, WFlags fl)
172 : QWidget( parent, name, fl ) 172 : QWidget( parent, name, fl )
173{ 173{
174 onMonday=onM; 174 onMonday=onM;
175 setPalette(white); 175 setPalette(white);
176 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 176 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
177 177
178 QVBoxLayout *layout = new QVBoxLayout( this ); 178 QVBoxLayout *layout = new QVBoxLayout( this );
179 179
180 qBubbleSort(ev); 180 qBubbleSort(ev);
181 QValueListIterator<EffectiveEvent> it; 181 QValueListIterator<EffectiveEvent> it;
182 it=ev.begin(); 182 it=ev.begin();
183 183
184 int dayOrder[7]; 184 int dayOrder[7];
185 if (onMonday) 185 if (onMonday)
186 for (int d=0; d<7; d++) dayOrder[d]=d+1; 186 for (int d=0; d<7; d++) dayOrder[d]=d+1;
187 else { 187 else {
188 for (int d=0; d<7; d++) dayOrder[d]=d; 188 for (int d=0; d<7; d++) dayOrder[d]=d;
189 dayOrder[0]=7; 189 dayOrder[0]=7;
190 } 190 }
191 191
192 for (int i=0; i<7; i++) { 192 for (int i=0; i<7; i++) {
193 // Header 193 // Header
194 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), 194 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i),
195 onMonday,this); 195 onMonday,this);
196 connect(hdr, SIGNAL(showDate(int,int,int)), 196 connect(hdr, SIGNAL(showDate(int,int,int)),
197 this, SIGNAL(showDate(int,int,int))); 197 this, SIGNAL(showDate(int,int,int)));
198 connect(hdr, SIGNAL(addEvent(const QDateTime &, 198 connect(hdr, SIGNAL(addEvent(const QDateTime &,
199 const QDateTime &, 199 const QDateTime &,
200 const QString &)), 200 const QString &)),
201 this, SIGNAL(addEvent(const QDateTime &, 201 this, SIGNAL(addEvent(const QDateTime &,
202 const QDateTime &, 202 const QDateTime &,
203 const QString &))); 203 const QString &)));
204 layout->addWidget(hdr); 204 layout->addWidget(hdr);
205 205
206 // Events 206 // Events
207 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 207 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
208 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); 208 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this);
209 layout->addWidget(l); 209 layout->addWidget(l);
210 connect (l, SIGNAL(editEvent(const Event &)), 210 connect (l, SIGNAL(editEvent(const Event &)),
211 this, SIGNAL(editEvent(const Event &))); 211 this, SIGNAL(editEvent(const Event &)));
212 it++; 212 it++;
213 } 213 }
214 214
215 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 215 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
216 } 216 }
217} 217}
218DateBookWeekLstView::~DateBookWeekLstView(){} 218DateBookWeekLstView::~DateBookWeekLstView(){}
219void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 219void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
220 220
221DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 221DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
222 QValueList<EffectiveEvent> &ev2, 222 QValueList<EffectiveEvent> &ev2,
223 QDate &d, bool onM, 223 QDate &d, bool onM,
224 QWidget* parent, 224 QWidget* parent,
225 const char* name, WFlags fl) 225 const char* name, WFlags fl)
226 : QWidget( parent, name, fl ) 226 : QWidget( parent, name, fl )
227{ 227{
228 QHBoxLayout *layout = new QHBoxLayout( this ); 228 QHBoxLayout *layout = new QHBoxLayout( this );
229 229
230 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 230 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
231 layout->addWidget(w); 231 layout->addWidget(w);
232 connect (w, SIGNAL(editEvent(const Event &)), 232 connect (w, SIGNAL(editEvent(const Event &)),
233 this, SIGNAL(editEvent(const Event &))); 233 this, SIGNAL(editEvent(const Event &)));
234 connect (w, SIGNAL(showDate(int,int,int)), 234 connect (w, SIGNAL(showDate(int,int,int)),
235 this, SIGNAL(showDate(int,int,int))); 235 this, SIGNAL(showDate(int,int,int)));
236 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 236 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
237 const QString &)), 237 const QString &)),
238 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 238 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
239 const QString &))); 239 const QString &)));
240 240
241 241
242 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 242 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
243 layout->addWidget(w); 243 layout->addWidget(w);
244 connect (w, SIGNAL(editEvent(const Event &)), 244 connect (w, SIGNAL(editEvent(const Event &)),
245 this, SIGNAL(editEvent(const Event &))); 245 this, SIGNAL(editEvent(const Event &)));
246 connect (w, SIGNAL(showDate(int,int,int)), 246 connect (w, SIGNAL(showDate(int,int,int)),
247 this, SIGNAL(showDate(int,int,int))); 247 this, SIGNAL(showDate(int,int,int)));
248 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 248 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
249 const QString &)), 249 const QString &)),
250 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 250 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
251 const QString &))); 251 const QString &)));
252} 252}
253 253
254DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 254DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
255 QWidget *parent, 255 QWidget *parent,
256 const char *name ) 256 const char *name )
257 : QWidget( parent, name ), 257 : QWidget( parent, name ),
258 db( newDB ), 258 db( newDB ),
259 startTime( 0 ), 259 startTime( 0 ),
260 ampm( ap ), 260 ampm( ap ),
261 onMonday(onM) 261 onMonday(onM)
262{ 262{
263 setFocusPolicy(StrongFocus); 263 setFocusPolicy(StrongFocus);
264 layout = new QVBoxLayout( this ); 264 layout = new QVBoxLayout( this );
265 layout->setMargin(0); 265 layout->setMargin(0);
266 266
267 header=new DateBookWeekLstHeader(onM, this); 267 header=new DateBookWeekLstHeader(onM, this);
268 layout->addWidget( header ); 268 layout->addWidget( header );
269 connect(header, SIGNAL(dateChanged(int,int)), 269 connect(header, SIGNAL(dateChanged(int,int)),
270 this, SLOT(dateChanged(int,int))); 270 this, SLOT(dateChanged(int,int)));
271 connect(header, SIGNAL(setDbl(bool)), 271 connect(header, SIGNAL(setDbl(bool)),
272 this, SLOT(setDbl(bool))); 272 this, SLOT(setDbl(bool)));
273 273
274 scroll=new QScrollView(this); 274 scroll=new QScrollView(this);
275 //scroll->setVScrollBarMode(QScrollView::AlwaysOn); 275 //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
276 //scroll->setHScrollBarMode(QScrollView::AlwaysOff); 276 //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
277 scroll->setResizePolicy(QScrollView::AutoOneFit); 277 scroll->setResizePolicy(QScrollView::AutoOneFit);
278 layout->addWidget(scroll); 278 layout->addWidget(scroll);
279 279
280 view=NULL; 280 view=NULL;
281 Config config("DateBook"); 281 Config config("DateBook");
282 config.setGroup("Main"); 282 config.setGroup("Main");
283 dbl=config.readBoolEntry("weeklst_dbl", false); 283 dbl=config.readBoolEntry("weeklst_dbl", false);
284 header->dbl->setOn(dbl); 284 header->dbl->setOn(dbl);
285} 285}
286DateBookWeekLst::~DateBookWeekLst(){ 286DateBookWeekLst::~DateBookWeekLst(){
287 Config config("DateBook"); 287 Config config("DateBook");
288 config.setGroup("Main"); 288 config.setGroup("Main");
289 config.writeEntry("weeklst_dbl", dbl); 289 config.writeEntry("weeklst_dbl", dbl);
290} 290}
291 291
292void DateBookWeekLst::setDate(const QDate &d) { 292void DateBookWeekLst::setDate(const QDate &d) {
293 int w,y; 293 int w,y;
294 calcWeek(d,w,y,onMonday); 294 calcWeek(d,w,y,onMonday);
295 year=y; 295 year=y;
296 _week=w; 296 _week=w;
297 header->setDate(date()); 297 header->setDate(date());
298} 298}
299void DateBookWeekLst::setDbl(bool on) { 299void DateBookWeekLst::setDbl(bool on) {
300 dbl=on; 300 dbl=on;
301 redraw(); 301 redraw();
302} 302}
303void DateBookWeekLst::redraw() {getEvents();} 303void DateBookWeekLst::redraw() {getEvents();}
304 304
305QDate DateBookWeekLst::date() const { 305QDate DateBookWeekLst::date() const {
306 QDate d; 306 QDate d;
307 d.setYMD(year,1,1); 307 d.setYMD(year,1,1);
308 308
309 int dow= d.dayOfWeek(); 309 int dow= d.dayOfWeek();
310 if (!onMonday) 310 if (!onMonday)
311 if (dow==7) dow=1; 311 if (dow==7) dow=1;
312 else dow++; 312 else dow++;
313 313
314 d=d.addDays( (_week-1)*7 - dow + 1 ); 314 d=d.addDays( (_week-1)*7 - dow + 1 );
315 return d; 315 return d;
316} 316}
317 317
318void DateBookWeekLst::getEvents() { 318void DateBookWeekLst::getEvents() {
319 QDate start = date(); 319 QDate start = date();
320 QDate stop = start.addDays(6); 320 QDate stop = start.addDays(6);
321 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 321 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
322 322
323 if (view) delete view; 323 if (view) delete view;
324 if (dbl) { 324 if (dbl) {
325 QDate start2=start.addDays(7); 325 QDate start2=start.addDays(7);
326 stop=start2.addDays(6); 326 stop=start2.addDays(6);
327 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 327 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
328 328
329 view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); 329 view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll);
330 } else { 330 } else {
331 view=new DateBookWeekLstView(el,start,onMonday,scroll); 331 view=new DateBookWeekLstView(el,start,onMonday,scroll);
332 } 332 }
333 333
334 connect (view, SIGNAL(editEvent(const Event &)), 334 connect (view, SIGNAL(editEvent(const Event &)),
335 this, SIGNAL(editEvent(const Event &))); 335 this, SIGNAL(editEvent(const Event &)));
336 connect (view, SIGNAL(showDate(int,int,int)), 336 connect (view, SIGNAL(showDate(int,int,int)),
337 this, SIGNAL(showDate(int,int,int))); 337 this, SIGNAL(showDate(int,int,int)));
338 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 338 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
339 const QString &)), 339 const QString &)),
340 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 340 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
341 const QString &))); 341 const QString &)));
342 342
343 scroll->addChild(view); 343 scroll->addChild(view);
344 view->show(); 344 view->show();
345 scroll->updateScrollBars(); 345 scroll->updateScrollBars();
346} 346}
347 347
348void DateBookWeekLst::dateChanged(int y, int w) { 348void DateBookWeekLst::dateChanged(int y, int w) {
349 year=y; 349 year=y;
350 _week=w; 350 _week=w;
351 getEvents(); 351 getEvents();
352} 352}
353 353
354void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 354void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
355{ 355{
356 switch(e->key()) { 356 switch(e->key()) {
357 case Key_Up: 357 case Key_Up:
358 scroll->scrollBy(0, -20); 358 scroll->scrollBy(0, -20);
359 break; 359 break;
360 case Key_Down: 360 case Key_Down:
361 scroll->scrollBy(0, 20); 361 scroll->scrollBy(0, 20);
362 break; 362 break;
363 case Key_Left: 363 case Key_Left:
364 header->prevWeek(); 364 header->prevWeek();
365 break; 365 break;
366 case Key_Right: 366 case Key_Right:
367 header->nextWeek(); 367 header->nextWeek();
368 break; 368 break;
369 default: 369 default:
370 e->ignore(); 370 e->ignore();
371 } 371 }
372} 372}
373 373