Diffstat (limited to 'kaddressbook/views/kaddressbooktableview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 89053c2..61703ee 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -118,195 +118,191 @@ void KAddressBookTableView::reconstructListView() | |||
118 | } else { | 118 | } else { |
119 | // qDebug("KAddressBookTableView::reconstructListView double"); | 119 | // qDebug("KAddressBookTableView::reconstructListView double"); |
120 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 120 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
121 | this, SLOT(addresseeExecuted(QListViewItem*))); | 121 | this, SLOT(addresseeExecuted(QListViewItem*))); |
122 | } | 122 | } |
123 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 123 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
124 | this, SLOT(addresseeExecuted(QListViewItem*))); | 124 | this, SLOT(addresseeExecuted(QListViewItem*))); |
125 | connect(mListView, SIGNAL(signalDelete()), | 125 | connect(mListView, SIGNAL(signalDelete()), |
126 | this, SLOT(addresseeDeleted())); | 126 | this, SLOT(addresseeDeleted())); |
127 | 127 | ||
128 | //US performceimprovement. Refresh is done from the outside | 128 | //US performceimprovement. Refresh is done from the outside |
129 | //US refresh(); | 129 | //US refresh(); |
130 | 130 | ||
131 | mListView->setSorting( 0, true ); | 131 | mListView->setSorting( 0, true ); |
132 | mainLayout->addWidget( mListView ); | 132 | mainLayout->addWidget( mListView ); |
133 | mainLayout->activate(); | 133 | mainLayout->activate(); |
134 | mListView->show(); | 134 | mListView->show(); |
135 | } | 135 | } |
136 | 136 | ||
137 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 137 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) |
138 | { | 138 | { |
139 | mListView->clear(); | 139 | mListView->clear(); |
140 | if ( s.isEmpty() || s == "*" ) { | 140 | if ( s.isEmpty() || s == "*" ) { |
141 | refresh(); | 141 | refresh(); |
142 | return; | 142 | return; |
143 | } | 143 | } |
144 | QString pattern = s.lower()+"*"; | 144 | QString pattern = s.lower()+"*"; |
145 | QRegExp re; | 145 | QRegExp re; |
146 | re.setWildcard(true); // most people understand these better. | 146 | re.setWildcard(true); // most people understand these better. |
147 | re.setCaseSensitive(false); | 147 | re.setCaseSensitive(false); |
148 | re.setPattern( pattern ); | 148 | re.setPattern( pattern ); |
149 | if (!re.isValid()) | 149 | if (!re.isValid()) |
150 | return; | 150 | return; |
151 | KABC::Addressee::List addresseeList = addressees(); | 151 | KABC::Addressee::List addresseeList = addressees(); |
152 | KABC::Addressee::List::Iterator it; | 152 | KABC::Addressee::List::Iterator it; |
153 | if ( field ) { | 153 | if ( field ) { |
154 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 154 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
155 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 155 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
156 | continue; | 156 | continue; |
157 | #if QT_VERSION >= 300 | 157 | #if QT_VERSION >= 300 |
158 | if (re.search(field->value( *it ).lower()) != -1) | 158 | if (re.search(field->value( *it ).lower()) != -1) |
159 | #else | 159 | #else |
160 | if (re.match(field->value( *it ).lower()) != -1) | 160 | if (re.match(field->value( *it ).lower()) != -1) |
161 | #endif | 161 | #endif |
162 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 162 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
163 | 163 | ||
164 | } | 164 | } |
165 | } else { | 165 | } else { |
166 | KABC::Field::List fieldList = fields(); | 166 | KABC::Field::List fieldList = allFields(); |
167 | KABC::Field::List::ConstIterator fieldIt; | 167 | KABC::Field::List::ConstIterator fieldIt; |
168 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 168 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
169 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 169 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
170 | continue; | 170 | continue; |
171 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 171 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
172 | #if QT_VERSION >= 300 | 172 | #if QT_VERSION >= 300 |
173 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 173 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
174 | #else | 174 | #else |
175 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 175 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
176 | #endif | 176 | #endif |
177 | { | 177 | { |
178 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 178 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
179 | break; | 179 | break; |
180 | } | 180 | } |
181 | } | 181 | } |
182 | } | 182 | } |
183 | } | 183 | } |
184 | // Sometimes the background pixmap gets messed up when we add lots | 184 | // Sometimes the background pixmap gets messed up when we add lots |
185 | // of items. | 185 | // of items. |
186 | mListView->repaint(); | 186 | mListView->repaint(); |
187 | if ( mListView->firstChild() ) { | 187 | if ( mListView->firstChild() ) { |
188 | mListView->setCurrentItem ( mListView->firstChild() ); | 188 | mListView->setCurrentItem ( mListView->firstChild() ); |
189 | mListView->setSelected ( mListView->firstChild(), true ); | 189 | mListView->setSelected ( mListView->firstChild(), true ); |
190 | } | 190 | } |
191 | else | 191 | else |
192 | emit selected(QString::null); | 192 | emit selected(QString::null); |
193 | 193 | ||
194 | } | 194 | } |
195 | void KAddressBookTableView::writeConfig(KConfig *config) | 195 | void KAddressBookTableView::writeConfig(KConfig *config) |
196 | { | 196 | { |
197 | KAddressBookView::writeConfig(config); | 197 | KAddressBookView::writeConfig(config); |
198 | 198 | ||
199 | mListView->saveLayout(config, config->group()); | 199 | mListView->saveLayout(config, config->group()); |
200 | } | 200 | } |
201 | 201 | ||
202 | void KAddressBookTableView::readConfig(KConfig *config) | 202 | void KAddressBookTableView::readConfig(KConfig *config) |
203 | { | 203 | { |
204 | KAddressBookView::readConfig( config ); | 204 | KAddressBookView::readConfig( config ); |
205 | // The config could have changed the fields, so we need to reconstruct | 205 | // The config could have changed the fields, so we need to reconstruct |
206 | // the listview. | 206 | // the listview. |
207 | reconstructListView(); | 207 | reconstructListView(); |
208 | 208 | ||
209 | // costum colors? | 209 | // costum colors? |
210 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 210 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
211 | { | 211 | { |
212 | QPalette p( mListView->palette() ); | 212 | QPalette p( mListView->palette() ); |
213 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 213 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
214 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 214 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
215 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 215 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
216 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 216 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
217 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 217 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
218 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 218 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
219 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 219 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
220 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 220 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
221 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 221 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
222 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 222 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
223 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 223 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
224 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 224 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
225 | #ifndef KAB_EMBEDDED | 225 | #ifndef KAB_EMBEDDED |
226 | c = KGlobalSettings::alternateBackgroundColor(); | 226 | c = KGlobalSettings::alternateBackgroundColor(); |
227 | #else //KAB_EMBEDDED | 227 | #else //KAB_EMBEDDED |
228 | c = QColor(240, 240, 240); | 228 | c = QColor(240, 240, 240); |
229 | #endif //KAB_EMBEDDED | 229 | #endif //KAB_EMBEDDED |
230 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); | 230 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); |
231 | mListView->setAlternateColor(c); | 231 | mListView->setAlternateColor(c); |
232 | 232 | ||
233 | 233 | ||
234 | //US mListView->viewport()->setPalette( p ); | 234 | //US mListView->viewport()->setPalette( p ); |
235 | mListView->setPalette( p ); | 235 | mListView->setPalette( p ); |
236 | } | 236 | } |
237 | else | 237 | else |
238 | { | 238 | { |
239 | // needed if turned off during a session. | 239 | // needed if turned off during a session. |
240 | //US mListView->viewport()->setPalette( mListView->palette() ); | 240 | //US mListView->viewport()->setPalette( mListView->palette() ); |
241 | mListView->setPalette( mListView->palette() ); | 241 | mListView->setPalette( mListView->palette() ); |
242 | } | 242 | } |
243 | 243 | ||
244 | //custom fonts? | 244 | //custom fonts? |
245 | QFont f( font() ); | 245 | QFont f( font() ); |
246 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 246 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
247 | { | 247 | { |
248 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 248 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
249 | f.setBold( true ); | 249 | f.setBold( true ); |
250 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 250 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
251 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); | 251 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); |
252 | } | 252 | } |
253 | else | 253 | else |
254 | { | 254 | { |
255 | mListView->setFont( f ); | 255 | mListView->setFont( f ); |
256 | f.setBold( true ); | 256 | f.setBold( true ); |
257 | //US mListView->setHeaderFont( f ); | 257 | //US mListView->setHeaderFont( f ); |
258 | mListView->header()->setFont( f ); | 258 | mListView->header()->setFont( f ); |
259 | } | 259 | } |
260 | 260 | ||
261 | |||
262 | |||
263 | |||
264 | |||
265 | // Set the list view options | 261 | // Set the list view options |
266 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 262 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
267 | true)); | 263 | true)); |
268 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 264 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
269 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 265 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
270 | 266 | ||
271 | if (config->readBoolEntry("Background", false)) | 267 | if (config->readBoolEntry("Background", false)) |
272 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 268 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
273 | 269 | ||
274 | // Restore the layout of the listview | 270 | // Restore the layout of the listview |
275 | mListView->restoreLayout(config, config->group()); | 271 | mListView->restoreLayout(config, config->group()); |
276 | } | 272 | } |
277 | 273 | ||
278 | void KAddressBookTableView::refresh(QString uid) | 274 | void KAddressBookTableView::refresh(QString uid) |
279 | { | 275 | { |
280 | // For now just repopulate. In reality this method should | 276 | // For now just repopulate. In reality this method should |
281 | // check the value of uid, and if valid iterate through | 277 | // check the value of uid, and if valid iterate through |
282 | // the listview to find the entry, then tell it to refresh. | 278 | // the listview to find the entry, then tell it to refresh. |
283 | 279 | ||
284 | if (uid.isNull()) { | 280 | if (uid.isNull()) { |
285 | // Clear the list view | 281 | // Clear the list view |
286 | QString currentUID, nextUID; | 282 | QString currentUID, nextUID; |
287 | #ifndef KAB_EMBEDDED | 283 | #ifndef KAB_EMBEDDED |
288 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 284 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
289 | #else //KAB_EMBEDDED | 285 | #else //KAB_EMBEDDED |
290 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 286 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
291 | #endif //KAB_EMBEDDED | 287 | #endif //KAB_EMBEDDED |
292 | 288 | ||
293 | if ( currentItem ) { | 289 | if ( currentItem ) { |
294 | #ifndef KAB_EMBEDDED | 290 | #ifndef KAB_EMBEDDED |
295 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 291 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
296 | #else //KAB_EMBEDDED | 292 | #else //KAB_EMBEDDED |
297 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 293 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
298 | #endif //KAB_EMBEDDED | 294 | #endif //KAB_EMBEDDED |
299 | if ( nextItem ) | 295 | if ( nextItem ) |
300 | nextUID = nextItem->addressee().uid(); | 296 | nextUID = nextItem->addressee().uid(); |
301 | currentUID = currentItem->addressee().uid(); | 297 | currentUID = currentItem->addressee().uid(); |
302 | } | 298 | } |
303 | 299 | ||
304 | mListView->clear(); | 300 | mListView->clear(); |
305 | 301 | ||
306 | currentItem = 0; | 302 | currentItem = 0; |
307 | KABC::Addressee::List addresseeList = addressees(); | 303 | KABC::Addressee::List addresseeList = addressees(); |
308 | KABC::Addressee::List::Iterator it; | 304 | KABC::Addressee::List::Iterator it; |
309 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 305 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
310 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 306 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
311 | continue; | 307 | continue; |
312 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 308 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |