summaryrefslogtreecommitdiff
authoreilers <eilers>2003-08-30 15:32:34 (UTC)
committer eilers <eilers>2003-08-30 15:32:34 (UTC)
commitcfb97af8f45087e58d4b82689df22191bd657c34 (patch) (unidiff)
tree9e01e85787092abb0d8c6733bbe3091eaf6a892a
parent9f07321949f8baf1a64db0e4caec58041d3f775f (diff)
downloadopie-cfb97af8f45087e58d4b82689df22191bd657c34.zip
opie-cfb97af8f45087e58d4b82689df22191bd657c34.tar.gz
opie-cfb97af8f45087e58d4b82689df22191bd657c34.tar.bz2
Speed optimization fix:
Startup and usability improved if a lot of contacts are stored. Left speed bootleneck is the xml file..
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/ablabel.cpp7
-rw-r--r--core/pim/addressbook/abtable.cpp101
-rw-r--r--core/pim/addressbook/abtable.h16
-rw-r--r--core/pim/addressbook/abview.cpp25
-rw-r--r--core/pim/addressbook/addressbook.cpp2
-rw-r--r--core/pim/addressbook/version.h2
6 files changed, 96 insertions, 57 deletions
diff --git a/core/pim/addressbook/ablabel.cpp b/core/pim/addressbook/ablabel.cpp
index 6d8de91..1914f71 100644
--- a/core/pim/addressbook/ablabel.cpp
+++ b/core/pim/addressbook/ablabel.cpp
@@ -73,6 +73,9 @@ bool AbLabel::selectContact( int UID )
73 73
74 for ( m_itCurContact = m_viewList.begin(); m_itCurContact != m_viewList.end(); ++m_itCurContact){ 74 for ( int r = 0; r < m_viewList.count(); ++r ) {
75 if ( (*m_itCurContact).uid() == UID ) 75 if ( m_viewList.uidAt( r ) == UID ){
76 m_itCurContact.setCurrent( r );
76 break; 77 break;
77 } 78 }
79 }
80
78 sync(); 81 sync();
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index a2617fa..4705c78 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -46,2 +46,4 @@
46 46
47#if 0
48
47/*! 49/*!
@@ -114,2 +116,4 @@ void AbPickItem::setContentFromEditor( QWidget *w )
114 116
117#endif
118
115/*! 119/*!
@@ -137,3 +141,3 @@ AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name
137 141
138 contactList.clear(); 142 // contactList.clear();
139 //qWarning("C'tor end"); 143 //qWarning("C'tor end");
@@ -160,3 +164,3 @@ void AbTable::setContacts( const OContactAccess::List& viewList )
160{ 164{
161 //qWarning("AbTable::setContacts()"); 165 qWarning("AbTable::setContacts()");
162 166
@@ -170,9 +174,9 @@ void AbTable::setContacts( const OContactAccess::List& viewList )
170 setNumRows( m_viewList.count() ); 174 setNumRows( m_viewList.count() );
171 int row = 0; 175 //int row = 0;
172 for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) 176 // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
173 insertIntoTable( *it, row++ ); 177 // insertIntoTable( *it, row++ );
174 178
175 setSorting( true ); 179 // setSorting( true );
176 180
177 resort(); 181 // resort();
178 182
@@ -192,5 +196,4 @@ bool AbTable::selectContact( int UID )
192{ 196{
193 //qWarning( "AbTable::selectContact( %d )", UID ); 197 qWarning( "AbTable::selectContact( %d )", UID );
194 int rows = numRows(); 198 int rows = numRows();
195 AbTableItem *abi;
196 OContact* foundContact = 0l; 199 OContact* foundContact = 0l;
@@ -199,6 +202,5 @@ bool AbTable::selectContact( int UID )
199 setPaintingEnabled( FALSE ); 202 setPaintingEnabled( FALSE );
203 qWarning( "search start" );
200 for ( int r = 0; r < rows; ++r ) { 204 for ( int r = 0; r < rows; ++r ) {
201 abi = static_cast<AbTableItem*>( item(r, 0) ); 205 if ( m_viewList.uidAt( r ) == UID ){
202 foundContact = &contactList[abi];
203 if ( foundContact -> uid() == UID ){
204 ensureCellVisible( r, 0 ); 206 ensureCellVisible( r, 0 );
@@ -209,2 +211,3 @@ bool AbTable::selectContact( int UID )
209 } 211 }
212 qWarning( "search end" );
210 213
@@ -220,5 +223,6 @@ bool AbTable::selectContact( int UID )
220 223
224#if 0
221void AbTable::insertIntoTable( const OContact& cnt, int row ) 225void AbTable::insertIntoTable( const OContact& cnt, int row )
222{ 226{
223 //qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); 227 qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
224 QString strName; 228 QString strName;
@@ -242,3 +246,3 @@ void AbTable::insertIntoTable( const OContact& cnt, int row )
242} 246}
243 247#endif
244 248
@@ -265,3 +269,4 @@ void AbTable::resort()
265{ 269{
266 //qWarning( "void AbTable::resort()" ); 270 qWarning( "void AbTable::resort() NOT POSSIBLE !!" );
271#if 0
267 setPaintingEnabled( FALSE ); 272 setPaintingEnabled( FALSE );
@@ -275,2 +280,3 @@ void AbTable::resort()
275 setPaintingEnabled( TRUE ); 280 setPaintingEnabled( TRUE );
281#endif
276} 282}
@@ -279,11 +285,3 @@ OContact AbTable::currentEntry()
279{ 285{
280 //qWarning( "OContact AbTable::currentEntry()" ); 286 return m_viewList[currentRow()];
281 OContact cnt;
282 AbTableItem *abItem;
283 abItem = static_cast<AbTableItem*>(item( currentRow(), 0 ));
284 if ( abItem ) {
285 cnt = contactList[abItem];
286 //cnt = contactList[currentRow()];
287 }
288 return cnt;
289} 287}
@@ -297,4 +295,4 @@ void AbTable::clear()
297{ 295{
298 //qWarning( "void AbTable::clear()" ); 296 qWarning( "void AbTable::clear()" );
299 contactList.clear(); 297 // contactList.clear();
300 298
@@ -315,3 +313,5 @@ void AbTable::refresh()
315{ 313{
316 //qWarning( "void AbTable::refresh()" ); 314 qWarning( "void AbTable::refresh() NOT IMPLEMENTED !!" );
315
316#if 0
317 int rows = numRows(); 317 int rows = numRows();
@@ -335,2 +335,4 @@ void AbTable::refresh()
335 setPaintingEnabled( TRUE ); 335 setPaintingEnabled( TRUE );
336
337#endif
336} 338}
@@ -367,4 +369,5 @@ void AbTable::moveTo( char c )
367{ 369{
368 qWarning( "void AbTable::moveTo( char c )" ); 370 qWarning( "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" );
369 371
372#if 0
370 int rows = numRows(); 373 int rows = numRows();
@@ -396,5 +399,8 @@ void AbTable::moveTo( char c )
396 setCurrentCell( r, currentColumn() ); 399 setCurrentCell( r, currentColumn() );
397}
398 400
401#endif
402}
399 403
404#if 0
405// Useless.. Nobody uses it .. (se)
400QString AbTable::findContactName( const OContact &entry ) 406QString AbTable::findContactName( const OContact &entry )
@@ -412,3 +418,3 @@ QString AbTable::findContactName( const OContact &entry )
412} 418}
413 419#endif
414 420
@@ -508,2 +514,3 @@ void AbTable::show()
508 514
515#if 0
509void AbTable::setChoiceNames( const QStringList& list) 516void AbTable::setChoiceNames( const QStringList& list)
@@ -522,2 +529,3 @@ void AbTable::setChoiceNames( const QStringList& list)
522} 529}
530#endif
523 531
@@ -534,2 +542,3 @@ void AbTable::itemClicked(int,int col)
534 542
543#if 0
535QStringList AbTable::choiceNames() const 544QStringList AbTable::choiceNames() const
@@ -539,2 +548,3 @@ QStringList AbTable::choiceNames() const
539 548
549#endif
540void AbTable::setChoiceSelection( const QValueList<int>& list ) 550void AbTable::setChoiceSelection( const QValueList<int>& list )
@@ -562,4 +572,2 @@ QStringList AbTable::choiceSelection(int /*index*/) const
562 572
563
564
565void AbTable::updateVisible() 573void AbTable::updateVisible()
@@ -632,2 +640,6 @@ void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool )
632 640
641 //qWarning( "Paint row: %d", row );
642
643 OContact act_contact = m_viewList[row];
644
633 // Paint alternating background bars 645 // Paint alternating background bars
@@ -649,7 +661,19 @@ void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool )
649 661
650 QPixmap pic = pixmap( row, col ); 662 QString nameText = act_contact.fileAs();
651 if ( !pic.isNull() ) 663
664 switch( col ){
665 case 0:
666 p->drawText( x + marg,2 + fm.ascent(), nameText );
667 break;
668 case 1:{
669
670 ContactItem contactItem = findContactContact( act_contact, 0 );
671 QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */
672 QString contactText = contactItem.value;
673
674 if ( !contactPic.isNull() )
652 { 675 {
653 p->drawPixmap( x + marg, y, pixmap( row, col ) ); 676 p->drawPixmap( x + marg, y, contactPic );
654 p->drawText( x + marg + pixmap( row, col ).width() + 4,2 + fm.ascent(), text( row, col ) ); 677 p->drawText( x + marg + contactPic.width()
678 + 4,2 + fm.ascent(), contactText );
655 } 679 }
@@ -657,5 +681,8 @@ void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool )
657 { 681 {
658 p->drawText( x + marg,2 + fm.ascent(), text( row, col ) ); 682 p->drawText( x + marg,2 + fm.ascent(), contactText );
659 } 683 }
684 }
685 break;
660 686
687 }
661 p->restore(); 688 p->restore();
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index 0f7bc29..b9ebe27 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -34,2 +34,3 @@
34 34
35#if 0
35class AbTableItem : public QTableItem 36class AbTableItem : public QTableItem
@@ -49,2 +50,4 @@ private:
49 50
51#endif
52
50// This is a simple container, storing all contact 53// This is a simple container, storing all contact
@@ -58,2 +61,3 @@ class ContactItem
58 61
62#if 0
59class AbPickItem : public QTableItem 63class AbPickItem : public QTableItem
@@ -70,2 +74,4 @@ private:
70 74
75#endif
76
71class AbTable : public QTable 77class AbTable : public QTable
@@ -93,3 +99,3 @@ public:
93 99
94 QString findContactName( const OContact &entry ); 100 // QString findContactName( const OContact &entry );
95 101
@@ -105,4 +111,4 @@ public:
105 // addresspicker mode (What's that ? se) 111 // addresspicker mode (What's that ? se)
106 void setChoiceNames( const QStringList& list); 112 // void setChoiceNames( const QStringList& list);
107 QStringList choiceNames() const; 113 // QStringList choiceNames() const;
108 void setChoiceSelection( const QValueList<int>& list ); 114 void setChoiceSelection( const QValueList<int>& list );
@@ -131,3 +137,3 @@ protected slots:
131private: 137private:
132 void insertIntoTable( const OContact &cnt, int row ); 138 // void insertIntoTable( const OContact &cnt, int row );
133 ContactItem findContactContact( const OContact &entry, int row ); 139 ContactItem findContactContact( const OContact &entry, int row );
@@ -141,3 +147,3 @@ private:
141 bool asc; 147 bool asc;
142 QMap<AbTableItem*, OContact> contactList; 148 // QMap<AbTableItem*, OContact> contactList;
143 QValueList<int> intFields; 149 QValueList<int> intFields;
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index 477f85b..6cbd556 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -53,2 +53,3 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ):
53{ 53{
54 qWarning("AbView::c'tor");
54 // Load default database and handle syncing myself.. ! 55 // Load default database and handle syncing myself.. !
@@ -99,3 +100,3 @@ void AbView::setView( Views view )
99{ 100{
100 //qWarning("AbView::setView( Views view )"); 101 qWarning("AbView::setView( Views view )");
101 m_curr_View = view; 102 m_curr_View = view;
@@ -106,3 +107,3 @@ void AbView::addEntry( const OContact &newContact )
106{ 107{
107 //qWarning("abview:AddContact"); 108 qWarning("abview:AddContact");
108 m_contactdb->add ( newContact ); 109 m_contactdb->add ( newContact );
@@ -113,3 +114,3 @@ void AbView::removeEntry( const int UID )
113{ 114{
114 //qWarning("abview:RemoveContact"); 115 qWarning("abview:RemoveContact");
115 m_contactdb->remove( UID ); 116 m_contactdb->remove( UID );
@@ -120,3 +121,3 @@ void AbView::replaceEntry( const OContact &contact )
120{ 121{
121 //qWarning("abview:ReplaceContact"); 122 qWarning("abview:ReplaceContact");
122 m_contactdb->replace( contact ); 123 m_contactdb->replace( contact );
@@ -151,3 +152,3 @@ void AbView::load()
151{ 152{
152 //qWarning("abView:Load data"); 153 qWarning("abView:Load data");
153 154
@@ -161,2 +162,3 @@ void AbView::load()
161 m_list = m_contactdb->sorted( true, 0, 0, 0 ); 162 m_list = m_contactdb->sorted( true, 0, 0, 0 );
163 if ( m_curr_category != -1 )
162 clearForCategory(); 164 clearForCategory();
@@ -172,3 +174,3 @@ void AbView::reload()
172{ 174{
173 //qWarning( "void AbView::reload()" ); 175 qWarning( "void AbView::reload()" );
174 176
@@ -185,3 +187,3 @@ void AbView::setShowByCategory( const QString& cat )
185{ 187{
186 //qWarning("AbView::setShowCategory( const QString& cat )"); 188 qWarning("AbView::setShowCategory( const QString& cat )");
187 189
@@ -209,7 +211,6 @@ void AbView::setShowToView( Views view )
209{ 211{
210 //qWarning("void AbView::setShowToView( View %d )", view); 212 qWarning("void AbView::setShowToView( View %d )", view);
211
212 //qWarning ("Change the View (Category is: %d)", m_curr_category);
213 213
214 if ( m_curr_View != view ){ 214 if ( m_curr_View != view ){
215 qWarning ("Change the View (Category is: %d)", m_curr_category);
215 m_prev_View = m_curr_View; 216 m_prev_View = m_curr_View;
@@ -252,2 +253,3 @@ void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode )
252 m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); 253 m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase );
254 if ( m_curr_category != -1 )
253 clearForCategory(); 255 clearForCategory();
@@ -276,3 +278,3 @@ void AbView::showPersonal( bool personal )
276{ 278{
277 //qWarning ("void AbView::showPersonal( %d )", personal); 279 qWarning ("void AbView::showPersonal( %d )", personal);
278 280
@@ -364,2 +366,3 @@ void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
364 // we will not have a lot of matching entries.. 366 // we will not have a lot of matching entries..
367 if ( m_curr_category != -1 )
365 clearForCategory(); 368 clearForCategory();
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 03c96c8..0ba024e 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -250,3 +250,3 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
250 250
251 m_abView->load(); 251 // m_abView->load(); // Already done by c'tor .
252 252
diff --git a/core/pim/addressbook/version.h b/core/pim/addressbook/version.h
index 9621826..790aa95 100644
--- a/core/pim/addressbook/version.h
+++ b/core/pim/addressbook/version.h
@@ -4,3 +4,3 @@
4#define MAINVERSION "1" 4#define MAINVERSION "1"
5#define SUBVERSION "0" 5#define SUBVERSION "1"
6#define PATCHVERSION "0" 6#define PATCHVERSION "0"