kmail
vcardviewer.cppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifdef HAVE_CONFIG_H
00021 #include <config.h>
00022 #endif
00023
00024 #include "vcardviewer.h"
00025 #include "kmaddrbook.h"
00026 #include <kaddrbook.h>
00027
00028 #include <addresseeview.h>
00029 using KPIM::AddresseeView;
00030
00031 #include <kabc/vcardconverter.h>
00032 #include <kabc/addressee.h>
00033 using KABC::VCardConverter;
00034 using KABC::Addressee;
00035
00036 #include <klocale.h>
00037
00038 #include <qstring.h>
00039
00040 KMail::VCardViewer::VCardViewer(QWidget *parent, const QString& vCard, const char* name)
00041 : KDialogBase( parent, name, false, i18n("VCard Viewer"), User1|User2|User3|Close, Close,
00042 true, i18n("&Import"), i18n("&Next Card"), i18n("&Previous Card") )
00043 {
00044 mAddresseeView = new AddresseeView(this);
00045 mAddresseeView->enableLinks( 0 );
00046 mAddresseeView->setVScrollBarMode(QScrollView::Auto);
00047 setMainWidget(mAddresseeView);
00048
00049 VCardConverter vcc;
00050 mAddresseeList = vcc.parseVCards( vCard );
00051 if ( !mAddresseeList.empty() ) {
00052 itAddresseeList = mAddresseeList.begin();
00053 mAddresseeView->setAddressee( *itAddresseeList );
00054 if ( mAddresseeList.size() <= 1 ) {
00055 showButton(User2, false);
00056 showButton(User3, false);
00057 }
00058 else
00059 enableButton(User3, false);
00060 }
00061 else {
00062 mAddresseeView->setText(i18n("Failed to parse vCard."));
00063 enableButton(User1, false);
00064 }
00065
00066 resize(300,400);
00067 }
00068
00069 KMail::VCardViewer::~VCardViewer()
00070 {
00071 }
00072
00073 void KMail::VCardViewer::slotUser1()
00074 {
00075 KAddrBookExternal::addVCard( *itAddresseeList, this );
00076 }
00077
00078 void KMail::VCardViewer::slotUser2()
00079 {
00080
00081 mAddresseeView->setAddressee( *(++itAddresseeList) );
00082 if ( itAddresseeList == --(mAddresseeList.end()) )
00083 enableButton(User2, false);
00084 enableButton(User3, true);
00085 }
00086
00087 void KMail::VCardViewer::slotUser3()
00088 {
00089
00090 mAddresseeView->setAddressee( *(--itAddresseeList) );
00091 if ( itAddresseeList == mAddresseeList.begin() )
00092 enableButton(User3, false);
00093 enableButton(User2, true);
00094 }
00095
00096 #include "vcardviewer.moc"
|