summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index e322473..565cd1d 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -1,474 +1,474 @@
1// $Id$ 1// $Id$
2 2
3#include <qvbox.h> 3#include <qvbox.h>
4#include <qlistbox.h> 4#include <qlistbox.h>
5#include <qwidget.h> 5#include <qwidget.h>
6#include <qfile.h> 6#include <qfile.h>
7#include <qimage.h> 7#include <qimage.h>
8#include <qcombobox.h> 8#include <qcombobox.h>
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qdragobject.h> 10#include <qdragobject.h>
11#include <qevent.h> 11#include <qevent.h>
12#include <qurl.h> 12#include <qurl.h>
13#include <qpixmap.h> 13#include <qpixmap.h>
14 14
15#include <kabc/addressbook.h> 15#include <kabc/addressbook.h>
16#include <kapplication.h> 16#include <kapplication.h>
17#include <kconfig.h> 17#include <kconfig.h>
18#include <kcolorbutton.h> 18#include <kcolorbutton.h>
19#include <kdebug.h> 19#include <kdebug.h>
20#include <kglobal.h> 20#include <kglobal.h>
21#include <kiconloader.h> 21#include <kiconloader.h>
22#include <klineedit.h> 22#include <klineedit.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kmessagebox.h> 24#include <kmessagebox.h>
25#include <kurl.h> 25#include <kurl.h>
26#include <kurlrequester.h> 26#include <kurlrequester.h>
27 27
28//US#include "configuretableviewdialog.h" 28//US#include "configuretableviewdialog.h"
29#include "contactlistview.h" 29#include "contactlistview.h"
30#include "kabprefs.h" 30#include "kabprefs.h"
31#include "undocmds.h" 31#include "undocmds.h"
32#include "viewmanager.h" 32#include "viewmanager.h"
33 33
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qheader.h> 35#include <qheader.h>
36#include <qregexp.h> 36#include <qregexp.h>
37 37
38#include "kaddressbooktableview.h" 38#include "kaddressbooktableview.h"
39 39
40 40
41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, 41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
42 QWidget *parent, const char *name ) 42 QWidget *parent, const char *name )
43 : KAddressBookView( ab, parent, name ) 43 : KAddressBookView( ab, parent, name )
44{ 44{
45 mainLayout = new QVBoxLayout( viewWidget(), 2 ); 45 mainLayout = new QVBoxLayout( viewWidget(), 2 );
46 46
47 // The list view will be created when the config is read. 47 // The list view will be created when the config is read.
48 mListView = 0; 48 mListView = 0;
49} 49}
50 50
51KAddressBookTableView::~KAddressBookTableView() 51KAddressBookTableView::~KAddressBookTableView()
52{ 52{
53} 53}
54void KAddressBookTableView::setFocusAV() 54void KAddressBookTableView::setFocusAV()
55{ 55{
56 if ( mListView ) 56 if ( mListView )
57 mListView->setFocus(); 57 mListView->setFocus();
58 58
59} 59}
60void KAddressBookTableView::scrollUP() 60void KAddressBookTableView::scrollUP()
61{ 61{
62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
63 QApplication::postEvent( mListView, ev ); 63 QApplication::postEvent( mListView, ev );
64 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 ); 64 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 );
65 QApplication::postEvent( mListView, ev ); 65 QApplication::postEvent( mListView, ev );
66} 66}
67void KAddressBookTableView::scrollDOWN() 67void KAddressBookTableView::scrollDOWN()
68{ 68{
69 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 69 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
70 QApplication::postEvent( mListView, ev ); 70 QApplication::postEvent( mListView, ev );
71 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 ); 71 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 );
72 QApplication::postEvent( mListView, ev ); 72 QApplication::postEvent( mListView, ev );
73} 73}
74void KAddressBookTableView::reconstructListView() 74void KAddressBookTableView::reconstructListView()
75{ 75{
76 if (mListView) 76 if (mListView)
77 { 77 {
78 disconnect(mListView, SIGNAL(selectionChanged()), 78 disconnect(mListView, SIGNAL(selectionChanged()),
79 this, SLOT(addresseeSelected())); 79 this, SLOT(addresseeSelected()));
80 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 80 disconnect(mListView, SIGNAL(executed(QListViewItem*)),
81 this, SLOT(addresseeExecuted(QListViewItem*))); 81 this, SLOT(addresseeExecuted(QListViewItem*)));
82 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 82 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
83 this, SLOT(addresseeExecuted(QListViewItem*))); 83 this, SLOT(addresseeExecuted(QListViewItem*)));
84 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 84 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
85 SIGNAL(startDrag())); 85 SIGNAL(startDrag()));
86 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 86 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
87 this, SLOT(addresseeExecuted(QListViewItem*))); 87 this, SLOT(addresseeExecuted(QListViewItem*)));
88 88
89 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 89 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
90 SIGNAL(dropped(QDropEvent*))); 90 SIGNAL(dropped(QDropEvent*)));
91 delete mListView; 91 delete mListView;
92 } 92 }
93 93
94 mListView = new ContactListView( this, addressBook(), viewWidget() ); 94 mListView = new ContactListView( this, addressBook(), viewWidget() );
95 95
96 connect(this, SIGNAL(printView()), 96 connect(this, SIGNAL(printView()),
97 mListView , SLOT(printMe())); 97 mListView , SLOT(printMe()));
98 //US set singleClick manually, because it is no global configparameter in embedded space 98 //US set singleClick manually, because it is no global configparameter in embedded space
99 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); 99 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
100 100
101 // Add the columns 101 // Add the columns
102 KABC::Field::List fieldList = fields(); 102 KABC::Field::List fieldList = fields();
103 KABC::Field::List::ConstIterator it; 103 KABC::Field::List::ConstIterator it;
104 104
105 int c = 0; 105 int c = 0;
106 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 106 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
107 mListView->addColumn( (*it)->label() ); 107 mListView->addColumn( (*it)->label() );
108 mListView->setColumnWidthMode(c++, QListView::Manual); 108 mListView->setColumnWidthMode(c++, QListView::Manual);
109//US 109//US
110 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 110 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
111 } 111 }
112 112
113 connect(mListView, SIGNAL(selectionChanged()), 113 connect(mListView, SIGNAL(selectionChanged()),
114 this, SLOT(addresseeSelected())); 114 this, SLOT(addresseeSelected()));
115 connect(mListView, SIGNAL(startAddresseeDrag()), this, 115 connect(mListView, SIGNAL(startAddresseeDrag()), this,
116 SIGNAL(startDrag())); 116 SIGNAL(startDrag()));
117 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 117 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
118 SIGNAL(dropped(QDropEvent*))); 118 SIGNAL(dropped(QDropEvent*)));
119 119
120 if (KABPrefs::instance()->mHonorSingleClick) { 120 if (KABPrefs::instance()->mHonorSingleClick) {
121 // qDebug("KAddressBookTableView::reconstructListView single"); 121 // qDebug("KAddressBookTableView::reconstructListView single");
122 connect(mListView, SIGNAL(executed(QListViewItem*)), 122 connect(mListView, SIGNAL(executed(QListViewItem*)),
123 this, SLOT(addresseeExecuted(QListViewItem*))); 123 this, SLOT(addresseeExecuted(QListViewItem*)));
124 } else { 124 } else {
125 // qDebug("KAddressBookTableView::reconstructListView double"); 125 // qDebug("KAddressBookTableView::reconstructListView double");
126 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 126 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
127 this, SLOT(addresseeExecuted(QListViewItem*))); 127 this, SLOT(addresseeExecuted(QListViewItem*)));
128 } 128 }
129 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 129 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
130 this, SLOT(addresseeExecuted(QListViewItem*))); 130 this, SLOT(addresseeExecuted(QListViewItem*)));
131 connect(mListView, SIGNAL(signalDelete()), 131 connect(mListView, SIGNAL(signalDelete()),
132 this, SLOT(addresseeDeleted())); 132 this, SLOT(addresseeDeleted()));
133 133
134//US performceimprovement. Refresh is done from the outside 134//US performceimprovement. Refresh is done from the outside
135//US refresh(); 135//US refresh();
136 136
137 mListView->setSorting( 0, true ); 137 mListView->setSorting( 0, true );
138 mainLayout->addWidget( mListView ); 138 mainLayout->addWidget( mListView );
139 mainLayout->activate(); 139 mainLayout->activate();
140 mListView->show(); 140 mListView->show();
141} 141}
142 142
143void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 143void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
144{ 144{
145 mListView->clear(); 145 mListView->clear();
146 if ( s.isEmpty() || s == "*" ) { 146 if ( s.isEmpty() || s == "*" ) {
147 refresh(); 147 refresh();
148 return; 148 return;
149 } 149 }
150 QRegExp re = getRegExp( s ); 150 QRegExp re = getRegExp( s );
151 if (!re.isValid()) 151 if (!re.isValid())
152 return; 152 return;
153 KABC::Addressee::List addresseeList = addressees(); 153 KABC::Addressee::List addresseeList = addressees();
154 KABC::Addressee::List::Iterator it; 154 KABC::Addressee::List::Iterator it;
155 if ( field ) { 155 if ( field ) {
156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
158 continue; 158 continue;
159#if QT_VERSION >= 0x030000 159#if QT_VERSION >= 0x030000
160 if (re.search(field->value( *it ).lower()) == 0) 160 if (re.search(field->value( *it ).lower()) == 0)
161#else 161#else
162 if (re.match(field->value( *it ).lower()) != -1) 162 if (re.match(field->value( *it ).lower()) != -1)
163#endif 163#endif
164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
165 165
166 } 166 }
167 } else { 167 } else {
168 KABC::Field::List fieldList = allFields(); 168 KABC::Field::List fieldList = allFields();
169 KABC::Field::List::ConstIterator fieldIt; 169 KABC::Field::List::ConstIterator fieldIt;
170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
172 continue; 172 continue;
173 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 173 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
174#if QT_VERSION >= 0x030000 174#if QT_VERSION >= 0x030000
175 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 175 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
176#else 176#else
177 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 177 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
178#endif 178#endif
179 { 179 {
180 //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() ); 180 //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() );
181 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 181 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
182 break; 182 break;
183 } 183 }
184 } 184 }
185 } 185 }
186 } 186 }
187 // Sometimes the background pixmap gets messed up when we add lots 187 // Sometimes the background pixmap gets messed up when we add lots
188 // of items. 188 // of items.
189 mListView->repaint(); 189 //mListView->repaint();
190 if ( mListView->firstChild() ) { 190 if ( mListView->firstChild() ) {
191 mListView->setCurrentItem ( mListView->firstChild() ); 191 mListView->setCurrentItem ( mListView->firstChild() );
192 mListView->setSelected ( mListView->firstChild(), true ); 192 mListView->setSelected ( mListView->firstChild(), true );
193 } 193 }
194 else 194 else
195 emit selected(QString::null); 195 emit selected(QString::null);
196 196
197} 197}
198void KAddressBookTableView::writeConfig(KConfig *config) 198void KAddressBookTableView::writeConfig(KConfig *config)
199{ 199{
200 KAddressBookView::writeConfig(config); 200 KAddressBookView::writeConfig(config);
201 201
202 mListView->saveLayout(config, config->group()); 202 mListView->saveLayout(config, config->group());
203} 203}
204 204
205void KAddressBookTableView::readConfig(KConfig *config) 205void KAddressBookTableView::readConfig(KConfig *config)
206{ 206{
207 KAddressBookView::readConfig( config ); 207 KAddressBookView::readConfig( config );
208 // The config could have changed the fields, so we need to reconstruct 208 // The config could have changed the fields, so we need to reconstruct
209 // the listview. 209 // the listview.
210 reconstructListView(); 210 reconstructListView();
211 211
212 // costum colors? 212 // costum colors?
213 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 213 if ( config->readBoolEntry( "EnableCustomColors", false ) )
214 { 214 {
215 QPalette p( mListView->palette() ); 215 QPalette p( mListView->palette() );
216 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 216 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
217 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 217 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
218 c = p.color(QPalette::Normal, QColorGroup::Text ); 218 c = p.color(QPalette::Normal, QColorGroup::Text );
219 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 219 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
220 c = p.color(QPalette::Normal, QColorGroup::Button ); 220 c = p.color(QPalette::Normal, QColorGroup::Button );
221 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 221 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
222 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 222 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
223 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 223 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
224 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 224 c = p.color(QPalette::Normal, QColorGroup::Highlight );
225 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 225 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
226 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 226 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
227 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 227 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
228#ifndef KAB_EMBEDDED 228#ifndef KAB_EMBEDDED
229 c = KGlobalSettings::alternateBackgroundColor(); 229 c = KGlobalSettings::alternateBackgroundColor();
230#else //KAB_EMBEDDED 230#else //KAB_EMBEDDED
231 c = QColor(240, 240, 240); 231 c = QColor(240, 240, 240);
232#endif //KAB_EMBEDDED 232#endif //KAB_EMBEDDED
233 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 233 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
234 mListView->setAlternateColor(c); 234 mListView->setAlternateColor(c);
235 235
236 236
237 //US mListView->viewport()->setPalette( p ); 237 //US mListView->viewport()->setPalette( p );
238 mListView->setPalette( p ); 238 mListView->setPalette( p );
239 } 239 }
240 else 240 else
241 { 241 {
242 // needed if turned off during a session. 242 // needed if turned off during a session.
243 //US mListView->viewport()->setPalette( mListView->palette() ); 243 //US mListView->viewport()->setPalette( mListView->palette() );
244 mListView->setPalette( mListView->palette() ); 244 mListView->setPalette( mListView->palette() );
245 } 245 }
246 246
247 //custom fonts? 247 //custom fonts?
248 QFont f( font() ); 248 QFont f( font() );
249 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 249 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
250 { 250 {
251 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 251 mListView->setFont( config->readFontEntry( "TextFont", &f) );
252 f.setBold( true ); 252 f.setBold( true );
253 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 253 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
254 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 254 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
255 } 255 }
256 else 256 else
257 { 257 {
258 mListView->setFont( f ); 258 mListView->setFont( f );
259 f.setBold( true ); 259 f.setBold( true );
260 //US mListView->setHeaderFont( f ); 260 //US mListView->setHeaderFont( f );
261 mListView->header()->setFont( f ); 261 mListView->header()->setFont( f );
262 } 262 }
263 263
264 // Set the list view options 264 // Set the list view options
265 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 265 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
266 true)); 266 true));
267 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 267 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
268 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 268 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
269 269
270 if (config->readBoolEntry("Background", false)) 270 if (config->readBoolEntry("Background", false))
271 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 271 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
272 272
273 // Restore the layout of the listview 273 // Restore the layout of the listview
274 mListView->restoreLayout(config, config->group()); 274 mListView->restoreLayout(config, config->group());
275} 275}
276 276
277void KAddressBookTableView::refresh(QString uid) 277void KAddressBookTableView::refresh(QString uid)
278{ 278{
279 // For now just repopulate. In reality this method should 279 // For now just repopulate. In reality this method should
280 // check the value of uid, and if valid iterate through 280 // check the value of uid, and if valid iterate through
281 // the listview to find the entry, then tell it to refresh. 281 // the listview to find the entry, then tell it to refresh.
282 282
283 if (uid.isNull()) { 283 if (uid.isNull()) {
284 // Clear the list view 284 // Clear the list view
285 QString currentUID, nextUID; 285 QString currentUID, nextUID;
286#ifndef KAB_EMBEDDED 286#ifndef KAB_EMBEDDED
287 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); 287 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() );
288#else //KAB_EMBEDDED 288#else //KAB_EMBEDDED
289 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); 289 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() );
290#endif //KAB_EMBEDDED 290#endif //KAB_EMBEDDED
291 291
292 if ( currentItem ) { 292 if ( currentItem ) {
293#ifndef KAB_EMBEDDED 293#ifndef KAB_EMBEDDED
294 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); 294 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() );
295#else //KAB_EMBEDDED 295#else //KAB_EMBEDDED
296 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); 296 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() );
297#endif //KAB_EMBEDDED 297#endif //KAB_EMBEDDED
298 if ( nextItem ) 298 if ( nextItem )
299 nextUID = nextItem->addressee().uid(); 299 nextUID = nextItem->addressee().uid();
300 currentUID = currentItem->addressee().uid(); 300 currentUID = currentItem->addressee().uid();
301 } 301 }
302 302
303 mListView->clear(); 303 mListView->clear();
304 304
305 currentItem = 0; 305 currentItem = 0;
306 KABC::Addressee::List addresseeList = addressees(); 306 KABC::Addressee::List addresseeList = addressees();
307 KABC::Addressee::List::Iterator it; 307 KABC::Addressee::List::Iterator it;
308 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 308 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
309 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 309 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
310 continue; 310 continue;
311 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 311 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
312 if ( (*it).uid() == currentUID ) 312 if ( (*it).uid() == currentUID )
313 currentItem = item; 313 currentItem = item;
314 else if ( (*it).uid() == nextUID && !currentItem ) 314 else if ( (*it).uid() == nextUID && !currentItem )
315 currentItem = item; 315 currentItem = item;
316 } 316 }
317 317
318 // Sometimes the background pixmap gets messed up when we add lots 318 // Sometimes the background pixmap gets messed up when we add lots
319 // of items. 319 // of items.
320 mListView->repaint(); 320 mListView->repaint();
321 321
322 if ( currentItem ) { 322 if ( currentItem ) {
323 mListView->setCurrentItem( currentItem ); 323 mListView->setCurrentItem( currentItem );
324 mListView->ensureItemVisible( currentItem ); 324 mListView->ensureItemVisible( currentItem );
325 } 325 }
326 } else { 326 } else {
327 // Only need to update on entry. Iterate through and try to find it 327 // Only need to update on entry. Iterate through and try to find it
328 ContactListViewItem *ceItem; 328 ContactListViewItem *ceItem;
329 QListViewItemIterator it( mListView ); 329 QListViewItemIterator it( mListView );
330 while ( it.current() ) { 330 while ( it.current() ) {
331#ifndef KAB_EMBEDDED 331#ifndef KAB_EMBEDDED
332 ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); 332 ceItem = dynamic_cast<ContactListViewItem*>( it.current() );
333#else //KAB_EMBEDDED 333#else //KAB_EMBEDDED
334 ceItem = (ContactListViewItem*)( it.current() ); 334 ceItem = (ContactListViewItem*)( it.current() );
335#endif //KAB_EMBEDDED 335#endif //KAB_EMBEDDED
336 336
337 if ( ceItem && ceItem->addressee().uid() == uid ) { 337 if ( ceItem && ceItem->addressee().uid() == uid ) {
338 ceItem->refresh(); 338 ceItem->refresh();
339 return; 339 return;
340 } 340 }
341 ++it; 341 ++it;
342 } 342 }
343 343
344 refresh( QString::null ); 344 refresh( QString::null );
345 } 345 }
346} 346}
347 347
348QStringList KAddressBookTableView::selectedUids() 348QStringList KAddressBookTableView::selectedUids()
349{ 349{
350 QStringList uidList; 350 QStringList uidList;
351 QListViewItem *item; 351 QListViewItem *item;
352 ContactListViewItem *ceItem; 352 ContactListViewItem *ceItem;
353 353
354 for(item = mListView->firstChild(); item; item = item->itemBelow()) 354 for(item = mListView->firstChild(); item; item = item->itemBelow())
355 { 355 {
356 if (mListView->isSelected( item )) 356 if (mListView->isSelected( item ))
357 { 357 {
358#ifndef KAB_EMBEDDED 358#ifndef KAB_EMBEDDED
359 ceItem = dynamic_cast<ContactListViewItem*>(item); 359 ceItem = dynamic_cast<ContactListViewItem*>(item);
360#else //KAB_EMBEDDED 360#else //KAB_EMBEDDED
361 ceItem = (ContactListViewItem*)(item); 361 ceItem = (ContactListViewItem*)(item);
362#endif //KAB_EMBEDDED 362#endif //KAB_EMBEDDED
363 363
364 if (ceItem != 0L) 364 if (ceItem != 0L)
365 uidList << ceItem->addressee().uid(); 365 uidList << ceItem->addressee().uid();
366 } 366 }
367 } 367 }
368 if ( uidList.count() == 0 ) 368 if ( uidList.count() == 0 )
369 if ( mListView->currentItem() ) { 369 if ( mListView->currentItem() ) {
370 ceItem = (ContactListViewItem*)(mListView->currentItem()) ; 370 ceItem = (ContactListViewItem*)(mListView->currentItem()) ;
371 uidList << ceItem->addressee().uid(); 371 uidList << ceItem->addressee().uid();
372 } 372 }
373 373
374 return uidList; 374 return uidList;
375} 375}
376 376
377void KAddressBookTableView::setSelected(QString uid, bool selected) 377void KAddressBookTableView::setSelected(QString uid, bool selected)
378{ 378{
379 QListViewItem *item; 379 QListViewItem *item;
380 ContactListViewItem *ceItem; 380 ContactListViewItem *ceItem;
381 381
382 if (uid.isNull()) 382 if (uid.isNull())
383 { 383 {
384 mListView->selectAll(selected); 384 mListView->selectAll(selected);
385 } 385 }
386 else 386 else
387 { 387 {
388 for(item = mListView->firstChild(); item; item = item->itemBelow()) 388 for(item = mListView->firstChild(); item; item = item->itemBelow())
389 { 389 {
390#ifndef KAB_EMBEDDED 390#ifndef KAB_EMBEDDED
391 ceItem = dynamic_cast<ContactListViewItem*>(item); 391 ceItem = dynamic_cast<ContactListViewItem*>(item);
392#else //KAB_EMBEDDED 392#else //KAB_EMBEDDED
393 ceItem = (ContactListViewItem*)(item); 393 ceItem = (ContactListViewItem*)(item);
394#endif //KAB_EMBEDDED 394#endif //KAB_EMBEDDED
395 395
396 396
397 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) 397 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid))
398 { 398 {
399 mListView->setSelected(item, selected); 399 mListView->setSelected(item, selected);
400 400
401 if (selected) 401 if (selected)
402 mListView->ensureItemVisible(item); 402 mListView->ensureItemVisible(item);
403 } 403 }
404 } 404 }
405 } 405 }
406} 406}
407 407
408void KAddressBookTableView::addresseeSelected() 408void KAddressBookTableView::addresseeSelected()
409{ 409{
410 // We need to try to find the first selected item. This might not be the 410 // We need to try to find the first selected item. This might not be the
411 // last selected item, but when QListView is in multiselection mode, 411 // last selected item, but when QListView is in multiselection mode,
412 // there is no way to figure out which one was 412 // there is no way to figure out which one was
413 // selected last. 413 // selected last.
414 QListViewItem *item; 414 QListViewItem *item;
415 bool found =false; 415 bool found =false;
416 for (item = mListView->firstChild(); item && !found; 416 for (item = mListView->firstChild(); item && !found;
417 item = item->nextSibling()) 417 item = item->nextSibling())
418 { 418 {
419 if (item->isSelected()) 419 if (item->isSelected())
420 { 420 {
421 found = true; 421 found = true;
422#ifndef KAB_EMBEDDED 422#ifndef KAB_EMBEDDED
423 ContactListViewItem *ceItem 423 ContactListViewItem *ceItem
424 = dynamic_cast<ContactListViewItem*>(item); 424 = dynamic_cast<ContactListViewItem*>(item);
425#else //KAB_EMBEDDED 425#else //KAB_EMBEDDED
426 ContactListViewItem *ceItem 426 ContactListViewItem *ceItem
427 = (ContactListViewItem*)(item); 427 = (ContactListViewItem*)(item);
428#endif //KAB_EMBEDDED 428#endif //KAB_EMBEDDED
429 429
430 if ( ceItem ) emit selected(ceItem->addressee().uid()); 430 if ( ceItem ) emit selected(ceItem->addressee().uid());
431 } 431 }
432 } 432 }
433 433
434 if (!found) 434 if (!found)
435 emit selected(QString::null); 435 emit selected(QString::null);
436} 436}
437 437
438void KAddressBookTableView::addresseeExecuted(QListViewItem *item) 438void KAddressBookTableView::addresseeExecuted(QListViewItem *item)
439{ 439{
440 if (item) 440 if (item)
441 { 441 {
442#ifndef KAB_EMBEDDED 442#ifndef KAB_EMBEDDED
443 ContactListViewItem *ceItem 443 ContactListViewItem *ceItem
444 = dynamic_cast<ContactListViewItem*>(item); 444 = dynamic_cast<ContactListViewItem*>(item);
445#else //KAB_EMBEDDED 445#else //KAB_EMBEDDED
446 ContactListViewItem *ceItem 446 ContactListViewItem *ceItem
447 = (ContactListViewItem*)(item); 447 = (ContactListViewItem*)(item);
448#endif //KAB_EMBEDDED 448#endif //KAB_EMBEDDED
449 449
450 if (ceItem) 450 if (ceItem)
451 { 451 {
452 emit executed(ceItem->addressee().uid()); 452 emit executed(ceItem->addressee().uid());
453 } 453 }
454 } 454 }
455 else 455 else
456 { 456 {
457 emit executed(QString::null); 457 emit executed(QString::null);
458 } 458 }
459} 459}
460 460
461void KAddressBookTableView::addresseeDeleted() 461void KAddressBookTableView::addresseeDeleted()
462{ 462{
463 463
464 emit deleteRequest(); 464 emit deleteRequest();
465 465
466} 466}
467 467
468 468
469 469
470 470
471 471
472#ifndef KAB_EMBEDDED 472#ifndef KAB_EMBEDDED
473#include "kaddressbooktableview.moc" 473#include "kaddressbooktableview.moc"
474#endif //KAB_EMBEDDED 474#endif //KAB_EMBEDDED