29 #include "accountcombobox.h"
31 #include "kmfolderdir.h"
32 #include "accountmanager.h"
35 using namespace KMail;
37 AccountComboBox::AccountComboBox( TQWidget* parent,
const char* name )
38 : TQComboBox( parent, name )
40 connect( kmkernel->acctMgr(), TQ_SIGNAL( accountAdded( KMAccount* ) ),
41 this, TQ_SLOT( slotRefreshAccounts() ) );
42 connect( kmkernel->acctMgr(), TQ_SIGNAL( accountRemoved( KMAccount* ) ),
43 this, TQ_SLOT( slotRefreshAccounts() ) );
44 slotRefreshAccounts();
47 void AccountComboBox::slotRefreshAccounts()
49 KMAccount* curr = currentAccount();
55 TQStringList accountNames;
56 TQValueList<KMAccount *> lst = applicableAccounts();
57 TQValueList<KMAccount *>::ConstIterator it = lst.begin();
58 for ( ; it != lst.end() ; ++it )
59 accountNames.append( (*it)->name() );
60 kdDebug() << k_funcinfo << accountNames << endl;
61 insertStringList( accountNames );
63 setCurrentAccount( curr );
67 void AccountComboBox::setCurrentAccount( KMAccount* account )
70 TQValueList<KMAccount *> lst = applicableAccounts();
71 TQValueList<KMAccount *>::ConstIterator it = lst.begin();
72 for ( ; it != lst.end() ; ++it, ++i ) {
73 if ( (*it) == account ) {
80 KMAccount* AccountComboBox::currentAccount()
const
83 TQValueList<KMAccount *> lst = applicableAccounts();
84 TQValueList<KMAccount *>::ConstIterator it = lst.begin();
85 while ( it != lst.end() && i < currentItem() ) {
89 if ( it != lst.end() )
94 TQValueList<KMAccount *> KMail::AccountComboBox::applicableAccounts()
const
96 TQValueList<KMAccount *> lst;
97 for( KMAccount *a = kmkernel->acctMgr()->first(); a;
98 a = kmkernel->acctMgr()->next() ) {
99 if ( a && a->type() ==
"cachedimap" ) {
106 #include "accountcombobox.moc"