summaryrefslogtreecommitdiff
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
parent603e969bb8cef91534a1785e27106ba71eb03ba6 (diff)
downloadopie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.zip
opie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.tar.gz
opie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.tar.bz2
Fixed today-button to show default view
Diffstat (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
@@ -147,49 +147,48 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
a->addTo( sub_bar );
a->addTo( view );
a->setToggleAction( TRUE );
weekLstAction = a;
a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
a->addTo( sub_bar );
a->addTo( view );
a->setToggleAction( TRUE );
monthAction = a;
a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 );
connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
a->addTo( sub_bar );
a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
a->addTo( settings );
QPopupMenu *default_view = new QPopupMenu(this);
settings->insertItem( tr( "Default View" ),default_view );
default_view->setCheckable(TRUE);
-
Config config("DateBook");
config.setGroup("Main");
int current=config.readNumEntry("defaultview", DAY);
QActionGroup *ag = new QActionGroup(this);
a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true );
if (current==DAY) a->setOn(true), viewDay();
ag->insert(a);
a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true );
if (current==WEEK) a->setOn(true), viewWeek();
ag->insert(a);
a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true );
if (current==WEEKLST) a->setOn(true), viewWeekLst();
ag->insert(a);
a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true );
if (current==MONTH) a->setOn(true), viewMonth();
ag->insert(a);
ag->addTo(default_view);
connect(ag, SIGNAL( selected ( QAction * ) ),
this, SLOT( newDefaultView(QAction *) )
);
connect( qApp, SIGNAL(clockChanged(bool)),
@@ -291,85 +290,98 @@ QString DateBook::checkEvent(const Event &e)
if(checkFailed)
return tr("Event duration is potentially longer\n"
"than interval between repeats.");
return QString::null;
}
QDate DateBook::currentDate()
{
QDate d = QDate::currentDate();
if ( dayView && views->visibleWidget() == dayView ) {
d = dayView->date();
} else if ( weekView && views->visibleWidget() == weekView ) {
d = weekView->date();
} else if ( weekLstView && views->visibleWidget() == weekLstView ) {
d = weekLstView->date();
} else if ( monthView && views->visibleWidget() == monthView ) {
d = monthView->selectedDate();
}
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 )
{
if (syncing) {
QMessageBox::warning( this, tr("Calendar"),
tr( "Can not edit data, currently syncing") );
return;
}
// workaround added for text input.
QDialog editDlg( this, 0, TRUE );
DateEntry *entry;
editDlg.setCaption( tr("Edit Event") );
QVBoxLayout *vb = new QVBoxLayout( &editDlg );
QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
sv->setResizePolicy( QScrollView::AutoOneFit );
// KLUDGE!!!
sv->setHScrollBarMode( QScrollView::AlwaysOff );
vb->addWidget( sv );
entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
entry->timezone->setEnabled( FALSE );
sv->addChild( entry );
@@ -397,52 +409,50 @@ void DateBook::removeEvent( const Event &e )
QMessageBox::warning( this, tr("Calendar"),
tr( "Can not edit data, currently syncing") );
return;
}
QString strName = e.description();
if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
return;
db->removeEvent( e );
if ( views->visibleWidget() == dayView && dayView )
dayView->redraw();
}
void DateBook::addEvent( const Event &e )
{
QDate d = e.start().date();
initDay();
dayView->setDate( d );
}
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()
{
if ( !dayView ) {
dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
views->addWidget( dayView, DAY );
dayView->setStartViewTime( startTime );
connect( this, SIGNAL( newEvent() ),
dayView, SLOT( redraw() ) );
connect( dayView, SIGNAL( newEvent() ),
this, SLOT( fileNew() ) );
connect( dayView, SIGNAL( removeEvent( const Event & ) ),
this, SLOT( removeEvent( const Event & ) ) );
connect( dayView, SIGNAL( editEvent( const Event & ) ),
this, SLOT( editEvent( const Event & ) ) );
connect( dayView, SIGNAL( beamEvent( const Event & ) ),
this, SLOT( beamEvent( const Event & ) ) );
connect( dayView, SIGNAL(sigNewEvent(const QString &)),
this, SLOT(slotNewEventFromKey(const QString &)) );
}
}
void DateBook::initWeek()
@@ -668,51 +678,50 @@ void DateBook::timerEvent( QTimerEvent *e )
} else {
stop = 0;
killTimer( e->timerId() );
}
}
void DateBook::changeClock( bool newClock )
{
ampm = newClock;
// repaint the affected objects...
if (dayView) dayView->redraw();
if (weekView) weekView->redraw();
if (weekLstView) weekLstView->redraw();
}
void DateBook::changeWeek( bool m )
{
/* no need to redraw, each widget catches. Do need to
store though for widgets we haven't made yet */
onMonday = 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 )
{
if(syncing) {
/* no need to save, did that at flush */
e->accept();
return;
}
// save settings will generate it's own error messages, no
// need to do checking ourselves.
saveSettings();
if ( db->save() )
e->accept();
else {
if ( QMessageBox::critical( this, tr( "Out of space" ),
tr("Calendar was unable to save\n"
"your changes.\n"
"Free up some space and try again.\n"
"\nQuit anyway?"),
QMessageBox::Yes|QMessageBox::Escape,
QMessageBox::No|QMessageBox::Default )
!= QMessageBox::No )
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
@@ -31,66 +31,70 @@ class DateBookWeek;
class DateBookWeekLst;
class DateBookMonth;
class Event;
class QDate;
class Ir;
class DateBook : public QMainWindow
{
Q_OBJECT
public:
DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~DateBook();
signals:
void newEvent();
void signalNotFound();
void signalWrapAround();
protected:
QDate currentDate();
void timerEvent( QTimerEvent *e );
void closeEvent( QCloseEvent *e );
+ void view(int v, const QDate &d);
+
public slots:
void flush();
void reload();
private slots:
void fileNew();
void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str);
void slotSettings();
void newDefaultView(QAction *a);
void slotToday(); // view today
void changeClock( bool newClock );
void changeWeek( bool newDay );
void appMessage(const QCString& msg, const QByteArray& data);
// handle key events in the day view...
void slotNewEventFromKey( const QString &str );
void slotFind();
void slotDoFind( const QString &, const QDate &, bool, bool, int );
+ void viewDefault(const QDate &d);
+
void viewDay();
void viewWeek();
void viewWeekLst();
void viewMonth();
void showDay( int y, int m, int d );
void editEvent( const Event &e );
void removeEvent( const Event &e );
void receive( const QCString &msg, const QByteArray &data );
void setDocument( const QString & );
void beamEvent( const Event &e );
void beamDone( Ir *ir );
private:
void addEvent( const Event &e );
void initDay();
void initWeek();
void initWeekLst();
void initMonth();
void loadSettings();
void saveSettings();
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
@@ -25,49 +25,49 @@
bool calcWeek(const QDate &d, int &week, int &year,
bool startOnMonday = false);
DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
const char* name, WFlags fl)
: DateBookWeekLstHeaderBase(parent, name, fl)
{
setBackgroundMode( PaletteButton );
labelDate->setBackgroundMode( PaletteButton );
labelWeek->setBackgroundMode( PaletteButton );
forward->setBackgroundMode( PaletteButton );
back->setBackgroundMode( PaletteButton );
DateBookWeekLstHeaderBaseLayout->setSpacing(0);
DateBookWeekLstHeaderBaseLayout->setMargin(0);
//setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
connect(back, SIGNAL(clicked()), this, SLOT(prevWeek()));
connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek()));
connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate()));
onMonday=onM;
}
DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
-void DateBookWeekLstHeader::setDate(QDate d) {
+void DateBookWeekLstHeader::setDate(const QDate &d) {
date=d;
int year,week;
calcWeek(d,week,year,onMonday);
labelWeek->setText("W: " + QString::number(week));
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()) );
emit dateChanged(year,week);
}
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() ),
@@ -221,49 +221,49 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
: QWidget( parent, name ),
db( newDB ),
startTime( 0 ),
ampm( ap ),
onMonday(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)));
scroll=new QScrollView(this);
//scroll->setVScrollBarMode(QScrollView::AlwaysOn);
//scroll->setHScrollBarMode(QScrollView::AlwaysOff);
scroll->setResizePolicy(QScrollView::AutoOneFit);
layout->addWidget(scroll);
view=NULL;
}
-void DateBookWeekLst::setDate( QDate &d ) {
+void DateBookWeekLst::setDate(const QDate &d) {
int w,y;
calcWeek(d,w,y,onMonday);
year=y;
_week=w;
header->setDate(date());
}
void DateBookWeekLst::redraw() {getEvents();}
QDate DateBookWeekLst::date() const {
QDate d;
d.setYMD(year,1,1);
int dow= d.dayOfWeek();
if (!onMonday)
if (dow==7) dow=1;
else dow++;
d=d.addDays( (_week-1)*7 - dow + 1 );
return d;
}
void DateBookWeekLst::getEvents() {
QDate start = date();
QDate stop = start.addDays(6);
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
@@ -1,49 +1,49 @@
#ifndef DATEBOOKWEEKLST
#define DATEBOOKWEEKLST
#include <qwidget.h>
#include <qdatetime.h>
#include <qpe/event.h>
#include <qlabel.h>
#include <qscrollview.h>
#include "datebookweeklstheader.h"
#include "datebookweeklstdayhdr.h"
#include "clickablelabel.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(QDate d);
+ void setDate(const QDate &d);
public slots:
void nextWeek();
void prevWeek();
void pickDate();
void setDate(int y, int m, int d);
signals:
void dateChanged(int y, int w);
private:
QDate date;
bool onMonday;
};
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:
@@ -76,49 +76,49 @@ public:
DateBookWeekLstView(QValueList<EffectiveEvent> &ev, QDate &d, bool onM,
QWidget* parent = 0, const char* name = 0,
WFlags fl = 0 );
~DateBookWeekLstView();
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);
private:
bool onMonday;
protected slots:
void keyPressEvent(QKeyEvent *);
};
class DateBookWeekLst : public QWidget
{
Q_OBJECT
public:
DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB,
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;
public slots:
void redraw();
void dateChanged(int y, int w);
protected slots:
void keyPressEvent(QKeyEvent *);
signals:
void showDate(int y, int m, int d);
void addEvent(const QDateTime &start, const QDateTime &stop,
const QString &str);
void editEvent(const Event &e);
private:
DateBookDB *db;
int startTime;
bool ampm;
bool onMonday;
int year, _week;
DateBookWeekLstHeader *header;
DateBookWeekLstView *view;
QVBoxLayout *layout;