From 5f5e9f321fe606b1175314c9a06da6286f0f92c0 Mon Sep 17 00:00:00 2001 From: eilers Date: Fri, 03 Jan 2003 13:39:22 +0000 Subject: Now it shows how many days are left until birthday/anniversary ! --- (limited to 'core/pim/today') diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp index 015ac6a..0d4cec8 100644 --- a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp +++ b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp @@ -107,8 +107,19 @@ void AddressBookPluginWidget::getAddress() { if ( m_list.count() > 0 ){ output = QObject::tr( "Next birthdays in %1 days:
" ).arg( m_daysLookAhead ); for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { - if ( ammount++ < m_maxLinesTask ) - output += "-" + (*m_it).fullName() + "
"; + 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() ); + + output += "-" + (*m_it).fullName() + + " (" + + QString::number(QDate::currentDate().daysTo(destdate)) + + " Days)
"; + } } } else { output = QObject::tr( "No birthdays in %1 days!
" ).arg( m_daysLookAhead ); @@ -124,8 +135,19 @@ void AddressBookPluginWidget::getAddress() { if ( m_list.count() > 0 ){ output += QObject::tr( "Next anniversaries in %1 days:
" ).arg( m_daysLookAhead ); for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { - if ( ammount++ < m_maxLinesTask ) - output += "-" + (*m_it).fullName() + "
"; + if ( ammount++ < m_maxLinesTask ){ + // Now we want to calculate how many days until anniversary. We have to set + // the correct year to calculate the day diff... + QDate destdate = (*m_it).anniversary(); + 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() ); + + output += "-" + (*m_it).fullName() + + " (" + + QString::number(QDate::currentDate().daysTo( destdate ) ) + + " Days)
"; + } } } else { output += QObject::tr( "No anniversaries in %1 days!
" ).arg( m_daysLookAhead ); -- cgit v0.9.0.2