kmail

foldersetselector.cpp
1 /*
2  Copyright (c) 2007 Volker Krause <vkrause@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
19 #include "foldersetselector.h"
20 
21 #include "globalsettings.h"
22 #include "kmfoldertree.h"
23 #include "simplefoldertree.h"
24 #include "kmfoldercachedimap.h"
25 
26 #include <tqvbox.h>
27 
28 using namespace KMail;
29 
30 FolderSetSelector::FolderSetSelector( KMFolderTree *ft, TQWidget * parent )
31  : KDialogBase( parent, "FolderSetSelector", true, TQString(), Ok|Cancel, Ok, true )
32 {
33  assert( ft );
34 
35  mTreeView = new KMail::SimpleFolderTreeBase<TQCheckListItem>( makeVBoxMainWidget(), ft,
36  GlobalSettings::self()->lastSelectedFolder(), false );
37  mTreeView->setFocus();
38 
39  TQListViewItemIterator it( mTreeView );
40  while ( it.current() ) {
41  SimpleFolderTreeItem<TQCheckListItem> *item = dynamic_cast<SimpleFolderTreeItem<TQCheckListItem>*>( it.current() );
42  ++it;
43  if ( !item )
44  continue;
45  if ( !item->folder() ) {
46  item->setEnabled( false );
47  continue;
48  }
49  if ( item->folder()->folderType() == KMFolderTypeCachedImap
50  && static_cast<const KMFolderCachedImap*>( item->folder()->storage() )->imapPath() == "/INBOX/" ) {
51  item->setOn( true );
52  }
53  if ( item->folder()->folderType() != KMFolderTypeCachedImap ) {
54  item->setEnabled( false );
55  }
56  }
57 
58 }
59 
60 TQValueList< int > FolderSetSelector::selectedFolders()
61 {
62  TQValueList<int> rv;
63  TQListViewItemIterator it( mTreeView );
64  while ( it.current() ) {
65  SimpleFolderTreeItem<TQCheckListItem> *item = dynamic_cast<SimpleFolderTreeItem<TQCheckListItem>*>( it.current() );
66  if ( item && item->isOn() && item->folder() )
67  rv.append( item->folder()->id() );
68  ++it;
69  }
70  return rv;
71 }
72 
73 void FolderSetSelector::setSelectedFolders(const TQValueList< int > & folderIds)
74 {
75  TQListViewItemIterator it( mTreeView );
76  while ( it.current() ) {
77  SimpleFolderTreeItem<TQCheckListItem> *item = dynamic_cast<SimpleFolderTreeItem<TQCheckListItem>*>( it.current() );
78  if ( item && item->folder() ) {
79  if ( folderIds.contains( item->folder()->id() ) )
80  item->setOn( true );
81  else
82  item->setOn( false );
83  }
84  ++it;
85  }
86 }
87 
88 #include "foldersetselector.moc"
@ Ok
The user rights/ACL have been fetched from the server sucessfully.
Definition: acljobs.h:66
folderdiaquotatab.h
Definition: aboutdata.cpp:40