summaryrefslogtreecommitdiff
path: root/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
Unidiff
Diffstat (limited to 'core/pim/today/plugins/addressbook/addresspluginwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/today/plugins/addressbook/addresspluginwidget.cpp83
1 files changed, 55 insertions, 28 deletions
diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
index 7d87fca..498de28 100644
--- a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
+++ b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
@@ -77,2 +77,4 @@ void AddressBookPluginWidget::readConfig() {
77 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); 77 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() );
78 m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true );
79 m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true );
78} 80}
@@ -98,3 +100,11 @@ void AddressBookPluginWidget::getAddress() {
98 // Check whether the database provide the search option.. 100 // Check whether the database provide the search option..
99 if ( ! m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ 101 // The following if-statement was replaced due to a bug in some
102 // implementations of libopie. The replacement should work everywhere..(eilers)
103 // if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){
104 if ( !( m_contactdb->querySettings() & OContactAccess::DateDiff ) ){
105 // Libopie seems to be old..
106 output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" );
107 addressLabel->setText( output );
108 return;
109 }
100 110
@@ -102,3 +112,6 @@ void AddressBookPluginWidget::getAddress() {
102 QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); 112 QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead );
103 qWarning("Searching from now (%s) until %s ! ", QDate::currentDate().toString().latin1(), 113 int ammount = 0;
114 if ( m_showBirthdays ){
115 qWarning("Searching from now (%s) until %s ! ",
116 QDate::currentDate().toString().latin1(),
104 lookAheadDate.toString().latin1() ); 117 lookAheadDate.toString().latin1() );
@@ -107,8 +120,9 @@ void AddressBookPluginWidget::getAddress() {
107 120
108 int ammount = 0;
109 121
110 m_list = m_contactdb->queryByExample( querybirthdays, OContactAccess::DateDiff ); 122 m_list = m_contactdb->queryByExample( querybirthdays,
123 OContactAccess::DateDiff );
111 if ( m_list.count() > 0 ){ 124 if ( m_list.count() > 0 ){
112 output = "<font color=" + m_headlineColor + ">" 125 output = "<font color=" + m_headlineColor + ">"
113 + QObject::tr( "Next birthdays in <b> %1 </b> days:" ).arg( m_daysLookAhead ) 126 + QObject::tr( "Next birthdays in <b> %1 </b> days:" )
127 .arg( m_daysLookAhead )
114 + "</font> <br>"; 128 + "</font> <br>";
@@ -116,8 +130,11 @@ void AddressBookPluginWidget::getAddress() {
116 if ( ammount++ < m_maxLinesTask ){ 130 if ( ammount++ < m_maxLinesTask ){
117 // Now we want to calculate how many days until birthday. We have to set 131 // Now we want to calculate how many days
132 //until birthday. We have to set
118 // the correct year to calculate the day diff... 133 // the correct year to calculate the day diff...
119 QDate destdate = (*m_it).birthday(); 134 QDate destdate = (*m_it).birthday();
120 destdate.setYMD( QDate::currentDate().year(), destdate.month(), destdate.day() ); 135 destdate.setYMD( QDate::currentDate().year(),
136 destdate.month(), destdate.day() );
121 if ( QDate::currentDate().daysTo(destdate) < 0 ) 137 if ( QDate::currentDate().daysTo(destdate) < 0 )
122 destdate.setYMD( QDate::currentDate().year()+1, destdate.month(), destdate.day() ); 138 destdate.setYMD( QDate::currentDate().year()+1,
139 destdate.month(), destdate.day() );
123 140
@@ -125,5 +142,7 @@ void AddressBookPluginWidget::getAddress() {
125 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) 142 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays )
126 output += "<font color=" + m_urgentColor + "><b>-" + (*m_it).fullName() 143 output += "<font color=" + m_urgentColor + "><b>-"
144 + (*m_it).fullName()
127 + " (" 145 + " ("
128 + QString::number(QDate::currentDate().daysTo(destdate)) 146 + QString::number(QDate::currentDate()
147 .daysTo(destdate))
129 + " Days) </b></font><br>"; 148 + " Days) </b></font><br>";
@@ -131,5 +150,7 @@ void AddressBookPluginWidget::getAddress() {
131 else 150 else
132 output += "<font color=" + m_entryColor + "><b>-" + (*m_it).fullName() 151 output += "<font color=" + m_entryColor + "><b>-"
152 + (*m_it).fullName()
133 + " (" 153 + " ("
134 + QString::number(QDate::currentDate().daysTo(destdate)) 154 + QString::number(QDate::currentDate()
155 .daysTo(destdate))
135 + " Days) </b></font><br>"; 156 + " Days) </b></font><br>";
@@ -139,6 +160,9 @@ void AddressBookPluginWidget::getAddress() {
139 output = "<font color=" + m_headlineColor + ">" 160 output = "<font color=" + m_headlineColor + ">"
140 + QObject::tr( "No birthdays in <b> %1 </b> days!" ).arg( m_daysLookAhead ) 161 + QObject::tr( "No birthdays in <b> %1 </b> days!" )
162 .arg( m_daysLookAhead )
141 + "</font> <br>"; 163 + "</font> <br>";
142 } 164 }
165 }
143 166
167 if ( m_showAnniversaries ){
144 // Define the query for anniversaries and start search.. 168 // Define the query for anniversaries and start search..
@@ -152,3 +176,4 @@ void AddressBookPluginWidget::getAddress() {
152 output += "<font color=" + m_headlineColor + ">" 176 output += "<font color=" + m_headlineColor + ">"
153 + QObject::tr( "Next anniversaries in <b> %1 </b> days:" ).arg( m_daysLookAhead ) 177 + QObject::tr( "Next anniversaries in <b> %1 </b> days:" )
178 .arg( m_daysLookAhead )
154 + "</font> <br>"; 179 + "</font> <br>";
@@ -156,18 +181,24 @@ void AddressBookPluginWidget::getAddress() {
156 if ( ammount++ < m_maxLinesTask ){ 181 if ( ammount++ < m_maxLinesTask ){
157 // Now we want to calculate how many days until anniversary. We have to set 182 // Now we want to calculate how many days until anniversary.
158 // the correct year to calculate the day diff... 183 // We have to set the correct year to calculate the day diff...
159 QDate destdate = (*m_it).anniversary(); 184 QDate destdate = (*m_it).anniversary();
160 destdate.setYMD( QDate::currentDate().year(), destdate.month(), destdate.day() ); 185 destdate.setYMD( QDate::currentDate().year(), destdate.month(),
186 destdate.day() );
161 if ( QDate::currentDate().daysTo(destdate) < 0 ) 187 if ( QDate::currentDate().daysTo(destdate) < 0 )
162 destdate.setYMD( QDate::currentDate().year()+1, destdate.month(), destdate.day() ); 188 destdate.setYMD( QDate::currentDate().year()+1,
189 destdate.month(), destdate.day() );
163 190
164 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) 191 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays )
165 output += "<font color=" + m_urgentColor + "><b>-" + (*m_it).fullName() 192 output += "<font color=" + m_urgentColor + "><b>-"
193 + (*m_it).fullName()
166 + " (" 194 + " ("
167 + QString::number(QDate::currentDate().daysTo( destdate ) ) 195 + QString::number(QDate::currentDate()
196 .daysTo( destdate ) )
168 + " Days) </b></font><br>"; 197 + " Days) </b></font><br>";
169 else 198 else
170 output += "<font color=" + m_entryColor + "><b>-" + (*m_it).fullName() 199 output += "<font color=" + m_entryColor + "><b>-"
200 + (*m_it).fullName()
171 + " (" 201 + " ("
172 + QString::number(QDate::currentDate().daysTo( destdate ) ) 202 + QString::number(QDate::currentDate()
203 .daysTo( destdate ) )
173 + " Days) </b></font><br>"; 204 + " Days) </b></font><br>";
@@ -177,10 +208,6 @@ void AddressBookPluginWidget::getAddress() {
177 output += "<font color=" + m_headlineColor + ">" 208 output += "<font color=" + m_headlineColor + ">"
178 + QObject::tr( "No anniversaries in <b> %1 </b> days!" ).arg( m_daysLookAhead ) 209 + QObject::tr( "No anniversaries in <b> %1 </b> days!" )
210 .arg( m_daysLookAhead )
179 + "</font> <br>"; 211 + "</font> <br>";
180 } 212 }
181
182
183 }else{
184 // Libopie seems to be old..
185 output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" );
186 } 213 }