summaryrefslogtreecommitdiff
authorzecke <zecke>2005-06-27 18:38:39 (UTC)
committer zecke <zecke>2005-06-27 18:38:39 (UTC)
commitb82756d94b91516a7c36903648382a224a36f0e2 (patch) (unidiff)
tree006d574768ad60e94860f9f59a9e91ccf29c71f4
parentc3d21fe2179b4841cc95b4ee9ecac6b053e9ee17 (diff)
downloadopie-b82756d94b91516a7c36903648382a224a36f0e2.zip
opie-b82756d94b91516a7c36903648382a224a36f0e2.tar.gz
opie-b82756d94b91516a7c36903648382a224a36f0e2.tar.bz2
Use the two new Sort Flags. I applied an older/wrong version of the patch before
Patch courtsey Marcin Juszkiewicz
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/plugins/addressbook/addresspluginwidget.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
index d74df51..7346cae 100644
--- a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
+++ b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
@@ -25,201 +25,201 @@
25 25
26AddressBookPluginWidget::AddressBookPluginWidget( QWidget *parent, const char* name ) 26AddressBookPluginWidget::AddressBookPluginWidget( QWidget *parent, const char* name )
27 : QWidget( parent, name ) { 27 : QWidget( parent, name ) {
28 28
29 addressLabel = 0l; 29 addressLabel = 0l;
30 m_contactdb = 0l; 30 m_contactdb = 0l;
31 layoutTodo = 0l; 31 layoutTodo = 0l;
32 32
33 m_contactdb = new Opie::OPimContactAccess("addressplugin"); 33 m_contactdb = new Opie::OPimContactAccess("addressplugin");
34 34
35 connect( m_contactdb, SIGNAL( signalChanged(const Opie::OPimContactAccess*) ), 35 connect( m_contactdb, SIGNAL( signalChanged(const Opie::OPimContactAccess*) ),
36 this, SLOT( refresh(const Opie::OPimContactAccess*) ) ); 36 this, SLOT( refresh(const Opie::OPimContactAccess*) ) );
37 37
38 38
39 readConfig(); 39 readConfig();
40 getAddress(); 40 getAddress();
41} 41}
42 42
43AddressBookPluginWidget::~AddressBookPluginWidget() { 43AddressBookPluginWidget::~AddressBookPluginWidget() {
44 delete m_contactdb; 44 delete m_contactdb;
45} 45}
46 46
47void AddressBookPluginWidget::refresh( const Opie::OPimContactAccess* ) 47void AddressBookPluginWidget::refresh( const Opie::OPimContactAccess* )
48{ 48{
49 owarn << " AddressBookPluginWidget::Database was changed externally ! " << oendl; 49 owarn << " AddressBookPluginWidget::Database was changed externally ! " << oendl;
50 m_contactdb->reload(); 50 m_contactdb->reload();
51 getAddress(); 51 getAddress();
52} 52}
53 53
54void AddressBookPluginWidget::reinitialize() { 54void AddressBookPluginWidget::reinitialize() {
55 readConfig(); 55 readConfig();
56 getAddress(); 56 getAddress();
57} 57}
58 58
59void AddressBookPluginWidget::readConfig() { 59void AddressBookPluginWidget::readConfig() {
60 Config cfg( "todayaddressplugin" ); 60 Config cfg( "todayaddressplugin" );
61 cfg.setGroup( "config" ); 61 cfg.setGroup( "config" );
62 m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); 62 m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 );
63 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); 63 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 );
64 m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); 64 m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 );
65 m_urgentDays = cfg.readNumEntry( "urgentdays", 7 ); 65 m_urgentDays = cfg.readNumEntry( "urgentdays", 7 );
66 m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() ); 66 m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() );
67 m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() ); 67 m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() );
68 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); 68 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() );
69 m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true ); 69 m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true );
70 m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true ); 70 m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true );
71} 71}
72 72
73 73
74/** 74/**
75 * Get the addresss 75 * Get the addresss
76 */ 76 */
77void AddressBookPluginWidget::getAddress() { 77void AddressBookPluginWidget::getAddress() {
78 78
79 if ( ! layoutTodo ){ 79 if ( ! layoutTodo ){
80 layoutTodo = new QVBoxLayout( this ); 80 layoutTodo = new QVBoxLayout( this );
81 } 81 }
82 82
83 if ( ! addressLabel ) { 83 if ( ! addressLabel ) {
84 addressLabel = new Opie::Ui::OClickableLabel( this ); 84 addressLabel = new Opie::Ui::OClickableLabel( this );
85 connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) ); 85 connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) );
86 layoutTodo->addWidget( addressLabel ); 86 layoutTodo->addWidget( addressLabel );
87 } 87 }
88 88
89 QString output; 89 QString output;
90 90
91 // Check whether the database provide the search option.. 91 // Check whether the database provide the search option..
92 if ( !m_contactdb->hasQuerySettings( Opie::OPimContactAccess::DateDiff ) ){ 92 if ( !m_contactdb->hasQuerySettings( Opie::OPimContactAccess::DateDiff ) ){
93 // Libopie seems to be old.. 93 // Libopie seems to be old..
94 output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" ); 94 output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" );
95 addressLabel->setText( output ); 95 addressLabel->setText( output );
96 return; 96 return;
97 } 97 }
98 98
99 // Define the query for birthdays and start search.. 99 // Define the query for birthdays and start search..
100 QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); 100 QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead );
101 int ammount = 0; 101 int ammount = 0;
102 if ( m_showBirthdays ){ 102 if ( m_showBirthdays ){
103 owarn << "Searching from now (" << QDate::currentDate().toString() << ") until " 103 owarn << "Searching from now (" << QDate::currentDate().toString() << ") until "
104 << lookAheadDate.toString() << " ! " << oendl; 104 << lookAheadDate.toString() << " ! " << oendl;
105 105
106 if ( m_contactdb->hasQuerySettings( Opie::OPimContactAccess::DateDiff ) ){ 106 if ( m_contactdb->hasQuerySettings( Opie::OPimContactAccess::DateDiff ) ){
107 107
108 108
109 Opie::OPimContact querybirthdays; 109 Opie::OPimContact querybirthdays;
110 querybirthdays.setBirthday( lookAheadDate ); 110 querybirthdays.setBirthday( lookAheadDate );
111 111
112 m_list = m_contactdb->queryByExample( querybirthdays, 112 m_list = m_contactdb->queryByExample( querybirthdays,
113 Opie::OPimContactAccess::DateDiff ); 113 Opie::OPimContactAccess::DateDiff );
114 if ( m_list.count() > 0 ){ 114 if ( m_list.count() > 0 ){
115 output = "<font color=" + m_headlineColor + ">" 115 output = "<font color=" + m_headlineColor + ">"
116 + QObject::tr( "Next birthdays in <b> %1 </b> days:" ) 116 + QObject::tr( "Next birthdays in <b> %1 </b> days:" )
117 .arg( m_daysLookAhead ) 117 .arg( m_daysLookAhead )
118 + "</font> <br>"; 118 + "</font> <br>";
119 119
120 // Sort filtered results 120 // Sort filtered results
121 m_list = m_contactdb->sorted( m_list, true, Opie::OPimContactAccess::SortBirthday, 121 m_list = m_contactdb->sorted( m_list, true, Opie::OPimContactAccess::SortBirthdayWithoutYear,
122 Opie::OPimContactAccess::FilterOff, 0 ); 122 Opie::OPimContactAccess::FilterOff, 0 );
123 123
124 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { 124 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
125 if ( ammount++ < m_maxLinesTask ){ 125 if ( ammount++ < m_maxLinesTask ){
126 // Now we want to calculate how many days 126 // Now we want to calculate how many days
127 //until birthday. We have to set 127 //until birthday. We have to set
128 // the correct year to calculate the day diff... 128 // the correct year to calculate the day diff...
129 QDate destdate = (*m_it).birthday(); 129 QDate destdate = (*m_it).birthday();
130 destdate.setYMD( QDate::currentDate().year(), 130 destdate.setYMD( QDate::currentDate().year(),
131 destdate.month(), destdate.day() ); 131 destdate.month(), destdate.day() );
132 if ( QDate::currentDate().daysTo(destdate) < 0 ) 132 if ( QDate::currentDate().daysTo(destdate) < 0 )
133 destdate.setYMD( QDate::currentDate().year()+1, 133 destdate.setYMD( QDate::currentDate().year()+1,
134 destdate.month(), destdate.day() ); 134 destdate.month(), destdate.day() );
135 135
136 136
137 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) 137 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays )
138 output += "<font color=" + m_urgentColor + "><b>-" 138 output += "<font color=" + m_urgentColor + "><b>-"
139 + (*m_it).fullName() 139 + (*m_it).fullName()
140 + " (" 140 + " ("
141 + QString::number(QDate::currentDate() 141 + QString::number(QDate::currentDate()
142 .daysTo(destdate)) 142 .daysTo(destdate))
143 + " Days) </b></font><br>"; 143 + " Days) </b></font><br>";
144 144
145 else 145 else
146 output += "<font color=" + m_entryColor + "><b>-" 146 output += "<font color=" + m_entryColor + "><b>-"
147 + (*m_it).fullName() 147 + (*m_it).fullName()
148 + " (" 148 + " ("
149 + QString::number(QDate::currentDate() 149 + QString::number(QDate::currentDate()
150 .daysTo(destdate)) 150 .daysTo(destdate))
151 + " Days) </b></font><br>"; 151 + " Days) </b></font><br>";
152 } 152 }
153 } 153 }
154 } else { 154 } else {
155 output = "<font color=" + m_headlineColor + ">" 155 output = "<font color=" + m_headlineColor + ">"
156 + QObject::tr( "No birthdays in <b> %1 </b> days!" ) 156 + QObject::tr( "No birthdays in <b> %1 </b> days!" )
157 .arg( m_daysLookAhead ) 157 .arg( m_daysLookAhead )
158 + "</font> <br>"; 158 + "</font> <br>";
159 } 159 }
160 } 160 }
161 } 161 }
162 162
163 if ( m_showAnniversaries ){ 163 if ( m_showAnniversaries ){
164 // Define the query for anniversaries and start search.. 164 // Define the query for anniversaries and start search..
165 Opie::OPimContact queryanniversaries; 165 Opie::OPimContact queryanniversaries;
166 queryanniversaries.setAnniversary( lookAheadDate ); 166 queryanniversaries.setAnniversary( lookAheadDate );
167 167
168 m_list = m_contactdb->queryByExample( queryanniversaries, Opie::OPimContactAccess::DateDiff ); 168 m_list = m_contactdb->queryByExample( queryanniversaries, Opie::OPimContactAccess::DateDiff );
169 169
170 ammount = 0; 170 ammount = 0;
171 if ( m_list.count() > 0 ){ 171 if ( m_list.count() > 0 ){
172 output += "<font color=" + m_headlineColor + ">" 172 output += "<font color=" + m_headlineColor + ">"
173 + QObject::tr( "Next anniversaries in <b> %1 </b> days:" ) 173 + QObject::tr( "Next anniversaries in <b> %1 </b> days:" )
174 .arg( m_daysLookAhead ) 174 .arg( m_daysLookAhead )
175 + "</font> <br>"; 175 + "</font> <br>";
176 176
177 // Sort filtered results 177 // Sort filtered results
178 m_list = m_contactdb->sorted( m_list, true, Opie::OPimContactAccess::SortAnniversary, 178 m_list = m_contactdb->sorted( m_list, true, Opie::OPimContactAccess::SortAnniversaryWithoutYear,
179 Opie::OPimContactAccess::FilterOff, 0 ); 179 Opie::OPimContactAccess::FilterOff, 0 );
180 180
181 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { 181 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
182 if ( ammount++ < m_maxLinesTask ){ 182 if ( ammount++ < m_maxLinesTask ){
183 // Now we want to calculate how many days until anniversary. 183 // Now we want to calculate how many days until anniversary.
184 // We have to set the correct year to calculate the day diff... 184 // We have to set the correct year to calculate the day diff...
185 QDate destdate = (*m_it).anniversary(); 185 QDate destdate = (*m_it).anniversary();
186 destdate.setYMD( QDate::currentDate().year(), destdate.month(), 186 destdate.setYMD( QDate::currentDate().year(), destdate.month(),
187 destdate.day() ); 187 destdate.day() );
188 if ( QDate::currentDate().daysTo(destdate) < 0 ) 188 if ( QDate::currentDate().daysTo(destdate) < 0 )
189 destdate.setYMD( QDate::currentDate().year()+1, 189 destdate.setYMD( QDate::currentDate().year()+1,
190 destdate.month(), destdate.day() ); 190 destdate.month(), destdate.day() );
191 191
192 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) 192 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays )
193 output += "<font color=" + m_urgentColor + "><b>-" 193 output += "<font color=" + m_urgentColor + "><b>-"
194 + (*m_it).fullName() 194 + (*m_it).fullName()
195 + " (" 195 + " ("
196 + QString::number(QDate::currentDate() 196 + QString::number(QDate::currentDate()
197 .daysTo( destdate ) ) 197 .daysTo( destdate ) )
198 + " Days) </b></font><br>"; 198 + " Days) </b></font><br>";
199 else 199 else
200 output += "<font color=" + m_entryColor + "><b>-" 200 output += "<font color=" + m_entryColor + "><b>-"
201 + (*m_it).fullName() 201 + (*m_it).fullName()
202 + " (" 202 + " ("
203 + QString::number(QDate::currentDate() 203 + QString::number(QDate::currentDate()
204 .daysTo( destdate ) ) 204 .daysTo( destdate ) )
205 + " Days) </b></font><br>"; 205 + " Days) </b></font><br>";
206 } 206 }
207 } 207 }
208 } else { 208 } else {
209 output += "<font color=" + m_headlineColor + ">" 209 output += "<font color=" + m_headlineColor + ">"
210 + QObject::tr( "No anniversaries in <b> %1 </b> days!" ) 210 + QObject::tr( "No anniversaries in <b> %1 </b> days!" )
211 .arg( m_daysLookAhead ) 211 .arg( m_daysLookAhead )
212 + "</font> <br>"; 212 + "</font> <br>";
213 } 213 }
214 } 214 }
215 215
216 addressLabel->setText( output ); 216 addressLabel->setText( output );
217} 217}
218 218
219/** 219/**
220 * start the todolist 220 * start the todolist
221 */ 221 */
222void AddressBookPluginWidget::startAddressBook() { 222void AddressBookPluginWidget::startAddressBook() {
223 QCopEnvelope e( "QPE/System", "execute(QString)" ); 223 QCopEnvelope e( "QPE/System", "execute(QString)" );
224 e << QString( "addressbook" ); 224 e << QString( "addressbook" );
225} 225}