diff --git a/accountcombobox.cpp b/accountcombobox.cpp index e933fc859..32dc275d7 100644 --- a/accountcombobox.cpp +++ b/accountcombobox.cpp @@ -64,9 +64,10 @@ void AccountComboBox::slotRefreshAccounts() void AccountComboBox::setCurrentAccount( KMAccount* account ) { int i = 0; - for( KMAccount *a = kmkernel->acctMgr()->first(); a; - a = kmkernel->acctMgr()->next(), ++i ) { - if ( a == account ) { + QValueList lst = applicableAccounts(); + QValueList::ConstIterator it = lst.begin(); + for ( ; it != lst.end() ; ++it, ++i ) { + if ( (*it) == account ) { setCurrentItem( i ); return; } @@ -94,6 +95,8 @@ QValueList KMail::AccountComboBox::applicableAccounts() const a = kmkernel->acctMgr()->next() ) { Q_ASSERT( a->folder() ); if ( a && a->folder() ) { + disconnect( a, SIGNAL( finishedCheck( bool, CheckStatus ) ), + this, SLOT( slotRefreshAccounts() ) ); bool ok = false; if ( mNeedsInbox ) { KMFolderDir* child = a->folder()->child(); @@ -106,6 +109,10 @@ QValueList KMail::AccountComboBox::applicableAccounts() const } } } + if ( !ok ) { // no inbox? maybe there'll be one on the next sync + connect( a, SIGNAL( finishedCheck( bool, CheckStatus ) ), + this, SLOT( slotRefreshAccounts() ) ); + } } else ok = true; if ( ok ) diff --git a/configuredialog.cpp b/configuredialog.cpp index a831fdda8..6798f217d 100644 --- a/configuredialog.cpp +++ b/configuredialog.cpp @@ -4199,10 +4199,9 @@ void MiscPage::GroupwareTab::load() { } // Iterate over accounts to select folderId if found (as an inbox folder) - int selectedAccount = -1; - i = 0; + KMAccount* selectedAccount = 0; for( KMAccount *a = kmkernel->acctMgr()->first(); a!=0; - a = kmkernel->acctMgr()->next(), ++i ) { + a = kmkernel->acctMgr()->next() ) { if( a->folder() && a->folder()->child() ) { // Look inside that folder for an INBOX KMFolderNode *node; @@ -4210,13 +4209,13 @@ void MiscPage::GroupwareTab::load() { if (!node->isDir() && node->name() == "INBOX") break; if ( node && static_cast(node)->idString() == folderId ) { - selectedAccount = i; + selectedAccount = a; break; } } } - if ( selectedAccount > -1 ) - mAccountCombo->setCurrentItem( selectedAccount ); + if ( selectedAccount ) + mAccountCombo->setCurrentAccount( selectedAccount ); else if ( GlobalSettings::theIMAPResourceStorageFormat() == 1 ) kdDebug(5006) << "Folder " << folderId << " not found as an account's inbox" << endl; }