28 #include <KontactInterface/Plugin>
31 #include <KComponentData>
35 #include <KPluginInfo>
37 #include <KServiceTypeTrader>
40 #include <QVBoxLayout>
45 KComponentData inst(
"kcmkontactsummary" );
50 class PluginItem :
public QTreeWidgetItem
53 PluginItem(
const KPluginInfo &info,
QTreeWidget *parent )
54 : QTreeWidgetItem( parent ), mInfo( info )
56 setIcon( 0, KIcon( mInfo.icon() ) );
57 setText( 0, mInfo.name() );
58 setToolTip( 0, mInfo.comment() );
59 setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
62 KPluginInfo pluginInfo()
const
67 virtual QString
text(
int column )
const
71 }
else if ( column == 1 ) {
72 return mInfo.comment();
86 setHeaderLabel( i18nc(
"@title:column plugin name",
"Summary Plugin Name" ) );
87 setRootIsDecorated(
false);
97 setButtons( NoAdditionalButton );
98 QVBoxLayout *layout =
new QVBoxLayout(
this );
99 layout->setSpacing( KDialog::spacingHint() );
100 layout->setMargin( 0 );
103 new QLabel( i18n(
"Select the plugin summaries to show on the summary page." ),
this );
104 layout->addWidget( label );
107 layout->addWidget( mPluginView );
109 layout->setStretchFactor( mPluginView, 1 );
112 connect( mPluginView, SIGNAL(itemChanged(QTreeWidgetItem*,
int)),
113 this, SLOT(changed()) );
115 KAboutData *about =
new KAboutData( I18N_NOOP(
"kontactsummary" ), 0,
116 ki18n(
"KDE Kontact Summary" ),
117 0, KLocalizedString(), KAboutData::License_GPL,
118 ki18n(
"(c), 2004 Tobias Koenig" ) );
120 about->addAuthor( ki18n(
"Tobias Koenig" ), KLocalizedString(),
"tokoe@kde.org" );
121 setAboutData( about );
126 KService::List offers = KServiceTypeTrader::self()->query(
127 QString::fromLatin1(
"Kontact/Plugin" ),
128 QString::fromLatin1(
"[X-KDE-KontactPluginVersion] == %1" ).arg( KONTACT_PLUGIN_VERSION ) );
130 QStringList activeSummaries;
132 KConfig config( QLatin1String(
"kontact_summaryrc") );
133 KConfigGroup grp( &config, QString() );
134 if ( !grp.hasKey(
"ActiveSummaries" ) ) {
135 activeSummaries << QLatin1String(
"kontact_kaddressbookplugin");
136 activeSummaries << QLatin1String(
"kontact_specialdatesplugin");
137 activeSummaries << QLatin1String(
"kontact_korganizerplugin");
138 activeSummaries << QLatin1String(
"kontact_todoplugin");
139 activeSummaries << QLatin1String(
"kontact_knotesplugin");
140 activeSummaries << QLatin1String(
"kontact_kmailplugin");
141 activeSummaries << QLatin1String(
"kontact_weatherplugin");
142 activeSummaries << QLatin1String(
"kontact_newstickerplugin");
143 activeSummaries << QLatin1String(
"kontact_plannerplugin");
145 activeSummaries = grp.readEntry(
"ActiveSummaries", QStringList() );
148 mPluginView->clear();
150 KPluginInfo::List pluginList =
151 KPluginInfo::fromServices( offers, KConfigGroup( &config,
"Plugins" ) );
152 KPluginInfo::List::Iterator it;
153 KPluginInfo::List::Iterator end(pluginList.end());
154 for ( it = pluginList.begin(); it != end; ++it ) {
157 if ( !it->isPluginEnabled() ) {
161 QVariant var = it->property( QLatin1String(
"X-KDE-KontactPluginHasSummary") );
162 if ( var.isValid() && var.toBool() == true ) {
163 PluginItem *item =
new PluginItem( *it, mPluginView );
165 if ( activeSummaries.contains( it->pluginName() ) ) {
166 item->setCheckState( 0, Qt::Checked );
168 item->setCheckState( 0, Qt::Unchecked );
176 QStringList activeSummaries;
178 QTreeWidgetItemIterator it( mPluginView );
180 PluginItem *item =
static_cast<PluginItem *
>( *it );
181 if ( item->checkState( 0 ) == Qt::Checked ) {
182 activeSummaries.append( item->pluginInfo().pluginName() );
187 KConfig config( QLatin1String(
"kontact_summaryrc") );
188 KConfigGroup grp( &config, QString() );
189 grp.writeEntry(
"ActiveSummaries", activeSummaries );
192 #include "kcmkontactsummary.moc"
virtual QByteArray text(quint32 serialNumber) const =0
PluginView(QWidget *parent)
KCMKontactSummary(const KComponentData &inst, QWidget *parent=0)
KCModule * create_kontactsummary(QWidget *parent, const char *)