summaryrefslogtreecommitdiffstats
path: root/xparts/src/kde
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /xparts/src/kde
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'xparts/src/kde')
-rw-r--r--xparts/src/kde/Makefile.am17
-rw-r--r--xparts/src/kde/kbrowsersignals.cpp31
-rw-r--r--xparts/src/kde/kbrowsersignals.h27
-rw-r--r--xparts/src/kde/xparthost_kpart.cpp150
-rw-r--r--xparts/src/kde/xparthost_kpart.h74
5 files changed, 299 insertions, 0 deletions
diff --git a/xparts/src/kde/Makefile.am b/xparts/src/kde/Makefile.am
new file mode 100644
index 00000000..acdfff7f
--- /dev/null
+++ b/xparts/src/kde/Makefile.am
@@ -0,0 +1,17 @@
+
+INCLUDES = -I$(srcdir)/../interfaces $(all_includes)
+
+lib_LTLIBRARIES = libkdexparts.la
+
+libkdexparts_la_SOURCES = xparthost_kpart.cpp xparthost.skel xpart.stub \
+ kbrowsersignals.cpp xbrowsersignals.skel xbrowserextension.stub
+libkdexparts_la_LIBADD = $(LIB_KPARTS)
+libkdexparts_la_LDFLAGS = $(all_libraries) -no-undefined -version-info 1:0
+
+xpart_DIR=$(srcdir)/../interfaces
+xparthost_DIR=$(srcdir)/../interfaces
+xbrowsersignals_DIR=$(srcdir)/../interfaces
+xbrowserextension_DIR=$(srcdir)/../interfaces
+
+METASOURCES = AUTO
+
diff --git a/xparts/src/kde/kbrowsersignals.cpp b/xparts/src/kde/kbrowsersignals.cpp
new file mode 100644
index 00000000..f96655f0
--- /dev/null
+++ b/xparts/src/kde/kbrowsersignals.cpp
@@ -0,0 +1,31 @@
+#include "kbrowsersignals.h"
+#include "xparthost_kpart.h"
+#include "xbrowserextension_stub.h"
+#include <kurl.h>
+
+KBrowserSignals::KBrowserSignals( XPartHost_KPart *_part, DCOPRef extension )
+ : KParts::BrowserExtension( _part )
+{
+ qDebug("KBrowserSignals constructor");
+ part = _part;
+ ext = new XBrowserExtension_stub( extension.app(), extension.object() );
+ ext->setBrowserSignals( DCOPRef( this ) );
+}
+
+KBrowserSignals::~KBrowserSignals()
+{
+ delete ext;
+}
+
+void KBrowserSignals::openURLRequest( const QCString &url)
+{
+ KURL u = QString(url);
+ emit KParts::BrowserExtension::openURLRequest(u);
+}
+
+void KBrowserSignals::createNewWindow( const QCString &url )
+{
+}
+
+#include "kbrowsersignals.moc"
+
diff --git a/xparts/src/kde/kbrowsersignals.h b/xparts/src/kde/kbrowsersignals.h
new file mode 100644
index 00000000..dab8f208
--- /dev/null
+++ b/xparts/src/kde/kbrowsersignals.h
@@ -0,0 +1,27 @@
+#ifndef __kbrowsersignals_h__
+#define __kbrowsersignals_h__
+
+#include <xbrowsersignals.h>
+#include <kparts/browserextension.h>
+#include <dcopref.h>
+
+class XBrowserExtension_stub;
+class XPartHost_KPart;
+
+class KBrowserSignals : public KParts::BrowserExtension, virtual public XBrowserSignals
+{
+ Q_OBJECT
+public:
+ KBrowserSignals( XPartHost_KPart *part, DCOPRef ref );
+ virtual ~KBrowserSignals();
+
+
+ virtual ASYNC openURLRequest( const QCString &url);
+ virtual ASYNC createNewWindow( const QCString &url );
+
+protected:
+ XPartHost_KPart *part;
+ XBrowserExtension_stub *ext;
+};
+
+#endif
diff --git a/xparts/src/kde/xparthost_kpart.cpp b/xparts/src/kde/xparthost_kpart.cpp
new file mode 100644
index 00000000..c88e0c99
--- /dev/null
+++ b/xparts/src/kde/xparthost_kpart.cpp
@@ -0,0 +1,150 @@
+#include "xparthost_kpart.h"
+#include "kbrowsersignals.h"
+#include "xpart_stub.h"
+
+#include <dcopclient.h>
+#include <kapplication.h>
+
+#include <assert.h>
+
+#include <qxembed.h>
+
+#include <qdom.h>
+#include <kaction.h>
+
+#include <kdebug.h>
+
+XPartHost_KPart::XPartHost_KPart( QWidget *parentWidget, const char *widgetName,
+ QObject *parent, const char *name )
+ : KParts::ReadOnlyPart( parent, name ),
+ XPartHost("parthost")
+{
+ m_stub = 0;
+ be = 0;
+ embed = new QXEmbed(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() );
+
+ kdDebug() << "embedding window " << m_stub->windowId() << endl;
+ embed->embed( static_cast<WId>( m_stub->windowId() ) );
+
+ m_stub->show();
+ 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 QCString &xmlActions )
+{
+ qDebug("--> createActions");
+ // creates a set of actions and adds them to the actionCollection
+ QDomDocument d;
+ d.setContent( xmlActions );
+
+ QDomElement docElem = d.documentElement();
+
+ kdDebug() << "docElement is " << docElem.tagName() << endl;
+
+ QDomNode n = docElem.firstChild();
+ while( !n.isNull() ) {
+ QDomElement e = n.toElement();
+ if( !e.isNull() ) {
+ if ( e.tagName() == "Action") {
+ QString name = e.attribute("name");
+ QString type = e.attribute("type");
+
+ if(type.isEmpty())
+ new KAction( name, 0, this, SLOT( actionActivated() ), actionCollection(), name.latin1() );
+ else if( type == "toggle" )
+ new KToggleAction( name, 0, this, SLOT( actionActivated() ), actionCollection(), name.latin1() );
+ kdDebug() << "action=" << name << " type=" << type << endl;
+ } else if ( e.tagName() == "XMLFile" ) {
+ QString location = e.attribute("location");
+ setXMLFile(location);
+ }
+ }
+ n = n.nextSibling();
+ }
+ emit actionsInitialized();
+}
+
+
+void XPartHost_KPart::setWindowCaption( const QString &caption )
+{
+ emit KParts::ReadOnlyPart::setWindowCaption( caption );
+}
+
+void XPartHost_KPart::setStatusBarText( const QString &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 QString &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 QObject *o = sender();
+
+ if( !o->inherits("KAction") ) return;
+
+ const KAction *action = static_cast<const KAction *>(o);
+ QString name = action->text();
+ int state = 0;
+
+ if(action->inherits("KToggleAction")) {
+ const KToggleAction *t = static_cast<const KToggleAction *>(action);
+ state = t->isChecked();
+ }
+
+ m_stub->activateAction(name, state);
+}
+
+#include "xparthost_kpart.moc"
diff --git a/xparts/src/kde/xparthost_kpart.h b/xparts/src/kde/xparthost_kpart.h
new file mode 100644
index 00000000..5a12dec0
--- /dev/null
+++ b/xparts/src/kde/xparthost_kpart.h
@@ -0,0 +1,74 @@
+#ifndef __xparthost_kpart_h__
+#define __xparthost_kpart_h__
+
+#include <xparthost.h>
+
+#include <kparts/part.h>
+
+class XPart_stub;
+class KBrowserSignals;
+class QXEmbed;
+
+
+/**
+ * This class is the middle class between the host of the KPart (usually a
+ * KParts::MainWindow) and the XPart. It transfer calls from the XPart to the
+ * KPartHost host and from the KPartHost to the XPart.
+ *
+ * Note : In the XPart white paper, this class is named KXPartHost
+ */
+class XPartHost_KPart : public KParts::ReadOnlyPart, public XPartHost
+{
+ Q_OBJECT
+public:
+ XPartHost_KPart( QWidget *parentWidget, const char *widgetName,
+ QObject *parent, const char *name );
+ virtual ~XPartHost_KPart();
+
+ // DCOP stuff
+
+ /** The XPart uses this function to register itself */
+ virtual DCOPRef registerXPart( const DCOPRef &part );
+
+ /** Return the XPart DCOPRef to someone willing to communicate with it */
+ virtual DCOPRef part();
+
+ // KPart signals
+
+ /** Emitted by the XPart, to be transfered to the KPart host */
+ virtual ASYNC createActions( const QCString &xmlActions );
+ /** Emitted by the XPart, to be transfered to the KPart host */
+ virtual ASYNC setWindowCaption( const QString &caption );
+ /** Emitted by the XPart, to be transfered to the KPart host */
+ virtual ASYNC setStatusBarText( const QString &text );
+
+ /** Emitted by the XPart, to be transfered to the KPart host */
+ virtual ASYNC started();
+ /** Emitted by the XPart, to be transfered to the KPart host */
+ virtual ASYNC completed();
+ /** Emitted by the XPart, to be transfered to the KPart host */
+ virtual ASYNC canceled( const QString &errMsg );
+
+ // reimplemented from KReadOnlyPart
+ /** function called by the KPart host to be forwarded to the XPart */
+ virtual bool openURL( const KURL &url );
+ /** function called by the KPart host to be forwarded to the XPart */
+ virtual bool closeURL();
+
+protected:
+ virtual bool openFile() { return false; }
+
+private slots:
+ void actionActivated();
+
+signals:
+ void actionsInitialized();
+
+private:
+ DCOPRef m_part;
+ XPart_stub *m_stub;
+ KBrowserSignals *be;
+ QXEmbed *embed;
+};
+
+#endif