author | harlekin <harlekin> | 2002-09-15 21:13:47 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-09-15 21:13:47 (UTC) |
commit | 87cd421d72df1d7706925285a48c008007471310 (patch) (side-by-side diff) | |
tree | eb7805bd6702f2820aac159baa4a9c5592a52ee4 /core/pim/today/plugins/datebook/datebookpluginwidget.cpp | |
parent | 251fd5b1687994c30e8bea1091e893468086223f (diff) | |
download | opie-87cd421d72df1d7706925285a48c008007471310.zip opie-87cd421d72df1d7706925285a48c008007471310.tar.gz opie-87cd421d72df1d7706925285a48c008007471310.tar.bz2 |
plugins for the new today
Diffstat (limited to 'core/pim/today/plugins/datebook/datebookpluginwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.cpp | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp new file mode 100644 index 0000000..e4667ae --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp @@ -0,0 +1,114 @@ +/* + * datebookpluginwidget.cpp + * + * copyright : (c) 2002 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 "datebookpluginwidget.h" +#include "datebookevent.h" + +#include <qpe/timestring.h> +#include <qpe/config.h> + +#include <qdatetime.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qtl.h> +#include <qscrollview.h> +#include <qtimer.h> + +DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name) + : QWidget(parent, name ) { + db = 0l; + readConfig(); + getDates(); +} + +DatebookPluginWidget::~DatebookPluginWidget() { + delete db; +} + + +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 ); +} + + +/** + * Get all events that are in the datebook xml file for today + */ +void DatebookPluginWidget::getDates() { + + + QDate date = QDate::currentDate(); + + QVBoxLayout* layoutDates = new QVBoxLayout( this ); + + if ( db ) { + delete db; + } + + db = new DateBookDB; + + QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date ); + + qBubbleSort( list ); + + Config config( "qpe" ); + + int count=0; + + if ( list.count() > 0 ) { + + for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { + + if ( count <= m_max_lines_meet ) { + QTime time = QTime::currentTime(); + + if ( !m_onlyLater ) { + count++; + DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); + layoutDates->addWidget( l ); + QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); + } else if ( ( time.toString() <= TimeString::dateString( (*it).event().end() ) ) ) { + count++; + // show only later appointments + DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); + layoutDates->addWidget( l ); + QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); + } + } + } + if ( m_onlyLater && count == 0 ) { + QLabel* noMoreEvents = new QLabel( this ); + noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); + layoutDates->addWidget( noMoreEvents ); + } + } else { + QLabel* noEvents = new QLabel( this ); + noEvents->setText( QObject::tr( "No appointments today" ) ); + layoutDates->addWidget( noEvents ); + } + + layoutDates->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); + + // how often refresh - later have qcop update calls in *db + //QTimer::singleShot( 20*1000, this , SLOT( getDates() ) ); +} + |