author | eilers <eilers> | 2003-07-07 16:17:27 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-07-07 16:17:27 (UTC) |
commit | 1c24ec58bd7fc8a0a46cdaf41e4c6b7e68e4dba6 (patch) (side-by-side diff) | |
tree | f18795fbdb55d60091738d9eb5d67663016a9820 /core/pim/today/plugins/addressbook/addresspluginwidget.cpp | |
parent | 2f6b0ede633948b44a5ed3ee1ec641395620f076 (diff) | |
download | opie-1c24ec58bd7fc8a0a46cdaf41e4c6b7e68e4dba6.zip opie-1c24ec58bd7fc8a0a46cdaf41e4c6b7e68e4dba6.tar.gz opie-1c24ec58bd7fc8a0a46cdaf41e4c6b7e68e4dba6.tar.bz2 |
Adding feature: Disabling/Enabling of Birthdays/Anniversaries is possible, now !
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.cpp | 83 |
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() { m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); + m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true ); + m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true ); } @@ -98,3 +100,11 @@ void AddressBookPluginWidget::getAddress() { // Check whether the database provide the search option.. - if ( ! m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ + // 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 !<br>" ); + addressLabel->setText( output ); + return; + } @@ -102,3 +112,6 @@ void AddressBookPluginWidget::getAddress() { QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); - qWarning("Searching from now (%s) until %s ! ", QDate::currentDate().toString().latin1(), + int ammount = 0; + if ( m_showBirthdays ){ + qWarning("Searching from now (%s) until %s ! ", + QDate::currentDate().toString().latin1(), lookAheadDate.toString().latin1() ); @@ -107,8 +120,9 @@ void AddressBookPluginWidget::getAddress() { - 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 = "<font color=" + m_headlineColor + ">" - + QObject::tr( "Next birthdays in <b> %1 </b> days:" ).arg( m_daysLookAhead ) + + QObject::tr( "Next birthdays in <b> %1 </b> days:" ) + .arg( m_daysLookAhead ) + "</font> <br>"; @@ -116,8 +130,11 @@ void AddressBookPluginWidget::getAddress() { 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() ); @@ -125,5 +142,7 @@ void AddressBookPluginWidget::getAddress() { if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) - output += "<font color=" + m_urgentColor + "><b>-" + (*m_it).fullName() + output += "<font color=" + m_urgentColor + "><b>-" + + (*m_it).fullName() + " (" - + QString::number(QDate::currentDate().daysTo(destdate)) + + QString::number(QDate::currentDate() + .daysTo(destdate)) + " Days) </b></font><br>"; @@ -131,5 +150,7 @@ void AddressBookPluginWidget::getAddress() { else - output += "<font color=" + m_entryColor + "><b>-" + (*m_it).fullName() + output += "<font color=" + m_entryColor + "><b>-" + + (*m_it).fullName() + " (" - + QString::number(QDate::currentDate().daysTo(destdate)) + + QString::number(QDate::currentDate() + .daysTo(destdate)) + " Days) </b></font><br>"; @@ -139,6 +160,9 @@ void AddressBookPluginWidget::getAddress() { output = "<font color=" + m_headlineColor + ">" - + QObject::tr( "No birthdays in <b> %1 </b> days!" ).arg( m_daysLookAhead ) + + QObject::tr( "No birthdays in <b> %1 </b> days!" ) + .arg( m_daysLookAhead ) + "</font> <br>"; } + } + if ( m_showAnniversaries ){ // Define the query for anniversaries and start search.. @@ -152,3 +176,4 @@ void AddressBookPluginWidget::getAddress() { output += "<font color=" + m_headlineColor + ">" - + QObject::tr( "Next anniversaries in <b> %1 </b> days:" ).arg( m_daysLookAhead ) + + QObject::tr( "Next anniversaries in <b> %1 </b> days:" ) + .arg( m_daysLookAhead ) + "</font> <br>"; @@ -156,18 +181,24 @@ void AddressBookPluginWidget::getAddress() { 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 += "<font color=" + m_urgentColor + "><b>-" + (*m_it).fullName() + output += "<font color=" + m_urgentColor + "><b>-" + + (*m_it).fullName() + " (" - + QString::number(QDate::currentDate().daysTo( destdate ) ) + + QString::number(QDate::currentDate() + .daysTo( destdate ) ) + " Days) </b></font><br>"; else - output += "<font color=" + m_entryColor + "><b>-" + (*m_it).fullName() + output += "<font color=" + m_entryColor + "><b>-" + + (*m_it).fullName() + " (" - + QString::number(QDate::currentDate().daysTo( destdate ) ) + + QString::number(QDate::currentDate() + .daysTo( destdate ) ) + " Days) </b></font><br>"; @@ -177,10 +208,6 @@ void AddressBookPluginWidget::getAddress() { output += "<font color=" + m_headlineColor + ">" - + QObject::tr( "No anniversaries in <b> %1 </b> days!" ).arg( m_daysLookAhead ) + + QObject::tr( "No anniversaries in <b> %1 </b> days!" ) + .arg( m_daysLookAhead ) + "</font> <br>"; } - - - }else{ - // Libopie seems to be old.. - output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" ); } |