summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/config.in2
-rw-r--r--core/pim/datebook/datebook.cpp10
-rw-r--r--core/pim/datebook/datebook.pro12
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp11
-rw-r--r--core/pim/datebook/datebookweeklst.cpp7
-rw-r--r--core/pim/datebook/dateentryimpl.cpp10
-rw-r--r--core/pim/datebook/opie-datebook.control2
7 files changed, 31 insertions, 23 deletions
diff --git a/core/pim/datebook/config.in b/core/pim/datebook/config.in
index d1dd44f..4658f3c 100644
--- a/core/pim/datebook/config.in
+++ b/core/pim/datebook/config.in
@@ -1,4 +1,4 @@
1 config DATEBOOK 1 config DATEBOOK
2 boolean "opie-datebook (a datebook/appointment manager)" 2 boolean "opie-datebook (a datebook/appointment manager)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 3934411..3d1bc0c 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,433 +1,435 @@
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 <opie2/odebug.h>
33
32#include <qpe/datebookmonth.h> 34#include <qpe/datebookmonth.h>
33#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
34#include <qpe/config.h> 36#include <qpe/config.h>
35#include <qpe/finddialog.h> 37#include <qpe/finddialog.h>
36#include <qpe/ir.h> 38#include <qpe/ir.h>
37#include <qpe/qpemessagebox.h> 39#include <qpe/qpemessagebox.h>
38#include <qpe/resource.h> 40#include <qpe/resource.h>
39#include <qpe/sound.h> 41#include <qpe/sound.h>
40#include <qtoolbar.h>
41#include <qpe/tzselect.h> 42#include <qpe/tzselect.h>
42 43
43#include <qaction.h> 44#include <qaction.h>
44#include <qcopchannel_qws.h> 45#include <qcopchannel_qws.h>
45#include <qlayout.h> 46#include <qlayout.h>
46#include <qmessagebox.h> 47#include <qmessagebox.h>
47#include <qtimer.h> 48#include <qtimer.h>
48#include <qtl.h> 49#include <qtl.h>
50#include <qtoolbar.h>
49#include <qwidgetstack.h> 51#include <qwidgetstack.h>
50 52
51#include <sys/stat.h> 53#include <sys/stat.h>
52#include <sys/types.h> 54#include <sys/types.h>
53#include <fcntl.h> 55#include <fcntl.h>
54#include <unistd.h> 56#include <unistd.h>
55 57
56#include <stdlib.h> 58#include <stdlib.h>
57 59
58DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 60DateBook::DateBook( QWidget *parent, const char *, WFlags f )
59 : QMainWindow( parent, "datebook", f ), 61 : QMainWindow( parent, "datebook", f ),
60 aPreset( FALSE ), 62 aPreset( FALSE ),
61 presetTime( -1 ), 63 presetTime( -1 ),
62 startTime( 8 ), // an acceptable default 64 startTime( 8 ), // an acceptable default
63 rowStyle( 0 ), 65 rowStyle( 0 ),
64 bJumpToCurTime(FALSE), 66 bJumpToCurTime(FALSE),
65 syncing(FALSE), 67 syncing(FALSE),
66 inSearch(FALSE), 68 inSearch(FALSE),
67 alarmCounter(0) 69 alarmCounter(0)
68{ 70{
69 bool needEvilHack= false; // if we need an Evil Hack 71 bool needEvilHack= false; // if we need an Evil Hack
70 QTime t; 72 QTime t;
71 t.start(); 73 t.start();
72 db = new DateBookDBHack; 74 db = new DateBookDBHack;
73 qDebug("loading db t=%d", t.elapsed() ); 75 Opie::Core::odebug << "loading db t=" << t.elapsed() << oendl;
74 loadSettings(); 76 loadSettings();
75 setCaption( tr("Calendar") ); 77 setCaption( tr("Calendar") );
76 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 78 setIcon( Resource::loadPixmap( "datebook_icon" ) );
77 79
78 setToolBarsMovable( FALSE ); 80 setToolBarsMovable( FALSE );
79 81
80 views = new QWidgetStack( this ); 82 views = new QWidgetStack( this );
81 setCentralWidget( views ); 83 setCentralWidget( views );
82 84
83 dayView = 0; 85 dayView = 0;
84 weekView = 0; 86 weekView = 0;
85 weekLstView = 0; 87 weekLstView = 0;
86 monthView = 0; 88 monthView = 0;
87 89
88// QToolBar *bar = new QToolBar( this ); 90// QToolBar *bar = new QToolBar( this );
89// bar->setHorizontalStretchable( TRUE ); 91// bar->setHorizontalStretchable( TRUE );
90 92
91// QMenuBar *mb = new QMenuBar( bar ); 93// QMenuBar *mb = new QMenuBar( bar );
92// mb->setMargin( 0 ); 94// mb->setMargin( 0 );
93 95
94// QPopupMenu *view = new QPopupMenu( this ); 96// QPopupMenu *view = new QPopupMenu( this );
95// mb->insertItem( tr( "View" ), view ); 97// mb->insertItem( tr( "View" ), view );
96 98
97 QToolBar *sub_bar = new QToolBar(this); 99 QToolBar *sub_bar = new QToolBar(this);
98 sub_bar->setHorizontalStretchable(TRUE); 100 sub_bar->setHorizontalStretchable(TRUE);
99 101
100 QActionGroup *g = new QActionGroup( this ); 102 QActionGroup *g = new QActionGroup( this );
101 g->setExclusive( TRUE ); 103 g->setExclusive( TRUE );
102 104
103 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 105 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
104 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 106 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
105 a->addTo( sub_bar ); 107 a->addTo( sub_bar );
106 108
107 sub_bar->addSeparator(); 109 sub_bar->addSeparator();
108 110
109 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); 111 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 );
110 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 112 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
111 a->addTo( sub_bar ); 113 a->addTo( sub_bar );
112 //a->addTo( view ); 114 //a->addTo( view );
113 115
114 sub_bar->addSeparator(); 116 sub_bar->addSeparator();
115 117
116 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 118 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
117 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 119 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
118 a->addTo( sub_bar ); 120 a->addTo( sub_bar );
119// a->addTo( view ); 121// a->addTo( view );
120 a->setToggleAction( TRUE ); 122 a->setToggleAction( TRUE );
121 a->setOn( TRUE ); 123 a->setOn( TRUE );
122 dayAction = a; 124 dayAction = a;
123 125
124 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 126 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
125 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 127 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
126 a->addTo( sub_bar ); 128 a->addTo( sub_bar );
127// a->addTo( view ); 129// a->addTo( view );
128 a->setToggleAction( TRUE ); 130 a->setToggleAction( TRUE );
129 weekAction = a; 131 weekAction = a;
130 132
131 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 133 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
132 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 134 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
133 a->addTo( sub_bar ); 135 a->addTo( sub_bar );
134// a->addTo( view ); 136// a->addTo( view );
135 a->setToggleAction( TRUE ); 137 a->setToggleAction( TRUE );
136 weekLstAction = a; 138 weekLstAction = a;
137 139
138 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 140 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
139 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 141 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
140 a->addTo( sub_bar ); 142 a->addTo( sub_bar );
141// a->addTo( view ); 143// a->addTo( view );
142 a->setToggleAction( TRUE ); 144 a->setToggleAction( TRUE );
143 monthAction = a; 145 monthAction = a;
144 146
145 sub_bar->addSeparator(); 147 sub_bar->addSeparator();
146 148
147 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 149 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
148 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 150 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
149 a->addTo( sub_bar ); 151 a->addTo( sub_bar );
150 152
151 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); 153 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 );
152 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 154 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
153 a->addTo( sub_bar ); 155 a->addTo( sub_bar );
154 156
155 if(defaultView==DAY) viewDay(); 157 if(defaultView==DAY) viewDay();
156 if(defaultView==WEEK) needEvilHack=true;// viewWeek(); 158 if(defaultView==WEEK) needEvilHack=true;// viewWeek();
157 if(defaultView==WEEKLST) viewWeekLst(); 159 if(defaultView==WEEKLST) viewWeekLst();
158 if(defaultView==MONTH) viewMonth(); 160 if(defaultView==MONTH) viewMonth();
159 161
160 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 162 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
161 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 163 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
162 164
163#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 165#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
164 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); 166 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) );
165#endif 167#endif
166 168
167 // listen on QPE/System 169 // listen on QPE/System
168#if defined(Q_WS_QWS) 170#if defined(Q_WS_QWS)
169#if !defined(QT_NO_COP) 171#if !defined(QT_NO_COP)
170 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 172 QCopChannel *channel = new QCopChannel( "QPE/System", this );
171 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 173 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
172 channel = new QCopChannel( "QPE/Datebook", this ); 174 channel = new QCopChannel( "QPE/Datebook", this );
173 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 175 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
174#endif 176#endif
175#endif 177#endif
176 178
177 qDebug("done t=%d", t.elapsed() ); 179 Opie::Core::odebug << "done t=" << t.elapsed() << oendl;
178 180
179 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 181 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
180 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); 182 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) );
181 /* 183 /*
182 * Here is a problem description: 184 * Here is a problem description:
183 * When Weekview is the default view 185 * When Weekview is the default view
184 * a DateBookWeekView get's created 186 * a DateBookWeekView get's created
185 * redraw() get's called. So what? 187 * redraw() get's called. So what?
186 * Remember that we're still in the c'tor 188 * Remember that we're still in the c'tor
187 * and no final layout has happened? Ok 189 * and no final layout has happened? Ok
188 * now all Events get arranged. Their x 190 * now all Events get arranged. Their x
189 * position get's determined by a QHeader 191 * position get's determined by a QHeader
190 * position. But the QHeader isn't layouted or 192 * position. But the QHeader isn't layouted or
191 * at the right position. redraw() is a slot 193 * at the right position. redraw() is a slot
192 * so we'll call it then via a singleShot 194 * so we'll call it then via a singleShot
193 * from view() 195 * from view()
194 */ 196 */
195 if( needEvilHack ){ 197 if( needEvilHack ){
196 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 198 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
197 } 199 }
198} 200}
199 201
200void DateBook::receive( const QCString &msg, const QByteArray &data ) 202void DateBook::receive( const QCString &msg, const QByteArray &data )
201{ 203{
202 QDataStream stream( data, IO_ReadOnly ); 204 QDataStream stream( data, IO_ReadOnly );
203 if ( msg == "timeChange(QString)" ) { 205 if ( msg == "timeChange(QString)" ) {
204 // update active view! 206 // update active view!
205 if ( dayAction->isOn() ) 207 if ( dayAction->isOn() )
206 viewDay(); 208 viewDay();
207 else if ( weekAction->isOn() ) 209 else if ( weekAction->isOn() )
208 viewWeek(); 210 viewWeek();
209 else if ( monthAction->isOn() ) 211 else if ( monthAction->isOn() )
210 viewMonth(); 212 viewMonth();
211 } 213 }
212 else if (msg == "editEvent(int)") { 214 else if (msg == "editEvent(int)") {
213 int uid; 215 int uid;
214 stream >> uid; 216 stream >> uid;
215 Event e=db->eventByUID(uid); 217 Event e=db->eventByUID(uid);
216 editEvent(e); 218 editEvent(e);
217 }else if (msg == "viewDefault(QDate)"){ 219 }else if (msg == "viewDefault(QDate)"){
218 QDate day; 220 QDate day;
219 stream >> day; 221 stream >> day;
220 viewDefault(day); 222 viewDefault(day);
221 } 223 }
222} 224}
223 225
224DateBook::~DateBook() 226DateBook::~DateBook()
225{ 227{
226} 228}
227 229
228void DateBook::slotSettings() 230void DateBook::slotSettings()
229{ 231{
230 DateBookSettings frmSettings( ampm, this ); 232 DateBookSettings frmSettings( ampm, this );
231 frmSettings.setStartTime( startTime ); 233 frmSettings.setStartTime( startTime );
232 frmSettings.setAlarmPreset( aPreset, presetTime ); 234 frmSettings.setAlarmPreset( aPreset, presetTime );
233 frmSettings.setJumpToCurTime( bJumpToCurTime ); 235 frmSettings.setJumpToCurTime( bJumpToCurTime );
234 frmSettings.setRowStyle( rowStyle ); 236 frmSettings.setRowStyle( rowStyle );
235 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 237 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
236 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 238 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
237 239
238 bool found=false; 240 bool found=false;
239 for (int i=0; i<(frmSettings.comboLocation->count()); i++) { 241 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
240 if ( frmSettings.comboLocation->text(i) == defaultLocation ) { 242 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
241 frmSettings.comboLocation->setCurrentItem(i); 243 frmSettings.comboLocation->setCurrentItem(i);
242 found=true; 244 found=true;
243 break; 245 break;
244 } 246 }
245 } 247 }
246 if(!found) { 248 if(!found) {
247 frmSettings.comboLocation->insertItem(defaultLocation); 249 frmSettings.comboLocation->insertItem(defaultLocation);
248 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); 250 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
249 } 251 }
250 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); 252 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
251 253
252 if ( QPEApplication::execDialog( &frmSettings ) ) { 254 if ( QPEApplication::execDialog( &frmSettings ) ) {
253 aPreset = frmSettings.alarmPreset(); 255 aPreset = frmSettings.alarmPreset();
254 presetTime = frmSettings.presetTime(); 256 presetTime = frmSettings.presetTime();
255 startTime = frmSettings.startTime(); 257 startTime = frmSettings.startTime();
256 bJumpToCurTime = frmSettings.jumpToCurTime(); 258 bJumpToCurTime = frmSettings.jumpToCurTime();
257 rowStyle = frmSettings.rowStyle(); 259 rowStyle = frmSettings.rowStyle();
258 defaultView=frmSettings.comboDefaultView->currentItem()+1; 260 defaultView=frmSettings.comboDefaultView->currentItem()+1;
259 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 261 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
260 defaultLocation=frmSettings.comboLocation->currentText(); 262 defaultLocation=frmSettings.comboLocation->currentText();
261 defaultCategories=frmSettings.comboCategory->currentCategories(); 263 defaultCategories=frmSettings.comboCategory->currentCategories();
262 264
263 if ( dayView ) { 265 if ( dayView ) {
264 dayView->setStartViewTime( startTime ); 266 dayView->setStartViewTime( startTime );
265 dayView->setJumpToCurTime( bJumpToCurTime ); 267 dayView->setJumpToCurTime( bJumpToCurTime );
266 dayView->setRowStyle( rowStyle ); 268 dayView->setRowStyle( rowStyle );
267 } 269 }
268 if ( weekView ) { 270 if ( weekView ) {
269 weekView->setStartViewTime( startTime ); 271 weekView->setStartViewTime( startTime );
270 } 272 }
271 saveSettings(); 273 saveSettings();
272 274
273 // make the change obvious 275 // make the change obvious
274 if ( views->visibleWidget() ) { 276 if ( views->visibleWidget() ) {
275 if ( views->visibleWidget() == dayView ) 277 if ( views->visibleWidget() == dayView )
276 dayView->redraw(); 278 dayView->redraw();
277 else if ( views->visibleWidget() == weekView ) 279 else if ( views->visibleWidget() == weekView )
278 weekView->redraw(); 280 weekView->redraw();
279 else if ( views->visibleWidget() == weekLstView ) 281 else if ( views->visibleWidget() == weekLstView )
280 weekLstView->redraw(); 282 weekLstView->redraw();
281 } 283 }
282 } 284 }
283} 285}
284 286
285void DateBook::fileNew() 287void DateBook::fileNew()
286{ 288{
287 slotNewEventFromKey(""); 289 slotNewEventFromKey("");
288} 290}
289 291
290QString DateBook::checkEvent(const Event &e) 292QString DateBook::checkEvent(const Event &e)
291{ 293{
292 /* check if overlaps with itself */ 294 /* check if overlaps with itself */
293 bool checkFailed = FALSE; 295 bool checkFailed = FALSE;
294 296
295 /* check the next 12 repeats. should catch most problems */ 297 /* check the next 12 repeats. should catch most problems */
296 QDate current_date = e.start().date(); 298 QDate current_date = e.start().date();
297 Event previous = e; 299 Event previous = e;
298 for(int i = 0; i < 12; i++) 300 for(int i = 0; i < 12; i++)
299 { 301 {
300 QDateTime next; 302 QDateTime next;
301 if (!nextOccurance(previous, current_date.addDays(1), next)) { 303 if (!nextOccurance(previous, current_date.addDays(1), next)) {
302 break; // no more repeats 304 break; // no more repeats
303 } 305 }
304 if(next < previous.end()) { 306 if(next < previous.end()) {
305 checkFailed = TRUE; 307 checkFailed = TRUE;
306 break; 308 break;
307 } 309 }
308 current_date = next.date(); 310 current_date = next.date();
309 } 311 }
310 312
311 if(checkFailed) 313 if(checkFailed)
312 return tr("Event duration is potentially longer\n" 314 return tr("Event duration is potentially longer\n"
313 "than interval between repeats."); 315 "than interval between repeats.");
314 316
315 return QString::null; 317 return QString::null;
316} 318}
317 319
318QDate DateBook::currentDate() 320QDate DateBook::currentDate()
319{ 321{
320 QDate d = QDate::currentDate(); 322 QDate d = QDate::currentDate();
321 323
322 if ( dayView && views->visibleWidget() == dayView ) { 324 if ( dayView && views->visibleWidget() == dayView ) {
323 d = dayView->date(); 325 d = dayView->date();
324 } else if ( weekView && views->visibleWidget() == weekView ) { 326 } else if ( weekView && views->visibleWidget() == weekView ) {
325 d = weekView->date(); 327 d = weekView->date();
326 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 328 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
327 d = weekLstView->date(); 329 d = weekLstView->date();
328 } else if ( monthView && views->visibleWidget() == monthView ) { 330 } else if ( monthView && views->visibleWidget() == monthView ) {
329 d = monthView->selectedDate(); 331 d = monthView->selectedDate();
330 } 332 }
331 333
332 return d; 334 return d;
333} 335}
334 336
335void DateBook::view(int v, const QDate &d) { 337void DateBook::view(int v, const QDate &d) {
336 if (v==DAY) { 338 if (v==DAY) {
337 initDay(); 339 initDay();
338 dayAction->setOn( TRUE ); 340 dayAction->setOn( TRUE );
339 dayView->setDate( d ); 341 dayView->setDate( d );
340 views->raiseWidget( dayView ); 342 views->raiseWidget( dayView );
341 dayView->redraw(); 343 dayView->redraw();
342 } else if (v==WEEK) { 344 } else if (v==WEEK) {
343 initWeek(); 345 initWeek();
344 weekAction->setOn( TRUE ); 346 weekAction->setOn( TRUE );
345 weekView->setDate( d ); 347 weekView->setDate( d );
346 views->raiseWidget( weekView ); 348 views->raiseWidget( weekView );
347 weekView->redraw(); 349 weekView->redraw();
348 } else if (v==WEEKLST) { 350 } else if (v==WEEKLST) {
349 initWeekLst(); 351 initWeekLst();
350 weekLstAction->setOn( TRUE ); 352 weekLstAction->setOn( TRUE );
351 weekLstView->setDate(d); 353 weekLstView->setDate(d);
352 views->raiseWidget( weekLstView ); 354 views->raiseWidget( weekLstView );
353 weekLstView->redraw(); 355 weekLstView->redraw();
354 } else if (v==MONTH) { 356 } else if (v==MONTH) {
355 initMonth(); 357 initMonth();
356 monthAction->setOn( TRUE ); 358 monthAction->setOn( TRUE );
357 monthView->setDate( d.year(), d.month(), d.day() ); 359 monthView->setDate( d.year(), d.month(), d.day() );
358 views->raiseWidget( monthView ); 360 views->raiseWidget( monthView );
359 monthView->redraw(); 361 monthView->redraw();
360 } 362 }
361} 363}
362 364
363void DateBook::viewDefault(const QDate &d) { 365void DateBook::viewDefault(const QDate &d) {
364 view(defaultView,d); 366 view(defaultView,d);
365} 367}
366 368
367void DateBook::viewDay() { 369void DateBook::viewDay() {
368 view(DAY,currentDate()); 370 view(DAY,currentDate());
369} 371}
370 372
371void DateBook::viewWeek() { 373void DateBook::viewWeek() {
372 view(WEEK,currentDate()); 374 view(WEEK,currentDate());
373} 375}
374 376
375void DateBook::viewWeekLst() { 377void DateBook::viewWeekLst() {
376 view(WEEKLST,currentDate()); 378 view(WEEKLST,currentDate());
377} 379}
378 380
379void DateBook::viewMonth() { 381void DateBook::viewMonth() {
380 view(MONTH,currentDate()); 382 view(MONTH,currentDate());
381} 383}
382 384
383void DateBook::insertEvent( const Event &e ) 385void DateBook::insertEvent( const Event &e )
384{ 386{
385 Event dupEvent=e; 387 Event dupEvent=e;
386 if(!dupEvent.isValidUid() ) // tkcRom seems to be different 388 if(!dupEvent.isValidUid() ) // tkcRom seems to be different
387 dupEvent.assignUid(); 389 dupEvent.assignUid();
388 dupEvent.setLocation(defaultLocation); 390 dupEvent.setLocation(defaultLocation);
389 dupEvent.setCategories(defaultCategories); 391 dupEvent.setCategories(defaultCategories);
390 db->addEvent(dupEvent); 392 db->addEvent(dupEvent);
391 emit newEvent(); 393 emit newEvent();
392} 394}
393 395
394void DateBook::duplicateEvent( const Event &e ) 396void DateBook::duplicateEvent( const Event &e )
395{ 397{
396 // Alot of code duplication, as this is almost like editEvent(); 398 // Alot of code duplication, as this is almost like editEvent();
397 if (syncing) { 399 if (syncing) {
398 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 400 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
399 return; 401 return;
400 } 402 }
401 403
402 Event dupevent(e);// Make a duplicate. 404 Event dupevent(e);// Make a duplicate.
403 405
404 // workaround added for text input. 406 // workaround added for text input.
405 QDialog editDlg( this, 0, TRUE ); 407 QDialog editDlg( this, 0, TRUE );
406 DateEntry *entry; 408 DateEntry *entry;
407 editDlg.setCaption( tr("Duplicate Event") ); 409 editDlg.setCaption( tr("Duplicate Event") );
408 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 410 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
409 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 411 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
410 sv->setResizePolicy( QScrollView::AutoOneFit ); 412 sv->setResizePolicy( QScrollView::AutoOneFit );
411 // KLUDGE!!! 413 // KLUDGE!!!
412 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 414 sv->setHScrollBarMode( QScrollView::AlwaysOff );
413 vb->addWidget( sv ); 415 vb->addWidget( sv );
414 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 416 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
415 entry->timezone->setEnabled( FALSE ); 417 entry->timezone->setEnabled( FALSE );
416 sv->addChild( entry ); 418 sv->addChild( entry );
417 419
418 while ( QPEApplication::execDialog( &editDlg ) ) { 420 while ( QPEApplication::execDialog( &editDlg ) ) {
419 Event newEv = entry->event(); 421 Event newEv = entry->event();
420 QString error = checkEvent(newEv); 422 QString error = checkEvent(newEv);
421 if (!error.isNull()) { 423 if (!error.isNull()) {
422 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) 424 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0)
423 continue; 425 continue;
424 } 426 }
425 /* 427 /*
426 * The problem: 428 * The problem:
427 * DateBookDB does remove repeating events not by uid but by the time 429 * DateBookDB does remove repeating events not by uid but by the time
428 * the recurrence was created 430 * the recurrence was created
429 * so we need to update that time as well 431 * so we need to update that time as well
430 */ 432 */
431 Event::RepeatPattern rp = newEv.repeatPattern(); 433 Event::RepeatPattern rp = newEv.repeatPattern();
432 rp.createTime = ::time( NULL ); 434 rp.createTime = ::time( NULL );
433 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... 435 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern...
@@ -647,424 +649,424 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data)
647 int stopTimer = 0; 649 int stopTimer = 0;
648 bool found = FALSE; 650 bool found = FALSE;
649 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 651 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
650 if ( (*it).event().hasAlarm() ) { 652 if ( (*it).event().hasAlarm() ) {
651 found = TRUE; 653 found = TRUE;
652 msg += "<CENTER><B>" + (*it).description() + "</B>" 654 msg += "<CENTER><B>" + (*it).description() + "</B>"
653 + "<BR>" + (*it).location() + "<BR>" 655 + "<BR>" + (*it).location() + "<BR>"
654 + TimeString::dateString((*it).event().start(),ampm) 656 + TimeString::dateString((*it).event().start(),ampm)
655 + (warn 657 + (warn
656 ? tr(" (in " + QString::number(warn) 658 ? tr(" (in " + QString::number(warn)
657 + tr(" minutes)")) 659 + tr(" minutes)"))
658 : QString("")) 660 : QString(""))
659 + "<BR>" 661 + "<BR>"
660 + (*it).notes() + "</CENTER>"; 662 + (*it).notes() + "</CENTER>";
661 if ( (*it).event().alarmSound() != Event::Silent ) { 663 if ( (*it).event().alarmSound() != Event::Silent ) {
662 bSound = TRUE; 664 bSound = TRUE;
663 } 665 }
664 } 666 }
665 } 667 }
666 if ( found ) { 668 if ( found ) {
667 if ( bSound ) { 669 if ( bSound ) {
668 Sound::soundAlarm(); 670 Sound::soundAlarm();
669 alarmCounter = 0; 671 alarmCounter = 0;
670 stopTimer = startTimer( 5000 ); 672 stopTimer = startTimer( 5000 );
671 } 673 }
672 QDialog dlg( this, 0, TRUE ); 674 QDialog dlg( this, 0, TRUE );
673 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 675 QVBoxLayout *vb = new QVBoxLayout( &dlg );
674 QScrollView *view = new QScrollView( &dlg, "scrollView"); 676 QScrollView *view = new QScrollView( &dlg, "scrollView");
675 view->setResizePolicy( QScrollView::AutoOneFit ); 677 view->setResizePolicy( QScrollView::AutoOneFit );
676 vb->addWidget( view ); 678 vb->addWidget( view );
677 QLabel *lblMsg = new QLabel( msg, &dlg ); 679 QLabel *lblMsg = new QLabel( msg, &dlg );
678 view->addChild( lblMsg ); 680 view->addChild( lblMsg );
679 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 681 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
680 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 682 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
681 vb->addWidget( cmdOk ); 683 vb->addWidget( cmdOk );
682 684
683 needShow = QPEApplication::execDialog( &dlg ); 685 needShow = QPEApplication::execDialog( &dlg );
684 686
685 if ( bSound ) 687 if ( bSound )
686 killTimer( stopTimer ); 688 killTimer( stopTimer );
687 } 689 }
688 } 690 }
689 } else if ( msg == "nextView()" ) { 691 } else if ( msg == "nextView()" ) {
690 needShow = true; 692 needShow = true;
691 if ( !qApp-> activeWindow ( )) { 693 if ( !qApp-> activeWindow ( )) {
692 needShow = TRUE; 694 needShow = TRUE;
693 } else { 695 } else {
694 QWidget* cur = views->visibleWidget(); 696 QWidget* cur = views->visibleWidget();
695 if ( cur ) { 697 if ( cur ) {
696 if ( cur == dayView ) 698 if ( cur == dayView )
697 viewWeek(); 699 viewWeek();
698 else if ( cur == weekView ) 700 else if ( cur == weekView )
699 viewWeekLst(); 701 viewWeekLst();
700 else if ( cur == weekLstView ) 702 else if ( cur == weekLstView )
701 viewMonth(); 703 viewMonth();
702 else if ( cur == monthView ) 704 else if ( cur == monthView )
703 viewDay(); 705 viewDay();
704 needShow = TRUE; 706 needShow = TRUE;
705 } 707 }
706 } 708 }
707 } else if (msg == "editEvent(int)") { 709 } else if (msg == "editEvent(int)") {
708 /* simple copy from receive */ 710 /* simple copy from receive */
709 QDataStream stream(data,IO_ReadOnly); 711 QDataStream stream(data,IO_ReadOnly);
710 int uid; 712 int uid;
711 stream >> uid; 713 stream >> uid;
712 Event e=db->eventByUID(uid); 714 Event e=db->eventByUID(uid);
713 editEvent(e); 715 editEvent(e);
714 } else if (msg == "viewDefault(QDate)"){ 716 } else if (msg == "viewDefault(QDate)"){
715 /* simple copy from receive */ 717 /* simple copy from receive */
716 QDataStream stream(data,IO_ReadOnly); 718 QDataStream stream(data,IO_ReadOnly);
717 QDate day; 719 QDate day;
718 stream >> day; 720 stream >> day;
719 viewDefault(day); 721 viewDefault(day);
720 needShow = true; 722 needShow = true;
721 } 723 }
722 724
723 if ( needShow ) { 725 if ( needShow ) {
724#if defined(Q_WS_QWS) || defined(_WS_QWS_) 726#if defined(Q_WS_QWS) || defined(_WS_QWS_)
725 // showMaximized(); 727 // showMaximized();
726#else 728#else
727 // show(); 729 // show();
728#endif 730#endif
729 // raise(); 731 // raise();
730 QPEApplication::setKeepRunning(); 732 QPEApplication::setKeepRunning();
731 // setActiveWindow(); 733 // setActiveWindow();
732 } 734 }
733} 735}
734 736
735void DateBook::reload() 737void DateBook::reload()
736{ 738{
737 db->reload(); 739 db->reload();
738 if ( dayAction->isOn() ) viewDay(); 740 if ( dayAction->isOn() ) viewDay();
739 else if ( weekAction->isOn() ) viewWeek(); 741 else if ( weekAction->isOn() ) viewWeek();
740 else if ( monthAction->isOn() ) viewMonth(); 742 else if ( monthAction->isOn() ) viewMonth();
741 syncing = FALSE; 743 syncing = FALSE;
742} 744}
743 745
744void DateBook::flush() 746void DateBook::flush()
745{ 747{
746 syncing = TRUE; 748 syncing = TRUE;
747 db->save(); 749 db->save();
748} 750}
749 751
750void DateBook::timerEvent( QTimerEvent *e ) 752void DateBook::timerEvent( QTimerEvent *e )
751{ 753{
752 if ( alarmCounter < 10 ) { 754 if ( alarmCounter < 10 ) {
753 alarmCounter++; 755 alarmCounter++;
754 Sound::soundAlarm(); 756 Sound::soundAlarm();
755 } else { 757 } else {
756 killTimer( e->timerId() ); 758 killTimer( e->timerId() );
757 } 759 }
758} 760}
759 761
760void DateBook::changeClock( bool newClock ) 762void DateBook::changeClock( bool newClock )
761{ 763{
762 ampm = newClock; 764 ampm = newClock;
763 // repaint the affected objects... 765 // repaint the affected objects...
764 if (dayView) dayView->redraw(); 766 if (dayView) dayView->redraw();
765 if (weekView) weekView->redraw(); 767 if (weekView) weekView->redraw();
766 if (weekLstView) weekLstView->redraw(); 768 if (weekLstView) weekLstView->redraw();
767} 769}
768 770
769void DateBook::changeWeek( bool m ) 771void DateBook::changeWeek( bool m )
770{ 772{
771 /* no need to redraw, each widget catches. Do need to 773 /* no need to redraw, each widget catches. Do need to
772 store though for widgets we haven't made yet */ 774 store though for widgets we haven't made yet */
773 onMonday = m; 775 onMonday = m;
774} 776}
775 777
776void DateBook::slotToday() 778void DateBook::slotToday()
777{ 779{
778 // we need to view today using default view 780 // we need to view today using default view
779 view(defaultView,QDate::currentDate()); 781 view(defaultView,QDate::currentDate());
780} 782}
781 783
782void DateBook::closeEvent( QCloseEvent *e ) 784void DateBook::closeEvent( QCloseEvent *e )
783{ 785{
784 if(syncing) { 786 if(syncing) {
785 /* no need to save, did that at flush */ 787 /* no need to save, did that at flush */
786 e->accept(); 788 e->accept();
787 return; 789 return;
788 } 790 }
789 791
790 // save settings will generate it's own error messages, no 792 // save settings will generate it's own error messages, no
791 // need to do checking ourselves. 793 // need to do checking ourselves.
792 saveSettings(); 794 saveSettings();
793 if ( db->save() ) { 795 if ( db->save() ) {
794 e->accept(); 796 e->accept();
795 } else { 797 } else {
796 if ( QMessageBox::critical( this, tr( "Out of space" ), 798 if ( QMessageBox::critical( this, tr( "Out of space" ),
797 tr("Calendar was unable to save\n" 799 tr("Calendar was unable to save\n"
798 "your changes.\n" 800 "your changes.\n"
799 "Free up some space and try again.\n" 801 "Free up some space and try again.\n"
800 "\nQuit anyway?"), 802 "\nQuit anyway?"),
801 QMessageBox::Yes|QMessageBox::Escape, 803 QMessageBox::Yes|QMessageBox::Escape,
802 QMessageBox::No|QMessageBox::Default ) 804 QMessageBox::No|QMessageBox::Default )
803 != QMessageBox::No ) 805 != QMessageBox::No )
804 e->accept(); 806 e->accept();
805 else 807 else
806 e->ignore(); 808 e->ignore();
807 } 809 }
808} 810}
809 811
810// Entering directly from the "keyboard" 812// Entering directly from the "keyboard"
811void DateBook::slotNewEventFromKey( const QString &str ) 813void DateBook::slotNewEventFromKey( const QString &str )
812{ 814{
813 if (syncing) { 815 if (syncing) {
814 QMessageBox::warning( this, tr("Calendar"), 816 QMessageBox::warning( this, tr("Calendar"),
815 tr( "Can not edit data, currently syncing") ); 817 tr( "Can not edit data, currently syncing") );
816 return; 818 return;
817 } 819 }
818 820
819 // We get to here from a key pressed in the Day View 821 // We get to here from a key pressed in the Day View
820 // So we can assume some things. We want the string 822 // So we can assume some things. We want the string
821 // passed in to be part of the description. 823 // passed in to be part of the description.
822 QDateTime start, end; 824 QDateTime start, end;
823 if ( views->visibleWidget() == dayView ) { 825 if ( views->visibleWidget() == dayView ) {
824 dayView->selectedDates( start, end ); 826 dayView->selectedDates( start, end );
825 } else if ( views->visibleWidget() == monthView ) { 827 } else if ( views->visibleWidget() == monthView ) {
826 QDate d = monthView->selectedDate(); 828 QDate d = monthView->selectedDate();
827 start = end = d; 829 start = end = d;
828 start.setTime( QTime( 10, 0 ) ); 830 start.setTime( QTime( 10, 0 ) );
829 end.setTime( QTime( 12, 0 ) ); 831 end.setTime( QTime( 12, 0 ) );
830 } else if ( views->visibleWidget() == weekView ) { 832 } else if ( views->visibleWidget() == weekView ) {
831 QDate d = weekView->date(); 833 QDate d = weekView->date();
832 start = end = d; 834 start = end = d;
833 start.setTime( QTime( 10, 0 ) ); 835 start.setTime( QTime( 10, 0 ) );
834 end.setTime( QTime( 12, 0 ) ); 836 end.setTime( QTime( 12, 0 ) );
835 } else if ( views->visibleWidget() == weekLstView ) { 837 } else if ( views->visibleWidget() == weekLstView ) {
836 QDate d = weekLstView->date(); 838 QDate d = weekLstView->date();
837 start = end = d; 839 start = end = d;
838 start.setTime( QTime( 10, 0 ) ); 840 start.setTime( QTime( 10, 0 ) );
839 end.setTime( QTime( 12, 0 ) ); 841 end.setTime( QTime( 12, 0 ) );
840 } 842 }
841 slotNewEntry(start, end, str); 843 slotNewEntry(start, end, str);
842} 844}
843void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 845void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
844 // argh! This really needs to be encapsulated in a class 846 // argh! This really needs to be encapsulated in a class
845 // or function. 847 // or function.
846 QDialog newDlg( this, 0, TRUE ); 848 QDialog newDlg( this, 0, TRUE );
847 newDlg.setCaption( DateEntryBase::tr("New Event") ); 849 newDlg.setCaption( DateEntryBase::tr("New Event") );
848 DateEntry *e; 850 DateEntry *e;
849 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 851 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
850 QScrollView *sv = new QScrollView( &newDlg ); 852 QScrollView *sv = new QScrollView( &newDlg );
851 sv->setResizePolicy( QScrollView::AutoOneFit ); 853 sv->setResizePolicy( QScrollView::AutoOneFit );
852 sv->setFrameStyle( QFrame::NoFrame ); 854 sv->setFrameStyle( QFrame::NoFrame );
853 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 855 sv->setHScrollBarMode( QScrollView::AlwaysOff );
854 vb->addWidget( sv ); 856 vb->addWidget( sv );
855 857
856 Event ev; 858 Event ev;
857 ev.setDescription( str ); 859 ev.setDescription( str );
858 // When the new gui comes in, change this... 860 // When the new gui comes in, change this...
859 if(location==0) { 861 if(location==0) {
860 if(defaultLocation.isEmpty()) { 862 if(defaultLocation.isEmpty()) {
861 ev.setLocation(tr("(Unknown)")); 863 ev.setLocation(tr("(Unknown)"));
862 } else { 864 } else {
863 ev.setLocation( defaultLocation ); 865 ev.setLocation( defaultLocation );
864 } 866 }
865 } else { 867 } else {
866 ev.setLocation(location); 868 ev.setLocation(location);
867 } 869 }
868 ev.setCategories(defaultCategories); 870 ev.setCategories(defaultCategories);
869 ev.setStart( start ); 871 ev.setStart( start );
870 ev.setEnd( end ); 872 ev.setEnd( end );
871 873
872 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 874 e = new DateEntry( onMonday, ev, ampm, &newDlg );
873 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 875 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
874 sv->addChild( e ); 876 sv->addChild( e );
875 while ( QPEApplication::execDialog( &newDlg ) ) { 877 while ( QPEApplication::execDialog( &newDlg ) ) {
876 ev = e->event(); 878 ev = e->event();
877 ev.assignUid(); 879 ev.assignUid();
878 QString error = checkEvent( ev ); 880 QString error = checkEvent( ev );
879 if ( !error.isNull() ) { 881 if ( !error.isNull() ) {
880 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 882 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
881 continue; 883 continue;
882 } 884 }
883 db->addEvent( ev ); 885 db->addEvent( ev );
884 emit newEvent(); 886 emit newEvent();
885 break; 887 break;
886 } 888 }
887} 889}
888 890
889void DateBook::setDocument( const QString &filename ) 891void DateBook::setDocument( const QString &filename )
890{ 892{
891 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 893 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
892 894
893 QValueList<Event> tl = Event::readVCalendar( filename ); 895 QValueList<Event> tl = Event::readVCalendar( filename );
894 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 896 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
895 db->addEvent( *it ); 897 db->addEvent( *it );
896 } 898 }
897} 899}
898 900
899static const char * beamfile = "/tmp/obex/event.vcs"; 901static const char * beamfile = "/tmp/obex/event.vcs";
900 902
901void DateBook::beamEvent( const Event &e ) 903void DateBook::beamEvent( const Event &e )
902{ 904{
903 qDebug("trying to beamn"); 905 Opie::Core::odebug << "trying to beam" << oendl;
904 unlink( beamfile ); // delete if exists 906 unlink( beamfile ); // delete if exists
905 mkdir("/tmp/obex/", 0755); 907 mkdir("/tmp/obex/", 0755);
906 Event::writeVCalendar( beamfile, e ); 908 Event::writeVCalendar( beamfile, e );
907 Ir *ir = new Ir( this ); 909 Ir *ir = new Ir( this );
908 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 910 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
909 QString description = e.description(); 911 QString description = e.description();
910 ir->send( beamfile, description, "text/x-vCalendar" ); 912 ir->send( beamfile, description, "text/x-vCalendar" );
911} 913}
912 914
913void DateBook::beamDone( Ir *ir ) 915void DateBook::beamDone( Ir *ir )
914{ 916{
915 delete ir; 917 delete ir;
916 unlink( beamfile ); 918 unlink( beamfile );
917} 919}
918 920
919void DateBook::slotFind() 921void DateBook::slotFind()
920{ 922{
921 // move it to the day view... 923 // move it to the day view...
922 viewDay(); 924 viewDay();
923 FindDialog frmFind( "Calendar", this ); // no tr needed 925 FindDialog frmFind( "Calendar", this ); // no tr needed
924 frmFind.setUseDate( true ); 926 frmFind.setUseDate( true );
925 frmFind.setDate( currentDate() ); 927 frmFind.setDate( currentDate() );
926 QObject::connect( &frmFind, 928 QObject::connect( &frmFind,
927 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)), 929 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)),
928 this, 930 this,
929 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) ); 931 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) );
930 QObject::connect( this, 932 QObject::connect( this,
931 SIGNAL(signalNotFound()), 933 SIGNAL(signalNotFound()),
932 &frmFind, 934 &frmFind,
933 SLOT(slotNotFound()) ); 935 SLOT(slotNotFound()) );
934 QObject::connect( this, 936 QObject::connect( this,
935 SIGNAL(signalWrapAround()), 937 SIGNAL(signalWrapAround()),
936 &frmFind, 938 &frmFind,
937 SLOT(slotWrapAround()) ); 939 SLOT(slotWrapAround()) );
938 frmFind.move(0,0); 940 frmFind.move(0,0);
939 frmFind.exec(); 941 frmFind.exec();
940 inSearch = false; 942 inSearch = false;
941} 943}
942 944
943bool catComp( QArray<int> cats, int category ) 945bool catComp( QArray<int> cats, int category )
944{ 946{
945 bool returnMe; 947 bool returnMe;
946 int i, 948 int i,
947 count; 949 count;
948 950
949 count = int(cats.count()); 951 count = int(cats.count());
950 returnMe = false; 952 returnMe = false;
951 if ( (category == -1 && count == 0) || category == -2 ) 953 if ( (category == -1 && count == 0) || category == -2 )
952 returnMe = true; 954 returnMe = true;
953 else { 955 else {
954 for ( i = 0; i < count; i++ ) { 956 for ( i = 0; i < count; i++ ) {
955 if ( category == cats[i] ) { 957 if ( category == cats[i] ) {
956 returnMe = true; 958 returnMe = true;
957 break; 959 break;
958 } 960 }
959 } 961 }
960 } 962 }
961 return returnMe; 963 return returnMe;
962} 964}
963 965
964 966
965void DateBook::slotDoFind( const QString& txt, const QDate &dt, 967void DateBook::slotDoFind( const QString& txt, const QDate &dt,
966 bool caseSensitive, bool /*backwards*/, 968 bool caseSensitive, bool /*backwards*/,
967 int category ) 969 int category )
968{ 970{
969 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 971 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
970 next; 972 next;
971 973
972 QRegExp r( txt ); 974 QRegExp r( txt );
973 r.setCaseSensitive( caseSensitive ); 975 r.setCaseSensitive( caseSensitive );
974 976
975 977
976 static Event rev, nonrev; 978 static Event rev, nonrev;
977 if ( !inSearch ) { 979 if ( !inSearch ) {
978 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 980 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
979 nonrev.setStart( rev.start() ); 981 nonrev.setStart( rev.start() );
980 inSearch = true; 982 inSearch = true;
981 } 983 }
982 static QDate searchDate = dt; 984 static QDate searchDate = dt;
983 // if true at the end we will start at the begin again and afterwards 985 // if true at the end we will start at the begin again and afterwards
984 // we will emit string not found 986 // we will emit string not found
985 static bool wrapAround = true; 987 static bool wrapAround = true;
986 bool candidtate; 988 bool candidtate;
987 candidtate = false; 989 candidtate = false;
988 990
989 QValueList<Event> repeats = db->getRawRepeats(); 991 QValueList<Event> repeats = db->getRawRepeats();
990 992
991 // find the candidate for the first repeat that matches... 993 // find the candidate for the first repeat that matches...
992 // first check if there can ever be a match and then compute 994 // first check if there can ever be a match and then compute
993 // the next occurence from start. See if this event is closer 995 // the next occurence from start. See if this event is closer
994 // to the beginning (start. next < dtEnd) and not smaller then the last 996 // to the beginning (start. next < dtEnd) and not smaller then the last
995 // result. If we find a canditate we set the dtEnd to the time 997 // result. If we find a canditate we set the dtEnd to the time
996 // of the ocurrence and rev to this occurence. 998 // of the ocurrence and rev to this occurence.
997 // set wrap around to true because there might be more events coming 999 // set wrap around to true because there might be more events coming
998 // and we're not at the end. 1000 // and we're not at the end.
999 QValueListConstIterator<Event> it; 1001 QValueListConstIterator<Event> it;
1000 QDate start = dt; 1002 QDate start = dt;
1001 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 1003 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
1002 if ( catComp( (*it).categories(), category ) ) { 1004 if ( catComp( (*it).categories(), category ) ) {
1003 if ( (*it).match( r ) ) { 1005 if ( (*it).match( r ) ) {
1004 if ( nextOccurance( *it, start, next ) ) { 1006 if ( nextOccurance( *it, start, next ) ) {
1005 if ( next < dtEnd && !(next <= rev.start() ) ) { 1007 if ( next < dtEnd && !(next <= rev.start() ) ) {
1006 rev = *it; 1008 rev = *it;
1007 dtEnd = next; 1009 dtEnd = next;
1008 rev.setStart( next ); 1010 rev.setStart( next );
1009 candidtate = true; 1011 candidtate = true;
1010 wrapAround = true; 1012 wrapAround = true;
1011 } 1013 }
1012 } 1014 }
1013 } 1015 }
1014 } 1016 }
1015 } 1017 }
1016 1018
1017 // now the for first non repeat... 1019 // now the for first non repeat...
1018 // dtEnd is set by the previous iteration of repeatingEvents 1020 // dtEnd is set by the previous iteration of repeatingEvents
1019 // check if we find a closer item. Also set dtEnd to find even 1021 // check if we find a closer item. Also set dtEnd to find even
1020 // more close occurrence 1022 // more close occurrence
1021 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); 1023 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
1022 qHeapSort( nonRepeats.begin(), nonRepeats.end() ); 1024 qHeapSort( nonRepeats.begin(), nonRepeats.end() );
1023 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { 1025 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
1024 if ( catComp( (*it).categories(), category ) ) { 1026 if ( catComp( (*it).categories(), category ) ) {
1025 if ( (*it).start() < dtEnd ) { 1027 if ( (*it).start() < dtEnd ) {
1026 if ( (*it).match( r ) && !(*it <= nonrev) ) { 1028 if ( (*it).match( r ) && !(*it <= nonrev) ) {
1027 nonrev = *it; 1029 nonrev = *it;
1028 dtEnd = nonrev.start(); 1030 dtEnd = nonrev.start();
1029 candidtate = true; 1031 candidtate = true;
1030 wrapAround = true; 1032 wrapAround = true;
1031 break; 1033 break;
1032 } 1034 }
1033 } 1035 }
1034 } 1036 }
1035 } 1037 }
1036 if ( candidtate ) { 1038 if ( candidtate ) {
1037 dayView->setStartViewTime( dtEnd.time().hour() ); 1039 dayView->setStartViewTime( dtEnd.time().hour() );
1038 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), 1040 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(),
1039 dtEnd.date().day() ); 1041 dtEnd.date().day() );
1040 } else { 1042 } else {
1041 if ( wrapAround ) { 1043 if ( wrapAround ) {
1042 emit signalWrapAround(); 1044 emit signalWrapAround();
1043 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 1045 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
1044 nonrev.setStart( rev.start() ); 1046 nonrev.setStart( rev.start() );
1045 } else 1047 } else
1046 emit signalNotFound(); 1048 emit signalNotFound();
1047 wrapAround = !wrapAround; 1049 wrapAround = !wrapAround;
1048 } 1050 }
1049} 1051}
1050 1052
1051Event DateBookDBHack::eventByUID(int uid) { 1053Event DateBookDBHack::eventByUID(int uid) {
1052 1054
1053 // FIXME: Dirty Hacks to get hold of the private event lists 1055 // FIXME: Dirty Hacks to get hold of the private event lists
1054 QDate start; 1056 QDate start;
1055 QDate end=start.addDays(-1); 1057 QDate end=start.addDays(-1);
1056 QValueList<Event> myEventList=getNonRepeatingEvents(start,end); 1058 QValueList<Event> myEventList=getNonRepeatingEvents(start,end);
1057 QValueList<Event> myRepeatEvents=getRawRepeats(); 1059 QValueList<Event> myRepeatEvents=getRawRepeats();
1058 1060
1059 QValueList<Event>::ConstIterator it; 1061 QValueList<Event>::ConstIterator it;
1060 1062
1061 for (it = myEventList.begin(); it != myEventList.end(); it++) { 1063 for (it = myEventList.begin(); it != myEventList.end(); it++) {
1062 if ((*it).uid() == uid) return *it; 1064 if ((*it).uid() == uid) return *it;
1063 } 1065 }
1064 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { 1066 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) {
1065 if ((*it).uid() == uid) return *it; 1067 if ((*it).uid() == uid) return *it;
1066 } 1068 }
1067 1069
1068 Event ev; 1070 Event ev;
1069 return ev; // return at least 1071 return ev; // return at least
1070} 1072}
diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro
index bf9a2cc..a79c25c 100644
--- a/core/pim/datebook/datebook.pro
+++ b/core/pim/datebook/datebook.pro
@@ -1,41 +1,41 @@
1 CONFIG += qt warn_on quick-app 1 CONFIG += qt warn_on quick-app
2 HEADERS= datebookday.h \ 2 HEADERS= datebookday.h \
3 datebook.h \ 3 datebook.h \
4 dateentryimpl.h \ 4 dateentryimpl.h \
5 datebookdayheaderimpl.h \ 5 datebookdayheaderimpl.h \
6 datebooksettings.h \ 6 datebooksettings.h \
7 datebookweek.h \ 7 datebookweek.h \
8 datebookweeklst.h \ 8 datebookweeklst.h \
9 datebookweekheaderimpl.h \ 9 datebookweekheaderimpl.h \
10 repeatentry.h \ 10 repeatentry.h \
11 noteentryimpl.h \ 11 noteentryimpl.h \
12 onoteedit.h \ 12 onoteedit.h \
13 datebookdayallday.h \ 13 datebookdayallday.h \
14 namespace_hack.h 14 namespace_hack.h
15 SOURCES= main.cpp \ 15 SOURCES= main.cpp \
16 datebookday.cpp \ 16 datebookday.cpp \
17 datebook.cpp \ 17 datebook.cpp \
18 dateentryimpl.cpp \ 18 dateentryimpl.cpp \
19 datebookdayheaderimpl.cpp \ 19 datebookdayheaderimpl.cpp \
20 datebooksettings.cpp \ 20 datebooksettings.cpp \
21 datebookweek.cpp \ 21 datebookweek.cpp \
22 datebookweeklst.cpp \ 22 datebookweeklst.cpp \
23 datebookweekheaderimpl.cpp \ 23 datebookweekheaderimpl.cpp \
24 repeatentry.cpp \ 24 repeatentry.cpp \
25 noteentryimpl.cpp \ 25 noteentryimpl.cpp \
26 onoteedit.cpp \ 26 onoteedit.cpp \
27 datebookdayallday.cpp 27 datebookdayallday.cpp
28 INTERFACES= dateentry.ui \ 28 INTERFACES= dateentry.ui \
29 datebookdayheader.ui \ 29 datebookdayheader.ui \
30 datebookweekheader.ui \ 30 datebookweekheader.ui \
31 datebookweeklstheader.ui \ 31 datebookweeklstheader.ui \
32 datebookweeklstdayhdr.ui \ 32 datebookweeklstdayhdr.ui \
33 repeatentrybase.ui \ 33 repeatentrybase.ui \
34 datebooksettingsbase.ui \ 34 datebooksettingsbase.ui \
35 noteentry.ui 35 noteentry.ui
36INCLUDEPATH += $(OPIEDIR)/include 36INCLUDEPATH += $(OPIEDIR)/include
37 DEPENDPATH+= $(OPIEDIR)/include 37 DEPENDPATH+= $(OPIEDIR)/include
38LIBS += -lqpe -lopieui2 -lopiecore2 38LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2
39 TARGET = datebook 39 TARGET = datebook
40 40
41include ( $(OPIEDIR)/include.pro ) 41include ( $(OPIEDIR)/include.pro )
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index c237b2d..123a478 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -1,120 +1,123 @@
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 "datebookweekheaderimpl.h" 20#include "datebookweekheaderimpl.h"
21#include "datebookweek.h" 21#include "datebookweek.h"
22
23#include <opie2/odebug.h>
24
22#include <qpe/resource.h> 25#include <qpe/resource.h>
23#include <qpe/datebookmonth.h> 26#include <qpe/datebookmonth.h>
24 27
25#include <qtoolbutton.h> 28#include <qtoolbutton.h>
26 29
27/* 30/*
28 * Constructs a DateBookWeekHeader which is a child of 'parent', with the 31 * Constructs a DateBookWeekHeader which is a child of 'parent', with the
29 * name 'name' and widget flags set to 'f' 32 * name 'name' and widget flags set to 'f'
30 */ 33 */
31DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) 34DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl )
32 : DateBookWeekHeaderBase( parent, name, fl ), 35 : DateBookWeekHeaderBase( parent, name, fl ),
33 bStartOnMonday( startOnMonday ) 36 bStartOnMonday( startOnMonday )
34{ 37{
35 setBackgroundMode( PaletteButton ); 38 setBackgroundMode( PaletteButton );
36 labelDate->setBackgroundMode( PaletteButton ); 39 labelDate->setBackgroundMode( PaletteButton );
37 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 40 backmonth->setPixmap( Resource::loadPixmap("fastback") );
38 backweek->setPixmap( Resource::loadPixmap("back") ); 41 backweek->setPixmap( Resource::loadPixmap("back") );
39 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 42 forwardweek->setPixmap( Resource::loadPixmap("forward") );
40 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 43 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
41} 44}
42 45
43/* 46/*
44 * Destroys the object and frees any allocated resources 47 * Destroys the object and frees any allocated resources
45 */ 48 */
46DateBookWeekHeader::~DateBookWeekHeader() 49DateBookWeekHeader::~DateBookWeekHeader()
47{ 50{
48 // no need to delete child widgets, Qt does it all for us 51 // no need to delete child widgets, Qt does it all for us
49} 52}
50 53
51void DateBookWeekHeader::pickDate() 54void DateBookWeekHeader::pickDate()
52{ 55{
53 static QPopupMenu *m1 = 0; 56 static QPopupMenu *m1 = 0;
54 static DateBookMonth *picker = 0; 57 static DateBookMonth *picker = 0;
55 if ( !m1 ) { 58 if ( !m1 ) {
56 m1 = new QPopupMenu( this ); 59 m1 = new QPopupMenu( this );
57 picker = new DateBookMonth( m1, 0, TRUE ); 60 picker = new DateBookMonth( m1, 0, TRUE );
58 m1->insertItem( picker ); 61 m1->insertItem( picker );
59 connect( picker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( setDate(int,int,int) ) ); 62 connect( picker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( setDate(int,int,int) ) );
60 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); 63 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) );
61 } 64 }
62 picker->setDate( date.year(), date.month(), date.day() ); 65 picker->setDate( date.year(), date.month(), date.day() );
63 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 66 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
64 picker->setFocus(); 67 picker->setFocus();
65} 68}
66 69
67void DateBookWeekHeader::nextMonth() 70void DateBookWeekHeader::nextMonth()
68{ 71{
69 qWarning("nextMonth() " ); 72 Opie::Core::owarn << "nextMonth()" << oendl;
70 setDate(date.addDays(28)); 73 setDate(date.addDays(28));
71} 74}
72void DateBookWeekHeader::prevMonth() 75void DateBookWeekHeader::prevMonth()
73{ 76{
74 qWarning("prevMonth() " ); 77 Opie::Core::owarn << "prevMonth()" << oendl;
75 setDate(date.addDays(-28)); 78 setDate(date.addDays(-28));
76} 79}
77void DateBookWeekHeader::nextWeek() 80void DateBookWeekHeader::nextWeek()
78{ 81{
79 qWarning("nextWeek() " ); 82 Opie::Core::owarn << "nextWeek()" << oendl;
80 setDate(date.addDays(7)); 83 setDate(date.addDays(7));
81} 84}
82void DateBookWeekHeader::prevWeek() 85void DateBookWeekHeader::prevWeek()
83{ 86{
84 qWarning("prevWeek() "); 87 Opie::Core::owarn << "prevWeek()" << oendl;
85 setDate(date.addDays(-7)); 88 setDate(date.addDays(-7));
86} 89}
87 90
88void DateBookWeekHeader::setDate( int y, int m, int d ) 91void DateBookWeekHeader::setDate( int y, int m, int d )
89{ 92{
90 setDate(QDate(y,m,d)); 93 setDate(QDate(y,m,d));
91} 94}
92 95
93void DateBookWeekHeader::setDate(const QDate &d) { 96void DateBookWeekHeader::setDate(const QDate &d) {
94 int year,week,dayofweek; 97 int year,week,dayofweek;
95 date=d; 98 date=d;
96 dayofweek=d.dayOfWeek(); 99 dayofweek=d.dayOfWeek();
97 if(bStartOnMonday) 100 if(bStartOnMonday)
98 dayofweek--; 101 dayofweek--;
99 else if( dayofweek == 7 ) 102 else if( dayofweek == 7 )
100 // we already have the right day -7 would lead to the current week.. 103 // we already have the right day -7 would lead to the current week..
101 dayofweek = 0; 104 dayofweek = 0;
102 105
103 date=date.addDays(-dayofweek); 106 date=date.addDays(-dayofweek);
104 calcWeek(date,week,year,bStartOnMonday); 107 calcWeek(date,week,year,bStartOnMonday);
105 QDate start=date; 108 QDate start=date;
106 QDate stop=start.addDays(6); 109 QDate stop=start.addDays(6);
107 labelDate->setText( QString::number(start.day()) + "." + 110 labelDate->setText( QString::number(start.day()) + "." +
108 Calendar::nameOfMonth( start.month()) + "-" + 111 Calendar::nameOfMonth( start.month()) + "-" +
109 QString::number(stop.day()) + "." + 112 QString::number(stop.day()) + "." +
110 Calendar::nameOfMonth( stop.month()) +" ("+ 113 Calendar::nameOfMonth( stop.month()) +" ("+
111 tr("w")+":"+QString::number( week ) +")"); 114 tr("w")+":"+QString::number( week ) +")");
112 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 115 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
113 emit dateChanged(date); 116 emit dateChanged(date);
114} 117}
115 118
116void DateBookWeekHeader::setStartOfWeek( bool onMonday ) 119void DateBookWeekHeader::setStartOfWeek( bool onMonday )
117{ 120{
118 bStartOnMonday = onMonday; 121 bStartOnMonday = onMonday;
119 setDate( date ); 122 setDate( date );
120} 123}
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index abaf3ea..de74d46 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,396 +1,397 @@
1#include "namespace_hack.h" 1#include "namespace_hack.h"
2#include "datebookweeklst.h" 2#include "datebookweeklst.h"
3 3
4
5#include "datebook.h" 4#include "datebook.h"
6 5
6#include <opie2/odebug.h>
7
7#include <qpe/datebookmonth.h> 8#include <qpe/datebookmonth.h>
8#include <qpe/config.h> 9#include <qpe/config.h>
9#include <qpe/resource.h> 10#include <qpe/resource.h>
10 11
11#include <qlayout.h> 12#include <qlayout.h>
12#include <qtoolbutton.h> 13#include <qtoolbutton.h>
13#include <qtl.h> 14#include <qtl.h>
14 15
15bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); 16bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
16 17
17using namespace Opie::Ui; 18using namespace Opie::Ui;
18DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) 19DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
19 : DateBookWeekLstHeaderBase(parent, name, fl) 20 : DateBookWeekLstHeaderBase(parent, name, fl)
20{ 21{
21 setBackgroundMode( PaletteButton ); 22 setBackgroundMode( PaletteButton );
22 labelDate->setBackgroundMode( PaletteButton ); 23 labelDate->setBackgroundMode( PaletteButton );
23 forwardweek->setBackgroundMode( PaletteButton ); 24 forwardweek->setBackgroundMode( PaletteButton );
24 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 25 forwardweek->setPixmap( Resource::loadPixmap("forward") );
25 forwardmonth->setBackgroundMode( PaletteButton ); 26 forwardmonth->setBackgroundMode( PaletteButton );
26 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 27 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
27 backweek->setBackgroundMode( PaletteButton ); 28 backweek->setBackgroundMode( PaletteButton );
28 backweek->setPixmap( Resource::loadPixmap("back") ); 29 backweek->setPixmap( Resource::loadPixmap("back") );
29 backmonth->setBackgroundMode( PaletteButton ); 30 backmonth->setBackgroundMode( PaletteButton );
30 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 31 backmonth->setPixmap( Resource::loadPixmap("fastback") );
31 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 32 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
32 DateBookWeekLstHeaderBaseLayout->setMargin(0); 33 DateBookWeekLstHeaderBaseLayout->setMargin(0);
33 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 34 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
34 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 35 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
35 36
36 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); 37 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
37 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); 38 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
38 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); 39 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
39 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); 40 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
40 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); 41 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
41 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 42 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
42 bStartOnMonday=onM; 43 bStartOnMonday=onM;
43} 44}
44DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 45DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
45 46
46void DateBookWeekLstHeader::setDate(const QDate &d) { 47void DateBookWeekLstHeader::setDate(const QDate &d) {
47 int year,week,dayofweek; 48 int year,week,dayofweek;
48 date=d; 49 date=d;
49 dayofweek=d.dayOfWeek(); 50 dayofweek=d.dayOfWeek();
50 if(bStartOnMonday) 51 if(bStartOnMonday)
51 dayofweek--; 52 dayofweek--;
52 else if( dayofweek == 7 ) 53 else if( dayofweek == 7 )
53 /* we already have the right day -7 would lead to the same week */ 54 /* we already have the right day -7 would lead to the same week */
54 dayofweek = 0; 55 dayofweek = 0;
55 56
56 date=date.addDays(-dayofweek); 57 date=date.addDays(-dayofweek);
57 58
58 calcWeek(date,week,year,bStartOnMonday); 59 calcWeek(date,week,year,bStartOnMonday);
59 QDate start=date; 60 QDate start=date;
60 QDate stop=start.addDays(6); 61 QDate stop=start.addDays(6);
61 labelDate->setText( QString::number(start.day()) + "." + 62 labelDate->setText( QString::number(start.day()) + "." +
62 Calendar::nameOfMonth( start.month() ) + "-" + 63 Calendar::nameOfMonth( start.month() ) + "-" +
63 QString::number(stop.day()) + "." + 64 QString::number(stop.day()) + "." +
64 Calendar::nameOfMonth( stop.month()) +" ("+ 65 Calendar::nameOfMonth( stop.month()) +" ("+
65 tr("w")+":"+QString::number( week ) +")"); 66 tr("w")+":"+QString::number( week ) +")");
66 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 67 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
67 emit dateChanged(date); 68 emit dateChanged(date);
68} 69}
69 70
70void DateBookWeekLstHeader::pickDate() { 71void DateBookWeekLstHeader::pickDate() {
71 static QPopupMenu *m1 = 0; 72 static QPopupMenu *m1 = 0;
72 static DateBookMonth *picker = 0; 73 static DateBookMonth *picker = 0;
73 if ( !m1 ) { 74 if ( !m1 ) {
74 m1 = new QPopupMenu( this ); 75 m1 = new QPopupMenu( this );
75 picker = new DateBookMonth( m1, 0, TRUE ); 76 picker = new DateBookMonth( m1, 0, TRUE );
76 m1->insertItem( picker ); 77 m1->insertItem( picker );
77 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); 78 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) );
78 //connect( m1, SIGNAL( aboutToHide() ), 79 //connect( m1, SIGNAL( aboutToHide() ),
79 //this, SLOT( gotHide() ) ); 80 //this, SLOT( gotHide() ) );
80 } 81 }
81 picker->setDate( date.year(), date.month(), date.day() ); 82 picker->setDate( date.year(), date.month(), date.day() );
82 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 83 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
83 picker->setFocus(); 84 picker->setFocus();
84} 85}
85void DateBookWeekLstHeader::setDate(int y, int m, int d) { 86void DateBookWeekLstHeader::setDate(int y, int m, int d) {
86 setDate(QDate(y,m,d)); 87 setDate(QDate(y,m,d));
87} 88}
88 89
89void DateBookWeekLstHeader::nextWeek() { 90void DateBookWeekLstHeader::nextWeek() {
90 setDate(date.addDays(7)); 91 setDate(date.addDays(7));
91} 92}
92void DateBookWeekLstHeader::prevWeek() { 93void DateBookWeekLstHeader::prevWeek() {
93 setDate(date.addDays(-7)); 94 setDate(date.addDays(-7));
94} 95}
95void DateBookWeekLstHeader::nextMonth() 96void DateBookWeekLstHeader::nextMonth()
96{ 97{
97 setDate(date.addDays(28)); 98 setDate(date.addDays(28));
98} 99}
99void DateBookWeekLstHeader::prevMonth() 100void DateBookWeekLstHeader::prevMonth()
100{ 101{
101 setDate(date.addDays(-28)); 102 setDate(date.addDays(-28));
102} 103}
103 104
104DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, 105DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
105 QWidget* parent, 106 QWidget* parent,
106 const char* name, 107 const char* name,
107 WFlags fl ) 108 WFlags fl )
108 : DateBookWeekLstDayHdrBase(parent, name, fl) { 109 : DateBookWeekLstDayHdrBase(parent, name, fl) {
109 110
110 date=d; 111 date=d;
111 112
112 static const QString wdays=tr("MTWTFSSM", "Week days"); 113 static const QString wdays=tr("MTWTFSSM", "Week days");
113 char day=wdays[d.dayOfWeek()-1]; 114 char day=wdays[d.dayOfWeek()-1];
114 115
115 //dont use dayOfWeek() to save space ! 116 //dont use dayOfWeek() to save space !
116 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); 117 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
117 118
118 add->setText("+"); 119 add->setText("+");
119 120
120 if (d == QDate::currentDate()) { 121 if (d == QDate::currentDate()) {
121 QPalette pal=label->palette(); 122 QPalette pal=label->palette();
122 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 123 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
123 label->setPalette(pal); 124 label->setPalette(pal);
124 125
125 /* 126 /*
126 QFont f=label->font(); 127 QFont f=label->font();
127 f.setItalic(true); 128 f.setItalic(true);
128 label->setFont(f); 129 label->setFont(f);
129 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 130 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
130 */ 131 */
131 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 132 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
132 QPalette pal=label->palette(); 133 QPalette pal=label->palette();
133 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 134 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
134 label->setPalette(pal); 135 label->setPalette(pal);
135 } 136 }
136 137
137 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 138 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
138 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 139 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
139} 140}
140 141
141void DateBookWeekLstDayHdr::showDay() { 142void DateBookWeekLstDayHdr::showDay() {
142 emit showDate(date.year(), date.month(), date.day()); 143 emit showDate(date.year(), date.month(), date.day());
143} 144}
144 145
145void DateBookWeekLstDayHdr::newEvent() { 146void DateBookWeekLstDayHdr::newEvent() {
146 QDateTime start, stop; 147 QDateTime start, stop;
147 start=stop=date; 148 start=stop=date;
148 start.setTime(QTime(10,0)); 149 start.setTime(QTime(10,0));
149 stop.setTime(QTime(12,0)); 150 stop.setTime(QTime(12,0));
150 151
151 emit addEvent(start,stop,"",0); 152 emit addEvent(start,stop,"",0);
152} 153}
153DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 154DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
154 int weeklistviewconfig, 155 int weeklistviewconfig,
155 QWidget* parent, 156 QWidget* parent,
156 const char* name, 157 const char* name,
157 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) 158 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
158{ 159{
159 // old values... lastday = "__|__", middle=" |---", Firstday="00:00", 160 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
160 QString s,start,middle,end,day; 161 QString s,start,middle,end,day;
161 162
162 qDebug("weeklistviewconfig=%d",weeklistviewconfig); 163 Opie::Core::odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl;
163 if(weeklistviewconfig==NONE) {// No times displayed. 164 if(weeklistviewconfig==NONE) {// No times displayed.
164 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 165 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
165 // middle.sprintf("<--->"); 166 // middle.sprintf("<--->");
166 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 167 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
167 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 168 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
168 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. 169 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time.
169 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 170 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
170 middle.sprintf(" |---"); 171 middle.sprintf(" |---");
171 end.sprintf("__|__"); 172 end.sprintf("__|__");
172 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 173 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
173 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. 174 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
174 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 175 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
175 middle.sprintf("<--->"); 176 middle.sprintf("<--->");
176 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 177 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
177 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 178 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
178 } 179 }
179 180
180 if(ev.event().type() == Event::Normal) { 181 if(ev.event().type() == Event::Normal) {
181 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. 182 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event.
182 s=day; 183 s=day;
183 } else if(ev.startDate()==ev.date()) {// start event. 184 } else if(ev.startDate()==ev.date()) {// start event.
184 s=start; 185 s=start;
185 } else if(ev.endDate()==ev.date()) { // end event. 186 } else if(ev.endDate()==ev.date()) { // end event.
186 s=end; 187 s=end;
187 } else {// middle day. 188 } else {// middle day.
188 s=middle; 189 s=middle;
189 } 190 }
190 } else { 191 } else {
191 s=""; 192 s="";
192 } 193 }
193 setText(QString(s) + " " + ev.description()); 194 setText(QString(s) + " " + ev.description());
194 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 195 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
195 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 196 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
196} 197}
197void DateBookWeekLstEvent::editMe() { 198void DateBookWeekLstEvent::editMe() {
198 emit editEvent(event.event()); 199 emit editEvent(event.event());
199} 200}
200 201
201 202
202DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 203DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
203 const QDate &d, bool onM, 204 const QDate &d, bool onM,
204 QWidget* parent, 205 QWidget* parent,
205 const char* name, WFlags fl) 206 const char* name, WFlags fl)
206 : QWidget( parent, name, fl ) 207 : QWidget( parent, name, fl )
207{ 208{
208 Config config("DateBook"); 209 Config config("DateBook");
209 config.setGroup("Main"); 210 config.setGroup("Main");
210 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); 211 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
211 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); 212 Opie::Core::odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl;
212 213
213 bStartOnMonday=onM; 214 bStartOnMonday=onM;
214 setPalette(white); 215 setPalette(white);
215 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 216 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
216 217
217 QVBoxLayout *layout = new QVBoxLayout( this ); 218 QVBoxLayout *layout = new QVBoxLayout( this );
218 219
219 qBubbleSort(ev); 220 qBubbleSort(ev);
220 QValueListIterator<EffectiveEvent> it; 221 QValueListIterator<EffectiveEvent> it;
221 it=ev.begin(); 222 it=ev.begin();
222 223
223 int dayOrder[7]; 224 int dayOrder[7];
224 if (bStartOnMonday) { 225 if (bStartOnMonday) {
225 for (int d=0; d<7; d++) dayOrder[d]=d+1; 226 for (int d=0; d<7; d++) dayOrder[d]=d+1;
226 } else { 227 } else {
227 for (int d=0; d<7; d++) dayOrder[d]=d; 228 for (int d=0; d<7; d++) dayOrder[d]=d;
228 dayOrder[0]=7; 229 dayOrder[0]=7;
229 } 230 }
230 231
231 // Calculate offset to first day of week. 232 // Calculate offset to first day of week.
232 int dayoffset=d.dayOfWeek(); 233 int dayoffset=d.dayOfWeek();
233 if(bStartOnMonday) dayoffset--; 234 if(bStartOnMonday) dayoffset--;
234 else if( dayoffset == 7 ) dayoffset = 0; 235 else if( dayoffset == 7 ) dayoffset = 0;
235 236
236 for (int i=0; i<7; i++) { 237 for (int i=0; i<7; i++) {
237 // Header 238 // Header
238 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); 239 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
239 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 240 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
240 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 241 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
241 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 242 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
242 layout->addWidget(hdr); 243 layout->addWidget(hdr);
243 244
244 // Events 245 // Events
245 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 246 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
246 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. 247 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day.
247 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); 248 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
248 layout->addWidget(l); 249 layout->addWidget(l);
249 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 250 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
250 } 251 }
251 it++; 252 it++;
252 } 253 }
253 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 254 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
254 } 255 }
255} 256}
256DateBookWeekLstView::~DateBookWeekLstView(){} 257DateBookWeekLstView::~DateBookWeekLstView(){}
257void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 258void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
258 259
259DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 260DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
260 QValueList<EffectiveEvent> &ev2, 261 QValueList<EffectiveEvent> &ev2,
261 QDate &d, bool onM, 262 QDate &d, bool onM,
262 QWidget* parent, 263 QWidget* parent,
263 const char* name, WFlags fl) 264 const char* name, WFlags fl)
264 : QWidget( parent, name, fl ) 265 : QWidget( parent, name, fl )
265{ 266{
266 QHBoxLayout *layout = new QHBoxLayout( this ); 267 QHBoxLayout *layout = new QHBoxLayout( this );
267 268
268 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 269 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
269 layout->addWidget(w); 270 layout->addWidget(w);
270 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 271 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
271 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 272 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
272 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 273 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
273 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 274 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
274 275
275 276
276 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 277 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
277 layout->addWidget(w); 278 layout->addWidget(w);
278 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 279 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
279 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 280 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
280 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 281 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
281 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 282 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
282} 283}
283 284
284DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 285DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
285 QWidget *parent, 286 QWidget *parent,
286 const char *name ) 287 const char *name )
287 : QWidget( parent, name ), 288 : QWidget( parent, name ),
288 db( newDB ), 289 db( newDB ),
289 startTime( 0 ), 290 startTime( 0 ),
290 ampm( ap ), 291 ampm( ap ),
291 bStartOnMonday(onM) 292 bStartOnMonday(onM)
292{ 293{
293 setFocusPolicy(StrongFocus); 294 setFocusPolicy(StrongFocus);
294 layout = new QVBoxLayout( this ); 295 layout = new QVBoxLayout( this );
295 layout->setMargin(0); 296 layout->setMargin(0);
296 297
297 header=new DateBookWeekLstHeader(onM, this); 298 header=new DateBookWeekLstHeader(onM, this);
298 layout->addWidget( header ); 299 layout->addWidget( header );
299 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); 300 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
300 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 301 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
301 302
302 scroll=new QScrollView(this); 303 scroll=new QScrollView(this);
303 scroll->setResizePolicy(QScrollView::AutoOneFit); 304 scroll->setResizePolicy(QScrollView::AutoOneFit);
304 layout->addWidget(scroll); 305 layout->addWidget(scroll);
305 306
306 view=NULL; 307 view=NULL;
307 Config config("DateBook"); 308 Config config("DateBook");
308 config.setGroup("Main"); 309 config.setGroup("Main");
309 dbl=config.readBoolEntry("weeklst_dbl", false); 310 dbl=config.readBoolEntry("weeklst_dbl", false);
310 header->dbl->setOn(dbl); 311 header->dbl->setOn(dbl);
311} 312}
312DateBookWeekLst::~DateBookWeekLst(){ 313DateBookWeekLst::~DateBookWeekLst(){
313 Config config("DateBook"); 314 Config config("DateBook");
314 config.setGroup("Main"); 315 config.setGroup("Main");
315 config.writeEntry("weeklst_dbl", dbl); 316 config.writeEntry("weeklst_dbl", dbl);
316} 317}
317 318
318void DateBookWeekLst::setDate(const QDate &d) { 319void DateBookWeekLst::setDate(const QDate &d) {
319 bdate=d; 320 bdate=d;
320 header->setDate(d); 321 header->setDate(d);
321} 322}
322 323
323void DateBookWeekLst::setDbl(bool on) { 324void DateBookWeekLst::setDbl(bool on) {
324 dbl=on; 325 dbl=on;
325 redraw(); 326 redraw();
326} 327}
327void DateBookWeekLst::redraw() {getEvents();} 328void DateBookWeekLst::redraw() {getEvents();}
328 329
329QDate DateBookWeekLst::date() { 330QDate DateBookWeekLst::date() {
330 return bdate; 331 return bdate;
331} 332}
332 333
333// return the date at the beginning of the week... 334// return the date at the beginning of the week...
334// copied from DateBookWeek 335// copied from DateBookWeek
335QDate DateBookWeekLst::weekDate() const 336QDate DateBookWeekLst::weekDate() const
336{ 337{
337 QDate d=bdate; 338 QDate d=bdate;
338 339
339 // Calculate offset to first day of week. 340 // Calculate offset to first day of week.
340 int dayoffset=d.dayOfWeek(); 341 int dayoffset=d.dayOfWeek();
341 if(bStartOnMonday) dayoffset--; 342 if(bStartOnMonday) dayoffset--;
342 else if( dayoffset == 7 ) 343 else if( dayoffset == 7 )
343 dayoffset = 0; 344 dayoffset = 0;
344 345
345 return d.addDays(-dayoffset); 346 return d.addDays(-dayoffset);
346} 347}
347 348
348void DateBookWeekLst::getEvents() { 349void DateBookWeekLst::getEvents() {
349 QDate start = weekDate(); //date(); 350 QDate start = weekDate(); //date();
350 QDate stop = start.addDays(6); 351 QDate stop = start.addDays(6);
351 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 352 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
352 353
353 if (view) delete view; 354 if (view) delete view;
354 if (dbl) { 355 if (dbl) {
355 QDate start2=start.addDays(7); 356 QDate start2=start.addDays(7);
356 stop=start2.addDays(6); 357 stop=start2.addDays(6);
357 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 358 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
358 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 359 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
359 } else { 360 } else {
360 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); 361 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
361 } 362 }
362 363
363 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 364 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
364 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 365 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
365 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 366 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
366 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 367 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
367 368
368 scroll->addChild(view); 369 scroll->addChild(view);
369 view->show(); 370 view->show();
370 scroll->updateScrollBars(); 371 scroll->updateScrollBars();
371} 372}
372 373
373void DateBookWeekLst::dateChanged(QDate &newdate) { 374void DateBookWeekLst::dateChanged(QDate &newdate) {
374 bdate=newdate; 375 bdate=newdate;
375 getEvents(); 376 getEvents();
376} 377}
377 378
378void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 379void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
379{ 380{
380 switch(e->key()) { 381 switch(e->key()) {
381 case Key_Up: 382 case Key_Up:
382 scroll->scrollBy(0, -20); 383 scroll->scrollBy(0, -20);
383 break; 384 break;
384 case Key_Down: 385 case Key_Down:
385 scroll->scrollBy(0, 20); 386 scroll->scrollBy(0, 20);
386 break; 387 break;
387 case Key_Left: 388 case Key_Left:
388 header->prevWeek(); 389 header->prevWeek();
389 break; 390 break;
390 case Key_Right: 391 case Key_Right:
391 header->nextWeek(); 392 header->nextWeek();
392 break; 393 break;
393 default: 394 default:
394 e->ignore(); 395 e->ignore();
395 } 396 }
396} 397}
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index 7b4716f..42bdbe2 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -1,560 +1,562 @@
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 "namespace_hack.h" 21#include "namespace_hack.h"
22#include "dateentryimpl.h" 22#include "dateentryimpl.h"
23#include "repeatentry.h" 23#include "repeatentry.h"
24 24
25#include <opie2/odebug.h>
26#include <opie2/otimepicker.h>
27
25#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
26#include <qpe/categoryselect.h> 29#include <qpe/categoryselect.h>
27#include <qpe/datebookmonth.h> 30#include <qpe/datebookmonth.h>
28#include <qpe/tzselect.h> 31#include <qpe/tzselect.h>
29 32
30#include <qlineedit.h> 33#include <qlineedit.h>
31#include <qspinbox.h> 34#include <qspinbox.h>
32 35
33#include <opie2/otimepicker.h>
34#include "onoteedit.h" 36#include "onoteedit.h"
35 37
36#include <stdlib.h> 38#include <stdlib.h>
37#include <stdio.h> 39#include <stdio.h>
38 40
39/* 41/*
40 * Constructs a DateEntry which is a child of 'parent', with the 42 * Constructs a DateEntry which is a child of 'parent', with the
41 * name 'name' and widget flags set to 'f' 43 * name 'name' and widget flags set to 'f'
42 * 44 *
43 * The dialog will by default be modeless, unless you set 'modal' to 45 * The dialog will by default be modeless, unless you set 'modal' to
44 * TRUE to construct a modal dialog. 46 * TRUE to construct a modal dialog.
45 */ 47 */
46 48
47DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, 49DateEntry::DateEntry( bool startOnMonday, const QDateTime &start,
48 const QDateTime &end, bool whichClock, QWidget* parent, 50 const QDateTime &end, bool whichClock, QWidget* parent,
49 const char* name ) 51 const char* name )
50 : DateEntryBase( parent, name ), 52 : DateEntryBase( parent, name ),
51 ampm( whichClock ), 53 ampm( whichClock ),
52 startWeekOnMonday( startOnMonday ), 54 startWeekOnMonday( startOnMonday ),
53 m_showStart(true) 55 m_showStart(true)
54{ 56{
55 init(); 57 init();
56 setDates(start,end); 58 setDates(start,end);
57 setFocusProxy(comboDescription); 59 setFocusProxy(comboDescription);
58} 60}
59 61
60bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) 62bool DateEntry::eventFilter(QObject *obj, QEvent *ev )
61{ 63{
62 if( ev->type() == QEvent::FocusIn ){ 64 if( ev->type() == QEvent::FocusIn ){
63 if( obj == comboStart ){ 65 if( obj == comboStart ){
64 timePickerStart->setHour(startTime.hour()); 66 timePickerStart->setHour(startTime.hour());
65 timePickerStart->setMinute(startTime.minute()); 67 timePickerStart->setMinute(startTime.minute());
66 TimePickerLabel->setText( tr("Start Time" ) ); 68 TimePickerLabel->setText( tr("Start Time" ) );
67 m_showStart= true; 69 m_showStart= true;
68 }else if( obj == comboEnd ){ 70 }else if( obj == comboEnd ){
69 timePickerStart->setHour(endTime.hour()); 71 timePickerStart->setHour(endTime.hour());
70 timePickerStart->setMinute(endTime.minute()); 72 timePickerStart->setMinute(endTime.minute());
71 TimePickerLabel->setText( tr("End Time") ); 73 TimePickerLabel->setText( tr("End Time") );
72 m_showStart = false; 74 m_showStart = false;
73 } 75 }
74 } else if( ev->type() == QEvent::FocusOut ){ 76 } else if( ev->type() == QEvent::FocusOut ){
75// if( obj == comboEnd ){ 77// if( obj == comboEnd ){
76// QString s; 78// QString s;
77// s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); 79// s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute());
78// comboEnd->setText(s); 80// comboEnd->setText(s);
79// } 81// }
80// else if( obj == comboStart ){ 82// else if( obj == comboStart ){
81// QString s; 83// QString s;
82// s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); 84// s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute());
83// comboStart->setText(s); 85// comboStart->setText(s);
84// } 86// }
85 } 87 }
86 88
87 return false; 89 return false;
88} 90}
89 91
90static void addOrPick( QComboBox* combo, const QString& t ) 92static void addOrPick( QComboBox* combo, const QString& t )
91{ 93{
92 // Pick an item if one excists 94 // Pick an item if one excists
93 for (int i=0; i<combo->count(); i++) { 95 for (int i=0; i<combo->count(); i++) {
94 if ( combo->text(i) == t ) { 96 if ( combo->text(i) == t ) {
95 combo->setCurrentItem(i); 97 combo->setCurrentItem(i);
96 return; 98 return;
97 } 99 }
98 } 100 }
99 101
100 // Else add one 102 // Else add one
101 combo->insertItem(t); 103 combo->insertItem(t);
102 combo->setCurrentItem(combo->count()-1); 104 combo->setCurrentItem(combo->count()-1);
103} 105}
104 106
105DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, 107DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock,
106 QWidget* parent, const char* name ) 108 QWidget* parent, const char* name )
107 : DateEntryBase( parent, name ), 109 : DateEntryBase( parent, name ),
108 ampm( whichClock ), 110 ampm( whichClock ),
109 startWeekOnMonday( startOnMonday ), 111 startWeekOnMonday( startOnMonday ),
110 m_showStart(true) 112 m_showStart(true)
111 113
112{ 114{
113 init(); 115 init();
114 setDates(event.start(),event.end()); 116 setDates(event.start(),event.end());
115 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); 117 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") );
116 if(!event.description().isEmpty()) 118 if(!event.description().isEmpty())
117 addOrPick( comboDescription, event.description() ); 119 addOrPick( comboDescription, event.description() );
118 if(!event.location().isEmpty()) 120 if(!event.location().isEmpty())
119 addOrPick( comboLocation, event.location() ); 121 addOrPick( comboLocation, event.location() );
120 checkAlarm->setChecked( event.hasAlarm() ); 122 checkAlarm->setChecked( event.hasAlarm() );
121 checkAllDay->setChecked( event.type() == Event::AllDay ); 123 checkAllDay->setChecked( event.type() == Event::AllDay );
122 if(!event.notes().isEmpty()) noteStr=event.notes(); 124 if(!event.notes().isEmpty()) noteStr=event.notes();
123 else noteStr=""; 125 else noteStr="";
124 spinAlarm->setValue(event.alarmTime()); 126 spinAlarm->setValue(event.alarmTime());
125 if ( event.alarmSound() != Event::Silent ) 127 if ( event.alarmSound() != Event::Silent )
126 comboSound->setCurrentItem( 1 ); 128 comboSound->setCurrentItem( 1 );
127 if ( event.hasRepeat() ) { 129 if ( event.hasRepeat() ) {
128 rp = event.repeatPattern(); 130 rp = event.repeatPattern();
129 cmdRepeat->setText( tr("Repeat...") ); 131 cmdRepeat->setText( tr("Repeat...") );
130 } 132 }
131 setRepeatLabel(); 133 setRepeatLabel();
132} 134}
133 135
134void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) 136void DateEntry::setDates( const QDateTime& s, const QDateTime& e )
135{ 137{
136 startDate = s.date(); 138 startDate = s.date();
137 endDate = e.date(); 139 endDate = e.date();
138 startTime = s.time(); 140 startTime = s.time();
139 endTime = e.time(); 141 endTime = e.time();
140 142
141 startDateChanged( s.date().year(), s.date().month(), s.date().day() ); 143 startDateChanged( s.date().year(), s.date().month(), s.date().day() );
142 endDateChanged( e.date().year(), e.date().month(), e.date().day() ); 144 endDateChanged( e.date().year(), e.date().month(), e.date().day() );
143 145
144 updateTimeEdit(true,true); 146 updateTimeEdit(true,true);
145} 147}
146 148
147void DateEntry::updateTimeEdit(bool s, bool e) { 149void DateEntry::updateTimeEdit(bool s, bool e) {
148 150
149 // Comboboxes 151 // Comboboxes
150 QString strStart, strEnd; 152 QString strStart, strEnd;
151 int shour, ehour; 153 int shour, ehour;
152 if ( ampm ) { 154 if ( ampm ) {
153 shour = startTime.hour(); 155 shour = startTime.hour();
154 ehour = endTime.hour(); 156 ehour = endTime.hour();
155 if ( shour >= 12 ) { 157 if ( shour >= 12 ) {
156 if ( shour > 12 ) 158 if ( shour > 12 )
157 shour -= 12; 159 shour -= 12;
158 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); 160 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() );
159 } else { 161 } else {
160 if ( shour == 0 ) 162 if ( shour == 0 )
161 shour = 12; 163 shour = 12;
162 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); 164 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() );
163 } 165 }
164 if ( ehour == 24 && endTime.minute() == 0 ) { 166 if ( ehour == 24 && endTime.minute() == 0 ) {
165 strEnd = "11:59 PM"; // or "midnight" 167 strEnd = "11:59 PM"; // or "midnight"
166 } else if ( ehour >= 12 ) { 168 } else if ( ehour >= 12 ) {
167 if ( ehour > 12 ) 169 if ( ehour > 12 )
168 ehour -= 12; 170 ehour -= 12;
169 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); 171 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() );
170 } else { 172 } else {
171 if ( ehour == 0 ) 173 if ( ehour == 0 )
172 ehour = 12; 174 ehour = 12;
173 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); 175 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() );
174 } 176 }
175 } else { 177 } else {
176 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); 178 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() );
177 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); 179 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() );
178 } 180 }
179 181
180 if (s) comboStart->setText(strStart); 182 if (s) comboStart->setText(strStart);
181 if (e) comboEnd->setText(strEnd); 183 if (e) comboEnd->setText(strEnd);
182} 184}
183 185
184void DateEntry::init() 186void DateEntry::init()
185{ 187{
186 comboDescription->setInsertionPolicy(QComboBox::AtCurrent); 188 comboDescription->setInsertionPolicy(QComboBox::AtCurrent);
187 comboLocation->setInsertionPolicy(QComboBox::AtCurrent); 189 comboLocation->setInsertionPolicy(QComboBox::AtCurrent);
188 190
189 initCombos(); 191 initCombos();
190 QPopupMenu *m1 = new QPopupMenu( this ); 192 QPopupMenu *m1 = new QPopupMenu( this );
191 startPicker = new DateBookMonth( m1, 0, TRUE ); 193 startPicker = new DateBookMonth( m1, 0, TRUE );
192 m1->insertItem( startPicker ); 194 m1->insertItem( startPicker );
193 buttonStart->setPopup( m1 ); 195 buttonStart->setPopup( m1 );
194 connect( startPicker, SIGNAL( dateClicked(int,int,int) ), 196 connect( startPicker, SIGNAL( dateClicked(int,int,int) ),
195 this, SLOT( startDateChanged(int,int,int) ) ); 197 this, SLOT( startDateChanged(int,int,int) ) );
196 198
197 //Let start button change both start and end dates 199 //Let start button change both start and end dates
198 connect( startPicker, SIGNAL( dateClicked(int,int,int) ), 200 connect( startPicker, SIGNAL( dateClicked(int,int,int) ),
199 this, SLOT( endDateChanged(int,int,int) ) ); 201 this, SLOT( endDateChanged(int,int,int) ) );
200 connect( qApp, SIGNAL( clockChanged(bool) ), 202 connect( qApp, SIGNAL( clockChanged(bool) ),
201 this, SLOT( slotChangeClock(bool) ) ); 203 this, SLOT( slotChangeClock(bool) ) );
202 connect( qApp, SIGNAL(weekChanged(bool)), 204 connect( qApp, SIGNAL(weekChanged(bool)),
203 this, SLOT(slotChangeStartOfWeek(bool)) ); 205 this, SLOT(slotChangeStartOfWeek(bool)) );
204 206
205 connect( editNote, SIGNAL(clicked()), 207 connect( editNote, SIGNAL(clicked()),
206 this, SLOT(slotEditNote()) ); 208 this, SLOT(slotEditNote()) );
207 209
208 QPopupMenu *m2 = new QPopupMenu( this ); 210 QPopupMenu *m2 = new QPopupMenu( this );
209 endPicker = new DateBookMonth( m2, 0, TRUE ); 211 endPicker = new DateBookMonth( m2, 0, TRUE );
210 m2->insertItem( endPicker ); 212 m2->insertItem( endPicker );
211 buttonEnd->setPopup( m2 ); 213 buttonEnd->setPopup( m2 );
212 connect( endPicker, SIGNAL( dateClicked(int,int,int) ), 214 connect( endPicker, SIGNAL( dateClicked(int,int,int) ),
213 this, SLOT( endDateChanged(int,int,int) ) ); 215 this, SLOT( endDateChanged(int,int,int) ) );
214 216
215 connect(timePickerStart, SIGNAL( timeChanged(const QTime&) ), 217 connect(timePickerStart, SIGNAL( timeChanged(const QTime&) ),
216 this, SLOT( startTimePicked(const QTime&) )); 218 this, SLOT( startTimePicked(const QTime&) ));
217 // install eventFilters 219 // install eventFilters
218 comboEnd->installEventFilter( this ); 220 comboEnd->installEventFilter( this );
219 comboStart->installEventFilter( this ); 221 comboStart->installEventFilter( this );
220} 222}
221 223
222/* 224/*
223 * Destroys the object and frees any allocated resources 225 * Destroys the object and frees any allocated resources
224 */ 226 */
225DateEntry::~DateEntry() 227DateEntry::~DateEntry()
226{ 228{
227 // no need to delete child widgets, Qt does it all for us 229 // no need to delete child widgets, Qt does it all for us
228 //cout << "Del: " << comboStart->currentText() << endl; 230 //cout << "Del: " << comboStart->currentText() << endl;
229} 231}
230 232
231/* 233/*
232 * public slot 234 * public slot
233 */ 235 */
234 236
235void DateEntry::slotEditNote() { 237void DateEntry::slotEditNote() {
236 QString s; 238 QString s;
237 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; 239 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>";
238// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); 240// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month());
239 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, 241 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr,
240 this,0,TRUE); 242 this,0,TRUE);
241 243
242 if ( QPEApplication::execDialog( &noteDlg ) ) { 244 if ( QPEApplication::execDialog( &noteDlg ) ) {
243 noteStr=noteDlg.note->text(); 245 noteStr=noteDlg.note->text();
244 } 246 }
245 247
246} 248}
247 249
248void DateEntry::endDateChanged( int y, int m, int d ) 250void DateEntry::endDateChanged( int y, int m, int d )
249{ 251{
250 endDate.setYMD( y, m, d ); 252 endDate.setYMD( y, m, d );
251 if ( endDate < startDate ) { 253 if ( endDate < startDate ) {
252 endDate = startDate; 254 endDate = startDate;
253 } 255 }
254 256
255 buttonEnd->setText( TimeString::shortDate( endDate ) ); 257 buttonEnd->setText( TimeString::shortDate( endDate ) );
256 258
257 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); 259 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() );
258} 260}
259 261
260static QTime parseTime( const QString& s, bool ampm ) 262static QTime parseTime( const QString& s, bool ampm )
261{ 263{
262 QTime tmpTime; 264 QTime tmpTime;
263 QStringList l = QStringList::split( ':', s ); 265 QStringList l = QStringList::split( ':', s );
264 int hour = l[0].toInt(); 266 int hour = l[0].toInt();
265 if ( ampm ) { 267 if ( ampm ) {
266 int i=0; 268 int i=0;
267 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') 269 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9')
268 i++; 270 i++;
269 QString digits = l[1].left(i); 271 QString digits = l[1].left(i);
270 if ( l[1].contains( "PM", FALSE ) ) { 272 if ( l[1].contains( "PM", FALSE ) ) {
271 if ( hour != 12 ) 273 if ( hour != 12 )
272 hour += 12; 274 hour += 12;
273 } else { 275 } else {
274 if ( hour == 12 ) 276 if ( hour == 12 )
275 hour = 0; 277 hour = 0;
276 } 278 }
277 l[1] = digits; 279 l[1] = digits;
278 } 280 }
279 int minute = l[1].toInt(); 281 int minute = l[1].toInt();
280 if ( minute > 59 ) 282 if ( minute > 59 )
281 minute = 59; 283 minute = 59;
282 else if ( minute < 0 ) 284 else if ( minute < 0 )
283 minute = 0; 285 minute = 0;
284 if ( hour > 23 ) { 286 if ( hour > 23 ) {
285 hour = 23; 287 hour = 23;
286 minute = 59; 288 minute = 59;
287 } else if ( hour < 0 ) 289 } else if ( hour < 0 )
288 hour = 0; 290 hour = 0;
289 tmpTime.setHMS( hour, minute, 0 ); 291 tmpTime.setHMS( hour, minute, 0 );
290 return tmpTime; 292 return tmpTime;
291} 293}
292 294
293/* 295/*
294 * public slot 296 * public slot
295 */ 297 */
296void DateEntry::endTimeChanged( const QString &s ) 298void DateEntry::endTimeChanged( const QString &s )
297{ 299{
298 endTimeChanged( parseTime(s,ampm) ); 300 endTimeChanged( parseTime(s,ampm) );
299} 301}
300 302
301void DateEntry::endTimeChanged( const QTime &t ) { 303void DateEntry::endTimeChanged( const QTime &t ) {
302 if ( endDate > startDate || t >= startTime ) { 304 if ( endDate > startDate || t >= startTime ) {
303 endTime = t; 305 endTime = t;
304 } else { 306 } else {
305 endTime = startTime; 307 endTime = startTime;
306 //comboEnd->setCurrentItem( comboStart->currentItem() ); 308 //comboEnd->setCurrentItem( comboStart->currentItem() );
307 } 309 }
308 timePickerStart->setHour(endTime.hour()); 310 timePickerStart->setHour(endTime.hour());
309 timePickerStart->setMinute(endTime.minute()); 311 timePickerStart->setMinute(endTime.minute());
310} 312}
311 313
312/* 314/*
313 * public slot 315 * public slot
314 */ 316 */
315void DateEntry::startDateChanged( int y, int m, int d ) 317void DateEntry::startDateChanged( int y, int m, int d )
316{ 318{
317 QDate prev = startDate; 319 QDate prev = startDate;
318 startDate.setYMD( y, m, d ); 320 startDate.setYMD( y, m, d );
319 if ( rp.type == Event::Weekly && 321 if ( rp.type == Event::Weekly &&
320 startDate.dayOfWeek() != prev.dayOfWeek() ) { 322 startDate.dayOfWeek() != prev.dayOfWeek() ) {
321 // if we change the start of a weekly repeating event 323 // if we change the start of a weekly repeating event
322 // set the repeating day appropriately 324 // set the repeating day appropriately
323 char mask = 1 << (prev.dayOfWeek()-1); 325 char mask = 1 << (prev.dayOfWeek()-1);
324 rp.days &= (~mask); 326 rp.days &= (~mask);
325 rp.days |= 1 << (startDate.dayOfWeek()-1); 327 rp.days |= 1 << (startDate.dayOfWeek()-1);
326 } 328 }
327 329
328 buttonStart->setText( TimeString::shortDate( startDate ) ); 330 buttonStart->setText( TimeString::shortDate( startDate ) );
329 331
330 // our pickers must be reset... 332 // our pickers must be reset...
331 startPicker->setDate( y, m, d ); 333 startPicker->setDate( y, m, d );
332 endPicker->setDate( y, m, d ); 334 endPicker->setDate( y, m, d );
333} 335}
334 336
335/* 337/*
336 * public slot 338 * public slot
337 */ 339 */
338void DateEntry::startTimeEdited( const QString &s ) 340void DateEntry::startTimeEdited( const QString &s )
339{ 341{
340 startTimeChanged(parseTime(s,ampm)); 342 startTimeChanged(parseTime(s,ampm));
341 updateTimeEdit(false,true); 343 updateTimeEdit(false,true);
342 timePickerStart->setHour(startTime.hour()); 344 timePickerStart->setHour(startTime.hour());
343 timePickerStart->setMinute(startTime.minute()); 345 timePickerStart->setMinute(startTime.minute());
344} 346}
345 347
346void DateEntry::startTimeChanged( const QTime &t ) 348void DateEntry::startTimeChanged( const QTime &t )
347{ 349{
348 int duration=startTime.secsTo(endTime); 350 int duration=startTime.secsTo(endTime);
349 startTime = t; 351 startTime = t;
350 endTime=t.addSecs(duration); 352 endTime=t.addSecs(duration);
351} 353}
352void DateEntry::startTimePicked( const QTime &t ) { 354void DateEntry::startTimePicked( const QTime &t ) {
353 if(m_showStart ){ 355 if(m_showStart ){
354 startTimeChanged(t); 356 startTimeChanged(t);
355 updateTimeEdit(true,true); 357 updateTimeEdit(true,true);
356 }else{ 358 }else{
357 endTimeChanged(t); 359 endTimeChanged(t);
358 updateTimeEdit(false, true ); 360 updateTimeEdit(false, true );
359 } 361 }
360} 362}
361 363
362/* 364/*
363 * public slot 365 * public slot
364 */ 366 */
365void DateEntry::typeChanged( const QString &s ) 367void DateEntry::typeChanged( const QString &s )
366{ 368{
367 bool b = s != "All Day"; 369 bool b = s != "All Day";
368 buttonStart->setEnabled( b ); 370 buttonStart->setEnabled( b );
369 comboStart->setEnabled( b ); 371 comboStart->setEnabled( b );
370 comboEnd->setEnabled( b ); 372 comboEnd->setEnabled( b );
371} 373}
372 374
373void DateEntry::slotRepeat() 375void DateEntry::slotRepeat()
374{ 376{
375 // Work around for compiler Bug.. 377 // Work around for compiler Bug..
376 RepeatEntry *e; 378 RepeatEntry *e;
377 379
378 // it is better in my opinion to just grab this from the mother, 380 // it is better in my opinion to just grab this from the mother,
379 // since, this dialog doesn't need to keep track of it... 381 // since, this dialog doesn't need to keep track of it...
380 if ( rp.type != Event::NoRepeat ) 382 if ( rp.type != Event::NoRepeat )
381 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); 383 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this);
382 else 384 else
383 e = new RepeatEntry( startWeekOnMonday, startDate, this ); 385 e = new RepeatEntry( startWeekOnMonday, startDate, this );
384 386
385 if ( QPEApplication::execDialog( e ) ) { 387 if ( QPEApplication::execDialog( e ) ) {
386 rp = e->repeatPattern(); 388 rp = e->repeatPattern();
387 setRepeatLabel(); 389 setRepeatLabel();
388 } 390 }
389 // deleting sounds like a nice idea... 391 // deleting sounds like a nice idea...
390 delete e; 392 delete e;
391} 393}
392 394
393void DateEntry::slotChangeStartOfWeek( bool onMonday ) 395void DateEntry::slotChangeStartOfWeek( bool onMonday )
394{ 396{
395 startWeekOnMonday = onMonday; 397 startWeekOnMonday = onMonday;
396} 398}
397 399
398Event DateEntry::event() 400Event DateEntry::event()
399{ 401{
400 Event ev; 402 Event ev;
401 Event::SoundTypeChoice st; 403 Event::SoundTypeChoice st;
402 ev.setDescription( comboDescription->currentText() ); 404 ev.setDescription( comboDescription->currentText() );
403 ev.setLocation( comboLocation->currentText() ); 405 ev.setLocation( comboLocation->currentText() );
404 ev.setCategories( comboCategory->currentCategories() ); 406 ev.setCategories( comboCategory->currentCategories() );
405 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); 407 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal );
406 if ( startDate > endDate ) { 408 if ( startDate > endDate ) {
407 QDate tmp = endDate; 409 QDate tmp = endDate;
408 endDate = startDate; 410 endDate = startDate;
409 startDate = tmp; 411 startDate = tmp;
410 } 412 }
411 413
412 // This is now done in the changed slots 414 // This is now done in the changed slots
413 // startTime = parseTime( comboStart->text(), ampm ); 415 // startTime = parseTime( comboStart->text(), ampm );
414 //endTime = parseTime( comboEnd->text(), ampm ); 416 //endTime = parseTime( comboEnd->text(), ampm );
415 417
416 if ( startTime > endTime && endDate == startDate ) { 418 if ( startTime > endTime && endDate == startDate ) {
417 QTime tmp = endTime; 419 QTime tmp = endTime;
418 endTime = startTime; 420 endTime = startTime;
419 startTime = tmp; 421 startTime = tmp;
420 } 422 }
421 // don't set the time if theres no need too 423 // don't set the time if theres no need too
422 if ( ev.type() == Event::AllDay ) { 424 if ( ev.type() == Event::AllDay ) {
423 startTime.setHMS( 0, 0, 0 ); 425 startTime.setHMS( 0, 0, 0 );
424 endTime.setHMS( 23, 59, 59 ); 426 endTime.setHMS( 23, 59, 59 );
425 } 427 }
426 428
427 // adjust start and end times based on timezone 429 // adjust start and end times based on timezone
428 QDateTime start( startDate, startTime ); 430 QDateTime start( startDate, startTime );
429 QDateTime end( endDate, endTime ); 431 QDateTime end( endDate, endTime );
430 time_t start_utc, end_utc; 432 time_t start_utc, end_utc;
431 433
432// qDebug( "tz: %s", timezone->currentZone().latin1() ); 434 //Opie::Core::odebug << "tz: " << timezone->currentZone() << oendl;
433 435
434 // get real timezone 436 // get real timezone
435 QString realTZ; 437 QString realTZ;
436 realTZ = QString::fromLocal8Bit( getenv("TZ") ); 438 realTZ = QString::fromLocal8Bit( getenv("TZ") );
437 439
438 // set timezone 440 // set timezone
439 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) 441 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 )
440 qWarning( "There was a problem setting the timezone." ); 442 Opie::Core::owarn << "There was a problem setting the timezone." << oendl;
441 443
442 // convert to UTC based on selected TZ (calling tzset internally) 444 // convert to UTC based on selected TZ (calling tzset internally)
443 start_utc = TimeConversion::toUTC( start ); 445 start_utc = TimeConversion::toUTC( start );
444 end_utc = TimeConversion::toUTC( end ); 446 end_utc = TimeConversion::toUTC( end );
445 447
446 // done playing around... put it all back 448 // done playing around... put it all back
447 unsetenv( "TZ" ); 449 unsetenv( "TZ" );
448 if ( !realTZ.isNull() ) 450 if ( !realTZ.isNull() )
449 if ( setenv( "TZ", realTZ, true ) != 0 ) 451 if ( setenv( "TZ", realTZ, true ) != 0 )
450 qWarning( "There was a problem setting the timezone." ); 452 Opie::Core::owarn << "There was a problem setting the timezone." << oendl;
451 453
452 // convert UTC to local time (calling tzset internally) 454 // convert UTC to local time (calling tzset internally)
453 ev.setStart( TimeConversion::fromUTC( start_utc ) ); 455 ev.setStart( TimeConversion::fromUTC( start_utc ) );
454 ev.setEnd( TimeConversion::fromUTC( end_utc ) ); 456 ev.setEnd( TimeConversion::fromUTC( end_utc ) );
455 457
456 // we only have one type of sound at the moment... LOUD!!! 458 // we only have one type of sound at the moment... LOUD!!!
457 if ( comboSound->currentItem() != 0 ) 459 if ( comboSound->currentItem() != 0 )
458 st = Event::Loud; 460 st = Event::Loud;
459 else 461 else
460 st = Event::Silent; 462 st = Event::Silent;
461 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st ); 463 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st );
462 if ( rp.type != Event::NoRepeat ) 464 if ( rp.type != Event::NoRepeat )
463 ev.setRepeat( TRUE, rp ); 465 ev.setRepeat( TRUE, rp );
464 ev.setNotes( noteStr ); 466 ev.setNotes( noteStr );
465 467
466 //cout << "Start: " << comboStart->currentText() << endl; 468 //cout << "Start: " << comboStart->currentText() << endl;
467 469
468 return ev; 470 return ev;
469} 471}
470 472
471void DateEntry::setRepeatLabel() 473void DateEntry::setRepeatLabel()
472{ 474{
473 475
474 switch( rp.type ) { 476 switch( rp.type ) {
475 case Event::Daily: 477 case Event::Daily:
476 cmdRepeat->setText( tr("Daily...") ); 478 cmdRepeat->setText( tr("Daily...") );
477 break; 479 break;
478 case Event::Weekly: 480 case Event::Weekly:
479 cmdRepeat->setText( tr("Weekly...") ); 481 cmdRepeat->setText( tr("Weekly...") );
480 break; 482 break;
481 case Event::MonthlyDay: 483 case Event::MonthlyDay:
482 case Event::MonthlyDate: 484 case Event::MonthlyDate:
483 cmdRepeat->setText( tr("Monthly...") ); 485 cmdRepeat->setText( tr("Monthly...") );
484 break; 486 break;
485 case Event::Yearly: 487 case Event::Yearly:
486 cmdRepeat->setText( tr("Yearly...") ); 488 cmdRepeat->setText( tr("Yearly...") );
487 break; 489 break;
488 default: 490 default:
489 cmdRepeat->setText( tr("No Repeat...") ); 491 cmdRepeat->setText( tr("No Repeat...") );
490 } 492 }
491} 493}
492 494
493void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound ) 495void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound )
494{ 496{
495 checkAlarm->setChecked( alarmPreset ); 497 checkAlarm->setChecked( alarmPreset );
496 spinAlarm->setValue( presetTime ); 498 spinAlarm->setValue( presetTime );
497 if ( sound != Event::Silent ) 499 if ( sound != Event::Silent )
498 comboSound->setCurrentItem( 1 ); 500 comboSound->setCurrentItem( 1 );
499 else 501 else
500 comboSound->setCurrentItem( 0 ); 502 comboSound->setCurrentItem( 0 );
501} 503}
502 504
503void DateEntry::initCombos() 505void DateEntry::initCombos()
504{ 506{
505 /* 507 /*
506 comboStart->clear(); 508 comboStart->clear();
507 comboEnd->clear(); 509 comboEnd->clear();
508 if ( ampm ) { 510 if ( ampm ) {
509 for ( int i = 0; i < 24; i++ ) { 511 for ( int i = 0; i < 24; i++ ) {
510 if ( i == 0 ) { 512 if ( i == 0 ) {
511 comboStart->insertItem( "12:00 AM" ); 513 comboStart->insertItem( "12:00 AM" );
512 comboStart->insertItem( "12:30 AM" ); 514 comboStart->insertItem( "12:30 AM" );
513 comboEnd->insertItem( "12:00 AM" ); 515 comboEnd->insertItem( "12:00 AM" );
514 comboEnd->insertItem( "12:30 AM" ); 516 comboEnd->insertItem( "12:30 AM" );
515 } else if ( i == 12 ) { 517 } else if ( i == 12 ) {
516 comboStart->insertItem( "12:00 PM" ); 518 comboStart->insertItem( "12:00 PM" );
517 comboStart->insertItem( "12:30 PM" ); 519 comboStart->insertItem( "12:30 PM" );
518 comboEnd->insertItem( "12:00 PM" ); 520 comboEnd->insertItem( "12:00 PM" );
519 comboEnd->insertItem( "12:30 PM" ); 521 comboEnd->insertItem( "12:30 PM" );
520 } else if ( i > 12 ) { 522 } else if ( i > 12 ) {
521 comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" ); 523 comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" );
522 comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" ); 524 comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" );
523 comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" ); 525 comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" );
524 comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" ); 526 comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" );
525 } else { 527 } else {
526 comboStart->insertItem( QString::number( i) + ":00 AM" ); 528 comboStart->insertItem( QString::number( i) + ":00 AM" );
527 comboStart->insertItem( QString::number( i ) + ":30 AM" ); 529 comboStart->insertItem( QString::number( i ) + ":30 AM" );
528 comboEnd->insertItem( QString::number( i ) + ":00 AM" ); 530 comboEnd->insertItem( QString::number( i ) + ":00 AM" );
529 comboEnd->insertItem( QString::number( i ) + ":30 AM" ); 531 comboEnd->insertItem( QString::number( i ) + ":30 AM" );
530 } 532 }
531 } 533 }
532 } else { 534 } else {
533 for ( int i = 0; i < 24; i++ ) { 535 for ( int i = 0; i < 24; i++ ) {
534 if ( i < 10 ) { 536 if ( i < 10 ) {
535 comboStart->insertItem( QString("0") 537 comboStart->insertItem( QString("0")
536 + QString::number(i) + ":00" ); 538 + QString::number(i) + ":00" );
537 comboStart->insertItem( QString("0") 539 comboStart->insertItem( QString("0")
538 + QString::number(i) + ":30" ); 540 + QString::number(i) + ":30" );
539 comboEnd->insertItem( QString("0") 541 comboEnd->insertItem( QString("0")
540 + QString::number(i) + ":00" ); 542 + QString::number(i) + ":00" );
541 comboEnd->insertItem( QString("0") 543 comboEnd->insertItem( QString("0")
542 + QString::number(i) + ":30" ); 544 + QString::number(i) + ":30" );
543 } else { 545 } else {
544 comboStart->insertItem( QString::number(i) + ":00" ); 546 comboStart->insertItem( QString::number(i) + ":00" );
545 comboStart->insertItem( QString::number(i) + ":30" ); 547 comboStart->insertItem( QString::number(i) + ":30" );
546 comboEnd->insertItem( QString::number(i) + ":00" ); 548 comboEnd->insertItem( QString::number(i) + ":00" );
547 comboEnd->insertItem( QString::number(i) + ":30" ); 549 comboEnd->insertItem( QString::number(i) + ":30" );
548 } 550 }
549 } 551 }
550 } 552 }
551 */ 553 */
552} 554}
553 555
554void DateEntry::slotChangeClock( bool whichClock ) 556void DateEntry::slotChangeClock( bool whichClock )
555{ 557{
556 ampm = whichClock; 558 ampm = whichClock;
557 initCombos(); 559 initCombos();
558 setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) ); 560 setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) );
559} 561}
560 562
diff --git a/core/pim/datebook/opie-datebook.control b/core/pim/datebook/opie-datebook.control
index 730b09d..acf28a7 100644
--- a/core/pim/datebook/opie-datebook.control
+++ b/core/pim/datebook/opie-datebook.control
@@ -1,11 +1,11 @@
1Package: opie-datebook 1Package: opie-datebook
2Files: plugins/application/libdatebook.so* bin/datebook apps/1Pim/datebook.desktop 2Files: plugins/application/libdatebook.so* bin/datebook apps/1Pim/datebook.desktop
3Priority: optional 3Priority: optional
4Section: opie/pim 4Section: opie/pim
5Conflicts: qpe-tkccalendar 5Conflicts: qpe-tkccalendar
6Maintainer: Holger 'Zecke' Freyther <zecke@handhelds.org> 6Maintainer: Holger 'Zecke' Freyther <zecke@handhelds.org>
7Architecture: arm 7Architecture: arm
8Depends: task-opie-minimal, libopiecore2, libopieui2,libopiepim2, opie-pics 8Depends: task-opie-minimal, libopiecore2, libopieui2, libopiepim2, opie-pics
9Description: A datebook/appointment manager 9Description: A datebook/appointment manager
10 A datebook/appointment manager for the Opie environment. 10 A datebook/appointment manager for the Opie environment.
11Version: $QPE_VERSION$EXTRAVERSION 11Version: $QPE_VERSION$EXTRAVERSION