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 setMainWidget(mContactViewer);
56 mAddresseeList = vcc.parseVCards( vCard );
57 if ( !mAddresseeList.empty() ) {
58 itAddresseeList = mAddresseeList.constBegin();
59 mContactViewer->setRawContact( *itAddresseeList );
60 if ( mAddresseeList.size() <= 1 ) {
61 showButton(User2,
false);
62 showButton(User3,
false);
65 enableButton(User3,
false);
66 connect(
this, SIGNAL(user1Clicked()), SLOT(slotUser1()) );
67 connect(
this, SIGNAL(user2Clicked()), SLOT(slotUser2()) );
68 connect(
this, SIGNAL(user3Clicked()), SLOT(slotUser3()) );
70 mContactViewer->setRawContact(KABC::Addressee());
71 enableButton(User1,
false);
72 showButton(User2,
false);
73 showButton(User3,
false);
84 void VCardViewer::readConfig()
87 const QSize size = group.readEntry(
"Size", QSize(300, 400) );
88 if ( size.isValid() ) {
93 void VCardViewer::writeConfig()
96 group.writeEntry(
"Size", size() );
101 void VCardViewer::slotUser1()
103 const KABC::Addressee contact = *itAddresseeList;
105 KPIM::AddContactJob *job =
new KPIM::AddContactJob( contact,
this,
this );
109 void VCardViewer::slotUser2()
112 mContactViewer->setRawContact( *(++itAddresseeList) );
113 if ( itAddresseeList == --(mAddresseeList.constEnd()) )
114 enableButton(User2,
false);
115 enableButton(User3,
true);
118 void VCardViewer::slotUser3()
121 mContactViewer->setRawContact( *(--itAddresseeList) );
122 if ( itAddresseeList == mAddresseeList.constBegin() )
123 enableButton(User3,
false);
124 enableButton(User2,
true);
127 #include "vcardviewer.moc"
static GlobalSettings * self()
VCardViewer(QWidget *parent, const QByteArray &vCard)