summaryrefslogtreecommitdiffstats
path: root/kexi/plugins/scripting/kexiapp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kexi/plugins/scripting/kexiapp
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kexi/plugins/scripting/kexiapp')
-rw-r--r--kexi/plugins/scripting/kexiapp/Makefile.am21
-rw-r--r--kexi/plugins/scripting/kexiapp/kexiappmainwindow.cpp106
-rw-r--r--kexi/plugins/scripting/kexiapp/kexiappmainwindow.h91
-rw-r--r--kexi/plugins/scripting/kexiapp/kexiappmodule.cpp97
-rw-r--r--kexi/plugins/scripting/kexiapp/kexiappmodule.h76
-rw-r--r--kexi/plugins/scripting/kexiapp/kexiapppart.cpp46
-rw-r--r--kexi/plugins/scripting/kexiapp/kexiapppart.h56
7 files changed, 493 insertions, 0 deletions
diff --git a/kexi/plugins/scripting/kexiapp/Makefile.am b/kexi/plugins/scripting/kexiapp/Makefile.am
new file mode 100644
index 00000000..a2702a26
--- /dev/null
+++ b/kexi/plugins/scripting/kexiapp/Makefile.am
@@ -0,0 +1,21 @@
+include $(top_srcdir)/kexi/Makefile.global
+
+INCLUDES = -I$(top_srcdir)/kexi $(KROSS_INCLUDES) $(all_includes)
+
+kde_module_LTLIBRARIES = krosskexiapp.la
+
+krosskexiapp_la_SOURCES = \
+ kexiapppart.cpp \
+ kexiappmainwindow.cpp \
+ kexiappmodule.cpp
+
+krosskexiapp_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) $(VER_INFO) -module
+krosskexiapp_la_LIBADD = \
+ $(LIB_QT) \
+ $(LIB_KDECORE) \
+ $(LIB_KROSS_API) \
+ $(LIB_KROSS_MAIN) \
+ $(top_builddir)/kexi/core/libkexicore.la
+
+METASOURCES = AUTO
+SUBDIRS = .
diff --git a/kexi/plugins/scripting/kexiapp/kexiappmainwindow.cpp b/kexi/plugins/scripting/kexiapp/kexiappmainwindow.cpp
new file mode 100644
index 00000000..4d82bc5d
--- /dev/null
+++ b/kexi/plugins/scripting/kexiapp/kexiappmainwindow.cpp
@@ -0,0 +1,106 @@
+/***************************************************************************
+ * kexiappmainwindow.cpp
+ * This file is part of the KDE project
+ * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ ***************************************************************************/
+
+#include "kexiappmainwindow.h"
+#include "kexiapppart.h"
+
+#include "core/keximainwindow.h"
+#include "core/kexiproject.h"
+#include "core/kexi.h"
+#include "kexidb/connection.h"
+
+#include "main/manager.h"
+
+//#include <kdebug.h>
+
+namespace Kross { namespace KexiApp {
+
+ /// \internal
+ class KexiAppMainWindowPrivate
+ {
+ public:
+ KexiMainWindow* mainwindow;
+
+ KexiProject* project() {
+ KexiProject* project = mainwindow->project();
+ if(! project)
+ throw Kross::Api::Exception::Ptr( new Kross::Api::Exception("No project loaded.") );
+ return project;
+ }
+ };
+
+}}
+
+using namespace Kross::KexiApp;
+
+KexiAppMainWindow::KexiAppMainWindow(KexiMainWindow* mainwindow)
+ : Kross::Api::Class<KexiAppMainWindow>("KexiAppMainWindow")
+ , d(new KexiAppMainWindowPrivate())
+{
+ d->mainwindow = mainwindow;
+
+ this->addFunction0<Kross::Api::Variant>("isConnected", this, &KexiAppMainWindow::isConnected);
+ this->addFunction0<Kross::Api::Object>("getConnection", this, &KexiAppMainWindow::getConnection);
+
+ this->addFunction1<Kross::Api::List, Kross::Api::Variant>("getPartItems", this, &KexiAppMainWindow::getPartItems);
+ this->addFunction1<Kross::Api::Variant, KexiAppPartItem>("openPartItem", this, &KexiAppMainWindow::openPartItem);
+}
+
+KexiAppMainWindow::~KexiAppMainWindow()
+{
+ delete d;
+}
+
+const QString KexiAppMainWindow::getClassName() const
+{
+ return "Kross::KexiApp::KexiAppMainWindow";
+}
+
+bool KexiAppMainWindow::isConnected()
+{
+ return d->project()->isConnected();
+}
+
+Kross::Api::Object::Ptr KexiAppMainWindow::getConnection()
+{
+ ::KexiDB::Connection* connection = d->project()->dbConnection();
+ if(! connection)
+ throw Kross::Api::Exception::Ptr( new Kross::Api::Exception("No connection established.") );
+ Kross::Api::Module::Ptr module = Kross::Api::Manager::scriptManager()->loadModule("krosskexidb");
+ if(! module)
+ throw Kross::Api::Exception::Ptr( new Kross::Api::Exception("Could not load \"krosskexidb\" module.") );
+ return module->get("KexiDBConnection", connection);
+}
+
+Kross::Api::List* KexiAppMainWindow::getPartItems(const QString& mimetype)
+{
+ if(mimetype.isNull()) return 0; // just to be sure...
+ KexiPart::ItemDict* items = d->project()->itemsForMimeType( mimetype.latin1() );
+ if(! items) return 0;
+ return new Kross::Api::ListT<KexiAppPartItem>( *items );
+}
+
+bool KexiAppMainWindow::openPartItem(KexiAppPartItem* partitem)
+{
+ bool openingCancelled;
+ KexiDialogBase* dialog = partitem
+ ? d->mainwindow->openObject(partitem->item(), Kexi::DataViewMode, openingCancelled)
+ : 0;
+ return (dialog != 0 && ! openingCancelled);
+}
diff --git a/kexi/plugins/scripting/kexiapp/kexiappmainwindow.h b/kexi/plugins/scripting/kexiapp/kexiappmainwindow.h
new file mode 100644
index 00000000..fd02c193
--- /dev/null
+++ b/kexi/plugins/scripting/kexiapp/kexiappmainwindow.h
@@ -0,0 +1,91 @@
+/***************************************************************************
+ * kexiappmainwindow.h
+ * This file is part of the KDE project
+ * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ ***************************************************************************/
+
+#ifndef KROSS_KEXIAPP_KEXIAPPMAINWINDOW_H
+#define KROSS_KEXIAPP_KEXIAPPMAINWINDOW_H
+
+#include <qstring.h>
+#include <qvariant.h>
+
+#include <api/object.h>
+#include <api/variant.h>
+#include <api/list.h>
+#include <api/class.h>
+
+// Forward declarations.
+class KexiMainWindow;
+
+namespace Kross { namespace KexiApp {
+
+ // Forward declarations.
+ class KexiAppPartItem;
+ class KexiAppMainWindowPrivate;
+
+ /**
+ * Class to handle Kexi's mainwindow instance.
+ */
+ class KexiAppMainWindow : public Kross::Api::Class<KexiAppMainWindow>
+ {
+ public:
+
+ /**
+ * Constructor.
+ *
+ * \param mainwindow The \a KexiMainWindow instance
+ * this class provides access to.
+ */
+ KexiAppMainWindow(KexiMainWindow* mainwindow);
+
+ /**
+ * Destructor.
+ */
+ virtual ~KexiAppMainWindow();
+
+ /// \see Kross::Api::Object::getClassName
+ virtual const QString getClassName() const;
+
+ /** \return true if Kexi is connected with a project else
+ false is returned. */
+ bool isConnected();
+
+ /** \return the \a Kross::KexiDB::KexiDBConnection object that
+ belongs to the opened project or throw an exception if there
+ was no project opened (no connection established). Cause the
+ KexiApp-module doesn't know anything about the KexiDB-module
+ we have to use the base-class \a Kross::Api::Object to pass
+ the \a Kross::KexiDB::KexiDBConnection object around. */
+ Kross::Api::Object::Ptr getConnection();
+
+ /** \return a list of \a KexiAppPartItem objects for the defined
+ \p mimetype string. */
+ Kross::Api::List* getPartItems(const QString& mimetype);
+
+ /** Try to open the defined \a KexiAppPartItem and \return true
+ on success else false. */
+ bool openPartItem(KexiAppPartItem* partitem);
+
+ private:
+ /// Private d-pointer class.
+ KexiAppMainWindowPrivate* d;
+ };
+
+}}
+
+#endif
+
diff --git a/kexi/plugins/scripting/kexiapp/kexiappmodule.cpp b/kexi/plugins/scripting/kexiapp/kexiappmodule.cpp
new file mode 100644
index 00000000..cb664496
--- /dev/null
+++ b/kexi/plugins/scripting/kexiapp/kexiappmodule.cpp
@@ -0,0 +1,97 @@
+/***************************************************************************
+ * kexiappmodule.cpp
+ * This file is part of the KDE project
+ * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ ***************************************************************************/
+
+#include "kexiappmodule.h"
+#include "kexiappmainwindow.h"
+
+#include "core/keximainwindow.h"
+
+#include <api/object.h>
+#include <api/qtobject.h>
+#include <main/manager.h>
+
+#include <kdebug.h>
+
+// The as version() published versionnumber of this kross-module.
+#define KROSS_KEXIAPP_VERSION 1
+
+extern "C"
+{
+ /**
+ * Exported an loadable function as entry point to use
+ * the \a KexiAppModule.
+ */
+ Kross::Api::Object* KDE_EXPORT init_module(Kross::Api::Manager* manager)
+ {
+ return new Kross::KexiApp::KexiAppModule(manager);
+ }
+}
+
+namespace Kross { namespace KexiApp {
+
+ /// \internal
+ class KexiAppModulePrivate
+ {
+ public:
+ Kross::Api::Manager* manager;
+ };
+
+}}
+
+using namespace Kross::KexiApp;
+
+KexiAppModule::KexiAppModule(Kross::Api::Manager* manager)
+ : Kross::Api::Module("KexiApp")
+ , d(new KexiAppModulePrivate())
+{
+ kdDebug() << "Kross::KexiApp::KexiAppModule Ctor" << endl;
+
+ d->manager = manager;
+
+ Kross::Api::Object::Ptr mainwinobject = manager->getChild("KexiMainWindow");
+ if(mainwinobject) {
+ Kross::Api::QtObject* mainwinqtobject = dynamic_cast< Kross::Api::QtObject* >( mainwinobject.data() );
+ if(mainwinqtobject) {
+ ::KexiMainWindow* mainwin = dynamic_cast< ::KexiMainWindow* >( mainwinqtobject->getObject() );
+ if(mainwin) {
+ addChild( "version", new Kross::Api::Variant(KROSS_KEXIAPP_VERSION) );
+ addChild( new KexiAppMainWindow(mainwin) );
+ return;
+ }
+ else kdDebug()<<"Kross::KexiApp::KexiAppModule: Failed to determinate KexiMainWindow instance"<<endl;
+ }
+ else kdDebug()<<"Kross::KexiApp::KexiAppModule: Failed to cast 'KexiMainWindow' to a QtObject"<<endl;
+ }
+ else kdDebug()<<"Kross::KexiApp::KexiAppModule: No such object 'KexiMainWindow'"<<endl;
+
+ throw Kross::Api::Exception::Ptr( new Kross::Api::Exception("There was no 'KexiMainWindow' published.") );
+}
+
+KexiAppModule::~KexiAppModule()
+{
+ kdDebug() << "Kross::KexiApp::KexiAppModule Dtor" << endl;
+ delete d;
+}
+
+
+const QString KexiAppModule::getClassName() const
+{
+ return "Kross::KexiApp::KexiAppModule";
+}
+
diff --git a/kexi/plugins/scripting/kexiapp/kexiappmodule.h b/kexi/plugins/scripting/kexiapp/kexiappmodule.h
new file mode 100644
index 00000000..08ed71f0
--- /dev/null
+++ b/kexi/plugins/scripting/kexiapp/kexiappmodule.h
@@ -0,0 +1,76 @@
+/***************************************************************************
+ * kexiappmodule.h
+ * This file is part of the KDE project
+ * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ ***************************************************************************/
+
+#ifndef KROSS_KEXIAPP_KEXIAPPMODULE_H
+#define KROSS_KEXIAPP_KEXIAPPMODULE_H
+
+#include <qstring.h>
+#include <qvariant.h>
+
+#include <api/module.h>
+
+namespace Kross { namespace Api {
+ class Manager;
+}}
+
+namespace Kross {
+
+/**
+ * Wrapper around the Kexi-application to access runtime
+ * information a running Kexi-application likes to
+ * provide.
+ */
+namespace KexiApp {
+
+ class KexiAppModulePrivate;
+
+ /**
+ * The Kexi-application module which provides us the
+ * main entrypoint to communicate with a running
+ * Kexi-application.
+ */
+ class KexiAppModule : public Kross::Api::Module
+ {
+ public:
+
+ /**
+ * Constructor.
+ *
+ * \param manager The \a Kross::Api::Manager singleton
+ * instance used to access this module.
+ */
+ KexiAppModule(Kross::Api::Manager* manager);
+
+ /**
+ * Destructor.
+ */
+ virtual ~KexiAppModule();
+
+ /// \see Kross::Api::Object::getClassName
+ virtual const QString getClassName() const;
+
+ private:
+ /// Private d-pointer class.
+ KexiAppModulePrivate* d;
+ };
+
+}}
+
+#endif
+
diff --git a/kexi/plugins/scripting/kexiapp/kexiapppart.cpp b/kexi/plugins/scripting/kexiapp/kexiapppart.cpp
new file mode 100644
index 00000000..23d6c2f5
--- /dev/null
+++ b/kexi/plugins/scripting/kexiapp/kexiapppart.cpp
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * kexiapppart.cpp
+ * This file is part of the KDE project
+ * copyright (C)2006 by Sebastian Sauer (mail@dipe.org)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ ***************************************************************************/
+
+#include "kexiapppart.h"
+
+#include "core/kexipart.h"
+#include "core/kexipartitem.h"
+//#include "core/kexiproject.h"
+
+using namespace Kross::KexiApp;
+
+KexiAppPartItem::KexiAppPartItem(KexiPart::Item* item)
+ : Kross::Api::Class<KexiAppPartItem>("KexiAppPartItem")
+{
+ this->addFunction0<Kross::Api::Variant>("identifier", item, &::KexiPart::Item::identifier );
+
+ this->addFunction1<void, Kross::Api::Variant>("setIdentifier", item, &::KexiPart::Item::setIdentifier );
+
+ this->addFunction0<Kross::Api::Variant>("mimeType", item, &::KexiPart::Item::mimeType );
+ this->addFunction1<void, Kross::Api::Variant>("setMimeType", item, &::KexiPart::Item::setMimeType );
+
+ this->addFunction0<Kross::Api::Variant>("name", item, &::KexiPart::Item::name );
+ this->addFunction1<void, Kross::Api::Variant>("setName", item, &::KexiPart::Item::setName );
+
+ this->addFunction0<Kross::Api::Variant>("caption", item, &::KexiPart::Item::caption );
+ this->addFunction1<void, Kross::Api::Variant>("setCaption", item, &::KexiPart::Item::setCaption );
+
+ this->addFunction0<Kross::Api::Variant>("description", item, &::KexiPart::Item::description );
+ this->addFunction1<void, Kross::Api::Variant>("setDescription", item, &::KexiPart::Item::setDescription );
+}
diff --git a/kexi/plugins/scripting/kexiapp/kexiapppart.h b/kexi/plugins/scripting/kexiapp/kexiapppart.h
new file mode 100644
index 00000000..5f55d6bf
--- /dev/null
+++ b/kexi/plugins/scripting/kexiapp/kexiapppart.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * kexiapppart.h
+ * This file is part of the KDE project
+ * copyright (C)2006 by Sebastian Sauer (mail@dipe.org)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ ***************************************************************************/
+
+#ifndef KROSS_KEXIAPP_KEXIAPPPART_H
+#define KROSS_KEXIAPP_KEXIAPPPART_H
+
+#include <qstring.h>
+#include <qvariant.h>
+
+#include <api/object.h>
+#include <api/variant.h>
+#include <api/class.h>
+
+// Forward declarations.
+namespace KexiPart {
+ class Item;
+ class Part;
+}
+
+namespace Kross { namespace KexiApp {
+
+ /**
+ * Class to handle Kexi Part::Item instance.
+ */
+ class KexiAppPartItem : public Kross::Api::Class<KexiAppPartItem>
+ {
+ public:
+ KexiAppPartItem(KexiPart::Item*);
+ virtual ~KexiAppPartItem() {}
+ virtual const QString getClassName() const { return "Kross::KexiApp::KexiAppPartItem"; }
+
+ KexiPart::Item* item() { return m_item; }
+ private:
+ KexiPart::Item* m_item;
+ };
+
+}}
+
+#endif
+