summaryrefslogtreecommitdiff
path: root/core/pim/today/plugins/datebook
authorharlekin <harlekin>2003-02-10 21:28:14 (UTC)
committer harlekin <harlekin>2003-02-10 21:28:14 (UTC)
commitbbb3cdf8f91d567f6c2e786bd144b64bd679ff9a (patch) (side-by-side diff)
tree9c622e670cab66c44d9bd079707945cf3c9bcb89 /core/pim/today/plugins/datebook
parentde272b8c47c3960a3fe574317fe2e6fb0c32e4af (diff)
downloadopie-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)
-rw-r--r--core/pim/today/plugins/datebook/datebookplugin.cpp14
-rw-r--r--core/pim/today/plugins/datebook/datebookplugin.h6
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginwidget.cpp53
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginwidget.h8
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
@@ -19,14 +19,15 @@
#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 {
@@ -42,7 +43,10 @@ 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;
}
QString DatebookPlugin::pixmapNameConfig() const {
@@ -60,3 +64,9 @@ QString DatebookPlugin::appName() const {
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
@@ -23,6 +23,8 @@
#include <opie/oclickablelabel.h>
#include <opie/todayplugininterface.h>
+#include "datebookpluginwidget.h"
+
class DatebookPlugin : public TodayPluginObject {
public:
@@ -37,6 +39,10 @@ public:
TodayConfigWidget* configWidget( QWidget *);
QString appName() const;
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,4 +1,4 @@
-/*
+ /*
* datebookpluginwidget.cpp
*
* copyright : (c) 2002 by Maximilian Reiß
@@ -16,7 +16,6 @@
#include "datebookpluginwidget.h"
-#include "datebookevent.h"
#include <qpe/timestring.h>
#include <qpe/config.h>
@@ -30,13 +29,28 @@
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;
}
@@ -50,36 +64,29 @@ void DatebookPluginWidget::readConfig() {
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();
@@ -87,26 +94,24 @@ void DatebookPluginWidget::getDates() {
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
@@ -19,10 +19,13 @@
#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 {
@@ -31,13 +34,16 @@ class DatebookPluginWidget : public QWidget {
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.