Diffstat (limited to 'core/pim/addressbook/abview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/abview.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp index 7abb45c..6be19f8 100644 --- a/core/pim/addressbook/abview.cpp +++ b/core/pim/addressbook/abview.cpp | |||
@@ -112,177 +112,188 @@ void AbView::addEntry( const Opie::OPimContact &newContact ) | |||
112 | load(); | 112 | load(); |
113 | 113 | ||
114 | } | 114 | } |
115 | void AbView::removeEntry( const int UID ) | 115 | void AbView::removeEntry( const int UID ) |
116 | { | 116 | { |
117 | odebug << "AbView;:RemoveContact" << oendl; | 117 | odebug << "AbView;:RemoveContact" << oendl; |
118 | m_contactdb->remove( UID ); | 118 | m_contactdb->remove( UID ); |
119 | load(); | 119 | load(); |
120 | } | 120 | } |
121 | 121 | ||
122 | void AbView::replaceEntry( const Opie::OPimContact &contact ) | 122 | void AbView::replaceEntry( const Opie::OPimContact &contact ) |
123 | { | 123 | { |
124 | odebug << "AbView::ReplaceContact" << oendl; | 124 | odebug << "AbView::ReplaceContact" << oendl; |
125 | m_contactdb->replace( contact ); | 125 | m_contactdb->replace( contact ); |
126 | load(); | 126 | load(); |
127 | 127 | ||
128 | } | 128 | } |
129 | 129 | ||
130 | Opie::OPimContact AbView::currentEntry() | 130 | Opie::OPimContact AbView::currentEntry() |
131 | { | 131 | { |
132 | Opie::OPimContact currentContact; | 132 | Opie::OPimContact currentContact; |
133 | 133 | ||
134 | switch ( (int) m_curr_View ) { | 134 | switch ( (int) m_curr_View ) { |
135 | case TableView: | 135 | case TableView: |
136 | currentContact = m_abTable -> currentEntry(); | 136 | currentContact = m_abTable -> currentEntry(); |
137 | break; | 137 | break; |
138 | case CardView: | 138 | case CardView: |
139 | currentContact = m_ablabel -> currentEntry(); | 139 | currentContact = m_ablabel -> currentEntry(); |
140 | break; | 140 | break; |
141 | } | 141 | } |
142 | m_curr_Contact = currentContact.uid(); | 142 | m_curr_Contact = currentContact.uid(); |
143 | return currentContact; | 143 | return currentContact; |
144 | } | 144 | } |
145 | 145 | ||
146 | bool AbView::save() | 146 | bool AbView::save() |
147 | { | 147 | { |
148 | //odebug << "AbView::Save data" << oendl; | 148 | //odebug << "AbView::Save data" << oendl; |
149 | 149 | ||
150 | return m_contactdb->save(); | 150 | return m_contactdb->save(); |
151 | } | 151 | } |
152 | 152 | ||
153 | void AbView::load() | 153 | void AbView::load() |
154 | { | 154 | { |
155 | odebug << "AbView::Load data" << oendl; | 155 | odebug << "AbView::Load data" << oendl; |
156 | 156 | ||
157 | // Letter Search is stopped at this place | 157 | // Letter Search is stopped at this place |
158 | emit signalClearLetterPicker(); | 158 | emit signalClearLetterPicker(); |
159 | 159 | ||
160 | if ( m_inPersonal ) | 160 | if ( m_curr_category == 0 ) { |
161 | // VCard Backend does not sort.. | 161 | // Show unfiled |
162 | m_list = m_contactdb->allRecords(); | 162 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, |
163 | else{ | 163 | Opie::OPimContactAccess::DoNotShowWithCategory, 0 ); |
164 | m_list = m_contactdb->sorted( true, 0, 0, 0 ); | 164 | } elseif ( m_curr_category != -1 ){ |
165 | if ( m_curr_category != -1 ) | 165 | // Just show selected category |
166 | clearForCategory(); | 166 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, |
167 | Opie::OPimBase::FilterCategory, m_curr_category ); | ||
168 | } else { | ||
169 | // Show all categories | ||
170 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, | ||
171 | Opie::OPimBase::FilterOff, 0 ); | ||
167 | } | 172 | } |
173 | |||
174 | // if ( m_curr_category != -1 ) | ||
175 | // clearForCategory(); | ||
168 | 176 | ||
169 | odebug << "Number of contacts: " << m_list.count() << oendl; | 177 | odebug << "Number of contacts: " << m_list.count() << oendl; |
170 | 178 | ||
171 | updateView( true ); | 179 | updateView( true ); |
172 | 180 | ||
173 | } | 181 | } |
174 | 182 | ||
175 | void AbView::reload() | 183 | void AbView::reload() |
176 | { | 184 | { |
177 | odebug << "AbView::::reload()" << oendl; | 185 | odebug << "AbView::::reload()" << oendl; |
178 | 186 | ||
179 | m_contactdb->reload(); | 187 | m_contactdb->reload(); |
180 | load(); | 188 | load(); |
181 | } | 189 | } |
182 | 190 | ||
183 | void AbView::clear() | 191 | void AbView::clear() |
184 | { | 192 | { |
185 | // :SX | 193 | // :SX |
186 | } | 194 | } |
187 | 195 | ||
188 | void AbView::setShowByCategory( const QString& cat ) | 196 | void AbView::setShowByCategory( const QString& cat ) |
189 | { | 197 | { |
190 | odebug << "AbView::setShowCategory( const QString& cat )" << oendl; | 198 | odebug << "AbView::setShowCategory( const QString& cat )" << oendl; |
191 | 199 | ||
192 | int intCat = 0; | 200 | int intCat = 0; |
193 | 201 | ||
194 | // All (cat == NULL) will be stored as -1 | 202 | // All (cat == NULL) will be stored as -1 |
195 | if ( cat.isNull() ) | 203 | if ( cat.isNull() ) |
196 | intCat = -1; | 204 | intCat = -1; |
197 | else | 205 | else |
198 | intCat = mCat.id("Contacts", cat ); | 206 | intCat = mCat.id("Contacts", cat ); |
199 | 207 | ||
200 | // Just do anything if we really change the category | 208 | // Just do anything if we really change the category |
201 | if ( intCat != m_curr_category ){ | 209 | if ( intCat != m_curr_category ){ |
202 | // odebug << "Categories: Selected " << cat << ".. Number: " | 210 | // odebug << "Categories: Selected " << cat << ".. Number: " |
203 | // << m_curr_category << oendl; | 211 | // << m_curr_category << oendl; |
204 | 212 | ||
205 | m_curr_category = intCat; | 213 | m_curr_category = intCat; |
206 | emit signalClearLetterPicker(); | 214 | emit signalClearLetterPicker(); |
207 | 215 | ||
208 | load(); | 216 | load(); |
209 | } | 217 | } |
210 | 218 | ||
211 | } | 219 | } |
212 | 220 | ||
213 | void AbView::setShowToView( Views view ) | 221 | void AbView::setShowToView( Views view ) |
214 | { | 222 | { |
215 | odebug << "void AbView::setShowToView( View " << view << " )" << oendl; | 223 | odebug << "void AbView::setShowToView( View " << view << " )" << oendl; |
216 | 224 | ||
217 | if ( m_curr_View != view ){ | 225 | if ( m_curr_View != view ){ |
218 | odebug << "Change the View (Category is: " << m_curr_category << ")" << oendl; | 226 | odebug << "Change the View (Category is: " << m_curr_category << ")" << oendl; |
219 | m_prev_View = m_curr_View; | 227 | m_prev_View = m_curr_View; |
220 | m_curr_View = view; | 228 | m_curr_View = view; |
221 | 229 | ||
222 | updateView(); | 230 | updateView(); |
223 | } | 231 | } |
224 | 232 | ||
225 | } | 233 | } |
226 | 234 | ||
227 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) | 235 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) |
228 | { | 236 | { |
229 | odebug << "void AbView::setShowByLetter( " << c << ", " << mode << " )" << oendl; | 237 | odebug << "void AbView::setShowByLetter( " << c << ", " << mode << " )" << oendl; |
230 | 238 | ||
231 | assert( mode < AbConfig::LASTELEMENT ); | 239 | assert( mode < AbConfig::LASTELEMENT ); |
232 | 240 | ||
233 | Opie::OPimContact query; | 241 | Opie::OPimContact query; |
234 | if ( c == 0 ){ | 242 | if ( c == 0 ){ |
235 | load(); | 243 | load(); |
236 | return; | 244 | return; |
237 | }else{ | 245 | }else{ |
238 | // If the current Backend is unable to solve the query, we will | 246 | // If the current Backend is unable to solve the query, we will |
239 | // ignore the request .. | 247 | // ignore the request .. |
240 | if ( ! m_contactdb->hasQuerySettings( Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ) ){ | 248 | if ( ! m_contactdb->hasQuerySettings( Opie::OPimContactAccess::WildCards | |
249 | Opie::OPimContactAccess::IgnoreCase ) ){ | ||
250 | owarn << "Tried to access queryByExample which is not supported by the current backend!!" << oendl; | ||
251 | owarn << "I have to ignore this access!" << oendl; | ||
241 | return; | 252 | return; |
242 | } | 253 | } |
243 | 254 | ||
244 | switch( mode ){ | 255 | switch( mode ){ |
245 | case AbConfig::LastName: | 256 | case AbConfig::LastName: |
246 | query.setLastName( QString("%1*").arg(c) ); | 257 | query.setLastName( QString("%1*").arg(c) ); |
247 | break; | 258 | break; |
248 | case AbConfig::FileAs: | 259 | case AbConfig::FileAs: |
249 | query.setFileAs( QString("%1*").arg(c) ); | 260 | query.setFileAs( QString("%1*").arg(c) ); |
250 | break; | 261 | break; |
251 | default: | 262 | default: |
252 | owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl | 263 | owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl |
253 | << "I will ignore it.." << oendl; | 264 | << "I will ignore it.." << oendl; |
254 | return; | 265 | return; |
255 | } | 266 | } |
256 | m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); | 267 | m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); |
257 | if ( m_curr_category != -1 ) | 268 | if ( m_curr_category != -1 ) |
258 | clearForCategory(); | 269 | clearForCategory(); |
259 | m_curr_Contact = 0; | 270 | m_curr_Contact = 0; |
260 | } | 271 | } |
261 | updateView( true ); | 272 | updateView( true ); |
262 | } | 273 | } |
263 | 274 | ||
264 | void AbView::setListOrder( const QValueList<int>& ordered ) | 275 | void AbView::setListOrder( const QValueList<int>& ordered ) |
265 | { | 276 | { |
266 | m_orderedFields = ordered; | 277 | m_orderedFields = ordered; |
267 | if ( m_abTable ){ | 278 | if ( m_abTable ){ |
268 | m_abTable->setOrderedList( ordered ); | 279 | m_abTable->setOrderedList( ordered ); |
269 | m_abTable->refresh(); | 280 | m_abTable->refresh(); |
270 | } | 281 | } |
271 | updateView(); | 282 | updateView(); |
272 | } | 283 | } |
273 | 284 | ||
274 | 285 | ||
275 | QString AbView::showCategory() const | 286 | QString AbView::showCategory() const |
276 | { | 287 | { |
277 | return mCat.label( "Contacts", m_curr_category ); | 288 | return mCat.label( "Contacts", m_curr_category ); |
278 | } | 289 | } |
279 | 290 | ||
280 | void AbView::showPersonal( bool personal ) | 291 | void AbView::showPersonal( bool personal ) |
281 | { | 292 | { |
282 | odebug << "void AbView::showPersonal( " << personal << " )" << oendl; | 293 | odebug << "void AbView::showPersonal( " << personal << " )" << oendl; |
283 | 294 | ||
284 | if ( personal ){ | 295 | if ( personal ){ |
285 | 296 | ||
286 | if ( m_inPersonal ) | 297 | if ( m_inPersonal ) |
287 | return; | 298 | return; |
288 | 299 | ||