-rw-r--r-- | core/pim/today/plugins/addressbook/addresspluginwidget.cpp | 9 | ||||
-rw-r--r-- | core/pim/today/plugins/addressbook/opie-today-addressbookplugin.control | 2 |
2 files changed, 5 insertions, 6 deletions
diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp index ea387d6..b48d4a7 100644 --- a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp +++ b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp | |||
@@ -1,221 +1,220 @@ | |||
1 | /* | 1 | /* |
2 | * addresspluginwidget.cpp | 2 | * addresspluginwidget.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2003 by Stefan Eilers | 4 | * copyright : (c) 2003 by Stefan Eilers |
5 | * email : eilers.stefan@epost.de | 5 | * email : eilers.stefan@epost.de |
6 | * | 6 | * |
7 | * This implementation was derived from the todolist plugin implementation | 7 | * This implementation was derived from the todolist plugin implementation |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | #include "addresspluginwidget.h" | 19 | #include "addresspluginwidget.h" |
20 | 20 | ||
21 | 21 | #include <opie2/odebug.h> | |
22 | #include <opie2/opimcontact.h> | 22 | #include <opie2/opimcontact.h> |
23 | 23 | ||
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | 25 | ||
26 | AddressBookPluginWidget::AddressBookPluginWidget( QWidget *parent, const char* name ) | 26 | AddressBookPluginWidget::AddressBookPluginWidget( QWidget *parent, const char* name ) |
27 | : QWidget( parent, name ) { | 27 | : QWidget( parent, name ) { |
28 | 28 | ||
29 | addressLabel = 0l; | 29 | addressLabel = 0l; |
30 | m_contactdb = 0l; | 30 | m_contactdb = 0l; |
31 | layoutTodo = 0l; | 31 | layoutTodo = 0l; |
32 | 32 | ||
33 | // Hä ? Nonsense ! (se) | 33 | // Hä ? Nonsense ! (se) |
34 | if ( m_contactdb ) { | 34 | if ( m_contactdb ) { |
35 | delete m_contactdb; | 35 | delete m_contactdb; |
36 | } | 36 | } |
37 | 37 | ||
38 | m_contactdb = new Opie::OPimContactAccess("addressplugin"); | 38 | m_contactdb = new Opie::OPimContactAccess("addressplugin"); |
39 | 39 | ||
40 | connect( m_contactdb, SIGNAL( signalChanged(const Opie::OPimContactAccess*) ), | 40 | connect( m_contactdb, SIGNAL( signalChanged(const Opie::OPimContactAccess*) ), |
41 | this, SLOT( refresh(const Opie::OPimContactAccess*) ) ); | 41 | this, SLOT( refresh(const Opie::OPimContactAccess*) ) ); |
42 | 42 | ||
43 | 43 | ||
44 | readConfig(); | 44 | readConfig(); |
45 | getAddress(); | 45 | getAddress(); |
46 | } | 46 | } |
47 | 47 | ||
48 | AddressBookPluginWidget::~AddressBookPluginWidget() { | 48 | AddressBookPluginWidget::~AddressBookPluginWidget() { |
49 | delete m_contactdb; | 49 | delete m_contactdb; |
50 | } | 50 | } |
51 | 51 | ||
52 | void AddressBookPluginWidget::refresh( const Opie::OPimContactAccess* ) | 52 | void AddressBookPluginWidget::refresh( const Opie::OPimContactAccess* ) |
53 | { | 53 | { |
54 | qWarning(" AddressBookPluginWidget::Database was changed externally ! "); | 54 | Opie::Core::owarn << " AddressBookPluginWidget::Database was changed externally ! " << oendl; |
55 | m_contactdb->reload(); | 55 | m_contactdb->reload(); |
56 | getAddress(); | 56 | getAddress(); |
57 | } | 57 | } |
58 | 58 | ||
59 | void AddressBookPluginWidget::reinitialize() { | 59 | void AddressBookPluginWidget::reinitialize() { |
60 | readConfig(); | 60 | readConfig(); |
61 | getAddress(); | 61 | getAddress(); |
62 | } | 62 | } |
63 | 63 | ||
64 | void AddressBookPluginWidget::readConfig() { | 64 | void AddressBookPluginWidget::readConfig() { |
65 | Config cfg( "todayaddressplugin" ); | 65 | Config cfg( "todayaddressplugin" ); |
66 | cfg.setGroup( "config" ); | 66 | cfg.setGroup( "config" ); |
67 | m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); | 67 | m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); |
68 | m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); | 68 | m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); |
69 | m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); | 69 | m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); |
70 | m_urgentDays = cfg.readNumEntry( "urgentdays", 7 ); | 70 | m_urgentDays = cfg.readNumEntry( "urgentdays", 7 ); |
71 | m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() ); | 71 | m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() ); |
72 | m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() ); | 72 | m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() ); |
73 | m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); | 73 | m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); |
74 | m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true ); | 74 | m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true ); |
75 | m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true ); | 75 | m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true ); |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Get the addresss | 80 | * Get the addresss |
81 | */ | 81 | */ |
82 | void AddressBookPluginWidget::getAddress() { | 82 | void AddressBookPluginWidget::getAddress() { |
83 | 83 | ||
84 | if ( ! layoutTodo ){ | 84 | if ( ! layoutTodo ){ |
85 | layoutTodo = new QVBoxLayout( this ); | 85 | layoutTodo = new QVBoxLayout( this ); |
86 | } | 86 | } |
87 | 87 | ||
88 | if ( ! addressLabel ) { | 88 | if ( ! addressLabel ) { |
89 | addressLabel = new Opie::Ui::OClickableLabel( this ); | 89 | addressLabel = new Opie::Ui::OClickableLabel( this ); |
90 | connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) ); | 90 | connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) ); |
91 | layoutTodo->addWidget( addressLabel ); | 91 | layoutTodo->addWidget( addressLabel ); |
92 | } | 92 | } |
93 | 93 | ||
94 | QString output; | 94 | QString output; |
95 | 95 | ||
96 | // Check whether the database provide the search option.. | 96 | // Check whether the database provide the search option.. |
97 | if ( !m_contactdb->hasQuerySettings( Opie::OPimContactAccess::DateDiff ) ){ | 97 | if ( !m_contactdb->hasQuerySettings( Opie::OPimContactAccess::DateDiff ) ){ |
98 | // Libopie seems to be old.. | 98 | // Libopie seems to be old.. |
99 | output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" ); | 99 | output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" ); |
100 | addressLabel->setText( output ); | 100 | addressLabel->setText( output ); |
101 | return; | 101 | return; |
102 | } | 102 | } |
103 | 103 | ||
104 | // Define the query for birthdays and start search.. | 104 | // Define the query for birthdays and start search.. |
105 | QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); | 105 | QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); |
106 | int ammount = 0; | 106 | int ammount = 0; |
107 | if ( m_showBirthdays ){ | 107 | if ( m_showBirthdays ){ |
108 | qWarning("Searching from now (%s) until %s ! ", | 108 | Opie::Core::owarn << "Searching from now (" << QDate::currentDate().toString() << ") until " |
109 | QDate::currentDate().toString().latin1(), | 109 | << lookAheadDate.toString() << " ! " << oendl; |
110 | lookAheadDate.toString().latin1() ); | ||
111 | } | 110 | } |
112 | 111 | ||
113 | if ( m_contactdb->hasQuerySettings( Opie::OPimContactAccess::DateDiff ) ){ | 112 | if ( m_contactdb->hasQuerySettings( Opie::OPimContactAccess::DateDiff ) ){ |
114 | 113 | ||
115 | 114 | ||
116 | Opie::OPimContact querybirthdays; | 115 | Opie::OPimContact querybirthdays; |
117 | querybirthdays.setBirthday( lookAheadDate ); | 116 | querybirthdays.setBirthday( lookAheadDate ); |
118 | 117 | ||
119 | m_list = m_contactdb->queryByExample( querybirthdays, | 118 | m_list = m_contactdb->queryByExample( querybirthdays, |
120 | Opie::OPimContactAccess::DateDiff ); | 119 | Opie::OPimContactAccess::DateDiff ); |
121 | if ( m_list.count() > 0 ){ | 120 | if ( m_list.count() > 0 ){ |
122 | output = "<font color=" + m_headlineColor + ">" | 121 | output = "<font color=" + m_headlineColor + ">" |
123 | + QObject::tr( "Next birthdays in <b> %1 </b> days:" ) | 122 | + QObject::tr( "Next birthdays in <b> %1 </b> days:" ) |
124 | .arg( m_daysLookAhead ) | 123 | .arg( m_daysLookAhead ) |
125 | + "</font> <br>"; | 124 | + "</font> <br>"; |
126 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { | 125 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { |
127 | if ( ammount++ < m_maxLinesTask ){ | 126 | if ( ammount++ < m_maxLinesTask ){ |
128 | // Now we want to calculate how many days | 127 | // Now we want to calculate how many days |
129 | //until birthday. We have to set | 128 | //until birthday. We have to set |
130 | // the correct year to calculate the day diff... | 129 | // the correct year to calculate the day diff... |
131 | QDate destdate = (*m_it).birthday(); | 130 | QDate destdate = (*m_it).birthday(); |
132 | destdate.setYMD( QDate::currentDate().year(), | 131 | destdate.setYMD( QDate::currentDate().year(), |
133 | destdate.month(), destdate.day() ); | 132 | destdate.month(), destdate.day() ); |
134 | if ( QDate::currentDate().daysTo(destdate) < 0 ) | 133 | if ( QDate::currentDate().daysTo(destdate) < 0 ) |
135 | destdate.setYMD( QDate::currentDate().year()+1, | 134 | destdate.setYMD( QDate::currentDate().year()+1, |
136 | destdate.month(), destdate.day() ); | 135 | destdate.month(), destdate.day() ); |
137 | 136 | ||
138 | 137 | ||
139 | if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) | 138 | if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) |
140 | output += "<font color=" + m_urgentColor + "><b>-" | 139 | output += "<font color=" + m_urgentColor + "><b>-" |
141 | + (*m_it).fullName() | 140 | + (*m_it).fullName() |
142 | + " (" | 141 | + " (" |
143 | + QString::number(QDate::currentDate() | 142 | + QString::number(QDate::currentDate() |
144 | .daysTo(destdate)) | 143 | .daysTo(destdate)) |
145 | + " Days) </b></font><br>"; | 144 | + " Days) </b></font><br>"; |
146 | 145 | ||
147 | else | 146 | else |
148 | output += "<font color=" + m_entryColor + "><b>-" | 147 | output += "<font color=" + m_entryColor + "><b>-" |
149 | + (*m_it).fullName() | 148 | + (*m_it).fullName() |
150 | + " (" | 149 | + " (" |
151 | + QString::number(QDate::currentDate() | 150 | + QString::number(QDate::currentDate() |
152 | .daysTo(destdate)) | 151 | .daysTo(destdate)) |
153 | + " Days) </b></font><br>"; | 152 | + " Days) </b></font><br>"; |
154 | } | 153 | } |
155 | } | 154 | } |
156 | } else { | 155 | } else { |
157 | output = "<font color=" + m_headlineColor + ">" | 156 | output = "<font color=" + m_headlineColor + ">" |
158 | + QObject::tr( "No birthdays in <b> %1 </b> days!" ) | 157 | + QObject::tr( "No birthdays in <b> %1 </b> days!" ) |
159 | .arg( m_daysLookAhead ) | 158 | .arg( m_daysLookAhead ) |
160 | + "</font> <br>"; | 159 | + "</font> <br>"; |
161 | } | 160 | } |
162 | } | 161 | } |
163 | 162 | ||
164 | if ( m_showAnniversaries ){ | 163 | if ( m_showAnniversaries ){ |
165 | // Define the query for anniversaries and start search.. | 164 | // Define the query for anniversaries and start search.. |
166 | Opie::OPimContact queryanniversaries; | 165 | Opie::OPimContact queryanniversaries; |
167 | queryanniversaries.setAnniversary( lookAheadDate ); | 166 | queryanniversaries.setAnniversary( lookAheadDate ); |
168 | 167 | ||
169 | m_list = m_contactdb->queryByExample( queryanniversaries, Opie::OPimContactAccess::DateDiff ); | 168 | m_list = m_contactdb->queryByExample( queryanniversaries, Opie::OPimContactAccess::DateDiff ); |
170 | 169 | ||
171 | ammount = 0; | 170 | ammount = 0; |
172 | if ( m_list.count() > 0 ){ | 171 | if ( m_list.count() > 0 ){ |
173 | output += "<font color=" + m_headlineColor + ">" | 172 | output += "<font color=" + m_headlineColor + ">" |
174 | + QObject::tr( "Next anniversaries in <b> %1 </b> days:" ) | 173 | + QObject::tr( "Next anniversaries in <b> %1 </b> days:" ) |
175 | .arg( m_daysLookAhead ) | 174 | .arg( m_daysLookAhead ) |
176 | + "</font> <br>"; | 175 | + "</font> <br>"; |
177 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { | 176 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { |
178 | if ( ammount++ < m_maxLinesTask ){ | 177 | if ( ammount++ < m_maxLinesTask ){ |
179 | // Now we want to calculate how many days until anniversary. | 178 | // Now we want to calculate how many days until anniversary. |
180 | // We have to set the correct year to calculate the day diff... | 179 | // We have to set the correct year to calculate the day diff... |
181 | QDate destdate = (*m_it).anniversary(); | 180 | QDate destdate = (*m_it).anniversary(); |
182 | destdate.setYMD( QDate::currentDate().year(), destdate.month(), | 181 | destdate.setYMD( QDate::currentDate().year(), destdate.month(), |
183 | destdate.day() ); | 182 | destdate.day() ); |
184 | if ( QDate::currentDate().daysTo(destdate) < 0 ) | 183 | if ( QDate::currentDate().daysTo(destdate) < 0 ) |
185 | destdate.setYMD( QDate::currentDate().year()+1, | 184 | destdate.setYMD( QDate::currentDate().year()+1, |
186 | destdate.month(), destdate.day() ); | 185 | destdate.month(), destdate.day() ); |
187 | 186 | ||
188 | if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) | 187 | if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) |
189 | output += "<font color=" + m_urgentColor + "><b>-" | 188 | output += "<font color=" + m_urgentColor + "><b>-" |
190 | + (*m_it).fullName() | 189 | + (*m_it).fullName() |
191 | + " (" | 190 | + " (" |
192 | + QString::number(QDate::currentDate() | 191 | + QString::number(QDate::currentDate() |
193 | .daysTo( destdate ) ) | 192 | .daysTo( destdate ) ) |
194 | + " Days) </b></font><br>"; | 193 | + " Days) </b></font><br>"; |
195 | else | 194 | else |
196 | output += "<font color=" + m_entryColor + "><b>-" | 195 | output += "<font color=" + m_entryColor + "><b>-" |
197 | + (*m_it).fullName() | 196 | + (*m_it).fullName() |
198 | + " (" | 197 | + " (" |
199 | + QString::number(QDate::currentDate() | 198 | + QString::number(QDate::currentDate() |
200 | .daysTo( destdate ) ) | 199 | .daysTo( destdate ) ) |
201 | + " Days) </b></font><br>"; | 200 | + " Days) </b></font><br>"; |
202 | } | 201 | } |
203 | } | 202 | } |
204 | } else { | 203 | } else { |
205 | output += "<font color=" + m_headlineColor + ">" | 204 | output += "<font color=" + m_headlineColor + ">" |
206 | + QObject::tr( "No anniversaries in <b> %1 </b> days!" ) | 205 | + QObject::tr( "No anniversaries in <b> %1 </b> days!" ) |
207 | .arg( m_daysLookAhead ) | 206 | .arg( m_daysLookAhead ) |
208 | + "</font> <br>"; | 207 | + "</font> <br>"; |
209 | } | 208 | } |
210 | } | 209 | } |
211 | 210 | ||
212 | addressLabel->setText( output ); | 211 | addressLabel->setText( output ); |
213 | } | 212 | } |
214 | 213 | ||
215 | /** | 214 | /** |
216 | * start the todolist | 215 | * start the todolist |
217 | */ | 216 | */ |
218 | void AddressBookPluginWidget::startAddressBook() { | 217 | void AddressBookPluginWidget::startAddressBook() { |
219 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 218 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
220 | e << QString( "addressbook" ); | 219 | e << QString( "addressbook" ); |
221 | } | 220 | } |
diff --git a/core/pim/today/plugins/addressbook/opie-today-addressbookplugin.control b/core/pim/today/plugins/addressbook/opie-today-addressbookplugin.control index 2fd1435..030d04b 100644 --- a/core/pim/today/plugins/addressbook/opie-today-addressbookplugin.control +++ b/core/pim/today/plugins/addressbook/opie-today-addressbookplugin.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-today-addressbookplugin | 1 | Package: opie-today-addressbookplugin |
2 | Files: plugins/today/libtodayaddressbookplugin.so* | 2 | Files: plugins/today/libtodayaddressbookplugin.so* |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/plugins | 4 | Section: opie/plugins |
5 | Maintainer: Stefan Eilers <eilers.stefan@epost.de> | 5 | Maintainer: Stefan Eilers <eilers.stefan@epost.de> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Depends: libqte2, opie-today, libopiecore2, libopieui2, libopiepim2, libopiedb2, libqtaux2 | 7 | Depends: libqte2, opie-today, libopiecore2, libopieui2, libopiepim2, libqtaux2 |
8 | Description: Addressbook plugin for Today | 8 | Description: Addressbook plugin for Today |
9 | Displays upcoming Birthdays and Anniversaries | 9 | Displays upcoming Birthdays and Anniversaries |
10 | Version: $QPE_VERSION$EXTRAVERSION | 10 | Version: $QPE_VERSION$EXTRAVERSION |