author | umopapisdn <umopapisdn> | 2003-04-12 03:56:46 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-04-12 03:56:46 (UTC) |
commit | 8c690a7bb709773217ba3d39d3ef769a2414cc72 (patch) (side-by-side diff) | |
tree | a34bae70ee8dc46f40f60150e1703088fbc4da36 | |
parent | 212aef7fd20182fe926644af2ab10a4b49549440 (diff) | |
download | opie-8c690a7bb709773217ba3d39d3ef769a2414cc72.zip opie-8c690a7bb709773217ba3d39d3ef769a2414cc72.tar.gz opie-8c690a7bb709773217ba3d39d3ef769a2414cc72.tar.bz2 |
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.
-rw-r--r-- | core/pim/datebook/datebook.cpp | 120 | ||||
-rw-r--r-- | core/pim/datebook/datebook.h | 6 | ||||
-rw-r--r-- | core/pim/datebook/datebooksettingsbase.ui | 394 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 123 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.h | 2 |
5 files changed, 396 insertions, 249 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 @@ -57,38 +57,32 @@ #include <qpushbutton.h> #include <qregexp.h> #include <qtextcodec.h> #include <qtextstream.h> #include <qtimer.h> #include <qtl.h> #include <qwidgetstack.h> #include <qwindowsystem_qws.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #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 ), aPreset( FALSE ), presetTime( -1 ), startTime( 8 ), // an acceptable default rowStyle( 0 ), bJumpToCurTime(FALSE), syncing(FALSE), inSearch(FALSE), alarmCounter(0) { bool needEvilHack= false; // if we need an Evil Hack QTime t; t.start(); db = new DateBookDBHack; qDebug("loading db t=%d", t.elapsed() ); @@ -153,82 +147,55 @@ 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 ); + 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 // 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 qDebug("done t=%d", t.elapsed() ); /* * Here is a problem description: * When Weekview is the default view * a DateBookWeekView get's created * redraw() get's called. So what? * Remember that we're still in the c'tor * and no final layout has happened? Ok * now all Events get arranged. Their x * position get's determined by a QHeader * position. But the QHeader isn't layouted or @@ -259,60 +226,67 @@ void DateBook::receive( const QCString &msg, const QByteArray &data ) Event e=db->eventByUID(uid); editEvent(e); } } DateBook::~DateBook() { } void DateBook::slotSettings() { 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 if ( frmSettings.exec() ) { aPreset = frmSettings.alarmPreset(); presetTime = frmSettings.presetTime(); startTime = frmSettings.startTime(); bJumpToCurTime = frmSettings.jumpToCurTime(); rowStyle = frmSettings.rowStyle(); + defaultView=frmSettings.comboDefaultView->currentItem()+1; + weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); if ( dayView ) { dayView->setStartViewTime( startTime ); dayView->setJumpToCurTime( bJumpToCurTime ); dayView->setRowStyle( rowStyle ); } if ( weekView ) { weekView->setStartViewTime( startTime ); } saveSettings(); // make the change obvious if ( views->visibleWidget() ) { if ( views->visibleWidget() == dayView ) dayView->redraw(); else if ( views->visibleWidget() == weekView ) weekView->redraw(); + else if ( views->visibleWidget() == weekLstView ) + weekLstView->redraw(); } } } void DateBook::fileNew() { slotNewEventFromKey(""); } QString DateBook::checkEvent(const Event &e) { /* check if overlaps with itself */ bool checkFailed = FALSE; /* check the next 12 repeats. should catch most problems */ QDate current_date = e.start().date(); @@ -370,37 +344,40 @@ void DateBook::view(int v, const QDate &d) { } 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::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() { view(DAY,currentDate()); } void DateBook::viewWeek() { view(WEEK,currentDate()); } void DateBook::viewWeekLst() { view(WEEKLST,currentDate()); } void DateBook::viewMonth() { view(MONTH,currentDate()); @@ -595,236 +572,217 @@ void DateBook::initWeekLst() { void DateBook::initMonth() { if ( !monthView ) { monthView = new DateBookMonth( views, "month view", FALSE, db ); views->addWidget( monthView, MONTH ); connect( monthView, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); qApp->processEvents(); } } 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); aPreset = config.readBoolEntry("alarmpreset"); 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); + 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() ) + if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) return; QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); if ( list.count() > 0 ) { QString msg; bool bSound = FALSE; 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; msg += "<CENTER><B>" + (*it).description() + "</B>" + "<BR>" + (*it).location() + "<BR>" + TimeString::dateString((*it).event().start(),ampm) + (warn ? tr(" (in " + QString::number(warn) + tr(" minutes)")) : QString("")) + "<BR>" + (*it).notes() + "</CENTER>"; 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(); #endif needShow = dlg.exec(); if ( bSound ) killTimer( stopTimer ); } } } else if ( msg == "nextView()" ) { if ( !qApp-> activeWindow ( )) { needShow = TRUE; - } - else { + } 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(); #else show(); #endif raise(); QPEApplication::setKeepRunning(); setActiveWindow(); } } 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; } void DateBook::flush() { syncing = TRUE; db->save(); } void DateBook::timerEvent( QTimerEvent *e ) { if ( alarmCounter < 10 ) { alarmCounter++; Sound::soundAlarm(); - } - else + } 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(); } 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 using default view - viewDefault(QDate::currentDate()); + view(defaultView,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() ) + if ( db->save() ) { e->accept(); - else { + } 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(); } } // Entering directly from the "keyboard" void DateBook::slotNewEventFromKey( const QString &str ) 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 @@ -11,32 +11,35 @@ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef DATEBOOK_H #define DATEBOOK_H #include <qpe/datebookdb.h> #include <qmainwindow.h> +enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values +enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes. + class QAction; class QWidgetStack; class DateBookDay; class DateBookWeek; class DateBookWeekLst; class DateBookMonth; class Event; class QDate; class Ir; class DateBookDBHack : public DateBookDB { public: Event eventByUID(int id); }; class DateBook : public QMainWindow @@ -54,33 +57,32 @@ signals: 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, const QString &location=0); 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(); @@ -99,33 +101,35 @@ private: void addEvent( const Event &e ); void initDay(); void initWeek(); void initWeekLst(); void initMonth(); void loadSettings(); void saveSettings(); private: DateBookDBHack *db; QWidgetStack *views; DateBookDay *dayView; DateBookWeek *weekView; 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; + int defaultView; bool bJumpToCurTime; //should jump to current time in dayview? bool ampm; bool onMonday; bool syncing; bool inSearch; int alarmCounter; QString checkEvent(const Event &); }; #endif 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 @@ -19,224 +19,402 @@ ** not clear to you. ** ** $Id$ ** **********************************************************************</comment> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>DateBookSettingsBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>220</width> - <height>290</height> + <width>273</width> + <height>303</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Preferences</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> - <grid> + <vbox> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> - <widget row="0" column="0" > - <class>QGroupBox</class> + <widget> + <class>QTabWidget</class> <property stdset="1"> <name>name</name> - <cstring>fraStart</cstring> + <cstring>TabWidget2</cstring> </property> + <widget> + <class>QWidget</class> <property stdset="1"> - <name>frameShape</name> - <enum>Box</enum> + <name>name</name> + <cstring>tab</cstring> </property> + <attribute> + <name>title</name> + <string>Views</string> + </attribute> + <vbox> <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> + <name>margin</name> + <number>11</number> </property> <property stdset="1"> - <name>title</name> - <string>Start viewing events</string> + <name>spacing</name> + <number>6</number> </property> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>Layout6</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>3</x> - <y>21</y> - <width>210</width> - <height>53</height> - </rect> + <cstring>Layout5</cstring> </property> - <grid> + <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> - <spacer row="1" column="0" > + <spacer> <property> <name>name</name> <cstring>Spacer1</cstring> </property> <property stdset="1"> <name>orientation</name> - <enum>Vertical</enum> + <enum>Horizontal</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> - <widget row="0" column="0" > - <class>QLayoutWidget</class> + <widget> + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>Layout1</cstring> + <cstring>TextLabel1_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Default view:</string> + </property> + </widget> + <widget> + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>Day</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Week</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Week List</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Month</string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>comboDefaultView</cstring> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer2</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox4</cstring> </property> - <hbox> + <property stdset="1"> + <name>title</name> + <string>Day</string> + </property> + <vbox> <property stdset="1"> <name>margin</name> - <number>0</number> + <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> - <class>QLabel</class> + <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>lblStartTime</cstring> + <cstring>chkJumpToCurTime</cstring> </property> <property stdset="1"> <name>text</name> - <string>Start Time:</string> + <string>Jump to current time</string> </property> </widget> <widget> - <class>QSpinBox</class> + <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>spinStart</cstring> + <cstring>Layout5</cstring> </property> + <hbox> <property stdset="1"> - <name>suffix</name> - <string>:00</string> + <name>margin</name> + <number>0</number> </property> <property stdset="1"> - <name>wrapping</name> - <bool>true</bool> + <name>spacing</name> + <number>6</number> </property> + <widget> + <class>QLabel</class> <property stdset="1"> - <name>maxValue</name> - <number>23</number> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Row style:</string> </property> </widget> - </hbox> + <widget> + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>Default</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Medium</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Large</string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>comboRowStyle</cstring> + </property> </widget> - </grid> + </hbox> </widget> + </vbox> </widget> - <widget row="1" column="0" > + <widget> <class>QGroupBox</class> <property stdset="1"> <name>name</name> - <cstring>fraAlarm</cstring> + <cstring>GroupBox5</cstring> </property> <property stdset="1"> <name>title</name> - <string>Alarm Settings</string> + <string>Week List</string> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> </property> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>Layout4</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>10</x> - <y>20</y> - <width>200</width> - <height>53</height> - </rect> + <cstring>Layout6</cstring> </property> - <grid> + <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> - <spacer row="1" column="0" > + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Time display</string> + </property> + </widget> + <widget> + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>None</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Start</string> + </property> + </item> + <item> <property> + <name>text</name> + <string>Start-End</string> + </property> + </item> + <property stdset="1"> <name>name</name> - <cstring>Spacer2</cstring> + <cstring>comboWeekListView</cstring> + </property> + </widget> + </hbox> + </widget> + </vbox> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer3_2</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> - <widget row="0" column="0" > + </vbox> + </widget> + <widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>tab</cstring> + </property> + <attribute> + <name>title</name> + <string>Misc</string> + </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox6</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Alarm Settings</string> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout6</cstring> </property> <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QCheckBox</class> @@ -269,129 +447,127 @@ </property> <property stdset="1"> <name>minValue</name> <number>0</number> </property> <property stdset="1"> <name>lineStep</name> <number>5</number> </property> <property stdset="1"> <name>value</name> <number>5</number> </property> </widget> </hbox> </widget> - </grid> - </widget> + </vbox> </widget> - <widget row="2" column="0" > + <widget> <class>QGroupBox</class> <property stdset="1"> <name>name</name> - <cstring>fraMisc</cstring> + <cstring>GroupBox7</cstring> </property> <property stdset="1"> <name>title</name> - <string>Misc</string> + <string>Start viewing events</string> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> </property> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>Layout5</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>10</x> - <y>40</y> - <width>170</width> - <height>24</height> - </rect> + <cstring>Layout1</cstring> </property> <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1</cstring> + <cstring>lblStartTime</cstring> </property> <property stdset="1"> <name>text</name> - <string>Row style:</string> + <string>Start Time:</string> </property> </widget> <widget> - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>Default</string> + <class>QSpinBox</class> + <property stdset="1"> + <name>name</name> + <cstring>spinStart</cstring> </property> - </item> - <item> - <property> - <name>text</name> - <string>Medium</string> + <property stdset="1"> + <name>suffix</name> + <string>:00</string> </property> - </item> - <item> - <property> - <name>text</name> - <string>Large</string> + <property stdset="1"> + <name>wrapping</name> + <bool>true</bool> </property> - </item> <property stdset="1"> - <name>name</name> - <cstring>comboRowStyle</cstring> + <name>maxValue</name> + <number>23</number> </property> </widget> </hbox> </widget> - <widget> - <class>QCheckBox</class> - <property stdset="1"> + </vbox> + </widget> + <spacer> + <property> <name>name</name> - <cstring>chkJumpToCurTime</cstring> + <cstring>Spacer9</cstring> </property> <property stdset="1"> - <name>geometry</name> - <rect> - <x>10</x> - <y>20</y> - <width>200</width> - <height>20</height> - </rect> + <name>orientation</name> + <enum>Vertical</enum> </property> <property stdset="1"> - <name>text</name> - <string>Jump to current time (dayview)</string> + <name>sizeType</name> + <enum>Expanding</enum> </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> </widget> </widget> - </grid> + </vbox> </widget> <connections> <connection> <sender>chkAlarmPreset</sender> <signal>toggled(bool)</signal> <receiver>spinPreset</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>spinStart</sender> <signal>valueChanged(int)</signal> <receiver>DateBookSettingsBase</receiver> <slot>slot12Hour( int )</slot> </connection> <slot access="public">slotChangeClock( bool )</slot> <slot access="public">slot12Hour( int )</slot> 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 @@ -1,20 +1,22 @@ #include "datebookweeklst.h" #include "datebookweekheaderimpl.h" +#include "datebook.h" + #include <qpe/calendar.h> #include <qpe/datebookdb.h> #include <qpe/event.h> #include <qpe/qpeapplication.h> #include <qpe/timestring.h> #include <qpe/datebookmonth.h> #include <qpe/config.h> #include <qpe/resource.h> #include <qdatetime.h> #include <qheader.h> #include <qlabel.h> #include <qlayout.h> #include <qpainter.h> #include <qpopupmenu.h> #include <qtimer.h> @@ -130,167 +132,176 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, connect (label, SIGNAL(clicked()), this, SLOT(showDay())); connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); } void DateBookWeekLstDayHdr::showDay() { emit showDate(date.year(), date.month(), date.day()); } void DateBookWeekLstDayHdr::newEvent() { QDateTime start, stop; start=stop=date; start.setTime(QTime(10,0)); stop.setTime(QTime(12,0)); emit addEvent(start,stop,"",0); } DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, + int weeklistviewconfig, QWidget* parent, const char* name, - WFlags fl) : - OClickableLabel(parent,name,fl), - event(ev) + 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()); } DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) { + Config config("DateBook"); + config.setGroup("Main"); + int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); + qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); + onMonday=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 (onMonday) + if (onMonday) { for (int d=0; d<7; d++) dayOrder[d]=d+1; - else { + } 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++; } 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 &))); + 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 &))); + 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 ), 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))); - connect(header, SIGNAL(setDbl(bool)), - this, SLOT(setDbl(bool))); + 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"); @@ -303,63 +314,61 @@ void DateBookWeekLst::setDate(const QDate &d) { year=y; _week=w; header->setDate(date()); } 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 (!onMonday) - if (dow==7) dow=1; - else dow++; + 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); 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,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(); } void DateBookWeekLst::dateChanged(int y, int w) { year=y; _week=w; getEvents(); } void DateBookWeekLst::keyPressEvent(QKeyEvent *e) { switch(e->key()) { case Key_Up: 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 @@ -46,33 +46,33 @@ public: 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; }; class DateBookWeekLstEvent: public OClickableLabel { Q_OBJECT public: - DateBookWeekLstEvent(const EffectiveEvent &ev, + DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, QWidget* parent = 0, const char* name = 0, WFlags fl = 0); signals: void editEvent(const Event &e); private slots: void editMe(); private: const EffectiveEvent event; }; class DateBookWeekLstView: public QWidget { Q_OBJECT public: DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent = 0, const char* name = 0, |