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

knode

  • sources
  • kde-4.14
  • kdepim
  • knode
  • configuration
identity_widget.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2009 Olivier Trichet <nive@nivalis.org>
3 
4  Permission to use, copy, modify, and distribute this software
5  and its documentation for any purpose and without fee is hereby
6  granted, provided that the above copyright notice appear in all
7  copies and that both that the copyright notice and this
8  permission notice and warranty disclaimer appear in supporting
9  documentation, and that the name of the author not be used in
10  advertising or publicity pertaining to distribution of the
11  software without specific, written prior permission.
12 
13  The author disclaim all warranties with regard to this
14  software, including all implied warranties of merchantability
15  and fitness. In no event shall the author be liable for any
16  special, indirect or consequential damages or any damages
17  whatsoever resulting from loss of use, data or profits, whether
18  in an action of contract, negligence or other tortious action,
19  arising out of or in connection with the use or performance of
20  this software.
21 */
22 
23 #include "identity_widget.h"
24 
25 #include "identity_edition_dialog.h"
26 #include "kngroup.h"
27 #include "knnntpaccount.h"
28 #include "settings.h"
29 #include "settings_container_interface.h"
30 
31 #include <KPIMIdentities/Identity>
32 #include <KPIMIdentities/IdentityManager>
33 #include <QPointer>
34 
35 
36 using namespace KPIMIdentities;
37 
38 namespace KNode {
39 
40 IdentityWidget::IdentityWidget( SettingsContainerInterface *settingsContainer, const KComponentData &inst, QWidget *parent )
41  : KCModule( inst, parent ),
42  mConfigurationContainer( settingsContainer )
43 {
44  setupUi( this );
45  if ( dynamic_cast< Settings * >( mConfigurationContainer ) ) {
46  // Ensure the identity selector is not disabled
47  mUseSpecificIdentity->setChecked( true );
48  mUseSpecificIdentity->hide();
49  }
50 
51  connect( mIdentitySelector, SIGNAL(identityChanged(uint)),
52  this, SLOT(identitySelected(uint)) );
53 
54  connect( mUseSpecificIdentity, SIGNAL(clicked(bool)),
55  this, SLOT(useSpecificIdentity(bool)) );
56 
57  connect( mModifyIdentitiesButton, SIGNAL(clicked(bool)),
58  this, SLOT(modifyIdentities()) );
59 }
60 
61 IdentityWidget::~IdentityWidget()
62 {
63 }
64 
65 
66 void IdentityWidget::load()
67 {
68  const Identity &identity = mConfigurationContainer->identity();
69  if ( identity.isNull() ) {
70  mUseSpecificIdentity->setChecked( false );
71  useSpecificIdentity( false );
72  } else {
73  mIdentitySelector->setCurrentIdentity( identity.uoid() );
74  mUseSpecificIdentity->setChecked( true );
75  useSpecificIdentity( true );
76  }
77 }
78 
79 void IdentityWidget::save()
80 {
81  if ( mUseSpecificIdentity->isChecked() ) {
82  IdentityManager *im = KNGlobals::self()->identityManager();
83  uint uoid = mIdentitySelector->currentIdentity();
84  mConfigurationContainer->setIdentity( im->identityForUoid( uoid ) );
85  } else {
86  mConfigurationContainer->setIdentity( Identity::null() );
87  }
88 
89  mConfigurationContainer->writeConfig();
90 }
91 
92 
93 void IdentityWidget::identitySelected( uint uoid )
94 {
95  KPIMIdentities::IdentityManager *im = KNGlobals::self()->identityManager();
96  const Identity &identity = im->identityForUoid( uoid );
97  loadFromIdentity( identity );
98 
99  emit changed( ( uoid != mConfigurationContainer->identity().uoid() ) );
100 }
101 
102 void IdentityWidget::useSpecificIdentity( bool useSpecific )
103 {
104  mIdentitySelector->setEnabled( useSpecific );
105  mModifyIdentitiesButton->setEnabled( useSpecific );
106  if ( useSpecific ) {
107  identitySelected( mIdentitySelector->currentIdentity() );
108  } else {
109  loadFromIdentity( Identity::null() );
110  emit changed( !mConfigurationContainer->identity().isNull() );
111  }
112 }
113 
114 void IdentityWidget::loadFromIdentity( const Identity &identity )
115 {
116  mName->setText( identity.fullName() );
117  mOrganisation->setText( identity.organization() );
118  mEmail->setText( identity.primaryEmailAddress() );
119  mReplyto->setText( identity.replyToAddr() );
120  mMailcopiesto->setText( identity.property( "Mail-Copies-To" ).toString() );
121 }
122 
123 void IdentityWidget::modifyIdentities()
124 {
125  IdentityEditionDialog dlg( mIdentitySelector->currentIdentity(), this );
126  dlg.exec();
127  // Note: the combo box "mIdentitySelector" is updated automatically via
128  // DBus through the IdentityManager
129 
130  // Reload information of the selected identity
131  identitySelected( mIdentitySelector->currentIdentity() );
132 }
133 
134 } // namespace KNode
135 
QWidget
identity_edition_dialog.h
KNode::IdentityWidget::load
virtual void load()
Reimplemented from KCModule::load().
Definition: identity_widget.cpp:66
KNGlobals::self
static KNGlobals * self()
Return the KNGlobals instance.
Definition: knglobals.cpp:72
identity_widget.h
kngroup.h
knnntpaccount.h
KNode::SettingsContainerInterface
Interface for object (global settings, account and group) that contains common settings (like identit...
Definition: settings_container_interface.h:40
KNGlobals::identityManager
KPIMIdentities::IdentityManager * identityManager()
Returns the identity manager.
Definition: knglobals.cpp:167
KNode::IdentityWidget::~IdentityWidget
~IdentityWidget()
Definition: identity_widget.cpp:61
settings_container_interface.h
KNode::IdentityWidget::save
virtual void save()
Reimplemented from KCModule::save();.
Definition: identity_widget.cpp:79
KNode::SettingsContainerInterface::identity
virtual const KPIMIdentities::Identity & identity() const =0
Returns the identity configured for this container.
settings.h
KNode::SettingsContainerInterface::setIdentity
virtual void setIdentity(const KPIMIdentities::Identity &identity)=0
Sets the identity for this group.
KNode::SettingsContainerInterface::writeConfig
virtual void writeConfig()=0
Save the configuration to disk.
KCModule
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knode

Skip menu "knode"
  • Main Page
  • Namespace List
  • 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
  • pimprint

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