author | eilers <eilers> | 2003-08-30 15:32:34 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-30 15:32:34 (UTC) |
commit | cfb97af8f45087e58d4b82689df22191bd657c34 (patch) (unidiff) | |
tree | 9e01e85787092abb0d8c6733bbe3091eaf6a892a | |
parent | 9f07321949f8baf1a64db0e4caec58041d3f775f (diff) | |
download | opie-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..
-rw-r--r-- | core/pim/addressbook/ablabel.cpp | 7 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 113 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.h | 16 | ||||
-rw-r--r-- | core/pim/addressbook/abview.cpp | 31 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 2 | ||||
-rw-r--r-- | core/pim/addressbook/version.h | 2 |
6 files changed, 105 insertions, 66 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 | |||
@@ -50,52 +50,55 @@ void AbLabel::setContacts( const OContactAccess::List& viewList ) | |||
50 | } | 50 | } |
51 | 51 | ||
52 | int AbLabel::currentEntry_UID() | 52 | int AbLabel::currentEntry_UID() |
53 | { | 53 | { |
54 | OContact contact = currentEntry(); | 54 | OContact contact = currentEntry(); |
55 | 55 | ||
56 | if ( contact.isEmpty() ) | 56 | if ( contact.isEmpty() ) |
57 | return 0; | 57 | return 0; |
58 | else | 58 | else |
59 | return ( contact.uid() ); | 59 | return ( contact.uid() ); |
60 | } | 60 | } |
61 | 61 | ||
62 | OContact AbLabel::currentEntry() | 62 | OContact AbLabel::currentEntry() |
63 | { | 63 | { |
64 | if ( ! m_empty ) | 64 | if ( ! m_empty ) |
65 | return ( *m_itCurContact ); | 65 | return ( *m_itCurContact ); |
66 | else | 66 | else |
67 | return OContact(); | 67 | return OContact(); |
68 | } | 68 | } |
69 | 69 | ||
70 | 70 | ||
71 | bool AbLabel::selectContact( int UID ) | 71 | bool AbLabel::selectContact( int UID ) |
72 | { | 72 | { |
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; |
78 | } | ||
77 | } | 79 | } |
80 | |||
78 | sync(); | 81 | sync(); |
79 | 82 | ||
80 | return true; | 83 | return true; |
81 | } | 84 | } |
82 | 85 | ||
83 | 86 | ||
84 | 87 | ||
85 | void AbLabel::sync() | 88 | void AbLabel::sync() |
86 | { | 89 | { |
87 | QString text = (*m_itCurContact).toRichText(); | 90 | QString text = (*m_itCurContact).toRichText(); |
88 | setText( text ); | 91 | setText( text ); |
89 | } | 92 | } |
90 | 93 | ||
91 | void AbLabel::keyPressEvent( QKeyEvent *e ) | 94 | void AbLabel::keyPressEvent( QKeyEvent *e ) |
92 | { | 95 | { |
93 | 96 | ||
94 | // Commonly handled keys | 97 | // Commonly handled keys |
95 | if ( !m_empty ){ | 98 | if ( !m_empty ){ |
96 | switch( e->key() ) { | 99 | switch( e->key() ) { |
97 | case Qt::Key_Left: | 100 | case Qt::Key_Left: |
98 | qWarning( "Left.."); | 101 | qWarning( "Left.."); |
99 | case Qt::Key_Right: | 102 | case Qt::Key_Right: |
100 | qWarning( "Right.."); | 103 | qWarning( "Right.."); |
101 | case Qt::Key_F33: | 104 | case Qt::Key_F33: |
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 | |||
@@ -23,48 +23,50 @@ | |||
23 | #include <qpe/categoryselect.h> | 23 | #include <qpe/categoryselect.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qpe/stringutil.h> | 25 | #include <qpe/stringutil.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qpe/timestring.h> | 27 | #include <qpe/timestring.h> |
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | 29 | ||
30 | #include <opie/orecordlist.h> | 30 | #include <opie/orecordlist.h> |
31 | 31 | ||
32 | #include <qasciidict.h> | 32 | #include <qasciidict.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | 37 | ||
38 | #include "abtable.h" | 38 | #include "abtable.h" |
39 | 39 | ||
40 | #include <errno.h> | 40 | #include <errno.h> |
41 | #include <fcntl.h> | 41 | #include <fcntl.h> |
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | 44 | ||
45 | #include <ctype.h> //toupper() for key hack | 45 | #include <ctype.h> //toupper() for key hack |
46 | 46 | ||
47 | #if 0 | ||
48 | |||
47 | /*! | 49 | /*! |
48 | \class AbTableItem abtable.h | 50 | \class AbTableItem abtable.h |
49 | 51 | ||
50 | \brief QTableItem based class for showing a field of an entry | 52 | \brief QTableItem based class for showing a field of an entry |
51 | */ | 53 | */ |
52 | 54 | ||
53 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, | 55 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, |
54 | const QString &secondSortKey) | 56 | const QString &secondSortKey) |
55 | : QTableItem( t, et, s ) | 57 | : QTableItem( t, et, s ) |
56 | { | 58 | { |
57 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); | 59 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); |
58 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); | 60 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); |
59 | } | 61 | } |
60 | 62 | ||
61 | int AbTableItem::alignment() const | 63 | int AbTableItem::alignment() const |
62 | { | 64 | { |
63 | return AlignLeft|AlignVCenter; | 65 | return AlignLeft|AlignVCenter; |
64 | } | 66 | } |
65 | 67 | ||
66 | QString AbTableItem::key() const | 68 | QString AbTableItem::key() const |
67 | { | 69 | { |
68 | return sortKey; | 70 | return sortKey; |
69 | } | 71 | } |
70 | 72 | ||
@@ -91,347 +93,351 @@ AbPickItem::AbPickItem( QTable *t ) : | |||
91 | QWidget *AbPickItem::createEditor() const | 93 | QWidget *AbPickItem::createEditor() const |
92 | { | 94 | { |
93 | QComboBox* combo = new QComboBox( table()->viewport() ); | 95 | QComboBox* combo = new QComboBox( table()->viewport() ); |
94 | ( (AbPickItem*)this )->cb = combo; | 96 | ( (AbPickItem*)this )->cb = combo; |
95 | AbTable* t = static_cast<AbTable*>(table()); | 97 | AbTable* t = static_cast<AbTable*>(table()); |
96 | QStringList c = t->choiceNames(); | 98 | QStringList c = t->choiceNames(); |
97 | int cur = 0; | 99 | int cur = 0; |
98 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { | 100 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { |
99 | if ( *it == text() ) | 101 | if ( *it == text() ) |
100 | cur = combo->count(); | 102 | cur = combo->count(); |
101 | combo->insertItem(*it); | 103 | combo->insertItem(*it); |
102 | } | 104 | } |
103 | combo->setCurrentItem(cur); | 105 | combo->setCurrentItem(cur); |
104 | return combo; | 106 | return combo; |
105 | } | 107 | } |
106 | 108 | ||
107 | void AbPickItem::setContentFromEditor( QWidget *w ) | 109 | void AbPickItem::setContentFromEditor( QWidget *w ) |
108 | { | 110 | { |
109 | if ( w->inherits("QComboBox") ) | 111 | if ( w->inherits("QComboBox") ) |
110 | setText( ( (QComboBox*)w )->currentText() ); | 112 | setText( ( (QComboBox*)w )->currentText() ); |
111 | else | 113 | else |
112 | QTableItem::setContentFromEditor( w ); | 114 | QTableItem::setContentFromEditor( w ); |
113 | } | 115 | } |
114 | 116 | ||
117 | #endif | ||
118 | |||
115 | /*! | 119 | /*! |
116 | \class AbTable abtable.h | 120 | \class AbTable abtable.h |
117 | 121 | ||
118 | \brief QTable based class for showing a list of entries | 122 | \brief QTable based class for showing a list of entries |
119 | */ | 123 | */ |
120 | 124 | ||
121 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) | 125 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) |
122 | : QTable( parent, name ), | 126 | : QTable( parent, name ), |
123 | lastSortCol( -1 ), | 127 | lastSortCol( -1 ), |
124 | asc( TRUE ), | 128 | asc( TRUE ), |
125 | intFields( order ), | 129 | intFields( order ), |
126 | enablePainting( true ), | 130 | enablePainting( true ), |
127 | columnVisible( true ), | 131 | columnVisible( true ), |
128 | countNested( 0 ) | 132 | countNested( 0 ) |
129 | { | 133 | { |
130 | //qWarning("C'tor start"); | 134 | //qWarning("C'tor start"); |
131 | 135 | ||
132 | setSelectionMode( NoSelection ); | 136 | setSelectionMode( NoSelection ); |
133 | init(); | 137 | init(); |
134 | setSorting( TRUE ); | 138 | setSorting( TRUE ); |
135 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), | 139 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), |
136 | this, SLOT(itemClicked(int,int)) ); | 140 | this, SLOT(itemClicked(int,int)) ); |
137 | 141 | ||
138 | contactList.clear(); | 142 | // contactList.clear(); |
139 | //qWarning("C'tor end"); | 143 | //qWarning("C'tor end"); |
140 | } | 144 | } |
141 | 145 | ||
142 | AbTable::~AbTable() | 146 | AbTable::~AbTable() |
143 | { | 147 | { |
144 | } | 148 | } |
145 | 149 | ||
146 | void AbTable::init() | 150 | void AbTable::init() |
147 | { | 151 | { |
148 | // :SX showChar = '\0'; | 152 | // :SX showChar = '\0'; |
149 | setNumRows( 0 ); | 153 | setNumRows( 0 ); |
150 | setNumCols( 2 ); | 154 | setNumCols( 2 ); |
151 | 155 | ||
152 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 156 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
153 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 157 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
154 | setLeftMargin( 0 ); | 158 | setLeftMargin( 0 ); |
155 | verticalHeader()->hide(); | 159 | verticalHeader()->hide(); |
156 | columnVisible = true; | 160 | columnVisible = true; |
157 | } | 161 | } |
158 | 162 | ||
159 | void AbTable::setContacts( const OContactAccess::List& viewList ) | 163 | void AbTable::setContacts( const OContactAccess::List& viewList ) |
160 | { | 164 | { |
161 | //qWarning("AbTable::setContacts()"); | 165 | qWarning("AbTable::setContacts()"); |
162 | 166 | ||
163 | clear(); | 167 | clear(); |
164 | m_viewList = viewList; | 168 | m_viewList = viewList; |
165 | 169 | ||
166 | setSorting( false ); | 170 | setSorting( false ); |
167 | setPaintingEnabled( FALSE ); | 171 | setPaintingEnabled( FALSE ); |
168 | 172 | ||
169 | OContactAccess::List::Iterator it; | 173 | OContactAccess::List::Iterator it; |
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 | ||
179 | updateVisible(); | 183 | updateVisible(); |
180 | 184 | ||
181 | setPaintingEnabled( TRUE ); | 185 | setPaintingEnabled( TRUE ); |
182 | 186 | ||
183 | } | 187 | } |
184 | 188 | ||
185 | void AbTable::setOrderedList( const QValueList<int> ordered ) | 189 | void AbTable::setOrderedList( const QValueList<int> ordered ) |
186 | { | 190 | { |
187 | intFields = ordered; | 191 | intFields = ordered; |
188 | } | 192 | } |
189 | 193 | ||
190 | 194 | ||
191 | bool AbTable::selectContact( int UID ) | 195 | 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; |
197 | bool found = false; | 200 | bool found = false; |
198 | 201 | ||
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 ); |
205 | setCurrentCell( r, 0 ); | 207 | setCurrentCell( r, 0 ); |
206 | found = true; | 208 | found = true; |
207 | break; | 209 | break; |
208 | } | 210 | } |
209 | } | 211 | } |
212 | qWarning( "search end" ); | ||
210 | 213 | ||
211 | if ( !found ){ | 214 | if ( !found ){ |
212 | ensureCellVisible( 0,0 ); | 215 | ensureCellVisible( 0,0 ); |
213 | setCurrentCell( 0, 0 ); | 216 | setCurrentCell( 0, 0 ); |
214 | } | 217 | } |
215 | 218 | ||
216 | setPaintingEnabled( TRUE ); | 219 | setPaintingEnabled( TRUE ); |
217 | 220 | ||
218 | return true; | 221 | return true; |
219 | } | 222 | } |
220 | 223 | ||
224 | #if 0 | ||
221 | void AbTable::insertIntoTable( const OContact& cnt, int row ) | 225 | void 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; |
225 | ContactItem contactItem; | 229 | ContactItem contactItem; |
226 | 230 | ||
227 | strName = findContactName( cnt ); | 231 | strName = findContactName( cnt ); |
228 | contactItem = findContactContact( cnt, row ); | 232 | contactItem = findContactContact( cnt, row ); |
229 | 233 | ||
230 | AbTableItem *ati; | 234 | AbTableItem *ati; |
231 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); | 235 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); |
232 | contactList.insert( ati, cnt ); | 236 | contactList.insert( ati, cnt ); |
233 | setItem( row, 0, ati ); | 237 | setItem( row, 0, ati ); |
234 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); | 238 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); |
235 | if ( !contactItem.icon.isNull() ) | 239 | if ( !contactItem.icon.isNull() ) |
236 | ati->setPixmap( contactItem.icon ); | 240 | ati->setPixmap( contactItem.icon ); |
237 | setItem( row, 1, ati ); | 241 | setItem( row, 1, ati ); |
238 | 242 | ||
239 | //### cannot do this; table only has two columns at this point | 243 | //### cannot do this; table only has two columns at this point |
240 | // setItem( row, 2, new AbPickItem( this ) ); | 244 | // setItem( row, 2, new AbPickItem( this ) ); |
241 | 245 | ||
242 | } | 246 | } |
243 | 247 | #endif | |
244 | 248 | ||
245 | 249 | ||
246 | void AbTable::columnClicked( int col ) | 250 | void AbTable::columnClicked( int col ) |
247 | { | 251 | { |
248 | if ( !sorting() ) | 252 | if ( !sorting() ) |
249 | return; | 253 | return; |
250 | 254 | ||
251 | if ( lastSortCol == -1 ) | 255 | if ( lastSortCol == -1 ) |
252 | lastSortCol = col; | 256 | lastSortCol = col; |
253 | 257 | ||
254 | if ( col == lastSortCol ) { | 258 | if ( col == lastSortCol ) { |
255 | asc = !asc; | 259 | asc = !asc; |
256 | } else { | 260 | } else { |
257 | lastSortCol = col; | 261 | lastSortCol = col; |
258 | asc = TRUE; | 262 | asc = TRUE; |
259 | } | 263 | } |
260 | //QMessageBox::information( this, "resort", "columnClicked" ); | 264 | //QMessageBox::information( this, "resort", "columnClicked" ); |
261 | resort(); | 265 | resort(); |
262 | } | 266 | } |
263 | 267 | ||
264 | void AbTable::resort() | 268 | 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 ); |
268 | if ( sorting() ) { | 273 | if ( sorting() ) { |
269 | if ( lastSortCol == -1 ) | 274 | if ( lastSortCol == -1 ) |
270 | lastSortCol = 0; | 275 | lastSortCol = 0; |
271 | sortColumn( lastSortCol, asc, TRUE ); | 276 | sortColumn( lastSortCol, asc, TRUE ); |
272 | //QMessageBox::information( this, "resort", "resort" ); | 277 | //QMessageBox::information( this, "resort", "resort" ); |
273 | updateVisible(); | 278 | updateVisible(); |
274 | } | 279 | } |
275 | setPaintingEnabled( TRUE ); | 280 | setPaintingEnabled( TRUE ); |
281 | #endif | ||
276 | } | 282 | } |
277 | 283 | ||
278 | OContact AbTable::currentEntry() | 284 | 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 | } |
290 | 288 | ||
291 | int AbTable::currentEntry_UID() | 289 | int AbTable::currentEntry_UID() |
292 | { | 290 | { |
293 | return ( currentEntry().uid() ); | 291 | return ( currentEntry().uid() ); |
294 | } | 292 | } |
295 | 293 | ||
296 | void AbTable::clear() | 294 | void AbTable::clear() |
297 | { | 295 | { |
298 | //qWarning( "void AbTable::clear()" ); | 296 | qWarning( "void AbTable::clear()" ); |
299 | contactList.clear(); | 297 | // contactList.clear(); |
300 | 298 | ||
301 | setPaintingEnabled( FALSE ); | 299 | setPaintingEnabled( FALSE ); |
302 | for ( int r = 0; r < numRows(); ++r ) { | 300 | for ( int r = 0; r < numRows(); ++r ) { |
303 | for ( int c = 0; c < numCols(); ++c ) { | 301 | for ( int c = 0; c < numCols(); ++c ) { |
304 | if ( cellWidget( r, c ) ) | 302 | if ( cellWidget( r, c ) ) |
305 | clearCellWidget( r, c ); | 303 | clearCellWidget( r, c ); |
306 | clearCell( r, c ); | 304 | clearCell( r, c ); |
307 | } | 305 | } |
308 | } | 306 | } |
309 | setNumRows( 0 ); | 307 | setNumRows( 0 ); |
310 | setPaintingEnabled( TRUE ); | 308 | setPaintingEnabled( TRUE ); |
311 | } | 309 | } |
312 | 310 | ||
313 | // Refresh updates column 2 if the contactsettings changed | 311 | // Refresh updates column 2 if the contactsettings changed |
314 | void AbTable::refresh() | 312 | 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(); |
318 | AbTableItem *abi; | 318 | AbTableItem *abi; |
319 | ContactItem contactItem; | 319 | ContactItem contactItem; |
320 | 320 | ||
321 | setPaintingEnabled( FALSE ); | 321 | setPaintingEnabled( FALSE ); |
322 | for ( int r = 0; r < rows; ++r ) { | 322 | for ( int r = 0; r < rows; ++r ) { |
323 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 323 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
324 | contactItem = findContactContact( contactList[abi], r ); | 324 | contactItem = findContactContact( contactList[abi], r ); |
325 | static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); | 325 | static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); |
326 | if ( !contactItem.icon.isNull() ){ | 326 | if ( !contactItem.icon.isNull() ){ |
327 | static_cast<AbTableItem*>( item(r, 1) )-> | 327 | static_cast<AbTableItem*>( item(r, 1) )-> |
328 | setPixmap( contactItem.icon ); | 328 | setPixmap( contactItem.icon ); |
329 | }else{ | 329 | }else{ |
330 | static_cast<AbTableItem*>( item(r, 1) )-> | 330 | static_cast<AbTableItem*>( item(r, 1) )-> |
331 | setPixmap( QPixmap() ); | 331 | setPixmap( QPixmap() ); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | resort(); | 334 | resort(); |
335 | setPaintingEnabled( TRUE ); | 335 | setPaintingEnabled( TRUE ); |
336 | |||
337 | #endif | ||
336 | } | 338 | } |
337 | 339 | ||
338 | void AbTable::keyPressEvent( QKeyEvent *e ) | 340 | void AbTable::keyPressEvent( QKeyEvent *e ) |
339 | { | 341 | { |
340 | char key = toupper( e->ascii() ); | 342 | char key = toupper( e->ascii() ); |
341 | 343 | ||
342 | if ( key >= 'A' && key <= 'Z' ) | 344 | if ( key >= 'A' && key <= 'Z' ) |
343 | moveTo( key ); | 345 | moveTo( key ); |
344 | 346 | ||
345 | //qWarning("Received key .."); | 347 | //qWarning("Received key .."); |
346 | switch( e->key() ) { | 348 | switch( e->key() ) { |
347 | case Qt::Key_Space: | 349 | case Qt::Key_Space: |
348 | case Qt::Key_Return: | 350 | case Qt::Key_Return: |
349 | case Qt::Key_Enter: | 351 | case Qt::Key_Enter: |
350 | emit signalSwitch(); | 352 | emit signalSwitch(); |
351 | break; | 353 | break; |
352 | // case Qt::Key_Up: | 354 | // case Qt::Key_Up: |
353 | // qWarning("a"); | 355 | // qWarning("a"); |
354 | // emit signalKeyUp(); | 356 | // emit signalKeyUp(); |
355 | // break; | 357 | // break; |
356 | // case Qt::Key_Down: | 358 | // case Qt::Key_Down: |
357 | // qWarning("b"); | 359 | // qWarning("b"); |
358 | // emit signalKeyDown(); | 360 | // emit signalKeyDown(); |
359 | // break; | 361 | // break; |
360 | default: | 362 | default: |
361 | QTable::keyPressEvent( e ); | 363 | QTable::keyPressEvent( e ); |
362 | } | 364 | } |
363 | 365 | ||
364 | } | 366 | } |
365 | 367 | ||
366 | void AbTable::moveTo( char c ) | 368 | 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(); |
371 | QString value; | 374 | QString value; |
372 | AbTableItem *abi; | 375 | AbTableItem *abi; |
373 | int r; | 376 | int r; |
374 | if ( asc ) { | 377 | if ( asc ) { |
375 | r = 0; | 378 | r = 0; |
376 | while ( r < rows-1) { | 379 | while ( r < rows-1) { |
377 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 380 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
378 | QChar first = abi->key()[0]; | 381 | QChar first = abi->key()[0]; |
379 | //### is there a bug in QChar to char comparison??? | 382 | //### is there a bug in QChar to char comparison??? |
380 | if ( first.row() || first.cell() >= c ) | 383 | if ( first.row() || first.cell() >= c ) |
381 | break; | 384 | break; |
382 | r++; | 385 | r++; |
383 | } | 386 | } |
384 | } else { | 387 | } else { |
385 | //### should probably disable reverse sorting instead | 388 | //### should probably disable reverse sorting instead |
386 | r = rows - 1; | 389 | r = rows - 1; |
387 | while ( r > 0 ) { | 390 | while ( r > 0 ) { |
388 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 391 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
389 | QChar first = abi->key()[0]; | 392 | QChar first = abi->key()[0]; |
390 | //### is there a bug in QChar to char comparison??? | 393 | //### is there a bug in QChar to char comparison??? |
391 | if ( first.row() || first.cell() >= c ) | 394 | if ( first.row() || first.cell() >= c ) |
392 | break; | 395 | break; |
393 | r--; | 396 | r--; |
394 | } | 397 | } |
395 | } | 398 | } |
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) | ||
400 | QString AbTable::findContactName( const OContact &entry ) | 406 | QString AbTable::findContactName( const OContact &entry ) |
401 | { | 407 | { |
402 | // We use the fileAs, then company, defaultEmail | 408 | // We use the fileAs, then company, defaultEmail |
403 | QString str; | 409 | QString str; |
404 | str = entry.fileAs(); | 410 | str = entry.fileAs(); |
405 | if ( str.isEmpty() ) { | 411 | if ( str.isEmpty() ) { |
406 | str = entry.company(); | 412 | str = entry.company(); |
407 | if ( str.isEmpty() ) { | 413 | if ( str.isEmpty() ) { |
408 | str = entry.defaultEmail(); | 414 | str = entry.defaultEmail(); |
409 | } | 415 | } |
410 | } | 416 | } |
411 | return str; | 417 | return str; |
412 | } | 418 | } |
413 | 419 | #endif | |
414 | 420 | ||
415 | 421 | ||
416 | void AbTable::resizeRows() { | 422 | void AbTable::resizeRows() { |
417 | /* | 423 | /* |
418 | if (numRows()) { | 424 | if (numRows()) { |
419 | for (int i = 0; i < numRows(); i++) { | 425 | for (int i = 0; i < numRows(); i++) { |
420 | setRowHeight( i, size ); | 426 | setRowHeight( i, size ); |
421 | } | 427 | } |
422 | } | 428 | } |
423 | updateVisible(); | 429 | updateVisible(); |
424 | */ | 430 | */ |
425 | } | 431 | } |
426 | 432 | ||
427 | 433 | ||
428 | void AbTable::realignTable() | 434 | void AbTable::realignTable() |
429 | { | 435 | { |
430 | //qWarning( "void AbTable::realignTable()" ); | 436 | //qWarning( "void AbTable::realignTable()" ); |
431 | 437 | ||
432 | setPaintingEnabled( FALSE ); | 438 | setPaintingEnabled( FALSE ); |
433 | 439 | ||
434 | resizeRows(); | 440 | resizeRows(); |
435 | fitColumns(); | 441 | fitColumns(); |
436 | 442 | ||
437 | setPaintingEnabled( TRUE ); | 443 | setPaintingEnabled( TRUE ); |
@@ -485,104 +491,106 @@ void AbTable::fitColumns() | |||
485 | setPaintingEnabled( FALSE ); | 491 | setPaintingEnabled( FALSE ); |
486 | 492 | ||
487 | if ( columnVisible == false ){ | 493 | if ( columnVisible == false ){ |
488 | showColumn(0); | 494 | showColumn(0); |
489 | columnVisible = true; | 495 | columnVisible = true; |
490 | } | 496 | } |
491 | 497 | ||
492 | //qWarning("Width: %d", contentsWidth); | 498 | //qWarning("Width: %d", contentsWidth); |
493 | 499 | ||
494 | setColumnWidth( 0, contentsWidth ); | 500 | setColumnWidth( 0, contentsWidth ); |
495 | adjustColumn(1); | 501 | adjustColumn(1); |
496 | if ( columnWidth(1) < contentsWidth ) | 502 | if ( columnWidth(1) < contentsWidth ) |
497 | setColumnWidth( 1, contentsWidth ); | 503 | setColumnWidth( 1, contentsWidth ); |
498 | 504 | ||
499 | setPaintingEnabled( TRUE ); | 505 | setPaintingEnabled( TRUE ); |
500 | } | 506 | } |
501 | 507 | ||
502 | void AbTable::show() | 508 | void AbTable::show() |
503 | { | 509 | { |
504 | //qWarning( "void AbTable::show()" ); | 510 | //qWarning( "void AbTable::show()" ); |
505 | realignTable(); | 511 | realignTable(); |
506 | QTable::show(); | 512 | QTable::show(); |
507 | } | 513 | } |
508 | 514 | ||
515 | #if 0 | ||
509 | void AbTable::setChoiceNames( const QStringList& list) | 516 | void AbTable::setChoiceNames( const QStringList& list) |
510 | { | 517 | { |
511 | choicenames = list; | 518 | choicenames = list; |
512 | if ( choicenames.isEmpty() ) { | 519 | if ( choicenames.isEmpty() ) { |
513 | // hide pick column | 520 | // hide pick column |
514 | setNumCols( 2 ); | 521 | setNumCols( 2 ); |
515 | } else { | 522 | } else { |
516 | // show pick column | 523 | // show pick column |
517 | setNumCols( 3 ); | 524 | setNumCols( 3 ); |
518 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); | 525 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); |
519 | horizontalHeader()->setLabel( 2, tr( "Pick" )); | 526 | horizontalHeader()->setLabel( 2, tr( "Pick" )); |
520 | } | 527 | } |
521 | fitColumns(); | 528 | fitColumns(); |
522 | } | 529 | } |
530 | #endif | ||
523 | 531 | ||
524 | void AbTable::itemClicked(int,int col) | 532 | void AbTable::itemClicked(int,int col) |
525 | { | 533 | { |
526 | //qWarning( "AbTable::itemClicked(int, col:%d)", col); | 534 | //qWarning( "AbTable::itemClicked(int, col:%d)", col); |
527 | if ( col == 2 ) { | 535 | if ( col == 2 ) { |
528 | return; | 536 | return; |
529 | } else { | 537 | } else { |
530 | // qWarning ("Emitting signalSwitch()"); | 538 | // qWarning ("Emitting signalSwitch()"); |
531 | emit signalSwitch(); | 539 | emit signalSwitch(); |
532 | } | 540 | } |
533 | } | 541 | } |
534 | 542 | ||
543 | #if 0 | ||
535 | QStringList AbTable::choiceNames() const | 544 | QStringList AbTable::choiceNames() const |
536 | { | 545 | { |
537 | return choicenames; | 546 | return choicenames; |
538 | } | 547 | } |
539 | 548 | ||
549 | #endif | ||
540 | void AbTable::setChoiceSelection( const QValueList<int>& list ) | 550 | void AbTable::setChoiceSelection( const QValueList<int>& list ) |
541 | { | 551 | { |
542 | intFields = list; | 552 | intFields = list; |
543 | } | 553 | } |
544 | 554 | ||
545 | QStringList AbTable::choiceSelection(int /*index*/) const | 555 | QStringList AbTable::choiceSelection(int /*index*/) const |
546 | { | 556 | { |
547 | QStringList r; | 557 | QStringList r; |
548 | /* ###### | 558 | /* ###### |
549 | 559 | ||
550 | QString selname = choicenames.at(index); | 560 | QString selname = choicenames.at(index); |
551 | for (each row) { | 561 | for (each row) { |
552 | OContact *c = contactForRow(row); | 562 | OContact *c = contactForRow(row); |
553 | if ( text(row,2) == selname ) { | 563 | if ( text(row,2) == selname ) { |
554 | r.append(c->email); | 564 | r.append(c->email); |
555 | } | 565 | } |
556 | } | 566 | } |
557 | 567 | ||
558 | */ | 568 | */ |
559 | return r; | 569 | return r; |
560 | } | 570 | } |
561 | 571 | ||
562 | 572 | ||
563 | |||
564 | |||
565 | void AbTable::updateVisible() | 573 | void AbTable::updateVisible() |
566 | { | 574 | { |
567 | //qWarning("void AbTable::updateVisible()"); | 575 | //qWarning("void AbTable::updateVisible()"); |
568 | 576 | ||
569 | int visible, | 577 | int visible, |
570 | totalRows, | 578 | totalRows, |
571 | row, | 579 | row, |
572 | selectedRow = 0; | 580 | selectedRow = 0; |
573 | 581 | ||
574 | visible = 0; | 582 | visible = 0; |
575 | 583 | ||
576 | setPaintingEnabled( FALSE ); | 584 | setPaintingEnabled( FALSE ); |
577 | 585 | ||
578 | realignTable(); | 586 | realignTable(); |
579 | 587 | ||
580 | totalRows = numRows(); | 588 | totalRows = numRows(); |
581 | for ( row = 0; row < totalRows; row++ ) { | 589 | for ( row = 0; row < totalRows; row++ ) { |
582 | if ( rowHeight(row) == 0 ) { | 590 | if ( rowHeight(row) == 0 ) { |
583 | showRow( row ); | 591 | showRow( row ); |
584 | adjustRow( row ); | 592 | adjustRow( row ); |
585 | if ( isSelected( row,0 ) || isSelected( row,1 ) ) | 593 | if ( isSelected( row,0 ) || isSelected( row,1 ) ) |
586 | selectedRow = row; | 594 | selectedRow = row; |
587 | } | 595 | } |
588 | visible++; | 596 | visible++; |
@@ -609,76 +617,95 @@ void AbTable::setPaintingEnabled( bool e ) | |||
609 | setUpdatesEnabled( true ); | 617 | setUpdatesEnabled( true ); |
610 | enablePainting = true; | 618 | enablePainting = true; |
611 | rowHeightChanged( 0 ); | 619 | rowHeightChanged( 0 ); |
612 | viewport()->update(); | 620 | viewport()->update(); |
613 | } | 621 | } |
614 | } else { | 622 | } else { |
615 | ++countNested; | 623 | ++countNested; |
616 | enablePainting = false; | 624 | enablePainting = false; |
617 | setUpdatesEnabled( false ); | 625 | setUpdatesEnabled( false ); |
618 | } | 626 | } |
619 | //qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); | 627 | //qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); |
620 | } | 628 | } |
621 | 629 | ||
622 | void AbTable::viewportPaintEvent( QPaintEvent* e ) { | 630 | void AbTable::viewportPaintEvent( QPaintEvent* e ) { |
623 | //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); | 631 | //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); |
624 | if ( enablePainting ) | 632 | if ( enablePainting ) |
625 | QTable::viewportPaintEvent( e ); | 633 | QTable::viewportPaintEvent( e ); |
626 | } | 634 | } |
627 | 635 | ||
628 | void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { | 636 | void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { |
629 | const QColorGroup &cg = colorGroup(); | 637 | const QColorGroup &cg = colorGroup(); |
630 | 638 | ||
631 | p->save(); | 639 | p->save(); |
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 |
634 | if ( (row % 2 ) == 0 ) { | 646 | if ( (row % 2 ) == 0 ) { |
635 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 647 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
636 | p->setPen( QPen( cg.text() ) ); | 648 | p->setPen( QPen( cg.text() ) ); |
637 | } | 649 | } |
638 | else { | 650 | else { |
639 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); | 651 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); |
640 | p->setPen( QPen( cg.buttonText() ) ); | 652 | p->setPen( QPen( cg.buttonText() ) ); |
641 | } | 653 | } |
642 | 654 | ||
643 | QFont f = p->font(); | 655 | QFont f = p->font(); |
644 | QFontMetrics fm(f); | 656 | QFontMetrics fm(f); |
645 | 657 | ||
646 | int marg = 2; | 658 | int marg = 2; |
647 | int x = 0; | 659 | int x = 0; |
648 | int y = ( cr.height() - 14 ) / 2; | 660 | int y = ( cr.height() - 14 ) / 2; |
649 | 661 | ||
650 | QPixmap pic = pixmap( row, col ); | 662 | QString nameText = act_contact.fileAs(); |
651 | if ( !pic.isNull() ) | 663 | |
652 | { | 664 | switch( col ){ |
653 | p->drawPixmap( x + marg, y, pixmap( row, col ) ); | 665 | case 0: |
654 | p->drawText( x + marg + pixmap( row, col ).width() + 4,2 + fm.ascent(), text( row, col ) ); | 666 | p->drawText( x + marg,2 + fm.ascent(), nameText ); |
655 | } | 667 | break; |
656 | else | 668 | case 1:{ |
657 | { | 669 | |
658 | p->drawText( x + marg,2 + fm.ascent(), text( row, col ) ); | 670 | ContactItem contactItem = findContactContact( act_contact, 0 ); |
659 | } | 671 | QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */ |
672 | QString contactText = contactItem.value; | ||
673 | |||
674 | if ( !contactPic.isNull() ) | ||
675 | { | ||
676 | p->drawPixmap( x + marg, y, contactPic ); | ||
677 | p->drawText( x + marg + contactPic.width() | ||
678 | + 4,2 + fm.ascent(), contactText ); | ||
679 | } | ||
680 | else | ||
681 | { | ||
682 | p->drawText( x + marg,2 + fm.ascent(), contactText ); | ||
683 | } | ||
684 | } | ||
685 | break; | ||
660 | 686 | ||
687 | } | ||
661 | p->restore(); | 688 | p->restore(); |
662 | } | 689 | } |
663 | 690 | ||
664 | void AbTable::rowHeightChanged( int row ) | 691 | void AbTable::rowHeightChanged( int row ) |
665 | { | 692 | { |
666 | if ( enablePainting ) | 693 | if ( enablePainting ) |
667 | QTable::rowHeightChanged( row ); | 694 | QTable::rowHeightChanged( row ); |
668 | } | 695 | } |
669 | ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ ) | 696 | ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ ) |
670 | { | 697 | { |
671 | 698 | ||
672 | ContactItem item; | 699 | ContactItem item; |
673 | 700 | ||
674 | item.value = ""; | 701 | item.value = ""; |
675 | 702 | ||
676 | for ( QValueList<int>::ConstIterator it = intFields.begin(); | 703 | for ( QValueList<int>::ConstIterator it = intFields.begin(); |
677 | it != intFields.end(); ++it ) { | 704 | it != intFields.end(); ++it ) { |
678 | switch ( *it ) { | 705 | switch ( *it ) { |
679 | default: | 706 | default: |
680 | break; | 707 | break; |
681 | case Qtopia::Title: | 708 | case Qtopia::Title: |
682 | item.value = entry.title(); | 709 | item.value = entry.title(); |
683 | break; | 710 | break; |
684 | case Qtopia::Suffix: | 711 | case Qtopia::Suffix: |
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 | |||
@@ -11,142 +11,148 @@ | |||
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
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 | #if 0 | ||
35 | class AbTableItem : public QTableItem | 36 | class AbTableItem : public QTableItem |
36 | { | 37 | { |
37 | public: | 38 | public: |
38 | AbTableItem( QTable *t, EditType et, const QString &s, | 39 | AbTableItem( QTable *t, EditType et, const QString &s, |
39 | const QString &secondSortKey); | 40 | const QString &secondSortKey); |
40 | QString entryKey() const; | 41 | QString entryKey() const; |
41 | void setEntryKey( const QString & k ); | 42 | void setEntryKey( const QString & k ); |
42 | virtual int alignment() const; | 43 | virtual int alignment() const; |
43 | virtual QString key() const; | 44 | virtual QString key() const; |
44 | void setItem( const QString &txt, const QString &secondKey ); | 45 | void setItem( const QString &txt, const QString &secondKey ); |
45 | 46 | ||
46 | private: | 47 | private: |
47 | QString sortKey; | 48 | QString sortKey; |
48 | }; | 49 | }; |
49 | 50 | ||
51 | #endif | ||
52 | |||
50 | // This is a simple container, storing all contact | 53 | // This is a simple container, storing all contact |
51 | // information | 54 | // information |
52 | class ContactItem | 55 | class ContactItem |
53 | { | 56 | { |
54 | public: | 57 | public: |
55 | QPixmap icon; | 58 | QPixmap icon; |
56 | QString value; | 59 | QString value; |
57 | }; | 60 | }; |
58 | 61 | ||
62 | #if 0 | ||
59 | class AbPickItem : public QTableItem | 63 | class AbPickItem : public QTableItem |
60 | { | 64 | { |
61 | public: | 65 | public: |
62 | AbPickItem( QTable *t ); | 66 | AbPickItem( QTable *t ); |
63 | 67 | ||
64 | QWidget *createEditor() const; | 68 | QWidget *createEditor() const; |
65 | void setContentFromEditor( QWidget *w ); | 69 | void setContentFromEditor( QWidget *w ); |
66 | 70 | ||
67 | private: | 71 | private: |
68 | QGuardedPtr<QComboBox> cb; | 72 | QGuardedPtr<QComboBox> cb; |
69 | }; | 73 | }; |
70 | 74 | ||
75 | #endif | ||
76 | |||
71 | class AbTable : public QTable | 77 | class AbTable : public QTable |
72 | { | 78 | { |
73 | Q_OBJECT | 79 | Q_OBJECT |
74 | 80 | ||
75 | public: | 81 | public: |
76 | AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 ); | 82 | AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 ); |
77 | ~AbTable(); | 83 | ~AbTable(); |
78 | 84 | ||
79 | // Set the contacts shown in the table | 85 | // Set the contacts shown in the table |
80 | void setContacts( const OContactAccess::List& viewList ); | 86 | void setContacts( const OContactAccess::List& viewList ); |
81 | 87 | ||
82 | // Set the list for primary contacts | 88 | // Set the list for primary contacts |
83 | void setOrderedList( const QValueList<int> ordered ); | 89 | void setOrderedList( const QValueList<int> ordered ); |
84 | 90 | ||
85 | // Selects a contact of a specific UID | 91 | // Selects a contact of a specific UID |
86 | bool selectContact( int UID ); | 92 | bool selectContact( int UID ); |
87 | 93 | ||
88 | // Get the current selected entry | 94 | // Get the current selected entry |
89 | OContact currentEntry(); | 95 | OContact currentEntry(); |
90 | 96 | ||
91 | // Get the UID of the current selected Entry | 97 | // Get the UID of the current selected Entry |
92 | int currentEntry_UID(); | 98 | int currentEntry_UID(); |
93 | 99 | ||
94 | QString findContactName( const OContact &entry ); | 100 | // QString findContactName( const OContact &entry ); |
95 | 101 | ||
96 | void init(); | 102 | void init(); |
97 | void clear(); | 103 | void clear(); |
98 | void refresh(); | 104 | void refresh(); |
99 | 105 | ||
100 | void show(); | 106 | void show(); |
101 | void setPaintingEnabled( bool e ); | 107 | void setPaintingEnabled( bool e ); |
102 | void viewportPaintEvent( QPaintEvent* e); | 108 | void viewportPaintEvent( QPaintEvent* e); |
103 | void paintCell(QPainter* p, int row, int col, const QRect&, bool ); | 109 | void paintCell(QPainter* p, int row, int col, const QRect&, bool ); |
104 | 110 | ||
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 ); |
109 | QStringList choiceSelection(int index) const; | 115 | QStringList choiceSelection(int index) const; |
110 | 116 | ||
111 | signals: | 117 | signals: |
112 | void signalSwitch(); | 118 | void signalSwitch(); |
113 | void signalEditor(); | 119 | void signalEditor(); |
114 | void signalKeyDown(); | 120 | void signalKeyDown(); |
115 | void signalKeyUp(); | 121 | void signalKeyUp(); |
116 | 122 | ||
117 | protected: | 123 | protected: |
118 | virtual void keyPressEvent( QKeyEvent *e ); | 124 | virtual void keyPressEvent( QKeyEvent *e ); |
119 | 125 | ||
120 | // int rowHeight( int ) const; | 126 | // int rowHeight( int ) const; |
121 | // int rowPos( int row ) const; | 127 | // int rowPos( int row ) const; |
122 | // virtual int rowAt( int pos ) const; | 128 | // virtual int rowAt( int pos ) const; |
123 | 129 | ||
124 | 130 | ||
125 | protected slots: | 131 | protected slots: |
126 | void moveTo( char ); | 132 | void moveTo( char ); |
127 | virtual void columnClicked( int col ); | 133 | virtual void columnClicked( int col ); |
128 | void itemClicked(int,int col); | 134 | void itemClicked(int,int col); |
129 | void rowHeightChanged( int row ); | 135 | void rowHeightChanged( int row ); |
130 | 136 | ||
131 | private: | 137 | private: |
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 ); |
134 | void fitColumns(); | 140 | void fitColumns(); |
135 | void resizeRows(); | 141 | void resizeRows(); |
136 | void realignTable(); | 142 | void realignTable(); |
137 | void resort(); | 143 | void resort(); |
138 | void updateVisible(); | 144 | void updateVisible(); |
139 | 145 | ||
140 | int lastSortCol; | 146 | int lastSortCol; |
141 | bool asc; | 147 | bool asc; |
142 | QMap<AbTableItem*, OContact> contactList; | 148 | // QMap<AbTableItem*, OContact> contactList; |
143 | QValueList<int> intFields; | 149 | QValueList<int> intFields; |
144 | QStringList choicenames; | 150 | QStringList choicenames; |
145 | bool enablePainting; | 151 | bool enablePainting; |
146 | bool columnVisible; | 152 | bool columnVisible; |
147 | int countNested; | 153 | int countNested; |
148 | 154 | ||
149 | OContactAccess::List m_viewList; | 155 | OContactAccess::List m_viewList; |
150 | 156 | ||
151 | }; | 157 | }; |
152 | #endif // ABTABLE_H | 158 | #endif // ABTABLE_H |
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 | |||
@@ -30,272 +30,274 @@ extern QString categoryFileName(); | |||
30 | 30 | ||
31 | QString addressbookPersonalVCardName() | 31 | QString addressbookPersonalVCardName() |
32 | { | 32 | { |
33 | QString filename = Global::applicationFileName("addressbook", | 33 | QString filename = Global::applicationFileName("addressbook", |
34 | "businesscard.vcf"); | 34 | "businesscard.vcf"); |
35 | return filename; | 35 | return filename; |
36 | } | 36 | } |
37 | 37 | ||
38 | 38 | ||
39 | AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): | 39 | AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): |
40 | QWidget(parent), | 40 | QWidget(parent), |
41 | mCat(0), | 41 | mCat(0), |
42 | m_inSearch( false ), | 42 | m_inSearch( false ), |
43 | m_inPersonal( false ), | 43 | m_inPersonal( false ), |
44 | m_curr_category( -1 ), | 44 | m_curr_category( -1 ), |
45 | m_curr_View( TableView ), | 45 | m_curr_View( TableView ), |
46 | m_prev_View( TableView ), | 46 | m_prev_View( TableView ), |
47 | m_curr_Contact ( 0 ), | 47 | m_curr_Contact ( 0 ), |
48 | m_contactdb ( 0l ), | 48 | m_contactdb ( 0l ), |
49 | m_storedDB ( 0l ), | 49 | m_storedDB ( 0l ), |
50 | m_viewStack( 0l ), | 50 | m_viewStack( 0l ), |
51 | m_abTable( 0l ), | 51 | m_abTable( 0l ), |
52 | m_orderedFields( ordered ) | 52 | m_orderedFields( ordered ) |
53 | { | 53 | { |
54 | qWarning("AbView::c'tor"); | ||
54 | // Load default database and handle syncing myself.. ! | 55 | // Load default database and handle syncing myself.. ! |
55 | m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ), | 56 | m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ), |
56 | mCat.load( categoryFileName() ); | 57 | mCat.load( categoryFileName() ); |
57 | 58 | ||
58 | // Create Layout and put WidgetStack into it. | 59 | // Create Layout and put WidgetStack into it. |
59 | QVBoxLayout *vb = new QVBoxLayout( this ); | 60 | QVBoxLayout *vb = new QVBoxLayout( this ); |
60 | m_viewStack = new QWidgetStack( this ); | 61 | m_viewStack = new QWidgetStack( this ); |
61 | vb->addWidget( m_viewStack ); | 62 | vb->addWidget( m_viewStack ); |
62 | 63 | ||
63 | // Creat TableView | 64 | // Creat TableView |
64 | QVBox* tableBox = new QVBox( m_viewStack ); | 65 | QVBox* tableBox = new QVBox( m_viewStack ); |
65 | m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); | 66 | m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); |
66 | m_abTable->setCurrentCell( 0, 0 ); | 67 | m_abTable->setCurrentCell( 0, 0 ); |
67 | m_abTable->setFocus(); | 68 | m_abTable->setFocus(); |
68 | 69 | ||
69 | // Add TableView to WidgetStack and raise it | 70 | // Add TableView to WidgetStack and raise it |
70 | m_viewStack -> addWidget( tableBox , TableView ); | 71 | m_viewStack -> addWidget( tableBox , TableView ); |
71 | 72 | ||
72 | // Create CardView and add it to WidgetStack | 73 | // Create CardView and add it to WidgetStack |
73 | QVBox* cardBox = new QVBox( m_viewStack ); | 74 | QVBox* cardBox = new QVBox( m_viewStack ); |
74 | m_ablabel = new AbLabel( cardBox, "CardView"); | 75 | m_ablabel = new AbLabel( cardBox, "CardView"); |
75 | m_viewStack -> addWidget( cardBox , CardView ); | 76 | m_viewStack -> addWidget( cardBox , CardView ); |
76 | 77 | ||
77 | // Connect views to me | 78 | // Connect views to me |
78 | connect ( m_abTable, SIGNAL( signalSwitch( void ) ), | 79 | connect ( m_abTable, SIGNAL( signalSwitch( void ) ), |
79 | this, SLOT( slotSwitch( void ) ) ); | 80 | this, SLOT( slotSwitch( void ) ) ); |
80 | connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ), | 81 | connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ), |
81 | this, SLOT( slotSwitch( void ) ) ); | 82 | this, SLOT( slotSwitch( void ) ) ); |
82 | 83 | ||
83 | load(); | 84 | load(); |
84 | } | 85 | } |
85 | 86 | ||
86 | AbView::~AbView() | 87 | AbView::~AbView() |
87 | { | 88 | { |
88 | m_contactdb -> save(); | 89 | m_contactdb -> save(); |
89 | delete m_contactdb; | 90 | delete m_contactdb; |
90 | 91 | ||
91 | if ( m_storedDB ){ | 92 | if ( m_storedDB ){ |
92 | m_storedDB -> save(); | 93 | m_storedDB -> save(); |
93 | delete m_storedDB; | 94 | delete m_storedDB; |
94 | } | 95 | } |
95 | } | 96 | } |
96 | 97 | ||
97 | 98 | ||
98 | void AbView::setView( Views view ) | 99 | 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; |
102 | load(); | 103 | load(); |
103 | } | 104 | } |
104 | 105 | ||
105 | void AbView::addEntry( const OContact &newContact ) | 106 | 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 ); |
109 | load(); | 110 | load(); |
110 | 111 | ||
111 | } | 112 | } |
112 | void AbView::removeEntry( const int UID ) | 113 | 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 ); |
116 | load(); | 117 | load(); |
117 | } | 118 | } |
118 | 119 | ||
119 | void AbView::replaceEntry( const OContact &contact ) | 120 | 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 ); |
123 | load(); | 124 | load(); |
124 | 125 | ||
125 | } | 126 | } |
126 | 127 | ||
127 | OContact AbView::currentEntry() | 128 | OContact AbView::currentEntry() |
128 | { | 129 | { |
129 | OContact currentContact; | 130 | OContact currentContact; |
130 | 131 | ||
131 | switch ( (int) m_curr_View ) { | 132 | switch ( (int) m_curr_View ) { |
132 | case TableView: | 133 | case TableView: |
133 | currentContact = m_abTable -> currentEntry(); | 134 | currentContact = m_abTable -> currentEntry(); |
134 | break; | 135 | break; |
135 | case CardView: | 136 | case CardView: |
136 | currentContact = m_ablabel -> currentEntry(); | 137 | currentContact = m_ablabel -> currentEntry(); |
137 | break; | 138 | break; |
138 | } | 139 | } |
139 | m_curr_Contact = currentContact.uid(); | 140 | m_curr_Contact = currentContact.uid(); |
140 | return currentContact; | 141 | return currentContact; |
141 | } | 142 | } |
142 | 143 | ||
143 | bool AbView::save() | 144 | bool AbView::save() |
144 | { | 145 | { |
145 | //qWarning("abView:Save data"); | 146 | //qWarning("abView:Save data"); |
146 | 147 | ||
147 | return m_contactdb->save(); | 148 | return m_contactdb->save(); |
148 | } | 149 | } |
149 | 150 | ||
150 | void AbView::load() | 151 | void AbView::load() |
151 | { | 152 | { |
152 | //qWarning("abView:Load data"); | 153 | qWarning("abView:Load data"); |
153 | 154 | ||
154 | // Letter Search is stopped at this place | 155 | // Letter Search is stopped at this place |
155 | emit signalClearLetterPicker(); | 156 | emit signalClearLetterPicker(); |
156 | 157 | ||
157 | if ( m_inPersonal ) | 158 | if ( m_inPersonal ) |
158 | // VCard Backend does not sort.. | 159 | // VCard Backend does not sort.. |
159 | m_list = m_contactdb->allRecords(); | 160 | m_list = m_contactdb->allRecords(); |
160 | else{ | 161 | else{ |
161 | m_list = m_contactdb->sorted( true, 0, 0, 0 ); | 162 | m_list = m_contactdb->sorted( true, 0, 0, 0 ); |
162 | clearForCategory(); | 163 | if ( m_curr_category != -1 ) |
164 | clearForCategory(); | ||
163 | } | 165 | } |
164 | 166 | ||
165 | qWarning ("Number of contacts: %d", m_list.count()); | 167 | qWarning ("Number of contacts: %d", m_list.count()); |
166 | 168 | ||
167 | updateView( true ); | 169 | updateView( true ); |
168 | 170 | ||
169 | } | 171 | } |
170 | 172 | ||
171 | void AbView::reload() | 173 | void AbView::reload() |
172 | { | 174 | { |
173 | //qWarning( "void AbView::reload()" ); | 175 | qWarning( "void AbView::reload()" ); |
174 | 176 | ||
175 | m_contactdb->reload(); | 177 | m_contactdb->reload(); |
176 | load(); | 178 | load(); |
177 | } | 179 | } |
178 | 180 | ||
179 | void AbView::clear() | 181 | void AbView::clear() |
180 | { | 182 | { |
181 | // :SX | 183 | // :SX |
182 | } | 184 | } |
183 | 185 | ||
184 | void AbView::setShowByCategory( const QString& cat ) | 186 | void AbView::setShowByCategory( const QString& cat ) |
185 | { | 187 | { |
186 | //qWarning("AbView::setShowCategory( const QString& cat )"); | 188 | qWarning("AbView::setShowCategory( const QString& cat )"); |
187 | 189 | ||
188 | int intCat = 0; | 190 | int intCat = 0; |
189 | 191 | ||
190 | // All (cat == NULL) will be stored as -1 | 192 | // All (cat == NULL) will be stored as -1 |
191 | if ( cat.isNull() ) | 193 | if ( cat.isNull() ) |
192 | intCat = -1; | 194 | intCat = -1; |
193 | else | 195 | else |
194 | intCat = mCat.id("Contacts", cat ); | 196 | intCat = mCat.id("Contacts", cat ); |
195 | 197 | ||
196 | // Just do anything if we really change the category | 198 | // Just do anything if we really change the category |
197 | if ( intCat != m_curr_category ){ | 199 | if ( intCat != m_curr_category ){ |
198 | // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); | 200 | // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); |
199 | 201 | ||
200 | m_curr_category = intCat; | 202 | m_curr_category = intCat; |
201 | emit signalClearLetterPicker(); | 203 | emit signalClearLetterPicker(); |
202 | 204 | ||
203 | load(); | 205 | load(); |
204 | } | 206 | } |
205 | 207 | ||
206 | } | 208 | } |
207 | 209 | ||
208 | void AbView::setShowToView( Views view ) | 210 | 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; |
216 | m_curr_View = view; | 217 | m_curr_View = view; |
217 | 218 | ||
218 | updateView(); | 219 | updateView(); |
219 | } | 220 | } |
220 | 221 | ||
221 | } | 222 | } |
222 | 223 | ||
223 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) | 224 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) |
224 | { | 225 | { |
225 | qWarning("void AbView::setShowByLetter( %c, %d )", c, mode ); | 226 | qWarning("void AbView::setShowByLetter( %c, %d )", c, mode ); |
226 | 227 | ||
227 | assert( mode < AbConfig::LASTELEMENT ); | 228 | assert( mode < AbConfig::LASTELEMENT ); |
228 | 229 | ||
229 | OContact query; | 230 | OContact query; |
230 | if ( c == 0 ){ | 231 | if ( c == 0 ){ |
231 | load(); | 232 | load(); |
232 | return; | 233 | return; |
233 | }else{ | 234 | }else{ |
234 | // If the current Backend is unable to solve the query, we will | 235 | // If the current Backend is unable to solve the query, we will |
235 | // ignore the request .. | 236 | // ignore the request .. |
236 | if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ | 237 | if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ |
237 | return; | 238 | return; |
238 | } | 239 | } |
239 | 240 | ||
240 | switch( mode ){ | 241 | switch( mode ){ |
241 | case AbConfig::LastName: | 242 | case AbConfig::LastName: |
242 | query.setLastName( QString("%1*").arg(c) ); | 243 | query.setLastName( QString("%1*").arg(c) ); |
243 | break; | 244 | break; |
244 | case AbConfig::FileAs: | 245 | case AbConfig::FileAs: |
245 | query.setFileAs( QString("%1*").arg(c) ); | 246 | query.setFileAs( QString("%1*").arg(c) ); |
246 | break; | 247 | break; |
247 | default: | 248 | default: |
248 | qWarning( "Unknown Searchmode for AbView::setShowByLetter ! -> %d", mode ); | 249 | qWarning( "Unknown Searchmode for AbView::setShowByLetter ! -> %d", mode ); |
249 | qWarning( "I will ignore it.." ); | 250 | qWarning( "I will ignore it.." ); |
250 | return; | 251 | return; |
251 | } | 252 | } |
252 | m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); | 253 | m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); |
253 | clearForCategory(); | 254 | if ( m_curr_category != -1 ) |
255 | clearForCategory(); | ||
254 | m_curr_Contact = 0; | 256 | m_curr_Contact = 0; |
255 | } | 257 | } |
256 | updateView( true ); | 258 | updateView( true ); |
257 | } | 259 | } |
258 | 260 | ||
259 | void AbView::setListOrder( const QValueList<int>& ordered ) | 261 | void AbView::setListOrder( const QValueList<int>& ordered ) |
260 | { | 262 | { |
261 | m_orderedFields = ordered; | 263 | m_orderedFields = ordered; |
262 | if ( m_abTable ){ | 264 | if ( m_abTable ){ |
263 | m_abTable->setOrderedList( ordered ); | 265 | m_abTable->setOrderedList( ordered ); |
264 | m_abTable->refresh(); | 266 | m_abTable->refresh(); |
265 | } | 267 | } |
266 | updateView(); | 268 | updateView(); |
267 | } | 269 | } |
268 | 270 | ||
269 | 271 | ||
270 | QString AbView::showCategory() const | 272 | QString AbView::showCategory() const |
271 | { | 273 | { |
272 | return mCat.label( "Contacts", m_curr_category ); | 274 | return mCat.label( "Contacts", m_curr_category ); |
273 | } | 275 | } |
274 | 276 | ||
275 | void AbView::showPersonal( bool personal ) | 277 | void AbView::showPersonal( bool personal ) |
276 | { | 278 | { |
277 | //qWarning ("void AbView::showPersonal( %d )", personal); | 279 | qWarning ("void AbView::showPersonal( %d )", personal); |
278 | 280 | ||
279 | if ( personal ){ | 281 | if ( personal ){ |
280 | 282 | ||
281 | if ( m_inPersonal ) | 283 | if ( m_inPersonal ) |
282 | return; | 284 | return; |
283 | 285 | ||
284 | // Now switch to vCard Backend and load data. | 286 | // Now switch to vCard Backend and load data. |
285 | // The current default backend will be stored | 287 | // The current default backend will be stored |
286 | // to avoid unneeded load/stores. | 288 | // to avoid unneeded load/stores. |
287 | m_storedDB = m_contactdb; | 289 | m_storedDB = m_contactdb; |
288 | 290 | ||
289 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 291 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
290 | addressbookPersonalVCardName() ); | 292 | addressbookPersonalVCardName() ); |
291 | m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 293 | m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
292 | 294 | ||
293 | m_inPersonal = true; | 295 | m_inPersonal = true; |
294 | m_curr_View = CardView; | 296 | m_curr_View = CardView; |
295 | 297 | ||
296 | }else{ | 298 | }else{ |
297 | 299 | ||
298 | if ( !m_inPersonal ) | 300 | if ( !m_inPersonal ) |
299 | return; | 301 | return; |
300 | 302 | ||
301 | // Remove vCard Backend and restore default | 303 | // Remove vCard Backend and restore default |
@@ -341,49 +343,50 @@ void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, | |||
341 | if ( cat.isEmpty() ) | 343 | if ( cat.isEmpty() ) |
342 | category = m_curr_category; | 344 | category = m_curr_category; |
343 | else{ | 345 | else{ |
344 | category = mCat.id("Contacts", cat ); | 346 | category = mCat.id("Contacts", cat ); |
345 | } | 347 | } |
346 | 348 | ||
347 | //qWarning ("Find in Category %d", category); | 349 | //qWarning ("Find in Category %d", category); |
348 | 350 | ||
349 | QRegExp r( str ); | 351 | QRegExp r( str ); |
350 | r.setCaseSensitive( caseSensitive ); | 352 | r.setCaseSensitive( caseSensitive ); |
351 | r.setWildcard( !useRegExp ); | 353 | r.setWildcard( !useRegExp ); |
352 | 354 | ||
353 | // Get all matching entries out of the database | 355 | // Get all matching entries out of the database |
354 | m_list = m_contactdb->matchRegexp( r ); | 356 | m_list = m_contactdb->matchRegexp( r ); |
355 | 357 | ||
356 | //qWarning( "found: %d", m_list.count() ); | 358 | //qWarning( "found: %d", m_list.count() ); |
357 | if ( m_list.count() == 0 ){ | 359 | if ( m_list.count() == 0 ){ |
358 | emit signalNotFound(); | 360 | emit signalNotFound(); |
359 | return; | 361 | return; |
360 | } | 362 | } |
361 | 363 | ||
362 | // Now remove all contacts with wrong category (if any selected) | 364 | // Now remove all contacts with wrong category (if any selected) |
363 | // This algorithm is a litte bit ineffective, but | 365 | // This algorithm is a litte bit ineffective, but |
364 | // we will not have a lot of matching entries.. | 366 | // we will not have a lot of matching entries.. |
365 | clearForCategory(); | 367 | if ( m_curr_category != -1 ) |
368 | clearForCategory(); | ||
366 | 369 | ||
367 | // Now show all found entries | 370 | // Now show all found entries |
368 | updateView( true ); | 371 | updateView( true ); |
369 | } | 372 | } |
370 | 373 | ||
371 | void AbView::offSearch() | 374 | void AbView::offSearch() |
372 | { | 375 | { |
373 | m_inSearch = false; | 376 | m_inSearch = false; |
374 | 377 | ||
375 | load(); | 378 | load(); |
376 | } | 379 | } |
377 | 380 | ||
378 | void AbView::slotSwitch(){ | 381 | void AbView::slotSwitch(){ |
379 | //qWarning("AbView::slotSwitch()"); | 382 | //qWarning("AbView::slotSwitch()"); |
380 | 383 | ||
381 | m_prev_View = m_curr_View; | 384 | m_prev_View = m_curr_View; |
382 | switch ( (int) m_curr_View ){ | 385 | switch ( (int) m_curr_View ){ |
383 | case TableView: | 386 | case TableView: |
384 | qWarning("Switching to CardView"); | 387 | qWarning("Switching to CardView"); |
385 | m_curr_View = CardView; | 388 | m_curr_View = CardView; |
386 | break; | 389 | break; |
387 | case CardView: | 390 | case CardView: |
388 | qWarning("Switching to TableView"); | 391 | qWarning("Switching to TableView"); |
389 | m_curr_View = TableView; | 392 | m_curr_View = TableView; |
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 | |||
@@ -227,49 +227,49 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
227 | // Remove this function for public Release ! This is only | 227 | // Remove this function for public Release ! This is only |
228 | // for debug purposes .. | 228 | // for debug purposes .. |
229 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); | 229 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); |
230 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); | 230 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); |
231 | a->addTo( edit ); | 231 | a->addTo( edit ); |
232 | #endif | 232 | #endif |
233 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, | 233 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, |
234 | 0, this, 0 ); | 234 | 0, this, 0 ); |
235 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); | 235 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); |
236 | a->addTo( edit ); | 236 | a->addTo( edit ); |
237 | 237 | ||
238 | // Create Views | 238 | // Create Views |
239 | listContainer = new QWidget( this ); | 239 | listContainer = new QWidget( this ); |
240 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | 240 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); |
241 | 241 | ||
242 | m_abView = new AbView( listContainer, m_config.orderList() ); | 242 | m_abView = new AbView( listContainer, m_config.orderList() ); |
243 | vb->addWidget( m_abView ); | 243 | vb->addWidget( m_abView ); |
244 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 244 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
245 | connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), | 245 | connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), |
246 | this, SLOT( slotViewSwitched( int ) ) ); | 246 | this, SLOT( slotViewSwitched( int ) ) ); |
247 | 247 | ||
248 | 248 | ||
249 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); | 249 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); |
250 | 250 | ||
251 | m_abView->load(); | 251 | // m_abView->load(); // Already done by c'tor . |
252 | 252 | ||
253 | // Letter Picker | 253 | // Letter Picker |
254 | pLabel = new LetterPicker( listContainer ); | 254 | pLabel = new LetterPicker( listContainer ); |
255 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 255 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
256 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); | 256 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); |
257 | 257 | ||
258 | vb->addWidget( pLabel ); | 258 | vb->addWidget( pLabel ); |
259 | 259 | ||
260 | // All Categories into view-menu.. | 260 | // All Categories into view-menu.. |
261 | populateCategories(); | 261 | populateCategories(); |
262 | 262 | ||
263 | // Fontsize | 263 | // Fontsize |
264 | defaultFont = new QFont( m_abView->font() ); | 264 | defaultFont = new QFont( m_abView->font() ); |
265 | slotSetFont(m_config.fontSize()); | 265 | slotSetFont(m_config.fontSize()); |
266 | m_curFontSize = m_config.fontSize(); | 266 | m_curFontSize = m_config.fontSize(); |
267 | 267 | ||
268 | setCentralWidget(listContainer); | 268 | setCentralWidget(listContainer); |
269 | 269 | ||
270 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 270 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
271 | 271 | ||
272 | 272 | ||
273 | isLoading = false; | 273 | isLoading = false; |
274 | } | 274 | } |
275 | 275 | ||
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 | |||
@@ -1,10 +1,10 @@ | |||
1 | #ifndef _VERSION_H_ | 1 | #ifndef _VERSION_H_ |
2 | #define _VERSION_H_ | 2 | #define _VERSION_H_ |
3 | 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" |
7 | 7 | ||
8 | #define APPNAME "OPIE_ADDRESSBOOK" | 8 | #define APPNAME "OPIE_ADDRESSBOOK" |
9 | 9 | ||
10 | #endif | 10 | #endif |