summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-03-29 18:35:10 (UTC)
committer zautrix <zautrix>2005-03-29 18:35:10 (UTC)
commitb70d9695bb6a2d567b75965c0530792ad90c84a3 (patch) (unidiff)
treebc27647d044cf4a8d9c75acd19d9a2d078fe00b2 /kaddressbook
parenta7c827aa0e555206b60dec3bc07f7afab4352883 (diff)
downloadkdepimpi-b70d9695bb6a2d567b75965c0530792ad90c84a3.zip
kdepimpi-b70d9695bb6a2d567b75965c0530792ad90c84a3.tar.gz
kdepimpi-b70d9695bb6a2d567b75965c0530792ad90c84a3.tar.bz2
icons
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditordialog.cpp2
-rw-r--r--kaddressbook/kabcore.cpp1
2 files changed, 2 insertions, 1 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp
index a84fc61..b5a60f2 100644
--- a/kaddressbook/addresseeeditordialog.cpp
+++ b/kaddressbook/addresseeeditordialog.cpp
@@ -1,123 +1,123 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qapplication.h> 25#include <qapplication.h>
26 26
27#include <kdebug.h> 27#include <kdebug.h>
28#include <klocale.h> 28#include <klocale.h>
29#include <kglobal.h> 29#include <kglobal.h>
30 30
31#include "addresseeeditorwidget.h" 31#include "addresseeeditorwidget.h"
32#include "kabcore.h" 32#include "kabcore.h"
33 33
34#include "addresseeeditordialog.h" 34#include "addresseeeditordialog.h"
35 35
36AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, 36AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent,
37 const char *name ) 37 const char *name )
38 : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), 38 : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ),
39 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, 39 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply,
40 KDialogBase::Ok, parent, name, true ) 40 KDialogBase::Ok, parent, name, true )
41{ 41{
42 42
43 43
44 QWidget *page = plainPage(); 44 QWidget *page = plainPage();
45 45
46 QVBoxLayout *layout = new QVBoxLayout( page ); 46 QVBoxLayout *layout = new QVBoxLayout( page );
47 47
48 mEditorWidget = new AddresseeEditorWidget( core, false, page ); 48 mEditorWidget = new AddresseeEditorWidget( core, false, page );
49 connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), 49 connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ),
50 SLOT( widgetModified() ) ); 50 SLOT( widgetModified() ) );
51 layout->addWidget( mEditorWidget ); 51 layout->addWidget( mEditorWidget );
52 52
53 enableButton( KDialogBase::Apply, false ); 53 enableButton( KDialogBase::Apply, false );
54 if ( QApplication::desktop()->width() < 480 ) { 54 if ( QApplication::desktop()->width() < 480 ) {
55 hideButtons(); 55 hideButtons();
56 } 56 }
57} 57}
58 58
59AddresseeEditorDialog::~AddresseeEditorDialog() 59AddresseeEditorDialog::~AddresseeEditorDialog()
60{ 60{
61 //emit editorDestroyed( mEditorWidget->addressee().uid() ); 61 //emit editorDestroyed( mEditorWidget->addressee().uid() );
62} 62}
63 63
64void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) 64void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr )
65{ 65{
66 enableButton( KDialogBase::Apply, false ); 66 enableButton( KDialogBase::Apply, false );
67 67
68 mEditorWidget->setAddressee( addr ); 68 mEditorWidget->setAddressee( addr );
69 69
70 this->setCaption("Edit " + addr.formattedName()); 70 this->setCaption(i18n ("Edit ") + addr.formattedName());
71} 71}
72 72
73KABC::Addressee AddresseeEditorDialog::addressee() 73KABC::Addressee AddresseeEditorDialog::addressee()
74{ 74{
75 return mEditorWidget->addressee(); 75 return mEditorWidget->addressee();
76} 76}
77 77
78bool AddresseeEditorDialog::dirty() 78bool AddresseeEditorDialog::dirty()
79{ 79{
80 return mEditorWidget->dirty(); 80 return mEditorWidget->dirty();
81} 81}
82 82
83void AddresseeEditorDialog::slotApply() 83void AddresseeEditorDialog::slotApply()
84{ 84{
85 if ( mEditorWidget->dirty() ) { 85 if ( mEditorWidget->dirty() ) {
86 mEditorWidget->save(); 86 mEditorWidget->save();
87 emit contactModified( mEditorWidget->addressee() ); 87 emit contactModified( mEditorWidget->addressee() );
88 } 88 }
89 89
90 enableButton( KDialogBase::Apply, false ); 90 enableButton( KDialogBase::Apply, false );
91 91
92 KDialogBase::slotApply(); 92 KDialogBase::slotApply();
93} 93}
94 94
95void AddresseeEditorDialog:: accept () 95void AddresseeEditorDialog:: accept ()
96{ 96{
97 slotOk(); 97 slotOk();
98 98
99} 99}
100void AddresseeEditorDialog::slotOk() 100void AddresseeEditorDialog::slotOk()
101{ 101{
102 slotApply(); 102 slotApply();
103 103
104 //KDialogBase::slotOk(); 104 //KDialogBase::slotOk();
105 emit okClicked(); 105 emit okClicked();
106 QDialog::accept(); 106 QDialog::accept();
107} 107}
108 108
109void AddresseeEditorDialog::widgetModified() 109void AddresseeEditorDialog::widgetModified()
110{ 110{
111 enableButton( KDialogBase::Apply, true ); 111 enableButton( KDialogBase::Apply, true );
112} 112}
113 113
114void AddresseeEditorDialog::slotCancel() 114void AddresseeEditorDialog::slotCancel()
115{ 115{
116 KDialogBase::slotCancel(); 116 KDialogBase::slotCancel();
117 117
118 118
119} 119}
120 120
121#ifndef KAB_EMBEDDED 121#ifndef KAB_EMBEDDED
122#include "addresseeeditordialog.moc" 122#include "addresseeeditordialog.moc"
123#endif //KAB_EMBEDDED 123#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 3f9b546..e1a490d 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1167,192 +1167,193 @@ void KABCore::incrementalSearch( const QString& text )
1167{ 1167{
1168 QString stext; 1168 QString stext;
1169 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1169 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1170 stext = "*" + text; 1170 stext = "*" + text;
1171 } else { 1171 } else {
1172 stext = text; 1172 stext = text;
1173 } 1173 }
1174 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1174 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1175} 1175}
1176 1176
1177void KABCore::setModified() 1177void KABCore::setModified()
1178{ 1178{
1179 setModified( true ); 1179 setModified( true );
1180} 1180}
1181 1181
1182void KABCore::setModifiedWOrefresh() 1182void KABCore::setModifiedWOrefresh()
1183{ 1183{
1184 // qDebug("KABCore::setModifiedWOrefresh() "); 1184 // qDebug("KABCore::setModifiedWOrefresh() ");
1185 mModified = true; 1185 mModified = true;
1186 mActionSave->setEnabled( mModified ); 1186 mActionSave->setEnabled( mModified );
1187 1187
1188 1188
1189} 1189}
1190void KABCore::setModified( bool modified ) 1190void KABCore::setModified( bool modified )
1191{ 1191{
1192 mModified = modified; 1192 mModified = modified;
1193 mActionSave->setEnabled( mModified ); 1193 mActionSave->setEnabled( mModified );
1194 1194
1195 if ( modified ) 1195 if ( modified )
1196 mJumpButtonBar->recreateButtons(); 1196 mJumpButtonBar->recreateButtons();
1197 1197
1198 mViewManager->refreshView(); 1198 mViewManager->refreshView();
1199 1199
1200} 1200}
1201 1201
1202bool KABCore::modified() const 1202bool KABCore::modified() const
1203{ 1203{
1204 return mModified; 1204 return mModified;
1205} 1205}
1206 1206
1207void KABCore::contactModified( const KABC::Addressee &addr ) 1207void KABCore::contactModified( const KABC::Addressee &addr )
1208{ 1208{
1209 addrModified( addr ); 1209 addrModified( addr );
1210#if 0 // debug only 1210#if 0 // debug only
1211 KABC::Addressee ad = addr; 1211 KABC::Addressee ad = addr;
1212 ad.computeCsum( "123"); 1212 ad.computeCsum( "123");
1213#endif 1213#endif
1214} 1214}
1215 1215
1216void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1216void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1217{ 1217{
1218 1218
1219 Command *command = 0; 1219 Command *command = 0;
1220 QString uid; 1220 QString uid;
1221 1221
1222 // check if it exists already 1222 // check if it exists already
1223 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1223 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1224 if ( origAddr.isEmpty() ) 1224 if ( origAddr.isEmpty() )
1225 command = new PwNewCommand( mAddressBook, addr ); 1225 command = new PwNewCommand( mAddressBook, addr );
1226 else { 1226 else {
1227 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1227 command = new PwEditCommand( mAddressBook, origAddr, addr );
1228 uid = addr.uid(); 1228 uid = addr.uid();
1229 } 1229 }
1230 1230
1231 UndoStack::instance()->push( command ); 1231 UndoStack::instance()->push( command );
1232 RedoStack::instance()->clear(); 1232 RedoStack::instance()->clear();
1233 if ( updateDetails ) 1233 if ( updateDetails )
1234 mDetails->setAddressee( addr ); 1234 mDetails->setAddressee( addr );
1235 setModified( true ); 1235 setModified( true );
1236} 1236}
1237 1237
1238void KABCore::newContact() 1238void KABCore::newContact()
1239{ 1239{
1240 1240
1241 1241
1242 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1242 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1243 1243
1244 QPtrList<KRES::Resource> kresResources; 1244 QPtrList<KRES::Resource> kresResources;
1245 QPtrListIterator<KABC::Resource> it( kabcResources ); 1245 QPtrListIterator<KABC::Resource> it( kabcResources );
1246 KABC::Resource *resource; 1246 KABC::Resource *resource;
1247 while ( ( resource = it.current() ) != 0 ) { 1247 while ( ( resource = it.current() ) != 0 ) {
1248 ++it; 1248 ++it;
1249 if ( !resource->readOnly() ) { 1249 if ( !resource->readOnly() ) {
1250 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1250 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1251 if ( res ) 1251 if ( res )
1252 kresResources.append( res ); 1252 kresResources.append( res );
1253 } 1253 }
1254 } 1254 }
1255 1255
1256 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1256 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1257 resource = static_cast<KABC::Resource*>( res ); 1257 resource = static_cast<KABC::Resource*>( res );
1258 1258
1259 if ( resource ) { 1259 if ( resource ) {
1260 KABC::Addressee addr; 1260 KABC::Addressee addr;
1261 addr.setResource( resource ); 1261 addr.setResource( resource );
1262 mEditorDialog->setAddressee( addr ); 1262 mEditorDialog->setAddressee( addr );
1263 mEditorDialog->setCaption( i18n("Edit new contact"));
1263 KApplication::execDialog ( mEditorDialog ); 1264 KApplication::execDialog ( mEditorDialog );
1264 1265
1265 } else 1266 } else
1266 return; 1267 return;
1267 1268
1268 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1269 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1269 1270
1270 1271
1271} 1272}
1272 1273
1273void KABCore::addEmail( QString aStr ) 1274void KABCore::addEmail( QString aStr )
1274{ 1275{
1275#ifndef KAB_EMBEDDED 1276#ifndef KAB_EMBEDDED
1276 QString fullName, email; 1277 QString fullName, email;
1277 1278
1278 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1279 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1279 1280
1280 // Try to lookup the addressee matching the email address 1281 // Try to lookup the addressee matching the email address
1281 bool found = false; 1282 bool found = false;
1282 QStringList emailList; 1283 QStringList emailList;
1283 KABC::AddressBook::Iterator it; 1284 KABC::AddressBook::Iterator it;
1284 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1285 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1285 emailList = (*it).emails(); 1286 emailList = (*it).emails();
1286 if ( emailList.contains( email ) > 0 ) { 1287 if ( emailList.contains( email ) > 0 ) {
1287 found = true; 1288 found = true;
1288 (*it).setNameFromString( fullName ); 1289 (*it).setNameFromString( fullName );
1289 editContact( (*it).uid() ); 1290 editContact( (*it).uid() );
1290 } 1291 }
1291 } 1292 }
1292 1293
1293 if ( !found ) { 1294 if ( !found ) {
1294 KABC::Addressee addr; 1295 KABC::Addressee addr;
1295 addr.setNameFromString( fullName ); 1296 addr.setNameFromString( fullName );
1296 addr.insertEmail( email, true ); 1297 addr.insertEmail( email, true );
1297 1298
1298 mAddressBook->insertAddressee( addr ); 1299 mAddressBook->insertAddressee( addr );
1299 mViewManager->refreshView( addr.uid() ); 1300 mViewManager->refreshView( addr.uid() );
1300 editContact( addr.uid() ); 1301 editContact( addr.uid() );
1301 } 1302 }
1302#else //KAB_EMBEDDED 1303#else //KAB_EMBEDDED
1303 qDebug("KABCore::addEmail finsih method"); 1304 qDebug("KABCore::addEmail finsih method");
1304#endif //KAB_EMBEDDED 1305#endif //KAB_EMBEDDED
1305} 1306}
1306 1307
1307void KABCore::importVCard( const KURL &url, bool showPreview ) 1308void KABCore::importVCard( const KURL &url, bool showPreview )
1308{ 1309{
1309 mXXPortManager->importVCard( url, showPreview ); 1310 mXXPortManager->importVCard( url, showPreview );
1310} 1311}
1311void KABCore::importFromOL() 1312void KABCore::importFromOL()
1312{ 1313{
1313#ifdef _OL_IMPORT_ 1314#ifdef _OL_IMPORT_
1314 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1315 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1315 idgl->exec(); 1316 idgl->exec();
1316 KABC::Addressee::List list = idgl->getAddressList(); 1317 KABC::Addressee::List list = idgl->getAddressList();
1317 if ( list.count() > 0 ) { 1318 if ( list.count() > 0 ) {
1318 KABC::Addressee::List listNew; 1319 KABC::Addressee::List listNew;
1319 KABC::Addressee::List listExisting; 1320 KABC::Addressee::List listExisting;
1320 KABC::Addressee::List::Iterator it; 1321 KABC::Addressee::List::Iterator it;
1321 KABC::AddressBook::Iterator iter; 1322 KABC::AddressBook::Iterator iter;
1322 for ( it = list.begin(); it != list.end(); ++it ) { 1323 for ( it = list.begin(); it != list.end(); ++it ) {
1323 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1324 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1324 listNew.append( (*it) ); 1325 listNew.append( (*it) );
1325 else 1326 else
1326 listExisting.append( (*it) ); 1327 listExisting.append( (*it) );
1327 } 1328 }
1328 if ( listExisting.count() > 0 ) 1329 if ( listExisting.count() > 0 )
1329 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1330 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1330 if ( listNew.count() > 0 ) { 1331 if ( listNew.count() > 0 ) {
1331 pasteWithNewUid = false; 1332 pasteWithNewUid = false;
1332 pasteContacts( listNew ); 1333 pasteContacts( listNew );
1333 pasteWithNewUid = true; 1334 pasteWithNewUid = true;
1334 } 1335 }
1335 } 1336 }
1336 delete idgl; 1337 delete idgl;
1337#endif 1338#endif
1338} 1339}
1339 1340
1340void KABCore::importVCard( const QString &vCard, bool showPreview ) 1341void KABCore::importVCard( const QString &vCard, bool showPreview )
1341{ 1342{
1342 mXXPortManager->importVCard( vCard, showPreview ); 1343 mXXPortManager->importVCard( vCard, showPreview );
1343} 1344}
1344 1345
1345//US added a second method without defaultparameter 1346//US added a second method without defaultparameter
1346void KABCore::editContact2() { 1347void KABCore::editContact2() {
1347 editContact( QString::null ); 1348 editContact( QString::null );
1348} 1349}
1349 1350
1350void KABCore::editContact( const QString &uid ) 1351void KABCore::editContact( const QString &uid )
1351{ 1352{
1352 1353
1353 if ( mExtensionManager->isQuickEditVisible() ) 1354 if ( mExtensionManager->isQuickEditVisible() )
1354 return; 1355 return;
1355 1356
1356 // First, locate the contact entry 1357 // First, locate the contact entry
1357 QString localUID = uid; 1358 QString localUID = uid;
1358 if ( localUID.isNull() ) { 1359 if ( localUID.isNull() ) {