From 8c690a7bb709773217ba3d39d3ef769a2414cc72 Mon Sep 17 00:00:00 2001 From: umopapisdn Date: Sat, 12 Apr 2003 03:56:46 +0000 Subject: New feature: Added a configurable option to make the weeklist view display either no times at all, only start times, or both start and end time. Also moved the configuration of default view from the menu into the preference dialog. --- 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 @@ -70,12 +70,6 @@ #include -#define DAY 1 -#define WEEK 2 -#define WEEKLST 4 -#define MONTH 3 - - DateBook::DateBook( QWidget *parent, const char *, WFlags f ) : QMainWindow( parent, "datebook", f ), aPreset( FALSE ), @@ -166,56 +160,29 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 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); - - 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)) ); + if(defaultView==DAY) viewDay(); + if(defaultView==WEEK) needEvilHack=true; // viewWeek(); + if(defaultView==WEEKLST) viewWeekLst(); + if(defaultView==MONTH) viewMonth(); + + 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 // listen on QPE/System #if defined(Q_WS_QWS) #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 #endif @@ -267,11 +234,14 @@ DateBook::~DateBook() void DateBook::slotSettings() { - DateBookSettings frmSettings( ampm, this ); - frmSettings.setStartTime( startTime ); - frmSettings.setAlarmPreset( aPreset, presetTime ); - frmSettings.setJumpToCurTime( bJumpToCurTime ); - frmSettings.setRowStyle( rowStyle ); + DateBookSettings frmSettings( ampm, this ); + frmSettings.setStartTime( startTime ); + frmSettings.setAlarmPreset( aPreset, presetTime ); + 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(); #endif @@ -283,6 +253,8 @@ void DateBook::slotSettings() startTime = frmSettings.startTime(); bJumpToCurTime = frmSettings.jumpToCurTime(); rowStyle = frmSettings.rowStyle(); + defaultView=frmSettings.comboDefaultView->currentItem()+1; + weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); if ( dayView ) { dayView->setStartViewTime( startTime ); @@ -300,6 +272,8 @@ void DateBook::slotSettings() dayView->redraw(); else if ( views->visibleWidget() == weekView ) weekView->redraw(); + else if ( views->visibleWidget() == weekLstView ) + weekLstView->redraw(); } } } @@ -383,11 +357,14 @@ void DateBook::view(int v, const QDate &d) { } void DateBook::viewDefault(const QDate &d) { +/* Config config("DateBook"); config.setGroup("Main"); int current=config.readNumEntry("defaultview", DAY); view(current,d); +*/ + view(defaultView,d); } void DateBook::viewDay() { @@ -608,14 +585,11 @@ 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"); startTime = config.readNumEntry("startviewtime", 8); @@ -623,206 +597,190 @@ void DateBook::loadSettings() presetTime = config.readNumEntry("presettime"); bJumpToCurTime = config.readBoolEntry("jumptocurtime"); rowStyle = config.readNumEntry("rowstyle"); - } + defaultView = config.readNumEntry("defaultview",DAY); + weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); } void DateBook::saveSettings() { - Config config( "qpe" ); - Config configDB( "DateBook" ); - configDB.setGroup( "Main" ); - configDB.writeEntry("startviewtime",startTime); - configDB.writeEntry("alarmpreset",aPreset); - configDB.writeEntry("presettime",presetTime); - 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); + Config config( "qpe" ); + Config configDB( "DateBook" ); + configDB.setGroup( "Main" ); + configDB.writeEntry("startviewtime",startTime); + configDB.writeEntry("alarmpreset",aPreset); + configDB.writeEntry("presettime",presetTime); + configDB.writeEntry("jumptocurtime", bJumpToCurTime); + configDB.writeEntry("rowstyle", rowStyle); + configDB.writeEntry("defaultview",defaultView); + configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); } void DateBook::appMessage(const QCString& msg, const QByteArray& data) { - bool needShow = FALSE; - if ( msg == "alarm(QDateTime,int)" ) { - QDataStream ds(data,IO_ReadOnly); - QDateTime when; int warn; - ds >> when >> warn; - - // check to make it's okay to continue, - // this is the case that the time was set ahead, and - // we are forced given a stale alarm... - QDateTime current = QDateTime::currentDateTime(); - if ( current.time().hour() != when.time().hour() - && current.time().minute() != when.time().minute() ) - return; - - QValueList list = db->getEffectiveEvents(when.addSecs(warn*60)); - if ( list.count() > 0 ) { - QString msg; - bool bSound = FALSE; - int stopTimer = 0; - bool found = FALSE; - for ( QValueList::ConstIterator it=list.begin(); - it!=list.end(); ++it ) { - if ( (*it).event().hasAlarm() ) { - found = TRUE; - msg += "
" + (*it).description() + "" - + "
" + (*it).location() + "
" - + TimeString::dateString((*it).event().start(),ampm) - + (warn - ? tr(" (in " + QString::number(warn) - + tr(" minutes)")) - : QString("")) - + "
" - + (*it).notes() + "
"; - if ( (*it).event().alarmSound() != Event::Silent ) { - bSound = TRUE; - } - } - } - if ( found ) { - if ( bSound ) { - Sound::soundAlarm(); - alarmCounter = 0; - stopTimer = startTimer( 5000 ); - } - - QDialog dlg( this, 0, TRUE ); - QVBoxLayout *vb = new QVBoxLayout( &dlg ); - QScrollView *view = new QScrollView( &dlg, "scrollView"); - view->setResizePolicy( QScrollView::AutoOneFit ); - vb->addWidget( view ); - QLabel *lblMsg = new QLabel( msg, &dlg ); - view->addChild( lblMsg ); - QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); - connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); - vb->addWidget( cmdOk ); + bool needShow = FALSE; + if ( msg == "alarm(QDateTime,int)" ) { + QDataStream ds(data,IO_ReadOnly); + QDateTime when; int warn; + ds >> when >> warn; + + // check to make it's okay to continue, + // this is the case that the time was set ahead, and + // we are forced given a stale alarm... + QDateTime current = QDateTime::currentDateTime(); + if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) + return; + + QValueList list = db->getEffectiveEvents(when.addSecs(warn*60)); + if ( list.count() > 0 ) { + QString msg; + bool bSound = FALSE; + int stopTimer = 0; + bool found = FALSE; + for ( QValueList::ConstIterator it=list.begin(); it!=list.end(); ++it ) { + if ( (*it).event().hasAlarm() ) { + found = TRUE; + msg += "
" + (*it).description() + "" + + "
" + (*it).location() + "
" + + TimeString::dateString((*it).event().start(),ampm) + + (warn + ? tr(" (in " + QString::number(warn) + + tr(" minutes)")) + : QString("")) + + "
" + + (*it).notes() + "
"; + if ( (*it).event().alarmSound() != Event::Silent ) { + bSound = TRUE; + } + } + } + if ( found ) { + if ( bSound ) { + Sound::soundAlarm(); + alarmCounter = 0; + stopTimer = startTimer( 5000 ); + } + QDialog dlg( this, 0, TRUE ); + QVBoxLayout *vb = new QVBoxLayout( &dlg ); + QScrollView *view = new QScrollView( &dlg, "scrollView"); + view->setResizePolicy( QScrollView::AutoOneFit ); + vb->addWidget( view ); + QLabel *lblMsg = new QLabel( msg, &dlg ); + view->addChild( lblMsg ); + QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); + connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); + vb->addWidget( cmdOk ); #if defined(Q_WS_QWS) || defined(_WS_QWS_) - dlg.showMaximized(); + dlg.showMaximized(); #endif - needShow = dlg.exec(); - - if ( bSound ) - killTimer( stopTimer ); - } - } - } else if ( msg == "nextView()" ) { - if ( !qApp-> activeWindow ( )) { - needShow = TRUE; - } - else { - QWidget* cur = views->visibleWidget(); - if ( cur ) { - if ( cur == dayView ) - viewWeek(); - else if ( cur == weekView ) - viewWeekLst(); - else if ( cur == weekLstView ) - viewMonth(); - else if ( cur == monthView ) - viewDay(); - needShow = TRUE; - } - } + needShow = dlg.exec(); + + if ( bSound ) + killTimer( stopTimer ); + } + } + } else if ( msg == "nextView()" ) { + if ( !qApp-> activeWindow ( )) { + needShow = TRUE; + } else { + QWidget* cur = views->visibleWidget(); + if ( cur ) { + if ( cur == dayView ) + viewWeek(); + else if ( cur == weekView ) + viewWeekLst(); + else if ( cur == weekLstView ) + viewMonth(); + else if ( cur == monthView ) + viewDay(); + needShow = TRUE; + } + } } if ( needShow ) { #if defined(Q_WS_QWS) || defined(_WS_QWS_) - showMaximized(); + showMaximized(); #else - show(); + show(); #endif - raise(); - QPEApplication::setKeepRunning(); - setActiveWindow(); - } + raise(); + QPEApplication::setKeepRunning(); + setActiveWindow(); + } } void DateBook::reload() { - db->reload(); - if ( dayAction->isOn() ) - viewDay(); - else if ( weekAction->isOn() ) - viewWeek(); - else if ( monthAction->isOn() ) - viewMonth(); - syncing = FALSE; + db->reload(); + if ( dayAction->isOn() ) viewDay(); + else if ( weekAction->isOn() ) viewWeek(); + else if ( monthAction->isOn() ) viewMonth(); + syncing = FALSE; } void DateBook::flush() { - syncing = TRUE; - db->save(); + syncing = TRUE; + db->save(); } void DateBook::timerEvent( QTimerEvent *e ) { - if ( alarmCounter < 10 ) { - alarmCounter++; - Sound::soundAlarm(); - } - else - killTimer( e->timerId() ); + if ( alarmCounter < 10 ) { + alarmCounter++; + Sound::soundAlarm(); + } else { + 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(); + 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; + /* 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 using default view - viewDefault(QDate::currentDate()); + // we need to view today using default view + view(defaultView,QDate::currentDate()); } void DateBook::closeEvent( QCloseEvent *e ) { - if(syncing) { - /* no need to save, did that at flush */ - e->accept(); - return; - } + 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 ) - e->accept(); - else - e->ignore(); + // 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 ) + e->accept(); + else + e->ignore(); } } diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index 623862b..5216770 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h @@ -24,6 +24,9 @@ #include +enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values +enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes. + class QAction; class QWidgetStack; class DateBookDay; @@ -67,7 +70,6 @@ private slots: void fileNew(); void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); void slotSettings(); - void newDefaultView(QAction *a); void slotToday(); // view today void changeClock( bool newClock ); void changeWeek( bool newDay ); @@ -112,11 +114,13 @@ private: DateBookMonth *monthView; DateBookWeekLst *weekLstView; QAction *dayAction, *weekAction, *weekLstAction, *monthAction; + int weeklistviewconfig; bool aPreset; // have everything set to alarm? int presetTime; // the standard time for the alarm int startTime; int rowStyle; - bool bJumpToCurTime; //should jump to current time in dayview? + int defaultView; + bool bJumpToCurTime; //should jump to current time in dayview? bool ampm; bool onMonday; diff --git a/core/pim/datebook/datebooksettingsbase.ui b/core/pim/datebook/datebooksettingsbase.ui index 816a441..3836330 100644 --- a/core/pim/datebook/datebooksettingsbase.ui +++ b/core/pim/datebook/datebooksettingsbase.ui @@ -32,8 +32,8 @@ 0 0 - 220 - 290 + 273 + 303 @@ -46,7 +46,7 @@ layoutSpacing - + margin 11 @@ -55,74 +55,36 @@ spacing 6 - - QGroupBox + + QTabWidget name - fraStart - - - frameShape - Box - - - frameShadow - Sunken - - - title - Start viewing events + TabWidget2 - QLayoutWidget + QWidget name - Layout6 + tab - - geometry - - 3 - 21 - 210 - 53 - - - + + title + Views + + margin - 0 + 11 spacing 6 - - - name - Spacer1 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - + QLayoutWidget name - Layout1 + Layout5 @@ -133,106 +95,106 @@ spacing 6 + + + name + Spacer1 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + QLabel name - lblStartTime + TextLabel1_2 text - Start Time: + Default view: - QSpinBox + QComboBox + + + text + Day + + + + + text + Week + + + + + text + Week List + + + + + text + Month + + name - spinStart + comboDefaultView - - suffix - :00 + + + + name + Spacer2 - wrapping - true + orientation + Horizontal - maxValue - 23 + sizeType + Expanding - + + sizeHint + + 20 + 20 + + + - - - - - QGroupBox - - name - fraAlarm - - - title - Alarm Settings - - - QLayoutWidget - - name - Layout4 - - - geometry - - 10 - 20 - 200 - 53 - - - - - margin - 0 - - - spacing - 6 - - - - name - Spacer2 - - - orientation - Vertical - + + QGroupBox - sizeType - Expanding - - - sizeHint - - 20 - 20 - + name + GroupBox4 - - - QLayoutWidget - name - Layout6 + title + Day - + margin - 0 + 11 spacing @@ -242,143 +204,357 @@ QCheckBox name - chkAlarmPreset + chkJumpToCurTime text - Alarm Preset + Jump to current time - QSpinBox + QLayoutWidget name - spinPreset - - - enabled - false - - - suffix - minutes - - - maxValue - 180 - - - minValue - 0 - - - lineStep - 5 + Layout5 + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + TextLabel1 + + + text + Row style: + + + + QComboBox + + + text + Default + + + + + text + Medium + + + + + text + Large + + + + name + comboRowStyle + + + + + + + + QGroupBox + + name + GroupBox5 + + + title + Week List + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget - value - 5 + name + Layout6 + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + TextLabel2 + + + text + Time display + + + + QComboBox + + + text + None + + + + + text + Start + + + + + text + Start-End + + + + name + comboWeekListView + + + - + - + + + name + Spacer3_2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + - - - QGroupBox - - name - fraMisc - - - title - Misc - - QLayoutWidget + QWidget name - Layout5 - - - geometry - - 10 - 40 - 170 - 24 - + tab - + + title + Misc + + margin - 0 + 11 spacing 6 - QLabel + QGroupBox name - TextLabel1 + GroupBox6 - text - Row style: + title + Alarm Settings - - - QComboBox - - - text - Default - - - - - text - Medium + + + margin + 11 - - - - text - Large + + spacing + 6 - + + QLayoutWidget + + name + Layout6 + + + + margin + 0 + + + spacing + 6 + + + QCheckBox + + name + chkAlarmPreset + + + text + Alarm Preset + + + + QSpinBox + + name + spinPreset + + + enabled + false + + + suffix + minutes + + + maxValue + 180 + + + minValue + 0 + + + lineStep + 5 + + + value + 5 + + + + + + + + QGroupBox name - comboRowStyle + GroupBox7 + + title + Start viewing events + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout1 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + lblStartTime + + + text + Start Time: + + + + QSpinBox + + name + spinStart + + + suffix + :00 + + + wrapping + true + + + maxValue + 23 + + + + + - - - - QCheckBox - - name - chkJumpToCurTime - - - geometry - - 10 - 20 - 200 - 20 - - - - text - Jump to current time (dayview) - + + + name + Spacer9 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + - + diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 3d6a029..3c8fc89 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp @@ -2,6 +2,8 @@ #include "datebookweekheaderimpl.h" +#include "datebook.h" + #include #include #include @@ -143,31 +145,51 @@ void DateBookWeekLstDayHdr::newEvent() { emit addEvent(start,stop,"",0); } DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, - QWidget* parent, - const char* name, - WFlags fl) : - OClickableLabel(parent,name,fl), - event(ev) + int weeklistviewconfig, + QWidget* parent, + const char* name, + WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) { - char s[10]; - if ( ev.startDate() != ev.date() ) { // multiday event (not first day) - if ( ev.endDate() == ev.date() ) { // last day - strcpy(s, "__|__"); - } else { - strcpy(s, " |---"); + // old values... lastday = "__|__", middle=" |---", Firstday="00:00", + QString s,start,middle,end,day; + + qDebug("weeklistviewconfig=%d",weeklistviewconfig); + if(weeklistviewconfig==NONE) { // No times displayed. +// start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); +// middle.sprintf("<--->"); +// end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); +// day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); + } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. + start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); + middle.sprintf(" |---"); + end.sprintf("__|__"); + day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); + } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. + start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); + middle.sprintf("<--->"); + end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); + day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); + } + + if(ev.event().type() == Event::Normal) { + if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. + s=day; + } else if(ev.startDate()==ev.date()) { // start event. + s=start; + } else if(ev.endDate()==ev.date()) { // end event. + s=end; + } else { // middle day. + s=middle; } } else { - if(ev.event().type() == Event::Normal ) - sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); - else - sprintf(s," "); + s=""; } setText(QString(s) + " " + ev.description()); connect(this, SIGNAL(clicked()), this, SLOT(editMe())); setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); } void DateBookWeekLstEvent::editMe() { - emit editEvent(event.event()); + emit editEvent(event.event()); } @@ -177,45 +199,44 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList &ev, const char* name, WFlags fl) : QWidget( parent, name, fl ) { - onMonday=onM; - setPalette(white); - setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); + Config config("DateBook"); + config.setGroup("Main"); + int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); + qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); - QVBoxLayout *layout = new QVBoxLayout( this ); + onMonday=onM; + setPalette(white); + setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); - qBubbleSort(ev); - QValueListIterator it; - it=ev.begin(); + QVBoxLayout *layout = new QVBoxLayout( this ); - int dayOrder[7]; - if (onMonday) - 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; - } + qBubbleSort(ev); + QValueListIterator it; + it=ev.begin(); + + int dayOrder[7]; + if (onMonday) { + 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++) { // Header - DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), - onMonday,this); + DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,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 &))); + 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,this); + DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); layout->addWidget(l); - connect (l, SIGNAL(editEvent(const Event &)), - this, SIGNAL(editEvent(const Event &))); + connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); } it++; } @@ -233,30 +254,22 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList &ev1, 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 &))); + 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, @@ -274,108 +287,104 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, header=new DateBookWeekLstHeader(onM, this); layout->addWidget( header ); - connect(header, SIGNAL(dateChanged(int,int)), - this, SLOT(dateChanged(int,int))); - connect(header, SIGNAL(setDbl(bool)), - this, SLOT(setDbl(bool))); - - scroll=new QScrollView(this); - //scroll->setVScrollBarMode(QScrollView::AlwaysOn); - //scroll->setHScrollBarMode(QScrollView::AlwaysOff); - 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); + connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); + connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); + + scroll=new QScrollView(this); + //scroll->setVScrollBarMode(QScrollView::AlwaysOn); + //scroll->setHScrollBarMode(QScrollView::AlwaysOff); + 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); + Config config("DateBook"); + config.setGroup("Main"); + config.writeEntry("weeklst_dbl", dbl); } void DateBookWeekLst::setDate(const QDate &d) { - int w,y; - calcWeek(d,w,y,onMonday); - year=y; - _week=w; - header->setDate(date()); + int w,y; + calcWeek(d,w,y,onMonday); + year=y; + _week=w; + header->setDate(date()); } void DateBookWeekLst::setDbl(bool on) { - dbl=on; - redraw(); + dbl=on; + redraw(); } void DateBookWeekLst::redraw() {getEvents();} QDate DateBookWeekLst::date() const { - QDate d; - d.setYMD(year,1,1); + QDate d; + d.setYMD(year,1,1); - int dow= d.dayOfWeek(); - if (!onMonday) - if (dow==7) dow=1; - else dow++; + int dow= d.dayOfWeek(); + if (!onMonday) + if (dow==7) { + dow=1; + } else { + dow++; + } - d=d.addDays( (_week-1)*7 - dow + 1 ); - return d; + d=d.addDays( (_week-1)*7 - dow + 1 ); + return d; } void DateBookWeekLst::getEvents() { - QDate start = date(); - QDate stop = start.addDays(6); - QValueList el = db->getEffectiveEvents(start, stop); - - if (view) delete view; - if (dbl) { - QDate start2=start.addDays(7); - stop=start2.addDays(6); - QValueList el2 = db->getEffectiveEvents(start2, stop); - - view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); - } else { - view=new DateBookWeekLstView(el,start,onMonday,scroll); - } + QDate start = date(); + QDate stop = start.addDays(6); + QValueList el = db->getEffectiveEvents(start, stop); + + if (view) delete view; + if (dbl) { + QDate start2=start.addDays(7); + stop=start2.addDays(6); + QValueList el2 = db->getEffectiveEvents(start2, stop); + view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); + } else { + view=new DateBookWeekLstView(el,start,onMonday,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 &))); - 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(); + scroll->addChild(view); + view->show(); + scroll->updateScrollBars(); } void DateBookWeekLst::dateChanged(int y, int w) { - year=y; - _week=w; - getEvents(); + year=y; + _week=w; + 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(); - } + 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(); + } } diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h index ea88f20..17dc01f 100644 --- a/core/pim/datebook/datebookweeklst.h +++ b/core/pim/datebook/datebookweeklst.h @@ -59,8 +59,8 @@ class DateBookWeekLstEvent: public OClickableLabel { Q_OBJECT public: - DateBookWeekLstEvent(const EffectiveEvent &ev, - QWidget* parent = 0, const char* name = 0, + DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, + QWidget* parent = 0, const char* name = 0, WFlags fl = 0); signals: void editEvent(const Event &e); @@ -75,7 +75,7 @@ class DateBookWeekLstView: public QWidget Q_OBJECT public: DateBookWeekLstView(QValueList &ev, const QDate &d, bool onM, - QWidget* parent = 0, const char* name = 0, + QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~DateBookWeekLstView(); signals: @@ -92,10 +92,10 @@ protected slots: class DateBookWeekLstDblView: public QWidget { Q_OBJECT public: - DateBookWeekLstDblView(QValueList &ev1, - QValueList &ev2, + DateBookWeekLstDblView(QValueList &ev1, + QValueList &ev2, QDate &d, bool onM, - QWidget* parent = 0, const char* name = 0, + QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); signals: void editEvent(const Event &e); @@ -104,20 +104,20 @@ signals: const QString &str, const QString &location); }; -class DateBookWeekLst : public QWidget +class DateBookWeekLst : public QWidget { Q_OBJECT public: - DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, - QWidget *parent = 0, + 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; - + public slots: void redraw(); void dateChanged(int y, int w); @@ -128,7 +128,7 @@ protected slots: signals: void showDate(int y, int m, int d); - void addEvent(const QDateTime &start, const QDateTime &stop, + void addEvent(const QDateTime &start, const QDateTime &stop, const QString &str, const QString &location); void editEvent(const Event &e); -- cgit v0.9.0.2