author | harlekin <harlekin> | 2003-12-05 11:20:37 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-05 11:20:37 (UTC) |
commit | 2b37759fc317b5efd9b371210b16117f7d346455 (patch) (side-by-side diff) | |
tree | f99beb5ff1c886f9b41a2d3a34300f8f121cf738 /core/pim/today/plugins/datebook | |
parent | 1ef5137234e2b7cd0be2a220a86d848503196269 (diff) | |
download | opie-2b37759fc317b5efd9b371210b16117f7d346455.zip opie-2b37759fc317b5efd9b371210b16117f7d346455.tar.gz opie-2b37759fc317b5efd9b371210b16117f7d346455.tar.bz2 |
today in HEAD up to date
Diffstat (limited to 'core/pim/today/plugins/datebook') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/today/plugins/datebook/.cvsignore | 1 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/config.in | 2 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebook.pro | 19 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookevent.cpp | 48 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookevent.h | 5 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookplugin.cpp | 7 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookplugin.h | 1 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.cpp | 50 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.h | 4 |
9 files changed, 99 insertions, 38 deletions
diff --git a/core/pim/today/plugins/datebook/.cvsignore b/core/pim/today/plugins/datebook/.cvsignore index 2888d4a..10cf625 100644 --- a/core/pim/today/plugins/datebook/.cvsignore +++ b/core/pim/today/plugins/datebook/.cvsignore @@ -1,2 +1,3 @@ Makefile* +datebookpluginconfigbase* moc* diff --git a/core/pim/today/plugins/datebook/config.in b/core/pim/today/plugins/datebook/config.in index 621510f..7a14438 100644 --- a/core/pim/today/plugins/datebook/config.in +++ b/core/pim/today/plugins/datebook/config.in @@ -1,4 +1,4 @@ config TODAY_DATEBOOK - boolean "opie-today-datebookplugin (datebook plugin)" + boolean "datebook" default "y" depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE diff --git a/core/pim/today/plugins/datebook/datebook.pro b/core/pim/today/plugins/datebook/datebook.pro index bd45f71..1f75964 100644 --- a/core/pim/today/plugins/datebook/datebook.pro +++ b/core/pim/today/plugins/datebook/datebook.pro @@ -1,21 +1,40 @@ TEMPLATE = lib CONFIG -= moc CONFIG += qt release # Input HEADERS = datebookplugin.h datebookpluginimpl.h datebookpluginconfig.h \ datebookevent.h datebookpluginwidget.h SOURCES = datebookplugin.cpp datebookpluginimpl.cpp datebookpluginconfig.cpp \ datebookevent.cpp datebookpluginwidget.cpp INTERFACES = datebookpluginconfigbase.ui INCLUDEPATH += $(OPIEDIR)/include \ ../ ../library DEPENDPATH += $(OPIEDIR)/include \ ../ ../library LIBS+= -lqpe -lopie DESTDIR = $(OPIEDIR)/plugins/today TARGET = todaydatebookplugin +TRANSLATIONS = ../../../../../i18n/de/libtodaydatebookplugin.ts \ + ../../../../../i18n/nl/libtodaydatebookplugin.ts \ + ../../../../../i18n/xx/libtodaydatebookplugin.ts \ + ../../../../../i18n/en/libtodaydatebookplugin.ts \ + ../../../../../i18n/es/libtodaydatebookplugin.ts \ + ../../../../../i18n/fr/libtodaydatebookplugin.ts \ + ../../../../../i18n/hu/libtodaydatebookplugin.ts \ + ../../../../../i18n/ja/libtodaydatebookplugin.ts \ + ../../../../../i18n/ko/libtodaydatebookplugin.ts \ + ../../../../../i18n/no/libtodaydatebookplugin.ts \ + ../../../../../i18n/pl/libtodaydatebookplugin.ts \ + ../../../../../i18n/pt/libtodaydatebookplugin.ts \ + ../../../../../i18n/pt_BR/libtodaydatebookplugin.ts \ + ../../../../../i18n/sl/libtodaydatebookplugin.ts \ + ../../../../../i18n/zh_CN/libtodaydatebookplugin.ts \ + ../../../../../i18n/zh_TW/libtodaydatebookplugin.ts \ + ../../../../../i18n/it/libtodaydatebookplugin.ts \ + ../../../../../i18n/da/libtodaydatebookplugin.ts + include ( $(OPIEDIR)/include.pro ) diff --git a/core/pim/today/plugins/datebook/datebookevent.cpp b/core/pim/today/plugins/datebook/datebookevent.cpp index 3c1e97a..e595047 100644 --- a/core/pim/today/plugins/datebook/datebookevent.cpp +++ b/core/pim/today/plugins/datebook/datebookevent.cpp @@ -1,138 +1,148 @@ /* * datebookevent.cpp * - * copyright : (c) 2002 by Maximilian Reiß + * copyright : (c) 2002, 2003 by Maximilian Reiß * email : harlekin@handhelds.org * */ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "datebookevent.h" #include <qpe/config.h> #include <qpe/timestring.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpeapplication.h> +#include <qpe/calendar.h> #include <opie/odevice.h> using namespace Opie; DateBookEvent::DateBookEvent(const EffectiveEvent &ev, QWidget* parent, bool show_location, bool show_notes, + bool timeExtraLine, int maxCharClip, const char* name, WFlags fl) : OClickableLabel(parent,name,fl), event(ev) { // setAlignment( AlignTop ); QString msg; Config config( "qpe" ); config.setGroup( "Time" ); // if 24 h format ampm = config.readBoolEntry( "AMPM", TRUE ); msg += "<B>" + (ev).description() + "</B>"; if ( (ev).event().hasAlarm() ) { msg += " <b>" + tr("[with alarm]") +"</b>"; } // include location or not if ( show_location ) { msg += "<BR><i>" + (ev).location() + "</i>"; } + QString timeSpacer = " "; + if ( timeExtraLine ) { + timeSpacer = "<br>"; + } + if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" ) && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) { - msg += "<br>All day"; + msg += tr ( "All day" ); } else { // start time of event - QDate tempDate = (ev).event().start().date(); - msg += "<br>" - + ampmTime( QTime( (ev).event().start().time() ) ) +// QDate tempDate = (ev).event().start().date(); + msg += timeSpacer; + msg += ampmTime( QTime( (ev).event().start().time() ) ) // end time of event - + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) ) - + differDate( tempDate ); + + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) ); + } + + if ( (ev).date() != QDate::currentDate() ) { + msg += differDate( (ev).date() /* tempDate*/ ); } // include possible note or not if ( show_notes ) { msg += "<br> <i>" + tr("note") + "</i>:" +( (ev).notes() ).mid( 0, maxCharClip ); } setText( msg ); connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) ); } DateBookEvent::~DateBookEvent() { } /** * AM/PM timestring conversion. * @param tm the timestring * @return formatted to am/pm is system is set to it */ QString DateBookEvent::ampmTime( QTime tm ) { QString s; if( ampm ) { int hour = tm.hour(); if ( hour == 0 ) { hour = 12; } if ( hour > 12 ) { hour -= 12; } s.sprintf( "%2d:%02d %s", hour, tm.minute(), (tm.hour() >= 12) ? "PM" : "AM" ); return s; } else { s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); return s; } } QString DateBookEvent::differDate( QDate date ) { - QDate currentDate = QDate::currentDate(); +// QDate currentDate = QDate::currentDate(); QString returnText = "<font color = #407DD9><b> "; - int differDate = currentDate.daysTo( date ); - if ( currentDate.dayOfWeek() == date.dayOfWeek() ) { - returnText += "" ; - // not working right for recurring events - //} else if ( differDate == 1 ) { - //returnText += tr( "tomorrow" ); - } else { - //returnText += tr( "in %1 days" ).arg( differDate ); - returnText += " [ " + date.dayName( date.dayOfWeek() ) + " ] "; - } +// int differDate = currentDate.daysTo( date ); +// if ( currentDate.dayOfWeek() == date.dayOfWeek() ) { +// returnText += "" ; +// // not working right for recurring events +// //} else if ( differDate == 1 ) { +// //returnText += tr( "tomorrow" ); +// } else { +// returnText += " [ " + Calendar::nameOfDay( date.dayOfWeek() ) + " ] "; +// } + returnText += " [ " + Calendar::nameOfDay( date.dayOfWeek() ) + " ] "; returnText += "</b></font>"; return returnText; } /** * starts the edit dialog as known from datebook */ void DateBookEvent::editEventSlot( const Event &e ) { if ( ODevice::inst()->system() == System_Zaurus ) { QCopEnvelope env( "QPE/Application/datebook", "raise()" ); } else { - QCopEnvelope env( "QPE/Datebook", "editEvent(int)" ); + QCopEnvelope env( "QPE/Application/datebook", "editEvent(int)" ); env << e.uid(); } } void DateBookEvent::editMe() { emit editEvent( event.event() ); } diff --git a/core/pim/today/plugins/datebook/datebookevent.h b/core/pim/today/plugins/datebook/datebookevent.h index 8027809..1a090e3 100644 --- a/core/pim/today/plugins/datebook/datebookevent.h +++ b/core/pim/today/plugins/datebook/datebookevent.h @@ -1,51 +1,54 @@ /* * datebookplugin.h * - * copyright : (c) 2002 by Maximilian Reiß + * copyright : (c) 2002, 2003 by Maximilian Reiß * email : harlekin@handhelds.org * */ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef DATEBOOKEVENT_PLUGIN_H #define DATEBOOKEVENT_PLUGIN_H #include <opie/oclickablelabel.h> #include <qpe/datebookdb.h> class DateBookEvent: public OClickableLabel { Q_OBJECT public: DateBookEvent( const EffectiveEvent &ev, QWidget* parent = 0, bool show_location = 0, bool show_notes = 0, + bool timeExtraLine = 0, int maxCharClip = 0, const char* name = 0, WFlags fl = 0 ); ~DateBookEvent(); + signals: void editEvent( const Event &e ); private slots: void editEventSlot( const Event &e ); void editMe(); + private: QString ampmTime( QTime ); QString differDate( QDate date ); const EffectiveEvent event; bool ampm; }; #endif diff --git a/core/pim/today/plugins/datebook/datebookplugin.cpp b/core/pim/today/plugins/datebook/datebookplugin.cpp index 4e650ee..f77e440 100644 --- a/core/pim/today/plugins/datebook/datebookplugin.cpp +++ b/core/pim/today/plugins/datebook/datebookplugin.cpp @@ -48,24 +48,31 @@ QWidget* DatebookPlugin::widget( QWidget* wid ) { return m_widget; } QString DatebookPlugin::pixmapNameConfig() const { return "datebook/DateBook"; } TodayConfigWidget* DatebookPlugin::configWidget( QWidget* wid ) { return new DatebookPluginConfig( wid , "Datebook" ); } QString DatebookPlugin::appName() const { return "datebook"; } bool DatebookPlugin::excludeFromRefresh() const { return false; } void DatebookPlugin::refresh() { if ( m_widget ) { m_widget->refresh(); } } + +void DatebookPlugin::reinitialize() { + if ( m_widget ) { + m_widget->reinitialize(); + } +} + diff --git a/core/pim/today/plugins/datebook/datebookplugin.h b/core/pim/today/plugins/datebook/datebookplugin.h index db899e8..890c59b 100644 --- a/core/pim/today/plugins/datebook/datebookplugin.h +++ b/core/pim/today/plugins/datebook/datebookplugin.h @@ -18,31 +18,32 @@ #define DATEBOOK_PLUGIN_H #include <qguardedptr.h> #include <opie/oclickablelabel.h> #include <opie/todayplugininterface.h> #include "datebookpluginwidget.h" class DatebookPlugin : public TodayPluginObject { public: DatebookPlugin(); ~DatebookPlugin(); QString pluginName() const; double versionNumber() const; QString pixmapNameWidget() const; QWidget* widget( QWidget *); QString pixmapNameConfig() const; TodayConfigWidget* configWidget( QWidget *); QString appName() const; bool excludeFromRefresh() const; void refresh(); + void reinitialize(); private: QGuardedPtr<DatebookPluginWidget> m_widget; }; #endif diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp index 1970654..9e95bcd 100644 --- a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp @@ -9,117 +9,135 @@ * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "datebookpluginwidget.h" #include <qpe/timestring.h> #include <qpe/config.h> #include <qdatetime.h> #include <qlabel.h> #include <qtl.h> DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name ) : QWidget(parent, name ) { db = 0l; m_layoutDates = 0l; - if ( db ) { - delete db; - } - db = new DateBookDB; - if ( m_layoutDates ) { delete m_layoutDates; } m_layoutDates = new QVBoxLayout( this ); m_layoutDates->setAutoAdd( true ); m_eventsList.setAutoDelete( true ); readConfig(); getDates(); - m_layoutDates->addStretch(5); } DatebookPluginWidget::~DatebookPluginWidget() { delete db; delete m_layoutDates; } void DatebookPluginWidget::readConfig() { Config cfg( "todaydatebookplugin" ); cfg.setGroup( "config" ); m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); m_show_location = cfg.readNumEntry( "showlocation", 1 ); m_show_notes = cfg.readNumEntry( "shownotes", 0 ); m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); m_moreDays = cfg.readNumEntry( "moredays", 0 ); + m_timeExtraLine = cfg.readNumEntry( "timeextraline", 1 ); +} + +void DatebookPluginWidget::reinitialize() { + readConfig(); + refresh(); } void DatebookPluginWidget::refresh() { m_eventsList.clear(); if ( m_layoutDates ) { delete m_layoutDates; } m_layoutDates = new QVBoxLayout( this ); m_layoutDates->setAutoAdd( true ); getDates(); - m_layoutDates->addStretch(5); } /** * Get all events that are in the datebook xml file for today */ void DatebookPluginWidget::getDates() { + + if ( db ) { + delete db; + } + db = new DateBookDB; + QDate date = QDate::currentDate(); QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); qBubbleSort( list ); int count = 0; if ( list.count() > 0 ) { for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { if ( count < m_max_lines_meet ) { if ( !m_onlyLater ) { count++; - DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); - m_eventsList.append( l ); - l->show(); - QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); - } else if ( QDateTime::currentDateTime() <= (*it).event().end() || (*it).event().start().date() != date ) { - count++; - // show only later appointments - DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); + DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine ); m_eventsList.append( l ); l->show(); QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); - } + } else { + if ( ( QDateTime::currentDateTime() <= (*it).event().end() ) + // Show events which span over many days and are not elapsed. + || ( ( (*it).event().start().date() != date ) && ( QDateTime::currentDateTime() <= (*it).event().end() ) ) + // Show repeated event for today that is not elapsed. + || ( ( (*it).event().repeatType() != Event::NoRepeat ) + && ( ( date.dayOfWeek() == (*it).date().dayOfWeek() ) + && ( QTime::currentTime() < (*it).event().start().time() ) ) ) + // Show repeated event for next days. + || ( ( (*it).event().repeatType() != Event::NoRepeat ) + && ( date.dayOfWeek() != (*it).date().dayOfWeek() ) ) + ) + { + count++; + // show only later appointments + DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine ); + m_eventsList.append( l ); + l->show(); + QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); + } + } } } if ( m_onlyLater && count == 0 ) { QLabel* noMoreEvents = new QLabel( this ); m_eventsList.append( noMoreEvents ); noMoreEvents->show(); noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); } } else { QLabel* noEvents = new QLabel( this ); m_eventsList.append( noEvents ); noEvents->show(); noEvents->setText( QObject::tr( "No appointments today" ) ); } } diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.h b/core/pim/today/plugins/datebook/datebookpluginwidget.h index 35d43cd..8988073 100644 --- a/core/pim/today/plugins/datebook/datebookpluginwidget.h +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.h @@ -13,46 +13,48 @@ * (at your option) any later version. * * * ***************************************************************************/ #ifndef DATEBOOK_PLUGIN_WIDGET_H #define DATEBOOK_PLUGIN_WIDGET_H #include <qlayout.h> #include <qguardedptr.h> #include <qlist.h> #include <qpe/datebookdb.h> #include <opie/oclickablelabel.h> #include "datebookevent.h" class DatebookPluginWidget : public QWidget { Q_OBJECT public: DatebookPluginWidget( QWidget *parent, const char *name ); ~DatebookPluginWidget(); void refresh(); + void reinitialize(); private: DateBookDB* db; QGuardedPtr<QVBoxLayout> m_layoutDates; QList<QWidget> m_eventsList; void readConfig(); void getDates(); // how many lines should be showed in the datebook section int m_max_lines_meet; // If location is to be showed too, 1 to activate it. bool m_show_location; // if notes should be shown bool m_show_notes; // should only later appointments be shown or all for the current day. bool m_onlyLater; int m_moreDays; - + // true if time of an appointment should be an extra line + bool m_timeExtraLine; }; #endif |