25 #include "kaddressbookgrantlee/widget/grantleecontactviewer.h"
27 #include <kabc/vcardconverter.h>
28 using KABC::VCardConverter;
29 using KABC::Addressee;
33 #include <libkdepim/job/addcontactjob.h>
35 #ifndef KABC_ADDRESSEE_METATYPE_DEFINED
36 Q_DECLARE_METATYPE( KABC::Addressee )
39 using namespace MessageViewer;
44 setCaption( i18n(
"vCard Viewer") );
45 setButtons( User1|User2|User3|Close );
47 setDefaultButton( Close );
48 setButtonGuiItem( User1, KGuiItem(i18n(
"&Import")) );
49 setButtonGuiItem( User2, KGuiItem(i18n(
"&Next Card")) );
50 setButtonGuiItem( User3, KGuiItem(i18n(
"&Previous Card")) );
52 mContactViewer =
new KAddressBookGrantlee::GrantleeContactViewer(
this );
53 mContactViewer->setForceDisableQRCode(
true);
54 setMainWidget(mContactViewer);
57 mAddresseeList = vcc.parseVCards( vCard );
58 if ( !mAddresseeList.empty() ) {
59 itAddresseeList = mAddresseeList.constBegin();
60 mContactViewer->setRawContact( *itAddresseeList );
61 if ( mAddresseeList.size() <= 1 ) {
62 showButton(User2,
false);
63 showButton(User3,
false);
66 enableButton(User3,
false);
67 connect(
this, SIGNAL(user1Clicked()), SLOT(slotUser1()) );
68 connect(
this, SIGNAL(user2Clicked()), SLOT(slotUser2()) );
69 connect(
this, SIGNAL(user3Clicked()), SLOT(slotUser3()) );
71 mContactViewer->setRawContact(KABC::Addressee());
72 enableButton(User1,
false);
73 showButton(User2,
false);
74 showButton(User3,
false);
85 void VCardViewer::readConfig()
88 const QSize size = group.readEntry(
"Size",
QSize(300, 400) );
94 void VCardViewer::writeConfig()
97 group.writeEntry(
"Size", size() );
102 void VCardViewer::slotUser1()
104 const KABC::Addressee contact = *itAddresseeList;
106 KPIM::AddContactJob *job =
new KPIM::AddContactJob( contact,
this,
this );
110 void VCardViewer::slotUser2()
113 mContactViewer->setRawContact( *(++itAddresseeList) );
114 if ( itAddresseeList == --(mAddresseeList.constEnd()) )
115 enableButton(User2,
false);
116 enableButton(User3,
true);
119 void VCardViewer::slotUser3()
122 mContactViewer->setRawContact( *(--itAddresseeList) );
123 if ( itAddresseeList == mAddresseeList.constBegin() )
124 enableButton(User3,
false);
125 enableButton(User2,
true);
static GlobalSettings * self()
VCardViewer(QWidget *parent, const QByteArray &vCard)