summaryrefslogtreecommitdiff
path: root/core/pim
authoralwin <alwin>2005-03-17 14:01:23 (UTC)
committer alwin <alwin>2005-03-17 14:01:23 (UTC)
commit8752141a5341877369f89a42fa1f0b5d08f56dbd (patch) (unidiff)
tree63dc48ee207a4e9fbb6b9e8abddb239ec724c155 /core/pim
parentafee05f4b4c1e8dab8463e3423fcfc8f9d45aa8b (diff)
downloadopie-8752141a5341877369f89a42fa1f0b5d08f56dbd.zip
opie-8752141a5341877369f89a42fa1f0b5d08f56dbd.tar.gz
opie-8752141a5341877369f89a42fa1f0b5d08f56dbd.tar.bz2
1. datebookweeklist - a week has SEVEN days, not SIX. I'm wondering why
events on sunday never showed there ;) 2. extra file datebooktypes contains some special classes used by datebook so other classes must not include the big mainheader file. 3. added support for holiday-plugins to week-views. Month view is a little bit more tricky 'cause TT has never heard about virtual methods and so I have the choice between complete copy the monthview and make the modifications or changing the interface of datebookdb-class to virtual. both isn't nice.
Diffstat (limited to 'core/pim') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp45
-rw-r--r--core/pim/datebook/datebook.h37
-rw-r--r--core/pim/datebook/datebookday.cpp5
-rw-r--r--core/pim/datebook/datebookday.h6
-rw-r--r--core/pim/datebook/datebookdayallday.cpp12
-rw-r--r--core/pim/datebook/datebooktypes.h59
-rw-r--r--core/pim/datebook/datebookweek.cpp3
-rw-r--r--core/pim/datebook/datebookweek.h5
-rw-r--r--core/pim/datebook/datebookweeklst.cpp9
-rw-r--r--core/pim/datebook/datebookweeklst.h5
10 files changed, 135 insertions, 51 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index f6aab0c..36c4bd7 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -75,9 +75,10 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
75 bool needEvilHack= false; // if we need an Evil Hack 75 bool needEvilHack= false; // if we need an Evil Hack
76 QTime t; 76 QTime t;
77 t.start(); 77 t.start();
78 db = new DateBookDBHack; 78 db = new DateBookDBHoliday;
79 odebug << "loading db t=" << t.elapsed() << oendl; 79 odebug << "loading db t=" << t.elapsed() << oendl;
80 db_holiday = new DateBookHoliday(); 80 db_holiday = new DateBookHoliday();
81 db->db_holiday=db_holiday;
81 82
82 loadSettings(); 83 loadSettings();
83 setCaption( tr("Calendar") ); 84 setCaption( tr("Calendar") );
@@ -1149,3 +1150,45 @@ QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned
1149 return holidaylist(QDate(year,month,day)); 1150 return holidaylist(QDate(year,month,day));
1150} 1151}
1151 1152
1153QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDate &from,const QDate &to )
1154{
1155 QValueList<EffectiveEvent> ret;
1156 QValueList<HPlugin*>::Iterator it;
1157 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
1158 HPlugin*_pl = *it;
1159 ret+=_pl->_plugin->events(from,to);
1160 }
1161 return ret;
1162}
1163
1164QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDate &from,const QDate &to )
1165{
1166 return DateBookDBHack::getEffectiveEvents(from,to);
1167}
1168
1169QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDateTime &start)
1170{
1171 return DateBookDBHack::getEffectiveEvents(start);
1172}
1173
1174QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDateTime &start)
1175{
1176 return getEffectiveEvents(start.date(),start.date());
1177}
1178
1179QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents(const QDate &from,const QDate &to )
1180{
1181 QValueList<EffectiveEvent> ret;
1182 odebug << "Ueberlagert 1" << oendl;
1183 if (db_holiday) {
1184 ret+=db_holiday->getEffectiveEvents(from,to);
1185 }
1186 ret+=getEffectiveEventsNoHoliday(from,to);
1187 return ret;
1188}
1189
1190QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents( const QDateTime &start)
1191{
1192 odebug << "Ueberlagert 2" << oendl;
1193 return DateBookDBHack::getEffectiveEvents(start);
1194}
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index 54ffcfb..3d7f5b5 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -20,6 +20,8 @@
20#ifndef DATEBOOK_H 20#ifndef DATEBOOK_H
21#define DATEBOOK_H 21#define DATEBOOK_H
22 22
23#include "datebooktypes.h"
24
23#include <qpe/datebookdb.h> 25#include <qpe/datebookdb.h>
24 26
25#include <qmainwindow.h> 27#include <qmainwindow.h>
@@ -36,39 +38,6 @@ class DateBookMonth;
36class Event; 38class Event;
37class QDate; 39class QDate;
38class Ir; 40class Ir;
39class QLibrary;
40
41namespace Opie {
42namespace Datebook {
43 class HolidayPlugin;
44 class HolidayPluginIf;
45}
46}
47
48class DateBookDBHack : public DateBookDB {
49 public:
50 Event eventByUID(int id);
51};
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 41
73class DateBook : public QMainWindow 42class DateBook : public QMainWindow
74{ 43{
@@ -137,7 +106,7 @@ private:
137 void saveSettings(); 106 void saveSettings();
138 107
139private: 108private:
140 DateBookDBHack *db; 109 DateBookDBHoliday *db;
141 DateBookHoliday*db_holiday; 110 DateBookHoliday*db_holiday;
142 QWidgetStack *views; 111 QWidgetStack *views;
143 DateBookDay *dayView; 112 DateBookDay *dayView;
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index dfe39e5..00ddd05 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -19,6 +19,7 @@
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "datebookday.h" 21#include "datebookday.h"
22#include "datebooktypes.h"
22#include "datebookdayheaderimpl.h" 23#include "datebookdayheaderimpl.h"
23#include "datebookdayallday.h" 24#include "datebookdayallday.h"
24 25
@@ -227,7 +228,7 @@ void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */)
227 228
228//=========================================================================== 229//===========================================================================
229 230
230DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, DateBookHoliday*newHdb, QWidget *parent, const char *name ) 231DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb, DateBookHoliday*newHdb, QWidget *parent, const char *name )
231 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) 232 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 )
232{ 233{
233 widgetList.setAutoDelete( true ); 234 widgetList.setAutoDelete( true );
@@ -367,7 +368,7 @@ void DateBookDay::getEvents()
367 if (!object) continue; 368 if (!object) continue;
368 /* not to do something with it */ 369 /* not to do something with it */
369 } 370 }
370 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); 371 QValueList<EffectiveEvent> eventList = db->getEffectiveEventsNoHoliday( currDate, currDate );
371 QValueListIterator<EffectiveEvent> it; 372 QValueListIterator<EffectiveEvent> it;
372 373
373 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 374 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h
index 3e44364..3b75eba 100644
--- a/core/pim/datebook/datebookday.h
+++ b/core/pim/datebook/datebookday.h
@@ -28,10 +28,12 @@
28#include <qlist.h> 28#include <qlist.h>
29 29
30#include "datebook.h" 30#include "datebook.h"
31#include "datebooktypes.h"
31#include <qlineedit.h> 32#include <qlineedit.h>
32 33
33class DateBookDayHeader; 34class DateBookDayHeader;
34class DateBookDB; 35class DateBookDB;
36class DateBookDBHoliday;
35class DatebookdayAllday; 37class DatebookdayAllday;
36class QDateTime; 38class QDateTime;
37class QMouseEvent; 39class QMouseEvent;
@@ -180,7 +182,7 @@ class DateBookDay : public QVBox
180 182
181 friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB 183 friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB
182public: 184public:
183 DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,DateBookHoliday*newHdb, 185 DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb,DateBookHoliday*newHdb,
184 QWidget *parent, const char *name ); 186 QWidget *parent, const char *name );
185 void selectedDates( QDateTime &start, QDateTime &end ); 187 void selectedDates( QDateTime &start, QDateTime &end );
186 188
@@ -225,7 +227,7 @@ private:
225 DateBookDayView *view; 227 DateBookDayView *view;
226 DateBookDayHeader *header; 228 DateBookDayHeader *header;
227 DatebookdayAllday *m_allDays; 229 DatebookdayAllday *m_allDays;
228 DateBookDB *db; 230 DateBookDBHoliday *db;
229 WidgetListClass widgetList; //reimplemented QList for sorting widgets by height 231 WidgetListClass widgetList; //reimplemented QList for sorting widgets by height
230 int startTime; 232 int startTime;
231 bool jumpToCurTime; //should we jump to current time in dayview? 233 bool jumpToCurTime; //should we jump to current time in dayview?
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp
index 3c3f482..5b40246 100644
--- a/core/pim/datebook/datebookdayallday.cpp
+++ b/core/pim/datebook/datebookdayallday.cpp
@@ -30,7 +30,8 @@ DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const cha
30 m_MainFrame = new QFrame(viewport()); 30 m_MainFrame = new QFrame(viewport());
31 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); 31 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain);
32 setFrameStyle(QFrame::NoFrame|QFrame::Plain); 32 setFrameStyle(QFrame::NoFrame|QFrame::Plain);
33 setResizePolicy( QScrollView::Default ); 33 //setResizePolicy( QScrollView::Default );
34 setResizePolicy(QScrollView::AutoOneFit);
34 setHScrollBarMode( AlwaysOff ); 35 setHScrollBarMode( AlwaysOff );
35 addChild(m_MainFrame); 36 addChild(m_MainFrame);
36 37
@@ -111,13 +112,18 @@ DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,co
111 ev.setDescription(strDesc); 112 ev.setDescription(strDesc);
112 ev.setAllDay(true); 113 ev.setAllDay(true);
113 m_Ev.setEvent(ev); 114 m_Ev.setEvent(ev);
114 setBackgroundColor(yellow);
115 setText(strDesc); 115 setText(strDesc);
116 setFrameStyle(QFrame::Raised|QFrame::Panel); 116
117 setAlignment(AlignHCenter);
118 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum));
119
120 //setFrameStyle(QFrame::Raised|QFrame::Panel);
121 //setBackgroundColor(yellow);
117 122
118 int s = QFontMetrics(font()).height()+4; 123 int s = QFontMetrics(font()).height()+4;
119 setMaximumHeight( s ); 124 setMaximumHeight( s );
120 setMinimumSize( QSize( 0, s ) ); 125 setMinimumSize( QSize( 0, s ) );
126
121 m_holiday = true; 127 m_holiday = true;
122} 128}
123 129
diff --git a/core/pim/datebook/datebooktypes.h b/core/pim/datebook/datebooktypes.h
new file mode 100644
index 0000000..9eb7e89
--- a/dev/null
+++ b/core/pim/datebook/datebooktypes.h
@@ -0,0 +1,59 @@
1#ifndef _DATEBOOK_TYPES_H
2#define _DATEBOOK_TYPES_H
3
4#include <qpe/datebookdb.h>
5
6#include <qvaluelist.h>
7#include <qstringlist.h>
8
9namespace Opie {
10namespace Datebook {
11 class HolidayPlugin;
12 class HolidayPluginIf;
13}
14}
15
16class QLibrary;
17
18class DateBookDBHack : virtual public DateBookDB {
19 public:
20 virtual ~DateBookDBHack(){}
21 Event eventByUID(int id);
22};
23
24class DateBookHoliday
25{
26public:
27 DateBookHoliday();
28 virtual ~DateBookHoliday();
29
30 QStringList holidaylist(const QDate&);
31 QStringList holidaylist(unsigned year, unsigned month, unsigned day);
32 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
33 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
34
35protected:
36 void init();
37 void deinit();
38
39 struct HPlugin {
40 Opie::Datebook::HolidayPlugin*_plugin;
41 QLibrary*_lib;
42 Opie::Datebook::HolidayPluginIf*_if;
43 };
44 QValueList<HPlugin*>_pluginlist;
45};
46
47class DateBookDBHoliday:virtual public DateBookDBHack {
48public:
49 DateBookDBHoliday():DateBookDBHack(){db_holiday=0;}
50 virtual ~DateBookDBHoliday(){}
51 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
52 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
53 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to );
54 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start);
55
56 DateBookHoliday*db_holiday;
57};
58
59#endif
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index 7503751..a509d89 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -19,6 +19,7 @@
19**********************************************************************/ 19**********************************************************************/
20#include "datebookweek.h" 20#include "datebookweek.h"
21#include "datebookweekheaderimpl.h" 21#include "datebookweekheaderimpl.h"
22#include "datebooktypes.h"
22 23
23#include <qpe/datebookdb.h> 24#include <qpe/datebookdb.h>
24#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
@@ -340,7 +341,7 @@ void DateBookWeekView::setStartOfWeek( bool bStartOnMonday )
340 341
341//------------------------------------------------------------------- 342//-------------------------------------------------------------------
342 343
343DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, 344DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDBHoliday *newDB,
344 QWidget *parent, const char *name ) 345 QWidget *parent, const char *name )
345 : QWidget( parent, name ), 346 : QWidget( parent, name ),
346 db( newDB ), 347 db( newDB ),
diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h
index c273e30..ddf54ed 100644
--- a/core/pim/datebook/datebookweek.h
+++ b/core/pim/datebook/datebookweek.h
@@ -28,6 +28,7 @@
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29 29
30class DateBookDB; 30class DateBookDB;
31class DateBookDBHoliday;
31class DateBookWeekHeader; 32class DateBookWeekHeader;
32class QDate; 33class QDate;
33class QLabel; 34class QLabel;
@@ -100,7 +101,7 @@ class DateBookWeek : public QWidget
100 Q_OBJECT 101 Q_OBJECT
101 102
102public: 103public:
103 DateBookWeek( bool ampm, bool weekOnMonday, DateBookDB *newDB, 104 DateBookWeek( bool ampm, bool weekOnMonday, DateBookDBHoliday *newDB,
104 QWidget *parent = 0, const char *name = 0 ); 105 QWidget *parent = 0, const char *name = 0 );
105 void setDate( int y, int m, int d ); 106 void setDate( int y, int m, int d );
106 void setDate( QDate d ); 107 void setDate( QDate d );
@@ -153,7 +154,7 @@ private:
153 QDate bdate; 154 QDate bdate;
154 DateBookWeekHeader *header; 155 DateBookWeekHeader *header;
155 DateBookWeekView *view; 156 DateBookWeekView *view;
156 DateBookDB *db; 157 DateBookDBHoliday *db;
157 QLabel *lblDesc; 158 QLabel *lblDesc;
158 QTimer *tHide; 159 QTimer *tHide;
159 int startTime; 160 int startTime;
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 771aa00..0555bc7 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -2,6 +2,7 @@
2#include "datebookweeklst.h" 2#include "datebookweeklst.h"
3 3
4#include "datebook.h" 4#include "datebook.h"
5#include "datebooktypes.h"
5 6
6#include <opie2/odebug.h> 7#include <opie2/odebug.h>
7 8
@@ -317,7 +318,7 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
317 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 318 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
318} 319}
319 320
320DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 321DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB,
321 QWidget *parent, 322 QWidget *parent,
322 const char *name ) 323 const char *name )
323 : QWidget( parent, name ), 324 : QWidget( parent, name ),
@@ -383,13 +384,13 @@ QDate DateBookWeekLst::weekDate() const
383 384
384void DateBookWeekLst::getEvents() { 385void DateBookWeekLst::getEvents() {
385 QDate start = weekDate(); //date(); 386 QDate start = weekDate(); //date();
386 QDate stop = start.addDays(6); 387 QDate stop = start.addDays(7);
387 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 388 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
388 389
389 if (view) delete view; 390 if (view) delete view;
390 if (dbl) { 391 if (dbl) {
391 QDate start2=start.addDays(7); 392 QDate start2=start.addDays(8);
392 stop=start2.addDays(6); 393 stop=start2.addDays(7);
393 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 394 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
394 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 395 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
395 } else { 396 } else {
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
index 3bc7f2f..38d7777 100644
--- a/core/pim/datebook/datebookweeklst.h
+++ b/core/pim/datebook/datebookweeklst.h
@@ -14,6 +14,7 @@
14 14
15class QDateTime; 15class QDateTime;
16class DateBookDB; 16class DateBookDB;
17class DateBookDBHoliday;
17 18
18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase 19class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
19{ 20{
@@ -130,7 +131,7 @@ class DateBookWeekLst : public QWidget
130 Q_OBJECT 131 Q_OBJECT
131 132
132public: 133public:
133 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, 134 DateBookWeekLst( bool ampm, bool onM, DateBookDBHoliday *newDB,
134 QWidget *parent = 0, 135 QWidget *parent = 0,
135 const char *name = 0 ); 136 const char *name = 0 );
136 ~DateBookWeekLst(); 137 ~DateBookWeekLst();
@@ -158,7 +159,7 @@ signals:
158 void beamEvent(const Event &e); 159 void beamEvent(const Event &e);
159 160
160private: 161private:
161 DateBookDB *db; 162 DateBookDBHoliday *db;
162 int startTime; 163 int startTime;
163 bool ampm; 164 bool ampm;
164 bool bStartOnMonday; 165 bool bStartOnMonday;