-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.cpp | 12 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.h | 5 |
2 files changed, 9 insertions, 8 deletions
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp index 9a18408..3a7360d 100644 --- a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp | |||
@@ -9,110 +9,110 @@ | |||
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 | 19 | ||
20 | #include <qpe/timestring.h> | 20 | #include <qpe/timestring.h> |
21 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
22 | 22 | ||
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qtl.h> | 26 | #include <qtl.h> |
27 | #include <qscrollview.h> | 27 | #include <qscrollview.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | 29 | ||
30 | DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name) | 30 | DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name) |
31 | : QWidget(parent, name ) { | 31 | : QWidget(parent, name ) { |
32 | 32 | ||
33 | db = 0l; | 33 | db = 0l; |
34 | m_layoutDates = 0l; | 34 | m_layoutDates = 0l; |
35 | 35 | ||
36 | if ( db ) { | 36 | if ( db ) { |
37 | delete db; | 37 | delete db; |
38 | } | 38 | } |
39 | db = new DateBookDB; | 39 | db = new DateBookDB; |
40 | 40 | ||
41 | |||
42 | if ( m_layoutDates ) { | 41 | if ( m_layoutDates ) { |
43 | delete m_layoutDates; | 42 | delete m_layoutDates; |
44 | } | 43 | } |
45 | m_layoutDates = new QVBoxLayout( this ); | 44 | m_layoutDates = new QVBoxLayout( this ); |
46 | m_layoutDates->setAutoAdd( true ); | 45 | m_layoutDates->setAutoAdd( true ); |
47 | 46 | ||
48 | m_eventsList.setAutoDelete( true ); | 47 | m_eventsList.setAutoDelete( true ); |
49 | 48 | ||
50 | readConfig(); | 49 | readConfig(); |
51 | getDates(); | 50 | getDates(); |
52 | } | 51 | } |
53 | 52 | ||
54 | DatebookPluginWidget::~DatebookPluginWidget() { | 53 | DatebookPluginWidget::~DatebookPluginWidget() { |
55 | delete db; | 54 | delete db; |
56 | delete m_layoutDates; | 55 | delete m_layoutDates; |
57 | } | 56 | } |
58 | 57 | ||
59 | 58 | ||
60 | void DatebookPluginWidget::readConfig() { | 59 | void DatebookPluginWidget::readConfig() { |
61 | Config cfg( "todaydatebookplugin" ); | 60 | Config cfg( "todaydatebookplugin" ); |
62 | cfg.setGroup( "config" ); | 61 | cfg.setGroup( "config" ); |
63 | m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); | 62 | m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); |
64 | m_show_location = cfg.readNumEntry( "showlocation", 1 ); | 63 | m_show_location = cfg.readNumEntry( "showlocation", 1 ); |
65 | m_show_notes = cfg.readNumEntry( "shownotes", 0 ); | 64 | m_show_notes = cfg.readNumEntry( "shownotes", 0 ); |
66 | m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); | 65 | m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); |
67 | m_moreDays = cfg.readNumEntry( "moredays", 0 ); | 66 | m_moreDays = cfg.readNumEntry( "moredays", 0 ); |
68 | } | 67 | } |
69 | 68 | ||
70 | void DatebookPluginWidget::refresh() { | 69 | void DatebookPluginWidget::refresh() { |
71 | DateBookEvent* ev; | ||
72 | for ( ev = m_eventsList.first(); ev != 0; ev = m_eventsList.next() ) { | ||
73 | delete ev; | ||
74 | } | ||
75 | m_eventsList.clear(); | 70 | m_eventsList.clear(); |
76 | getDates(); | 71 | getDates(); |
77 | } | 72 | } |
78 | 73 | ||
79 | /** | 74 | /** |
80 | * Get all events that are in the datebook xml file for today | 75 | * Get all events that are in the datebook xml file for today |
81 | */ | 76 | */ |
82 | void DatebookPluginWidget::getDates() { | 77 | void DatebookPluginWidget::getDates() { |
83 | 78 | ||
84 | QDate date = QDate::currentDate(); | 79 | QDate date = QDate::currentDate(); |
85 | QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); | 80 | QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); |
86 | qBubbleSort( list ); | 81 | qBubbleSort( list ); |
87 | int count = 0; | 82 | int count = 0; |
88 | 83 | ||
89 | qDebug( QString("List count %1" ).arg(list.count() ) ); | ||
90 | if ( list.count() > 0 ) { | 84 | if ( list.count() > 0 ) { |
91 | 85 | ||
92 | for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { | 86 | for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { |
93 | 87 | ||
94 | if ( count <= m_max_lines_meet ) { | 88 | if ( count <= m_max_lines_meet ) { |
95 | if ( !m_onlyLater ) { | 89 | if ( !m_onlyLater ) { |
96 | count++; | 90 | count++; |
97 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); | 91 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); |
98 | m_eventsList.append( l ); | 92 | m_eventsList.append( l ); |
93 | l->show(); | ||
99 | QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); | 94 | QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); |
100 | } else if ( QDateTime::currentDateTime() <= (*it).event().end() ) { | 95 | } else if ( QDateTime::currentDateTime() <= (*it).event().end() ) { |
101 | count++; | 96 | count++; |
102 | // show only later appointments | 97 | // show only later appointments |
103 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); | 98 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); |
104 | m_eventsList.append( l ); | 99 | m_eventsList.append( l ); |
100 | l->show(); | ||
105 | QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); | 101 | QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); |
106 | } | 102 | } |
107 | } | 103 | } |
108 | } | 104 | } |
109 | if ( m_onlyLater && count == 0 ) { | 105 | if ( m_onlyLater && count == 0 ) { |
110 | QLabel* noMoreEvents = new QLabel( this ); | 106 | QLabel* noMoreEvents = new QLabel( this ); |
107 | m_eventsList.append( noMoreEvents ); | ||
108 | noMoreEvents->show(); | ||
111 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); | 109 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); |
112 | } | 110 | } |
113 | } else { | 111 | } else { |
114 | QLabel* noEvents = new QLabel( this ); | 112 | QLabel* noEvents = new QLabel( this ); |
113 | m_eventsList.append( noEvents ); | ||
114 | noEvents->show(); | ||
115 | noEvents->setText( QObject::tr( "No appointments today" ) ); | 115 | noEvents->setText( QObject::tr( "No appointments today" ) ); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.h b/core/pim/today/plugins/datebook/datebookpluginwidget.h index 8380bc7..e10f059 100644 --- a/core/pim/today/plugins/datebook/datebookpluginwidget.h +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.h | |||
@@ -1,59 +1,60 @@ | |||
1 | /* | 1 | /* |
2 | * datebookpluginwidget.h | 2 | * datebookpluginwidget.h |
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 | #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> | 22 | #include <qlayout.h> |
23 | #include <qguardedptr.h> | ||
23 | #include <qlist.h> | 24 | #include <qlist.h> |
24 | 25 | ||
25 | #include <qpe/datebookdb.h> | 26 | #include <qpe/datebookdb.h> |
26 | #include <opie/oclickablelabel.h> | 27 | #include <opie/oclickablelabel.h> |
27 | 28 | ||
28 | #include "datebookevent.h" | 29 | #include "datebookevent.h" |
29 | 30 | ||
30 | class DatebookPluginWidget : public QWidget { | 31 | class DatebookPluginWidget : public QWidget { |
31 | 32 | ||
32 | Q_OBJECT | 33 | Q_OBJECT |
33 | 34 | ||
34 | public: | 35 | public: |
35 | DatebookPluginWidget( QWidget *parent, const char *name ); | 36 | DatebookPluginWidget( QWidget *parent, const char *name ); |
36 | ~DatebookPluginWidget(); | 37 | ~DatebookPluginWidget(); |
37 | void refresh(); | 38 | void refresh(); |
38 | 39 | ||
39 | private: | 40 | private: |
40 | DateBookDB* db; | 41 | DateBookDB* db; |
41 | QVBoxLayout* m_layoutDates; | 42 | QGuardedPtr<QVBoxLayout> m_layoutDates; |
42 | QList<DateBookEvent> m_eventsList; | 43 | QList<QWidget> m_eventsList; |
43 | void readConfig(); | 44 | void readConfig(); |
44 | void getDates(); | 45 | void getDates(); |
45 | 46 | ||
46 | 47 | ||
47 | // how many lines should be showed in the datebook section | 48 | // how many lines should be showed in the datebook section |
48 | int m_max_lines_meet; | 49 | int m_max_lines_meet; |
49 | // If location is to be showed too, 1 to activate it. | 50 | // If location is to be showed too, 1 to activate it. |
50 | bool m_show_location; | 51 | bool m_show_location; |
51 | // if notes should be shown | 52 | // if notes should be shown |
52 | bool m_show_notes; | 53 | bool m_show_notes; |
53 | // should only later appointments be shown or all for the current day. | 54 | // should only later appointments be shown or all for the current day. |
54 | bool m_onlyLater; | 55 | bool m_onlyLater; |
55 | int m_moreDays; | 56 | int m_moreDays; |
56 | 57 | ||
57 | }; | 58 | }; |
58 | 59 | ||
59 | #endif | 60 | #endif |