32 #include "identitymanager.h"
34 #include <klocalizedstring.h>
38 using namespace KPIMIdentities;
45 class KPIMIdentities::IdentityCombo::Private
50 IdentityCombo::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() );
62 IdentityCombo::~IdentityCombo()
67 QString IdentityCombo::currentIdentityName()
const
69 return mIdentityManager->identities()[ currentIndex()];
72 uint IdentityCombo::currentIdentity()
const
74 return mUoidList[ currentIndex()];
77 void IdentityCombo::setCurrentIdentity(
const Identity &identity )
79 setCurrentIdentity( identity.
uoid() );
82 void 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 );
96 void 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 );
110 void IdentityCombo::reloadCombo()
112 QStringList identities = mIdentityManager->identities();
114 assert( !identities.isEmpty() );
116 addItems( identities );
119 void IdentityCombo::reloadUoidList()
122 IdentityManager::ConstIterator it;
123 IdentityManager::ConstIterator end( mIdentityManager->end() );
124 for ( it = mIdentityManager->begin(); it != end; ++it ) {
125 mUoidList << ( *it ).uoid();
129 void 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() );
149 void IdentityCombo::slotEmitChanged(
int idx )
151 emit identityChanged( mUoidList[idx] );
154 void IdentityCombo::slotUpdateTooltip( uint uoid )
156 setToolTip( mIdentityManager->identityForUoid( uoid ).fullEmailAddr() );
161 return mIdentityManager;
This file is part of the API for handling user identities and defines the IdentityCombo class...
Manages the list of identities.
uint uoid() const
Unique Object Identifier for this identity.
User identity information.