From 1c24ec58bd7fc8a0a46cdaf41e4c6b7e68e4dba6 Mon Sep 17 00:00:00 2001 From: eilers Date: Mon, 07 Jul 2003 16:17:27 +0000 Subject: Adding feature: Disabling/Enabling of Birthdays/Anniversaries is possible, now ! --- (limited to 'core/pim/today/plugins/addressbook/addresspluginwidget.cpp') 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 @@ -75,6 +75,8 @@ void AddressBookPluginWidget::readConfig() { m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() ); m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() ); m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); + m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true ); + m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true ); } @@ -96,51 +98,73 @@ void AddressBookPluginWidget::getAddress() { QString output; // Check whether the database provide the search option.. - if ( ! m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ - - // Define the query for birthdays and start search.. - QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); - qWarning("Searching from now (%s) until %s ! ", QDate::currentDate().toString().latin1(), + // The following if-statement was replaced due to a bug in some + // implementations of libopie. The replacement should work everywhere..(eilers) + // if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ + if ( !( m_contactdb->querySettings() & OContactAccess::DateDiff ) ){ + // Libopie seems to be old.. + output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !
" ); + 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(), lookAheadDate.toString().latin1() ); OContact querybirthdays; querybirthdays.setBirthday( lookAheadDate ); - - int ammount = 0; - m_list = m_contactdb->queryByExample( querybirthdays, OContactAccess::DateDiff ); + + m_list = m_contactdb->queryByExample( querybirthdays, + OContactAccess::DateDiff ); if ( m_list.count() > 0 ){ output = "" - + QObject::tr( "Next birthdays in %1 days:" ).arg( m_daysLookAhead ) + + 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 ){ - // Now we want to calculate how many days until birthday. We have to set + // 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() ); + 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() ); + destdate.setYMD( QDate::currentDate().year()+1, + destdate.month(), destdate.day() ); if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) - output += "-" + (*m_it).fullName() + output += "-" + + (*m_it).fullName() + " (" - + QString::number(QDate::currentDate().daysTo(destdate)) + + QString::number(QDate::currentDate() + .daysTo(destdate)) + " Days)
"; else - output += "-" + (*m_it).fullName() + output += "-" + + (*m_it).fullName() + " (" - + QString::number(QDate::currentDate().daysTo(destdate)) + + QString::number(QDate::currentDate() + .daysTo(destdate)) + " Days)
"; } } } else { output = "" - + QObject::tr( "No birthdays in %1 days!" ).arg( m_daysLookAhead ) + + QObject::tr( "No birthdays in %1 days!" ) + .arg( m_daysLookAhead ) + "
"; } + } + if ( m_showAnniversaries ){ // Define the query for anniversaries and start search.. OContact queryanniversaries; queryanniversaries.setAnniversary( lookAheadDate ); @@ -150,41 +174,44 @@ void AddressBookPluginWidget::getAddress() { ammount = 0; if ( m_list.count() > 0 ){ output += "" - + QObject::tr( "Next anniversaries in %1 days:" ).arg( m_daysLookAhead ) + + 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 ){ - // Now we want to calculate how many days until anniversary. We have to set - // the correct year to calculate the day diff... + // 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() ); + 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() ); + destdate.setYMD( QDate::currentDate().year()+1, + destdate.month(), destdate.day() ); if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) - output += "-" + (*m_it).fullName() + output += "-" + + (*m_it).fullName() + " (" - + QString::number(QDate::currentDate().daysTo( destdate ) ) + + QString::number(QDate::currentDate() + .daysTo( destdate ) ) + " Days)
"; else - output += "-" + (*m_it).fullName() + output += "-" + + (*m_it).fullName() + " (" - + QString::number(QDate::currentDate().daysTo( destdate ) ) + + QString::number(QDate::currentDate() + .daysTo( destdate ) ) + " Days)
"; } } } else { output += "" - + QObject::tr( "No anniversaries in %1 days!" ).arg( m_daysLookAhead ) + + QObject::tr( "No anniversaries in %1 days!" ) + .arg( m_daysLookAhead ) + "
"; } - - - }else{ - // Libopie seems to be old.. - output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !
" ); } - + addressLabel->setText( output ); } -- cgit v0.9.0.2