Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 00335ae..aec390d 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -105,249 +105,249 @@ QWidget *AbPickItem::createEditor() const | |||
105 | 105 | ||
106 | void AbPickItem::setContentFromEditor( QWidget *w ) | 106 | void AbPickItem::setContentFromEditor( QWidget *w ) |
107 | { | 107 | { |
108 | if ( w->inherits("QComboBox") ) | 108 | if ( w->inherits("QComboBox") ) |
109 | setText( ( (QComboBox*)w )->currentText() ); | 109 | setText( ( (QComboBox*)w )->currentText() ); |
110 | else | 110 | else |
111 | QTableItem::setContentFromEditor( w ); | 111 | QTableItem::setContentFromEditor( w ); |
112 | } | 112 | } |
113 | 113 | ||
114 | /*! | 114 | /*! |
115 | \class AbTable abtable.h | 115 | \class AbTable abtable.h |
116 | 116 | ||
117 | \brief QTable based class for showing a list of entries | 117 | \brief QTable based class for showing a list of entries |
118 | */ | 118 | */ |
119 | 119 | ||
120 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) | 120 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) |
121 | : QTable( parent, name ), | 121 | : QTable( parent, name ), |
122 | lastSortCol( -1 ), | 122 | lastSortCol( -1 ), |
123 | asc( TRUE ), | 123 | asc( TRUE ), |
124 | intFields( order ), | 124 | intFields( order ), |
125 | enablePainting( true ), | 125 | enablePainting( true ), |
126 | columnVisible( true ), | 126 | columnVisible( true ), |
127 | countNested( 0 ) | 127 | countNested( 0 ) |
128 | { | 128 | { |
129 | qWarning("C'tor start"); | 129 | //qWarning("C'tor start"); |
130 | 130 | ||
131 | setSelectionMode( NoSelection ); | 131 | setSelectionMode( NoSelection ); |
132 | init(); | 132 | init(); |
133 | setSorting( TRUE ); | 133 | setSorting( TRUE ); |
134 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), | 134 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), |
135 | this, SLOT(itemClicked(int,int)) ); | 135 | this, SLOT(itemClicked(int,int)) ); |
136 | 136 | ||
137 | contactList.clear(); | 137 | contactList.clear(); |
138 | qWarning("C'tor end"); | 138 | //qWarning("C'tor end"); |
139 | } | 139 | } |
140 | 140 | ||
141 | AbTable::~AbTable() | 141 | AbTable::~AbTable() |
142 | { | 142 | { |
143 | } | 143 | } |
144 | 144 | ||
145 | void AbTable::init() | 145 | void AbTable::init() |
146 | { | 146 | { |
147 | // :SX showChar = '\0'; | 147 | // :SX showChar = '\0'; |
148 | setNumRows( 0 ); | 148 | setNumRows( 0 ); |
149 | setNumCols( 2 ); | 149 | setNumCols( 2 ); |
150 | 150 | ||
151 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 151 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
152 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 152 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
153 | setLeftMargin( 0 ); | 153 | setLeftMargin( 0 ); |
154 | verticalHeader()->hide(); | 154 | verticalHeader()->hide(); |
155 | columnVisible = true; | 155 | columnVisible = true; |
156 | } | 156 | } |
157 | 157 | ||
158 | void AbTable::setContacts( const OContactAccess::List& viewList ) | 158 | void AbTable::setContacts( const OContactAccess::List& viewList ) |
159 | { | 159 | { |
160 | qWarning("AbTable::setContacts()"); | 160 | //qWarning("AbTable::setContacts()"); |
161 | 161 | ||
162 | clear(); | 162 | clear(); |
163 | m_viewList = viewList; | 163 | m_viewList = viewList; |
164 | 164 | ||
165 | setSorting( false ); | 165 | setSorting( false ); |
166 | setPaintingEnabled( FALSE ); | 166 | setPaintingEnabled( FALSE ); |
167 | 167 | ||
168 | OContactAccess::List::Iterator it; | 168 | OContactAccess::List::Iterator it; |
169 | setNumRows( m_viewList.count() ); | 169 | setNumRows( m_viewList.count() ); |
170 | int row = 0; | 170 | int row = 0; |
171 | for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) | 171 | for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) |
172 | insertIntoTable( *it, row++ ); | 172 | insertIntoTable( *it, row++ ); |
173 | 173 | ||
174 | setSorting( true ); | 174 | setSorting( true ); |
175 | 175 | ||
176 | resort(); | 176 | resort(); |
177 | 177 | ||
178 | updateVisible(); | 178 | updateVisible(); |
179 | 179 | ||
180 | setPaintingEnabled( TRUE ); | 180 | setPaintingEnabled( TRUE ); |
181 | 181 | ||
182 | } | 182 | } |
183 | 183 | ||
184 | bool AbTable::selectContact( int UID ) | 184 | bool AbTable::selectContact( int UID ) |
185 | { | 185 | { |
186 | qWarning( "AbTable::selectContact( %d )", UID ); | 186 | //qWarning( "AbTable::selectContact( %d )", UID ); |
187 | int rows = numRows(); | 187 | int rows = numRows(); |
188 | AbTableItem *abi; | 188 | AbTableItem *abi; |
189 | OContact* foundContact = 0l; | 189 | OContact* foundContact = 0l; |
190 | bool found = false; | 190 | bool found = false; |
191 | 191 | ||
192 | setPaintingEnabled( FALSE ); | 192 | setPaintingEnabled( FALSE ); |
193 | for ( int r = 0; r < rows; ++r ) { | 193 | for ( int r = 0; r < rows; ++r ) { |
194 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 194 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
195 | foundContact = &contactList[abi]; | 195 | foundContact = &contactList[abi]; |
196 | if ( foundContact -> uid() == UID ){ | 196 | if ( foundContact -> uid() == UID ){ |
197 | ensureCellVisible( r, 0 ); | 197 | ensureCellVisible( r, 0 ); |
198 | setCurrentCell( r, 0 ); | 198 | setCurrentCell( r, 0 ); |
199 | found = true; | 199 | found = true; |
200 | break; | 200 | break; |
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | if ( !found ){ | 204 | if ( !found ){ |
205 | ensureCellVisible( 0,0 ); | 205 | ensureCellVisible( 0,0 ); |
206 | setCurrentCell( 0, 0 ); | 206 | setCurrentCell( 0, 0 ); |
207 | } | 207 | } |
208 | 208 | ||
209 | setPaintingEnabled( TRUE ); | 209 | setPaintingEnabled( TRUE ); |
210 | 210 | ||
211 | return true; | 211 | return true; |
212 | } | 212 | } |
213 | 213 | ||
214 | void AbTable::insertIntoTable( const OContact& cnt, int row ) | 214 | void AbTable::insertIntoTable( const OContact& cnt, int row ) |
215 | { | 215 | { |
216 | qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); | 216 | //qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); |
217 | QString strName, | 217 | QString strName, |
218 | strContact; | 218 | strContact; |
219 | 219 | ||
220 | strName = findContactName( cnt ); | 220 | strName = findContactName( cnt ); |
221 | strContact = findContactContact( cnt, row ); | 221 | strContact = findContactContact( cnt, row ); |
222 | 222 | ||
223 | AbTableItem *ati; | 223 | AbTableItem *ati; |
224 | ati = new AbTableItem( this, QTableItem::Never, strName, strContact); | 224 | ati = new AbTableItem( this, QTableItem::Never, strName, strContact); |
225 | contactList.insert( ati, cnt ); | 225 | contactList.insert( ati, cnt ); |
226 | setItem( row, 0, ati ); | 226 | setItem( row, 0, ati ); |
227 | ati = new AbTableItem( this, QTableItem::Never, strContact, strName); | 227 | ati = new AbTableItem( this, QTableItem::Never, strContact, strName); |
228 | setItem( row, 1, ati ); | 228 | setItem( row, 1, ati ); |
229 | 229 | ||
230 | //### cannot do this; table only has two columns at this point | 230 | //### cannot do this; table only has two columns at this point |
231 | // setItem( row, 2, new AbPickItem( this ) ); | 231 | // setItem( row, 2, new AbPickItem( this ) ); |
232 | 232 | ||
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | 236 | ||
237 | void AbTable::columnClicked( int col ) | 237 | void AbTable::columnClicked( int col ) |
238 | { | 238 | { |
239 | if ( !sorting() ) | 239 | if ( !sorting() ) |
240 | return; | 240 | return; |
241 | 241 | ||
242 | if ( lastSortCol == -1 ) | 242 | if ( lastSortCol == -1 ) |
243 | lastSortCol = col; | 243 | lastSortCol = col; |
244 | 244 | ||
245 | if ( col == lastSortCol ) { | 245 | if ( col == lastSortCol ) { |
246 | asc = !asc; | 246 | asc = !asc; |
247 | } else { | 247 | } else { |
248 | lastSortCol = col; | 248 | lastSortCol = col; |
249 | asc = TRUE; | 249 | asc = TRUE; |
250 | } | 250 | } |
251 | //QMessageBox::information( this, "resort", "columnClicked" ); | 251 | //QMessageBox::information( this, "resort", "columnClicked" ); |
252 | resort(); | 252 | resort(); |
253 | } | 253 | } |
254 | 254 | ||
255 | void AbTable::resort() | 255 | void AbTable::resort() |
256 | { | 256 | { |
257 | qWarning( "void AbTable::resort()" ); | 257 | //qWarning( "void AbTable::resort()" ); |
258 | setPaintingEnabled( FALSE ); | 258 | setPaintingEnabled( FALSE ); |
259 | if ( sorting() ) { | 259 | if ( sorting() ) { |
260 | if ( lastSortCol == -1 ) | 260 | if ( lastSortCol == -1 ) |
261 | lastSortCol = 0; | 261 | lastSortCol = 0; |
262 | sortColumn( lastSortCol, asc, TRUE ); | 262 | sortColumn( lastSortCol, asc, TRUE ); |
263 | //QMessageBox::information( this, "resort", "resort" ); | 263 | //QMessageBox::information( this, "resort", "resort" ); |
264 | updateVisible(); | 264 | updateVisible(); |
265 | } | 265 | } |
266 | setPaintingEnabled( TRUE ); | 266 | setPaintingEnabled( TRUE ); |
267 | } | 267 | } |
268 | 268 | ||
269 | OContact AbTable::currentEntry() | 269 | OContact AbTable::currentEntry() |
270 | { | 270 | { |
271 | qWarning( "OContact AbTable::currentEntry()" ); | 271 | //qWarning( "OContact AbTable::currentEntry()" ); |
272 | OContact cnt; | 272 | OContact cnt; |
273 | AbTableItem *abItem; | 273 | AbTableItem *abItem; |
274 | abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); | 274 | abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); |
275 | if ( abItem ) { | 275 | if ( abItem ) { |
276 | cnt = contactList[abItem]; | 276 | cnt = contactList[abItem]; |
277 | //cnt = contactList[currentRow()]; | 277 | //cnt = contactList[currentRow()]; |
278 | } | 278 | } |
279 | return cnt; | 279 | return cnt; |
280 | } | 280 | } |
281 | 281 | ||
282 | int AbTable::currentEntry_UID() | 282 | int AbTable::currentEntry_UID() |
283 | { | 283 | { |
284 | return ( currentEntry().uid() ); | 284 | return ( currentEntry().uid() ); |
285 | } | 285 | } |
286 | 286 | ||
287 | void AbTable::clear() | 287 | void AbTable::clear() |
288 | { | 288 | { |
289 | qWarning( "void AbTable::clear()" ); | 289 | //qWarning( "void AbTable::clear()" ); |
290 | contactList.clear(); | 290 | contactList.clear(); |
291 | 291 | ||
292 | setPaintingEnabled( FALSE ); | 292 | setPaintingEnabled( FALSE ); |
293 | for ( int r = 0; r < numRows(); ++r ) { | 293 | for ( int r = 0; r < numRows(); ++r ) { |
294 | for ( int c = 0; c < numCols(); ++c ) { | 294 | for ( int c = 0; c < numCols(); ++c ) { |
295 | if ( cellWidget( r, c ) ) | 295 | if ( cellWidget( r, c ) ) |
296 | clearCellWidget( r, c ); | 296 | clearCellWidget( r, c ); |
297 | clearCell( r, c ); | 297 | clearCell( r, c ); |
298 | } | 298 | } |
299 | } | 299 | } |
300 | setNumRows( 0 ); | 300 | setNumRows( 0 ); |
301 | setPaintingEnabled( TRUE ); | 301 | setPaintingEnabled( TRUE ); |
302 | } | 302 | } |
303 | 303 | ||
304 | // Refresh updates column 2 if the contactsettings changed | 304 | // Refresh updates column 2 if the contactsettings changed |
305 | void AbTable::refresh() | 305 | void AbTable::refresh() |
306 | { | 306 | { |
307 | qWarning( "void AbTable::refresh()" ); | 307 | //qWarning( "void AbTable::refresh()" ); |
308 | int rows = numRows(); | 308 | int rows = numRows(); |
309 | QString value; | 309 | QString value; |
310 | AbTableItem *abi; | 310 | AbTableItem *abi; |
311 | 311 | ||
312 | setPaintingEnabled( FALSE ); | 312 | setPaintingEnabled( FALSE ); |
313 | for ( int r = 0; r < rows; ++r ) { | 313 | for ( int r = 0; r < rows; ++r ) { |
314 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 314 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
315 | value = findContactContact( contactList[abi], r ); | 315 | value = findContactContact( contactList[abi], r ); |
316 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); | 316 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); |
317 | } | 317 | } |
318 | resort(); | 318 | resort(); |
319 | setPaintingEnabled( TRUE ); | 319 | setPaintingEnabled( TRUE ); |
320 | } | 320 | } |
321 | 321 | ||
322 | void AbTable::keyPressEvent( QKeyEvent *e ) | 322 | void AbTable::keyPressEvent( QKeyEvent *e ) |
323 | { | 323 | { |
324 | char key = toupper( e->ascii() ); | 324 | char key = toupper( e->ascii() ); |
325 | 325 | ||
326 | if ( key >= 'A' && key <= 'Z' ) | 326 | if ( key >= 'A' && key <= 'Z' ) |
327 | moveTo( key ); | 327 | moveTo( key ); |
328 | 328 | ||
329 | qWarning("Received key .."); | 329 | //qWarning("Received key .."); |
330 | switch( e->key() ) { | 330 | switch( e->key() ) { |
331 | case Qt::Key_Space: | 331 | case Qt::Key_Space: |
332 | case Qt::Key_Return: | 332 | case Qt::Key_Return: |
333 | case Qt::Key_Enter: | 333 | case Qt::Key_Enter: |
334 | emit signalSwitch(); | 334 | emit signalSwitch(); |
335 | break; | 335 | break; |
336 | // case Qt::Key_Up: | 336 | // case Qt::Key_Up: |
337 | // qWarning("a"); | 337 | // qWarning("a"); |
338 | // emit signalKeyUp(); | 338 | // emit signalKeyUp(); |
339 | // break; | 339 | // break; |
340 | // case Qt::Key_Down: | 340 | // case Qt::Key_Down: |
341 | // qWarning("b"); | 341 | // qWarning("b"); |
342 | // emit signalKeyDown(); | 342 | // emit signalKeyDown(); |
343 | // break; | 343 | // break; |
344 | default: | 344 | default: |
345 | QTable::keyPressEvent( e ); | 345 | QTable::keyPressEvent( e ); |
346 | } | 346 | } |
347 | 347 | ||
348 | } | 348 | } |
349 | 349 | ||
350 | void AbTable::moveTo( char c ) | 350 | void AbTable::moveTo( char c ) |
351 | { | 351 | { |
352 | qWarning( "void AbTable::moveTo( char c )" ); | 352 | qWarning( "void AbTable::moveTo( char c )" ); |
353 | 353 | ||
@@ -390,49 +390,49 @@ QString AbTable::findContactName( const OContact &entry ) | |||
390 | str = entry.company(); | 390 | str = entry.company(); |
391 | if ( str.isEmpty() ) { | 391 | if ( str.isEmpty() ) { |
392 | str = entry.defaultEmail(); | 392 | str = entry.defaultEmail(); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | return str; | 395 | return str; |
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | 399 | ||
400 | void AbTable::resizeRows() { | 400 | void AbTable::resizeRows() { |
401 | /* | 401 | /* |
402 | if (numRows()) { | 402 | if (numRows()) { |
403 | for (int i = 0; i < numRows(); i++) { | 403 | for (int i = 0; i < numRows(); i++) { |
404 | setRowHeight( i, size ); | 404 | setRowHeight( i, size ); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | updateVisible(); | 407 | updateVisible(); |
408 | */ | 408 | */ |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | void AbTable::realignTable() | 412 | void AbTable::realignTable() |
413 | { | 413 | { |
414 | qWarning( "void AbTable::realignTable()" ); | 414 | //qWarning( "void AbTable::realignTable()" ); |
415 | 415 | ||
416 | setPaintingEnabled( FALSE ); | 416 | setPaintingEnabled( FALSE ); |
417 | 417 | ||
418 | resizeRows(); | 418 | resizeRows(); |
419 | fitColumns(); | 419 | fitColumns(); |
420 | 420 | ||
421 | setPaintingEnabled( TRUE ); | 421 | setPaintingEnabled( TRUE ); |
422 | 422 | ||
423 | } | 423 | } |
424 | 424 | ||
425 | 425 | ||
426 | 426 | ||
427 | 427 | ||
428 | #if QT_VERSION <= 230 | 428 | #if QT_VERSION <= 230 |
429 | #ifndef SINGLE_APP | 429 | #ifndef SINGLE_APP |
430 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | 430 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) |
431 | { | 431 | { |
432 | // Region of the rect we should draw | 432 | // Region of the rect we should draw |
433 | QRegion reg( QRect( cx, cy, cw, ch ) ); | 433 | QRegion reg( QRect( cx, cy, cw, ch ) ); |
434 | // Subtract the table from it | 434 | // Subtract the table from it |
435 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); | 435 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); |
436 | // And draw the rectangles (transformed as needed) | 436 | // And draw the rectangles (transformed as needed) |
437 | QArray<QRect> r = reg.rects(); | 437 | QArray<QRect> r = reg.rects(); |
438 | for (unsigned int i=0; i<r.count(); i++) | 438 | for (unsigned int i=0; i<r.count(); i++) |
@@ -440,194 +440,194 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | |||
440 | } | 440 | } |
441 | #endif | 441 | #endif |
442 | #endif | 442 | #endif |
443 | 443 | ||
444 | 444 | ||
445 | // int AbTable::rowHeight( int ) const | 445 | // int AbTable::rowHeight( int ) const |
446 | // { | 446 | // { |
447 | // return 18; | 447 | // return 18; |
448 | // } | 448 | // } |
449 | 449 | ||
450 | // int AbTable::rowPos( int row ) const | 450 | // int AbTable::rowPos( int row ) const |
451 | // { | 451 | // { |
452 | // return 18*row; | 452 | // return 18*row; |
453 | // } | 453 | // } |
454 | 454 | ||
455 | // int AbTable::rowAt( int pos ) const | 455 | // int AbTable::rowAt( int pos ) const |
456 | // { | 456 | // { |
457 | // return QMIN( pos/18, numRows()-1 ); | 457 | // return QMIN( pos/18, numRows()-1 ); |
458 | // } | 458 | // } |
459 | 459 | ||
460 | 460 | ||
461 | 461 | ||
462 | void AbTable::fitColumns() | 462 | void AbTable::fitColumns() |
463 | { | 463 | { |
464 | qWarning( "void AbTable::fitColumns()" ); | 464 | //qWarning( "void AbTable::fitColumns()" ); |
465 | int contentsWidth = visibleWidth() / 2; // :SX Why too low | 465 | int contentsWidth = visibleWidth() / 2; // :SX Why too low |
466 | // Fix to better value | 466 | // Fix to better value |
467 | // contentsWidth = 130; | 467 | // contentsWidth = 130; |
468 | 468 | ||
469 | setPaintingEnabled( FALSE ); | 469 | setPaintingEnabled( FALSE ); |
470 | 470 | ||
471 | if ( columnVisible == false ){ | 471 | if ( columnVisible == false ){ |
472 | showColumn(0); | 472 | showColumn(0); |
473 | columnVisible = true; | 473 | columnVisible = true; |
474 | } | 474 | } |
475 | 475 | ||
476 | qWarning("Width: %d", contentsWidth); | 476 | //qWarning("Width: %d", contentsWidth); |
477 | 477 | ||
478 | setColumnWidth( 0, contentsWidth ); | 478 | setColumnWidth( 0, contentsWidth ); |
479 | adjustColumn(1); | 479 | adjustColumn(1); |
480 | if ( columnWidth(1) < contentsWidth ) | 480 | if ( columnWidth(1) < contentsWidth ) |
481 | setColumnWidth( 1, contentsWidth ); | 481 | setColumnWidth( 1, contentsWidth ); |
482 | 482 | ||
483 | setPaintingEnabled( TRUE ); | 483 | setPaintingEnabled( TRUE ); |
484 | } | 484 | } |
485 | 485 | ||
486 | void AbTable::show() | 486 | void AbTable::show() |
487 | { | 487 | { |
488 | qWarning( "void AbTable::show()" ); | 488 | //qWarning( "void AbTable::show()" ); |
489 | realignTable(); | 489 | realignTable(); |
490 | QTable::show(); | 490 | QTable::show(); |
491 | } | 491 | } |
492 | 492 | ||
493 | void AbTable::setChoiceNames( const QStringList& list) | 493 | void AbTable::setChoiceNames( const QStringList& list) |
494 | { | 494 | { |
495 | choicenames = list; | 495 | choicenames = list; |
496 | if ( choicenames.isEmpty() ) { | 496 | if ( choicenames.isEmpty() ) { |
497 | // hide pick column | 497 | // hide pick column |
498 | setNumCols( 2 ); | 498 | setNumCols( 2 ); |
499 | } else { | 499 | } else { |
500 | // show pick column | 500 | // show pick column |
501 | setNumCols( 3 ); | 501 | setNumCols( 3 ); |
502 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); | 502 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); |
503 | horizontalHeader()->setLabel( 2, tr( "Pick" )); | 503 | horizontalHeader()->setLabel( 2, tr( "Pick" )); |
504 | } | 504 | } |
505 | fitColumns(); | 505 | fitColumns(); |
506 | } | 506 | } |
507 | 507 | ||
508 | void AbTable::itemClicked(int,int col) | 508 | void AbTable::itemClicked(int,int col) |
509 | { | 509 | { |
510 | qWarning( "AbTable::itemClicked(int, col:%d)", col); | 510 | //qWarning( "AbTable::itemClicked(int, col:%d)", col); |
511 | if ( col == 2 ) { | 511 | if ( col == 2 ) { |
512 | return; | 512 | return; |
513 | } else { | 513 | } else { |
514 | qWarning ("Emitting signalSwitch()"); | 514 | // qWarning ("Emitting signalSwitch()"); |
515 | emit signalSwitch(); | 515 | emit signalSwitch(); |
516 | } | 516 | } |
517 | } | 517 | } |
518 | 518 | ||
519 | QStringList AbTable::choiceNames() const | 519 | QStringList AbTable::choiceNames() const |
520 | { | 520 | { |
521 | return choicenames; | 521 | return choicenames; |
522 | } | 522 | } |
523 | 523 | ||
524 | void AbTable::setChoiceSelection( const QValueList<int>& list ) | 524 | void AbTable::setChoiceSelection( const QValueList<int>& list ) |
525 | { | 525 | { |
526 | intFields = list; | 526 | intFields = list; |
527 | } | 527 | } |
528 | 528 | ||
529 | QStringList AbTable::choiceSelection(int /*index*/) const | 529 | QStringList AbTable::choiceSelection(int /*index*/) const |
530 | { | 530 | { |
531 | QStringList r; | 531 | QStringList r; |
532 | /* ###### | 532 | /* ###### |
533 | 533 | ||
534 | QString selname = choicenames.at(index); | 534 | QString selname = choicenames.at(index); |
535 | for (each row) { | 535 | for (each row) { |
536 | OContact *c = contactForRow(row); | 536 | OContact *c = contactForRow(row); |
537 | if ( text(row,2) == selname ) { | 537 | if ( text(row,2) == selname ) { |
538 | r.append(c->email); | 538 | r.append(c->email); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | */ | 542 | */ |
543 | return r; | 543 | return r; |
544 | } | 544 | } |
545 | 545 | ||
546 | 546 | ||
547 | 547 | ||
548 | 548 | ||
549 | void AbTable::updateVisible() | 549 | void AbTable::updateVisible() |
550 | { | 550 | { |
551 | qWarning("void AbTable::updateVisible()"); | 551 | //qWarning("void AbTable::updateVisible()"); |
552 | 552 | ||
553 | int visible, | 553 | int visible, |
554 | totalRows, | 554 | totalRows, |
555 | row, | 555 | row, |
556 | selectedRow = 0; | 556 | selectedRow = 0; |
557 | 557 | ||
558 | visible = 0; | 558 | visible = 0; |
559 | 559 | ||
560 | setPaintingEnabled( FALSE ); | 560 | setPaintingEnabled( FALSE ); |
561 | 561 | ||
562 | realignTable(); | 562 | realignTable(); |
563 | 563 | ||
564 | totalRows = numRows(); | 564 | totalRows = numRows(); |
565 | for ( row = 0; row < totalRows; row++ ) { | 565 | for ( row = 0; row < totalRows; row++ ) { |
566 | if ( rowHeight(row) == 0 ) { | 566 | if ( rowHeight(row) == 0 ) { |
567 | showRow( row ); | 567 | showRow( row ); |
568 | adjustRow( row ); | 568 | adjustRow( row ); |
569 | if ( isSelected( row,0 ) || isSelected( row,1 ) ) | 569 | if ( isSelected( row,0 ) || isSelected( row,1 ) ) |
570 | selectedRow = row; | 570 | selectedRow = row; |
571 | } | 571 | } |
572 | visible++; | 572 | visible++; |
573 | } | 573 | } |
574 | 574 | ||
575 | if ( selectedRow ) | 575 | if ( selectedRow ) |
576 | setCurrentCell( selectedRow, 0 ); | 576 | setCurrentCell( selectedRow, 0 ); |
577 | 577 | ||
578 | if ( !visible ) | 578 | if ( !visible ) |
579 | setCurrentCell( -1, 0 ); | 579 | setCurrentCell( -1, 0 ); |
580 | 580 | ||
581 | setPaintingEnabled( TRUE ); | 581 | setPaintingEnabled( TRUE ); |
582 | 582 | ||
583 | 583 | ||
584 | } | 584 | } |
585 | 585 | ||
586 | 586 | ||
587 | void AbTable::setPaintingEnabled( bool e ) | 587 | void AbTable::setPaintingEnabled( bool e ) |
588 | { | 588 | { |
589 | qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); | 589 | //qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); |
590 | 590 | ||
591 | if ( e ) { | 591 | if ( e ) { |
592 | if ( countNested > 0 ) | 592 | if ( countNested > 0 ) |
593 | --countNested; | 593 | --countNested; |
594 | if ( ! countNested ){ | 594 | if ( ! countNested ){ |
595 | setUpdatesEnabled( true ); | 595 | setUpdatesEnabled( true ); |
596 | enablePainting = true; | 596 | enablePainting = true; |
597 | rowHeightChanged( 0 ); | 597 | rowHeightChanged( 0 ); |
598 | viewport()->update(); | 598 | viewport()->update(); |
599 | } | 599 | } |
600 | } else { | 600 | } else { |
601 | ++countNested; | 601 | ++countNested; |
602 | enablePainting = false; | 602 | enablePainting = false; |
603 | setUpdatesEnabled( false ); | 603 | setUpdatesEnabled( false ); |
604 | } | 604 | } |
605 | qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); | 605 | //qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); |
606 | } | 606 | } |
607 | 607 | ||
608 | void AbTable::viewportPaintEvent( QPaintEvent* e ) { | 608 | void AbTable::viewportPaintEvent( QPaintEvent* e ) { |
609 | qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); | 609 | //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); |
610 | if ( enablePainting ) | 610 | if ( enablePainting ) |
611 | QTable::viewportPaintEvent( e ); | 611 | QTable::viewportPaintEvent( e ); |
612 | } | 612 | } |
613 | 613 | ||
614 | 614 | ||
615 | 615 | ||
616 | void AbTable::rowHeightChanged( int row ) | 616 | void AbTable::rowHeightChanged( int row ) |
617 | { | 617 | { |
618 | if ( enablePainting ) | 618 | if ( enablePainting ) |
619 | QTable::rowHeightChanged( row ); | 619 | QTable::rowHeightChanged( row ); |
620 | } | 620 | } |
621 | QString AbTable::findContactContact( const OContact &entry, int /* row */ ) | 621 | QString AbTable::findContactContact( const OContact &entry, int /* row */ ) |
622 | { | 622 | { |
623 | QString value; | 623 | QString value; |
624 | value = ""; | 624 | value = ""; |
625 | for ( QValueList<int>::ConstIterator it = intFields.begin(); | 625 | for ( QValueList<int>::ConstIterator it = intFields.begin(); |
626 | it != intFields.end(); ++it ) { | 626 | it != intFields.end(); ++it ) { |
627 | switch ( *it ) { | 627 | switch ( *it ) { |
628 | default: | 628 | default: |
629 | break; | 629 | break; |
630 | case Qtopia::Title: | 630 | case Qtopia::Title: |
631 | value = entry.title(); | 631 | value = entry.title(); |
632 | break; | 632 | break; |
633 | case Qtopia::Suffix: | 633 | case Qtopia::Suffix: |