6 #include "kmfoldercombobox.h"
7 #include "kmfoldermgr.h"
11 KMFolderComboBox::KMFolderComboBox( TQWidget *parent,
char *name )
12 : TQComboBox( parent, name )
20 KMFolderComboBox::KMFolderComboBox(
bool rw, TQWidget *parent,
char *name )
21 : TQComboBox( rw, parent, name )
29 void KMFolderComboBox::init()
35 connect(
this, TQ_SIGNAL( activated(
int) ),
36 this, TQ_SLOT( slotActivated(
int) ) );
37 connect( kmkernel->folderMgr(), TQ_SIGNAL(changed()),
38 this, TQ_SLOT(refreshFolders()) );
39 connect( kmkernel->dimapFolderMgr(), TQ_SIGNAL(changed()),
40 this, TQ_SLOT(refreshFolders()) );
42 connect( kmkernel->imapFolderMgr(), TQ_SIGNAL(changed()),
43 this, TQ_SLOT(refreshFolders()) );
49 void KMFolderComboBox::showOutboxFolder(
bool shown)
57 void KMFolderComboBox::showImapFolders(
bool shown)
62 connect( kmkernel->imapFolderMgr(), TQ_SIGNAL(changed()),
63 this, TQ_SLOT(refreshFolders()) );
65 disconnect( kmkernel->imapFolderMgr(), TQ_SIGNAL(changed()),
66 this, TQ_SLOT(refreshFolders()) );
71 void KMFolderComboBox::createFolderList(TQStringList *names,
72 TQValueList<TQGuardedPtr<KMFolder> > *folders)
74 kmkernel->folderMgr()->createI18nFolderList( names, folders );
75 if ( !mOutboxShown ) {
76 TQValueList< TQGuardedPtr<KMFolder> >::iterator folderIt = folders->begin();
77 TQStringList::iterator namesIt = names->begin();
78 for ( ; folderIt != folders->end(); ++folderIt, ++namesIt ) {
80 if ( folder == kmkernel->outboxFolder() )
83 if ( folderIt != folders->end() ) {
84 folders->
remove( folderIt );
85 names->remove( namesIt );
90 kmkernel->imapFolderMgr()->createI18nFolderList( names, folders );
92 kmkernel->dimapFolderMgr()->createI18nFolderList( names, folders );
97 void KMFolderComboBox::refreshFolders()
100 TQValueList<TQGuardedPtr<KMFolder> > folders;
101 createFolderList( &names, &folders );
105 insertStringList( names );
111 void KMFolderComboBox::setFolder(
KMFolder *aFolder )
114 TQValueList<TQGuardedPtr<KMFolder> > folders;
115 createFolderList( &names, &folders );
117 int idx = folders.findIndex( aFolder );
119 idx = folders.findIndex( kmkernel->draftsFolder() );
120 setCurrentItem( idx >= 0 ? idx : 0 );
125 void KMFolderComboBox::setFolder(
const TQString &idString )
127 KMFolder * folder = kmkernel->findFolderById( idString );
128 if (!folder && !idString.isEmpty())
130 if (mSpecialIdx >= 0)
131 removeItem(mSpecialIdx);
132 mSpecialIdx = count();
133 insertItem(idString, -1);
134 setCurrentItem(mSpecialIdx);
144 KMFolder *KMFolderComboBox::getFolder()
150 TQValueList<TQGuardedPtr<KMFolder> > folders;
151 createFolderList( &names, &folders );
153 if (currentItem() == mSpecialIdx)
156 TQString text = currentText();
158 TQStringList::Iterator it;
159 for ( it = names.begin(); it != names.end(); ++it ) {
160 if ( ! (*it).compare( text ) )
161 return *folders.at( idx );
165 return kmkernel->draftsFolder();
170 void KMFolderComboBox::slotActivated(
int index)
173 TQValueList<TQGuardedPtr<KMFolder> > folders;
174 createFolderList( &names, &folders );
176 if (index == mSpecialIdx)
182 mFolder = *folders.at( index );
188 #include "kmfoldercombobox.moc"
void remove()
Removes the folder physically from disk and empties the contents of the folder in memory.