-rw-r--r-- | core/pim/addressbook/abtable.cpp | 13 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.h | 4 | ||||
-rw-r--r-- | core/pim/addressbook/abview.cpp | 4 |
3 files changed, 19 insertions, 2 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index a829dc2..a2617fa 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -121,128 +121,134 @@ void AbPickItem::setContentFromEditor( QWidget *w ) | |||
121 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) | 121 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) |
122 | : QTable( parent, name ), | 122 | : QTable( parent, name ), |
123 | lastSortCol( -1 ), | 123 | lastSortCol( -1 ), |
124 | asc( TRUE ), | 124 | asc( TRUE ), |
125 | intFields( order ), | 125 | intFields( order ), |
126 | enablePainting( true ), | 126 | enablePainting( true ), |
127 | columnVisible( true ), | 127 | columnVisible( true ), |
128 | countNested( 0 ) | 128 | countNested( 0 ) |
129 | { | 129 | { |
130 | //qWarning("C'tor start"); | 130 | //qWarning("C'tor start"); |
131 | 131 | ||
132 | setSelectionMode( NoSelection ); | 132 | setSelectionMode( NoSelection ); |
133 | init(); | 133 | init(); |
134 | setSorting( TRUE ); | 134 | setSorting( TRUE ); |
135 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), | 135 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), |
136 | this, SLOT(itemClicked(int,int)) ); | 136 | this, SLOT(itemClicked(int,int)) ); |
137 | 137 | ||
138 | contactList.clear(); | 138 | contactList.clear(); |
139 | //qWarning("C'tor end"); | 139 | //qWarning("C'tor end"); |
140 | } | 140 | } |
141 | 141 | ||
142 | AbTable::~AbTable() | 142 | AbTable::~AbTable() |
143 | { | 143 | { |
144 | } | 144 | } |
145 | 145 | ||
146 | void AbTable::init() | 146 | void AbTable::init() |
147 | { | 147 | { |
148 | // :SX showChar = '\0'; | 148 | // :SX showChar = '\0'; |
149 | setNumRows( 0 ); | 149 | setNumRows( 0 ); |
150 | setNumCols( 2 ); | 150 | setNumCols( 2 ); |
151 | 151 | ||
152 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 152 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
153 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 153 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
154 | setLeftMargin( 0 ); | 154 | setLeftMargin( 0 ); |
155 | verticalHeader()->hide(); | 155 | verticalHeader()->hide(); |
156 | columnVisible = true; | 156 | columnVisible = true; |
157 | } | 157 | } |
158 | 158 | ||
159 | void AbTable::setContacts( const OContactAccess::List& viewList ) | 159 | void AbTable::setContacts( const OContactAccess::List& viewList ) |
160 | { | 160 | { |
161 | //qWarning("AbTable::setContacts()"); | 161 | //qWarning("AbTable::setContacts()"); |
162 | 162 | ||
163 | clear(); | 163 | clear(); |
164 | m_viewList = viewList; | 164 | m_viewList = viewList; |
165 | 165 | ||
166 | setSorting( false ); | 166 | setSorting( false ); |
167 | setPaintingEnabled( FALSE ); | 167 | setPaintingEnabled( FALSE ); |
168 | 168 | ||
169 | OContactAccess::List::Iterator it; | 169 | OContactAccess::List::Iterator it; |
170 | setNumRows( m_viewList.count() ); | 170 | setNumRows( m_viewList.count() ); |
171 | int row = 0; | 171 | int row = 0; |
172 | for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) | 172 | for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) |
173 | insertIntoTable( *it, row++ ); | 173 | insertIntoTable( *it, row++ ); |
174 | 174 | ||
175 | setSorting( true ); | 175 | setSorting( true ); |
176 | 176 | ||
177 | resort(); | 177 | resort(); |
178 | 178 | ||
179 | updateVisible(); | 179 | updateVisible(); |
180 | 180 | ||
181 | setPaintingEnabled( TRUE ); | 181 | setPaintingEnabled( TRUE ); |
182 | 182 | ||
183 | } | 183 | } |
184 | 184 | ||
185 | void AbTable::setOrderedList( const QValueList<int> ordered ) | ||
186 | { | ||
187 | intFields = ordered; | ||
188 | } | ||
189 | |||
190 | |||
185 | bool AbTable::selectContact( int UID ) | 191 | bool AbTable::selectContact( int UID ) |
186 | { | 192 | { |
187 | //qWarning( "AbTable::selectContact( %d )", UID ); | 193 | //qWarning( "AbTable::selectContact( %d )", UID ); |
188 | int rows = numRows(); | 194 | int rows = numRows(); |
189 | AbTableItem *abi; | 195 | AbTableItem *abi; |
190 | OContact* foundContact = 0l; | 196 | OContact* foundContact = 0l; |
191 | bool found = false; | 197 | bool found = false; |
192 | 198 | ||
193 | setPaintingEnabled( FALSE ); | 199 | setPaintingEnabled( FALSE ); |
194 | for ( int r = 0; r < rows; ++r ) { | 200 | for ( int r = 0; r < rows; ++r ) { |
195 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 201 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
196 | foundContact = &contactList[abi]; | 202 | foundContact = &contactList[abi]; |
197 | if ( foundContact -> uid() == UID ){ | 203 | if ( foundContact -> uid() == UID ){ |
198 | ensureCellVisible( r, 0 ); | 204 | ensureCellVisible( r, 0 ); |
199 | setCurrentCell( r, 0 ); | 205 | setCurrentCell( r, 0 ); |
200 | found = true; | 206 | found = true; |
201 | break; | 207 | break; |
202 | } | 208 | } |
203 | } | 209 | } |
204 | 210 | ||
205 | if ( !found ){ | 211 | if ( !found ){ |
206 | ensureCellVisible( 0,0 ); | 212 | ensureCellVisible( 0,0 ); |
207 | setCurrentCell( 0, 0 ); | 213 | setCurrentCell( 0, 0 ); |
208 | } | 214 | } |
209 | 215 | ||
210 | setPaintingEnabled( TRUE ); | 216 | setPaintingEnabled( TRUE ); |
211 | 217 | ||
212 | return true; | 218 | return true; |
213 | } | 219 | } |
214 | 220 | ||
215 | void AbTable::insertIntoTable( const OContact& cnt, int row ) | 221 | void AbTable::insertIntoTable( const OContact& cnt, int row ) |
216 | { | 222 | { |
217 | //qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); | 223 | //qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); |
218 | QString strName; | 224 | QString strName; |
219 | ContactItem contactItem; | 225 | ContactItem contactItem; |
220 | 226 | ||
221 | strName = findContactName( cnt ); | 227 | strName = findContactName( cnt ); |
222 | contactItem = findContactContact( cnt, row ); | 228 | contactItem = findContactContact( cnt, row ); |
223 | 229 | ||
224 | AbTableItem *ati; | 230 | AbTableItem *ati; |
225 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); | 231 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); |
226 | contactList.insert( ati, cnt ); | 232 | contactList.insert( ati, cnt ); |
227 | setItem( row, 0, ati ); | 233 | setItem( row, 0, ati ); |
228 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); | 234 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); |
229 | if ( !contactItem.icon.isNull() ) | 235 | if ( !contactItem.icon.isNull() ) |
230 | ati->setPixmap( contactItem.icon ); | 236 | ati->setPixmap( contactItem.icon ); |
231 | setItem( row, 1, ati ); | 237 | setItem( row, 1, ati ); |
232 | 238 | ||
233 | //### cannot do this; table only has two columns at this point | 239 | //### cannot do this; table only has two columns at this point |
234 | // setItem( row, 2, new AbPickItem( this ) ); | 240 | // setItem( row, 2, new AbPickItem( this ) ); |
235 | 241 | ||
236 | } | 242 | } |
237 | 243 | ||
238 | 244 | ||
239 | 245 | ||
240 | void AbTable::columnClicked( int col ) | 246 | void AbTable::columnClicked( int col ) |
241 | { | 247 | { |
242 | if ( !sorting() ) | 248 | if ( !sorting() ) |
243 | return; | 249 | return; |
244 | 250 | ||
245 | if ( lastSortCol == -1 ) | 251 | if ( lastSortCol == -1 ) |
246 | lastSortCol = col; | 252 | lastSortCol = col; |
247 | 253 | ||
248 | if ( col == lastSortCol ) { | 254 | if ( col == lastSortCol ) { |
@@ -256,132 +262,135 @@ void AbTable::columnClicked( int col ) | |||
256 | } | 262 | } |
257 | 263 | ||
258 | void AbTable::resort() | 264 | void AbTable::resort() |
259 | { | 265 | { |
260 | //qWarning( "void AbTable::resort()" ); | 266 | //qWarning( "void AbTable::resort()" ); |
261 | setPaintingEnabled( FALSE ); | 267 | setPaintingEnabled( FALSE ); |
262 | if ( sorting() ) { | 268 | if ( sorting() ) { |
263 | if ( lastSortCol == -1 ) | 269 | if ( lastSortCol == -1 ) |
264 | lastSortCol = 0; | 270 | lastSortCol = 0; |
265 | sortColumn( lastSortCol, asc, TRUE ); | 271 | sortColumn( lastSortCol, asc, TRUE ); |
266 | //QMessageBox::information( this, "resort", "resort" ); | 272 | //QMessageBox::information( this, "resort", "resort" ); |
267 | updateVisible(); | 273 | updateVisible(); |
268 | } | 274 | } |
269 | setPaintingEnabled( TRUE ); | 275 | setPaintingEnabled( TRUE ); |
270 | } | 276 | } |
271 | 277 | ||
272 | OContact AbTable::currentEntry() | 278 | OContact AbTable::currentEntry() |
273 | { | 279 | { |
274 | //qWarning( "OContact AbTable::currentEntry()" ); | 280 | //qWarning( "OContact AbTable::currentEntry()" ); |
275 | OContact cnt; | 281 | OContact cnt; |
276 | AbTableItem *abItem; | 282 | AbTableItem *abItem; |
277 | abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); | 283 | abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); |
278 | if ( abItem ) { | 284 | if ( abItem ) { |
279 | cnt = contactList[abItem]; | 285 | cnt = contactList[abItem]; |
280 | //cnt = contactList[currentRow()]; | 286 | //cnt = contactList[currentRow()]; |
281 | } | 287 | } |
282 | return cnt; | 288 | return cnt; |
283 | } | 289 | } |
284 | 290 | ||
285 | int AbTable::currentEntry_UID() | 291 | int AbTable::currentEntry_UID() |
286 | { | 292 | { |
287 | return ( currentEntry().uid() ); | 293 | return ( currentEntry().uid() ); |
288 | } | 294 | } |
289 | 295 | ||
290 | void AbTable::clear() | 296 | void AbTable::clear() |
291 | { | 297 | { |
292 | //qWarning( "void AbTable::clear()" ); | 298 | //qWarning( "void AbTable::clear()" ); |
293 | contactList.clear(); | 299 | contactList.clear(); |
294 | 300 | ||
295 | setPaintingEnabled( FALSE ); | 301 | setPaintingEnabled( FALSE ); |
296 | for ( int r = 0; r < numRows(); ++r ) { | 302 | for ( int r = 0; r < numRows(); ++r ) { |
297 | for ( int c = 0; c < numCols(); ++c ) { | 303 | for ( int c = 0; c < numCols(); ++c ) { |
298 | if ( cellWidget( r, c ) ) | 304 | if ( cellWidget( r, c ) ) |
299 | clearCellWidget( r, c ); | 305 | clearCellWidget( r, c ); |
300 | clearCell( r, c ); | 306 | clearCell( r, c ); |
301 | } | 307 | } |
302 | } | 308 | } |
303 | setNumRows( 0 ); | 309 | setNumRows( 0 ); |
304 | setPaintingEnabled( TRUE ); | 310 | setPaintingEnabled( TRUE ); |
305 | } | 311 | } |
306 | 312 | ||
307 | // Refresh updates column 2 if the contactsettings changed | 313 | // Refresh updates column 2 if the contactsettings changed |
308 | void AbTable::refresh() | 314 | void AbTable::refresh() |
309 | { | 315 | { |
310 | //qWarning( "void AbTable::refresh()" ); | 316 | //qWarning( "void AbTable::refresh()" ); |
311 | int rows = numRows(); | 317 | int rows = numRows(); |
312 | AbTableItem *abi; | 318 | AbTableItem *abi; |
313 | ContactItem contactItem; | 319 | ContactItem contactItem; |
314 | 320 | ||
315 | setPaintingEnabled( FALSE ); | 321 | setPaintingEnabled( FALSE ); |
316 | for ( int r = 0; r < rows; ++r ) { | 322 | for ( int r = 0; r < rows; ++r ) { |
317 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 323 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
318 | contactItem = findContactContact( contactList[abi], r ); | 324 | contactItem = findContactContact( contactList[abi], r ); |
319 | static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); | 325 | static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); |
320 | if ( !contactItem.icon.isNull() ) | 326 | if ( !contactItem.icon.isNull() ){ |
321 | static_cast<AbTableItem*>( item(r, 1) )-> | 327 | static_cast<AbTableItem*>( item(r, 1) )-> |
322 | setPixmap( contactItem.icon ); | 328 | setPixmap( contactItem.icon ); |
323 | 329 | }else{ | |
330 | static_cast<AbTableItem*>( item(r, 1) )-> | ||
331 | setPixmap( QPixmap() ); | ||
332 | } | ||
324 | } | 333 | } |
325 | resort(); | 334 | resort(); |
326 | setPaintingEnabled( TRUE ); | 335 | setPaintingEnabled( TRUE ); |
327 | } | 336 | } |
328 | 337 | ||
329 | void AbTable::keyPressEvent( QKeyEvent *e ) | 338 | void AbTable::keyPressEvent( QKeyEvent *e ) |
330 | { | 339 | { |
331 | char key = toupper( e->ascii() ); | 340 | char key = toupper( e->ascii() ); |
332 | 341 | ||
333 | if ( key >= 'A' && key <= 'Z' ) | 342 | if ( key >= 'A' && key <= 'Z' ) |
334 | moveTo( key ); | 343 | moveTo( key ); |
335 | 344 | ||
336 | //qWarning("Received key .."); | 345 | //qWarning("Received key .."); |
337 | switch( e->key() ) { | 346 | switch( e->key() ) { |
338 | case Qt::Key_Space: | 347 | case Qt::Key_Space: |
339 | case Qt::Key_Return: | 348 | case Qt::Key_Return: |
340 | case Qt::Key_Enter: | 349 | case Qt::Key_Enter: |
341 | emit signalSwitch(); | 350 | emit signalSwitch(); |
342 | break; | 351 | break; |
343 | // case Qt::Key_Up: | 352 | // case Qt::Key_Up: |
344 | // qWarning("a"); | 353 | // qWarning("a"); |
345 | // emit signalKeyUp(); | 354 | // emit signalKeyUp(); |
346 | // break; | 355 | // break; |
347 | // case Qt::Key_Down: | 356 | // case Qt::Key_Down: |
348 | // qWarning("b"); | 357 | // qWarning("b"); |
349 | // emit signalKeyDown(); | 358 | // emit signalKeyDown(); |
350 | // break; | 359 | // break; |
351 | default: | 360 | default: |
352 | QTable::keyPressEvent( e ); | 361 | QTable::keyPressEvent( e ); |
353 | } | 362 | } |
354 | 363 | ||
355 | } | 364 | } |
356 | 365 | ||
357 | void AbTable::moveTo( char c ) | 366 | void AbTable::moveTo( char c ) |
358 | { | 367 | { |
359 | qWarning( "void AbTable::moveTo( char c )" ); | 368 | qWarning( "void AbTable::moveTo( char c )" ); |
360 | 369 | ||
361 | int rows = numRows(); | 370 | int rows = numRows(); |
362 | QString value; | 371 | QString value; |
363 | AbTableItem *abi; | 372 | AbTableItem *abi; |
364 | int r; | 373 | int r; |
365 | if ( asc ) { | 374 | if ( asc ) { |
366 | r = 0; | 375 | r = 0; |
367 | while ( r < rows-1) { | 376 | while ( r < rows-1) { |
368 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 377 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
369 | QChar first = abi->key()[0]; | 378 | QChar first = abi->key()[0]; |
370 | //### is there a bug in QChar to char comparison??? | 379 | //### is there a bug in QChar to char comparison??? |
371 | if ( first.row() || first.cell() >= c ) | 380 | if ( first.row() || first.cell() >= c ) |
372 | break; | 381 | break; |
373 | r++; | 382 | r++; |
374 | } | 383 | } |
375 | } else { | 384 | } else { |
376 | //### should probably disable reverse sorting instead | 385 | //### should probably disable reverse sorting instead |
377 | r = rows - 1; | 386 | r = rows - 1; |
378 | while ( r > 0 ) { | 387 | while ( r > 0 ) { |
379 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 388 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
380 | QChar first = abi->key()[0]; | 389 | QChar first = abi->key()[0]; |
381 | //### is there a bug in QChar to char comparison??? | 390 | //### is there a bug in QChar to char comparison??? |
382 | if ( first.row() || first.cell() >= c ) | 391 | if ( first.row() || first.cell() >= c ) |
383 | break; | 392 | break; |
384 | r--; | 393 | r--; |
385 | } | 394 | } |
386 | } | 395 | } |
387 | setCurrentCell( r, currentColumn() ); | 396 | setCurrentCell( r, currentColumn() ); |
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h index 4e6b294..0f7bc29 100644 --- a/core/pim/addressbook/abtable.h +++ b/core/pim/addressbook/abtable.h | |||
@@ -17,128 +17,132 @@ | |||
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #ifndef ABTABLE_H | 22 | #ifndef ABTABLE_H |
23 | #define ABTABLE_H | 23 | #define ABTABLE_H |
24 | 24 | ||
25 | #include <qpe/categories.h> | 25 | #include <qpe/categories.h> |
26 | #include <opie/ocontact.h> | 26 | #include <opie/ocontact.h> |
27 | #include <opie/ocontactaccess.h> | 27 | #include <opie/ocontactaccess.h> |
28 | 28 | ||
29 | #include <qmap.h> | 29 | #include <qmap.h> |
30 | #include <qtable.h> | 30 | #include <qtable.h> |
31 | #include <qstringlist.h> | 31 | #include <qstringlist.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qpixmap.h> | 33 | #include <qpixmap.h> |
34 | 34 | ||
35 | class AbTableItem : public QTableItem | 35 | class AbTableItem : public QTableItem |
36 | { | 36 | { |
37 | public: | 37 | public: |
38 | AbTableItem( QTable *t, EditType et, const QString &s, | 38 | AbTableItem( QTable *t, EditType et, const QString &s, |
39 | const QString &secondSortKey); | 39 | const QString &secondSortKey); |
40 | QString entryKey() const; | 40 | QString entryKey() const; |
41 | void setEntryKey( const QString & k ); | 41 | void setEntryKey( const QString & k ); |
42 | virtual int alignment() const; | 42 | virtual int alignment() const; |
43 | virtual QString key() const; | 43 | virtual QString key() const; |
44 | void setItem( const QString &txt, const QString &secondKey ); | 44 | void setItem( const QString &txt, const QString &secondKey ); |
45 | 45 | ||
46 | private: | 46 | private: |
47 | QString sortKey; | 47 | QString sortKey; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | // This is a simple container, storing all contact | 50 | // This is a simple container, storing all contact |
51 | // information | 51 | // information |
52 | class ContactItem | 52 | class ContactItem |
53 | { | 53 | { |
54 | public: | 54 | public: |
55 | QPixmap icon; | 55 | QPixmap icon; |
56 | QString value; | 56 | QString value; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | class AbPickItem : public QTableItem | 59 | class AbPickItem : public QTableItem |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | AbPickItem( QTable *t ); | 62 | AbPickItem( QTable *t ); |
63 | 63 | ||
64 | QWidget *createEditor() const; | 64 | QWidget *createEditor() const; |
65 | void setContentFromEditor( QWidget *w ); | 65 | void setContentFromEditor( QWidget *w ); |
66 | 66 | ||
67 | private: | 67 | private: |
68 | QGuardedPtr<QComboBox> cb; | 68 | QGuardedPtr<QComboBox> cb; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | class AbTable : public QTable | 71 | class AbTable : public QTable |
72 | { | 72 | { |
73 | Q_OBJECT | 73 | Q_OBJECT |
74 | 74 | ||
75 | public: | 75 | public: |
76 | AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 ); | 76 | AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 ); |
77 | ~AbTable(); | 77 | ~AbTable(); |
78 | 78 | ||
79 | // Set the contacts shown in the table | 79 | // Set the contacts shown in the table |
80 | void setContacts( const OContactAccess::List& viewList ); | 80 | void setContacts( const OContactAccess::List& viewList ); |
81 | |||
82 | // Set the list for primary contacts | ||
83 | void setOrderedList( const QValueList<int> ordered ); | ||
84 | |||
81 | // Selects a contact of a specific UID | 85 | // Selects a contact of a specific UID |
82 | bool selectContact( int UID ); | 86 | bool selectContact( int UID ); |
83 | 87 | ||
84 | // Get the current selected entry | 88 | // Get the current selected entry |
85 | OContact currentEntry(); | 89 | OContact currentEntry(); |
86 | 90 | ||
87 | // Get the UID of the current selected Entry | 91 | // Get the UID of the current selected Entry |
88 | int currentEntry_UID(); | 92 | int currentEntry_UID(); |
89 | 93 | ||
90 | QString findContactName( const OContact &entry ); | 94 | QString findContactName( const OContact &entry ); |
91 | 95 | ||
92 | void init(); | 96 | void init(); |
93 | void clear(); | 97 | void clear(); |
94 | void refresh(); | 98 | void refresh(); |
95 | 99 | ||
96 | void show(); | 100 | void show(); |
97 | void setPaintingEnabled( bool e ); | 101 | void setPaintingEnabled( bool e ); |
98 | void viewportPaintEvent( QPaintEvent* e); | 102 | void viewportPaintEvent( QPaintEvent* e); |
99 | void paintCell(QPainter* p, int row, int col, const QRect&, bool ); | 103 | void paintCell(QPainter* p, int row, int col, const QRect&, bool ); |
100 | 104 | ||
101 | // addresspicker mode (What's that ? se) | 105 | // addresspicker mode (What's that ? se) |
102 | void setChoiceNames( const QStringList& list); | 106 | void setChoiceNames( const QStringList& list); |
103 | QStringList choiceNames() const; | 107 | QStringList choiceNames() const; |
104 | void setChoiceSelection( const QValueList<int>& list ); | 108 | void setChoiceSelection( const QValueList<int>& list ); |
105 | QStringList choiceSelection(int index) const; | 109 | QStringList choiceSelection(int index) const; |
106 | 110 | ||
107 | signals: | 111 | signals: |
108 | void signalSwitch(); | 112 | void signalSwitch(); |
109 | void signalEditor(); | 113 | void signalEditor(); |
110 | void signalKeyDown(); | 114 | void signalKeyDown(); |
111 | void signalKeyUp(); | 115 | void signalKeyUp(); |
112 | 116 | ||
113 | protected: | 117 | protected: |
114 | virtual void keyPressEvent( QKeyEvent *e ); | 118 | virtual void keyPressEvent( QKeyEvent *e ); |
115 | 119 | ||
116 | // int rowHeight( int ) const; | 120 | // int rowHeight( int ) const; |
117 | // int rowPos( int row ) const; | 121 | // int rowPos( int row ) const; |
118 | // virtual int rowAt( int pos ) const; | 122 | // virtual int rowAt( int pos ) const; |
119 | 123 | ||
120 | 124 | ||
121 | protected slots: | 125 | protected slots: |
122 | void moveTo( char ); | 126 | void moveTo( char ); |
123 | virtual void columnClicked( int col ); | 127 | virtual void columnClicked( int col ); |
124 | void itemClicked(int,int col); | 128 | void itemClicked(int,int col); |
125 | void rowHeightChanged( int row ); | 129 | void rowHeightChanged( int row ); |
126 | 130 | ||
127 | private: | 131 | private: |
128 | void insertIntoTable( const OContact &cnt, int row ); | 132 | void insertIntoTable( const OContact &cnt, int row ); |
129 | ContactItem findContactContact( const OContact &entry, int row ); | 133 | ContactItem findContactContact( const OContact &entry, int row ); |
130 | void fitColumns(); | 134 | void fitColumns(); |
131 | void resizeRows(); | 135 | void resizeRows(); |
132 | void realignTable(); | 136 | void realignTable(); |
133 | void resort(); | 137 | void resort(); |
134 | void updateVisible(); | 138 | void updateVisible(); |
135 | 139 | ||
136 | int lastSortCol; | 140 | int lastSortCol; |
137 | bool asc; | 141 | bool asc; |
138 | QMap<AbTableItem*, OContact> contactList; | 142 | QMap<AbTableItem*, OContact> contactList; |
139 | QValueList<int> intFields; | 143 | QValueList<int> intFields; |
140 | QStringList choicenames; | 144 | QStringList choicenames; |
141 | bool enablePainting; | 145 | bool enablePainting; |
142 | bool columnVisible; | 146 | bool columnVisible; |
143 | int countNested; | 147 | int countNested; |
144 | 148 | ||
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp index 7da0992..b89b794 100644 --- a/core/pim/addressbook/abview.cpp +++ b/core/pim/addressbook/abview.cpp | |||
@@ -182,128 +182,132 @@ void AbView::clear() | |||
182 | void AbView::setShowByCategory( const QString& cat ) | 182 | void AbView::setShowByCategory( const QString& cat ) |
183 | { | 183 | { |
184 | //qWarning("AbView::setShowCategory( const QString& cat )"); | 184 | //qWarning("AbView::setShowCategory( const QString& cat )"); |
185 | 185 | ||
186 | int intCat = 0; | 186 | int intCat = 0; |
187 | 187 | ||
188 | // All (cat == NULL) will be stored as -1 | 188 | // All (cat == NULL) will be stored as -1 |
189 | if ( cat.isNull() ) | 189 | if ( cat.isNull() ) |
190 | intCat = -1; | 190 | intCat = -1; |
191 | else | 191 | else |
192 | intCat = mCat.id("Contacts", cat ); | 192 | intCat = mCat.id("Contacts", cat ); |
193 | 193 | ||
194 | // Just do anything if we really change the category | 194 | // Just do anything if we really change the category |
195 | if ( intCat != m_curr_category ){ | 195 | if ( intCat != m_curr_category ){ |
196 | // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); | 196 | // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); |
197 | 197 | ||
198 | m_curr_category = intCat; | 198 | m_curr_category = intCat; |
199 | emit signalClearLetterPicker(); | 199 | emit signalClearLetterPicker(); |
200 | 200 | ||
201 | load(); | 201 | load(); |
202 | } | 202 | } |
203 | 203 | ||
204 | } | 204 | } |
205 | 205 | ||
206 | void AbView::setShowToView( Views view ) | 206 | void AbView::setShowToView( Views view ) |
207 | { | 207 | { |
208 | //qWarning("void AbView::setShowToView( View %d )", view); | 208 | //qWarning("void AbView::setShowToView( View %d )", view); |
209 | 209 | ||
210 | //qWarning ("Change the View (Category is: %d)", m_curr_category); | 210 | //qWarning ("Change the View (Category is: %d)", m_curr_category); |
211 | 211 | ||
212 | if ( m_curr_View != view ){ | 212 | if ( m_curr_View != view ){ |
213 | m_prev_View = m_curr_View; | 213 | m_prev_View = m_curr_View; |
214 | m_curr_View = view; | 214 | m_curr_View = view; |
215 | 215 | ||
216 | updateView(); | 216 | updateView(); |
217 | } | 217 | } |
218 | 218 | ||
219 | } | 219 | } |
220 | 220 | ||
221 | void AbView::setShowByLetter( char c ) | 221 | void AbView::setShowByLetter( char c ) |
222 | { | 222 | { |
223 | //qWarning("void AbView::setShowByLetter( %c )", c ); | 223 | //qWarning("void AbView::setShowByLetter( %c )", c ); |
224 | OContact query; | 224 | OContact query; |
225 | if ( c == 0 ){ | 225 | if ( c == 0 ){ |
226 | load(); | 226 | load(); |
227 | return; | 227 | return; |
228 | }else{ | 228 | }else{ |
229 | // If the current Backend is unable to solve the query, we will | 229 | // If the current Backend is unable to solve the query, we will |
230 | // ignore the request .. | 230 | // ignore the request .. |
231 | if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ | 231 | if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ |
232 | return; | 232 | return; |
233 | } | 233 | } |
234 | 234 | ||
235 | query.setLastName( QString("%1*").arg(c) ); | 235 | query.setLastName( QString("%1*").arg(c) ); |
236 | m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); | 236 | m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); |
237 | clearForCategory(); | 237 | clearForCategory(); |
238 | m_curr_Contact = 0; | 238 | m_curr_Contact = 0; |
239 | } | 239 | } |
240 | updateView( true ); | 240 | updateView( true ); |
241 | } | 241 | } |
242 | 242 | ||
243 | void AbView::setListOrder( const QValueList<int>& ordered ) | 243 | void AbView::setListOrder( const QValueList<int>& ordered ) |
244 | { | 244 | { |
245 | m_orderedFields = ordered; | 245 | m_orderedFields = ordered; |
246 | if ( m_abTable ){ | ||
247 | m_abTable->setOrderedList( ordered ); | ||
248 | m_abTable->refresh(); | ||
249 | } | ||
246 | updateView(); | 250 | updateView(); |
247 | } | 251 | } |
248 | 252 | ||
249 | 253 | ||
250 | QString AbView::showCategory() const | 254 | QString AbView::showCategory() const |
251 | { | 255 | { |
252 | return mCat.label( "Contacts", m_curr_category ); | 256 | return mCat.label( "Contacts", m_curr_category ); |
253 | } | 257 | } |
254 | 258 | ||
255 | void AbView::showPersonal( bool personal ) | 259 | void AbView::showPersonal( bool personal ) |
256 | { | 260 | { |
257 | //qWarning ("void AbView::showPersonal( %d )", personal); | 261 | //qWarning ("void AbView::showPersonal( %d )", personal); |
258 | 262 | ||
259 | if ( personal ){ | 263 | if ( personal ){ |
260 | 264 | ||
261 | if ( m_inPersonal ) | 265 | if ( m_inPersonal ) |
262 | return; | 266 | return; |
263 | 267 | ||
264 | // Now switch to vCard Backend and load data. | 268 | // Now switch to vCard Backend and load data. |
265 | // The current default backend will be stored | 269 | // The current default backend will be stored |
266 | // to avoid unneeded load/stores. | 270 | // to avoid unneeded load/stores. |
267 | m_storedDB = m_contactdb; | 271 | m_storedDB = m_contactdb; |
268 | 272 | ||
269 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 273 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
270 | addressbookPersonalVCardName() ); | 274 | addressbookPersonalVCardName() ); |
271 | m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 275 | m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
272 | 276 | ||
273 | m_inPersonal = true; | 277 | m_inPersonal = true; |
274 | m_curr_View = CardView; | 278 | m_curr_View = CardView; |
275 | 279 | ||
276 | }else{ | 280 | }else{ |
277 | 281 | ||
278 | if ( !m_inPersonal ) | 282 | if ( !m_inPersonal ) |
279 | return; | 283 | return; |
280 | 284 | ||
281 | // Remove vCard Backend and restore default | 285 | // Remove vCard Backend and restore default |
282 | m_contactdb->save(); | 286 | m_contactdb->save(); |
283 | delete m_contactdb; | 287 | delete m_contactdb; |
284 | 288 | ||
285 | m_contactdb = m_storedDB; | 289 | m_contactdb = m_storedDB; |
286 | m_storedDB = 0l; | 290 | m_storedDB = 0l; |
287 | 291 | ||
288 | m_curr_View = TableView; | 292 | m_curr_View = TableView; |
289 | m_inPersonal = false; | 293 | m_inPersonal = false; |
290 | 294 | ||
291 | } | 295 | } |
292 | load(); | 296 | load(); |
293 | } | 297 | } |
294 | 298 | ||
295 | QStringList AbView::categories() | 299 | QStringList AbView::categories() |
296 | { | 300 | { |
297 | mCat.load( categoryFileName() ); | 301 | mCat.load( categoryFileName() ); |
298 | QStringList categoryList = mCat.labels( "Contacts" ); | 302 | QStringList categoryList = mCat.labels( "Contacts" ); |
299 | return categoryList; | 303 | return categoryList; |
300 | } | 304 | } |
301 | 305 | ||
302 | // BEGIN: Slots | 306 | // BEGIN: Slots |
303 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, | 307 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, |
304 | bool , QString cat ) | 308 | bool , QString cat ) |
305 | { | 309 | { |
306 | //qWarning( "void AbView::slotDoFind" ); | 310 | //qWarning( "void AbView::slotDoFind" ); |
307 | 311 | ||
308 | // We reloading the data: Deselect Letterpicker | 312 | // We reloading the data: Deselect Letterpicker |
309 | emit signalClearLetterPicker(); | 313 | emit signalClearLetterPicker(); |