24 #include <tqcheckbox.h>
29 #include <tdeaboutdata.h>
30 #include <tdeaccelmanager.h>
31 #include <tdeapplication.h>
32 #include <tdeconfig.h>
35 #include <tdelistview.h>
36 #include <tdelocale.h>
38 #include "kcmkmailsummary.h"
40 #include <tdemacros.h>
44 TDE_EXPORT TDECModule *create_kmailsummary( TQWidget *parent,
const char * )
46 return new KCMKMailSummary( parent,
"kcmkmailsummary" );
50 KCMKMailSummary::KCMKMailSummary( TQWidget *parent,
const char *name )
51 : TDECModule( parent, name )
55 connect( mFolderView, TQ_SIGNAL( clicked( TQListViewItem* ) ), TQ_SLOT( modified() ) );
56 connect( mFullPath, TQ_SIGNAL( toggled(
bool ) ), TQ_SLOT( modified() ) );
58 TDEAcceleratorManager::manage(
this );
62 TDEAboutData *about =
new TDEAboutData( I18N_NOOP(
"kcmkmailsummary" ),
63 I18N_NOOP(
"Mail Summary Configuration Dialog" ),
64 0, 0, TDEAboutData::License_GPL,
65 I18N_NOOP(
"(c) 2004 Tobias Koenig" ) );
67 about->addAuthor(
"Tobias Koenig", 0,
"tokoe@kde.org" );
68 setAboutData( about );
71 void KCMKMailSummary::modified()
76 void KCMKMailSummary::initGUI()
78 TQVBoxLayout *layout =
new TQVBoxLayout(
this, 0, KDialog::spacingHint() );
80 mFolderView =
new TDEListView(
this );
81 mFolderView->setRootIsDecorated(
true );
82 mFolderView->setFullWidth(
true );
84 mFolderView->addColumn( i18n(
"Summary" ) );
86 mFullPath =
new TQCheckBox( i18n(
"Show full path for folders" ),
this );
88 layout->addWidget( mFolderView );
89 layout->addWidget( mFullPath );
92 void KCMKMailSummary::initFolders()
94 DCOPRef kmail(
"kmail",
"KMailIface" );
96 TQStringList folderList;
97 kmail.call(
"folderList" ).get( folderList );
102 TQStringList::Iterator it;
103 for ( it = folderList.begin(); it != folderList.end(); ++it ) {
104 TQString displayName;
105 if ( (*it) ==
"/Local" )
106 displayName = i18n(
"prefix for local folders",
"Local" );
108 DCOPRef folderRef = kmail.call(
"getFolder(TQString)", *it );
109 folderRef.call(
"displayName()" ).get( displayName );
111 if ( (*it).contains(
'/' ) == 1 ) {
112 if ( mFolderMap.find( *it ) == mFolderMap.end() )
113 mFolderMap.insert( *it,
new TQListViewItem( mFolderView,
116 const int pos = (*it).findRev(
'/' );
117 const TQString parentFolder = (*it).left( pos );
118 mFolderMap.insert( *it,
119 new TQCheckListItem( mFolderMap[ parentFolder ],
121 TQCheckListItem::CheckBox ) );
126 void KCMKMailSummary::loadFolders()
128 TDEConfig config(
"kcmkmailsummaryrc" );
129 config.setGroup(
"General" );
131 TQStringList folders;
132 if ( !config.hasKey(
"ActiveFolders" ) )
133 folders <<
"/Local/inbox";
135 folders = config.readListEntry(
"ActiveFolders" );
137 TQMap<TQString, TQListViewItem*>::Iterator it;
138 for ( it = mFolderMap.begin(); it != mFolderMap.end(); ++it ) {
139 if ( TQCheckListItem *qli =
dynamic_cast<TQCheckListItem*
>( it.data() ) ) {
140 if ( folders.contains( it.key() ) ) {
142 mFolderView->ensureItemVisible( it.data() );
148 mFullPath->setChecked( config.readBoolEntry(
"ShowFullPath",
true ) );
151 void KCMKMailSummary::storeFolders()
153 TDEConfig config(
"kcmkmailsummaryrc" );
154 config.setGroup(
"General" );
156 TQStringList folders;
158 TQMap<TQString, TQListViewItem*>::Iterator it;
159 for ( it = mFolderMap.begin(); it != mFolderMap.end(); ++it )
160 if ( TQCheckListItem *qli =
dynamic_cast<TQCheckListItem*
>( it.data() ) )
162 folders.append( it.key() );
164 config.writeEntry(
"ActiveFolders", folders );
165 config.writeEntry(
"ShowFullPath", mFullPath->isChecked() );
170 void KCMKMailSummary::load()
175 emit changed(
false );
178 void KCMKMailSummary::save()
182 emit changed(
false );
185 void KCMKMailSummary::defaults()
187 mFullPath->setChecked(
true );
189 emit changed(
true );
192 #include "kcmkmailsummary.moc"