Diffstat (limited to 'core/pim/today/plugins/datebook/datebookpluginwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.cpp | 53 |
1 files changed, 29 insertions, 24 deletions
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,3 +1,3 @@ | |||
1 | /* | 1 | /* |
2 | * datebookpluginwidget.cpp | 2 | * datebookpluginwidget.cpp |
3 | * | 3 | * |
@@ -17,5 +17,4 @@ | |||
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> |
@@ -31,5 +30,19 @@ | |||
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(); |
@@ -38,4 +51,5 @@ DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name) | |||
38 | DatebookPluginWidget::~DatebookPluginWidget() { | 51 | DatebookPluginWidget::~DatebookPluginWidget() { |
39 | delete db; | 52 | delete db; |
53 | delete m_layoutDates; | ||
40 | } | 54 | } |
41 | 55 | ||
@@ -51,4 +65,11 @@ void DatebookPluginWidget::readConfig() { | |||
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 | /** |
@@ -57,28 +78,14 @@ void DatebookPluginWidget::readConfig() { | |||
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 ) { |
@@ -88,12 +95,12 @@ void DatebookPluginWidget::getDates() { | |||
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 | } |
@@ -102,10 +109,8 @@ void DatebookPluginWidget::getDates() { | |||
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 | } |