Example #1
0
AkregatorMenu::AkregatorMenu( KonqPopupMenu * popupmenu, const char *name, const QStringList& /* list */ )
    : KonqPopupMenuPlugin( popupmenu, name), PluginBase(), m_conf(0), m_part(0)
{
    kdDebug() << "AkregatorMenu::AkregatorMenu()" << endl;
    if ( QCString( kapp->name() ) == "kdesktop" && !kapp->authorize("editable_desktop_icons" ) )
        return;

    // Do nothing if user has turned us off.
    // TODO: Not yet implemented in aKregator settings.
    /*m_conf = new KConfig( "akregatorrc" );
    m_conf->setGroup( "AkregatorKonqPlugin" );
    if ( !m_conf->readBoolEntry( "Enable", true ) )
        return;
    */
    
    KHTMLView* view = 0L;
          
    if (popupmenu && popupmenu->parent() && popupmenu->parent()->inherits("KHTMLView"))
            view = static_cast<KHTMLView*>(popupmenu->parent());
    
    if (view)
        m_part = view->part();
     
    KGlobal::locale()->insertCatalogue("akregator_konqplugin");
    m_feedMimeTypes << "text/rss" << "text/rdf" << "text/xml";
    // Get the list of URLs clicked on from Konqi.
    //KFileItemList m_list = popupmenu->fileItemList();
    // See if any are RSS feeds.
    
    KFileItemList list = popupmenu->fileItemList();
    KFileItem* it = list.first();
    while (it != 0)
    {
	if (isFeedUrl(it))
        {
	    kdDebug() << "AkregatorMenu: found feed URL " << it->url().prettyURL() << endl;
            KAction *action = new KAction( i18n( "Add Feed to Akregator" ), "akregator", 0, this, SLOT( slotAddFeed() ), actionCollection(), "akregatorkonqplugin_mnu" );
            addAction( action );
            addSeparator();
	    m_feedURL = it->url().url();
            break;
        }
	
	it = list.next();
    }
}