diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch) | |
tree | acaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/cpp/app_templates/kofficepart/kopart_factory.cpp | |
download | tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.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/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'languages/cpp/app_templates/kofficepart/kopart_factory.cpp')
-rw-r--r-- | languages/cpp/app_templates/kofficepart/kopart_factory.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/languages/cpp/app_templates/kofficepart/kopart_factory.cpp b/languages/cpp/app_templates/kofficepart/kopart_factory.cpp new file mode 100644 index 00000000..bd79c317 --- /dev/null +++ b/languages/cpp/app_templates/kofficepart/kopart_factory.cpp @@ -0,0 +1,76 @@ + +/* This template is based off of the KOffice example written by Torben Weis <weis@kde.org + It was converted to a KDevelop template by Ian Reinhart Geiser <geiseri@yahoo.com> +*/ +#include <%{APPNAMELC}_factory.h> +#include <%{APPNAMELC}_part.h> +#include <%{APPNAMELC}_aboutdata.h> +#include <kinstance.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kdebug.h> +#include <kglobal.h> + +extern "C" +{ + void* init_lib%{APPNAMELC}part() + { + KGlobal::locale()->insertCatalogue("%{APPNAMELC}"); + return new %{APPNAME}Factory; + } +}; + +KInstance* %{APPNAME}Factory::s_global = 0L; +KAboutData* %{APPNAME}Factory::s_aboutData = 0L; + +%{APPNAME}Factory::%{APPNAME}Factory( QObject* parent, const char* name ) + : KoFactory( parent, name ) +{ + global(); +} + +%{APPNAME}Factory::~%{APPNAME}Factory() +{ + delete s_aboutData; + s_aboutData = 0L; + delete s_global; + s_global = 0L; +} + +KParts::Part* %{APPNAME}Factory::createPartObject( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name, const char* classname, const QStringList & ) +{ + // If classname is "KoDocument", our host is a koffice application + // otherwise, the host wants us as a simple part, so switch to readonly and single view. + bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 ); + + // parentWidget and widgetName are used by KoDocument for the "readonly+singleView" case. + %{APPNAME}Part *part = new %{APPNAME}Part( parentWidget, widgetName, parent, name, !bWantKoDocument ); + + if ( !bWantKoDocument ) + part->setReadWrite( false ); + + return part; +} + +KAboutData* %{APPNAME}Factory::aboutData() +{ + if ( !s_aboutData ) + // Change this, of course + s_aboutData = new%{APPNAME}AboutData(); + return s_aboutData; +} + +KInstance* %{APPNAME}Factory::global() +{ + if ( !s_global ) + { + s_global = new KInstance( aboutData() ); + // Add any application-specific resource directories here + + // Tell the iconloader about share/apps/koffice/icons + s_global->iconLoader()->addAppDir("koffice"); + } + return s_global; +} + +#include <%{APPNAMELC}_factory.moc> |