summaryrefslogtreecommitdiff
path: root/core/pim/datebook
authorhakan <hakan>2002-03-09 13:07:57 (UTC)
committer hakan <hakan>2002-03-09 13:07:57 (UTC)
commit62c21e8bdbb365a64f05dd363a98abd7fc1f0558 (patch) (side-by-side diff)
treebde5aec77cc0c22a4240b16f0fc4acc41b2d162f /core/pim/datebook
parent603e969bb8cef91534a1785e27106ba71eb03ba6 (diff)
downloadopie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.zip
opie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.tar.gz
opie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.tar.bz2
Fixed today-button to show default view
Diffstat (limited to 'core/pim/datebook') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp85
-rw-r--r--core/pim/datebook/datebook.h4
-rw-r--r--core/pim/datebook/datebookweeklst.cpp4
-rw-r--r--core/pim/datebook/datebookweeklst.h4
4 files changed, 55 insertions, 42 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 9880e2d..92dbdc8 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -168,7 +168,6 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
settings->insertItem( tr( "Default View" ),default_view );
default_view->setCheckable(TRUE);
-
Config config("DateBook");
config.setGroup("Main");
int current=config.readNumEntry("defaultview", DAY);
@@ -312,43 +311,56 @@ QDate DateBook::currentDate()
return d;
}
-void DateBook::viewDay()
-{
- initDay();
- dayAction->setOn( TRUE );
- QDate d = currentDate();
- dayView->setDate( d );
- views->raiseWidget( dayView );
- dayView->redraw();
+void DateBook::view(int v, const QDate &d) {
+ if (v==DAY) {
+ initDay();
+ dayAction->setOn( TRUE );
+ dayView->setDate( d );
+ views->raiseWidget( dayView );
+ dayView->redraw();
+ } else if (v==WEEK) {
+ initWeek();
+ weekAction->setOn( TRUE );
+ weekView->setDate( d );
+ views->raiseWidget( weekView );
+ weekView->redraw();
+ } else if (v==WEEKLST) {
+ initWeekLst();
+ weekLstAction->setOn( TRUE );
+ weekLstView->setDate(d);
+ views->raiseWidget( weekLstView );
+ weekLstView->redraw();
+ } else if (v==MONTH) {
+ initMonth();
+ monthAction->setOn( TRUE );
+ monthView->setDate( d.year(), d.month(), d.day() );
+ views->raiseWidget( monthView );
+ monthView->redraw();
+ }
}
-void DateBook::viewWeek()
-{
- initWeek();
- weekAction->setOn( TRUE );
- QDate d = currentDate();
- weekView->setDate( d );
- views->raiseWidget( weekView );
- weekView->redraw();
+void DateBook::viewDefault(const QDate &d) {
+ Config config("DateBook");
+ config.setGroup("Main");
+ int current=config.readNumEntry("defaultview", DAY);
+
+ view(current,d);
+}
+
+void DateBook::viewDay() {
+ view(DAY,currentDate());
+}
+
+void DateBook::viewWeek() {
+ view(WEEK,currentDate());
}
void DateBook::viewWeekLst() {
- initWeekLst();
- weekLstAction->setOn( TRUE );
- QDate d=currentDate();
- weekLstView->setDate(d);
- views->raiseWidget( weekLstView );
- weekLstView->redraw();
+ view(WEEKLST,currentDate());
}
-void DateBook::viewMonth()
-{
- initMonth();
- monthAction->setOn( TRUE );
- QDate d = currentDate();
- monthView->setDate( d.year(), d.month(), d.day() );
- views->raiseWidget( monthView );
- monthView->redraw();
+void DateBook::viewMonth() {
+ view(MONTH,currentDate());
}
void DateBook::editEvent( const Event &e )
@@ -418,10 +430,8 @@ void DateBook::addEvent( const Event &e )
void DateBook::showDay( int year, int month, int day )
{
- initDay();
- dayView->setDate( year, month, day );
- views->raiseWidget( dayView );
- dayAction->setOn( TRUE );
+ QDate d(year, month, day);
+ view(DAY,d);
}
void DateBook::initDay()
@@ -689,9 +699,8 @@ void DateBook::changeWeek( bool m )
void DateBook::slotToday()
{
- // we need to view today
- QDate dt = QDate::currentDate();
- showDay( dt.year(), dt.month(), dt.day() );
+ // we need to view today using default view
+ viewDefault(QDate::currentDate());
}
void DateBook::closeEvent( QCloseEvent *e )
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index fcdbfec..2ffcdbe 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -52,6 +52,8 @@ protected:
void timerEvent( QTimerEvent *e );
void closeEvent( QCloseEvent *e );
+ void view(int v, const QDate &d);
+
public slots:
void flush();
void reload();
@@ -70,6 +72,8 @@ private slots:
void slotFind();
void slotDoFind( const QString &, const QDate &, bool, bool, int );
+ void viewDefault(const QDate &d);
+
void viewDay();
void viewWeek();
void viewWeekLst();
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 05e36be..dc141c0 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -46,7 +46,7 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
onMonday=onM;
}
DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
-void DateBookWeekLstHeader::setDate(QDate d) {
+void DateBookWeekLstHeader::setDate(const QDate &d) {
date=d;
int year,week;
@@ -242,7 +242,7 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
}
-void DateBookWeekLst::setDate( QDate &d ) {
+void DateBookWeekLst::setDate(const QDate &d) {
int w,y;
calcWeek(d,w,y,onMonday);
year=y;
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
index d2a07cc..39c956d 100644
--- a/core/pim/datebook/datebookweeklst.h
+++ b/core/pim/datebook/datebookweeklst.h
@@ -22,7 +22,7 @@ public:
DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
WFlags fl = 0 );
~DateBookWeekLstHeader();
- void setDate(QDate d);
+ void setDate(const QDate &d);
public slots:
void nextWeek();
@@ -97,7 +97,7 @@ public:
QWidget *parent = 0,
const char *name = 0 );
void setDate( int y, int w );
- void setDate( QDate &d );
+ void setDate(const QDate &d );
int week() const { return _week; };
QDate date() const;