Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 93 |
1 files changed, 7 insertions, 86 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 49e66ad..60f3177 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -115,25 +115,26 @@ void AbPickItem::setContentFromEditor( QWidget *w ) | |||
115 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) | 115 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) |
116 | : QTable( parent, name ), | 116 | : QTable( parent, name ), |
117 | lastSortCol( -1 ), | 117 | lastSortCol( -1 ), |
118 | asc( TRUE ), | 118 | asc( TRUE ), |
119 | intFields( order ), | 119 | intFields( order ), |
120 | enablePainting( true ), | 120 | enablePainting( true ), |
121 | columnVisible( true ), | 121 | columnVisible( true ), |
122 | countNested( 0 ) | 122 | countNested( 0 ) |
123 | { | 123 | { |
124 | //odebug << "C'tor start" << oendl; | 124 | //odebug << "C'tor start" << oendl; |
125 | setSelectionMode( NoSelection ); | 125 | setSelectionMode( NoSelection ); |
126 | init(); | 126 | init(); |
127 | setSorting( TRUE ); | 127 | setSorting( false ); // The table should not sort by itself! |
128 | |||
128 | connect( this, SIGNAL(clicked(int,int,int,const QPoint&)), | 129 | connect( this, SIGNAL(clicked(int,int,int,const QPoint&)), |
129 | this, SLOT(itemClicked(int,int)) ); | 130 | this, SLOT(itemClicked(int,int)) ); |
130 | 131 | ||
131 | // contactList.clear(); | 132 | // contactList.clear(); |
132 | //odebug << "C'tor end" << oendl; | 133 | //odebug << "C'tor end" << oendl; |
133 | } | 134 | } |
134 | 135 | ||
135 | AbTable::~AbTable() | 136 | AbTable::~AbTable() |
136 | { | 137 | { |
137 | } | 138 | } |
138 | 139 | ||
139 | void AbTable::init() | 140 | void AbTable::init() |
@@ -147,35 +148,28 @@ void AbTable::init() | |||
147 | setLeftMargin( 0 ); | 148 | setLeftMargin( 0 ); |
148 | verticalHeader()->hide(); | 149 | verticalHeader()->hide(); |
149 | columnVisible = true; | 150 | columnVisible = true; |
150 | } | 151 | } |
151 | 152 | ||
152 | void AbTable::setContacts( const Opie::OPimContactAccess::List& viewList ) | 153 | void AbTable::setContacts( const Opie::OPimContactAccess::List& viewList ) |
153 | { | 154 | { |
154 | odebug << "AbTable::setContacts()" << oendl; | 155 | odebug << "AbTable::setContacts()" << oendl; |
155 | 156 | ||
156 | clear(); | 157 | clear(); |
157 | m_viewList = viewList; | 158 | m_viewList = viewList; |
158 | 159 | ||
159 | setSorting( false ); | ||
160 | setPaintingEnabled( FALSE ); | 160 | setPaintingEnabled( FALSE ); |
161 | 161 | ||
162 | setNumRows( m_viewList.count() ); | 162 | setNumRows( m_viewList.count() ); |
163 | //int row = 0; | ||
164 | // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) | ||
165 | // insertIntoTable( *it, row++ ); | ||
166 | |||
167 | // setSorting( true ); | ||
168 | 163 | ||
169 | // resort(); | ||
170 | 164 | ||
171 | updateVisible(); | 165 | updateVisible(); |
172 | 166 | ||
173 | setPaintingEnabled( TRUE ); | 167 | setPaintingEnabled( TRUE ); |
174 | 168 | ||
175 | } | 169 | } |
176 | 170 | ||
177 | void AbTable::setOrderedList( const QValueList<int> ordered ) | 171 | void AbTable::setOrderedList( const QValueList<int> ordered ) |
178 | { | 172 | { |
179 | intFields = ordered; | 173 | intFields = ordered; |
180 | } | 174 | } |
181 | 175 | ||
@@ -199,83 +193,40 @@ bool AbTable::selectContact( int UID ) | |||
199 | odebug << "Search end" << oendl; | 193 | odebug << "Search end" << oendl; |
200 | 194 | ||
201 | if ( !found ){ | 195 | if ( !found ){ |
202 | ensureCellVisible( 0,0 ); | 196 | ensureCellVisible( 0,0 ); |
203 | setCurrentCell( 0, 0 ); | 197 | setCurrentCell( 0, 0 ); |
204 | } | 198 | } |
205 | 199 | ||
206 | setPaintingEnabled( TRUE ); | 200 | setPaintingEnabled( TRUE ); |
207 | 201 | ||
208 | return true; | 202 | return true; |
209 | } | 203 | } |
210 | 204 | ||
211 | #if 0 | ||
212 | void AbTable::insertIntoTable( const Opie::OPimContact& cnt, int row ) | ||
213 | { | ||
214 | odebug << "void AbTable::insertIntoTable( const Opie::OPimContact& cnt, " | ||
215 | << row << " )" << oendl; | ||
216 | QString strName; | ||
217 | ContactItem contactItem; | ||
218 | |||
219 | strName = findContactName( cnt ); | ||
220 | contactItem = findContactContact( cnt, row ); | ||
221 | |||
222 | AbTableItem *ati; | ||
223 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); | ||
224 | contactList.insert( ati, cnt ); | ||
225 | setItem( row, 0, ati ); | ||
226 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); | ||
227 | if ( !contactItem.icon.isNull() ) | ||
228 | ati->setPixmap( contactItem.icon ); | ||
229 | setItem( row, 1, ati ); | ||
230 | |||
231 | //### cannot do this; table only has two columns at this point | ||
232 | // setItem( row, 2, new AbPickItem( this ) ); | ||
233 | |||
234 | } | ||
235 | #endif | ||
236 | |||
237 | 205 | ||
238 | void AbTable::columnClicked( int col ) | 206 | void AbTable::columnClicked( int col ) |
239 | { | 207 | { |
240 | if ( !sorting() ) | 208 | odebug << "columClicked(" << col << ")" << oendl; |
241 | return; | ||
242 | |||
243 | if ( lastSortCol == -1 ) | ||
244 | lastSortCol = col; | ||
245 | 209 | ||
246 | if ( col == lastSortCol ) { | 210 | if ( col == 0 ){ |
211 | odebug << "Change sort order: " << asc << oendl; | ||
247 | asc = !asc; | 212 | asc = !asc; |
248 | } else { | 213 | emit signalSortOrderChanged( asc ); |
249 | lastSortCol = col; | ||
250 | asc = TRUE; | ||
251 | } | 214 | } |
252 | //QMessageBox::information( this, "resort", "columnClicked" ); | ||
253 | resort(); | ||
254 | } | 215 | } |
255 | 216 | ||
256 | void AbTable::resort() | 217 | void AbTable::resort() |
257 | { | 218 | { |
258 | owarn << "void AbTable::resort() NOT POSSIBLE !!" << oendl; | 219 | owarn << "void AbTable::resort() NOT POSSIBLE !!" << oendl; |
259 | #if 0 | 220 | |
260 | setPaintingEnabled( FALSE ); | ||
261 | if ( sorting() ) { | ||
262 | if ( lastSortCol == -1 ) | ||
263 | lastSortCol = 0; | ||
264 | sortColumn( lastSortCol, asc, TRUE ); | ||
265 | //QMessageBox::information( this, "resort", "resort" ); | ||
266 | updateVisible(); | ||
267 | } | ||
268 | setPaintingEnabled( TRUE ); | ||
269 | #endif | ||
270 | } | 221 | } |
271 | 222 | ||
272 | Opie::OPimContact AbTable::currentEntry() | 223 | Opie::OPimContact AbTable::currentEntry() |
273 | { | 224 | { |
274 | return m_viewList[currentRow()]; | 225 | return m_viewList[currentRow()]; |
275 | } | 226 | } |
276 | 227 | ||
277 | int AbTable::currentEntry_UID() | 228 | int AbTable::currentEntry_UID() |
278 | { | 229 | { |
279 | return ( currentEntry().uid() ); | 230 | return ( currentEntry().uid() ); |
280 | } | 231 | } |
281 | 232 | ||
@@ -348,54 +299,24 @@ void AbTable::keyPressEvent( QKeyEvent *e ) | |||
348 | // emit signalKeyDown(); | 299 | // emit signalKeyDown(); |
349 | // break; | 300 | // break; |
350 | default: | 301 | default: |
351 | QTable::keyPressEvent( e ); | 302 | QTable::keyPressEvent( e ); |
352 | } | 303 | } |
353 | 304 | ||
354 | } | 305 | } |
355 | 306 | ||
356 | void AbTable::moveTo( char /*c*/ ) | 307 | void AbTable::moveTo( char /*c*/ ) |
357 | { | 308 | { |
358 | odebug << "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" << oendl; | 309 | odebug << "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" << oendl; |
359 | 310 | ||
360 | #if 0 | ||
361 | int rows = numRows(); | ||
362 | QString value; | ||
363 | AbTableItem *abi; | ||
364 | int r; | ||
365 | if ( asc ) { | ||
366 | r = 0; | ||
367 | while ( r < rows-1) { | ||
368 | abi = static_cast<AbTableItem*>( item(r, 0) ); | ||
369 | QChar first = abi->key()[0]; | ||
370 | //### is there a bug in QChar to char comparison??? | ||
371 | if ( first.row() || first.cell() >= c ) | ||
372 | break; | ||
373 | r++; | ||
374 | } | ||
375 | } else { | ||
376 | //### should probably disable reverse sorting instead | ||
377 | r = rows - 1; | ||
378 | while ( r > 0 ) { | ||
379 | abi = static_cast<AbTableItem*>( item(r, 0) ); | ||
380 | QChar first = abi->key()[0]; | ||
381 | //### is there a bug in QChar to char comparison??? | ||
382 | if ( first.row() || first.cell() >= c ) | ||
383 | break; | ||
384 | r--; | ||
385 | } | ||
386 | } | ||
387 | setCurrentCell( r, currentColumn() ); | ||
388 | |||
389 | #endif | ||
390 | } | 311 | } |
391 | 312 | ||
392 | #if 0 | 313 | #if 0 |
393 | // Useless.. Nobody uses it .. (se) | 314 | // Useless.. Nobody uses it .. (se) |
394 | QString AbTable::findContactName( const Opie::OPimContact &entry ) | 315 | QString AbTable::findContactName( const Opie::OPimContact &entry ) |
395 | { | 316 | { |
396 | // We use the fileAs, then company, defaultEmail | 317 | // We use the fileAs, then company, defaultEmail |
397 | QString str; | 318 | QString str; |
398 | str = entry.fileAs(); | 319 | str = entry.fileAs(); |
399 | if ( str.isEmpty() ) { | 320 | if ( str.isEmpty() ) { |
400 | str = entry.company(); | 321 | str = entry.company(); |
401 | if ( str.isEmpty() ) { | 322 | if ( str.isEmpty() ) { |