summaryrefslogtreecommitdiff
path: root/core
authorumopapisdn <umopapisdn>2003-05-13 22:58:18 (UTC)
committer umopapisdn <umopapisdn>2003-05-13 22:58:18 (UTC)
commit1e0e2f57472538bd880967ebe061c8f39a7e270b (patch) (side-by-side diff)
treefcc070d53148385f93c0dc6ab5443d5100be0d26 /core
parent45c0386de12b107e54e4d020d54eb05517a9efac (diff)
downloadopie-1e0e2f57472538bd880967ebe061c8f39a7e270b.zip
opie-1e0e2f57472538bd880967ebe061c8f39a7e270b.tar.gz
opie-1e0e2f57472538bd880967ebe061c8f39a7e270b.tar.bz2
Bugfix: (Bug #0000902) Adding events in weekview shouldn't create them as events on the first day of the week but rather the last visited day.
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweek.cpp47
-rw-r--r--core/pim/datebook/datebookweek.h6
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp26
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.h4
-rw-r--r--core/pim/datebook/datebookweeklst.cpp76
-rw-r--r--core/pim/datebook/datebookweeklst.h11
6 files changed, 66 insertions, 104 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index 3ae4610..12f57a0 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -349,117 +349,110 @@ DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
QWidget *parent, const char *name )
: QWidget( parent, name ),
db( newDB ),
startTime( 0 ),
ampm( ap ),
bStartOnMonday( startOnMonday )
{
setFocusPolicy(StrongFocus);
QVBoxLayout *vb = new QVBoxLayout( this );
header = new DateBookWeekHeader( bStartOnMonday, this );
view = new DateBookWeekView( ampm, startOnMonday, this );
vb->addWidget( header );
vb->addWidget( view );
lblDesc = new QLabel( this, "event label" );
lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box );
lblDesc->setBackgroundColor( yellow );
lblDesc->hide();
tHide = new QTimer( this );
connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) );
connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) );
connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) );
- connect( header, SIGNAL( dateChanged( int, int ) ), this, SLOT( dateChanged( int, int ) ) );
+ connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) );
connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) );
connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
setDate(QDate::currentDate());
}
void DateBookWeek::keyPressEvent(QKeyEvent *e)
{
switch(e->key()) {
case Key_Up:
view->scrollBy(0, -20);
break;
case Key_Down:
view->scrollBy(0, 20);
break;
case Key_Left:
setDate(date().addDays(-7));
break;
case Key_Right:
setDate(date().addDays(7));
break;
default:
e->ignore();
}
}
void DateBookWeek::showDay( int day )
{
- QDate d;
- d = dateFromWeek( _week, year, bStartOnMonday );
+ QDate d=bdate;
+
+ // Calculate offset to first day of week.
+ int dayoffset=d.dayOfWeek();
+ if(bStartOnMonday) dayoffset--;
+
day--;
- d = d.addDays( day );
+ d=d.addDays(day-dayoffset);
emit showDate( d.year(), d.month(), d.day() );
+ qDebug("%4d-%02d-%02d / Day %d\n",d.year(),d.month(),d.day(),day);
}
void DateBookWeek::setDate( int y, int m, int d )
{
setDate(QDate(y, m, d));
}
-void DateBookWeek::setDate(QDate date)
+void DateBookWeek::setDate(QDate newdate)
{
- dow = date.dayOfWeek();
- int w, y;
- calcWeek( date, w, y, bStartOnMonday );
- header->setDate( date );
+ bdate=newdate;
+ dow = newdate.dayOfWeek();
+ header->setDate( newdate );
}
-void DateBookWeek::dateChanged( int y, int w )
+void DateBookWeek::dateChanged( QDate &newdate )
{
- year = y;
- _week = w;
+ bdate=newdate;
getEvents();
}
QDate DateBookWeek::date() const
{
- QDate d;
- d = dateFromWeek( _week - 1, year, bStartOnMonday );
- if ( bStartOnMonday )
- d = d.addDays( 7 + dow - 1 );
- else {
- if ( dow == 7 )
- d = d.addDays( dow );
- else
- d = d.addDays( 7 + dow );
- }
- return d;
+ return bdate;
}
void DateBookWeek::getEvents()
{
QDate startWeek = weekDate();
QDate endWeek = startWeek.addDays( 6 );
QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek);
view->showEvents( eventList );
view->moveToHour( startTime );
}
void DateBookWeek::generateAllDayTooltext( QString& text ) {
text += "<b>" + tr("This is an all day event.") + "</b><br>";
}
void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) {
str += "<b>" + QObject::tr("Start") + "</b>: ";
str += TimeString::timeString( ev.event().start().time(), ampm, FALSE );
if( ev.startDate()!=ev.endDate() ) {
str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>";
}
str += "<br>";
str += "<b>" + QObject::tr("End") + "</b>: ";
@@ -557,49 +550,55 @@ void DateBookWeek::slotYearChanged( int y )
int throwAway;
calcWeek( d, totWeek, throwAway, bStartOnMonday );
while ( totWeek == 1 ) {
d = d.addDays( -1 );
calcWeek( d, totWeek, throwAway, bStartOnMonday );
}
}
void DateBookWeek::slotWeekChanged( bool onMonday )
{
bStartOnMonday = onMonday;
view->setStartOfWeek( bStartOnMonday );
header->setStartOfWeek( bStartOnMonday );
redraw();
}
void DateBookWeek::slotClockChanged( bool ap )
{
ampm = ap;
}
// return the date at the beginning of the week...
QDate DateBookWeek::weekDate() const
{
- return dateFromWeek( _week, year, bStartOnMonday );
+ QDate d=bdate;
+
+ // Calculate offset to first day of week.
+ int dayoffset=d.dayOfWeek();
+ if(bStartOnMonday) dayoffset--;
+
+ return d.addDays(-dayoffset);
}
// this used to only be needed by datebook.cpp, but now we need it inside
// week view since
// we need to be able to figure out our total number of weeks on the fly...
// this is probably the best place to put it..
// For Weeks that start on Monday... (EASY!)
// At the moment we will use ISO 8601 method for computing
// the week. Granted, other countries use other methods,
// bet we aren't doing any Locale stuff at the moment. So,
// this should pass. This Algorithim is public domain and
// available at:
// http://personal.ecu.edu/mccartyr/ISOwdALG.txt
// the week number is return, and the year number is returned in year
// for Instance 2001/12/31 is actually the first week in 2002.
// There is a more mathematical definition, but I will implement it when
// we are pass our deadline.
// For Weeks that start on Sunday... (ahh... home rolled)
// okay, if Jan 1 is on Friday or Saturday,
// it will go to the pervious
// week...
diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h
index 8c5e06d..c273e30 100644
--- a/core/pim/datebook/datebookweek.h
+++ b/core/pim/datebook/datebookweek.h
@@ -103,64 +103,64 @@ public:
DateBookWeek( bool ampm, bool weekOnMonday, DateBookDB *newDB,
QWidget *parent = 0, const char *name = 0 );
void setDate( int y, int m, int d );
void setDate( QDate d );
QDate date() const;
DateBookWeekView *weekView() const { return view; }
void setStartViewTime( int startHere );
int startViewTime() const;
int week() const { return _week; };
QDate weekDate() const;
public slots:
void redraw();
void slotWeekChanged( bool bStartOnMonday );
void slotClockChanged( bool a );
signals:
void showDate( int y, int m, int d );
protected slots:
void keyPressEvent(QKeyEvent *);
private slots:
void showDay( int day );
- void dateChanged( int y, int w );
+ void dateChanged( QDate &newdate );
void slotShowEvent( const EffectiveEvent & );
void slotHideEvent();
void slotYearChanged( int );
private:
void getEvents();
/**
* Wow that's a hell lot of code duplication
* in datebook. I vote for a common base class
* but never the less. This add a note
* that the Event is an all day event
*
*/
void generateAllDayTooltext( QString& text );
/**
* This will add the times to the text
* It will be shown in the Tooltip bubble
*/
void generateNormalTooltext( QString& text,
const EffectiveEvent &ev);
int year;
int _week;
int dow;
+ QDate bdate;
DateBookWeekHeader *header;
DateBookWeekView *view;
DateBookDB *db;
QLabel *lblDesc;
QTimer *tHide;
int startTime;
bool ampm;
bool bStartOnMonday;
};
-bool calcWeek( const QDate &d, int &week, int &year,
- bool startOnMonday = false );
+bool calcWeek( const QDate &d, int &week, int &year, bool startOnMonday = false );
#endif
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index fd792e2..ff7626f 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -84,56 +84,32 @@ void DateBookWeekHeader::prevWeek()
{
setDate(date.addDays(-7));
}
void DateBookWeekHeader::setDate( int y, int m, int d )
{
setDate(QDate(y,m,d));
}
void DateBookWeekHeader::setDate(const QDate &d) {
int year,week,dayofweek;
date=d;
dayofweek=d.dayOfWeek();
if(bStartOnMonday) dayofweek--;
date=date.addDays(-dayofweek);
calcWeek(date,week,year,bStartOnMonday);
QDate start=date;
QDate stop=start.addDays(6);
labelDate->setText( QString::number(start.day()) + "." +
start.monthName(start.month()) + "-" +
QString::number(stop.day()) + "." +
start.monthName(stop.month()) +" ("+
tr("w")+":"+QString::number( week ) +")");
- emit dateChanged(year,week);
+ emit dateChanged(date);
}
void DateBookWeekHeader::setStartOfWeek( bool onMonday )
{
bStartOnMonday = onMonday;
setDate( date );
}
-
-// dateFromWeek
-// compute the date from the week in the year
-QDate dateFromWeek( int week, int year, bool startOnMonday )
-{
- QDate d;
- d.setYMD( year, 1, 1 );
- int dayOfWeek = d.dayOfWeek();
- if ( startOnMonday ) {
- if ( dayOfWeek <= 4 ) {
- d = d.addDays( ( week - 1 ) * 7 - dayOfWeek + 1 );
- } else {
- d = d.addDays( (week) * 7 - dayOfWeek + 1 );
- }
- } else {
- if ( dayOfWeek <= 4 || dayOfWeek == 7) {
- d = d.addDays( ( week - 1 ) * 7 - dayOfWeek % 7 );
- } else {
- d = d.addDays( ( week ) * 7 - dayOfWeek % 7 );
- }
- }
- return d;
-}
-
diff --git a/core/pim/datebook/datebookweekheaderimpl.h b/core/pim/datebook/datebookweekheaderimpl.h
index 1ab1d52..d8dce90 100644
--- a/core/pim/datebook/datebookweekheaderimpl.h
+++ b/core/pim/datebook/datebookweekheaderimpl.h
@@ -15,45 +15,43 @@
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DATEBOOKDAYHEADER_H
#define DATEBOOKDAYHEADER_H
#include <qdatetime.h>
#include "datebookweekheader.h"
class DateBookWeekHeader : public DateBookWeekHeaderBase
{
Q_OBJECT
public:
DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0,
const char* name = 0, WFlags fl = 0 );
~DateBookWeekHeader();
void setDate(const QDate &d);
void setStartOfWeek( bool onMonday );
signals:
- void dateChanged( int y, int w );
+ void dateChanged( QDate &date );
public slots:
void pickDate();
void nextMonth();
void prevMonth();
void nextWeek();
void prevWeek();
void setDate( int y, int m, int d);
protected slots:
void keyPressEvent(QKeyEvent *e) { e->ignore(); }
private:
QDate date;
bool bStartOnMonday;
};
-QDate dateFromWeek( int week, int year, bool startOnMonday );
-
#endif // DATEBOOKDAYHEADER_H
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index a39ff40..7817042 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -51,94 +51,94 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const ch
connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
bStartOnMonday=onM;
}
DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
void DateBookWeekLstHeader::setDate(const QDate &d) {
int year,week,dayofweek;
date=d;
dayofweek=d.dayOfWeek();
if(bStartOnMonday) dayofweek--;
date=date.addDays(-dayofweek);
calcWeek(date,week,year,bStartOnMonday);
QDate start=date;
QDate stop=start.addDays(6);
labelDate->setText( QString::number(start.day()) + "." +
start.monthName(start.month()) + "-" +
QString::number(stop.day()) + "." +
start.monthName(stop.month()) +" ("+
tr("w")+":"+QString::number( week ) +")");
- emit dateChanged(year,week);
+ emit dateChanged(date);
}
void DateBookWeekLstHeader::pickDate() {
static QPopupMenu *m1 = 0;
static DateBookMonth *picker = 0;
if ( !m1 ) {
m1 = new QPopupMenu( this );
picker = new DateBookMonth( m1, 0, TRUE );
m1->insertItem( picker );
connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) );
//connect( m1, SIGNAL( aboutToHide() ),
//this, SLOT( gotHide() ) );
}
picker->setDate( date.year(), date.month(), date.day() );
m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
picker->setFocus();
}
void DateBookWeekLstHeader::setDate(int y, int m, int d) {
setDate(QDate(y,m,d));
}
void DateBookWeekLstHeader::nextWeek() {
setDate(date.addDays(7));
}
void DateBookWeekLstHeader::prevWeek() {
setDate(date.addDays(-7));
}
void DateBookWeekLstHeader::nextMonth()
{
setDate(date.addDays(28));
}
void DateBookWeekLstHeader::prevMonth()
{
setDate(date.addDays(-28));
}
-DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
+DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
QWidget* parent,
const char* name,
WFlags fl )
: DateBookWeekLstDayHdrBase(parent, name, fl) {
date=d;
- static const char *wdays={"MTWTFSS"};
+ static const char *wdays={"MTWTFSSM"};
char day=wdays[d.dayOfWeek()-1];
label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
add->setText("+");
if (d == QDate::currentDate()) {
QPalette pal=label->palette();
pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
label->setPalette(pal);
/*
QFont f=label->font();
f.setItalic(true);
label->setFont(f);
label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
*/
} else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
QPalette pal=label->palette();
pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
label->setPalette(pal);
}
connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
@@ -213,186 +213,174 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
{
Config config("DateBook");
config.setGroup("Main");
int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
qDebug("Read weeklistviewconfig: %d",weeklistviewconfig);
bStartOnMonday=onM;
setPalette(white);
setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
QVBoxLayout *layout = new QVBoxLayout( this );
qBubbleSort(ev);
QValueListIterator<EffectiveEvent> it;
it=ev.begin();
int dayOrder[7];
if (bStartOnMonday) {
for (int d=0; d<7; d++) dayOrder[d]=d+1;
} else {
for (int d=0; d<7; d++) dayOrder[d]=d;
dayOrder[0]=7;
}
- for (int i=0; i<7; i++) {
+ // Calculate offset to first day of week.
+ int dayoffset=d.dayOfWeek();
+ if(bStartOnMonday) dayoffset--;
+
+ for (int i=0; i<7; i++) {
// Header
- DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), bStartOnMonday,this);
- connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
- connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
- this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
- layout->addWidget(hdr);
-
- // Events
- while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
- if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day.
- DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
- layout->addWidget(l);
- connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
+ DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
+ connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
+ connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
+ this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
+ layout->addWidget(hdr);
+
+ // Events
+ while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
+ if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day.
+ DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
+ layout->addWidget(l);
+ connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
+ }
+ it++;
}
- it++;
- }
-
- layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
+ layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
}
}
DateBookWeekLstView::~DateBookWeekLstView(){}
void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
QValueList<EffectiveEvent> &ev2,
QDate &d, bool onM,
QWidget* parent,
const char* name, WFlags fl)
: QWidget( parent, name, fl )
{
QHBoxLayout *layout = new QHBoxLayout( this );
DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
layout->addWidget(w);
connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)),
this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
layout->addWidget(w);
connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
}
DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
QWidget *parent,
const char *name )
: QWidget( parent, name ),
db( newDB ),
startTime( 0 ),
ampm( ap ),
bStartOnMonday(onM)
{
setFocusPolicy(StrongFocus);
layout = new QVBoxLayout( this );
layout->setMargin(0);
header=new DateBookWeekLstHeader(onM, this);
layout->addWidget( header );
- connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int)));
+ connect(header, SIGNAL(dateChanged(QDate &)), this, SLOT(dateChanged(QDate &)));
connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
scroll=new QScrollView(this);
scroll->setResizePolicy(QScrollView::AutoOneFit);
layout->addWidget(scroll);
view=NULL;
Config config("DateBook");
config.setGroup("Main");
dbl=config.readBoolEntry("weeklst_dbl", false);
header->dbl->setOn(dbl);
}
DateBookWeekLst::~DateBookWeekLst(){
Config config("DateBook");
config.setGroup("Main");
config.writeEntry("weeklst_dbl", dbl);
}
void DateBookWeekLst::setDate(const QDate &d) {
- int w,y;
- calcWeek(d,w,y,bStartOnMonday);
- year=y;
- _week=w;
- header->setDate(date());
+ bdate=d;
+ header->setDate(d);
}
+
void DateBookWeekLst::setDbl(bool on) {
dbl=on;
redraw();
}
void DateBookWeekLst::redraw() {getEvents();}
-QDate DateBookWeekLst::date() const {
- QDate d;
- d.setYMD(year,1,1);
-
- int dow= d.dayOfWeek();
- if (!bStartOnMonday)
- if (dow==7) {
- dow=1;
- } else {
- dow++;
- }
-
- d=d.addDays( (_week-1)*7 - dow + 1 );
- return d;
+QDate DateBookWeekLst::date() {
+ return bdate;
}
void DateBookWeekLst::getEvents() {
QDate start = date();
QDate stop = start.addDays(6);
QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
if (view) delete view;
if (dbl) {
QDate start2=start.addDays(7);
stop=start2.addDays(6);
QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
} else {
view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
}
connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
scroll->addChild(view);
view->show();
scroll->updateScrollBars();
}
-void DateBookWeekLst::dateChanged(int y, int w) {
- year=y;
- _week=w;
+void DateBookWeekLst::dateChanged(QDate &newdate) {
+ bdate=newdate;
getEvents();
}
void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
{
switch(e->key()) {
case Key_Up:
scroll->scrollBy(0, -20);
break;
case Key_Down:
scroll->scrollBy(0, 20);
break;
case Key_Left:
header->prevWeek();
break;
case Key_Right:
header->nextWeek();
break;
default:
e->ignore();
}
-} \ No newline at end of file
+}
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
index f858c4f..0bfbcda 100644
--- a/core/pim/datebook/datebookweeklst.h
+++ b/core/pim/datebook/datebookweeklst.h
@@ -11,49 +11,49 @@
#include "datebookweeklstdayhdr.h"
#include <opie/oclickablelabel.h>
class QDateTime;
class DateBookDB;
class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
{
Q_OBJECT
public:
DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
WFlags fl = 0 );
~DateBookWeekLstHeader();
void setDate(const QDate &d);
public slots:
void nextWeek();
void prevWeek();
void nextMonth();
void prevMonth();
void pickDate();
void setDate(int y, int m, int d);
signals:
- void dateChanged(int y, int w);
+ void dateChanged(QDate &newdate);
void setDbl(bool on);
private:
QDate date;
// bool onMonday;
bool bStartOnMonday;
};
class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
{
Q_OBJECT
public:
DateBookWeekLstDayHdr(const QDate &d, bool onM,
QWidget* parent = 0, const char* name = 0,
WFlags fl = 0 );
public slots:
void showDay();
void newEvent();
signals:
void showDate(int y, int m, int d);
void addEvent(const QDateTime &start, const QDateTime &stop,
const QString &str, const QString &location);
private:
QDate date;
};
@@ -98,57 +98,58 @@ public:
DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
QValueList<EffectiveEvent> &ev2,
QDate &d, bool onM,
QWidget* parent = 0, const char* name = 0,
WFlags fl = 0 );
signals:
void editEvent(const Event &e);
void showDate(int y, int m, int d);
void addEvent(const QDateTime &start, const QDateTime &stop,
const QString &str, const QString &location);
};
class DateBookWeekLst : public QWidget
{
Q_OBJECT
public:
DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB,
QWidget *parent = 0,
const char *name = 0 );
~DateBookWeekLst();
void setDate( int y, int w );
void setDate(const QDate &d );
int week() const { return _week; };
- QDate date() const;
+ QDate date();
public slots:
void redraw();
- void dateChanged(int y, int w);
+ void dateChanged(QDate &date);
protected slots:
void keyPressEvent(QKeyEvent *);
void setDbl(bool on);
signals:
void showDate(int y, int m, int d);
void addEvent(const QDateTime &start, const QDateTime &stop,
const QString &str, const QString &location);
void editEvent(const Event &e);
private:
DateBookDB *db;
int startTime;
bool ampm;
bool bStartOnMonday;
bool dbl;
- int year, _week;
+ QDate bdate;
+ int year, _week,dow;
DateBookWeekLstHeader *header;
QWidget *view;
QVBoxLayout *layout;
QScrollView *scroll;
-
+
void getEvents();
};
#endif