author | harlekin <harlekin> | 2003-02-10 23:42:49 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-02-10 23:42:49 (UTC) |
commit | 4abed72fea334ebfda6b146f70542dad522424b7 (patch) (side-by-side diff) | |
tree | fc106623928f2fabc604d06f1c73b73ae9811512 /core/pim/today/plugins | |
parent | 871eadc731c0c05c553b8edc8c0e3198127057b6 (diff) | |
download | opie-4abed72fea334ebfda6b146f70542dad522424b7.zip opie-4abed72fea334ebfda6b146f70542dad522424b7.tar.gz opie-4abed72fea334ebfda6b146f70542dad522424b7.tar.bz2 |
fix refresh
-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.cpp | 12 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.h | 5 |
2 files changed, 9 insertions, 8 deletions
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp index 9a18408..3a7360d 100644 --- a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp @@ -35,13 +35,12 @@ DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name) if ( db ) { delete db; } db = new DateBookDB; - if ( m_layoutDates ) { delete m_layoutDates; } m_layoutDates = new QVBoxLayout( this ); m_layoutDates->setAutoAdd( true ); @@ -65,16 +64,12 @@ void DatebookPluginWidget::readConfig() { m_show_notes = cfg.readNumEntry( "shownotes", 0 ); m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); m_moreDays = cfg.readNumEntry( "moredays", 0 ); } void DatebookPluginWidget::refresh() { - DateBookEvent* ev; - for ( ev = m_eventsList.first(); ev != 0; ev = m_eventsList.next() ) { - delete ev; - } m_eventsList.clear(); getDates(); } /** * Get all events that are in the datebook xml file for today @@ -83,36 +78,41 @@ void DatebookPluginWidget::getDates() { QDate date = QDate::currentDate(); QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); qBubbleSort( list ); int count = 0; - qDebug( QString("List count %1" ).arg(list.count() ) ); 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() ) { count++; // show only later appointments 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 & ) ) ); } } } 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 8380bc7..e10f059 100644 --- a/core/pim/today/plugins/datebook/datebookpluginwidget.h +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.h @@ -17,12 +17,13 @@ #ifndef DATEBOOK_PLUGIN_WIDGET_H #define DATEBOOK_PLUGIN_WIDGET_H #include <qstring.h> #include <qwidget.h> #include <qlayout.h> +#include <qguardedptr.h> #include <qlist.h> #include <qpe/datebookdb.h> #include <opie/oclickablelabel.h> #include "datebookevent.h" @@ -35,14 +36,14 @@ public: DatebookPluginWidget( QWidget *parent, const char *name ); ~DatebookPluginWidget(); void refresh(); private: DateBookDB* db; - QVBoxLayout* m_layoutDates; - QList<DateBookEvent> m_eventsList; + 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; |