summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
authorzautrix <zautrix>2004-09-11 22:40:15 (UTC)
committer zautrix <zautrix>2004-09-11 22:40:15 (UTC)
commita040c9d56282dae396b02627fafb602e44323837 (patch) (unidiff)
tree9ee997f51e46a1ae6ab5aeaab709f1b8e138f3df /kaddressbook/views
parent53dda80aaab72d7efdbed8a206dc1fa64fed10ee (diff)
downloadkdepimpi-a040c9d56282dae396b02627fafb602e44323837.zip
kdepimpi-a040c9d56282dae396b02627fafb602e44323837.tar.gz
kdepimpi-a040c9d56282dae396b02627fafb602e44323837.tar.bz2
Added configure for search
Diffstat (limited to 'kaddressbook/views') (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 12f7c27..63ad0ed 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -1,442 +1,442 @@
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 36
37#include "kaddressbooktableview.h" 37#include "kaddressbooktableview.h"
38 38
39 39
40KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, 40KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
41 QWidget *parent, const char *name ) 41 QWidget *parent, const char *name )
42 : KAddressBookView( ab, parent, name ) 42 : KAddressBookView( ab, parent, name )
43{ 43{
44 mainLayout = new QVBoxLayout( viewWidget(), 2 ); 44 mainLayout = new QVBoxLayout( viewWidget(), 2 );
45 45
46 // The list view will be created when the config is read. 46 // The list view will be created when the config is read.
47 mListView = 0; 47 mListView = 0;
48} 48}
49 49
50KAddressBookTableView::~KAddressBookTableView() 50KAddressBookTableView::~KAddressBookTableView()
51{ 51{
52} 52}
53 53
54void KAddressBookTableView::reconstructListView() 54void KAddressBookTableView::reconstructListView()
55{ 55{
56 if (mListView) 56 if (mListView)
57 { 57 {
58 disconnect(mListView, SIGNAL(selectionChanged()), 58 disconnect(mListView, SIGNAL(selectionChanged()),
59 this, SLOT(addresseeSelected())); 59 this, SLOT(addresseeSelected()));
60 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 60 disconnect(mListView, SIGNAL(executed(QListViewItem*)),
61 this, SLOT(addresseeExecuted(QListViewItem*))); 61 this, SLOT(addresseeExecuted(QListViewItem*)));
62 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 62 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
63 this, SLOT(addresseeExecuted(QListViewItem*))); 63 this, SLOT(addresseeExecuted(QListViewItem*)));
64 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 64 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
65 SIGNAL(startDrag())); 65 SIGNAL(startDrag()));
66 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 66 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
67 this, SLOT(addresseeExecuted(QListViewItem*))); 67 this, SLOT(addresseeExecuted(QListViewItem*)));
68 68
69 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 69 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
70 SIGNAL(dropped(QDropEvent*))); 70 SIGNAL(dropped(QDropEvent*)));
71 delete mListView; 71 delete mListView;
72 } 72 }
73 73
74 mListView = new ContactListView( this, addressBook(), viewWidget() ); 74 mListView = new ContactListView( this, addressBook(), viewWidget() );
75 75
76 // Add the columns 76 // Add the columns
77 KABC::Field::List fieldList = fields(); 77 KABC::Field::List fieldList = fields();
78 KABC::Field::List::ConstIterator it; 78 KABC::Field::List::ConstIterator it;
79 79
80 int c = 0; 80 int c = 0;
81 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 81 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
82 mListView->addColumn( (*it)->label() ); 82 mListView->addColumn( (*it)->label() );
83 mListView->setColumnWidthMode(c++, QListView::Manual); 83 mListView->setColumnWidthMode(c++, QListView::Manual);
84//US 84//US
85 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 85 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
86 } 86 }
87 87
88 connect(mListView, SIGNAL(selectionChanged()), 88 connect(mListView, SIGNAL(selectionChanged()),
89 this, SLOT(addresseeSelected())); 89 this, SLOT(addresseeSelected()));
90 connect(mListView, SIGNAL(startAddresseeDrag()), this, 90 connect(mListView, SIGNAL(startAddresseeDrag()), this,
91 SIGNAL(startDrag())); 91 SIGNAL(startDrag()));
92 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 92 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
93 SIGNAL(dropped(QDropEvent*))); 93 SIGNAL(dropped(QDropEvent*)));
94 94
95 if (KABPrefs::instance()->mHonorSingleClick) 95 if (KABPrefs::instance()->mHonorSingleClick)
96 connect(mListView, SIGNAL(executed(QListViewItem*)), 96 connect(mListView, SIGNAL(executed(QListViewItem*)),
97 this, SLOT(addresseeExecuted(QListViewItem*))); 97 this, SLOT(addresseeExecuted(QListViewItem*)));
98 else 98 else
99 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 99 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
100 this, SLOT(addresseeExecuted(QListViewItem*))); 100 this, SLOT(addresseeExecuted(QListViewItem*)));
101 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 101 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
102 this, SLOT(addresseeExecuted(QListViewItem*))); 102 this, SLOT(addresseeExecuted(QListViewItem*)));
103 connect(mListView, SIGNAL(signalDelete()), 103 connect(mListView, SIGNAL(signalDelete()),
104 this, SLOT(addresseeDeleted())); 104 this, SLOT(addresseeDeleted()));
105 105
106//US performceimprovement. Refresh is done from the outside 106//US performceimprovement. Refresh is done from the outside
107//US refresh(); 107//US refresh();
108 108
109 mListView->setSorting( 0, true ); 109 mListView->setSorting( 0, true );
110 mainLayout->addWidget( mListView ); 110 mainLayout->addWidget( mListView );
111 mainLayout->activate(); 111 mainLayout->activate();
112 mListView->show(); 112 mListView->show();
113} 113}
114 114
115void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 115void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
116{ 116{
117 mListView->clear(); 117 mListView->clear();
118 if ( s.isEmpty() || s == "*" ) { 118 if ( s.isEmpty() || s == "*" ) {
119 refresh(); 119 refresh();
120 return; 120 return;
121 } 121 }
122 QString pattern = s.lower()+"*"; 122 QString pattern = s.lower()+"*";
123 QRegExp re; 123 QRegExp re;
124 re.setWildcard(true); // most people understand these better. 124 re.setWildcard(true); // most people understand these better.
125 re.setCaseSensitive(false); 125 re.setCaseSensitive(false);
126 re.setPattern( pattern ); 126 re.setPattern( pattern );
127 if (!re.isValid()) 127 if (!re.isValid())
128 return; 128 return;
129 KABC::Addressee::List addresseeList = addressees(); 129 KABC::Addressee::List addresseeList = addressees();
130 KABC::Addressee::List::Iterator it; 130 KABC::Addressee::List::Iterator it;
131 if ( field ) { 131 if ( field ) {
132 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 132 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
133#if QT_VERSION >= 300 133#if QT_VERSION >= 300
134 if (re.search(field->value( *it ).lower()) != -1) 134 if (re.search(field->value( *it ).lower()) != -1)
135#else 135#else
136 if (re.match(field->value( *it ).lower()) != -1) 136 if (re.match(field->value( *it ).lower()) != -1)
137#endif 137#endif
138 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 138 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
139 139
140 } 140 }
141 } else { 141 } else {
142 KABC::Field::List fieldList = fields(); 142 KABC::Field::List fieldList = fields();
143 KABC::Field::List::ConstIterator fieldIt; 143 KABC::Field::List::ConstIterator fieldIt;
144 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 144 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
145 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 145 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
146#if QT_VERSION >= 300 146#if QT_VERSION >= 300
147 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 147 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
148#else 148#else
149 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 149 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
150#endif 150#endif
151 { 151 {
152 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 152 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
153 continue; 153 break;
154 } 154 }
155 } 155 }
156 } 156 }
157 } 157 }
158 // Sometimes the background pixmap gets messed up when we add lots 158 // Sometimes the background pixmap gets messed up when we add lots
159 // of items. 159 // of items.
160 mListView->repaint(); 160 mListView->repaint();
161 emit selected(QString::null); 161 emit selected(QString::null);
162 162
163} 163}
164void KAddressBookTableView::writeConfig(KConfig *config) 164void KAddressBookTableView::writeConfig(KConfig *config)
165{ 165{
166 KAddressBookView::writeConfig(config); 166 KAddressBookView::writeConfig(config);
167 167
168 mListView->saveLayout(config, config->group()); 168 mListView->saveLayout(config, config->group());
169} 169}
170 170
171void KAddressBookTableView::readConfig(KConfig *config) 171void KAddressBookTableView::readConfig(KConfig *config)
172{ 172{
173 KAddressBookView::readConfig( config ); 173 KAddressBookView::readConfig( config );
174 // The config could have changed the fields, so we need to reconstruct 174 // The config could have changed the fields, so we need to reconstruct
175 // the listview. 175 // the listview.
176 reconstructListView(); 176 reconstructListView();
177 177
178 // costum colors? 178 // costum colors?
179 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 179 if ( config->readBoolEntry( "EnableCustomColors", false ) )
180 { 180 {
181 QPalette p( mListView->palette() ); 181 QPalette p( mListView->palette() );
182 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 182 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
183 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 183 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
184 c = p.color(QPalette::Normal, QColorGroup::Text ); 184 c = p.color(QPalette::Normal, QColorGroup::Text );
185 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 185 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
186 c = p.color(QPalette::Normal, QColorGroup::Button ); 186 c = p.color(QPalette::Normal, QColorGroup::Button );
187 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 187 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
188 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 188 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
189 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 189 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
190 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 190 c = p.color(QPalette::Normal, QColorGroup::Highlight );
191 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 191 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
192 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 192 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
193 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 193 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
194#ifndef KAB_EMBEDDED 194#ifndef KAB_EMBEDDED
195 c = KGlobalSettings::alternateBackgroundColor(); 195 c = KGlobalSettings::alternateBackgroundColor();
196#else //KAB_EMBEDDED 196#else //KAB_EMBEDDED
197 c = QColor(240, 240, 240); 197 c = QColor(240, 240, 240);
198#endif //KAB_EMBEDDED 198#endif //KAB_EMBEDDED
199 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 199 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
200 mListView->setAlternateColor(c); 200 mListView->setAlternateColor(c);
201 201
202 202
203 //US mListView->viewport()->setPalette( p ); 203 //US mListView->viewport()->setPalette( p );
204 mListView->setPalette( p ); 204 mListView->setPalette( p );
205 } 205 }
206 else 206 else
207 { 207 {
208 // needed if turned off during a session. 208 // needed if turned off during a session.
209 //US mListView->viewport()->setPalette( mListView->palette() ); 209 //US mListView->viewport()->setPalette( mListView->palette() );
210 mListView->setPalette( mListView->palette() ); 210 mListView->setPalette( mListView->palette() );
211 } 211 }
212 212
213 //custom fonts? 213 //custom fonts?
214 QFont f( font() ); 214 QFont f( font() );
215 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 215 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
216 { 216 {
217 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 217 mListView->setFont( config->readFontEntry( "TextFont", &f) );
218 f.setBold( true ); 218 f.setBold( true );
219 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 219 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
220 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 220 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
221 } 221 }
222 else 222 else
223 { 223 {
224 mListView->setFont( f ); 224 mListView->setFont( f );
225 f.setBold( true ); 225 f.setBold( true );
226 //US mListView->setHeaderFont( f ); 226 //US mListView->setHeaderFont( f );
227 mListView->header()->setFont( f ); 227 mListView->header()->setFont( f );
228 } 228 }
229 229
230 230
231 231
232 232
233 233
234 // Set the list view options 234 // Set the list view options
235 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 235 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
236 true)); 236 true));
237 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 237 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
238 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 238 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
239 239
240 if (config->readBoolEntry("Background", false)) 240 if (config->readBoolEntry("Background", false))
241 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 241 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
242 242
243 // Restore the layout of the listview 243 // Restore the layout of the listview
244 mListView->restoreLayout(config, config->group()); 244 mListView->restoreLayout(config, config->group());
245} 245}
246 246
247void KAddressBookTableView::refresh(QString uid) 247void KAddressBookTableView::refresh(QString uid)
248{ 248{
249 // For now just repopulate. In reality this method should 249 // For now just repopulate. In reality this method should
250 // check the value of uid, and if valid iterate through 250 // check the value of uid, and if valid iterate through
251 // the listview to find the entry, then tell it to refresh. 251 // the listview to find the entry, then tell it to refresh.
252 252
253 if (uid.isNull()) { 253 if (uid.isNull()) {
254 // Clear the list view 254 // Clear the list view
255 QString currentUID, nextUID; 255 QString currentUID, nextUID;
256#ifndef KAB_EMBEDDED 256#ifndef KAB_EMBEDDED
257 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); 257 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() );
258#else //KAB_EMBEDDED 258#else //KAB_EMBEDDED
259 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); 259 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() );
260#endif //KAB_EMBEDDED 260#endif //KAB_EMBEDDED
261 261
262 if ( currentItem ) { 262 if ( currentItem ) {
263#ifndef KAB_EMBEDDED 263#ifndef KAB_EMBEDDED
264 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); 264 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() );
265#else //KAB_EMBEDDED 265#else //KAB_EMBEDDED
266 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); 266 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() );
267#endif //KAB_EMBEDDED 267#endif //KAB_EMBEDDED
268 if ( nextItem ) 268 if ( nextItem )
269 nextUID = nextItem->addressee().uid(); 269 nextUID = nextItem->addressee().uid();
270 currentUID = currentItem->addressee().uid(); 270 currentUID = currentItem->addressee().uid();
271 } 271 }
272 272
273 mListView->clear(); 273 mListView->clear();
274 274
275 currentItem = 0; 275 currentItem = 0;
276 KABC::Addressee::List addresseeList = addressees(); 276 KABC::Addressee::List addresseeList = addressees();
277 KABC::Addressee::List::Iterator it; 277 KABC::Addressee::List::Iterator it;
278 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 278 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
279 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 279 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
280 if ( (*it).uid() == currentUID ) 280 if ( (*it).uid() == currentUID )
281 currentItem = item; 281 currentItem = item;
282 else if ( (*it).uid() == nextUID && !currentItem ) 282 else if ( (*it).uid() == nextUID && !currentItem )
283 currentItem = item; 283 currentItem = item;
284 } 284 }
285 285
286 // Sometimes the background pixmap gets messed up when we add lots 286 // Sometimes the background pixmap gets messed up when we add lots
287 // of items. 287 // of items.
288 mListView->repaint(); 288 mListView->repaint();
289 289
290 if ( currentItem ) { 290 if ( currentItem ) {
291 mListView->setCurrentItem( currentItem ); 291 mListView->setCurrentItem( currentItem );
292 mListView->ensureItemVisible( currentItem ); 292 mListView->ensureItemVisible( currentItem );
293 } 293 }
294 } else { 294 } else {
295 // Only need to update on entry. Iterate through and try to find it 295 // Only need to update on entry. Iterate through and try to find it
296 ContactListViewItem *ceItem; 296 ContactListViewItem *ceItem;
297 QListViewItemIterator it( mListView ); 297 QListViewItemIterator it( mListView );
298 while ( it.current() ) { 298 while ( it.current() ) {
299#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED
300 ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); 300 ceItem = dynamic_cast<ContactListViewItem*>( it.current() );
301#else //KAB_EMBEDDED 301#else //KAB_EMBEDDED
302 ceItem = (ContactListViewItem*)( it.current() ); 302 ceItem = (ContactListViewItem*)( it.current() );
303#endif //KAB_EMBEDDED 303#endif //KAB_EMBEDDED
304 304
305 if ( ceItem && ceItem->addressee().uid() == uid ) { 305 if ( ceItem && ceItem->addressee().uid() == uid ) {
306 ceItem->refresh(); 306 ceItem->refresh();
307 return; 307 return;
308 } 308 }
309 ++it; 309 ++it;
310 } 310 }
311 311
312 refresh( QString::null ); 312 refresh( QString::null );
313 } 313 }
314} 314}
315 315
316QStringList KAddressBookTableView::selectedUids() 316QStringList KAddressBookTableView::selectedUids()
317{ 317{
318 QStringList uidList; 318 QStringList uidList;
319 QListViewItem *item; 319 QListViewItem *item;
320 ContactListViewItem *ceItem; 320 ContactListViewItem *ceItem;
321 321
322 for(item = mListView->firstChild(); item; item = item->itemBelow()) 322 for(item = mListView->firstChild(); item; item = item->itemBelow())
323 { 323 {
324 if (mListView->isSelected( item )) 324 if (mListView->isSelected( item ))
325 { 325 {
326#ifndef KAB_EMBEDDED 326#ifndef KAB_EMBEDDED
327 ceItem = dynamic_cast<ContactListViewItem*>(item); 327 ceItem = dynamic_cast<ContactListViewItem*>(item);
328#else //KAB_EMBEDDED 328#else //KAB_EMBEDDED
329 ceItem = (ContactListViewItem*)(item); 329 ceItem = (ContactListViewItem*)(item);
330#endif //KAB_EMBEDDED 330#endif //KAB_EMBEDDED
331 331
332 if (ceItem != 0L) 332 if (ceItem != 0L)
333 uidList << ceItem->addressee().uid(); 333 uidList << ceItem->addressee().uid();
334 } 334 }
335 } 335 }
336 if ( uidList.count() == 0 ) 336 if ( uidList.count() == 0 )
337 if ( mListView->currentItem() ) { 337 if ( mListView->currentItem() ) {
338 ceItem = (ContactListViewItem*)(mListView->currentItem()) ; 338 ceItem = (ContactListViewItem*)(mListView->currentItem()) ;
339 uidList << ceItem->addressee().uid(); 339 uidList << ceItem->addressee().uid();
340 } 340 }
341 341
342 return uidList; 342 return uidList;
343} 343}
344 344
345void KAddressBookTableView::setSelected(QString uid, bool selected) 345void KAddressBookTableView::setSelected(QString uid, bool selected)
346{ 346{
347 QListViewItem *item; 347 QListViewItem *item;
348 ContactListViewItem *ceItem; 348 ContactListViewItem *ceItem;
349 349
350 if (uid.isNull()) 350 if (uid.isNull())
351 { 351 {
352 mListView->selectAll(selected); 352 mListView->selectAll(selected);
353 } 353 }
354 else 354 else
355 { 355 {
356 for(item = mListView->firstChild(); item; item = item->itemBelow()) 356 for(item = mListView->firstChild(); item; item = item->itemBelow())
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 364
365 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) 365 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid))
366 { 366 {
367 mListView->setSelected(item, selected); 367 mListView->setSelected(item, selected);
368 368
369 if (selected) 369 if (selected)
370 mListView->ensureItemVisible(item); 370 mListView->ensureItemVisible(item);
371 } 371 }
372 } 372 }
373 } 373 }
374} 374}
375 375
376void KAddressBookTableView::addresseeSelected() 376void KAddressBookTableView::addresseeSelected()
377{ 377{
378 // We need to try to find the first selected item. This might not be the 378 // We need to try to find the first selected item. This might not be the
379 // last selected item, but when QListView is in multiselection mode, 379 // last selected item, but when QListView is in multiselection mode,
380 // there is no way to figure out which one was 380 // there is no way to figure out which one was
381 // selected last. 381 // selected last.
382 QListViewItem *item; 382 QListViewItem *item;
383 bool found =false; 383 bool found =false;
384 for (item = mListView->firstChild(); item && !found; 384 for (item = mListView->firstChild(); item && !found;
385 item = item->nextSibling()) 385 item = item->nextSibling())
386 { 386 {
387 if (item->isSelected()) 387 if (item->isSelected())
388 { 388 {
389 found = true; 389 found = true;
390#ifndef KAB_EMBEDDED 390#ifndef KAB_EMBEDDED
391 ContactListViewItem *ceItem 391 ContactListViewItem *ceItem
392 = dynamic_cast<ContactListViewItem*>(item); 392 = dynamic_cast<ContactListViewItem*>(item);
393#else //KAB_EMBEDDED 393#else //KAB_EMBEDDED
394 ContactListViewItem *ceItem 394 ContactListViewItem *ceItem
395 = (ContactListViewItem*)(item); 395 = (ContactListViewItem*)(item);
396#endif //KAB_EMBEDDED 396#endif //KAB_EMBEDDED
397 397
398 if ( ceItem ) emit selected(ceItem->addressee().uid()); 398 if ( ceItem ) emit selected(ceItem->addressee().uid());
399 } 399 }
400 } 400 }
401 401
402 if (!found) 402 if (!found)
403 emit selected(QString::null); 403 emit selected(QString::null);
404} 404}
405 405
406void KAddressBookTableView::addresseeExecuted(QListViewItem *item) 406void KAddressBookTableView::addresseeExecuted(QListViewItem *item)
407{ 407{
408 if (item) 408 if (item)
409 { 409 {
410#ifndef KAB_EMBEDDED 410#ifndef KAB_EMBEDDED
411 ContactListViewItem *ceItem 411 ContactListViewItem *ceItem
412 = dynamic_cast<ContactListViewItem*>(item); 412 = dynamic_cast<ContactListViewItem*>(item);
413#else //KAB_EMBEDDED 413#else //KAB_EMBEDDED
414 ContactListViewItem *ceItem 414 ContactListViewItem *ceItem
415 = (ContactListViewItem*)(item); 415 = (ContactListViewItem*)(item);
416#endif //KAB_EMBEDDED 416#endif //KAB_EMBEDDED
417 417
418 if (ceItem) 418 if (ceItem)
419 { 419 {
420 emit executed(ceItem->addressee().uid()); 420 emit executed(ceItem->addressee().uid());
421 } 421 }
422 } 422 }
423 else 423 else
424 { 424 {
425 emit executed(QString::null); 425 emit executed(QString::null);
426 } 426 }
427} 427}
428 428
429void KAddressBookTableView::addresseeDeleted() 429void KAddressBookTableView::addresseeDeleted()
430{ 430{
431 431
432 emit deleteRequest(); 432 emit deleteRequest();
433 433
434} 434}
435 435
436 436
437 437
438 438
439 439
440#ifndef KAB_EMBEDDED 440#ifndef KAB_EMBEDDED
441#include "kaddressbooktableview.moc" 441#include "kaddressbooktableview.moc"
442#endif //KAB_EMBEDDED 442#endif //KAB_EMBEDDED