-rw-r--r-- | core/pim/today/TODO | 2 | ||||
-rw-r--r-- | core/pim/today/changelog | 1 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookplugin.cpp | 14 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookplugin.h | 6 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.cpp | 53 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.h | 8 | ||||
-rw-r--r-- | core/pim/today/plugins/mail/mailplugin.cpp | 17 | ||||
-rw-r--r-- | core/pim/today/plugins/mail/mailplugin.h | 6 | ||||
-rw-r--r-- | core/pim/today/plugins/mail/mailpluginwidget.cpp | 33 | ||||
-rw-r--r-- | core/pim/today/plugins/mail/mailpluginwidget.h | 6 | ||||
-rw-r--r-- | core/pim/today/plugins/todolist/todoplugin.cpp | 16 | ||||
-rw-r--r-- | core/pim/today/plugins/todolist/todoplugin.h | 8 | ||||
-rw-r--r-- | core/pim/today/plugins/todolist/todopluginwidget.cpp | 34 | ||||
-rw-r--r-- | core/pim/today/plugins/todolist/todopluginwidget.h | 4 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 42 |
15 files changed, 174 insertions, 76 deletions
diff --git a/core/pim/today/TODO b/core/pim/today/TODO index 4dc22aa..04354e7 100644 --- a/core/pim/today/TODO +++ b/core/pim/today/TODO @@ -1,13 +1,11 @@ TODO for today: - retail rom mail plugin (z) - autostart on retail rom (Z) -* show "upcoming appointents the next days - * show alarm icons on alarm events (partly done) * qcop integration for updating events? diff --git a/core/pim/today/changelog b/core/pim/today/changelog index ea618c8..500090d 100644 --- a/core/pim/today/changelog +++ b/core/pim/today/changelog @@ -1,35 +1,36 @@ 0.6.1 * datebook plugin now can now also show following days ++ changed refresh * fixed one mem leak 0.6 * longer refresh intervals possible * plugins can decide now if they want to take part in refresh cycles 0.5.2 * refresh settings * only launch datebook config when clicked on a date ( opie only ) * less qcop trouble on sharps retail rom 0.5.1 * icons scalable and clickable again 0.5 * now fully plugin based 0.3.4 * "fill our business card now a clickable label" * Several bugfixes regarding todo section. 0.3.3 * Changed the logo so it better scales to bigger display and also made the "Today" string translatable. * some am/pm fixes * clickable labels now in libopie 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 @@ -1,62 +1,72 @@ /* * datebookplugin.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 "datebookevent.h" #include "datebookplugin.h" -#include "datebookpluginwidget.h" #include "datebookpluginconfig.h" DatebookPlugin::DatebookPlugin() { + m_widget = 0; } DatebookPlugin::~DatebookPlugin() { + delete m_widget; } QString DatebookPlugin::pluginName() const { return QObject::tr( "Datebook plugin"); } double DatebookPlugin::versionNumber() const { return 1.0; } QString DatebookPlugin::pixmapNameWidget() const { return "DateBook"; } QWidget* DatebookPlugin::widget( QWidget* wid ) { - return new DatebookPluginWidget( wid, "Datebook" ); + if(!m_widget) { + m_widget = new DatebookPluginWidget( wid, "Datebook" ); + } + return m_widget; } QString DatebookPlugin::pixmapNameConfig() const { return "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(); + } +} 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 @@ -1,43 +1,49 @@ /* * datebookplugin.h * * 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. * * * ***************************************************************************/ #ifndef DATEBOOK_PLUGIN_H #define DATEBOOK_PLUGIN_H #include <qstring.h> #include <qwidget.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(); + + private: + DatebookPluginWidget *m_widget; }; #endif 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,112 +1,117 @@ -/* + /* * 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; + 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(); getDates(); } 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 ); } +void DatebookPluginWidget::refresh() { + DateBookEvent* ev; + for ( ev = m_eventsList.first(); ev != 0; ev = m_eventsList.next() ) { + delete ev; + } + getDates(); +} /** * Get all events that are in the datebook xml file for today */ 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; if ( list.count() > 0 ) { - for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { + 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 &) ) ); + 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() ) ) ) { 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 &) ) ); + m_eventsList.append( 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 ); } } 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 @@ -1,53 +1,59 @@ /* * datebookpluginwidget.h * * 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. * * * ***************************************************************************/ #ifndef DATEBOOK_PLUGIN_WIDGET_H #define DATEBOOK_PLUGIN_WIDGET_H #include <qstring.h> #include <qwidget.h> +#include <qlayout.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(); private: DateBookDB* db; + QVBoxLayout* m_layoutDates; + QList<DateBookEvent> 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; }; #endif diff --git a/core/pim/today/plugins/mail/mailplugin.cpp b/core/pim/today/plugins/mail/mailplugin.cpp index d497970..a37d506 100644 --- a/core/pim/today/plugins/mail/mailplugin.cpp +++ b/core/pim/today/plugins/mail/mailplugin.cpp @@ -1,60 +1,69 @@ /* * mailplugin.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 "mailplugin.h" -#include "mailpluginwidget.h" - MailPlugin::MailPlugin() { + m_widget = 0l; } MailPlugin::~MailPlugin() { + delete m_widget; } QString MailPlugin::pluginName() const { return QObject::tr( "Mail plugin" ); } double MailPlugin::versionNumber() const { return 0.6; } QString MailPlugin::pixmapNameWidget() const { return "mail/desktopicon"; } QWidget* MailPlugin::widget( QWidget * wid ) { - return new MailPluginWidget( wid, "Mail" ); + if(!m_widget) { + m_widget = new MailPluginWidget( wid, "Datebook" ); + } + return m_widget; } + QString MailPlugin::pixmapNameConfig() const { return 0l; } -TodayConfigWidget* MailPlugin::configWidget( QWidget* wid ) { +TodayConfigWidget* MailPlugin::configWidget( QWidget* ) { return 0l; } QString MailPlugin::appName() const { return "mail"; } bool MailPlugin::excludeFromRefresh() const { return false; } +void MailPlugin::refresh() { + if ( m_widget ) { + m_widget->refresh(); + } +} diff --git a/core/pim/today/plugins/mail/mailplugin.h b/core/pim/today/plugins/mail/mailplugin.h index c937b9e..67fac0c 100644 --- a/core/pim/today/plugins/mail/mailplugin.h +++ b/core/pim/today/plugins/mail/mailplugin.h @@ -1,46 +1,52 @@ /* * mailplugin.h * * 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. * * * ***************************************************************************/ #ifndef MAIL_PLUGIN_H #define MAIL_PLUGIN_H #include <qstring.h> #include <qwidget.h> #include <opie/tododb.h> #include <opie/oclickablelabel.h> #include <opie/todayplugininterface.h> #include <opie/todayconfigwidget.h> +#include "mailpluginwidget.h" + class MailPlugin : public TodayPluginObject { public: MailPlugin(); ~MailPlugin(); 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(); + + private: + MailPluginWidget *m_widget; }; #endif diff --git a/core/pim/today/plugins/mail/mailpluginwidget.cpp b/core/pim/today/plugins/mail/mailpluginwidget.cpp index a6f3562..aad1d07 100644 --- a/core/pim/today/plugins/mail/mailpluginwidget.cpp +++ b/core/pim/today/plugins/mail/mailpluginwidget.cpp @@ -1,73 +1,88 @@ /* * mailpluginwidget.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 <qvaluelist.h> #include <qtl.h> #include <qstring.h> #include <qobject.h> #include <qlayout.h> #include <qpe/config.h> #include <qpe/timestring.h> #include <qpe/qcopenvelope_qws.h> #include "mailpluginwidget.h" MailPluginWidget::MailPluginWidget( QWidget *parent, const char* name) : QWidget(parent, name ) { + m_mailLabel = 0l; + m_layout = 0l; + + if ( m_mailLabel ) { + delete m_mailLabel; + } + m_mailLabel = new OClickableLabel( this ); + m_mailLabel->setMaximumHeight( 15 ); + connect( m_mailLabel, SIGNAL( clicked() ), this, SLOT( startMail() ) ); + + if ( m_layout ) { + delete m_layout; + } + m_layout = new QHBoxLayout( this ); + m_layout->setAutoAdd( true ); + readConfig(); getInfo(); } MailPluginWidget::~MailPluginWidget() { + delete m_mailLabel; + delete m_layout; } void MailPluginWidget::readConfig() { Config cfg( "todaymailplugin" ); cfg.setGroup( "config" ); } -void MailPluginWidget::getInfo() { - - QHBoxLayout* layout = new QHBoxLayout( this ); +void MailPluginWidget::refresh() { + getInfo(); +} - mailLabel = new OClickableLabel( this ); - mailLabel->setMaximumHeight( 15 ); - connect( mailLabel, SIGNAL( clicked() ), this, SLOT( startMail() ) ); +void MailPluginWidget::getInfo() { Config cfg( "opiemail" ); cfg.setGroup( "today" ); int NEW_MAILS = cfg.readNumEntry( "newmails", 0 ); int OUTGOING = cfg.readNumEntry( "outgoing", 0 ); - QString output = QObject::tr( "<b>%1</b> new mail(s), <b>%2</b> outgoing" ).arg( NEW_MAILS ).arg( OUTGOING ); + //QString output = QObject::tr( "<b>%1</b> new mail(s), <b>%2</b> outgoing" ).arg( NEW_MAILS ).arg( OUTGOING ); - mailLabel->setText( output ); - layout->addWidget( mailLabel ); + m_mailLabel->setText( QObject::tr( "<b>%1</b> new mail(s), <b>%2</b> outgoing" ).arg( NEW_MAILS ).arg( OUTGOING ) ); } /** * launches datebook */ void MailPluginWidget::startMail() { QCopEnvelope e("QPE/System", "execute(QString)"); e << QString( "mail" ); } diff --git a/core/pim/today/plugins/mail/mailpluginwidget.h b/core/pim/today/plugins/mail/mailpluginwidget.h index 2feef80..c678833 100644 --- a/core/pim/today/plugins/mail/mailpluginwidget.h +++ b/core/pim/today/plugins/mail/mailpluginwidget.h @@ -1,45 +1,49 @@ /* * mailpluginwidget.h * * 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. * * * ***************************************************************************/ #ifndef MAIL_PLUGIN_WIDGET_H #define MAIL_PLUGIN_WIDGET_H #include <qstring.h> #include <qwidget.h> +#include <qlayout.h> #include <opie/tododb.h> #include <opie/oclickablelabel.h> class MailPluginWidget : public QWidget { Q_OBJECT public: MailPluginWidget( QWidget *parent, const char *name ); ~MailPluginWidget(); + + void refresh(); protected slots: void startMail(); private: - OClickableLabel *mailLabel; + OClickableLabel* m_mailLabel; + QHBoxLayout* m_layout; void readConfig(); void getInfo(); }; #endif diff --git a/core/pim/today/plugins/todolist/todoplugin.cpp b/core/pim/today/plugins/todolist/todoplugin.cpp index b5abbd3..1238f92 100644 --- a/core/pim/today/plugins/todolist/todoplugin.cpp +++ b/core/pim/today/plugins/todolist/todoplugin.cpp @@ -1,61 +1,71 @@ /* * todoplugin.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 "todoplugin.h" #include "todopluginconfig.h" -#include "todopluginwidget.h" TodolistPlugin::TodolistPlugin() { + m_widget = 0l; } TodolistPlugin::~TodolistPlugin() { + delete m_widget; } QString TodolistPlugin::pluginName() const { return QObject::tr( "Todolist plugin" ); } double TodolistPlugin::versionNumber() const { - return 0.8; + return 0.9; } QString TodolistPlugin::pixmapNameWidget() const { return "TodoList"; } QWidget* TodolistPlugin::widget( QWidget *wid ) { - return new TodolistPluginWidget( wid, "Todolist" ); + if(!m_widget) { + m_widget = new TodolistPluginWidget( wid, "Todolist" ); + } + return m_widget; } QString TodolistPlugin::pixmapNameConfig() const { return "TodoList"; } TodayConfigWidget* TodolistPlugin::configWidget( QWidget* wid ) { return new TodolistPluginConfig( wid , "Todolist" ); } QString TodolistPlugin::appName() const { return "todolist"; } bool TodolistPlugin::excludeFromRefresh() const { return false; } + +void TodolistPlugin::refresh() { + if ( m_widget ) { + m_widget->refresh(); + } +} diff --git a/core/pim/today/plugins/todolist/todoplugin.h b/core/pim/today/plugins/todolist/todoplugin.h index f98afdb..6106d0c 100644 --- a/core/pim/today/plugins/todolist/todoplugin.h +++ b/core/pim/today/plugins/todolist/todoplugin.h @@ -1,43 +1,49 @@ /* * todoplugin.h * * 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. * * * ***************************************************************************/ #ifndef TODOLIST_PLUGIN_H #define TODOLIST_PLUGIN_H #include <qstring.h> #include <qwidget.h> #include <opie/tododb.h> #include <opie/oclickablelabel.h> #include <opie/todayplugininterface.h> +#include "todopluginwidget.h" + class TodolistPlugin : public TodayPluginObject { public: TodolistPlugin(); ~TodolistPlugin(); - + 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(); + + private: + TodolistPluginWidget *m_widget; }; #endif diff --git a/core/pim/today/plugins/todolist/todopluginwidget.cpp b/core/pim/today/plugins/todolist/todopluginwidget.cpp index 773e5cf..3242dac 100644 --- a/core/pim/today/plugins/todolist/todopluginwidget.cpp +++ b/core/pim/today/plugins/todolist/todopluginwidget.cpp @@ -1,130 +1,140 @@ /* * todopluginwidget.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 "todopluginwidget.h" #include <qvaluelist.h> #include <qtl.h> #include <qstring.h> #include <qscrollview.h> #include <qobject.h> #include <qlayout.h> #include <qpe/config.h> #include <qpe/timestring.h> #include <qpe/qcopenvelope_qws.h> TodolistPluginWidget::TodolistPluginWidget( QWidget *parent, const char* name ) : QWidget( parent, name ) { - todoLabel = 0l; todo = 0l; + layoutTodo = 0l; + todoLabel = 0l; if ( todo ) { delete todo; } - todo = new OTodoAccess(); todo->load(); + if ( layoutTodo ) { + delete layoutTodo; + } + layoutTodo = new QVBoxLayout( this ); + layoutTodo->setAutoAdd( true ); + + + if ( todoLabel ) { + delete todoLabel; + } + todoLabel = new OClickableLabel( this ); + + connect( todoLabel, SIGNAL( clicked() ), this, SLOT( startTodolist() ) ); + readConfig(); getTodo(); } TodolistPluginWidget::~TodolistPluginWidget() { delete todo; + delete todoLabel; + delete layoutTodo; } void TodolistPluginWidget::readConfig() { Config cfg( "todaytodoplugin" ); cfg.setGroup( "config" ); m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); } +void TodolistPluginWidget:: refresh() { + getTodo(); +} /** * Get the todos */ void TodolistPluginWidget::getTodo() { - QVBoxLayout* layoutTodo = new QVBoxLayout( this ); - - if ( todoLabel ) { - delete todoLabel; - } - - todoLabel = new OClickableLabel( this ); - connect( todoLabel, SIGNAL( clicked() ), this, SLOT( startTodolist() ) ); QString output; QString tmpout; int count = 0; int ammount = 0; // get overdue todos first m_list = todo->overDue(); for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { if (!(*m_it).isCompleted() && ( ammount < m_maxLinesTask ) ) { QString desc = (*m_it).summary(); if( desc.isEmpty() ) { desc = (*m_it).description(); } tmpout += "<font color=#e00000><b>-" + desc.mid( 0, m_maxCharClip ) + "</b></font><br>"; - ammount++; + ammount++ ; } } // get total number of still open todos m_list = todo->sorted( true, 1, 4, 1); for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { count +=1; // not the overdues, we allready got them, and not if we are // over the maxlines if ( !(*m_it).isOverdue() && ( ammount < m_maxLinesTask ) ) { QString desc = (*m_it).summary(); if( desc.isEmpty() ) { desc = (*m_it).description(); } tmpout += "<b>-</b>" + desc.mid( 0, m_maxCharClip ) + "<br>"; ammount++; } } if ( count > 0 ) { if( count == 1 ) { output += QObject::tr( "There is <b> 1</b> active task: <br>" ); } else { output += QObject::tr( "There are <b> %1</b> active tasks: <br>" ).arg( count ); } output += tmpout; } else { output = QObject::tr( "No active tasks" ); } todoLabel->setText( output ); - layoutTodo->addWidget( todoLabel ); } /** * start the todolist */ void TodolistPluginWidget::startTodolist() { QCopEnvelope e( "QPE/System", "execute(QString)" ); e << QString( "todolist" ); } diff --git a/core/pim/today/plugins/todolist/todopluginwidget.h b/core/pim/today/plugins/todolist/todopluginwidget.h index 37b0ee1..0d0deb5 100644 --- a/core/pim/today/plugins/todolist/todopluginwidget.h +++ b/core/pim/today/plugins/todolist/todopluginwidget.h @@ -1,52 +1,56 @@ /* * todopluginwidget.h * * 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. * * * ***************************************************************************/ #ifndef TODOLIST_PLUGIN_WIDGET_H #define TODOLIST_PLUGIN_WIDGET_H #include <qstring.h> #include <qwidget.h> +#include <qlayout.h> #include <opie/otodo.h> #include <opie/otodoaccess.h> #include <opie/oclickablelabel.h> class TodolistPluginWidget : public QWidget { Q_OBJECT public: TodolistPluginWidget( QWidget *parent, const char *name ); ~TodolistPluginWidget(); + void refresh(); + protected slots: void startTodolist(); private: OClickableLabel *todoLabel; + QVBoxLayout* layoutTodo; OTodoAccess *todo; OTodoAccess::List m_list; OTodoAccess::List::Iterator m_it; void readConfig(); void getTodo(); int m_maxLinesTask; int m_maxCharClip; }; #endif diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 91028c8..1f758f2 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -41,65 +41,66 @@ struct TodayPlugin { TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} QLibrary *library; QInterfacePtr<TodayPluginInterface> iface; TodayPluginObject *guiPart; QWidget *guiBox; QString name; bool active; bool excludeRefresh; int pos; }; static QValueList<TodayPlugin> pluginList; Today::Today( QWidget* parent, const char* name, WFlags fl ) : TodayBase( parent, name, fl ) { QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); #if defined(Q_WS_QWS) #if !defined(QT_NO_COP) QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); #endif #endif setOwnerField(); m_refreshTimer = new QTimer( this ); connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); m_refreshTimer->start( 15000 ); - refresh(); + init(); + loadPlugins(); showMaximized(); } /** * Qcop receive method. */ void Today::channelReceived( const QCString &msg, const QByteArray & data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "message(QString)" ) { QString message; stream >> message; setOwnerField( message ); } } void Today::setRefreshTimer( int interval ) { disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); // 0 is "never" case if ( !interval == 0 ) { connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); m_refreshTimer->changeInterval( interval ); } } /** * Initialises the owner field with the default value, the username */ void Today::setOwnerField() { QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); @@ -107,64 +108,79 @@ void Today::setOwnerField() { Contact cont = Contact::readVCard( file )[0]; QString returnString = cont.fullName(); OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); } else { OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); } } /** * Set the owner field with a given QString, for example per qcop. */ void Today::setOwnerField( QString &message ) { if ( !message.isEmpty() ) { OwnerField->setText( "<b>" + message + "</b>" ); } } /** * Init stuff needed for today. Reads the config file. */ void Today::init() { // read config Config cfg( "today" ); cfg.setGroup( "Plugins" ); m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); m_allApplets = cfg.readListEntry( "AllApplets", ',' ); cfg.setGroup( "General" ); m_iconSize = cfg.readNumEntry( "IconSize", 18 ); setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); + + + // qDebug(" refresh "); + // set the date in top label + QDate date = QDate::currentDate(); + QString time = ( tr( date.toString() ) ); + + DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); + + if ( layout ) { + delete layout; + } + layout = new QVBoxLayout( this ); + layout->addWidget( Frame ); + layout->addWidget( OwnerField ); } /** * Load the plugins */ void Today::loadPlugins() { // extra list for plugins that exclude themself from periodic refresh QMap<QString, TodayPlugin> pluginListRefreshExclude; QValueList<TodayPlugin>::Iterator tit; if ( !pluginList.isEmpty() ) { for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { if ( (*tit).excludeRefresh ) { pluginListRefreshExclude.insert( (*tit).name , (*tit) ); qDebug( "Found a plugin that does not want refresh feature" ); } else { (*tit).guiBox->hide(); (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); (*tit).library->unload(); delete (*tit).guiBox; delete (*tit).library; } } pluginList.clear(); } QString path = QPEApplication::qpeDir() + "/plugins/today"; QDir dir( path, "lib*.so" ); QStringList list = dir.entryList(); @@ -237,64 +253,65 @@ void Today::loadPlugins() { tempList.insert( plugin.name, plugin ); // on first start the list is off course empty if ( m_allApplets.isEmpty() ) { layout->addWidget( plugin.guiBox ); pluginList.append( plugin ); } // if plugin is not yet in the list, add it to the layout too else if ( !m_allApplets.contains( plugin.name ) ) { layout->addWidget( plugin.guiBox ); pluginList.append( plugin ); } } } else { qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); delete lib; } } if ( !m_allApplets.isEmpty() ) { TodayPlugin tempPlugin; QStringList::Iterator stringit; for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { tempPlugin = ( tempList.find( *stringit ) ).data(); if ( !( (tempPlugin.name).isEmpty() ) ) { layout->addWidget( tempPlugin.guiBox ); pluginList.append( tempPlugin ); } } } + draw(); } /** * Repaint method. Reread all fields. */ void Today::draw() { if ( pluginList.count() == 0 ) { QLabel *noPlugins = new QLabel( this ); noPlugins->setText( tr( "No plugins found" ) ); layout->addWidget( noPlugins ); return; } uint count = 0; TodayPlugin plugin; for ( uint i = 0; i < pluginList.count(); i++ ) { plugin = pluginList[i]; if ( plugin.active ) { // qDebug( plugin.name + " is ACTIVE " ); plugin.guiBox->show(); } else { // qDebug( plugin.name + " is INACTIVE" ); plugin.guiBox->hide(); } count++; } if ( count == 0 ) { QLabel *noPluginsActive = new QLabel( this ); @@ -311,80 +328,71 @@ void Today::draw() { void Today::startConfig() { // disconnect timer to prevent problems while being on config dialog disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); TodayConfig conf( this, "dialog", true ); TodayPlugin plugin; QList<TodayConfigWidget> configWidgetList; for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) { plugin = pluginList[i]; // load the config widgets in the tabs if ( plugin.guiPart->configWidget( this ) != 0l ) { TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); configWidgetList.append( widget ); conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() , plugin.guiPart->appName() ); } // set the order/activate tab conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); } if ( conf.exec() == QDialog::Accepted ) { conf.writeConfig(); TodayConfigWidget *confWidget; for ( confWidget = configWidgetList.first(); confWidget != 0; confWidget = configWidgetList.next() ) { confWidget->writeConfig(); } - refresh(); + loadPlugins(); } else { // since refresh is not called in that case , reconnect the signal connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); } } /** * Refresh for the view. Reload all applets * */ void Today::refresh() { init(); - // qDebug(" refresh "); - // set the date in top label - QDate date = QDate::currentDate(); - QString time = ( tr( date.toString() ) ); - - DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); - - if ( layout ) { - delete layout; + QValueList<TodayPlugin>::Iterator it; + for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { + if ( !(*it).excludeRefresh ) { + (*it).guiPart->refresh(); + qDebug( "refresh" ); + } } - layout = new QVBoxLayout( this ); - layout->addWidget( Frame ); - layout->addWidget( OwnerField ); - - loadPlugins(); - draw(); } void Today::startApplication() { QCopEnvelope e( "QPE/System", "execute(QString)" ); e << QString( sender()->name() ); } /** * launch addressbook (personal card) */ void Today::editCard() { QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); } Today::~Today() { } |