CVS commit by vkrause: Add a X-KDE-KontactPluginHasPart property to Kontact plugins and use it in Plugin::showInSideBar(). We need this to hide summary-only plugins in the default startup plugin selection. This is backward-compatible, so nothing changes for the current plugins. M +2 -0 interfaces/kontactplugin.desktop 1.88 M +12 -0 interfaces/plugin.cpp 1.38 M +7 -2 interfaces/plugin.h 1.44 M +6 -1 src/kcmkontact.cpp 1.19 M +4 -0 src/main.cpp 1.58 M +3 -0 src/mainwindow.cpp 1.163 --- kdepim/kontact/interfaces/kontactplugin.desktop #1.87:1.88 @@ -54,2 +54,4 @@ [PropertyDef::X-KDE-KontactPluginHasSummary] Type=bool +[PropertyDef::X-KDE-KontactPluginHasPart] +Type=bool --- kdepim/kontact/interfaces/plugin.cpp #1.37:1.38 @@ -47,4 +47,5 @@ class Plugin::Private QString executableName; QCString partLibraryName; + bool hasPart; KParts::ReadOnlyPart *part; }; @@ -59,4 +60,5 @@ Plugin::Plugin( Kontact::Core *core, QOb d->dcopClient = 0; d->newActions = new QPtrList; + d->hasPart = true; d->part = 0; } @@ -206,4 +208,14 @@ void Plugin::bringToForeground() } +bool Kontact::Plugin::showInSideBar() const +{ + return d->hasPart; +} + +void Kontact::Plugin::setShowInSideBar( bool hasPart ) +{ + d->hasPart = hasPart; +} + void Plugin::virtual_hook( int, void* ) { //BASE::virtual_hook( id, data ); --- kdepim/kontact/interfaces/plugin.h #1.43:1.44 @@ -174,7 +174,12 @@ class KDE_EXPORT Plugin : public QObject /** - Reimplement this method if you don't want to have a plugin shown in the sidebar. + Returns wether the plugin provides a part that should be shown in the sidebar. */ - virtual bool showInSideBar() const { return true; } + virtual bool showInSideBar() const; + + /** + Set if the plugin provides a part that should be shown in the sidebar. + */ + void setShowInSideBar( bool hasPart ); /** --- kdepim/kontact/src/kcmkontact.cpp #1.18:1.19 @@ -115,9 +115,14 @@ void PluginSelection::readConfig() const KTrader::OfferList offers = KTrader::self()->query( QString::fromLatin1( "Kontact/Plugin" ), - QString( "[X-KDE-KontactPluginVersion] == %1" ).arg( KONTACT_PLUGIN_VERSION ) ); + int activeComponent = 0; + mPluginCombo->clear(); for ( KService::List::ConstIterator it = offers.begin(); it != offers.end(); ++it ) { KService::Ptr service = *it; + // skip summary only plugins + QVariant var = service->property( "X-KDE-KontactPluginHasPart" ); + if ( var.isValid() && var.toBool() == false ) + continue; mPluginCombo->insertItem( service->name() ); mPluginList.append( service ); --- kdepim/kontact/src/main.cpp #1.57:1.58 @@ -65,4 +65,8 @@ static void listPlugins() for ( KService::List::Iterator it = offers.begin(); it != offers.end(); ++it ) { KService::Ptr service = (*it); + // skip summary only plugins + QVariant var = service->property( "X-KDE-KontactPluginHasPart" ); + if ( var.isValid() && var.toBool() == false ) + continue; cout << service->library().remove( "libkontact_" ).latin1() << endl; } --- kdepim/kontact/src/mainwindow.cpp #1.162:1.163 @@ -395,4 +395,5 @@ void MainWindow::loadPlugins() QVariant exeNameProp = (*it)->property( "X-KDE-KontactPartExecutableName" ); QVariant loadOnStart = (*it)->property( "X-KDE-KontactPartLoadOnStart" ); + QVariant hasPartProp = (*it)->property( "X-KDE-KontactPluginHasPart" ); if ( !loadOnStart.isNull() && loadOnStart.toBool() ) @@ -403,4 +404,6 @@ void MainWindow::loadPlugins() plugin->setPartLibraryName( libNameProp.toString().utf8() ); plugin->setExecutableName( exeNameProp.toString() ); + if ( hasPartProp.isValid() ) + plugin->setShowInSideBar( hasPartProp.toBool() ); for ( i = 0; i < plugins.count(); ++i ) {