summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp3
-rw-r--r--core/pim/datebook/datebookweeklst.cpp43
-rw-r--r--core/pim/datebook/datebookweeklst.h35
3 files changed, 72 insertions, 9 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 0a47bb8..a18a5b4 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -534,64 +534,67 @@ void DateBook::initWeek()
534 weekView->setStartViewTime( startTime ); 534 weekView->setStartViewTime( startTime );
535 views->addWidget( weekView, WEEK ); 535 views->addWidget( weekView, WEEK );
536 connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 536 connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
537 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); 537 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
538 } 538 }
539 539
540 //But also get it right: the year that we display can be different 540 //But also get it right: the year that we display can be different
541 //from the year of the current date. So, first find the year 541 //from the year of the current date. So, first find the year
542 //number of the current week. 542 //number of the current week.
543 int yearNumber, totWeeks; 543 int yearNumber, totWeeks;
544 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 544 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
545 545
546 QDate d = QDate( yearNumber, 12, 31 ); 546 QDate d = QDate( yearNumber, 12, 31 );
547 calcWeek( d, totWeeks, yearNumber, onMonday ); 547 calcWeek( d, totWeeks, yearNumber, onMonday );
548 548
549 while ( totWeeks == 1 ) { 549 while ( totWeeks == 1 ) {
550 d = d.addDays( -1 ); 550 d = d.addDays( -1 );
551 calcWeek( d, totWeeks, yearNumber, onMonday ); 551 calcWeek( d, totWeeks, yearNumber, onMonday );
552 } 552 }
553} 553}
554 554
555void DateBook::initWeekLst() { 555void DateBook::initWeekLst() {
556 if ( !weekLstView ) { 556 if ( !weekLstView ) {
557 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); 557 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" );
558 views->addWidget( weekLstView, WEEKLST ); 558 views->addWidget( weekLstView, WEEKLST );
559 559
560 //weekLstView->setStartViewTime( startTime ); 560 //weekLstView->setStartViewTime( startTime );
561 connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 561 connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
562 connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), 562 connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ),
563 this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); 563 this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) );
564 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); 564 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) );
565 connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); 565 connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
566 connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) );
567 connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) );
568 connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) );
566 } 569 }
567} 570}
568 571
569 572
570void DateBook::initMonth() 573void DateBook::initMonth()
571{ 574{
572 if ( !monthView ) { 575 if ( !monthView ) {
573 monthView = new DateBookMonth( views, "month view", FALSE, db ); 576 monthView = new DateBookMonth( views, "month view", FALSE, db );
574 views->addWidget( monthView, MONTH ); 577 views->addWidget( monthView, MONTH );
575 connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 578 connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
576 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); 579 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) );
577 qApp->processEvents(); 580 qApp->processEvents();
578 } 581 }
579} 582}
580 583
581void DateBook::loadSettings() 584void DateBook::loadSettings()
582{ 585{
583 Config qpeconfig( "qpe" ); 586 Config qpeconfig( "qpe" );
584 qpeconfig.setGroup("Time"); 587 qpeconfig.setGroup("Time");
585 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); 588 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
586 onMonday = qpeconfig.readBoolEntry( "MONDAY" ); 589 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
587 590
588 Config config("DateBook"); 591 Config config("DateBook");
589 config.setGroup("Main"); 592 config.setGroup("Main");
590 startTime = config.readNumEntry("startviewtime", 8); 593 startTime = config.readNumEntry("startviewtime", 8);
591 aPreset = config.readBoolEntry("alarmpreset"); 594 aPreset = config.readBoolEntry("alarmpreset");
592 presetTime = config.readNumEntry("presettime"); 595 presetTime = config.readNumEntry("presettime");
593 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 596 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
594 rowStyle = config.readNumEntry("rowstyle"); 597 rowStyle = config.readNumEntry("rowstyle");
595 defaultView = config.readNumEntry("defaultview",DAY); 598 defaultView = config.readNumEntry("defaultview",DAY);
596 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 599 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
597 600
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index fe2ab51..771aa00 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,41 +1,42 @@
1#include "namespace_hack.h" 1#include "namespace_hack.h"
2#include "datebookweeklst.h" 2#include "datebookweeklst.h"
3 3
4#include "datebook.h" 4#include "datebook.h"
5 5
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7 7
8#include <qpe/datebookmonth.h> 8#include <qpe/datebookmonth.h>
9#include <qpe/config.h> 9#include <qpe/config.h>
10#include <qpe/ir.h>
10#include <qpe/resource.h> 11#include <qpe/resource.h>
11 12
12#include <qlayout.h> 13#include <qlayout.h>
13#include <qtoolbutton.h> 14#include <qtoolbutton.h>
14#include <qtl.h> 15#include <qtl.h>
15 16
16bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); 17bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
17 18
18using namespace Opie::Ui; 19using namespace Opie::Ui;
19DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) 20DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
20 : DateBookWeekLstHeaderBase(parent, name, fl) 21 : DateBookWeekLstHeaderBase(parent, name, fl)
21{ 22{
22 setBackgroundMode( PaletteButton ); 23 setBackgroundMode( PaletteButton );
23 labelDate->setBackgroundMode( PaletteButton ); 24 labelDate->setBackgroundMode( PaletteButton );
24 forwardweek->setBackgroundMode( PaletteButton ); 25 forwardweek->setBackgroundMode( PaletteButton );
25 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 26 forwardweek->setPixmap( Resource::loadPixmap("forward") );
26 forwardmonth->setBackgroundMode( PaletteButton ); 27 forwardmonth->setBackgroundMode( PaletteButton );
27 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 28 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
28 backweek->setBackgroundMode( PaletteButton ); 29 backweek->setBackgroundMode( PaletteButton );
29 backweek->setPixmap( Resource::loadPixmap("back") ); 30 backweek->setPixmap( Resource::loadPixmap("back") );
30 backmonth->setBackgroundMode( PaletteButton ); 31 backmonth->setBackgroundMode( PaletteButton );
31 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 32 backmonth->setPixmap( Resource::loadPixmap("fastback") );
32 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 33 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
33 DateBookWeekLstHeaderBaseLayout->setMargin(0); 34 DateBookWeekLstHeaderBaseLayout->setMargin(0);
34 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 35 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
35 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 36 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
36 37
37 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); 38 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
38 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); 39 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
39 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); 40 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
40 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); 41 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
41 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); 42 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
@@ -163,149 +164,183 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
163 odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; 164 odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl;
164 if(weeklistviewconfig==NONE) {// No times displayed. 165 if(weeklistviewconfig==NONE) {// No times displayed.
165 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 166 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
166 // middle.sprintf("<--->"); 167 // middle.sprintf("<--->");
167 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 168 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
168 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 169 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
169 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. 170 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time.
170 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 171 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
171 middle.sprintf(" |---"); 172 middle.sprintf(" |---");
172 end.sprintf("__|__"); 173 end.sprintf("__|__");
173 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 174 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
174 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. 175 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
175 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 176 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
176 middle.sprintf("<--->"); 177 middle.sprintf("<--->");
177 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 178 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
178 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 179 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
179 } 180 }
180 181
181 if(ev.event().type() == Event::Normal) { 182 if(ev.event().type() == Event::Normal) {
182 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. 183 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event.
183 s=day; 184 s=day;
184 } else if(ev.startDate()==ev.date()) {// start event. 185 } else if(ev.startDate()==ev.date()) {// start event.
185 s=start; 186 s=start;
186 } else if(ev.endDate()==ev.date()) { // end event. 187 } else if(ev.endDate()==ev.date()) { // end event.
187 s=end; 188 s=end;
188 } else {// middle day. 189 } else {// middle day.
189 s=middle; 190 s=middle;
190 } 191 }
191 } else { 192 } else {
192 s=""; 193 s="";
193 } 194 }
194 setText(QString(s) + " " + ev.description()); 195 setText(QString(s) + " " + ev.description());
195 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 196 //connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
196 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 197 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
197} 198}
198void DateBookWeekLstEvent::editMe() { 199void DateBookWeekLstEvent::editMe() {
199 emit editEvent(event.event()); 200 emit editEvent(event.event());
200} 201}
201 202void DateBookWeekLstEvent::duplicateMe()
203{
204 emit duplicateEvent(event.event());
205}
206void DateBookWeekLstEvent::deleteMe()
207{
208 emit removeEvent(event.event());
209 emit redraw();
210}
211void DateBookWeekLstEvent::beamMe()
212{
213 emit beamEvent( event.event() );
214}
215void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e )
216{
217 popmenue = new QPopupMenu;
218 popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe()));
219 popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe()));
220 popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe()));
221 if(Ir::supported())
222 popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe()));
223 popmenue->popup( mapToGlobal( e->pos() ));
224}
202 225
203DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 226DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
204 const QDate &d, bool onM, 227 const QDate &d, bool onM,
205 QWidget* parent, 228 QWidget* parent,
206 const char* name, WFlags fl) 229 const char* name, WFlags fl)
207 : QWidget( parent, name, fl ) 230 : QWidget( parent, name, fl )
208{ 231{
209 Config config("DateBook"); 232 Config config("DateBook");
210 config.setGroup("Main"); 233 config.setGroup("Main");
211 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); 234 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
212 odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; 235 odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl;
213 236
214 bStartOnMonday=onM; 237 bStartOnMonday=onM;
215 setPalette(white); 238 setPalette(white);
216 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 239 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
217 240
218 QVBoxLayout *layout = new QVBoxLayout( this ); 241 QVBoxLayout *layout = new QVBoxLayout( this );
219 242
220 qBubbleSort(ev); 243 qBubbleSort(ev);
221 QValueListIterator<EffectiveEvent> it; 244 QValueListIterator<EffectiveEvent> it;
222 it=ev.begin(); 245 it=ev.begin();
223 246
224 int dayOrder[7]; 247 int dayOrder[7];
225 if (bStartOnMonday) { 248 if (bStartOnMonday) {
226 for (int d=0; d<7; d++) dayOrder[d]=d+1; 249 for (int d=0; d<7; d++) dayOrder[d]=d+1;
227 } else { 250 } else {
228 for (int d=0; d<7; d++) dayOrder[d]=d; 251 for (int d=0; d<7; d++) dayOrder[d]=d;
229 dayOrder[0]=7; 252 dayOrder[0]=7;
230 } 253 }
231 254
232 // Calculate offset to first day of week. 255 // Calculate offset to first day of week.
233 int dayoffset=d.dayOfWeek(); 256 int dayoffset=d.dayOfWeek();
234 if(bStartOnMonday) dayoffset--; 257 if(bStartOnMonday) dayoffset--;
235 else if( dayoffset == 7 ) dayoffset = 0; 258 else if( dayoffset == 7 ) dayoffset = 0;
236 259
237 for (int i=0; i<7; i++) { 260 for (int i=0; i<7; i++) {
238 // Header 261 // Header
239 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); 262 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
240 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 263 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
241 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 264 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
242 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 265 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
243 layout->addWidget(hdr); 266 layout->addWidget(hdr);
244 267
245 // Events 268 // Events
246 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 269 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
247 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. 270 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day.
248 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); 271 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
249 layout->addWidget(l); 272 layout->addWidget(l);
250 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 273 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
274 connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
275 connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
276 connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
277 connect (l, SIGNAL(redraw()), this, SIGNAL(redraw()));
251 } 278 }
252 it++; 279 it++;
253 } 280 }
254 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 281 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
255 } 282 }
256} 283}
257DateBookWeekLstView::~DateBookWeekLstView(){} 284DateBookWeekLstView::~DateBookWeekLstView(){}
258void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 285void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
259 286
260DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 287DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
261 QValueList<EffectiveEvent> &ev2, 288 QValueList<EffectiveEvent> &ev2,
262 QDate &d, bool onM, 289 QDate &d, bool onM,
263 QWidget* parent, 290 QWidget* parent,
264 const char* name, WFlags fl) 291 const char* name, WFlags fl)
265 : QWidget( parent, name, fl ) 292 : QWidget( parent, name, fl )
266{ 293{
267 QHBoxLayout *layout = new QHBoxLayout( this ); 294 QHBoxLayout *layout = new QHBoxLayout( this );
268 295
269 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 296 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
270 layout->addWidget(w); 297 layout->addWidget(w);
271 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 298 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
299 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
300 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
301 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
302 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
272 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 303 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
273 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 304 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
274 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 305 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
275 306
276 307
277 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 308 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
278 layout->addWidget(w); 309 layout->addWidget(w);
279 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 310 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
311 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
312 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
313 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
314 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
280 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 315 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
281 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 316 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
282 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 317 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
283} 318}
284 319
285DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 320DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
286 QWidget *parent, 321 QWidget *parent,
287 const char *name ) 322 const char *name )
288 : QWidget( parent, name ), 323 : QWidget( parent, name ),
289 db( newDB ), 324 db( newDB ),
290 startTime( 0 ), 325 startTime( 0 ),
291 ampm( ap ), 326 ampm( ap ),
292 bStartOnMonday(onM) 327 bStartOnMonday(onM)
293{ 328{
294 setFocusPolicy(StrongFocus); 329 setFocusPolicy(StrongFocus);
295 layout = new QVBoxLayout( this ); 330 layout = new QVBoxLayout( this );
296 layout->setMargin(0); 331 layout->setMargin(0);
297 332
298 header=new DateBookWeekLstHeader(onM, this); 333 header=new DateBookWeekLstHeader(onM, this);
299 layout->addWidget( header ); 334 layout->addWidget( header );
300 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); 335 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
301 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 336 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
302 337
303 scroll=new QScrollView(this); 338 scroll=new QScrollView(this);
304 scroll->setResizePolicy(QScrollView::AutoOneFit); 339 scroll->setResizePolicy(QScrollView::AutoOneFit);
305 layout->addWidget(scroll); 340 layout->addWidget(scroll);
306 341
307 view=NULL; 342 view=NULL;
308 Config config("DateBook"); 343 Config config("DateBook");
309 config.setGroup("Main"); 344 config.setGroup("Main");
310 dbl=config.readBoolEntry("weeklst_dbl", false); 345 dbl=config.readBoolEntry("weeklst_dbl", false);
311 header->dbl->setOn(dbl); 346 header->dbl->setOn(dbl);
@@ -333,64 +368,68 @@ QDate DateBookWeekLst::date() {
333 368
334// return the date at the beginning of the week... 369// return the date at the beginning of the week...
335// copied from DateBookWeek 370// copied from DateBookWeek
336QDate DateBookWeekLst::weekDate() const 371QDate DateBookWeekLst::weekDate() const
337{ 372{
338 QDate d=bdate; 373 QDate d=bdate;
339 374
340 // Calculate offset to first day of week. 375 // Calculate offset to first day of week.
341 int dayoffset=d.dayOfWeek(); 376 int dayoffset=d.dayOfWeek();
342 if(bStartOnMonday) dayoffset--; 377 if(bStartOnMonday) dayoffset--;
343 else if( dayoffset == 7 ) 378 else if( dayoffset == 7 )
344 dayoffset = 0; 379 dayoffset = 0;
345 380
346 return d.addDays(-dayoffset); 381 return d.addDays(-dayoffset);
347} 382}
348 383
349void DateBookWeekLst::getEvents() { 384void DateBookWeekLst::getEvents() {
350 QDate start = weekDate(); //date(); 385 QDate start = weekDate(); //date();
351 QDate stop = start.addDays(6); 386 QDate stop = start.addDays(6);
352 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 387 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
353 388
354 if (view) delete view; 389 if (view) delete view;
355 if (dbl) { 390 if (dbl) {
356 QDate start2=start.addDays(7); 391 QDate start2=start.addDays(7);
357 stop=start2.addDays(6); 392 stop=start2.addDays(6);
358 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 393 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
359 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 394 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
360 } else { 395 } else {
361 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); 396 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
362 } 397 }
363 398
364 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 399 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
400 connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
401 connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
402 connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
403 connect (view, SIGNAL(redraw()), this, SLOT(redraw()));
365 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 404 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
366 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 405 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
367 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 406 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
368 407
369 scroll->addChild(view); 408 scroll->addChild(view);
370 view->show(); 409 view->show();
371 scroll->updateScrollBars(); 410 scroll->updateScrollBars();
372} 411}
373 412
374void DateBookWeekLst::dateChanged(QDate &newdate) { 413void DateBookWeekLst::dateChanged(QDate &newdate) {
375 bdate=newdate; 414 bdate=newdate;
376 getEvents(); 415 getEvents();
377} 416}
378 417
379void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 418void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
380{ 419{
381 switch(e->key()) { 420 switch(e->key()) {
382 case Key_Up: 421 case Key_Up:
383 scroll->scrollBy(0, -20); 422 scroll->scrollBy(0, -20);
384 break; 423 break;
385 case Key_Down: 424 case Key_Down:
386 scroll->scrollBy(0, 20); 425 scroll->scrollBy(0, 20);
387 break; 426 break;
388 case Key_Left: 427 case Key_Left:
389 header->prevWeek(); 428 header->prevWeek();
390 break; 429 break;
391 case Key_Right: 430 case Key_Right:
392 header->nextWeek(); 431 header->nextWeek();
393 break; 432 break;
394 default: 433 default:
395 e->ignore(); 434 e->ignore();
396 } 435 }
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
index 32fa23f..3bc7f2f 100644
--- a/core/pim/datebook/datebookweeklst.h
+++ b/core/pim/datebook/datebookweeklst.h
@@ -1,156 +1,177 @@
1#ifndef DATEBOOKWEEKLST 1#ifndef DATEBOOKWEEKLST
2#define DATEBOOKWEEKLST 2#define DATEBOOKWEEKLST
3 3
4#include <qwidget.h> 4#include <qwidget.h>
5#include <qdatetime.h> 5#include <qdatetime.h>
6#include <qpe/event.h> 6#include <qpe/event.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qscrollview.h> 8#include <qscrollview.h>
9 9
10#include "datebookweeklstheader.h" 10#include "datebookweeklstheader.h"
11#include "datebookweeklstdayhdr.h" 11#include "datebookweeklstdayhdr.h"
12 12
13#include <opie2/oclickablelabel.h> 13#include <opie2/oclickablelabel.h>
14 14
15class QDateTime; 15class QDateTime;
16class DateBookDB; 16class DateBookDB;
17 17
18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase 18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
19{ 19{
20 Q_OBJECT 20 Q_OBJECT
21public: 21public:
22 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, 22 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
23 WFlags fl = 0 ); 23 WFlags fl = 0 );
24 ~DateBookWeekLstHeader(); 24 ~DateBookWeekLstHeader();
25 void setDate(const QDate &d); 25 void setDate(const QDate &d);
26 26
27public slots: 27public slots:
28 void nextWeek(); 28 void nextWeek();
29 void prevWeek(); 29 void prevWeek();
30 void nextMonth(); 30 void nextMonth();
31 void prevMonth(); 31 void prevMonth();
32 void pickDate(); 32 void pickDate();
33 void setDate(int y, int m, int d); 33 void setDate(int y, int m, int d);
34signals: 34signals:
35 void dateChanged(QDate &newdate); 35 void dateChanged(QDate &newdate);
36 void setDbl(bool on); 36 void setDbl(bool on);
37private: 37private:
38 QDate date; 38 QDate date;
39 //bool onMonday; 39 //bool onMonday;
40 bool bStartOnMonday; 40 bool bStartOnMonday;
41}; 41};
42 42
43class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase 43class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46public: 46public:
47 DateBookWeekLstDayHdr(const QDate &d, bool onM, 47 DateBookWeekLstDayHdr(const QDate &d, bool onM,
48 QWidget* parent = 0, const char* name = 0, 48 QWidget* parent = 0, const char* name = 0,
49 WFlags fl = 0 ); 49 WFlags fl = 0 );
50public slots: 50public slots:
51 void showDay(); 51 void showDay();
52 void newEvent(); 52 void newEvent();
53signals: 53signals:
54 void showDate(int y, int m, int d); 54 void showDate(int y, int m, int d);
55 void addEvent(const QDateTime &start, const QDateTime &stop, 55 void addEvent(const QDateTime &start, const QDateTime &stop,
56 const QString &str, const QString &location); 56 const QString &str, const QString &location);
57private: 57private:
58 QDate date; 58 QDate date;
59}; 59};
60 60
61class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel 61class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, 65 DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1,
66 QWidget* parent = 0, const char* name = 0, 66 QWidget* parent = 0, const char* name = 0,
67 WFlags fl = 0); 67 WFlags fl = 0);
68signals: 68signals:
69 void editEvent(const Event &e); 69 void editEvent(const Event &e);
70 void duplicateEvent(const Event &e);
71 void removeEvent(const Event &e);
72 void beamEvent(const Event &e);
73 void redraw();
70private slots: 74private slots:
71 void editMe(); 75 void editMe();
76 void duplicateMe();
77 void deleteMe();
78 void beamMe();
72private: 79private:
73 const EffectiveEvent event; 80 const EffectiveEvent event;
81 QPopupMenu* popmenue;
82protected:
83 void mousePressEvent( QMouseEvent *e );
74}; 84};
75 85
76class DateBookWeekLstView: public QWidget 86class DateBookWeekLstView: public QWidget
77{ 87{
78 Q_OBJECT 88 Q_OBJECT
79public: 89public:
80 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, 90 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM,
81 QWidget* parent = 0, const char* name = 0, 91 QWidget* parent = 0, const char* name = 0,
82 WFlags fl = 0 ); 92 WFlags fl = 0 );
83 ~DateBookWeekLstView(); 93 ~DateBookWeekLstView();
84signals: 94signals:
85 void editEvent(const Event &e); 95 void editEvent(const Event &e);
96 void duplicateEvent(const Event &e);
97 void removeEvent(const Event &e);
98 void beamEvent(const Event &e);
99 void redraw();
86 void showDate(int y, int m, int d); 100 void showDate(int y, int m, int d);
87 void addEvent(const QDateTime &start, const QDateTime &stop, 101 void addEvent(const QDateTime &start, const QDateTime &stop,
88 const QString &str, const QString &location); 102 const QString &str, const QString &location);
89private: 103private:
90 bool bStartOnMonday; 104 bool bStartOnMonday;
91protected slots: 105protected slots:
92 void keyPressEvent(QKeyEvent *); 106 void keyPressEvent(QKeyEvent *);
93}; 107};
94 108
95class DateBookWeekLstDblView: public QWidget { 109class DateBookWeekLstDblView: public QWidget {
96 Q_OBJECT 110 Q_OBJECT
97public: 111public:
98 DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 112 DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
99 QValueList<EffectiveEvent> &ev2, 113 QValueList<EffectiveEvent> &ev2,
100 QDate &d, bool onM, 114 QDate &d, bool onM,
101 QWidget* parent = 0, const char* name = 0, 115 QWidget* parent = 0, const char* name = 0,
102 WFlags fl = 0 ); 116 WFlags fl = 0 );
103signals: 117signals:
104 void editEvent(const Event &e); 118 void editEvent(const Event &e);
119 void duplicateEvent(const Event &e);
120 void removeEvent(const Event &e);
121 void beamEvent(const Event &e);
122 void redraw();
105 void showDate(int y, int m, int d); 123 void showDate(int y, int m, int d);
106 void addEvent(const QDateTime &start, const QDateTime &stop, 124 void addEvent(const QDateTime &start, const QDateTime &stop,
107 const QString &str, const QString &location); 125 const QString &str, const QString &location);
108}; 126};
109 127
110class DateBookWeekLst : public QWidget 128class DateBookWeekLst : public QWidget
111{ 129{
112 Q_OBJECT 130 Q_OBJECT
113 131
114public: 132public:
115 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, 133 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB,
116 QWidget *parent = 0, 134 QWidget *parent = 0,
117 const char *name = 0 ); 135 const char *name = 0 );
118 ~DateBookWeekLst(); 136 ~DateBookWeekLst();
119 void setDate( int y, int w ); 137 void setDate( int y, int w );
120 void setDate(const QDate &d ); 138 void setDate(const QDate &d );
121 int week() const { return _week; }; 139 int week() const { return _week; };
122 QDate date(); 140 QDate date();
123 QDate weekDate() const; 141 QDate weekDate() const;
124 142
125public slots: 143public slots:
126 void redraw(); 144 void redraw();
127 void dateChanged(QDate &date); 145 void dateChanged(QDate &date);
128 146
129protected slots: 147protected slots:
130 void keyPressEvent(QKeyEvent *); 148 void keyPressEvent(QKeyEvent *);
131 void setDbl(bool on); 149 void setDbl(bool on);
132 150
133signals: 151signals:
134 void showDate(int y, int m, int d); 152 void showDate(int y, int m, int d);
135 void addEvent(const QDateTime &start, const QDateTime &stop, 153 void addEvent(const QDateTime &start, const QDateTime &stop,
136 const QString &str, const QString &location); 154 const QString &str, const QString &location);
137 void editEvent(const Event &e); 155 void editEvent(const Event &e);
156 void duplicateEvent(const Event &e);
157 void removeEvent(const Event &e);
158 void beamEvent(const Event &e);
138 159
139private: 160private:
140 DateBookDB *db; 161 DateBookDB *db;
141 int startTime; 162 int startTime;
142 bool ampm; 163 bool ampm;
143 bool bStartOnMonday; 164 bool bStartOnMonday;
144 bool dbl; 165 bool dbl;
145 QDate bdate; 166 QDate bdate;
146 int year, _week,dow; 167 int year, _week,dow;
147 DateBookWeekLstHeader *header; 168 DateBookWeekLstHeader *header;
148 QWidget *view; 169 QWidget *view;
149 QVBoxLayout *layout; 170 QVBoxLayout *layout;
150 QScrollView *scroll; 171 QScrollView *scroll;
151 172
152 void getEvents(); 173 void getEvents();
153}; 174};
154 175
155#endif 176#endif
156 177