24 #include "vcardviewer.h"
25 #include "kmaddrbook.h"
26 #include <kaddrbook.h>
28 #include <addresseeview.h>
29 using KPIM::AddresseeView;
31 #include <tdeabc/vcardconverter.h>
32 #include <tdeabc/addressee.h>
33 using TDEABC::VCardConverter;
34 using TDEABC::Addressee;
36 #include <tdelocale.h>
40 #if defined(KABC_VCARD_ENCODING_FIX)
41 KMail::VCardViewer::VCardViewer( TQWidget *parent, const TQByteArray &vCard, const char *name )
43 KMail::VCardViewer::VCardViewer( TQWidget *parent, const TQString &vCard, const char *name )
45 : KDialogBase( parent, name, false, i18n( "VCard Viewer"), User1|User2|User3|Close, Close,
46 true, i18n( "&Import"), i18n( "&Next Card"), i18n( "&Previous Card") )
48 mAddresseeView = new AddresseeView( this);
49 mAddresseeView->enableLinks( 0 );
50 mAddresseeView->setVScrollBarMode(TQScrollView::Auto);
51 setMainWidget(mAddresseeView);
54 #if defined(KABC_VCARD_ENCODING_FIX)
55 mAddresseeList = vcc.parseVCardsRaw( vCard.data() );
57 mAddresseeList = vcc.parseVCards( vCard );
59 if ( !mAddresseeList.empty() ) {
60 itAddresseeList = mAddresseeList.begin();
61 mAddresseeView->setAddressee( *itAddresseeList );
62 if ( mAddresseeList.size() <= 1 ) {
63 showButton(User2, false);
64 showButton(User3, false);
67 enableButton(User3, false);
70 mAddresseeView->setText(i18n( "Failed to parse vCard."));
71 enableButton(User1, false);
77 KMail::VCardViewer::~VCardViewer()
81 void KMail::VCardViewer::slotUser1()
83 KAddrBookExternal::addVCard( *itAddresseeList, this );
86 void KMail::VCardViewer::slotUser2()
89 mAddresseeView->setAddressee( *(++itAddresseeList) );
90 if ( itAddresseeList == --(mAddresseeList.end()) )
91 enableButton(User2, false);
92 enableButton(User3, true);
95 void KMail::VCardViewer::slotUser3()
98 mAddresseeView->setAddressee( *(--itAddresseeList) );
99 if ( itAddresseeList == mAddresseeList.begin() )
100 enableButton(User3, false);
101 enableButton(User2, true);
104 #include "vcardviewer.moc"
|