summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp78
-rw-r--r--core/pim/datebook/datebook.h29
-rw-r--r--core/pim/datebook/datebookday.cpp14
-rw-r--r--core/pim/datebook/datebookday.h4
-rw-r--r--core/pim/datebook/datebookdayallday.cpp37
-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, 229 insertions, 4 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
@@ -21,67 +21,73 @@
21**********************************************************************/ 21**********************************************************************/
22 22
23#define QTOPIA_INTERNAL_FD 23#define QTOPIA_INTERNAL_FD
24 24
25#include "datebook.h" 25#include "datebook.h"
26#include "datebookday.h" 26#include "datebookday.h"
27#include "datebooksettings.h" 27#include "datebooksettings.h"
28#include "datebookweek.h" 28#include "datebookweek.h"
29#include "datebookweeklst.h" 29#include "datebookweeklst.h"
30#include "dateentryimpl.h" 30#include "dateentryimpl.h"
31 31
32#include <opie2/odebug.h> 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>
36#include <qpe/config.h> 38#include <qpe/config.h>
37#include <qpe/finddialog.h> 39#include <qpe/finddialog.h>
38#include <qpe/ir.h> 40#include <qpe/ir.h>
39#include <qpe/qpemessagebox.h> 41#include <qpe/qpemessagebox.h>
40#include <qpe/resource.h> 42#include <qpe/resource.h>
41#include <qpe/sound.h> 43#include <qpe/sound.h>
42#include <qpe/tzselect.h> 44#include <qpe/tzselect.h>
43 45
44#include <qaction.h> 46#include <qaction.h>
45#include <qcopchannel_qws.h> 47#include <qcopchannel_qws.h>
46#include <qlayout.h> 48#include <qlayout.h>
47#include <qmessagebox.h> 49#include <qmessagebox.h>
48#include <qtimer.h> 50#include <qtimer.h>
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>
55#include <fcntl.h> 59#include <fcntl.h>
56#include <unistd.h> 60#include <unistd.h>
57 61
58#include <stdlib.h> 62#include <stdlib.h>
59 63
60DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 64DateBook::DateBook( QWidget *parent, const char *, WFlags f )
61 : QMainWindow( parent, "datebook", f ), 65 : QMainWindow( parent, "datebook", f ),
62 aPreset( FALSE ), 66 aPreset( FALSE ),
63 presetTime( -1 ), 67 presetTime( -1 ),
64 startTime( 8 ), // an acceptable default 68 startTime( 8 ), // an acceptable default
65 rowStyle( 0 ), 69 rowStyle( 0 ),
66 bJumpToCurTime(FALSE), 70 bJumpToCurTime(FALSE),
67 syncing(FALSE), 71 syncing(FALSE),
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;
80 db_holiday = new DateBookHoliday();
81
76 loadSettings(); 82 loadSettings();
77 setCaption( tr("Calendar") ); 83 setCaption( tr("Calendar") );
78 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 84 setIcon( Resource::loadPixmap( "datebook_icon" ) );
79 85
80 setToolBarsMovable( FALSE ); 86 setToolBarsMovable( FALSE );
81 87
82 views = new QWidgetStack( this ); 88 views = new QWidgetStack( this );
83 setCentralWidget( views ); 89 setCentralWidget( views );
84 90
85 dayView = 0; 91 dayView = 0;
86 weekView = 0; 92 weekView = 0;
87 weekLstView = 0; 93 weekLstView = 0;
@@ -216,24 +222,25 @@ void DateBook::receive( const QCString &msg, const QByteArray &data )
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;
222 viewDefault(day); 228 viewDefault(day);
223 } 229 }
224} 230}
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
@@ -503,25 +510,25 @@ void DateBook::addEvent( const Event &e )
503 dayView->setDate( d ); 510 dayView->setDate( d );
504} 511}
505 512
506void DateBook::showDay( int year, int month, int day ) 513void DateBook::showDay( int year, int month, int day )
507{ 514{
508 QDate d(year, month, day); 515 QDate d(year, month, day);
509 view(DAY,d); 516 view(DAY,d);
510} 517}
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 }
@@ -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
@@ -27,30 +27,58 @@
27 enum { DAY=1,WEEK,WEEKLST,MONTH };// defaultView values 27 enum { DAY=1,WEEK,WEEKLST,MONTH };// defaultView values
28 enum { NONE=0,NORMAL,EXTENDED };// WeekLstView's modes. 28 enum { NONE=0,NORMAL,EXTENDED };// WeekLstView's modes.
29 29
30class QAction; 30class QAction;
31class QWidgetStack; 31class QWidgetStack;
32class DateBookDay; 32class DateBookDay;
33class DateBookWeek; 33class DateBookWeek;
34class DateBookWeekLst; 34class DateBookWeekLst;
35class DateBookMonth; 35class 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
54signals: 82signals:
55 void newEvent(); 83 void newEvent();
56 void signalNotFound(); 84 void signalNotFound();
@@ -101,24 +129,25 @@ private slots:
101 129
102private: 130private:
103 void addEvent( const Event &e ); 131 void addEvent( const Event &e );
104 void initDay(); 132 void initDay();
105 void initWeek(); 133 void initWeek();
106 void initWeekLst(); 134 void initWeekLst();
107 void initMonth(); 135 void initMonth();
108 void loadSettings(); 136 void loadSettings();
109 void saveSettings(); 137 void saveSettings();
110 138
111private: 139private:
112 DateBookDBHack *db; 140 DateBookDBHack *db;
141 DateBookHoliday*db_holiday;
113 QWidgetStack *views; 142 QWidgetStack *views;
114 DateBookDay *dayView; 143 DateBookDay *dayView;
115 DateBookWeek *weekView; 144 DateBookWeek *weekView;
116 DateBookMonth *monthView; 145 DateBookMonth *monthView;
117 DateBookWeekLst *weekLstView; 146 DateBookWeekLst *weekLstView;
118 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 147 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
119 int weeklistviewconfig; 148 int weeklistviewconfig;
120 bool aPreset; // have everything set to alarm? 149 bool aPreset; // have everything set to alarm?
121 int presetTime; // the standard time for the alarm 150 int presetTime; // the standard time for the alarm
122 int startTime; 151 int startTime;
123 int rowStyle; 152 int rowStyle;
124 int defaultView; 153 int defaultView;
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
@@ -13,24 +13,25 @@
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "datebookday.h" 21#include "datebookday.h"
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>
28 29
29#include <qsimplerichtext.h> 30#include <qsimplerichtext.h>
30#include <qpopupmenu.h> 31#include <qpopupmenu.h>
31 32
32 33
33#include <qtimer.h> 34#include <qtimer.h>
34 35
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() )
@@ -217,28 +218,29 @@ void DateBookDayViewQuickLineEdit::slotReturnPressed()
217} 218}
218void DateBookDayViewQuickLineEdit::finallyCallClose() { 219void DateBookDayViewQuickLineEdit::finallyCallClose() {
219 close(true); // also deletes this widget... 220 close(true); // also deletes this widget...
220} 221}
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 );
234 _holiday_db = newHdb;
233 header = new DateBookDayHeader( startOnMonday, this, "day header" ); 235 header = new DateBookDayHeader( startOnMonday, this, "day header" );
234 header->setDate( currDate.year(), currDate.month(), currDate.day() ); 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)) );
@@ -348,27 +350,35 @@ void DateBookDay::redraw()
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
362 QStringList hdays = _holiday_db->holidaylist(currDate);
363 QStringList::Iterator sit;
364 QObject* object = 0;
365 for (sit=hdays.begin();sit!=hdays.end();++sit) {
366 object = m_allDays->addHoliday(*sit);
367 if (!object) continue;
368 /* not to do something with it */
369 }
360 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); 370 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate );
361 QValueListIterator<EffectiveEvent> it; 371 QValueListIterator<EffectiveEvent> it;
362 QObject* object = 0; 372
363 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 373 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
364 EffectiveEvent ev=*it; 374 EffectiveEvent ev=*it;
365 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. 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 }
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
@@ -171,27 +171,28 @@ class WidgetListClass : public QList<DateBookDayWidget>
171 } 171 }
172 } 172 }
173 173
174 174
175}; 175};
176 176
177class DateBookDay : public QVBox 177class DateBookDay : public QVBox
178{ 178{
179 Q_OBJECT 179 Q_OBJECT
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 );
189 int startViewTime() const; 190 int startViewTime() const;
190 void setSelectedWidget( DateBookDayWidget * ); 191 void setSelectedWidget( DateBookDayWidget * );
191 DateBookDayWidget * getSelectedWidget( void ); 192 DateBookDayWidget * getSelectedWidget( void );
192 void setJumpToCurTime( bool bJump ); 193 void setJumpToCurTime( bool bJump );
193 void setRowStyle( int style ); 194 void setRowStyle( int style );
194 static QDate findRealStart( int uid, const QDate& isIncluded, 195 static QDate findRealStart( int uid, const QDate& isIncluded,
195 DateBookDB* ); 196 DateBookDB* );
196 197
197public slots: 198public slots:
@@ -222,15 +223,16 @@ private:
222 DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom ); 223 DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom );
223 QDate currDate; 224 QDate currDate;
224 DateBookDayView *view; 225 DateBookDayView *view;
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
@@ -57,51 +57,86 @@ DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev)
57 DatebookAlldayDisp * lb; 57 DatebookAlldayDisp * lb;
58 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); 58 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL);
59 lb->show(); 59 lb->show();
60 datebookdayalldayLayout->addWidget(lb); 60 datebookdayalldayLayout->addWidget(lb);
61 subWidgets.append(lb); 61 subWidgets.append(lb);
62 62
63 connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&))); 63 connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&)));
64 ++item_count; 64 ++item_count;
65 65
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();
72 item_count = 0; 86 item_count = 0;
73} 87}
74 88
75DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, 89DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
76 QWidget* parent,const char* name,WFlags f) 90 QWidget* parent,const char* name,WFlags f)
77 : QLabel(parent,name,f),m_Ev(ev),dateBook(db) 91 : QLabel(parent,name,f),m_Ev(ev),dateBook(db)
78{ 92{
79 QString strDesc = m_Ev.description(); 93 QString strDesc = m_Ev.description();
80 strDesc = strDesc.replace(QRegExp("<"),"&#60;"); 94 strDesc = strDesc.replace(QRegExp("<"),"&#60;");
81 setBackgroundColor(yellow); 95 setBackgroundColor(yellow);
82 setText(strDesc); 96 setText(strDesc);
83 setFrameStyle(QFrame::Raised|QFrame::Panel); 97 setFrameStyle(QFrame::Raised|QFrame::Panel);
84 98
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()
91{ 125{
92} 126}
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
99 * the values of effective m_Events 134 * the values of effective m_Events
100 * If it is a multi day m_Event we need to find the real start and end date... 135 * If it is a multi day m_Event we need to find the real start and end date...
101 */ 136 */
102 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { 137 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) {
103 Event m_Event( m_Ev.event() ); 138 Event m_Event( m_Ev.event() );
104 139
105 QDateTime dt( m_Ev.date(), m_Ev.start() ); 140 QDateTime dt( m_Ev.date(), m_Ev.start() );
106 m_Event.setStart( dt ); 141 m_Event.setStart( dt );
107 142
@@ -142,29 +177,31 @@ void DatebookAlldayDisp::beam_single_event()
142 m_Event.setEnd ( end ); 177 m_Event.setEnd ( end );
143 emit beamMe( m_Event ); 178 emit beamMe( m_Event );
144 } 179 }
145} 180}
146 181
147void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) 182void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
148{ 183{
149 Event ev = m_Ev.event(); 184 Event ev = m_Ev.event();
150 QColor b = backgroundColor(); 185 QColor b = backgroundColor();
151 setBackgroundColor(green); 186 setBackgroundColor(green);
152 update(); 187 update();
153 QPopupMenu m; 188 QPopupMenu m;
189 if (!m_holiday) {
154 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); 190 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 );
155 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); 191 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 );
156 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); 192 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 );
157 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); 193 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 );
158 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); 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);
162 update(); 199 update();
163 switch (r) { 200 switch (r) {
164 case 1: 201 case 1:
165 emit editMe( ev ); 202 emit editMe( ev );
166 break; 203 break;
167 case 2: 204 case 2:
168 emit deleteMe( ev ); 205 emit deleteMe( ev );
169 break; 206 break;
170 case 3: 207 case 3:
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
@@ -15,61 +15,65 @@ class DatebookAlldayDisp;
15class DatebookEventDesc; 15class DatebookEventDesc;
16class DateBookDB; 16class DateBookDB;
17 17
18class DatebookdayAllday : public QScrollView 18class DatebookdayAllday : public QScrollView
19{ 19{
20 Q_OBJECT 20 Q_OBJECT
21 21
22public: 22public:
23 DatebookdayAllday(DateBookDB* db, 23 DatebookdayAllday(DateBookDB* db,
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:
30 void removeAllEvents(); 31 void removeAllEvents();
31 32
32protected: 33protected:
33 QFrame * m_MainFrame; 34 QFrame * m_MainFrame;
34 QVBoxLayout* datebookdayalldayLayout; 35 QVBoxLayout* datebookdayalldayLayout;
35 DatebookEventDesc * lblDesc; 36 DatebookEventDesc * lblDesc;
36 unsigned int item_count; 37 unsigned int item_count;
37 QList<DatebookAlldayDisp> subWidgets; 38 QList<DatebookAlldayDisp> subWidgets;
38 DateBookDB *dateBook; 39 DateBookDB *dateBook;
39}; 40};
40 41
41class DatebookAlldayDisp : public QLabel 42class DatebookAlldayDisp : public QLabel
42{ 43{
43 Q_OBJECT 44 Q_OBJECT
44 45
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:
51 void deleteMe( const Event &e ); 54 void deleteMe( const Event &e );
52 void duplicateMe( const Event &e ); 55 void duplicateMe( const Event &e );
53 void editMe( const Event &e ); 56 void editMe( const Event &e );
54 void beamMe( const Event &e ); 57 void beamMe( const Event &e );
55 void displayMe(const Event &e); 58 void displayMe(const Event &e);
56 59
57public slots: 60public slots:
58 61
59protected: 62protected:
60 EffectiveEvent m_Ev; 63 EffectiveEvent m_Ev;
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
67{ 71{
68 Q_OBJECT 72 Q_OBJECT
69 73
70public: 74public:
71 DatebookEventDesc(QWidget* Parent=0,const char* name = 0); 75 DatebookEventDesc(QWidget* Parent=0,const char* name = 0);
72 virtual ~DatebookEventDesc(); 76 virtual ~DatebookEventDesc();
73 77
74public slots: 78public slots:
75 void disp_event(const Event&e); 79 void disp_event(const Event&e);
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