• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • widgets
vcardviewer.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  Copyright (C) 2002 Daniel Molkentin <molkentin@kde.org>
3  Copyright (C) 2013 Laurent Montel <montel@kde.org>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; see the file COPYING. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19  */
20 
21 
22 
23 #include "vcardviewer.h"
24 #include "settings/globalsettings.h"
25 #include "kaddressbookgrantlee/widget/grantleecontactviewer.h"
26 
27 #include <kabc/vcardconverter.h>
28 using KABC::VCardConverter;
29 using KABC::Addressee;
30 
31 #include <klocale.h>
32 
33 #include <libkdepim/job/addcontactjob.h>
34 
35 #ifndef KABC_ADDRESSEE_METATYPE_DEFINED
36 Q_DECLARE_METATYPE( KABC::Addressee )
37 #endif
38 
39 using namespace MessageViewer;
40 
41 VCardViewer::VCardViewer(QWidget *parent, const QByteArray& vCard)
42  : KDialog( parent )
43 {
44  setCaption( i18n("vCard Viewer") );
45  setButtons( User1|User2|User3|Close );
46  setModal( false );
47  setDefaultButton( Close );
48  setButtonGuiItem( User1, KGuiItem(i18n("&Import")) );
49  setButtonGuiItem( User2, KGuiItem(i18n("&Next Card")) );
50  setButtonGuiItem( User3, KGuiItem(i18n("&Previous Card")) );
51 
52  mContactViewer = new KAddressBookGrantlee::GrantleeContactViewer( this );
53  setMainWidget(mContactViewer);
54 
55  VCardConverter vcc;
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);
63  }
64  else
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()) );
69  } else {
70  mContactViewer->setRawContact(KABC::Addressee());
71  enableButton(User1, false);
72  showButton(User2, false);
73  showButton(User3, false);
74  }
75 
76  readConfig();
77 }
78 
79 VCardViewer::~VCardViewer()
80 {
81  writeConfig();
82 }
83 
84 void VCardViewer::readConfig()
85 {
86  KConfigGroup group( MessageViewer::GlobalSettings::self()->config(), "VCardViewer" );
87  const QSize size = group.readEntry( "Size", QSize(300, 400) );
88  if ( size.isValid() ) {
89  resize( size );
90  }
91 }
92 
93 void VCardViewer::writeConfig()
94 {
95  KConfigGroup group( MessageViewer::GlobalSettings::self()->config(), "VCardViewer" );
96  group.writeEntry( "Size", size() );
97  group.sync();
98 }
99 
100 
101 void VCardViewer::slotUser1()
102 {
103  const KABC::Addressee contact = *itAddresseeList;
104 
105  KPIM::AddContactJob *job = new KPIM::AddContactJob( contact, this, this );
106  job->start();
107 }
108 
109 void VCardViewer::slotUser2()
110 {
111  // next vcard
112  mContactViewer->setRawContact( *(++itAddresseeList) );
113  if ( itAddresseeList == --(mAddresseeList.constEnd()) )
114  enableButton(User2, false);
115  enableButton(User3, true);
116 }
117 
118 void VCardViewer::slotUser3()
119 {
120  // previous vcard
121  mContactViewer->setRawContact( *(--itAddresseeList) );
122  if ( itAddresseeList == mAddresseeList.constBegin() )
123  enableButton(User3, false);
124  enableButton(User2, true);
125 }
126 
127 #include "vcardviewer.moc"
globalsettings.h
QWidget
KDialog
MessageViewer::VCardViewer::~VCardViewer
~VCardViewer()
Definition: vcardviewer.cpp:79
MessageViewer::GlobalSettings::self
static GlobalSettings * self()
Definition: globalsettings.cpp:34
MessageViewer::VCardViewer::VCardViewer
VCardViewer(QWidget *parent, const QByteArray &vCard)
Definition: vcardviewer.cpp:41
vcardviewer.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal