summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseedialog.cpp18
-rw-r--r--kabc/addresseedialog.h2
2 files changed, 16 insertions, 4 deletions
diff --git a/kabc/addresseedialog.cpp b/kabc/addresseedialog.cpp
index e89584d..3e7b72c 100644
--- a/kabc/addresseedialog.cpp
+++ b/kabc/addresseedialog.cpp
@@ -1,348 +1,360 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qpushbutton.h> 22#include <qpushbutton.h>
23#include <qgroupbox.h> 23#include <qgroupbox.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qvbox.h> 26#include <qvbox.h>
27#include <qlabel.h> 27#include <qlabel.h>
28 28
29#include <klocale.h> 29#include <klocale.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kglobalsettings.h> 31#include <kglobalsettings.h>
32 32
33#include "stdaddressbook.h" 33#include "stdaddressbook.h"
34 34
35#include "addresseedialog.h" 35#include "addresseedialog.h"
36#include "KDGanttMinimizeSplitter.h" 36#include "KDGanttMinimizeSplitter.h"
37//#include "addresseedialog.moc" 37//#include "addresseedialog.moc"
38 38
39using namespace KABC; 39using namespace KABC;
40 40
41AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) : 41AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) :
42 QListViewItem( parent ), 42 QListViewItem( parent ),
43 mAddressee( addressee ) 43 mAddressee( addressee )
44{ 44{
45 setText( Name,addressee.realName()); 45 setText( Name,addressee.realName());
46 setText( Email, addressee.preferredEmail() ); 46 setText( Email, addressee.preferredEmail() );
47 setText( Category, addressee.categories().join(";") );
47} 48}
48 49
49QString AddresseeItem::key( int column, bool ) const 50QString AddresseeItem::key( int column, bool ) const
50{ 51{
51 52
52 if (column == Email) { 53 if (column == Email) {
53 QString value = text(Email); 54 QString value = text(Email);
54 int val = value.findRev("@"); 55 int val = value.findRev("@");
55 return value.mid( val) + value.left( val ); 56 return value.mid( val) + value.left( val );
56 } 57 }
57 return text(column).lower(); 58 return text(column).lower();
58} 59}
59 60
60AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) : 61AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) :
61 KDialogBase( KDialogBase::Plain, i18n("Select Addressee"), 62 KDialogBase( KDialogBase::Plain, i18n("Select Addressee"),
62 Ok|Cancel, No, parent ), mMultiple( multiple ) 63 Ok|Cancel, No, parent ), mMultiple( multiple )
63{ 64{
64 qDebug("NEW AddresseeDialog "); 65 qDebug("NEW AddresseeDialog ");
65 QWidget *topWidget = plainPage(); 66 QWidget *topWidget = plainPage();
66 67
67 QBoxLayout *topLayout = new QHBoxLayout( topWidget ); 68 QBoxLayout *topLayout = new QHBoxLayout( topWidget );
68 69
69 70
70 KDGanttMinimizeSplitter* mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, topWidget); 71 KDGanttMinimizeSplitter* mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, topWidget);
71 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 72 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
72 73
73 topLayout->addWidget(mMiniSplitter ); 74 topLayout->addWidget(mMiniSplitter );
74 75
75 QWidget *listWidget = new QWidget( mMiniSplitter ); 76 QWidget *listWidget = new QWidget( mMiniSplitter );
76 77
77 QBoxLayout *listLayout = new QVBoxLayout (listWidget) ; 78 QBoxLayout *listLayout = new QVBoxLayout (listWidget) ;
78 //topLayout->addLayout( listLayout ); 79 //topLayout->addLayout( listLayout );
79 80
80 mAddresseeList = new KListView( listWidget ); 81 mAddresseeList = new KListView( listWidget );
81 mAddresseeList->addColumn( i18n("Name") ); 82 mAddresseeList->addColumn( i18n("Name") );
82 mAddresseeList->addColumn( i18n("Email") ); 83 mAddresseeList->addColumn( i18n("Email") );
84 mAddresseeList->addColumn( i18n("Category") );
83 mAddresseeList->setAllColumnsShowFocus( true ); 85 mAddresseeList->setAllColumnsShowFocus( true );
84 mAddresseeList->setFullWidth( true ); 86 mAddresseeList->setFullWidth( true );
85 listLayout->addWidget( mAddresseeList ); 87 listLayout->addWidget( mAddresseeList );
86 connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ), 88 connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ),
87 SLOT( slotOk() ) ); 89 SLOT( slotOk() ) );
88 90
89 mAddresseeEdit = new QLineEdit( listWidget ); 91 QHBox* searchBox = new QHBox ( listWidget );
92 mAddresseeEdit = new QLineEdit( searchBox );
90 connect( mAddresseeEdit, SIGNAL( returnPressed() ), 93 connect( mAddresseeEdit, SIGNAL( returnPressed() ),
91 SLOT( loadAddressBook() ) ); 94 SLOT( loadAddressBook() ) );
92 mAddresseeEdit->setFocus(); 95 mAddresseeEdit->setFocus();
96 QPushButton *searchButton = new QPushButton( i18n("Search!"), searchBox );
97 connect ( searchButton, SIGNAL( clicked() ), SLOT( loadAddressBook() ) );
93 98
94 listLayout->addWidget( mAddresseeEdit ); 99 listLayout->addWidget( searchBox );
95 100
96 if ( mMultiple ) { 101 if ( mMultiple ) {
97 //QBoxLayout *selectedLayout = new QVBoxLayout; 102 //QBoxLayout *selectedLayout = new QVBoxLayout;
98 //topLayout->addLayout( selectedLayout ); 103 //topLayout->addLayout( selectedLayout );
99 //topLayout->setSpacing( spacingHint() ); 104 //topLayout->setSpacing( spacingHint() );
100 105
101 QVBox *selectedGroup = new QVBox( mMiniSplitter ); 106 QVBox *selectedGroup = new QVBox( mMiniSplitter );
102 new QLabel ( i18n("Selected:"), selectedGroup ); 107 new QLabel ( i18n("Selected:"), selectedGroup );
103 //selectedLayout->addWidget( selectedGroup ); 108 //selectedLayout->addWidget( selectedGroup );
104 109
105 mSelectedList = new KListView( selectedGroup ); 110 mSelectedList = new KListView( selectedGroup );
106 mSelectedList->addColumn( i18n("Name") ); 111 mSelectedList->addColumn( i18n("Name") );
107 mSelectedList->addColumn( i18n("Email") ); 112 mSelectedList->addColumn( i18n("Email") );
108 mSelectedList->setAllColumnsShowFocus( true ); 113 mSelectedList->setAllColumnsShowFocus( true );
109 mSelectedList->setFullWidth( true ); 114 mSelectedList->setFullWidth( true );
110 connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ), 115 //connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ),
116 // SLOT( removeSelected() ) );
117 connect( mSelectedList, SIGNAL( clicked( QListViewItem * ) ),
118 SLOT( removeSelected() ) );
119 connect( mSelectedList, SIGNAL( returnPressed( QListViewItem *) ),
111 SLOT( removeSelected() ) ); 120 SLOT( removeSelected() ) );
112 121
122#if 0
113 QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup ); 123 QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup );
114 connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) ); 124 connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) );
115 125
126#endif
116 connect( mAddresseeList, SIGNAL( clicked( QListViewItem * ) ), 127 connect( mAddresseeList, SIGNAL( clicked( QListViewItem * ) ),
117 SLOT( addSelected( QListViewItem * ) ) ); 128 SLOT( addSelected( QListViewItem * ) ) );
118 connect( mAddresseeList, SIGNAL( returnPressed( QListViewItem * ) ), 129 connect( mAddresseeList, SIGNAL( returnPressed( QListViewItem * ) ),
119 SLOT( selectNextItem( QListViewItem * ) ) ); 130 SLOT( selectNextItem( QListViewItem * ) ) );
120 131
121 } 132 }
122 133
123 mAddressBook = StdAddressBook::self( true ); 134 mAddressBook = StdAddressBook::self( true );
124 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ), 135 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ),
125 SLOT( addressBookChanged() ) ); 136 SLOT( addressBookChanged() ) );
126#if 0 137#if 0
127 connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ), 138 connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ),
128 SLOT( addressBookChanged() ) ); 139 SLOT( addressBookChanged() ) );
129#endif 140#endif
130 loadAddressBook(); 141 loadAddressBook();
131 QValueList<int> splitterSize; 142 QValueList<int> splitterSize;
132 splitterSize.append( ( width() / 5 ) * 3 ); 143 splitterSize.append( ( width() / 5 ) * 3 );
133 splitterSize.append( ( width() / 5 ) *2 ); 144 splitterSize.append( ( width() / 5 ) *2 );
134 mMiniSplitter->setSizes( splitterSize ); 145 mMiniSplitter->setSizes( splitterSize );
135} 146}
136 147
137AddresseeDialog::~AddresseeDialog() 148AddresseeDialog::~AddresseeDialog()
138{ 149{
139 qDebug("DELETE AddresseeDialog "); 150 qDebug("DELETE AddresseeDialog ");
140} 151}
141 152
142void AddresseeDialog::loadAddressBook() 153void AddresseeDialog::loadAddressBook()
143{ 154{
144 mAddresseeList->clear(); 155 mAddresseeList->clear();
145 mItemDict.clear(); 156 mItemDict.clear();
146 if ( mAddresseeEdit->text().isEmpty() ) { 157 if ( mAddresseeEdit->text().isEmpty() ) {
147 AddressBook::Iterator it; 158 AddressBook::Iterator it;
148 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 159 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
149 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 160 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
150 continue; 161 continue;
151 new AddresseeItem( mAddresseeList, (*it) ); 162 new AddresseeItem( mAddresseeList, (*it) );
152 } 163 }
153 return; 164 return;
154 } 165 }
155 //mAddresseeEdit->completionObject()->clear(); 166 //mAddresseeEdit->completionObject()->clear();
156 QRegExp re; 167 QRegExp re;
157 re.setWildcard(true); // most people understand these better. 168 re.setWildcard(true); // most people understand these better.
158 re.setCaseSensitive(false); 169 re.setCaseSensitive(false);
159 re.setPattern( "*"+ mAddresseeEdit->text() + "*"); 170 re.setPattern( "*"+ mAddresseeEdit->text() + "*");
160 171
161 AddressBook::Iterator it; 172 AddressBook::Iterator it;
162 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 173 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
163 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 174 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
164 continue; 175 continue;
165 QString name = (*it).realName(); 176 QString name = (*it).realName();
166 name += (*it).preferredEmail(); 177 name += (*it).preferredEmail();
178 name += (*it).categories().join(";");
167#if QT_VERSION >= 0x030000 179#if QT_VERSION >= 0x030000
168 if (re.search(name) != -1) 180 if (re.search(name) != -1)
169#else 181#else
170 if (re.match(name) != -1) 182 if (re.match(name) != -1)
171#endif 183#endif
172 AddresseeItem *item = new AddresseeItem( mAddresseeList, (*it) ); 184 AddresseeItem *item = new AddresseeItem( mAddresseeList, (*it) );
173 } 185 }
174} 186}
175 187
176void AddresseeDialog::addCompletionItem( const QString &str, QListViewItem *item ) 188void AddresseeDialog::addCompletionItem( const QString &str, QListViewItem *item )
177{ 189{
178 if ( str.isEmpty() ) return; 190 if ( str.isEmpty() ) return;
179 191
180 mItemDict.insert( str, item ); 192 mItemDict.insert( str, item );
181 //mAddresseeEdit->completionObject()->addItem( str ); 193 //mAddresseeEdit->completionObject()->addItem( str );
182} 194}
183 195
184void AddresseeDialog::selectItem( const QString &str ) 196void AddresseeDialog::selectItem( const QString &str )
185{ 197{
186 if ( str.isEmpty() ) return; 198 if ( str.isEmpty() ) return;
187 199
188 QListViewItem *item = mItemDict.find( str ); 200 QListViewItem *item = mItemDict.find( str );
189 if ( item ) { 201 if ( item ) {
190 mAddresseeList->blockSignals( true ); 202 mAddresseeList->blockSignals( true );
191 mAddresseeList->setSelected( item, true ); 203 mAddresseeList->setSelected( item, true );
192 mAddresseeList->ensureItemVisible( item ); 204 mAddresseeList->ensureItemVisible( item );
193 mAddresseeList->blockSignals( false ); 205 mAddresseeList->blockSignals( false );
194 } 206 }
195} 207}
196 208
197void AddresseeDialog::updateEdit( QListViewItem *item ) 209void AddresseeDialog::updateEdit( QListViewItem *item )
198{ 210{
199 mAddresseeEdit->setText( item->text( 0 ) ); 211 mAddresseeEdit->setText( item->text( 0 ) );
200 mAddresseeEdit->setSelection( 0, item->text( 0 ).length() ); 212 mAddresseeEdit->setSelection( 0, item->text( 0 ).length() );
201} 213}
202 214
203void AddresseeDialog::selectNextItem( QListViewItem *item ) 215void AddresseeDialog::selectNextItem( QListViewItem *item )
204{ 216{
205 addSelected( item ); 217 addSelected( item );
206 QListViewItem *next = item->nextSibling(); 218 QListViewItem *next = item->nextSibling();
207 if ( next ) { 219 if ( next ) {
208 next->setSelected( true ); 220 next->setSelected( true );
209 item->setSelected( false ); 221 item->setSelected( false );
210 mAddresseeList->setCurrentItem( next ); 222 mAddresseeList->setCurrentItem( next );
211 } 223 }
212} 224}
213void AddresseeDialog::addSelected( QListViewItem *item ) 225void AddresseeDialog::addSelected( QListViewItem *item )
214{ 226{
215 AddresseeItem *addrItem = (AddresseeItem *)( item ); 227 AddresseeItem *addrItem = (AddresseeItem *)( item );
216 if ( !addrItem ) return; 228 if ( !addrItem ) return;
217 229
218 Addressee a = addrItem->addressee(); 230 Addressee a = addrItem->addressee();
219 231
220 QListViewItem *selectedItem = mSelectedDict.find( a.uid() ); 232 QListViewItem *selectedItem = mSelectedDict.find( a.uid() );
221 if ( !selectedItem ) { 233 if ( !selectedItem ) {
222 selectedItem = new AddresseeItem( mSelectedList, a ); 234 selectedItem = new AddresseeItem( mSelectedList, a );
223 mSelectedDict.insert( a.uid(), selectedItem ); 235 mSelectedDict.insert( a.uid(), selectedItem );
224 } 236 }
225 237
226} 238}
227 239
228void AddresseeDialog::removeSelected() 240void AddresseeDialog::removeSelected()
229{ 241{
230 QListViewItem *item = mSelectedList->selectedItem(); 242 QListViewItem *item = mSelectedList->selectedItem();
231 AddresseeItem *addrItem = (AddresseeItem *)( item ); 243 AddresseeItem *addrItem = (AddresseeItem *)( item );
232 if ( !addrItem ) return; 244 if ( !addrItem ) return;
233 QListViewItem *next = item->nextSibling(); 245 QListViewItem *next = item->nextSibling();
234 mSelectedDict.remove( addrItem->addressee().uid() ); 246 mSelectedDict.remove( addrItem->addressee().uid() );
235 delete addrItem; 247 delete addrItem;
236 if ( next ) 248 if ( next )
237 next->setSelected( true ); 249 next->setSelected( true );
238} 250}
239 251
240Addressee AddresseeDialog::addressee() 252Addressee AddresseeDialog::addressee()
241{ 253{
242 AddresseeItem *aItem = 0; 254 AddresseeItem *aItem = 0;
243 255
244 if ( mMultiple ) 256 if ( mMultiple )
245 aItem = (AddresseeItem *)( mSelectedList->firstChild() ); 257 aItem = (AddresseeItem *)( mSelectedList->firstChild() );
246 else 258 else
247 aItem = (AddresseeItem *)( mAddresseeList->selectedItem() ); 259 aItem = (AddresseeItem *)( mAddresseeList->selectedItem() );
248 260
249 if (aItem) return aItem->addressee(); 261 if (aItem) return aItem->addressee();
250 return Addressee(); 262 return Addressee();
251} 263}
252 264
253Addressee::List AddresseeDialog::addressees() 265Addressee::List AddresseeDialog::addressees()
254{ 266{
255 Addressee::List al; 267 Addressee::List al;
256 AddresseeItem *aItem = 0; 268 AddresseeItem *aItem = 0;
257 269
258 if ( mMultiple ) { 270 if ( mMultiple ) {
259 QListViewItem *item = mSelectedList->firstChild(); 271 QListViewItem *item = mSelectedList->firstChild();
260 while( item ) { 272 while( item ) {
261 aItem = (AddresseeItem *)( item ); 273 aItem = (AddresseeItem *)( item );
262 if ( aItem ) al.append( aItem->addressee() ); 274 if ( aItem ) al.append( aItem->addressee() );
263 item = item->nextSibling(); 275 item = item->nextSibling();
264 } 276 }
265 } 277 }
266 else 278 else
267 { 279 {
268 aItem = (AddresseeItem *)( mAddresseeList->selectedItem() ); 280 aItem = (AddresseeItem *)( mAddresseeList->selectedItem() );
269 if (aItem) al.append( aItem->addressee() ); 281 if (aItem) al.append( aItem->addressee() );
270 } 282 }
271 283
272 return al; 284 return al;
273} 285}
274 286
275Addressee AddresseeDialog::getAddressee( QWidget *parent ) 287Addressee AddresseeDialog::getAddressee( QWidget *parent )
276{ 288{
277 AddresseeDialog *dlg = new AddresseeDialog( parent ); 289 AddresseeDialog *dlg = new AddresseeDialog( parent );
278 Addressee addressee; 290 Addressee addressee;
279#ifdef DESKTOP_VERSION 291#ifdef DESKTOP_VERSION
280 static int geoX = 0; 292 static int geoX = 0;
281 static int geoY = 0; 293 static int geoY = 0;
282 static int geoW = 0; 294 static int geoW = 0;
283 static int geoH = 0; 295 static int geoH = 0;
284 if ( !geoX && ! geoY && !geoW &&!geoH ) { 296 if ( !geoX && ! geoY && !geoW &&!geoH ) {
285 geoX = dlg->geometry().x(); 297 geoX = dlg->geometry().x();
286 geoY = dlg->geometry().y(); 298 geoY = dlg->geometry().y();
287 geoW = dlg->width(); 299 geoW = dlg->width();
288 geoH = dlg->height(); 300 geoH = dlg->height();
289 } else { 301 } else {
290 dlg->show(); 302 dlg->show();
291 dlg->setGeometry(geoX , geoY,geoW , geoH ); 303 dlg->setGeometry(geoX , geoY,geoW , geoH );
292 304
293 } 305 }
294#endif 306#endif
295 int result = dlg->exec(); 307 int result = dlg->exec();
296#ifdef DESKTOP_VERSION 308#ifdef DESKTOP_VERSION
297 geoX = dlg->geometry().x(); 309 geoX = dlg->geometry().x();
298 geoY = dlg->geometry().y(); 310 geoY = dlg->geometry().y();
299 geoW = dlg->width(); 311 geoW = dlg->width();
300 geoH = dlg->height(); 312 geoH = dlg->height();
301#endif 313#endif
302 if ( result == QDialog::Accepted ) { 314 if ( result == QDialog::Accepted ) {
303 addressee = dlg->addressee(); 315 addressee = dlg->addressee();
304 } 316 }
305 317
306 delete dlg; 318 delete dlg;
307 return addressee; 319 return addressee;
308} 320}
309 321
310Addressee::List AddresseeDialog::getAddressees( QWidget *parent ) 322Addressee::List AddresseeDialog::getAddressees( QWidget *parent )
311{ 323{
312 AddresseeDialog *dlg = new AddresseeDialog( parent, true ); 324 AddresseeDialog *dlg = new AddresseeDialog( parent, true );
313 Addressee::List addressees; 325 Addressee::List addressees;
314 static int geoX = 0; 326 static int geoX = 0;
315 static int geoY = 0; 327 static int geoY = 0;
316 static int geoW = 0; 328 static int geoW = 0;
317 static int geoH = 0; 329 static int geoH = 0;
318 if ( QApplication::desktop()->width() <= 640 ) 330 if ( QApplication::desktop()->width() <= 640 )
319 dlg->showMaximized(); 331 dlg->showMaximized();
320 else { 332 else {
321 if ( !geoX && ! geoY && !geoW &&!geoH ) { 333 if ( !geoX && ! geoY && !geoW &&!geoH ) {
322 geoX = dlg->geometry().x(); 334 geoX = dlg->geometry().x();
323 geoY = dlg->geometry().y(); 335 geoY = dlg->geometry().y();
324 geoW = dlg->width(); 336 geoW = dlg->width();
325 geoH = dlg->height(); 337 geoH = dlg->height();
326 } else { 338 } else {
327 dlg->show(); 339 dlg->show();
328 dlg->setGeometry(geoX , geoY,geoW , geoH ); 340 dlg->setGeometry(geoX , geoY,geoW , geoH );
329 341
330 } 342 }
331 } 343 }
332 int result = dlg->exec(); 344 int result = dlg->exec();
333 geoX = dlg->geometry().x(); 345 geoX = dlg->geometry().x();
334 geoY = dlg->geometry().y(); 346 geoY = dlg->geometry().y();
335 geoW = dlg->width(); 347 geoW = dlg->width();
336 geoH = dlg->height(); 348 geoH = dlg->height();
337 if ( result == QDialog::Accepted ) { 349 if ( result == QDialog::Accepted ) {
338 addressees = dlg->addressees(); 350 addressees = dlg->addressees();
339 } 351 }
340 352
341 delete dlg; 353 delete dlg;
342 return addressees; 354 return addressees;
343} 355}
344 356
345void AddresseeDialog::addressBookChanged() 357void AddresseeDialog::addressBookChanged()
346{ 358{
347 loadAddressBook(); 359 loadAddressBook();
348} 360}
diff --git a/kabc/addresseedialog.h b/kabc/addresseedialog.h
index 99c74bd..6fab62d 100644
--- a/kabc/addresseedialog.h
+++ b/kabc/addresseedialog.h
@@ -1,161 +1,161 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#ifndef KABC_ADDRESSEEDIALOG_H 21#ifndef KABC_ADDRESSEEDIALOG_H
22#define KABC_ADDRESSEEDIALOG_H 22#define KABC_ADDRESSEEDIALOG_H
23 23
24#include <qdict.h> 24#include <qdict.h>
25 25
26#include <kdialogbase.h> 26#include <kdialogbase.h>
27#include <klineedit.h> 27#include <klineedit.h>
28#include <klistview.h> 28#include <klistview.h>
29 29
30#include "addressbook.h" 30#include "addressbook.h"
31 31
32namespace KABC { 32namespace KABC {
33 33
34/** 34/**
35 @short Special ListViewItem, that is used by the AddresseeDialog. 35 @short Special ListViewItem, that is used by the AddresseeDialog.
36*/ 36*/
37class AddresseeItem : public QListViewItem 37class AddresseeItem : public QListViewItem
38{ 38{
39 public: 39 public:
40 40
41 /** 41 /**
42 Type of column 42 Type of column
43 @li @p Name - Name in Addressee 43 @li @p Name - Name in Addressee
44 @li @p Email - Email in Addressee 44 @li @p Email - Email in Addressee
45 */ 45 */
46 enum columns { Name = 0, Email = 1 }; 46 enum columns { Name = 0, Email = 1,Category = 2 };
47 47
48 /** 48 /**
49 Constructor. 49 Constructor.
50 50
51 @param parent The parent listview. 51 @param parent The parent listview.
52 @param addressee The associated addressee. 52 @param addressee The associated addressee.
53 */ 53 */
54 AddresseeItem( QListView *parent, const Addressee &addressee ); 54 AddresseeItem( QListView *parent, const Addressee &addressee );
55 55
56 /** 56 /**
57 Returns the addressee. 57 Returns the addressee.
58 */ 58 */
59 Addressee addressee() const { return mAddressee; } 59 Addressee addressee() const { return mAddressee; }
60 60
61 /** 61 /**
62 Method used by QListView to sort the items. 62 Method used by QListView to sort the items.
63 */ 63 */
64 virtual QString key( int column, bool ascending ) const; 64 virtual QString key( int column, bool ascending ) const;
65 65
66 private: 66 private:
67 Addressee mAddressee; 67 Addressee mAddressee;
68}; 68};
69 69
70/** 70/**
71 @short Dialog for selecting address book entries. 71 @short Dialog for selecting address book entries.
72 72
73 This class provides a dialog for selecting entries from the standard KDE 73 This class provides a dialog for selecting entries from the standard KDE
74 address book. Use the getAddressee() function to open a modal dialog, 74 address book. Use the getAddressee() function to open a modal dialog,
75 returning an address book entry. 75 returning an address book entry.
76 76
77 In the dialog you can select an entry from the list with the mouse or type in 77 In the dialog you can select an entry from the list with the mouse or type in
78 the first letters of the name or email address you are searching for. The 78 the first letters of the name or email address you are searching for. The
79 entry matching best is automatically selected. Use double click, pressing 79 entry matching best is automatically selected. Use double click, pressing
80 return or pressing the ok button to return the selected addressee to the 80 return or pressing the ok button to return the selected addressee to the
81 application. 81 application.
82*/ 82*/
83class AddresseeDialog : public KDialogBase 83class AddresseeDialog : public KDialogBase
84{ 84{
85 Q_OBJECT 85 Q_OBJECT
86 86
87 public: 87 public:
88 /** 88 /**
89 Construct addressbook entry select dialog. 89 Construct addressbook entry select dialog.
90 90
91 @param parent parent widget 91 @param parent parent widget
92 */ 92 */
93 AddresseeDialog( QWidget *parent=0, bool multiple=false ); 93 AddresseeDialog( QWidget *parent=0, bool multiple=false );
94 94
95 /** 95 /**
96 Destructor. 96 Destructor.
97 */ 97 */
98 virtual ~AddresseeDialog(); 98 virtual ~AddresseeDialog();
99 99
100 /** 100 /**
101 Return the address chosen. 101 Return the address chosen.
102 102
103 If it is a multiple select, this will return only the first address chosen 103 If it is a multiple select, this will return only the first address chosen
104 */ 104 */
105 Addressee addressee(); 105 Addressee addressee();
106 106
107 /** 107 /**
108 Return the list of addresses chosen 108 Return the list of addresses chosen
109 */ 109 */
110 Addressee::List addressees(); 110 Addressee::List addressees();
111 111
112 /** 112 /**
113 Select a single address book entry. 113 Select a single address book entry.
114 114
115 Open addressee select dialog and return the entry selected by the user. 115 Open addressee select dialog and return the entry selected by the user.
116 If the user doesn't select an entry or presses cancel, the returned 116 If the user doesn't select an entry or presses cancel, the returned
117 addressee is empty. 117 addressee is empty.
118 */ 118 */
119 static Addressee getAddressee( QWidget *parent ); 119 static Addressee getAddressee( QWidget *parent );
120 120
121 /** 121 /**
122 Select multiple address book entries. 122 Select multiple address book entries.
123 123
124 Open addressee select dialog and return the entries selected by the user. 124 Open addressee select dialog and return the entries selected by the user.
125 If the user doesn't select an entry or presses cancel, the returned 125 If the user doesn't select an entry or presses cancel, the returned
126 addressee list is empty. 126 addressee list is empty.
127 */ 127 */
128 static Addressee::List getAddressees( QWidget *parent ); 128 static Addressee::List getAddressees( QWidget *parent );
129 129
130 private slots: 130 private slots:
131 void selectItem( const QString & ); 131 void selectItem( const QString & );
132 void selectNextItem( QListViewItem *item ); 132 void selectNextItem( QListViewItem *item );
133 void updateEdit( QListViewItem *item ); 133 void updateEdit( QListViewItem *item );
134 void addSelected( QListViewItem *item ); 134 void addSelected( QListViewItem *item );
135 void removeSelected(); 135 void removeSelected();
136 void loadAddressBook(); 136 void loadAddressBook();
137 137
138 protected slots: 138 protected slots:
139 void addressBookChanged(); 139 void addressBookChanged();
140 140
141 private: 141 private:
142 void addCompletionItem( const QString &str, QListViewItem *item ); 142 void addCompletionItem( const QString &str, QListViewItem *item );
143 143
144 bool mMultiple; 144 bool mMultiple;
145 145
146 KListView *mAddresseeList; 146 KListView *mAddresseeList;
147 QLineEdit *mAddresseeEdit; 147 QLineEdit *mAddresseeEdit;
148 148
149 KListView *mSelectedList; 149 KListView *mSelectedList;
150 150
151 AddressBook *mAddressBook; 151 AddressBook *mAddressBook;
152 152
153 QDict<QListViewItem> mItemDict; 153 QDict<QListViewItem> mItemDict;
154 QDict<QListViewItem> mSelectedDict; 154 QDict<QListViewItem> mSelectedDict;
155 155
156 class AddresseeDialogPrivate; 156 class AddresseeDialogPrivate;
157 AddresseeDialogPrivate *d; 157 AddresseeDialogPrivate *d;
158}; 158};
159 159
160} 160}
161#endif 161#endif