author | harlekin <harlekin> | 2003-02-10 21:28:14 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-02-10 21:28:14 (UTC) |
commit | bbb3cdf8f91d567f6c2e786bd144b64bd679ff9a (patch) (unidiff) | |
tree | 9c622e670cab66c44d9bd079707945cf3c9bcb89 /core/pim/today/plugins/datebook | |
parent | de272b8c47c3960a3fe574317fe2e6fb0c32e4af (diff) | |
download | opie-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)
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 | |||
@@ -10,53 +10,63 @@ | |||
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | 18 | ||
19 | 19 | ||
20 | #include "datebookevent.h" | 20 | #include "datebookevent.h" |
21 | #include "datebookplugin.h" | 21 | #include "datebookplugin.h" |
22 | #include "datebookpluginwidget.h" | ||
23 | #include "datebookpluginconfig.h" | 22 | #include "datebookpluginconfig.h" |
24 | 23 | ||
25 | 24 | ||
26 | DatebookPlugin::DatebookPlugin() { | 25 | DatebookPlugin::DatebookPlugin() { |
26 | m_widget = 0; | ||
27 | } | 27 | } |
28 | 28 | ||
29 | DatebookPlugin::~DatebookPlugin() { | 29 | DatebookPlugin::~DatebookPlugin() { |
30 | delete m_widget; | ||
30 | } | 31 | } |
31 | 32 | ||
32 | QString DatebookPlugin::pluginName() const { | 33 | QString DatebookPlugin::pluginName() const { |
33 | return QObject::tr( "Datebook plugin"); | 34 | return QObject::tr( "Datebook plugin"); |
34 | } | 35 | } |
35 | 36 | ||
36 | double DatebookPlugin::versionNumber() const { | 37 | double DatebookPlugin::versionNumber() const { |
37 | return 1.0; | 38 | return 1.0; |
38 | } | 39 | } |
39 | 40 | ||
40 | QString DatebookPlugin::pixmapNameWidget() const { | 41 | QString DatebookPlugin::pixmapNameWidget() const { |
41 | return "DateBook"; | 42 | return "DateBook"; |
42 | } | 43 | } |
43 | 44 | ||
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 | } |
47 | 51 | ||
48 | QString DatebookPlugin::pixmapNameConfig() const { | 52 | QString DatebookPlugin::pixmapNameConfig() const { |
49 | return "DateBook"; | 53 | return "DateBook"; |
50 | } | 54 | } |
51 | 55 | ||
52 | TodayConfigWidget* DatebookPlugin::configWidget( QWidget* wid ) { | 56 | TodayConfigWidget* DatebookPlugin::configWidget( QWidget* wid ) { |
53 | return new DatebookPluginConfig( wid , "Datebook" ); | 57 | return new DatebookPluginConfig( wid , "Datebook" ); |
54 | } | 58 | } |
55 | 59 | ||
56 | QString DatebookPlugin::appName() const { | 60 | QString DatebookPlugin::appName() const { |
57 | return "datebook"; | 61 | return "datebook"; |
58 | } | 62 | } |
59 | 63 | ||
60 | bool DatebookPlugin::excludeFromRefresh() const { | 64 | bool DatebookPlugin::excludeFromRefresh() const { |
61 | return false; | 65 | return false; |
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 | |||
@@ -14,30 +14,36 @@ | |||
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #ifndef DATEBOOK_PLUGIN_H | 17 | #ifndef DATEBOOK_PLUGIN_H |
18 | #define DATEBOOK_PLUGIN_H | 18 | #define DATEBOOK_PLUGIN_H |
19 | 19 | ||
20 | #include <qstring.h> | 20 | #include <qstring.h> |
21 | #include <qwidget.h> | 21 | #include <qwidget.h> |
22 | 22 | ||
23 | #include <opie/oclickablelabel.h> | 23 | #include <opie/oclickablelabel.h> |
24 | #include <opie/todayplugininterface.h> | 24 | #include <opie/todayplugininterface.h> |
25 | 25 | ||
26 | #include "datebookpluginwidget.h" | ||
27 | |||
26 | class DatebookPlugin : public TodayPluginObject { | 28 | class DatebookPlugin : public TodayPluginObject { |
27 | 29 | ||
28 | public: | 30 | public: |
29 | DatebookPlugin(); | 31 | DatebookPlugin(); |
30 | ~DatebookPlugin(); | 32 | ~DatebookPlugin(); |
31 | 33 | ||
32 | QString pluginName() const; | 34 | QString pluginName() const; |
33 | double versionNumber() const; | 35 | double versionNumber() const; |
34 | QString pixmapNameWidget() const; | 36 | QString pixmapNameWidget() const; |
35 | QWidget* widget( QWidget *); | 37 | QWidget* widget( QWidget *); |
36 | QString pixmapNameConfig() const; | 38 | QString pixmapNameConfig() const; |
37 | TodayConfigWidget* configWidget( QWidget *); | 39 | TodayConfigWidget* configWidget( QWidget *); |
38 | QString appName() const; | 40 | QString appName() const; |
39 | bool excludeFromRefresh() const; | 41 | bool excludeFromRefresh() const; |
42 | void refresh(); | ||
43 | |||
44 | private: | ||
45 | DatebookPluginWidget *m_widget; | ||
40 | }; | 46 | }; |
41 | 47 | ||
42 | 48 | ||
43 | #endif | 49 | #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 @@ | |||
1 | /* | 1 | /* |
2 | * datebookpluginwidget.cpp | 2 | * datebookpluginwidget.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002 by Maximilian Reiß | 4 | * copyright : (c) 2002 by Maximilian Reiß |
5 | * email : harlekin@handhelds.org | 5 | * email : harlekin@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | 17 | ||
18 | #include "datebookpluginwidget.h" | 18 | #include "datebookpluginwidget.h" |
19 | #include "datebookevent.h" | ||
20 | 19 | ||
21 | #include <qpe/timestring.h> | 20 | #include <qpe/timestring.h> |
22 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
23 | 22 | ||
24 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
25 | #include <qlabel.h> | 24 | #include <qlabel.h> |
26 | #include <qlayout.h> | 25 | #include <qlayout.h> |
27 | #include <qtl.h> | 26 | #include <qtl.h> |
28 | #include <qscrollview.h> | 27 | #include <qscrollview.h> |
29 | #include <qtimer.h> | 28 | #include <qtimer.h> |
30 | 29 | ||
31 | DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name) | 30 | 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(); |
35 | getDates(); | 48 | getDates(); |
36 | } | 49 | } |
37 | 50 | ||
38 | DatebookPluginWidget::~DatebookPluginWidget() { | 51 | DatebookPluginWidget::~DatebookPluginWidget() { |
39 | delete db; | 52 | delete db; |
53 | delete m_layoutDates; | ||
40 | } | 54 | } |
41 | 55 | ||
42 | 56 | ||
43 | void DatebookPluginWidget::readConfig() { | 57 | void DatebookPluginWidget::readConfig() { |
44 | Config cfg( "todaydatebookplugin" ); | 58 | Config cfg( "todaydatebookplugin" ); |
45 | cfg.setGroup( "config" ); | 59 | cfg.setGroup( "config" ); |
46 | m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); | 60 | m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); |
47 | m_show_location = cfg.readNumEntry( "showlocation", 1 ); | 61 | m_show_location = cfg.readNumEntry( "showlocation", 1 ); |
48 | m_show_notes = cfg.readNumEntry( "shownotes", 0 ); | 62 | m_show_notes = cfg.readNumEntry( "shownotes", 0 ); |
49 | m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); | 63 | m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); |
50 | m_moreDays = cfg.readNumEntry( "moredays", 0 ); | 64 | m_moreDays = cfg.readNumEntry( "moredays", 0 ); |
51 | } | 65 | } |
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 | ||
54 | /** | 75 | /** |
55 | * Get all events that are in the datebook xml file for today | 76 | * Get all events that are in the datebook xml file for today |
56 | */ | 77 | */ |
57 | void DatebookPluginWidget::getDates() { | 78 | 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; |
79 | 86 | ||
80 | if ( list.count() > 0 ) { | 87 | if ( list.count() > 0 ) { |
81 | 88 | ||
82 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { | 89 | for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { |
83 | 90 | ||
84 | if ( count <= m_max_lines_meet ) { | 91 | if ( count <= m_max_lines_meet ) { |
85 | QTime time = QTime::currentTime(); | 92 | QTime time = QTime::currentTime(); |
86 | 93 | ||
87 | if ( !m_onlyLater ) { | 94 | if ( !m_onlyLater ) { |
88 | count++; | 95 | count++; |
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 & ) ) ); |
92 | } else if ( ( time.toString() <= TimeString::dateString( (*it).event().end() ) ) ) { | 99 | } else if ( ( time.toString() <= TimeString::dateString( (*it).event().end() ) ) ) { |
93 | count++; | 100 | count++; |
94 | // show only later appointments | 101 | // show only later appointments |
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 & ) ) ); |
98 | } | 105 | } |
99 | } | 106 | } |
100 | } | 107 | } |
101 | if ( m_onlyLater && count == 0 ) { | 108 | if ( m_onlyLater && count == 0 ) { |
102 | QLabel* noMoreEvents = new QLabel( this ); | 109 | QLabel* noMoreEvents = new QLabel( this ); |
103 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); | 110 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); |
104 | layoutDates->addWidget( noMoreEvents ); | ||
105 | } | 111 | } |
106 | } else { | 112 | } else { |
107 | QLabel* noEvents = new QLabel( this ); | 113 | QLabel* noEvents = new QLabel( this ); |
108 | noEvents->setText( QObject::tr( "No appointments today" ) ); | 114 | noEvents->setText( QObject::tr( "No appointments today" ) ); |
109 | layoutDates->addWidget( noEvents ); | ||
110 | } | 115 | } |
111 | } | 116 | } |
112 | 117 | ||
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 | |||
@@ -10,43 +10,49 @@ | |||
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #ifndef DATEBOOK_PLUGIN_WIDGET_H | 17 | #ifndef DATEBOOK_PLUGIN_WIDGET_H |
18 | #define DATEBOOK_PLUGIN_WIDGET_H | 18 | #define DATEBOOK_PLUGIN_WIDGET_H |
19 | 19 | ||
20 | #include <qstring.h> | 20 | #include <qstring.h> |
21 | #include <qwidget.h> | 21 | #include <qwidget.h> |
22 | #include <qlayout.h> | ||
23 | #include <qlist.h> | ||
22 | 24 | ||
23 | #include <qpe/datebookdb.h> | 25 | #include <qpe/datebookdb.h> |
24 | #include <opie/oclickablelabel.h> | 26 | #include <opie/oclickablelabel.h> |
25 | 27 | ||
28 | #include "datebookevent.h" | ||
26 | 29 | ||
27 | class DatebookPluginWidget : public QWidget { | 30 | class DatebookPluginWidget : public QWidget { |
28 | 31 | ||
29 | Q_OBJECT | 32 | Q_OBJECT |
30 | 33 | ||
31 | public: | 34 | public: |
32 | DatebookPluginWidget( QWidget *parent, const char *name ); | 35 | DatebookPluginWidget( QWidget *parent, const char *name ); |
33 | ~DatebookPluginWidget(); | 36 | ~DatebookPluginWidget(); |
34 | 37 | void refresh(); | |
35 | 38 | ||
36 | private: | 39 | private: |
37 | DateBookDB* db; | 40 | DateBookDB* db; |
41 | QVBoxLayout* m_layoutDates; | ||
42 | QList<DateBookEvent> m_eventsList; | ||
38 | void readConfig(); | 43 | void readConfig(); |
39 | void getDates(); | 44 | void getDates(); |
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 |
42 | int m_max_lines_meet; | 48 | int m_max_lines_meet; |
43 | // If location is to be showed too, 1 to activate it. | 49 | // If location is to be showed too, 1 to activate it. |
44 | bool m_show_location; | 50 | bool m_show_location; |
45 | // if notes should be shown | 51 | // if notes should be shown |
46 | bool m_show_notes; | 52 | bool m_show_notes; |
47 | // should only later appointments be shown or all for the current day. | 53 | // should only later appointments be shown or all for the current day. |
48 | bool m_onlyLater; | 54 | bool m_onlyLater; |
49 | int m_moreDays; | 55 | int m_moreDays; |
50 | 56 | ||
51 | }; | 57 | }; |
52 | 58 | ||