32#include "identitymanager.h"
34#include <klocalizedstring.h>
38using namespace KPIMIdentities;
45class KPIMIdentities::IdentityCombo::Private
50IdentityCombo::IdentityCombo(
IdentityManager *manager, QWidget *parent )
51 : QComboBox( parent ), mIdentityManager( manager ), d( 0 )
55 connect(
this, SIGNAL(activated(
int)), SLOT(slotEmitChanged(
int)) );
56 connect(
this, SIGNAL(identityChanged(uint)),
this, SLOT(slotUpdateTooltip(uint)) );
57 connect( manager, SIGNAL(changed()),
58 SLOT(slotIdentityManagerChanged()) );
59 slotUpdateTooltip( currentIdentity() );
62IdentityCombo::~IdentityCombo()
67QString IdentityCombo::currentIdentityName()
const
69 return mIdentityManager->
identities()[ currentIndex()];
72uint IdentityCombo::currentIdentity()
const
74 return mUoidList[ currentIndex()];
77void IdentityCombo::setCurrentIdentity(
const Identity &identity )
79 setCurrentIdentity( identity.
uoid() );
82void IdentityCombo::setCurrentIdentity(
const QString &name )
84 int idx = mIdentityManager->
identities().indexOf( name );
85 if ( ( idx < 0 ) || ( idx == currentIndex() ) ) {
90 setCurrentIndex( idx );
91 blockSignals(
false );
93 slotEmitChanged( idx );
96void IdentityCombo::setCurrentIdentity( uint uoid )
98 int idx = mUoidList.indexOf( uoid );
99 if ( ( idx < 0 ) || ( idx == currentIndex() ) ) {
103 blockSignals(
true );
104 setCurrentIndex( idx );
105 blockSignals(
false );
107 slotEmitChanged( idx );
110void IdentityCombo::reloadCombo()
112 QStringList identities = mIdentityManager->
identities();
114 assert( !identities.isEmpty() );
116 addItems( identities );
119void IdentityCombo::reloadUoidList()
122 IdentityManager::ConstIterator it;
123 IdentityManager::ConstIterator end( mIdentityManager->end() );
124 for ( it = mIdentityManager->begin(); it != end; ++it ) {
125 mUoidList << ( *it ).uoid();
129void IdentityCombo::slotIdentityManagerChanged()
131 uint oldIdentity = mUoidList[ currentIndex()];
134 int idx = mUoidList.indexOf( oldIdentity );
136 blockSignals(
true );
138 setCurrentIndex( idx < 0 ? 0 : idx );
139 blockSignals(
false );
141 slotUpdateTooltip( currentIdentity() );
145 slotEmitChanged( currentIndex() );
149void IdentityCombo::slotEmitChanged(
int idx )
151 emit identityChanged( mUoidList[idx] );
154void IdentityCombo::slotUpdateTooltip( uint uoid )
161 return mIdentityManager;
Manages the list of identities.
const Identity & identityForUoid(uint uoid) const
QStringList identities() const
User identity information.
QString fullEmailAddr() const
email address in the format "username <name@host>" suitable for the "From:" field of email messages.
uint uoid() const
Unique Object Identifier for this identity.
This file is part of the API for handling user identities and defines the IdentityCombo class.