Diffstat (limited to 'core/pim/today/plugins/datebook') (more/less context) (show whitespace changes)
4 files changed, 50 insertions, 23 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 @@ | |||
21 | #include "datebookplugin.h" | 21 | #include "datebookplugin.h" |
22 | #include "datebookpluginwidget.h" | ||
23 | #include "datebookpluginconfig.h" | 22 | #include "datebookpluginconfig.h" |
@@ -26,2 +25,3 @@ | |||
26 | DatebookPlugin::DatebookPlugin() { | 25 | DatebookPlugin::DatebookPlugin() { |
26 | m_widget = 0; | ||
27 | } | 27 | } |
@@ -29,2 +29,3 @@ DatebookPlugin::DatebookPlugin() { | |||
29 | DatebookPlugin::~DatebookPlugin() { | 29 | DatebookPlugin::~DatebookPlugin() { |
30 | delete m_widget; | ||
30 | } | 31 | } |
@@ -44,3 +45,6 @@ QString DatebookPlugin::pixmapNameWidget() const { | |||
44 | QWidget* DatebookPlugin::widget( QWidget* wid ) { | 45 | QWidget* DatebookPlugin::widget( QWidget* wid ) { |
45 | return new DatebookPluginWidget( wid, "Datebook" ); | 46 | if(!m_widget) { |
47 | m_widget = new DatebookPluginWidget( wid, "Datebook" ); | ||
48 | } | ||
49 | return m_widget; | ||
46 | } | 50 | } |
@@ -62 +66,7 @@ bool DatebookPlugin::excludeFromRefresh() const { | |||
62 | } | 66 | } |
67 | |||
68 | void DatebookPlugin::refresh() { | ||
69 | if ( m_widget ) { | ||
70 | m_widget->refresh(); | ||
71 | } | ||
72 | } | ||
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 @@ | |||
25 | 25 | ||
26 | #include "datebookpluginwidget.h" | ||
27 | |||
26 | class DatebookPlugin : public TodayPluginObject { | 28 | class DatebookPlugin : public TodayPluginObject { |
@@ -39,2 +41,6 @@ public: | |||
39 | bool excludeFromRefresh() const; | 41 | bool excludeFromRefresh() const; |
42 | void refresh(); | ||
43 | |||
44 | private: | ||
45 | DatebookPluginWidget *m_widget; | ||
40 | }; | 46 | }; |
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 | |||
@@ -18,3 +18,2 @@ | |||
18 | #include "datebookpluginwidget.h" | 18 | #include "datebookpluginwidget.h" |
19 | #include "datebookevent.h" | ||
20 | 19 | ||
@@ -32,3 +31,17 @@ DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name) | |||
32 | : QWidget(parent, name ) { | 31 | : QWidget(parent, name ) { |
32 | |||
33 | db = 0l; | 33 | db = 0l; |
34 | m_layoutDates = 0l; | ||
35 | |||
36 | if ( db ) { | ||
37 | delete db; | ||
38 | } | ||
39 | db = new DateBookDB; | ||
40 | |||
41 | if ( m_layoutDates ) { | ||
42 | delete m_layoutDates; | ||
43 | } | ||
44 | m_layoutDates = new QVBoxLayout( this ); | ||
45 | m_layoutDates->setAutoAdd( true ); | ||
46 | |||
34 | readConfig(); | 47 | readConfig(); |
@@ -39,2 +52,3 @@ DatebookPluginWidget::~DatebookPluginWidget() { | |||
39 | delete db; | 52 | delete db; |
53 | delete m_layoutDates; | ||
40 | } | 54 | } |
@@ -52,2 +66,9 @@ void DatebookPluginWidget::readConfig() { | |||
52 | 66 | ||
67 | void DatebookPluginWidget::refresh() { | ||
68 | DateBookEvent* ev; | ||
69 | for ( ev = m_eventsList.first(); ev != 0; ev = m_eventsList.next() ) { | ||
70 | delete ev; | ||
71 | } | ||
72 | getDates(); | ||
73 | } | ||
53 | 74 | ||
@@ -58,21 +79,7 @@ void DatebookPluginWidget::getDates() { | |||
58 | 79 | ||
59 | |||
60 | QDate date = QDate::currentDate(); | 80 | QDate date = QDate::currentDate(); |
61 | 81 | ||
62 | QVBoxLayout* layoutDates = new QVBoxLayout( this ); | ||
63 | layoutDates->setSpacing( 1 ); | ||
64 | layoutDates->setMargin( 1 ); | ||
65 | |||
66 | if ( db ) { | ||
67 | delete db; | ||
68 | } | ||
69 | |||
70 | db = new DateBookDB; | ||
71 | |||
72 | QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); | 82 | QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); |
73 | |||
74 | qBubbleSort( list ); | 83 | qBubbleSort( list ); |
75 | 84 | //Config config( "qpe" ); | |
76 | Config config( "qpe" ); | ||
77 | |||
78 | int count=0; | 85 | int count=0; |
@@ -89,3 +96,3 @@ void DatebookPluginWidget::getDates() { | |||
89 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); | 96 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); |
90 | layoutDates->addWidget( l ); | 97 | m_eventsList.append( l ); |
91 | QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); | 98 | QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); |
@@ -95,3 +102,3 @@ void DatebookPluginWidget::getDates() { | |||
95 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); | 102 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); |
96 | layoutDates->addWidget( l ); | 103 | m_eventsList.append( l ); |
97 | QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); | 104 | QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); |
@@ -103,3 +110,2 @@ void DatebookPluginWidget::getDates() { | |||
103 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); | 110 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); |
104 | layoutDates->addWidget( noMoreEvents ); | ||
105 | } | 111 | } |
@@ -108,3 +114,2 @@ void DatebookPluginWidget::getDates() { | |||
108 | noEvents->setText( QObject::tr( "No appointments today" ) ); | 114 | noEvents->setText( QObject::tr( "No appointments today" ) ); |
109 | layoutDates->addWidget( noEvents ); | ||
110 | } | 115 | } |
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 @@ | |||
21 | #include <qwidget.h> | 21 | #include <qwidget.h> |
22 | #include <qlayout.h> | ||
23 | #include <qlist.h> | ||
22 | 24 | ||
@@ -25,2 +27,3 @@ | |||
25 | 27 | ||
28 | #include "datebookevent.h" | ||
26 | 29 | ||
@@ -33,3 +36,3 @@ public: | |||
33 | ~DatebookPluginWidget(); | 36 | ~DatebookPluginWidget(); |
34 | 37 | void refresh(); | |
35 | 38 | ||
@@ -37,2 +40,4 @@ private: | |||
37 | DateBookDB* db; | 40 | DateBookDB* db; |
41 | QVBoxLayout* m_layoutDates; | ||
42 | QList<DateBookEvent> m_eventsList; | ||
38 | void readConfig(); | 43 | void readConfig(); |
@@ -40,2 +45,3 @@ private: | |||
40 | 45 | ||
46 | |||
41 | // how many lines should be showed in the datebook section | 47 | // how many lines should be showed in the datebook section |