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.cpp55
1 files changed, 40 insertions, 15 deletions
diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
index c81beee..7d87fca 100644
--- a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
+++ b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
@@ -68,10 +68,13 @@ void AddressBookPluginWidget::refresh( const OContactAccess* )
68void AddressBookPluginWidget::readConfig() { 68void AddressBookPluginWidget::readConfig() {
69 Config cfg( "todayaddressplugin" ); 69 Config cfg( "todayaddressplugin" );
70 cfg.setGroup( "config" ); 70 cfg.setGroup( "config" );
71 m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); 71 m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 );
72 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); 72 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 );
73 m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); 73 m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 );
74 m_entryColor = cfg.readEntry("entrycolor", Qt::red.name() ); 74 m_urgentDays = cfg.readNumEntry( "urgentdays", 7 );
75 m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() );
76 m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() );
77 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() );
75} 78}
76 79
77 80
@@ -106,7 +109,9 @@ void AddressBookPluginWidget::getAddress() {
106 109
107 m_list = m_contactdb->queryByExample( querybirthdays, OContactAccess::DateDiff ); 110 m_list = m_contactdb->queryByExample( querybirthdays, OContactAccess::DateDiff );
108 if ( m_list.count() > 0 ){ 111 if ( m_list.count() > 0 ){
109 output = QObject::tr( "Next birthdays in <b> %1 </b> days: <br>" ).arg( m_daysLookAhead ); 112 output = "<font color=" + m_headlineColor + ">"
113 + QObject::tr( "Next birthdays in <b> %1 </b> days:" ).arg( m_daysLookAhead )
114 + "</font> <br>";
110 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { 115 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
111 if ( ammount++ < m_maxLinesTask ){ 116 if ( ammount++ < m_maxLinesTask ){
112 // Now we want to calculate how many days until birthday. We have to set 117 // Now we want to calculate how many days until birthday. We have to set
@@ -116,14 +121,24 @@ void AddressBookPluginWidget::getAddress() {
116 if ( QDate::currentDate().daysTo(destdate) < 0 ) 121 if ( QDate::currentDate().daysTo(destdate) < 0 )
117 destdate.setYMD( QDate::currentDate().year()+1, destdate.month(), destdate.day() ); 122 destdate.setYMD( QDate::currentDate().year()+1, destdate.month(), destdate.day() );
118 123
119 output += "<font color=" + m_entryColor + "><b>-" + (*m_it).fullName() 124
120 + " (" 125 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays )
121 + QString::number(QDate::currentDate().daysTo(destdate)) 126 output += "<font color=" + m_urgentColor + "><b>-" + (*m_it).fullName()
122 + " Days) </b></font><br>"; 127 + " ("
128 + QString::number(QDate::currentDate().daysTo(destdate))
129 + " Days) </b></font><br>";
130
131 else
132 output += "<font color=" + m_entryColor + "><b>-" + (*m_it).fullName()
133 + " ("
134 + QString::number(QDate::currentDate().daysTo(destdate))
135 + " Days) </b></font><br>";
123 } 136 }
124 } 137 }
125 } else { 138 } else {
126 output = QObject::tr( "No birthdays in <b> %1 </b> days! <br>" ).arg( m_daysLookAhead ); 139 output = "<font color=" + m_headlineColor + ">"
140 + QObject::tr( "No birthdays in <b> %1 </b> days!" ).arg( m_daysLookAhead )
141 + "</font> <br>";
127 } 142 }
128 143
129 // Define the query for anniversaries and start search.. 144 // Define the query for anniversaries and start search..
@@ -134,7 +149,9 @@ void AddressBookPluginWidget::getAddress() {
134 149
135 ammount = 0; 150 ammount = 0;
136 if ( m_list.count() > 0 ){ 151 if ( m_list.count() > 0 ){
137 output += QObject::tr( "Next anniversaries in <b> %1 </b> days: <br>" ).arg( m_daysLookAhead ); 152 output += "<font color=" + m_headlineColor + ">"
153 + QObject::tr( "Next anniversaries in <b> %1 </b> days:" ).arg( m_daysLookAhead )
154 + "</font> <br>";
138 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { 155 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
139 if ( ammount++ < m_maxLinesTask ){ 156 if ( ammount++ < m_maxLinesTask ){
140 // Now we want to calculate how many days until anniversary. We have to set 157 // Now we want to calculate how many days until anniversary. We have to set
@@ -144,14 +161,22 @@ void AddressBookPluginWidget::getAddress() {
144 if ( QDate::currentDate().daysTo(destdate) < 0 ) 161 if ( QDate::currentDate().daysTo(destdate) < 0 )
145 destdate.setYMD( QDate::currentDate().year()+1, destdate.month(), destdate.day() ); 162 destdate.setYMD( QDate::currentDate().year()+1, destdate.month(), destdate.day() );
146 163
147 output += "<font color=#e00000><b>-" + (*m_it).fullName() 164 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays )
148 + " (" 165 output += "<font color=" + m_urgentColor + "><b>-" + (*m_it).fullName()
149 + QString::number(QDate::currentDate().daysTo( destdate ) ) 166 + " ("
150 + " Days) </b></font><br>"; 167 + QString::number(QDate::currentDate().daysTo( destdate ) )
168 + " Days) </b></font><br>";
169 else
170 output += "<font color=" + m_entryColor + "><b>-" + (*m_it).fullName()
171 + " ("
172 + QString::number(QDate::currentDate().daysTo( destdate ) )
173 + " Days) </b></font><br>";
151 } 174 }
152 } 175 }
153 } else { 176 } else {
154 output += QObject::tr( "No anniversaries in <b> %1 </b> days! <br>" ).arg( m_daysLookAhead ); 177 output += "<font color=" + m_headlineColor + ">"
178 + QObject::tr( "No anniversaries in <b> %1 </b> days!" ).arg( m_daysLookAhead )
179 + "</font> <br>";
155 } 180 }
156 181
157 182