author | alwin <alwin> | 2005-03-19 13:44:30 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-19 13:44:30 (UTC) |
commit | 34e42590a8ef21c1377f89c7b82f25bcf0aec3cb (patch) (unidiff) | |
tree | f5afdae31945ca2bac7339a339499fa87ece50d9 | |
parent | d9e8b9e797e3162ab564bb3b0f04663ef1167541 (diff) | |
download | opie-34e42590a8ef21c1377f89c7b82f25bcf0aec3cb.zip opie-34e42590a8ef21c1377f89c7b82f25bcf0aec3cb.tar.gz opie-34e42590a8ef21c1377f89c7b82f25bcf0aec3cb.tar.bz2 |
so....
I looked for a problem. could not found due the kind of code structure.
so I had reorganized the code into a more sensefull structure so every one
should be able to find some code sequences when searching for a bug.
yes - now I found the problem and can thinking about resolving it.
21 files changed, 736 insertions, 629 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 70dd7b5..0579279 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -25,9 +25,9 @@ | |||
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 "modules/weeklst/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> | 33 | #include <opie2/oholidaypluginif.h> |
@@ -43,8 +43,9 @@ | |||
43 | #include <qpe/qpemessagebox.h> | 43 | #include <qpe/qpemessagebox.h> |
44 | #include <qpe/resource.h> | 44 | #include <qpe/resource.h> |
45 | #include <qpe/sound.h> | 45 | #include <qpe/sound.h> |
46 | #include <qpe/tzselect.h> | 46 | #include <qpe/tzselect.h> |
47 | #include <qtopia/qlibrary.h> | ||
47 | 48 | ||
48 | #include <qaction.h> | 49 | #include <qaction.h> |
49 | #include <qcopchannel_qws.h> | 50 | #include <qcopchannel_qws.h> |
50 | #include <qlayout.h> | 51 | #include <qlayout.h> |
@@ -53,9 +54,9 @@ | |||
53 | #include <qtl.h> | 54 | #include <qtl.h> |
54 | #include <qtoolbar.h> | 55 | #include <qtoolbar.h> |
55 | #include <qwidgetstack.h> | 56 | #include <qwidgetstack.h> |
56 | #include <qdir.h> | 57 | #include <qdir.h> |
57 | #include <qtopia/qlibrary.h> | 58 | #include <qlabel.h> |
58 | 59 | ||
59 | #include <sys/stat.h> | 60 | #include <sys/stat.h> |
60 | #include <sys/types.h> | 61 | #include <sys/types.h> |
61 | #include <fcntl.h> | 62 | #include <fcntl.h> |
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index 3d7f5b5..fb8b083 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h | |||
@@ -25,11 +25,8 @@ | |||
25 | #include <qpe/datebookdb.h> | 25 | #include <qpe/datebookdb.h> |
26 | 26 | ||
27 | #include <qmainwindow.h> | 27 | #include <qmainwindow.h> |
28 | 28 | ||
29 | enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values | ||
30 | enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes. | ||
31 | |||
32 | class QAction; | 29 | class QAction; |
33 | class QWidgetStack; | 30 | class QWidgetStack; |
34 | class DateBookDay; | 31 | class DateBookDay; |
35 | class DateBookWeek; | 32 | class DateBookWeek; |
diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro index 046bcdf..26f4d8d 100644 --- a/core/pim/datebook/datebook.pro +++ b/core/pim/datebook/datebook.pro | |||
@@ -4,9 +4,14 @@ HEADERS = datebookday.h \ | |||
4 | dateentryimpl.h \ | 4 | dateentryimpl.h \ |
5 | datebookdayheaderimpl.h \ | 5 | datebookdayheaderimpl.h \ |
6 | datebooksettings.h \ | 6 | datebooksettings.h \ |
7 | datebookweek.h \ | 7 | datebookweek.h \ |
8 | datebookweeklst.h \ | 8 | modules/weeklst/datebookweeklst.h \ |
9 | modules/weeklst/datebookweeklstdayhdr.h \ | ||
10 | modules/weeklst/datebookweeklstheader.h \ | ||
11 | modules/weeklst/datebookweeklstevent.h \ | ||
12 | modules/weeklst/datebookweeklstview.h \ | ||
13 | modules/weeklst/datebookweeklstdblview.h \ | ||
9 | datebookweekheaderimpl.h \ | 14 | datebookweekheaderimpl.h \ |
10 | repeatentry.h \ | 15 | repeatentry.h \ |
11 | noteentryimpl.h \ | 16 | noteentryimpl.h \ |
12 | onoteedit.h \ | 17 | onoteedit.h \ |
@@ -19,19 +24,24 @@ SOURCES = main.cpp \ | |||
19 | dateentryimpl.cpp \ | 24 | dateentryimpl.cpp \ |
20 | datebookdayheaderimpl.cpp \ | 25 | datebookdayheaderimpl.cpp \ |
21 | datebooksettings.cpp \ | 26 | datebooksettings.cpp \ |
22 | datebookweek.cpp \ | 27 | datebookweek.cpp \ |
23 | datebookweeklst.cpp \ | 28 | modules/weeklst/datebookweeklst.cpp \ |
29 | modules/weeklst/datebookweeklstdayhdr.cpp \ | ||
30 | modules/weeklst/datebookweeklstheader.cpp \ | ||
31 | modules/weeklst/datebookweeklstevent.cpp \ | ||
32 | modules/weeklst/datebookweeklstview.cpp \ | ||
33 | modules/weeklst/datebookweeklstdblview.cpp \ | ||
24 | datebookweekheaderimpl.cpp \ | 34 | datebookweekheaderimpl.cpp \ |
25 | repeatentry.cpp \ | 35 | repeatentry.cpp \ |
26 | noteentryimpl.cpp \ | 36 | noteentryimpl.cpp \ |
27 | onoteedit.cpp \ | 37 | onoteedit.cpp \ |
28 | datebookdayallday.cpp | 38 | datebookdayallday.cpp |
29 | INTERFACES= dateentry.ui \ | 39 | INTERFACES= dateentry.ui \ |
30 | datebookdayheader.ui \ | 40 | datebookdayheader.ui \ |
31 | datebookweekheader.ui \ | 41 | datebookweekheader.ui \ |
32 | datebookweeklstheader.ui \ | 42 | modules/weeklst/datebookweeklstheaderbase.ui \ |
33 | datebookweeklstdayhdr.ui \ | 43 | modules/weeklst/datebookweeklstdayhdrbase.ui \ |
34 | repeatentrybase.ui \ | 44 | repeatentrybase.ui \ |
35 | datebooksettingsbase.ui \ | 45 | datebooksettingsbase.ui \ |
36 | noteentry.ui | 46 | noteentry.ui |
37 | INCLUDEPATH += $(OPIEDIR)/include | 47 | INCLUDEPATH += $(OPIEDIR)/include |
diff --git a/core/pim/datebook/datebooktypes.h b/core/pim/datebook/datebooktypes.h index 2966814..9453be8 100644 --- a/core/pim/datebook/datebooktypes.h +++ b/core/pim/datebook/datebooktypes.h | |||
@@ -18,8 +18,11 @@ namespace Core { | |||
18 | } | 18 | } |
19 | 19 | ||
20 | class QLibrary; | 20 | class QLibrary; |
21 | 21 | ||
22 | enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values | ||
23 | enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes. | ||
24 | |||
22 | class DateBookDBHack : virtual public DateBookDB { | 25 | class DateBookDBHack : virtual public DateBookDB { |
23 | public: | 26 | public: |
24 | virtual ~DateBookDBHack(){} | 27 | virtual ~DateBookDBHack(){} |
25 | Event eventByUID(int id); | 28 | Event eventByUID(int id); |
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp deleted file mode 100644 index 3c871ea..0000000 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/dev/null | |||
@@ -1,442 +0,0 @@ | |||
1 | #include "namespace_hack.h" | ||
2 | #include "datebookweeklst.h" | ||
3 | |||
4 | #include "datebook.h" | ||
5 | #include "datebooktypes.h" | ||
6 | |||
7 | #include <opie2/odebug.h> | ||
8 | |||
9 | #include <qpe/datebookmonth.h> | ||
10 | #include <qpe/config.h> | ||
11 | #include <qpe/ir.h> | ||
12 | #include <qpe/resource.h> | ||
13 | |||
14 | #include <qlayout.h> | ||
15 | #include <qtoolbutton.h> | ||
16 | #include <qtl.h> | ||
17 | |||
18 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); | ||
19 | |||
20 | using namespace Opie::Ui; | ||
21 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) | ||
22 | : DateBookWeekLstHeaderBase(parent, name, fl) | ||
23 | { | ||
24 | setBackgroundMode( PaletteButton ); | ||
25 | labelDate->setBackgroundMode( PaletteButton ); | ||
26 | forwardweek->setBackgroundMode( PaletteButton ); | ||
27 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); | ||
28 | forwardmonth->setBackgroundMode( PaletteButton ); | ||
29 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); | ||
30 | backweek->setBackgroundMode( PaletteButton ); | ||
31 | backweek->setPixmap( Resource::loadPixmap("back") ); | ||
32 | backmonth->setBackgroundMode( PaletteButton ); | ||
33 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); | ||
34 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); | ||
35 | DateBookWeekLstHeaderBaseLayout->setMargin(0); | ||
36 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); | ||
37 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | ||
38 | |||
39 | connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); | ||
40 | connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); | ||
41 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); | ||
42 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); | ||
43 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); | ||
44 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); | ||
45 | bStartOnMonday=onM; | ||
46 | } | ||
47 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | ||
48 | |||
49 | void DateBookWeekLstHeader::setDate(const QDate &d) { | ||
50 | int year,week,dayofweek; | ||
51 | date=d; | ||
52 | dayofweek=d.dayOfWeek(); | ||
53 | if(bStartOnMonday) | ||
54 | dayofweek--; | ||
55 | else if( dayofweek == 7 ) | ||
56 | /* we already have the right day -7 would lead to the same week */ | ||
57 | dayofweek = 0; | ||
58 | |||
59 | date=date.addDays(-dayofweek); | ||
60 | |||
61 | calcWeek(date,week,year,bStartOnMonday); | ||
62 | QDate start=date; | ||
63 | QDate stop=start.addDays(6); | ||
64 | labelDate->setText( QString::number(start.day()) + "." + | ||
65 | Calendar::nameOfMonth( start.month() ) + "-" + | ||
66 | QString::number(stop.day()) + "." + | ||
67 | Calendar::nameOfMonth( stop.month()) +" ("+ | ||
68 | tr("w")+":"+QString::number( week ) +")"); | ||
69 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! | ||
70 | emit dateChanged(date); | ||
71 | } | ||
72 | |||
73 | void DateBookWeekLstHeader::pickDate() { | ||
74 | static QPopupMenu *m1 = 0; | ||
75 | static DateBookMonth *picker = 0; | ||
76 | if ( !m1 ) { | ||
77 | m1 = new QPopupMenu( this ); | ||
78 | picker = new DateBookMonth( m1, 0, TRUE ); | ||
79 | m1->insertItem( picker ); | ||
80 | connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); | ||
81 | //connect( m1, SIGNAL( aboutToHide() ), | ||
82 | //this, SLOT( gotHide() ) ); | ||
83 | } | ||
84 | picker->setDate( date.year(), date.month(), date.day() ); | ||
85 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); | ||
86 | picker->setFocus(); | ||
87 | } | ||
88 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { | ||
89 | setDate(QDate(y,m,d)); | ||
90 | } | ||
91 | |||
92 | void DateBookWeekLstHeader::nextWeek() { | ||
93 | setDate(date.addDays(7)); | ||
94 | } | ||
95 | void DateBookWeekLstHeader::prevWeek() { | ||
96 | setDate(date.addDays(-7)); | ||
97 | } | ||
98 | void DateBookWeekLstHeader::nextMonth() | ||
99 | { | ||
100 | setDate(date.addDays(28)); | ||
101 | } | ||
102 | void DateBookWeekLstHeader::prevMonth() | ||
103 | { | ||
104 | setDate(date.addDays(-28)); | ||
105 | } | ||
106 | |||
107 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, | ||
108 | QWidget* parent, | ||
109 | const char* name, | ||
110 | WFlags fl ) | ||
111 | : DateBookWeekLstDayHdrBase(parent, name, fl) { | ||
112 | |||
113 | date=d; | ||
114 | |||
115 | static const QString wdays=tr("MTWTFSSM", "Week days"); | ||
116 | char day=wdays[d.dayOfWeek()-1]; | ||
117 | |||
118 | //dont use dayOfWeek() to save space ! | ||
119 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); | ||
120 | |||
121 | add->setText("+"); | ||
122 | |||
123 | if (d == QDate::currentDate()) { | ||
124 | QPalette pal=label->palette(); | ||
125 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); | ||
126 | label->setPalette(pal); | ||
127 | |||
128 | /* | ||
129 | QFont f=label->font(); | ||
130 | f.setItalic(true); | ||
131 | label->setFont(f); | ||
132 | label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); | ||
133 | */ | ||
134 | } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday | ||
135 | QPalette pal=label->palette(); | ||
136 | pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); | ||
137 | label->setPalette(pal); | ||
138 | } | ||
139 | |||
140 | connect (label, SIGNAL(clicked()), this, SLOT(showDay())); | ||
141 | connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); | ||
142 | } | ||
143 | |||
144 | void DateBookWeekLstDayHdr::showDay() { | ||
145 | emit showDate(date.year(), date.month(), date.day()); | ||
146 | } | ||
147 | |||
148 | void DateBookWeekLstDayHdr::newEvent() { | ||
149 | QDateTime start, stop; | ||
150 | start=stop=date; | ||
151 | start.setTime(QTime(10,0)); | ||
152 | stop.setTime(QTime(12,0)); | ||
153 | |||
154 | emit addEvent(start,stop,"",0); | ||
155 | } | ||
156 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | ||
157 | int weeklistviewconfig, | ||
158 | QWidget* parent, | ||
159 | const char* name, | ||
160 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) | ||
161 | { | ||
162 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", | ||
163 | QString s,start,middle,end,day; | ||
164 | |||
165 | odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; | ||
166 | if(weeklistviewconfig==NONE) { // No times displayed. | ||
167 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | ||
168 | // middle.sprintf("<--->"); | ||
169 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | ||
170 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | ||
171 | } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. | ||
172 | start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | ||
173 | middle.sprintf(" |---"); | ||
174 | end.sprintf("__|__"); | ||
175 | day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | ||
176 | } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. | ||
177 | start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | ||
178 | middle.sprintf("<--->"); | ||
179 | end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | ||
180 | day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | ||
181 | } | ||
182 | |||
183 | if(ev.event().type() == Event::Normal) { | ||
184 | if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. | ||
185 | s=day; | ||
186 | } else if(ev.startDate()==ev.date()) { // start event. | ||
187 | s=start; | ||
188 | } else if(ev.endDate()==ev.date()) { // end event. | ||
189 | s=end; | ||
190 | } else { // middle day. | ||
191 | s=middle; | ||
192 | } | ||
193 | } else { | ||
194 | s=""; | ||
195 | } | ||
196 | setText(QString(s) + " " + ev.description()); | ||
197 | // connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | ||
198 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | ||
199 | } | ||
200 | void DateBookWeekLstEvent::editMe() { | ||
201 | emit editEvent(event.event()); | ||
202 | } | ||
203 | void DateBookWeekLstEvent::duplicateMe() | ||
204 | { | ||
205 | emit duplicateEvent(event.event()); | ||
206 | } | ||
207 | void DateBookWeekLstEvent::deleteMe() | ||
208 | { | ||
209 | emit removeEvent(event.event()); | ||
210 | emit redraw(); | ||
211 | } | ||
212 | void DateBookWeekLstEvent::beamMe() | ||
213 | { | ||
214 | emit beamEvent( event.event() ); | ||
215 | } | ||
216 | void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) | ||
217 | { | ||
218 | if (!event.event().isValidUid()) { | ||
219 | // this is just such a holiday event. | ||
220 | return; | ||
221 | } | ||
222 | popmenue = new QPopupMenu; | ||
223 | |||
224 | popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); | ||
225 | popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); | ||
226 | popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); | ||
227 | if(Ir::supported()) | ||
228 | popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); | ||
229 | popmenue->popup( mapToGlobal( e->pos() )); | ||
230 | } | ||
231 | |||
232 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | ||
233 | const QDate &d, bool onM, | ||
234 | QWidget* parent, | ||
235 | const char* name, WFlags fl) | ||
236 | : QWidget( parent, name, fl ) | ||
237 | { | ||
238 | Config config("DateBook"); | ||
239 | config.setGroup("Main"); | ||
240 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); | ||
241 | odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; | ||
242 | |||
243 | bStartOnMonday=onM; | ||
244 | setPalette(white); | ||
245 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | ||
246 | |||
247 | QVBoxLayout *layout = new QVBoxLayout( this ); | ||
248 | |||
249 | qBubbleSort(ev); | ||
250 | QValueListIterator<EffectiveEvent> it; | ||
251 | it=ev.begin(); | ||
252 | |||
253 | int dayOrder[7]; | ||
254 | if (bStartOnMonday) { | ||
255 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | ||
256 | } else { | ||
257 | for (int d=0; d<7; d++) dayOrder[d]=d; | ||
258 | dayOrder[0]=7; | ||
259 | } | ||
260 | |||
261 | // Calculate offset to first day of week. | ||
262 | int dayoffset=d.dayOfWeek(); | ||
263 | if(bStartOnMonday) dayoffset--; | ||
264 | else if( dayoffset == 7 ) dayoffset = 0; | ||
265 | |||
266 | for (int i=0; i<7; i++) { | ||
267 | // Header | ||
268 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); | ||
269 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
270 | connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
271 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | ||
272 | layout->addWidget(hdr); | ||
273 | |||
274 | // Events | ||
275 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | ||
276 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. | ||
277 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); | ||
278 | layout->addWidget(l); | ||
279 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | ||
280 | connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
281 | connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
282 | connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
283 | connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
284 | } | ||
285 | it++; | ||
286 | } | ||
287 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | ||
288 | } | ||
289 | } | ||
290 | DateBookWeekLstView::~DateBookWeekLstView(){} | ||
291 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | ||
292 | |||
293 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | ||
294 | QValueList<EffectiveEvent> &ev2, | ||
295 | QDate &d, bool onM, | ||
296 | QWidget* parent, | ||
297 | const char* name, WFlags fl) | ||
298 | : QWidget( parent, name, fl ) | ||
299 | { | ||
300 | QHBoxLayout *layout = new QHBoxLayout( this ); | ||
301 | |||
302 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); | ||
303 | layout->addWidget(w); | ||
304 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | ||
305 | connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
306 | connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
307 | connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
308 | connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
309 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
310 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
311 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | ||
312 | |||
313 | |||
314 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | ||
315 | layout->addWidget(w); | ||
316 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | ||
317 | connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
318 | connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
319 | connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
320 | connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
321 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
322 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
323 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | ||
324 | } | ||
325 | |||
326 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, | ||
327 | QWidget *parent, | ||
328 | const char *name ) | ||
329 | : QWidget( parent, name ), | ||
330 | db( newDB ), | ||
331 | startTime( 0 ), | ||
332 | ampm( ap ), | ||
333 | bStartOnMonday(onM) | ||
334 | { | ||
335 | setFocusPolicy(StrongFocus); | ||
336 | layout = new QVBoxLayout( this ); | ||
337 | layout->setMargin(0); | ||
338 | |||
339 | header=new DateBookWeekLstHeader(onM, this); | ||
340 | layout->addWidget( header ); | ||
341 | connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); | ||
342 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); | ||
343 | |||
344 | scroll=new QScrollView(this); | ||
345 | scroll->setResizePolicy(QScrollView::AutoOneFit); | ||
346 | layout->addWidget(scroll); | ||
347 | |||
348 | view=NULL; | ||
349 | Config config("DateBook"); | ||
350 | config.setGroup("Main"); | ||
351 | dbl=config.readBoolEntry("weeklst_dbl", false); | ||
352 | header->dbl->setOn(dbl); | ||
353 | } | ||
354 | DateBookWeekLst::~DateBookWeekLst(){ | ||
355 | Config config("DateBook"); | ||
356 | config.setGroup("Main"); | ||
357 | config.writeEntry("weeklst_dbl", dbl); | ||
358 | } | ||
359 | |||
360 | void DateBookWeekLst::setDate(const QDate &d) { | ||
361 | bdate=d; | ||
362 | header->setDate(d); | ||
363 | } | ||
364 | |||
365 | void DateBookWeekLst::setDbl(bool on) { | ||
366 | dbl=on; | ||
367 | redraw(); | ||
368 | } | ||
369 | void DateBookWeekLst::redraw() {getEvents();} | ||
370 | |||
371 | QDate DateBookWeekLst::date() { | ||
372 | return bdate; | ||
373 | } | ||
374 | |||
375 | // return the date at the beginning of the week... | ||
376 | // copied from DateBookWeek | ||
377 | QDate DateBookWeekLst::weekDate() const | ||
378 | { | ||
379 | QDate d=bdate; | ||
380 | |||
381 | // Calculate offset to first day of week. | ||
382 | int dayoffset=d.dayOfWeek(); | ||
383 | if(bStartOnMonday) dayoffset--; | ||
384 | else if( dayoffset == 7 ) | ||
385 | dayoffset = 0; | ||
386 | |||
387 | return d.addDays(-dayoffset); | ||
388 | } | ||
389 | |||
390 | void DateBookWeekLst::getEvents() { | ||
391 | QDate start = weekDate(); //date(); | ||
392 | QDate stop = start.addDays(6); | ||
393 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | ||
394 | |||
395 | if (view) delete view; | ||
396 | if (dbl) { | ||
397 | QDate start2=start.addDays(7); | ||
398 | stop=start2.addDays(6); | ||
399 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | ||
400 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); | ||
401 | } else { | ||
402 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); | ||
403 | } | ||
404 | |||
405 | connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | ||
406 | connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
407 | connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
408 | connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
409 | connect (view, SIGNAL(redraw()), this, SLOT(redraw())); | ||
410 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
411 | connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
412 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | ||
413 | |||
414 | scroll->addChild(view); | ||
415 | view->show(); | ||
416 | scroll->updateScrollBars(); | ||
417 | } | ||
418 | |||
419 | void DateBookWeekLst::dateChanged(QDate &newdate) { | ||
420 | bdate=newdate; | ||
421 | getEvents(); | ||
422 | } | ||
423 | |||
424 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | ||
425 | { | ||
426 | switch(e->key()) { | ||
427 | case Key_Up: | ||
428 | scroll->scrollBy(0, -20); | ||
429 | break; | ||
430 | case Key_Down: | ||
431 | scroll->scrollBy(0, 20); | ||
432 | break; | ||
433 | case Key_Left: | ||
434 | header->prevWeek(); | ||
435 | break; | ||
436 | case Key_Right: | ||
437 | header->nextWeek(); | ||
438 | break; | ||
439 | default: | ||
440 | e->ignore(); | ||
441 | } | ||
442 | } | ||
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h deleted file mode 100644 index 38d7777..0000000 --- a/core/pim/datebook/datebookweeklst.h +++ b/dev/null | |||
@@ -1,178 +0,0 @@ | |||
1 | #ifndef DATEBOOKWEEKLST | ||
2 | #define DATEBOOKWEEKLST | ||
3 | |||
4 | #include <qwidget.h> | ||
5 | #include <qdatetime.h> | ||
6 | #include <qpe/event.h> | ||
7 | #include <qlabel.h> | ||
8 | #include <qscrollview.h> | ||
9 | |||
10 | #include "datebookweeklstheader.h" | ||
11 | #include "datebookweeklstdayhdr.h" | ||
12 | |||
13 | #include <opie2/oclickablelabel.h> | ||
14 | |||
15 | class QDateTime; | ||
16 | class DateBookDB; | ||
17 | class DateBookDBHoliday; | ||
18 | |||
19 | class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase | ||
20 | { | ||
21 | Q_OBJECT | ||
22 | public: | ||
23 | DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, | ||
24 | WFlags fl = 0 ); | ||
25 | ~DateBookWeekLstHeader(); | ||
26 | void setDate(const QDate &d); | ||
27 | |||
28 | public slots: | ||
29 | void nextWeek(); | ||
30 | void prevWeek(); | ||
31 | void nextMonth(); | ||
32 | void prevMonth(); | ||
33 | void pickDate(); | ||
34 | void setDate(int y, int m, int d); | ||
35 | signals: | ||
36 | void dateChanged(QDate &newdate); | ||
37 | void setDbl(bool on); | ||
38 | private: | ||
39 | QDate date; | ||
40 | // bool onMonday; | ||
41 | bool bStartOnMonday; | ||
42 | }; | ||
43 | |||
44 | class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase | ||
45 | { | ||
46 | Q_OBJECT | ||
47 | public: | ||
48 | DateBookWeekLstDayHdr(const QDate &d, bool onM, | ||
49 | QWidget* parent = 0, const char* name = 0, | ||
50 | WFlags fl = 0 ); | ||
51 | public slots: | ||
52 | void showDay(); | ||
53 | void newEvent(); | ||
54 | signals: | ||
55 | void showDate(int y, int m, int d); | ||
56 | void addEvent(const QDateTime &start, const QDateTime &stop, | ||
57 | const QString &str, const QString &location); | ||
58 | private: | ||
59 | QDate date; | ||
60 | }; | ||
61 | |||
62 | class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel | ||
63 | { | ||
64 | Q_OBJECT | ||
65 | public: | ||
66 | DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, | ||
67 | QWidget* parent = 0, const char* name = 0, | ||
68 | WFlags fl = 0); | ||
69 | signals: | ||
70 | void editEvent(const Event &e); | ||
71 | void duplicateEvent(const Event &e); | ||
72 | void removeEvent(const Event &e); | ||
73 | void beamEvent(const Event &e); | ||
74 | void redraw(); | ||
75 | private slots: | ||
76 | void editMe(); | ||
77 | void duplicateMe(); | ||
78 | void deleteMe(); | ||
79 | void beamMe(); | ||
80 | private: | ||
81 | const EffectiveEvent event; | ||
82 | QPopupMenu* popmenue; | ||
83 | protected: | ||
84 | void mousePressEvent( QMouseEvent *e ); | ||
85 | }; | ||
86 | |||
87 | class DateBookWeekLstView: public QWidget | ||
88 | { | ||
89 | Q_OBJECT | ||
90 | public: | ||
91 | DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, | ||
92 | QWidget* parent = 0, const char* name = 0, | ||
93 | WFlags fl = 0 ); | ||
94 | ~DateBookWeekLstView(); | ||
95 | signals: | ||
96 | void editEvent(const Event &e); | ||
97 | void duplicateEvent(const Event &e); | ||
98 | void removeEvent(const Event &e); | ||
99 | void beamEvent(const Event &e); | ||
100 | void redraw(); | ||
101 | void showDate(int y, int m, int d); | ||
102 | void addEvent(const QDateTime &start, const QDateTime &stop, | ||
103 | const QString &str, const QString &location); | ||
104 | private: | ||
105 | bool bStartOnMonday; | ||
106 | protected slots: | ||
107 | void keyPressEvent(QKeyEvent *); | ||
108 | }; | ||
109 | |||
110 | class DateBookWeekLstDblView: public QWidget { | ||
111 | Q_OBJECT | ||
112 | public: | ||
113 | DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | ||
114 | QValueList<EffectiveEvent> &ev2, | ||
115 | QDate &d, bool onM, | ||
116 | QWidget* parent = 0, const char* name = 0, | ||
117 | WFlags fl = 0 ); | ||
118 | signals: | ||
119 | void editEvent(const Event &e); | ||
120 | void duplicateEvent(const Event &e); | ||
121 | void removeEvent(const Event &e); | ||
122 | void beamEvent(const Event &e); | ||
123 | void redraw(); | ||
124 | void showDate(int y, int m, int d); | ||
125 | void addEvent(const QDateTime &start, const QDateTime &stop, | ||
126 | const QString &str, const QString &location); | ||
127 | }; | ||
128 | |||
129 | class DateBookWeekLst : public QWidget | ||
130 | { | ||
131 | Q_OBJECT | ||
132 | |||
133 | public: | ||
134 | DateBookWeekLst( bool ampm, bool onM, DateBookDBHoliday *newDB, | ||
135 | QWidget *parent = 0, | ||
136 | const char *name = 0 ); | ||
137 | ~DateBookWeekLst(); | ||
138 | void setDate( int y, int w ); | ||
139 | void setDate(const QDate &d ); | ||
140 | int week() const { return _week; }; | ||
141 | QDate date(); | ||
142 | QDate weekDate() const; | ||
143 | |||
144 | public slots: | ||
145 | void redraw(); | ||
146 | void dateChanged(QDate &date); | ||
147 | |||
148 | protected slots: | ||
149 | void keyPressEvent(QKeyEvent *); | ||
150 | void setDbl(bool on); | ||
151 | |||
152 | signals: | ||
153 | void showDate(int y, int m, int d); | ||
154 | void addEvent(const QDateTime &start, const QDateTime &stop, | ||
155 | const QString &str, const QString &location); | ||
156 | void editEvent(const Event &e); | ||
157 | void duplicateEvent(const Event &e); | ||
158 | void removeEvent(const Event &e); | ||
159 | void beamEvent(const Event &e); | ||
160 | |||
161 | private: | ||
162 | DateBookDBHoliday *db; | ||
163 | int startTime; | ||
164 | bool ampm; | ||
165 | bool bStartOnMonday; | ||
166 | bool dbl; | ||
167 | QDate bdate; | ||
168 | int year, _week,dow; | ||
169 | DateBookWeekLstHeader *header; | ||
170 | QWidget *view; | ||
171 | QVBoxLayout *layout; | ||
172 | QScrollView *scroll; | ||
173 | |||
174 | void getEvents(); | ||
175 | }; | ||
176 | |||
177 | #endif | ||
178 | |||
diff --git a/core/pim/datebook/modules/weeklst/.cvsignore b/core/pim/datebook/modules/weeklst/.cvsignore new file mode 100644 index 0000000..2da0b2b --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/.cvsignore | |||
@@ -0,0 +1,4 @@ | |||
1 | datebookweeklstdayhdrbase.cpp | ||
2 | datebookweeklstdayhdrbase.h | ||
3 | datebookweeklstheaderbase.cpp | ||
4 | datebookweeklstheaderbase.h | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp new file mode 100644 index 0000000..47bc597 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp | |||
@@ -0,0 +1,138 @@ | |||
1 | #include "namespace_hack.h" | ||
2 | #include "datebookweeklst.h" | ||
3 | #include "datebookweeklstheader.h" | ||
4 | #include "datebookweeklstview.h" | ||
5 | #include "datebookweeklstdblview.h" | ||
6 | |||
7 | #include "datebook.h" | ||
8 | |||
9 | #include <opie2/odebug.h> | ||
10 | |||
11 | #include <qpe/datebookmonth.h> | ||
12 | #include <qpe/config.h> | ||
13 | #include <qpe/resource.h> | ||
14 | |||
15 | #include <qlayout.h> | ||
16 | #include <qtoolbutton.h> | ||
17 | |||
18 | using namespace Opie::Ui; | ||
19 | |||
20 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, | ||
21 | QWidget *parent, | ||
22 | const char *name ) | ||
23 | : QWidget( parent, name ), | ||
24 | db( newDB ), | ||
25 | startTime( 0 ), | ||
26 | ampm( ap ), | ||
27 | bStartOnMonday(onM) | ||
28 | { | ||
29 | setFocusPolicy(StrongFocus); | ||
30 | layout = new QVBoxLayout( this ); | ||
31 | layout->setMargin(0); | ||
32 | |||
33 | header=new DateBookWeekLstHeader(onM, this); | ||
34 | layout->addWidget( header ); | ||
35 | connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); | ||
36 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); | ||
37 | |||
38 | scroll=new QScrollView(this); | ||
39 | scroll->setResizePolicy(QScrollView::AutoOneFit); | ||
40 | layout->addWidget(scroll); | ||
41 | |||
42 | view=NULL; | ||
43 | Config config("DateBook"); | ||
44 | config.setGroup("Main"); | ||
45 | dbl=config.readBoolEntry("weeklst_dbl", false); | ||
46 | header->dbl->setOn(dbl); | ||
47 | } | ||
48 | DateBookWeekLst::~DateBookWeekLst(){ | ||
49 | Config config("DateBook"); | ||
50 | config.setGroup("Main"); | ||
51 | config.writeEntry("weeklst_dbl", dbl); | ||
52 | } | ||
53 | |||
54 | void DateBookWeekLst::setDate(const QDate &d) { | ||
55 | bdate=d; | ||
56 | header->setDate(d); | ||
57 | } | ||
58 | |||
59 | void DateBookWeekLst::setDbl(bool on) { | ||
60 | dbl=on; | ||
61 | redraw(); | ||
62 | } | ||
63 | void DateBookWeekLst::redraw() {getEvents();} | ||
64 | |||
65 | QDate DateBookWeekLst::date() { | ||
66 | return bdate; | ||
67 | } | ||
68 | |||
69 | // return the date at the beginning of the week... | ||
70 | // copied from DateBookWeek | ||
71 | QDate DateBookWeekLst::weekDate() const | ||
72 | { | ||
73 | QDate d=bdate; | ||
74 | |||
75 | // Calculate offset to first day of week. | ||
76 | int dayoffset=d.dayOfWeek(); | ||
77 | if(bStartOnMonday) dayoffset--; | ||
78 | else if( dayoffset == 7 ) | ||
79 | dayoffset = 0; | ||
80 | |||
81 | return d.addDays(-dayoffset); | ||
82 | } | ||
83 | |||
84 | void DateBookWeekLst::getEvents() { | ||
85 | QDate start = weekDate(); //date(); | ||
86 | QDate stop = start.addDays(6); | ||
87 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | ||
88 | |||
89 | setUpdatesEnabled(false); | ||
90 | if (view) delete view; | ||
91 | if (dbl) { | ||
92 | QDate start2=start.addDays(7); | ||
93 | stop=start2.addDays(6); | ||
94 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | ||
95 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); | ||
96 | } else { | ||
97 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); | ||
98 | } | ||
99 | |||
100 | connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | ||
101 | connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
102 | connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
103 | connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
104 | connect (view, SIGNAL(redraw()), this, SLOT(redraw())); | ||
105 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
106 | connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
107 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | ||
108 | |||
109 | scroll->addChild(view); | ||
110 | view->show(); | ||
111 | scroll->updateScrollBars(); | ||
112 | setUpdatesEnabled(true); | ||
113 | } | ||
114 | |||
115 | void DateBookWeekLst::dateChanged(QDate &newdate) { | ||
116 | bdate=newdate; | ||
117 | getEvents(); | ||
118 | } | ||
119 | |||
120 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | ||
121 | { | ||
122 | switch(e->key()) { | ||
123 | case Key_Up: | ||
124 | scroll->scrollBy(0, -20); | ||
125 | break; | ||
126 | case Key_Down: | ||
127 | scroll->scrollBy(0, 20); | ||
128 | break; | ||
129 | case Key_Left: | ||
130 | header->prevWeek(); | ||
131 | break; | ||
132 | case Key_Right: | ||
133 | header->nextWeek(); | ||
134 | break; | ||
135 | default: | ||
136 | e->ignore(); | ||
137 | } | ||
138 | } | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.h b/core/pim/datebook/modules/weeklst/datebookweeklst.h new file mode 100644 index 0000000..3922fa1 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklst.h | |||
@@ -0,0 +1,65 @@ | |||
1 | #ifndef DATEBOOKWEEKLST | ||
2 | #define DATEBOOKWEEKLST | ||
3 | |||
4 | #include <qpe/event.h> | ||
5 | |||
6 | #include <qwidget.h> | ||
7 | #include <qdatetime.h> | ||
8 | |||
9 | class DateBookDB; | ||
10 | class DateBookDBHoliday; | ||
11 | class DateBookWeekLstHeader; | ||
12 | class DateBookWeekLstEvent; | ||
13 | class DateBookWeekLstView; | ||
14 | class QVBoxLayout; | ||
15 | class QScrollView; | ||
16 | |||
17 | class DateBookWeekLst : public QWidget | ||
18 | { | ||
19 | Q_OBJECT | ||
20 | |||
21 | public: | ||
22 | DateBookWeekLst( bool ampm, bool onM, DateBookDBHoliday *newDB, | ||
23 | QWidget *parent = 0, | ||
24 | const char *name = 0 ); | ||
25 | ~DateBookWeekLst(); | ||
26 | void setDate( int y, int w ); | ||
27 | void setDate(const QDate &d ); | ||
28 | int week() const { return _week; }; | ||
29 | QDate date(); | ||
30 | QDate weekDate() const; | ||
31 | |||
32 | public slots: | ||
33 | void redraw(); | ||
34 | void dateChanged(QDate &date); | ||
35 | |||
36 | protected slots: | ||
37 | void keyPressEvent(QKeyEvent *); | ||
38 | void setDbl(bool on); | ||
39 | |||
40 | signals: | ||
41 | void showDate(int y, int m, int d); | ||
42 | void addEvent(const QDateTime &start, const QDateTime &stop, | ||
43 | const QString &str, const QString &location); | ||
44 | void editEvent(const Event &e); | ||
45 | void duplicateEvent(const Event &e); | ||
46 | void removeEvent(const Event &e); | ||
47 | void beamEvent(const Event &e); | ||
48 | |||
49 | private: | ||
50 | DateBookDBHoliday *db; | ||
51 | int startTime; | ||
52 | bool ampm; | ||
53 | bool bStartOnMonday; | ||
54 | bool dbl; | ||
55 | QDate bdate; | ||
56 | int year, _week,dow; | ||
57 | DateBookWeekLstHeader *header; | ||
58 | QWidget *view; | ||
59 | QVBoxLayout *layout; | ||
60 | QScrollView *scroll; | ||
61 | |||
62 | void getEvents(); | ||
63 | }; | ||
64 | |||
65 | #endif | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.cpp new file mode 100644 index 0000000..d173444 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.cpp | |||
@@ -0,0 +1,53 @@ | |||
1 | #include "datebookweeklstdayhdr.h" | ||
2 | |||
3 | #include "namespace_hack.h" | ||
4 | |||
5 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, | ||
6 | QWidget* parent, | ||
7 | const char* name, | ||
8 | WFlags fl ) | ||
9 | : DateBookWeekLstDayHdrBase(parent, name, fl) { | ||
10 | |||
11 | date=d; | ||
12 | |||
13 | static const QString wdays=tr("MTWTFSSM", "Week days"); | ||
14 | char day=wdays[d.dayOfWeek()-1]; | ||
15 | |||
16 | //dont use dayOfWeek() to save space ! | ||
17 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); | ||
18 | |||
19 | add->setText("+"); | ||
20 | |||
21 | if (d == QDate::currentDate()) { | ||
22 | QPalette pal=label->palette(); | ||
23 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); | ||
24 | label->setPalette(pal); | ||
25 | |||
26 | /* | ||
27 | QFont f=label->font(); | ||
28 | f.setItalic(true); | ||
29 | label->setFont(f); | ||
30 | label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); | ||
31 | */ | ||
32 | } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday | ||
33 | QPalette pal=label->palette(); | ||
34 | pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); | ||
35 | label->setPalette(pal); | ||
36 | } | ||
37 | |||
38 | connect (label, SIGNAL(clicked()), this, SLOT(showDay())); | ||
39 | connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); | ||
40 | } | ||
41 | |||
42 | void DateBookWeekLstDayHdr::showDay() { | ||
43 | emit showDate(date.year(), date.month(), date.day()); | ||
44 | } | ||
45 | |||
46 | void DateBookWeekLstDayHdr::newEvent() { | ||
47 | QDateTime start, stop; | ||
48 | start=stop=date; | ||
49 | start.setTime(QTime(10,0)); | ||
50 | stop.setTime(QTime(12,0)); | ||
51 | |||
52 | emit addEvent(start,stop,"",0); | ||
53 | } | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.h b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.h new file mode 100644 index 0000000..de046d8 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.h | |||
@@ -0,0 +1,26 @@ | |||
1 | #ifndef _DATEBOOKWEEKLSTDAYHDR_H | ||
2 | #define _DATEBOOKWEEKLSTDAYHDR_H | ||
3 | |||
4 | #include "datebookweeklstdayhdrbase.h" | ||
5 | |||
6 | #include <qdatetime.h> | ||
7 | |||
8 | class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase | ||
9 | { | ||
10 | Q_OBJECT | ||
11 | public: | ||
12 | DateBookWeekLstDayHdr(const QDate &d, bool onM, | ||
13 | QWidget* parent = 0, const char* name = 0, | ||
14 | WFlags fl = 0 ); | ||
15 | public slots: | ||
16 | void showDay(); | ||
17 | void newEvent(); | ||
18 | signals: | ||
19 | void showDate(int y, int m, int d); | ||
20 | void addEvent(const QDateTime &start, const QDateTime &stop, | ||
21 | const QString &str, const QString &location); | ||
22 | private: | ||
23 | QDate date; | ||
24 | }; | ||
25 | |||
26 | #endif | ||
diff --git a/core/pim/datebook/datebookweeklstdayhdr.ui b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdrbase.ui index 74ea584..74ea584 100644 --- a/core/pim/datebook/datebookweeklstdayhdr.ui +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdrbase.ui | |||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp new file mode 100644 index 0000000..1cea602 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp | |||
@@ -0,0 +1,41 @@ | |||
1 | #include "datebookweeklstdblview.h" | ||
2 | #include "datebookweeklstview.h" | ||
3 | |||
4 | #include <qlayout.h> | ||
5 | |||
6 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | ||
7 | QValueList<EffectiveEvent> &ev2, | ||
8 | QDate &d, bool onM, | ||
9 | QWidget* parent, | ||
10 | const char* name, WFlags fl) | ||
11 | : QWidget( parent, name, fl ) | ||
12 | { | ||
13 | QHBoxLayout *layout = new QHBoxLayout( this ); | ||
14 | |||
15 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); | ||
16 | layout->addWidget(w); | ||
17 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | ||
18 | connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
19 | connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
20 | connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
21 | connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
22 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
23 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
24 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | ||
25 | |||
26 | |||
27 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | ||
28 | layout->addWidget(w); | ||
29 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | ||
30 | connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
31 | connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
32 | connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
33 | connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
34 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
35 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
36 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | ||
37 | } | ||
38 | |||
39 | DateBookWeekLstDblView::~DateBookWeekLstDblView() | ||
40 | { | ||
41 | } | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h new file mode 100644 index 0000000..57e9690 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef _DATEBOOKWEEKLSTDBLVIEW_H | ||
2 | #define _DATEBOOKWEEKLSTDBLVIEW_H | ||
3 | |||
4 | #include <qpe/event.h> | ||
5 | |||
6 | #include <qwidget.h> | ||
7 | #include <qvaluelist.h> | ||
8 | #include <qdatetime.h> | ||
9 | #include <qstring.h> | ||
10 | |||
11 | class DateBookWeekLstDblView: public QWidget { | ||
12 | Q_OBJECT | ||
13 | public: | ||
14 | DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | ||
15 | QValueList<EffectiveEvent> &ev2, | ||
16 | QDate &d, bool onM, | ||
17 | QWidget* parent = 0, const char* name = 0, | ||
18 | WFlags fl = 0 ); | ||
19 | virtual ~DateBookWeekLstDblView(); | ||
20 | signals: | ||
21 | void editEvent(const Event &e); | ||
22 | void duplicateEvent(const Event &e); | ||
23 | void removeEvent(const Event &e); | ||
24 | void beamEvent(const Event &e); | ||
25 | void redraw(); | ||
26 | void showDate(int y, int m, int d); | ||
27 | void addEvent(const QDateTime &start, const QDateTime &stop, | ||
28 | const QString &str, const QString &location); | ||
29 | }; | ||
30 | |||
31 | #endif | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp new file mode 100644 index 0000000..797f766 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp | |||
@@ -0,0 +1,85 @@ | |||
1 | #include "datebookweeklstevent.h" | ||
2 | #include "datebooktypes.h" | ||
3 | |||
4 | #include <opie2/odebug.h> | ||
5 | |||
6 | #include <qpe/ir.h> | ||
7 | |||
8 | #include <qstring.h> | ||
9 | #include <qpopupmenu.h> | ||
10 | |||
11 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | ||
12 | int weeklistviewconfig, | ||
13 | QWidget* parent, | ||
14 | const char* name, | ||
15 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) | ||
16 | { | ||
17 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", | ||
18 | QString s,start,middle,end,day; | ||
19 | |||
20 | odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; | ||
21 | if(weeklistviewconfig==NONE) { // No times displayed. | ||
22 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | ||
23 | // middle.sprintf("<--->"); | ||
24 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | ||
25 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | ||
26 | } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. | ||
27 | start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | ||
28 | middle.sprintf(" |---"); | ||
29 | end.sprintf("__|__"); | ||
30 | day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | ||
31 | } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. | ||
32 | start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | ||
33 | middle.sprintf("<--->"); | ||
34 | end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | ||
35 | day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | ||
36 | } | ||
37 | |||
38 | if(ev.event().type() == Event::Normal) { | ||
39 | if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. | ||
40 | s=day; | ||
41 | } else if(ev.startDate()==ev.date()) { // start event. | ||
42 | s=start; | ||
43 | } else if(ev.endDate()==ev.date()) { // end event. | ||
44 | s=end; | ||
45 | } else { // middle day. | ||
46 | s=middle; | ||
47 | } | ||
48 | } else { | ||
49 | s=""; | ||
50 | } | ||
51 | setText(QString(s) + " " + ev.description()); | ||
52 | // connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | ||
53 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | ||
54 | } | ||
55 | void DateBookWeekLstEvent::editMe() { | ||
56 | emit editEvent(event.event()); | ||
57 | } | ||
58 | void DateBookWeekLstEvent::duplicateMe() | ||
59 | { | ||
60 | emit duplicateEvent(event.event()); | ||
61 | } | ||
62 | void DateBookWeekLstEvent::deleteMe() | ||
63 | { | ||
64 | emit removeEvent(event.event()); | ||
65 | emit redraw(); | ||
66 | } | ||
67 | void DateBookWeekLstEvent::beamMe() | ||
68 | { | ||
69 | emit beamEvent( event.event() ); | ||
70 | } | ||
71 | void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) | ||
72 | { | ||
73 | if (!event.event().isValidUid()) { | ||
74 | // this is just such a holiday event. | ||
75 | return; | ||
76 | } | ||
77 | popmenue = new QPopupMenu; | ||
78 | |||
79 | popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); | ||
80 | popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); | ||
81 | popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); | ||
82 | if(Ir::supported()) | ||
83 | popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); | ||
84 | popmenue->popup( mapToGlobal( e->pos() )); | ||
85 | } | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstevent.h b/core/pim/datebook/modules/weeklst/datebookweeklstevent.h new file mode 100644 index 0000000..77f6283 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstevent.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef _DATEBOOKWEEKLSTEVENT_H | ||
2 | #define _DATEBOOKWEEKLSTEVENT_H | ||
3 | |||
4 | #include <opie2/oclickablelabel.h> | ||
5 | |||
6 | #include <qpe/event.h> | ||
7 | |||
8 | class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel | ||
9 | { | ||
10 | Q_OBJECT | ||
11 | public: | ||
12 | DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, | ||
13 | QWidget* parent = 0, const char* name = 0, | ||
14 | WFlags fl = 0); | ||
15 | signals: | ||
16 | void editEvent(const Event &e); | ||
17 | void duplicateEvent(const Event &e); | ||
18 | void removeEvent(const Event &e); | ||
19 | void beamEvent(const Event &e); | ||
20 | void redraw(); | ||
21 | private slots: | ||
22 | void editMe(); | ||
23 | void duplicateMe(); | ||
24 | void deleteMe(); | ||
25 | void beamMe(); | ||
26 | private: | ||
27 | const EffectiveEvent event; | ||
28 | QPopupMenu* popmenue; | ||
29 | protected: | ||
30 | void mousePressEvent( QMouseEvent *e ); | ||
31 | }; | ||
32 | |||
33 | |||
34 | #endif | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp new file mode 100644 index 0000000..81e0c31 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp | |||
@@ -0,0 +1,96 @@ | |||
1 | #include "datebookweeklstheader.h" | ||
2 | |||
3 | #include <qpe/resource.h> | ||
4 | #include <qpe/datebookmonth.h> | ||
5 | |||
6 | #include <qtoolbutton.h> | ||
7 | #include <qlayout.h> | ||
8 | |||
9 | /* implenented in datebookweek.cpp - HELL */ | ||
10 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); | ||
11 | |||
12 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) | ||
13 | : DateBookWeekLstHeaderBase(parent, name, fl) | ||
14 | { | ||
15 | setBackgroundMode( PaletteButton ); | ||
16 | labelDate->setBackgroundMode( PaletteButton ); | ||
17 | forwardweek->setBackgroundMode( PaletteButton ); | ||
18 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); | ||
19 | forwardmonth->setBackgroundMode( PaletteButton ); | ||
20 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); | ||
21 | backweek->setBackgroundMode( PaletteButton ); | ||
22 | backweek->setPixmap( Resource::loadPixmap("back") ); | ||
23 | backmonth->setBackgroundMode( PaletteButton ); | ||
24 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); | ||
25 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); | ||
26 | DateBookWeekLstHeaderBaseLayout->setMargin(0); | ||
27 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); | ||
28 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | ||
29 | |||
30 | connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); | ||
31 | connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); | ||
32 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); | ||
33 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); | ||
34 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); | ||
35 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); | ||
36 | bStartOnMonday=onM; | ||
37 | } | ||
38 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | ||
39 | |||
40 | void DateBookWeekLstHeader::setDate(const QDate &d) { | ||
41 | int year,week,dayofweek; | ||
42 | date=d; | ||
43 | dayofweek=d.dayOfWeek(); | ||
44 | if(bStartOnMonday) | ||
45 | dayofweek--; | ||
46 | else if( dayofweek == 7 ) | ||
47 | /* we already have the right day -7 would lead to the same week */ | ||
48 | dayofweek = 0; | ||
49 | |||
50 | date=date.addDays(-dayofweek); | ||
51 | |||
52 | calcWeek(date,week,year,bStartOnMonday); | ||
53 | QDate start=date; | ||
54 | QDate stop=start.addDays(6); | ||
55 | labelDate->setText( QString::number(start.day()) + "." + | ||
56 | Calendar::nameOfMonth( start.month() ) + "-" + | ||
57 | QString::number(stop.day()) + "." + | ||
58 | Calendar::nameOfMonth( stop.month()) +" ("+ | ||
59 | tr("w")+":"+QString::number( week ) +")"); | ||
60 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! | ||
61 | emit dateChanged(date); | ||
62 | } | ||
63 | |||
64 | void DateBookWeekLstHeader::pickDate() { | ||
65 | static QPopupMenu *m1 = 0; | ||
66 | static DateBookMonth *picker = 0; | ||
67 | if ( !m1 ) { | ||
68 | m1 = new QPopupMenu( this ); | ||
69 | picker = new DateBookMonth( m1, 0, TRUE ); | ||
70 | m1->insertItem( picker ); | ||
71 | connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); | ||
72 | //connect( m1, SIGNAL( aboutToHide() ), | ||
73 | //this, SLOT( gotHide() ) ); | ||
74 | } | ||
75 | picker->setDate( date.year(), date.month(), date.day() ); | ||
76 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); | ||
77 | picker->setFocus(); | ||
78 | } | ||
79 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { | ||
80 | setDate(QDate(y,m,d)); | ||
81 | } | ||
82 | |||
83 | void DateBookWeekLstHeader::nextWeek() { | ||
84 | setDate(date.addDays(7)); | ||
85 | } | ||
86 | void DateBookWeekLstHeader::prevWeek() { | ||
87 | setDate(date.addDays(-7)); | ||
88 | } | ||
89 | void DateBookWeekLstHeader::nextMonth() | ||
90 | { | ||
91 | setDate(date.addDays(28)); | ||
92 | } | ||
93 | void DateBookWeekLstHeader::prevMonth() | ||
94 | { | ||
95 | setDate(date.addDays(-28)); | ||
96 | } | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstheader.h b/core/pim/datebook/modules/weeklst/datebookweeklstheader.h new file mode 100644 index 0000000..818b825 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstheader.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef _DATEBOOKWEEKLSTHEADER_H | ||
2 | #define _DATEBOOKWEEKLSTHEADER_H | ||
3 | |||
4 | #include "datebookweeklstheaderbase.h" | ||
5 | |||
6 | #include <qdatetime.h> | ||
7 | |||
8 | class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase | ||
9 | { | ||
10 | Q_OBJECT | ||
11 | public: | ||
12 | DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, | ||
13 | WFlags fl = 0 ); | ||
14 | ~DateBookWeekLstHeader(); | ||
15 | void setDate(const QDate &d); | ||
16 | |||
17 | public slots: | ||
18 | void nextWeek(); | ||
19 | void prevWeek(); | ||
20 | void nextMonth(); | ||
21 | void prevMonth(); | ||
22 | void pickDate(); | ||
23 | void setDate(int y, int m, int d); | ||
24 | signals: | ||
25 | void dateChanged(QDate &newdate); | ||
26 | void setDbl(bool on); | ||
27 | protected: | ||
28 | QDate date; | ||
29 | // bool onMonday; | ||
30 | bool bStartOnMonday; | ||
31 | |||
32 | }; | ||
33 | |||
34 | #endif | ||
diff --git a/core/pim/datebook/datebookweeklstheader.ui b/core/pim/datebook/modules/weeklst/datebookweeklstheaderbase.ui index e925ec3..e925ec3 100644 --- a/core/pim/datebook/datebookweeklstheader.ui +++ b/core/pim/datebook/modules/weeklst/datebookweeklstheaderbase.ui | |||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp new file mode 100644 index 0000000..efb4c01 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp | |||
@@ -0,0 +1,73 @@ | |||
1 | #include "datebookweeklstview.h" | ||
2 | #include "datebooktypes.h" | ||
3 | #include "datebookweeklstdayhdr.h" | ||
4 | #include "datebookweeklstheader.h" | ||
5 | #include "datebookweeklstevent.h" | ||
6 | |||
7 | #include <opie2/odebug.h> | ||
8 | |||
9 | #include <qpe/config.h> | ||
10 | |||
11 | #include <qlayout.h> | ||
12 | #include <qtl.h> | ||
13 | |||
14 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | ||
15 | const QDate &d, bool onM, | ||
16 | QWidget* parent, | ||
17 | const char* name, WFlags fl) | ||
18 | : QWidget( parent, name, fl ) | ||
19 | { | ||
20 | Config config("DateBook"); | ||
21 | config.setGroup("Main"); | ||
22 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); | ||
23 | odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; | ||
24 | |||
25 | bStartOnMonday=onM; | ||
26 | setPalette(white); | ||
27 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | ||
28 | |||
29 | QVBoxLayout *layout = new QVBoxLayout( this ); | ||
30 | |||
31 | qBubbleSort(ev); | ||
32 | QValueListIterator<EffectiveEvent> it; | ||
33 | it=ev.begin(); | ||
34 | |||
35 | int dayOrder[7]; | ||
36 | if (bStartOnMonday) { | ||
37 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | ||
38 | } else { | ||
39 | for (int d=0; d<7; d++) dayOrder[d]=d; | ||
40 | dayOrder[0]=7; | ||
41 | } | ||
42 | |||
43 | // Calculate offset to first day of week. | ||
44 | int dayoffset=d.dayOfWeek(); | ||
45 | if(bStartOnMonday) dayoffset--; | ||
46 | else if( dayoffset == 7 ) dayoffset = 0; | ||
47 | |||
48 | for (int i=0; i<7; i++) { | ||
49 | // Header | ||
50 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); | ||
51 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
52 | connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
53 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | ||
54 | layout->addWidget(hdr); | ||
55 | |||
56 | // Events | ||
57 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | ||
58 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. | ||
59 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); | ||
60 | layout->addWidget(l); | ||
61 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | ||
62 | connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
63 | connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
64 | connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
65 | connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
66 | } | ||
67 | it++; | ||
68 | } | ||
69 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | ||
70 | } | ||
71 | } | ||
72 | DateBookWeekLstView::~DateBookWeekLstView(){} | ||
73 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.h b/core/pim/datebook/modules/weeklst/datebookweeklstview.h new file mode 100644 index 0000000..2428f1f --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef _DATEBOOKWEEKLISTVIEW_H | ||
2 | #define _DATEBOOKWEEKLISTVIEW_H | ||
3 | |||
4 | #include <qpe/event.h> | ||
5 | |||
6 | #include <qwidget.h> | ||
7 | #include <qvaluelist.h> | ||
8 | #include <qstring.h> | ||
9 | #include <qdatetime.h> | ||
10 | |||
11 | class QKeyEvent; | ||
12 | |||
13 | class DateBookWeekLstView: public QWidget | ||
14 | { | ||
15 | Q_OBJECT | ||
16 | public: | ||
17 | DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, | ||
18 | QWidget* parent = 0, const char* name = 0, | ||
19 | WFlags fl = 0 ); | ||
20 | ~DateBookWeekLstView(); | ||
21 | signals: | ||
22 | void editEvent(const Event &e); | ||
23 | void duplicateEvent(const Event &e); | ||
24 | void removeEvent(const Event &e); | ||
25 | void beamEvent(const Event &e); | ||
26 | void redraw(); | ||
27 | void showDate(int y, int m, int d); | ||
28 | void addEvent(const QDateTime &start, const QDateTime &stop, | ||
29 | const QString &str, const QString &location); | ||
30 | private: | ||
31 | bool bStartOnMonday; | ||
32 | protected slots: | ||
33 | void keyPressEvent(QKeyEvent *); | ||
34 | }; | ||
35 | |||
36 | #endif | ||