#include "xparthost_kpart.h" #include "kbrowsersignals.h" #include "xpart_stub.h" #include #include #include #include #include #include #include XPartHost_KPart::XPartHost_KPart( TTQWidget *parentWidget, const char *widgetName, TTQObject *parent, const char *name ) : KParts::ReadOnlyPart( parent, name ), XPartHost("parthost") { m_stub = 0; be = 0; embed = new TQXEmbed(parentWidget, widgetName); setWidget(embed); } XPartHost_KPart::~XPartHost_KPart() { delete m_stub; } DCOPRef XPartHost_KPart::part() { return m_part; } DCOPRef XPartHost_KPart::registerXPart( const DCOPRef &part ) { m_part = part; assert( m_stub == 0 ); m_stub = new XPart_stub( part.app(), part.object() ); m_stub->show(); kdDebug() << "embedding window " << m_stub->windowId() << endl; embed->embed( static_cast( m_stub->windowId() ) ); embed->show(); DCOPRef ref = m_stub->queryExtension("browserextension"); if( !ref.isNull() ) { qDebug(" found browser extension "); be = new KBrowserSignals( this, ref ); } return DCOPRef( kapp->dcopClient()->appId(), objId() ); } void XPartHost_KPart::createActions( const TTQCString &xmlActions ) { qDebug("--> createActions"); // creates a set of actions and adds them to the actionCollection TTQDomDocument d; d.setContent( xmlActions ); TTQDomElement docElem = d.documentElement(); kdDebug() << "docElement is " << docElem.tagName() << endl; TTQDomNode n = docElem.firstChild(); while( !n.isNull() ) { TTQDomElement e = n.toElement(); if( !e.isNull() ) { if ( e.tagName() == "Action") { TTQString name = e.attribute("name"); TTQString type = e.attribute("type"); if(type.isEmpty()) new KAction( name, 0, this, TQT_SLOT( actionActivated() ), actionCollection(), name.latin1() ); else if( type == "toggle" ) new KToggleAction( name, 0, this, TQT_SLOT( actionActivated() ), actionCollection(), name.latin1() ); kdDebug() << "action=" << name << " type=" << type << endl; } else if ( e.tagName() == "XMLFile" ) { TTQString location = e.attribute("location"); setXMLFile(location); } } n = n.nextSibling(); } emit actionsInitialized(); } void XPartHost_KPart::setWindowCaption( const TTQString &caption ) { emit KParts::ReadOnlyPart::setWindowCaption( caption ); } void XPartHost_KPart::setStatusBarText( const TTQString &text ) { emit KParts::ReadOnlyPart::setStatusBarText( text ); } void XPartHost_KPart::started() { emit KParts::ReadOnlyPart::started( 0 ); } void XPartHost_KPart::completed() { emit KParts::ReadOnlyPart::completed(); } void XPartHost_KPart::canceled( const TTQString &errMsg ) { emit KParts::ReadOnlyPart::canceled( errMsg ); } bool XPartHost_KPart::openURL( const KURL &url ) { qDebug("XPartHost_KPart::openUrl()"); return m_stub->openURL( url.url().latin1() ); } bool XPartHost_KPart::closeURL() { return m_stub->closeURL(); } void XPartHost_KPart::actionActivated() { const TTQObject *o = sender(); if( !o->inherits("KAction") ) return; const KAction *action = static_cast(o); TTQString name = action->text(); int state = 0; if(action->inherits("KToggleAction")) { const KToggleAction *t = static_cast(action); state = t->isChecked(); } m_stub->activateAction(name, state); } #include "xparthost_kpart.moc"