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/datebookpluginwidget.cpp | |
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/datebookpluginwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.cpp | 50 |
1 files changed, 34 insertions, 16 deletions
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 @@ -27,28 +27,22 @@ 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; } @@ -59,56 +53,80 @@ void DatebookPluginWidget::readConfig() { 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(); |