author | harlekin <harlekin> | 2003-02-10 21:28:14 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-02-10 21:28:14 (UTC) |
commit | bbb3cdf8f91d567f6c2e786bd144b64bd679ff9a (patch) (side-by-side diff) | |
tree | 9c622e670cab66c44d9bd079707945cf3c9bcb89 /core/pim/today/plugins/datebook | |
parent | de272b8c47c3960a3fe574317fe2e6fb0c32e4af (diff) | |
download | opie-bbb3cdf8f91d567f6c2e786bd144b64bd679ff9a.zip opie-bbb3cdf8f91d567f6c2e786bd144b64bd679ff9a.tar.gz opie-bbb3cdf8f91d567f6c2e786bd144b64bd679ff9a.tar.bz2 |
adapted to new refresh, datebookplugin still need some work
Diffstat (limited to 'core/pim/today/plugins/datebook') (more/less context) (ignore whitespace changes)
4 files changed, 54 insertions, 27 deletions
diff --git a/core/pim/today/plugins/datebook/datebookplugin.cpp b/core/pim/today/plugins/datebook/datebookplugin.cpp index eda84be..2ac7d01 100644 --- a/core/pim/today/plugins/datebook/datebookplugin.cpp +++ b/core/pim/today/plugins/datebook/datebookplugin.cpp @@ -21,3 +21,2 @@ #include "datebookplugin.h" -#include "datebookpluginwidget.h" #include "datebookpluginconfig.h" @@ -26,2 +25,3 @@ DatebookPlugin::DatebookPlugin() { + m_widget = 0; } @@ -29,2 +29,3 @@ DatebookPlugin::DatebookPlugin() { DatebookPlugin::~DatebookPlugin() { + delete m_widget; } @@ -44,3 +45,6 @@ QString DatebookPlugin::pixmapNameWidget() const { QWidget* DatebookPlugin::widget( QWidget* wid ) { - return new DatebookPluginWidget( wid, "Datebook" ); + if(!m_widget) { + m_widget = new DatebookPluginWidget( wid, "Datebook" ); + } + return m_widget; } @@ -62 +66,7 @@ bool DatebookPlugin::excludeFromRefresh() const { } + +void DatebookPlugin::refresh() { + if ( m_widget ) { + m_widget->refresh(); + } +} diff --git a/core/pim/today/plugins/datebook/datebookplugin.h b/core/pim/today/plugins/datebook/datebookplugin.h index 13c62a9..644a614 100644 --- a/core/pim/today/plugins/datebook/datebookplugin.h +++ b/core/pim/today/plugins/datebook/datebookplugin.h @@ -25,2 +25,4 @@ +#include "datebookpluginwidget.h" + class DatebookPlugin : public TodayPluginObject { @@ -39,2 +41,6 @@ public: bool excludeFromRefresh() const; + void refresh(); + + private: + DatebookPluginWidget *m_widget; }; diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp index c6aa2a6..e2f492e 100644 --- a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp @@ -1,2 +1,2 @@ -/* + /* * datebookpluginwidget.cpp @@ -18,3 +18,2 @@ #include "datebookpluginwidget.h" -#include "datebookevent.h" @@ -32,3 +31,17 @@ 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 ); + readConfig(); @@ -39,2 +52,3 @@ DatebookPluginWidget::~DatebookPluginWidget() { delete db; + delete m_layoutDates; } @@ -52,2 +66,9 @@ void DatebookPluginWidget::readConfig() { +void DatebookPluginWidget::refresh() { + DateBookEvent* ev; + for ( ev = m_eventsList.first(); ev != 0; ev = m_eventsList.next() ) { + delete ev; + } + getDates(); +} @@ -58,21 +79,7 @@ void DatebookPluginWidget::getDates() { - QDate date = QDate::currentDate(); - QVBoxLayout* layoutDates = new QVBoxLayout( this ); - layoutDates->setSpacing( 1 ); - layoutDates->setMargin( 1 ); - - if ( db ) { - delete db; - } - - db = new DateBookDB; - QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); - qBubbleSort( list ); - - Config config( "qpe" ); - + //Config config( "qpe" ); int count=0; @@ -81,3 +88,3 @@ void DatebookPluginWidget::getDates() { - for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { + for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { @@ -89,4 +96,4 @@ void DatebookPluginWidget::getDates() { 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 &) ) ); + m_eventsList.append( l ); + QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); } else if ( ( time.toString() <= TimeString::dateString( (*it).event().end() ) ) ) { @@ -95,4 +102,4 @@ void DatebookPluginWidget::getDates() { 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 &) ) ); + m_eventsList.append( l ); + QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); } @@ -103,3 +110,2 @@ void DatebookPluginWidget::getDates() { noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); - layoutDates->addWidget( noMoreEvents ); } @@ -108,3 +114,2 @@ void DatebookPluginWidget::getDates() { noEvents->setText( QObject::tr( "No appointments today" ) ); - layoutDates->addWidget( noEvents ); } diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.h b/core/pim/today/plugins/datebook/datebookpluginwidget.h index 3ebbc3d..8380bc7 100644 --- a/core/pim/today/plugins/datebook/datebookpluginwidget.h +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.h @@ -21,2 +21,4 @@ #include <qwidget.h> +#include <qlayout.h> +#include <qlist.h> @@ -25,2 +27,3 @@ +#include "datebookevent.h" @@ -33,3 +36,3 @@ public: ~DatebookPluginWidget(); - + void refresh(); @@ -37,2 +40,4 @@ private: DateBookDB* db; + QVBoxLayout* m_layoutDates; + QList<DateBookEvent> m_eventsList; void readConfig(); @@ -40,2 +45,3 @@ private: + // how many lines should be showed in the datebook section |