summaryrefslogtreecommitdiffstats
path: root/kaddressbook
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kaddressbook
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kaddressbook')
-rw-r--r--kaddressbook/HACKING100
-rw-r--r--kaddressbook/Makefile.am96
-rw-r--r--kaddressbook/TODO65
-rw-r--r--kaddressbook/addresseditwidget.cpp678
-rw-r--r--kaddressbook/addresseditwidget.h154
-rw-r--r--kaddressbook/addresseeconfig.cpp99
-rw-r--r--kaddressbook/addresseeconfig.h56
-rw-r--r--kaddressbook/addresseeeditorbase.cpp24
-rw-r--r--kaddressbook/addresseeeditorbase.h59
-rw-r--r--kaddressbook/addresseeeditordialog.cpp153
-rw-r--r--kaddressbook/addresseeeditordialog.h65
-rw-r--r--kaddressbook/addresseeeditorextension.cpp76
-rw-r--r--kaddressbook/addresseeeditorextension.h59
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp909
-rw-r--r--kaddressbook/addresseeeditorwidget.h167
-rw-r--r--kaddressbook/addresseeutil.cpp55
-rw-r--r--kaddressbook/addresseeutil.h66
-rw-r--r--kaddressbook/addviewdialog.cpp110
-rw-r--r--kaddressbook/addviewdialog.h73
-rw-r--r--kaddressbook/advancedcustomfields.cpp148
-rw-r--r--kaddressbook/advancedcustomfields.h60
-rw-r--r--kaddressbook/common/Makefile.am12
-rw-r--r--kaddressbook/common/filter.cpp219
-rw-r--r--kaddressbook/common/filter.h160
-rw-r--r--kaddressbook/common/kabprefs.cpp82
-rw-r--r--kaddressbook/common/kabprefs.h86
-rw-r--r--kaddressbook/common/kabprefs_base.kcfgc11
-rw-r--r--kaddressbook/common/kaddressbook.kcfg93
-rw-r--r--kaddressbook/common/locationmap.cpp96
-rw-r--r--kaddressbook/common/locationmap.h51
-rw-r--r--kaddressbook/contacteditorwidgetmanager.cpp217
-rw-r--r--kaddressbook/contacteditorwidgetmanager.h113
-rw-r--r--kaddressbook/csv-templates/Makefile.am2
-rw-r--r--kaddressbook/csv-templates/README49
-rw-r--r--kaddressbook/csv-templates/kaddressbook.desktop83
-rw-r--r--kaddressbook/csv-templates/outlook2000.desktop109
-rw-r--r--kaddressbook/csv-templates/yahoo.desktop105
-rw-r--r--kaddressbook/customfieldswidget.cpp535
-rw-r--r--kaddressbook/customfieldswidget.h162
-rw-r--r--kaddressbook/dcopaddressbook.desktop60
-rw-r--r--kaddressbook/distributionlisteditor.cpp284
-rw-r--r--kaddressbook/distributionlisteditor.h62
-rw-r--r--kaddressbook/distributionlisteditor_p.h83
-rw-r--r--kaddressbook/distributionlistentryview.cpp140
-rw-r--r--kaddressbook/distributionlistentryview.h58
-rw-r--r--kaddressbook/distributionlistpicker.cpp142
-rw-r--r--kaddressbook/distributionlistpicker.h69
-rw-r--r--kaddressbook/editors/Makefile.am32
-rw-r--r--kaddressbook/editors/cryptosettings.desktop56
-rw-r--r--kaddressbook/editors/cryptowidget.cpp227
-rw-r--r--kaddressbook/editors/cryptowidget.h71
-rw-r--r--kaddressbook/editors/icons/Makefile.am3
-rw-r--r--kaddressbook/editors/icons/cr16-app-aim_protocol.pngbin0 -> 708 bytes
-rw-r--r--kaddressbook/editors/icons/cr16-app-gadu_protocol.pngbin0 -> 944 bytes
-rw-r--r--kaddressbook/editors/icons/cr16-app-groupwise_protocol.pngbin0 -> 515 bytes
-rw-r--r--kaddressbook/editors/icons/cr16-app-icq_protocol.pngbin0 -> 1103 bytes
-rw-r--r--kaddressbook/editors/icons/cr16-app-irc_protocol.pngbin0 -> 812 bytes
-rw-r--r--kaddressbook/editors/icons/cr16-app-jabber_protocol.pngbin0 -> 877 bytes
-rw-r--r--kaddressbook/editors/icons/cr16-app-meanwhile_protocol.pngbin0 -> 800 bytes
-rw-r--r--kaddressbook/editors/icons/cr16-app-msn_protocol.pngbin0 -> 943 bytes
-rw-r--r--kaddressbook/editors/icons/cr16-app-skype_protocol.pngbin0 -> 943 bytes
-rw-r--r--kaddressbook/editors/icons/cr16-app-sms_protocol.pngbin0 -> 1039 bytes
-rw-r--r--kaddressbook/editors/icons/cr16-app-yahoo_protocol.pngbin0 -> 975 bytes
-rw-r--r--kaddressbook/editors/imaddressbase.ui89
-rw-r--r--kaddressbook/editors/imaddresseditor.desktop104
-rw-r--r--kaddressbook/editors/imaddresswidget.cpp137
-rw-r--r--kaddressbook/editors/imaddresswidget.h74
-rw-r--r--kaddressbook/editors/imeditorbase.ui164
-rw-r--r--kaddressbook/editors/imeditorwidget.cpp491
-rw-r--r--kaddressbook/editors/imeditorwidget.h128
-rw-r--r--kaddressbook/editors/kaddressbookimprotocol.desktop57
-rw-r--r--kaddressbook/editors/protocols/Makefile.am6
-rw-r--r--kaddressbook/editors/protocols/aimprotocol.desktop63
-rw-r--r--kaddressbook/editors/protocols/gaduprotocol.desktop63
-rw-r--r--kaddressbook/editors/protocols/groupwiseprotocol.desktop44
-rw-r--r--kaddressbook/editors/protocols/icqprotocol.desktop61
-rw-r--r--kaddressbook/editors/protocols/ircprotocol.desktop31
-rw-r--r--kaddressbook/editors/protocols/jabberprotocol.desktop63
-rw-r--r--kaddressbook/editors/protocols/meanwhileprotocol.desktop61
-rw-r--r--kaddressbook/editors/protocols/msnprotocol.desktop34
-rw-r--r--kaddressbook/editors/protocols/skypeprotocol.desktop53
-rw-r--r--kaddressbook/editors/protocols/smsprotocol.desktop64
-rw-r--r--kaddressbook/editors/protocols/yahooprotocol.desktop66
-rw-r--r--kaddressbook/emaileditwidget.cpp352
-rw-r--r--kaddressbook/emaileditwidget.h99
-rw-r--r--kaddressbook/extensionmanager.cpp256
-rw-r--r--kaddressbook/extensionmanager.h118
-rw-r--r--kaddressbook/features/Makefile.am36
-rw-r--r--kaddressbook/features/distributionlist.desktop116
-rw-r--r--kaddressbook/features/distributionlistng.desktop86
-rw-r--r--kaddressbook/features/distributionlistngwidget.cpp249
-rw-r--r--kaddressbook/features/distributionlistngwidget.h104
-rw-r--r--kaddressbook/features/distributionlistwidget.cpp673
-rw-r--r--kaddressbook/features/distributionlistwidget.h140
-rw-r--r--kaddressbook/features/resourceselection.cpp421
-rw-r--r--kaddressbook/features/resourceselection.desktop110
-rw-r--r--kaddressbook/features/resourceselection.h81
-rw-r--r--kaddressbook/filtereditdialog.cpp279
-rw-r--r--kaddressbook/filtereditdialog.h96
-rw-r--r--kaddressbook/filterselectionwidget.cpp65
-rw-r--r--kaddressbook/filterselectionwidget.h56
-rw-r--r--kaddressbook/freebusywidget.cpp78
-rw-r--r--kaddressbook/freebusywidget.h61
-rw-r--r--kaddressbook/geowidget.cpp562
-rw-r--r--kaddressbook/geowidget.h159
-rw-r--r--kaddressbook/hi128-app-kaddressbook.pngbin0 -> 12214 bytes
-rw-r--r--kaddressbook/hi16-app-kaddressbook.pngbin0 -> 784 bytes
-rw-r--r--kaddressbook/hi32-app-kaddressbook.pngbin0 -> 1947 bytes
-rw-r--r--kaddressbook/hi48-app-kaddressbook.pngbin0 -> 3322 bytes
-rw-r--r--kaddressbook/hi64-app-kaddressbook.pngbin0 -> 4842 bytes
-rw-r--r--kaddressbook/imagewidget.cpp325
-rw-r--r--kaddressbook/imagewidget.h153
-rw-r--r--kaddressbook/imeditwidget.cpp145
-rw-r--r--kaddressbook/imeditwidget.h75
-rw-r--r--kaddressbook/incsearchwidget.cpp171
-rw-r--r--kaddressbook/incsearchwidget.h88
-rw-r--r--kaddressbook/interfaces/Makefile.am18
-rw-r--r--kaddressbook/interfaces/configurewidget.cpp53
-rw-r--r--kaddressbook/interfaces/configurewidget.h72
-rw-r--r--kaddressbook/interfaces/contacteditorwidget.cpp60
-rw-r--r--kaddressbook/interfaces/contacteditorwidget.h143
-rw-r--r--kaddressbook/interfaces/core.cpp33
-rw-r--r--kaddressbook/interfaces/core.h203
-rw-r--r--kaddressbook/interfaces/extensionwidget.cpp68
-rw-r--r--kaddressbook/interfaces/extensionwidget.h120
-rw-r--r--kaddressbook/interfaces/kaddressbook_contacteditorwidget.desktop55
-rw-r--r--kaddressbook/interfaces/kaddressbook_extension.desktop59
-rw-r--r--kaddressbook/interfaces/kaddressbook_xxport.desktop62
-rw-r--r--kaddressbook/interfaces/xxport.cpp128
-rw-r--r--kaddressbook/interfaces/xxport.h179
-rw-r--r--kaddressbook/jumpbuttonbar.cpp239
-rw-r--r--kaddressbook/jumpbuttonbar.h79
-rw-r--r--kaddressbook/kabcore.cpp1647
-rw-r--r--kaddressbook/kabcore.h497
-rw-r--r--kaddressbook/kablock.cpp108
-rw-r--r--kaddressbook/kablock.h58
-rw-r--r--kaddressbook/kabtools.cpp268
-rw-r--r--kaddressbook/kabtools.h45
-rw-r--r--kaddressbook/kaddressbook.desktop82
-rw-r--r--kaddressbook/kaddressbook_options.h43
-rw-r--r--kaddressbook/kaddressbook_part.cpp179
-rw-r--r--kaddressbook/kaddressbook_part.h71
-rw-r--r--kaddressbook/kaddressbook_part.rc112
-rw-r--r--kaddressbook/kaddressbook_view.desktop60
-rw-r--r--kaddressbook/kaddressbookiface.h72
-rw-r--r--kaddressbook/kaddressbookmain.cpp186
-rw-r--r--kaddressbook/kaddressbookmain.h98
-rw-r--r--kaddressbook/kaddressbookservice.cpp41
-rw-r--r--kaddressbook/kaddressbookservice.h56
-rw-r--r--kaddressbook/kaddressbookui.rc116
-rw-r--r--kaddressbook/kaddressbookview.cpp203
-rw-r--r--kaddressbook/kaddressbookview.h314
-rw-r--r--kaddressbook/kcmconfigs/Makefile.am38
-rw-r--r--kaddressbook/kcmconfigs/addhostdialog.cpp127
-rw-r--r--kaddressbook/kcmconfigs/addhostdialog.h54
-rw-r--r--kaddressbook/kcmconfigs/addresseewidget.cpp202
-rw-r--r--kaddressbook/kcmconfigs/addresseewidget.h89
-rw-r--r--kaddressbook/kcmconfigs/extensionconfigdialog.cpp57
-rw-r--r--kaddressbook/kcmconfigs/extensionconfigdialog.h52
-rw-r--r--kaddressbook/kcmconfigs/kabconfig.desktop180
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp223
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.h70
-rw-r--r--kaddressbook/kcmconfigs/kabcustomfields.desktop163
-rw-r--r--kaddressbook/kcmconfigs/kabldapconfig.desktop171
-rw-r--r--kaddressbook/kcmconfigs/kcmkabconfig.cpp78
-rw-r--r--kaddressbook/kcmconfigs/kcmkabconfig.h46
-rw-r--r--kaddressbook/kcmconfigs/kcmkabcustomfields.cpp77
-rw-r--r--kaddressbook/kcmconfigs/kcmkabcustomfields.h43
-rw-r--r--kaddressbook/kcmconfigs/kcmkabldapconfig.cpp79
-rw-r--r--kaddressbook/kcmconfigs/kcmkabldapconfig.h48
-rw-r--r--kaddressbook/kcmconfigs/ldapoptionswidget.cpp303
-rw-r--r--kaddressbook/kcmconfigs/ldapoptionswidget.h71
-rw-r--r--kaddressbook/keywidget.cpp201
-rw-r--r--kaddressbook/keywidget.h65
-rw-r--r--kaddressbook/ldapsearchdialog.cpp634
-rw-r--r--kaddressbook/ldapsearchdialog.h117
-rw-r--r--kaddressbook/main.cpp130
-rw-r--r--kaddressbook/nameeditdialog.cpp321
-rw-r--r--kaddressbook/nameeditdialog.h98
-rw-r--r--kaddressbook/phoneeditwidget.cpp344
-rw-r--r--kaddressbook/phoneeditwidget.h144
-rw-r--r--kaddressbook/pics/Makefile.am5
-rw-r--r--kaddressbook/pics/README6
-rw-r--r--kaddressbook/pics/cr16-action-ldap_lookup.pngbin0 -> 825 bytes
-rw-r--r--kaddressbook/pics/cr16-action-smallcal.pngbin0 -> 506 bytes
-rw-r--r--kaddressbook/pics/cr32-action-homepage.pngbin0 -> 2407 bytes
-rw-r--r--kaddressbook/pics/lo16-action-contact.pngbin0 -> 430 bytes
-rw-r--r--kaddressbook/pics/lo16-action-down.pngbin0 -> 443 bytes
-rw-r--r--kaddressbook/pics/lo16-action-group.pngbin0 -> 658 bytes
-rw-r--r--kaddressbook/pics/lo16-action-up.pngbin0 -> 374 bytes
-rw-r--r--kaddressbook/pics/lo22-action-page.pngbin0 -> 690 bytes
-rw-r--r--kaddressbook/pics/world.jpgbin0 -> 28526 bytes
-rw-r--r--kaddressbook/printing/Makefile.am32
-rw-r--r--kaddressbook/printing/README15
-rw-r--r--kaddressbook/printing/detailed-style.pngbin0 -> 9621 bytes
-rw-r--r--kaddressbook/printing/detailledstyle.cpp291
-rw-r--r--kaddressbook/printing/detailledstyle.h68
-rw-r--r--kaddressbook/printing/ds_appearance.ui479
-rw-r--r--kaddressbook/printing/kabentrypainter.cpp521
-rw-r--r--kaddressbook/printing/kabentrypainter.h133
-rw-r--r--kaddressbook/printing/mike-style.pngbin0 -> 6538 bytes
-rw-r--r--kaddressbook/printing/mikesstyle.cpp262
-rw-r--r--kaddressbook/printing/mikesstyle.h65
-rw-r--r--kaddressbook/printing/printingwizard.cpp220
-rw-r--r--kaddressbook/printing/printingwizard.h115
-rw-r--r--kaddressbook/printing/printprogress.cpp83
-rw-r--r--kaddressbook/printing/printprogress.h67
-rw-r--r--kaddressbook/printing/printsortmode.cpp76
-rw-r--r--kaddressbook/printing/printsortmode.h50
-rw-r--r--kaddressbook/printing/printstyle.cpp130
-rw-r--r--kaddressbook/printing/printstyle.h171
-rw-r--r--kaddressbook/printing/selectionpage.cpp169
-rw-r--r--kaddressbook/printing/selectionpage.h68
-rw-r--r--kaddressbook/printing/stylepage.cpp162
-rw-r--r--kaddressbook/printing/stylepage.h102
-rw-r--r--kaddressbook/searchmanager.cpp198
-rw-r--r--kaddressbook/searchmanager.h110
-rw-r--r--kaddressbook/secrecywidget.cpp72
-rw-r--r--kaddressbook/secrecywidget.h52
-rw-r--r--kaddressbook/simpleaddresseeeditor.cpp129
-rw-r--r--kaddressbook/simpleaddresseeeditor.h65
-rw-r--r--kaddressbook/soundwidget.cpp179
-rw-r--r--kaddressbook/soundwidget.h75
-rw-r--r--kaddressbook/thumbnailcreator/Makefile.am15
-rw-r--r--kaddressbook/thumbnailcreator/ldifvcardcreator.cpp297
-rw-r--r--kaddressbook/thumbnailcreator/ldifvcardcreator.h50
-rw-r--r--kaddressbook/thumbnailcreator/ldifvcardthumbnail.desktop57
-rw-r--r--kaddressbook/typecombo.h177
-rw-r--r--kaddressbook/undocmds.cpp272
-rw-r--r--kaddressbook/undocmds.h130
-rw-r--r--kaddressbook/viewconfigurefieldspage.cpp285
-rw-r--r--kaddressbook/viewconfigurefieldspage.h72
-rw-r--r--kaddressbook/viewconfigurefilterpage.cpp111
-rw-r--r--kaddressbook/viewconfigurefilterpage.h53
-rw-r--r--kaddressbook/viewconfigurewidget.cpp116
-rw-r--r--kaddressbook/viewconfigurewidget.h106
-rw-r--r--kaddressbook/viewmanager.cpp604
-rw-r--r--kaddressbook/viewmanager.h162
-rw-r--r--kaddressbook/views/Makefile.am38
-rw-r--r--kaddressbook/views/cardview.cpp1563
-rw-r--r--kaddressbook/views/cardview.desktop62
-rw-r--r--kaddressbook/views/cardview.h579
-rw-r--r--kaddressbook/views/colorlistbox.cpp193
-rw-r--r--kaddressbook/views/colorlistbox.h71
-rw-r--r--kaddressbook/views/configurecardviewdialog.cpp319
-rw-r--r--kaddressbook/views/configurecardviewdialog.h113
-rw-r--r--kaddressbook/views/configuretableviewdialog.cpp156
-rw-r--r--kaddressbook/views/configuretableviewdialog.h89
-rw-r--r--kaddressbook/views/contactlistview.cpp380
-rw-r--r--kaddressbook/views/contactlistview.h176
-rw-r--r--kaddressbook/views/iconview.desktop76
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp370
-rw-r--r--kaddressbook/views/kaddressbookcardview.h94
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp312
-rw-r--r--kaddressbook/views/kaddressbookiconview.h93
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp384
-rw-r--r--kaddressbook/views/kaddressbooktableview.h115
-rw-r--r--kaddressbook/views/tableview.desktop64
-rw-r--r--kaddressbook/xxport/HACKING38
-rw-r--r--kaddressbook/xxport/Makefile.am64
-rw-r--r--kaddressbook/xxport/bookmark_xxport.cpp72
-rw-r--r--kaddressbook/xxport/bookmark_xxport.desktop103
-rw-r--r--kaddressbook/xxport/bookmark_xxport.h53
-rw-r--r--kaddressbook/xxport/bookmark_xxportui.rc11
-rw-r--r--kaddressbook/xxport/configure.in.bot7
-rw-r--r--kaddressbook/xxport/configure.in.in2
-rw-r--r--kaddressbook/xxport/csv_xxport.cpp129
-rw-r--r--kaddressbook/xxport/csv_xxport.desktop102
-rw-r--r--kaddressbook/xxport/csv_xxport.h46
-rw-r--r--kaddressbook/xxport/csv_xxportui.rc14
-rw-r--r--kaddressbook/xxport/csvimportdialog.cpp962
-rw-r--r--kaddressbook/xxport/csvimportdialog.h124
-rw-r--r--kaddressbook/xxport/dateparser.cpp112
-rw-r--r--kaddressbook/xxport/dateparser.h51
-rw-r--r--kaddressbook/xxport/eudora_xxport.cpp213
-rw-r--r--kaddressbook/xxport/eudora_xxport.desktop104
-rw-r--r--kaddressbook/xxport/eudora_xxport.h49
-rw-r--r--kaddressbook/xxport/eudora_xxportui.rc11
-rw-r--r--kaddressbook/xxport/gnokii_xxport.cpp1609
-rw-r--r--kaddressbook/xxport/gnokii_xxport.desktop103
-rw-r--r--kaddressbook/xxport/gnokii_xxport.h43
-rw-r--r--kaddressbook/xxport/gnokii_xxportui.rc14
-rw-r--r--kaddressbook/xxport/kde2_xxport.cpp79
-rw-r--r--kaddressbook/xxport/kde2_xxport.desktop106
-rw-r--r--kaddressbook/xxport/kde2_xxport.h42
-rw-r--r--kaddressbook/xxport/kde2_xxportui.rc11
-rw-r--r--kaddressbook/xxport/ldif_xxport.cpp140
-rw-r--r--kaddressbook/xxport/ldif_xxport.desktop105
-rw-r--r--kaddressbook/xxport/ldif_xxport.h47
-rw-r--r--kaddressbook/xxport/ldif_xxportui.rc14
-rw-r--r--kaddressbook/xxport/opera_xxport.cpp126
-rw-r--r--kaddressbook/xxport/opera_xxport.desktop103
-rw-r--r--kaddressbook/xxport/opera_xxport.h43
-rw-r--r--kaddressbook/xxport/opera_xxportui.rc11
-rw-r--r--kaddressbook/xxport/pab_mapihd.cpp396
-rw-r--r--kaddressbook/xxport/pab_mapihd.h117
-rw-r--r--kaddressbook/xxport/pab_pablib.cpp333
-rw-r--r--kaddressbook/xxport/pab_pablib.h77
-rw-r--r--kaddressbook/xxport/pab_xxport.cpp71
-rw-r--r--kaddressbook/xxport/pab_xxport.desktop103
-rw-r--r--kaddressbook/xxport/pab_xxport.h217
-rw-r--r--kaddressbook/xxport/pab_xxportui.rc11
-rw-r--r--kaddressbook/xxport/samples/PAB_format.pdfbin0 -> 36137 bytes
-rw-r--r--kaddressbook/xxport/samples/ecdancers.txt193
-rw-r--r--kaddressbook/xxport/samples/netscape.ldif38
-rw-r--r--kaddressbook/xxport/samples/rfc2849.txt1
-rw-r--r--kaddressbook/xxport/vcard_xxport.cpp537
-rw-r--r--kaddressbook/xxport/vcard_xxport.desktop105
-rw-r--r--kaddressbook/xxport/vcard_xxport.h50
-rw-r--r--kaddressbook/xxport/vcard_xxportui.rc15
-rw-r--r--kaddressbook/xxportmanager.cpp159
-rw-r--r--kaddressbook/xxportmanager.h73
-rw-r--r--kaddressbook/xxportselectdialog.cpp251
-rw-r--r--kaddressbook/xxportselectdialog.h84
-rw-r--r--kaddressbook/zone.tab371
315 files changed, 43792 insertions, 0 deletions
diff --git a/kaddressbook/HACKING b/kaddressbook/HACKING
new file mode 100644
index 00000000..b5714e39
--- /dev/null
+++ b/kaddressbook/HACKING
@@ -0,0 +1,100 @@
+Coding Style
+============
+
+See http://korganizer.kde.org/develop/hacking.html for an HTML version.
+
+Formatting
+----------
+
+- No Tabs.
+- Indent with 2 spaces.
+- A line must not have more than 80 chars.
+- Put Spaces between brackets and arguments of functions.
+- For if, else, while and similar statements put the brackets on the same line
+ as the statement.
+- Function and class definitions have their brackets on separate lines.
+
+Example:
+
+void MyClass::myFunction()
+{
+ if ( blah == fasel ) {
+ blubbVariable = arglValue;
+ } else {
+ blubbVariable = oerxValue;
+ }
+}
+
+
+Header Formatting
+-----------------
+
+- General formatting rules apply.
+- Access modifiers are indented.
+- Put curly brackets of class definition on its own line.
+- Double inclusion protection defines are all upper case letters and are
+ composed of the namespace (if available), the classname and a H suffix
+ separated by underscores.
+- Inside a namespace there is no indentation.
+
+Example:
+
+#ifndef XKJ_MYCLASS_H
+#define XKJ_MYCLASS_H
+
+namespace XKJ {
+
+class MyClass
+{
+ public:
+ MyClass();
+
+ private:
+ int mMyInt;
+};
+
+}
+
+#endif
+
+
+API docs
+--------
+
+- Each public function must have a Doxygen compatible comment in the header
+- Use C-style comments without additional asterisks
+- Indent correctly.
+- Comments should be grammatically correct, e.g. sentences start with uppercase
+ letters and end with a full stop.
+- Be concise.
+
+Example:
+
+ /**
+ This function makes tea.
+
+ @param cups number of cups.
+ @result tea
+ */
+ Tea makeTea( int cups );
+
+
+Class and File Names
+--------------------
+
+- Put classes in files, which have the same name as the class, but only
+ lower-case letters.
+- Designer-generated files should have a name classname_base.ui and shoul
+ contain a class called ClassnameBase.
+- Classes inheriting from designer-generated classes have the same name as the
+ generated class, but without the Base suffix.
+
+Class and Variable Names
+------------------------
+
+- For class, variable, function names seperate multiple words by upper-casing
+ the words precedeed by other words.
+- Class names start with an upper-case letter.
+- Function names start with a lower-case letter.
+- Variable names start with a lower-case letter.
+- Member variables of a class start with "m" followed by an upper-case letter.
diff --git a/kaddressbook/Makefile.am b/kaddressbook/Makefile.am
new file mode 100644
index 00000000..fe39a108
--- /dev/null
+++ b/kaddressbook/Makefile.am
@@ -0,0 +1,96 @@
+SUBDIRS = interfaces common printing editors . views features xxport kcmconfigs pics csv-templates \
+ thumbnailcreator
+SRCDOC_DEST = $(kde_htmldir)/en/kaddressbook
+
+
+INCLUDES= -I$(top_srcdir)/kaddressbook/interfaces \
+ -I$(top_srcdir)/kaddressbook/features \
+ -I$(top_srcdir)/kaddressbook/views \
+ -I$(top_srcdir)/kaddressbook/printing \
+ -I$(top_srcdir)/kaddressbook/common \
+ -I$(top_srcdir)/kaddressbook/editors \
+ -I$(top_builddir)/kaddressbook/common \
+ -I$(top_srcdir) \
+ -I$(top_buildir)/kaddressbook/editors \
+ $(all_includes)
+
+bin_PROGRAMS = kaddressbook
+
+kaddressbook_SOURCES = main.cpp kaddressbookmain.cpp
+kaddressbook_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+kaddressbook_LDADD = libkaddressbook.la
+
+kde_module_LTLIBRARIES = libkaddressbookpart.la
+
+libkaddressbookpart_la_SOURCES = kaddressbook_part.cpp
+libkaddressbookpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined
+libkaddressbookpart_la_LIBADD = libkaddressbook.la
+
+lib_LTLIBRARIES = libkaddressbook.la
+libkaddressbook_la_SOURCES = addresseeconfig.cpp addresseeeditordialog.cpp \
+ addresseeeditorwidget.cpp addresseeeditorbase.cpp addresseeeditorextension.cpp addresseeutil.cpp addresseditwidget.cpp \
+ addviewdialog.cpp emaileditwidget.cpp extensionmanager.cpp \
+ filtereditdialog.cpp filterselectionwidget.cpp geowidget.cpp \
+ imagewidget.cpp incsearchwidget.cpp jumpbuttonbar.cpp kabcore.cpp kablock.cpp \
+ kaddressbookiface.skel kaddressbookservice.cpp \
+ kaddressbookview.cpp keywidget.cpp ldapsearchdialog.cpp nameeditdialog.cpp \
+ phoneeditwidget.cpp secrecywidget.cpp soundwidget.cpp \
+ viewconfigurefieldspage.cpp viewconfigurefilterpage.cpp \
+ viewconfigurewidget.cpp undocmds.cpp viewmanager.cpp \
+ xxportmanager.cpp xxportselectdialog.cpp contacteditorwidgetmanager.cpp \
+ simpleaddresseeeditor.cpp advancedcustomfields.cpp customfieldswidget.cpp \
+ freebusywidget.cpp searchmanager.cpp imeditwidget.cpp kabtools.cpp distributionlistpicker.cpp distributionlisteditor.cpp distributionlistentryview.cpp
+libkaddressbook_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
+libkaddressbook_la_LIBADD = $(top_builddir)/kaddressbook/printing/libprinter.la \
+ $(top_builddir)/kaddressbook/interfaces/libkabinterfaces.la \
+ $(top_builddir)/libkdepim/libkdepim.la \
+ $(top_builddir)/libkcal/libkcal.la \
+ -lkabc_file $(LIB_KABC) $(LIB_KHTML) \
+ $(top_builddir)/kaddressbook/common/libkabcommon.la \
+ $(top_builddir)/kaddressbook/editors/libkabim.la \
+ -lkdeprint
+libkaddressbook_la_COMPILE_FIRST = $(top_srcdir)/libkdepim/categoryselectdialog.h \
+ $(top_srcdir)/libkdepim/categoryeditdialog.h \
+ $(top_builddir)/kaddressbook/common/kabprefs_base.h
+
+
+noinst_HEADERS = \
+ addresseditwidget.h addresseeconfig.h \
+ addresseeeditordialog.h addresseeeditorwidget.h addresseeutil.h \
+ addviewdialog.h emaileditwidget.h extensionmanager.h \
+ filtereditdialog.h filterselectionwidget.h geowidget.h imagewidget.h \
+ incsearchwidget.h jumpbuttonbar.h kablock.h kaddressbook_part.h \
+ kaddressbookservice.h kaddressbookview.h keywidget.h \
+ ldapsearchdialog.h nameeditdialog.h phoneeditwidget.h secrecywidget.h \
+ soundwidget.h typecombo.h undocmds.h viewconfigurefieldspage.h \
+ viewconfigurefilterpage.h viewconfigurewidget.h viewmanager.h xxportmanager.h \
+ xxportselectdialog.h advancedcustomfields.h imeditwidget.h
+
+kaddressbook_METASOURCES = AUTO
+
+rcdir = $(kde_datadir)/kaddressbook
+rc_DATA = kaddressbookui.rc kaddressbook_part.rc
+
+kabdatadir = $(kde_datadir)/kaddressbook
+kabdata_DATA = zone.tab
+
+xdg_apps_DATA = kaddressbook.desktop
+
+servicetypedir = $(kde_servicetypesdir)
+servicetype_DATA = kaddressbook_view.desktop dcopaddressbook.desktop
+
+KDE_ICON = kaddressbook
+
+messages: rc.cpp
+ $(EXTRACTRC) --context="Instant messaging" editors/im*.ui >> rc.cpp
+ $(EXTRACTRC) printing/*.ui >> rc.cpp
+ $(EXTRACTRC) */*.kcfg >> rc.cpp
+ $(XGETTEXT) *.h *.cpp common/*.cpp editors/*.cpp features/*.cpp printing/*.cpp views/*.cpp xxport/*.cpp interfaces/*.h -o $(podir)/kaddressbook.pot
+
+srcdoc:
+ $(mkinstalldirs) $(SRCDOC_DEST)
+ kdoc -H -d $(SRCDOC_DEST) kaddressbook $(noinst_HEADERS) -lqt
+
+include $(top_srcdir)/admin/Doxyfile.am
+
+kaddressbook_part.lo: common/kabprefs_base.h
diff --git a/kaddressbook/TODO b/kaddressbook/TODO
new file mode 100644
index 00000000..df0db82b
--- /dev/null
+++ b/kaddressbook/TODO
@@ -0,0 +1,65 @@
+KAddressBook Todo (not sorted at all!):
+---------------------------------------
+
+--------------------
+For KDE 3.1 (July 1)
+--------------------
+
+New Features (features people want that have not been implemented)
+------------
+- Implement other views (CardView) - 80% (Painting and selection problems)
+- Embed quickedit widget - 95%
+- Implement filtering - DONE
+- Add a Confirm Quit dialog if the addressbook is modified and the
+ user tries to quit
+- Printing Framework - DONE
+
+
+Improvements (things that just need to be improved/rewritten)
+------------
+- Lazy loading of views - DONE
+- Move view information into the manager (don't let the part read the config
+ file to get a list of views) - DONE
+- Redo and move the DCOP interface - 50%
+- Cleanup the tableview more - DONE
+- Relayout the edit contact dialog - DONE
+- Remove ContactEntry*. Impelement supporting classes required
+ for this. - DONE
+- Update the way the ConfigureView dialog gets the view config page - DONE
+- Add a meta data wrapper for views - DONE
+- Add show/hide toolbars in the edit menu - DONE
+- Break KAddressBook into KAddressBook and ViewManager - DONE
+- Change the view items to take a KABC::Addressee rather than a uid - DONE
+- DnD on Card View - DONE
+- Card View specific config options - DONE
+- Implemented a good date picker widget somehow using the KDatePicker
+ widget (needed for korganizer also) - DONE
+- Implement more print styles
+- Add categories for Contact grouping - DONE
+- Move the Filter and Incremental search tools to toolbars
+- Move detailed view from a separate view to a common widget in the view
+ manager
+- Rename the 'sync' button to 'Save' - DONE
+
+
+Fixes (things that used to work and are now broken)
+-----
+- Fix import/export code to use KABC::Addressee - DONE
+- Fix/reinstate LDAP dialog - DONE
+- Fix vcard importing
+- Fix KPilot abbrowser conduit
+- Re-add specific view options pages for Table View - DONE
+
+
+-------------
+After KDE 3.1
+-------------
+
+New Features (features people want that have not been implemented)
+------------
+- Move to a Read/Write part
+- More advanced searching using any field in a contact
+
+Fixes
+-----
+- Reinstate custom fields and a custom field editor
diff --git a/kaddressbook/addresseditwidget.cpp b/kaddressbook/addresseditwidget.cpp
new file mode 100644
index 00000000..54171c34
--- /dev/null
+++ b/kaddressbook/addresseditwidget.cpp
@@ -0,0 +1,678 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+ 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qbuttongroup.h>
+#include <qcheckbox.h>
+#include <qhbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlistbox.h>
+#include <qlistview.h>
+#include <qpushbutton.h>
+#include <qsignal.h>
+#include <qstring.h>
+#include <qtextedit.h>
+#include <qtoolbutton.h>
+#include <qtooltip.h>
+
+#include <kaccelmanager.h>
+#include <kactivelabel.h>
+#include <kapplication.h>
+#include <kbuttonbox.h>
+#include <kcombobox.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <kinputdialog.h>
+#include <klineedit.h>
+#include <klistview.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kseparator.h>
+
+#include "addresseditwidget.h"
+
+class TabPressEater : public QObject
+{
+ public:
+ TabPressEater( QObject *parent )
+ : QObject( parent, "TabPressEater" )
+ {
+ }
+
+ protected:
+ bool eventFilter( QObject*, QEvent *event )
+ {
+ if ( event->type() == QEvent::KeyPress ) {
+ QKeyEvent *keyEvent = (QKeyEvent*)event;
+ if ( keyEvent->key() == Qt::Key_Tab ) {
+ QApplication::sendEvent( parent(), event );
+ return true;
+ } else
+ return false;
+ } else {
+ return false;
+ }
+ }
+};
+
+
+AddressEditWidget::AddressEditWidget( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+ QBoxLayout *layout = new QVBoxLayout( this, 4, 2 );
+ layout->setSpacing( KDialog::spacingHint() );
+
+ mTypeCombo = new AddressTypeCombo( mAddressList, this );
+ connect( mTypeCombo, SIGNAL( activated( int ) ),
+ SLOT( updateAddressEdit() ) );
+ layout->addWidget( mTypeCombo );
+
+ mAddressField = new KActiveLabel( this );
+ mAddressField->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ mAddressField->setMinimumHeight( 20 );
+ mAddressField->setAlignment( Qt::AlignTop );
+ mAddressField->setTextFormat( Qt::PlainText );
+ layout->addWidget( mAddressField );
+
+ mEditButton = new QPushButton( i18n( "street/postal", "&Edit Addresses..." ), this );
+ connect( mEditButton, SIGNAL( clicked() ), this, SLOT( edit() ) );
+
+ layout->addWidget( mEditButton );
+}
+
+AddressEditWidget::~AddressEditWidget()
+{
+}
+
+void AddressEditWidget::setReadOnly( bool readOnly )
+{
+ mEditButton->setEnabled( !readOnly );
+}
+
+KABC::Address::List AddressEditWidget::addresses()
+{
+ KABC::Address::List retList;
+
+ KABC::Address::List::ConstIterator it;
+ for ( it = mAddressList.begin(); it != mAddressList.end(); ++it )
+ if ( !(*it).isEmpty() )
+ retList.append( *it );
+
+ return retList;
+}
+
+void AddressEditWidget::setAddresses( const KABC::Addressee &addr,
+ const KABC::Address::List &list )
+{
+ mAddressee = addr;
+
+ mAddressList.clear();
+
+ // Insert types for existing numbers.
+ mTypeCombo->insertTypeList( list );
+
+ QValueList<int> defaultTypes;
+ defaultTypes << KABC::Address::Home;
+ defaultTypes << KABC::Address::Work;
+
+ AddresseeConfig config( mAddressee );
+ const QValueList<int> configList = config.noDefaultAddrTypes();
+ QValueList<int>::ConstIterator it;
+ for ( it = configList.begin(); it != configList.end(); ++it )
+ defaultTypes.remove( *it );
+
+ // Insert default types.
+ // Doing this for mPrefCombo is enough because the list is shared by all
+ // combos.
+ for ( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) {
+ if ( !mTypeCombo->hasType( *it ) )
+ mTypeCombo->insertType( list, *it, Address( *it ) );
+ }
+
+ mTypeCombo->updateTypes();
+
+ // find preferred address which will be shown
+ int preferred = KABC::Address::Home; // default if no preferred address set
+ KABC::Address::List::ConstIterator addrIt;
+ for ( addrIt = list.begin(); addrIt != list.end(); ++addrIt )
+ if ( (*addrIt).type() & KABC::Address::Pref ) {
+ preferred = (*addrIt).type();
+ break;
+ }
+
+ mTypeCombo->selectType( preferred );
+
+ updateAddressEdit();
+}
+
+void AddressEditWidget::updateAddressee( const KABC::Addressee &addr )
+{
+ mAddressee = addr;
+ updateAddressEdit();
+}
+
+void AddressEditWidget::edit()
+{
+ AddressEditDialog dialog( mAddressList, mTypeCombo->currentItem(), this );
+ if ( dialog.exec() ) {
+ if ( dialog.changed() ) {
+ mAddressList = dialog.addresses();
+
+ bool hasHome = false, hasWork = false;
+ KABC::Address::List::ConstIterator it;
+ for ( it = mAddressList.begin(); it != mAddressList.end(); ++it ) {
+ if ( (*it).type() == KABC::Address::Home ) {
+ if ( !(*it).isEmpty() )
+ hasHome = true;
+ }
+ if ( (*it).type() == KABC::Address::Work ) {
+ if ( !(*it).isEmpty() )
+ hasWork = true;
+ }
+ }
+
+ AddresseeConfig config( mAddressee );
+ QValueList<int> configList;
+ if ( !hasHome )
+ configList << KABC::Address::Home;
+ if ( !hasWork )
+ configList << KABC::Address::Work;
+ config.setNoDefaultAddrTypes( configList );
+
+ mTypeCombo->updateTypes();
+ updateAddressEdit();
+ emit modified();
+ }
+ }
+}
+
+void AddressEditWidget::updateAddressEdit()
+{
+ KABC::Address::List::Iterator it = mTypeCombo->selectedElement();
+
+ bool block = signalsBlocked();
+ blockSignals( true );
+
+ mAddressField->setText( "" );
+
+ if ( it != mAddressList.end() ) {
+ KABC::Address a = *it;
+ if ( !a.isEmpty() ) {
+#if KDE_VERSION >= 319
+ if ( a.type() & KABC::Address::Work && mAddressee.realName() != mAddressee.organization() ) {
+ mAddressField->setText( a.formattedAddress( mAddressee.realName(),
+ mAddressee.organization() ) );
+ } else {
+ mAddressField->setText( a.formattedAddress( mAddressee.realName() ) );
+ }
+#else
+ QString text;
+ if ( !a.street().isEmpty() )
+ text += a.street() + "\n";
+
+ if ( !a.postOfficeBox().isEmpty() )
+ text += a.postOfficeBox() + "\n";
+
+ text += a.locality() + QString(" ") + a.region();
+
+ if ( !a.postalCode().isEmpty() )
+ text += QString(", ") + a.postalCode();
+
+ text += "\n";
+
+ if ( !a.country().isEmpty() )
+ text += a.country() + "\n";
+
+ text += a.extended();
+
+ mAddressField->setText( text );
+#endif
+ }
+ }
+
+ blockSignals( block );
+}
+
+AddressEditDialog::AddressEditDialog( const KABC::Address::List &list,
+ int selected, QWidget *parent,
+ const char *name )
+ : KDialogBase( Plain, i18n( "street/postal", "Edit Address" ), Ok | Cancel, Ok,
+ parent, name, true, true ),
+ mPreviousAddress( 0 )
+{
+ mAddressList = list;
+
+ QWidget *page = plainPage();
+
+ QGridLayout *topLayout = new QGridLayout( page, 8, 2 );
+ topLayout->setSpacing( spacingHint() );
+
+ mTypeCombo = new AddressTypeCombo( mAddressList, page );
+ topLayout->addMultiCellWidget( mTypeCombo, 0, 0, 0, 1 );
+
+ QLabel *label = new QLabel( i18n( "<streetLabel>:", "%1:" ).arg( KABC::Address::streetLabel() ), page );
+ label->setAlignment( Qt::AlignTop | Qt::AlignLeft );
+ topLayout->addWidget( label, 1, 0 );
+ mStreetTextEdit = new QTextEdit( page );
+ mStreetTextEdit->setTextFormat( Qt::PlainText );
+ label->setBuddy( mStreetTextEdit );
+ topLayout->addWidget( mStreetTextEdit, 1, 1 );
+
+ TabPressEater *eater = new TabPressEater( this );
+ mStreetTextEdit->installEventFilter( eater );
+
+ label = new QLabel( i18n( "<postOfficeBoxLabel>:", "%1:" ).arg( KABC::Address::postOfficeBoxLabel() ), page );
+ topLayout->addWidget( label, 2 , 0 );
+ mPOBoxEdit = new KLineEdit( page );
+ label->setBuddy( mPOBoxEdit );
+ topLayout->addWidget( mPOBoxEdit, 2, 1 );
+
+ label = new QLabel( i18n( "<localityLabel>:", "%1:" ).arg( KABC::Address::localityLabel() ), page );
+ topLayout->addWidget( label, 3, 0 );
+ mLocalityEdit = new KLineEdit( page );
+ label->setBuddy( mLocalityEdit );
+ topLayout->addWidget( mLocalityEdit, 3, 1 );
+
+ label = new QLabel( i18n( "<regionLabel>:", "%1:" ).arg( KABC::Address::regionLabel() ), page );
+ topLayout->addWidget( label, 4, 0 );
+ mRegionEdit = new KLineEdit( page );
+ label->setBuddy( mRegionEdit );
+ topLayout->addWidget( mRegionEdit, 4, 1 );
+
+ label = new QLabel( i18n( "<postalCodeLabel>:", "%1:" ).arg( KABC::Address::postalCodeLabel() ), page );
+ topLayout->addWidget( label, 5, 0 );
+ mPostalCodeEdit = new KLineEdit( page );
+ label->setBuddy( mPostalCodeEdit );
+ topLayout->addWidget( mPostalCodeEdit, 5, 1 );
+
+ label = new QLabel( i18n( "<countryLabel>:", "%1:" ).arg( KABC::Address::countryLabel() ), page );
+ topLayout->addWidget( label, 6, 0 );
+ mCountryCombo = new KComboBox( page );
+ mCountryCombo->setEditable( true );
+ mCountryCombo->setDuplicatesEnabled( false );
+
+#if KDE_IS_VERSION(3,3,0)
+ QPushButton *labelButton = new QPushButton( i18n( "Edit Label..." ), page );
+ topLayout->addMultiCellWidget( labelButton, 7, 7, 0, 1 );
+ connect( labelButton, SIGNAL( clicked() ), SLOT( editLabel() ) );
+#endif
+
+ fillCountryCombo();
+ label->setBuddy( mCountryCombo );
+ topLayout->addWidget( mCountryCombo, 6, 1 );
+
+ mPreferredCheckBox = new QCheckBox( i18n( "street/postal", "This is the preferred address" ), page );
+ topLayout->addMultiCellWidget( mPreferredCheckBox, 8, 8, 0, 1 );
+
+ KSeparator *sep = new KSeparator( KSeparator::HLine, page );
+ topLayout->addMultiCellWidget( sep, 9, 9, 0, 1 );
+
+ QHBox *buttonBox = new QHBox( page );
+ buttonBox->setSpacing( spacingHint() );
+ topLayout->addMultiCellWidget( buttonBox, 10, 10, 0, 1 );
+
+ QPushButton *addButton = new QPushButton( i18n( "New..." ), buttonBox );
+ connect( addButton, SIGNAL( clicked() ), SLOT( addAddress() ) );
+
+ mRemoveButton = new QPushButton( i18n( "Remove" ), buttonBox );
+ connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeAddress() ) );
+
+ mChangeTypeButton = new QPushButton( i18n( "Change Type..." ), buttonBox );
+ connect( mChangeTypeButton, SIGNAL( clicked() ), SLOT( changeType() ) );
+
+ mTypeCombo->updateTypes();
+ mTypeCombo->setCurrentItem( selected );
+
+ updateAddressEdits();
+
+ connect( mTypeCombo, SIGNAL( activated( int ) ),
+ SLOT( updateAddressEdits() ) );
+ connect( mStreetTextEdit, SIGNAL( textChanged() ), SLOT( modified() ) );
+ connect( mPOBoxEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
+ connect( mLocalityEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
+ connect( mRegionEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
+ connect( mPostalCodeEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
+ connect( mCountryCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
+ connect( mPreferredCheckBox, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
+
+ KAcceleratorManager::manage( this );
+
+ mChanged = false;
+
+ bool state = (mAddressList.count() > 0);
+ mRemoveButton->setEnabled( state );
+ mChangeTypeButton->setEnabled( state );
+}
+
+AddressEditDialog::~AddressEditDialog()
+{
+}
+
+KABC::Address::List AddressEditDialog::addresses()
+{
+ saveAddress( *(mTypeCombo->selectedElement()) );
+
+ return mAddressList;
+}
+
+bool AddressEditDialog::changed() const
+{
+ return mChanged;
+}
+
+void AddressEditDialog::addAddress()
+{
+ AddressTypeDialog dlg( mTypeCombo->selectedType(), this );
+ if ( dlg.exec() ) {
+ mAddressList.append( Address( dlg.type() ) );
+
+ mTypeCombo->updateTypes();
+ mTypeCombo->setCurrentItem( mTypeCombo->count() - 1 );
+ updateAddressEdits();
+
+ modified();
+
+ mRemoveButton->setEnabled( true );
+ mChangeTypeButton->setEnabled( true );
+ }
+}
+
+void AddressEditDialog::removeAddress()
+{
+ if ( mAddressList.count() > 0 ) {
+ KABC::Address::List::Iterator it = mTypeCombo->selectedElement();
+ if ( mPreviousAddress && mPreviousAddress->id() == (*it).id() )
+ mPreviousAddress = 0;
+
+ mAddressList.remove( it );
+ mTypeCombo->updateTypes();
+ updateAddressEdits();
+
+ modified();
+ }
+
+ bool state = ( mAddressList.count() > 0 );
+ mRemoveButton->setEnabled( state );
+ mChangeTypeButton->setEnabled( state );
+}
+
+void AddressEditDialog::changeType()
+{
+ KABC::Address::List::Iterator a = mTypeCombo->selectedElement();
+
+ AddressTypeDialog dlg( (*a).type(), this );
+ if ( dlg.exec() ) {
+ (*a).setType( dlg.type() );
+
+ mTypeCombo->updateTypes();
+
+ modified();
+ }
+}
+
+void AddressEditDialog::editLabel()
+{
+#if KDE_IS_VERSION(3,3,0)
+ bool ok = false;
+ QString result = KInputDialog::getMultiLineText( KABC::Address::labelLabel(),
+ KABC::Address::labelLabel(),
+ mLabel, &ok, this );
+ if ( ok ) {
+ mLabel = result;
+ modified();
+ }
+#endif
+}
+
+void AddressEditDialog::updateAddressEdits()
+{
+ if ( mPreviousAddress )
+ saveAddress( *mPreviousAddress );
+
+ KABC::Address::List::Iterator it = mTypeCombo->selectedElement();
+ KABC::Address a = *it;
+ mPreviousAddress = &(*it);
+
+ bool tmp = mChanged;
+
+ mStreetTextEdit->setText( a.street() );
+ mRegionEdit->setText( a.region() );
+ mLocalityEdit->setText( a.locality() );
+ mPostalCodeEdit->setText( a.postalCode() );
+ mPOBoxEdit->setText( a.postOfficeBox() );
+ mCountryCombo->setCurrentText( a.country() );
+ mLabel = a.label();
+
+ mPreferredCheckBox->setChecked( a.type() & KABC::Address::Pref );
+
+ if ( a.isEmpty() )
+ mCountryCombo->setCurrentText( KGlobal::locale()->twoAlphaToCountryName( KGlobal::locale()->country() ) );
+
+ mStreetTextEdit->setFocus();
+
+ mChanged = tmp;
+}
+
+void AddressEditDialog::modified()
+{
+ mChanged = true;
+}
+
+void AddressEditDialog::saveAddress( KABC::Address &addr )
+{
+ addr.setLocality( mLocalityEdit->text() );
+ addr.setRegion( mRegionEdit->text() );
+ addr.setPostalCode( mPostalCodeEdit->text() );
+ addr.setCountry( mCountryCombo->currentText() );
+ addr.setPostOfficeBox( mPOBoxEdit->text() );
+ addr.setStreet( mStreetTextEdit->text() );
+ addr.setLabel( mLabel );
+
+
+ if ( mPreferredCheckBox->isChecked() ) {
+ KABC::Address::List::Iterator it;
+ for ( it = mAddressList.begin(); it != mAddressList.end(); ++it )
+ (*it).setType( (*it).type() & ~( KABC::Address::Pref ) );
+
+ addr.setType( addr.type() | KABC::Address::Pref );
+ } else
+ addr.setType( addr.type() & ~( KABC::Address::Pref ) );
+}
+
+void AddressEditDialog::fillCountryCombo()
+{
+ QString country[] = {
+ i18n( "Afghanistan" ), i18n( "Albania" ), i18n( "Algeria" ),
+ i18n( "American Samoa" ), i18n( "Andorra" ), i18n( "Angola" ),
+ i18n( "Anguilla" ), i18n( "Antarctica" ), i18n( "Antigua and Barbuda" ),
+ i18n( "Argentina" ), i18n( "Armenia" ), i18n( "Aruba" ),
+ i18n( "Ashmore and Cartier Islands" ), i18n( "Australia" ),
+ i18n( "Austria" ), i18n( "Azerbaijan" ), i18n( "Bahamas" ),
+ i18n( "Bahrain" ), i18n( "Bangladesh" ), i18n( "Barbados" ),
+ i18n( "Belarus" ), i18n( "Belgium" ), i18n( "Belize" ),
+ i18n( "Benin" ), i18n( "Bermuda" ), i18n( "Bhutan" ),
+ i18n( "Bolivia" ), i18n( "Bosnia and Herzegovina" ), i18n( "Botswana" ),
+ i18n( "Brazil" ), i18n( "Brunei" ), i18n( "Bulgaria" ),
+ i18n( "Burkina Faso" ), i18n( "Burundi" ), i18n( "Cambodia" ),
+ i18n( "Cameroon" ), i18n( "Canada" ), i18n( "Cape Verde" ),
+ i18n( "Cayman Islands" ), i18n( "Central African Republic" ),
+ i18n( "Chad" ), i18n( "Chile" ), i18n( "China" ), i18n( "Colombia" ),
+ i18n( "Comoros" ), i18n( "Congo" ), i18n( "Congo, Dem. Rep." ),
+ i18n( "Costa Rica" ), i18n( "Croatia" ),
+ i18n( "Cuba" ), i18n( "Cyprus" ), i18n( "Czech Republic" ),
+ i18n( "Denmark" ), i18n( "Djibouti" ),
+ i18n( "Dominica" ), i18n( "Dominican Republic" ), i18n( "Ecuador" ),
+ i18n( "Egypt" ), i18n( "El Salvador" ), i18n( "Equatorial Guinea" ),
+ i18n( "Eritrea" ), i18n( "Estonia" ), i18n( "England" ),
+ i18n( "Ethiopia" ), i18n( "European Union" ), i18n( "Faroe Islands" ),
+ i18n( "Fiji" ), i18n( "Finland" ), i18n( "France" ),
+ i18n( "French Polynesia" ), i18n( "Gabon" ), i18n( "Gambia" ),
+ i18n( "Georgia" ), i18n( "Germany" ), i18n( "Ghana" ),
+ i18n( "Greece" ), i18n( "Greenland" ), i18n( "Grenada" ),
+ i18n( "Guam" ), i18n( "Guatemala" ), i18n( "Guinea" ),
+ i18n( "Guinea-Bissau" ), i18n( "Guyana" ), i18n( "Haiti" ),
+ i18n( "Honduras" ), i18n( "Hong Kong" ), i18n( "Hungary" ),
+ i18n( "Iceland" ), i18n( "India" ), i18n( "Indonesia" ),
+ i18n( "Iran" ), i18n( "Iraq" ), i18n( "Ireland" ),
+ i18n( "Israel" ), i18n( "Italy" ), i18n( "Ivory Coast" ),
+ i18n( "Jamaica" ), i18n( "Japan" ), i18n( "Jordan" ),
+ i18n( "Kazakhstan" ), i18n( "Kenya" ), i18n( "Kiribati" ),
+ i18n( "Korea, North" ), i18n( "Korea, South" ),
+ i18n( "Kuwait" ), i18n( "Kyrgyzstan" ), i18n( "Laos" ),
+ i18n( "Latvia" ), i18n( "Lebanon" ), i18n( "Lesotho" ),
+ i18n( "Liberia" ), i18n( "Libya" ), i18n( "Liechtenstein" ),
+ i18n( "Lithuania" ), i18n( "Luxembourg" ), i18n( "Macau" ),
+ i18n( "Madagascar" ), i18n( "Malawi" ), i18n( "Malaysia" ),
+ i18n( "Maldives" ), i18n( "Mali" ), i18n( "Malta" ),
+ i18n( "Marshall Islands" ), i18n( "Martinique" ), i18n( "Mauritania" ),
+ i18n( "Mauritius" ), i18n( "Mexico" ),
+ i18n( "Micronesia, Federated States Of" ), i18n( "Moldova" ),
+ i18n( "Monaco" ), i18n( "Mongolia" ), i18n( "Montserrat" ),
+ i18n( "Morocco" ), i18n( "Mozambique" ), i18n( "Myanmar" ),
+ i18n( "Namibia" ),
+ i18n( "Nauru" ), i18n( "Nepal" ), i18n( "Netherlands" ),
+ i18n( "Netherlands Antilles" ), i18n( "New Caledonia" ),
+ i18n( "New Zealand" ), i18n( "Nicaragua" ), i18n( "Niger" ),
+ i18n( "Nigeria" ), i18n( "Niue" ), i18n( "North Korea" ),
+ i18n( "Northern Ireland" ), i18n( "Northern Mariana Islands" ),
+ i18n( "Norway" ), i18n( "Oman" ), i18n( "Pakistan" ), i18n( "Palau" ),
+ i18n( "Palestinian" ), i18n( "Panama" ), i18n( "Papua New Guinea" ),
+ i18n( "Paraguay" ), i18n( "Peru" ), i18n( "Philippines" ),
+ i18n( "Poland" ), i18n( "Portugal" ), i18n( "Puerto Rico" ),
+ i18n( "Qatar" ), i18n( "Romania" ), i18n( "Russia" ), i18n( "Rwanda" ),
+ i18n( "St. Kitts and Nevis" ), i18n( "St. Lucia" ),
+ i18n( "St. Vincent and the Grenadines" ), i18n( "San Marino" ),
+ i18n( "Sao Tome and Principe" ), i18n( "Saudi Arabia" ),
+ i18n( "Senegal" ), i18n( "Serbia & Montenegro" ), i18n( "Seychelles" ),
+ i18n( "Sierra Leone" ), i18n( "Singapore" ), i18n( "Slovakia" ),
+ i18n( "Slovenia" ), i18n( "Solomon Islands" ), i18n( "Somalia" ),
+ i18n( "South Africa" ), i18n( "South Korea" ), i18n( "Spain" ),
+ i18n( "Sri Lanka" ), i18n( "St. Kitts and Nevis" ), i18n( "Sudan" ),
+ i18n( "Suriname" ), i18n( "Swaziland" ), i18n( "Sweden" ),
+ i18n( "Switzerland" ), i18n( "Syria" ), i18n( "Taiwan" ),
+ i18n( "Tajikistan" ), i18n( "Tanzania" ), i18n( "Thailand" ),
+ i18n( "Tibet" ), i18n( "Togo" ), i18n( "Tonga" ),
+ i18n( "Trinidad and Tobago" ), i18n( "Tunisia" ), i18n( "Turkey" ),
+ i18n( "Turkmenistan" ), i18n( "Turks and Caicos Islands" ),
+ i18n( "Tuvalu" ), i18n( "Uganda" ), i18n( "Ukraine" ),
+ i18n( "United Arab Emirates" ), i18n( "United Kingdom" ),
+ i18n( "United States" ), i18n( "Uruguay" ), i18n( "Uzbekistan" ),
+ i18n( "Vanuatu" ), i18n( "Vatican City" ), i18n( "Venezuela" ),
+ i18n( "Vietnam" ), i18n( "Western Samoa" ), i18n( "Yemen" ),
+ i18n( "Yugoslavia" ), i18n( "Zaire" ), i18n( "Zambia" ),
+ i18n( "Zimbabwe" ),
+ ""
+ };
+
+ QStringList countries;
+ for ( int i = 0; !country[ i ].isEmpty(); ++i )
+ countries.append( country[ i ] );
+
+ countries = sortLocaleAware( countries );
+
+ mCountryCombo->insertStringList( countries );
+ mCountryCombo->completionObject()->setItems( countries );
+ mCountryCombo->setAutoCompletion( true );
+}
+
+
+AddressTypeDialog::AddressTypeDialog( int type, QWidget *parent )
+ : KDialogBase( Plain, i18n( "street/postal", "Edit Address Type" ), Ok | Cancel, Ok,
+ parent, "AddressTypeDialog" )
+{
+ QWidget *page = plainPage();
+ QVBoxLayout *layout = new QVBoxLayout( page );
+
+ mGroup = new QButtonGroup( 2, Horizontal, i18n( "street/postal", "Address Types" ), page );
+ layout->addWidget( mGroup );
+
+ mTypeList = KABC::Address::typeList();
+ mTypeList.remove( KABC::Address::Pref );
+
+ KABC::Address::TypeList::ConstIterator it;
+ for ( it = mTypeList.begin(); it != mTypeList.end(); ++it )
+ new QCheckBox( KABC::Address::typeLabel( *it ), mGroup );
+
+ for ( int i = 0; i < mGroup->count(); ++i ) {
+ QCheckBox *box = (QCheckBox*)mGroup->find( i );
+ box->setChecked( type & mTypeList[ i ] );
+ }
+}
+
+AddressTypeDialog::~AddressTypeDialog()
+{
+}
+
+int AddressTypeDialog::type() const
+{
+ int type = 0;
+ for ( int i = 0; i < mGroup->count(); ++i ) {
+ QCheckBox *box = (QCheckBox*)mGroup->find( i );
+ if ( box->isChecked() )
+ type += mTypeList[ i ];
+ }
+
+ return type;
+}
+
+/**
+ Small helper class, I hope we can remove it as soon as a general solution has
+ been committed to kdelibs
+ */
+class LocaleAwareString : public QString
+{
+ public:
+ LocaleAwareString() : QString()
+ {}
+
+ LocaleAwareString( const QString &str ) : QString( str )
+ {}
+};
+
+static bool operator<( const LocaleAwareString &s1, const LocaleAwareString &s2 )
+{
+ return ( QString::localeAwareCompare( s1, s2 ) < 0 );
+}
+
+QStringList AddressEditDialog::sortLocaleAware( const QStringList &list )
+{
+ QValueList<LocaleAwareString> sortedList;
+
+ QStringList::ConstIterator it;
+ for ( it = list.begin(); it != list.end(); ++it )
+ sortedList.append( LocaleAwareString( *it ) );
+
+ qHeapSort( sortedList );
+
+ QStringList retval;
+ QValueList<LocaleAwareString>::ConstIterator retIt;
+ for ( retIt = sortedList.begin(); retIt != sortedList.end(); ++retIt )
+ retval.append( *retIt );
+
+ return retval;
+}
+
+#include "addresseditwidget.moc"
diff --git a/kaddressbook/addresseditwidget.h b/kaddressbook/addresseditwidget.h
new file mode 100644
index 00000000..cf770315
--- /dev/null
+++ b/kaddressbook/addresseditwidget.h
@@ -0,0 +1,154 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef ADDRESSEDITWIDGET_H
+#define ADDRESSEDITWIDGET_H
+
+#include <qwidget.h>
+
+#include <kdialogbase.h>
+#include <kabc/address.h>
+#include <kabc/addressee.h>
+
+#include "addresseeconfig.h"
+#include "typecombo.h"
+
+class QButtonGroup;
+class QCheckBox;
+class QListView;
+class QTextEdit;
+class QToolButton;
+
+class KActiveLabel;
+class KComboBox;
+class KLineEdit;
+class KListView;
+
+typedef TypeCombo<KABC::Address> AddressTypeCombo;
+
+/**
+ Editor widget for addresses.
+ */
+class AddressEditWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ AddressEditWidget( QWidget *parent, const char *name = 0 );
+ ~AddressEditWidget();
+
+ KABC::Address::List addresses();
+ void setAddresses( const KABC::Addressee &addr,
+ const KABC::Address::List &list );
+ void updateAddressee( const KABC::Addressee &addr );
+
+ void updateTypeCombo( const KABC::Address::List&, KComboBox* );
+ KABC::Address currentAddress( KComboBox*, int );
+
+ void setReadOnly( bool readOnly );
+
+ signals:
+ void modified();
+
+ protected slots:
+ void updateAddressEdit();
+
+ void edit();
+
+ private:
+ AddressTypeCombo *mTypeCombo;
+
+ QPushButton *mEditButton;
+ KActiveLabel *mAddressField;
+
+ KABC::Address::List mAddressList;
+ KABC::Addressee mAddressee;
+ int mIndex;
+};
+
+/**
+ Dialog for editing address details.
+ */
+class AddressEditDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ AddressEditDialog( const KABC::Address::List &list, int selected,
+ QWidget *parent, const char *name = 0 );
+ ~AddressEditDialog();
+
+ KABC::Address::List addresses();
+ bool changed() const;
+
+ protected slots:
+ void addAddress();
+ void removeAddress();
+ void changeType();
+ void editLabel();
+
+ void updateAddressEdits();
+ void modified();
+
+ private:
+ void saveAddress( KABC::Address &addr );
+ void fillCountryCombo();
+ QStringList sortLocaleAware( const QStringList& );
+
+ AddressTypeCombo *mTypeCombo;
+ QTextEdit *mStreetTextEdit;
+ KComboBox *mCountryCombo;
+ KLineEdit *mRegionEdit;
+ KLineEdit *mLocalityEdit;
+ KLineEdit *mPostalCodeEdit;
+ KLineEdit *mPOBoxEdit;
+ QCheckBox *mPreferredCheckBox;
+
+ QPushButton *mRemoveButton;
+ QPushButton *mChangeTypeButton;
+
+ KABC::Address::List mAddressList;
+ KABC::Address *mPreviousAddress;
+ bool mChanged;
+
+ QString mLabel;
+};
+
+/**
+ Dialog for selecting an address type.
+ */
+class AddressTypeDialog : public KDialogBase
+{
+ public:
+ AddressTypeDialog( int type, QWidget *parent );
+ ~AddressTypeDialog();
+
+ int type() const;
+
+ private:
+ QButtonGroup *mGroup;
+
+ KABC::Address::TypeList mTypeList;
+};
+
+#endif
diff --git a/kaddressbook/addresseeconfig.cpp b/kaddressbook/addresseeconfig.cpp
new file mode 100644
index 00000000..830127eb
--- /dev/null
+++ b/kaddressbook/addresseeconfig.cpp
@@ -0,0 +1,99 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include "addresseeconfig.h"
+#include "kabprefs.h"
+
+using namespace KABC;
+
+AddresseeConfig::AddresseeConfig()
+{
+ mAddressee = Addressee();
+}
+
+AddresseeConfig::AddresseeConfig( const Addressee &addr )
+{
+ mAddressee = addr;
+}
+
+void AddresseeConfig::setAddressee( const Addressee &addr )
+{
+ mAddressee = addr;
+}
+
+Addressee AddresseeConfig::addressee()
+{
+ return mAddressee;
+}
+
+void AddresseeConfig::setAutomaticNameParsing( bool value )
+{
+ KConfig config( "kaddressbook_addrconfig" );
+ config.setGroup( mAddressee.uid() );
+ config.writeEntry( "AutomaticNameParsing", value );
+ config.sync();
+}
+
+bool AddresseeConfig::automaticNameParsing()
+{
+ KConfig config( "kaddressbook_addrconfig" );
+ config.setGroup( mAddressee.uid() );
+ return config.readBoolEntry( "AutomaticNameParsing",
+ KABPrefs::instance()->automaticNameParsing() );
+}
+
+void AddresseeConfig::setNoDefaultAddrTypes( const QValueList<int> &types )
+{
+ KConfig config( "kaddressbook_addrconfig" );
+ config.setGroup( mAddressee.uid() );
+ config.writeEntry( "NoDefaultAddrTypes", types );
+ config.sync();
+}
+
+QValueList<int> AddresseeConfig::noDefaultAddrTypes() const
+{
+ KConfig config( "kaddressbook_addrconfig" );
+ config.setGroup( mAddressee.uid() );
+ return config.readIntListEntry( "NoDefaultAddrTypes" );
+}
+
+void AddresseeConfig::setCustomFields( const QStringList &fields )
+{
+ KConfig config( "kaddressbook_addrconfig" );
+ config.setGroup( mAddressee.uid() );
+ config.writeEntry( "LocalCustomFields", fields );
+ config.sync();
+}
+
+QStringList AddresseeConfig::customFields() const
+{
+ KConfig config( "kaddressbook_addrconfig" );
+ config.setGroup( mAddressee.uid() );
+ return config.readListEntry( "LocalCustomFields" );
+}
+
+void AddresseeConfig::remove()
+{
+ KConfig config( "kaddressbook_addrconfig" );
+ config.deleteGroup( mAddressee.uid() );
+}
diff --git a/kaddressbook/addresseeconfig.h b/kaddressbook/addresseeconfig.h
new file mode 100644
index 00000000..798d35e5
--- /dev/null
+++ b/kaddressbook/addresseeconfig.h
@@ -0,0 +1,56 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef ADDRESSEECONFIG_H
+#define ADDRESSEECONFIG_H
+
+#include <kabc/addressee.h>
+#include <kconfig.h>
+
+using namespace KABC;
+
+class AddresseeConfig
+{
+ public:
+ AddresseeConfig();
+ AddresseeConfig( const Addressee &addr );
+
+ void setAddressee( const Addressee &addr );
+ Addressee addressee();
+
+ void setAutomaticNameParsing( bool value );
+ bool automaticNameParsing();
+
+ void setNoDefaultAddrTypes( const QValueList<int> &types );
+ QValueList<int> noDefaultAddrTypes() const;
+
+ void setCustomFields( const QStringList &fields );
+ QStringList customFields() const;
+
+ void remove();
+
+ private:
+ Addressee mAddressee;
+};
+
+#endif
diff --git a/kaddressbook/addresseeeditorbase.cpp b/kaddressbook/addresseeeditorbase.cpp
new file mode 100644
index 00000000..f0352a70
--- /dev/null
+++ b/kaddressbook/addresseeeditorbase.cpp
@@ -0,0 +1,24 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include "addresseeeditorbase.moc"
diff --git a/kaddressbook/addresseeeditorbase.h b/kaddressbook/addresseeeditorbase.h
new file mode 100644
index 00000000..394223b1
--- /dev/null
+++ b/kaddressbook/addresseeeditorbase.h
@@ -0,0 +1,59 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef ADDRESSEEEDITORBASE_H
+#define ADDRESSEEEDITORBASE_H
+
+#include <kabc/addressee.h>
+
+#include <qwidget.h>
+
+class AddresseeEditorBase : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ AddresseeEditorBase( QWidget *parent, const char *name = 0 )
+ : QWidget( parent, name )
+ {
+ }
+
+ ~AddresseeEditorBase() {}
+
+ virtual void setAddressee( const KABC::Addressee& ) = 0;
+ virtual const KABC::Addressee &addressee() = 0;
+
+ virtual void setInitialFocus() = 0;
+
+ virtual void load() = 0;
+ virtual void save() = 0;
+
+ virtual bool dirty() = 0;
+
+ virtual bool readyToClose() { return true; }
+
+ signals:
+ void modified();
+};
+
+#endif
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp
new file mode 100644
index 00000000..8df8357a
--- /dev/null
+++ b/kaddressbook/addresseeeditordialog.cpp
@@ -0,0 +1,153 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qapplication.h>
+#include <qlayout.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+
+#include "core.h"
+#include "addresseeeditorwidget.h"
+#include "simpleaddresseeeditor.h"
+#include "kabprefs.h"
+
+#include "addresseeeditordialog.h"
+
+AddresseeEditorDialog::AddresseeEditorDialog( KAB::Core *core,
+ QWidget *parent, const char *name )
+ : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ),
+ KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply,
+ KDialogBase::Ok, parent, name, false )
+{
+ // Set this to be the group leader for all subdialogs - this means
+ // modal subdialogs will only affect this dialog, not the other windows
+ setWFlags( getWFlags() | WGroupLeader );
+
+ kdDebug(5720) << "AddresseeEditorDialog()" << endl;
+
+ QWidget *page = plainPage();
+
+ QVBoxLayout *layout = new QVBoxLayout( page );
+
+ if ( KABPrefs::instance()->editorType() == KABPrefs::SimpleEditor ) {
+ mEditorWidget = new SimpleAddresseeEditor( page );
+ } else {
+ mEditorWidget = new AddresseeEditorWidget( page );
+ }
+ connect( mEditorWidget, SIGNAL( modified() ), SLOT( widgetModified() ) );
+ layout->addWidget( mEditorWidget );
+
+ enableButton( KDialogBase::Apply, false );
+
+ KConfig config( "kaddressbookrc" );
+ config.setGroup( "AddresseeEditor" );
+ QSize defaultSize( 750, 570 );
+ resize( config.readSizeEntry( "Size", &defaultSize ) );
+}
+
+AddresseeEditorDialog::~AddresseeEditorDialog()
+{
+ kdDebug(5720) << "~AddresseeEditorDialog()" << endl;
+
+ KConfig config( "kaddressbookrc" );
+ config.setGroup( "AddresseeEditor" );
+ config.writeEntry( "Size", size() );
+
+ emit editorDestroyed( mEditorWidget->addressee().uid() );
+}
+
+void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr )
+{
+ enableButton( KDialogBase::Apply, false );
+
+ setTitle( addr );
+
+ mEditorWidget->setAddressee( addr );
+ mEditorWidget->setInitialFocus();
+}
+
+KABC::Addressee AddresseeEditorDialog::addressee()
+{
+ return mEditorWidget->addressee();
+}
+
+bool AddresseeEditorDialog::dirty()
+{
+ return mEditorWidget->dirty();
+}
+
+void AddresseeEditorDialog::slotApply()
+{
+ if ( !mEditorWidget->readyToClose() )
+ return;
+
+ if ( mEditorWidget->dirty() ) {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ mEditorWidget->save();
+ emit contactModified( mEditorWidget->addressee() );
+ QApplication::restoreOverrideCursor();
+ }
+
+ enableButton( KDialogBase::Apply, false );
+
+ KDialogBase::slotApply();
+}
+
+void AddresseeEditorDialog::slotOk()
+{
+ if ( !mEditorWidget->readyToClose() )
+ return;
+
+ slotApply();
+
+ KDialogBase::slotOk();
+
+ // Destroy this dialog
+ delayedDestruct();
+}
+
+void AddresseeEditorDialog::widgetModified()
+{
+ const KABC::Addressee addressee = mEditorWidget->addressee();
+ if ( !addressee.isEmpty() )
+ setTitle( addressee );
+
+ enableButton( KDialogBase::Apply, true );
+}
+
+void AddresseeEditorDialog::slotCancel()
+{
+ KDialogBase::slotCancel();
+
+ // Destroy this dialog
+ delayedDestruct();
+}
+
+void AddresseeEditorDialog::setTitle( const KABC::Addressee &addr )
+{
+ if ( !addr.realName().isEmpty() )
+ setCaption( i18n( "Edit Contact '%1'" ).arg( addr.realName() ) );
+}
+
+#include "addresseeeditordialog.moc"
diff --git a/kaddressbook/addresseeeditordialog.h b/kaddressbook/addresseeeditordialog.h
new file mode 100644
index 00000000..889dd655
--- /dev/null
+++ b/kaddressbook/addresseeeditordialog.h
@@ -0,0 +1,65 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef ADDRESSEEEDITORDIALOG_H
+#define ADDRESSEEEDITORDIALOG_H
+
+#include <kdialogbase.h>
+
+#include <kabc/addressbook.h>
+
+class AddresseeEditorBase;
+class QWidget;
+namespace KAB { class Core; }
+
+class AddresseeEditorDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ AddresseeEditorDialog( KAB::Core *core,
+ QWidget *parent, const char *name = 0 );
+ ~AddresseeEditorDialog();
+
+ void setAddressee( const KABC::Addressee& );
+ KABC::Addressee addressee();
+
+ bool dirty();
+
+ signals:
+ void contactModified( const KABC::Addressee& );
+ void editorDestroyed( const QString& );
+
+ protected slots:
+ virtual void slotApply();
+ virtual void slotOk();
+ virtual void slotCancel();
+ void widgetModified();
+
+ private:
+ virtual void setTitle( const KABC::Addressee& );
+
+ AddresseeEditorBase *mEditorWidget;
+};
+
+#endif
diff --git a/kaddressbook/addresseeeditorextension.cpp b/kaddressbook/addresseeeditorextension.cpp
new file mode 100644
index 00000000..b98260a7
--- /dev/null
+++ b/kaddressbook/addresseeeditorextension.cpp
@@ -0,0 +1,76 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qlayout.h>
+
+#include <klocale.h>
+
+#include "kabprefs.h"
+
+#include "addresseeeditorwidget.h"
+#include "simpleaddresseeeditor.h"
+
+#include "addresseeeditorextension.h"
+
+AddresseeEditorExtension::AddresseeEditorExtension( KAB::Core *core, QWidget *parent, const char *name )
+ : KAB::ExtensionWidget( core, parent, name )
+{
+ QVBoxLayout *layout = new QVBoxLayout( this );
+
+ if ( KABPrefs::instance()->editorType() == KABPrefs::SimpleEditor )
+ mAddresseeEditor = new SimpleAddresseeEditor( this );
+ else
+ mAddresseeEditor = new AddresseeEditorWidget( this );
+
+ layout->addWidget( mAddresseeEditor );
+}
+
+AddresseeEditorExtension::~AddresseeEditorExtension()
+{
+}
+
+void AddresseeEditorExtension::contactsSelectionChanged()
+{
+ const KABC::Addressee::List selectedAddressees = selectedContacts();
+ KABC::Addressee::List addressees;
+
+ if ( mAddresseeEditor->dirty() ) {
+ mAddresseeEditor->save();
+ addressees.append( mAddresseeEditor->addressee() );
+ emit modified( addressees );
+ }
+
+ mAddresseeEditor->setAddressee( selectedAddressees[ 0 ] );
+}
+
+QString AddresseeEditorExtension::title() const
+{
+ return i18n( "Contact Editor" );
+}
+
+QString AddresseeEditorExtension::identifier() const
+{
+ return "contact_editor";
+}
+
+#include "addresseeeditorextension.moc"
diff --git a/kaddressbook/addresseeeditorextension.h b/kaddressbook/addresseeeditorextension.h
new file mode 100644
index 00000000..3eab5c13
--- /dev/null
+++ b/kaddressbook/addresseeeditorextension.h
@@ -0,0 +1,59 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef ADDRESSEEEDITOREXTENSION_H
+#define ADDRESSEEEDITOREXTENSION_H
+
+#include "addresseeeditorbase.h"
+#include "extensionwidget.h"
+
+class AddresseeEditorExtension : public KAB::ExtensionWidget
+{
+ Q_OBJECT
+
+ public:
+ AddresseeEditorExtension( KAB::Core *core, QWidget *parent, const char *name = 0 );
+ ~AddresseeEditorExtension();
+
+ /**
+ This method is called whenever the selection in the view changed.
+ */
+ virtual void contactsSelectionChanged();
+
+ /**
+ This method should be reimplemented and return the i18ned title of this
+ widget.
+ */
+ virtual QString title() const;
+
+ /**
+ This method should be reimplemented and return a unique identifier.
+ */
+ virtual QString identifier() const;
+
+ private:
+ AddresseeEditorBase *mAddresseeEditor;
+ bool mDirty;
+};
+
+#endif
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
new file mode 100644
index 00000000..253c3b45
--- /dev/null
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -0,0 +1,909 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qcheckbox.h>
+#include <qhbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlistbox.h>
+#include <qpushbutton.h>
+#include <qtabwidget.h>
+#include <qtextedit.h>
+#include <qtoolbutton.h>
+#include <qtooltip.h>
+
+#include <kabc/resource.h>
+#include <kabc/stdaddressbook.h>
+#include <kaccelmanager.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klineedit.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kseparator.h>
+#include <ksqueezedtextlabel.h>
+#include <kstandarddirs.h>
+
+#include <libkdepim/addresseelineedit.h>
+#include <libkdepim/categoryeditdialog.h>
+#include <libkdepim/categoryselectdialog.h>
+#include <libkdepim/kdateedit.h>
+#include <libkdepim/resourceabc.h>
+
+#include "addresseditwidget.h"
+#include "advancedcustomfields.h"
+#include "emaileditwidget.h"
+#include "imeditwidget.h"
+#include "kabprefs.h"
+#include "keywidget.h"
+#include "nameeditdialog.h"
+#include "phoneeditwidget.h"
+#include "secrecywidget.h"
+
+#include "addresseeeditorwidget.h"
+
+AddresseeEditorWidget::AddresseeEditorWidget( QWidget *parent, const char *name )
+ : AddresseeEditorBase( parent, name ),
+ mBlockSignals( false ), mReadOnly( false )
+{
+ kdDebug(5720) << "AddresseeEditorWidget()" << endl;
+
+ initGUI();
+ mCategorySelectDialog = 0;
+ mCategoryEditDialog = 0;
+
+ // Load the empty addressee as defaults
+ load();
+
+ mDirty = false;
+}
+
+AddresseeEditorWidget::~AddresseeEditorWidget()
+{
+ kdDebug(5720) << "~AddresseeEditorWidget()" << endl;
+}
+
+void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr )
+{
+ if ( mAddressee.uid() == addr.uid() )
+ return;
+ mAddressee = addr;
+
+ bool readOnly = false;
+ if ( KABC::Resource *res = addr.resource() ) {
+ if ( res->readOnly() ) {
+ readOnly = true;
+
+ //Kolab resources have finer access control than planned in the overall design.
+ } else if ( res->inherits( "KPIM::ResourceABC" ) ) {
+ KPIM::ResourceABC *resAbc = static_cast<KPIM::ResourceABC *>( res );
+
+ QString subresource = resAbc->uidToResourceMap()[ addr.uid() ];
+ if ( !subresource.isEmpty() )
+ readOnly |= !resAbc->subresourceWritable( subresource );
+ }
+ }
+ setReadOnly( readOnly );
+
+ load();
+}
+
+const KABC::Addressee &AddresseeEditorWidget::addressee()
+{
+ return mAddressee;
+}
+
+void AddresseeEditorWidget::textChanged( const QString& )
+{
+ emitModified();
+}
+
+void AddresseeEditorWidget::initGUI()
+{
+ QVBoxLayout *layout = new QVBoxLayout( this );
+
+ mTabWidget = new QTabWidget( this );
+ layout->addWidget( mTabWidget );
+
+ setupTab1();
+ setupTab2();
+ setupAdditionalTabs();
+ setupCustomFieldsTabs();
+
+ connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ),
+ SLOT( pageChanged(QWidget*) ) );
+}
+
+void AddresseeEditorWidget::setupTab1()
+{
+ // This is the General tab
+ QWidget *tab1 = new QWidget( mTabWidget );
+
+ QGridLayout *layout = new QGridLayout( tab1, 11, 7 );
+ layout->setMargin( KDialogBase::marginHint() );
+ layout->setSpacing( KDialogBase::spacingHint() );
+
+ QLabel *label;
+ KSeparator* bar;
+ QPushButton *button;
+
+ //////////////////////////////////
+ // Upper left group (person info)
+
+ // Person icon
+ label = new QLabel( tab1 );
+ label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop,
+ KIcon::SizeMedium ) );
+ layout->addMultiCellWidget( label, 0, 1, 0, 0 );
+
+ // First name
+ button = new QPushButton( i18n( "Edit Name..." ), tab1 );
+ QToolTip::add( button, i18n( "Edit the contact's name" ) );
+ mNameEdit = new KLineEdit( tab1, "mNameEdit" );
+ connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( nameTextChanged( const QString& ) ) );
+ connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) );
+ mNameLabel = new KSqueezedTextLabel( tab1 );
+
+ if ( KABPrefs::instance()->automaticNameParsing() ) {
+ mNameLabel->hide();
+ mNameEdit->show();
+ } else {
+ mNameEdit->hide();
+ mNameLabel->show();
+ }
+
+ layout->addWidget( button, 0, 1 );
+ layout->addWidget( mNameEdit, 0, 2 );
+ layout->addWidget( mNameLabel, 0, 2 );
+ label = new QLabel( i18n( "<roleLabel>:", "%1:" ).arg( KABC::Addressee::roleLabel() ), tab1 );
+ mRoleEdit = new KLineEdit( tab1 );
+ connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mRoleEdit );
+ layout->addWidget( label, 1, 1 );
+ layout->addWidget( mRoleEdit, 1, 2 );
+
+ // Organization
+ label = new QLabel( i18n( "<organizationLabel>:", "%1:" ).arg( KABC::Addressee::organizationLabel() ), tab1 );
+ mOrgEdit = new KLineEdit( tab1 );
+ label->setBuddy( mOrgEdit );
+ connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( organizationTextChanged( const QString& ) ) );
+ layout->addWidget( label, 2, 1 );
+ layout->addWidget( mOrgEdit, 2, 2 );
+
+ // File as (formatted name)
+ label = new QLabel( i18n( "Formatted name:" ), tab1 );
+ mFormattedNameLabel = new KSqueezedTextLabel( tab1 );
+ layout->addWidget( label, 3, 1 );
+ layout->addWidget( mFormattedNameLabel, 3, 2 );
+
+ // Left hand separator. This separator doesn't go all the way
+ // across so the dialog still flows from top to bottom
+ bar = new KSeparator( KSeparator::HLine, tab1 );
+ layout->addMultiCellWidget( bar, 4, 4, 0, 2 );
+
+ //////////////////////////////////////
+ // Phone numbers (upper right)
+ label = new QLabel( tab1 );
+ label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook",
+ KIcon::Desktop, KIcon::SizeMedium ) );
+ layout->addMultiCellWidget( label, 0, 1, 3, 3 );
+
+ mPhoneEditWidget = new PhoneEditWidget( tab1 );
+ connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
+ layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 );
+
+ bar = new KSeparator( KSeparator::HLine, tab1 );
+ layout->addMultiCellWidget( bar, 4, 4, 3, 6 );
+
+ //////////////////////////////////////
+ // Addresses (lower left)
+ label = new QLabel( tab1 );
+ label->setPixmap( KGlobal::iconLoader()->loadIcon( "kfm_home", KIcon::Desktop,
+ KIcon::SizeMedium ) );
+ layout->addMultiCellWidget( label, 5, 6, 0, 0 );
+
+ mAddressEditWidget = new AddressEditWidget( tab1 );
+ connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
+ layout->addMultiCellWidget( mAddressEditWidget, 5, 10, 1, 2 );
+
+ //////////////////////////////////////
+ // Email / Web (lower right)
+ label = new QLabel( tab1 );
+ label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop,
+ KIcon::SizeMedium ) );
+ layout->addMultiCellWidget( label, 5, 6, 3, 3 );
+
+ mEmailWidget = new EmailEditWidget( tab1 );
+ connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
+ layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 );
+
+ // add the separator
+ bar = new KSeparator( KSeparator::HLine, tab1 );
+ layout->addMultiCellWidget( bar, 7, 7, 3, 6 );
+
+ QHBoxLayout *homePageLayout = new QHBoxLayout( 0, 11, 7 );
+
+ label = new QLabel( tab1 );
+ label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop,
+ KIcon::SizeMedium ) );
+ homePageLayout->addWidget( label );
+
+ label = new QLabel( i18n( "<urlLabel>:", "%1:" ).arg( KABC::Addressee::urlLabel() ), tab1 );
+ mURLEdit = new KLineEdit( tab1 );
+ connect( mURLEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mURLEdit );
+ homePageLayout->addWidget( label );
+ homePageLayout->addWidget( mURLEdit );
+ layout->addMultiCellLayout( homePageLayout, 8, 8, 3, 6 );
+
+ QHBoxLayout *blogLayout = new QHBoxLayout( 0, 11, 7 );
+ label = new QLabel( i18n("Blog feed:"), tab1 );
+ blogLayout->addWidget( label );
+ mBlogEdit = new KLineEdit( tab1 );
+ blogLayout->addWidget( mBlogEdit );
+ connect( mBlogEdit, SIGNAL( textChanged( const QString & ) ),
+ SLOT( textChanged( const QString & ) ) );
+ label->setBuddy( mBlogEdit );
+ layout->addMultiCellLayout( blogLayout, 9, 9, 4, 6 );
+
+ mIMWidget = new IMEditWidget( tab1, mAddressee );
+ connect( mIMWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
+ layout->addMultiCellWidget( mIMWidget, 10, 10, 4, 6 );
+
+ layout->addColSpacing( 6, 50 );
+
+ bar = new KSeparator( KSeparator::HLine, tab1 );
+ layout->addMultiCellWidget( bar, 11, 11, 0, 6 );
+
+ ///////////////////////////////////////
+ QHBox *categoryBox = new QHBox( tab1 );
+ categoryBox->setSpacing( KDialogBase::spacingHint() );
+
+ // Categories
+ mCategoryButton = new QPushButton( i18n( "Select Categories..." ), categoryBox );
+ connect( mCategoryButton, SIGNAL( clicked() ), SLOT( selectCategories() ) );
+
+ mCategoryEdit = new KLineEdit( categoryBox );
+ mCategoryEdit->setReadOnly( true );
+ connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+
+ mSecrecyWidget = new SecrecyWidget( categoryBox );
+ connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
+
+ layout->addMultiCellWidget( categoryBox, 12, 12, 0, 6 );
+
+ // Build the layout and add to the tab widget
+ layout->activate(); // required
+
+ mTabWidget->addTab( tab1, i18n( "&General" ) );
+}
+
+void AddresseeEditorWidget::setupTab2()
+{
+ // This is the Details tab
+ QWidget *tab2 = new QWidget( mTabWidget );
+
+ QGridLayout *layout = new QGridLayout( tab2, 6, 6 );
+ layout->setMargin( KDialogBase::marginHint() );
+ layout->setSpacing( KDialogBase::spacingHint() );
+
+ QLabel *label;
+ KSeparator* bar;
+
+ ///////////////////////
+ // Office info
+
+ // Department
+ label = new QLabel( tab2 );
+ label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop,
+ KIcon::SizeMedium ) );
+ layout->addMultiCellWidget( label, 0, 1, 0, 0 );
+
+ label = new QLabel( i18n( "Department:" ), tab2 );
+ layout->addWidget( label, 0, 1 );
+ mDepartmentEdit = new KLineEdit( tab2 );
+ connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mDepartmentEdit );
+ layout->addWidget( mDepartmentEdit, 0, 2 );
+
+ label = new QLabel( i18n( "Office:" ), tab2 );
+ layout->addWidget( label, 1, 1 );
+ mOfficeEdit = new KLineEdit( tab2 );
+ connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mOfficeEdit );
+ layout->addWidget( mOfficeEdit, 1, 2 );
+
+ label = new QLabel( i18n( "Profession:" ), tab2 );
+ layout->addWidget( label, 2, 1 );
+ mProfessionEdit = new KLineEdit( tab2 );
+ connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mProfessionEdit );
+ layout->addWidget( mProfessionEdit, 2, 2 );
+
+ label = new QLabel( i18n( "Manager\'s name:" ), tab2 );
+ layout->addWidget( label, 0, 3 );
+ mManagerEdit = new KPIM::AddresseeLineEdit( tab2 );
+ connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mManagerEdit );
+ layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 );
+
+ label = new QLabel( i18n( "Assistant's name:" ), tab2 );
+ layout->addWidget( label, 1, 3 );
+ mAssistantEdit = new KPIM::AddresseeLineEdit( tab2 );
+ connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mAssistantEdit );
+ layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 );
+
+ label = new QLabel( i18n( "<titleLabel>:", "%1:" ).arg( KABC::Addressee::titleLabel() ), tab2 );
+ layout->addWidget( label, 2, 3 );
+ mTitleEdit = new KLineEdit( tab2 );
+ connect( mTitleEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mTitleEdit );
+ layout->addMultiCellWidget( mTitleEdit, 2, 2, 4, 5 );
+
+ bar = new KSeparator( KSeparator::HLine, tab2 );
+ layout->addMultiCellWidget( bar, 3, 3, 0, 5 );
+
+ /////////////////////////////////////////////////
+ // Personal info
+
+ label = new QLabel( tab2 );
+ label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop,
+ KIcon::SizeMedium ) );
+ layout->addMultiCellWidget( label, 4, 5, 0, 0 );
+
+ label = new QLabel( i18n( "Nickname:" ), tab2 );
+ layout->addWidget( label, 4, 1 );
+ mNicknameEdit = new KLineEdit( tab2 );
+ connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mNicknameEdit );
+ layout->addWidget( mNicknameEdit, 4, 2 );
+
+ label = new QLabel( i18n( "Partner's name:" ), tab2 );
+ layout->addWidget( label, 5, 1 );
+ mSpouseEdit = new KPIM::AddresseeLineEdit( tab2 );
+ connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mSpouseEdit );
+ layout->addWidget( mSpouseEdit, 5, 2 );
+
+ label = new QLabel( i18n( "Birthdate:" ), tab2 );
+ layout->addWidget( label, 4, 3 );
+ mBirthdayPicker = new KDateEdit( tab2 );
+ connect( mBirthdayPicker, SIGNAL( dateChanged( const QDate& ) ),
+ SLOT( dateChanged( const QDate& ) ) );
+ connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ),
+ SLOT( emitModified() ) );
+ label->setBuddy( mBirthdayPicker );
+ layout->addWidget( mBirthdayPicker, 4, 4 );
+
+ label = new QLabel( i18n( "Anniversary:" ), tab2 );
+ layout->addWidget( label, 5, 3 );
+ mAnniversaryPicker = new KDateEdit( tab2 );
+ connect( mAnniversaryPicker, SIGNAL( dateChanged( const QDate& ) ),
+ SLOT( dateChanged( const QDate& ) ) );
+ connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ),
+ SLOT( emitModified() ) );
+ label->setBuddy( mAnniversaryPicker );
+ layout->addWidget( mAnniversaryPicker, 5, 4 );
+
+ bar = new KSeparator( KSeparator::HLine, tab2 );
+ layout->addMultiCellWidget( bar, 6, 6, 0, 5 );
+
+ //////////////////////////////////////
+ // Notes
+ label = new QLabel( i18n( "Note:" ), tab2 );
+ label->setAlignment( Qt::AlignTop | Qt::AlignLeft );
+ layout->addWidget( label, 7, 0 );
+ mNoteEdit = new QTextEdit( tab2 );
+ mNoteEdit->setWordWrap( QTextEdit::WidgetWidth );
+ mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
+ connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) );
+ label->setBuddy( mNoteEdit );
+ layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 );
+
+ // Build the layout and add to the tab widget
+ layout->activate(); // required
+
+ mTabWidget->addTab( tab2, i18n( "&Details" ) );
+}
+
+void AddresseeEditorWidget::setupAdditionalTabs()
+{
+ ContactEditorWidgetManager *manager = ContactEditorWidgetManager::self();
+
+ // create all tab pages and add the widgets
+ for ( int i = 0; i < manager->count(); ++i ) {
+ QString pageIdentifier = manager->factory( i )->pageIdentifier();
+ QString pageTitle = manager->factory( i )->pageTitle();
+
+ if ( pageIdentifier == "misc" )
+ pageTitle = i18n( "Misc" );
+
+ ContactEditorTabPage *page = mTabPages[ pageIdentifier ];
+ if ( page == 0 ) { // tab not yet available, create one
+ page = new ContactEditorTabPage( mTabWidget );
+ mTabPages.insert( pageIdentifier, page );
+
+ mTabWidget->addTab( page, pageTitle );
+
+ connect( page, SIGNAL( changed() ), SLOT( emitModified() ) );
+ }
+
+ KAB::ContactEditorWidget *widget
+ = manager->factory( i )->createWidget( KABC::StdAddressBook::self( true ),
+ page );
+ if ( widget )
+ page->addWidget( widget );
+ }
+
+ // query the layout update
+ QDictIterator<ContactEditorTabPage> it( mTabPages );
+ for ( ; it.current(); ++it )
+ it.current()->updateLayout();
+}
+
+void AddresseeEditorWidget::setupCustomFieldsTabs()
+{
+ QStringList activePages = KABPrefs::instance()->advancedCustomFields();
+
+ const QStringList list = KGlobal::dirs()->findAllResources( "data", "kaddressbook/contacteditorpages/*.ui", true, true );
+ for ( QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) {
+ if ( activePages.find( (*it).mid( (*it).findRev('/') + 1 ) ) == activePages.end() )
+ continue;
+
+ ContactEditorTabPage *page = new ContactEditorTabPage( mTabWidget );
+ AdvancedCustomFields *wdg = new AdvancedCustomFields( *it, KABC::StdAddressBook::self( true ), page );
+ if ( wdg ) {
+ mTabPages.insert( wdg->pageIdentifier(), page );
+ mTabWidget->addTab( page, wdg->pageTitle() );
+
+ page->addWidget( wdg );
+ page->updateLayout();
+
+ connect( page, SIGNAL( changed() ), SLOT( emitModified() ) );
+ } else
+ delete page;
+ }
+}
+
+void AddresseeEditorWidget::load()
+{
+ kdDebug(5720) << "AddresseeEditorWidget::load()" << endl;
+
+ // Block signals in case anything tries to emit modified
+ // CS: This doesn't seem to work.
+ bool block = signalsBlocked();
+ blockSignals( true );
+ mBlockSignals = true; // used for internal signal blocking
+
+ mNameEdit->blockSignals( true );
+ mNameEdit->setText( mAddressee.assembledName() );
+ mNameEdit->blockSignals( false );
+
+ if ( mAddressee.formattedName().isEmpty() ) {
+ KConfig config( "kaddressbookrc" );
+ config.setGroup( "General" );
+ mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 );
+ mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
+ } else {
+ if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) )
+ mFormattedNameType = NameEditDialog::SimpleName;
+ else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) )
+ mFormattedNameType = NameEditDialog::FullName;
+ else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseNameWithComma ) )
+ mFormattedNameType = NameEditDialog::ReverseNameWithComma;
+ else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) )
+ mFormattedNameType = NameEditDialog::ReverseName;
+ else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::Organization ) )
+ mFormattedNameType = NameEditDialog::Organization;
+ else
+ mFormattedNameType = NameEditDialog::CustomName;
+ }
+
+ mFormattedNameLabel->setText( mAddressee.formattedName() );
+
+ mRoleEdit->setText( mAddressee.role() );
+ mOrgEdit->setText( mAddressee.organization() );
+#if KDE_IS_VERSION(3,5,8)
+ mDepartmentEdit->setText( mAddressee.department() );
+ // compatibility with older versions
+ if ( mAddressee.department().isEmpty() )
+#endif
+ mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) );
+ mURLEdit->setURL( mAddressee.url() );
+ mURLEdit->home( false );
+ mBlogEdit->setURL( mAddressee.custom( "KADDRESSBOOK", "BlogFeed" ) );
+ mNoteEdit->setText( mAddressee.note() );
+ mEmailWidget->setEmails( mAddressee.emails() );
+ mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() );
+ mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() );
+ mBirthdayPicker->setDate( mAddressee.birthday().date() );
+
+ QString anniversaryStr = mAddressee.custom( "KADDRESSBOOK", "X-Anniversary" );
+ QDate anniversary = (anniversaryStr.isEmpty() ? QDate() : QDate::fromString( anniversaryStr, Qt::ISODate ));
+ mAnniversaryPicker->setDate( anniversary );
+ mNicknameEdit->setText( mAddressee.nickName() );
+ mCategoryEdit->setText( mAddressee.categories().join( "," ) );
+
+ mSecrecyWidget->setSecrecy( mAddressee.secrecy() );
+
+ // Load customs
+ mIMWidget->setPreferredIM( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) );
+ mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) );
+ mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) );
+ mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) );
+ mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) );
+ mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) );
+ mTitleEdit->setText( mAddressee.title() );
+
+ QDictIterator<ContactEditorTabPage> it( mTabPages );
+ for ( ; it.current(); ++it )
+ it.current()->loadContact( &mAddressee );
+
+ blockSignals( block );
+ mBlockSignals = false;
+
+ mDirty = false;
+}
+
+void AddresseeEditorWidget::save()
+{
+ if ( !mDirty ) return;
+
+ mAddressee.setRole( mRoleEdit->text() );
+ mAddressee.setOrganization( mOrgEdit->text() );
+#if KDE_IS_VERSION(3,5,8)
+ mAddressee.setDepartment( mDepartmentEdit->text() );
+#else
+ if ( !mDepartmentEdit->text().isEmpty() )
+ mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() );
+ else
+ mAddressee.removeCustom( "KADDRESSBOOK", "X-Department" );
+#endif
+
+ QString homepage = mURLEdit->text().stripWhiteSpace();
+ if ( homepage.isEmpty() )
+ mAddressee.setUrl( KURL() );
+ else {
+ if( !homepage.startsWith("http") )
+ homepage = "http://" + homepage;
+ mAddressee.setUrl( KURL( homepage ) );
+ }
+ if ( !mBlogEdit->text().isEmpty() )
+ mAddressee.insertCustom( "KADDRESSBOOK", "BlogFeed", mBlogEdit->text() );
+ else
+ mAddressee.removeCustom( "KADDRESSBOOK", "BlogFeed" );
+
+ mAddressee.setNote( mNoteEdit->text() );
+ if ( mBirthdayPicker->date().isValid() )
+ mAddressee.setBirthday( QDateTime( mBirthdayPicker->date() ) );
+ else
+ mAddressee.setBirthday( QDateTime() );
+
+ mAddressee.setNickName( mNicknameEdit->text() );
+ mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) );
+
+ mAddressee.setSecrecy( mSecrecyWidget->secrecy() );
+
+ // save custom fields
+ if ( !mIMWidget->preferredIM().isEmpty() )
+ mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMWidget->preferredIM() );
+ else
+ mAddressee.removeCustom( "KADDRESSBOOK", "X-IMAddress" );
+ if ( !mSpouseEdit->text().isEmpty() )
+ mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() );
+ else
+ mAddressee.removeCustom( "KADDRESSBOOK", "X-SpousesName" );
+ if ( !mManagerEdit->text().isEmpty() )
+ mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() );
+ else
+ mAddressee.removeCustom( "KADDRESSBOOK", "X-ManagersName" );
+ if ( !mAssistantEdit->text().isEmpty() )
+ mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() );
+ else
+ mAddressee.removeCustom( "KADDRESSBOOK", "X-AssistantsName" );
+
+ if ( !mOfficeEdit->text().isEmpty() )
+ mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() );
+ else
+ mAddressee.removeCustom( "KADDRESSBOOK", "X-Office" );
+ if ( !mProfessionEdit->text().isEmpty() )
+ mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() );
+ else
+ mAddressee.removeCustom( "KADDRESSBOOK", "X-Profession" );
+
+ if ( mAnniversaryPicker->date().isValid() )
+ mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary",
+ mAnniversaryPicker->date().toString( Qt::ISODate ) );
+ else
+ mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" );
+
+ mAddressee.setTitle( mTitleEdit->text() );
+
+ // Save the email addresses
+ mAddressee.setEmails( mEmailWidget->emails() );
+
+ // Save the phone numbers
+ KABC::PhoneNumber::List phoneNumbers;
+ KABC::PhoneNumber::List::ConstIterator phoneIter;
+ phoneNumbers = mAddressee.phoneNumbers();
+ for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
+ ++phoneIter )
+ mAddressee.removePhoneNumber( *phoneIter );
+
+ phoneNumbers = mPhoneEditWidget->phoneNumbers();
+ for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
+ ++phoneIter )
+ mAddressee.insertPhoneNumber( *phoneIter );
+
+ // Save the addresses
+ KABC::Address::List addresses;
+ KABC::Address::List::ConstIterator addressIter;
+ addresses = mAddressee.addresses();
+ for ( addressIter = addresses.begin(); addressIter != addresses.end();
+ ++addressIter )
+ mAddressee.removeAddress( *addressIter );
+
+ addresses = mAddressEditWidget->addresses();
+ for ( addressIter = addresses.begin(); addressIter != addresses.end();
+ ++addressIter )
+ mAddressee.insertAddress( *addressIter );
+
+ QDictIterator<ContactEditorTabPage> it( mTabPages );
+ for ( ; it.current(); ++it )
+ it.current()->storeContact( &mAddressee );
+
+ mDirty = false;
+}
+
+bool AddresseeEditorWidget::dirty()
+{
+ return mDirty;
+}
+
+void AddresseeEditorWidget::nameTextChanged( const QString &text )
+{
+ // use the addressee class to parse the name for us
+ AddresseeConfig config( mAddressee );
+ if ( config.automaticNameParsing() ) {
+ if ( !mAddressee.formattedName().isEmpty() ) {
+ QString fn = mAddressee.formattedName();
+ mAddressee.setNameFromString( text );
+ mAddressee.setFormattedName( fn );
+ } else {
+ // use extra addressee to avoid a formatted name assignment
+ Addressee addr;
+ addr.setNameFromString( text );
+ mAddressee.setPrefix( addr.prefix() );
+ mAddressee.setGivenName( addr.givenName() );
+ mAddressee.setAdditionalName( addr.additionalName() );
+ mAddressee.setFamilyName( addr.familyName() );
+ mAddressee.setSuffix( addr.suffix() );
+ }
+ }
+
+ nameBoxChanged();
+
+ emitModified();
+}
+
+void AddresseeEditorWidget::organizationTextChanged( const QString &text )
+{
+
+ AddresseeConfig config( mAddressee );
+ if ( config.automaticNameParsing() )
+ mAddressee.setOrganization( text );
+
+ nameBoxChanged();
+
+ mAddressEditWidget->updateAddressee( mAddressee );
+
+ emitModified();
+}
+
+void AddresseeEditorWidget::nameBoxChanged()
+{
+ KABC::Addressee addr;
+ AddresseeConfig config( mAddressee );
+ if ( config.automaticNameParsing() ) {
+ addr.setNameFromString( mNameEdit->text() );
+ mNameLabel->hide();
+ mNameEdit->show();
+ } else {
+ addr = mAddressee;
+ mNameEdit->hide();
+ mNameLabel->setText( mNameEdit->text() );
+ mNameLabel->show();
+ }
+
+ if ( mFormattedNameType != NameEditDialog::CustomName ) {
+ mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
+ mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
+ }
+
+ mAddressEditWidget->updateAddressee( mAddressee );
+}
+
+void AddresseeEditorWidget::nameButtonClicked()
+{
+ // show the name dialog.
+ NameEditDialog dialog( mAddressee, mFormattedNameType, mReadOnly, this );
+
+ if ( dialog.exec() ) {
+ if ( dialog.changed() ) {
+ mAddressee.setFamilyName( dialog.familyName() );
+ mAddressee.setGivenName( dialog.givenName() );
+ mAddressee.setPrefix( dialog.prefix() );
+ mAddressee.setSuffix( dialog.suffix() );
+ mAddressee.setAdditionalName( dialog.additionalName() );
+ mFormattedNameType = dialog.formattedNameType();
+ if ( mFormattedNameType == NameEditDialog::CustomName ) {
+ mFormattedNameLabel->setText( dialog.customFormattedName() );
+ mAddressee.setFormattedName( dialog.customFormattedName() );
+ }
+ // Update the name edit.
+ bool block = mNameEdit->signalsBlocked();
+ mNameEdit->blockSignals( true );
+ mNameEdit->setText( mAddressee.assembledName() );
+ mNameEdit->blockSignals( block );
+
+ // Update the combo box.
+ nameBoxChanged();
+
+ emitModified();
+ }
+ }
+}
+
+void AddresseeEditorWidget::selectCategories()
+{
+ // Show the category dialog
+ if ( mCategorySelectDialog == 0 ) {
+ mCategorySelectDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this );
+ connect( mCategorySelectDialog, SIGNAL( categoriesSelected( const QStringList& ) ),
+ this, SLOT( categoriesSelected( const QStringList& ) ) );
+ connect( mCategorySelectDialog, SIGNAL( editCategories() ),
+ this, SLOT( editCategories() ) );
+ }
+
+ mCategorySelectDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) );
+ mCategorySelectDialog->exec();
+}
+
+void AddresseeEditorWidget::categoriesSelected( const QStringList &list )
+{
+ mCategoryEdit->setText( list.join( "," ) );
+}
+
+void AddresseeEditorWidget::editCategories()
+{
+ if ( mCategoryEditDialog == 0 ) {
+ mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this );
+ connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ),
+ mCategorySelectDialog, SLOT( updateCategoryConfig() ) );
+ }
+
+ mCategoryEditDialog->exec();
+}
+
+void AddresseeEditorWidget::emitModified()
+{
+ if ( mBlockSignals )
+ return;
+
+ mDirty = true;
+
+ emit modified();
+}
+
+void AddresseeEditorWidget::dateChanged( const QDate& )
+{
+ emitModified();
+}
+
+void AddresseeEditorWidget::invalidDate()
+{
+ KMessageBox::sorry( this, i18n( "You must specify a valid date" ) );
+}
+
+void AddresseeEditorWidget::pageChanged( QWidget *wdg )
+{
+ if ( wdg )
+ KAcceleratorManager::manage( wdg );
+}
+
+void AddresseeEditorWidget::setInitialFocus()
+{
+ mNameEdit->setFocus();
+}
+
+bool AddresseeEditorWidget::readyToClose()
+{
+ bool ok = true;
+
+ QDate date = mBirthdayPicker->date();
+ if ( !date.isValid() && !mBirthdayPicker->currentText().isEmpty() ) {
+ KMessageBox::error( this, i18n( "You have to enter a valid birthdate." ) );
+ ok = false;
+ }
+
+ date = mAnniversaryPicker->date();
+ if ( !date.isValid() && !mAnniversaryPicker->currentText().isEmpty() ) {
+ KMessageBox::error( this, i18n( "You have to enter a valid anniversary." ) );
+ ok = false;
+ }
+
+ return ok;
+}
+
+void AddresseeEditorWidget::setReadOnly( bool readOnly )
+{
+ mReadOnly = readOnly;
+
+ mNameEdit->setReadOnly( readOnly );
+ mRoleEdit->setReadOnly( readOnly );
+ mOrgEdit->setReadOnly( readOnly );
+ mPhoneEditWidget->setReadOnly( readOnly );
+ mAddressEditWidget->setReadOnly( readOnly );
+ mEmailWidget->setReadOnly( readOnly );
+ mURLEdit->setReadOnly( readOnly );
+ mBlogEdit->setReadOnly( readOnly );
+ mIMWidget->setReadOnly( readOnly );
+ mCategoryButton->setEnabled( !readOnly );
+ mSecrecyWidget->setReadOnly( readOnly );
+ mDepartmentEdit->setReadOnly( readOnly );
+ mOfficeEdit->setReadOnly( readOnly );
+ mProfessionEdit->setReadOnly( readOnly );
+ mManagerEdit->setReadOnly( readOnly );
+ mAssistantEdit->setReadOnly( readOnly );
+ mTitleEdit->setReadOnly( readOnly );
+ mNicknameEdit->setReadOnly( readOnly );
+ mSpouseEdit->setReadOnly( readOnly );
+ mBirthdayPicker->setEnabled( !readOnly );
+ mAnniversaryPicker->setEnabled( !readOnly );
+ mNoteEdit->setReadOnly( mReadOnly );
+
+ QDictIterator<ContactEditorTabPage> it( mTabPages );
+ for ( ; it.current(); ++it )
+ it.current()->setReadOnly( readOnly );
+}
+
+#include "addresseeeditorwidget.moc"
diff --git a/kaddressbook/addresseeeditorwidget.h b/kaddressbook/addresseeeditorwidget.h
new file mode 100644
index 00000000..93917245
--- /dev/null
+++ b/kaddressbook/addresseeeditorwidget.h
@@ -0,0 +1,167 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef ADDRESSEEEDITORWIDGET_H
+#define ADDRESSEEEDITORWIDGET_H
+
+#include <qdatetime.h>
+
+#include <kabc/addressee.h>
+#include <kdialogbase.h>
+#include <kjanuswidget.h>
+
+#include "addresseeeditorbase.h"
+#include "contacteditorwidgetmanager.h"
+#include "extensionwidget.h"
+
+class QCheckBox;
+class QSpinBox;
+class QTabWidget;
+class QTextEdit;
+
+class KComboBox;
+class KDateEdit;
+class KLineEdit;
+class KSqueezedTextLabel;
+
+class AddressEditWidget;
+class EmailEditWidget;
+class IMEditWidget;
+class KeyWidget;
+class PhoneEditWidget;
+class SecrecyWidget;
+
+namespace KAB {
+class Core;
+}
+
+namespace KPIM {
+class AddresseeLineEdit;
+class CategorySelectDialog;
+class CategoryEditDialog;
+}
+
+namespace KABC { class AddressBook; }
+
+class AddresseeEditorWidget : public AddresseeEditorBase
+{
+ Q_OBJECT
+
+ public:
+ AddresseeEditorWidget( QWidget *parent, const char *name = 0 );
+ ~AddresseeEditorWidget();
+
+ void setAddressee( const KABC::Addressee& );
+ const KABC::Addressee &addressee();
+
+ void load();
+ void save();
+
+ bool dirty();
+
+ void setInitialFocus();
+
+ bool readyToClose();
+
+ protected slots:
+ void textChanged( const QString& );
+ void pageChanged( QWidget *wdg );
+
+ /**
+ Emits the modified signal and sets the dirty flag. Any slot
+ that modifies data should use this method instead of calling emit
+ modified() directly.
+ */
+ void emitModified();
+
+ void dateChanged( const QDate& );
+ void invalidDate();
+ void nameTextChanged( const QString& );
+ void organizationTextChanged( const QString& );
+ void nameBoxChanged();
+ void nameButtonClicked();
+ void selectCategories();
+
+ /**
+ Called whenever the categories change in the categories dialog.
+ */
+ void categoriesSelected( const QStringList& );
+
+ /**
+ Edits which categories are available in the CategorySelectDialog.
+ */
+ void editCategories();
+
+ private:
+ void initGUI();
+ void setupTab1();
+ void setupTab2();
+ void setupAdditionalTabs();
+ void setupCustomFieldsTabs();
+
+ void setReadOnly( bool );
+
+ KABC::Addressee mAddressee;
+ int mFormattedNameType;
+ bool mDirty;
+ bool mBlockSignals;
+ bool mReadOnly;
+
+ // GUI
+ KPIM::CategorySelectDialog *mCategorySelectDialog;
+ KPIM::CategoryEditDialog *mCategoryEditDialog;
+ QTabWidget *mTabWidget;
+
+ // Tab1
+ KLineEdit *mNameEdit;
+ KLineEdit *mRoleEdit;
+ KLineEdit *mOrgEdit;
+ KSqueezedTextLabel *mFormattedNameLabel;
+ AddressEditWidget *mAddressEditWidget;
+ EmailEditWidget *mEmailWidget;
+ IMEditWidget *mIMWidget;
+ PhoneEditWidget *mPhoneEditWidget;
+ KLineEdit *mURLEdit;
+ KLineEdit *mBlogEdit;
+ QPushButton *mCategoryButton;
+ KLineEdit *mCategoryEdit;
+ SecrecyWidget *mSecrecyWidget;
+ KSqueezedTextLabel *mNameLabel;
+
+ // Tab2
+ KLineEdit *mDepartmentEdit;
+ KLineEdit *mOfficeEdit;
+ KLineEdit *mProfessionEdit;
+ KLineEdit *mTitleEdit;
+ KPIM::AddresseeLineEdit *mManagerEdit;
+ KPIM::AddresseeLineEdit *mAssistantEdit;
+ KLineEdit *mNicknameEdit;
+ KPIM::AddresseeLineEdit *mSpouseEdit;
+ KDateEdit *mBirthdayPicker;
+ KDateEdit *mAnniversaryPicker;
+ QTextEdit *mNoteEdit;
+
+ QDict<ContactEditorTabPage> mTabPages;
+};
+
+#endif
diff --git a/kaddressbook/addresseeutil.cpp b/kaddressbook/addresseeutil.cpp
new file mode 100644
index 00000000..e84cfea0
--- /dev/null
+++ b/kaddressbook/addresseeutil.cpp
@@ -0,0 +1,55 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <kabc/stdaddressbook.h>
+#include <kabc/vcardconverter.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "addresseeutil.h"
+
+QString AddresseeUtil::addresseesToClipboard( const KABC::Addressee::List &list )
+{
+ KABC::VCardConverter converter;
+
+ return converter.createVCards( list );
+}
+
+KABC::Addressee::List AddresseeUtil::clipboardToAddressees( const QString &data )
+{
+ KABC::VCardConverter converter;
+
+ return converter.parseVCards( data );
+}
+
+QString AddresseeUtil::addresseesToEmails( const KABC::Addressee::List &addrList )
+{
+ QStringList emails;
+
+ KABC::Addressee::List::ConstIterator it;
+ for ( it = addrList.begin(); it != addrList.end(); ++it )
+ emails.append( (*it).fullEmail() );
+
+ return emails.join( "," );
+}
diff --git a/kaddressbook/addresseeutil.h b/kaddressbook/addresseeutil.h
new file mode 100644
index 00000000..1b67fcf3
--- /dev/null
+++ b/kaddressbook/addresseeutil.h
@@ -0,0 +1,66 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef ADDRESSEEUTIL_H
+#define ADDRESSEEUTIL_H
+
+#include <qstring.h>
+#include <kabc/addressee.h>
+
+/**
+ This class provides some utility methods for transposing an
+ addressee to different types (ie: clipboard). This class
+ is probably just temporary until these function stablize and move
+ to KABC.
+
+ NOTE: Currently these methods are not implemented properly. The
+ vCard parser in KABC needs to be updated and there is no way to get from
+ KABC::Addressee to vCard.
+*/
+class AddresseeUtil
+{
+ public:
+ /**
+ Same as above function, except that an entire list of KABC::Addressee
+ objects will be converted to vCard and put in the string.
+ */
+ static QString addresseesToClipboard( const KABC::Addressee::List &addrList );
+
+ /**
+ Convert a string from the clipboard into a list of addressee objects.
+ If the clipboard text was not a valid vcard, an empty list
+ will be returned.
+ */
+ static KABC::Addressee::List clipboardToAddressees( const QString &clipboard );
+
+ /**
+ Converts the list of addressee objects into a list of email addresses.
+ */
+ static QString addresseesToEmails( const KABC::Addressee::List &addrList );
+
+ private:
+ AddresseeUtil() {}
+ ~AddresseeUtil() {}
+};
+
+#endif
diff --git a/kaddressbook/addviewdialog.cpp b/kaddressbook/addviewdialog.cpp
new file mode 100644
index 00000000..68046359
--- /dev/null
+++ b/kaddressbook/addviewdialog.cpp
@@ -0,0 +1,110 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qbuttongroup.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qradiobutton.h>
+
+#include <klocale.h>
+
+#include "kaddressbookview.h"
+
+#include "addviewdialog.h"
+
+AddViewDialog::AddViewDialog( QDict<ViewFactory> *viewFactoryDict,
+ QWidget *parent, const char *name )
+ : KDialogBase( KDialogBase::Plain, i18n( "Add View" ),
+ KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
+ parent, name ),
+ mViewFactoryDict( viewFactoryDict )
+{
+ mTypeId = 0;
+
+ QWidget *page = plainPage();
+
+ QGridLayout *layout = new QGridLayout( page, 2, 2 );
+ layout->setSpacing( spacingHint() );
+ layout->setRowStretch( 1, 1 );
+ layout->setColStretch( 1, 1 );
+
+ QLabel *label = new QLabel( i18n( "View name:" ), page );
+ layout->addWidget( label, 0, 0 );
+
+ mViewNameEdit = new QLineEdit( page );
+ connect( mViewNameEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ layout->addWidget( mViewNameEdit, 0, 1 );
+
+ mTypeGroup = new QButtonGroup( 0, Qt::Horizontal, i18n( "View Type" ), page );
+ connect( mTypeGroup, SIGNAL( clicked( int ) ), this, SLOT( clicked( int ) ) );
+ layout->addMultiCellWidget( mTypeGroup, 1, 1, 0, 1 );
+ QGridLayout *groupLayout = new QGridLayout( mTypeGroup->layout(), 3, 2 );
+ groupLayout->setSpacing( spacingHint() );
+
+ int row = 0;
+ QDictIterator<ViewFactory> iter( *mViewFactoryDict );
+ for ( iter.toFirst(); iter.current(); ++iter ) {
+ QRadioButton *button = new QRadioButton( i18n((*iter)->type().utf8()),
+ mTypeGroup, (*iter)->type().latin1() );
+ label = new QLabel( (*iter)->description(), mTypeGroup );
+ label->setAlignment( Qt::WordBreak );
+
+ groupLayout->addWidget( button, row, 0, Qt::AlignTop );
+ groupLayout->addWidget( label, row, 1, Qt::AlignTop );
+
+ row++;
+ }
+
+ mTypeGroup->setButton( 0 );
+ mViewNameEdit->setFocus();
+ enableButton( KDialogBase::Ok, false );
+}
+
+AddViewDialog::~AddViewDialog()
+{
+}
+
+QString AddViewDialog::viewName()const
+{
+ return mViewNameEdit->text();
+}
+
+QString AddViewDialog::viewType()const
+{
+ // we missuse the name property for storing the type
+ return mTypeGroup->find( mTypeId )->name();
+}
+
+void AddViewDialog::clicked( int id )
+{
+ mTypeId = id;
+}
+
+void AddViewDialog::textChanged( const QString &text )
+{
+ enableButton( KDialogBase::Ok, !text.isEmpty() );
+}
+
+#include "addviewdialog.moc"
diff --git a/kaddressbook/addviewdialog.h b/kaddressbook/addviewdialog.h
new file mode 100644
index 00000000..972f6ef3
--- /dev/null
+++ b/kaddressbook/addviewdialog.h
@@ -0,0 +1,73 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef ADDVIEWDIALOG_H
+#define ADDVIEWDIALOG_H
+
+#include <kdialogbase.h>
+#include <qdict.h>
+#include <qstring.h>
+
+class QButtonGroup;
+class QLineEdit;
+class ViewFactory;
+
+
+/**
+ Modal dialog used for adding a new view. The dialog asks for the name of
+ the view as well as the type. Someday it would be nice for this to be a
+ wizard.
+ */
+class AddViewDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ AddViewDialog( QDict<ViewFactory> *viewFactoryDict, QWidget *parent,
+ const char *name = 0 );
+ ~AddViewDialog();
+
+ QString viewName()const;
+
+ QString viewType()const ;
+
+ protected slots:
+ /**
+ Called when the user selects a type radio button.
+ */
+ void clicked( int id );
+
+ /**
+ Called when the user changes the text in the name of the view.
+ */
+ void textChanged( const QString &text );
+
+ private:
+ QDict<ViewFactory> *mViewFactoryDict;
+ QLineEdit *mViewNameEdit;
+ QButtonGroup *mTypeGroup;
+
+ int mTypeId;
+};
+
+#endif
diff --git a/kaddressbook/advancedcustomfields.cpp b/kaddressbook/advancedcustomfields.cpp
new file mode 100644
index 00000000..ad630835
--- /dev/null
+++ b/kaddressbook/advancedcustomfields.cpp
@@ -0,0 +1,148 @@
+/*
+ This file is part of KAddressbook.
+
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+ Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qdatetimeedit.h>
+#include <qlayout.h>
+#include <qobjectlist.h>
+#include <qspinbox.h>
+#include <qregexp.h>
+#include <qtextedit.h>
+#include <qwidgetfactory.h>
+
+#include <kdatepicker.h>
+#include <kdatetimewidget.h>
+#include <kdialog.h>
+#include <klineedit.h>
+#include <kstandarddirs.h>
+
+#include <libkdepim/designerfields.h>
+
+#include "customfieldswidget.h"
+
+#include "advancedcustomfields.h"
+
+class KABCStorage : public KPIM::DesignerFields::Storage
+{
+ public:
+ KABCStorage( KABC::Addressee *a, const QString &ns )
+ : mAddressee( a ), mNs( ns )
+ {
+ }
+
+ QStringList keys()
+ {
+ QStringList keys;
+
+ const QStringList customs = mAddressee->customs();
+ QStringList::ConstIterator it;
+ for ( it = customs.begin(); it != customs.end(); ++it ) {
+ QString app, name, value;
+ splitField( *it, app, name, value );
+ if ( app == mNs ) keys.append( name );
+ }
+
+ return keys;
+ }
+
+ QString read( const QString &key )
+ {
+ return mAddressee->custom( mNs, key );
+ }
+
+ void write( const QString &key, const QString &value )
+ {
+ mAddressee->insertCustom( mNs, key, value );
+ }
+
+ private:
+ KABC::Addressee *mAddressee;
+ QString mNs;
+};
+
+
+AdvancedCustomFields::AdvancedCustomFields( const QString &uiFile, KABC::AddressBook *ab,
+ QWidget *parent, const char *name )
+ : KAB::ContactEditorWidget( ab, parent, name )
+{
+ initGUI( uiFile );
+}
+
+void AdvancedCustomFields::loadContact( KABC::Addressee *addr )
+{
+ QString ns;
+ if ( mFields->identifier().upper() == "KADDRESSBOOK" ||
+ QRegExp( "^Form\\d\\d?$" ).search( mFields->identifier() ) >= 0 ) {
+ ns = "KADDRESSBOOK";
+ } else {
+ ns = mFields->identifier();
+ }
+
+ KABCStorage storage( addr, ns );
+ mFields->load( &storage );
+}
+
+void AdvancedCustomFields::storeContact( KABC::Addressee *addr )
+{
+ QString ns;
+ if ( mFields->identifier().upper() == "KADDRESSBOOK" ||
+ QRegExp( "^Form\\d\\d?$" ).search( mFields->identifier() ) >= 0 ) {
+ ns = "KADDRESSBOOK";
+ } else {
+ ns = mFields->identifier();
+ }
+
+ KABCStorage storage( addr, ns );
+ mFields->save( &storage );
+}
+
+void AdvancedCustomFields::setReadOnly( bool readOnly )
+{
+ mFields->setReadOnly( readOnly );
+}
+
+void AdvancedCustomFields::initGUI( const QString &uiFile )
+{
+ QVBoxLayout *layout = new QVBoxLayout( this, KDialog::marginHint(),
+ KDialog::spacingHint() );
+
+ mFields = new KPIM::DesignerFields( uiFile, this );
+ layout->addWidget( mFields );
+
+ connect( mFields, SIGNAL( modified() ), SLOT( setModified() ) );
+}
+
+QString AdvancedCustomFields::pageIdentifier() const
+{
+ return mFields->identifier();
+}
+
+QString AdvancedCustomFields::pageTitle() const
+{
+ return mFields->title();
+}
+
+#include "advancedcustomfields.moc"
diff --git a/kaddressbook/advancedcustomfields.h b/kaddressbook/advancedcustomfields.h
new file mode 100644
index 00000000..b997ffb9
--- /dev/null
+++ b/kaddressbook/advancedcustomfields.h
@@ -0,0 +1,60 @@
+/*
+ This file is part of KAddressbook.
+
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+ Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef ADVANCEDCUSTOMFIELDS_H
+#define ADVANCEDCUSTOMFIELDS_H
+
+#include <klocale.h>
+
+#include <qmap.h>
+#include <qpair.h>
+#include <qstringlist.h>
+
+#include <libkdepim/designerfields.h>
+
+#include "contacteditorwidget.h"
+
+class AdvancedCustomFields : public KAB::ContactEditorWidget
+{
+ Q_OBJECT
+
+ public:
+ AdvancedCustomFields( const QString &uiFile, KABC::AddressBook *ab,
+ QWidget *parent, const char *name = 0 );
+
+ void loadContact( KABC::Addressee *addr );
+ void storeContact( KABC::Addressee *addr );
+ void setReadOnly( bool readOnly );
+
+ QString pageIdentifier() const;
+ QString pageTitle() const;
+
+ private:
+ void initGUI( const QString& );
+
+ KPIM::DesignerFields *mFields;
+};
+
+#endif
diff --git a/kaddressbook/common/Makefile.am b/kaddressbook/common/Makefile.am
new file mode 100644
index 00000000..63a0951d
--- /dev/null
+++ b/kaddressbook/common/Makefile.am
@@ -0,0 +1,12 @@
+INCLUDES= -I$(top_srcdir)/kaddressbook/interfaces \
+ -I$(top_srcdir) \
+ $(all_includes)
+
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libkabcommon.la
+libkabcommon_la_SOURCES = kabprefs.cpp kabprefs_base.kcfgc locationmap.cpp filter.cpp
+libkabcommon_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
+libkabcommon_la_LIBADD = $(top_builddir)/kaddressbook/interfaces/libkabinterfaces.la \
+ $(top_builddir)/libkdepim/libkdepim.la
+noinst_HEADERS = filter.h kabprefs.h
diff --git a/kaddressbook/common/filter.cpp b/kaddressbook/common/filter.cpp
new file mode 100644
index 00000000..ccac46ef
--- /dev/null
+++ b/kaddressbook/common/filter.cpp
@@ -0,0 +1,219 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <kconfig.h>
+#include <kdebug.h>
+
+#include "kabprefs.h"
+
+#include "filter.h"
+
+Filter::Filter()
+ : mName( QString::null ), mMatchRule( Matching ), mEnabled( true ),
+ mInternal( false ), mIsEmpty( true )
+{
+}
+
+Filter::Filter( const QString &name )
+ : mName( name ), mMatchRule( Matching ), mEnabled( true ),
+ mInternal( false ), mIsEmpty( false )
+{
+}
+
+Filter::~Filter()
+{
+}
+
+void Filter::setName( const QString &name )
+{
+ mName = name;
+
+ mIsEmpty = false;
+}
+
+const QString &Filter::name() const
+{
+ return mName;
+}
+
+bool Filter::isInternal() const
+{
+ return mInternal;
+}
+
+void Filter::apply( KABC::Addressee::List &addresseeList )
+{
+ KABC::Addressee::List::Iterator iter;
+ for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) {
+ if ( filterAddressee( *iter ) )
+ ++iter;
+ else
+ iter = addresseeList.erase( iter );
+ }
+}
+
+bool Filter::filterAddressee( const KABC::Addressee &a ) const
+{
+ QStringList::ConstIterator iter;
+ iter = mCategoryList.begin();
+ // empty filter always matches
+
+ if ( iter == mCategoryList.end() ) {
+ if ( mMatchRule == Matching )
+ return true;
+ else {
+ if ( a.categories().empty() )
+ return true;
+ else
+ return false;
+ }
+ }
+
+ for ( ; iter != mCategoryList.end(); ++iter ) {
+ if ( a.hasCategory( *iter ) )
+ return ( mMatchRule == Matching );
+ }
+
+ return !( mMatchRule == Matching );
+}
+
+void Filter::setEnabled( bool on )
+{
+ mEnabled = on;
+
+ mIsEmpty = false;
+}
+
+bool Filter::isEnabled() const
+{
+ return mEnabled;
+}
+
+void Filter::setCategories( const QStringList &list )
+{
+ mCategoryList = list;
+
+ mIsEmpty = false;
+}
+
+const QStringList &Filter::categories() const
+{
+ return mCategoryList;
+}
+
+void Filter::save( KConfig *config )
+{
+ config->writeEntry( "Name", mName );
+ config->writeEntry( "Enabled", mEnabled );
+ config->writeEntry( "Categories", mCategoryList );
+ config->writeEntry( "MatchRule", (int)mMatchRule );
+}
+
+void Filter::restore( KConfig *config )
+{
+ mName = config->readEntry( "Name", "<internal error>" );
+ mEnabled = config->readBoolEntry( "Enabled", true );
+ mCategoryList = config->readListEntry( "Categories" );
+ mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching );
+
+ mIsEmpty = false;
+}
+
+void Filter::save( KConfig *config, const QString &baseGroup, Filter::List &list )
+{
+ {
+ KConfigGroupSaver s( config, baseGroup );
+
+ // remove the old filters
+ uint count = config->readNumEntry( "Count" );
+ for ( uint i = 0; i < count; ++i )
+ config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) );
+
+ }
+
+ int index = 0;
+ Filter::List::Iterator iter;
+ for ( iter = list.begin(); iter != list.end(); ++iter ) {
+ if ( !(*iter).mInternal ) {
+ KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup )
+ .arg( index ) );
+ (*iter).save( config );
+ index++;
+ }
+ }
+
+ KConfigGroupSaver s( config, baseGroup );
+ config->writeEntry( "Count", index );
+}
+
+Filter::List Filter::restore( KConfig *config, const QString &baseGroup )
+{
+ Filter::List list;
+ int count = 0;
+ Filter f;
+
+ {
+ KConfigGroupSaver s( config, baseGroup );
+ count = config->readNumEntry( "Count", 0 );
+ }
+
+ for ( int i = 0; i < count; i++ ) {
+ {
+ KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) );
+ f.restore( config );
+ }
+
+ list.append( f );
+ }
+
+ const QStringList cats = KABPrefs::instance()->customCategories();
+ for ( QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it ) {
+ Filter filter;
+ filter.mName = *it;
+ filter.mEnabled = true;
+ filter.mCategoryList = *it;
+ filter.mMatchRule = Matching;
+ filter.mInternal = true;
+ filter.mIsEmpty = false;
+ list.append( filter );
+ }
+
+ return list;
+}
+
+void Filter::setMatchRule( MatchRule rule )
+{
+ mMatchRule = rule;
+
+ mIsEmpty = false;
+}
+
+Filter::MatchRule Filter::matchRule() const
+{
+ return mMatchRule;
+}
+
+bool Filter::isEmpty() const
+{
+ return mIsEmpty;
+}
diff --git a/kaddressbook/common/filter.h b/kaddressbook/common/filter.h
new file mode 100644
index 00000000..9251c5c1
--- /dev/null
+++ b/kaddressbook/common/filter.h
@@ -0,0 +1,160 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef FILTER_H
+#define FILTER_H
+
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qvaluelist.h>
+
+#include <kabc/addressee.h>
+#include <kconfig.h>
+
+/**
+ Filter for AddressBook related objects (Addressees)
+
+ @todo This class should be switched to use shared data.
+ */
+class Filter
+{
+ public:
+ typedef QValueList<Filter> List;
+
+ enum MatchRule { Matching = 0, NotMatching = 1 };
+
+ Filter();
+ Filter( const QString& name );
+ ~Filter();
+
+ /**
+ Set the name of the filter.
+ */
+ void setName( const QString &name );
+
+ /**
+ @return The name of the filter.
+ */
+ const QString &name() const;
+
+ /**
+ @return Whether the filter is an internal one.
+ */
+ bool isInternal() const;
+
+ /**
+ Apply the filter to the addressee list. All addressees not passing
+ the filter criterias will be removed from the list.
+
+ If the MatchRule is NotMatch, then all the addressees matching the
+ filter will be removed from the list.
+ */
+ void apply( KABC::Addressee::List &addresseeList );
+
+ /**
+ Apply the filter to the addressee.
+
+ @return True if the addressee passes the criteria, false otherwise.
+ The return values are opposite if the MatchRule is NotMatch.
+ */
+ bool filterAddressee( const KABC::Addressee &a ) const;
+
+ /**
+ Enable or disable the filter
+ */
+ void setEnabled( bool on );
+
+ /**
+ @return True if this filter is enabled, false otherwise.
+ */
+ bool isEnabled() const;
+
+ /**
+ Set the list of categories. This list is used to filter addressees.
+ */
+ void setCategories( const QStringList &list );
+
+ /**
+ @return The list of categories.
+ */
+ const QStringList &categories() const;
+
+ /**
+ Saves the filter to the config file. The group should already be set.
+ */
+ void save( KConfig *config );
+
+ /**
+ Loads the filter from the config file. The group should already be set.
+ */
+ void restore( KConfig *config );
+
+ /**
+ Saves a list of filters to the config file.
+
+ @param config The config file to use
+ @param baseGroup The base groupname to use. The number of filters
+ will be written to this group, then a _1, _2, etc
+ will be append for each filter saved.
+ @param list The list of filters to be saved.
+ */
+ static void save( KConfig *config, const QString &baseGroup, Filter::List &list );
+
+ /**
+ Restores a list of filters from a config file.
+
+ @param config The config file to read from.
+ @param baseGroup The base group name to be used to find the filters
+
+ @return The list of filters.
+ */
+ static Filter::List restore( KConfig *config, const QString &baseGroup );
+
+ /**
+ Sets the filter rule. If the rule is Filter::Matching (default),
+ then the filter will return true on items that match the filter.
+ If the rule is Filter::NotMatching, then the filter will return
+ true on items that do not match the filter.
+ */
+ void setMatchRule( MatchRule rule );
+
+ /**
+ @return The current match rule.
+ */
+ MatchRule matchRule() const;
+
+ /**
+ @return true if the category list is empty.
+ */
+ bool isEmpty() const;
+
+ private:
+ QString mName;
+ QStringList mCategoryList;
+ MatchRule mMatchRule;
+ bool mEnabled;
+ bool mInternal;
+ bool mIsEmpty;
+};
+
+#endif
diff --git a/kaddressbook/common/kabprefs.cpp b/kaddressbook/common/kabprefs.cpp
new file mode 100644
index 00000000..e8402d56
--- /dev/null
+++ b/kaddressbook/common/kabprefs.cpp
@@ -0,0 +1,82 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <kconfig.h>
+#include <klocale.h>
+#include <kstaticdeleter.h>
+
+#include "kabprefs.h"
+
+KABPrefs *KABPrefs::mInstance = 0;
+static KStaticDeleter<KABPrefs> staticDeleter;
+
+KABPrefs::KABPrefs()
+ : KABPrefsBase()
+{
+ KConfigSkeleton::setCurrentGroup( "General" );
+
+ QStringList defaultMap;
+ defaultMap << "http://maps.google.com/maps?f=q&hl=%1&q=%n,%l,%s";
+ addItemString( "LocationMapURL", mLocationMapURL, defaultMap[ 0 ] );
+ addItemStringList( "LocationMapURLs", mLocationMapURLs, defaultMap );
+}
+
+KABPrefs::~KABPrefs()
+{
+}
+
+KABPrefs *KABPrefs::instance()
+{
+ if ( !mInstance ) {
+ staticDeleter.setObject( mInstance, new KABPrefs() );
+ mInstance->readConfig();
+ }
+
+ return mInstance;
+}
+
+void KABPrefs::setCategoryDefaults()
+{
+ mCustomCategories.clear();
+ mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
+ << i18n( "Customer" ) << i18n( "Friend" );
+}
+
+void KABPrefs::usrReadConfig()
+{
+ config()->setGroup( "General" );
+ mCustomCategories = config()->readListEntry( "Custom Categories" );
+ if ( mCustomCategories.isEmpty() )
+ setCategoryDefaults();
+
+ KPimPrefs::usrReadConfig();
+}
+
+
+void KABPrefs::usrWriteConfig()
+{
+ config()->setGroup( "General" );
+ config()->writeEntry( "Custom Categories", mCustomCategories );
+
+ KPimPrefs::usrWriteConfig();
+}
diff --git a/kaddressbook/common/kabprefs.h b/kaddressbook/common/kabprefs.h
new file mode 100644
index 00000000..3c2db152
--- /dev/null
+++ b/kaddressbook/common/kabprefs.h
@@ -0,0 +1,86 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KABPREFS_H
+#define KABPREFS_H
+
+#include <qstringlist.h>
+#include <kdepimmacros.h>
+#include "kabprefs_base.h"
+
+class KConfig;
+
+class KDE_EXPORT KABPrefs : public KABPrefsBase
+{
+ public:
+ virtual ~KABPrefs();
+
+ static KABPrefs *instance();
+
+ void usrReadConfig();
+ void usrWriteConfig();
+
+ void setLocationMapURL( const QString &locationMapURL )
+ {
+ if ( !isImmutable( QString::fromLatin1( "LocationMapURL" ) ) )
+ mLocationMapURL = locationMapURL;
+ }
+
+ QString locationMapURL() const
+ {
+ return mLocationMapURL;
+ }
+
+ void setLocationMapURLs( const QStringList &locationMapURLs )
+ {
+ if ( !isImmutable( QString::fromLatin1( "LocationMapURLs" ) ) )
+ mLocationMapURLs = locationMapURLs;
+ }
+
+ QStringList locationMapURLs() const
+ {
+ return mLocationMapURLs;
+ }
+
+ QStringList customCategories() const
+ {
+ return mCustomCategories;
+ }
+
+ void setCustomCategories(const QStringList & s)
+ {
+ mCustomCategories = s;
+ }
+
+ void setCategoryDefaults();
+
+ private:
+ KABPrefs();
+
+ static KABPrefs *mInstance;
+
+ QString mLocationMapURL;
+ QStringList mLocationMapURLs;
+};
+
+#endif
diff --git a/kaddressbook/common/kabprefs_base.kcfgc b/kaddressbook/common/kabprefs_base.kcfgc
new file mode 100644
index 00000000..cca2c933
--- /dev/null
+++ b/kaddressbook/common/kabprefs_base.kcfgc
@@ -0,0 +1,11 @@
+# Code generation options for kconfig_compiler
+File=kaddressbook.kcfg
+ClassName=KABPrefsBase
+Singleton=false
+Mutators=true
+Inherits=KPimPrefs
+IncludeFiles=libkdepim/kpimprefs.h
+MemberVariables=public
+GlobalEnums=true
+ItemAccessors=true
+SetUserTexts=true
diff --git a/kaddressbook/common/kaddressbook.kcfg b/kaddressbook/common/kaddressbook.kcfg
new file mode 100644
index 00000000..37e6ff0a
--- /dev/null
+++ b/kaddressbook/common/kaddressbook.kcfg
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile name="kaddressbookrc"/>
+
+ <group name="General">
+ <entry type="Bool" name="AutomaticNameParsing">
+ <label>Automatic name parsing for new addressees</label>
+ <whatsthis></whatsthis>
+ <default>true</default>
+ </entry>
+ <entry type="Int" name="CurrentIncSearchField">
+ <default>0</default>
+ </entry>
+ <entry type="String" name="PhoneHookApplication">
+ <label>Phone</label>
+ <whatsthis></whatsthis>
+ </entry>
+ <entry type="String" name="FaxHookApplication">
+ <label>Fax</label>
+ <whatsthis></whatsthis>
+ <default>kdeprintfax --phone %N</default>
+ </entry>
+ <entry type="String" name="SMSHookApplication">
+ <label>SMS</label>
+ <whatsthis>The script used to send a GSM SMS text message to the mobile phone</whatsthis>
+ </entry>
+ </group>
+
+ <group name="Views">
+ <entry type="Bool" name="HonorSingleClick">
+ <label>Honor KDE single click</label>
+ <whatsthis></whatsthis>
+ <default>false</default>
+ </entry>
+ <entry type="String" name="CurrentView">
+ <default>Default Table View</default>
+ </entry>
+ <entry type="StringList" name="ViewNames">
+ <default>Default Table View</default>
+ </entry>
+ </group>
+
+ <group name="MainWindow">
+ <entry type="Bool" name="JumpButtonBarVisible">
+ <default>false</default>
+ </entry>
+ <entry type="Bool" name="DetailsPageVisible">
+ <default>true</default>
+ </entry>
+ <entry type="IntList" name="DetailsSplitter">
+ </entry>
+ <entry type="IntList" name="LeftSplitter">
+ </entry>
+ <entry type="Bool" name="ContactListAboveExtensions">
+ <default>true</default>
+ <whatsthis>If true, the contact list will be placed above the extensions on the left (distribution list editor etc.) instead of in the middle of the main window</whatsthis>
+
+ </entry>
+ </group>
+
+ <group name="ExtensionsGeneral">
+ <entry type="String" name="CurrentExtension">
+ <default>resourceselection</default>
+ </entry>
+ <entry type="StringList" name="activeExtensions">
+ <default>distribution_list_editor_ng,resourceselection</default>
+ </entry>
+ <entry type="IntList" name="ExtensionsSplitterSizes"/>
+ </group>
+
+ <group name="Filters">
+ <entry type="Int" name="CurrentFilter">
+ <default>0</default>
+ </entry>
+ </group>
+
+ <group name="AddresseeEditor">
+ <entry type="Enum" name="EditorType">
+ <choices>
+ <choice name="FullEditor"/>
+ <choice name="SimpleEditor"/>
+ </choices>
+ <default>FullEditor</default>
+ </entry>
+ <entry type="StringList" name="GlobalCustomFields">
+ </entry>
+ <entry type="StringList" name="AdvancedCustomFields">
+ </entry>
+ </group>
+</kcfg>
diff --git a/kaddressbook/common/locationmap.cpp b/kaddressbook/common/locationmap.cpp
new file mode 100644
index 00000000..92bdfaab
--- /dev/null
+++ b/kaddressbook/common/locationmap.cpp
@@ -0,0 +1,96 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdeversion.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kstaticdeleter.h>
+#include <kurl.h>
+
+#include "kabprefs.h"
+#include "locationmap.h"
+
+LocationMap *LocationMap::mSelf = 0;
+static KStaticDeleter<LocationMap> locationMapDeleter;
+
+LocationMap::LocationMap()
+{
+}
+
+LocationMap::~LocationMap()
+{
+}
+
+LocationMap *LocationMap::instance()
+{
+ if ( !mSelf )
+ locationMapDeleter.setObject( mSelf, new LocationMap );
+
+ return mSelf;
+}
+
+void LocationMap::showAddress( const KABC::Address &addr )
+{
+ KURL url( createUrl( addr ) );
+ if ( url.isEmpty() )
+ return;
+
+ kapp->invokeBrowser( url.url() );
+}
+
+QString LocationMap::createUrl( const KABC::Address &addr )
+{
+ /**
+ This method makes substitutions for the following place holders:
+ %s street
+ %r region
+ %l locality
+ %z zip code
+ %c country (in ISO format)
+ */
+
+ QString urlTemplate = KABPrefs::instance()->locationMapURL().arg( KGlobal::locale()->country() );
+ if ( urlTemplate.isEmpty() ) {
+ KMessageBox::error( 0, i18n( "No service provider available for map lookup!\nPlease add one in the configuration dialog." ) );
+ return QString::null;
+ }
+
+#if KDE_VERSION >= 319
+ return urlTemplate.replace( "%s", addr.street() ).
+ replace( "%r", addr.region() ).
+ replace( "%l", addr.locality() ).
+ replace( "%z", addr.postalCode() ).
+ replace( "%c", addr.countryToISO( addr.country() ) );
+#else
+ return urlTemplate.replace( "%s", addr.street() ).
+ replace( "%r", addr.region() ).
+ replace( "%l", addr.locality() ).
+ replace( "%z", addr.postalCode() ).
+ replace( "%c", "" );
+#endif
+}
+
+#include "locationmap.moc"
diff --git a/kaddressbook/common/locationmap.h b/kaddressbook/common/locationmap.h
new file mode 100644
index 00000000..82300d9d
--- /dev/null
+++ b/kaddressbook/common/locationmap.h
@@ -0,0 +1,51 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef LOCATIONMAP_H
+#define LOCATIONMAP_H
+
+#include <kabc/address.h>
+#include <qobject.h>
+#include <qstring.h>
+
+class LocationMap : public QObject
+{
+ Q_OBJECT
+
+ public:
+ static LocationMap *instance();
+ ~LocationMap();
+
+ public slots:
+ void showAddress( const KABC::Address& );
+
+ protected:
+ LocationMap();
+
+ private:
+ QString createUrl( const KABC::Address& );
+
+ static LocationMap *mSelf;
+};
+
+#endif
diff --git a/kaddressbook/contacteditorwidgetmanager.cpp b/kaddressbook/contacteditorwidgetmanager.cpp
new file mode 100644
index 00000000..de21528c
--- /dev/null
+++ b/kaddressbook/contacteditorwidgetmanager.cpp
@@ -0,0 +1,217 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qlayout.h>
+
+#include <kapplication.h>
+#include <kdialog.h>
+#include <klibloader.h>
+#include <ktrader.h>
+
+// include non-plugin contact editor widgets
+#include "customfieldswidget.h"
+#include "freebusywidget.h"
+#include "geowidget.h"
+#include "imagewidget.h"
+#include "soundwidget.h"
+
+#include "contacteditorwidget.h"
+#include "contacteditorwidgetmanager.h"
+
+ContactEditorWidgetManager *ContactEditorWidgetManager::mSelf = 0;
+
+ContactEditorWidgetManager::ContactEditorWidgetManager()
+ : QObject( qApp )
+{
+ reload();
+}
+
+ContactEditorWidgetManager::~ContactEditorWidgetManager()
+{
+ mFactories.clear();
+}
+
+ContactEditorWidgetManager *ContactEditorWidgetManager::self()
+{
+ kdWarning( !kapp, 7520 ) << "No QApplication object available!" << endl;
+
+ if ( !mSelf )
+ mSelf = new ContactEditorWidgetManager();
+
+ return mSelf;
+}
+
+int ContactEditorWidgetManager::count() const
+{
+ return mFactories.count();
+}
+
+KAB::ContactEditorWidgetFactory *ContactEditorWidgetManager::factory( int pos ) const
+{
+ return mFactories[ pos ];
+}
+
+void ContactEditorWidgetManager::reload()
+{
+ mFactories.clear();
+ kdDebug(5720) << "ContactEditorWidgetManager::reload()" << endl;
+ const KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/ContactEditorWidget",
+ QString( "[X-KDE-KAddressBook-CEWPluginVersion] == %1" ).arg( KAB_CEW_PLUGIN_VERSION ) );
+
+ KTrader::OfferList::ConstIterator it;
+ for ( it = plugins.begin(); it != plugins.end(); ++it ) {
+ KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
+ if ( !factory ) {
+ kdDebug(5720) << "ContactEditorWidgetManager::reload(): Factory creation failed" << endl;
+ continue;
+ }
+
+ KAB::ContactEditorWidgetFactory *pageFactory =
+ static_cast<KAB::ContactEditorWidgetFactory*>( factory );
+
+ if ( !pageFactory ) {
+ kdDebug(5720) << "ContactEditorWidgetManager::reload(): Cast failed" << endl;
+ continue;
+ }
+
+ mFactories.append( pageFactory );
+ }
+
+ // add all non-plugin contact editor factories
+ mFactories.append( new FreeBusyWidgetFactory );
+ mFactories.append( new ImageWidgetFactory );
+ mFactories.append( new SoundWidgetFactory );
+ mFactories.append( new GeoWidgetFactory );
+ mFactories.append( new CustomFieldsWidgetFactory );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+ContactEditorTabPage::ContactEditorTabPage( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+ mLayout = new QGridLayout( this, 0, 2, KDialog::marginHint(),
+ KDialog::spacingHint() );
+}
+
+void ContactEditorTabPage::addWidget( KAB::ContactEditorWidget *widget )
+{
+ if ( widget->logicalWidth() == 2 ) {
+ mWidgets.prepend( widget );
+ connect( widget, SIGNAL( changed() ), SIGNAL( changed() ) );
+ return;
+ }
+
+ // insert it in descending order
+ KAB::ContactEditorWidget::List::Iterator it;
+ for ( it = mWidgets.begin(); it != mWidgets.end(); ++it ) {
+ if ( widget->logicalHeight() > (*it)->logicalHeight() &&
+ (*it)->logicalWidth() == 1 ) {
+ --it;
+ break;
+ }
+ }
+ mWidgets.insert( ++it, widget );
+
+ connect( widget, SIGNAL( changed() ), SIGNAL( changed() ) );
+}
+
+void ContactEditorTabPage::loadContact( KABC::Addressee *addr )
+{
+ KAB::ContactEditorWidget::List::Iterator it;
+ for ( it = mWidgets.begin(); it != mWidgets.end(); ++it ) {
+ (*it)->setModified( false );
+ (*it)->loadContact( addr );
+ }
+}
+
+void ContactEditorTabPage::storeContact( KABC::Addressee *addr )
+{
+ KAB::ContactEditorWidget::List::Iterator it;
+ for ( it = mWidgets.begin(); it != mWidgets.end(); ++it ) {
+ if ( (*it)->modified() ) {
+ (*it)->storeContact( addr );
+ (*it)->setModified( false );
+ }
+ }
+}
+
+void ContactEditorTabPage::setReadOnly( bool readOnly )
+{
+ KAB::ContactEditorWidget::List::Iterator it;
+ for ( it = mWidgets.begin(); it != mWidgets.end(); ++it )
+ (*it)->setReadOnly( readOnly );
+}
+
+void ContactEditorTabPage::updateLayout()
+{
+ KAB::ContactEditorWidget::List::ConstIterator it;
+
+ int row = 0;
+ for ( it = mWidgets.begin(); it != mWidgets.end(); ++it ) {
+ if ( (*it)->logicalWidth() == 2 ) {
+ mLayout->addMultiCellWidget( *it, row, row + (*it)->logicalHeight() - 1, 0, 1 );
+ row += (*it)->logicalHeight();
+
+ if ( it != mWidgets.fromLast() ) {
+ QFrame *frame = new QFrame( this );
+ frame->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+ mLayout->addMultiCellWidget( frame, row, row, 0, 1 );
+ row++;
+ }
+ continue;
+ }
+
+ // fill left side
+ int leftHeight = (*it)->logicalHeight();
+
+ if ( it == mWidgets.fromLast() ) { // last widget gets full width
+ mLayout->addMultiCellWidget( *it, row, row + leftHeight - 1, 0, 1 );
+ return;
+ } else {
+ mLayout->addMultiCellWidget( *it, row, row + leftHeight - 1, 0, 0 );
+ QFrame *frame = new QFrame( this );
+ frame->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+ mLayout->addMultiCellWidget( frame, row + leftHeight, row + leftHeight, 0, 1 );
+ }
+
+ // fill right side
+ for ( int i = 0; i < leftHeight; ++i ) {
+ ++it;
+ if ( it == mWidgets.end() )
+ break;
+
+ int rightHeight = (*it)->logicalHeight();
+ if ( rightHeight + i <= leftHeight )
+ mLayout->addMultiCellWidget( *it, row + i, row + i + rightHeight - 1, 1, 1 );
+ else {
+ --i;
+ break;
+ }
+ }
+
+ row += 2;
+ }
+}
+
+#include "contacteditorwidgetmanager.moc"
diff --git a/kaddressbook/contacteditorwidgetmanager.h b/kaddressbook/contacteditorwidgetmanager.h
new file mode 100644
index 00000000..9b0efbc1
--- /dev/null
+++ b/kaddressbook/contacteditorwidgetmanager.h
@@ -0,0 +1,113 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef CONTACTEDITORWIDGETMANAGER_H
+#define CONTACTEDITORWIDGETMANAGER_H
+
+#include <qwidget.h>
+
+#include "contacteditorwidget.h"
+
+namespace KABC {
+class Addressee;
+}
+
+class QGridLayout;
+
+class ContactEditorWidgetManager : public QObject
+{
+ Q_OBJECT
+
+ public:
+ static ContactEditorWidgetManager *self();
+
+ /**
+ Returns the number of available Contact Editor Page factories.
+ */
+ int count() const;
+
+ /**
+ Returns a factory.
+ */
+ KAB::ContactEditorWidgetFactory *factory( int pos ) const;
+
+ protected:
+ ContactEditorWidgetManager();
+ ~ContactEditorWidgetManager();
+
+ private:
+ void reload();
+
+ QValueList<KAB::ContactEditorWidgetFactory*> mFactories;
+
+ static ContactEditorWidgetManager *mSelf;
+};
+
+class ContactEditorTabPage : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ ContactEditorTabPage( QWidget *parent, const char *name = 0 );
+
+ /**
+ Adds a widget to the tab.
+ */
+ void addWidget( KAB::ContactEditorWidget *widget );
+
+ /**
+ Load the contacts data into the GUI.
+ */
+ void loadContact( KABC::Addressee *addr );
+
+ /**
+ Save the data from the GUI into the passed contact
+ object.
+ */
+ void storeContact( KABC::Addressee *addr );
+
+ /**
+ Sets whether the contact should be presented as
+ read-only. You should update your GUI in the reimplemented
+ method.
+ */
+ void setReadOnly( bool readOnly );
+
+ /**
+ Calculates the layout of the widgets and moves them to the
+ correct position.
+ */
+ void updateLayout();
+
+ signals:
+ /**
+ Emitted whenever the page has changed.
+ */
+ void changed();
+
+ private:
+ QGridLayout *mLayout;
+ KAB::ContactEditorWidget::List mWidgets;
+};
+
+#endif
diff --git a/kaddressbook/csv-templates/Makefile.am b/kaddressbook/csv-templates/Makefile.am
new file mode 100644
index 00000000..e92e5d2c
--- /dev/null
+++ b/kaddressbook/csv-templates/Makefile.am
@@ -0,0 +1,2 @@
+templatedir = $(kde_datadir)/kaddressbook/csv-templates
+template_DATA = kaddressbook.desktop outlook2000.desktop yahoo.desktop
diff --git a/kaddressbook/csv-templates/README b/kaddressbook/csv-templates/README
new file mode 100644
index 00000000..befe2ab4
--- /dev/null
+++ b/kaddressbook/csv-templates/README
@@ -0,0 +1,49 @@
+Here are listed all fields kaddressbook can import via csv. If you want
+to create a new csv import template, you have to create a file like
+'kaddressbook.desktop', but with the correct column mapping.
+
+---
+
+00 "Formatted Name"
+01 "Family Name"
+02 "Given Name"
+03 "Additional Names"
+04 "Honorific Prefixes"
+05 "Honorific Suffixes"
+06 "Nick Name"
+07 "Birthday"
+08 "Home Address Street"
+09 "Home Address Locality"
+10 "Home Address Region"
+11 "Home Address Postal Code"
+12 "Home Address Country"
+13 "Home Address Label"
+14 "Business Address Street"
+15 "Business Address Locality"
+16 "Business Address Region"
+17 "Business Address Postal Code"
+18 "Business Address Country"
+19 "Business Address Label"
+20 "Home Phone"
+21 "Business Phone"
+22 "Mobile Phone"
+23 "Home Fax"
+24 "Business Fax"
+25 "Car Phone"
+26 "Isdn"
+27 "Pager"
+28 "Email Address"
+29 "Mail Client"
+30 "Title"
+31 "Role"
+32 "Organization"
+33 "Note"
+34 "URL"
+35 "Department"
+36 "Profession"
+37 "Assistant's Name"
+38 "Manager's Name"
+39 "Partner's Name"
+40 "Office"
+41 "IM Address"
+42 "Anniversary"
diff --git a/kaddressbook/csv-templates/kaddressbook.desktop b/kaddressbook/csv-templates/kaddressbook.desktop
new file mode 100644
index 00000000..a5b9c406
--- /dev/null
+++ b/kaddressbook/csv-templates/kaddressbook.desktop
@@ -0,0 +1,83 @@
+[General]
+Columns=43
+DatePattern=Y-M-D
+DelimiterOther=
+DelimiterType=0
+QuoteType=0
+
+[Misc]
+Name=KAddressBook (KDE 3.1)
+Name[af]=K-adresboek (Kde 3.1)
+Name[ar]=دفتر العناوين KAddressBook (KDE 3.1(
+Name[ca]=Llibreta d'adreces (KDE 3.1)
+Name[cs]=Kniha adres (KDE 3.1)
+Name[cy]=KLlyfrCyfeiriadau (KDE 3.1)
+Name[de]=Adressbuch (KDE 3.1)
+Name[et]=KDE aadressiraamat (KDE 3.1)
+Name[fo]=KAdressubók (KDE 3.1)
+Name[hi]=केडीईएड्रेसबुक (केडीई 3.1)
+Name[hr]=KAdressBook (KDE 3.1)
+Name[hu]=Címjegyzék (KDE 3.1)
+Name[it]=Rubrica indirizzi (KDE 3.1)
+Name[ka]=წიგნაკი (KDE 3.1)
+Name[mk]=КАдресар (KDE 3.1)
+Name[nb]=Adressebok (KDE 3.1)
+Name[nds]=KAdressbook (KDE 3.1)
+Name[ne]=केडीई ठेगाना पुस्तिका (केडीई ३.१)
+Name[nn]=KDE-adressebok (KDE 3.1)
+Name[nso]=KBuka ya Diaterese (KDE 3.1)
+Name[pl]=Książka adresowa (KDE 3.1)
+Name[ro]=Cartea de adrese (KDE 3.1)
+Name[ru]=Адресная книга (KDE 3.1)
+Name[se]=KDE-čujuhusgirji (KDE 3.3)
+Name[sl]=Adresar (KDE 3.1)
+Name[sv]=Kadressbok (KDE 3.1)
+Name[ta]=கேமுகவரிப்புத்தகம் (KDE 3.1)
+Name[tg]=Китоби адрес (KDE 3.1)
+Name[tr]=KDE Adres Defteri (KDE 3.1)
+Name[ven]=Bugu ya diresi ya K (KDE 3.1)
+
+[csv column map]
+0=1
+1=2
+10=11
+11=12
+12=13
+13=14
+14=15
+15=16
+16=17
+17=18
+18=19
+19=20
+2=3
+20=21
+21=22
+22=23
+23=24
+24=25
+25=26
+26=27
+27=28
+28=29
+29=30
+3=4
+30=31
+31=32
+32=33
+33=34
+34=35
+35=36
+36=37
+37=38
+38=39
+39=40
+4=5
+40=41
+41=42
+42=43
+5=6
+6=7
+7=8
+8=9
+9=10
diff --git a/kaddressbook/csv-templates/outlook2000.desktop b/kaddressbook/csv-templates/outlook2000.desktop
new file mode 100644
index 00000000..d5c6a4b2
--- /dev/null
+++ b/kaddressbook/csv-templates/outlook2000.desktop
@@ -0,0 +1,109 @@
+[General]
+Columns=92
+DelimiterOther=
+DelimiterType=0
+QuoteType=0
+
+[Misc]
+Name=Outlook 2000
+Name[ar]=برنامج Outlook 2000
+Name[eo]=Redmondo 2000
+Name[fa]=اوت لوک ۲۰۰۰
+Name[hi]=आउटलुक 2000
+Name[ne]=आउटलुक २०००
+Name[nso]=Bokantle 2000
+Name[ta]=அவுட்லுக் 2000
+
+[csv column map]
+0=5
+1=3
+10=0
+11=16
+12=17
+13=18
+14=19
+15=9
+16=0
+17=0
+18=10
+19=11
+2=4
+20=12
+21=13
+22=0
+23=0
+24=0
+25=0
+26=0
+27=0
+28=0
+29=0
+3=2
+30=25
+31=22
+32=0
+33=0
+34=26
+35=0
+36=24
+37=21
+38=0
+39=27
+4=6
+40=23
+41=0
+42=0
+43=28
+44=0
+45=0
+46=0
+47=0
+48=0
+49=43
+5=33
+50=38
+51=0
+52=8
+53=0
+54=0
+55=0
+56=0
+57=29
+58=0
+59=1
+6=36
+60=0
+61=0
+62=0
+63=0
+64=0
+65=0
+66=0
+67=0
+68=0
+69=0
+7=31
+70=0
+71=0
+72=0
+73=0
+74=0
+75=39
+76=0
+77=34
+78=0
+79=0
+8=15
+80=0
+81=0
+82=0
+83=37
+84=0
+85=0
+86=40
+87=0
+88=0
+89=0
+9=0
+90=0
+91=35
diff --git a/kaddressbook/csv-templates/yahoo.desktop b/kaddressbook/csv-templates/yahoo.desktop
new file mode 100644
index 00000000..b365365c
--- /dev/null
+++ b/kaddressbook/csv-templates/yahoo.desktop
@@ -0,0 +1,105 @@
+[General]
+Columns=39
+DatePattern=M/D/Y
+DelimiterOther=
+DelimiterType=0
+QuoteType=0
+
+[Misc]
+Name=Yahoo! AddressBook
+Name[af]=Yahoo! Adresboek
+Name[ar]=دفتر العناوين Yahoo!
+Name[be]=Адрасная кніга Yahoo!
+Name[br]=Karned chomlec'hioù Yahoo !
+Name[bs]=Yahoo! Adresar
+Name[ca]=Llibreta d'adreces Yahoo!
+Name[cs]=Kniha adres Yahoo!
+Name[cy]=Llyfr Cyfeiriadau Yahoo!
+Name[da]=Yahoo! adressebog
+Name[de]=Yahoo!-Adressbuch
+Name[el]=Βιβλίο διευθύνσεων Yahoo!
+Name[eo]=Yahoo! Adresaro
+Name[es]=Libreta de direcciones de Yahoo!
+Name[et]=Yahoo! aadressiraamat
+Name[eu]=Yahoo! helbide-liburua
+Name[fa]=کتاب نشانی یاهو!
+Name[fi]=Yahoo-osoitekirja
+Name[fr]=Carnet d'adresses Yahoo!
+Name[fy]=Yahoo!-adresboek
+Name[he]=פנקס כתובת של Yahoo!
+Name[hi]=याहू! पता पुस्तिका
+Name[hu]=Yahoo! címjegyzék
+Name[is]=Yahoo! póstfangaskrá
+Name[it]=Rubrica indirizzi Yahoo!
+Name[ja]=Yahoo! アドレス帳
+Name[ka]=წიგნაკი Yahoo!
+Name[kk]=Yahoo! адрестік кітапшасы
+Name[km]=សៀវភៅ​អាសយដ្ឋាន​របស់​យ៉ាហ៊ូ
+Name[ko]=Yahoo! 주소록
+Name[lt]=Yahoo! Adresų knygutė
+Name[mk]=Адресар од Yahoo!
+Name[nb]=Yahoo! adressebok
+Name[nds]=Yahoo!-Adressbook
+Name[ne]=याहू! ठेगाना पुस्तिका
+Name[nl]=Yahoo!-adresboek
+Name[nn]=Yahoo! Adressebok
+Name[pa]=Yahoo! ਸਿਰਨਾਵਾਂ ਕਿਤਾਬ
+Name[pl]=Książka adresowa Yahoo!
+Name[pt]=Livro de Endereços do Yahoo!
+Name[pt_BR]=Livro de Endereços do Yahoo!
+Name[ru]=Адресная книга Yahoo!
+Name[se]=Yahoo! čujuhusgirji
+Name[sk]=Yahoo! kniha adries
+Name[sl]=Adresar Yahoo!
+Name[sr]=Yahoo! адресар
+Name[sr@Latn]=Yahoo! adresar
+Name[sv]=Yahoo!-adressbok
+Name[ta]=யாஹூ! முகவரிப் புத்தகம்
+Name[tg]=Китоби адресии Yahoo!
+Name[tr]=Yahoo! Adres Defteri
+Name[uk]=Адресна книга Yahoo
+Name[uz]=Yahoo! manzillar daftari
+Name[uz@cyrillic]=Yahoo! манзиллар дафтари
+Name[zh_CN]=Yahoo! 地址簿
+Name[zh_TW]=Yahoo! 通訊錄
+
+[csv column map]
+0=3
+1=4
+10=28
+11=24
+12=23
+13=0
+14=0
+15=0
+16=0
+17=0
+18=35
+19=0
+2=2
+20=31
+21=33
+22=15
+23=16
+24=17
+25=18
+26=19
+27=9
+28=10
+29=11
+3=7
+30=12
+31=13
+32=8
+33=43
+34=0
+35=0
+36=0
+37=0
+38=34
+4=29
+5=0
+6=0
+7=0
+8=21
+9=22
diff --git a/kaddressbook/customfieldswidget.cpp b/kaddressbook/customfieldswidget.cpp
new file mode 100644
index 00000000..a2a6e701
--- /dev/null
+++ b/kaddressbook/customfieldswidget.cpp
@@ -0,0 +1,535 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qcheckbox.h>
+#include <qdatetimeedit.h>
+#include <qframe.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qvalidator.h>
+#include <qspinbox.h>
+
+#include <kaccelmanager.h>
+#include <kcombobox.h>
+#include <kinputdialog.h>
+#include <klineedit.h>
+#include <kmessagebox.h>
+
+#include "addresseeconfig.h"
+#include "kabprefs.h"
+
+#include "customfieldswidget.h"
+
+
+AddFieldDialog::AddFieldDialog( QWidget *parent, const char *name )
+ : KDialogBase( Plain, i18n( "Add Field" ), Ok | Cancel,
+ Ok, parent, name, true, true )
+{
+ QWidget *page = plainPage();
+
+ QGridLayout *layout = new QGridLayout( page, 3, 2, marginHint(), spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "Title:" ), page );
+ layout->addWidget( label, 0, 0 );
+
+ mTitle = new KLineEdit( page );
+ mTitle->setValidator( new QRegExpValidator( QRegExp( "([a-zA-Z]|\\d|-)+" ), mTitle ) );
+ label->setBuddy( mTitle );
+ layout->addWidget( mTitle, 0, 1 );
+
+ label = new QLabel( i18n( "Type:" ), page );
+ layout->addWidget( label, 1, 0 );
+
+ mType = new KComboBox( page );
+ label->setBuddy( mType );
+ layout->addWidget( mType, 1, 1 );
+
+ mGlobal = new QCheckBox( i18n( "Is available for all contacts" ), page );
+ mGlobal->setChecked( true );
+ layout->addMultiCellWidget( mGlobal, 2, 2, 0, 1 );
+
+ connect( mTitle, SIGNAL( textChanged( const QString& ) ),
+ this, SLOT( nameChanged( const QString& ) ) );
+
+ KAcceleratorManager::manage( this );
+
+ mTypeList.append( "text" );
+ mTypeName.append( i18n( "Text" ) );
+ mTypeList.append( "integer" );
+ mTypeName.append( i18n( "Numeric Value" ) );
+ mTypeList.append( "boolean" );
+ mTypeName.append( i18n( "Boolean" ) );
+ mTypeList.append( "date" );
+ mTypeName.append( i18n( "Date" ) );
+ mTypeList.append( "time" );
+ mTypeName.append( i18n( "Time" ) );
+ mTypeList.append( "datetime" );
+ mTypeName.append( i18n( "Date & Time" ) );
+
+ for ( uint i = 0; i < mTypeName.count(); ++i )
+ mType->insertItem( mTypeName[ i ] );
+
+ nameChanged( "" );
+
+ mTitle->setFocus();
+}
+
+QString AddFieldDialog::title() const
+{
+ return mTitle->text();
+}
+
+QString AddFieldDialog::identifier() const
+{
+ QString id = mTitle->text().lower();
+ return id.replace( ",", "_" ).replace( " ", "_" );
+}
+
+QString AddFieldDialog::type() const
+{
+ return mTypeList[ mType->currentItem() ];
+}
+
+bool AddFieldDialog::isGlobal() const
+{
+ return mGlobal->isChecked();
+}
+
+void AddFieldDialog::nameChanged( const QString &name )
+{
+ enableButton( Ok, !name.isEmpty() );
+}
+
+FieldWidget::FieldWidget( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+ QVBoxLayout *layout = new QVBoxLayout( this, KDialog::marginHint(),
+ KDialog::spacingHint() );
+
+ mGlobalLayout = new QVBoxLayout( layout, KDialog::spacingHint() );
+ mGlobalLayout->setAlignment( Qt::AlignTop );
+
+ mSeparator = new QFrame( this );
+ mSeparator->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+ mSeparator->hide();
+ layout->addWidget( mSeparator );
+
+ mLocalLayout = new QVBoxLayout( layout, KDialog::spacingHint() );
+ mLocalLayout->setAlignment( Qt::AlignTop );
+}
+
+void FieldWidget::addField( const QString &identifier, const QString &title,
+ const QString &type, bool isGlobal )
+{
+ FieldRecord record;
+
+ record.mIdentifier = identifier;
+ record.mTitle = title;
+ record.mLabel = new QLabel( title + ":", this );
+ record.mGlobal = isGlobal;
+ if ( type == "integer" ) {
+ QSpinBox *wdg = new QSpinBox( 0, 1000, 1, this );
+ record.mWidget = wdg;
+ connect( wdg, SIGNAL( valueChanged( int ) ),
+ this, SIGNAL( changed() ) );
+ } else if ( type == "boolean" ) {
+ QCheckBox *wdg = new QCheckBox( this );
+ record.mWidget = wdg;
+ connect( wdg, SIGNAL( toggled( bool ) ),
+ this, SIGNAL( changed() ) );
+ } else if ( type == "date" ) {
+ QDateEdit *wdg = new QDateEdit( this );
+ record.mWidget = wdg;
+ connect( wdg, SIGNAL( valueChanged( const QDate& ) ),
+ this, SIGNAL( changed() ) );
+ } else if ( type == "time" ) {
+ QTimeEdit *wdg = new QTimeEdit( this );
+ record.mWidget = wdg;
+ connect( wdg, SIGNAL( valueChanged( const QTime& ) ),
+ this, SIGNAL( changed() ) );
+ } else if ( type == "datetime" ) {
+ QDateTimeEdit *wdg = new QDateTimeEdit( this );
+ record.mWidget = wdg;
+ connect( wdg, SIGNAL( valueChanged( const QDateTime& ) ),
+ this, SIGNAL( changed() ) );
+ } else if ( type == "text" ) {
+ QLineEdit *wdg = new QLineEdit( this );
+ record.mWidget = wdg;
+ connect( wdg, SIGNAL( textChanged( const QString& ) ),
+ this, SIGNAL( changed() ) );
+ }
+
+ record.mLabel->show();
+ record.mWidget->show();
+
+ if ( isGlobal ) {
+ record.mLayout = new QHBoxLayout( mGlobalLayout );
+ record.mLayout->addWidget( record.mLabel );
+ record.mLayout->addWidget( record.mWidget, Qt::AlignLeft );
+ } else {
+ record.mLayout = new QHBoxLayout( mLocalLayout );
+ record.mLayout->addWidget( record.mLabel );
+ record.mLayout->addWidget( record.mWidget, Qt::AlignLeft );
+ mSeparator->show();
+ }
+
+ mFieldList.append( record );
+
+ recalculateLayout();
+}
+
+void FieldWidget::removeField( const QString &identifier )
+{
+ FieldRecordList::Iterator it;
+ for ( it = mFieldList.begin(); it != mFieldList.end(); ++it ) {
+ if ( (*it).mIdentifier == identifier ) {
+ delete (*it).mLabel;
+ delete (*it).mWidget;
+ delete (*it).mLayout;
+
+ mFieldList.remove( it );
+ recalculateLayout();
+
+ bool hasLocal = false;
+ for ( it = mFieldList.begin(); it != mFieldList.end(); ++it )
+ hasLocal = hasLocal || !(*it).mGlobal;
+
+ if ( !hasLocal )
+ mSeparator->hide();
+
+ return;
+ }
+ }
+}
+
+void FieldWidget::clearFields()
+{
+ FieldRecordList::ConstIterator fieldIt;
+ for ( fieldIt = mFieldList.begin(); fieldIt != mFieldList.end(); ++fieldIt ) {
+ if ( (*fieldIt).mWidget->isA( "QLineEdit" ) ) {
+ QLineEdit *wdg = static_cast<QLineEdit*>( (*fieldIt).mWidget );
+ wdg->setText( QString() );
+ } else if ( (*fieldIt).mWidget->isA( "QSpinBox" ) ) {
+ QSpinBox *wdg = static_cast<QSpinBox*>( (*fieldIt).mWidget );
+ wdg->setValue( 0 );
+ } else if ( (*fieldIt).mWidget->isA( "QCheckBox" ) ) {
+ QCheckBox *wdg = static_cast<QCheckBox*>( (*fieldIt).mWidget );
+ wdg->setChecked( true );
+ } else if ( (*fieldIt).mWidget->isA( "QDateEdit" ) ) {
+ QDateEdit *wdg = static_cast<QDateEdit*>( (*fieldIt).mWidget );
+ wdg->setDate( QDate::currentDate() );
+ } else if ( (*fieldIt).mWidget->isA( "QTimeEdit" ) ) {
+ QTimeEdit *wdg = static_cast<QTimeEdit*>( (*fieldIt).mWidget );
+ wdg->setTime( QTime::currentTime() );
+ } else if ( (*fieldIt).mWidget->isA( "QDateTimeEdit" ) ) {
+ QDateTimeEdit *wdg = static_cast<QDateTimeEdit*>( (*fieldIt).mWidget );
+ wdg->setDateTime( QDateTime::currentDateTime() );
+ }
+ }
+}
+
+void FieldWidget::loadContact( KABC::Addressee *addr )
+{
+ const QStringList customs = addr->customs();
+
+ clearFields();
+
+ QStringList::ConstIterator it;
+ for ( it = customs.begin(); it != customs.end(); ++it ) {
+ QString app, name, value;
+ splitField( *it, app, name, value );
+ if ( app != "KADDRESSBOOK" )
+ continue;
+
+ FieldRecordList::ConstIterator fieldIt;
+ for ( fieldIt = mFieldList.begin(); fieldIt != mFieldList.end(); ++fieldIt ) {
+ if ( (*fieldIt).mIdentifier == name ) {
+ if ( (*fieldIt).mWidget->isA( "QLineEdit" ) ) {
+ QLineEdit *wdg = static_cast<QLineEdit*>( (*fieldIt).mWidget );
+ wdg->setText( value );
+ } else if ( (*fieldIt).mWidget->isA( "QSpinBox" ) ) {
+ QSpinBox *wdg = static_cast<QSpinBox*>( (*fieldIt).mWidget );
+ wdg->setValue( value.toInt() );
+ } else if ( (*fieldIt).mWidget->isA( "QCheckBox" ) ) {
+ QCheckBox *wdg = static_cast<QCheckBox*>( (*fieldIt).mWidget );
+ wdg->setChecked( value == "true" || value == "1" );
+ } else if ( (*fieldIt).mWidget->isA( "QDateEdit" ) ) {
+ QDateEdit *wdg = static_cast<QDateEdit*>( (*fieldIt).mWidget );
+ wdg->setDate( QDate::fromString( value, Qt::ISODate ) );
+ } else if ( (*fieldIt).mWidget->isA( "QTimeEdit" ) ) {
+ QTimeEdit *wdg = static_cast<QTimeEdit*>( (*fieldIt).mWidget );
+ wdg->setTime( QTime::fromString( value, Qt::ISODate ) );
+ } else if ( (*fieldIt).mWidget->isA( "QDateTimeEdit" ) ) {
+ QDateTimeEdit *wdg = static_cast<QDateTimeEdit*>( (*fieldIt).mWidget );
+ wdg->setDateTime( QDateTime::fromString( value, Qt::ISODate ) );
+ }
+ }
+ }
+ }
+}
+
+void FieldWidget::storeContact( KABC::Addressee *addr )
+{
+ FieldRecordList::ConstIterator it;
+ for ( it = mFieldList.begin(); it != mFieldList.end(); ++it ) {
+ QString value;
+ if ( (*it).mWidget->isA( "QLineEdit" ) ) {
+ QLineEdit *wdg = static_cast<QLineEdit*>( (*it).mWidget );
+ value = wdg->text();
+ } else if ( (*it).mWidget->isA( "QSpinBox" ) ) {
+ QSpinBox *wdg = static_cast<QSpinBox*>( (*it).mWidget );
+ value = QString::number( wdg->value() );
+ } else if ( (*it).mWidget->isA( "QCheckBox" ) ) {
+ QCheckBox *wdg = static_cast<QCheckBox*>( (*it).mWidget );
+ value = ( wdg->isChecked() ? "true" : "false" );
+ } else if ( (*it).mWidget->isA( "QDateEdit" ) ) {
+ QDateEdit *wdg = static_cast<QDateEdit*>( (*it).mWidget );
+ value = wdg->date().toString( Qt::ISODate );
+ } else if ( (*it).mWidget->isA( "QTimeEdit" ) ) {
+ QTimeEdit *wdg = static_cast<QTimeEdit*>( (*it).mWidget );
+ value = wdg->time().toString( Qt::ISODate );
+ } else if ( (*it).mWidget->isA( "QDateTimeEdit" ) ) {
+ QDateTimeEdit *wdg = static_cast<QDateTimeEdit*>( (*it).mWidget );
+ value = wdg->dateTime().toString( Qt::ISODate );
+ }
+
+ if ( value.isEmpty() )
+ addr->removeCustom( "KADDRESSBOOK", (*it).mIdentifier );
+ else
+ addr->insertCustom( "KADDRESSBOOK", (*it).mIdentifier, value );
+ }
+}
+
+void FieldWidget::removeLocalFields()
+{
+ FieldRecordList::Iterator it;
+ for ( it = mFieldList.begin(); it != mFieldList.end(); ++it ) {
+ if ( !(*it).mGlobal ) {
+ delete (*it).mLabel;
+ delete (*it).mWidget;
+ delete (*it).mLayout;
+
+ it = mFieldList.remove( it );
+ it--;
+ recalculateLayout();
+ }
+ }
+}
+
+void FieldWidget::recalculateLayout()
+{
+ int maxWidth = 0;
+
+ FieldRecordList::ConstIterator it;
+ for ( it = mFieldList.begin(); it != mFieldList.end(); ++it )
+ maxWidth = QMAX( maxWidth, (*it).mLabel->minimumSizeHint().width() );
+
+ for ( it = mFieldList.begin(); it != mFieldList.end(); ++it )
+ (*it).mLabel->setMinimumWidth( maxWidth );
+}
+
+CustomFieldsWidget::CustomFieldsWidget( KABC::AddressBook *ab,
+ QWidget *parent, const char *name )
+ : KAB::ContactEditorWidget( ab, parent, name )
+{
+ initGUI();
+
+ connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addField() ) );
+ connect( mRemoveButton, SIGNAL( clicked() ), this, SLOT( removeField() ) );
+
+ connect( mFieldWidget, SIGNAL( changed() ), this, SLOT( setModified() ) );
+}
+
+void CustomFieldsWidget::loadContact( KABC::Addressee *addr )
+{
+ mAddressee = *addr;
+
+ mFieldWidget->removeLocalFields();
+
+ AddresseeConfig addrConfig( mAddressee );
+ QStringList fields = addrConfig.customFields();
+
+ if ( !fields.isEmpty() ) {
+ for ( uint i = 0; i < fields.count(); i += 3 ) {
+ mFieldWidget->addField( fields[ i ], fields[ i + 1 ],
+ fields[ i + 2 ] , false );
+ mRemoveButton->setEnabled( true );
+ }
+ }
+
+ mFieldWidget->loadContact( addr );
+}
+
+void CustomFieldsWidget::storeContact( KABC::Addressee *addr )
+{
+ mFieldWidget->storeContact( addr );
+}
+
+void CustomFieldsWidget::setReadOnly( bool readOnly )
+{
+ mAddButton->setEnabled( !readOnly );
+ mRemoveButton->setEnabled( !readOnly && !mFieldWidget->fields().isEmpty() );
+}
+
+void CustomFieldsWidget::addField()
+{
+ AddFieldDialog dlg( this );
+
+ if ( dlg.exec() ) {
+ FieldRecordList list = mFieldWidget->fields();
+
+ FieldRecordList::ConstIterator it;
+ for ( it = list.begin(); it != list.end(); ++it )
+ if ( (*it).mIdentifier == dlg.identifier() ) {
+ KMessageBox::sorry( this, i18n( "A field with the same name already exists, please choose another one." ) );
+ return;
+ }
+
+ mFieldWidget->addField( dlg.identifier(), dlg.title(),
+ dlg.type(), dlg.isGlobal() );
+
+ if ( dlg.isGlobal() ) {
+ KABPrefs::instance()->setGlobalCustomFields( marshallFields( true ) );
+ } else {
+ AddresseeConfig addrConfig( mAddressee );
+ addrConfig.setCustomFields( marshallFields( false ) );
+ }
+
+ mRemoveButton->setEnabled( true );
+ }
+}
+
+void CustomFieldsWidget::removeField()
+{
+ const FieldRecordList list = mFieldWidget->fields();
+
+ QStringList fields;
+
+ FieldRecordList::ConstIterator it;
+ for ( it = list.begin(); it != list.end(); ++it )
+ fields.append( (*it).mTitle );
+
+ bool ok;
+ QString title = KInputDialog::getItem( i18n( "Remove Field" ),
+ i18n( "Select the field you want to remove:" ),
+ fields, 0, false, &ok, this );
+
+ if ( ok ) {
+ for ( it = list.begin(); it != list.end(); ++it )
+ if ( (*it).mTitle == title ) {
+ mFieldWidget->removeField( (*it).mIdentifier );
+
+ if ( list.count() == 1 )
+ mRemoveButton->setEnabled( false );
+
+ if ( (*it).mGlobal ) {
+ KABPrefs::instance()->setGlobalCustomFields( marshallFields( true ) );
+ } else {
+ AddresseeConfig addrConfig( mAddressee );
+ addrConfig.setCustomFields( marshallFields( false ) );
+ }
+
+ return;
+ }
+ }
+}
+
+void CustomFieldsWidget::initGUI()
+{
+ QGridLayout *layout = new QGridLayout( this, 2, 3, KDialog::marginHint(),
+ KDialog::spacingHint() );
+
+ mFieldWidget = new FieldWidget( this );
+ layout->addMultiCellWidget( mFieldWidget, 0, 0, 0, 2 );
+
+ mAddButton = new QPushButton( i18n( "Add Field..." ), this );
+ layout->addWidget( mAddButton, 1, 1, Qt::AlignRight );
+
+ mRemoveButton = new QPushButton( i18n( "Remove Field..." ), this );
+ mRemoveButton->setEnabled( false );
+ layout->addWidget( mRemoveButton, 1, 2, Qt::AlignRight );
+
+ // load global fields
+ QStringList globalFields = KABPrefs::instance()->globalCustomFields();
+
+ if ( globalFields.isEmpty() )
+ return;
+
+ for ( uint i = 0; i < globalFields.count(); i += 3 ) {
+ mFieldWidget->addField( globalFields[ i ], globalFields[ i + 1 ],
+ globalFields[ i + 2 ] , true );
+ mRemoveButton->setEnabled( true );
+ }
+}
+
+QStringList CustomFieldsWidget::marshallFields( bool global ) const
+{
+ QStringList retval;
+
+ const FieldRecordList list = mFieldWidget->fields();
+ FieldRecordList::ConstIterator it;
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ if ( (*it).mGlobal == global ) {
+ retval.append( (*it).mIdentifier );
+ retval.append( (*it).mTitle );
+
+ QString type = "text";
+ if ( (*it).mWidget->isA( "QSpinBox" ) ) {
+ type = "integer";
+ } else if ( (*it).mWidget->isA( "QCheckBox" ) ) {
+ type = "boolean";
+ } else if ( (*it).mWidget->isA( "QDateEdit" ) ) {
+ type = "date";
+ } else if ( (*it).mWidget->isA( "QTimeEdit" ) ) {
+ type = "time";
+ } else if ( (*it).mWidget->isA( "QDateTimeEdit" ) ) {
+ type = "datetime";
+ } else if ( (*it).mWidget->isA( "QLineEdit" ) ) {
+ type = "text";
+ }
+
+ retval.append( type );
+ }
+ }
+
+ return retval;
+}
+
+
+void splitField( const QString &str, QString &app, QString &name, QString &value )
+{
+ int colon = str.find( ':' );
+ if ( colon != -1 ) {
+ QString tmp = str.left( colon );
+ value = str.mid( colon + 1 );
+
+ int dash = tmp.find( '-' );
+ if ( dash != -1 ) {
+ app = tmp.left( dash );
+ name = tmp.mid( dash + 1 );
+ }
+ }
+}
+
+#include "customfieldswidget.moc"
diff --git a/kaddressbook/customfieldswidget.h b/kaddressbook/customfieldswidget.h
new file mode 100644
index 00000000..6ee10a39
--- /dev/null
+++ b/kaddressbook/customfieldswidget.h
@@ -0,0 +1,162 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef CUSTOMFIELDSWIDGET_H
+#define CUSTOMFIELDSWIDGET_H
+
+#include <kabc/addressee.h>
+#include <kdialogbase.h>
+#include <klocale.h>
+
+#include <qmap.h>
+#include <qpair.h>
+#include <qstringlist.h>
+#include <qvaluevector.h>
+#include <qwidget.h>
+
+#include "contacteditorwidget.h"
+
+class QCheckBox;
+class QGridLayout;
+class QLabel;
+class QPushButton;
+class QVBoxLayout;
+class QWidget;
+
+class KComboBox;
+class KLineEdit;
+
+typedef struct {
+ QString mIdentifier;
+ QString mTitle;
+ bool mGlobal;
+
+ QLabel *mLabel;
+ QWidget *mWidget;
+ QHBoxLayout *mLayout;
+} FieldRecord;
+
+typedef QValueList<FieldRecord> FieldRecordList;
+
+class AddFieldDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ AddFieldDialog( QWidget *parent, const char *name = 0 );
+
+ QString title() const;
+ QString identifier() const;
+ QString type() const;
+ bool isGlobal() const;
+
+ private slots:
+ void nameChanged( const QString& );
+
+ private:
+ KLineEdit *mTitle;
+ KComboBox *mType;
+ QCheckBox *mGlobal;
+
+ QValueVector<QString> mTypeList;
+ QValueVector<QString> mTypeName;
+};
+
+class FieldWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ FieldWidget( QWidget *parent, const char *name = 0 );
+
+ void addField( const QString &identifier, const QString &title,
+ const QString &type, bool isGlobal );
+
+ void removeField( const QString &identifier );
+
+ void loadContact( KABC::Addressee *addr );
+ void storeContact( KABC::Addressee *addr );
+ void setReadOnly( bool readOnly );
+
+ FieldRecordList fields() const { return mFieldList; }
+
+ void removeLocalFields();
+ void clearFields();
+
+ signals:
+ void changed();
+
+ private:
+ void recalculateLayout();
+
+ QVBoxLayout *mGlobalLayout;
+ QVBoxLayout *mLocalLayout;
+ QFrame *mSeparator;
+
+ FieldRecordList mFieldList;
+};
+
+class CustomFieldsWidget : public KAB::ContactEditorWidget
+{
+ Q_OBJECT
+
+ public:
+ CustomFieldsWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
+
+ void loadContact( KABC::Addressee *addr );
+ void storeContact( KABC::Addressee *addr );
+ void setReadOnly( bool readOnly );
+
+ private slots:
+ void addField();
+ void removeField();
+
+ private:
+ void initGUI();
+
+ QStringList marshallFields( bool ) const;
+
+ QPushButton *mAddButton;
+ QPushButton *mRemoveButton;
+ QGridLayout *mLayout;
+
+ FieldWidget *mFieldWidget;
+
+ KABC::Addressee mAddressee;
+};
+
+class CustomFieldsWidgetFactory : public KAB::ContactEditorWidgetFactory
+{
+ public:
+ KAB::ContactEditorWidget *createWidget( KABC::AddressBook *ab, QWidget *parent, const char *name )
+ {
+ return new CustomFieldsWidget( ab, parent, name );
+ }
+
+ QString pageTitle() const { return i18n( "Custom Fields" ); }
+ QString pageIdentifier() const { return "custom_fields"; }
+};
+
+void splitField( const QString&, QString&, QString&, QString& );
+
+#endif
diff --git a/kaddressbook/dcopaddressbook.desktop b/kaddressbook/dcopaddressbook.desktop
new file mode 100644
index 00000000..50ee3455
--- /dev/null
+++ b/kaddressbook/dcopaddressbook.desktop
@@ -0,0 +1,60 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=DCOP/AddressBook
+Comment=Address Book with a DCOP interface
+Comment[af]=Adres boek met 'n DCOP koppelvlak
+Comment[ar]=دفتر عناوين مع واجهة DCOP
+Comment[be]=Адрасная кніга з DCOP інтэрфэйсам
+Comment[bg]=Адресник с интерфейс DCOP
+Comment[bs]=Adresar sa DCOP interfejsom
+Comment[ca]=Llibreta d'adreces amb una interfície DCOP
+Comment[cs]=Kniha adres s DCOP rozhraním
+Comment[cy]=Llyfr Cyfeiriadau gyda Rhyngwyneb DCOP
+Comment[da]=Adressebog med en DCOP-grænseflade
+Comment[de]=Adressbuch mit DCOP-Schnittstelle
+Comment[el]=Βιβλίο διευθύνσεων με ένα περιβάλλον χρήσης DCOP
+Comment[eo]=Adresaro kun DCOP-interfaco
+Comment[es]=Libreta de direcciones con un interfaz DCOP
+Comment[et]=Aadressiraamat DCOP-liidesega
+Comment[eu]=DCOP interfazedun helbide-liburua
+Comment[fa]=کتاب نشانی با یک واسط DCOP
+Comment[fi]=Osoitekirja DCOP-rajapinnalla
+Comment[fr]=Carnet d'adresses avec une interface DCOP
+Comment[fy]=Adresboek mei DCOP-ynterface
+Comment[gl]=Libro de enderezos con interface DCOP
+Comment[he]=פנקס כתובת עם ממשק DCOP
+Comment[hi]=डीकॉप इंटरफेस सहित एक पता पुस्तिका
+Comment[hu]=Címjegyzék DCOP-felülettel
+Comment[is]=Vistfangaskrá með DCOP tengingu
+Comment[it]=Rubrica indirizzi con un'interfaccia DCOP
+Comment[ja]=DCOP インターフェースを持つアドレス帳
+Comment[ka]=წიგნაკი DCOP-ის ინტერფეისით
+Comment[kk]=DCOP интерфейсті адрестік кітапшасы
+Comment[km]=សៀវភៅ​អាសយដ្ឋាន​ដែល​មាន​ចំណុច​ប្រទាក់ DCOP
+Comment[ko]=DCOP 인터페이스를 사용하는 주소록
+Comment[lt]=Adresų knygelė su DCOP sąsaja
+Comment[mk]=Адресар со DCOP-интерфејс
+Comment[nb]=Adressebok med DCOP-grensesnitt
+Comment[nds]=Adressbook mit DCOP-Koppelsteed
+Comment[ne]=डीसीओपी ईन्टरफेससँगको ठेगाना पुस्तिका
+Comment[nl]=Adresboek met DCOP-interface
+Comment[nn]=Adressebok med DCOP-grensesnitt
+Comment[pl]=Książka adresowa z interfejsem DCOP
+Comment[pt]=Livro de Endereços com uma Interface de DCOP
+Comment[pt_BR]=Livro de Endereços com uma interface DCOP
+Comment[ro]=Carte de adrese cu interfaţă DCOP
+Comment[ru]=Адресная книга с интерфейсом DCOP
+Comment[se]=Čujuhusgirji mas lea DCOP-lákta
+Comment[sk]=Kniha adries s DCOP rozhraním
+Comment[sl]=Adresar z vmesnikom DCOP
+Comment[sr]=Адресар са DCOP интерфејсом
+Comment[sr@Latn]=Adresar sa DCOP interfejsom
+Comment[sv]=Adressbok med DCOP-gränssnitt
+Comment[ta]=முகவரிப்புத்தகத்துடன் DCOP முகப்பு
+Comment[tg]=Китоби адрес бо интерфейси DCOP
+Comment[tr]=DCOP Arayüzü Olan Adres Defteri
+Comment[uk]=Адресна книга з інтерфейсом DCOP
+Comment[uz]=DCOP interfeysli manzillar daftari
+Comment[uz@cyrillic]=DCOP интерфейсли манзиллар дафтари
+Comment[zh_CN]=具有 DCOP 接口的地址簿
+Comment[zh_TW]=有 DCOP 介面的通訊錄
diff --git a/kaddressbook/distributionlisteditor.cpp b/kaddressbook/distributionlisteditor.cpp
new file mode 100644
index 00000000..a18b5493
--- /dev/null
+++ b/kaddressbook/distributionlisteditor.cpp
@@ -0,0 +1,284 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2007 Klaralvdalens Datakonsult AB <frank@kdab.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include "distributionlisteditor.h"
+#include "distributionlisteditor_p.h"
+
+#include <libkdepim/addresseelineedit.h>
+#include <libkdepim/distributionlist.h>
+#include <libemailfunctions/email.h>
+
+#include <kabc/addressbook.h>
+
+#include <kapplication.h>
+#include <kdialogbase.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klineedit.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qsignalmapper.h>
+#include <qtoolbutton.h>
+
+class KPIM::DistributionListEditor::EditorWidgetPrivate
+{
+public:
+ QScrollView* scrollView;
+ QSignalMapper* mapper;
+ KABC::AddressBook* addressBook;
+ QString distListUid;
+ QLabel* nameLabel;
+ QLabel* memberListLabel;
+ KLineEdit* nameLineEdit;
+ QWidget* memberListWidget;
+ QVBoxLayout* addresseeLayout;
+ QValueList<KPIM::DistributionListEditor::Line*> addressees;
+ KPIM::DistributionList distributionList;
+ KPIM::DistributionListEditor::Line* addLineForEntry( const KPIM::DistributionList::Entry& entry );
+ int lastLineId;
+};
+
+
+KPIM::DistributionListEditor::Line::Line( KABC::AddressBook* book, QWidget* parent ) : QWidget( parent ), m_addressBook( book )
+{
+ Q_ASSERT( m_addressBook );
+ QBoxLayout* layout = new QHBoxLayout( this );
+ layout->setSpacing( KDialog::spacingHint() );
+ m_lineEdit = new KPIM::DistributionListEditor::LineEdit( this );
+ connect( m_lineEdit, SIGNAL( textChanged( const QString& ) ),
+ this, SLOT( textChanged( const QString& ) ) );
+ layout->addWidget( m_lineEdit );
+ m_clearButton = new QToolButton( this );
+ m_clearButton->setIconSet( KApplication::reverseLayout() ? SmallIconSet("locationbar_erase") : SmallIconSet( "clear_left" ) );
+ m_clearButton->setEnabled( false );
+ layout->addWidget( m_clearButton );
+ connect( m_clearButton, SIGNAL( clicked() ), m_lineEdit, SLOT( clear() ) );
+}
+
+void KPIM::DistributionListEditor::Line::textChanged( const QString& text )
+{
+ m_clearButton->setEnabled( !text.isEmpty() );
+ if ( text.isEmpty() )
+ emit cleared();
+ emit textChanged();
+}
+
+void KPIM::DistributionListEditor::Line::setFocusToLineEdit()
+{
+ m_lineEdit->setFocus();
+}
+
+void KPIM::DistributionListEditor::Line::setEntry( const KPIM::DistributionList::Entry& entry )
+{
+ m_uid = entry.addressee.uid();
+ m_initialText = entry.addressee.fullEmail( entry.email );
+ m_lineEdit->setText( m_initialText );
+}
+
+KABC::Addressee KPIM::DistributionListEditor::Line::findAddressee( const QString& name, const QString& email ) const
+{
+ if ( name.isEmpty() && email.isEmpty() )
+ return KABC::Addressee();
+
+ typedef KABC::Addressee::List List;
+ const List byEmail = m_addressBook->findByEmail( email );
+ if ( !byEmail.isEmpty() )
+ {
+ const List::ConstIterator end = byEmail.end();
+ for ( List::ConstIterator it = byEmail.begin(); it != end; ++it )
+ {
+ if ( (*it).formattedName() == name )
+ return *it;
+ }
+ return byEmail.first();
+ }
+ // no entry found, create new addressee:
+ KABC::Addressee addressee;
+ addressee.setUid( KApplication::randomString( 10 ) );
+ addressee.setFormattedName( name );
+ addressee.setEmails( email );
+ m_addressBook->insertAddressee( addressee );
+ return addressee;
+}
+
+KPIM::DistributionList::Entry KPIM::DistributionListEditor::Line::entry() const
+{
+ const QString text = m_lineEdit->text();
+ QString name;
+ QString email;
+ KPIM::getNameAndMail(m_lineEdit->text(), name, email );
+
+ KPIM::DistributionList::Entry res;
+ if ( !m_uid.isNull() )
+ {
+ const KABC::Addressee addr = m_addressBook->findByUid( m_uid );
+ if ( m_initialText == text || addr.formattedName() == name )
+ res.addressee = addr;
+ }
+ if ( res.addressee.isEmpty() )
+ res.addressee = findAddressee( name, email );
+ res.email = res.addressee.preferredEmail() != email ? email : QString();
+ return res;
+}
+
+
+KPIM::DistributionListEditor::LineEdit::LineEdit( QWidget* parent ) : KPIM::AddresseeLineEdit( parent )
+{
+}
+
+
+KPIM::DistributionListEditor::EditorWidget::EditorWidget( KABC::AddressBook* book, QWidget* parent )
+ : KDialogBase( parent, /*name=*/0, /*modal=*/ true, /*caption=*/QString(), KDialogBase::Ok|KDialogBase::Cancel ), d( new DistributionListEditor::EditorWidgetPrivate )
+{
+ d->addressBook = book;
+ Q_ASSERT( d->addressBook );
+ d->lastLineId = 0;
+ d->mapper = new QSignalMapper( this );
+ connect( d->mapper, SIGNAL( mapped( int ) ),
+ this, SLOT( lineTextChanged( int ) ) );
+ setCaption( i18n( "Edit Distribution List" ) );
+ QWidget* main = new QWidget( this );
+ QVBoxLayout* mainLayout = new QVBoxLayout( main );
+ mainLayout->setMargin( KDialog::marginHint() );
+ mainLayout->setSpacing( KDialog::spacingHint() );
+
+ QHBoxLayout* nameLayout = new QHBoxLayout;
+ nameLayout->setSpacing( KDialog::spacingHint() );
+ d->nameLabel = new QLabel( main );
+ d->nameLabel->setText( i18n( "Name:" ) );
+ nameLayout->addWidget( d->nameLabel );
+
+ d->nameLineEdit = new KLineEdit( main );
+ nameLayout->addWidget( d->nameLineEdit );
+
+ mainLayout->addLayout( nameLayout );
+ mainLayout->addSpacing( 30 );
+
+ d->memberListLabel = new QLabel( main );
+ d->memberListLabel->setText( i18n( "Distribution list members:" ) );
+ mainLayout->addWidget( d->memberListLabel );
+
+ d->scrollView = new QScrollView( main );
+ d->scrollView->setFrameShape( QFrame::NoFrame );
+ mainLayout->addWidget( d->scrollView );
+ d->memberListWidget = new QWidget( d->scrollView->viewport() );
+ d->memberListWidget->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
+ QVBoxLayout* memberLayout = new QVBoxLayout( d->memberListWidget );
+ d->addresseeLayout = new QVBoxLayout;
+ d->addresseeLayout->setSpacing( KDialog::spacingHint() );
+ memberLayout->addItem( d->addresseeLayout );
+ memberLayout->addStretch();
+ d->scrollView->addChild( d->memberListWidget );
+ d->scrollView->setResizePolicy( QScrollView::AutoOneFit );
+
+ setMainWidget( main );
+
+ KPIM::DistributionListEditor::Line* const last = d->addLineForEntry( KPIM::DistributionList::Entry() );
+ const QSize hint = sizeHint();
+ resize( hint.width() * 1.5, hint.height() );
+}
+
+KPIM::DistributionListEditor::EditorWidget::~EditorWidget()
+{
+ delete d;
+}
+
+void KPIM::DistributionListEditor::EditorWidget::lineTextChanged( int id )
+{
+ if ( id != d->lastLineId )
+ return;
+ d->addLineForEntry( KPIM::DistributionList::Entry() );
+ d->scrollView->updateContents();
+}
+
+void KPIM::DistributionListEditor::EditorWidget::setDistributionList( const KPIM::DistributionList& list )
+{
+ d->distListUid = list.uid();
+ d->nameLineEdit->setText( list.name() );
+
+ using KPIM::DistributionListEditor::Line;
+ typedef QValueList<Line*>::ConstIterator ListIterator;
+ for ( ListIterator it = d->addressees.begin(), end = d->addressees.end(); it != end; ++it )
+ {
+ delete *it;
+ }
+ d->addressees.clear();
+
+ typedef KPIM::DistributionList::Entry Entry;
+ const Entry::List entries = list.entries( d->addressBook );
+
+ for ( Entry::List::ConstIterator it = entries.begin(), end = entries.end(); it != end; ++it )
+ {
+ d->addLineForEntry( *it );
+ }
+ KPIM::DistributionListEditor::Line* const last = d->addLineForEntry( Entry() );
+ last->setFocusToLineEdit();
+}
+
+KPIM::DistributionListEditor::Line* KPIM::DistributionListEditor::EditorWidgetPrivate::addLineForEntry( const KPIM::DistributionList::Entry& entry )
+{
+ KPIM::DistributionListEditor::Line* line = new KPIM::DistributionListEditor::Line( addressBook, memberListWidget );
+ line->setEntry( entry );
+ addresseeLayout->addWidget( line );
+ addressees.append( line );
+ QObject::connect( line, SIGNAL( textChanged() ),
+ mapper, SLOT( map() ) );
+ mapper->setMapping( line, ++lastLineId );
+ line->setShown( true );
+ return line;
+}
+
+void KPIM::DistributionListEditor::EditorWidget::slotOk()
+{
+ const QString name = d->nameLineEdit->text();
+ const KPIM::DistributionList existing = KPIM::DistributionList::findByName( d->addressBook, name );
+ if ( !existing.isEmpty() && existing.uid() != d->distListUid )
+ {
+ KMessageBox::error( this, i18n( "A distribution list with the name %1 already exists. Please choose another name." ).arg( name ), i18n( "Name in Use" ) );
+ return;
+ }
+
+ KPIM::DistributionList list;
+ list.setUid( d->distListUid.isNull() ? KApplication::randomString( 10 ) :d->distListUid );
+ list.setName( name );
+ typedef QValueList<KPIM::DistributionListEditor::Line*>::ConstIterator ListIterator;
+ for ( ListIterator it = d->addressees.begin(), end = d->addressees.end(); it != end; ++it )
+ {
+ const KPIM::DistributionList::Entry entry = (*it)->entry();
+ if ( entry.addressee.isEmpty() )
+ continue;
+ list.insertEntry( entry.addressee, entry.email );
+ }
+ d->distributionList = list;
+ accept();
+}
+
+KPIM::DistributionList KPIM::DistributionListEditor::EditorWidget::distributionList() const
+{
+ return d->distributionList;
+}
+
+#include "distributionlisteditor.moc"
+#include "distributionlisteditor_p.moc"
diff --git a/kaddressbook/distributionlisteditor.h b/kaddressbook/distributionlisteditor.h
new file mode 100644
index 00000000..193ff83f
--- /dev/null
+++ b/kaddressbook/distributionlisteditor.h
@@ -0,0 +1,62 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2007 Klaralvdalens Datakonsult AB <frank@kdab.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KPIM_DISTRIBUTIONLISTEDITOR_H
+#define KPIM_DISTRIBUTIONLISTEDITOR_H
+
+#include <kdialogbase.h>
+
+namespace KABC {
+ class AddressBook;
+}
+
+namespace KPIM {
+
+class DistributionList;
+
+namespace DistributionListEditor {
+
+class EditorWidgetPrivate;
+class EditorWidget : public KDialogBase
+{
+ Q_OBJECT
+public:
+ explicit EditorWidget( KABC::AddressBook* book, QWidget* parent = 0 );
+ ~EditorWidget();
+
+ void setDistributionList( const KPIM::DistributionList& list );
+ KPIM::DistributionList distributionList() const;
+
+private slots:
+
+ //override
+ void slotOk();
+ void lineTextChanged( int id );
+
+private:
+ EditorWidgetPrivate* const d;
+};
+
+} // namespace DisributionListEditor
+} // namespace KPIM
+
+#endif // KPIM_DISTRIBUTIONLISTEDITOR_H
diff --git a/kaddressbook/distributionlisteditor_p.h b/kaddressbook/distributionlisteditor_p.h
new file mode 100644
index 00000000..e8708698
--- /dev/null
+++ b/kaddressbook/distributionlisteditor_p.h
@@ -0,0 +1,83 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2007 Klaralvdalens Datakonsult AB <frank@kdab.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KPIM_DISTRIBUTIONLISTEDITOR_P_H
+#define KPIM_DISTRIBUTIONLISTEDITOR_P_H
+
+#include <libkdepim/addresseelineedit.h>
+#include <libkdepim/distributionlist.h>
+
+#include <qpushbutton.h>
+#include <qstring.h>
+
+class QToolButton;
+
+namespace KABC {
+ class Addressee;
+ class AddressBook;
+}
+
+namespace KPIM {
+namespace DistributionListEditor {
+
+class LineEdit : public KPIM::AddresseeLineEdit
+{
+ Q_OBJECT
+public:
+ explicit LineEdit( QWidget* parent = 0 );
+};
+
+
+class Line : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit Line( KABC::AddressBook* book, QWidget* parent = 0 );
+
+ void setEntry( const KPIM::DistributionList::Entry& entry );
+ KPIM::DistributionList::Entry entry() const;
+ void setFocusToLineEdit();
+
+signals:
+ void cleared();
+ void textChanged();
+
+private:
+ KABC::Addressee findAddressee( const QString& name, const QString& email ) const;
+
+private slots:
+ void textChanged( const QString& );
+
+private:
+ QString m_uid;
+ QString m_initialText;
+ LineEdit* m_lineEdit;
+ QToolButton* m_clearButton;
+ KABC::AddressBook* m_addressBook;
+};
+
+} // namespace DisributionListEditor
+} // namespace KPIM
+
+#endif // KPIM_DISTRIBUTIONLISTEDITOR_P_H
+
+
diff --git a/kaddressbook/distributionlistentryview.cpp b/kaddressbook/distributionlistentryview.cpp
new file mode 100644
index 00000000..2db13f80
--- /dev/null
+++ b/kaddressbook/distributionlistentryview.cpp
@@ -0,0 +1,140 @@
+#include "distributionlistentryview.h"
+#include "imagewidget.h"
+#include <interfaces/core.h>
+
+#include <libkdepim/resourceabc.h>
+
+#include <kabc/addressbook.h>
+#include <kabc/resource.h>
+
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kurllabel.h>
+
+#include <qbuttongroup.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qradiobutton.h>
+#include <qstringlist.h>
+#include <qvbuttongroup.h>
+
+KAB::DistributionListEntryView::DistributionListEntryView( KAB::Core* core, QWidget* parent ) : QWidget( parent ), m_core( core ), m_emailGroup( 0 )
+{
+ m_mainLayout = new QVBoxLayout( this );
+ m_mainLayout->setSpacing( KDialog::spacingHint() );
+ m_mainLayout->setMargin( KDialog::marginHint() );
+
+ QBoxLayout* headerLayout = new QHBoxLayout;
+ headerLayout->setSpacing( KDialog::spacingHint() * 3 );
+
+ m_imageLabel = new QLabel( this );
+ m_imageLabel->setAutoResize( true );
+ headerLayout->addWidget( m_imageLabel, 0, Qt::AlignTop );
+
+ m_addresseeLabel = new QLabel( this );
+ headerLayout->addWidget( m_addresseeLabel, 0, Qt::AlignTop );
+ headerLayout->addStretch();
+
+ m_mainLayout->addItem( headerLayout );
+
+ QBoxLayout* distLayout = new QHBoxLayout;
+ distLayout->setSpacing( KDialog::spacingHint() );
+
+ QLabel* distLabel = new QLabel( this );
+ distLabel->setText( i18n( "<b>Distribution list:</b>" ) );
+ distLabel->setAlignment( Qt::SingleLine );
+ distLayout->addWidget( distLabel );
+
+ m_distListLabel = new KURLLabel( this );
+ distLabel->setBuddy( m_distListLabel );
+ connect( m_distListLabel, SIGNAL( leftClickedURL( const QString& ) ),
+ this, SIGNAL( distributionListClicked( const QString& ) ) );
+ distLayout->addWidget( m_distListLabel );
+ distLayout->addStretch();
+ m_mainLayout->addItem( distLayout );
+
+ QLabel* emailLabel = new QLabel( this );
+ emailLabel->setText( i18n( "<b>Email address to use in this list:</b>" ) );
+ emailLabel->setAlignment( Qt::SingleLine );
+ m_mainLayout->addWidget( emailLabel );
+
+ QBoxLayout* emailLayout = new QHBoxLayout;
+ emailLayout->setSpacing( KDialog::spacingHint() );
+ emailLayout->addSpacing( 30 );
+
+ m_radioLayout = new QGridLayout;
+ emailLayout->addItem( m_radioLayout );
+ emailLayout->addStretch();
+ m_mainLayout->addItem( emailLayout );
+
+ QBoxLayout* resourceLayout = new QHBoxLayout;
+ resourceLayout->setSpacing( KDialog::spacingHint() );
+ m_resourceLabel = new QLabel( this );
+ resourceLayout->addWidget( m_resourceLabel );
+ resourceLayout->addStretch();
+
+ m_mainLayout->addItem( resourceLayout );
+ m_mainLayout->addStretch();
+}
+
+void KAB::DistributionListEntryView::emailButtonClicked( int id )
+{
+ const QString email = m_idToEmail[ id ];
+ if ( m_entry.email == email )
+ return;
+ m_list.removeEntry( m_entry.addressee, m_entry.email );
+ m_entry.email = email;
+ m_list.insertEntry( m_entry.addressee, m_entry.email );
+ m_core->addressBook()->insertAddressee( m_list );
+}
+
+void KAB::DistributionListEntryView::clear()
+{
+ setEntry( KPIM::DistributionList(), KPIM::DistributionList::Entry() );
+}
+
+void KAB::DistributionListEntryView::setEntry( const KPIM::DistributionList& list, const KPIM::DistributionList::Entry& entry )
+{
+ m_list = list;
+ m_entry = entry;
+
+ delete m_emailGroup;
+ m_emailGroup = 0;
+
+ QPixmap pixmap;
+ pixmap.convertFromImage( m_entry.addressee.photo().data() );
+ m_imageLabel->setPixmap( pixmap.isNull() ? KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) : pixmap );
+ m_addresseeLabel->setText( i18n( "Formatted name, role, organization", "<qt><h2>%1</h2><p>%2<br/>%3</p></qt>" ).arg( m_entry.addressee.formattedName(), m_entry.addressee.role(), m_entry.addressee.organization() ) );
+ m_distListLabel->setURL( m_list.name() );
+ m_distListLabel->setText( m_list.name() );
+ m_resourceLabel->setText( i18n( "<b>Address book:</b> %1" ).arg( m_entry.addressee.resource() ? m_entry.addressee.resource()->resourceName() : QString() ) );
+ m_resourceLabel->setAlignment( Qt::SingleLine );
+
+ m_emailGroup = new QVButtonGroup( this );
+ m_emailGroup->setFlat( true );
+ m_emailGroup->setExclusive( true );
+ m_emailGroup->setFrameShape( QFrame::NoFrame );
+
+ const QString preferred = m_entry.email.isNull() ? m_entry.addressee.preferredEmail() : m_entry.email;
+ const QStringList mails = m_entry.addressee.emails();
+ m_idToEmail.clear();
+ for ( QStringList::ConstIterator it = mails.begin(); it != mails.end(); ++it )
+ {
+ QRadioButton* button = new QRadioButton( m_emailGroup );
+ button->setText( *it );
+ m_idToEmail.insert( m_emailGroup->insert( button ), *it );
+ if ( *it == preferred )
+ button->setChecked( true );
+ button->setShown( true );
+ }
+ connect( m_emailGroup, SIGNAL( clicked( int ) ),
+ this, SLOT( emailButtonClicked( int ) ) );
+ m_radioLayout->addWidget( m_emailGroup, 0, 0 );
+ m_emailGroup->setShown( true );
+ m_mainLayout->invalidate();
+}
+
+
+#include "distributionlistentryview.moc"
diff --git a/kaddressbook/distributionlistentryview.h b/kaddressbook/distributionlistentryview.h
new file mode 100644
index 00000000..1fbf9f2d
--- /dev/null
+++ b/kaddressbook/distributionlistentryview.h
@@ -0,0 +1,58 @@
+#ifndef KAB_DISTRIBUTIONLISTENTRYVIEW_H
+#define KAB_DISTRIBUTIONLISTENTRYVIEW_H
+
+#include <libkdepim/distributionlist.h>
+
+#include <qmap.h>
+#include <qstring.h>
+#include <qwidget.h>
+
+class QBoxLayout;
+class QButtonGroup;
+class QComboBox;
+class QGridLayout;
+class QLabel;
+
+class KURLLabel;
+
+class ImageButton;
+
+namespace KAB {
+
+class Core;
+
+class DistributionListEntryView : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit DistributionListEntryView( KAB::Core* core, QWidget* parent = 0 );
+ void setEntry( const KPIM::DistributionList& list, const KPIM::DistributionList::Entry& entry );
+
+public slots:
+ void clear();
+
+signals:
+ void distributionListClicked( const QString& );
+
+private slots:
+ void emailButtonClicked( int id );
+
+private:
+ QMap<int, QString> m_idToEmail;
+ KAB::Core* m_core;
+ KPIM::DistributionList m_list;
+ KPIM::DistributionList::Entry m_entry;
+ QGridLayout* m_radioLayout;
+ QBoxLayout* m_mainLayout;
+ QButtonGroup* m_emailGroup;
+ QLabel* m_addresseeLabel;
+ KURLLabel* m_distListLabel;
+ QLabel* m_imageLabel;
+ QLabel* m_resourceLabel;
+ QMap<int, QString> m_indexToIdentifier;
+};
+
+}
+
+#endif // KAB_DISTRIBUTIONLISTENTRYVIEW_H
diff --git a/kaddressbook/distributionlistpicker.cpp b/kaddressbook/distributionlistpicker.cpp
new file mode 100644
index 00000000..c2eb3ee0
--- /dev/null
+++ b/kaddressbook/distributionlistpicker.cpp
@@ -0,0 +1,142 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2007 Klaralvdalens Datakonsult AB <frank@kdab.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include "distributionlistpicker.h"
+#include "config.h"
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+#include <libkdepim/distributionlist.h>
+#endif
+
+#include <kabc/addressbook.h>
+
+#include <kapplication.h>
+#include <kinputdialog.h>
+#include <klistbox.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qregexp.h>
+#include <qvalidator.h>
+
+KPIM::DistributionListPickerDialog::DistributionListPickerDialog( KABC::AddressBook* book, QWidget* parent ) : KDialogBase( parent, 0, true, QString(), Ok | Cancel | User1 ), m_book( book )
+{
+ Q_ASSERT( m_book );
+ setModal( true );
+ enableButton( Ok, false );
+ setButtonText( User1, i18n( "Add New Distribution List" ) );
+ QWidget* main = new QWidget( this );
+ QGridLayout* layout = new QGridLayout( main );
+ layout->setSpacing( KDialog::spacingHint() );
+ m_label = new QLabel( main );
+ layout->addWidget( m_label, 0, 0 );
+ m_listBox = new KListBox( main );
+ layout->addWidget( m_listBox, 1, 0 );
+ connect( m_listBox, SIGNAL( highlighted( const QString& ) ),
+ this, SLOT( entrySelected( const QString& ) ) );
+ connect( m_listBox, SIGNAL( selected( const QString& ) ),
+ this, SLOT( entrySelected( const QString& ) ) );
+ setMainWidget( main );
+#ifdef KDEPIM_NEW_DISTRLISTS
+ typedef QValueList<KPIM::DistributionList> DistListList;
+ const DistListList lists = KPIM::DistributionList::allDistributionLists( m_book );
+ for ( DistListList::ConstIterator it = lists.begin(); it != lists.end(); ++it )
+ {
+ m_listBox->insertItem ( (*it).name() );
+ }
+#endif
+}
+
+void KPIM::DistributionListPickerDialog::entrySelected( const QString& name )
+{
+ actionButton( Ok )->setEnabled( !name.isNull() );
+}
+
+void KPIM::DistributionListPickerDialog::setLabelText( const QString& text )
+{
+ m_label->setText( text );
+}
+
+void KPIM::DistributionListPickerDialog::slotUser1()
+{
+#ifdef KDEPIM_NEW_DISTRLISTS
+ const QValueList<KPIM::DistributionList> lists = KPIM::DistributionList::allDistributionLists( m_book );
+ QStringList listNames;
+ for ( QValueList<KPIM::DistributionList>::ConstIterator it = lists.begin(); it != lists.end(); ++it )
+ {
+ listNames += (*it).name();
+ }
+
+ bool validName = false;
+ do
+ {
+ QRegExpValidator validator( QRegExp( "\\S+.*" ), 0 );
+ const QString name = KInputDialog::getText( i18n( "Enter Name" ), i18n( "Enter a name for the new distribution list:" ), QString(), 0, this, 0, &validator ).stripWhiteSpace();
+ if ( name.isEmpty() )
+ return;
+
+ validName = !listNames.contains( name );
+
+ if ( validName )
+ {
+ KPIM::DistributionList list;
+ list.setName( name );
+ list.setUid( KApplication::randomString( 10 ) );
+ m_book->insertAddressee( list );
+
+ m_listBox->insertItem( name );
+ QListBoxItem* item = m_listBox->findItem( name );
+ m_listBox->setSelected( item, true );
+ }
+ else
+ {
+ KMessageBox::error( this, i18n( "A distribution list with the the name %1 already exists. Please choose another name" ).arg( name ), i18n( "Name Exists" ) );
+ }
+ }
+ while ( !validName );
+#endif
+}
+
+
+void KPIM::DistributionListPickerDialog::slotOk()
+{
+ QListBoxItem* item = m_listBox->selectedItem();
+ m_selectedDistributionList = item ? item->text() : QString();
+ KDialogBase::slotOk();
+}
+
+void KPIM::DistributionListPickerDialog::slotCancel()
+{
+ m_selectedDistributionList = QString();
+ KDialogBase::slotCancel();
+}
+
+QString KPIM::DistributionListPickerDialog::selectedDistributionList() const
+{
+ return m_selectedDistributionList;
+}
+
+#include "distributionlistpicker.moc"
+
diff --git a/kaddressbook/distributionlistpicker.h b/kaddressbook/distributionlistpicker.h
new file mode 100644
index 00000000..0081fc62
--- /dev/null
+++ b/kaddressbook/distributionlistpicker.h
@@ -0,0 +1,69 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2007 Klaralvdalens Datakonsult AB <frank@kdab.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KPIM_DISTRIBUTIONLISTPICKER_H
+#define KPIM_DISTRIBUTIONLISTPICKER_H
+
+#include <kdialogbase.h>
+
+#include <qstring.h>
+
+class KListBox;
+
+namespace KABC {
+ class AddressBook;
+}
+
+namespace KPIM {
+
+class DistributionListPickerDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ explicit DistributionListPickerDialog( KABC::AddressBook* book, QWidget* parent = 0 );
+ QString selectedDistributionList() const;
+
+ void setLabelText( const QString& text );
+
+private slots:
+
+ //override
+ void slotOk();
+
+ //override
+ void slotCancel();
+
+ //override
+ void slotUser1();
+
+ void entrySelected( const QString& name );
+
+private:
+ KABC::AddressBook* m_book;
+ QLabel* m_label;
+ KListBox* m_listBox;
+ QString m_selectedDistributionList;
+};
+
+} //namespace KPIM
+
+#endif // KPIM_DISTRIBUTIONLISTPICKER_H
diff --git a/kaddressbook/editors/Makefile.am b/kaddressbook/editors/Makefile.am
new file mode 100644
index 00000000..e611bb5e
--- /dev/null
+++ b/kaddressbook/editors/Makefile.am
@@ -0,0 +1,32 @@
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/kaddressbook/interfaces \
+ -I$(top_srcdir)/kaddressbook \
+ -I$(top_srcdir)/certmanager/lib \
+ -I$(top_srcdir)/libkdenetwork \
+ -I$(top_builddir)/kaddressbook/editors \
+ $(GPGME_CFLAGS) \
+ $(all_includes)
+
+kde_module_LTLIBRARIES = libkaddrbk_cryptosettings.la
+
+XXLIBS = $(top_builddir)/kaddressbook/interfaces/libkabinterfaces.la \
+ $(top_builddir)/certmanager/lib/libkleopatra.la
+
+libkaddrbk_cryptosettings_la_SOURCES = cryptowidget.cpp
+libkaddrbk_cryptosettings_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) # -no-undefined
+libkaddrbk_cryptosettings_la_LIBADD = $(XXLIBS)
+
+noinst_HEADERS = cryptowidget.h imeditorwidget.h imaddresswidget.h
+
+METASOURCES = AUTO
+
+SUBDIRS = protocols icons
+servicedir = $(kde_servicesdir)/kaddressbook
+service_DATA = cryptosettings.desktop
+
+servicetypedir = $(kde_servicetypesdir)
+servicetype_DATA = kaddressbookimprotocol.desktop
+
+noinst_LTLIBRARIES = libkabim.la
+libkabim_la_SOURCES = imeditorwidget.cpp imeditorbase.ui imaddressbase.ui imaddresswidget.cpp
+libkabim_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
+libkabim_la_LIBADD = $(top_builddir)/kaddressbook/interfaces/libkabinterfaces.la
diff --git a/kaddressbook/editors/cryptosettings.desktop b/kaddressbook/editors/cryptosettings.desktop
new file mode 100644
index 00000000..90ea108b
--- /dev/null
+++ b/kaddressbook/editors/cryptosettings.desktop
@@ -0,0 +1,56 @@
+[Desktop Entry]
+X-KDE-Library=libkaddrbk_cryptosettings
+Name=Crypto Preferences
+Name[af]=Kripto Voorkeure
+Name[be]=Перавагі крыптаграфіі
+Name[bg]=Шифроване
+Name[bs]=Postavke kriptografije
+Name[ca]=Preferències de criptografia
+Name[cs]=Nastavení šifrování
+Name[da]=Krypto-indstillinger
+Name[de]=Kryptographie-Einstellungen
+Name[el]=Προτιμήσεις κρυπτογραφίας
+Name[eo]=Agordoj pri Ĉifrado
+Name[es]=Preferencias de cifrado
+Name[et]=Krüptoseadistused
+Name[eu]=Kriptografia hobespenak
+Name[fa]=تنظیمات مخفی
+Name[fi]=Salauksen asetukset
+Name[fr]=Préférences de chiffrement
+Name[fy]=Fersiferingynstellings
+Name[gl]=Preferencias de Cifraxe
+Name[he]=מאפייני הצפנה
+Name[hu]=Titkosítási beállítások
+Name[is]=Stillingar dulritunar
+Name[it]=Preferenze crittografia
+Name[ja]=暗号の設定
+Name[ka]=დაშიფრვის პარამეტრები
+Name[kk]=Шифрлау параметрлері
+Name[km]=ចំណង់​ចំណូល​ចិត្ត Crypto
+Name[ko]=암호화 설정
+Name[lt]=Šifravimo pasirinkimai
+Name[ms]=Keutamaan Kripto
+Name[nb]=Krypteringsinnstillinger
+Name[nds]=Verslöteln-Instellen
+Name[ne]=गुप्तिकरण प्राथमिकता
+Name[nl]=Versleutelingsinstellingen
+Name[nn]=Krypteringsinnstillinger
+Name[pl]=Ustawienia kryptograficzne
+Name[pt]=Preferências de Encriptação
+Name[pt_BR]=Configurações de Criptografia
+Name[ru]=Настройки шифрования
+Name[se]=Krypterenheivehusat
+Name[sk]=Nastavenie šifrovania
+Name[sl]=Lastnosti šifriranja
+Name[sr]=Криптографска подешавања
+Name[sr@Latn]=Kriptografska podešavanja
+Name[sv]=Krypteringsinställningar
+Name[ta]= க்ரிப்டோ முன்னுரிமைகள்
+Name[tg]=Танзимоти рамзгузорӣ
+Name[tr]=Şifreleme Özellikleri
+Name[uk]=Параметри шифрування
+Name[zh_CN]=加密首选项
+Name[zh_TW]=加密設定
+Type=Service
+ServiceTypes=KAddressBook/ContactEditorWidget
+X-KDE-KAddressBook-CEWPluginVersion=1
diff --git a/kaddressbook/editors/cryptowidget.cpp b/kaddressbook/editors/cryptowidget.cpp
new file mode 100644
index 00000000..d2d5917f
--- /dev/null
+++ b/kaddressbook/editors/cryptowidget.cpp
@@ -0,0 +1,227 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2004 Klar�vdalens Datakonsult AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <config.h>
+#include "certmanager/lib/ui/keyrequester.h"
+#include "certmanager/lib/cryptplugfactory.h"
+#include "certmanager/lib/cryptplugwrapper.h"
+#include "certmanager/lib/kleo/enum.h"
+
+#include "gpgmepp/data.h"
+#include "gpgmepp/key.h"
+
+#include <kdebug.h>
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <klocale.h>
+
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qpushbutton.h>
+#include <qvgroupbox.h>
+#include <qhbox.h>
+
+#include "cryptowidget.h"
+
+extern "C" {
+ void *init_libkaddrbk_cryptosettings()
+ {
+ return ( new CryptoWidgetFactory );
+ }
+}
+
+CryptoWidgetFactory::CryptoWidgetFactory()
+{
+ KGlobal::locale()->insertCatalogue( "libkleopatra" );
+ KGlobal::iconLoader()->addAppDir( "libkleopatra" );
+}
+
+QString CryptoWidgetFactory::pageTitle() const
+{
+ return i18n( "Crypto Settings" );
+}
+
+QString CryptoWidgetFactory::pageIdentifier() const
+{
+ return "crypto";
+}
+
+CryptoWidget::CryptoWidget( KABC::AddressBook *ab, QWidget *parent, const char *name )
+ : KAB::ContactEditorWidget( ab, parent, name ), mReadOnly( false )
+{
+ QGridLayout *topLayout = new QGridLayout( this, 2, 5, KDialog::marginHint(),
+ KDialog::spacingHint() );
+ topLayout->setColStretch( 1, 1 );
+ topLayout->setRowStretch( 4, 1 );
+
+ QVGroupBox* protGB = new QVGroupBox( i18n( "Allowed Protocols" ), this );
+ topLayout->addMultiCellWidget( protGB, 0, 0, 0, 1 );
+
+ uint msgFormat = 1;
+ for ( uint i = 0 ; i < NumberOfProtocols ; ++i ) {
+ Kleo::CryptoMessageFormat f = static_cast<Kleo::CryptoMessageFormat>( msgFormat );
+ mProtocolCB[ i ] = new QCheckBox( Kleo::cryptoMessageFormatToLabel( f ), protGB );
+ connect( mProtocolCB[i], SIGNAL( clicked() ), this, SLOT( setModified() ) );
+
+ // Iterating over a bitfield means *2 every time
+ msgFormat *= 2;
+ }
+
+ QLabel* l = new QLabel( i18n( "Preferred OpenPGP encryption key:" ), this );
+ topLayout->addWidget( l, 1, 0 );
+
+ mPgpKey = new Kleo::EncryptionKeyRequester( true, Kleo::EncryptionKeyRequester::OpenPGP, this );
+ topLayout->addWidget( mPgpKey, 1, 1 );
+
+ l = new QLabel( i18n( "Preferred S/MIME encryption certificate:" ), this );
+ topLayout->addWidget( l, 2, 0 );
+
+ mSmimeCert = new Kleo::EncryptionKeyRequester( true, Kleo::EncryptionKeyRequester::SMIME, this );
+ topLayout->addWidget( mSmimeCert, 2, 1 );
+
+ QGroupBox* box = new QVGroupBox( i18n( "Message Preference" ), this );
+ topLayout->addMultiCellWidget( box, 3, 3, 0, 1 );
+
+
+ // Send preferences/sign (see certmanager/lib/kleo/enum.h)
+ QHBox* hbox = new QHBox( box );
+
+ l = new QLabel( i18n( "Sign:" ), hbox );
+
+ mSignPref = new QComboBox( false, hbox );
+ for ( unsigned int i = Kleo::UnknownSigningPreference; i < Kleo::MaxSigningPreference ; ++i )
+ mSignPref->insertItem( Kleo::signingPreferenceToLabel(
+ static_cast<Kleo::SigningPreference>( i ) ) );
+
+ // Send preferences/encrypt (see certmanager/lib/kleo/enum.h)
+ hbox = new QHBox( box );
+
+ l = new QLabel( i18n("Encrypt:"), hbox );
+
+ mCryptPref = new QComboBox( false, hbox );
+ for ( unsigned int i = Kleo::UnknownPreference; i < Kleo::MaxEncryptionPreference ; ++i )
+ mCryptPref->insertItem( Kleo::encryptionPreferenceToLabel(
+ static_cast<Kleo::EncryptionPreference>( i ) ) );
+
+ // Emit "changed()" signal
+ connect( mSignPref, SIGNAL( activated(int) ), this, SLOT( setModified() ) );
+ connect( mCryptPref, SIGNAL( activated(int) ), this, SLOT( setModified() ) );
+ // Not optimal, but KeyRequester doesn't emit any signals when the key changes
+ connect( mPgpKey->eraseButton(), SIGNAL( clicked() ), this, SLOT( setModified() ) );
+ connect( mPgpKey->dialogButton(), SIGNAL( clicked() ), this, SLOT( setModified() ) );
+ connect( mSmimeCert->eraseButton(), SIGNAL( clicked() ), this, SLOT( setModified() ) );
+ connect( mSmimeCert->dialogButton(), SIGNAL( clicked() ), this, SLOT( setModified() ) );
+}
+
+CryptoWidget::~CryptoWidget()
+{
+}
+
+void CryptoWidget::loadContact( KABC::Addressee *addr )
+{
+ bool blocked = signalsBlocked();
+ blockSignals( true );
+
+ QStringList lst = QStringList::split( ',', addr->custom( "KADDRESSBOOK",
+ "CRYPTOPROTOPREF" ) );
+ uint cryptoFormats = Kleo::stringListToCryptoMessageFormats( lst );
+
+ uint msgFormat = 1;
+ for ( uint i = 0 ; i < NumberOfProtocols ; ++i, msgFormat *= 2 ) {
+ mProtocolCB[i]->setChecked( cryptoFormats & msgFormat );
+ }
+
+ mSignPref->setCurrentItem( Kleo::stringToSigningPreference( addr->custom( "KADDRESSBOOK",
+ "CRYPTOSIGNPREF" ) ) );
+ mCryptPref->setCurrentItem( Kleo::stringToEncryptionPreference( addr->custom( "KADDRESSBOOK",
+ "CRYPTOENCRYPTPREF" ) ) );
+
+ // We dont use the contents of addr->key(...) because we want just a ref.
+ // to the key/cert. stored elsewhere.
+
+ mPgpKey->setFingerprints( QStringList::split( ",", addr->custom( "KADDRESSBOOK", "OPENPGPFP" ) ) );
+ mSmimeCert->setFingerprints( QStringList::split( ",", addr->custom( "KADDRESSBOOK", "SMIMEFP" ) ) );
+
+ blockSignals( blocked );
+}
+
+void CryptoWidget::storeContact( KABC::Addressee *addr )
+{
+ uint cryptoFormats = 0;
+ uint msgFormat = 1;
+ for ( uint i = 0 ; i < NumberOfProtocols ; ++i, msgFormat *= 2 ) {
+ if ( mProtocolCB[ i ]->isChecked() )
+ cryptoFormats |= msgFormat;
+ }
+
+ QStringList lst = Kleo::cryptoMessageFormatsToStringList( cryptoFormats );
+ if ( !lst.isEmpty() )
+ addr->insertCustom( "KADDRESSBOOK", "CRYPTOPROTOPREF", lst.join( "," ) );
+ else
+ addr->removeCustom( "KADDRESSBOOK", "CRYPTOPROTOPREF" );
+
+ Kleo::SigningPreference signPref =
+ static_cast<Kleo::SigningPreference>( mSignPref->currentItem() );
+ if ( signPref != Kleo::UnknownSigningPreference )
+ addr->insertCustom( "KADDRESSBOOK", "CRYPTOSIGNPREF",
+ Kleo::signingPreferenceToString( signPref ) );
+ else
+ addr->removeCustom( "KADDRESSBOOK", "CRYPTOSIGNPREF" );
+
+ Kleo::EncryptionPreference encryptPref =
+ static_cast<Kleo::EncryptionPreference>( mCryptPref->currentItem() );
+ if ( encryptPref != Kleo::UnknownPreference )
+ addr->insertCustom( "KADDRESSBOOK", "CRYPTOENCRYPTPREF",
+ Kleo::encryptionPreferenceToString( encryptPref ) );
+ else
+ addr->removeCustom( "KADDRESSBOOK", "CRYPTOENCRYPTPREF" );
+
+ QStringList pfp = mPgpKey->fingerprints();
+ QStringList sfp = mSmimeCert->fingerprints();
+
+ if ( !pfp.isEmpty() )
+ addr->insertCustom( "KADDRESSBOOK", "OPENPGPFP", pfp.join( "," ) );
+ else
+ addr->removeCustom( "KADDRESSBOOK", "OPENPGPFP" );
+
+ if ( !sfp.isEmpty() )
+ addr->insertCustom( "KADDRESSBOOK", "SMIMEFP", sfp.join( "," ) );
+ else
+ addr->removeCustom( "KADDRESSBOOK", "SMIMEFP" );
+}
+
+void CryptoWidget::setReadOnly( bool readOnly )
+{
+ mReadOnly = readOnly;
+ for ( uint i = 0 ; i < NumberOfProtocols ; ++i )
+ mProtocolCB[ i ]->setEnabled( !readOnly );
+
+ mSignPref->setEnabled( !readOnly );
+ mCryptPref->setEnabled( !readOnly );
+ mPgpKey->setEnabled( !readOnly );
+ mSmimeCert->setEnabled( !readOnly );
+}
+
+#include "cryptowidget.moc"
diff --git a/kaddressbook/editors/cryptowidget.h b/kaddressbook/editors/cryptowidget.h
new file mode 100644
index 00000000..de2c7bfc
--- /dev/null
+++ b/kaddressbook/editors/cryptowidget.h
@@ -0,0 +1,71 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2004 Klarlvdalens Datakonsult AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef CRYPTOWIDGET_H
+#define CRYPTOWIDGET_H
+
+#include "contacteditorwidget.h"
+
+class QComboBox;
+
+namespace Kleo {
+ class KeyRequester;
+}
+class QCheckBox;
+
+class CryptoWidget : public KAB::ContactEditorWidget
+{
+ Q_OBJECT
+
+ public:
+ CryptoWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
+ ~CryptoWidget();
+
+ void loadContact( KABC::Addressee *addr );
+ void storeContact( KABC::Addressee *addr );
+ void setReadOnly( bool readOnly );
+
+ private:
+ enum { NumberOfProtocols = 4 };
+ QCheckBox* mProtocolCB[NumberOfProtocols];
+ QComboBox* mSignPref;
+ QComboBox* mCryptPref;
+ Kleo::KeyRequester* mPgpKey;
+ Kleo::KeyRequester* mSmimeCert;
+ bool mReadOnly;
+};
+
+class CryptoWidgetFactory : public KAB::ContactEditorWidgetFactory
+{
+ public:
+ CryptoWidgetFactory();
+ KAB::ContactEditorWidget *createWidget( KABC::AddressBook *ab, QWidget *parent, const char *name )
+ {
+ return new CryptoWidget( ab, parent, name );
+ }
+
+ QString pageTitle() const;
+ QString pageIdentifier() const;
+};
+
+#endif
diff --git a/kaddressbook/editors/icons/Makefile.am b/kaddressbook/editors/icons/Makefile.am
new file mode 100644
index 00000000..828085c7
--- /dev/null
+++ b/kaddressbook/editors/icons/Makefile.am
@@ -0,0 +1,3 @@
+kaddressbookicondir = $(kde_datadir)/kaddressbook/icons
+kaddressbookicon_ICON = AUTO
+
diff --git a/kaddressbook/editors/icons/cr16-app-aim_protocol.png b/kaddressbook/editors/icons/cr16-app-aim_protocol.png
new file mode 100644
index 00000000..1e89df85
--- /dev/null
+++ b/kaddressbook/editors/icons/cr16-app-aim_protocol.png
Binary files differ
diff --git a/kaddressbook/editors/icons/cr16-app-gadu_protocol.png b/kaddressbook/editors/icons/cr16-app-gadu_protocol.png
new file mode 100644
index 00000000..46f062c3
--- /dev/null
+++ b/kaddressbook/editors/icons/cr16-app-gadu_protocol.png
Binary files differ
diff --git a/kaddressbook/editors/icons/cr16-app-groupwise_protocol.png b/kaddressbook/editors/icons/cr16-app-groupwise_protocol.png
new file mode 100644
index 00000000..87dcf0dc
--- /dev/null
+++ b/kaddressbook/editors/icons/cr16-app-groupwise_protocol.png
Binary files differ
diff --git a/kaddressbook/editors/icons/cr16-app-icq_protocol.png b/kaddressbook/editors/icons/cr16-app-icq_protocol.png
new file mode 100644
index 00000000..eda0f8c4
--- /dev/null
+++ b/kaddressbook/editors/icons/cr16-app-icq_protocol.png
Binary files differ
diff --git a/kaddressbook/editors/icons/cr16-app-irc_protocol.png b/kaddressbook/editors/icons/cr16-app-irc_protocol.png
new file mode 100644
index 00000000..c5678d1e
--- /dev/null
+++ b/kaddressbook/editors/icons/cr16-app-irc_protocol.png
Binary files differ
diff --git a/kaddressbook/editors/icons/cr16-app-jabber_protocol.png b/kaddressbook/editors/icons/cr16-app-jabber_protocol.png
new file mode 100644
index 00000000..48dd715e
--- /dev/null
+++ b/kaddressbook/editors/icons/cr16-app-jabber_protocol.png
Binary files differ
diff --git a/kaddressbook/editors/icons/cr16-app-meanwhile_protocol.png b/kaddressbook/editors/icons/cr16-app-meanwhile_protocol.png
new file mode 100644
index 00000000..69767ef3
--- /dev/null
+++ b/kaddressbook/editors/icons/cr16-app-meanwhile_protocol.png
Binary files differ
diff --git a/kaddressbook/editors/icons/cr16-app-msn_protocol.png b/kaddressbook/editors/icons/cr16-app-msn_protocol.png
new file mode 100644
index 00000000..a18ff5d4
--- /dev/null
+++ b/kaddressbook/editors/icons/cr16-app-msn_protocol.png
Binary files differ
diff --git a/kaddressbook/editors/icons/cr16-app-skype_protocol.png b/kaddressbook/editors/icons/cr16-app-skype_protocol.png
new file mode 100644
index 00000000..5649464f
--- /dev/null
+++ b/kaddressbook/editors/icons/cr16-app-skype_protocol.png
Binary files differ
diff --git a/kaddressbook/editors/icons/cr16-app-sms_protocol.png b/kaddressbook/editors/icons/cr16-app-sms_protocol.png
new file mode 100644
index 00000000..3bfa3627
--- /dev/null
+++ b/kaddressbook/editors/icons/cr16-app-sms_protocol.png
Binary files differ
diff --git a/kaddressbook/editors/icons/cr16-app-yahoo_protocol.png b/kaddressbook/editors/icons/cr16-app-yahoo_protocol.png
new file mode 100644
index 00000000..30569212
--- /dev/null
+++ b/kaddressbook/editors/icons/cr16-app-yahoo_protocol.png
Binary files differ
diff --git a/kaddressbook/editors/imaddressbase.ui b/kaddressbook/editors/imaddressbase.ui
new file mode 100644
index 00000000..f62ac00d
--- /dev/null
+++ b/kaddressbook/editors/imaddressbase.ui
@@ -0,0 +1,89 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>IMAddressBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>IMAddressBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>208</width>
+ <height>121</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Edit Address</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QComboBox" row="0" column="1">
+ <property name="name">
+ <cstring>cmbProtocol</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>labelProtocol</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Protocol:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>cmbProtocol</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>edtAddress</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>labelAddress</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Address:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>edtAddress</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>labelNetwork</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Network:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>edtNetwork</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="2" column="1">
+ <property name="name">
+ <cstring>edtNetwork</cstring>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<tabstops>
+ <tabstop>cmbProtocol</tabstop>
+ <tabstop>edtAddress</tabstop>
+</tabstops>
+<slots>
+ <slot>slotProtocolChanged( const QString &amp; )</slot>
+ <slot>slotProtocolChanged()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kaddressbook/editors/imaddresseditor.desktop b/kaddressbook/editors/imaddresseditor.desktop
new file mode 100644
index 00000000..64dc7442
--- /dev/null
+++ b/kaddressbook/editors/imaddresseditor.desktop
@@ -0,0 +1,104 @@
+[Desktop Entry]
+Type=Service
+Name=Instant Messaging
+Name[af]=Kits bootskap
+Name[bg]=Мигновени съобщения
+Name[br]=Postelerezh a-benn-kaer
+Name[bs]=Instant poruke
+Name[ca]=Missatgeria instantània
+Name[cs]=Komunikátor
+Name[el]=Στιγμιαίο μήνυμα
+Name[eo]=Rapidmesaĝilo
+Name[es]=Mensajería instantánea
+Name[et]=Kiirsuhtlus
+Name[eu]=Berehalako mezularitza
+Name[fa]=پیام‌دهی فوری
+Name[fi]=Pikaviestintä
+Name[fr]=Messagerie instantanée
+Name[gl]=Mensaxería Instantánea
+Name[he]=מסרים מיידיים
+Name[hu]=Azonnali üzenetküldés (IM)
+Name[is]=Skilaboðaforrit
+Name[it]=Messaggistica istantanea
+Name[ja]=インスタントメッセージ
+Name[ka]=მყისიერი შეტყობინებები
+Name[kk]=Лезде хабарласу
+Name[km]=ផ្ញើ​សារ​បន្ទាន់
+Name[ko]=인스턴트 페시징
+Name[lt]=Momentinės žinutės
+Name[ms]=Penghantaran Mesej Segera
+Name[nb]=Lynmelding
+Name[nds]=Kortnarichten-Maker
+Name[ne]=संदेशन दृश्टान्त
+Name[nn]=Lynmelding
+Name[pl]=Komunikacja internetowa
+Name[pt]=Mensagens Instantâneas
+Name[pt_BR]=Mensagem Instantâneo
+Name[ru]=Службы обмена сообщениями
+Name[se]=Šleađgadieđáhus
+Name[sk]=Rozhovor
+Name[sl]=Takojšno sporočanje
+Name[sr]=Тренутне поруке
+Name[sr@Latn]=Trenutne poruke
+Name[sv]=Direktmeddelanden
+Name[ta]=உடனடி செய்தி பரிமாற்றம்
+Name[tg]=Хизматгоҳи мубодилаи иттилоот
+Name[tr]=Hızlı Mesajlaşma
+Name[uk]=Миттєвий зв'язок
+Name[uz]=Xabar almashish
+Name[uz@cyrillic]=Хабар алмашиш
+Name[zh_CN]=即时通讯
+Name[zh_TW]=即時通訊
+Comment=Instant Messaging Address Editor
+Comment[af]=Kits boodskap adres redigeerder
+Comment[bg]=Редактор на адреси за мигновените съобщения
+Comment[bs]=Editor adresa za instant poruke
+Comment[ca]=Editor d'adreces de missatgeria instantània
+Comment[cs]=Editor adres komunikátorů
+Comment[da]=Instant Messaging adresseeditor
+Comment[de]=Editor für Instant Messaging-Adressen
+Comment[el]=Επεξεργαστής διευθύνσεων στιγμιαίων μηνυμάτων
+Comment[eo]=Rapidmesaĝila Adres-Redaktilo
+Comment[es]=Editor de direcciones de mensajería instantánea
+Comment[et]=Kiirsuhtluse aadresside redaktor
+Comment[eu]=Berehalako mezularitza helbide editorea
+Comment[fa]=ویرایشگر نشانی پیام‌دهی فوری
+Comment[fi]=Pikaviestinnän osoitteet
+Comment[fr]=Éditeur d'adresses de messagerie instantanée
+Comment[fy]=Instant Messaging Adresbewurker
+Comment[gl]=Editor de Enderezos de Mensaxería Instantánea
+Comment[he]=עורך כתובות מסרים מידיים
+Comment[hu]=IM-címszerkesztő
+Comment[is]=Vistfangaritill fyrir skilaboðaforrit
+Comment[it]=Editor degli indirizzi per messaggi istantanei
+Comment[ja]=インスタントメッセージのアドレスを編集
+Comment[ka]=მყისიერი შეტყობინებების წიგნაკის რედაქტორი
+Comment[kk]=Лезде хабарласу адрестер өңдегіші
+Comment[km]=កម្មវិធី​និពន្ធ​អាសយដ្ឋាន​ដើម្បី​ផ្ញើ​សារ​បន្ទាន់
+Comment[ko]=인스턴트 메시징 주소 편집기
+Comment[lt]=Momentinių žinučių adresų redaktorius
+Comment[ms]=Pengedit Alamat Penghantaran Mesej Segera
+Comment[nb]=Adresse-redigerer for lynmelding
+Comment[nds]=Editor för Kortnarichten-Adressen
+Comment[ne]=दृष्टान्त संदेशन ठेगाना सम्पादक
+Comment[nl]=Instant Messaging Adresbewerker
+Comment[nn]=Adresseredigering for lynmelding
+Comment[pl]=Edytor adresów komunikatorów internetowych
+Comment[pt]=Editor de Endereços do Mensageiro Instantâneo
+Comment[pt_BR]=Editor de Endereços do Mensageiro Instantâneo
+Comment[ru]=Редактор контактов служб обмена сообщениями
+Comment[se]=Šleađgadieđáhusaid čujuhusdoaimmaheaddji
+Comment[sk]=Editor adries pre Instant Messaging
+Comment[sl]=Urejevalnik naslovov takojšnega sporočanja
+Comment[sr]=Едитор адреса тренутних порука
+Comment[sr@Latn]=Editor adresa trenutnih poruka
+Comment[sv]=Adresseditor för direktmeddelanden
+Comment[ta]= உடனடி செய்தி பரிமாற்றத்தின் முகவரி தொகுப்பான்
+Comment[tg]=Муҳаррири алоқоти хизматгоҳҳои мубодилаи иттилоот
+Comment[tr]=Hızlı Mesajlaşma Adres Düzenleyicisi
+Comment[uk]=Редактор адрес миттєвого зв'язку
+Comment[zh_CN]=即时通讯地址编辑器
+Comment[zh_TW]=即時通訊位址編輯器
+ServiceTypes=KAddressBook/ContactEditorWidget
+X-KDE-Library=libkaddrbk_instantmessaging
+X-KDE-KAddressBook-CEWPluginVersion=1
diff --git a/kaddressbook/editors/imaddresswidget.cpp b/kaddressbook/editors/imaddresswidget.cpp
new file mode 100644
index 00000000..3d2af677
--- /dev/null
+++ b/kaddressbook/editors/imaddresswidget.cpp
@@ -0,0 +1,137 @@
+/*
+ IM address editor widget for KAddressbook
+
+ Copyright (c) 2004 Will Stephenson <lists@stevello.free-online.co.uk>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+
+#include <kdebug.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kplugininfo.h>
+
+#include "imaddresswidget.h"
+
+IMAddressWidget::IMAddressWidget( QWidget *parent, QValueList<KPluginInfo *> protocols )
+ : IMAddressBase( parent )
+{
+ mProtocols = protocols;
+ populateProtocols();
+ init();
+}
+
+IMAddressWidget::IMAddressWidget( QWidget *parent, QValueList<KPluginInfo *> protocols,
+ KPluginInfo *protocol, const QString& address,
+ const IMContext& context )
+ : IMAddressBase( parent )
+{
+ Q_UNUSED( context );
+
+ mProtocols = protocols;
+ populateProtocols();
+ cmbProtocol->setCurrentItem( mProtocols.findIndex( protocol ) );
+
+ edtAddress->setText( address.section( QChar( 0xE120 ), 0, 0 ) );
+ edtNetwork->setText( address.section( QChar( 0xE120 ), 1 ) );
+
+ init();
+}
+
+void IMAddressWidget::init()
+{
+ connect( cmbProtocol, SIGNAL( activated( const QString& ) ),
+ this, SLOT( slotProtocolChanged() ) );
+ connect( edtAddress, SIGNAL( textChanged( const QString& ) ),
+ this, SLOT( slotAddressChanged( const QString& ) ) );
+
+ slotProtocolChanged();
+}
+
+void IMAddressWidget::slotAddressChanged( const QString &text )
+{
+ emit inValidState( !text.stripWhiteSpace().isEmpty() );
+}
+
+KPluginInfo * IMAddressWidget::protocol() const
+{
+ int protocolIndex = cmbProtocol->currentItem();
+
+ return mProtocols[ protocolIndex ];
+}
+
+IMContext IMAddressWidget::context() const
+{
+ IMContext context = Any;
+/* if ( cmbContext->currentItem() )
+ {
+
+ int contextIndex = cmbContext->currentItem();
+ switch ( contextIndex )
+ {
+ case 0:
+ context = Any;
+ break;
+ case 1:
+ context = Home;
+ break;
+ case 2:
+ context = Work;
+ break;
+ }
+ }
+ */
+
+ return context;
+}
+
+QString IMAddressWidget::address() const
+{
+ // The protocol irc is a special case and hard coded in.
+ // It's not nice, but the simplest way that I can see.
+ if ( protocol()->name() == "IRC" && !edtNetwork->text().stripWhiteSpace().isEmpty() )
+ return edtAddress->text().stripWhiteSpace() + QChar( 0xE120 ) + edtNetwork->text().stripWhiteSpace();
+ else
+ return edtAddress->text().stripWhiteSpace();
+}
+
+void IMAddressWidget::populateProtocols()
+{
+ // insert the protocols in order
+ QValueList<KPluginInfo *>::ConstIterator it;
+ for ( it = mProtocols.begin(); it != mProtocols.end(); ++it )
+ cmbProtocol->insertItem( SmallIcon( (*it)->icon() ), (*it)->name() );
+}
+
+void IMAddressWidget::slotProtocolChanged()
+{
+ if ( protocol()->name() == "IRC" ) {
+ edtNetwork->show();
+ labelNetwork->show();
+ } else {
+ edtNetwork->hide();
+ labelNetwork->hide();
+ }
+}
+
+#include "imaddresswidget.moc"
diff --git a/kaddressbook/editors/imaddresswidget.h b/kaddressbook/editors/imaddresswidget.h
new file mode 100644
index 00000000..29d93b13
--- /dev/null
+++ b/kaddressbook/editors/imaddresswidget.h
@@ -0,0 +1,74 @@
+/*
+ IM address editor widget for KAddressbook
+
+ Copyright (c) 2004 Will Stephenson <lists@stevello.free-online.co.uk>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+#ifndef IMADDRESSWIDGET_H
+#define IMADDRESSWIDGET_H
+
+#include <qvaluelist.h>
+
+#include "imaddressbase.h"
+#include "imeditorwidget.h"
+
+class KPluginInfo;
+
+/* Note regarding Context:
+ * It wasn not possible to get an idea of Context into Kopete in time for KDE 3.3,
+ * so it has been removed from the UI and functionally disabled in the code.
+ */
+
+/**
+ * A widget for editing an instant messaging address
+ */
+class IMAddressWidget : public IMAddressBase
+{
+ Q_OBJECT
+
+ public:
+ IMAddressWidget( QWidget *parent, QValueList<KPluginInfo *> protocols);
+ IMAddressWidget( QWidget *parent, QValueList<KPluginInfo *> protocols,
+ KPluginInfo *protocol, const QString& address,
+ const IMContext& context = Any );
+
+ KPluginInfo * protocol() const;
+ IMContext context() const;
+ QString address() const ;
+ QValueList<KPluginInfo *> mProtocols;
+
+ signals:
+ void inValidState( bool );
+
+ protected:
+ /**
+ * Populate combobox with protocols
+ */
+ void populateProtocols();
+
+ protected slots:
+ void slotProtocolChanged();
+ void slotAddressChanged( const QString &text );
+
+ private:
+ void init();
+};
+
+#endif
diff --git a/kaddressbook/editors/imeditorbase.ui b/kaddressbook/editors/imeditorbase.ui
new file mode 100644
index 00000000..24a5696a
--- /dev/null
+++ b/kaddressbook/editors/imeditorbase.ui
@@ -0,0 +1,164 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>IMEditorBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>IMEditorBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>442</width>
+ <height>247</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>IM Addresses</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="4" column="1">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton" row="3" column="1">
+ <property name="name">
+ <cstring>btnSetStandard</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Set Standard</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The IM Address that is set as the standard is the address that is shown in main editor window.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;Only one IM Address can be set as the standard IM Address.&lt;br&gt;The standard IM Address is shown in the main editor window, and other programs may use this as hint for deciding which IM Address to show.&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="2" column="1">
+ <property name="name">
+ <cstring>btnDelete</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Remove</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>btnEdit</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Edit...</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>btnAdd</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Add...</string>
+ </property>
+ </widget>
+ <widget class="KListView" row="0" column="0" rowspan="5" colspan="1">
+ <column>
+ <property name="text">
+ <string>Protocol</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Address</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lvAddresses</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>28</height>
+ </size>
+ </property>
+ <property name="selectionMode" stdset="0">
+ <enum>Extended</enum>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="fullWidth">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="KActiveLabel" row="5" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>lblWarning</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;em&gt;Note:&lt;/em&gt; Please read the help page before adding or editing Instant Messenging Addresses here.</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<layoutdefaults spacing="6" margin="0"/>
+<layoutfunctions spacing="KDialog::spacingHint"/>
+<includehints>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>klistview.h</includehint>
+ <includehint>kactivelabel.h</includehint>
+</includehints>
+</UI>
diff --git a/kaddressbook/editors/imeditorwidget.cpp b/kaddressbook/editors/imeditorwidget.cpp
new file mode 100644
index 00000000..f61e0638
--- /dev/null
+++ b/kaddressbook/editors/imeditorwidget.cpp
@@ -0,0 +1,491 @@
+/*
+ IM address editor widget for KAddressBook
+
+ Copyright (c) 2004 Will Stephenson <lists@stevello.free-online.co.uk>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qlistview.h>
+#include <qstringlist.h>
+#include <qvbox.h>
+#include <qlayout.h>
+#include <qfont.h>
+#include <qpainter.h>
+
+#include <kdialogbase.h>
+#include <kdebug.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kplugininfo.h>
+#include <kpushbutton.h>
+#include <ktrader.h>
+
+#include "imaddresswidget.h"
+#include "imeditorbase.h"
+#include "imeditorwidget.h"
+
+
+IMAddressLVI::IMAddressLVI( KListView *parent, KPluginInfo *protocol,
+ const QString &address, const IMContext &context )
+ : KListViewItem( parent )
+{
+ setProtocol( protocol );
+ setAddress( address );
+ setContext( context );
+ mPreferred = false;
+}
+
+void IMAddressLVI::setPreferred( bool preferred )
+{
+ mPreferred = preferred;
+}
+
+bool IMAddressLVI::preferred() const
+{
+ return mPreferred;
+}
+
+void IMAddressLVI::paintCell( QPainter *p, const QColorGroup &cg,
+ int column, int width, int alignment )
+{
+ if ( mPreferred ) {
+ QFont font = p->font();
+ font.setBold( true );
+ p->setFont( font );
+ }
+
+ KListViewItem::paintCell( p, cg, column, width, alignment );
+}
+
+void IMAddressLVI::setAddress( const QString &address )
+{
+ // irc uses 0xE120 to seperate the nick and the server group.
+ QString serverOrGroup = address.section( QChar( 0xE120 ), 1 );
+
+ if ( serverOrGroup.isEmpty() )
+ setText( 1, address );
+ else {
+ QString nickname = address.section( QChar( 0xE120 ), 0, 0 );
+ setText( 1, i18n( "<nickname> on <server>","%1 on %2" )
+ .arg( nickname ).arg( serverOrGroup ) );
+ }
+
+ mAddress = address;
+}
+
+void IMAddressLVI::setContext( const IMContext &context )
+{
+ mContext = context;
+ // set context
+/* switch ( context )
+ {
+ case Home:
+ setText( 2, i18n( "Home" ) );
+ break;
+ case Work:
+ setText( 2, i18n( "Work" ) );
+ break;
+ case Any:
+ setText( 2, i18n( "Any" ) );
+ break;
+ }
+*/
+}
+
+void IMAddressLVI::setProtocol( KPluginInfo *protocol )
+{
+ mProtocol = protocol;
+
+ setPixmap( 0, SmallIcon( mProtocol->icon() ) );
+ setText( 0, mProtocol->name() );
+}
+
+KPluginInfo * IMAddressLVI::protocol() const
+{
+ return mProtocol;
+}
+
+IMContext IMAddressLVI::context() const
+{
+ return mContext;
+}
+
+QString IMAddressLVI::address() const
+{
+ return mAddress;
+}
+
+void IMAddressLVI::activate()
+{
+ // show editor
+}
+
+/*===========================================================================*/
+
+IMEditorWidget::IMEditorWidget( QWidget *parent, const QString &preferredIM, const char *name )
+ : KDialogBase( parent, name, false, i18n( "Edit Instant Messenging Address" ),
+ Help | Ok | Cancel, Ok, false ),
+ mReadOnly( false )
+{
+ mWidget = new IMEditorBase( this );
+ setMainWidget( mWidget );
+
+ connect( mWidget->btnAdd, SIGNAL( clicked() ), SLOT( slotAdd() ) );
+ connect( mWidget->btnEdit, SIGNAL( clicked() ), SLOT( slotEdit() ) );
+ connect( mWidget->btnDelete, SIGNAL( clicked() ), SLOT( slotDelete() ) );
+ connect( mWidget->btnSetStandard, SIGNAL( clicked()), SLOT( slotSetStandard() ) );
+ connect( mWidget->lvAddresses, SIGNAL( selectionChanged() ), SLOT( slotUpdateButtons() ) );
+
+ connect( mWidget->lvAddresses, SIGNAL( doubleClicked( QListViewItem*, const QPoint&, int ) ),
+ SLOT( slotEdit() ) );
+
+ setHelp( "managing-contacts-im-addresses" );
+
+ mWidget->btnEdit->setEnabled( false );
+ mWidget->btnDelete->setEnabled( false );
+ mWidget->btnSetStandard->setEnabled( false );
+ // Disabled pending implementation
+ //mWidget->btnUp->setEnabled( false );
+ //mWidget->btnDown->setEnabled( false );
+ mPreferred = preferredIM;
+ mPreferred = mPreferred.replace( " on ", QString( QChar( 0xE120 ) ), true );
+ mProtocols = KPluginInfo::fromServices( KTrader::self()->query( QString::fromLatin1( "KABC/IMProtocol" ) ) );
+
+ // order the protocols by putting them in a qmap, then sorting the set of keys and recreating the list
+ QMap<QString, KPluginInfo *> protocolMap;
+ QValueList<KPluginInfo *>::ConstIterator it;
+ QValueList<KPluginInfo *> sorted;
+ for ( it = mProtocols.begin(); it != mProtocols.end(); ++it )
+ protocolMap.insert( (*it)->name(), (*it) );
+
+ QStringList keys = protocolMap.keys();
+ keys.sort();
+ QStringList::ConstIterator keyIt = keys.begin();
+ QStringList::ConstIterator end = keys.end();
+ for ( ; keyIt != end; ++keyIt )
+ sorted.append( protocolMap[*keyIt] );
+ mProtocols = sorted;
+}
+
+QValueList<KPluginInfo *> IMEditorWidget::availableProtocols() const
+{
+ return mProtocols;
+}
+
+void IMEditorWidget::loadContact( KABC::Addressee *addr )
+{
+ if ( mWidget->lvAddresses )
+ mWidget->lvAddresses->clear();
+
+ // see README for details of how Evolution stores IM addresses (differently)
+ const QStringList customs = addr->customs();
+
+ QStringList::ConstIterator it;
+ bool isSet = false;
+ for ( it = customs.begin(); it != customs.end(); ++it ) {
+ QString app, name, value;
+ splitField( *it, app, name, value );
+
+ if ( app.startsWith( QString::fromLatin1( "messaging/" ) ) ) {
+ if ( name == QString::fromLatin1( "All" ) ) {
+ KPluginInfo *protocol = protocolFromString( app );
+ if ( protocol ) {
+ QStringList addresses = QStringList::split( QChar( 0xE000 ), value );
+ QStringList::iterator end = addresses.end();
+ for ( QStringList::ConstIterator it = addresses.begin(); it != end; ++it ) {
+ IMAddressLVI *imaddresslvi = new IMAddressLVI( mWidget->lvAddresses, protocol, *it, Any/*, false*/ );
+ if ( !isSet && (*it).stripWhiteSpace().lower() == mPreferred.stripWhiteSpace().lower() ) {
+ imaddresslvi->setPreferred( true );
+ isSet = true; //Only set one item to be preferred
+ }
+ }
+ } else
+ kdDebug( 5720 ) << k_funcinfo << " no protocol found for: " << app << endl;
+ }
+ }
+ }
+
+ if ( mWidget->lvAddresses->firstChild() )
+ mWidget->lvAddresses->firstChild()->setSelected( true );
+}
+
+void IMEditorWidget::storeContact( KABC::Addressee *addr )
+{
+ // for each changed protocol, write a new custom field containing the current set of
+ // addresses
+ QValueList<KPluginInfo *>::ConstIterator protocolIt;
+ for ( protocolIt = mChangedProtocols.begin(); protocolIt != mChangedProtocols.end(); ++protocolIt ) {
+ QStringList lst;
+ QListViewItemIterator addressIt( mWidget->lvAddresses );
+ while ( addressIt.current() ) {
+ IMAddressLVI* currentAddress = static_cast<IMAddressLVI*>( *addressIt );
+ if ( currentAddress->protocol() == *protocolIt )
+ lst.append( currentAddress->address() );
+ ++addressIt;
+ }
+
+ QString addrBookField = (*protocolIt)->property( "X-KDE-InstantMessagingKABCField" ).toString();
+ if ( !lst.isEmpty() )
+ addr->insertCustom( addrBookField, QString::fromLatin1( "All" ), lst.join( QChar( 0xE000 ) ) );
+ else
+ addr->removeCustom( addrBookField, QString::fromLatin1( "All" ) );
+ }
+}
+
+void IMEditorWidget::setReadOnly( bool readOnly )
+{
+ mReadOnly = readOnly;
+ slotUpdateButtons();
+}
+
+void IMEditorWidget::slotSetStandard()
+{
+ QListViewItemIterator it( mWidget->lvAddresses, QListViewItemIterator::Selected );
+
+ // Just set the first one selected as standard
+ if ( IMAddressLVI *current = static_cast<IMAddressLVI*>( it.current() ) ) {
+ QListViewItemIterator it2( mWidget->lvAddresses );
+ while ( it2.current() ) {
+ IMAddressLVI *item = static_cast<IMAddressLVI*>( it2.current() );
+
+ if ( item->preferred() ) {
+ if ( current == item )
+ return; //Selected is already preferred
+ else {
+ item->setPreferred( false );
+ mWidget->lvAddresses->repaintItem( item );
+ break;
+ }
+ }
+
+ ++it2;
+ }
+
+ mPreferred = current->address();
+ current->setPreferred( true );
+ setModified( true );
+ mWidget->lvAddresses->repaintItem( current );
+ }
+}
+
+void IMEditorWidget::slotUpdateButtons()
+{
+ int num_selected = 0;
+ QListViewItemIterator it( mWidget->lvAddresses, QListViewItemIterator::Selected );
+ while ( it.current() ) {
+ ++num_selected;
+ if ( num_selected > 1 )
+ break; //no need to count above 2.
+
+ ++it;
+ }
+
+ if ( !mReadOnly && num_selected == 1 ) {
+ mWidget->btnAdd->setEnabled( true );
+ mWidget->btnEdit->setEnabled( true );
+ mWidget->btnDelete->setEnabled( true );
+ IMAddressLVI *current = static_cast<IMAddressLVI*>( it.current() );
+
+ // Disable "set standard" if already standard
+ mWidget->btnSetStandard->setEnabled( !current || !current->preferred() );
+ } else if ( !mReadOnly && num_selected > 1 ) {
+ mWidget->btnAdd->setEnabled( true );
+ mWidget->btnEdit->setEnabled( false );
+ mWidget->btnDelete->setEnabled( true );
+ mWidget->btnSetStandard->setEnabled( false );
+ } else {
+ mWidget->btnAdd->setEnabled( !mReadOnly );
+ mWidget->btnSetStandard->setEnabled( false );
+ mWidget->btnEdit->setEnabled( false );
+ mWidget->btnDelete->setEnabled( false );
+ }
+}
+
+void IMEditorWidget::setModified( bool modified )
+{
+ mModified = modified;
+}
+
+bool IMEditorWidget::isModified() const
+{
+ return mModified;
+}
+
+void IMEditorWidget::slotAdd()
+{
+ KDialogBase addDialog( this, "addaddress", true, i18n( "Instant messaging", "Add Address" ),
+ KDialogBase::Ok | KDialogBase::Cancel );
+
+ IMAddressWidget *addressWid = new IMAddressWidget( &addDialog, mProtocols );
+ addDialog.enableButtonOK( false );
+ connect( addressWid, SIGNAL( inValidState( bool ) ),
+ &addDialog, SLOT( enableButtonOK( bool ) ) );
+ addDialog.setMainWidget( addressWid );
+
+ if ( addDialog.exec() == QDialog::Accepted ) {
+ // add the new item
+ IMAddressLVI *imaddresslvi = new IMAddressLVI( mWidget->lvAddresses, addressWid->protocol(),
+ addressWid->address() /*, addressWid->context() */ );
+
+ // If it's a new address, set is as preferred.
+ if ( mPreferred.isEmpty() ) {
+ imaddresslvi->setPreferred( true );
+ mPreferred = addressWid->address();
+ }
+
+ if ( mChangedProtocols.find( addressWid->protocol() ) == mChangedProtocols.end() )
+ mChangedProtocols.append( addressWid->protocol() );
+
+ mWidget->lvAddresses->sort();
+
+ setModified( true );
+ }
+}
+
+void IMEditorWidget::slotEdit()
+{
+ QListViewItemIterator it( mWidget->lvAddresses, QListViewItemIterator::Selected );
+
+ // Just edit the first one selected.
+ if ( IMAddressLVI *current = static_cast<IMAddressLVI*>( it.current() ) ) {
+ KDialogBase editDialog( this, "editaddress", true, i18n( "Instant messaging", "Edit Address" ),
+ KDialogBase::Ok | KDialogBase::Cancel );
+ IMAddressWidget *addressWid = new IMAddressWidget( &editDialog, mProtocols, current->protocol(),
+ current->address(), current->context() ) ;
+ connect( addressWid, SIGNAL( inValidState( bool ) ),
+ &editDialog, SLOT( enableButtonOK( bool ) ) );
+ editDialog.setMainWidget( addressWid );
+
+ if ( editDialog.exec() == QDialog::Accepted ) {
+ bool modified = false;
+ if ( addressWid->address() != current->address() ) {
+ modified = true;
+ current->setAddress( addressWid->address() );
+ }
+ if ( addressWid->context() != current->context() ) {
+ modified = true;
+ current->setContext( addressWid->context() );
+ }
+
+ // the entry for the protocol of the current address has changed
+ if ( mChangedProtocols.find( current->protocol() ) == mChangedProtocols.end() ) {
+ mChangedProtocols.append( current->protocol() );
+ }
+ // update protocol - has another protocol gained an address?
+ if ( current->protocol() != addressWid->protocol() ) {
+ modified = true;
+ // this proto is losing an entry
+ current->setProtocol( addressWid->protocol() );
+ if ( mChangedProtocols.find( current->protocol() ) == mChangedProtocols.end() )
+ mChangedProtocols.append( current->protocol() );
+ }
+
+ if ( modified )
+ setModified(true);
+ }
+ }
+}
+
+void IMEditorWidget::slotDelete()
+{
+ int num_selected = 0;
+
+ {
+ QListViewItemIterator it( mWidget->lvAddresses, QListViewItemIterator::Selected );
+ while ( it.current() ) {
+ num_selected++;
+ ++it;
+ }
+ }
+
+ if ( num_selected == 0 )
+ return;
+
+ if ( KMessageBox::warningContinueCancel( this, i18n( "Do you really want to delete the selected address?",
+ "Do you really want to delete the %n selected addresses?", num_selected ),
+ i18n( "Confirm Delete" ), KStdGuiItem::del() ) != KMessageBox::Continue )
+ return;
+
+ QListViewItemIterator it( mWidget->lvAddresses );
+ bool deletedPreferred = false;
+ while( it.current() ) {
+ if ( it.current()->isSelected() ) {
+ IMAddressLVI * current = static_cast<IMAddressLVI*>( *it );
+ if ( mChangedProtocols.find( current->protocol() ) == mChangedProtocols.end() )
+ mChangedProtocols.append( current->protocol() );
+
+ if ( current->preferred() )
+ deletedPreferred = true;
+
+ delete current;
+ } else
+ ++it;
+ }
+
+ if ( deletedPreferred ) {
+ IMAddressLVI *first = static_cast<IMAddressLVI*>( mWidget->lvAddresses->firstChild() );
+ if ( first ) {
+ first->setPreferred( true );
+ mPreferred = first->address();
+ } else
+ mPreferred = "";
+ }
+
+ setModified( true );
+}
+
+QString IMEditorWidget::preferred() const
+{
+ QString retval( mPreferred );
+ return retval.replace( QChar( 0xE120 ), " on " );
+}
+
+
+KPluginInfo * IMEditorWidget::protocolFromString( const QString &fieldValue ) const
+{
+ QValueList<KPluginInfo *>::ConstIterator it;
+ KPluginInfo * protocol = 0;
+ for ( it = mProtocols.begin(); it != mProtocols.end(); ++it ) {
+ if ( (*it)->property( "X-KDE-InstantMessagingKABCField" ).toString() == fieldValue ) {
+ protocol = *it;
+ break;
+ }
+ }
+
+ return protocol;
+}
+
+void IMEditorWidget::splitField( const QString &str, QString &app, QString &name, QString &value )
+{
+ int colon = str.find( ':' );
+ if ( colon != -1 ) {
+ QString tmp = str.left( colon );
+ value = str.mid( colon + 1 );
+
+ int dash = tmp.find( '-' );
+ if ( dash != -1 ) {
+ app = tmp.left( dash );
+ name = tmp.mid( dash + 1 );
+ }
+ }
+}
+
+#include "imeditorwidget.moc"
diff --git a/kaddressbook/editors/imeditorwidget.h b/kaddressbook/editors/imeditorwidget.h
new file mode 100644
index 00000000..441db257
--- /dev/null
+++ b/kaddressbook/editors/imeditorwidget.h
@@ -0,0 +1,128 @@
+/*
+ IM addresses editor widget for KAddressbook
+
+ Copyright (c) 2004 Will Stephenson <lists@stevello.free-online.co.uk>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef IMEDITORWIDGET_H
+#define IMEDITORWIDGET_H
+
+#include <qvaluelist.h>
+#include <klistview.h>
+#include <kdialogbase.h>
+
+#include "contacteditorwidget.h"
+
+
+class AddressWidget;
+class KPluginInfo;
+class IMEditorBase;
+
+enum IMContext { Any, Home, Work };
+
+/* Note regarding Context:
+ * It wasn not possible to get an idea of Context into Kopete in time for KDE 3.3,
+ * so it has been removed from the UI and functionally disabled in the code.
+ */
+
+/**
+ * The widget we add to KAddressbook's contact editor dialog
+ */
+class IMEditorWidget : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ IMEditorWidget( QWidget *parent, const QString &preferredIM, const char *name = 0 );
+ ~IMEditorWidget() {};
+
+ void loadContact( KABC::Addressee *addr );
+ void storeContact( KABC::Addressee *addr );
+ void setReadOnly( bool readOnly );
+ QValueList<KPluginInfo *> availableProtocols() const;
+ bool isModified() const;
+ QString preferred() const;
+
+ protected slots:
+ void slotUpdateButtons();
+ void slotAdd();
+ void slotEdit();
+ void slotDelete();
+ void slotSetStandard();
+
+ protected:
+ /**
+ * Helper method to split the contents of an addressbook field up
+ */
+ static void splitField( const QString &str, QString &app, QString &name, QString &value );
+
+ /**
+ * Find a protocol that matches the KABC key, or 0 if none found
+ */
+ KPluginInfo * protocolFromString( const QString &fieldValue ) const;
+
+ private:
+ bool mReadOnly;
+ bool mModified;
+ QString mPreferred;
+ IMEditorBase *mWidget;
+ void setModified( bool modified );
+
+ // Used to track changed protocols to reduce KABC writes
+ QValueList<KPluginInfo *> mChangedProtocols;
+ QValueList<KPluginInfo *> mProtocols;
+};
+
+/**
+ * List view item representing a single IM address.
+ */
+
+// VCard has been disabled as there is no standard VCard location to store IM addresses yet.
+class IMAddressLVI : public KListViewItem
+{
+ public:
+ IMAddressLVI( KListView *parent, KPluginInfo * protocol,
+ const QString &address, const IMContext &context = Any );
+
+ void setAddress( const QString &address );
+ void setProtocol( KPluginInfo * protocol );
+ void setContext( const IMContext &context );
+ void activate();
+
+ KPluginInfo * protocol() const;
+ QString address() const;
+ IMContext context() const;
+
+ void setPreferred( bool preferred );
+ bool preferred() const;
+
+ protected:
+ virtual void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
+
+ private:
+ KPluginInfo * mProtocol;
+ bool mPreferred;
+ IMContext mContext;
+ QString mAddress;
+};
+
+#endif
+
diff --git a/kaddressbook/editors/kaddressbookimprotocol.desktop b/kaddressbook/editors/kaddressbookimprotocol.desktop
new file mode 100644
index 00000000..80a6f89a
--- /dev/null
+++ b/kaddressbook/editors/kaddressbookimprotocol.desktop
@@ -0,0 +1,57 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=KABC/IMProtocol
+X-KDE-KAddressBook-CEWVersion=1
+Name=KAddressbook Instant Messaging Protocol
+Name[af]=KAddressbook kits boodskap protokol
+Name[bg]=Протокол за мигновени съобщения за адресника
+Name[bs]=KAddressbook protokol za instant poruke
+Name[ca]=Protocol de missatgeria instantània KAddressbook
+Name[cs]=KAddressbook instant messaging protokol
+Name[da]=KAddressbook kvikbesked-protokol
+Name[de]=Adressbuch Instant Messaging Protokoll
+Name[el]=Πρωτόκολλο στιγμιαίου μηνύματος του KAddressbook
+Name[eo]=KAddressbook Rapidmesaĝila Protokolo
+Name[es]=Protocolo de mensajería instantánea de KAddressbook
+Name[et]=KDE aadressiraamatu kiirsuhtlusprotokoll
+Name[eu]=KAddressbook berehalako mezularitza protokoloa
+Name[fa]=قرارداد پیام‌دهی فوری KAddressbook
+Name[fi]=KAddresbookin pikaviestintäprotokolla
+Name[fr]=Protocole de messagerie instantanée pour KAddressbook
+Name[fy]=KAddressbook Instant Messaging-protokol
+Name[gl]=Protocolo de Mensaxería Instantánea de KAddressbook
+Name[he]=פרוטוקול מסרים מידיים של KAddressbook
+Name[hu]=KAddressbook azonnali üzenetküldési protokoll
+Name[is]=KAddressbook skilaboðaforritið
+Name[it]=KAddressbook protocollo messaggistica istantanea
+Name[ja]=KAddressbook インスタントメッセージプロトコル
+Name[ka]=KDE ოქმი მყისიერი შეტყობინებებისათვისწიგნაკითვის
+Name[kk]=KAddressbook лезде хабарласу протоколы
+Name[km]=ពិធីការ​ផ្ញើសារ​បន្ទាន់​របស់ KAddressbook
+Name[ko]=KAddressbook 인스턴트 메시징 프로토콜
+Name[lt]=KAddressbook momentinių žinučių protokolas
+Name[ms]=Protokol Penghantaran Mesej Segera KAddressbook
+Name[nb]=KAdressbook lynmeldingsprotokoll
+Name[nds]=KAddressbook-Kortnarichten-Protokoll
+Name[ne]=केडीई ठेगानापुस्तिका दृष्टान्त संदेशन प्रोटोकल
+Name[nl]=KAddressbook Instant Messaging-protocol
+Name[nn]=Lynmeldingsprotokoll for KDE-adresseboka
+Name[pl]=Protokół komunikacji internetowej KAddressbook
+Name[pt]=Protocolo de Mensagens Instantâneas do KAdressbook
+Name[pt_BR]=Protocolo de Mensagens Instantâneas do KAddressbook
+Name[ru]=Протокол обмена сообщениями адресной книги KDE
+Name[se]=Šleađgadieđáhusprotokolla KDE-čujuhusgirjji várás
+Name[sk]=Protokol pre KDE Adresár Instant Messaging
+Name[sl]=Protokol takojšnega sporočanja za Adresar
+Name[sr]=KAddressbook протокол тренутних адреса
+Name[sr@Latn]=KAddressbook protokol trenutnih adresa
+Name[sv]=Direktmeddelandeprotokoll för adressboken
+Name[ta]=கேஅட்ரஸ்புக் உடனடி செய்தி பரிமாற்றம்
+Name[tg]=Протоколи мубодилаи иттилооти китоби адресии KDE
+Name[tr]=KAddressbook Hızlı Mesajlaşma Protokolü
+Name[uk]=Протокол миттєвого зв'язку KAddressbook
+Name[zh_CN]=KAddressbook 即时通讯协议
+Name[zh_TW]=KAddressbook 即時通訊協定
+[PropertyDef::X-KDE-InstantMessagingKABCField]
+Type=QString
+
diff --git a/kaddressbook/editors/protocols/Makefile.am b/kaddressbook/editors/protocols/Makefile.am
new file mode 100644
index 00000000..4ec5576b
--- /dev/null
+++ b/kaddressbook/editors/protocols/Makefile.am
@@ -0,0 +1,6 @@
+servicedir = $(kde_servicesdir)/kaddressbook
+service_DATA = icqprotocol.desktop aimprotocol.desktop ircprotocol.desktop \
+ smsprotocol.desktop gaduprotocol.desktop \
+ jabberprotocol.desktop yahooprotocol.desktop \
+ msnprotocol.desktop groupwiseprotocol.desktop \
+ meanwhileprotocol.desktop skypeprotocol.desktop
diff --git a/kaddressbook/editors/protocols/aimprotocol.desktop b/kaddressbook/editors/protocols/aimprotocol.desktop
new file mode 100644
index 00000000..e17be1f6
--- /dev/null
+++ b/kaddressbook/editors/protocols/aimprotocol.desktop
@@ -0,0 +1,63 @@
+[Desktop Entry]
+Type=Service
+Icon=aim_protocol
+ServiceTypes=KABC/IMProtocol,KPluginInfo
+X-KDE-InstantMessagingKABCField=messaging/aim
+Comment=AIM Protocol
+Comment[ar]=ميفاق AIM
+Comment[be]=Пратакол AIM
+Comment[bg]=Протокол AIM
+Comment[br]=Komenad AIM
+Comment[bs]=AIM protokol
+Comment[ca]=Protocol AIM
+Comment[cs]=AIM protokol
+Comment[da]=AIM Protokol
+Comment[de]=AIM-Protokoll
+Comment[el]=Πρωτόκολλο AIM
+Comment[eo]=AIM-Protokolo
+Comment[es]=Protocolo AIM
+Comment[et]=AIM protokoll
+Comment[eu]=AIM protokoloa
+Comment[fa]=قرارداد AIM
+Comment[fi]=AIM-protokolla
+Comment[fr]=Protocole AIM
+Comment[fy]=AIM-protokol
+Comment[ga]=Prótacal AIM
+Comment[gl]=Protocolo AIM
+Comment[he]=פרוטוקול AIM
+Comment[hu]=AIM protokoll
+Comment[is]=AIM samskiptamátinn
+Comment[it]=Protocollo AIM
+Comment[ja]=AIM プロトコル
+Comment[ka]=AIM ოქმი
+Comment[kk]=AIM протоколы
+Comment[km]=ពិធីការ AIM
+Comment[ko]=AIM 프로토콜
+Comment[lt]=AIM protokolas
+Comment[mk]=AIM-протокол
+Comment[ms]=Protokol AIM
+Comment[nb]=AIM-protokoll
+Comment[nds]=AIM-Protokoll
+Comment[ne]=एआईएम प्रोटोकल
+Comment[nl]=AIM-protocol
+Comment[nn]=AIM-protokoll
+Comment[pa]=AIM ਪ੍ਰੋਟੋਕਾਲ
+Comment[pl]=Protokół AIM
+Comment[pt]=Protocolo AIM
+Comment[pt_BR]=Protocolo AIM
+Comment[ru]=Протокол AIM
+Comment[se]=AIM-protokolla
+Comment[sk]=Protokol AIM
+Comment[sl]=Protokol AIM
+Comment[sr]=AIM протокол
+Comment[sr@Latn]=AIM protokol
+Comment[sv]=AIM-protokoll
+Comment[ta]=AIM நெறிமுறை
+Comment[tg]=Протоколи AIM
+Comment[tr]=AIM Protokolü
+Comment[uk]=Протокол AIM
+Comment[zh_CN]=AIM 协议
+Comment[zh_TW]=AIM 協定
+Name=AIM
+Name[ne]=एआईएम
+
diff --git a/kaddressbook/editors/protocols/gaduprotocol.desktop b/kaddressbook/editors/protocols/gaduprotocol.desktop
new file mode 100644
index 00000000..96ee6e9e
--- /dev/null
+++ b/kaddressbook/editors/protocols/gaduprotocol.desktop
@@ -0,0 +1,63 @@
+[Desktop Entry]
+Type=Service
+Icon=gadu_protocol
+ServiceTypes=KABC/IMProtocol,KPluginInfo
+X-KDE-InstantMessagingKABCField=messaging/gadu
+Comment=Gadu-Gadu Protocol
+Comment[af]=Gadu-Gadu protokol
+Comment[ar]=ميفاق Gadu-Gadu
+Comment[be]=Пратакол Gadu-Gadu
+Comment[bg]=Протокол Gadu-Gadu
+Comment[br]=Komenad Gadu-Gadu
+Comment[bs]=Gadu-Gadu protokol
+Comment[ca]=Protocol Gadu-Gadu
+Comment[cs]=Gadu-Gadu protokol
+Comment[da]=Gadu-Gadu Protokol
+Comment[de]=Gadu-Gadu-Protokoll
+Comment[el]=Πρωτόκολλο Gadu-Gadu
+Comment[eo]=Gadu-Gadu Protokolo
+Comment[es]=Protocolo Gadu-Gadu
+Comment[et]=Gadu-Gadu protokoll
+Comment[eu]=Gadu-Gadu protokoloa
+Comment[fa]=قرارداد Gadu-Gadu
+Comment[fi]=Gadu-Gadu -protokolla
+Comment[fr]=Protocole Gadu-Gadu
+Comment[fy]=Gadu-Gadu-protokol
+Comment[ga]=Prótacal Gadu-Gadu
+Comment[gl]=Protocolo Gadu-Gadu
+Comment[he]=פרוטוקול Gadu-Gadu
+Comment[hu]=Gadu-Gadu protokoll
+Comment[is]=Gadu-Gadu samskiptamátinn
+Comment[it]=Protocollo Gadu-Gadu
+Comment[ja]=Gadu-Gadu プロトコル
+Comment[ka]=Gadu-Gadu ოქმი
+Comment[kk]=Gadu-Gadu протоколы
+Comment[km]=ពិធីការ Gadu-Gadu
+Comment[lt]=Gadu-Gadu protokolas
+Comment[mk]=Gadu-Gadu-протокол
+Comment[ms]=Protokol Gadu-Gadu
+Comment[nb]=Gadu-Gadu-protokoll
+Comment[nds]=Gadu-Gadu-Protokoll
+Comment[ne]=गाडु-गाडु प्रोटोकल
+Comment[nl]=Gadu-Gadu-protocol
+Comment[nn]=Gadu-Gadu-protokoll
+Comment[pl]=Protokół Gadu-Gadu
+Comment[pt]=Protocolo Gadu-Gadu
+Comment[pt_BR]=Protocolo Gadu-Gadu
+Comment[ru]=протокол Gadu-Gadu
+Comment[se]=Gadu-Gadu-protokolla
+Comment[sk]=Protokol Gadu-Gadu
+Comment[sl]=Protokol Gadu-Gadu
+Comment[sr]=Gadu-Gadu протокол
+Comment[sr@Latn]=Gadu-Gadu protokol
+Comment[sv]=Gadu-Gadu-protokoll
+Comment[ta]=கடு-கடு நெறிமுறை
+Comment[tg]=протоколи Gadu-Gadu
+Comment[tr]=Gadu-Gadu Protokolü
+Comment[uk]=Протокол Gadu-Gadu
+Comment[zh_CN]=Gadu-Gadu 协议
+Comment[zh_TW]=Gadu-Gadu 協定
+Name=Gadu-Gadu
+Name[ne]=गाडु-गाडु
+Name[ta]=கடு-கடு
+
diff --git a/kaddressbook/editors/protocols/groupwiseprotocol.desktop b/kaddressbook/editors/protocols/groupwiseprotocol.desktop
new file mode 100644
index 00000000..0ee40fd2
--- /dev/null
+++ b/kaddressbook/editors/protocols/groupwiseprotocol.desktop
@@ -0,0 +1,44 @@
+[Desktop Entry]
+Type=Service
+Icon=groupwise_protocol
+ServiceTypes=KABC/IMProtocol,KPluginInfo
+X-KDE-InstantMessagingKABCField=messaging/groupwise
+Comment=Novell GroupWise Messenger
+Comment[af]=Novell GroupWise boodskappe
+Comment[bg]=Месинджър Novell GroupWise
+Comment[cs]=Novell GroupWise komunikátor
+Comment[el]=GroupWise Messenger της Novell
+Comment[eo]=Novell GroupWise Mesaĝilo
+Comment[es]=Servidor de mensajería de Novell GroupWise
+Comment[et]=Novelli GroupWise Messenger
+Comment[eu]=Novell GroupWise mezularia
+Comment[fa]=مدیر Novell GroupWise
+Comment[fr]=Messagerie GroupWise de Novell
+Comment[fy]=Novell GroupWise-messenger
+Comment[he]=מסנג'ר של Novell GroupWise
+Comment[is]=Novell GroupWise Samskiptatólið
+Comment[ja]=Novell GroupWise メッセンジャー
+Comment[ka]= Novell GroupWise მყისიერი შეტყობინებების მაცნე
+Comment[kk]=Novell GroupWise хабарласу
+Comment[km]=កម្មវិធី​ផ្ញើ​សារ​របស់​ណូវែល - GroupWise
+Comment[lt]=Novell GroupWise momentinių žinučių klientas
+Comment[ms]=Pembawa mesej Novell GroupWise
+Comment[nds]=Novell-GroupWise-Kortnarichtenmaker
+Comment[ne]=नोभेल समूहगत म्यासेन्जर
+Comment[nl]=Novell GroupWise-messenger
+Comment[pl]=Komunikator Novell GroupWise
+Comment[pt_BR]=Mensageiro GroupWise da Novell
+Comment[ru]=Обмен сообщениями Novell GroupWise
+Comment[sr]=Novell-ов GroupWise Messenger
+Comment[sr@Latn]=Novell-ov GroupWise Messenger
+Comment[sv]=Novell Groupwise Messenger
+Comment[ta]=நோவல் குழுவாரியான செய்தியாளன்
+Comment[tr]=Novell GroupWise Mesajlaşma Uygulaması
+Comment[zh_CN]=Novell GroupWise 信使
+Name=GroupWise
+Name[ne]=समूहगत
+Name[sr]=Groupware
+Name[sr@Latn]=Groupware
+Name[sv]=Groupwise
+Name[ta]=குழுவாரியாக
+
diff --git a/kaddressbook/editors/protocols/icqprotocol.desktop b/kaddressbook/editors/protocols/icqprotocol.desktop
new file mode 100644
index 00000000..e071238e
--- /dev/null
+++ b/kaddressbook/editors/protocols/icqprotocol.desktop
@@ -0,0 +1,61 @@
+[Desktop Entry]
+Type=Service
+Icon=icq_protocol
+ServiceTypes=KABC/IMProtocol,KPluginInfo
+X-KDE-InstantMessagingKABCField=messaging/icq
+Comment=ICQ Protocol
+Comment[af]=ICQ protokol
+Comment[be]=Пратакол ICQ
+Comment[bg]=Протокол ICQ
+Comment[br]=Komenad ICQ
+Comment[bs]=ICQ protokol
+Comment[ca]=Protocol ICQ
+Comment[cs]=ICQ protokol
+Comment[da]=ICQ Protokol
+Comment[de]=ICQ-Protokoll
+Comment[el]=Πρωτόκολλο ICQ
+Comment[eo]=ICQ Protokolo
+Comment[es]=Protocolo ICQ
+Comment[et]=ICQ protokoll
+Comment[eu]=ICQ protokoloa
+Comment[fa]=قرارداد ICQ
+Comment[fi]=ICQ-protokolla
+Comment[fr]=Protocole ICQ
+Comment[fy]=ICQ-protokol
+Comment[ga]=Prótacal ICQ
+Comment[gl]=Protocolo ICQ
+Comment[he]=פרוטוקול ICQ
+Comment[hu]=ICQ protokoll
+Comment[is]=ICQ samskiptamátinn
+Comment[it]=Protocollo ICQ
+Comment[ja]=ICQ プロトコル
+Comment[ka]=ICQ ოქმი
+Comment[kk]=ICQ протоколы
+Comment[km]=ពិធីការ ICQ
+Comment[lt]=ICQ protokolas
+Comment[mk]=ICQ-протокол
+Comment[ms]=Protokol ICQ
+Comment[nb]=ICQ-protokoll
+Comment[nds]=ICQ-Protokoll
+Comment[ne]=आईसीक्यू प्रोटोकल
+Comment[nl]=ICQ-protocol
+Comment[nn]=ICQ-protokoll
+Comment[pl]=Protokół ICQ
+Comment[pt]=Protocolo ICQ
+Comment[pt_BR]=Protocolo ICQ
+Comment[ru]=Протокол ICQ
+Comment[se]=ICQ-protokolla
+Comment[sk]=Protokol ICQ
+Comment[sl]=Protokol ICQ
+Comment[sr]=ICQ протокол
+Comment[sr@Latn]=ICQ protokol
+Comment[sv]=ICQ-protokoll
+Comment[ta]=ICQ நெறிமுறை
+Comment[tg]=Протоколи ICQ
+Comment[tr]=ICQ Protokolü
+Comment[uk]=Протокол ICQ
+Comment[zh_CN]=ICQ 协议
+Comment[zh_TW]=ICQ 協定
+Name=ICQ
+Name[ne]=आईसीक्यू
+
diff --git a/kaddressbook/editors/protocols/ircprotocol.desktop b/kaddressbook/editors/protocols/ircprotocol.desktop
new file mode 100644
index 00000000..78f19447
--- /dev/null
+++ b/kaddressbook/editors/protocols/ircprotocol.desktop
@@ -0,0 +1,31 @@
+[Desktop Entry]
+Type=Service
+Icon=irc_protocol
+ServiceTypes=KABC/IMProtocol,KPluginInfo
+X-KDE-InstantMessagingKABCField=messaging/irc
+Comment=Internet Relay Chat
+Comment[bg]=Протокол IRC
+Comment[fa]=گپ بازپخش اینترنت
+Comment[hu]=IRC (Internet Relay Chat)
+Comment[is]=Internet spjall
+Comment[ja]=インターネットリレーチャット
+Comment[ka]=IRC
+Comment[kk]=Internet Relay Chat хабарласу
+Comment[km]=ជជែក​កំសាន្ត​តាមអ៊ីនធឺណិត
+Comment[lt]=Estafetinis Interneto pokalbis
+Comment[ne]=इन्टरनेटबाट प्रसारण कुराकानी
+Comment[pl]=IRC (Internet Relay Chat)
+Comment[pt_BR]=Protocolo de Bate-papo na Internet - IRC
+Comment[ru]=IRC
+Comment[sl]=Internet Relay Chat (»internetno prenešen klepet«)
+Comment[sr]=Ћаскање преко интернета
+Comment[sr@Latn]=Ćaskanje preko interneta
+Comment[ta]=இணைய வழங்கும் அறட்டை
+Comment[tg]=IRC (Internet Relay Chat)
+Comment[tr]=İnternet Genel Sohbeti
+Comment[uk]=IRChat
+Comment[zh_CN]=Internet 聊天
+Comment[zh_TW]=IRC
+Name=IRC
+Name[ne]=आईआरसी
+
diff --git a/kaddressbook/editors/protocols/jabberprotocol.desktop b/kaddressbook/editors/protocols/jabberprotocol.desktop
new file mode 100644
index 00000000..94b7271b
--- /dev/null
+++ b/kaddressbook/editors/protocols/jabberprotocol.desktop
@@ -0,0 +1,63 @@
+[Desktop Entry]
+Type=Service
+Icon=jabber_protocol
+ServiceTypes=KABC/IMProtocol,KPluginInfo
+X-KDE-InstantMessagingKABCField=messaging/xmpp
+Comment=Jabber Protocol
+Comment[af]=Jabber protokol
+Comment[ar]=ميفاق Jabber
+Comment[be]=Пратакол Jabber
+Comment[bg]=Протокол Jabber
+Comment[br]=Komenad Jabber
+Comment[bs]=Jabber protokol
+Comment[ca]=Protocol Jabber
+Comment[cs]=Jabber protokol
+Comment[da]=Jabber Protokol
+Comment[de]=Jabber-Protokoll
+Comment[el]=Πρωτόκολλο Jabber
+Comment[eo]=Jabber Protokolo
+Comment[es]=Protocolo Jabber
+Comment[et]=Jabberi protokoll
+Comment[eu]=Jabber protokoloa
+Comment[fa]=قرارداد Jabber
+Comment[fi]=Jabber-protokolla
+Comment[fr]=Protocole Jabber
+Comment[fy]=Jabber-protokol
+Comment[ga]=Prótacal Jabber
+Comment[gl]=Protocolo Jabber
+Comment[he]=פרוטוקול Jabber
+Comment[hu]=Jabber protokoll
+Comment[is]=Jabber samskiptamátinn
+Comment[it]=Protocollo Jabber
+Comment[ja]=Jabber プロトコル
+Comment[ka]=Jabber ოქმი
+Comment[kk]=Jabber протоколы
+Comment[km]=ពិធីការ Jabber
+Comment[lt]=Jabber protokolas
+Comment[mk]=Jabber-протокол
+Comment[ms]=Protokol Jabber
+Comment[nb]=Jabber-protokoll
+Comment[nds]=Jabber-Protokoll
+Comment[ne]=ज्याबर प्रोटोकल
+Comment[nl]=Jabber-protocol
+Comment[nn]=Jabber-protokoll
+Comment[pl]=Protokół Jabber
+Comment[pt]=Protocolo Jabber
+Comment[pt_BR]=Protocolo Jabber
+Comment[ru]=протокол Jabber
+Comment[se]=Jabber-protokolla
+Comment[sk]=Protokol Jabber
+Comment[sl]=Protokol Jabber
+Comment[sr]=Jabber протокол
+Comment[sr@Latn]=Jabber protokol
+Comment[sv]=Jabber-protokoll
+Comment[ta]=ஜாபர் நெறிமுறை
+Comment[tg]=протоколи Jabber
+Comment[tr]=Jabber Protokolü
+Comment[uk]=Протокол Jabber
+Comment[zh_CN]=Jabber 协议
+Comment[zh_TW]=Jabber 協定
+Name=Jabber
+Name[ne]=ज्याबर
+Name[ta]=ஜாபர்
+
diff --git a/kaddressbook/editors/protocols/meanwhileprotocol.desktop b/kaddressbook/editors/protocols/meanwhileprotocol.desktop
new file mode 100644
index 00000000..7442cd04
--- /dev/null
+++ b/kaddressbook/editors/protocols/meanwhileprotocol.desktop
@@ -0,0 +1,61 @@
+[Desktop Entry]
+Type=Service
+Icon=meanwhile_protocol
+ServiceTypes=KABC/IMProtocol,KPluginInfo
+X-KDE-InstantMessagingKABCField=messaging/meanwhile
+Comment=Meanwhile Protocol
+Comment[af]=Meanwhile protokol
+Comment[ar]=ميفاق Meanwhile
+Comment[be]=Пратакол Meanwhile
+Comment[bg]=Протокол Meanwhile
+Comment[br]=Komenad Meanwhile
+Comment[ca]=Protocol Meanwhile
+Comment[cs]=Meanwhile protokol
+Comment[da]=Meanwhile Protokol
+Comment[de]=Meanwhile-Protokoll
+Comment[el]=Πρωτόκολλο Meanwhile
+Comment[eo]=Meanwhile Protokolo
+Comment[es]=Protocolo Meanwhile
+Comment[et]=Meanwhile'i protokoll
+Comment[eu]=Meanwhile protokoloa
+Comment[fa]=قرارداد در ضمن
+Comment[fi]=Meanwhile-protokolla
+Comment[fr]=Protocole Meanwhile
+Comment[fy]=Meanwhile-protokol
+Comment[ga]=Prótacal Meanwhile
+Comment[gl]=Protocolo Meanwhile
+Comment[he]=פרוטוקול Meanhwile
+Comment[hu]=Meanwhile protokoll
+Comment[is]=Meanwhile samskiptamátinn
+Comment[it]=Protocollo Meanwhile
+Comment[ja]=Meanwhile プロトコル
+Comment[ka]=Meanwhile ოქმი
+Comment[kk]=Meanwhile протоколы
+Comment[km]=ពិធីការ Meanwhile
+Comment[lt]=Meanwhile protokolas
+Comment[mk]=Meanwhile-протокол
+Comment[ms]=Protokol Meanwhile
+Comment[nb]=Meanwhile-protokoll
+Comment[nds]=Meanwhile-Protokoll
+Comment[ne]=त्यसै समयको प्रोटोकल
+Comment[nl]=Meanwhile-protocol
+Comment[nn]=Meanwhile-protokollen
+Comment[pl]=Protokół Meanwhile
+Comment[pt]=Protocolo Meanwhile
+Comment[pt_BR]=Protocolo Meanwhile
+Comment[ru]=Протокол Meanwhile
+Comment[se]=Meanwhile-protokolla
+Comment[sk]=Meanwhile protokol
+Comment[sl]=Protokol Meanwhile
+Comment[sr]=Meanwhile протокол
+Comment[sr@Latn]=Meanwhile protokol
+Comment[sv]=Meanwhile-protokoll
+Comment[ta]=நெறிமுறை
+Comment[tr]=Meanwhile Protokolü
+Comment[uk]=Протокол Meanwhile
+Comment[zh_CN]=Meanwhile 协议
+Comment[zh_TW]=Meanwhile 協定
+Name=Meanwhile
+Name[fa]=در ضمن
+Name[ne]=त्यस समयको
+
diff --git a/kaddressbook/editors/protocols/msnprotocol.desktop b/kaddressbook/editors/protocols/msnprotocol.desktop
new file mode 100644
index 00000000..58504fd7
--- /dev/null
+++ b/kaddressbook/editors/protocols/msnprotocol.desktop
@@ -0,0 +1,34 @@
+[Desktop Entry]
+Type=Service
+Icon=msn_protocol
+ServiceTypes=KABC/IMProtocol,KPluginInfo
+X-KDE-InstantMessagingKABCField=messaging/msn
+Comment=MSN Messenger
+Comment[af]=MSN boodskapper
+Comment[bg]=Протокол MSN
+Comment[cy]=Negesydd MSN
+Comment[eo]=MSN Mesaĝilo
+Comment[fa]=پیام‌رسان MSN
+Comment[fr]=Messagerie MSN
+Comment[is]=MSN spjallforritið
+Comment[ja]=MSN メッセンジャー
+Comment[ka]=MSN შიკრიკი
+Comment[km]=កម្មវិធី​ផ្ញើ​សារ MSN
+Comment[nds]=MSN-Kortnarichtenmaker
+Comment[ne]=एमएसएन म्यासेन्जर
+Comment[pa]=MSN ਸੁਨੇਹਾਦਾਰ
+Comment[ta]=MSN மெசஞ்சர்
+Comment[tr]=MSN Mesajcısı
+Name=MSN Messenger
+Name[bg]=MSN
+Name[cy]=Negesydd MSN
+Name[eo]=MSN Mesaĝilo
+Name[fa]=پیام‌رسان MSN
+Name[ja]=MSN メッセンジャー
+Name[ka]=MSN შიკრიკი
+Name[km]=កម្មវិធី​ផ្ញើសារ MSN
+Name[nds]=MSN-Kortnarichtenmaker
+Name[ne]=एमएसएन म्यासेन्जर
+Name[ta]=MSN மெசஞ்சர்
+Name[tr]=MSN Mesajcısı
+
diff --git a/kaddressbook/editors/protocols/skypeprotocol.desktop b/kaddressbook/editors/protocols/skypeprotocol.desktop
new file mode 100644
index 00000000..60ac3406
--- /dev/null
+++ b/kaddressbook/editors/protocols/skypeprotocol.desktop
@@ -0,0 +1,53 @@
+[Desktop Entry]
+Type=Service
+Icon=skype_protocol
+ServiceTypes=KABC/IMProtocol,KPluginInfo
+X-KDE-InstantMessagingKABCField=messaging/skype
+Comment=Skype Internet Telephony
+Comment[af]=Skype Internet Telefoon
+Comment[bg]=Интернет телефония чрез Skype
+Comment[ca]=Telefonia per Internet Skype
+Comment[cs]=Internetová telefonie Skype
+Comment[da]=Skype internettelefoni
+Comment[de]=Internet-Telefonie mit Skype
+Comment[eo]=Skype Interreta Telefonado
+Comment[es]=Telefonía por internet con Skype
+Comment[et]=Internetitelefon Skype
+Comment[eu]=Skype-en internet telefonia
+Comment[fa]=ارتباط تلفنی اینترنت Skype
+Comment[fi]=Skype Internet-puhelin
+Comment[fr]=Téléphonie Internet Skype
+Comment[fy]=Skype ynternettelefony
+Comment[gl]=Telefonía por Internet con Skype
+Comment[he]=טלפוניית רשת של Skype
+Comment[hu]=Skype internetes telefon
+Comment[is]=Skype Internet sími
+Comment[it]=Telefonia internet Skype
+Comment[ja]=Skype インターネット電話
+Comment[ka]=Skype ინტერნეტ ტელეფონი
+Comment[kk]=Skype Интернет телефониясы
+Comment[km]=ទូរស័ព្ទ​តាម​អ៊ីនធឺណិត​ដោយ​ប្រើ Skype
+Comment[lt]=Skype Interneto telefonija
+Comment[mk]=Интернет-телефонија со Skype
+Comment[nb]=Skype IP-telefoni
+Comment[nds]=Internet-Telefoneren mit Skype
+Comment[ne]=स्काइप इन्टरनेट दूरभाषी
+Comment[nl]=Skype internettelefonie
+Comment[nn]=Skype Internett-telefoni
+Comment[pl]=Skype - telefonia internetowa
+Comment[pt]=Telefonia Internet Skype
+Comment[pt_BR]=Telefonia via Internet Skype
+Comment[ru]=Интернет-телефон Skype
+Comment[se]=Skype Interneahtta-telefoniija
+Comment[sk]=Skype Internet telefonovanie
+Comment[sl]=Internetno telefoniranje Skype
+Comment[sr]=Skype интернет телефонија
+Comment[sr@Latn]=Skype internet telefonija
+Comment[sv]=Skype Internettelefoni
+Comment[tr]=Skype İnternet Telefonu
+Comment[uk]=Інтернет-телефон Skype
+Comment[zh_CN]=Skype Internet 电话
+Comment[zh_TW]=Skype 網路電話
+Name=Skype
+Name[eo]=kype
+Name[ne]=स्काइप
diff --git a/kaddressbook/editors/protocols/smsprotocol.desktop b/kaddressbook/editors/protocols/smsprotocol.desktop
new file mode 100644
index 00000000..30b50a1e
--- /dev/null
+++ b/kaddressbook/editors/protocols/smsprotocol.desktop
@@ -0,0 +1,64 @@
+[Desktop Entry]
+Type=Service
+Icon=sms_protocol
+ServiceTypes=KABC/IMProtocol,KPluginInfo
+X-KDE-InstantMessagingKABCField=messaging/sms
+Comment=SMS Protocol
+Comment[af]=SMS protokol
+Comment[be]=Пратакол SMS
+Comment[bg]=Протокол SMS
+Comment[br]=Komenad SMS
+Comment[bs]=SMS poruke
+Comment[ca]=Protocol SMS
+Comment[cs]=SMS protokol
+Comment[da]=SMS Protokol
+Comment[de]=SMS-Protokoll
+Comment[el]=Πρωτόκολλο SMS
+Comment[eo]=SMS Protokolo
+Comment[es]=Protocolo SMS
+Comment[et]=SMS protokoll
+Comment[eu]=SMS protokoloa
+Comment[fa]=قرارداد پیام کوتاه
+Comment[fi]=SMS-protokolla
+Comment[fr]=Protocole SMS
+Comment[fy]=SMS-protokol
+Comment[ga]=Prótacal SMS
+Comment[gl]=Protocolo SMS
+Comment[he]=פרוטוקול SMS
+Comment[hu]=SMS protokoll
+Comment[is]=SMS samskiptamátinn
+Comment[it]=Protocollo SMS
+Comment[ja]=SMS プロトコル
+Comment[ka]= SMS ოქმი
+Comment[kk]=SMS протоколы
+Comment[km]=ពិធីការ​សេវា​សារ​ខ្លីៗ
+Comment[lt]=SMS protokolas
+Comment[mk]=SMS-протокол
+Comment[ms]=Protokol SMS
+Comment[nb]=SMS Protokoll
+Comment[nds]=SMS-Protokoll
+Comment[ne]=एसएमएस प्रोटोकल
+Comment[nl]=SMS-protocol
+Comment[nn]=SMS-protokoll
+Comment[pl]=Protokół SMS
+Comment[pt]=Protocolo SMS
+Comment[pt_BR]=Protocolo SMS
+Comment[ru]=протокол SMS
+Comment[se]=SMS-protokolla
+Comment[sk]=Protokol SMS
+Comment[sl]=Protokol SMS
+Comment[sr]=SMS протокол
+Comment[sr@Latn]=SMS protokol
+Comment[sv]=SMS-protokoll
+Comment[ta]=SMS நெறிமுறை
+Comment[tg]=протоколи SMS
+Comment[tr]=SMS Protokolü
+Comment[uk]=Протокол SMS
+Comment[zh_CN]=短信息协议
+Comment[zh_TW]=SMS 協定
+Name=SMS
+Name[fa]=پیام کوتاه
+Name[km]=សេវា​សារ​ខ្លីៗ
+Name[ne]=एसएमएस
+Name[zh_CN]=短信息
+
diff --git a/kaddressbook/editors/protocols/yahooprotocol.desktop b/kaddressbook/editors/protocols/yahooprotocol.desktop
new file mode 100644
index 00000000..c3055472
--- /dev/null
+++ b/kaddressbook/editors/protocols/yahooprotocol.desktop
@@ -0,0 +1,66 @@
+[Desktop Entry]
+Type=Service
+Icon=yahoo_protocol
+ServiceTypes=KABC/IMProtocol,KPluginInfo
+X-KDE-InstantMessagingKABCField=messaging/yahoo
+Comment=Yahoo Protocol
+Comment[af]=Yahoo protokol
+Comment[ar]=ميفاق Yahoo
+Comment[be]=Пратакол Yahoo
+Comment[bg]=Протокол Yahoo
+Comment[br]=Komenad Yahoo
+Comment[bs]=Yahoo protokol
+Comment[ca]=Protocol Yahoo
+Comment[cs]=Yahoo protokol
+Comment[da]=Yahoo Protokol
+Comment[de]=Yahoo!-Protokoll
+Comment[el]=Πρωτόκολλο Yahoo
+Comment[eo]=Yahoo Protokolo
+Comment[es]=Protocolo Yahoo
+Comment[et]=Yahoo protokoll
+Comment[eu]=Yahoo protokoloa
+Comment[fa]=قرارداد یاهو
+Comment[fi]=Yahoo-protokolla
+Comment[fr]=Protocole Yahoo
+Comment[fy]=Yahoo-protokol
+Comment[ga]=Prótacal Yahoo
+Comment[gl]=Protocolo Yahoo
+Comment[he]=פרוטוקול Yahoo
+Comment[hu]=Yahoo protokoll
+Comment[is]=Yahoo samskiptamátinn
+Comment[it]=Protocollo Yahoo
+Comment[ja]=Yahoo プロトコル
+Comment[ka]=Yahoo ოქმი
+Comment[kk]=Yahoo протоколы
+Comment[km]=ពិធីការ​យ៉ាហ៊ូ
+Comment[lt]=Yahoo protokolas
+Comment[mk]=Yahoo-протокол
+Comment[ms]=Protokol Yahoo
+Comment[nb]=Yahoo-protokoll
+Comment[nds]=Yahoo-Protokoll
+Comment[ne]=याहू प्रोटोकल
+Comment[nl]=Yahoo-protocol
+Comment[nn]=Yahoo-protokoll
+Comment[pl]=Protokół Yahoo
+Comment[pt]=Protocolo Yahoo
+Comment[pt_BR]=Protocolo Yahoo
+Comment[ru]=Протокол Yahoo
+Comment[se]=Yahoo-protokolla
+Comment[sk]=Protokol Yahoo
+Comment[sl]=Protokol Yahoo
+Comment[sr]=Yahoo протокол
+Comment[sr@Latn]=Yahoo protokol
+Comment[sv]=Yahoo-protokoll
+Comment[ta]=Yahoo நெறிமுறை
+Comment[tg]=Протоколи Yahoo
+Comment[tr]=Yahoo Protokolü
+Comment[uk]=Протокол Yahoo
+Comment[zh_CN]=Yahoo 协议
+Comment[zh_TW]=Yahoo 協定
+Name=Yahoo
+Name[de]=Yahoo!
+Name[fa]=یاهو
+Name[km]=យ៉ាហ៊ូ
+Name[ne]=याहू
+Name[pa]=ਯਾਹੂ
+
diff --git a/kaddressbook/emaileditwidget.cpp b/kaddressbook/emaileditwidget.cpp
new file mode 100644
index 00000000..8fc857f7
--- /dev/null
+++ b/kaddressbook/emaileditwidget.cpp
@@ -0,0 +1,352 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qpushbutton.h>
+#include <qvalidator.h>
+#include <qstring.h>
+#include <qtoolbutton.h>
+#include <qtooltip.h>
+
+#include <kaccelmanager.h>
+#include <kconfig.h>
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <kinputdialog.h>
+#include <klineedit.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "emaileditwidget.h"
+
+class EmailValidator : public QRegExpValidator
+{
+ public:
+ EmailValidator()
+ : QRegExpValidator( 0, "EmailValidator" )
+ {
+ QRegExp rx( ".*@.*\\.[A-Za-z]+" );
+ setRegExp( rx );
+ }
+};
+
+class EmailItem : public QListBoxText
+{
+ public:
+ EmailItem( QListBox *parent, const QString &text, bool preferred )
+ : QListBoxText( parent, text ), mPreferred( preferred )
+ {}
+
+ void setPreferred( bool preferred ) { mPreferred = preferred; }
+ bool preferred() const { return mPreferred; }
+
+ void setText( const QString &text )
+ {
+ QListBoxText::setText( text );
+ }
+
+ protected:
+ virtual void paint( QPainter *p )
+ {
+ if ( mPreferred ) {
+ QFont font = p->font();
+ font.setBold( true );
+ p->setFont( font );
+ }
+
+ QListBoxText::paint( p );
+ }
+
+ private:
+ bool mPreferred;
+};
+
+EmailEditWidget::EmailEditWidget( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+ QGridLayout *topLayout = new QGridLayout( this, 2, 2, KDialog::marginHint(),
+ KDialog::spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "Email:" ), this );
+ topLayout->addWidget( label, 0, 0 );
+
+ mEmailEdit = new KLineEdit( this );
+ mEmailEdit->setValidator( new EmailValidator );
+ connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ),
+ SIGNAL( modified() ) );
+ label->setBuddy( mEmailEdit );
+ topLayout->addWidget( mEmailEdit, 0, 1 );
+
+ mEditButton = new QPushButton( i18n( "Edit Email Addresses..." ), this);
+ connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) );
+ topLayout->addMultiCellWidget( mEditButton, 1, 1, 0, 1 );
+
+ topLayout->activate();
+}
+
+EmailEditWidget::~EmailEditWidget()
+{
+}
+
+void EmailEditWidget::setReadOnly( bool readOnly )
+{
+ mEmailEdit->setReadOnly( readOnly );
+ mEditButton->setEnabled( !readOnly );
+}
+
+void EmailEditWidget::setEmails( const QStringList &list )
+{
+ mEmailList = list;
+
+ bool blocked = mEmailEdit->signalsBlocked();
+ mEmailEdit->blockSignals( true );
+ if ( list.count() > 0 )
+ mEmailEdit->setText( list[ 0 ] );
+ else
+ mEmailEdit->setText( "" );
+ mEmailEdit->blockSignals( blocked );
+}
+
+QStringList EmailEditWidget::emails()
+{
+ if ( mEmailEdit->text().isEmpty() ) {
+ if ( mEmailList.count() > 0 )
+ mEmailList.remove( mEmailList.begin() );
+ } else {
+ if ( mEmailList.count() > 0 )
+ mEmailList.remove( mEmailList.begin() );
+
+ mEmailList.prepend( mEmailEdit->text() );
+ }
+
+ return mEmailList;
+}
+
+void EmailEditWidget::edit()
+{
+ EmailEditDialog dlg( mEmailList, this );
+
+ if ( dlg.exec() ) {
+ if ( dlg.changed() ) {
+ mEmailList = dlg.emails();
+ mEmailEdit->setText( mEmailList[ 0 ] );
+ emit modified();
+ }
+ }
+}
+
+void EmailEditWidget::textChanged( const QString &text )
+{
+ if ( mEmailList.count() > 0 )
+ mEmailList.remove( mEmailList.begin() );
+
+ mEmailList.prepend( text );
+}
+
+
+EmailEditDialog::EmailEditDialog( const QStringList &list, QWidget *parent,
+ const char *name )
+ : KDialogBase( KDialogBase::Plain, i18n( "Edit Email Addresses" ),
+ KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Help,
+ parent, name, true )
+{
+ QWidget *page = plainPage();
+
+ QGridLayout *topLayout = new QGridLayout( page, 4, 3, 0, spacingHint() );
+
+ mEmailListBox = new QListBox( page );
+
+ // Make sure there is room for the scrollbar
+ mEmailListBox->setMinimumHeight( mEmailListBox->sizeHint().height() + 30 );
+ connect( mEmailListBox, SIGNAL( highlighted( int ) ),
+ SLOT( selectionChanged( int ) ) );
+ connect( mEmailListBox, SIGNAL( selected( int ) ),
+ SLOT( edit() ) );
+ topLayout->addMultiCellWidget( mEmailListBox, 0, 3, 0, 1 );
+
+ mAddButton = new QPushButton( i18n( "Add..." ), page );
+ connect( mAddButton, SIGNAL( clicked() ), SLOT( add() ) );
+ topLayout->addWidget( mAddButton, 0, 2 );
+
+ mEditButton = new QPushButton( i18n( "Edit..." ), page );
+ connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) );
+ topLayout->addWidget( mEditButton, 1, 2 );
+
+ mRemoveButton = new QPushButton( i18n( "Remove" ), page );
+ connect( mRemoveButton, SIGNAL( clicked() ), SLOT( remove() ) );
+ topLayout->addWidget( mRemoveButton, 2, 2 );
+
+ mStandardButton = new QPushButton( i18n( "Set Standard" ), page );
+ connect( mStandardButton, SIGNAL( clicked() ), SLOT( standard() ) );
+ topLayout->addWidget( mStandardButton, 3, 2 );
+
+ topLayout->activate();
+
+ QStringList items = list;
+ if ( items.remove( "" ) > 0 )
+ mChanged = true;
+ else
+ mChanged = false;
+
+ QStringList::ConstIterator it;
+ bool preferred = true;
+ for ( it = items.begin(); it != items.end(); ++it ) {
+ new EmailItem( mEmailListBox, *it, preferred );
+ preferred = false;
+ }
+
+ // set default state
+ selectionChanged( -1 );
+ KAcceleratorManager::manage( this );
+
+ setInitialSize( QSize( 400, 200 ) );
+}
+
+EmailEditDialog::~EmailEditDialog()
+{
+}
+
+QStringList EmailEditDialog::emails() const
+{
+ QStringList emails;
+
+ for ( uint i = 0; i < mEmailListBox->count(); ++i ) {
+ EmailItem *item = static_cast<EmailItem*>( mEmailListBox->item( i ) );
+ if ( item->preferred() )
+ emails.prepend( item->text() );
+ else
+ emails.append( item->text() );
+ }
+
+ return emails;
+}
+
+void EmailEditDialog::add()
+{
+ EmailValidator *validator = new EmailValidator;
+ bool ok = false;
+
+ QString email = KInputDialog::getText( i18n( "Add Email" ), i18n( "New Email:" ),
+ QString::null, &ok, this, "EmailEditDialog",
+ validator );
+
+ if ( !ok )
+ return;
+
+ // check if item already available, ignore if so...
+ for ( uint i = 0; i < mEmailListBox->count(); ++i ) {
+ if ( mEmailListBox->text( i ) == email )
+ return;
+ }
+
+ new EmailItem( mEmailListBox, email, (mEmailListBox->count() == 0) );
+
+ mChanged = true;
+}
+
+void EmailEditDialog::edit()
+{
+ EmailValidator *validator = new EmailValidator;
+ bool ok = false;
+
+ int editPos = mEmailListBox->currentItem();
+
+ QString email = KInputDialog::getText( i18n( "Edit Email" ), i18n( "Email:" ),
+ mEmailListBox->text( editPos ), &ok, this,
+ "EmailEditDialog", validator );
+
+ if ( !ok )
+ return;
+
+ // check if item already available, ignore if so...
+ for ( uint i = 0; i < mEmailListBox->count(); ++i ) {
+ if ( mEmailListBox->text( i ) == email )
+ return;
+ }
+
+ EmailItem *item = static_cast<EmailItem*>( mEmailListBox->item( editPos ) );
+ item->setText( email );
+ mEmailListBox->triggerUpdate( true );
+
+ mChanged = true;
+}
+
+void EmailEditDialog::remove()
+{
+ QString address = mEmailListBox->currentText();
+
+ QString text = i18n( "<qt>Are you sure that you want to remove the email address <b>%1</b>?</qt>" ).arg( address );
+ QString caption = i18n( "Confirm Remove" );
+
+ if ( KMessageBox::warningContinueCancel( this, text, caption, KGuiItem( i18n("&Delete"), "editdelete") ) == KMessageBox::Continue) {
+ EmailItem *item = static_cast<EmailItem*>( mEmailListBox->item( mEmailListBox->currentItem() ) );
+
+ bool preferred = item->preferred();
+ mEmailListBox->removeItem( mEmailListBox->currentItem() );
+ if ( preferred ) {
+ item = dynamic_cast<EmailItem*>( mEmailListBox->item( 0 ) );
+ if ( item )
+ item->setPreferred( true );
+ }
+
+ mChanged = true;
+ }
+}
+
+bool EmailEditDialog::changed() const
+{
+ return mChanged;
+}
+
+void EmailEditDialog::standard()
+{
+ for ( uint i = 0; i < mEmailListBox->count(); ++i ) {
+ EmailItem *item = static_cast<EmailItem*>( mEmailListBox->item( i ) );
+ if ( (int)i == mEmailListBox->currentItem() )
+ item->setPreferred( true );
+ else
+ item->setPreferred( false );
+ }
+
+ mEmailListBox->triggerUpdate( true );
+
+ mChanged = true;
+}
+
+void EmailEditDialog::selectionChanged( int index )
+{
+ bool value = ( index >= 0 ); // An item is selected
+
+ mRemoveButton->setEnabled( value );
+ mEditButton->setEnabled( value );
+ mStandardButton->setEnabled( value );
+}
+
+#include "emaileditwidget.moc"
diff --git a/kaddressbook/emaileditwidget.h b/kaddressbook/emaileditwidget.h
new file mode 100644
index 00000000..a8cef676
--- /dev/null
+++ b/kaddressbook/emaileditwidget.h
@@ -0,0 +1,99 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef EMAILEDITWIDGET_H
+#define EMAILEDITWIDGET_H
+
+#include <kabc/addressee.h>
+#include <kdialogbase.h>
+
+class QButtonGroup;
+class QCheckBox;
+class QListView;
+class QTextEdit;
+class QToolButton;
+
+class KComboBox;
+class KLineEdit;
+class KListView;
+
+/**
+ This widget displays a list box of the email addresses as well as buttons
+ to manipulate them (up, down, add, remove).
+*/
+class EmailEditWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ EmailEditWidget( QWidget *parent, const char *name = 0 );
+ ~EmailEditWidget();
+
+ void setEmails( const QStringList &list );
+ QStringList emails();
+
+ void setReadOnly( bool readOnly );
+
+ signals:
+ void modified();
+
+ private slots:
+ void edit();
+ void textChanged( const QString& );
+
+ private:
+ KLineEdit *mEmailEdit;
+ QPushButton *mEditButton;
+ QStringList mEmailList;
+};
+
+class EmailEditDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ EmailEditDialog( const QStringList &list, QWidget *parent,
+ const char *name = 0 );
+ ~EmailEditDialog();
+
+ QStringList emails() const;
+ bool changed() const;
+
+ protected slots:
+ void add();
+ void edit();
+ void remove();
+ void standard();
+ void selectionChanged( int );
+
+ private:
+ QListBox *mEmailListBox;
+ QPushButton *mAddButton;
+ QPushButton *mRemoveButton;
+ QPushButton *mEditButton;
+ QPushButton *mStandardButton;
+
+ bool mChanged;
+};
+
+#endif
diff --git a/kaddressbook/extensionmanager.cpp b/kaddressbook/extensionmanager.cpp
new file mode 100644
index 00000000..121c6a1c
--- /dev/null
+++ b/kaddressbook/extensionmanager.cpp
@@ -0,0 +1,256 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <kactionclasses.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <ktrader.h>
+
+#include <qlayout.h>
+#include <qobjectlist.h>
+#include <qsignalmapper.h>
+#include <qsplitter.h>
+#include <qtimer.h>
+#include <qwidgetstack.h>
+
+#include "addresseeeditorextension.h"
+#include "core.h"
+#include "kabprefs.h"
+
+#include "extensionmanager.h"
+
+ExtensionData::ExtensionData() : action( 0 ), widget( 0 ), weight( 0 ), isDetailsExtension( false )
+{
+}
+
+ExtensionManager::ExtensionManager( QWidget* extensionBar, QWidgetStack* detailsStack, KAB::Core *core, QObject *parent,
+ const char *name )
+ : QObject( parent, name ), mExtensionBar( extensionBar ), mCore( core ),
+ mMapper( 0 ), mDetailsStack( detailsStack ), mActiveDetailsWidget( 0 )
+{
+ Q_ASSERT( mExtensionBar );
+ QVBoxLayout* layout = new QVBoxLayout( mExtensionBar );
+ mSplitter = new QSplitter( mExtensionBar );
+ mSplitter->setOrientation( QSplitter::Vertical );
+ layout->addWidget( mSplitter );
+
+ createExtensionWidgets();
+
+ mActionCollection = new KActionCollection( this, "ActionCollection" );
+
+ extensionBar->setShown( false );
+ QTimer::singleShot( 0, this, SLOT( createActions() ) );
+}
+
+ExtensionManager::~ExtensionManager()
+{
+}
+
+
+void ExtensionManager::restoreSettings()
+{
+ const QStringList activeExtensions = KABPrefs::instance()->activeExtensions();
+
+ typedef QMap<QString, ExtensionData>::ConstIterator ConstIterator;
+ for ( ConstIterator it = mExtensionMap.begin(), end = mExtensionMap.end(); it != end; ++it ) {
+ if ( activeExtensions.contains( it.data().identifier ) ) {
+ KToggleAction *action = static_cast<KToggleAction*>( it.data().action );
+ if ( action )
+ action->setChecked( true );
+ setExtensionActive( it.data().identifier, true );
+ }
+ }
+ const QValueList<int> sizes = KABPrefs::instance()->extensionsSplitterSizes();
+ mSplitter->setSizes( sizes );
+}
+
+void ExtensionManager::saveSettings()
+{
+ KABPrefs::instance()->setActiveExtensions( mActiveExtensions );
+ KABPrefs::instance()->setExtensionsSplitterSizes( mSplitter->sizes() );
+}
+
+void ExtensionManager::reconfigure()
+{
+ saveSettings();
+ createExtensionWidgets();
+ createActions();
+ restoreSettings();
+ mExtensionBar->setShown( !mActiveExtensions.isEmpty() );
+}
+
+bool ExtensionManager::isQuickEditVisible() const
+{
+ return mActiveExtensions.contains( "contact_editor" );
+}
+
+void ExtensionManager::setSelectionChanged()
+{
+ for ( QStringList::ConstIterator it = mActiveExtensions.begin(), end = mActiveExtensions.end(); it != end; ++it ) {
+ if ( mExtensionMap.contains( *it ) && mExtensionMap[*it].widget )
+ mExtensionMap[*it].widget->contactsSelectionChanged();
+ }
+}
+
+void ExtensionManager::activationToggled( const QString &extid )
+{
+ if ( !mExtensionMap.contains( extid ) )
+ return;
+ const ExtensionData data = mExtensionMap[ extid ];
+ const bool activated = data.action->isChecked();
+ setExtensionActive( extid, activated );
+}
+
+void ExtensionManager::setExtensionActive( const QString& extid, bool active )
+{
+ if ( !mExtensionMap.contains( extid ) )
+ return;
+ if ( mActiveExtensions.contains( extid ) == active )
+ return;
+ const ExtensionData data = mExtensionMap[ extid ];
+ if ( active ) {
+ mActiveExtensions.append( extid );
+ if ( data.widget ) {
+ if ( data.isDetailsExtension ) {
+ mActiveDetailsWidget = data.widget;
+ emit detailsWidgetActivated( data.widget );
+ } else {
+ data.widget->show();
+ }
+ data.widget->contactsSelectionChanged();
+ }
+ } else {
+ mActiveExtensions.remove( extid );
+ if ( data.widget && !data.isDetailsExtension ) {
+ data.widget->hide();
+ }
+ if ( data.isDetailsExtension ) {
+ mActiveDetailsWidget = 0;
+ emit detailsWidgetDeactivated( data.widget );
+ }
+ }
+ mExtensionBar->setShown( !mActiveExtensions.isEmpty() );
+}
+
+void ExtensionManager::createActions()
+{
+ mCore->guiClient()->unplugActionList( "extensions_list" );
+ mActionList.setAutoDelete( true );
+ mActionList.clear();
+ mActionList.setAutoDelete( false );
+
+ delete mMapper;
+ mMapper = new QSignalMapper( this, "SignalMapper" );
+ connect( mMapper, SIGNAL( mapped( const QString& ) ),
+ this, SLOT( activationToggled( const QString& ) ) );
+
+ ExtensionData::List::ConstIterator it;
+ for ( QMap<QString, ExtensionData>::Iterator it = mExtensionMap.begin(), end = mExtensionMap.end(); it != end; ++it ) {
+ ExtensionData& data = it.data();
+ data.action = new KToggleAction( data.title, 0, mMapper, SLOT( map() ),
+ mActionCollection,
+ QString( data.identifier + "_extension" ).latin1() );
+ mMapper->setMapping( data.action, data.identifier );
+ mActionList.append( data.action );
+
+ if ( mActiveExtensions.contains( data.identifier ) )
+ data.action->setChecked( true );
+ }
+
+ mActionList.append( new KActionSeparator( mActionCollection ) );
+ mCore->guiClient()->plugActionList( "extensions_list", mActionList );
+}
+
+QWidget* ExtensionManager::activeDetailsWidget() const
+{
+ return mActiveDetailsWidget;
+}
+
+void ExtensionManager::createExtensionWidgets()
+{
+ // clean up
+ for ( QMap<QString, ExtensionData>::ConstIterator it = mExtensionMap.begin(), end = mExtensionMap.end(); it != end; ++it ) {
+ delete it.data().widget;
+ }
+ mExtensionMap.clear();
+
+ KAB::ExtensionWidget *wdg = 0;
+
+ {
+ // add addressee editor as default
+ wdg = new AddresseeEditorExtension( mCore, mDetailsStack );
+ wdg->hide();
+
+ connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
+ SIGNAL( modified( const KABC::Addressee::List& ) ) );
+ connect( wdg, SIGNAL( deleted( const QStringList& ) ),
+ SIGNAL( deleted( const QStringList& ) ) );
+
+ ExtensionData data;
+ data.identifier = wdg->identifier();
+ data.title = wdg->title();
+ data.widget = wdg;
+ data.isDetailsExtension = true;
+ mExtensionMap.insert( data.identifier, data );
+ }
+
+ // load the other extensions
+ const KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension",
+ QString( "[X-KDE-KAddressBook-ExtensionPluginVersion] == %1" ).arg( KAB_EXTENSIONWIDGET_PLUGIN_VERSION ) );
+
+ KTrader::OfferList::ConstIterator it;
+ for ( it = plugins.begin(); it != plugins.end(); ++it ) {
+ KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
+ if ( !factory ) {
+ kdDebug(5720) << "ExtensionManager::loadExtensions(): Factory creation failed" << endl;
+ continue;
+ }
+
+ KAB::ExtensionFactory *extensionFactory = static_cast<KAB::ExtensionFactory*>( factory );
+
+ if ( !extensionFactory ) {
+ kdDebug(5720) << "ExtensionManager::loadExtensions(): Cast failed" << endl;
+ continue;
+ }
+
+ wdg = extensionFactory->extension( mCore, mSplitter );
+ if ( wdg ) {
+ if ( wdg->identifier() == "distribution_list_editor_ng" )
+ mSplitter->moveToFirst( wdg );
+ wdg->hide();
+ connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
+ SIGNAL( modified( const KABC::Addressee::List& ) ) );
+ connect( wdg, SIGNAL( deleted( const QStringList& ) ),
+ SIGNAL( deleted( const QStringList& ) ) );
+
+ ExtensionData data;
+ data.identifier = wdg->identifier();
+ data.title = wdg->title();
+ data.widget = wdg;
+ mExtensionMap.insert( data.identifier, data );
+ }
+ }
+}
+
+#include "extensionmanager.moc"
diff --git a/kaddressbook/extensionmanager.h b/kaddressbook/extensionmanager.h
new file mode 100644
index 00000000..5ecc725b
--- /dev/null
+++ b/kaddressbook/extensionmanager.h
@@ -0,0 +1,118 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef EXTENSIONMANAGER_H
+#define EXTENSIONMANAGER_H
+
+#include "extensionwidget.h"
+
+#include <qwidget.h>
+#include <qmap.h>
+#include <qptrlist.h>
+#include <qstringlist.h>
+
+class QSignalMapper;
+class QWidgetStack;
+class KActionCollection;
+
+namespace KAB {
+class Core;
+}
+
+class ExtensionData
+{
+ public:
+ ExtensionData();
+ typedef QValueList<ExtensionData> List;
+
+ KToggleAction* action;
+ KAB::ExtensionWidget *widget;
+ QString identifier;
+ QString title;
+ int weight;
+ bool isDetailsExtension;
+};
+
+class ExtensionManager : public QObject
+{
+ Q_OBJECT
+
+ public:
+ ExtensionManager( QWidget *extensionBar, QWidgetStack *detailsStack, KAB::Core *core, QObject *parent, const char *name = 0 );
+ ~ExtensionManager();
+
+ /**
+ Restores the extension manager specific settings.
+ */
+ void restoreSettings();
+
+ /**
+ Saves the extension manager specific settings.
+ */
+ void saveSettings();
+
+ /**
+ Rereads the extension manager specific settings with some
+ additional initialization stuff.
+ */
+ void reconfigure();
+
+ /**
+ Returns whether the quickedit extension is currently visible.
+ */
+ bool isQuickEditVisible() const;
+
+ QWidget *activeDetailsWidget() const;
+
+ public slots:
+ void setSelectionChanged();
+ void createActions();
+
+ signals:
+
+ void detailsWidgetActivated( QWidget* widget );
+ void detailsWidgetDeactivated( QWidget* widget );
+ void modified( const KABC::Addressee::List& );
+ void deleted( const QStringList& );
+
+ private slots:
+ void activationToggled( const QString &extid );
+
+ private:
+ void createExtensionWidgets();
+ void setExtensionActive( const QString &extid, bool active );
+
+ private:
+ QWidget *mExtensionBar;
+ KAB::Core *mCore;
+ QMap<QString, ExtensionData> mExtensionMap;
+ QStringList mActiveExtensions;
+ QSignalMapper *mMapper;
+ QPtrList<KAction> mActionList;
+ KActionCollection *mActionCollection;
+ QSplitter *mSplitter;
+ QWidgetStack *mDetailsStack;
+ QWidget *mActiveDetailsWidget;
+};
+
+#endif
diff --git a/kaddressbook/features/Makefile.am b/kaddressbook/features/Makefile.am
new file mode 100644
index 00000000..d3311c77
--- /dev/null
+++ b/kaddressbook/features/Makefile.am
@@ -0,0 +1,36 @@
+INCLUDES = -I$(top_srcdir)/kaddressbook/interfaces -I$(top_srcdir)/kaddressbook \
+ -I$(top_srcdir) $(all_includes)
+
+if compile_newdistrlists
+TARGET_DISTRIBUTIONLISTNG=libkaddrbk_distributionlistng.la
+DISTRIBUTIONLISTNG_DESKTOPFILE=distributionlistng.desktop
+else
+DISTRIBUTIONLIST_DESKTOPFILE=distributionlist.desktop
+endif
+
+kde_module_LTLIBRARIES = $(TARGET_DISTRIBUTIONLISTNG) libkaddrbk_distributionlist.la libkaddrbk_resourceselection.la
+
+XXLIBS = $(top_builddir)/kaddressbook/interfaces/libkabinterfaces.la \
+ $(top_builddir)/libkdepim/libkdepim.la
+
+
+if compile_newdistrlists
+libkaddrbk_distributionlistng_la_SOURCES = distributionlistngwidget.cpp
+libkaddrbk_distributionlistng_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined
+libkaddrbk_distributionlistng_la_LIBADD = $(XXLIBS)
+else
+libkaddrbk_distributionlist_la_SOURCES = distributionlistwidget.cpp
+libkaddrbk_distributionlist_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined
+libkaddrbk_distributionlist_la_LIBADD = $(XXLIBS)
+endif
+
+libkaddrbk_resourceselection_la_SOURCES = resourceselection.cpp
+libkaddrbk_resourceselection_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined
+libkaddrbk_resourceselection_la_LIBADD = $(XXLIBS)
+
+noinst_HEADERS = distributionlistwidget.h distributionlistngwidget.h resourceselection.h
+
+METASOURCES = AUTO
+
+servicedir = $(kde_servicesdir)/kaddressbook
+service_DATA = $(DISTRIBUTIONLISTNG_DESKTOPFILE) $(DISTRIBUTIONLIST_DESKTOPFILE) resourceselection.desktop
diff --git a/kaddressbook/features/distributionlist.desktop b/kaddressbook/features/distributionlist.desktop
new file mode 100644
index 00000000..b05d7b5e
--- /dev/null
+++ b/kaddressbook/features/distributionlist.desktop
@@ -0,0 +1,116 @@
+[Desktop Entry]
+X-KDE-Library=libkaddrbk_distributionlist
+Name=KAB Distribution List Plugin
+Name[af]=KAB verspreiding lys inprop module
+Name[ar]=ملحق قائمة توزيع KAB
+Name[be]=Дапаўненне KAB "Сьпіс распаўсюджвання"
+Name[bg]=Приставка за списъка за разпращане на KAB
+Name[br]=Lugent roll ingaladur evit KAB
+Name[bs]=KAB dodatak za distribucione liste
+Name[ca]=Endollable de la llista de distribució KAB
+Name[cs]=Modul distribučního seznamu
+Name[cy]=Ategyn Rhestr Ddosbarthu KAB
+Name[da]=KAB-Distribution liste-plugin
+Name[de]=Verteilerlisten-Modul für Adressbuch
+Name[el]=Πρόσθετο λίστας διανομής του KAB
+Name[eo]=KAB Distribulista Kromprogramo
+Name[es]=Plugin KAB para listas de distribución
+Name[et]=KAB postiloendi plugin
+Name[eu]=KAB banaketa zerrenda plugin-a
+Name[fa]=وصلۀ فهرست توزیع KAB
+Name[fi]=KAB-jakelulistaliitännäinen
+Name[fr]=Module de liste de diffusion pour KAB
+Name[fy]=KAB Distribúsjelist-plugin
+Name[gl]=Extensión de Lista de Distribución KAB
+Name[hi]=केएबी वितरण सूची प्लगइन
+Name[hu]=KAB címlista bővítőmodul
+Name[is]=Íforrit fyrir KAB dreifilista
+Name[it]=Plugin lista di distribuzione KAB
+Name[ja]=KAB 配布リストプラグイン
+Name[ka]=KAB დისტრიბუციის სიის მოდული
+Name[kk]=KAB тарату тізімінің плагин модулі
+Name[km]=កម្មវិធី​ជំនួយ​បញ្ជី​ចែកចាយ​របស់ KAB
+Name[lt]=KAB platinimo sąrašo priedas
+Name[ms]=Plugin Senarai Agihan KAB
+Name[nb]=KAB programtillegg for distribusjonslister
+Name[nds]=Verdeellist-Moduul för KAdressbook
+Name[ne]=KAB वितरण सूची प्लगइन
+Name[nl]=KAB Distributielijst-plugin
+Name[nn]=Programtillegg for KAB distribusjonsliste
+Name[pl]=Wtyczka KAB do obsługi list wysyłkowych
+Name[pt]='Plugin' de Lista de Distribuição do KAB
+Name[pt_BR]=Plug-in de Lista de Distribuição do KAB
+Name[ru]=Списки рассылки
+Name[se]=KAB:a distribušuvdnalistu lassemoduvla
+Name[sk]=KAB plugin distribučného zoznamu
+Name[sl]=Vstavek za distribucijski seznam KAB
+Name[sr]=Прикључак KAB-а за дистрибуционе листе
+Name[sr@Latn]=Priključak KAB-a za distribucione liste
+Name[sv]=Adressbokens insticksprogram för distributionslistor
+Name[ta]=KABயின் பகிர்ந்தளித்தல் பட்டியல் சொருகுப்பொருள்
+Name[tg]=Рӯйхати ба ҳар тараф мефиристодагӣ
+Name[tr]=KAB Dağıtım Listesi Eklentisi
+Name[uk]=Втулок списку розповсюдження KAB
+Name[uz]=Tarqatish roʻyxat plagini
+Name[uz@cyrillic]=Тарқатиш рўйхат плагини
+Name[zh_CN]=KAB 分发列表插件
+Comment=Plugin for managing distribution lists
+Comment[af]=Inprop module vir die bestuur van verspreiding lyste
+Comment[ar]=ملحق لإدارة قوائم التوزيع
+Comment[be]=Дапаўненне для кіравання сьпісамі распаўсюджвання
+Comment[bg]=Приставка за управление на списъци
+Comment[br]=Lugent melestradur ar rolloù ingaladur
+Comment[bs]=Dodatak za upravljanje distribucionim listama
+Comment[ca]=Endollable per a gestionar llistes de distribució
+Comment[cs]=Modul pro správu distribučních seznamů
+Comment[cy]=Ategyn ar gyfer rheoli rhestri dosbarthu
+Comment[da]=Plugin til at håndtere distributionslister
+Comment[de]=Modul zur Verwaltung von Verteilerlisten
+Comment[el]=Πρόσθετο για τη διαχείριση λιστών διανομής
+Comment[eo]=Kromaĵo por administri distribulistojn
+Comment[es]=Plugin para gestionar listas de distribución
+Comment[et]=Plugin postiloendite haldamiseks
+Comment[eu]=Banaketa zerrendak kudeatzeko plugin-a
+Comment[fa]=وصله برای مدیریت فهرستهای توزیع
+Comment[fi]=Liitännäinen jakelulistojen hallintaan
+Comment[fr]=Module pour gérer des listes de diffusion
+Comment[fy]=Plugin foar nit behearen fan distribúsjelisten
+Comment[gl]=Plugin para manexar listas de distribución
+Comment[he]=תוסף לניהול רשימות תפוצה
+Comment[hi]=वितरण सूची प्रबंधन के लिए प्लगइन
+Comment[hu]=Bővítőmodul címlisták kezeléséhez
+Comment[is]=Íforrit til að sjá um dreifilista
+Comment[it]=Plugin per gestire liste di distribuzione
+Comment[ja]=配布リスト管理用プラグイン
+Comment[ka]=სადისტრიბუციო სიათა მართვის მოდული
+Comment[kk]=Тарату тізімімен айналысу плагин модулі
+Comment[km]=កម្មវិធី​ជំនួយ​ដើម្បី​គ្រប់គ្រង​បញ្ជី​ចែកចាយ
+Comment[lt]=Priedas platinimo sąrašų tvarkymui
+Comment[ms]=Plug masuk untuk pengurusan senarai edaran
+Comment[nb]=Programtillegg for å håndtere distribusjonslister
+Comment[nds]=Moduul för't Plegen vun Verdeellisten
+Comment[ne]=व्यवस्थापन वितरण सूचीका लागि प्लगइन
+Comment[nl]=Plugin voor het beheren van distributielijsten
+Comment[nn]=Programtillegg for handtering av distibusjonsliste
+Comment[pl]=Wtyczka do zarządzania listami wysyłkowymi
+Comment[pt]=Um 'plugin' para gerir as listas de distribuição
+Comment[pt_BR]=Plug-in para gerenciar listas de distribuição
+Comment[ro]=Modul pentru administrarea listelor de distribuţie
+Comment[ru]=Работа со списками рассылок
+Comment[se]=Lassemoduvla mii gieđahallá distribušuvdnalisttuid
+Comment[sk]=Plugin pre správu distribučných zoznamov
+Comment[sl]=Vstavek za upravljanje distribucijskih seznamov
+Comment[sr]=Прикључак за управљање дистрибуционим листама
+Comment[sr@Latn]=Priključak za upravljanje distribucionim listama
+Comment[sv]=Insticksprogram för att hantera distributionslistor
+Comment[ta]=பகிர்தல் பட்டியல் நிர்வகித்தலின் சொருகுப்பொருள்
+Comment[tg]=Кор бо рӯйхати ба ҳар тараф мефиристодагӣ
+Comment[tr]=Dağıtım listelerini yönetmek için eklenti
+Comment[uk]=Втулок для керування списками розповсюдження
+Comment[uz]=Tarqatish roʻyxatlarni boshqarish uchu plagin
+Comment[uz@cyrillic]=Тарқатиш рўйхатларни бошқариш учу плагин
+Comment[zh_CN]=管理分发列表的插件
+Comment[zh_TW]=管理分配清單外掛程式
+Type=Service
+ServiceTypes=KAddressBook/Extension
+X-KDE-KAddressBook-ExtensionPluginVersion=1
diff --git a/kaddressbook/features/distributionlistng.desktop b/kaddressbook/features/distributionlistng.desktop
new file mode 100644
index 00000000..84d7070b
--- /dev/null
+++ b/kaddressbook/features/distributionlistng.desktop
@@ -0,0 +1,86 @@
+[Desktop Entry]
+X-KDE-Library=libkaddrbk_distributionlistng
+Name=KAB Distribution List Next Generation Plugin
+Name[bg]=Приставка от следващо поколение за списъка за разпращане на KAB
+Name[ca]=Endollable de la propera generació de la llista de distribució KAB
+Name[da]=Næste generations-plugin til KAB-Distribution-liste
+Name[de]=Verteilerlisten-Modul für neues Adressbuch
+Name[el]=Πρόσθετο επόμενης γενιάς λίστας διανομής του KAB
+Name[es]=Complemento de nueva generación KAB para listas de distribución
+Name[et]=KAB postiloendi järgmise põlvkonna plugin
+Name[fr]=Module de liste de diffusion nouvelle génération pour KAB
+Name[is]=Næstu kynslóðar íforrit fyrir KAB dreifilista
+Name[it]=Plugin lista di distribuzione KAB di nuova generazione
+Name[ja]=KAB 配布リスト次世代プラグイン
+Name[km]=កម្មវិធី​ជំនួយ​ជំនាន់​ក្រោយ​របស់​​បញ្ជី​ចែកចាយ​ KAB
+Name[nds]=Verbetert Verdeellist-Moduul för KAdressbook
+Name[nl]=Plugin voor KAB Distributielijst (Nieuwe Generatie)
+Name[pl]=Wtyczka KAB do obsługi list wysyłkowych
+Name[ru]=Списки рассылки (новая версия)
+Name[sk]=KAB plugin distribučného zoznamu ďaľšej generácie
+Name[sr]=Прикључак KAB-а наредне генерације за дистрибуционе листе
+Name[sr@Latn]=Priključak KAB-a naredne generacije za distribucione liste
+Name[sv]=Adressbokens nästa generation insticksprogram för distributionslistor
+Name[tr]=KAB Dağıtım Listesi Sonraki Kuşak Eklentisi
+Name[zh_CN]=KAB 分发列表生成插件
+Name[zh_TW]=KAB 分派清單下一代外掛程式
+Comment=Plugin for managing distribution lists
+Comment[af]=Inprop module vir die bestuur van verspreiding lyste
+Comment[ar]=ملحق لإدارة قوائم التوزيع
+Comment[be]=Дапаўненне для кіравання сьпісамі распаўсюджвання
+Comment[bg]=Приставка за управление на списъци
+Comment[br]=Lugent melestradur ar rolloù ingaladur
+Comment[bs]=Dodatak za upravljanje distribucionim listama
+Comment[ca]=Endollable per a gestionar llistes de distribució
+Comment[cs]=Modul pro správu distribučních seznamů
+Comment[cy]=Ategyn ar gyfer rheoli rhestri dosbarthu
+Comment[da]=Plugin til at håndtere distributionslister
+Comment[de]=Modul zur Verwaltung von Verteilerlisten
+Comment[el]=Πρόσθετο για τη διαχείριση λιστών διανομής
+Comment[eo]=Kromaĵo por administri distribulistojn
+Comment[es]=Plugin para gestionar listas de distribución
+Comment[et]=Plugin postiloendite haldamiseks
+Comment[eu]=Banaketa zerrendak kudeatzeko plugin-a
+Comment[fa]=وصله برای مدیریت فهرستهای توزیع
+Comment[fi]=Liitännäinen jakelulistojen hallintaan
+Comment[fr]=Module pour gérer des listes de diffusion
+Comment[fy]=Plugin foar nit behearen fan distribúsjelisten
+Comment[gl]=Plugin para manexar listas de distribución
+Comment[he]=תוסף לניהול רשימות תפוצה
+Comment[hi]=वितरण सूची प्रबंधन के लिए प्लगइन
+Comment[hu]=Bővítőmodul címlisták kezeléséhez
+Comment[is]=Íforrit til að sjá um dreifilista
+Comment[it]=Plugin per gestire liste di distribuzione
+Comment[ja]=配布リスト管理用プラグイン
+Comment[ka]=სადისტრიბუციო სიათა მართვის მოდული
+Comment[kk]=Тарату тізімімен айналысу плагин модулі
+Comment[km]=កម្មវិធី​ជំនួយ​ដើម្បី​គ្រប់គ្រង​បញ្ជី​ចែកចាយ
+Comment[lt]=Priedas platinimo sąrašų tvarkymui
+Comment[ms]=Plug masuk untuk pengurusan senarai edaran
+Comment[nb]=Programtillegg for å håndtere distribusjonslister
+Comment[nds]=Moduul för't Plegen vun Verdeellisten
+Comment[ne]=व्यवस्थापन वितरण सूचीका लागि प्लगइन
+Comment[nl]=Plugin voor het beheren van distributielijsten
+Comment[nn]=Programtillegg for handtering av distibusjonsliste
+Comment[pl]=Wtyczka do zarządzania listami wysyłkowymi
+Comment[pt]=Um 'plugin' para gerir as listas de distribuição
+Comment[pt_BR]=Plug-in para gerenciar listas de distribuição
+Comment[ro]=Modul pentru administrarea listelor de distribuţie
+Comment[ru]=Работа со списками рассылок
+Comment[se]=Lassemoduvla mii gieđahallá distribušuvdnalisttuid
+Comment[sk]=Plugin pre správu distribučných zoznamov
+Comment[sl]=Vstavek za upravljanje distribucijskih seznamov
+Comment[sr]=Прикључак за управљање дистрибуционим листама
+Comment[sr@Latn]=Priključak za upravljanje distribucionim listama
+Comment[sv]=Insticksprogram för att hantera distributionslistor
+Comment[ta]=பகிர்தல் பட்டியல் நிர்வகித்தலின் சொருகுப்பொருள்
+Comment[tg]=Кор бо рӯйхати ба ҳар тараф мефиристодагӣ
+Comment[tr]=Dağıtım listelerini yönetmek için eklenti
+Comment[uk]=Втулок для керування списками розповсюдження
+Comment[uz]=Tarqatish roʻyxatlarni boshqarish uchu plagin
+Comment[uz@cyrillic]=Тарқатиш рўйхатларни бошқариш учу плагин
+Comment[zh_CN]=管理分发列表的插件
+Comment[zh_TW]=管理分配清單外掛程式
+Type=Service
+ServiceTypes=KAddressBook/Extension
+X-KDE-KAddressBook-ExtensionPluginVersion=1
diff --git a/kaddressbook/features/distributionlistngwidget.cpp b/kaddressbook/features/distributionlistngwidget.cpp
new file mode 100644
index 00000000..fee8377a
--- /dev/null
+++ b/kaddressbook/features/distributionlistngwidget.cpp
@@ -0,0 +1,249 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2007 Klaralvdalens Datakonsult AB <frank@kdab.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include "distributionlistngwidget.h"
+#include "interfaces/core.h"
+#include "searchmanager.h"
+
+#include <libkdepim/distributionlist.h>
+#include <libkdepim/kvcarddrag.h>
+
+#include <kabc/vcardconverter.h>
+
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <klistview.h>
+#include <klocale.h>
+#include <kpopupmenu.h>
+
+#include <qevent.h>
+#include <qguardedptr.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpoint.h>
+#include <qtimer.h>
+#include <qpushbutton.h>
+#include <qtooltip.h>
+
+KAB::DistributionListNg::ListBox::ListBox( QWidget* parent ) : KListBox( parent )
+{
+ setAcceptDrops( true );
+}
+
+void KAB::DistributionListNg::ListBox::dragMoveEvent( QDragMoveEvent *event )
+{
+ QListBoxItem *item = itemAt( event->pos() );
+ if ( !item ) {
+ event->ignore();
+ }
+ else {
+ event->accept( itemRect( item ) );
+ }
+}
+
+void KAB::DistributionListNg::ListBox::dragEnterEvent( QDragEnterEvent *event )
+{
+ KListBox::dragEnterEvent( event );
+}
+
+void KAB::DistributionListNg::ListBox::dropEvent( QDropEvent *event )
+{
+ QListBoxItem *item = itemAt( event->pos() );
+ if ( !item || index( item ) == 0 )
+ return;
+
+ QString vcards;
+ if ( !KVCardDrag::decode( event, vcards ) )
+ return;
+
+ KABC::VCardConverter converter;
+ emit dropped( item->text(), converter.parseVCards( vcards ) );
+}
+
+namespace KAB {
+namespace DistributionListNg {
+
+class Factory : public KAB::ExtensionFactory
+{
+ public:
+ KAB::ExtensionWidget *extension( KAB::Core *core, QWidget *parent, const char *name )
+ {
+ return new KAB::DistributionListNg::MainWidget( core, parent, name );
+ }
+
+ QString identifier() const
+ {
+ return "distribution_list_editor";
+ }
+};
+
+}
+}
+
+extern "C" {
+ void *init_libkaddrbk_distributionlistng()
+ {
+ return ( new KAB::DistributionListNg::Factory );
+ }
+}
+
+QString KAB::DistributionListNg::MainWidget::title() const
+{
+ return i18n( "Distribution List Editor NG" );
+}
+
+QString KAB::DistributionListNg::MainWidget::identifier() const
+{
+ return "distribution_list_editor_ng";
+}
+
+KAB::DistributionListNg::MainWidget::MainWidget( KAB::Core *core, QWidget *parent, const char *name ) : KAB::ExtensionWidget( core, parent, name )
+{
+ QVBoxLayout *layout = new QVBoxLayout( this );
+ layout->setSpacing( KDialog::spacingHint() );
+
+ QHBoxLayout *buttonLayout = new QHBoxLayout();
+ layout->addLayout( buttonLayout );
+
+ QLabel *label = new QLabel( this );
+ label->setText( i18n( "Distribution Lists" ) );
+ buttonLayout->addWidget( label );
+ buttonLayout->addStretch( 1 );
+
+ mAddButton = new QPushButton( this );
+ mAddButton->setIconSet( SmallIconSet( "add" ) );
+ QToolTip::add( mAddButton, i18n( "Add distribution list" ) );
+ connect( mAddButton, SIGNAL(clicked()), core, SLOT(newDistributionList()) );
+ buttonLayout->addWidget( mAddButton );
+
+ mEditButton = new QPushButton( this );
+ mEditButton->setIconSet( SmallIconSet( "edit" ) );
+ QToolTip::add( mEditButton, i18n( "Edit distribution list" ) );
+ connect( mEditButton, SIGNAL(clicked()), this, SLOT(editSelectedDistributionList()) );
+ buttonLayout->addWidget( mEditButton );
+
+ mRemoveButton = new QPushButton( this );
+ mRemoveButton->setIconSet( SmallIconSet( "remove" ) );
+ QToolTip::add( mRemoveButton, i18n( "Remove distribution list" ) );
+ connect( mRemoveButton, SIGNAL(clicked()), this, SLOT(deleteSelectedDistributionList()) );
+ buttonLayout->addWidget( mRemoveButton );
+
+ mListBox = new ListBox( this );
+ connect( mListBox, SIGNAL( contextMenuRequested( QListBoxItem*, const QPoint& ) ),
+ this, SLOT( contextMenuRequested( QListBoxItem*, const QPoint& ) ) );
+ connect( mListBox, SIGNAL( dropped( const QString &, const KABC::Addressee::List & ) ),
+ this, SLOT( contactsDropped( const QString &, const KABC::Addressee::List & ) ) );
+ connect( mListBox, SIGNAL( highlighted( int ) ),
+ this, SLOT( itemSelected( int ) ) );
+ layout->addWidget( mListBox );
+
+ connect( core, SIGNAL( contactsUpdated() ),
+ this, SLOT( updateEntries() ) );
+ connect( core->addressBook(), SIGNAL( addressBookChanged( AddressBook* ) ),
+ this, SLOT( updateEntries() ) );
+
+ // When contacts are changed, update both distr list combo and contents of displayed distr list
+ connect( core, SIGNAL( contactsUpdated() ),
+ this, SLOT( updateEntries() ) );
+
+ QTimer::singleShot( 0, this, SLOT( updateEntries() ) );
+}
+
+void KAB::DistributionListNg::MainWidget::contextMenuRequested( QListBoxItem *item, const QPoint &point )
+{
+ QGuardedPtr<KPopupMenu> menu = new KPopupMenu( this );
+ menu->insertItem( i18n( "New Distribution List..." ), core(), SLOT( newDistributionList() ) );
+ if ( item )
+ {
+ menu->insertItem( i18n( "Edit..." ), this, SLOT( editSelectedDistributionList() ) );
+ menu->insertItem( i18n( "Delete" ), this, SLOT( deleteSelectedDistributionList() ) );
+ }
+ menu->exec( point );
+ delete menu;
+}
+
+void KAB::DistributionListNg::MainWidget::editSelectedDistributionList()
+{
+ const QListBoxItem* const item = mListBox->selectedItem();
+ if ( !item )
+ return;
+ core()->editDistributionList( item->text() );
+}
+
+void KAB::DistributionListNg::MainWidget::deleteSelectedDistributionList()
+{
+ const QListBoxItem* const item = mListBox->selectedItem();
+ const QString name = item ? item->text() : QString();
+ if ( name.isNull() )
+ return;
+ const KPIM::DistributionList list = KPIM::DistributionList::findByName(
+ core()->addressBook(), name );
+ if ( list.isEmpty() )
+ return;
+ core()->deleteDistributionLists( name );
+}
+
+void KAB::DistributionListNg::MainWidget::contactsDropped( const QString &listName, const KABC::Addressee::List &addressees )
+{
+ if ( addressees.isEmpty() )
+ return;
+
+ KPIM::DistributionList list = KPIM::DistributionList::findByName(
+ core()->addressBook(), listName );
+ if ( list.isEmpty() ) // not found [should be impossible]
+ return;
+
+ for ( KABC::Addressee::List::ConstIterator it = addressees.begin(); it != addressees.end(); ++it ) {
+ list.insertEntry( *it );
+ }
+
+ core()->addressBook()->insertAddressee( list );
+ changed( list );
+}
+
+void KAB::DistributionListNg::MainWidget::changed( const KABC::Addressee& dist )
+{
+ emit modified( KABC::Addressee::List() << dist );
+}
+
+void KAB::DistributionListNg::MainWidget::updateEntries()
+{
+ const bool hadSelection = mListBox->selectedItem() != 0;
+ const QStringList newEntries = core()->distributionListNames();
+ if ( !mCurrentEntries.isEmpty() && newEntries == mCurrentEntries )
+ return;
+ mCurrentEntries = newEntries;
+ mListBox->clear();
+ mListBox->insertItem( i18n( "All Contacts" ), 0 );
+ mListBox->insertStringList( mCurrentEntries );
+ if ( !hadSelection )
+ mListBox->setSelected( 0, true );
+}
+
+void KAB::DistributionListNg::MainWidget::itemSelected( int index )
+{
+ core()->setSelectedDistributionList( index == 0 ? QString() : mListBox->item( index )->text() );
+ mEditButton->setEnabled( index > 0 );
+ mRemoveButton->setEnabled( index > 0 );
+}
+
+#include "distributionlistngwidget.moc"
diff --git a/kaddressbook/features/distributionlistngwidget.h b/kaddressbook/features/distributionlistngwidget.h
new file mode 100644
index 00000000..4a174dd8
--- /dev/null
+++ b/kaddressbook/features/distributionlistngwidget.h
@@ -0,0 +1,104 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2007 Klaralvdalens Datakonsult AB <frank@kdab.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KAB_DISTRIBUTIONLISTNG_MAINWIDGET_H
+#define KAB_DISTRIBUTIONLISTNG_MAINWIDGET_H
+
+#include "extensionwidget.h"
+
+#include <kabc/addressee.h>
+
+#include <klistbox.h>
+
+#include <qstringlist.h>
+
+class QDragEnterEvent;
+class QDragMoveEvent;
+class QDropEvent;
+class QPoint;
+class QPushButton;
+
+namespace KABC {
+ class DistributionListManager;
+}
+
+namespace KAB {
+namespace DistributionListNg {
+
+class ListBox : public KListBox
+{
+ Q_OBJECT
+public:
+ ListBox( QWidget* parent = 0 );
+
+signals:
+
+ void dropped( const QString &listName, const KABC::Addressee::List &addressees );
+
+protected:
+ //override
+ void dragEnterEvent( QDragEnterEvent *event );
+ //override
+ void dragMoveEvent( QDragMoveEvent *event );
+ //override
+ void dropEvent( QDropEvent *event );
+};
+
+class MainWidget : public KAB::ExtensionWidget
+{
+ Q_OBJECT
+
+public:
+ explicit MainWidget( KAB::Core *core, QWidget *parent = 0, const char *name = 0 );
+
+ //impl
+ QString title() const;
+
+ //impl
+ QString identifier() const;
+
+
+private:
+ void changed( const KABC::Addressee& );
+
+private slots:
+
+ void deleteSelectedDistributionList();
+ void editSelectedDistributionList();
+
+ void contextMenuRequested( QListBoxItem *item, const QPoint &point );
+ void updateEntries();
+ void itemSelected( int index );
+ void contactsDropped( const QString &listName, const KABC::Addressee::List &addressees );
+
+private:
+ ListBox *mListBox;
+ QStringList mCurrentEntries;
+ QPushButton *mAddButton;
+ QPushButton *mEditButton;
+ QPushButton *mRemoveButton;
+};
+
+} // namespace DistributionListNg
+} // namespace KAB
+
+#endif // KAB_DISTRIBUTIONLISTNG_MAINWIDGET_H
diff --git a/kaddressbook/features/distributionlistwidget.cpp b/kaddressbook/features/distributionlistwidget.cpp
new file mode 100644
index 00000000..9c322d6f
--- /dev/null
+++ b/kaddressbook/features/distributionlistwidget.cpp
@@ -0,0 +1,673 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include "distributionlistwidget.h"
+
+#include <qbuttongroup.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlistview.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+
+#include <kaccelmanager.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kinputdialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include <kabc/addresseedialog.h>
+#ifdef KDEPIM_NEW_DISTRLISTS
+#include <libkdepim/distributionlist.h>
+typedef KPIM::DistributionList DistributionList;
+#else
+#include <kabc/distributionlist.h>
+typedef KABC::DistributionList DistributionList;
+#endif
+#include <kabc/stdaddressbook.h>
+#include <kabc/vcardconverter.h>
+#include <libkdepim/kvcarddrag.h>
+
+#include "core.h"
+
+class DistributionListFactory : public KAB::ExtensionFactory
+{
+ public:
+ KAB::ExtensionWidget *extension( KAB::Core *core, QWidget *parent, const char *name )
+ {
+ return new DistributionListWidget( core, parent, name );
+ }
+
+ QString identifier() const
+ {
+ return "distribution_list_editor";
+ }
+};
+
+extern "C" {
+ void *init_libkaddrbk_distributionlist()
+ {
+ return ( new DistributionListFactory );
+ }
+}
+
+/**
+ We have to catch when the 'Del' key is pressed, otherwise
+ the event is forwarded to the ViewManager and it tries to
+ remove a contact instead of the distribution list.
+ */
+class DeletePressedCatcher : public QObject
+{
+ public:
+ DeletePressedCatcher( DistributionListWidget *parent )
+ : QObject( parent, "DeletePressedCatcher" ), mWidget( parent )
+ {
+ }
+
+ protected:
+ bool eventFilter( QObject*, QEvent *event )
+ {
+ if ( event->type() == QEvent::AccelOverride ) {
+ QKeyEvent *keyEvent = (QKeyEvent*)event;
+ if ( keyEvent->key() == Qt::Key_Delete ) {
+ keyEvent->accept();
+ mWidget->removeContact();
+ return true;
+ } else
+ return false;
+ } else {
+ return false;
+ }
+ }
+
+ private:
+ DistributionListWidget *mWidget;
+};
+
+class ContactItem : public QListViewItem
+{
+ public:
+ ContactItem( DistributionListView *parent, const KABC::Addressee &addressee,
+ const QString &email = QString::null ) :
+ QListViewItem( parent ),
+ mAddressee( addressee ),
+ mEmail( email )
+ {
+ setText( 0, addressee.realName() );
+ if ( email.isEmpty() ) {
+ setText( 1, addressee.preferredEmail() );
+ setText( 2, i18n( "Yes" ) );
+ } else {
+ setText( 1, email );
+ setText( 2, i18n( "No" ) );
+ }
+ }
+
+ KABC::Addressee addressee() const
+ {
+ return mAddressee;
+ }
+
+ QString email() const
+ {
+ return mEmail;
+ }
+
+ protected:
+ bool acceptDrop( const QMimeSource* )
+ {
+ return true;
+ }
+
+ private:
+ KABC::Addressee mAddressee;
+ QString mEmail;
+};
+
+DistributionListWidget::DistributionListWidget( KAB::Core *core, QWidget *parent,
+ const char *name )
+ : KAB::ExtensionWidget( core, parent, name )
+#ifndef KDEPIM_NEW_DISTRLISTS
+ , mManager( 0 )
+#endif
+{
+ QGridLayout *topLayout = new QGridLayout( this, 3, 4, KDialog::marginHint(),
+ KDialog::spacingHint() );
+
+ mNameCombo = new QComboBox( this );
+ topLayout->addWidget( mNameCombo, 0, 0 );
+ connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateContactView() ) );
+
+ mCreateListButton = new QPushButton( i18n( "New List..." ), this );
+ topLayout->addWidget( mCreateListButton, 0, 1 );
+ connect( mCreateListButton, SIGNAL( clicked() ), SLOT( createList() ) );
+
+ mEditListButton = new QPushButton( i18n( "Rename List..." ), this );
+ topLayout->addWidget( mEditListButton, 0, 2 );
+ connect( mEditListButton, SIGNAL( clicked() ), SLOT( editList() ) );
+
+ mRemoveListButton = new QPushButton( i18n( "Remove List" ), this );
+ topLayout->addWidget( mRemoveListButton, 0, 3 );
+ connect( mRemoveListButton, SIGNAL( clicked() ), SLOT( removeList() ) );
+
+ mContactView = new DistributionListView( this );
+ mContactView->addColumn( i18n( "Name" ) );
+ mContactView->addColumn( i18n( "Email" ) );
+ mContactView->addColumn( i18n( "Use Preferred" ) );
+ mContactView->setEnabled( false );
+ mContactView->setAllColumnsShowFocus( true );
+ mContactView->setFullWidth( true );
+ topLayout->addMultiCellWidget( mContactView, 1, 1, 0, 3 );
+ connect( mContactView, SIGNAL( selectionChanged() ),
+ SLOT( selectionContactViewChanged() ) );
+ connect( mContactView, SIGNAL( dropped( QDropEvent*, QListViewItem* ) ),
+ SLOT( dropped( QDropEvent*, QListViewItem* ) ) );
+
+ mAddContactButton = new QPushButton( i18n( "Add Contact" ), this );
+ mAddContactButton->setEnabled( false );
+ topLayout->addWidget( mAddContactButton, 2, 0 );
+ connect( mAddContactButton, SIGNAL( clicked() ), SLOT( addContact() ) );
+
+ mEntryCountLabel = new QLabel( this );
+ topLayout->addWidget( mEntryCountLabel, 2, 1 );
+
+ mChangeEmailButton = new QPushButton( i18n( "Change Email..." ), this );
+ topLayout->addWidget( mChangeEmailButton, 2, 2 );
+ connect( mChangeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) );
+
+ mRemoveContactButton = new QPushButton( i18n( "Remove Contact" ), this );
+ topLayout->addWidget( mRemoveContactButton, 2, 3 );
+ connect( mRemoveContactButton, SIGNAL( clicked() ), SLOT( removeContact() ) );
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+ // When contacts are changed, update both distr list combo and contents of displayed distr list
+ connect( core, SIGNAL( contactsUpdated() ),
+ this, SLOT( updateNameCombo() ) );
+#else
+ mManager = new KABC::DistributionListManager( core->addressBook() );
+
+ connect( KABC::DistributionListWatcher::self(), SIGNAL( changed() ),
+ this, SLOT( updateNameCombo() ) );
+#endif
+
+ connect( core->addressBook(), SIGNAL( addressBookChanged( AddressBook* ) ),
+ this, SLOT( updateNameCombo() ) );
+
+ updateNameCombo();
+
+ QObject *catcher = new DeletePressedCatcher( this );
+ installEventFilter( catcher );
+ mContactView->installEventFilter( catcher );
+
+ mContactView->restoreLayout( KGlobal::config(), "DistributionListViewColumns" );
+
+ KAcceleratorManager::manage( this );
+}
+
+DistributionListWidget::~DistributionListWidget()
+{
+#ifndef KDEPIM_NEW_DISTRLISTS
+ delete mManager;
+#endif
+
+ mContactView->saveLayout( KGlobal::config(), "DistributionListViewColumns" );
+}
+
+void DistributionListWidget::save()
+{
+#ifndef KDEPIM_NEW_DISTRLISTS
+ mManager->save();
+#endif
+}
+
+void DistributionListWidget::selectionContactViewChanged()
+{
+ ContactItem *contactItem =
+ static_cast<ContactItem *>( mContactView->selectedItem() );
+ bool state = contactItem;
+
+ mChangeEmailButton->setEnabled( state );
+ mRemoveContactButton->setEnabled( state );
+}
+
+bool DistributionListWidget::alreadyExists( const QString& distrListName ) const
+{
+#ifdef KDEPIM_NEW_DISTRLISTS
+ return core()->distributionListNames().contains( distrListName );
+#else
+ return mManager->listNames().contains( distrListName );
+#endif
+}
+
+void DistributionListWidget::createList()
+{
+ QString newName = KInputDialog::getText( i18n( "New Distribution List" ),
+ i18n( "Please enter name:" ),
+ QString::null, 0, this );
+
+ if ( newName.isEmpty() ) return;
+
+ if ( alreadyExists( newName ) ) {
+ KMessageBox::sorry( this, i18n( "The name already exists" ) );
+ return;
+ }
+#ifdef KDEPIM_NEW_DISTRLISTS
+ KABC::Resource* resource = core()->requestResource( this );
+ if ( !resource )
+ return;
+
+ KPIM::DistributionList dist;
+ dist.setResource( resource );
+ dist.setName( newName );
+ // Creates undo-redo command, calls setModified, also triggers contactsUpdated,
+ // which triggers updateNameCombo, so the new name appears
+ changed( dist );
+ core()->addressBook()->insertAddressee( dist );
+
+#else
+ new KABC::DistributionList( mManager, newName );
+ changed();
+
+ updateNameCombo();
+#endif
+
+ // Select the new one in the list
+ mNameCombo->setCurrentText( newName );
+ // Display the contents of the list we just selected (well, it's empty)
+ updateContactView();
+}
+
+void DistributionListWidget::editList()
+{
+ const QString oldName = mNameCombo->currentText();
+
+ const QString newName = KInputDialog::getText( i18n( "Rename Distribution List" ),
+ i18n( "Please enter name:" ),
+ oldName, 0, this );
+
+ if ( newName.isEmpty() ) return;
+
+ if ( alreadyExists( newName ) ) {
+ KMessageBox::sorry( this, i18n( "The name already exists." ) );
+ return;
+ }
+#ifdef KDEPIM_NEW_DISTRLISTS
+ KPIM::DistributionList dist = KPIM::DistributionList::findByName(
+ core()->addressBook(), mNameCombo->currentText() );
+ if ( dist.isEmpty() ) // not found [should be impossible]
+ return;
+
+ dist.setFormattedName( newName );
+ core()->addressBook()->insertAddressee( dist );
+
+ changed( dist );
+#else
+ KABC::DistributionList *list = mManager->list( oldName );
+ list->setName( newName );
+ mManager->save();
+ updateNameCombo();
+#endif
+
+ // Select the new name in the list (updateNameCombo couldn't know we wanted that one)
+ mNameCombo->setCurrentText( newName );
+ // Display the contents of the list we just selected
+ updateContactView();
+
+#ifndef KDEPIM_NEW_DISTRLISTS
+ changed();
+#endif
+}
+
+void DistributionListWidget::removeList()
+{
+ int result = KMessageBox::warningContinueCancel( this,
+ i18n( "<qt>Delete distribution list <b>%1</b>?</qt>" ) .arg( mNameCombo->currentText() ),
+ QString::null, KGuiItem( i18n("Delete"), "editdelete") );
+
+ if ( result != KMessageBox::Continue )
+ return;
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+ KPIM::DistributionList dist = KPIM::DistributionList::findByName(
+ core()->addressBook(), mNameCombo->currentText() );
+ if ( dist.isEmpty() ) // not found [should be impossible]
+ return;
+
+ emit deleted( dist.uid() );
+ core()->addressBook()->removeAddressee( dist );
+#else
+ mManager->remove( mManager->list( mNameCombo->currentText() ) );
+ mNameCombo->removeItem( mNameCombo->currentItem() );
+
+ updateContactView();
+
+ changed();
+#endif
+}
+
+void DistributionListWidget::addContact()
+{
+#ifdef KDEPIM_NEW_DISTRLISTS
+ KPIM::DistributionList dist = KPIM::DistributionList::findByName(
+ core()->addressBook(), mNameCombo->currentText() );
+ if ( dist.isEmpty() ) { // not found
+ kdDebug(5720) << k_funcinfo << mNameCombo->currentText() << " not found" << endl;
+ return;
+ }
+#else
+ KABC::DistributionList *list = mManager->list( mNameCombo->currentText() );
+ if ( !list )
+ return;
+ KABC::DistributionList& dist = *list;
+#endif
+
+ const KABC::Addressee::List addrList = selectedContacts();
+ KABC::Addressee::List::ConstIterator it;
+ for ( it = addrList.begin(); it != addrList.end(); ++it )
+ dist.insertEntry( *it );
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+ core()->addressBook()->insertAddressee( dist );
+ changed( dist );
+#else
+ updateContactView();
+ changed();
+#endif
+}
+
+void DistributionListWidget::removeContact()
+{
+#ifdef KDEPIM_NEW_DISTRLISTS
+ KPIM::DistributionList dist = KPIM::DistributionList::findByName(
+ core()->addressBook(), mNameCombo->currentText() );
+ if ( dist.isEmpty() ) // not found
+ return;
+#else
+ KABC::DistributionList *list = mManager->list( mNameCombo->currentText() );
+ if ( !list )
+ return;
+ KABC::DistributionList& dist = *list;
+#endif
+
+ ContactItem *contactItem =
+ static_cast<ContactItem *>( mContactView->selectedItem() );
+ if ( !contactItem )
+ return;
+
+ dist.removeEntry( contactItem->addressee(), contactItem->email() );
+ delete contactItem;
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+ core()->addressBook()->insertAddressee( dist );
+ changed( dist );
+#else
+ changed();
+#endif
+}
+
+void DistributionListWidget::changeEmail()
+{
+#ifdef KDEPIM_NEW_DISTRLISTS
+ KPIM::DistributionList dist = KPIM::DistributionList::findByName(
+ core()->addressBook(), mNameCombo->currentText() );
+ if ( dist.isEmpty() ) // not found
+ return;
+#else
+ KABC::DistributionList *list = mManager->list( mNameCombo->currentText() );
+ if ( !list )
+ return;
+ KABC::DistributionList& dist = *list;
+#endif
+
+ ContactItem *contactItem =
+ static_cast<ContactItem *>( mContactView->selectedItem() );
+ if ( !contactItem )
+ return;
+
+ bool canceled = false;
+ const QString email = EmailSelector::getEmail( contactItem->addressee().emails(),
+ contactItem->email(), this, canceled);
+ if( canceled)
+ return;
+ dist.removeEntry( contactItem->addressee(), contactItem->email() );
+ dist.insertEntry( contactItem->addressee(), email );
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+ core()->addressBook()->insertAddressee( dist );
+ changed( dist );
+#else
+ updateContactView();
+ changed();
+#endif
+}
+
+void DistributionListWidget::updateContactView()
+{
+ mContactView->clear();
+
+ bool isListSelected = false;
+#ifdef KDEPIM_NEW_DISTRLISTS
+ KPIM::DistributionList dist;
+ if ( mNameCombo->count() != 0 )
+ dist = KPIM::DistributionList::findByName(
+ core()->addressBook(), mNameCombo->currentText() );
+ isListSelected = !dist.isEmpty();
+#else
+ KABC::DistributionList *list = mManager->list( mNameCombo->currentText() );
+ isListSelected = list != 0;
+#endif
+ if ( !isListSelected ) {
+ mEditListButton->setEnabled( false );
+ mRemoveListButton->setEnabled( false );
+ mChangeEmailButton->setEnabled( false );
+ mRemoveContactButton->setEnabled( false );
+ mContactView->setEnabled( false );
+ return;
+ }
+ mEditListButton->setEnabled( true );
+ mRemoveListButton->setEnabled( true );
+ mContactView->setEnabled( true );
+
+ uint entryCount = 0;
+#ifdef KDEPIM_NEW_DISTRLISTS
+ const KPIM::DistributionList::Entry::List entries = dist.entries( core()->addressBook() );
+ KPIM::DistributionList::Entry::List::ConstIterator it;
+#else
+ const KABC::DistributionList::Entry::List entries = list->entries();
+ KABC::DistributionList::Entry::List::ConstIterator it;
+#endif
+ for ( it = entries.begin(); it != entries.end(); ++it, ++entryCount )
+ new ContactItem( mContactView, (*it).addressee, (*it).email );
+
+ bool state = mContactView->selectedItem() != 0;
+ mChangeEmailButton->setEnabled( state );
+ mRemoveContactButton->setEnabled( state );
+
+ mEntryCountLabel->setText( i18n( "Count: %n contact", "Count: %n contacts", entryCount ) );
+}
+
+void DistributionListWidget::updateNameCombo()
+{
+ int pos = mNameCombo->currentItem();
+ mNameCombo->clear();
+#ifdef KDEPIM_NEW_DISTRLISTS
+ const QStringList names = core()->distributionListNames();
+#else
+ mManager->load();
+ const QStringList names = mManager->listNames();
+#endif
+ mNameCombo->insertStringList( names );
+ mNameCombo->setCurrentItem( QMIN( pos, (int)names.count() - 1 ) );
+
+ updateContactView();
+}
+
+void DistributionListWidget::dropEvent( QDropEvent *e )
+{
+ if ( mNameCombo->count() == 0 )
+ return;
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+ KPIM::DistributionList dist = KPIM::DistributionList::findByName(
+ core()->addressBook(), mNameCombo->currentText() );
+ if ( dist.isEmpty() )
+ return;
+#else
+ KABC::DistributionList *list = mManager->list( mNameCombo->currentText() );
+ if ( !list )
+ return;
+ KABC::DistributionList& dist = *list;
+#endif
+
+ QString vcards;
+ if ( KVCardDrag::decode( e, vcards ) ) {
+ KABC::VCardConverter converter;
+ const KABC::Addressee::List lst = converter.parseVCards( vcards );
+ for ( KABC::Addressee::List::ConstIterator it = lst.begin(); it != lst.end(); ++it )
+ dist.insertEntry( *it );
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+ core()->addressBook()->insertAddressee( dist );
+ changed( dist );
+#else
+ changed();
+ updateContactView();
+#endif
+ }
+}
+
+void DistributionListWidget::contactsSelectionChanged()
+{
+ mAddContactButton->setEnabled( contactsSelected() && mNameCombo->count() > 0 );
+}
+
+QString DistributionListWidget::title() const
+{
+ return i18n( "Distribution List Editor" );
+}
+
+QString DistributionListWidget::identifier() const
+{
+ return "distribution_list_editor";
+}
+
+void DistributionListWidget::dropped( QDropEvent *e, QListViewItem* )
+{
+ dropEvent( e );
+}
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+void DistributionListWidget::changed( const KABC::Addressee& dist )
+{
+ emit modified( KABC::Addressee::List() << dist );
+}
+#else
+void DistributionListWidget::changed()
+{
+ save();
+}
+#endif
+
+DistributionListView::DistributionListView( QWidget *parent, const char* name )
+ : KListView( parent, name )
+{
+ setDragEnabled( true );
+ setAcceptDrops( true );
+ setAllColumnsShowFocus( true );
+}
+
+void DistributionListView::dragEnterEvent( QDragEnterEvent* e )
+{
+ bool canDecode = QTextDrag::canDecode( e );
+ e->accept( canDecode );
+}
+
+void DistributionListView::viewportDragMoveEvent( QDragMoveEvent *e )
+{
+ bool canDecode = QTextDrag::canDecode( e );
+ e->accept( canDecode );
+}
+
+void DistributionListView::viewportDropEvent( QDropEvent *e )
+{
+ emit dropped( e, 0 );
+}
+
+void DistributionListView::dropEvent( QDropEvent *e )
+{
+ emit dropped( e, 0 );
+}
+
+
+EmailSelector::EmailSelector( const QStringList &emails,
+ const QString &current, QWidget *parent )
+ : KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok|Cancel, Ok,
+ parent )
+{
+ QFrame *topFrame = plainPage();
+ QBoxLayout *topLayout = new QVBoxLayout( topFrame );
+
+ mButtonGroup = new QButtonGroup( 1, Horizontal, i18n("Email Addresses"),
+ topFrame );
+ mButtonGroup->setRadioButtonExclusive( true );
+ topLayout->addWidget( mButtonGroup );
+
+ QRadioButton *button = new QRadioButton( i18n("Preferred address"), mButtonGroup );
+ button->setDown( true );
+ mEmailMap.insert( mButtonGroup->id( button ), "" );
+
+ QStringList::ConstIterator it;
+ for ( it = emails.begin(); it != emails.end(); ++it ) {
+ button = new QRadioButton( *it, mButtonGroup );
+ mEmailMap.insert( mButtonGroup->id( button ), *it );
+ if ( (*it) == current )
+ button->setDown( true );
+ }
+}
+
+QString EmailSelector::selected() const
+{
+ QButton *button = mButtonGroup->selected();
+ if ( button )
+ return mEmailMap[ mButtonGroup->id( button ) ];
+
+ return QString::null;
+}
+
+QString EmailSelector::getEmail( const QStringList &emails,
+ const QString &current, QWidget *parent, bool &canceled )
+{
+ EmailSelector dlg( emails, current, parent );
+ if(dlg.exec())
+ {
+ canceled = false;
+ return dlg.selected();
+ }
+ canceled = true;
+ return QString();
+}
+
+
+#include "distributionlistwidget.moc"
diff --git a/kaddressbook/features/distributionlistwidget.h b/kaddressbook/features/distributionlistwidget.h
new file mode 100644
index 00000000..d52a06ab
--- /dev/null
+++ b/kaddressbook/features/distributionlistwidget.h
@@ -0,0 +1,140 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef DISTRIBUTIONLISTWIDGET_H
+#define DISTRIBUTIONLISTWIDGET_H
+
+#include <config.h> // for KDEPIM_NEW_DISTRLISTS
+#include <kdialogbase.h>
+#include <klistview.h>
+
+#include "extensionwidget.h"
+
+class QButtonGroup;
+class QComboBox;
+class QListView;
+
+class DistributionListView;
+
+namespace KAB {
+class Core;
+}
+
+namespace KABC {
+class AddressBook;
+class DistributionListManager;
+}
+
+class DistributionListWidget : public KAB::ExtensionWidget
+{
+ Q_OBJECT
+
+ public:
+ DistributionListWidget( KAB::Core*, QWidget *parent, const char *name = 0 );
+ virtual ~DistributionListWidget();
+
+ void contactsSelectionChanged();
+
+ QString title() const;
+ QString identifier() const;
+
+ public slots:
+ void save();
+ void dropped( QDropEvent*, QListViewItem* );
+
+ void removeContact();
+
+ private slots:
+ void createList();
+ void editList();
+ void removeList();
+ void addContact();
+ void changeEmail();
+ void updateNameCombo();
+ void updateContactView();
+ void selectionContactViewChanged();
+
+ private:
+#ifdef KDEPIM_NEW_DISTRLISTS
+ void changed( const KABC::Addressee& dist );
+#else
+ void changed();
+#endif
+ bool alreadyExists( const QString& distrListName ) const;
+
+ protected:
+ void dropEvent( QDropEvent* );
+
+ private:
+ QComboBox *mNameCombo;
+ QLabel *mEntryCountLabel;
+ DistributionListView *mContactView;
+
+#ifndef KDEPIM_NEW_DISTRLISTS
+ KABC::DistributionListManager *mManager;
+#endif
+ QPushButton *mCreateListButton;
+ QPushButton *mEditListButton;
+ QPushButton *mRemoveListButton;
+ QPushButton *mChangeEmailButton;
+ QPushButton *mAddContactButton;
+ QPushButton *mRemoveContactButton;
+};
+
+/**
+ @short Helper class
+*/
+class DistributionListView : public KListView
+{
+ Q_OBJECT
+
+ public:
+ DistributionListView( QWidget *parent, const char* name = 0 );
+
+ protected:
+ void dragEnterEvent( QDragEnterEvent *e );
+ void dropEvent( QDropEvent *e );
+ void viewportDragMoveEvent( QDragMoveEvent *e );
+ void viewportDropEvent( QDropEvent *e );
+};
+
+/**
+ @short Helper class
+*/
+class EmailSelector : public KDialogBase
+{
+ public:
+ EmailSelector( const QStringList &emails, const QString &current,
+ QWidget *parent );
+
+ QString selected() const;
+
+ static QString getEmail( const QStringList &emails, const QString &current,
+ QWidget *parent, bool &canceled );
+
+ private:
+ QButtonGroup *mButtonGroup;
+ QMap<int, QString> mEmailMap;
+};
+
+#endif
diff --git a/kaddressbook/features/resourceselection.cpp b/kaddressbook/features/resourceselection.cpp
new file mode 100644
index 00000000..c7e89dbf
--- /dev/null
+++ b/kaddressbook/features/resourceselection.cpp
@@ -0,0 +1,421 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qtimer.h>
+#include <qlabel.h>
+#include <qheader.h>
+#include <qtooltip.h>
+
+#include <kabc/resource.h>
+#include <kdialog.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <kinputdialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kresources/configdialog.h>
+
+#include "core.h"
+
+#include "resourceselection.h"
+#include <libkdepim/resourceabc.h>
+
+class AddressBookWrapper : public KABC::AddressBook
+{
+ public:
+ AddressBookWrapper( KABC::AddressBook* );
+
+ KRES::Manager<KABC::Resource>* getResourceManager()
+ {
+ return resourceManager();
+ }
+};
+
+class ResourceItem : public QCheckListItem
+{
+ public:
+ ResourceItem( KListView *parent, KABC::Resource *resource )
+ : QCheckListItem( parent, resource->resourceName(), CheckBox ),
+ mResource( resource ), mChecked( false ),
+ mIsSubresource( false ), mSubItemsCreated( false ),
+ mResourceIdentifier()
+ {
+ setOn( resource->isActive() );
+ setPixmap( 0, KGlobal::iconLoader()->loadIcon( "contents", KIcon::Small ) );
+ mChecked = isOn();
+ }
+
+ ResourceItem( KPIM::ResourceABC *resourceABC, ResourceItem* parent,
+ const QString& resourceIdent )
+ : QCheckListItem( parent, resourceABC->subresourceLabel( resourceIdent ), CheckBox ),
+ mResource( resourceABC ), mChecked( false ),
+ mIsSubresource( true ), mSubItemsCreated( false ),
+ mResourceIdentifier( resourceIdent )
+ {
+ KPIM::ResourceABC* res = dynamic_cast<KPIM::ResourceABC *>( mResource );
+ setOn( res->subresourceActive( mResourceIdentifier ) );
+ setPixmap( 0, KGlobal::iconLoader()->loadIcon( "contents", KIcon::Small ) );
+ mChecked = isOn();
+ }
+
+ void createSubresourceItems();
+
+ void setChecked( bool state ) { mChecked = state; }
+ bool checked() const { return mChecked; }
+ KABC::Resource *resource() const { return mResource; }
+ QString resourceIdentifier() const { return mResourceIdentifier; }
+ bool isSubResource() const { return mIsSubresource; }
+
+ virtual void stateChange( bool active );
+
+ private:
+ KABC::Resource * const mResource;
+ bool mChecked;
+ const bool mIsSubresource;
+ bool mSubItemsCreated;
+ const QString mResourceIdentifier;
+};
+
+// Comes from korganizer/resourceview.cpp
+void ResourceItem::createSubresourceItems()
+{
+ KPIM::ResourceABC* res = dynamic_cast<KPIM::ResourceABC *>( mResource );
+ QStringList subresources;
+ if ( res )
+ subresources = res->subresources();
+ if ( !subresources.isEmpty() ) {
+ setOpen( true );
+ setExpandable( true );
+ // This resource has subresources
+ QStringList::ConstIterator it;
+ for ( it = subresources.begin(); it != subresources.end(); ++it ) {
+ (void)new ResourceItem( res, this, *it );
+ }
+ }
+ mSubItemsCreated = true;
+}
+
+// TODO: connect this to some signalResourceModified
+// void ResourceItem::setGuiState()
+// {
+// if ( mIsSubresource )
+// setOn( mResource->subresourceActive( mResourceIdentifier ) );
+// else
+// setOn( mResource->isActive() );
+// }
+
+void ResourceItem::stateChange( bool active )
+{
+ //kdDebug(5720) << k_funcinfo << this << " " << text( 0 ) << " active=" << active << endl;
+ if ( active && !mIsSubresource ) {
+ if ( !mSubItemsCreated )
+ createSubresourceItems();
+ }
+
+ setOpen( active && childCount() > 0 );
+}
+
+////
+
+ResourceSelection::ResourceSelection( KAB::Core *core, QWidget *parent, const char *name )
+ : KAB::ExtensionWidget( core, parent, name ), mManager( 0 )
+{
+ initGUI();
+
+ AddressBookWrapper *wrapper = static_cast<AddressBookWrapper*>( core->addressBook() );
+ mManager = wrapper->getResourceManager();
+
+ connect( mAddButton, SIGNAL( clicked() ), SLOT( add() ) );
+ connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) );
+ connect( mRemoveButton, SIGNAL( clicked() ), SLOT( remove() ) );
+
+ connect( mListView, SIGNAL( clicked( QListViewItem* ) ),
+ SLOT( currentChanged( QListViewItem* ) ) );
+
+ QTimer::singleShot( 0, this, SLOT( updateView() ) );
+}
+
+ResourceSelection::~ResourceSelection()
+{
+}
+
+QString ResourceSelection::title() const
+{
+ return i18n( "Address Books" );
+}
+
+QString ResourceSelection::identifier() const
+{
+ return "resourceselection";
+}
+
+void ResourceSelection::add()
+{
+ QStringList types = mManager->resourceTypeNames();
+ QStringList descs = mManager->resourceTypeDescriptions();
+
+ bool ok = false;
+ QString desc = KInputDialog::getItem( i18n( "Add Address Book" ),
+ i18n( "Please select type of the new address book:" ),
+ descs, 0, false, &ok, this );
+ if ( !ok )
+ return;
+
+ QString type = types[ descs.findIndex( desc ) ];
+
+ // Create new resource
+ KABC::Resource *resource = mManager->createResource( type );
+ if ( !resource ) {
+ KMessageBox::error( this, i18n("<qt>Unable to create an address book of type <b>%1</b>.</qt>")
+ .arg( type ) );
+ return;
+ }
+
+ resource->setResourceName( i18n( "%1 address book" ).arg( type ) );
+ resource->setAddressBook(core()->addressBook());
+
+ KRES::ConfigDialog dlg( this, QString( "contact" ), resource );
+
+ if ( dlg.exec() ) {
+ core()->addressBook()->addResource( resource );
+ resource->asyncLoad();
+
+ mLastResource = resource->identifier();
+ updateView();
+ } else {
+ delete resource;
+ resource = 0;
+ }
+}
+
+void ResourceSelection::edit()
+{
+ ResourceItem *item = selectedItem();
+ if ( !item )
+ return;
+
+ KRES::ConfigDialog dlg( this, QString( "contact" ), item->resource() );
+
+ if ( dlg.exec() ) {
+ mManager->change( item->resource() );
+ item->resource()->asyncLoad();
+
+ mLastResource = item->resource()->identifier();
+ updateView();
+ }
+}
+
+void ResourceSelection::remove()
+{
+ ResourceItem *item = selectedItem();
+ if ( !item )
+ return;
+
+ int result = KMessageBox::warningContinueCancel( this,
+ i18n( "<qt>Do you really want to remove the address book <b>%1</b>?</qt>" )
+ .arg( item->resource()->resourceName() ), "",
+ KGuiItem( i18n( "&Remove" ), "editdelete" ) );
+ if ( result == KMessageBox::Cancel )
+ return;
+
+ mLastResource = item->resource()->identifier();
+
+ core()->addressBook()->removeResource( item->resource() );
+ core()->addressBook()->emitAddressBookChanged();
+
+ updateView();
+}
+
+void ResourceSelection::currentChanged( QListViewItem *item )
+{
+ ResourceItem *resItem = static_cast<ResourceItem*>( item );
+ bool state = (resItem && !resItem->isSubResource() );
+
+ mEditButton->setEnabled( state );
+ mRemoveButton->setEnabled( state );
+
+ if ( !resItem )
+ return;
+
+ KABC::Resource *resource = resItem->resource();
+
+ if ( resItem->checked() != resItem->isOn() ) {
+ resItem->setChecked( resItem->isOn() );
+ if ( resItem->isSubResource() ) {
+ KPIM::ResourceABC *res = dynamic_cast<KPIM::ResourceABC *>( resource );
+ res->setSubresourceActive( resItem->resourceIdentifier(), resItem->isOn() );
+ mManager->change( resource );
+ } else {
+ resource->setActive( resItem->isOn() );
+ mManager->change( resource );
+
+ if ( resItem->checked() ) {
+ if ( !resource->addressBook() )
+ resource->setAddressBook( core()->addressBook() );
+
+ if ( !resource->isOpen() )
+ resource->open();
+
+ resource->asyncLoad();
+ } else {
+ resource->close();
+ }
+ }
+
+ mLastResource = resource->identifier();
+ core()->addressBook()->emitAddressBookChanged();
+ //updateView();
+ }
+}
+
+void ResourceSelection::updateView()
+{
+ if ( !mManager )
+ return;
+
+ mListView->clear();
+
+ KRES::Manager<KABC::Resource>::Iterator it;
+ for ( it = mManager->begin(); it != mManager->end(); ++it ) {
+
+ new ResourceItem( mListView, *it );
+ KPIM::ResourceABC* resource = dynamic_cast<KPIM::ResourceABC *>( *it );
+ if ( resource ) {
+ disconnect( resource, 0, this, 0 );
+ connect( resource, SIGNAL( signalSubresourceAdded( KPIM::ResourceABC *,
+ const QString &, const QString & ) ),
+ SLOT( slotSubresourceAdded( KPIM::ResourceABC *,
+ const QString &, const QString & ) ) );
+
+ connect( resource, SIGNAL( signalSubresourceRemoved( KPIM::ResourceABC *,
+ const QString &, const QString & ) ),
+ SLOT( slotSubresourceRemoved( KPIM::ResourceABC *,
+ const QString &, const QString & ) ) );
+ //connect( resource, SIGNAL( resourceSaved( KPIM::ResourceABC * ) ),
+ // SLOT( closeResource( KPIM::ResourceABC * ) ) );
+ }
+ }
+
+ QListViewItemIterator itemIt( mListView );
+ while ( itemIt.current() ) {
+ ResourceItem *item = static_cast<ResourceItem*>( itemIt.current() );
+ if ( item->resource()->identifier() == mLastResource ) {
+ mListView->setSelected( item, true );
+ mListView->ensureItemVisible( item );
+ break;
+ }
+ ++itemIt;
+ }
+
+ core()->addressBook()->emitAddressBookChanged();
+}
+
+
+// Add a new entry
+void ResourceSelection::slotSubresourceAdded( KPIM::ResourceABC *resource,
+ const QString& /*type*/,
+ const QString& subResource )
+{
+ kdDebug(5720) << k_funcinfo << resource->resourceName() << " " << subResource << endl;
+ QListViewItem *i = mListView->findItem( resource->resourceName(), 0 );
+ if ( !i )
+ // Not found
+ return;
+
+ ResourceItem *item = static_cast<ResourceItem *>( i );
+ (void)new ResourceItem( resource, item, subResource );
+}
+
+// Remove an entry
+void ResourceSelection::slotSubresourceRemoved( KPIM::ResourceABC* resource,
+ const QString& /*type*/,
+ const QString& subResource )
+{
+ core()->addressBook()->emitAddressBookChanged();
+ updateView();
+}
+
+ResourceItem* ResourceSelection::selectedItem() const
+{
+ return static_cast<ResourceItem*>( mListView->selectedItem() );
+}
+
+void ResourceSelection::initGUI()
+{
+ QBoxLayout *topLayout = new QVBoxLayout( this );
+ topLayout->setSpacing( KDialog::spacingHint() );
+
+ QBoxLayout *buttonLayout = new QHBoxLayout();
+ buttonLayout->setSpacing( KDialog::spacingHint() );
+ topLayout->addLayout( buttonLayout );
+
+ QLabel *abLabel = new QLabel( i18n( "Address Books" ), this );
+ buttonLayout->addWidget( abLabel );
+ buttonLayout->addStretch( 1 );
+
+ mAddButton = new QPushButton( this );
+ mAddButton->setIconSet( SmallIconSet( "add" ) );
+ QToolTip::add( mAddButton, i18n( "Add addressbook" ) );
+ buttonLayout->addWidget( mAddButton );
+ mEditButton = new QPushButton( this );
+ mEditButton->setIconSet( SmallIconSet( "edit" ) );
+ mEditButton->setEnabled( false );
+ QToolTip::add( mEditButton, i18n( "Edit addressbook settings" ) );
+ buttonLayout->addWidget( mEditButton );
+ mRemoveButton = new QPushButton( this );
+ mRemoveButton->setIconSet( SmallIconSet( "remove" ) );
+ mRemoveButton->setEnabled( false );
+ QToolTip::add( mRemoveButton, i18n( "Remove addressbook" ) );
+ buttonLayout->addWidget( mRemoveButton );
+
+ mListView = new KListView( this );
+ mListView->header()->hide();
+ mListView->addColumn( i18n( "Address Books" ) );
+ mListView->setFullWidth( true );
+ topLayout->addWidget( mListView );
+}
+
+class ResourceSelectionFactory : public KAB::ExtensionFactory
+{
+ public:
+ KAB::ExtensionWidget *extension( KAB::Core *core, QWidget *parent, const char *name )
+ {
+ return new ResourceSelection( core, parent, name );
+ }
+
+ QString identifier() const
+ {
+ return "resourceselection";
+ }
+};
+
+extern "C" {
+ void *init_libkaddrbk_resourceselection()
+ {
+ return ( new ResourceSelectionFactory );
+ }
+}
+
+#include "resourceselection.moc"
diff --git a/kaddressbook/features/resourceselection.desktop b/kaddressbook/features/resourceselection.desktop
new file mode 100644
index 00000000..4879e939
--- /dev/null
+++ b/kaddressbook/features/resourceselection.desktop
@@ -0,0 +1,110 @@
+[Desktop Entry]
+X-KDE-Library=libkaddrbk_resourceselection
+Name=Address Book Management Plugin
+Name[af]=Adres boek bestuur inprop module
+Name[be]=Дапаўненне "Кіраванне адраснамі кнігамі"
+Name[bg]=Приставка за управление на адресника
+Name[br]=Lugent melestradur ar c'harnedoù chomlec'hioù
+Name[bs]=Dodatak za rukovanje adresarom
+Name[ca]=Endollable de gestió de llibretes d'adreces
+Name[cs]=Modul pro správu knih adres
+Name[da]=Plugin for adressebogshåndtering
+Name[de]=Adressbuchverwaltungs-Modul
+Name[el]=Πρόσθετο διαχείρισης βιβλίου διευθύνσεων
+Name[eo]=Adresar-administra kromaĵo
+Name[es]=Extensión para gestionar la libreta de direcciones
+Name[et]=Aadressihalduri plugin
+Name[eu]=Helbide-liburu kudeaketa plugin-a
+Name[fa]=وصلۀ مدیریت کتاب نشانی
+Name[fi]=Osoitekirjan ylläpidon laajennus
+Name[fr]=Module de gestion de carnet d'adresses
+Name[fy]=Plugin foar adresboekbehear
+Name[ga]=Breiseán Bhainisteoireacht Leabhar na Seoltaí
+Name[gl]=Extensión para xestión do Caderno de Enderezos
+Name[he]=תוסף מנהל הכתובות
+Name[hu]=Címjegyzékkezelő bővítőmodul
+Name[is]=Umsjónaríforrit vistfangaflettis
+Name[it]=Plugin per gestire rubriche indirizzi
+Name[ja]=アドレス帳管理プラグイン
+Name[ka]=წიგნაკის მართვის მოდული
+Name[kk]=Адрестік кітапшамен айналысу плагин модулі
+Name[km]=កម្មវិធី​ជំនួយ​ការ​គ្រប់គ្រង​សៀវភៅ​អាសយដ្ឋាន
+Name[lt]=Adresų knygelės tvarkymo priedas
+Name[mk]=Приклучок за менаџирање адресари
+Name[ms]=Plugin Pengurusan Buku Alamat
+Name[nb]=Programtillegg for adressebok behandling
+Name[nds]=Adressbookpleeg-Moduul
+Name[ne]=ठेगाना पुस्तिका व्यवस्थापन प्लगइन
+Name[nl]=Plugin voor adresboekbeheer
+Name[nn]=Programtillegg for adressebokhandtering
+Name[pl]=Wtyczka zarządzania Książką adresową
+Name[pt]='Plugin' de Gestão do Livro de Endereços
+Name[pt_BR]=Plug-in de Gerenciamento do Livro de Endereços
+Name[ru]=Управление адресной книгой
+Name[se]=Lassemoduvla mii gieđáhalla čujuhusgirjjiid
+Name[sk]=Modul pre správu adresára
+Name[sl]=Vstavek Upravitelj adresarjev
+Name[sr]=Прикључак управљања адресаром
+Name[sr@Latn]=Priključak upravljanja adresarom
+Name[sv]=Insticksprogram för adressbokshantering
+Name[ta]=முகவரி புத்தகம் மேலாண்மை சொருகுப்பொருள்
+Name[tg]=Идоракунии китоби адресӣ
+Name[tr]=Adres Defteri Düzenleme Eklentisi
+Name[uk]=Втулок для керування адресною книгою
+Name[zh_CN]=地址簿管理插件
+Name[zh_TW]=管理通訊錄外掛程式
+Comment=Plugin for managing address books
+Comment[af]=Inprop module om adres boeke te bestuur
+Comment[be]=Дапаўненне для кіравання адраснамі кнігамі
+Comment[bg]=Приставка за управление на адресника
+Comment[br]=Lugent melestradur ar c'harnedoù chomlec'hioù
+Comment[bs]=Dodatak za upravljanje adresarima
+Comment[ca]=Endollable per gestionar llibretes d'adreces
+Comment[cs]=Modul pro správu knih adres
+Comment[da]=Plugin til at håndtere adressebøger
+Comment[de]=Modul zur Verwaltung von Adressbüchern
+Comment[el]=Πρόσθετο για τη διαχείριση βιβλίων διευθύνσεων
+Comment[eo]=Kromaĵo por administri ddresarojn
+Comment[es]=Extenxión para gestionar libretas de direcciones
+Comment[et]=Plugin aadressiraamatute haldamiseks
+Comment[eu]=Helbide-liburuak kudeatzeko plugin-a
+Comment[fa]=وصله برای مدیریت کتابهای نشانی
+Comment[fi]=Osoitekirjojen ylläpidon laajennus
+Comment[fr]=Module pour gérer les carnets d'adresses
+Comment[fy]=Plugin foar it behearen fan adresboeken
+Comment[gl]=Extensión para xestionar cadernos de enderezos
+Comment[he]=תוסף לניהול פנקסי כתובות
+Comment[hu]=Bővítőmodul címjegyzékek kezeléséhez
+Comment[is]=Íforrit til að sjá um vistfangaskrár
+Comment[it]=Plugin per gestire rubriche indirizzi
+Comment[ja]=アドレス帳管理用プラグイン
+Comment[ka]=წიგნაკის მართვის მოდული
+Comment[kk]=Адрестік кітапшамен айналысу плагин модулі
+Comment[km]=កម្មវិធី​ជំនួយ​ដើម្បី​គ្រប់គ្រង​សៀវភៅ​អាសយដ្ឋាន
+Comment[lt]=Priedas adresų knygelių tvarkymui
+Comment[mk]=Приклучок за менаџирање адресари
+Comment[ms]=Plugin untuk pengurusan buku alamat
+Comment[nb]=Programtillegg for å håndtere adressebøker
+Comment[nds]=Moduul för't Plegen vun Adressböker
+Comment[ne]=ठगाना पुस्तिका व्यवस्थापनका लागि प्लगइन
+Comment[nl]=Plugin voor het beheren van adresboeken
+Comment[nn]=Programtillegg for handtering av adressebøker
+Comment[pl]=Wtyczka do zarządzania książkami adresowymi
+Comment[pt]=Um 'plugin' para gerir os livros de endereços
+Comment[pt_BR]=Plug-in para gerenciar livros de endereços
+Comment[ru]=Управление адресными книгами
+Comment[se]=Lassemoduvla mii gieđahallá čujuhusgirjjiid
+Comment[sk]=Modul pre správu adresárov
+Comment[sl]=Vstavek za upravljanje adresarjev
+Comment[sr]=Прикључак за управљање адресарима
+Comment[sr@Latn]=Priključak za upravljanje adresarima
+Comment[sv]=Insticksprogram för att hantera adressböcker
+Comment[ta]=பகிர்தல் பட்டியல் நிர்வகித்தலின் சொருகுப்பொருள்
+Comment[tg]=Идоракунии китобҳои адресӣ
+Comment[tr]=Adres defteterini düzenlemek için eklenti
+Comment[uk]=Втулок для керування адресними книгами
+Comment[zh_CN]=管理地址簿的插件
+Comment[zh_TW]=管理通訊錄外掛程式
+Type=Service
+ServiceTypes=KAddressBook/Extension
+X-KDE-KAddressBook-ExtensionPluginVersion=1
diff --git a/kaddressbook/features/resourceselection.h b/kaddressbook/features/resourceselection.h
new file mode 100644
index 00000000..07c458f3
--- /dev/null
+++ b/kaddressbook/features/resourceselection.h
@@ -0,0 +1,81 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef RESOURCESELECTION_H
+#define RESOURCESELECTION_H
+
+#include <klistview.h>
+
+#include "extensionwidget.h"
+
+class QListViewItem;
+class QPushButton;
+
+namespace KPIM { class ResourceABC; }
+
+class ResourceItem;
+
+class ResourceSelection : public KAB::ExtensionWidget
+{
+ Q_OBJECT
+
+ public:
+ ResourceSelection( KAB::Core*, QWidget *parent, const char *name );
+ virtual ~ResourceSelection();
+
+ QString title() const;
+ QString identifier() const;
+
+ void contactsSelectionChanged() {};
+
+ private slots:
+ void add();
+ void edit();
+ void remove();
+ void currentChanged( QListViewItem* );
+
+ void updateView();
+
+ void slotSubresourceAdded( KPIM::ResourceABC *resource,
+ const QString& /*type*/,
+ const QString& subResource );
+ void slotSubresourceRemoved( KPIM::ResourceABC* /*resource*/,
+ const QString& /*type*/,
+ const QString& subResource );
+
+ private:
+ void initGUI();
+
+ ResourceItem* selectedItem() const;
+
+ KListView *mListView;
+ QPushButton *mAddButton;
+ QPushButton *mEditButton;
+ QPushButton *mRemoveButton;
+
+ QString mLastResource;
+
+ KRES::Manager<KABC::Resource> *mManager;
+};
+
+#endif
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp
new file mode 100644
index 00000000..40c0f077
--- /dev/null
+++ b/kaddressbook/filtereditdialog.cpp
@@ -0,0 +1,279 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qbuttongroup.h>
+#include <qhbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qregexp.h>
+#include <qstring.h>
+#include <qtoolbutton.h>
+#include <qtooltip.h>
+#include <qwidget.h>
+
+#include <kapplication.h>
+#include <kbuttonbox.h>
+#include <kdebug.h>
+#include <kiconloader.h>
+#include <klineedit.h>
+#include <klistbox.h>
+#include <klistview.h>
+#include <klocale.h>
+
+#include "kabprefs.h"
+#include "filtereditdialog.h"
+
+FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name )
+ : KDialogBase( Plain, i18n( "Edit Address Book Filter" ),
+ Help | Ok | Cancel, Ok, parent, name, false, true )
+{
+ initGUI();
+
+ const QStringList cats = KABPrefs::instance()->customCategories();
+
+ QStringList::ConstIterator it;
+ for ( it = cats.begin(); it != cats.end(); ++it )
+ mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox ) );
+
+ filterNameTextChanged( mNameEdit->text() );
+}
+
+FilterEditDialog::~FilterEditDialog()
+{
+}
+
+void FilterEditDialog::setFilter( const Filter &filter )
+{
+ mNameEdit->setText( filter.name() );
+
+ QStringList categories = filter.categories();
+ QListViewItem *item = mCategoriesView->firstChild();
+ while ( item != 0 ) {
+ if ( categories.contains( item->text( 0 ) ) ) {
+ QCheckListItem *checkItem = static_cast<QCheckListItem*>( item );
+ checkItem->setOn( true );
+ }
+
+ item = item->nextSibling();
+ }
+
+ if ( filter.matchRule() == Filter::Matching )
+ mMatchRuleGroup->setButton( 0 );
+ else
+ mMatchRuleGroup->setButton( 1 );
+}
+
+Filter FilterEditDialog::filter()
+{
+ Filter filter;
+
+ filter.setName( mNameEdit->text() );
+
+ QStringList categories;
+ QListViewItem *item = mCategoriesView->firstChild();
+ while ( item != 0 ) {
+ QCheckListItem *checkItem = static_cast<QCheckListItem*>( item );
+ if ( checkItem->isOn() )
+ categories.append( item->text( 0 ) );
+
+ item = item->nextSibling();
+ }
+ filter.setCategories( categories );
+
+ if ( mMatchRuleGroup->find( 0 )->isOn() )
+ filter.setMatchRule( Filter::Matching );
+ else
+ filter.setMatchRule( Filter::NotMatching );
+
+ return filter;
+}
+
+void FilterEditDialog::initGUI()
+{
+ resize( 490, 300 );
+
+ QWidget *page = plainPage();
+ QLabel *label;
+
+ QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() );
+
+ label = new QLabel( i18n( "Name:" ), page );
+ mNameEdit = new KLineEdit( page );
+ mNameEdit->setFocus();
+ topLayout->addWidget( label, 0, 0 );
+ topLayout->addWidget( mNameEdit, 0, 1 );
+ connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( filterNameTextChanged( const QString&) ) );
+
+ mCategoriesView = new KListView( page );
+ mCategoriesView->addColumn( i18n( "Category" ) );
+ mCategoriesView->setFullWidth( true );
+ topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 );
+
+ mMatchRuleGroup = new QButtonGroup( page );
+ mMatchRuleGroup->setExclusive( true );
+
+ QBoxLayout *gbLayout = new QVBoxLayout( mMatchRuleGroup );
+ gbLayout->setSpacing( KDialog::spacingHint() );
+ gbLayout->setMargin( KDialog::marginHint() );
+
+ QRadioButton *radio = new QRadioButton( i18n( "Show only contacts matching the selected categories" ), mMatchRuleGroup );
+ radio->setChecked( true );
+ mMatchRuleGroup->insert( radio );
+ gbLayout->addWidget( radio );
+
+ radio = new QRadioButton( i18n( "Show all contacts except those matching the selected categories" ), mMatchRuleGroup );
+ mMatchRuleGroup->insert( radio );
+ gbLayout->addWidget( radio );
+
+ topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 );
+}
+
+void FilterEditDialog::filterNameTextChanged( const QString &text )
+{
+ enableButtonOK( !text.isEmpty() );
+}
+
+void FilterEditDialog::slotHelp()
+{
+ kapp->invokeHelp( "using-filters" );
+}
+
+FilterDialog::FilterDialog( QWidget *parent, const char *name )
+ : KDialogBase( Plain, i18n( "Edit Address Book Filters" ),
+ Ok | Cancel, Ok, parent, name, false, true )
+{
+ initGUI();
+}
+
+FilterDialog::~FilterDialog()
+{
+}
+
+void FilterDialog::setFilters( const Filter::List &list )
+{
+ mFilterList.clear();
+ mInternalFilterList.clear();
+
+ Filter::List::ConstIterator it;
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ if ( (*it).isInternal() )
+ mInternalFilterList.append( *it );
+ else
+ mFilterList.append( *it );
+ }
+
+ refresh();
+}
+
+Filter::List FilterDialog::filters() const
+{
+ Filter::List list = mFilterList + mInternalFilterList;
+ return list;
+}
+
+void FilterDialog::add()
+{
+ FilterEditDialog dlg( this );
+
+ if ( dlg.exec() )
+ mFilterList.append( dlg.filter() );
+
+ refresh();
+
+ mFilterListBox->setCurrentItem( mFilterListBox->count() - 1 );
+}
+
+void FilterDialog::edit()
+{
+ FilterEditDialog dlg( this );
+
+ uint pos = mFilterListBox->currentItem();
+
+ dlg.setFilter( mFilterList[ pos ] );
+
+ if ( dlg.exec() ) {
+ mFilterList.remove( mFilterList.at( pos ) );
+ mFilterList.insert( mFilterList.at( pos ), dlg.filter() );
+ }
+
+ refresh();
+
+ mFilterListBox->setCurrentItem( pos );
+}
+
+void FilterDialog::remove()
+{
+ mFilterList.remove( mFilterList.at( mFilterListBox->currentItem() ) );
+
+ selectionChanged( 0 );
+
+ refresh();
+}
+
+void FilterDialog::refresh()
+{
+ mFilterListBox->clear();
+
+ Filter::List::ConstIterator it;
+ for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
+ mFilterListBox->insertItem( (*it).name() );
+}
+
+void FilterDialog::selectionChanged( QListBoxItem *item )
+{
+ bool state = ( item != 0 );
+
+ mEditButton->setEnabled( state );
+ mRemoveButton->setEnabled( state );
+}
+
+void FilterDialog::initGUI()
+{
+ resize( 330, 200 );
+
+ QWidget *page = plainPage();
+
+ QGridLayout *topLayout = new QGridLayout( page, 1, 2, 0, spacingHint() );
+
+ mFilterListBox = new KListBox( page );
+ topLayout->addWidget( mFilterListBox, 0, 0 );
+ connect( mFilterListBox, SIGNAL( selectionChanged( QListBoxItem * ) ),
+ SLOT( selectionChanged( QListBoxItem * ) ) );
+ connect( mFilterListBox, SIGNAL( doubleClicked ( QListBoxItem * ) ),
+ SLOT( edit() ) );
+
+ KButtonBox *buttonBox = new KButtonBox( page, Vertical );
+ buttonBox->addButton( i18n( "&Add..." ), this, SLOT( add() ) );
+ mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( edit() ) );
+ mEditButton->setEnabled( false );
+ mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( remove() ) );
+ mRemoveButton->setEnabled( false );
+
+ buttonBox->layout();
+ topLayout->addWidget( buttonBox, 0, 1 );
+}
+
+#include "filtereditdialog.moc"
diff --git a/kaddressbook/filtereditdialog.h b/kaddressbook/filtereditdialog.h
new file mode 100644
index 00000000..b61c36ca
--- /dev/null
+++ b/kaddressbook/filtereditdialog.h
@@ -0,0 +1,96 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef FILTEREDITDIALOG_H
+#define FILTEREDITDIALOG_H
+
+class QButtonGroup;
+class QString;
+class QToolButton;
+class QWidget;
+
+class KLineEdit;
+class KListBox;
+class KListView;
+
+#include <kdialogbase.h>
+
+#include "filter.h"
+
+class FilterDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ FilterDialog( QWidget *parent, const char *name = 0 );
+ ~FilterDialog();
+
+ void setFilters( const Filter::List &list );
+ Filter::List filters() const;
+
+ protected slots:
+ void add();
+ void edit();
+ void remove();
+ void selectionChanged( QListBoxItem* );
+
+ private:
+ void initGUI();
+ void refresh();
+
+ Filter::List mFilterList;
+ Filter::List mInternalFilterList;
+
+ KListBox *mFilterListBox;
+ QPushButton *mAddButton;
+ QPushButton *mEditButton;
+ QPushButton *mRemoveButton;
+};
+
+class FilterEditDialog : public KDialogBase
+{
+ Q_OBJECT
+ public:
+ FilterEditDialog( QWidget *parent, const char *name = 0 );
+ ~FilterEditDialog();
+
+ void setFilter( const Filter &filter );
+ Filter filter();
+
+ protected slots:
+ void filterNameTextChanged( const QString& );
+ void slotHelp();
+
+ private:
+ void initGUI();
+
+ Filter mFilter;
+
+ KLineEdit *mNameEdit;
+ KListView *mCategoriesView;
+ QButtonGroup *mMatchRuleGroup;
+ QPushButton *mEditButton;
+ QPushButton *mRemoveButton;
+};
+
+#endif
diff --git a/kaddressbook/filterselectionwidget.cpp b/kaddressbook/filterselectionwidget.cpp
new file mode 100644
index 00000000..ddd4fa2f
--- /dev/null
+++ b/kaddressbook/filterselectionwidget.cpp
@@ -0,0 +1,65 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qlabel.h>
+
+#include <kcombobox.h>
+#include <kdialog.h>
+#include <klocale.h>
+
+#include "filterselectionwidget.h"
+
+FilterSelectionWidget::FilterSelectionWidget( QWidget *parent, const char *name )
+ : QHBox( parent, name )
+{
+ setSpacing( KDialog::spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "Filter:" ), this, "kde toolbar widget" );
+
+ mFilterCombo = new KComboBox( this );
+ label->setBuddy( mFilterCombo );
+ connect( mFilterCombo, SIGNAL( activated( int ) ),
+ this, SIGNAL( filterActivated( int ) ) );
+}
+
+FilterSelectionWidget::~FilterSelectionWidget()
+{
+}
+
+int FilterSelectionWidget::currentItem() const
+{
+ return mFilterCombo->currentItem();
+}
+
+void FilterSelectionWidget::setCurrentItem( int index )
+{
+ mFilterCombo->setCurrentItem( index );
+}
+
+void FilterSelectionWidget::setItems( const QStringList &names )
+{
+ mFilterCombo->clear();
+ mFilterCombo->insertStringList( names );
+}
+
+#include "filterselectionwidget.moc"
diff --git a/kaddressbook/filterselectionwidget.h b/kaddressbook/filterselectionwidget.h
new file mode 100644
index 00000000..fcae42fc
--- /dev/null
+++ b/kaddressbook/filterselectionwidget.h
@@ -0,0 +1,56 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef FILTERSELECTIONWIDGET_H
+#define FILTERSELECTIONWIDGET_H
+
+#include <qhbox.h>
+
+class KComboBox;
+
+/**
+ A simple widget which consists of a label and a combo box in a
+ horizontal line. The combo box allows the user to select the active
+ filter.
+ */
+class FilterSelectionWidget : public QHBox
+{
+ Q_OBJECT
+
+ public:
+ FilterSelectionWidget( QWidget *parent, const char *name = 0 );
+ ~FilterSelectionWidget();
+
+ void setItems( const QStringList &names );
+
+ int currentItem() const;
+ void setCurrentItem( int index );
+
+ signals:
+ void filterActivated( int );
+
+ private:
+ KComboBox *mFilterCombo;
+};
+
+#endif
diff --git a/kaddressbook/freebusywidget.cpp b/kaddressbook/freebusywidget.cpp
new file mode 100644
index 00000000..d06a0ebd
--- /dev/null
+++ b/kaddressbook/freebusywidget.cpp
@@ -0,0 +1,78 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qlabel.h>
+#include <qlayout.h>
+
+#include <kdialog.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+
+#include <libkcal/freebusyurlstore.h>
+
+#include "freebusywidget.h"
+
+FreeBusyWidget::FreeBusyWidget( KABC::AddressBook *ab, QWidget *parent, const char *name )
+ : KAB::ContactEditorWidget( ab, parent, name )
+{
+ QHBoxLayout *layout = new QHBoxLayout( this, KDialog::marginHint(),
+ KDialog::spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "Location of Free/Busy information:" ), this );
+ layout->addWidget( label );
+
+ mURL = new KURLRequester( this );
+ label->setBuddy( mURL );
+ layout->addWidget( mURL );
+
+ connect( mURL, SIGNAL( textChanged( const QString& ) ),
+ this, SLOT( setModified() ) );
+}
+
+FreeBusyWidget::~FreeBusyWidget()
+{
+}
+
+void FreeBusyWidget::loadContact( KABC::Addressee *addr )
+{
+ if ( addr->preferredEmail().isEmpty() )
+ return;
+
+ mURL->setURL( KCal::FreeBusyUrlStore::self()->readUrl( addr->preferredEmail() ) );
+}
+
+void FreeBusyWidget::storeContact( KABC::Addressee *addr )
+{
+ if ( addr->preferredEmail().isEmpty() )
+ return;
+
+ KCal::FreeBusyUrlStore::self()->writeUrl( addr->preferredEmail(), mURL->url() );
+ KCal::FreeBusyUrlStore::self()->sync();
+}
+
+void FreeBusyWidget::setReadOnly( bool readOnly )
+{
+ mURL->setEnabled( !readOnly );
+}
+
+#include "freebusywidget.moc"
diff --git a/kaddressbook/freebusywidget.h b/kaddressbook/freebusywidget.h
new file mode 100644
index 00000000..99d32320
--- /dev/null
+++ b/kaddressbook/freebusywidget.h
@@ -0,0 +1,61 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef FREEBUSYWIDGET_H
+#define FREEBUSYWIDGET_H
+
+#include <kurlrequester.h>
+
+#include "contacteditorwidget.h"
+
+class FreeBusyWidget : public KAB::ContactEditorWidget
+{
+ Q_OBJECT
+
+ public:
+ FreeBusyWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
+ ~FreeBusyWidget();
+
+ void loadContact( KABC::Addressee *addr );
+ void storeContact( KABC::Addressee *addr );
+
+ void setReadOnly( bool readOnly );
+
+ private:
+ KURLRequester *mURL;
+
+ bool mReadOnly;
+};
+
+class FreeBusyWidgetFactory : public KAB::ContactEditorWidgetFactory
+{
+ public:
+ KAB::ContactEditorWidget *createWidget( KABC::AddressBook *ab, QWidget *parent, const char *name )
+ {
+ return new FreeBusyWidget( ab, parent, name );
+ }
+
+ QString pageIdentifier() const { return "misc"; }
+};
+
+#endif
diff --git a/kaddressbook/geowidget.cpp b/kaddressbook/geowidget.cpp
new file mode 100644
index 00000000..3563f118
--- /dev/null
+++ b/kaddressbook/geowidget.cpp
@@ -0,0 +1,562 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <kabc/geo.h>
+#include <kaccelmanager.h>
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <knuminput.h>
+#include <kstandarddirs.h>
+
+#include <qcheckbox.h>
+#include <qfile.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlistbox.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qpushbutton.h>
+#include <qregexp.h>
+#include <qstring.h>
+
+#include "geowidget.h"
+
+GeoWidget::GeoWidget( KABC::AddressBook *ab, QWidget *parent, const char *name )
+ : KAB::ContactEditorWidget( ab, parent, name ), mReadOnly( false )
+{
+ QLabel *label = 0;
+
+ QGridLayout *topLayout = new QGridLayout( this, 4, 3 );
+ topLayout->setMargin( KDialog::marginHint() );
+ topLayout->setSpacing( KDialog::spacingHint() );
+
+ label = new QLabel( this );
+ label->setPixmap( KGlobal::iconLoader()->loadIcon( "package_network",
+ KIcon::Desktop, KIcon::SizeMedium ) );
+ label->setAlignment( Qt::AlignTop );
+ topLayout->addMultiCellWidget( label, 0, 3, 0, 0 );
+
+ mGeoIsValid = new QCheckBox( i18n( "Use geo data" ), this );
+ topLayout->addMultiCellWidget( mGeoIsValid, 0, 0, 1, 2 );
+
+ label = new QLabel( i18n( "Latitude:" ), this );
+ topLayout->addWidget( label, 1, 1 );
+
+ mLatitudeBox = new KDoubleSpinBox( -90, 90, 1, 0, 6, this );
+ mLatitudeBox->setEnabled( false );
+ mLatitudeBox->setSuffix( "" );
+ topLayout->addWidget( mLatitudeBox, 1, 2 );
+ label->setBuddy( mLatitudeBox );
+
+ label = new QLabel( i18n( "Longitude:" ), this );
+ topLayout->addWidget( label, 2, 1 );
+
+ mLongitudeBox = new KDoubleSpinBox( -180, 180, 1, 0, 6, this );
+ mLongitudeBox->setEnabled( false );
+ mLongitudeBox->setSuffix( "" );
+ topLayout->addWidget( mLongitudeBox, 2, 2 );
+ label->setBuddy( mLongitudeBox );
+
+ mExtendedButton = new QPushButton( i18n( "Edit Geo Data..." ), this );
+ mExtendedButton->setEnabled( false );
+ topLayout->addMultiCellWidget( mExtendedButton, 3, 3, 1, 2 );
+
+ connect( mLatitudeBox, SIGNAL( valueChanged( double ) ),
+ SLOT( setModified() ) );
+ connect( mLongitudeBox, SIGNAL( valueChanged( double ) ),
+ SLOT( setModified() ) );
+ connect( mExtendedButton, SIGNAL( clicked() ),
+ SLOT( editGeoData() ) );
+
+ connect( mGeoIsValid, SIGNAL( toggled( bool ) ),
+ mLatitudeBox, SLOT( setEnabled( bool ) ) );
+ connect( mGeoIsValid, SIGNAL( toggled( bool ) ),
+ mLongitudeBox, SLOT( setEnabled( bool ) ) );
+ connect( mGeoIsValid, SIGNAL( toggled( bool ) ),
+ mExtendedButton, SLOT( setEnabled( bool ) ) );
+ connect( mGeoIsValid, SIGNAL( toggled( bool ) ),
+ SLOT( setModified() ) );
+}
+
+GeoWidget::~GeoWidget()
+{
+}
+
+void GeoWidget::loadContact( KABC::Addressee *addr )
+{
+ KABC::Geo geo = addr->geo();
+
+ if ( geo.isValid() ) {
+ if ( !mReadOnly )
+ mGeoIsValid->setChecked( true );
+ mLatitudeBox->setValue( geo.latitude() );
+ mLongitudeBox->setValue( geo.longitude() );
+ } else
+ mGeoIsValid->setChecked( false );
+}
+
+void GeoWidget::storeContact( KABC::Addressee *addr )
+{
+ KABC::Geo geo;
+
+ if ( mGeoIsValid->isChecked() ) {
+ geo.setLatitude( mLatitudeBox->value() );
+ geo.setLongitude( mLongitudeBox->value() );
+ } else {
+ geo.setLatitude( 91 );
+ geo.setLongitude( 181 );
+ }
+
+ addr->setGeo( geo );
+}
+
+void GeoWidget::setReadOnly( bool readOnly )
+{
+ mReadOnly = readOnly;
+
+ mGeoIsValid->setEnabled( !mReadOnly );
+}
+
+void GeoWidget::editGeoData()
+{
+ GeoDialog dlg( this );
+
+ dlg.setLatitude( mLatitudeBox->value() );
+ dlg.setLongitude( mLongitudeBox->value() );
+
+ if ( dlg.exec() ) {
+ mLatitudeBox->setValue( dlg.latitude() );
+ mLongitudeBox->setValue( dlg.longitude() );
+
+ setModified( true );
+ }
+}
+
+
+
+GeoDialog::GeoDialog( QWidget *parent, const char *name )
+ : KDialogBase( Plain, i18n( "Geo Data Input" ), Ok | Cancel, Ok,
+ parent, name, true, true ),
+ mUpdateSexagesimalInput( true )
+{
+ QFrame *page = plainPage();
+
+ QGridLayout *topLayout = new QGridLayout( page, 2, 2, marginHint(),
+ spacingHint() );
+ topLayout->setRowStretch( 1, 1 );
+
+ mMapWidget = new GeoMapWidget( page );
+ topLayout->addMultiCellWidget( mMapWidget, 0, 1, 0, 0 );
+
+ mCityCombo = new KComboBox( page );
+ topLayout->addWidget( mCityCombo, 0, 1 );
+
+ QGroupBox *sexagesimalGroup = new QGroupBox( 0, Vertical, i18n( "Sexagesimal" ), page );
+ QGridLayout *sexagesimalLayout = new QGridLayout( sexagesimalGroup->layout(),
+ 2, 5, spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "Latitude:" ), sexagesimalGroup );
+ sexagesimalLayout->addWidget( label, 0, 0 );
+
+ mLatDegrees = new QSpinBox( 0, 90, 1, sexagesimalGroup );
+ mLatDegrees->setSuffix( "" );
+ mLatDegrees->setWrapping( false );
+ label->setBuddy( mLatDegrees );
+ sexagesimalLayout->addWidget( mLatDegrees, 0, 1 );
+
+ mLatMinutes = new QSpinBox( 0, 59, 1, sexagesimalGroup );
+ mLatMinutes->setSuffix( "'" );
+ sexagesimalLayout->addWidget( mLatMinutes, 0, 2 );
+
+ mLatSeconds = new QSpinBox( 0, 59, 1, sexagesimalGroup );
+ mLatSeconds->setSuffix( "\"" );
+ sexagesimalLayout->addWidget( mLatSeconds, 0, 3 );
+
+ mLatDirection = new KComboBox( sexagesimalGroup );
+ mLatDirection->insertItem( i18n( "North" ) );
+ mLatDirection->insertItem( i18n( "South" ) );
+ sexagesimalLayout->addWidget( mLatDirection, 0, 4 );
+
+ label = new QLabel( i18n( "Longitude:" ), sexagesimalGroup );
+ sexagesimalLayout->addWidget( label, 1, 0 );
+
+ mLongDegrees = new QSpinBox( 0, 180, 1, sexagesimalGroup );
+ mLongDegrees->setSuffix( "" );
+ label->setBuddy( mLongDegrees );
+ sexagesimalLayout->addWidget( mLongDegrees, 1, 1 );
+
+ mLongMinutes = new QSpinBox( 0, 59, 1, sexagesimalGroup );
+ mLongMinutes->setSuffix( "'" );
+ sexagesimalLayout->addWidget( mLongMinutes, 1, 2 );
+
+ mLongSeconds = new QSpinBox( 0, 59, 1, sexagesimalGroup );
+ mLongSeconds->setSuffix( "\"" );
+ sexagesimalLayout->addWidget( mLongSeconds, 1, 3 );
+
+ mLongDirection = new KComboBox( sexagesimalGroup );
+ mLongDirection->insertItem( i18n( "East" ) );
+ mLongDirection->insertItem( i18n( "West" ) );
+ sexagesimalLayout->addWidget( mLongDirection, 1, 4 );
+
+ topLayout->addWidget( sexagesimalGroup, 1, 1 );
+
+ loadCityList();
+
+ connect( mMapWidget, SIGNAL( changed() ),
+ SLOT( geoMapChanged() ) );
+ connect( mCityCombo, SIGNAL( activated( int ) ),
+ SLOT( cityInputChanged() ) );
+ connect( mLatDegrees, SIGNAL( valueChanged( int ) ),
+ SLOT( sexagesimalInputChanged() ) );
+ connect( mLatMinutes, SIGNAL( valueChanged( int ) ),
+ SLOT( sexagesimalInputChanged() ) );
+ connect( mLatSeconds, SIGNAL( valueChanged( int ) ),
+ SLOT( sexagesimalInputChanged() ) );
+ connect( mLatDirection, SIGNAL( activated( int ) ),
+ SLOT( sexagesimalInputChanged() ) );
+ connect( mLongDegrees, SIGNAL( valueChanged( int ) ),
+ SLOT( sexagesimalInputChanged() ) );
+ connect( mLongMinutes, SIGNAL( valueChanged( int ) ),
+ SLOT( sexagesimalInputChanged() ) );
+ connect( mLongSeconds, SIGNAL( valueChanged( int ) ),
+ SLOT( sexagesimalInputChanged() ) );
+ connect( mLongDirection, SIGNAL( activated( int ) ),
+ SLOT( sexagesimalInputChanged() ) );
+
+ KAcceleratorManager::manage( this );
+}
+
+GeoDialog::~GeoDialog()
+{
+}
+
+void GeoDialog::setLatitude( double latitude )
+{
+ mLatitude = latitude;
+ updateInputs();
+}
+
+double GeoDialog::latitude() const
+{
+ return mLatitude;
+}
+
+void GeoDialog::setLongitude( double longitude )
+{
+ mLongitude = longitude;
+ updateInputs();
+}
+
+double GeoDialog::longitude() const
+{
+ return mLongitude;
+}
+
+void GeoDialog::sexagesimalInputChanged()
+{
+ mLatitude = (double)( mLatDegrees->value() + (double)mLatMinutes->value() /
+ 60 + (double)mLatSeconds->value() / 3600 );
+
+ mLatitude *= ( mLatDirection->currentItem() == 1 ? -1 : 1 );
+
+ mLongitude = (double)( mLongDegrees->value() + (double)mLongMinutes->value() /
+ 60 + (double)mLongSeconds->value() / 3600 );
+
+ mLongitude *= ( mLongDirection->currentItem() == 1 ? -1 : 1 );
+
+ mUpdateSexagesimalInput = false;
+
+ updateInputs();
+}
+
+void GeoDialog::geoMapChanged()
+{
+ mLatitude = mMapWidget->latitude();
+ mLongitude = mMapWidget->longitude();
+
+ updateInputs();
+}
+
+void GeoDialog::cityInputChanged()
+{
+ if ( mCityCombo->currentItem() != 0 ) {
+ GeoData data = mGeoDataMap[ mCityCombo->currentText() ];
+ mLatitude = data.latitude;
+ mLongitude = data.longitude;
+ } else
+ mLatitude = mLongitude = 0;
+
+ updateInputs();
+}
+
+void GeoDialog::updateInputs()
+{
+ // hmm, doesn't look nice, but there is no better way AFAIK
+ mCityCombo->blockSignals( true );
+ mLatDegrees->blockSignals( true );
+ mLatMinutes->blockSignals( true );
+ mLatSeconds->blockSignals( true );
+ mLatDirection->blockSignals( true );
+ mLongDegrees->blockSignals( true );
+ mLongMinutes->blockSignals( true );
+ mLongSeconds->blockSignals( true );
+ mLongDirection->blockSignals( true );
+
+ mMapWidget->setLatitude( mLatitude );
+ mMapWidget->setLongitude( mLongitude );
+ mMapWidget->update();
+
+ if ( mUpdateSexagesimalInput ) {
+ int degrees, minutes, seconds;
+ double latitude = mLatitude;
+ double longitude = mLongitude;
+
+ latitude *= ( mLatitude < 0 ? -1 : 1 );
+ longitude *= ( mLongitude < 0 ? -1 : 1 );
+
+ degrees = (int)( latitude * 1 );
+ minutes = (int)( ( latitude - degrees ) * 60 );
+ seconds = (int)( (double)( (double)latitude - (double)degrees - ( (double)minutes / (double)60 ) ) * (double)3600 );
+
+ mLatDegrees->setValue( degrees );
+ mLatMinutes->setValue( minutes );
+ mLatSeconds->setValue( seconds );
+
+ mLatDirection->setCurrentItem( mLatitude < 0 ? 1 : 0 );
+
+ degrees = (int)( longitude * 1 );
+ minutes = (int)( ( longitude - degrees ) * 60 );
+ seconds = (int)( (double)( longitude - (double)degrees - ( (double)minutes / 60 ) ) * 3600 );
+
+ mLongDegrees->setValue( degrees );
+ mLongMinutes->setValue( minutes );
+ mLongSeconds->setValue( seconds );
+ mLongDirection->setCurrentItem( mLongitude < 0 ? 1 : 0 );
+ }
+ mUpdateSexagesimalInput = true;
+
+ int pos = nearestCity( mLongitude, mLatitude );
+ if ( pos != -1 )
+ mCityCombo->setCurrentItem( pos + 1 );
+ else
+ mCityCombo->setCurrentItem( 0 );
+
+ mCityCombo->blockSignals( false );
+ mLatDegrees->blockSignals( false );
+ mLatMinutes->blockSignals( false );
+ mLatSeconds->blockSignals( false );
+ mLatDirection->blockSignals( false );
+ mLongDegrees->blockSignals( false );
+ mLongMinutes->blockSignals( false );
+ mLongSeconds->blockSignals( false );
+ mLongDirection->blockSignals( false );
+}
+
+void GeoDialog::loadCityList()
+{
+ mCityCombo->clear();
+ mGeoDataMap.clear();
+
+ QFile file( locate( "data", "kaddressbook/zone.tab" ) );
+
+ if ( file.open( IO_ReadOnly ) ) {
+ QTextStream s( &file );
+
+ QString line, country;
+ QRegExp coord( "[+-]\\d+[+-]\\d+" );
+ QRegExp name( "[^\\s]+/[^\\s]+" );
+ int pos;
+
+ while ( !s.eof() ) {
+ line = s.readLine().stripWhiteSpace();
+ if ( line.isEmpty() || line[ 0 ] == '#' )
+ continue;
+
+ country = line.left( 2 );
+ QString c, n;
+ pos = coord.search( line, 0 );
+ if ( pos >= 0 )
+ c = line.mid( pos, coord.matchedLength() );
+
+ pos = name.search(line, pos);
+ if ( pos > 0 ) {
+ n = line.mid( pos, name.matchedLength() ).stripWhiteSpace();
+ n.replace( '_', " " );
+ }
+
+ if ( !c.isEmpty() && !n.isEmpty() ) {
+ pos = c.find( "+", 1 );
+ if ( pos < 0 )
+ pos = c.find( "-", 1 );
+ if ( pos > 0 ) {
+ GeoData data;
+ data.latitude = calculateCoordinate( c.left( pos ) );
+ data.longitude = calculateCoordinate( c.mid( pos ) );
+ data.country = country;
+
+ mGeoDataMap.insert( n, data );
+ }
+ }
+ }
+ QStringList items( mGeoDataMap.keys() );
+ items.prepend( i18n( "Undefined" ) );
+ mCityCombo->insertStringList( items );
+
+ file.close();
+ }
+}
+
+double GeoDialog::calculateCoordinate( const QString &coordinate ) const
+{
+ int neg;
+ int d = 0, m = 0, s = 0;
+ QString str = coordinate;
+
+ neg = str.left( 1 ) == "-";
+ str.remove( 0, 1 );
+
+ switch ( str.length() ) {
+ case 4:
+ d = str.left( 2 ).toInt();
+ m = str.mid( 2 ).toInt();
+ break;
+ case 5:
+ d = str.left( 3 ).toInt();
+ m = str.mid( 3 ).toInt();
+ break;
+ case 6:
+ d = str.left( 2 ).toInt();
+ m = str.mid( 2, 2 ).toInt();
+ s = str.right( 2 ).toInt();
+ break;
+ case 7:
+ d = str.left( 3 ).toInt();
+ m = str.mid( 3, 2 ).toInt();
+ s = str.right( 2 ).toInt();
+ break;
+ default:
+ break;
+ }
+
+ if ( neg )
+ return - ( d + m / 60.0 + s / 3600.0 );
+ else
+ return d + m / 60.0 + s / 3600.0;
+}
+
+int GeoDialog::nearestCity( double x, double y ) const
+{
+ QMap<QString, GeoData>::ConstIterator it;
+ int pos = 0;
+ for ( it = mGeoDataMap.begin(); it != mGeoDataMap.end(); ++it, ++pos ) {
+ double dist = ( (*it).longitude - x ) * ( (*it).longitude - x ) +
+ ( (*it).latitude - y ) * ( (*it).latitude - y );
+ if ( dist < 1.5 )
+ return pos;
+ }
+
+ return -1;
+}
+
+
+GeoMapWidget::GeoMapWidget( QWidget *parent, const char *name )
+ : QWidget( parent, name ), mLatitude( 0 ), mLongitude( 0 )
+{
+ setBackgroundMode( NoBackground );
+
+ setFixedSize( 400, 200 );
+
+ update();
+}
+
+GeoMapWidget::~GeoMapWidget()
+{
+}
+
+void GeoMapWidget::setLatitude( double latitude )
+{
+ mLatitude = latitude;
+}
+
+double GeoMapWidget::latitude()const
+{
+ return mLatitude;
+}
+
+void GeoMapWidget::setLongitude( double longitude )
+{
+ mLongitude = longitude;
+}
+
+double GeoMapWidget::longitude()const
+{
+ return mLongitude;
+}
+
+void GeoMapWidget::mousePressEvent( QMouseEvent *event )
+{
+ double latMid = height() / 2;
+ double longMid = width() / 2;
+
+ double latOffset = latMid - event->y();
+ double longOffset = event->x() - longMid;
+
+ mLatitude = ( latOffset * 90 ) / latMid;
+ mLongitude = ( longOffset * 180 ) / longMid;
+
+ emit changed();
+}
+
+void GeoMapWidget::paintEvent( QPaintEvent* )
+{
+ uint w = width();
+ uint h = height();
+
+ QPixmap pm( w, h );
+ QPainter p;
+ p.begin( &pm, this );
+
+ p.setPen( QColor( 255, 0, 0 ) );
+ p.setBrush( QColor( 255, 0, 0 ) );
+
+ QPixmap world( locate( "data", "kaddressbook/pics/world.jpg" ) );
+ p.drawPixmap( 0, 0, world );
+
+ double latMid = h / 2;
+ double longMid = w / 2;
+
+ double latOffset = ( mLatitude * latMid ) / 90;
+ double longOffset = ( mLongitude * longMid ) / 180;
+
+ int x = (int)(longMid + longOffset);
+ int y = (int)(latMid - latOffset);
+ p.drawEllipse( x, y, 4, 4 );
+
+ p.end();
+ bitBlt( this, 0, 0, &pm );
+}
+
+#include "geowidget.moc"
diff --git a/kaddressbook/geowidget.h b/kaddressbook/geowidget.h
new file mode 100644
index 00000000..85140849
--- /dev/null
+++ b/kaddressbook/geowidget.h
@@ -0,0 +1,159 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef GEOWIDGET_H
+#define GEOWIDGET_H
+
+#include <kdialogbase.h>
+
+#include "contacteditorwidget.h"
+
+namespace KABC {
+class Geo;
+}
+
+class GeoMapWidget;
+
+class KComboBox;
+class KDoubleSpinBox;
+
+class QCheckBox;
+class QLabel;
+class QSpinBox;
+class QPushButton;
+
+typedef struct {
+ double latitude;
+ double longitude;
+ QString country;
+} GeoData;
+
+class GeoWidget : public KAB::ContactEditorWidget
+{
+ Q_OBJECT
+
+ public:
+ GeoWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
+ ~GeoWidget();
+
+ void loadContact( KABC::Addressee *addr );
+ void storeContact( KABC::Addressee *addr );
+
+ void setReadOnly( bool readOnly );
+
+ private slots:
+ void editGeoData();
+
+ private:
+ KDoubleSpinBox *mLatitudeBox;
+ KDoubleSpinBox *mLongitudeBox;
+
+ QCheckBox *mGeoIsValid;
+ QPushButton *mExtendedButton;
+
+ bool mReadOnly;
+};
+
+class GeoDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ GeoDialog( QWidget *parent, const char *name = 0 );
+ ~GeoDialog();
+
+ void setLatitude( double latitude );
+ double latitude() const;
+
+ void setLongitude( double longitude );
+ double longitude() const;
+
+ private slots:
+ void updateInputs();
+
+ void sexagesimalInputChanged();
+ void geoMapChanged();
+ void cityInputChanged();
+
+ private:
+ void loadCityList();
+ double calculateCoordinate( const QString& ) const;
+ int nearestCity( double, double ) const;
+
+ GeoMapWidget *mMapWidget;
+ KComboBox *mCityCombo;
+
+ QSpinBox *mLatDegrees;
+ QSpinBox *mLatMinutes;
+ QSpinBox *mLatSeconds;
+ KComboBox *mLatDirection;
+
+ QSpinBox *mLongDegrees;
+ QSpinBox *mLongMinutes;
+ QSpinBox *mLongSeconds;
+ KComboBox *mLongDirection;
+
+ double mLatitude;
+ double mLongitude;
+ QMap<QString, GeoData> mGeoDataMap;
+ bool mUpdateSexagesimalInput;
+};
+
+class GeoMapWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ GeoMapWidget( QWidget *parent, const char *name = 0 );
+ ~GeoMapWidget();
+
+ void setLatitude( double latitude );
+ double latitude()const;
+
+ void setLongitude( double longitude );
+ double longitude()const;
+
+ signals:
+ void changed();
+
+ protected:
+ virtual void mousePressEvent( QMouseEvent* );
+ virtual void paintEvent( QPaintEvent* );
+
+ private:
+ double mLatitude;
+ double mLongitude;
+};
+
+class GeoWidgetFactory : public KAB::ContactEditorWidgetFactory
+{
+ public:
+ KAB::ContactEditorWidget *createWidget( KABC::AddressBook *ab, QWidget *parent, const char *name )
+ {
+ return new GeoWidget( ab, parent, name );
+ }
+
+ QString pageIdentifier() const { return "misc"; }
+};
+
+#endif
diff --git a/kaddressbook/hi128-app-kaddressbook.png b/kaddressbook/hi128-app-kaddressbook.png
new file mode 100644
index 00000000..5ca543be
--- /dev/null
+++ b/kaddressbook/hi128-app-kaddressbook.png
Binary files differ
diff --git a/kaddressbook/hi16-app-kaddressbook.png b/kaddressbook/hi16-app-kaddressbook.png
new file mode 100644
index 00000000..b9bc82e0
--- /dev/null
+++ b/kaddressbook/hi16-app-kaddressbook.png
Binary files differ
diff --git a/kaddressbook/hi32-app-kaddressbook.png b/kaddressbook/hi32-app-kaddressbook.png
new file mode 100644
index 00000000..ff5cfdfc
--- /dev/null
+++ b/kaddressbook/hi32-app-kaddressbook.png
Binary files differ
diff --git a/kaddressbook/hi48-app-kaddressbook.png b/kaddressbook/hi48-app-kaddressbook.png
new file mode 100644
index 00000000..c0525bc1
--- /dev/null
+++ b/kaddressbook/hi48-app-kaddressbook.png
Binary files differ
diff --git a/kaddressbook/hi64-app-kaddressbook.png b/kaddressbook/hi64-app-kaddressbook.png
new file mode 100644
index 00000000..672a7b48
--- /dev/null
+++ b/kaddressbook/hi64-app-kaddressbook.png
Binary files differ
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp
new file mode 100644
index 00000000..ad0fad55
--- /dev/null
+++ b/kaddressbook/imagewidget.cpp
@@ -0,0 +1,325 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <kabc/picture.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <kfiledialog.h>
+#include <kglobalsettings.h>
+#include <kiconloader.h>
+#include <kimageio.h>
+#include <kio/netaccess.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kurldrag.h>
+#include <libkdepim/kpixmapregionselectordialog.h>
+
+#include <qapplication.h>
+#include <qdragobject.h>
+#include <qeventloop.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpixmap.h>
+#include <qpopupmenu.h>
+
+#include <unistd.h>
+
+#include "imagewidget.h"
+
+ImageLoader::ImageLoader( QWidget *parent )
+ : QObject( 0, "ImageLoader" ), mParent( parent )
+{
+}
+
+KABC::Picture ImageLoader::loadPicture( const KURL &url, bool *ok )
+{
+ KABC::Picture picture;
+ QString tempFile;
+
+ if ( url.isEmpty() )
+ return picture;
+
+ (*ok) = false;
+
+ QImage image;
+ if ( url.isLocalFile() ) {
+ image.load( url.path() );
+ picture.setData( image );
+ (*ok) = true;
+ } else if ( KIO::NetAccess::download( url, tempFile, mParent ) ) {
+ image.load( tempFile );
+ picture.setData( image );
+ (*ok) = true;
+ KIO::NetAccess::removeTempFile( tempFile );
+ }
+
+ if ( !(*ok) ) {
+ // image does not exist (any more)
+ KMessageBox::sorry( mParent, i18n( "This contact's image cannot be found." ) );
+ return picture;
+ }
+
+ QPixmap pixmap = picture.data();
+
+ QPixmap selectedPixmap = KPIM::KPixmapRegionSelectorDialog::getSelectedImage( pixmap, 100, 140, mParent );
+ if ( selectedPixmap.isNull() ) {
+ (*ok) = false;
+ return picture;
+ }
+
+ image = selectedPixmap;
+ if ( image.height() != 140 || image.width() != 100 ) {
+ if ( image.height() > image.width() )
+ image = image.scaleHeight( 140 );
+ else
+ image = image.scaleWidth( 100 );
+ }
+
+ picture.setData( image );
+ (*ok) = true;
+
+ return picture;
+}
+
+
+ImageButton::ImageButton( const QString &title, QWidget *parent )
+ : QPushButton( title, parent ),
+ mReadOnly( false ), mImageLoader( 0 )
+{
+ setAcceptDrops( true );
+
+ connect( this, SIGNAL( clicked() ), SLOT( load() ) );
+}
+
+void ImageButton::setReadOnly( bool readOnly )
+{
+ mReadOnly = readOnly;
+}
+
+void ImageButton::setPicture( const KABC::Picture &picture )
+{
+ mPicture = picture;
+ updateGUI();
+}
+
+KABC::Picture ImageButton::picture() const
+{
+ return mPicture;
+}
+
+void ImageButton::setImageLoader( ImageLoader *loader )
+{
+ mImageLoader = loader;
+}
+
+void ImageButton::startDrag()
+{
+ if ( !mPicture.data().isNull() ) {
+ QImageDrag *drag = new QImageDrag( mPicture.data(), this );
+ drag->dragCopy();
+ }
+}
+
+void ImageButton::updateGUI()
+{
+ if ( mPicture.data().isNull() )
+ setPixmap( KGlobal::iconLoader()->iconPath( "personal", KIcon::Desktop ) );
+ else
+ setPixmap( mPicture.data() );
+}
+
+void ImageButton::dragEnterEvent( QDragEnterEvent *event )
+{
+ bool accepted = false;
+
+ if ( QImageDrag::canDecode( event ) )
+ accepted = true;
+
+ if ( QUriDrag::canDecode( event ) )
+ accepted = true;
+
+ event->accept( accepted );
+}
+
+void ImageButton::dropEvent( QDropEvent *event )
+{
+ if ( mReadOnly )
+ return;
+
+ if ( QImageDrag::canDecode( event ) ) {
+ QPixmap pm;
+
+ if ( QImageDrag::decode( event, pm ) ) {
+ mPicture.setData( pm.convertToImage() );
+ updateGUI();
+ emit changed();
+ }
+ }
+
+ if ( QUriDrag::canDecode( event ) ) {
+ KURL::List urls;
+ if ( KURLDrag::decode( event, urls ) ) {
+ if ( urls.isEmpty() ) { // oops, no data
+ event->accept( false );
+ return;
+ }
+ }
+
+ if ( mImageLoader ) {
+ bool ok = false;
+ KABC::Picture pic = mImageLoader->loadPicture( urls[ 0 ], &ok );
+ if ( ok ) {
+ mPicture = pic;
+ updateGUI();
+ emit changed();
+ }
+ }
+ }
+}
+
+void ImageButton::mousePressEvent( QMouseEvent *event )
+{
+ mDragStartPos = event->pos();
+ QPushButton::mousePressEvent( event );
+}
+
+void ImageButton::mouseMoveEvent( QMouseEvent *event )
+{
+ if ( (event->state() & LeftButton) &&
+ (event->pos() - mDragStartPos).manhattanLength() >
+ KGlobalSettings::dndEventDelay() ) {
+ startDrag();
+ }
+}
+
+void ImageButton::contextMenuEvent( QContextMenuEvent *event )
+{
+ QPopupMenu menu( this );
+ menu.insertItem( i18n( "Reset" ), this, SLOT( clear() ) );
+ menu.exec( event->globalPos() );
+}
+
+void ImageButton::load()
+{
+ KURL url = KFileDialog::getOpenURL( QString(), KImageIO::pattern(), this );
+ if ( url.isValid() ) {
+ if ( mImageLoader ) {
+ bool ok = false;
+ KABC::Picture pic = mImageLoader->loadPicture( url, &ok );
+ if ( ok ) {
+ mPicture = pic;
+ updateGUI();
+ emit changed();
+ }
+ }
+ }
+}
+
+void ImageButton::clear()
+{
+ mPicture = KABC::Picture();
+ updateGUI();
+
+ emit changed();
+}
+
+ImageBaseWidget::ImageBaseWidget( const QString &title,
+ QWidget *parent, const char *name )
+ : QWidget( parent, name ), mReadOnly( false )
+{
+ mImageLoader = new ImageLoader( this );
+
+ QVBoxLayout *topLayout = new QVBoxLayout( this, KDialog::marginHint(),
+ KDialog::spacingHint() );
+ QGroupBox *box = new QGroupBox( 0, Qt::Vertical, title, this );
+ QVBoxLayout *layout = new QVBoxLayout( box->layout(), KDialog::spacingHint() );
+
+ mImageButton = new ImageButton( i18n( "Picture" ), box );
+ mImageButton->setFixedSize( 100, 140 );
+ mImageButton->setImageLoader( mImageLoader );
+ layout->addWidget( mImageButton );
+
+ topLayout->addWidget( box );
+
+ connect( mImageButton, SIGNAL( changed() ), SIGNAL( changed() ) );
+}
+
+ImageBaseWidget::~ImageBaseWidget()
+{
+ delete mImageLoader;
+ mImageLoader = 0;
+}
+
+void ImageBaseWidget::setReadOnly( bool readOnly )
+{
+ mReadOnly = readOnly;
+ mImageButton->setReadOnly( mReadOnly );
+}
+
+void ImageBaseWidget::setImage( const KABC::Picture &photo )
+{
+ mImageButton->setPicture( photo );
+}
+
+KABC::Picture ImageBaseWidget::image() const
+{
+ return mImageButton->picture();
+}
+
+
+ImageWidget::ImageWidget( KABC::AddressBook *ab, QWidget *parent, const char *name )
+ : KAB::ContactEditorWidget( ab, parent, name )
+{
+ QHBoxLayout *layout = new QHBoxLayout( this, KDialog::marginHint(),
+ KDialog::spacingHint() );
+
+ mPhotoWidget = new ImageBaseWidget( KABC::Addressee::photoLabel(), this );
+ layout->addWidget( mPhotoWidget );
+
+ mLogoWidget = new ImageBaseWidget( KABC::Addressee::logoLabel(), this );
+ layout->addWidget( mLogoWidget );
+
+ connect( mPhotoWidget, SIGNAL( changed() ), SLOT( setModified() ) );
+ connect( mLogoWidget, SIGNAL( changed() ), SLOT( setModified() ) );
+}
+
+void ImageWidget::loadContact( KABC::Addressee *addr )
+{
+ mPhotoWidget->setImage( addr->photo() );
+ mLogoWidget->setImage( addr->logo() );
+}
+
+void ImageWidget::storeContact( KABC::Addressee *addr )
+{
+ addr->setPhoto( mPhotoWidget->image() );
+ addr->setLogo( mLogoWidget->image() );
+}
+
+void ImageWidget::setReadOnly( bool readOnly )
+{
+ mPhotoWidget->setReadOnly( readOnly );
+ mLogoWidget->setReadOnly( readOnly );
+}
+
+#include "imagewidget.moc"
diff --git a/kaddressbook/imagewidget.h b/kaddressbook/imagewidget.h
new file mode 100644
index 00000000..02a3577c
--- /dev/null
+++ b/kaddressbook/imagewidget.h
@@ -0,0 +1,153 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef IMAGEWIDGET_H
+#define IMAGEWIDGET_H
+
+#include <qlabel.h>
+#include <qpushbutton.h>
+
+#include <kabc/picture.h>
+#include <kdialogbase.h>
+
+#include "contacteditorwidget.h"
+
+/**
+ Small helper class
+ */
+class ImageLoader : public QObject
+{
+ Q_OBJECT
+
+ public:
+ ImageLoader( QWidget *parent );
+
+ KABC::Picture loadPicture( const KURL &url, bool *ok );
+
+ private:
+ KABC::Picture mPicture;
+ QWidget *mParent;
+};
+
+/**
+ Small helper class
+ */
+class ImageButton : public QPushButton
+{
+ Q_OBJECT
+
+ public:
+ ImageButton( const QString &title, QWidget *parent );
+
+ void setReadOnly( bool readOnly );
+
+ void setPicture( const KABC::Picture &picture );
+ KABC::Picture picture() const;
+
+ void setImageLoader( ImageLoader *loader );
+
+ signals:
+ void changed();
+ void urlDropped( const KURL& );
+
+ protected:
+ virtual void dragEnterEvent( QDragEnterEvent *event );
+ virtual void dropEvent( QDropEvent *event );
+ virtual void mouseMoveEvent( QMouseEvent *event );
+ virtual void mousePressEvent( QMouseEvent *event );
+ virtual void contextMenuEvent( QContextMenuEvent *event );
+
+ private slots:
+ void load();
+ void clear();
+
+ private:
+ void startDrag();
+ void updateGUI();
+
+ bool mReadOnly;
+ QPoint mDragStartPos;
+ KABC::Picture mPicture;
+
+ ImageLoader *mImageLoader;
+};
+
+
+class ImageBaseWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ ImageBaseWidget( const QString &title, QWidget *parent, const char *name = 0 );
+ ~ImageBaseWidget();
+
+ /**
+ Sets the photo object.
+ */
+ void setImage( const KABC::Picture &photo );
+
+ /**
+ Returns a photo object.
+ */
+ KABC::Picture image() const;
+
+ void setReadOnly( bool readOnly );
+
+ signals:
+ void changed();
+
+ private:
+ ImageButton *mImageButton;
+ ImageLoader *mImageLoader;
+
+ bool mReadOnly;
+};
+
+class ImageWidget : public KAB::ContactEditorWidget
+{
+ public:
+ ImageWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
+
+ void loadContact( KABC::Addressee *addr );
+ void storeContact( KABC::Addressee *addr );
+ void setReadOnly( bool readOnly );
+
+ int logicalWidth() const { return 2; }
+
+ private:
+ ImageBaseWidget *mPhotoWidget;
+ ImageBaseWidget *mLogoWidget;
+};
+
+class ImageWidgetFactory : public KAB::ContactEditorWidgetFactory
+{
+ public:
+ KAB::ContactEditorWidget *createWidget( KABC::AddressBook *ab, QWidget *parent, const char *name )
+ {
+ return new ImageWidget( ab, parent, name );
+ }
+
+ QString pageIdentifier() const { return "misc"; }
+};
+
+#endif
diff --git a/kaddressbook/imeditwidget.cpp b/kaddressbook/imeditwidget.cpp
new file mode 100644
index 00000000..7e663d25
--- /dev/null
+++ b/kaddressbook/imeditwidget.cpp
@@ -0,0 +1,145 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qpushbutton.h>
+#include <qstring.h>
+#include <qtoolbutton.h>
+#include <qtooltip.h>
+
+#include <kaccelmanager.h>
+#include <kconfig.h>
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <klineedit.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "imeditwidget.h"
+#include "imeditorwidget.h"
+
+IMEditWidget::IMEditWidget( QWidget *parent, KABC::Addressee &addr, const char *name )
+ : QWidget( parent, name ), mAddressee(addr)
+{
+ QGridLayout *topLayout = new QGridLayout( this, 2, 2, KDialog::marginHint(),
+ KDialog::spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "IM address:" ), this );
+ topLayout->addWidget( label, 0, 0 );
+
+ mIMEdit = new KLineEdit( this );
+ connect( mIMEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ connect( mIMEdit, SIGNAL( textChanged( const QString& ) ),
+ SIGNAL( modified() ) );
+ label->setBuddy( mIMEdit );
+ topLayout->addWidget( mIMEdit, 0, 1 );
+
+ mEditButton = new QPushButton( i18n( "Edit IM Addresses..." ), this);
+ connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) );
+ topLayout->addMultiCellWidget( mEditButton, 1, 1, 0, 1 );
+
+ topLayout->activate();
+}
+
+IMEditWidget::~IMEditWidget()
+{
+}
+
+void IMEditWidget::setReadOnly( bool readOnly )
+{
+ mIMEdit->setReadOnly( readOnly );
+ mReadOnly = readOnly;
+// mEditButton->setEnabled( !readOnly );
+}
+void IMEditWidget::setPreferredIM( const QString &addr )
+{
+ bool blocked = mIMEdit->signalsBlocked();
+ mIMEdit->blockSignals( true );
+ mIMEdit->setText( addr );
+ mIMEdit->blockSignals( blocked );
+}
+void IMEditWidget::setIMs( const QStringList &list )
+{
+ mIMList = list;
+
+ bool blocked = mIMEdit->signalsBlocked();
+ mIMEdit->blockSignals( true );
+ if ( list.count() > 0 )
+ mIMEdit->setText( list[ 0 ] );
+ else
+ mIMEdit->setText( "" );
+ mIMEdit->blockSignals( blocked );
+}
+
+QStringList IMEditWidget::ims()
+{
+ if ( mIMEdit->text().isEmpty() ) {
+ if ( mIMList.count() > 0 )
+ mIMList.remove( mIMList.begin() );
+ } else {
+ if ( mIMList.count() > 0 )
+ mIMList.remove( mIMList.begin() );
+
+ mIMList.prepend( mIMEdit->text() );
+ }
+
+ return mIMList;
+}
+QString IMEditWidget::preferredIM()
+{
+ return mIMEdit->text();
+}
+void IMEditWidget::edit()
+{
+ IMEditorWidget dlg(this, mIMEdit->text());
+ dlg.loadContact(&mAddressee);
+ dlg.setReadOnly(mReadOnly);
+
+ if ( dlg.exec() ) {
+ if ( dlg.isModified() ) {
+ //Stores the changes into mAddressee. mAddressee isn't actually saved to the addressbook
+ //until we save the record.
+ dlg.storeContact(&mAddressee);
+ mIMEdit->setText( dlg.preferred() );
+ emit modified();
+ }
+ }
+}
+
+void IMEditWidget::textChanged( const QString &text )
+{
+ if ( mIMList.count() > 0 )
+ mIMList.remove( mIMList.begin() );
+
+ mIMList.prepend( text );
+}
+
+
+#include "imeditwidget.moc"
+
diff --git a/kaddressbook/imeditwidget.h b/kaddressbook/imeditwidget.h
new file mode 100644
index 00000000..8a20b9b2
--- /dev/null
+++ b/kaddressbook/imeditwidget.h
@@ -0,0 +1,75 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef IMEDITWIDGET_H
+#define IMEDITWIDGET_H
+
+#include <kabc/addressee.h>
+#include <kdialogbase.h>
+
+class QButtonGroup;
+class QCheckBox;
+class QListView;
+class QTextEdit;
+class QToolButton;
+
+class KComboBox;
+class KLineEdit;
+class KListView;
+
+/**
+ This widget displays a list box of the instant messaging addresses as well as buttons
+ to manipulate them (up, down, add, remove).
+*/
+class IMEditWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ IMEditWidget(QWidget *parent, KABC::Addressee &addr, const char *name = 0 );
+ ~IMEditWidget();
+
+ void setIMs( const QStringList &list );
+ QStringList ims();
+
+ void setPreferredIM( const QString &addr );
+ QString preferredIM();
+ void setReadOnly( bool readOnly );
+
+ signals:
+ void modified();
+
+ private slots:
+ void edit();
+ void textChanged( const QString& );
+
+ private:
+ KLineEdit *mIMEdit;
+ QPushButton *mEditButton;
+ QStringList mIMList;
+ bool mReadOnly;
+ KABC::Addressee &mAddressee;
+};
+
+
+#endif
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
new file mode 100644
index 00000000..e435d100
--- /dev/null
+++ b/kaddressbook/incsearchwidget.cpp
@@ -0,0 +1,171 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qapplication.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qtimer.h>
+#include <qtoolbutton.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <klineedit.h>
+#include <klocale.h>
+
+#include "incsearchwidget.h"
+
+IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+ QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() );
+
+ QToolButton *button = new QToolButton( this );
+ button->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
+ button->setPixmap( SmallIcon( QApplication::reverseLayout() ? "clear_left" : "locationbar_erase" ) );
+ button->setAccel( QKeySequence( CTRL+ALT+Key_S ) );
+ button->setAutoRaise( true );
+ QToolTip::add( button, i18n( "Reset" ) );
+ layout->addWidget( button );
+
+ QLabel *label = new QLabel( i18n( "Search:" ), this, "kde toolbar widget" );
+ label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight );
+ layout->addWidget( label );
+
+ mSearchText = new KLineEdit( this );
+ mSearchText->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
+ QWhatsThis::add( mSearchText, i18n( "The incremental search<p>Enter some text here will start the search for the contact, which matches the search pattern best. The part of the contact, which will be used for matching, depends on the field selection." ) );
+ label->setBuddy( mSearchText );
+ layout->addWidget( mSearchText );
+
+ label = new QLabel( i18n( "as in 'Search in:'", "&in:" ), this, "kde toolbar widget" );
+ label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight );
+ layout->addWidget( label );
+
+ mFieldCombo = new QComboBox( false, this );
+ layout->addWidget( mFieldCombo );
+ label->setBuddy(mFieldCombo);
+
+ QToolTip::add( mFieldCombo, i18n( "Select incremental search field" ) );
+ QWhatsThis::add( mFieldCombo, i18n( "Here you can choose the field, which shall be used for incremental search." ) );
+
+ mInputTimer = new QTimer( this );
+
+ connect( mInputTimer, SIGNAL( timeout() ),
+ SLOT( timeout() ) );
+ connect( mSearchText, SIGNAL( textChanged( const QString& ) ),
+ SLOT( announceDoSearch() ) );
+ connect( mSearchText, SIGNAL( returnPressed() ),
+ SLOT( announceDoSearch() ) );
+ connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
+ SLOT( announceDoSearch() ) );
+ connect( button, SIGNAL( clicked() ),
+ mSearchText, SLOT( clear() ) );
+ connect( button, SIGNAL( clicked() ),
+ SLOT( announceDoSearch() ) );
+
+ initFields();
+
+ mSearchText->installEventFilter( this );
+
+ setFocusProxy( mSearchText );
+}
+
+IncSearchWidget::~IncSearchWidget()
+{
+}
+
+void IncSearchWidget::announceDoSearch()
+{
+ if ( mInputTimer->isActive() )
+ mInputTimer->stop();
+
+ mInputTimer->start( 0, true );
+}
+
+void IncSearchWidget::timeout()
+{
+ emit doSearch( mSearchText->text() );
+}
+
+void IncSearchWidget::initFields()
+{
+ mFieldList = KABC::Field::allFields();
+
+ mFieldCombo->clear();
+ mFieldCombo->insertItem( i18n( "Visible Fields" ) );
+ mFieldCombo->insertItem( i18n( "All Fields" ) );
+
+ KABC::Field::List::ConstIterator it;
+ for ( it = mFieldList.begin(); it != mFieldList.end(); ++it )
+ mFieldCombo->insertItem( (*it)->label() );
+
+ announceDoSearch();
+}
+
+KABC::Field::List IncSearchWidget::currentFields() const
+{
+ KABC::Field::List fieldList;
+
+ if ( mFieldCombo->currentItem() == 0 )
+ fieldList = mViewFields;
+ else if ( mFieldCombo->currentItem() > 1 )
+ fieldList.append( mFieldList[ mFieldCombo->currentItem() - 2 ] );
+
+ return fieldList;
+}
+
+void IncSearchWidget::setCurrentItem( int pos )
+{
+ mFieldCombo->setCurrentItem( pos );
+}
+
+int IncSearchWidget::currentItem() const
+{
+ return mFieldCombo->currentItem();
+}
+
+void IncSearchWidget::setViewFields( const KABC::Field::List &fields )
+{
+ mViewFields = fields;
+}
+
+void IncSearchWidget::clear()
+{
+ mSearchText->clear();
+}
+
+void IncSearchWidget::keyPressEvent( QKeyEvent *event )
+{
+ if ( event->key() == Qt::Key_Up ) {
+ event->accept();
+ emit scrollUp();
+ } else if ( event->key() == Qt::Key_Down ) {
+ event->accept();
+ emit scrollDown();
+ }
+}
+
+#include "incsearchwidget.moc"
diff --git a/kaddressbook/incsearchwidget.h b/kaddressbook/incsearchwidget.h
new file mode 100644
index 00000000..c4eb1936
--- /dev/null
+++ b/kaddressbook/incsearchwidget.h
@@ -0,0 +1,88 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef INCSEARCHWIDGET_H
+#define INCSEARCHWIDGET_H
+
+#include <qwidget.h>
+
+#include <kabc/field.h>
+
+class QComboBox;
+class QTimer;
+class KLineEdit;
+
+class IncSearchWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ IncSearchWidget( QWidget *parent, const char *name = 0 );
+ ~IncSearchWidget();
+
+ KABC::Field::List currentFields() const;
+
+ void setCurrentItem( int pos );
+ int currentItem() const;
+
+ void clear();
+
+ signals:
+ /**
+ This signal is emitted whenever the text in the input
+ widget is changed. You can get the sorting field by
+ @ref currentField.
+ */
+ void doSearch( const QString& text );
+
+ /**
+ Emitted when the up key is pressed.
+ */
+ void scrollUp();
+
+ /**
+ Emitted when the down key is pressed.
+ */
+ void scrollDown();
+
+ public slots:
+ void setViewFields( const KABC::Field::List& );
+
+ private slots:
+ void announceDoSearch();
+ void timeout();
+
+ protected:
+ virtual void keyPressEvent( QKeyEvent* );
+
+ private:
+ void initFields();
+
+ QComboBox* mFieldCombo;
+ KLineEdit* mSearchText;
+ KABC::Field::List mFieldList;
+ KABC::Field::List mViewFields;
+ QTimer* mInputTimer;
+};
+
+#endif
diff --git a/kaddressbook/interfaces/Makefile.am b/kaddressbook/interfaces/Makefile.am
new file mode 100644
index 00000000..7b437364
--- /dev/null
+++ b/kaddressbook/interfaces/Makefile.am
@@ -0,0 +1,18 @@
+INCLUDES = -I$(top_srcdir) $(all_includes)
+
+lib_LTLIBRARIES = libkabinterfaces.la
+
+libkabinterfaces_la_SOURCES = configurewidget.cpp contacteditorwidget.cpp \
+ core.cpp extensionwidget.cpp xxport.cpp
+libkabinterfaces_la_LDFLAGS = $(all_libraries) -version-info 1:0:0 -no-undefined
+libkabinterfaces_la_LIBADD = $(LIB_KABC)
+
+kabincludedir = $(includedir)/kaddressbook
+kabinclude_HEADERS = configurewidget.h contacteditorwidget.h core.h \
+ extensionwidget.h xxport.h
+
+METASOURCES = AUTO
+
+servicetypedir = $(kde_servicetypesdir)
+servicetype_DATA = kaddressbook_contacteditorwidget.desktop \
+ kaddressbook_extension.desktop kaddressbook_xxport.desktop
diff --git a/kaddressbook/interfaces/configurewidget.cpp b/kaddressbook/interfaces/configurewidget.cpp
new file mode 100644
index 00000000..518a2953
--- /dev/null
+++ b/kaddressbook/interfaces/configurewidget.cpp
@@ -0,0 +1,53 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <kabc/addressbook.h>
+
+#include "configurewidget.h"
+
+using namespace KAB;
+
+ConfigureWidget::ConfigureWidget( KABC::AddressBook *ab, QWidget *parent,
+ const char *name )
+ : QWidget( parent, name ), mAddressBook( ab )
+{
+}
+
+ConfigureWidget::~ConfigureWidget()
+{
+}
+
+void ConfigureWidget::restoreSettings( KConfig* )
+{
+ // should be reimplemented in the views, extensions etc.
+}
+
+void ConfigureWidget::saveSettings( KConfig* )
+{
+ // should be reimplemented in the views, extensions etc.
+}
+
+KABC::AddressBook *ConfigureWidget::addressBook() const
+{
+ return mAddressBook;
+}
diff --git a/kaddressbook/interfaces/configurewidget.h b/kaddressbook/interfaces/configurewidget.h
new file mode 100644
index 00000000..601adce9
--- /dev/null
+++ b/kaddressbook/interfaces/configurewidget.h
@@ -0,0 +1,72 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KAB_CONFIGUREWIDGET_H
+#define KAB_CONFIGUREWIDGET_H
+
+#include <qwidget.h>
+
+#include <kconfig.h>
+#include <kdepimmacros.h>
+
+namespace KABC {
+class AddressBook;
+}
+
+namespace KAB {
+
+class KDE_EXPORT ConfigureWidget : public QWidget
+{
+ public:
+ ConfigureWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
+ ~ConfigureWidget();
+
+ /**
+ This method is called before the configure dialog is shown.
+ The widget should reimplement it and fill the GUI with the
+ values from the config file.
+ Important: Don't change the group of cfg!
+ */
+ virtual void restoreSettings( KConfig *cfg );
+
+ /**
+ This method is called after the user clicked the 'Ok' button.
+ The widget should reimplement it and save all values from
+ the GUI to the config file.
+ Important: Don't change the group of cfg!
+ */
+ virtual void saveSettings( KConfig *cfg );
+
+
+ /**
+ Returns a pointer to the address book of this widget.
+ */
+ KABC::AddressBook *addressBook() const;
+
+ private:
+ KABC::AddressBook *mAddressBook;
+};
+
+}
+
+#endif
diff --git a/kaddressbook/interfaces/contacteditorwidget.cpp b/kaddressbook/interfaces/contacteditorwidget.cpp
new file mode 100644
index 00000000..366087c6
--- /dev/null
+++ b/kaddressbook/interfaces/contacteditorwidget.cpp
@@ -0,0 +1,60 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include "contacteditorwidget.h"
+
+using namespace KAB;
+
+ContactEditorWidget::ContactEditorWidget( KABC::AddressBook *ab,
+ QWidget *parent, const char *name )
+ : QWidget( parent, name ), mAddressBook( ab ), mModified( false )
+{
+}
+
+ContactEditorWidget::~ContactEditorWidget()
+{
+}
+
+KABC::AddressBook *ContactEditorWidget::addressBook() const
+{
+ return mAddressBook;
+}
+
+bool ContactEditorWidget::modified() const
+{
+ return mModified;
+}
+
+void ContactEditorWidget::setModified()
+{
+ setModified( true );
+}
+
+void ContactEditorWidget::setModified( bool modified )
+{
+ mModified = modified;
+ if ( modified )
+ emit changed();
+}
+
+#include "contacteditorwidget.moc"
diff --git a/kaddressbook/interfaces/contacteditorwidget.h b/kaddressbook/interfaces/contacteditorwidget.h
new file mode 100644
index 00000000..4b80b44f
--- /dev/null
+++ b/kaddressbook/interfaces/contacteditorwidget.h
@@ -0,0 +1,143 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KAB_CONTACTEDITORWIDGET_H
+#define KAB_CONTACTEDITORWIDGET_H
+
+#include <qwidget.h>
+
+#include <kabc/addressbook.h>
+#include <klibloader.h>
+#include <kdepimmacros.h>
+
+#define KAB_CEW_PLUGIN_VERSION 1
+
+namespace KAB {
+
+class KDE_EXPORT ContactEditorWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ typedef QValueList<ContactEditorWidget*> List;
+
+ ContactEditorWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
+ ~ContactEditorWidget();
+
+ /**
+ Return logical height of the widget. This is used to calculate how
+ much vertical space relative to other widgets this widget will use
+ in the summary view.
+ */
+ virtual int logicalHeight() const { return 1; }
+
+ /**
+ Return logical wide of the widget. This is used to calculate how
+ much horizontal space relative to other widgets this widget will use
+ in the summary view.
+ */
+ virtual int logicalWidth() const { return 1; }
+
+ /**
+ Load the contacts data into the GUI.
+ */
+ virtual void loadContact( KABC::Addressee *addr ) = 0;
+
+ /**
+ Save the data from the GUI into the passed contact
+ object.
+ */
+ virtual void storeContact( KABC::Addressee *addr ) = 0;
+
+ /**
+ Sets whether the contact should be presented as
+ read-only. You should update your GUI in the reimplemented
+ method.
+ */
+ virtual void setReadOnly( bool readOnly ) = 0;
+
+ /**
+ Returns whether this widget was modified.
+ */
+ bool modified() const;
+
+ signals:
+ /**
+ Emitted whenever the page has changed, do not emit it directly,
+ use setModified() instead.
+ */
+ void changed();
+
+ public slots:
+ /**
+ Call this slot whenever the data were changed by the user. It
+ will emit the changed() signal and set the modified property.
+
+ @param modified Set whether the widget was modified.
+ */
+ void setModified( bool modified );
+
+ void setModified();
+
+ protected:
+ /**
+ Returns a pointer to the address book object.
+ */
+ KABC::AddressBook *addressBook() const;
+
+ private:
+ KABC::AddressBook *mAddressBook;
+ bool mModified;
+
+ class ContactEditorWidgetPrivate;
+ ContactEditorWidgetPrivate *d;
+};
+
+class ContactEditorWidgetFactory : public KLibFactory
+{
+ public:
+ virtual ContactEditorWidget *createWidget( KABC::AddressBook *ab, QWidget *parent,
+ const char *name = 0 ) = 0;
+
+ /**
+ Returns the i18ned title of this tab page.
+ */
+ virtual QString pageTitle() const { return ""; }
+
+ /**
+ Returns the identifier of the tab page where the widget
+ shall belong to.
+ */
+ virtual QString pageIdentifier() const = 0;
+
+ protected:
+ virtual QObject* createObject( QObject*, const char*, const char*,
+ const QStringList & )
+ {
+ return 0;
+ }
+};
+
+}
+
+#endif
diff --git a/kaddressbook/interfaces/core.cpp b/kaddressbook/interfaces/core.cpp
new file mode 100644
index 00000000..6c8e1091
--- /dev/null
+++ b/kaddressbook/interfaces/core.cpp
@@ -0,0 +1,33 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include "core.h"
+
+using namespace KAB;
+
+Core::Core( KXMLGUIClient *client, QObject *parent, const char *name )
+ : QObject( parent, name ), mGUIClient( client )
+{
+}
+
+#include "core.moc"
diff --git a/kaddressbook/interfaces/core.h b/kaddressbook/interfaces/core.h
new file mode 100644
index 00000000..276b20d6
--- /dev/null
+++ b/kaddressbook/interfaces/core.h
@@ -0,0 +1,203 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KAB_CORE_H
+#define KAB_CORE_H
+
+#include <config.h> // for KDEPIM_NEW_DISTRLISTS
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+#include <libkdepim/distributionlist.h>
+#endif
+
+#include <qobject.h>
+
+#include <kabc/field.h>
+#include <kcommand.h>
+#include <kxmlguiclient.h>
+#include <kdepimmacros.h>
+
+namespace KABC {
+class AddressBook;
+class Resource;
+}
+
+class QWidget;
+
+class KActionCollection;
+class KConfig;
+class KURL;
+
+namespace KAB {
+
+class SearchManager;
+
+class KDE_EXPORT Core : public QObject
+{
+ Q_OBJECT
+
+ public:
+ Core( KXMLGUIClient *client, QObject *parent, const char *name = 0 );
+
+ /**
+ Returns a pointer to the StdAddressBook of the application.
+ */
+ virtual KABC::AddressBook *addressBook() const = 0;
+
+ /**
+ Returns a pointer to the KConfig object of the application.
+ */
+ virtual KConfig *config() const = 0;
+
+ /**
+ Returns a pointer to the global KActionCollection object. So
+ other classes can register their actions easily.
+ */
+ virtual KActionCollection *actionCollection() const = 0;
+
+ /**
+ Returns a pointer to the gui client.
+ */
+ virtual KXMLGUIClient *guiClient() const { return mGUIClient; }
+
+ /**
+ Returns the current sort field.
+ */
+ virtual KABC::Field *currentSortField() const = 0;
+
+ /**
+ Returns the uid list of the currently selected contacts.
+ */
+ virtual QStringList selectedUIDs() const = 0;
+
+ /**
+ Displays a ResourceSelectDialog and returns the selected
+ resource or a null pointer if no resource was selected by
+ the user.
+ */
+ virtual KABC::Resource *requestResource( QWidget *parent ) = 0;
+
+ /**
+ Returns the parent widget.
+ */
+ virtual QWidget *widget() const = 0;
+
+ /**
+ Deletes given contacts from the address book.
+
+ @param uids The uids of the contacts, which shall be deleted.
+ */
+ virtual void deleteContacts( const QStringList &uids ) = 0;
+
+ /**
+ Deletes given contacts from the address book.
+
+ @param uids The uids of the contacts, which shall be deleted.
+ */
+ virtual void deleteDistributionLists( const QStringList &uids ) = 0;
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+ /**
+ Returns all the distribution lists.
+ */
+ virtual KPIM::DistributionList::List distributionLists() const = 0;
+
+
+ /**
+ Returns the name of all the distribution lists.
+ */
+ virtual QStringList distributionListNames() const = 0;
+
+ /**
+ sets the distribution list to display. If null, the regular
+ address book is to be displayed.
+ */
+ virtual void setSelectedDistributionList( const QString &name ) = 0;
+#endif
+
+ //// This class isn't part of interfaces/, so this method here isn't really useful
+ virtual SearchManager *searchManager() const = 0;
+
+ virtual KCommandHistory *commandHistory() const = 0;
+
+ signals:
+ /**
+ Forwarded from SearchManager
+ After it is emitted, distributionListNames() might have a different result.
+ */
+ void contactsUpdated();
+
+ public slots:
+ /**
+ Is called whenever a contact is selected in the view.
+ */
+ virtual void setContactSelected( const QString &uid ) = 0;
+
+ /**
+ DCOP METHOD: Adds the given email address to address book.
+ */
+ virtual void addEmail( const QString& addr ) = 0;
+
+ /**
+ DCOP METHOD: Imports the vCard, located at the given url.
+ */
+ virtual void importVCard( const KURL& url ) = 0;
+
+ /**
+ DCOP METHOD: Imports the given vCard.
+ */
+ virtual void importVCardFromData( const QString& vCard ) = 0;
+
+ /**
+ DCOP METHOD: Opens contact editor to input a new contact.
+ */
+ virtual void newContact() = 0;
+
+ /**
+ DCOP METHOD: Opens distribution list editor to input a new distribution list.
+ */
+ virtual void newDistributionList() = 0;
+
+ /**
+ DCOP METHOD: Returns the name of the contact, that matches the given
+ phone number.
+ */
+ virtual QString getNameByPhone( const QString& phone ) = 0;
+
+ /**
+ Shows an edit dialog for the given uid.
+ */
+ virtual void editContact( const QString &uid = QString::null ) = 0;
+
+ /**
+ Shows an edit dialog for the given distribution list
+ */
+ virtual void editDistributionList( const QString &name ) = 0;
+
+ private:
+ KXMLGUIClient *mGUIClient;
+};
+
+}
+
+#endif
diff --git a/kaddressbook/interfaces/extensionwidget.cpp b/kaddressbook/interfaces/extensionwidget.cpp
new file mode 100644
index 00000000..b7029158
--- /dev/null
+++ b/kaddressbook/interfaces/extensionwidget.cpp
@@ -0,0 +1,68 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include "core.h"
+
+#include "extensionwidget.h"
+
+using namespace KAB;
+
+ExtensionWidget::ExtensionWidget( Core *core, QWidget *parent,
+ const char *name )
+ : QWidget( parent, name ), mCore( core )
+{
+}
+
+ExtensionWidget::~ExtensionWidget()
+{
+}
+
+KAB::Core *ExtensionWidget::core() const
+{
+ return mCore;
+}
+
+bool ExtensionWidget::contactsSelected() const
+{
+ return mCore->selectedUIDs().count() != 0;
+}
+
+KABC::Addressee::List ExtensionWidget::selectedContacts()
+{
+ KABC::Addressee::List list;
+
+ const QStringList uids = mCore->selectedUIDs();
+ QStringList::ConstIterator it;
+ const QStringList::ConstIterator endIt = uids.end();
+ for ( it = uids.begin(); it != endIt; ++it )
+ list.append( mCore->addressBook()->findByUid( *it ) );
+
+ return list;
+}
+
+void ExtensionWidget::contactsSelectionChanged()
+{
+ // do nothing
+}
+
+#include "extensionwidget.moc"
diff --git a/kaddressbook/interfaces/extensionwidget.h b/kaddressbook/interfaces/extensionwidget.h
new file mode 100644
index 00000000..076defad
--- /dev/null
+++ b/kaddressbook/interfaces/extensionwidget.h
@@ -0,0 +1,120 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KAB_EXTENSIONWIDGET_H
+#define KAB_EXTENSIONWIDGET_H
+
+#include <qwidget.h>
+
+#include <kabc/addressbook.h>
+#include <klibloader.h>
+#include <kdepimmacros.h>
+
+#define KAB_EXTENSIONWIDGET_PLUGIN_VERSION 1
+
+namespace KAB {
+class Core;
+class ConfigureWidget;
+
+class KDE_EXPORT ExtensionWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ ExtensionWidget( Core *core, QWidget *parent, const char *name = 0 );
+ ~ExtensionWidget();
+
+ /**
+ @return A pointer to the core object
+ */
+ KAB::Core *core() const;
+
+ /**
+ Returns whether there are selected contacts in the view.
+ */
+ bool contactsSelected() const;
+
+ /**
+ Returns a list of contacts that are selected in the view.
+ Use @ref addresseesSelected() to test if there exists selected
+ contacts.
+ */
+ KABC::Addressee::List selectedContacts();
+
+ /**
+ This method is called whenever the selection in the view changed.
+ */
+ virtual void contactsSelectionChanged();
+
+ /**
+ This method should be reimplemented and return the i18ned title of this
+ widget.
+ */
+ virtual QString title() const = 0;
+
+ /**
+ This method should be reimplemented and return a unique identifier.
+ */
+ virtual QString identifier() const = 0;
+
+ signals:
+ void modified( const KABC::Addressee::List &list );
+ void deleted( const QStringList& uidList );
+
+ private:
+ KAB::Core *mCore;
+
+ class ExtensionWidgetPrivate;
+ ExtensionWidgetPrivate *d;
+};
+
+class ExtensionFactory : public KLibFactory
+{
+ public:
+ virtual ExtensionWidget *extension( KAB::Core *core, QWidget *parent,
+ const char *name = 0 ) = 0;
+
+ virtual ConfigureWidget *configureWidget( QWidget*, const char* = 0 )
+ {
+ return 0;
+ }
+
+ virtual bool configureWidgetAvailable() { return false; }
+
+ /**
+ This method should return the same identifier like the config
+ widget.
+ */
+ virtual QString identifier() const = 0;
+
+ protected:
+ virtual QObject* createObject( QObject*, const char*, const char*,
+ const QStringList & )
+ {
+ return 0;
+ }
+};
+
+}
+
+#endif
diff --git a/kaddressbook/interfaces/kaddressbook_contacteditorwidget.desktop b/kaddressbook/interfaces/kaddressbook_contacteditorwidget.desktop
new file mode 100644
index 00000000..bb646e78
--- /dev/null
+++ b/kaddressbook/interfaces/kaddressbook_contacteditorwidget.desktop
@@ -0,0 +1,55 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=KAddressBook/ContactEditorWidget
+Comment=KAddressBook Contact Editor Widget Plugin
+Comment[af]=KAddressBook kontak redigeerder inprop module
+Comment[bg]=Приставка за редактиране на контактите от адресника
+Comment[bs]=KAddressBook dodatak za prozor za izmjenu kontakta
+Comment[ca]=Endollable de l'estri editor de contactes de la llibreta d'adreces
+Comment[cs]=Modul widgetu editoru kontaktů KAddressBook
+Comment[da]=KAddressBook plugin til kontakteditorkontrol
+Comment[de]=Adressbuch Kontakteditor-Modul
+Comment[el]=Πρόσθετο επεξεργασίας επαφής του KAddressBook
+Comment[eo]=Kromaĵo por KAddressBook Kontaktredaktila Fenestraĵo
+Comment[es]=Accesorio de elemento de editor de contactos para KAddressBook
+Comment[et]=KDE aadressiraamatu kontaktide redigeerimise plugin
+Comment[eu]=KAddressBook-en kontaktu editore trepetaren plugin-a
+Comment[fa]=وصلۀ عنصر ویرایشگر تماس KAddressBook
+Comment[fi]=Osoitekirjan yhteystietojen muokkainliitännäinen
+Comment[fr]=Module d'édition de contacts de KAddressBook
+Comment[fy]=KAddressBook Kontaktbewurker-plugin
+Comment[gl]=Extensión Editor de Contactos para KAddressBook
+Comment[he]=תוסף תצוגה עבור עורך אנשי קשר של פנקס הכתובות
+Comment[hu]=KAddressBook névjegyszerkesztő bővítőmodul
+Comment[is]=KAddressbook tengiliðaritils íforrit
+Comment[it]=Plugin editor dei contatti di KAddressbook
+Comment[ja]=KAddressbook 連絡先エディタ ウィジェット プラグイン
+Comment[ka]= KDE-ს წიგნაკის კონტაქტთა რედაქტირების ელემენტის მოდული
+Comment[kk]=Адрестік кітапшаның контактты өңдеу модулі
+Comment[km]=កម្មវិធី​ជំនួយ​ធាតុ​ក្រាហ្វិក​កម្មវិធី​និពន្ធ​ទំនាក់ទំនង​របស់ KAddressBook
+Comment[lt]=KAddressBook kontaktų redaktoriaus valdiklių priedas
+Comment[mk]=Приклучок за уредување контакти во КАдресар
+Comment[ms]=Plugin Widget Editor Orang Hubungan KAddressBook
+Comment[nb]=KAddressbook programtillegg for kontakt redigeringselement
+Comment[nds]=Editormoduul för KAdressbook-Kontakten
+Comment[ne]=केडीई ठेगाना पुस्तिका सम्पर्क सम्पादक विजेट प्लगइन
+Comment[nl]=KAddressBook Contacteditor-plugin
+Comment[nn]=Programtillegg for kontaktredigering i KDE-adresseboka
+Comment[pl]=Wtyczka okna edycji wizytówki dla KAddressBook
+Comment[pt]='Plugin' de Edição de 'Widgets' de Contacto do KAddressbook
+Comment[pt_BR]=Plug-in do Editor de Contatos do KAddressBook
+Comment[ru]=Редактор контакта адресной книги KDE
+Comment[sk]=KAddressBook modul pre editor kontaktov
+Comment[sl]=Vstavek gradnika urejevalnika stikov za Adresar
+Comment[sr]=KAddressBook прикључак контроле едитора контаката
+Comment[sr@Latn]=KAddressBook priključak kontrole editora kontakata
+Comment[sv]=Kadressbok-insticksprogram för kontakteditor
+Comment[ta]=கேமுகவரிபுத்தகம் தொடர்பு தொகுப்பான் சாளர சொருகுப்பொருள்
+Comment[tg]=Муҳаррири алоқоти китоби адресии KDE
+Comment[tr]=Adres Defteri Kişi Düzenleyici Parçacık Eklentisi
+Comment[uk]=Втулок редагування контактів адресної книги
+Comment[zh_CN]=KAddressBook 联系人编辑部件插件
+Comment[zh_TW]=KAddressBook 聯絡人編輯器外掛程式
+
+[PropertyDef::X-KDE-KAddressBook-CEWPluginVersion]
+Type=int
diff --git a/kaddressbook/interfaces/kaddressbook_extension.desktop b/kaddressbook/interfaces/kaddressbook_extension.desktop
new file mode 100644
index 00000000..55be3b71
--- /dev/null
+++ b/kaddressbook/interfaces/kaddressbook_extension.desktop
@@ -0,0 +1,59 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=KAddressBook/Extension
+Comment=KAddressBook Extension Plugin
+Comment[af]=KAddressBook uitbrei inprop module
+Comment[be]=Дапаўненне K Адраснай кнігі "Пашырэнне"
+Comment[bg]=Приставка-разширение за адресника
+Comment[bs]=KAddressBook dodatak proširenja
+Comment[ca]=Endollable Extension per al KAddressBook
+Comment[cs]=Rozšiřující modul pro Knihu adres
+Comment[cy]=Ategyn Estyniad KLlyfrCyfeiriadau
+Comment[da]=KAddressBook udvidelsesplugin
+Comment[de]=Erweiterungsmodul für Adressbuch
+Comment[el]=Πρόσθετο επέκτασης του KAddressBook
+Comment[eo]=KAddressBook Etendiga Kromaĵo
+Comment[es]=Plugin de extensión de KAddressBook
+Comment[et]=KDE aadressiraamatu laiendi plugin
+Comment[eu]=KAddressBook-en luzapen plugin-a
+Comment[fa]=وصلۀ پسوند KAddressBook
+Comment[fi]=KAddressbookin laajennusliitännäinen
+Comment[fr]=Module d'extension pour KAddressBook
+Comment[fy]=KAddressBook taheaksel plugin
+Comment[gl]=Engadido de Extensión para KAddressBook
+Comment[he]=תוסף הרחבה עבור פנקס הכתובות
+Comment[hi]=के-एड्रेस-बुक विस्तार प्लगइन
+Comment[hu]=KAddressBook kiegészítő modul
+Comment[is]=KAddressbook viðbótar íforrit
+Comment[it]=Plugin estensione di KAddressbook
+Comment[ja]=KAddressbook 拡張プラグイン
+Comment[ka]=KDE წიგნაკის გაფართოების მოდული
+Comment[kk]=KAddressBook кеңейту модулі
+Comment[km]=កម្មវិធី​ជំនួយ​ផ្នែក​បន្ថែម​របស់ KAddressBook
+Comment[lt]=KAddressBook praplėtimo priedas
+Comment[mk]=Приклучок за екстензии во КАдресар
+Comment[ms]=Plug masuk Sambungan KAddressBook
+Comment[nb]=KAddressbook-programtillegg for utvidelser
+Comment[nds]=Verwiedernmodüul för KAdressbook
+Comment[ne]=केडीई ठेगाना पुस्तिका विस्तार प्लगइन
+Comment[nl]=KAddressBook Extensie Plugin
+Comment[nn]=Programtillegg for utviding av KDE-adresseboka
+Comment[pl]=Wtyczka rozszerzenia dla KAddressBook
+Comment[pt]='Plugin' de Extensão do KAddressbook
+Comment[pt_BR]=Plug-in de Extensão do KAddressBook
+Comment[ro]=Modul de extensie KAddressBook
+Comment[ru]=Расширение адресной книги KDE
+Comment[sk]=KAddressBook plugin rozšírení
+Comment[sl]=Razširitveni vstavek za Adresar
+Comment[sr]=Прикључак KAddressBook-а за проширења
+Comment[sr@Latn]=Priključak KAddressBook-a za proširenja
+Comment[sv]=Kadressbok-utökningsinsticksprogram
+Comment[ta]=கேமுகவரிப்புத்தகம் விரிவாக்க சொருகுப்பொருள்
+Comment[tg]=Модули вусъатоти китоби адресии KDE
+Comment[tr]=KAdresDefteri Uzantı Eklentisi
+Comment[uk]=Втулок розширення адресної книги KAddressBook
+Comment[zh_CN]=KAddressBook 扩展插件
+Comment[zh_TW]=KAddressBook 延伸外掛程式
+
+[PropertyDef::X-KDE-KAddressBook-ExtensionPluginVersion]
+Type=int
diff --git a/kaddressbook/interfaces/kaddressbook_xxport.desktop b/kaddressbook/interfaces/kaddressbook_xxport.desktop
new file mode 100644
index 00000000..fb2b03d0
--- /dev/null
+++ b/kaddressbook/interfaces/kaddressbook_xxport.desktop
@@ -0,0 +1,62 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=KAddressBook/XXPort
+Comment=KAddressBook Import/Export Plugin
+Comment[af]=KAddressBook Invoer/Uitvoer inprop module
+Comment[be]=Дапаўненне K Адраснай кнігі "Імпарт/Экспарт"
+Comment[bg]=Приставка за импортиране/експортиране на данни от адресника
+Comment[br]=Lugent enporzh/ezporzh evit KAddressBook
+Comment[bs]=KAddressBook dodatak za uvoz/izvoz
+Comment[ca]=Endollable d'importació/exportació per a la llibreta d'adreces
+Comment[cs]=Modul knihy adres pro import/export
+Comment[cy]=Ategyn Mewnforio/Allforio KLlyfrCyfeiriadau
+Comment[da]=KAddressBook Import/Eksport-plugin
+Comment[de]=Import/Export-Modul für Adressbuch
+Comment[el]=Πρόσθετο εισαγωγής/εξαγωγής του KAddressBook
+Comment[eo]=KAddressBook Import-/Eksport-Kromaĵo
+Comment[es]=Plugin para importar/exportar en KAddressBook
+Comment[et]=KDE aadressiraamatu import/eksportplugin
+Comment[eu]=KAddressBook-en inportazio/esportazio plugin-a
+Comment[fa]=وصلۀ صادرات/واردات KAddressBook
+Comment[fi]=KAddressbookin tuonti/vienti-liitännäinen
+Comment[fr]=Module d'import / export pour KAddressBook
+Comment[fy]=KAddressBook Ymport/Eksport Plugin
+Comment[gl]=Extensión de Importación/Exportación para KAddressBook
+Comment[he]=תוסף ייבוא/יצוא עבור פנקס הכתובות
+Comment[hi]=के-एड्रेस-बुक आयात/निर्यात प्लगइन
+Comment[hu]=KAddressBook importálási/exportálási bővítőmodul
+Comment[is]=KAddressbook flytja inn/út íforrit
+Comment[it]=Plugin importa/esporta di KAddressbook
+Comment[ja]=KAddressbook インポート/エクスポートプラグイン
+Comment[ka]=წიგნაკის იმპორტ/ექსპორტის მოდული
+Comment[kk]=KAddressBook импорт/экспорт модулі
+Comment[km]=កម្មវិធី​ជំនួយ​នាំចូល/នាំចេញ​របស់ KAddressBook
+Comment[lt]=KAddressBook importo/eksporto priedas
+Comment[mk]=Приклучок за внесување/изнесување во КАдресар
+Comment[ms]=Plug masuk Import Eksport KAddressBook
+Comment[nb]=KAddressbook-programtillegg for import/eksport
+Comment[nds]=Import-/Exportmoduul för KAdressbook
+Comment[ne]=केडीई ठेगाना पुस्तिका आयात/निर्यात प्लगइन
+Comment[nn]=Programtillegg for importering/ekportering i KDE-adresseboka
+Comment[pl]=Wtyczka importu/eksportu dla KAddressBook
+Comment[pt]='Plugin' de Importação/Exportação do KAddressbook
+Comment[pt_BR]=Plug-in de Importação/Exportação do KAddressBook
+Comment[ro]=Modul de import/export pentru KAddressBook
+Comment[ru]=Экспорт и импорт адресной книги
+Comment[sk]=KAddressBook import/export plugin
+Comment[sl]=Vstavek za uvoz in izvoz iz Adresarja
+Comment[sr]=Прикључак KAddressBook-а за увоз/извоз
+Comment[sr@Latn]=Priključak KAddressBook-a za uvoz/izvoz
+Comment[sv]=Kadressbok-insticksprogram för import/export
+Comment[ta]=கேமுகவரிப்புத்தகம் ஏற்றுமதி/இறக்குமதி சொருகுப்பொருள்
+Comment[tg]=Содирот ва воридоти китоби адрес
+Comment[tr]=KAdresDefteri Al/Gönder Eklentisi
+Comment[uk]=Втулок імпорту/експорту адресної книги KAddressBook
+Comment[uz]=Manzillar daftari uchun import/eksport plagini
+Comment[uz@cyrillic]=Манзиллар дафтари учун импорт/экспорт плагини
+Comment[zh_CN]=KAddressBook 导入/导出插件
+Comment[zh_TW]=KAddressBook 匯入/匯出外掛程式
+
+[PropertyDef::X-KDE-KAddressBook-XXPortPluginVersion]
+Type=int
+
diff --git a/kaddressbook/interfaces/xxport.cpp b/kaddressbook/interfaces/xxport.cpp
new file mode 100644
index 00000000..0e9e515c
--- /dev/null
+++ b/kaddressbook/interfaces/xxport.cpp
@@ -0,0 +1,128 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qmap.h>
+#include <qsignalmapper.h>
+
+#include <kaction.h>
+#include <kinstance.h>
+#include <kmessagebox.h>
+#include <kapplication.h>
+#include "xxport.h"
+
+using namespace KAB;
+
+class XXPort::XXPortPrivate
+{
+ public:
+ QSignalMapper *mExportMapper;
+ QSignalMapper *mImportMapper;
+ KApplication *mKApp;
+};
+
+XXPort::XXPort( KABC::AddressBook *ab, QWidget *parent,
+ const char *name )
+ : QObject( parent, name ), mAddressBook( ab ), mParentWidget( parent ),
+ d( new XXPortPrivate )
+{
+ setInstance( new KInstance( "kaddressbook" ) );
+
+ d->mExportMapper = new QSignalMapper( this );
+ d->mImportMapper = new QSignalMapper( this );
+
+ connect( d->mExportMapper, SIGNAL( mapped( const QString& ) ),
+ SLOT( slotExportActivated( const QString& ) ) );
+ connect( d->mImportMapper, SIGNAL( mapped( const QString& ) ),
+ SLOT( slotImportActivated( const QString& ) ) );
+}
+
+XXPort::~XXPort()
+{
+ delete d;
+ d = 0;
+}
+
+bool XXPort::exportContacts( const KABC::AddresseeList&, const QString& )
+{
+ // do nothing
+ return false;
+}
+
+KABC::AddresseeList XXPort::importContacts( const QString& ) const
+{
+ // do nothing
+ return KABC::AddresseeList();
+}
+
+void XXPort::createImportAction( const QString &label, const QString &data )
+{
+ QString id = "file_import_" + identifier() + ( data.isEmpty() ? QString( "" ) : "_" + data );
+ KAction *action = new KAction( label, 0, d->mImportMapper, SLOT( map() ), actionCollection(), id.latin1() );
+
+ d->mImportMapper->setMapping( action, ( data.isEmpty() ? QString( "<empty>" ) : data ) );
+
+ setXMLFile( identifier() + "_xxportui.rc" );
+}
+
+void XXPort::createExportAction( const QString &label, const QString &data )
+{
+ QString id = "file_export_" + identifier() + ( data.isEmpty() ? QString( "" ) : "_" + data );
+ KAction *action = new KAction( label, 0, d->mExportMapper, SLOT( map() ), actionCollection(), id.latin1() );
+
+ d->mExportMapper->setMapping( action, ( data.isEmpty() ? QString( "<empty>" ) : data ) );
+
+ setXMLFile( identifier() + "_xxportui.rc" );
+}
+
+KABC::AddressBook *XXPort::addressBook() const
+{
+ return mAddressBook;
+}
+
+QWidget *XXPort::parentWidget() const
+{
+ return mParentWidget;
+}
+
+void XXPort::setKApplication( KApplication *app )
+{
+ d->mKApp = app;
+}
+
+void XXPort::processEvents() const
+{
+ if ( d->mKApp )
+ d->mKApp->processEvents();
+}
+
+void XXPort::slotExportActivated( const QString &data )
+{
+ emit exportActivated( identifier(), ( data == "<empty>" ? QString::null : data ) );
+}
+
+void XXPort::slotImportActivated( const QString &data )
+{
+ emit importActivated( identifier(), ( data == "<empty>" ? QString::null : data ) );
+}
+
+#include "xxport.moc"
diff --git a/kaddressbook/interfaces/xxport.h b/kaddressbook/interfaces/xxport.h
new file mode 100644
index 00000000..098688b9
--- /dev/null
+++ b/kaddressbook/interfaces/xxport.h
@@ -0,0 +1,179 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KAB_XXPORT_H
+#define KAB_XXPORT_H
+
+#include <qobject.h>
+
+#include <kabc/addressbook.h>
+#include <kabc/addresseelist.h>
+#include <klibloader.h>
+#include <kxmlguiclient.h>
+#include <kdepimmacros.h>
+
+#define KAB_XXPORT_PLUGIN_VERSION 1
+
+class KApplication;
+
+/**
+ K_EXPORT_KADDRESSBOOK_XXFILTER_CATALOG() creates the stub for a KAddressbook import/export filter.
+ @libname filename of the shared library, e.g. libkaddrbk_bookmark_xxport
+ @XXPortClass the import/export class - derived from the XXPort class
+ @catalog catalog file to search for translation lookup (NULL if no catalog needed)
+ @see: K_EXPORT_COMPONENT_FACTORY()
+ */
+#define K_EXPORT_KADDRESSBOOK_XXFILTER_CATALOG( libname, XXPortClass, catalog ) \
+ class KDE_NO_EXPORT localXXPortFactory : public KAB::XXPortFactory { \
+ KAB::XXPort *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) \
+ { const char *cat = catalog; \
+ if (cat) KGlobal::locale()->insertCatalogue(cat); \
+ return new XXPortClass( ab, parent, name ); \
+ } \
+ }; \
+ K_EXPORT_COMPONENT_FACTORY( libname, localXXPortFactory )
+
+/**
+ K_EXPORT_KADDRESSBOOK_XXFILTER() creates the stub for a KAddressbook import/export filter.
+ @libname filename of the shared library, e.g. libkaddrbk_bookmark_xxport
+ @XXPortClass the import/export class - derived from the XXPort class
+ @see: K_EXPORT_COMPONENT_FACTORY()
+ */
+#define K_EXPORT_KADDRESSBOOK_XXFILTER( libname, XXPortClass ) \
+ K_EXPORT_KADDRESSBOOK_XXFILTER_CATALOG( libname, XXPortClass, NULL )
+
+
+namespace KAB {
+
+class KDE_EXPORT XXPort : public QObject, virtual public KXMLGUIClient
+{
+ Q_OBJECT
+
+ public:
+ XXPort( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
+ ~XXPort();
+
+ /**
+ Returns the unique identifier of this xxport modul, it should
+ be the lowercase name of the import/export format e.g. 'vcard'
+ */
+ virtual QString identifier() const = 0;
+
+ /**
+ Reimplement this method if the XXPortManager shall
+ pass a sorted list to @ref exportContacts().
+ */
+ virtual bool requiresSorting() const { return false; }
+
+ /**
+ set the KApplication pointer.
+ @see: processEvents()
+ */
+ void setKApplication( KApplication *app );
+
+ /**
+ Processes outstanding KApplication events. It should be called
+ occasionally when the import/export filter is busy performing
+ a long operation (e.g. reading from slow external devices).
+ @see: QApplication::processEvents()
+ */
+ void processEvents() const;
+
+ public slots:
+ /**
+ Reimplement this method for exporting the contacts.
+ */
+ virtual bool exportContacts( const KABC::AddresseeList &list, const QString& identifier );
+
+ /**
+ Reimplement this method for importing the contacts.
+ */
+ virtual KABC::AddresseeList importContacts( const QString& identifier ) const;
+
+ signals:
+ /**
+ Emitted whenever the export action is activated.
+ The parameter contains the @ref identifier() for
+ unique identification.
+ */
+ void exportActivated( const QString&, const QString& );
+
+ /**
+ Emitted whenever the import action is activated.
+ The parameter contains the @ref identifier() for
+ unique identification.
+ */
+ void importActivated( const QString&, const QString& );
+
+ protected:
+ /**
+ Create the import action. The identifier is passed in the import slot.
+ */
+ void createImportAction( const QString &label, const QString &identifier = QString::null );
+
+ /**
+ Create the export action. The identifier is passed in the export slot.
+ */
+ void createExportAction( const QString &label, const QString &identifier = QString::null );
+
+ /**
+ Returns a pointer to the address book object.
+ */
+ KABC::AddressBook *addressBook() const;
+
+ /**
+ Returns a pointer to the parent widget. It can be used as parent for
+ message boxes.
+ */
+ QWidget *parentWidget() const;
+
+ private slots:
+ void slotImportActivated( const QString& );
+ void slotExportActivated( const QString& );
+
+ private:
+ KABC::AddressBook *mAddressBook;
+ QWidget *mParentWidget;
+
+ class XXPortPrivate;
+ XXPortPrivate *d;
+};
+
+class XXPortFactory : public KLibFactory
+{
+ public:
+ virtual XXPort *xxportObject( KABC::AddressBook *ab, QWidget *parent,
+ const char *name = 0 ) = 0;
+
+ protected:
+ virtual QObject* createObject( QObject*, const char*, const char*,
+ const QStringList & )
+ {
+ return 0;
+ }
+};
+
+
+} /* namespace KAB */
+
+#endif
diff --git a/kaddressbook/jumpbuttonbar.cpp b/kaddressbook/jumpbuttonbar.cpp
new file mode 100644
index 00000000..1c8eddba
--- /dev/null
+++ b/kaddressbook/jumpbuttonbar.cpp
@@ -0,0 +1,239 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qapplication.h>
+#include <qbuttongroup.h>
+#include <qevent.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qstring.h>
+#include <qstyle.h>
+
+#include <kabc/addressbook.h>
+#include <kabc/field.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <klocale.h>
+
+#include "core.h"
+
+#include "jumpbuttonbar.h"
+
+class JumpButton : public QPushButton
+{
+ public:
+ JumpButton( const QString &firstChar, const QString &lastChar,
+ QWidget *parent );
+
+ QString firstChar() const { return mChar; }
+
+ private:
+ QString mChar;
+};
+
+JumpButton::JumpButton( const QString &firstChar, const QString &lastChar,
+ QWidget *parent )
+ : QPushButton( "", parent ), mChar( firstChar )
+{
+ setToggleButton( true );
+ if ( !lastChar.isEmpty() )
+ setText( QString( "%1 - %2" ).arg( firstChar.upper() ).arg( lastChar.upper() ) );
+ else
+ setText( firstChar.upper() );
+}
+
+JumpButtonBar::JumpButtonBar( KAB::Core *core, QWidget *parent, const char *name )
+ : QWidget( parent, name ), mCore( core )
+{
+ setMinimumSize( 1, 1 );
+
+ QVBoxLayout *layout = new QVBoxLayout( this, 0, 0 );
+ layout->setAlignment( Qt::AlignTop );
+ layout->setAutoAdd( true );
+ layout->setResizeMode( QLayout::FreeResize );
+
+ mGroupBox = new QButtonGroup( 1, Qt::Horizontal, this );
+ mGroupBox->setExclusive( true );
+ mGroupBox->layout()->setSpacing( 0 );
+ mGroupBox->layout()->setMargin( 0 );
+ mGroupBox->setFrameStyle( QFrame::NoFrame );
+}
+
+JumpButtonBar::~JumpButtonBar()
+{
+}
+
+void JumpButtonBar::updateButtons()
+{
+ int currentButton = mGroupBox->selectedId();
+
+ // the easiest way to remove all buttons ;)
+ mButtons.setAutoDelete( true );
+ mButtons.clear();
+ mButtons.setAutoDelete( false );
+
+ QStringList characters;
+
+ // calculate how many buttons are possible
+ QFontMetrics fm = fontMetrics();
+ QPushButton *btn = new QPushButton( "", this );
+ btn->hide();
+ QSize buttonSize = style().sizeFromContents( QStyle::CT_PushButton, btn,
+ fm.size( ShowPrefix, "X - X") ).
+ expandedTo( QApplication::globalStrut() );
+ delete btn;
+
+ int buttonHeight = buttonSize.height() + 8;
+ uint possibleButtons = (height() / buttonHeight) - 1;
+
+ QString character;
+ KABC::AddressBook *ab = mCore->addressBook();
+ KABC::AddressBook::Iterator it;
+ for ( it = ab->begin(); it != ab->end(); ++it ) {
+ KABC::Field *field = 0;
+ field = mCore->currentSortField();
+ if ( field ) {
+ setEnabled( true );
+ if ( !field->value( *it ).isEmpty() )
+ character = field->value( *it )[ 0 ].lower();
+ } else {
+ setEnabled( false );
+ return;
+ }
+
+ if ( !character.isEmpty() && !characters.contains( character ) )
+ characters.append( character );
+ }
+
+ sortListLocaleAware( characters );
+
+ if ( characters.count() <= possibleButtons ) {
+ // at first the easy case: all buttons fits in window
+ for ( uint i = 0; i < characters.count(); ++i ) {
+ JumpButton *button = new JumpButton( characters[ i ], QString::null,
+ mGroupBox );
+ connect( button, SIGNAL( clicked() ), this, SLOT( letterClicked() ) );
+ mButtons.append( button );
+ button->show();
+ }
+ } else {
+ if ( possibleButtons == 0 ) // to avoid crashes on startup
+ return;
+ int offset = characters.count() / possibleButtons;
+ int odd = characters.count() % possibleButtons;
+ if ( odd )
+ offset++;
+
+ int current = 0;
+ for ( uint i = 0; i < possibleButtons; ++i ) {
+ if ( characters.count() - current == 0 )
+ continue;
+ if ( characters.count() - current <= possibleButtons - i ) {
+ JumpButton *button = new JumpButton( characters[ current ],
+ QString::null, mGroupBox );
+ connect( button, SIGNAL( clicked() ), this, SLOT( letterClicked() ) );
+ mButtons.append( button );
+ button->show();
+ current++;
+ } else {
+ int pos = ( current + offset >= (int)characters.count() ?
+ characters.count() - 1 : current + offset - 1 );
+ QString range;
+ for ( int j = current; j < pos + 1; ++j )
+ range.append( characters[ j ] );
+ JumpButton *button = new JumpButton( characters[ current ],
+ characters[ pos ], mGroupBox );
+ connect( button, SIGNAL( clicked() ), this, SLOT( letterClicked() ) );
+ mButtons.append( button );
+ button->show();
+ current = ( i + 1 ) * offset;
+ }
+ }
+ }
+
+ if ( currentButton != -1 )
+ mGroupBox->setButton( currentButton );
+ else
+ mGroupBox->setButton( 0 );
+
+ int maxWidth = 0;
+ QPushButton *button;
+ for ( button = mButtons.first(); button; button = mButtons.next() )
+ maxWidth = QMAX( maxWidth, button->sizeHint().width() );
+
+ setFixedWidth( maxWidth );
+}
+
+void JumpButtonBar::letterClicked()
+{
+ JumpButton *button = (JumpButton*)sender();
+ QString character = button->firstChar();
+
+ emit jumpToLetter( character );
+}
+
+void JumpButtonBar::resizeEvent( QResizeEvent* )
+{
+ updateButtons();
+}
+
+class SortContainer
+{
+ public:
+ SortContainer() {}
+ SortContainer( const QString &string )
+ : mString( string )
+ {
+ }
+
+ bool operator< ( const SortContainer &cnt )
+ {
+ return ( QString::localeAwareCompare( mString, cnt.mString ) < 0 );
+ }
+
+ QString data() const
+ {
+ return mString;
+ }
+
+ private:
+ QString mString;
+};
+
+void JumpButtonBar::sortListLocaleAware( QStringList &list )
+{
+ QValueList<SortContainer> sortList;
+
+ QStringList::ConstIterator it;
+ for ( it = list.begin(); it != list.end(); ++it )
+ sortList.append( SortContainer( *it ) );
+
+ qHeapSort( sortList );
+ list.clear();
+
+ QValueList<SortContainer>::ConstIterator sortIt;
+ for ( sortIt = sortList.begin(); sortIt != sortList.end(); ++sortIt )
+ list.append( (*sortIt).data() );
+}
+
+#include "jumpbuttonbar.moc"
diff --git a/kaddressbook/jumpbuttonbar.h b/kaddressbook/jumpbuttonbar.h
new file mode 100644
index 00000000..850b51b4
--- /dev/null
+++ b/kaddressbook/jumpbuttonbar.h
@@ -0,0 +1,79 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef JUMPBUTTONBAR_H
+#define JUMPBUTTONBAR_H
+
+#include <qsizepolicy.h>
+#include <qwidget.h>
+#include <qptrlist.h>
+#include <qstringlist.h>
+
+class QButtonGroup;
+class QResizeEvent;
+class QPushButton;
+
+namespace KAB {
+class Core;
+}
+
+namespace KABC {
+class Field;
+}
+
+/**
+ Used to draw the jump button bar on the right of the view.
+ */
+class JumpButtonBar : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ JumpButtonBar( KAB::Core *core, QWidget *parent, const char *name = 0 );
+ ~JumpButtonBar();
+
+ public slots:
+ void updateButtons();
+
+ signals:
+ /**
+ Emitted whenever a letter is selected by the user.
+ */
+ void jumpToLetter( const QString &character );
+
+ protected slots:
+ void letterClicked();
+
+ protected:
+ virtual void resizeEvent( QResizeEvent* );
+
+ private:
+ void sortListLocaleAware( QStringList &list );
+
+ KAB::Core *mCore;
+
+ QButtonGroup *mGroupBox;
+ QPtrList<QPushButton> mButtons;
+};
+
+#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
new file mode 100644
index 00000000..0702ce04
--- /dev/null
+++ b/kaddressbook/kabcore.cpp
@@ -0,0 +1,1647 @@
+/*
+ This file is part of KAddressbook.
+ Copyright (c) 2003 - 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+// Needed for ugly hack, to be removed in 4.0
+#include <unistd.h> // for usleep
+#include <qeventloop.h>
+
+#include <qclipboard.h>
+#include <qdir.h>
+#include <qfile.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qptrlist.h>
+#include <qwidgetstack.h>
+#include <qregexp.h>
+#include <qvbox.h>
+
+#include <kabc/addresseelist.h>
+#include <kabc/errorhandler.h>
+#include <kabc/resource.h>
+#include <kabc/stdaddressbook.h>
+#include <kabc/vcardconverter.h>
+#include <kabc/resourcefile.h>
+#include <kaboutdata.h>
+#include <kaccelmanager.h>
+#include <kapplication.h>
+#include <dcopclient.h>
+#include <kactionclasses.h>
+#include <kcmdlineargs.h>
+#include <kcmultidialog.h>
+#include <kdebug.h>
+#include <kdeversion.h>
+#include <kimproxy.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kprinter.h>
+#include <kprotocolinfo.h>
+#include <kpushbutton.h>
+#include <kresources/selectdialog.h>
+#include <kstandarddirs.h>
+#include <kstatusbar.h>
+#include <kstdguiitem.h>
+#include <kxmlguiclient.h>
+#include <ktoolbar.h>
+#include <libkdepim/addresseeview.h>
+#include <libkdepim/categoryeditdialog.h>
+#include <libkdepim/categoryselectdialog.h>
+#include <libkdepim/resourceabc.h>
+#include "distributionlisteditor.h"
+
+#include "addresseeutil.h"
+#include "addresseeeditordialog.h"
+#include "distributionlistentryview.h"
+#include "extensionmanager.h"
+#include "filterselectionwidget.h"
+#include "incsearchwidget.h"
+#include "jumpbuttonbar.h"
+#include "kablock.h"
+#include "kabprefs.h"
+#include "kabtools.h"
+#include "kaddressbookservice.h"
+#include "kaddressbookiface.h"
+#include "ldapsearchdialog.h"
+#include "locationmap.h"
+#include "printing/printingwizard.h"
+#include "searchmanager.h"
+#include "undocmds.h"
+#include "viewmanager.h"
+#include "xxportmanager.h"
+
+#include "kabcore.h"
+
+KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent,
+ const QString &file, const char *name )
+ : KAB::Core( client, parent, name ), mStatusBar( 0 ), mViewManager( 0 ),
+ mExtensionManager( 0 ), mJumpButtonBar( 0 ), mCategorySelectDialog( 0 ),
+ mCategoryEditDialog( 0 ), mLdapSearchDialog( 0 ), mReadWrite( readWrite ),
+ mModified( false )
+{
+ mWidget = new QWidget( parent, name );
+
+ mIsPart = !parent->isA( "KAddressBookMain" );
+
+ mAddressBookChangedTimer = new QTimer( this );
+ connect( mAddressBookChangedTimer, SIGNAL( timeout() ),
+ this, SLOT( addressBookChanged() ) );
+
+ if ( file.isEmpty() ) {
+ mAddressBook = KABC::StdAddressBook::self( true );
+ } else {
+ kdDebug(5720) << "KABCore(): document '" << file << "'" << endl;
+ mAddressBook = new KABC::AddressBook;
+ mAddressBook->addResource( new KABC::ResourceFile( file ) );
+ if ( !mAddressBook->load() ) {
+ KMessageBox::error( parent, i18n("Unable to load '%1'.").arg( file ) );
+ }
+ }
+ mAddressBook->setErrorHandler( new KABC::GuiErrorHandler( mWidget ) );
+
+#if ! KDE_IS_VERSION(3,5,8)
+ mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
+ "X-Department", "KADDRESSBOOK" );
+#endif
+ mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
+ "X-Profession", "KADDRESSBOOK" );
+ mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
+ "X-AssistantsName", "KADDRESSBOOK" );
+ mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
+ "X-ManagersName", "KADDRESSBOOK" );
+ mAddressBook->addCustomField( i18n( "Partner's Name" ), KABC::Field::Personal,
+ "X-SpousesName", "KADDRESSBOOK" );
+ mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
+ "X-Office", "KADDRESSBOOK" );
+ mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
+ "X-IMAddress", "KADDRESSBOOK" );
+ mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
+ "X-Anniversary", "KADDRESSBOOK" );
+ mAddressBook->addCustomField( i18n( "Blog" ), KABC::Field::Personal,
+ "BlogFeed", "KADDRESSBOOK" );
+
+ mSearchManager = new KAB::SearchManager( mAddressBook, parent );
+
+ connect( mSearchManager, SIGNAL( contactsUpdated() ),
+ this, SLOT( slotContactsUpdated() ) );
+
+ initGUI();
+
+ connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ),
+ SLOT( delayedAddressBookChanged() ) );
+ connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ),
+ SLOT( delayedAddressBookChanged() ) );
+
+ mIncSearchWidget->setFocus();
+
+ connect( mViewManager, SIGNAL( selected( const QString& ) ),
+ SLOT( setContactSelected( const QString& ) ) );
+ connect( mViewManager, SIGNAL( executed( const QString& ) ),
+ SLOT( editContact( const QString& ) ) );
+ connect( mViewManager, SIGNAL( modified() ),
+ SLOT( setModified() ) );
+ connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
+ mXXPortManager, SLOT( importVCard( const KURL& ) ) );
+ connect( mViewManager, SIGNAL( viewFieldsChanged() ),
+ SLOT( updateIncSearchWidget() ) );
+ connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ),
+ this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
+ connect( mExtensionManager, SIGNAL( deleted( const QStringList& ) ),
+ this, SLOT( extensionDeleted( const QStringList& ) ) );
+
+ connect( mXXPortManager, SIGNAL( modified() ),
+ SLOT( setModified() ) );
+
+ connect( mDetailsViewer, SIGNAL( highlightedMessage( const QString& ) ),
+ SLOT( detailsHighlighted( const QString& ) ) );
+
+ connect( mIncSearchWidget, SIGNAL( scrollUp() ),
+ mViewManager, SLOT( scrollUp() ) );
+ connect( mIncSearchWidget, SIGNAL( scrollDown() ),
+ mViewManager, SLOT( scrollDown() ) );
+
+ mAddressBookService = new KAddressBookService( this );
+
+ mCommandHistory = new KCommandHistory( actionCollection(), true );
+ connect( mCommandHistory, SIGNAL( commandExecuted() ),
+ mSearchManager, SLOT( reload() ) );
+
+ mSearchManager->reload();
+
+ setModified( false );
+