36 #include "identitycombo.h"
38 #include "identitymanager.h"
40 #include <tdelocale.h>
46 IdentityCombo::IdentityCombo( IdentityManager* manager, TQWidget * parent,
const char * name )
47 : TQComboBox( false, parent, name ), mIdentityManager( manager )
51 connect(
this, TQ_SIGNAL(activated(
int)), TQ_SLOT(slotEmitChanged(
int)) );
52 connect( manager, TQ_SIGNAL(changed()),
53 TQ_SLOT(slotIdentityManagerChanged()) );
56 TQString IdentityCombo::currentIdentityName()
const {
57 return mIdentityManager->identities()[ currentItem() ];
60 uint IdentityCombo::currentIdentity()
const {
61 return mUoidList[ currentItem() ];
64 void IdentityCombo::setCurrentIdentity(
const Identity & identity ) {
65 setCurrentIdentity( identity.
uoid() );
68 void IdentityCombo::setCurrentIdentity(
const TQString & name ) {
69 int idx = mIdentityManager->identities().findIndex( name );
70 if ( idx < 0 )
return;
71 if ( idx == currentItem() )
return;
74 setCurrentItem( idx );
75 blockSignals(
false );
77 slotEmitChanged( idx );
80 void IdentityCombo::setCurrentIdentity( uint uoid ) {
81 int idx = mUoidList.findIndex( uoid );
82 if ( idx < 0 )
return;
83 if ( idx == currentItem() )
return;
86 setCurrentItem( idx );
87 blockSignals(
false );
89 slotEmitChanged( idx );
92 void IdentityCombo::reloadCombo() {
93 TQStringList identities = mIdentityManager->identities();
95 assert( !identities.isEmpty() );
96 identities.first() = i18n(
"%1 (Default)").arg( identities.first() );
98 insertStringList( identities );
101 void IdentityCombo::reloadUoidList() {
103 IdentityManager::ConstIterator it;
104 for ( it = mIdentityManager->begin() ; it != mIdentityManager->end() ; ++it )
105 mUoidList << (*it).uoid();
109 uint oldIdentity = mUoidList[ currentItem() ];
112 int idx = mUoidList.findIndex( oldIdentity );
114 blockSignals(
true );
116 setCurrentItem( idx < 0 ? 0 : idx );
117 blockSignals(
false );
121 slotEmitChanged( currentItem() );
124 void IdentityCombo::slotEmitChanged(
int idx ) {
129 #include "identitycombo.moc"
void identityChanged(const TQString &identityName)
void slotIdentityManagerChanged()
Connected to IdentityManager::changed().
User identity information.
uint uoid() const
Unique Object Identifier for this identity.