From kde-commits Sun Sep 12 18:59:37 2010 From: Artur Duque de Souza Date: Sun, 12 Sep 2010 18:59:37 +0000 To: kde-commits Subject: KDE/kdepim/akregator/src Message-Id: <20100912185937.940DDAC887 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=128431768910933 SVN commit 1174532 by asouza: Export articles (signals), plugins with parents and KCModules as plugins This patch export the selected articles with a signal, enabling plugins to know which articles are selected and perform actions. It also set's akregator_part as the parent of the plugins, enabling them to connect to it's signals and have a way of communicating with it (like getting the signal of selected articles). Also load the config modules looking for them on service trade, instead of hardcoding: this way it's easier to provide config modules for plugins: it just needs a proper .desktop file. Reviewed-by: Frank M +8 -14 akregator_part.cpp M +2 -1 akregator_part.h M +3 -0 mainwidget.cpp M +3 -0 mainwidget.h M +2 -2 pluginmanager.cpp M +1 -1 pluginmanager.h --- trunk/KDE/kdepim/akregator/src/akregator_part.cpp #1174531:1174532 @@ -245,6 +245,8 @@ kapp, SLOT(quit())) ; connect( m_mainWidget, SIGNAL(signalUnreadCountChanged(int)), trayIcon, SLOT(slotSetUnread(int)) ); + connect( m_mainWidget, SIGNAL(signalArticlesSelected(QList)), + this, SIGNAL(signalArticlesSelected(QList)) ); connect(kapp, SIGNAL(aboutToQuit()), this, SLOT(slotOnShutdown())); @@ -270,7 +272,7 @@ const KService::List offers = PluginManager::query( QString::fromLatin1("[X-KDE-akregator-plugintype] == '%1'").arg( type ) ); Q_FOREACH ( const KService::Ptr& i, offers ) { - Akregator::Plugin* plugin = PluginManager::createFromService( i ); + Akregator::Plugin* plugin = PluginManager::createFromService( i, this ); if ( !plugin ) continue; plugin->initialize(); @@ -581,19 +583,11 @@ connect( m_dialog, SIGNAL(configCommitted()), TrayIcon::getInstance(), SLOT(settingsChanged()) ); - QStringList modules; - - modules.append( "akregator_config_general.desktop" ); - modules.append( "akregator_config_onlinesync.desktop" ); - modules.append( "akregator_config_archive.desktop" ); - modules.append( "akregator_config_appearance.desktop" ); - modules.append( "akregator_config_browser.desktop" ); - modules.append( "akregator_config_advanced.desktop" ); - - // add them all - QStringList::iterator mit; - for ( mit = modules.begin(); mit != modules.end(); ++mit ) { - m_dialog->addModule( *mit ); + // query for akregator's kcm modules + const QString constraint = "[X-KDE-ParentApp] == 'akregator'"; + const KService::List offers = KServiceTypeTrader::self()->query( "KCModule", constraint ); + foreach( const KService::Ptr &service, offers ) { + m_dialog->addModule( service->storageId() ); } } --- trunk/KDE/kdepim/akregator/src/akregator_part.h #1174531:1174532 @@ -48,6 +48,7 @@ class Storage; } +class Article; class ActionManagerImpl; class Feed; class FeedList; @@ -145,8 +146,8 @@ signals: void signalSettingsChanged(); + void signalArticlesSelected( const QList& ); - private: /** @return Whether the tray icon is enabled or not */ --- trunk/KDE/kdepim/akregator/src/mainwidget.cpp #1174531:1174532 @@ -803,6 +803,9 @@ assert( article.isNull() || article.feed() ); + QList
articles = m_selectionController->selectedArticles(); + emit signalArticlesSelected( articles ); + KToggleAction* const maai = qobject_cast( m_actionManager->action( "article_set_status_important" ) ); assert( maai ); maai->setChecked( article.keep() ); --- trunk/KDE/kdepim/akregator/src/mainwidget.h #1174531:1174532 @@ -119,6 +119,9 @@ /** emitted when the unread count of "All Feeds" was changed */ void signalUnreadCountChanged(int); + /** emitted when the articles selected changed */ + void signalArticlesSelected(const QList&); + public slots: /** opens the current article (currentItem) in external browser --- trunk/KDE/kdepim/akregator/src/pluginmanager.cpp #1174531:1174532 @@ -79,7 +79,7 @@ Plugin* -PluginManager::createFromService( const KService::Ptr service ) +PluginManager::createFromService( const KService::Ptr service, QObject *parent ) { kDebug() <<"Trying to load:" << service->library(); @@ -90,7 +90,7 @@ " Error message: %2" ).arg( service->library(), loader.errorString() ); return 0; } - Plugin* const plugin = factory->create(); + Plugin* const plugin = factory->create( parent ); //put plugin into store StoreItem item; --- trunk/KDE/kdepim/akregator/src/pluginmanager.h #1174531:1174532 @@ -70,7 +70,7 @@ * @param service Pointer to KService * @return Pointer to Plugin, or NULL if error */ - static Akregator::Plugin* createFromService( const KService::Ptr service ); + static Akregator::Plugin* createFromService( const KService::Ptr service, QObject *parent = 0 ); /** * Remove library and delete plugin