25 #include <tdeaboutdata.h>
26 #include <tdeconfig.h>
29 #include <kiconloader.h>
30 #include <kiconloader.h>
31 #include <tdelocale.h>
33 #include <kplugininfo.h>
40 #include "kcmkontactsummary.h"
42 #include <tdemacros.h>
46 TDE_EXPORT TDECModule *create_kontactsummary( TQWidget *parent,
const char * ) {
47 return new KCMKontactSummary( parent,
"kcmkontactsummary" );
51 class PluginItem :
public TQCheckListItem
54 PluginItem( KPluginInfo *info, TDEListView *parent )
55 : TQCheckListItem( parent, TQString(), TQCheckListItem::CheckBox ),
58 TQPixmap pm = TDEGlobal::iconLoader()->loadIcon( mInfo->icon(), TDEIcon::Small );
62 KPluginInfo* pluginInfo()
const
67 virtual TQString text(
int column )
const
71 else if ( column == 1 )
72 return mInfo->comment();
81 PluginView::PluginView( TQWidget *parent,
const char *name )
82 : TDEListView( parent, name )
84 addColumn( i18n(
"Name" ) );
85 setAllColumnsShowFocus(
true );
89 PluginView::~PluginView()
93 KCMKontactSummary::KCMKontactSummary( TQWidget *parent,
const char *name )
94 : TDECModule( parent, name )
96 TQVBoxLayout *layout =
new TQVBoxLayout(
this, 0, KDialog::spacingHint() );
98 TQLabel *label =
new TQLabel( i18n(
"Here you can select which summary plugins to have visible in your summary view." ),
this );
99 layout->addWidget( label );
101 mPluginView =
new PluginView(
this );
102 layout->addWidget( mPluginView );
104 layout->setStretchFactor( mPluginView, 1 );
106 connect( mPluginView, TQ_SIGNAL( clicked( TQListViewItem* ) ),
107 this, TQ_SLOT( itemClicked( TQListViewItem* ) ) );
110 TDEAboutData *about =
new TDEAboutData( I18N_NOOP(
"kontactsummary" ),
111 I18N_NOOP(
"TDE Kontact Summary" ),
112 0, 0, TDEAboutData::License_GPL,
113 I18N_NOOP(
"(c), 2004 Tobias Koenig" ) );
115 about->addAuthor(
"Tobias Koenig", 0,
"tokoe@kde.org" );
116 setAboutData( about );
119 void KCMKontactSummary::load()
121 TDETrader::OfferList offers = TDETrader::self()->query(
122 TQString::fromLatin1(
"Kontact/Plugin" ),
123 TQString(
"[X-TDE-KontactPluginVersion] == %1" ).arg( KONTACT_PLUGIN_VERSION ) );
125 TQStringList activeSummaries;
127 TDEConfig config(
"kontact_summaryrc" );
128 if ( !config.hasKey(
"ActiveSummaries" ) ) {
129 activeSummaries <<
"kontact_kaddressbookplugin";
130 activeSummaries <<
"kontact_specialdatesplugin";
131 activeSummaries <<
"kontact_korganizerplugin";
132 activeSummaries <<
"kontact_todoplugin";
133 activeSummaries <<
"kontact_kpilotplugin";
134 activeSummaries <<
"kontact_weatherplugin";
135 activeSummaries <<
"kontact_newstickerplugin";
137 activeSummaries = config.readListEntry(
"ActiveSummaries" );
140 mPluginView->clear();
143 mPluginList = KPluginInfo::fromServices( offers, &config,
"Plugins" );
144 KPluginInfo::List::Iterator it;
145 TDEConfig *conf =
new TDEConfig(
"kontactrc");
146 TDEConfigGroup *cg =
new TDEConfigGroup( conf,
"Plugins" );
147 for ( it = mPluginList.begin(); it != mPluginList.end(); ++it ) {
150 if ( !(*it)->isPluginEnabled() )
153 TQVariant var = (*it)->property(
"X-TDE-KontactPluginHasSummary" );
154 if ( !var.isValid() )
157 if ( var.toBool() ==
true ) {
158 PluginItem *item =
new PluginItem( *it, mPluginView );
160 if ( activeSummaries.find( (*it)->pluginName() ) != activeSummaries.end() )
166 void KCMKontactSummary::save()
168 TQStringList activeSummaries;
170 TQListViewItemIterator it( mPluginView, TQListViewItemIterator::Checked );
171 while ( it.current() ) {
172 PluginItem *item =
static_cast<PluginItem*
>( it.current() );
173 activeSummaries.append( item->pluginInfo()->pluginName() );
177 TDEConfig config(
"kontact_summaryrc" );
178 config.writeEntry(
"ActiveSummaries", activeSummaries );
181 void KCMKontactSummary::defaults()
183 emit changed(
true );
186 void KCMKontactSummary::itemClicked( TQListViewItem* )
188 emit changed(
true );
191 #include "kcmkontactsummary.moc"