summaryrefslogtreecommitdiff
path: root/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
Unidiff
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() {
81 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); 81 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() );
82 m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true ); 82 m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true );
83 m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true ); 83 m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true );
84} 84}
85 85
86 86
87/** 87/**
88 * Get the addresss 88 * Get the addresss
89 */ 89 */
90void AddressBookPluginWidget::getAddress() { 90void AddressBookPluginWidget::getAddress() {
91 91
92 if ( ! layoutTodo ){ 92 if ( ! layoutTodo ){
93 layoutTodo = new QVBoxLayout( this ); 93 layoutTodo = new QVBoxLayout( this );
94 } 94 }
95 95
96 if ( ! addressLabel ) { 96 if ( ! addressLabel ) {
97 addressLabel = new OClickableLabel( this ); 97 addressLabel = new OClickableLabel( this );
98 connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) ); 98 connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) );
99 layoutTodo->addWidget( addressLabel ); 99 layoutTodo->addWidget( addressLabel );
100 } 100 }
101 101
102 QString output; 102 QString output;
103 103
104 // Check whether the database provide the search option.. 104 // Check whether the database provide the search option..
105 if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ 105 if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){
106 // Libopie seems to be old.. 106 // Libopie seems to be old..
107 output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" ); 107 output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" );
108 addressLabel->setText( output ); 108 addressLabel->setText( output );
109 return; 109 return;
110 } 110 }
111 111
112 // Define the query for birthdays and start search.. 112 // Define the query for birthdays and start search..
113 QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); 113 QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead );
114 int ammount = 0; 114 int ammount = 0;
115 if ( m_showBirthdays ){ 115 if ( m_showBirthdays ){
116 qWarning("Searching from now (%s) until %s ! ", 116 qWarning("Searching from now (%s) until %s ! ",
117 QDate::currentDate().toString().latin1(), 117 QDate::currentDate().toString().latin1(),
118 lookAheadDate.toString().latin1() ); 118 lookAheadDate.toString().latin1() );
119 }
120
121 if ( m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){
122
119 123
120 OContact querybirthdays; 124 OContact querybirthdays;
121 querybirthdays.setBirthday( lookAheadDate ); 125 querybirthdays.setBirthday( lookAheadDate );
122 126
123 m_list = m_contactdb->queryByExample( querybirthdays, 127 m_list = m_contactdb->queryByExample( querybirthdays,
124 OContactAccess::DateDiff ); 128 OContactAccess::DateDiff );
125 if ( m_list.count() > 0 ){ 129 if ( m_list.count() > 0 ){
126 output = "<font color=" + m_headlineColor + ">" 130 output = "<font color=" + m_headlineColor + ">"
127 + QObject::tr( "Next birthdays in <b> %1 </b> days:" ) 131 + QObject::tr( "Next birthdays in <b> %1 </b> days:" )
128 .arg( m_daysLookAhead ) 132 .arg( m_daysLookAhead )
129 + "</font> <br>"; 133 + "</font> <br>";
130 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { 134 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
131 if ( ammount++ < m_maxLinesTask ){ 135 if ( ammount++ < m_maxLinesTask ){
132 // Now we want to calculate how many days 136 // Now we want to calculate how many days
133 //until birthday. We have to set 137 //until birthday. We have to set
134 // the correct year to calculate the day diff... 138 // the correct year to calculate the day diff...
135 QDate destdate = (*m_it).birthday(); 139 QDate destdate = (*m_it).birthday();
136 destdate.setYMD( QDate::currentDate().year(), 140 destdate.setYMD( QDate::currentDate().year(),
137 destdate.month(), destdate.day() ); 141 destdate.month(), destdate.day() );
138 if ( QDate::currentDate().daysTo(destdate) < 0 ) 142 if ( QDate::currentDate().daysTo(destdate) < 0 )
139 destdate.setYMD( QDate::currentDate().year()+1, 143 destdate.setYMD( QDate::currentDate().year()+1,
140 destdate.month(), destdate.day() ); 144 destdate.month(), destdate.day() );
141 145
142 146