Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 120 |
1 files changed, 39 insertions, 81 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 829f8f8..4fbcb10 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -71,10 +71,4 @@ #include <stdlib.h> -#define DAY 1 -#define WEEK 2 -#define WEEKLST 4 -#define MONTH 3 - - DateBook::DateBook( QWidget *parent, const char *, WFlags f ) : QMainWindow( parent, "datebook", f ), @@ -167,43 +161,18 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) a->addTo( sub_bar ); - a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); + a = new QAction( tr( "Edit..." ), 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); + if(defaultView==DAY) viewDay(); + if(defaultView==WEEK) needEvilHack=true; // viewWeek(); + if(defaultView==WEEKLST) viewWeekLst(); + if(defaultView==MONTH) viewMonth(); - 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(),*/ needEvilHack = true; - 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)), - this, SLOT(changeClock(bool)) ); - connect( qApp, SIGNAL(weekChanged(bool)), - this, SLOT(changeWeek(bool)) ); + connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); + connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) - connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), - this, SLOT(appMessage(const QCString&, const QByteArray&)) ); + connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); #endif @@ -212,9 +181,7 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) #if !defined(QT_NO_COP) QCopChannel *channel = new QCopChannel( "QPE/System", this ); - connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), - this, SLOT(receive(const QCString&, const QByteArray&)) ); + connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); channel = new QCopChannel( "QPE/Datebook", this ); - connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), - this, SLOT(receive(const QCString&, const QByteArray&)) ); + connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); qDebug("olle\n"); #endif @@ -273,4 +240,7 @@ void DateBook::slotSettings() frmSettings.setJumpToCurTime( bJumpToCurTime ); frmSettings.setRowStyle( rowStyle ); + frmSettings.comboDefaultView->setCurrentItem(defaultView-1); + frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); + #if defined (Q_WS_QWS) || defined(_WS_QWS_) frmSettings.showMaximized(); @@ -284,4 +254,6 @@ void DateBook::slotSettings() bJumpToCurTime = frmSettings.jumpToCurTime(); rowStyle = frmSettings.rowStyle(); + defaultView=frmSettings.comboDefaultView->currentItem()+1; + weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); if ( dayView ) { @@ -301,4 +273,6 @@ void DateBook::slotSettings() else if ( views->visibleWidget() == weekView ) weekView->redraw(); + else if ( views->visibleWidget() == weekLstView ) + weekLstView->redraw(); } } @@ -384,4 +358,5 @@ void DateBook::view(int v, const QDate &d) { void DateBook::viewDefault(const QDate &d) { +/* Config config("DateBook"); config.setGroup("Main"); @@ -389,4 +364,6 @@ void DateBook::viewDefault(const QDate &d) { view(current,d); +*/ + view(defaultView,d); } @@ -609,12 +586,9 @@ void DateBook::initMonth() void DateBook::loadSettings() { - { - Config config( "qpe" ); - config.setGroup("Time"); - ampm = config.readBoolEntry( "AMPM", TRUE ); - onMonday = config.readBoolEntry( "MONDAY" ); - } + Config qpeconfig( "qpe" ); + qpeconfig.setGroup("Time"); + ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); + onMonday = qpeconfig.readBoolEntry( "MONDAY" ); - { Config config("DateBook"); config.setGroup("Main"); @@ -624,5 +598,6 @@ void DateBook::loadSettings() bJumpToCurTime = config.readBoolEntry("jumptocurtime"); rowStyle = config.readNumEntry("rowstyle"); - } + defaultView = config.readNumEntry("defaultview",DAY); + weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); } @@ -637,16 +612,6 @@ void DateBook::saveSettings() configDB.writeEntry("jumptocurtime", bJumpToCurTime); configDB.writeEntry("rowstyle", rowStyle); -} - -void DateBook::newDefaultView(QAction *a) { - int val=DAY; - if (a->text() == "Day") val=DAY; - if (a->text() == "Week") val=WEEK; - if (a->text() == "WeekLst") val=WEEKLST; - if (a->text() == "Month") val=MONTH; - - Config configDB( "DateBook" ); - configDB.setGroup( "Main" ); - configDB.writeEntry("defaultview",val); + configDB.writeEntry("defaultview",defaultView); + configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); } @@ -663,6 +628,5 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) // we are forced given a stale alarm... QDateTime current = QDateTime::currentDateTime(); - if ( current.time().hour() != when.time().hour() - && current.time().minute() != when.time().minute() ) + if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) return; @@ -673,6 +637,5 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) int stopTimer = 0; bool found = FALSE; - for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); - it!=list.end(); ++it ) { + for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { if ( (*it).event().hasAlarm() ) { found = TRUE; @@ -697,5 +660,4 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) stopTimer = startTimer( 5000 ); } - QDialog dlg( this, 0, TRUE ); QVBoxLayout *vb = new QVBoxLayout( &dlg ); @@ -721,6 +683,5 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) if ( !qApp-> activeWindow ( )) { needShow = TRUE; - } - else { + } else { QWidget* cur = views->visibleWidget(); if ( cur ) { @@ -752,10 +713,7 @@ void DateBook::reload() { db->reload(); - if ( dayAction->isOn() ) - viewDay(); - else if ( weekAction->isOn() ) - viewWeek(); - else if ( monthAction->isOn() ) - viewMonth(); + if ( dayAction->isOn() ) viewDay(); + else if ( weekAction->isOn() ) viewWeek(); + else if ( monthAction->isOn() ) viewMonth(); syncing = FALSE; } @@ -772,8 +730,8 @@ void DateBook::timerEvent( QTimerEvent *e ) alarmCounter++; Sound::soundAlarm(); - } - else + } else { killTimer( e->timerId() ); } +} void DateBook::changeClock( bool newClock ) @@ -796,5 +754,5 @@ void DateBook::slotToday() { // we need to view today using default view - viewDefault(QDate::currentDate()); + view(defaultView,QDate::currentDate()); } @@ -810,7 +768,7 @@ void DateBook::closeEvent( QCloseEvent *e ) // need to do checking ourselves. saveSettings(); - if ( db->save() ) + if ( db->save() ) { e->accept(); - else { + } else { if ( QMessageBox::critical( this, tr( "Out of space" ), tr("Calendar was unable to save\n" |