-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp index eb6d47a..781cfcf 100644 --- a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp | |||
@@ -1,141 +1,141 @@ | |||
1 | /* | 1 | /* |
2 | * datebookpluginwidget.cpp | 2 | * datebookpluginwidget.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002,2003, 2004 by Maximilian Reiß | 4 | * copyright : (c) 2002,2003, 2004 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 | 19 | ||
20 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
21 | 21 | ||
22 | #include <qtl.h> | 22 | #include <qtl.h> |
23 | 23 | ||
24 | DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name ) | 24 | DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name ) |
25 | : QWidget(parent, name ) { | 25 | : QWidget(parent, name ) { |
26 | 26 | ||
27 | db = 0l; | 27 | db = 0l; |
28 | m_layoutDates = 0l; | 28 | m_layoutDates = 0l; |
29 | 29 | ||
30 | if ( m_layoutDates ) { | 30 | if ( m_layoutDates ) { |
31 | delete m_layoutDates; | 31 | delete m_layoutDates; |
32 | } | 32 | } |
33 | m_layoutDates = new QVBoxLayout( this ); | 33 | m_layoutDates = new QVBoxLayout( this ); |
34 | m_layoutDates->setAutoAdd( true ); | 34 | m_layoutDates->setAutoAdd( true ); |
35 | 35 | ||
36 | m_eventsList.setAutoDelete( true ); | 36 | m_eventsList.setAutoDelete( true ); |
37 | 37 | ||
38 | readConfig(); | 38 | readConfig(); |
39 | getDates(); | 39 | getDates(); |
40 | } | 40 | } |
41 | 41 | ||
42 | DatebookPluginWidget::~DatebookPluginWidget() { | 42 | DatebookPluginWidget::~DatebookPluginWidget() { |
43 | delete db; | 43 | delete db; |
44 | delete m_layoutDates; | 44 | delete m_layoutDates; |
45 | } | 45 | } |
46 | 46 | ||
47 | 47 | ||
48 | void DatebookPluginWidget::readConfig() { | 48 | void DatebookPluginWidget::readConfig() { |
49 | Config cfg( "todaydatebookplugin" ); | 49 | Config cfg( "todaydatebookplugin" ); |
50 | cfg.setGroup( "config" ); | 50 | cfg.setGroup( "config" ); |
51 | m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); | 51 | m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); |
52 | m_show_location = cfg.readNumEntry( "showlocation", 1 ); | 52 | m_show_location = cfg.readNumEntry( "showlocation", 1 ); |
53 | m_show_notes = cfg.readNumEntry( "shownotes", 0 ); | 53 | m_show_notes = cfg.readNumEntry( "shownotes", 0 ); |
54 | m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); | 54 | m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); |
55 | m_moreDays = cfg.readNumEntry( "moredays", 0 ); | 55 | m_moreDays = cfg.readNumEntry( "moredays", 0 ); |
56 | m_timeExtraLine = cfg.readNumEntry( "timeextraline", 1 ); | 56 | m_timeExtraLine = cfg.readNumEntry( "timeextraline", 1 ); |
57 | m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); | 57 | m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); |
58 | } | 58 | } |
59 | 59 | ||
60 | void DatebookPluginWidget::reinitialize() { | 60 | void DatebookPluginWidget::reinitialize() { |
61 | readConfig(); | 61 | readConfig(); |
62 | refresh(); | 62 | refresh(); |
63 | } | 63 | } |
64 | 64 | ||
65 | void DatebookPluginWidget::refresh() { | 65 | void DatebookPluginWidget::refresh() { |
66 | m_eventsList.clear(); | 66 | m_eventsList.clear(); |
67 | 67 | ||
68 | if ( m_layoutDates ) { | 68 | if ( m_layoutDates ) { |
69 | delete m_layoutDates; | 69 | delete m_layoutDates; |
70 | } | 70 | } |
71 | m_layoutDates = new QVBoxLayout( this ); | 71 | m_layoutDates = new QVBoxLayout( this ); |
72 | m_layoutDates->setAutoAdd( true ); | 72 | m_layoutDates->setAutoAdd( true ); |
73 | 73 | ||
74 | getDates(); | 74 | getDates(); |
75 | } | 75 | } |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Get all events that are in the datebook xml file for today | 78 | * Get all events that are in the datebook xml file for today |
79 | */ | 79 | */ |
80 | void DatebookPluginWidget::getDates() { | 80 | void DatebookPluginWidget::getDates() { |
81 | 81 | ||
82 | 82 | ||
83 | if ( db ) { | 83 | if ( db ) { |
84 | delete db; | 84 | delete db; |
85 | } | 85 | } |
86 | db = new DateBookDB; | 86 | db = new DateBookDB; |
87 | 87 | ||
88 | QDate date = QDate::currentDate(); | 88 | QDate date = QDate::currentDate(); |
89 | QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); | 89 | QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); |
90 | qBubbleSort( list ); | 90 | qBubbleSort( list ); |
91 | int count = 0; | 91 | int count = 0; |
92 | 92 | ||
93 | if ( list.count() > 0 ) { | 93 | if ( list.count() > 0 ) { |
94 | 94 | ||
95 | for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { | 95 | for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { |
96 | 96 | ||
97 | if ( count < m_max_lines_meet ) { | 97 | if ( count < m_max_lines_meet ) { |
98 | if ( !m_onlyLater ) { | 98 | if ( !m_onlyLater ) { |
99 | count++; | 99 | count++; |
100 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine, m_maxCharClip ); | 100 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine, m_maxCharClip ); |
101 | m_eventsList.append( l ); | 101 | m_eventsList.append( l ); |
102 | l->show(); | 102 | l->show(); |
103 | QObject::connect ( l, SIGNAL( editEvent(const Event&) ), l, SLOT( editEventSlot(const Event&) ) ); | 103 | QObject::connect ( l, SIGNAL( editEvent(const Event&) ), l, SLOT( editEventSlot(const Event&) ) ); |
104 | } else { | 104 | } else { |
105 | if ( ( QDateTime::currentDateTime() <= (*it).event().end() ) | 105 | if ( ( QDateTime::currentDateTime() <= (*it).event().end() ) |
106 | // Show events which span over many days and are not elapsed. | 106 | // Show events which span over many days and are not elapsed. |
107 | || ( ( (*it).event().start().date() != date ) && ( QDateTime::currentDateTime() <= (*it).event().end() ) ) | 107 | || ( ( (*it).event().start().date() != date ) && ( QDateTime::currentDateTime() <= (*it).event().end() ) ) |
108 | // Show repeated event for today that is not elapsed. | 108 | // Show repeated event for today that is not elapsed. |
109 | || ( ( (*it).event().repeatType() != Event::NoRepeat ) | 109 | || ( ( (*it).event().repeatType() != Event::NoRepeat ) |
110 | && ( ( date.dayOfWeek() == (*it).date().dayOfWeek() ) | 110 | && ( ( date.dayOfWeek() == (*it).date().dayOfWeek() ) |
111 | && ( QTime::currentTime() < (*it).event().start().time() ) ) ) | 111 | && ( QTime::currentTime() < (*it).event().start().time() ) ) ) |
112 | // Show repeated event for next days. | 112 | // Show repeated event for next days. |
113 | || ( ( (*it).event().repeatType() != Event::NoRepeat ) | 113 | || ( ( (*it).event().repeatType() != Event::NoRepeat ) |
114 | && ( date.dayOfWeek() != (*it).date().dayOfWeek() ) ) | 114 | && ( date.dayOfWeek() != (*it).date().dayOfWeek() ) ) |
115 | ) | 115 | ) |
116 | { | 116 | { |
117 | count++; | 117 | count++; |
118 | // show only later appointments | 118 | // show only later appointments |
119 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine ); | 119 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine, m_maxCharClip ); |
120 | m_eventsList.append( l ); | 120 | m_eventsList.append( l ); |
121 | l->show(); | 121 | l->show(); |
122 | QObject::connect ( l, SIGNAL( editEvent(const Event&) ), l, SLOT( editEventSlot(const Event&) ) ); | 122 | QObject::connect ( l, SIGNAL( editEvent(const Event&) ), l, SLOT( editEventSlot(const Event&) ) ); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } | 125 | } |
126 | } | 126 | } |
127 | if ( m_onlyLater && count == 0 ) { | 127 | if ( m_onlyLater && count == 0 ) { |
128 | QLabel* noMoreEvents = new QLabel( this ); | 128 | QLabel* noMoreEvents = new QLabel( this ); |
129 | m_eventsList.append( noMoreEvents ); | 129 | m_eventsList.append( noMoreEvents ); |
130 | noMoreEvents->show(); | 130 | noMoreEvents->show(); |
131 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); | 131 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); |
132 | } | 132 | } |
133 | } else { | 133 | } else { |
134 | QLabel* noEvents = new QLabel( this ); | 134 | QLabel* noEvents = new QLabel( this ); |
135 | m_eventsList.append( noEvents ); | 135 | m_eventsList.append( noEvents ); |
136 | noEvents->show(); | 136 | noEvents->show(); |
137 | noEvents->setText( QObject::tr( "No appointments today" ) ); | 137 | noEvents->setText( QObject::tr( "No appointments today" ) ); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||