summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-16 13:14:26 (UTC)
committer alwin <alwin>2005-03-16 13:14:26 (UTC)
commit3d43b9e40e562957e1a3fcbe9268634db45951ce (patch) (unidiff)
tree637f67a6768f6a90e7834b96100f6c70bb66950b
parent4fef85eb55dbef5f8546caee084e4f0ce51081d3 (diff)
downloadopie-3d43b9e40e562957e1a3fcbe9268634db45951ce.zip
opie-3d43b9e40e562957e1a3fcbe9268634db45951ce.tar.gz
opie-3d43b9e40e562957e1a3fcbe9268634db45951ce.tar.bz2
ho.
in dayview a holiday will displayed (if plugin found) generated a straight forward dummy-holiday-plugin for testing the stuff.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp1258
-rw-r--r--core/pim/datebook/datebook.h87
-rw-r--r--core/pim/datebook/datebookday.cpp1084
-rw-r--r--core/pim/datebook/datebookday.h60
-rw-r--r--core/pim/datebook/datebookdayallday.cpp47
-rw-r--r--core/pim/datebook/datebookdayallday.h4
-rw-r--r--core/pim/datebook/holiday/dummy/config.in8
-rw-r--r--core/pim/datebook/holiday/dummy/dummy.pro20
-rw-r--r--core/pim/datebook/holiday/dummy/dummyholiday.cpp20
-rw-r--r--core/pim/datebook/holiday/dummy/dummyholiday.h19
10 files changed, 1416 insertions, 1191 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index a18a5b4..f6aab0c 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -30,6 +30,8 @@
30#include "dateentryimpl.h" 30#include "dateentryimpl.h"
31 31
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33#include <opie2/oholidaypluginif.h>
34#include <opie2/oholidayplugin.h>
33 35
34#include <qpe/datebookmonth.h> 36#include <qpe/datebookmonth.h>
35#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
@@ -49,6 +51,8 @@
49#include <qtl.h> 51#include <qtl.h>
50#include <qtoolbar.h> 52#include <qtoolbar.h>
51#include <qwidgetstack.h> 53#include <qwidgetstack.h>
54#include <qdir.h>
55#include <qtopia/qlibrary.h>
52 56
53#include <sys/stat.h> 57#include <sys/stat.h>
54#include <sys/types.h> 58#include <sys/types.h>
@@ -68,24 +72,26 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
68 inSearch(FALSE), 72 inSearch(FALSE),
69 alarmCounter(0) 73 alarmCounter(0)
70{ 74{
71 bool needEvilHack= false; // if we need an Evil Hack 75 bool needEvilHack= false; // if we need an Evil Hack
72 QTime t; 76 QTime t;
73 t.start(); 77 t.start();
74 db = new DateBookDBHack; 78 db = new DateBookDBHack;
75 odebug << "loading db t=" << t.elapsed() << oendl; 79 odebug << "loading db t=" << t.elapsed() << oendl;
76 loadSettings(); 80 db_holiday = new DateBookHoliday();
77 setCaption( tr("Calendar") );
78 setIcon( Resource::loadPixmap( "datebook_icon" ) );
79 81
80 setToolBarsMovable( FALSE ); 82 loadSettings();
83 setCaption( tr("Calendar") );
84 setIcon( Resource::loadPixmap( "datebook_icon" ) );
81 85
82 views = new QWidgetStack( this ); 86 setToolBarsMovable( FALSE );
83 setCentralWidget( views );
84 87
85 dayView = 0; 88 views = new QWidgetStack( this );
86 weekView = 0; 89 setCentralWidget( views );
87 weekLstView = 0; 90
88 monthView = 0; 91 dayView = 0;
92 weekView = 0;
93 weekLstView = 0;
94 monthView = 0;
89 95
90// QToolBar *bar = new QToolBar( this ); 96// QToolBar *bar = new QToolBar( this );
91// bar->setHorizontalStretchable( TRUE ); 97// bar->setHorizontalStretchable( TRUE );
@@ -96,87 +102,87 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
96// QPopupMenu *view = new QPopupMenu( this ); 102// QPopupMenu *view = new QPopupMenu( this );
97// mb->insertItem( tr( "View" ), view ); 103// mb->insertItem( tr( "View" ), view );
98 104
99 QToolBar *sub_bar = new QToolBar(this); 105 QToolBar *sub_bar = new QToolBar(this);
100 sub_bar->setHorizontalStretchable(TRUE); 106 sub_bar->setHorizontalStretchable(TRUE);
101 107
102 QActionGroup *g = new QActionGroup( this ); 108 QActionGroup *g = new QActionGroup( this );
103 g->setExclusive( TRUE ); 109 g->setExclusive( TRUE );
104 110
105 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 111 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
106 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 112 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
107 a->addTo( sub_bar ); 113 a->addTo( sub_bar );
108 114
109 sub_bar->addSeparator(); 115 sub_bar->addSeparator();
110 116
111 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); 117 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 );
112 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 118 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
113 a->addTo( sub_bar ); 119 a->addTo( sub_bar );
114 //a->addTo( view ); 120// a->addTo( view );
115 121
116 sub_bar->addSeparator(); 122 sub_bar->addSeparator();
117 123
118 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 124 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
119 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 125 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
120 a->addTo( sub_bar ); 126 a->addTo( sub_bar );
121// a->addTo( view ); 127// a->addTo( view );
122 a->setToggleAction( TRUE ); 128 a->setToggleAction( TRUE );
123 a->setOn( TRUE ); 129 a->setOn( TRUE );
124 dayAction = a; 130 dayAction = a;
125 131
126 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 132 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
127 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 133 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
128 a->addTo( sub_bar ); 134 a->addTo( sub_bar );
129// a->addTo( view ); 135// a->addTo( view );
130 a->setToggleAction( TRUE ); 136 a->setToggleAction( TRUE );
131 weekAction = a; 137 weekAction = a;
132 138
133 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 139 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
134 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 140 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
135 a->addTo( sub_bar ); 141 a->addTo( sub_bar );
136// a->addTo( view ); 142// a->addTo( view );
137 a->setToggleAction( TRUE ); 143 a->setToggleAction( TRUE );
138 weekLstAction = a; 144 weekLstAction = a;
139 145
140 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 146 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
141 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 147 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
142 a->addTo( sub_bar ); 148 a->addTo( sub_bar );
143// a->addTo( view ); 149// a->addTo( view );
144 a->setToggleAction( TRUE ); 150 a->setToggleAction( TRUE );
145 monthAction = a; 151 monthAction = a;
146 152
147 sub_bar->addSeparator(); 153 sub_bar->addSeparator();
148 154
149 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 155 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
150 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 156 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
151 a->addTo( sub_bar ); 157 a->addTo( sub_bar );
152 158
153 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); 159 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 );
154 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 160 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
155 a->addTo( sub_bar ); 161 a->addTo( sub_bar );
156 162
157 if(defaultView==DAY) viewDay(); 163 if(defaultView==DAY) viewDay();
158 if(defaultView==WEEK) needEvilHack=true;// viewWeek(); 164 if(defaultView==WEEK) needEvilHack=true; // viewWeek();
159 if(defaultView==WEEKLST) viewWeekLst(); 165 if(defaultView==WEEKLST) viewWeekLst();
160 if(defaultView==MONTH) viewMonth(); 166 if(defaultView==MONTH) viewMonth();
161 167
162 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 168 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
163 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 169 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
164 170
165#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 171#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
166 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); 172 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) );
167#endif 173#endif
168 174
169 // listen on QPE/System 175 // listen on QPE/System
170#if defined(Q_WS_QWS) 176#if defined(Q_WS_QWS)
171#if !defined(QT_NO_COP) 177#if !defined(QT_NO_COP)
172 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 178 QCopChannel *channel = new QCopChannel( "QPE/System", this );
173 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 179 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
174 channel = new QCopChannel( "QPE/Datebook", this ); 180 channel = new QCopChannel( "QPE/Datebook", this );
175 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 181 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
176#endif 182#endif
177#endif 183#endif
178 184
179 odebug << "done t=" << t.elapsed() << oendl; 185 odebug << "done t=" << t.elapsed() << oendl;
180 186
181 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 187 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
182 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); 188 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) );
@@ -194,28 +200,28 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
194 * so we'll call it then via a singleShot 200 * so we'll call it then via a singleShot
195 * from view() 201 * from view()
196 */ 202 */
197 if( needEvilHack ){ 203 if( needEvilHack ){
198 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 204 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
199 } 205 }
200} 206}
201 207
202void DateBook::receive( const QCString &msg, const QByteArray &data ) 208void DateBook::receive( const QCString &msg, const QByteArray &data )
203{ 209{
204 QDataStream stream( data, IO_ReadOnly ); 210 QDataStream stream( data, IO_ReadOnly );
205 if ( msg == "timeChange(QString)" ) { 211 if ( msg == "timeChange(QString)" ) {
206 // update active view! 212 // update active view!
207 if ( dayAction->isOn() ) 213 if ( dayAction->isOn() )
208 viewDay(); 214 viewDay();
209 else if ( weekAction->isOn() ) 215 else if ( weekAction->isOn() )
210 viewWeek(); 216 viewWeek();
211 else if ( monthAction->isOn() ) 217 else if ( monthAction->isOn() )
212 viewMonth(); 218 viewMonth();
213 } 219 }
214 else if (msg == "editEvent(int)") { 220 else if (msg == "editEvent(int)") {
215 int uid; 221 int uid;
216 stream >> uid; 222 stream >> uid;
217 Event e=db->eventByUID(uid); 223 Event e=db->eventByUID(uid);
218 editEvent(e); 224 editEvent(e);
219 }else if (msg == "viewDefault(QDate)"){ 225 }else if (msg == "viewDefault(QDate)"){
220 QDate day; 226 QDate day;
221 stream >> day; 227 stream >> day;
@@ -225,63 +231,64 @@ void DateBook::receive( const QCString &msg, const QByteArray &data )
225 231
226DateBook::~DateBook() 232DateBook::~DateBook()
227{ 233{
234 delete db_holiday;
228} 235}
229 236
230void DateBook::slotSettings() 237void DateBook::slotSettings()
231{ 238{
232 DateBookSettings frmSettings( ampm, this ); 239 DateBookSettings frmSettings( ampm, this );
233 frmSettings.setStartTime( startTime ); 240 frmSettings.setStartTime( startTime );
234 frmSettings.setAlarmPreset( aPreset, presetTime ); 241 frmSettings.setAlarmPreset( aPreset, presetTime );
235 frmSettings.setJumpToCurTime( bJumpToCurTime ); 242 frmSettings.setJumpToCurTime( bJumpToCurTime );
236 frmSettings.setRowStyle( rowStyle ); 243 frmSettings.setRowStyle( rowStyle );
237 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 244 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
238 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 245 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
239 246
240 bool found=false; 247 bool found=false;
241 for (int i=0; i<(frmSettings.comboLocation->count()); i++) { 248 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
242 if ( frmSettings.comboLocation->text(i) == defaultLocation ) { 249 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
243 frmSettings.comboLocation->setCurrentItem(i); 250 frmSettings.comboLocation->setCurrentItem(i);
244 found=true; 251 found=true;
245 break; 252 break;
246 } 253 }
247 } 254 }
248 if(!found) { 255 if(!found) {
249 frmSettings.comboLocation->insertItem(defaultLocation); 256 frmSettings.comboLocation->insertItem(defaultLocation);
250 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); 257 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
251 } 258 }
252 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); 259 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
253 260
254 if ( QPEApplication::execDialog( &frmSettings ) ) { 261 if ( QPEApplication::execDialog( &frmSettings ) ) {
255 aPreset = frmSettings.alarmPreset(); 262 aPreset = frmSettings.alarmPreset();
256 presetTime = frmSettings.presetTime(); 263 presetTime = frmSettings.presetTime();
257 startTime = frmSettings.startTime(); 264 startTime = frmSettings.startTime();
258 bJumpToCurTime = frmSettings.jumpToCurTime(); 265 bJumpToCurTime = frmSettings.jumpToCurTime();
259 rowStyle = frmSettings.rowStyle(); 266 rowStyle = frmSettings.rowStyle();
260 defaultView=frmSettings.comboDefaultView->currentItem()+1; 267 defaultView=frmSettings.comboDefaultView->currentItem()+1;
261 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 268 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
262 defaultLocation=frmSettings.comboLocation->currentText(); 269 defaultLocation=frmSettings.comboLocation->currentText();
263 defaultCategories=frmSettings.comboCategory->currentCategories(); 270 defaultCategories=frmSettings.comboCategory->currentCategories();
264 271
265 if ( dayView ) { 272 if ( dayView ) {
266 dayView->setStartViewTime( startTime ); 273 dayView->setStartViewTime( startTime );
267 dayView->setJumpToCurTime( bJumpToCurTime ); 274 dayView->setJumpToCurTime( bJumpToCurTime );
268 dayView->setRowStyle( rowStyle ); 275 dayView->setRowStyle( rowStyle );
269 } 276 }
270 if ( weekView ) { 277 if ( weekView ) {
271 weekView->setStartViewTime( startTime ); 278 weekView->setStartViewTime( startTime );
272 } 279 }
273 saveSettings(); 280 saveSettings();
274 281
275 // make the change obvious 282 // make the change obvious
276 if ( views->visibleWidget() ) { 283 if ( views->visibleWidget() ) {
277 if ( views->visibleWidget() == dayView ) 284 if ( views->visibleWidget() == dayView )
278 dayView->redraw(); 285 dayView->redraw();
279 else if ( views->visibleWidget() == weekView ) 286 else if ( views->visibleWidget() == weekView )
280 weekView->redraw(); 287 weekView->redraw();
281 else if ( views->visibleWidget() == weekLstView ) 288 else if ( views->visibleWidget() == weekLstView )
282 weekLstView->redraw(); 289 weekLstView->redraw();
283 } 290 }
284 } 291 }
285} 292}
286 293
287void DateBook::fileNew() 294void DateBook::fileNew()
@@ -299,20 +306,20 @@ QString DateBook::checkEvent(const Event &e)
299 Event previous = e; 306 Event previous = e;
300 for(int i = 0; i < 12; i++) 307 for(int i = 0; i < 12; i++)
301 { 308 {
302 QDateTime next; 309 QDateTime next;
303 if (!nextOccurance(previous, current_date.addDays(1), next)) { 310 if (!nextOccurance(previous, current_date.addDays(1), next)) {
304 break; // no more repeats 311 break; // no more repeats
305 } 312 }
306 if(next < previous.end()) { 313 if(next < previous.end()) {
307 checkFailed = TRUE; 314 checkFailed = TRUE;
308 break; 315 break;
309 } 316 }
310 current_date = next.date(); 317 current_date = next.date();
311 } 318 }
312 319
313 if(checkFailed) 320 if(checkFailed)
314 return tr("Event duration is potentially longer\n" 321 return tr("Event duration is potentially longer\n"
315 "than interval between repeats."); 322 "than interval between repeats.");
316 323
317 return QString::null; 324 return QString::null;
318} 325}
@@ -322,108 +329,108 @@ QDate DateBook::currentDate()
322 QDate d = QDate::currentDate(); 329 QDate d = QDate::currentDate();
323 330
324 if ( dayView && views->visibleWidget() == dayView ) { 331 if ( dayView && views->visibleWidget() == dayView ) {
325 d = dayView->date(); 332 d = dayView->date();
326 } else if ( weekView && views->visibleWidget() == weekView ) { 333 } else if ( weekView && views->visibleWidget() == weekView ) {
327 d = weekView->date(); 334 d = weekView->date();
328 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 335 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
329 d = weekLstView->date(); 336 d = weekLstView->date();
330 } else if ( monthView && views->visibleWidget() == monthView ) { 337 } else if ( monthView && views->visibleWidget() == monthView ) {
331 d = monthView->selectedDate(); 338 d = monthView->selectedDate();
332 } 339 }
333 340
334 return d; 341 return d;
335} 342}
336 343
337void DateBook::view(int v, const QDate &d) { 344void DateBook::view(int v, const QDate &d) {
338 if (v==DAY) { 345 if (v==DAY) {
339 initDay(); 346 initDay();
340 dayAction->setOn( TRUE ); 347 dayAction->setOn( TRUE );
341 dayView->setDate( d ); 348 dayView->setDate( d );
342 views->raiseWidget( dayView ); 349 views->raiseWidget( dayView );
343 dayView->redraw(); 350 dayView->redraw();
344 } else if (v==WEEK) { 351 } else if (v==WEEK) {
345 initWeek(); 352 initWeek();
346 weekAction->setOn( TRUE ); 353 weekAction->setOn( TRUE );
347 weekView->setDate( d ); 354 weekView->setDate( d );
348 views->raiseWidget( weekView ); 355 views->raiseWidget( weekView );
349 weekView->redraw(); 356 weekView->redraw();
350 } else if (v==WEEKLST) { 357 } else if (v==WEEKLST) {
351 initWeekLst(); 358 initWeekLst();
352 weekLstAction->setOn( TRUE ); 359 weekLstAction->setOn( TRUE );
353 weekLstView->setDate(d); 360 weekLstView->setDate(d);
354 views->raiseWidget( weekLstView ); 361 views->raiseWidget( weekLstView );
355 weekLstView->redraw(); 362 weekLstView->redraw();
356 } else if (v==MONTH) { 363 } else if (v==MONTH) {
357 initMonth(); 364 initMonth();
358 monthAction->setOn( TRUE ); 365 monthAction->setOn( TRUE );
359 monthView->setDate( d.year(), d.month(), d.day() ); 366 monthView->setDate( d.year(), d.month(), d.day() );
360 views->raiseWidget( monthView ); 367 views->raiseWidget( monthView );
361 monthView->redraw(); 368 monthView->redraw();
362 } 369 }
363} 370}
364 371
365void DateBook::viewDefault(const QDate &d) { 372void DateBook::viewDefault(const QDate &d) {
366 view(defaultView,d); 373 view(defaultView,d);
367} 374}
368 375
369void DateBook::viewDay() { 376void DateBook::viewDay() {
370 view(DAY,currentDate()); 377 view(DAY,currentDate());
371} 378}
372 379
373void DateBook::viewWeek() { 380void DateBook::viewWeek() {
374 view(WEEK,currentDate()); 381 view(WEEK,currentDate());
375} 382}
376 383
377void DateBook::viewWeekLst() { 384void DateBook::viewWeekLst() {
378 view(WEEKLST,currentDate()); 385 view(WEEKLST,currentDate());
379} 386}
380 387
381void DateBook::viewMonth() { 388void DateBook::viewMonth() {
382 view(MONTH,currentDate()); 389 view(MONTH,currentDate());
383} 390}
384 391
385void DateBook::insertEvent( const Event &e ) 392void DateBook::insertEvent( const Event &e )
386{ 393{
387 Event dupEvent=e; 394 Event dupEvent=e;
388 if(!dupEvent.isValidUid() ) // tkcRom seems to be different 395 if(!dupEvent.isValidUid() ) // tkcRom seems to be different
389 dupEvent.assignUid(); 396 dupEvent.assignUid();
390 dupEvent.setLocation(defaultLocation); 397 dupEvent.setLocation(defaultLocation);
391 dupEvent.setCategories(defaultCategories); 398 dupEvent.setCategories(defaultCategories);
392 db->addEvent(dupEvent); 399 db->addEvent(dupEvent);
393 emit newEvent(); 400 emit newEvent();
394} 401}
395 402
396void DateBook::duplicateEvent( const Event &e ) 403void DateBook::duplicateEvent( const Event &e )
397{ 404{
398 // Alot of code duplication, as this is almost like editEvent(); 405 // Alot of code duplication, as this is almost like editEvent();
399 if (syncing) { 406 if (syncing) {
400 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 407 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
401 return; 408 return;
402 } 409 }
403 410
404 Event dupevent(e);// Make a duplicate. 411 Event dupevent(e); // Make a duplicate.
405 412
406 // workaround added for text input. 413 // workaround added for text input.
407 QDialog editDlg( this, 0, TRUE ); 414 QDialog editDlg( this, 0, TRUE );
408 DateEntry *entry; 415 DateEntry *entry;
409 editDlg.setCaption( tr("Duplicate Event") ); 416 editDlg.setCaption( tr("Duplicate Event") );
410 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 417 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
411 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 418 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
412 sv->setResizePolicy( QScrollView::AutoOneFit ); 419 sv->setResizePolicy( QScrollView::AutoOneFit );
413 // KLUDGE!!! 420 // KLUDGE!!!
414 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 421 sv->setHScrollBarMode( QScrollView::AlwaysOff );
415 vb->addWidget( sv ); 422 vb->addWidget( sv );
416 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 423 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
417 entry->timezone->setEnabled( FALSE ); 424 entry->timezone->setEnabled( FALSE );
418 sv->addChild( entry ); 425 sv->addChild( entry );
419 426
420 while ( QPEApplication::execDialog( &editDlg ) ) { 427 while ( QPEApplication::execDialog( &editDlg ) ) {
421 Event newEv = entry->event(); 428 Event newEv = entry->event();
422 QString error = checkEvent(newEv); 429 QString error = checkEvent(newEv);
423 if (!error.isNull()) { 430 if (!error.isNull()) {
424 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) 431 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0)
425 continue; 432 continue;
426 } 433 }
427 /* 434 /*
428 * The problem: 435 * The problem:
429 * DateBookDB does remove repeating events not by uid but by the time 436 * DateBookDB does remove repeating events not by uid but by the time
@@ -433,62 +440,62 @@ void DateBook::duplicateEvent( const Event &e )
433 Event::RepeatPattern rp = newEv.repeatPattern(); 440 Event::RepeatPattern rp = newEv.repeatPattern();
434 rp.createTime = ::time( NULL ); 441 rp.createTime = ::time( NULL );
435 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... 442 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern...
436 if( newEv.uid() == e.uid() || !newEv.isValidUid() ) 443 if( newEv.uid() == e.uid() || !newEv.isValidUid() )
437 newEv.assignUid(); 444 newEv.assignUid();
438 445
439 db->addEvent(newEv); 446 db->addEvent(newEv);
440 emit newEvent(); 447 emit newEvent();
441 break; 448 break;
442 } 449 }
443} 450}
444 451
445void DateBook::editEvent( const Event &e ) 452void DateBook::editEvent( const Event &e )
446{ 453{
447 if (syncing) { 454 if (syncing) {
448 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 455 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
449 return; 456 return;
450 } 457 }
451 458
452 // workaround added for text input. 459 // workaround added for text input.
453 QDialog editDlg( this, 0, TRUE ); 460 QDialog editDlg( this, 0, TRUE );
454 DateEntry *entry; 461 DateEntry *entry;
455 editDlg.setCaption( tr("Edit Event") ); 462 editDlg.setCaption( tr("Edit Event") );
456 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 463 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
457 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 464 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
458 sv->setResizePolicy( QScrollView::AutoOneFit ); 465 sv->setResizePolicy( QScrollView::AutoOneFit );
459 // KLUDGE!!! 466 // KLUDGE!!!
460 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 467 sv->setHScrollBarMode( QScrollView::AlwaysOff );
461 vb->addWidget( sv ); 468 vb->addWidget( sv );
462 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 469 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
463 entry->timezone->setEnabled( FALSE ); 470 entry->timezone->setEnabled( FALSE );
464 sv->addChild( entry ); 471 sv->addChild( entry );
465 472
466 while ( QPEApplication::execDialog( &editDlg ) ) { 473 while ( QPEApplication::execDialog( &editDlg ) ) {
467 Event newEv = entry->event(); 474 Event newEv = entry->event();
468 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 475 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
469 break; 476 break;
470 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 477 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
471 QString error = checkEvent(newEv); 478 QString error = checkEvent(newEv);
472 if (!error.isNull()) { 479 if (!error.isNull()) {
473 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; 480 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue;
474 } 481 }
475 db->editEvent(e, newEv); 482 db->editEvent(e, newEv);
476 emit newEvent(); 483 emit newEvent();
477 break; 484 break;
478 } 485 }
479} 486}
480 487
481void DateBook::removeEvent( const Event &e ) 488void DateBook::removeEvent( const Event &e )
482{ 489{
483 if (syncing) { 490 if (syncing) {
484 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 491 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
485 return; 492 return;
486 } 493 }
487 494
488 QString strName = e.description(); 495 QString strName = e.description();
489 496
490 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 497 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
491 return; 498 return;
492 499
493 db->removeEvent( e ); 500 db->removeEvent( e );
494 if ( views->visibleWidget() == dayView && dayView ) 501 if ( views->visibleWidget() == dayView && dayView )
@@ -511,211 +518,211 @@ void DateBook::showDay( int year, int month, int day )
511 518
512void DateBook::initDay() 519void DateBook::initDay()
513{ 520{
514 if ( !dayView ) { 521 if ( !dayView ) {
515 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 522 dayView = new DateBookDay( ampm, onMonday, db, db_holiday, views, "day view" );
516 views->addWidget( dayView, DAY ); 523 views->addWidget( dayView, DAY );
517 dayView->setJumpToCurTime( bJumpToCurTime ); 524 dayView->setJumpToCurTime( bJumpToCurTime );
518 dayView->setStartViewTime( startTime ); 525 dayView->setStartViewTime( startTime );
519 dayView->setRowStyle( rowStyle ); 526 dayView->setRowStyle( rowStyle );
520 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); 527 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
521 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); 528 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
522 connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) ); 529 connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) );
523 connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); 530 connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
524 connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) ); 531 connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) );
525 connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); 532 connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) );
526 connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) ); 533 connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) );
527 } 534 }
528} 535}
529 536
530void DateBook::initWeek() 537void DateBook::initWeek()
531{ 538{
532 if ( !weekView ) { 539 if ( !weekView ) {
533 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 540 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
534 weekView->setStartViewTime( startTime ); 541 weekView->setStartViewTime( startTime );
535 views->addWidget( weekView, WEEK ); 542 views->addWidget( weekView, WEEK );
536 connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 543 connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
537 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); 544 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
538 } 545 }
539 546
540 //But also get it right: the year that we display can be different 547 //But also get it right: the year that we display can be different
541 //from the year of the current date. So, first find the year 548 //from the year of the current date. So, first find the year
542 //number of the current week. 549 //number of the current week.
543 int yearNumber, totWeeks; 550 int yearNumber, totWeeks;
544 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 551 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
545 552
546 QDate d = QDate( yearNumber, 12, 31 ); 553 QDate d = QDate( yearNumber, 12, 31 );
547 calcWeek( d, totWeeks, yearNumber, onMonday ); 554 calcWeek( d, totWeeks, yearNumber, onMonday );
548 555
549 while ( totWeeks == 1 ) { 556 while ( totWeeks == 1 ) {
550 d = d.addDays( -1 ); 557 d = d.addDays( -1 );
551 calcWeek( d, totWeeks, yearNumber, onMonday ); 558 calcWeek( d, totWeeks, yearNumber, onMonday );
552 } 559 }
553} 560}
554 561
555void DateBook::initWeekLst() { 562void DateBook::initWeekLst() {
556 if ( !weekLstView ) { 563 if ( !weekLstView ) {
557 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); 564 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" );
558 views->addWidget( weekLstView, WEEKLST ); 565 views->addWidget( weekLstView, WEEKLST );
559 566
560 //weekLstView->setStartViewTime( startTime ); 567 //weekLstView->setStartViewTime( startTime );
561 connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 568 connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
562 connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), 569 connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ),
563 this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); 570 this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) );
564 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); 571 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) );
565 connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); 572 connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
566 connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); 573 connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) );
567 connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); 574 connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) );
568 connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); 575 connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) );
569 } 576 }
570} 577}
571 578
572 579
573void DateBook::initMonth() 580void DateBook::initMonth()
574{ 581{
575 if ( !monthView ) { 582 if ( !monthView ) {
576 monthView = new DateBookMonth( views, "month view", FALSE, db ); 583 monthView = new DateBookMonth( views, "month view", FALSE, db );
577 views->addWidget( monthView, MONTH ); 584 views->addWidget( monthView, MONTH );
578 connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 585 connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
579 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); 586 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) );
580 qApp->processEvents(); 587 qApp->processEvents();
581 } 588 }
582} 589}
583 590
584void DateBook::loadSettings() 591void DateBook::loadSettings()
585{ 592{
586 Config qpeconfig( "qpe" ); 593 Config qpeconfig( "qpe" );
587 qpeconfig.setGroup("Time"); 594 qpeconfig.setGroup("Time");
588 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); 595 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
589 onMonday = qpeconfig.readBoolEntry( "MONDAY" ); 596 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
590 597
591 Config config("DateBook"); 598 Config config("DateBook");
592 config.setGroup("Main"); 599 config.setGroup("Main");
593 startTime = config.readNumEntry("startviewtime", 8); 600 startTime = config.readNumEntry("startviewtime", 8);
594 aPreset = config.readBoolEntry("alarmpreset"); 601 aPreset = config.readBoolEntry("alarmpreset");
595 presetTime = config.readNumEntry("presettime"); 602 presetTime = config.readNumEntry("presettime");
596 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 603 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
597 rowStyle = config.readNumEntry("rowstyle"); 604 rowStyle = config.readNumEntry("rowstyle");
598 defaultView = config.readNumEntry("defaultview",DAY); 605 defaultView = config.readNumEntry("defaultview",DAY);
599 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 606 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
600 607
601 defaultLocation=config.readEntry("defaultLocation"); 608 defaultLocation=config.readEntry("defaultLocation");
602 QString tmpString=config.readEntry("defaultCategories"); 609 QString tmpString=config.readEntry("defaultCategories");
603 QStringList tmpStringList=QStringList::split(",",tmpString); 610 QStringList tmpStringList=QStringList::split(",",tmpString);
604 defaultCategories.truncate(0); 611 defaultCategories.truncate(0);
605 612
606 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { 613 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
607 defaultCategories.resize(defaultCategories.count()+1); 614 defaultCategories.resize(defaultCategories.count()+1);
608 defaultCategories[defaultCategories.count()-1]=(*i).toInt(); 615 defaultCategories[defaultCategories.count()-1]=(*i).toInt();
609 } 616 }
610} 617}
611 618
612void DateBook::saveSettings() 619void DateBook::saveSettings()
613{ 620{
614 Config config( "qpe" ); 621 Config config( "qpe" );
615 Config configDB( "DateBook" ); 622 Config configDB( "DateBook" );
616 configDB.setGroup( "Main" ); 623 configDB.setGroup( "Main" );
617 configDB.writeEntry("startviewtime",startTime); 624 configDB.writeEntry("startviewtime",startTime);
618 configDB.writeEntry("alarmpreset",aPreset); 625 configDB.writeEntry("alarmpreset",aPreset);
619 configDB.writeEntry("presettime",presetTime); 626 configDB.writeEntry("presettime",presetTime);
620 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 627 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
621 configDB.writeEntry("rowstyle", rowStyle); 628 configDB.writeEntry("rowstyle", rowStyle);
622 configDB.writeEntry("defaultview",defaultView); 629 configDB.writeEntry("defaultview",defaultView);
623 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); 630 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
624 631
625 configDB.writeEntry("defaultLocation",defaultLocation); 632 configDB.writeEntry("defaultLocation",defaultLocation);
626 QStringList tmpStringList; 633 QStringList tmpStringList;
627 for( uint i=0; i<defaultCategories.count(); i++) { 634 for( uint i=0; i<defaultCategories.count(); i++) {
628 tmpStringList << QString::number(defaultCategories[i]); 635 tmpStringList << QString::number(defaultCategories[i]);
629 } 636 }
630 configDB.writeEntry("defaultCategories",tmpStringList.join(",")); 637 configDB.writeEntry("defaultCategories",tmpStringList.join(","));
631} 638}
632 639
633void DateBook::appMessage(const QCString& msg, const QByteArray& data) 640void DateBook::appMessage(const QCString& msg, const QByteArray& data)
634{ 641{
635 bool needShow = FALSE; 642 bool needShow = FALSE;
636 if ( msg == "alarm(QDateTime,int)" ) { 643 if ( msg == "alarm(QDateTime,int)" ) {
637 QDataStream ds(data,IO_ReadOnly); 644 QDataStream ds(data,IO_ReadOnly);
638 QDateTime when; int warn; 645 QDateTime when; int warn;
639 ds >> when >> warn; 646 ds >> when >> warn;
640 647
641 // check to make it's okay to continue, 648 // check to make it's okay to continue,
642 // this is the case that the time was set ahead, and 649 // this is the case that the time was set ahead, and
643 // we are forced given a stale alarm... 650 // we are forced given a stale alarm...
644 QDateTime current = QDateTime::currentDateTime(); 651 QDateTime current = QDateTime::currentDateTime();
645 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) 652 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
646 return; 653 return;
647 654
648 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 655 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
649 if ( list.count() > 0 ) { 656 if ( list.count() > 0 ) {
650 QString msg; 657 QString msg;
651 bool bSound = FALSE; 658 bool bSound = FALSE;
652 int stopTimer = 0; 659 int stopTimer = 0;
653 bool found = FALSE; 660 bool found = FALSE;
654 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 661 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
655 if ( (*it).event().hasAlarm() ) { 662 if ( (*it).event().hasAlarm() ) {
656 found = TRUE; 663 found = TRUE;
657 msg += "<CENTER><B>" + (*it).description() + "</B>" 664 msg += "<CENTER><B>" + (*it).description() + "</B>"
658 + "<BR>" + (*it).location() + "<BR>" 665 + "<BR>" + (*it).location() + "<BR>"
659 + TimeString::dateString((*it).event().start(),ampm) 666 + TimeString::dateString((*it).event().start(),ampm)
660 + (warn 667 + (warn
661 ? tr(" (in " + QString::number(warn) 668 ? tr(" (in " + QString::number(warn)
662 + tr(" minutes)")) 669 + tr(" minutes)"))
663 : QString("")) 670 : QString(""))
664 + "<BR>" 671 + "<BR>"
665 + (*it).notes() + "</CENTER>"; 672 + (*it).notes() + "</CENTER>";
666 if ( (*it).event().alarmSound() != Event::Silent ) { 673 if ( (*it).event().alarmSound() != Event::Silent ) {
667 bSound = TRUE; 674 bSound = TRUE;
668 } 675 }
669 } 676 }
670 } 677 }
671 if ( found ) { 678 if ( found ) {
672 if ( bSound ) { 679 if ( bSound ) {
673 Sound::soundAlarm(); 680 Sound::soundAlarm();
674 alarmCounter = 0; 681 alarmCounter = 0;
675 stopTimer = startTimer( 5000 ); 682 stopTimer = startTimer( 5000 );
676 } 683 }
677 QDialog dlg( this, 0, TRUE ); 684 QDialog dlg( this, 0, TRUE );
678 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 685 QVBoxLayout *vb = new QVBoxLayout( &dlg );
679 QScrollView *view = new QScrollView( &dlg, "scrollView"); 686 QScrollView *view = new QScrollView( &dlg, "scrollView");
680 view->setResizePolicy( QScrollView::AutoOneFit ); 687 view->setResizePolicy( QScrollView::AutoOneFit );
681 vb->addWidget( view ); 688 vb->addWidget( view );
682 QLabel *lblMsg = new QLabel( msg, &dlg ); 689 QLabel *lblMsg = new QLabel( msg, &dlg );
683 view->addChild( lblMsg ); 690 view->addChild( lblMsg );
684 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 691 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
685 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 692 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
686 vb->addWidget( cmdOk ); 693 vb->addWidget( cmdOk );
687 694
688 needShow = QPEApplication::execDialog( &dlg ); 695 needShow = QPEApplication::execDialog( &dlg );
689 696
690 if ( bSound ) 697 if ( bSound )
691 killTimer( stopTimer ); 698 killTimer( stopTimer );
692 } 699 }
693 } 700 }
694 } else if ( msg == "nextView()" ) { 701 } else if ( msg == "nextView()" ) {
695 needShow = true; 702 needShow = true;
696 if ( !qApp-> activeWindow ( )) { 703 if ( !qApp-> activeWindow ( )) {
697 needShow = TRUE; 704 needShow = TRUE;
698 } else { 705 } else {
699 QWidget* cur = views->visibleWidget(); 706 QWidget* cur = views->visibleWidget();
700 if ( cur ) { 707 if ( cur ) {
701 if ( cur == dayView ) 708 if ( cur == dayView )
702 viewWeek(); 709 viewWeek();
703 else if ( cur == weekView ) 710 else if ( cur == weekView )
704 viewWeekLst(); 711 viewWeekLst();
705 else if ( cur == weekLstView ) 712 else if ( cur == weekLstView )
706 viewMonth(); 713 viewMonth();
707 else if ( cur == monthView ) 714 else if ( cur == monthView )
708 viewDay(); 715 viewDay();
709 needShow = TRUE; 716 needShow = TRUE;
710 } 717 }
711 } 718 }
712 } else if (msg == "editEvent(int)") { 719 } else if (msg == "editEvent(int)") {
713 /* simple copy from receive */ 720 /* simple copy from receive */
714 QDataStream stream(data,IO_ReadOnly); 721 QDataStream stream(data,IO_ReadOnly);
715 int uid; 722 int uid;
716 stream >> uid; 723 stream >> uid;
717 Event e=db->eventByUID(uid); 724 Event e=db->eventByUID(uid);
718 editEvent(e); 725 editEvent(e);
719 } else if (msg == "viewDefault(QDate)"){ 726 } else if (msg == "viewDefault(QDate)"){
720 /* simple copy from receive */ 727 /* simple copy from receive */
721 QDataStream stream(data,IO_ReadOnly); 728 QDataStream stream(data,IO_ReadOnly);
@@ -727,88 +734,88 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data)
727 734
728 if ( needShow ) { 735 if ( needShow ) {
729#if defined(Q_WS_QWS) || defined(_WS_QWS_) 736#if defined(Q_WS_QWS) || defined(_WS_QWS_)
730 // showMaximized(); 737// showMaximized();
731#else 738#else
732 // show(); 739// show();
733#endif 740#endif
734 // raise(); 741// raise();
735 QPEApplication::setKeepRunning(); 742 QPEApplication::setKeepRunning();
736 // setActiveWindow(); 743// setActiveWindow();
737 } 744 }
738} 745}
739 746
740void DateBook::reload() 747void DateBook::reload()
741{ 748{
742 db->reload(); 749 db->reload();
743 if ( dayAction->isOn() ) viewDay(); 750 if ( dayAction->isOn() ) viewDay();
744 else if ( weekAction->isOn() ) viewWeek(); 751 else if ( weekAction->isOn() ) viewWeek();
745 else if ( monthAction->isOn() ) viewMonth(); 752 else if ( monthAction->isOn() ) viewMonth();
746 syncing = FALSE; 753 syncing = FALSE;
747} 754}
748 755
749void DateBook::flush() 756void DateBook::flush()
750{ 757{
751 syncing = TRUE; 758 syncing = TRUE;
752 db->save(); 759 db->save();
753} 760}
754 761
755void DateBook::timerEvent( QTimerEvent *e ) 762void DateBook::timerEvent( QTimerEvent *e )
756{ 763{
757 if ( alarmCounter < 10 ) { 764 if ( alarmCounter < 10 ) {
758 alarmCounter++; 765 alarmCounter++;
759 Sound::soundAlarm(); 766 Sound::soundAlarm();
760 } else { 767 } else {
761 killTimer( e->timerId() ); 768 killTimer( e->timerId() );
762 } 769 }
763} 770}
764 771
765void DateBook::changeClock( bool newClock ) 772void DateBook::changeClock( bool newClock )
766{ 773{
767 ampm = newClock; 774 ampm = newClock;
768 // repaint the affected objects... 775 // repaint the affected objects...
769 if (dayView) dayView->redraw(); 776 if (dayView) dayView->redraw();
770 if (weekView) weekView->redraw(); 777 if (weekView) weekView->redraw();
771 if (weekLstView) weekLstView->redraw(); 778 if (weekLstView) weekLstView->redraw();
772} 779}
773 780
774void DateBook::changeWeek( bool m ) 781void DateBook::changeWeek( bool m )
775{ 782{
776 /* no need to redraw, each widget catches. Do need to 783 /* no need to redraw, each widget catches. Do need to
777 store though for widgets we haven't made yet */ 784 store though for widgets we haven't made yet */
778 onMonday = m; 785 onMonday = m;
779} 786}
780 787
781void DateBook::slotToday() 788void DateBook::slotToday()
782{ 789{
783 // we need to view today using default view 790 // we need to view today using default view
784 view(defaultView,QDate::currentDate()); 791 view(defaultView,QDate::currentDate());
785} 792}
786 793
787void DateBook::closeEvent( QCloseEvent *e ) 794void DateBook::closeEvent( QCloseEvent *e )
788{ 795{
789 if(syncing) { 796 if(syncing) {
790 /* no need to save, did that at flush */ 797 /* no need to save, did that at flush */
791 e->accept(); 798 e->accept();
792 return; 799 return;
793 } 800 }
794 801
795 // save settings will generate it's own error messages, no 802 // save settings will generate it's own error messages, no
796 // need to do checking ourselves. 803 // need to do checking ourselves.
797 saveSettings(); 804 saveSettings();
798 if ( db->save() ) { 805 if ( db->save() ) {
799 e->accept(); 806 e->accept();
800 } else { 807 } else {
801 if ( QMessageBox::critical( this, tr( "Out of space" ), 808 if ( QMessageBox::critical( this, tr( "Out of space" ),
802 tr("Calendar was unable to save\n" 809 tr("Calendar was unable to save\n"
803 "your changes.\n" 810 "your changes.\n"
804 "Free up some space and try again.\n" 811 "Free up some space and try again.\n"
805 "\nQuit anyway?"), 812 "\nQuit anyway?"),
806 QMessageBox::Yes|QMessageBox::Escape, 813 QMessageBox::Yes|QMessageBox::Escape,
807 QMessageBox::No|QMessageBox::Default ) 814 QMessageBox::No|QMessageBox::Default )
808 != QMessageBox::No ) 815 != QMessageBox::No )
809 e->accept(); 816 e->accept();
810 else 817 else
811 e->ignore(); 818 e->ignore();
812 } 819 }
813} 820}
814 821
@@ -816,9 +823,9 @@ void DateBook::closeEvent( QCloseEvent *e )
816void DateBook::slotNewEventFromKey( const QString &str ) 823void DateBook::slotNewEventFromKey( const QString &str )
817{ 824{
818 if (syncing) { 825 if (syncing) {
819 QMessageBox::warning( this, tr("Calendar"), 826 QMessageBox::warning( this, tr("Calendar"),
820 tr( "Can not edit data, currently syncing") ); 827 tr( "Can not edit data, currently syncing") );
821 return; 828 return;
822 } 829 }
823 830
824 // We get to here from a key pressed in the Day View 831 // We get to here from a key pressed in the Day View
@@ -826,69 +833,69 @@ void DateBook::slotNewEventFromKey( const QString &str )
826 // passed in to be part of the description. 833 // passed in to be part of the description.
827 QDateTime start, end; 834 QDateTime start, end;
828 if ( views->visibleWidget() == dayView ) { 835 if ( views->visibleWidget() == dayView ) {
829 dayView->selectedDates( start, end ); 836 dayView->selectedDates( start, end );
830 } else if ( views->visibleWidget() == monthView ) { 837 } else if ( views->visibleWidget() == monthView ) {
831 QDate d = monthView->selectedDate(); 838 QDate d = monthView->selectedDate();
832 start = end = d; 839 start = end = d;
833 start.setTime( QTime( 10, 0 ) ); 840 start.setTime( QTime( 10, 0 ) );
834 end.setTime( QTime( 12, 0 ) ); 841 end.setTime( QTime( 12, 0 ) );
835 } else if ( views->visibleWidget() == weekView ) { 842 } else if ( views->visibleWidget() == weekView ) {
836 QDate d = weekView->date(); 843 QDate d = weekView->date();
837 start = end = d; 844 start = end = d;
838 start.setTime( QTime( 10, 0 ) ); 845 start.setTime( QTime( 10, 0 ) );
839 end.setTime( QTime( 12, 0 ) ); 846 end.setTime( QTime( 12, 0 ) );
840 } else if ( views->visibleWidget() == weekLstView ) { 847 } else if ( views->visibleWidget() == weekLstView ) {
841 QDate d = weekLstView->date(); 848 QDate d = weekLstView->date();
842 start = end = d; 849 start = end = d;
843 start.setTime( QTime( 10, 0 ) ); 850 start.setTime( QTime( 10, 0 ) );
844 end.setTime( QTime( 12, 0 ) ); 851 end.setTime( QTime( 12, 0 ) );
845 } 852 }
846 slotNewEntry(start, end, str); 853 slotNewEntry(start, end, str);
847} 854}
848void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 855void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
849 // argh! This really needs to be encapsulated in a class 856 // argh! This really needs to be encapsulated in a class
850 // or function. 857 // or function.
851 QDialog newDlg( this, 0, TRUE ); 858 QDialog newDlg( this, 0, TRUE );
852 newDlg.setCaption( DateEntryBase::tr("New Event") ); 859 newDlg.setCaption( DateEntryBase::tr("New Event") );
853 DateEntry *e; 860 DateEntry *e;
854 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 861 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
855 QScrollView *sv = new QScrollView( &newDlg ); 862 QScrollView *sv = new QScrollView( &newDlg );
856 sv->setResizePolicy( QScrollView::AutoOneFit ); 863 sv->setResizePolicy( QScrollView::AutoOneFit );
857 sv->setFrameStyle( QFrame::NoFrame ); 864 sv->setFrameStyle( QFrame::NoFrame );
858 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 865 sv->setHScrollBarMode( QScrollView::AlwaysOff );
859 vb->addWidget( sv ); 866 vb->addWidget( sv );
860 867
861 Event ev; 868 Event ev;
862 ev.setDescription( str ); 869 ev.setDescription( str );
863 // When the new gui comes in, change this... 870 // When the new gui comes in, change this...
864 if(location==0) { 871 if(location==0) {
865 if(defaultLocation.isEmpty()) { 872 if(defaultLocation.isEmpty()) {
866 ev.setLocation(tr("(Unknown)")); 873 ev.setLocation(tr("(Unknown)"));
867 } else { 874 } else {
868 ev.setLocation( defaultLocation ); 875 ev.setLocation( defaultLocation );
869 } 876 }
870 } else { 877 } else {
871 ev.setLocation(location); 878 ev.setLocation(location);
872 } 879 }
873 ev.setCategories(defaultCategories); 880 ev.setCategories(defaultCategories);
874 ev.setStart( start ); 881 ev.setStart( start );
875 ev.setEnd( end ); 882 ev.setEnd( end );
876 883
877 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 884 e = new DateEntry( onMonday, ev, ampm, &newDlg );
878 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 885 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
879 sv->addChild( e ); 886 sv->addChild( e );
880 while ( QPEApplication::execDialog( &newDlg ) ) { 887 while ( QPEApplication::execDialog( &newDlg ) ) {
881 ev = e->event(); 888 ev = e->event();
882 ev.assignUid(); 889 ev.assignUid();
883 QString error = checkEvent( ev ); 890 QString error = checkEvent( ev );
884 if ( !error.isNull() ) { 891 if ( !error.isNull() ) {
885 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 892 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
886 continue; 893 continue;
887 } 894 }
888 db->addEvent( ev ); 895 db->addEvent( ev );
889 emit newEvent(); 896 emit newEvent();
890 break; 897 break;
891 } 898 }
892} 899}
893 900
894void DateBook::setDocument( const QString &filename ) 901void DateBook::setDocument( const QString &filename )
@@ -897,7 +904,7 @@ void DateBook::setDocument( const QString &filename )
897 904
898 QValueList<Event> tl = Event::readVCalendar( filename ); 905 QValueList<Event> tl = Event::readVCalendar( filename );
899 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 906 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
900 db->addEvent( *it ); 907 db->addEvent( *it );
901 } 908 }
902} 909}
903 910
@@ -905,7 +912,7 @@ static const char * beamfile = "/tmp/obex/event.vcs";
905 912
906void DateBook::beamEvent( const Event &e ) 913void DateBook::beamEvent( const Event &e )
907{ 914{
908 odebug << "trying to beam" << oendl; 915 odebug << "trying to beam" << oendl;
909 unlink( beamfile ); // delete if exists 916 unlink( beamfile ); // delete if exists
910 mkdir("/tmp/obex/", 0755); 917 mkdir("/tmp/obex/", 0755);
911 Event::writeVCalendar( beamfile, e ); 918 Event::writeVCalendar( beamfile, e );
@@ -930,17 +937,17 @@ void DateBook::slotFind()
930 frmFind.setDate( currentDate() ); 937 frmFind.setDate( currentDate() );
931 QObject::connect( &frmFind, 938 QObject::connect( &frmFind,
932 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)), 939 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)),
933 this, 940 this,
934 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) ); 941 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) );
935 QObject::connect( this, 942 QObject::connect( this,
936 SIGNAL(signalNotFound()), 943 SIGNAL(signalNotFound()),
937 &frmFind, 944 &frmFind,
938 SLOT(slotNotFound()) ); 945 SLOT(slotNotFound()) );
939 QObject::connect( this, 946 QObject::connect( this,
940 SIGNAL(signalWrapAround()), 947 SIGNAL(signalWrapAround()),
941 &frmFind, 948 &frmFind,
942 SLOT(slotWrapAround()) ); 949 SLOT(slotWrapAround()) );
943 frmFind.move(0,0); 950 frmFind.move(0,0);
944 frmFind.exec(); 951 frmFind.exec();
945 inSearch = false; 952 inSearch = false;
946} 953}
@@ -949,30 +956,30 @@ bool catComp( QArray<int> cats, int category )
949{ 956{
950 bool returnMe; 957 bool returnMe;
951 int i, 958 int i,
952 count; 959 count;
953 960
954 count = int(cats.count()); 961 count = int(cats.count());
955 returnMe = false; 962 returnMe = false;
956 if ( (category == -1 && count == 0) || category == -2 ) 963 if ( (category == -1 && count == 0) || category == -2 )
957 returnMe = true; 964 returnMe = true;
958 else { 965 else {
959 for ( i = 0; i < count; i++ ) { 966 for ( i = 0; i < count; i++ ) {
960 if ( category == cats[i] ) { 967 if ( category == cats[i] ) {
961 returnMe = true; 968 returnMe = true;
962 break; 969 break;
963 } 970 }
964 } 971 }
965 } 972 }
966 return returnMe; 973 return returnMe;
967} 974}
968 975
969 976
970void DateBook::slotDoFind( const QString& txt, const QDate &dt, 977void DateBook::slotDoFind( const QString& txt, const QDate &dt,
971 bool caseSensitive, bool /*backwards*/, 978 bool caseSensitive, bool /*backwards*/,
972 int category ) 979 int category )
973{ 980{
974 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 981 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
975 next; 982 next;
976 983
977 QRegExp r( txt ); 984 QRegExp r( txt );
978 r.setCaseSensitive( caseSensitive ); 985 r.setCaseSensitive( caseSensitive );
@@ -980,9 +987,9 @@ void DateBook::slotDoFind( const QString& txt, const QDate &dt,
980 987
981 static Event rev, nonrev; 988 static Event rev, nonrev;
982 if ( !inSearch ) { 989 if ( !inSearch ) {
983 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 990 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
984 nonrev.setStart( rev.start() ); 991 nonrev.setStart( rev.start() );
985 inSearch = true; 992 inSearch = true;
986 } 993 }
987 static QDate searchDate = dt; 994 static QDate searchDate = dt;
988 // if true at the end we will start at the begin again and afterwards 995 // if true at the end we will start at the begin again and afterwards
@@ -1004,7 +1011,7 @@ void DateBook::slotDoFind( const QString& txt, const QDate &dt,
1004 QValueListConstIterator<Event> it; 1011 QValueListConstIterator<Event> it;
1005 QDate start = dt; 1012 QDate start = dt;
1006 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 1013 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
1007 if ( catComp( (*it).categories(), category ) ) { 1014 if ( catComp( (*it).categories(), category ) ) {
1008 if ( (*it).match( r ) ) { 1015 if ( (*it).match( r ) ) {
1009 if ( nextOccurance( *it, start, next ) ) { 1016 if ( nextOccurance( *it, start, next ) ) {
1010 if ( next < dtEnd && !(next <= rev.start() ) ) { 1017 if ( next < dtEnd && !(next <= rev.start() ) ) {
@@ -1026,30 +1033,30 @@ void DateBook::slotDoFind( const QString& txt, const QDate &dt,
1026 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); 1033 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
1027 qHeapSort( nonRepeats.begin(), nonRepeats.end() ); 1034 qHeapSort( nonRepeats.begin(), nonRepeats.end() );
1028 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { 1035 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
1029 if ( catComp( (*it).categories(), category ) ) { 1036 if ( catComp( (*it).categories(), category ) ) {
1030 if ( (*it).start() < dtEnd ) { 1037 if ( (*it).start() < dtEnd ) {
1031 if ( (*it).match( r ) && !(*it <= nonrev) ) { 1038 if ( (*it).match( r ) && !(*it <= nonrev) ) {
1032 nonrev = *it; 1039 nonrev = *it;
1033 dtEnd = nonrev.start(); 1040 dtEnd = nonrev.start();
1034 candidtate = true; 1041 candidtate = true;
1035 wrapAround = true; 1042 wrapAround = true;
1036 break; 1043 break;
1037 } 1044 }
1038 } 1045 }
1039 } 1046 }
1040 } 1047 }
1041 if ( candidtate ) { 1048 if ( candidtate ) {
1042 dayView->setStartViewTime( dtEnd.time().hour() ); 1049 dayView->setStartViewTime( dtEnd.time().hour() );
1043 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), 1050 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(),
1044 dtEnd.date().day() ); 1051 dtEnd.date().day() );
1045 } else { 1052 } else {
1046 if ( wrapAround ) { 1053 if ( wrapAround ) {
1047 emit signalWrapAround(); 1054 emit signalWrapAround();
1048 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 1055 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
1049 nonrev.setStart( rev.start() ); 1056 nonrev.setStart( rev.start() );
1050 } else 1057 } else
1051 emit signalNotFound(); 1058 emit signalNotFound();
1052 wrapAround = !wrapAround; 1059 wrapAround = !wrapAround;
1053 } 1060 }
1054} 1061}
1055 1062
@@ -1064,12 +1071,81 @@ Event DateBookDBHack::eventByUID(int uid) {
1064 QValueList<Event>::ConstIterator it; 1071 QValueList<Event>::ConstIterator it;
1065 1072
1066 for (it = myEventList.begin(); it != myEventList.end(); it++) { 1073 for (it = myEventList.begin(); it != myEventList.end(); it++) {
1067 if ((*it).uid() == uid) return *it; 1074 if ((*it).uid() == uid) return *it;
1068 } 1075 }
1069 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { 1076 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) {
1070 if ((*it).uid() == uid) return *it; 1077 if ((*it).uid() == uid) return *it;
1071 } 1078 }
1072 1079
1073 Event ev; 1080 Event ev;
1074 return ev; // return at least 1081 return ev; // return at least
1075} 1082}
1083
1084DateBookHoliday::DateBookHoliday()
1085{
1086 _pluginlist.clear();
1087 init();
1088}
1089
1090DateBookHoliday::~DateBookHoliday()
1091{
1092 deinit();
1093}
1094
1095void DateBookHoliday::deinit()
1096{
1097 QValueList<HPlugin*>::Iterator it;
1098 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
1099 HPlugin*_pl = *it;
1100 // destructs itself?
1101 _pl->_if->release();
1102 _pl->_lib->unload();
1103 delete _pl->_lib;
1104 delete _pl;
1105 }
1106 _pluginlist.clear();
1107}
1108
1109void DateBookHoliday::init()
1110{
1111 deinit();
1112 QString path = QPEApplication::qpeDir() + "plugins/datebook/holiday";
1113 QDir dir( path, "lib*.so" );
1114 QStringList list = dir.entryList();
1115 QStringList::Iterator it;
1116 for (it=list.begin();it!=list.end();++it) {
1117 Opie::Datebook::HolidayPluginIf*hif = 0;
1118 QLibrary*lib=new QLibrary(path+"/"+*it);
1119 if ((lib->queryInterface(IID_HOLIDAY_PLUGIN,(QUnknownInterface**)&hif) == QS_OK) && hif) {
1120 Opie::Datebook::HolidayPlugin*pl = hif->plugin();
1121 if (pl) {
1122 HPlugin*_pl=new HPlugin;
1123 _pl->_plugin = pl;
1124 odebug << "Found holiday " << pl->description()<<oendl;
1125 _pl->_lib = lib;
1126 _pl->_if = hif;
1127 _pluginlist.append(_pl);
1128 } else {
1129 }
1130 } else {
1131 delete lib;
1132 }
1133 }
1134}
1135
1136QStringList DateBookHoliday::holidaylist(const QDate&aDate)
1137{
1138 QStringList ret;
1139 QValueList<HPlugin*>::Iterator it;
1140 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
1141 HPlugin*_pl = *it;
1142 ret+=_pl->_plugin->entries(aDate);
1143 }
1144 return ret;
1145}
1146
1147QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day)
1148{
1149 return holidaylist(QDate(year,month,day));
1150}
1151
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index d7cfb33..54ffcfb 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -24,8 +24,8 @@
24 24
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26 26
27 enum { DAY=1,WEEK,WEEKLST,MONTH };// defaultView values 27enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values
28 enum { NONE=0,NORMAL,EXTENDED };// WeekLstView's modes. 28enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes.
29 29
30class QAction; 30class QAction;
31class QWidgetStack; 31class QWidgetStack;
@@ -36,18 +36,46 @@ class DateBookMonth;
36class Event; 36class Event;
37class QDate; 37class QDate;
38class Ir; 38class Ir;
39class QLibrary;
40
41namespace Opie {
42namespace Datebook {
43 class HolidayPlugin;
44 class HolidayPluginIf;
45}
46}
39 47
40class DateBookDBHack : public DateBookDB { 48class DateBookDBHack : public DateBookDB {
41 public: 49 public:
42 Event eventByUID(int id); 50 Event eventByUID(int id);
43}; 51};
44 52
53class DateBookHoliday
54{
55public:
56 DateBookHoliday();
57 virtual ~DateBookHoliday();
58
59 QStringList holidaylist(const QDate&);
60 QStringList holidaylist(unsigned year, unsigned month, unsigned day);
61protected:
62 void init();
63 void deinit();
64
65 struct HPlugin {
66 Opie::Datebook::HolidayPlugin*_plugin;
67 QLibrary*_lib;
68 Opie::Datebook::HolidayPluginIf*_if;
69 };
70 QValueList<HPlugin*>_pluginlist;
71};
72
45class DateBook : public QMainWindow 73class DateBook : public QMainWindow
46{ 74{
47 Q_OBJECT 75 Q_OBJECT
48 76
49public: 77public:
50 static QString appName() { return QString::fromLatin1("datebook"); } 78 static QString appName() { return QString::fromLatin1("datebook"); }
51 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 79 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
52 ~DateBook(); 80 ~DateBook();
53 81
@@ -71,7 +99,7 @@ private slots:
71 void fileNew(); 99 void fileNew();
72 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); 100 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0);
73 void slotSettings(); 101 void slotSettings();
74 void slotToday();// view today 102 void slotToday(); // view today
75 void changeClock( bool newClock ); 103 void changeClock( bool newClock );
76 void changeWeek( bool newDay ); 104 void changeWeek( bool newDay );
77 void appMessage(const QCString& msg, const QByteArray& data); 105 void appMessage(const QCString& msg, const QByteArray& data);
@@ -89,8 +117,8 @@ private slots:
89 117
90 void showDay( int y, int m, int d ); 118 void showDay( int y, int m, int d );
91 119
92 void insertEvent( const Event &e ); 120 void insertEvent( const Event &e );
93 void editEvent( const Event &e ); 121 void editEvent( const Event &e );
94 void duplicateEvent( const Event &e ); 122 void duplicateEvent( const Event &e );
95 void removeEvent( const Event &e ); 123 void removeEvent( const Event &e );
96 124
@@ -109,29 +137,30 @@ private:
109 void saveSettings(); 137 void saveSettings();
110 138
111private: 139private:
112 DateBookDBHack *db; 140 DateBookDBHack *db;
113 QWidgetStack *views; 141 DateBookHoliday*db_holiday;
114 DateBookDay *dayView; 142 QWidgetStack *views;
115 DateBookWeek *weekView; 143 DateBookDay *dayView;
116 DateBookMonth *monthView; 144 DateBookWeek *weekView;
117 DateBookWeekLst *weekLstView; 145 DateBookMonth *monthView;
118 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 146 DateBookWeekLst *weekLstView;
119 int weeklistviewconfig; 147 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
120 bool aPreset; // have everything set to alarm? 148 int weeklistviewconfig;
121 int presetTime; // the standard time for the alarm 149 bool aPreset; // have everything set to alarm?
122 int startTime; 150 int presetTime; // the standard time for the alarm
123 int rowStyle; 151 int startTime;
124 int defaultView; 152 int rowStyle;
125 QArray<int> defaultCategories; 153 int defaultView;
126 QString defaultLocation; 154 QArray<int> defaultCategories;
127 bool bJumpToCurTime; //should jump to current time in dayview? 155 QString defaultLocation;
128 bool ampm; 156 bool bJumpToCurTime; //should jump to current time in dayview?
129 bool onMonday; 157 bool ampm;
130 158 bool onMonday;
131 bool syncing; 159
132 bool inSearch; 160 bool syncing;
133 161 bool inSearch;
134 int alarmCounter; 162
163 int alarmCounter;
135 164
136 QString checkEvent(const Event &); 165 QString checkEvent(const Event &);
137}; 166};
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index ca63dc5..dfe39e5 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -22,6 +22,7 @@
22#include "datebookdayheaderimpl.h" 22#include "datebookdayheaderimpl.h"
23#include "datebookdayallday.h" 23#include "datebookdayallday.h"
24 24
25#include <opie2/oholidayplugin.h>
25#include <qpe/resource.h> 26#include <qpe/resource.h>
26#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
27#include <qpe/ir.h> 28#include <qpe/ir.h>
@@ -35,109 +36,109 @@
35DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) 36DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name )
36 : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) 37 : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() )
37{ 38{
38 enableClipper(TRUE); 39 enableClipper(TRUE);
39 setTopMargin( 0 ); 40 setTopMargin( 0 );
40 horizontalHeader()->hide(); 41 horizontalHeader()->hide();
41 setLeftMargin(38); 42 setLeftMargin(38);
42 setColumnStretchable( 0, TRUE ); 43 setColumnStretchable( 0, TRUE );
43 setHScrollBarMode( QScrollView::AlwaysOff ); 44 setHScrollBarMode( QScrollView::AlwaysOff );
44 verticalHeader()->setPalette(white); 45 verticalHeader()->setPalette(white);
45 verticalHeader()->setResizeEnabled(FALSE); 46 verticalHeader()->setResizeEnabled(FALSE);
46 setSelectionMode( Single ); 47 setSelectionMode( Single );
47 48
48 // get rid of being able to edit things... 49 // get rid of being able to edit things...
49 QTableItem *tmp; 50 QTableItem *tmp;
50 int row; 51 int row;
51 for ( row = 0; row < numRows(); row++ ) { 52 for ( row = 0; row < numRows(); row++ ) {
52 tmp = new QTableItem( this, QTableItem::Never, QString::null); 53 tmp = new QTableItem( this, QTableItem::Never, QString::null);
53 setItem( row, 0, tmp ); 54 setItem( row, 0, tmp );
54 //setRowHeight( row, 40); 55 //setRowHeight( row, 40);
55 } 56 }
56 57
57 initHeader(); 58 initHeader();
58 QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); 59 QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) );
59} 60}
60 61
61void DateBookDayView::initHeader() 62void DateBookDayView::initHeader()
62{ 63{
63 QString strTmp; 64 QString strTmp;
64 int preferredWidth = 0; 65 int preferredWidth = 0;
65 for ( int i = 0; i < 24; ++i ) { 66 for ( int i = 0; i < 24; ++i ) {
66 if ( ampm ) { 67 if ( ampm ) {
67 if ( i == 0 ) 68 if ( i == 0 )
68 strTmp = QString::number(12) + ":00"; 69 strTmp = QString::number(12) + ":00";
69 else if ( i == 12 ) 70 else if ( i == 12 )
70 strTmp = QString::number(12) + tr(":00p"); 71 strTmp = QString::number(12) + tr(":00p");
71 else if ( i > 12 ) 72 else if ( i > 12 )
72 strTmp = QString::number( i - 12 ) + tr(":00p"); 73 strTmp = QString::number( i - 12 ) + tr(":00p");
73 else 74 else
74 strTmp = QString::number(i) + ":00"; 75 strTmp = QString::number(i) + ":00";
75 } else { 76 } else {
76 if ( i < 10 ) 77 if ( i < 10 )
77 strTmp = "0" + QString::number(i) + ":00"; 78 strTmp = "0" + QString::number(i) + ":00";
78 else 79 else
79 strTmp = QString::number(i) + ":00"; 80 strTmp = QString::number(i) + ":00";
80 } 81 }
81 strTmp = strTmp.rightJustify( 6, ' ' ); 82 strTmp = strTmp.rightJustify( 6, ' ' );
82 verticalHeader()->setLabel( i, strTmp ); 83 verticalHeader()->setLabel( i, strTmp );
83 84
84 // Compute correct width for current Font (Add some space right) 85 // Compute correct width for current Font (Add some space right)
85 int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") ); 86 int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") );
86 if ( preferredWidth < actWidth ) 87 if ( preferredWidth < actWidth )
87 preferredWidth = actWidth; 88 preferredWidth = actWidth;
88 setRowStretchable( i, FALSE ); 89 setRowStretchable( i, FALSE );
89 } 90 }
90 91
91 // It seems as if the header has a bug. It does not resize 92 // It seems as if the header has a bug. It does not resize
92 // correct horizontally if it is used vertical.. 93 // correct horizontally if it is used vertical..
93 // Thus, we do it manually.. 94 // Thus, we do it manually..
94 setLeftMargin( preferredWidth ); 95 setLeftMargin( preferredWidth );
95} 96}
96 97
97void DateBookDayView::slotDateChanged( int y, int m, int d ) 98void DateBookDayView::slotDateChanged( int y, int m, int d )
98{ 99{
99 currDate.setYMD(y,m,d); 100 currDate.setYMD(y,m,d);
100} 101}
101 102
102void DateBookDayView::slotChangeClock( bool newClock ) 103void DateBookDayView::slotChangeClock( bool newClock )
103{ 104{
104 ampm = newClock; 105 ampm = newClock;
105 initHeader(); 106 initHeader();
106} 107}
107 108
108bool DateBookDayView::whichClock() const 109bool DateBookDayView::whichClock() const
109{ 110{
110 return ampm; 111 return ampm;
111} 112}
112 113
113void DateBookDayView::moveUp() 114void DateBookDayView::moveUp()
114{ 115{
115 scrollBy(0, -20); 116 scrollBy(0, -20);
116} 117}
117 118
118void DateBookDayView::moveDown() 119void DateBookDayView::moveDown()
119{ 120{
120 scrollBy(0, 20); 121 scrollBy(0, 20);
121} 122}
122 123
123void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) 124void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool )
124{ 125{
125 int w = cr.width(); 126 int w = cr.width();
126 int h = cr.height(); 127 int h = cr.height();
127 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); 128 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) );
128 if ( showGrid() ) { 129 if ( showGrid() ) {
129 // Draw our lines 130 // Draw our lines
130 int x2 = w - 1; 131 int x2 = w - 1;
131 int y2 = h - 1; 132 int y2 = h - 1;
132 QPen pen( p->pen() ); 133 QPen pen( p->pen() );
133 p->setPen( colorGroup().dark() ); 134 p->setPen( colorGroup().dark() );
134 p->drawLine( x2, 0, x2, y2 ); 135 p->drawLine( x2, 0, x2, y2 );
135 p->drawLine( 0, y2, x2, y2 ); 136 p->drawLine( 0, y2, x2, y2 );
136 137
137 p->setPen( colorGroup().midlight() ); 138 p->setPen( colorGroup().midlight() );
138 p->drawLine( 0, y2 - h/2, x2, y2 - h/2); 139 p->drawLine( 0, y2 - h/2, x2, y2 - h/2);
139 140
140 p->setPen( pen ); 141 p->setPen( pen );
141 } 142 }
142} 143}
143 144
@@ -147,73 +148,73 @@ void DateBookDayView::paintFocus( QPainter *, const QRect & )
147 148
148void DateBookDayView::resizeEvent( QResizeEvent *e ) 149void DateBookDayView::resizeEvent( QResizeEvent *e )
149{ 150{
150 QTable::resizeEvent( e ); 151 QTable::resizeEvent( e );
151 columnWidthChanged( 0 ); 152 columnWidthChanged( 0 );
152 emit sigColWidthChanged(); 153 emit sigColWidthChanged();
153} 154}
154 155
155void DateBookDayView::keyPressEvent( QKeyEvent *e ) 156void DateBookDayView::keyPressEvent( QKeyEvent *e )
156{ 157{
157 QString txt = e->text(); 158 QString txt = e->text();
158 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { 159 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) {
159 // we this is some sort of thing we know about... 160 // we this is some sort of thing we know about...
160 e->accept(); 161 e->accept();
161 emit sigCapturedKey( txt ); 162 emit sigCapturedKey( txt );
162 } else { 163 } else {
163 // I don't know what this key is, do you? 164 // I don't know what this key is, do you?
164 e->ignore(); 165 e->ignore();
165 } 166 }
166} 167}
167 168
168void DateBookDayView::setRowStyle( int style ) 169void DateBookDayView::setRowStyle( int style )
169{ 170{
170 if (style<0) style = 0; 171 if (style<0) style = 0;
171 172
172 for (int i=0; i<numRows(); i++) 173 for (int i=0; i<numRows(); i++)
173 setRowHeight(i, style*10+20); 174 setRowHeight(i, style*10+20);
174} 175}
175 176
176void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ ) 177void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ )
177{ 178{
178 int sh=99,eh=-1; 179 int sh=99,eh=-1;
179 180
180 for(int i=0;i<this->numSelections();i++) { 181 for(int i=0;i<this->numSelections();i++) {
181 QTableSelection sel = this->selection( i ); 182 QTableSelection sel = this->selection( i );
182 sh = QMIN(sh,sel.topRow()); 183 sh = QMIN(sh,sel.topRow());
183 eh = QMAX(sh,sel.bottomRow()+1); 184 eh = QMAX(sh,sel.bottomRow()+1);
184 } 185 }
185 if (sh > 23 || eh < 1) { 186 if (sh > 23 || eh < 1) {
186 sh=8; 187 sh=8;
187 eh=9; 188 eh=9;
188 } 189 }
189 190
190 quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); 191 quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit");
191 quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); 192 quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0));
192 this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); 193 this->moveChild(quickLineEdit,0,sh*this->rowHeight(0));
193 quickLineEdit->setFocus(); 194 quickLineEdit->setFocus();
194 quickLineEdit->show(); 195 quickLineEdit->show();
195} 196}
196 197
197//=========================================================================== 198//===========================================================================
198 199
199DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) 200DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name)
200{ 201{
201 active=1; 202 active=1;
202 quickEvent.setStart(start); 203 quickEvent.setStart(start);
203 quickEvent.setEnd(end); 204 quickEvent.setEnd(end);
204 connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); 205 connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed()));
205} 206}
206 207
207void DateBookDayViewQuickLineEdit::slotReturnPressed() 208void DateBookDayViewQuickLineEdit::slotReturnPressed()
208{ 209{
209 if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. 210 if(active && (!this->text().isEmpty())) { // Fix to avoid having this event beeing added multiple times.
210 quickEvent.setDescription(this->text()); 211 quickEvent.setDescription(this->text());
211 connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&))); 212 connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&)));
212 emit(insertEvent(quickEvent)); 213 emit(insertEvent(quickEvent));
213 active=0; 214 active=0;
214 } 215 }
215 /* we need to return to this object.. */ 216 /* we need to return to this object.. */
216 QTimer::singleShot(500, this, SLOT(finallyCallClose()) );// Close and also delete this widget 217 QTimer::singleShot(500, this, SLOT(finallyCallClose()) ); // Close and also delete this widget
217} 218}
218void DateBookDayViewQuickLineEdit::finallyCallClose() { 219void DateBookDayViewQuickLineEdit::finallyCallClose() {
219 close(true); // also deletes this widget... 220 close(true); // also deletes this widget...
@@ -221,154 +222,163 @@ void DateBookDayViewQuickLineEdit::finallyCallClose() {
221 222
222void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */) 223void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */)
223{ 224{
224 slotReturnPressed(); // Reuse code to add event and close this widget. 225 slotReturnPressed(); // Reuse code to add event and close this widget.
225} 226}
226 227
227//=========================================================================== 228//===========================================================================
228 229
229DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) 230DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, DateBookHoliday*newHdb, QWidget *parent, const char *name )
230 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) 231 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 )
231{ 232{
232 widgetList.setAutoDelete( true ); 233 widgetList.setAutoDelete( true );
233 header = new DateBookDayHeader( startOnMonday, this, "day header" ); 234 _holiday_db = newHdb;
234 header->setDate( currDate.year(), currDate.month(), currDate.day() ); 235 header = new DateBookDayHeader( startOnMonday, this, "day header" );
236 header->setDate( currDate.year(), currDate.month(), currDate.day() );
235 237
236 m_allDays = new DatebookdayAllday(newDb, this, "all day event list" ); 238 m_allDays = new DatebookdayAllday(newDb, this, "all day event list" );
237 m_allDays->hide(); 239 m_allDays->hide();
238 240
239 view = new DateBookDayView( ampm, this, "day view" ); 241 view = new DateBookDayView( ampm, this, "day view" );
240 242
241 connect( header, SIGNAL( dateChanged(int,int,int) ), this, SLOT( dateChanged(int,int,int) ) ); 243 connect( header, SIGNAL( dateChanged(int,int,int) ), this, SLOT( dateChanged(int,int,int) ) );
242 connect( header, SIGNAL( dateChanged(int,int,int) ), view, SLOT( slotDateChanged(int,int,int) ) ); 244 connect( header, SIGNAL( dateChanged(int,int,int) ), view, SLOT( slotDateChanged(int,int,int) ) );
243 connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); 245 connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) );
244 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); 246 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
245 connect( view, SIGNAL(sigCapturedKey(const QString&)), this, SIGNAL(sigNewEvent(const QString&)) ); 247 connect( view, SIGNAL(sigCapturedKey(const QString&)), this, SIGNAL(sigNewEvent(const QString&)) );
246 248
247 QTimer *timer = new QTimer( this ); 249 QTimer *timer = new QTimer( this );
248 250
249 connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors 251 connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) ); //connect timer for updating timeMarker & daywidgetcolors
250 timer->start( 1000*60*5, FALSE ); //update every 5min 252 timer->start( 1000*60*5, FALSE ); //update every 5min
251 253
252 selectedWidget = 0; 254 selectedWidget = 0;
253 255
254 timeMarker = new DateBookDayTimeMarker( this ); 256 timeMarker = new DateBookDayTimeMarker( this );
255 timeMarker->setTime( QTime::currentTime() ); 257 timeMarker->setTime( QTime::currentTime() );
256 rowStyle = -1; // initialize with bogus values 258 rowStyle = -1; // initialize with bogus values
257 jumpToCurTime = false; 259 jumpToCurTime = false;
258} 260}
259 261
260void DateBookDay::setJumpToCurTime( bool bJump ) 262void DateBookDay::setJumpToCurTime( bool bJump )
261{ 263{
262 jumpToCurTime = bJump; 264 jumpToCurTime = bJump;
263} 265}
264 266
265void DateBookDay::setRowStyle( int style ) 267void DateBookDay::setRowStyle( int style )
266{ 268{
267 if (rowStyle != style) view->setRowStyle( style ); 269 if (rowStyle != style) view->setRowStyle( style );
268 rowStyle = style; 270 rowStyle = style;
269} 271}
270 272
271void DateBookDay::updateView( void ) 273void DateBookDay::updateView( void )
272{ 274{
273 timeMarker->setTime( QTime::currentTime() ); 275 timeMarker->setTime( QTime::currentTime() );
274 //need to find a way to update all DateBookDayWidgets 276 //need to find a way to update all DateBookDayWidgets
275} 277}
276 278
277void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) 279void DateBookDay::setSelectedWidget( DateBookDayWidget *w )
278{ 280{
279 selectedWidget = w; 281 selectedWidget = w;
280} 282}
281 283
282DateBookDayWidget * DateBookDay::getSelectedWidget( void ) 284DateBookDayWidget * DateBookDay::getSelectedWidget( void )
283{ 285{
284 return selectedWidget; 286 return selectedWidget;
285} 287}
286 288
287void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) 289void DateBookDay::selectedDates( QDateTime &start, QDateTime &end )
288{ 290{
289 start.setDate( currDate ); 291 start.setDate( currDate );
290 end.setDate( currDate ); 292 end.setDate( currDate );
291 293
292 int sh=99,eh=-1; 294 int sh=99,eh=-1;
293 295
294 int n = dayView()->numSelections(); 296 int n = dayView()->numSelections();
295 297
296 for (int i=0; i<n; i++) { 298 for (int i=0; i<n; i++) {
297 QTableSelection sel = dayView()->selection( i ); 299 QTableSelection sel = dayView()->selection( i );
298 sh = QMIN(sh,sel.topRow()); 300 sh = QMIN(sh,sel.topRow());
299 eh = QMAX(sh,sel.bottomRow()+1); 301 eh = QMAX(sh,sel.bottomRow()+1);
300 } 302 }
301 303
302 if (sh > 23 || eh < 1) { 304 if (sh > 23 || eh < 1) {
303 sh=8; 305 sh=8;
304 eh=9; 306 eh=9;
305 } 307 }
306 308
307 start.setTime( QTime( sh, 0, 0 ) ); 309 start.setTime( QTime( sh, 0, 0 ) );
308 end.setTime( QTime( eh, 0, 0 ) ); 310 end.setTime( QTime( eh, 0, 0 ) );
309} 311}
310 312
311void DateBookDay::setDate( int y, int m, int d ) 313void DateBookDay::setDate( int y, int m, int d )
312{ 314{
313 header->setDate( y, m, d ); 315 header->setDate( y, m, d );
314 selectedWidget = 0; 316 selectedWidget = 0;
315} 317}
316 318
317void DateBookDay::setDate( QDate d) 319void DateBookDay::setDate( QDate d)
318{ 320{
319 header->setDate( d.year(), d.month(), d.day() ); 321 header->setDate( d.year(), d.month(), d.day() );
320 selectedWidget = 0; 322 selectedWidget = 0;
321} 323}
322 324
323void DateBookDay::dateChanged( int y, int m, int d ) 325void DateBookDay::dateChanged( int y, int m, int d )
324{ 326{
325 QDate date( y, m, d ); 327 QDate date( y, m, d );
326 if ( currDate == date ) 328 if ( currDate == date )
327 return; 329 return;
328 currDate.setYMD( y, m, d ); 330 currDate.setYMD( y, m, d );
329 relayoutPage(); 331 relayoutPage();
330 dayView()->clearSelection(); 332 dayView()->clearSelection();
331 QTableSelection ts; 333 QTableSelection ts;
332 334
333 if (jumpToCurTime && this->date() == QDate::currentDate()) 335 if (jumpToCurTime && this->date() == QDate::currentDate())
334 { 336 {
335 ts.init( QTime::currentTime().hour(), 0); 337 ts.init( QTime::currentTime().hour(), 0);
336 ts.expandTo( QTime::currentTime().hour(), 0); 338 ts.expandTo( QTime::currentTime().hour(), 0);
337 } else { 339 } else {
338 ts.init( startTime, 0 ); 340 ts.init( startTime, 0 );
339 ts.expandTo( startTime, 0 ); 341 ts.expandTo( startTime, 0 );
340 } 342 }
341 343
342 dayView()->addSelection( ts ); 344 dayView()->addSelection( ts );
343 selectedWidget = 0; 345 selectedWidget = 0;
344} 346}
345 347
346void DateBookDay::redraw() 348void DateBookDay::redraw()
347{ 349{
348 if ( isUpdatesEnabled() ) 350 if ( isUpdatesEnabled() )
349 relayoutPage(); 351 relayoutPage();
350} 352}
351 353
352void DateBookDay::getEvents() 354void DateBookDay::getEvents()
353{ 355{
354 widgetList.clear(); 356 widgetList.clear();
355 357
356 /* clear the AllDay List */ 358 /* clear the AllDay List */
357 m_allDays->hide(); // just in case 359 m_allDays->hide(); // just in case
358 m_allDays->removeAllEvents(); 360 m_allDays->removeAllEvents();
359 361
360 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); 362 QStringList hdays = _holiday_db->holidaylist(currDate);
361 QValueListIterator<EffectiveEvent> it; 363 QStringList::Iterator sit;
362 QObject* object = 0; 364 QObject* object = 0;
363 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 365 for (sit=hdays.begin();sit!=hdays.end();++sit) {
364 EffectiveEvent ev=*it; 366 object = m_allDays->addHoliday(*sit);
365 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. 367 if (!object) continue;
368 /* not to do something with it */
369 }
370 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate );
371 QValueListIterator<EffectiveEvent> it;
372
373 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
374 EffectiveEvent ev=*it;
375 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) { // Skip events ending at 00:00 starting at another day.
366 if (ev.event().type() == Event::AllDay ) { 376 if (ev.event().type() == Event::AllDay ) {
367 object = m_allDays->addEvent( ev ); 377 object = m_allDays->addEvent( ev );
368 if (!object) 378 if (!object)
369 continue; 379 continue;
370 }else { 380 }else {
371 DateBookDayWidget* w = new DateBookDayWidget( *it, this ); 381 DateBookDayWidget* w = new DateBookDayWidget( *it, this );
372 widgetList.append( w ); 382 widgetList.append( w );
373 object = w; 383 object = w;
374 } 384 }
@@ -378,50 +388,50 @@ void DateBookDay::getEvents()
378 connect( object, SIGNAL( editMe(const Event&) ), this, SIGNAL( editEvent(const Event&) ) ); 388 connect( object, SIGNAL( editMe(const Event&) ), this, SIGNAL( editEvent(const Event&) ) );
379 connect( object, SIGNAL( beamMe(const Event&) ), this, SIGNAL( beamEvent(const Event&) ) ); 389 connect( object, SIGNAL( beamMe(const Event&) ), this, SIGNAL( beamEvent(const Event&) ) );
380 390
381 } 391 }
382 } 392 }
383} 393}
384 394
385static int place( const DateBookDayWidget *item, bool *used, int maxn ) 395static int place( const DateBookDayWidget *item, bool *used, int maxn )
386{ 396{
387 int place = 0; 397 int place = 0;
388 int start = item->event().start().hour(); 398 int start = item->event().start().hour();
389 QTime e = item->event().end(); 399 QTime e = item->event().end();
390 int end = e.hour(); 400 int end = e.hour();
391 if ( e.minute() < 5 ) 401 if ( e.minute() < 5 )
392 end--; 402 end--;
393 if ( end < start ) 403 if ( end < start )
394 end = start; 404 end = start;
395 while ( place < maxn ) { 405 while ( place < maxn ) {
396 bool free = TRUE; 406 bool free = TRUE;
397 int s = start; 407 int s = start;
398 while( s <= end ) { 408 while( s <= end ) {
399 if ( used[10*s+place] ) { 409 if ( used[10*s+place] ) {
400 free = FALSE; 410 free = FALSE;
401 break; 411 break;
402 } 412 }
403 s++; 413 s++;
404 } 414 }
405 if ( free ) 415 if ( free )
406 break; 416 break;
407 place++; 417 place++;
408 } 418 }
409 if ( place == maxn ) { 419 if ( place == maxn ) {
410 return -1; 420 return -1;
411 } 421 }
412 while( start <= end ) { 422 while( start <= end ) {
413 used[10*start+place] = TRUE; 423 used[10*start+place] = TRUE;
414 start++; 424 start++;
415 } 425 }
416 return place; 426 return place;
417} 427}
418 428
419 429
420void DateBookDay::relayoutPage( bool fromResize ) 430void DateBookDay::relayoutPage( bool fromResize )
421{ 431{
422 setUpdatesEnabled( FALSE ); 432 setUpdatesEnabled( FALSE );
423 if ( !fromResize ) { 433 if ( !fromResize ) {
424 getEvents(); // no need we already have them! 434 getEvents(); // no need we already have them!
425 435
426 if (m_allDays->items() > 0 ) 436 if (m_allDays->items() > 0 )
427 m_allDays->show(); 437 m_allDays->show();
@@ -430,282 +440,282 @@ void DateBookDay::relayoutPage( bool fromResize )
430 */ 440 */
431 } 441 }
432 442
433 widgetList.sort(); 443 widgetList.sort();
434 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning 444 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning
435 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view 445 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view
436 446
437 int wCount = widgetList.count(); 447 int wCount = widgetList.count();
438 int wid = view->columnWidth(0)-1; 448 int wid = view->columnWidth(0)-1;
439 int wd; 449 int wd;
440 int n = 1; 450 int n = 1;
441 451
442 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget 452 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget
443 453
444 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); 454 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++);
445 455
446 if ( wCount < 20 ) { 456 if ( wCount < 20 ) {
447 457
448 QArray<QRect> geometries(wCount); 458 QArray<QRect> geometries(wCount);
449 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector 459 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++); //stores geometry for each widget in vector
450 460
451 for ( int i = 0; i < wCount; i++) { 461 for ( int i = 0; i < wCount; i++) {
452 QValueList<int> intersectedWidgets; 462 QValueList<int> intersectedWidgets;
453 463
454 //find all widgets intersecting with widgetList.at(i) 464 //find all widgets intersecting with widgetList.at(i)
455 for ( int j = 0; j < wCount; j++) { 465 for ( int j = 0; j < wCount; j++) {
456 if (i != j) 466 if (i != j)
457 if (geometries[j].intersects(geometries[i])) 467 if (geometries[j].intersects(geometries[i]))
458 intersectedWidgets.append(j); 468 intersectedWidgets.append(j);
459 } 469 }
460 470
461 //for each of these intersecting widgets find out how many widgets are they intersecting with 471 //for each of these intersecting widgets find out how many widgets are they intersecting with
462 for ( uint j = 0; j < intersectedWidgets.count(); j++) 472 for ( uint j = 0; j < intersectedWidgets.count(); j++)
463 { 473 {
464 QArray<int> inter(wCount); 474 QArray<int> inter(wCount);
465 inter[j]=1; 475 inter[j]=1;
466 476
467 if (intersectedWidgets[j] != -1) 477 if (intersectedWidgets[j] != -1)
468 for ( uint k = j; k < intersectedWidgets.count(); k++) { 478 for ( uint k = j; k < intersectedWidgets.count(); k++) {
469 if (j != k && intersectedWidgets[k] != -1) 479 if (j != k && intersectedWidgets[k] != -1)
470 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { 480 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) {
471 inter[j]++; 481 inter[j]++;
472 intersectedWidgets[k] = -1; 482 intersectedWidgets[k] = -1;
473 } 483 }
474 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; 484 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1;
475 } 485 }
476 } 486 }
477 if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; 487 if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++;
478 } 488 }
479 489
480 490
481 for ( int i = 0; i < wCount; i++) { 491 for ( int i = 0; i < wCount; i++) {
482 DateBookDayWidget *w = widgetList.at(i); 492 DateBookDayWidget *w = widgetList.at(i);
483 QRect geom = w->geometry(); 493 QRect geom = w->geometry();
484 geom.setX( 0 ); 494 geom.setX( 0 );
485 wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); 495 wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0);
486 geom.setWidth( wd ); 496 geom.setWidth( wd );
487 while ( intersects( w, geom ) ) { 497 while ( intersects( w, geom ) ) {
488 geom.moveBy( wd + 2 + 1, 0 ); 498 geom.moveBy( wd + 2 + 1, 0 );
489 } 499 }
490 w->setGeometry( geom ); 500 w->setGeometry( geom );
491 } 501 }
492 502
493 if (jumpToCurTime && this->date() == QDate::currentDate()) { 503 if (jumpToCurTime && this->date() == QDate::currentDate()) {
494 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour 504 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour
495 } else { 505 } else {
496 view->setContentsPos( 0, startTime * view->rowHeight(0) ); 506 view->setContentsPos( 0, startTime * view->rowHeight(0) );
497 } 507 }
498 } else { 508 } else {
499 int hours[24]; 509 int hours[24];
500 memset( hours, 0, 24*sizeof( int ) ); 510 memset( hours, 0, 24*sizeof( int ) );
501 bool overFlow = FALSE; 511 bool overFlow = FALSE;
502 for ( int i = 0; i < wCount; i++ ) { 512 for ( int i = 0; i < wCount; i++ ) {
503 DateBookDayWidget *w = widgetList.at(i); 513 DateBookDayWidget *w = widgetList.at(i);
504 int start = w->event().start().hour(); 514 int start = w->event().start().hour();
505 QTime e = w->event().end(); 515 QTime e = w->event().end();
506 int end = e.hour(); 516 int end = e.hour();
507 if ( e.minute() < 5 ) 517 if ( e.minute() < 5 )
508 end--; 518 end--;
509 if ( end < start ) 519 if ( end < start )
510 end = start; 520 end = start;
511 while( start <= end ) { 521 while( start <= end ) {
512 hours[start]++; 522 hours[start]++;
513 if ( hours[start] >= 10 ) 523 if ( hours[start] >= 10 )
514 overFlow = TRUE; 524 overFlow = TRUE;
515 ++start; 525 ++start;
516 } 526 }
517 if ( overFlow ) 527 if ( overFlow )
518 break; 528 break;
519 } 529 }
520 for ( int i = 0; i < 24; i++ ) { 530 for ( int i = 0; i < 24; i++ ) {
521 n = QMAX( n, hours[i] ); 531 n = QMAX( n, hours[i] );
522 } 532 }
523 wid = ( view->columnWidth(0)-1 ) / n; 533 wid = ( view->columnWidth(0)-1 ) / n;
524 534
525 bool used[24*10]; 535 bool used[24*10];
526 memset( used, FALSE, 24*10*sizeof( bool ) ); 536 memset( used, FALSE, 24*10*sizeof( bool ) );
527 537
528 for ( int i = 0; i < wCount; i++ ) { 538 for ( int i = 0; i < wCount; i++ ) {
529 DateBookDayWidget *w = widgetList.at(i); 539 DateBookDayWidget *w = widgetList.at(i);
530 int xp = place( w, used, n ); 540 int xp = place( w, used, n );
531 if ( xp != -1 ) { 541 if ( xp != -1 ) {
532 QRect geom = w->geometry(); 542 QRect geom = w->geometry();
533 geom.setX( xp*(wid+2) ); 543 geom.setX( xp*(wid+2) );
534 geom.setWidth( wid ); 544 geom.setWidth( wid );
535 w->setGeometry( geom ); 545 w->setGeometry( geom );
536 } 546 }
537 } 547 }
538 548
539 if (jumpToCurTime && this->date() == QDate::currentDate()) { 549 if (jumpToCurTime && this->date() == QDate::currentDate()) {
540 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour 550 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour
541 } else { 551 } else {
542 view->setContentsPos( 0, startTime * view->rowHeight(0) ); 552 view->setContentsPos( 0, startTime * view->rowHeight(0) );
543 } 553 }
544 } 554 }
545 555
546 timeMarker->setTime( QTime::currentTime() );//display timeMarker 556 timeMarker->setTime( QTime::currentTime() ); //display timeMarker
547 timeMarker->raise(); //on top of all widgets 557 timeMarker->raise(); //on top of all widgets
548 if (this->date() == QDate::currentDate()) { //only show timeMarker on current day 558 if (this->date() == QDate::currentDate()) { //only show timeMarker on current day
549 timeMarker->show(); 559 timeMarker->show();
550 } else { 560 } else {
551 timeMarker->hide(); 561 timeMarker->hide();
552 } 562 }
553 setUpdatesEnabled( TRUE ); 563 setUpdatesEnabled( TRUE );
554 return; 564 return;
555} 565}
556 566
557DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) 567DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom )
558{ 568{
559 int i = 0; 569 int i = 0;
560 DateBookDayWidget *w = widgetList.at(i); 570 DateBookDayWidget *w = widgetList.at(i);
561 int wCount = widgetList.count(); 571 int wCount = widgetList.count();
562 while ( i < wCount && w != item ) { 572 while ( i < wCount && w != item ) {
563 if ( w->geometry().intersects( geom ) ) { 573 if ( w->geometry().intersects( geom ) ) {
564 return w; 574 return w;
565 } 575 }
566 w = widgetList.at(++i); 576 w = widgetList.at(++i);
567 } 577 }
568 578
569 return 0; 579 return 0;
570} 580}
571 581
572 582
573QDate DateBookDay::date() const 583QDate DateBookDay::date() const
574{ 584{
575 return currDate; 585 return currDate;
576} 586}
577 587
578void DateBookDay::setStartViewTime( int startHere ) 588void DateBookDay::setStartViewTime( int startHere )
579{ 589{
580 startTime = startHere; 590 startTime = startHere;
581 dayView()->clearSelection(); 591 dayView()->clearSelection();
582 QTableSelection ts; 592 QTableSelection ts;
583 593
584 if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called? 594 if (jumpToCurTime && this->date() == QDate::currentDate()) { //this should probably be in datebook.cpp where it's called?
585 ts.init( QTime::currentTime().hour(), 0); 595 ts.init( QTime::currentTime().hour(), 0);
586 ts.expandTo( QTime::currentTime().hour(), 0); 596 ts.expandTo( QTime::currentTime().hour(), 0);
587 } else { 597 } else {
588 ts.init( startTime, 0 ); 598 ts.init( startTime, 0 );
589 ts.expandTo( startTime, 0 ); 599 ts.expandTo( startTime, 0 );
590 } 600 }
591 601
592 dayView()->addSelection( ts ); 602 dayView()->addSelection( ts );
593} 603}
594 604
595int DateBookDay::startViewTime() const 605int DateBookDay::startViewTime() const
596{ 606{
597 return startTime; 607 return startTime;
598} 608}
599 609
600void DateBookDay::slotWeekChanged( bool bStartOnMonday ) 610void DateBookDay::slotWeekChanged( bool bStartOnMonday )
601{ 611{
602 header->setStartOfWeek( bStartOnMonday ); 612 header->setStartOfWeek( bStartOnMonday );
603 //redraw(); 613// redraw();
604} 614}
605 615
606void DateBookDay::keyPressEvent(QKeyEvent *e) 616void DateBookDay::keyPressEvent(QKeyEvent *e)
607{ 617{
608 switch(e->key()) { 618 switch(e->key()) {
609 case Key_Up: 619 case Key_Up:
610 view->moveUp(); 620 view->moveUp();
611 break; 621 break;
612 case Key_Down: 622 case Key_Down:
613 view->moveDown(); 623 view->moveDown();
614 break; 624 break;
615 case Key_Left: 625 case Key_Left:
616 setDate(QDate(currDate).addDays(-1)); 626 setDate(QDate(currDate).addDays(-1));
617 break; 627 break;
618 case Key_Right: 628 case Key_Right:
619 setDate(QDate(currDate).addDays(1)); 629 setDate(QDate(currDate).addDays(1));
620 break; 630 break;
621 default: 631 default:
622 e->ignore(); 632 e->ignore();
623 } 633 }
624} 634}
625 635
626//=========================================================================== 636//===========================================================================
627 637
628DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) 638DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db )
629 : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) 639 : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db )
630{ 640{
631 // why would someone use "<"? Oh well, fix it up... 641 // why would someone use "<"? Oh well, fix it up...
632 // I wonder what other things may be messed up... 642 // I wonder what other things may be messed up...
633 QString strDesc = ev.description(); 643 QString strDesc = ev.description();
634 int where = strDesc.find( "<" ); 644 int where = strDesc.find( "<" );
635 while ( where != -1 ) { 645 while ( where != -1 ) {
636 strDesc.remove( where, 1 ); 646 strDesc.remove( where, 1 );
637 strDesc.insert( where, "&#60;" ); 647 strDesc.insert( where, "&#60;" );
638 where = strDesc.find( "<", where ); 648 where = strDesc.find( "<", where );
639 } 649 }
640 650
641 QString strCat; 651 QString strCat;
642// ### Fix later... 652// ### Fix later...
643// QString strCat = ev.category(); 653// QString strCat = ev.category();
644// where = strCat.find( "<" ); 654// where = strCat.find( "<" );
645// while ( where != -1 ) { 655// while ( where != -1 ) {
646 // strCat.remove( where, 1 ); 656// strCat.remove( where, 1 );
647 // strCat.insert( where, "&#60;" ); 657// strCat.insert( where, "&#60;" );
648 // where = strCat.find( "<", where ); 658// where = strCat.find( "<", where );
649// } 659// }
650 660
651 QString strNote = ev.notes(); 661 QString strNote = ev.notes();
652 where = strNote.find( "<" ); 662 where = strNote.find( "<" );
653 while ( where != -1 ) { 663 while ( where != -1 ) {
654 strNote.remove( where, 1 ); 664 strNote.remove( where, 1 );
655 strNote.insert( where, "&#60;" ); 665 strNote.insert( where, "&#60;" );
656 where = strNote.find( "<", where ); 666 where = strNote.find( "<", where );
657 } 667 }
658 668
659 text = "<b>" + strDesc + "</b><br>" + "<i>"; 669 text = "<b>" + strDesc + "</b><br>" + "<i>";
660 if ( !strCat.isEmpty() ) { 670 if ( !strCat.isEmpty() ) {
661 text += strCat + "</i><br>"; 671 text += strCat + "</i><br>";
662 } 672 }
663 if (ev.event().type() == Event::Normal ) { 673 if (ev.event().type() == Event::Normal ) {
664 setEventText( text ); 674 setEventText( text );
665 } else { 675 } else {
666 setAllDayText( text ); 676 setAllDayText( text );
667 } 677 }
668 678
669 text += "<br><br>" + strNote; 679 text += "<br><br>" + strNote;
670 680
671 setBackgroundMode( PaletteBase ); 681 setBackgroundMode( PaletteBase );
672 682
673 QTime start = ev.start(); 683 QTime start = ev.start();
674 QTime end = ev.end(); 684 QTime end = ev.end();
675 int y = start.hour()*60+start.minute(); 685 int y = start.hour()*60+start.minute();
676 int h = end.hour()*60+end.minute()-y; 686 int h = end.hour()*60+end.minute()-y;
677 int rh = dateBook->dayView()->rowHeight(0); 687 int rh = dateBook->dayView()->rowHeight(0);
678 y = y*rh/60; 688 y = y*rh/60;
679 h = h*rh/60; 689 h = h*rh/60;
680 690
681 if ( h < 12 ) h = 12;// Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line. 691 if ( h < 12 ) h = 12; // Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line.
682 if ( y > ((24*rh)-12) ) y=(24*rh)-12;// Make sure the widget fits inside the dayview. 692 if ( y > ((24*rh)-12) ) y=(24*rh)-12; // Make sure the widget fits inside the dayview.
683 geom.setY( y ); 693 geom.setY( y );
684 geom.setHeight( h ); 694 geom.setHeight( h );
685 geom.setX( 0 ); 695 geom.setX( 0 );
686 geom.setWidth(dateBook->dayView()->columnWidth(0)-1); 696 geom.setWidth(dateBook->dayView()->columnWidth(0)-1);
687 697
688} 698}
689 699
690void DateBookDayWidget::setAllDayText( QString &text ) { 700void DateBookDayWidget::setAllDayText( QString &text ) {
691 text += "<b>" + tr("This is an all day event.") + "</b>"; 701 text += "<b>" + tr("This is an all day event.") + "</b>";
692} 702}
693 703
694void DateBookDayWidget::setEventText( QString& text ) { 704void DateBookDayWidget::setEventText( QString& text ) {
695 bool whichClock = dateBook->dayView()->whichClock(); 705 bool whichClock = dateBook->dayView()->whichClock();
696 if ( ev.startDate() != ev.endDate() ) { 706 if ( ev.startDate() != ev.endDate() ) {
697 text += "<b>" + tr("Start") + "</b>: "; 707 text += "<b>" + tr("Start") + "</b>: ";
698 text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); 708 text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE );
699 text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; 709 text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>";
700 text += "<b>" + tr("End") + "</b>: "; 710 text += "<b>" + tr("End") + "</b>: ";
701 text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); 711 text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE );
702 text += " - " + TimeString::longDateString( ev.endDate() ); 712 text += " - " + TimeString::longDateString( ev.endDate() );
703 } else { 713 } else {
704 text += "<b>" + tr("Time") + "</b>: "; 714 text += "<b>" + tr("Time") + "</b>: ";
705 text += TimeString::timeString( ev.start(), whichClock, FALSE ); 715 text += TimeString::timeString( ev.start(), whichClock, FALSE );
706 text += "<b>" + tr(" - ") + "</b>"; 716 text += "<b>" + tr(" - ") + "</b>";
707 text += TimeString::timeString( ev.end(), whichClock, FALSE ); 717 text += TimeString::timeString( ev.end(), whichClock, FALSE );
708 } 718 }
709} 719}
710 720
711DateBookDayWidget::~DateBookDayWidget() 721DateBookDayWidget::~DateBookDayWidget()
@@ -714,51 +724,51 @@ DateBookDayWidget::~DateBookDayWidget()
714 724
715void DateBookDayWidget::paintEvent( QPaintEvent *e ) 725void DateBookDayWidget::paintEvent( QPaintEvent *e )
716{ 726{
717 QPainter p( this ); 727 QPainter p( this );
718 728
719 if (dateBook->getSelectedWidget() == this) { 729 if (dateBook->getSelectedWidget() == this) {
720 p.setBrush( QColor( 155, 240, 230 ) ); // selected item 730 p.setBrush( QColor( 155, 240, 230 ) ); // selected item
721 } else { 731 } else {
722 if (dateBook->date() == QDate::currentDate()) { 732 if (dateBook->date() == QDate::currentDate()) {
723 QTime curTime = QTime::currentTime(); 733 QTime curTime = QTime::currentTime();
724 if (ev.end() < curTime) { 734 if (ev.end() < curTime) {
725 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive 735 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive
726 } else { 736 } else {
727 //change color in dependence of the time till the event starts 737 //change color in dependence of the time till the event starts
728 int duration = curTime.secsTo(ev.start()); 738 int duration = curTime.secsTo(ev.start());
729 if (duration < 0) duration = 0; 739 if (duration < 0) duration = 0;
730 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift 740 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift
731 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue 741 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue
732 } 742 }
733 } else { 743 } else {
734 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) 744 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date)
735 //perhaps make a distinction between future/past dates 745 //perhaps make a distinction between future/past dates
736 } 746 }
737 } 747 }
738 748
739 p.setPen( QColor(100, 100, 100) ); 749 p.setPen( QColor(100, 100, 100) );
740 p.drawRect(rect()); 750 p.drawRect(rect());
741 751
742 // p.drawRect(0,0, 5, height()); 752 // p.drawRect(0,0, 5, height());
743 753
744 int y = 0; 754 int y = 0;
745 int d = 0; 755 int d = 0;
746 756
747 if ( ev.event().hasAlarm() ) { 757 if ( ev.event().hasAlarm() ) {
748 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); 758 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) );
749 y = 20; 759 y = 20;
750 d = 20; 760 d = 20;
751 } 761 }
752 762
753 if ( ev.event().hasRepeat() ) { 763 if ( ev.event().hasRepeat() ) {
754 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); 764 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) );
755 d = 20; 765 d = 20;
756 y += 20; 766 y += 20;
757 } 767 }
758 768
759 QSimpleRichText rt( text, font() ); 769 QSimpleRichText rt( text, font() );
760 rt.setWidth( geom.width() - d - 6 ); 770 rt.setWidth( geom.width() - d - 6 );
761 rt.draw( &p, 7, 0, e->region(), colorGroup() ); 771 rt.draw( &p, 7, 0, e->region(), colorGroup() );
762} 772}
763 773
764/* 774/*
@@ -785,34 +795,34 @@ QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB
785 795
786void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) 796void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
787{ 797{
788 DateBookDayWidget *item; 798 DateBookDayWidget *item;
789 799
790 item = dateBook->getSelectedWidget(); 800 item = dateBook->getSelectedWidget();
791 if (item) 801 if (item)
792 item->update(); 802 item->update();
793 803
794 dateBook->setSelectedWidget(this); 804 dateBook->setSelectedWidget(this);
795 update(); 805 update();
796 dateBook->repaint(); 806 dateBook->repaint();
797 807
798 Event eve = ev.event(); 808 Event eve = ev.event();
799 809
800 QPopupMenu m; 810 QPopupMenu m;
801 m.insertItem( tr( "Edit" ), 1 ); 811 m.insertItem( tr( "Edit" ), 1 );
802 m.insertItem( tr( "Duplicate" ), 4 ); 812 m.insertItem( tr( "Duplicate" ), 4 );
803 m.insertItem( tr( "Delete" ), 2 ); 813 m.insertItem( tr( "Delete" ), 2 );
804 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); 814 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 );
805 if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 ); 815 if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 );
806 int r = m.exec( e->globalPos() ); 816 int r = m.exec( e->globalPos() );
807 if ( r == 1 ) { 817 if ( r == 1 ) {
808 emit editMe( eve ); 818 emit editMe( eve );
809 } else if ( r == 2 ) { 819 } else if ( r == 2 ) {
810 emit deleteMe( eve ); 820 emit deleteMe( eve );
811 } else if ( r == 3 ) { 821 } else if ( r == 3 ) {
812 emit beamMe( eve ); 822 emit beamMe( eve );
813 } else if ( r == 4 ) { 823 } else if ( r == 4 ) {
814 emit duplicateMe( eve ); 824 emit duplicateMe( eve );
815 } else if ( r == 5 ) { 825 } else if ( r == 5 ) {
816 // create an Event and beam it... 826 // create an Event and beam it...
817 /* 827 /*
818 * Start with the easy stuff. If start and end date is the same we can just use 828 * Start with the easy stuff. If start and end date is the same we can just use
@@ -874,10 +884,10 @@ void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
874 884
875void DateBookDayWidget::setGeometry( const QRect &r ) 885void DateBookDayWidget::setGeometry( const QRect &r )
876{ 886{
877 geom = r; 887 geom = r;
878 setFixedSize( r.width()+1, r.height()+1 ); 888 setFixedSize( r.width()+1, r.height()+1 );
879 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); 889 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
880 show(); 890 show();
881} 891}
882 892
883 893
@@ -886,9 +896,9 @@ void DateBookDayWidget::setGeometry( const QRect &r )
886 896
887 897
888DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) 898DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db )
889 : QWidget( db->dayView()->viewport() ), dateBook( db ) 899 : QWidget( db->dayView()->viewport() ), dateBook( db )
890{ 900{
891 setBackgroundMode( PaletteBase ); 901 setBackgroundMode( PaletteBase );
892} 902}
893 903
894DateBookDayTimeMarker::~DateBookDayTimeMarker() 904DateBookDayTimeMarker::~DateBookDayTimeMarker()
@@ -897,39 +907,39 @@ DateBookDayTimeMarker::~DateBookDayTimeMarker()
897 907
898void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) 908void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ )
899{ 909{
900 QPainter p( this ); 910 QPainter p( this );
901 p.setBrush( QColor( 255, 0, 0 ) ); 911 p.setBrush( QColor( 255, 0, 0 ) );
902 912
903 QPen pen; 913 QPen pen;
904 pen.setStyle(NoPen); 914 pen.setStyle(NoPen);
905 915
906 p.setPen( pen ); 916 p.setPen( pen );
907 p.drawRect(rect()); 917 p.drawRect(rect());
908} 918}
909 919
910void DateBookDayTimeMarker::setTime( const QTime &t ) 920void DateBookDayTimeMarker::setTime( const QTime &t )
911{ 921{
912 int y = t.hour()*60+t.minute(); 922 int y = t.hour()*60+t.minute();
913 int rh = dateBook->dayView()->rowHeight(0); 923 int rh = dateBook->dayView()->rowHeight(0);
914 y = y*rh/60; 924 y = y*rh/60;
915 925
916 geom.setX( 0 ); 926 geom.setX( 0 );
917 927
918 int x = dateBook->dayView()->columnWidth(0)-1; 928 int x = dateBook->dayView()->columnWidth(0)-1;
919 geom.setWidth( x ); 929 geom.setWidth( x );
920 930
921 geom.setY( y ); 931 geom.setY( y );
922 geom.setHeight( 1 ); 932 geom.setHeight( 1 );
923 933
924 setGeometry( geom ); 934 setGeometry( geom );
925 935
926 time = t; 936 time = t;
927} 937}
928 938
929void DateBookDayTimeMarker::setGeometry( const QRect &r ) 939void DateBookDayTimeMarker::setGeometry( const QRect &r )
930{ 940{
931 geom = r; 941 geom = r;
932 setFixedSize( r.width()+1, r.height()+1 ); 942 setFixedSize( r.width()+1, r.height()+1 );
933 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); 943 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
934 show(); 944 show();
935} 945}
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h
index c8cb26b..3e44364 100644
--- a/core/pim/datebook/datebookday.h
+++ b/core/pim/datebook/datebookday.h
@@ -40,18 +40,18 @@ class QResizeEvent;
40 40
41class DateBookDayViewQuickLineEdit : public QLineEdit 41class DateBookDayViewQuickLineEdit : public QLineEdit
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44public: 44public:
45 DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0); 45 DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0);
46protected: 46protected:
47 Event quickEvent; 47 Event quickEvent;
48 int active; 48 int active;
49 void focusOutEvent( QFocusEvent *e ); 49 void focusOutEvent( QFocusEvent *e );
50protected slots: 50protected slots:
51 void slotReturnPressed(void); 51 void slotReturnPressed(void);
52 void finallyCallClose(); 52 void finallyCallClose();
53signals: 53signals:
54 void insertEvent(const Event &e); 54 void insertEvent(const Event &e);
55}; 55};
56 56
57 57
@@ -67,13 +67,13 @@ public:
67public slots: 67public slots:
68 void moveUp(); 68 void moveUp();
69 void moveDown(); 69 void moveDown();
70 void slotDateChanged( int year, int month, int day ); 70 void slotDateChanged( int year, int month, int day );
71 71
72signals: 72signals:
73 void sigColWidthChanged(); 73 void sigColWidthChanged();
74 void sigCapturedKey( const QString &txt ); 74 void sigCapturedKey( const QString &txt );
75protected slots: 75protected slots:
76 void slotChangeClock( bool ); 76 void slotChangeClock( bool );
77protected: 77protected:
78 virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); 78 virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected );
79 virtual void paintFocus( QPainter *p, const QRect &cr ); 79 virtual void paintFocus( QPainter *p, const QRect &cr );
@@ -84,8 +84,8 @@ protected:
84 void initHeader(); 84 void initHeader();
85private: 85private:
86 bool ampm; 86 bool ampm;
87 QDate currDate; 87 QDate currDate;
88 DateBookDayViewQuickLineEdit *quickLineEdit; 88 DateBookDayViewQuickLineEdit *quickLineEdit;
89}; 89};
90 90
91class DateBookDay; 91class DateBookDay;
@@ -157,19 +157,19 @@ private:
157//reimplemented the compareItems function so that it sorts DayWidgets by geometry heights 157//reimplemented the compareItems function so that it sorts DayWidgets by geometry heights
158class WidgetListClass : public QList<DateBookDayWidget> 158class WidgetListClass : public QList<DateBookDayWidget>
159{ 159{
160 private: 160 private:
161 161
162 int compareItems( QCollection::Item s1, QCollection::Item s2 ) 162 int compareItems( QCollection::Item s1, QCollection::Item s2 )
163 { 163 {
164 //hmm, don't punish me for that ;) 164 //hmm, don't punish me for that ;)
165 if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) 165 if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height())
166 { 166 {
167 return -1; 167 return -1;
168 } else 168 } else
169 { 169 {
170 return 1; 170 return 1;
171 } 171 }
172 } 172 }
173 173
174 174
175}; 175};
@@ -180,9 +180,10 @@ class DateBookDay : public QVBox
180 180
181 friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB 181 friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB
182public: 182public:
183 DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, 183 DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,DateBookHoliday*newHdb,
184 QWidget *parent, const char *name ); 184 QWidget *parent, const char *name );
185 void selectedDates( QDateTime &start, QDateTime &end ); 185 void selectedDates( QDateTime &start, QDateTime &end );
186
186 QDate date() const; 187 QDate date() const;
187 DateBookDayView *dayView() const { return view; } 188 DateBookDayView *dayView() const { return view; }
188 void setStartViewTime( int startHere ); 189 void setStartViewTime( int startHere );
@@ -199,7 +200,7 @@ public slots:
199 void setDate( QDate ); 200 void setDate( QDate );
200 void redraw(); 201 void redraw();
201 void slotWeekChanged( bool bStartOnMonday ); 202 void slotWeekChanged( bool bStartOnMonday );
202 void updateView();//updates TimeMarker and DayWidget-colors 203 void updateView(); //updates TimeMarker and DayWidget-colors
203 204
204signals: 205signals:
205 void removeEvent( const Event& ); 206 void removeEvent( const Event& );
@@ -225,12 +226,13 @@ private:
225 DateBookDayHeader *header; 226 DateBookDayHeader *header;
226 DatebookdayAllday *m_allDays; 227 DatebookdayAllday *m_allDays;
227 DateBookDB *db; 228 DateBookDB *db;
228 WidgetListClass widgetList;//reimplemented QList for sorting widgets by height 229 WidgetListClass widgetList; //reimplemented QList for sorting widgets by height
229 int startTime; 230 int startTime;
230 bool jumpToCurTime;//should we jump to current time in dayview? 231 bool jumpToCurTime; //should we jump to current time in dayview?
231 int rowStyle; 232 int rowStyle;
232 DateBookDayWidget *selectedWidget; //actual selected widget (obviously) 233 DateBookDayWidget *selectedWidget; //actual selected widget (obviously)
233 DateBookDayTimeMarker *timeMarker;//marker for current time 234 DateBookDayTimeMarker *timeMarker; //marker for current time
235 DateBookHoliday*_holiday_db;
234}; 236};
235 237
236#endif 238#endif
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp
index a0aefd3..3c3f482 100644
--- a/core/pim/datebook/datebookdayallday.cpp
+++ b/core/pim/datebook/datebookdayallday.cpp
@@ -66,6 +66,20 @@ DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev)
66 return lb; 66 return lb;
67} 67}
68 68
69DatebookAlldayDisp* DatebookdayAllday::addHoliday(const QString&e)
70{
71 DatebookAlldayDisp * lb;
72 lb = new DatebookAlldayDisp(e,m_MainFrame,NULL);
73 lb->show();
74 datebookdayalldayLayout->addWidget(lb);
75 subWidgets.append(lb);
76
77 connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&)));
78 ++item_count;
79
80 return lb;
81}
82
69void DatebookdayAllday::removeAllEvents() 83void DatebookdayAllday::removeAllEvents()
70{ 84{
71 subWidgets.clear(); 85 subWidgets.clear();
@@ -85,6 +99,26 @@ DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
85 int s = QFontMetrics(font()).height()+4; 99 int s = QFontMetrics(font()).height()+4;
86 setMaximumHeight( s ); 100 setMaximumHeight( s );
87 setMinimumSize( QSize( 0, s ) ); 101 setMinimumSize( QSize( 0, s ) );
102 m_holiday = false;
103}
104
105DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,const char* name, WFlags fl)
106 : QLabel(parent,name,fl),m_Ev(),dateBook(0)
107{
108 QString strDesc = aholiday;
109 strDesc = strDesc.replace(QRegExp("<"),"&#60;");
110 Event ev;
111 ev.setDescription(strDesc);
112 ev.setAllDay(true);
113 m_Ev.setEvent(ev);
114 setBackgroundColor(yellow);
115 setText(strDesc);
116 setFrameStyle(QFrame::Raised|QFrame::Panel);
117
118 int s = QFontMetrics(font()).height()+4;
119 setMaximumHeight( s );
120 setMinimumSize( QSize( 0, s ) );
121 m_holiday = true;
88} 122}
89 123
90DatebookAlldayDisp::~DatebookAlldayDisp() 124DatebookAlldayDisp::~DatebookAlldayDisp()
@@ -93,6 +127,7 @@ DatebookAlldayDisp::~DatebookAlldayDisp()
93 127
94void DatebookAlldayDisp::beam_single_event() 128void DatebookAlldayDisp::beam_single_event()
95{ 129{
130 if (m_holiday) return;
96 // create an Event and beam it... 131 // create an Event and beam it...
97 /* 132 /*
98 * Start with the easy stuff. If start and end date is the same we can just use 133 * Start with the easy stuff. If start and end date is the same we can just use
@@ -151,11 +186,13 @@ void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
151 setBackgroundColor(green); 186 setBackgroundColor(green);
152 update(); 187 update();
153 QPopupMenu m; 188 QPopupMenu m;
154 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); 189 if (!m_holiday) {
155 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); 190 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 );
156 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); 191 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 );
157 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); 192 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 );
158 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); 193 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 );
194 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 );
195 }
159 m.insertItem( tr( "Info"),6); 196 m.insertItem( tr( "Info"),6);
160 int r = m.exec( e->globalPos() ); 197 int r = m.exec( e->globalPos() );
161 setBackgroundColor(b); 198 setBackgroundColor(b);
diff --git a/core/pim/datebook/datebookdayallday.h b/core/pim/datebook/datebookdayallday.h
index f5867e5..4f5cffa 100644
--- a/core/pim/datebook/datebookdayallday.h
+++ b/core/pim/datebook/datebookdayallday.h
@@ -24,6 +24,7 @@ public:
24 QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 24 QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
25 ~DatebookdayAllday(); 25 ~DatebookdayAllday();
26 DatebookAlldayDisp* addEvent(const EffectiveEvent&e); 26 DatebookAlldayDisp* addEvent(const EffectiveEvent&e);
27 DatebookAlldayDisp* addHoliday(const QString&e);
27 const unsigned int items()const{return item_count;} 28 const unsigned int items()const{return item_count;}
28 29
29public slots: 30public slots:
@@ -45,6 +46,8 @@ class DatebookAlldayDisp : public QLabel
45public: 46public:
46 DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e, 47 DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e,
47 QWidget* parent=0,const char* name = 0, WFlags fl=0); 48 QWidget* parent=0,const char* name = 0, WFlags fl=0);
49 DatebookAlldayDisp(const QString&aholiday,
50 QWidget* parent=0,const char* name = 0, WFlags fl=0);
48 virtual ~DatebookAlldayDisp(); 51 virtual ~DatebookAlldayDisp();
49 52
50signals: 53signals:
@@ -61,6 +64,7 @@ protected:
61 DateBookDB* dateBook; 64 DateBookDB* dateBook;
62 void mousePressEvent( QMouseEvent *e ); 65 void mousePressEvent( QMouseEvent *e );
63 void beam_single_event(); 66 void beam_single_event();
67 bool m_holiday:1;
64}; 68};
65 69
66class DatebookEventDesc: public QLabel 70class DatebookEventDesc: public QLabel
diff --git a/core/pim/datebook/holiday/dummy/config.in b/core/pim/datebook/holiday/dummy/config.in
new file mode 100644
index 0000000..caa90bc
--- a/dev/null
+++ b/core/pim/datebook/holiday/dummy/config.in
@@ -0,0 +1,8 @@
1 config DATEBOOK_DUMMY_HOLIDAY
2 boolean "opie-datebook-dummyholidayplugin"
3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM
5
6 comment "opie-datebook-dummyholidayplugin requires libopie2core, libopie2ui, libopie2pim"
7 depends !( ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM )
8
diff --git a/core/pim/datebook/holiday/dummy/dummy.pro b/core/pim/datebook/holiday/dummy/dummy.pro
new file mode 100644
index 0000000..768bb77
--- a/dev/null
+++ b/core/pim/datebook/holiday/dummy/dummy.pro
@@ -0,0 +1,20 @@
1TEMPLATE = lib
2CONFIG -= moc
3CONFIG += qt plugin
4
5# Input
6HEADERS = dummyholiday.h
7SOURCES = dummyholiday.cpp
8INTERFACES=
9
10INCLUDEPATH += $(OPIEDIR)/include \
11 ../ ../library
12DEPENDPATH += $(OPIEDIR)/include \
13 ../ ../library
14
15LIBS+= -lqpe -lopiecore2 -lopieui2
16
17DESTDIR = $(OPIEDIR)/plugins/datebook/holiday
18TARGET = dummyholidayplugin
19
20include( $(OPIEDIR)/include.pro )
diff --git a/core/pim/datebook/holiday/dummy/dummyholiday.cpp b/core/pim/datebook/holiday/dummy/dummyholiday.cpp
new file mode 100644
index 0000000..dd00b9b
--- a/dev/null
+++ b/core/pim/datebook/holiday/dummy/dummyholiday.cpp
@@ -0,0 +1,20 @@
1#include "dummyholiday.h"
2
3#include <qobject.h>
4
5QString DummyHoliday::description()
6{
7 return QObject::tr("Test holiday plugin","dummyholiday");
8}
9
10QStringList DummyHoliday::entries(const QDate&aDate)
11{
12 return entries(0,0,aDate.day());
13}
14
15QStringList DummyHoliday::entries(unsigned year, unsigned month, unsigned day)
16{
17 QStringList ret;
18 if (day%2==0) ret.append(QObject::tr("You have a holiday!","dummyholiday"));
19 return ret;
20}
diff --git a/core/pim/datebook/holiday/dummy/dummyholiday.h b/core/pim/datebook/holiday/dummy/dummyholiday.h
new file mode 100644
index 0000000..9b28f24
--- a/dev/null
+++ b/core/pim/datebook/holiday/dummy/dummyholiday.h
@@ -0,0 +1,19 @@
1#ifndef __DUMMY_HOLIDAY_H
2#define __DUMMY_HOLIDAY_H
3
4#include <opie2/oholidayplugin.h>
5#include <opie2/oholidaypluginif.h>
6
7class DummyHoliday:public Opie::Datebook::HolidayPlugin
8{
9public:
10 DummyHoliday():Opie::Datebook::HolidayPlugin(){}
11 virtual ~DummyHoliday(){}
12
13 virtual QString description();
14 virtual QStringList entries(const QDate&);
15 virtual QStringList entries(unsigned year, unsigned month, unsigned day);
16};
17
18EXPORT_HOLIDAY_PLUGIN(DummyHoliday);
19#endif