summaryrefslogtreecommitdiffstats
path: root/kmail/kmacctfolder.cpp
blob: 3d363e143966613154f1fb0b836121b0df8d86d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// kmacctfolder.cpp

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "kmacctfolder.h"

//-----------------------------------------------------------------------------
KMAccount* KMAcctFolder::account()
{
  if ( acctList() )
      return acctList()->first();
  return 0;
}

//-----------------------------------------------------------------------------
void KMAcctFolder::addAccount( KMAccount* aAcct )
{
  if ( !aAcct ) return;
  if ( !acctList() )
      setAcctList( new AccountList() );

  acctList()->append( aAcct );
  aAcct->setFolder( this );
}

//-----------------------------------------------------------------------------
void KMAcctFolder::clearAccountList()
{
  if ( acctList() )
      acctList()->clear();
}

//-----------------------------------------------------------------------------
void KMAcctFolder::removeAccount( KMAccount* aAcct )
{
  if ( !aAcct || !acctList() ) return;

  acctList()->remove( aAcct );
  aAcct->setFolder( 0 );
  if ( acctList()->count() <= 0 ) {
    delete acctList();
    setAcctList( 0 );
  }
}