summaryrefslogtreecommitdiff
path: root/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/today/plugins/addressbook/addresspluginwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/plugins/addressbook/addresspluginwidget.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
index dad09db..d47bc0b 100644
--- a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
+++ b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
@@ -81,62 +81,66 @@ void AddressBookPluginWidget::readConfig() {
m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() );
m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true );
m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true );
}
/**
* Get the addresss
*/
void AddressBookPluginWidget::getAddress() {
if ( ! layoutTodo ){
layoutTodo = new QVBoxLayout( this );
}
if ( ! addressLabel ) {
addressLabel = new OClickableLabel( this );
connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) );
layoutTodo->addWidget( addressLabel );
}
QString output;
// Check whether the database provide the search option..
- if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){
+ if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){
// Libopie seems to be old..
output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" );
addressLabel->setText( output );
return;
}
-
+
// Define the query for birthdays and start search..
QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead );
int ammount = 0;
if ( m_showBirthdays ){
- qWarning("Searching from now (%s) until %s ! ",
- QDate::currentDate().toString().latin1(),
+ qWarning("Searching from now (%s) until %s ! ",
+ QDate::currentDate().toString().latin1(),
lookAheadDate.toString().latin1() );
+ }
+
+ if ( m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){
+
OContact querybirthdays;
querybirthdays.setBirthday( lookAheadDate );
m_list = m_contactdb->queryByExample( querybirthdays,
OContactAccess::DateDiff );
if ( m_list.count() > 0 ){
output = "<font color=" + m_headlineColor + ">"
+ QObject::tr( "Next birthdays in <b> %1 </b> days:" )
.arg( m_daysLookAhead )
+ "</font> <br>";
for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
if ( ammount++ < m_maxLinesTask ){
// Now we want to calculate how many days
//until birthday. We have to set
// the correct year to calculate the day diff...
QDate destdate = (*m_it).birthday();
destdate.setYMD( QDate::currentDate().year(),
destdate.month(), destdate.day() );
if ( QDate::currentDate().daysTo(destdate) < 0 )
destdate.setYMD( QDate::currentDate().year()+1,
destdate.month(), destdate.day() );