summaryrefslogtreecommitdiff
path: root/core/pim/today/plugins/datebook
Side-by-side diff
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
@@ -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