-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp index e2f492e..9a18408 100644 --- a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp | |||
@@ -25,91 +25,92 @@ | |||
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 | |||
41 | if ( m_layoutDates ) { | 42 | if ( m_layoutDates ) { |
42 | delete m_layoutDates; | 43 | delete m_layoutDates; |
43 | } | 44 | } |
44 | m_layoutDates = new QVBoxLayout( this ); | 45 | m_layoutDates = new QVBoxLayout( this ); |
45 | m_layoutDates->setAutoAdd( true ); | 46 | m_layoutDates->setAutoAdd( true ); |
46 | 47 | ||
48 | m_eventsList.setAutoDelete( true ); | ||
49 | |||
47 | readConfig(); | 50 | readConfig(); |
48 | getDates(); | 51 | getDates(); |
49 | } | 52 | } |
50 | 53 | ||
51 | DatebookPluginWidget::~DatebookPluginWidget() { | 54 | DatebookPluginWidget::~DatebookPluginWidget() { |
52 | delete db; | 55 | delete db; |
53 | delete m_layoutDates; | 56 | delete m_layoutDates; |
54 | } | 57 | } |
55 | 58 | ||
56 | 59 | ||
57 | void DatebookPluginWidget::readConfig() { | 60 | void DatebookPluginWidget::readConfig() { |
58 | Config cfg( "todaydatebookplugin" ); | 61 | Config cfg( "todaydatebookplugin" ); |
59 | cfg.setGroup( "config" ); | 62 | cfg.setGroup( "config" ); |
60 | m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); | 63 | m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); |
61 | m_show_location = cfg.readNumEntry( "showlocation", 1 ); | 64 | m_show_location = cfg.readNumEntry( "showlocation", 1 ); |
62 | m_show_notes = cfg.readNumEntry( "shownotes", 0 ); | 65 | m_show_notes = cfg.readNumEntry( "shownotes", 0 ); |
63 | m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); | 66 | m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); |
64 | m_moreDays = cfg.readNumEntry( "moredays", 0 ); | 67 | m_moreDays = cfg.readNumEntry( "moredays", 0 ); |
65 | } | 68 | } |
66 | 69 | ||
67 | void DatebookPluginWidget::refresh() { | 70 | void DatebookPluginWidget::refresh() { |
68 | DateBookEvent* ev; | 71 | DateBookEvent* ev; |
69 | for ( ev = m_eventsList.first(); ev != 0; ev = m_eventsList.next() ) { | 72 | for ( ev = m_eventsList.first(); ev != 0; ev = m_eventsList.next() ) { |
70 | delete ev; | 73 | delete ev; |
71 | } | 74 | } |
75 | m_eventsList.clear(); | ||
72 | getDates(); | 76 | getDates(); |
73 | } | 77 | } |
74 | 78 | ||
75 | /** | 79 | /** |
76 | * Get all events that are in the datebook xml file for today | 80 | * Get all events that are in the datebook xml file for today |
77 | */ | 81 | */ |
78 | void DatebookPluginWidget::getDates() { | 82 | void DatebookPluginWidget::getDates() { |
79 | 83 | ||
80 | QDate date = QDate::currentDate(); | 84 | QDate date = QDate::currentDate(); |
81 | |||
82 | QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); | 85 | QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); |
83 | qBubbleSort( list ); | 86 | qBubbleSort( list ); |
84 | //Config config( "qpe" ); | 87 | int count = 0; |
85 | int count=0; | ||
86 | 88 | ||
89 | qDebug( QString("List count %1" ).arg(list.count() ) ); | ||
87 | if ( list.count() > 0 ) { | 90 | if ( list.count() > 0 ) { |
88 | 91 | ||
89 | for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { | 92 | for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { |
90 | 93 | ||
91 | if ( count <= m_max_lines_meet ) { | 94 | if ( count <= m_max_lines_meet ) { |
92 | QTime time = QTime::currentTime(); | ||
93 | |||
94 | if ( !m_onlyLater ) { | 95 | if ( !m_onlyLater ) { |
95 | count++; | 96 | count++; |
96 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); | 97 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); |
97 | m_eventsList.append( l ); | 98 | m_eventsList.append( l ); |
98 | QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); | 99 | QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); |
99 | } else if ( ( time.toString() <= TimeString::dateString( (*it).event().end() ) ) ) { | 100 | } else if ( QDateTime::currentDateTime() <= (*it).event().end() ) { |
100 | count++; | 101 | count++; |
101 | // show only later appointments | 102 | // show only later appointments |
102 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); | 103 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); |
103 | m_eventsList.append( l ); | 104 | m_eventsList.append( l ); |
104 | QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); | 105 | QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); |
105 | } | 106 | } |
106 | } | 107 | } |
107 | } | 108 | } |
108 | if ( m_onlyLater && count == 0 ) { | 109 | if ( m_onlyLater && count == 0 ) { |
109 | QLabel* noMoreEvents = new QLabel( this ); | 110 | QLabel* noMoreEvents = new QLabel( this ); |
110 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); | 111 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); |
111 | } | 112 | } |
112 | } else { | 113 | } else { |
113 | QLabel* noEvents = new QLabel( this ); | 114 | QLabel* noEvents = new QLabel( this ); |
114 | noEvents->setText( QObject::tr( "No appointments today" ) ); | 115 | noEvents->setText( QObject::tr( "No appointments today" ) ); |
115 | } | 116 | } |