diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2016-03-26 13:50:43 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2016-03-26 13:50:43 +0100 |
commit | d62c8c002c51fb7c36487839eeeb4ac89f044dee (patch) | |
tree | bb4d1f5c631ab1f22a3018ba39e6a806035f80fd /part/kxmleditorfactory.cpp | |
download | kxmleditor-d62c8c002c51fb7c36487839eeeb4ac89f044dee.tar.gz kxmleditor-d62c8c002c51fb7c36487839eeeb4ac89f044dee.zip |
Initial import of kxmleditor 1.1.4
Diffstat (limited to 'part/kxmleditorfactory.cpp')
-rw-r--r-- | part/kxmleditorfactory.cpp | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/part/kxmleditorfactory.cpp b/part/kxmleditorfactory.cpp new file mode 100644 index 0000000..40819db --- /dev/null +++ b/part/kxmleditorfactory.cpp @@ -0,0 +1,104 @@ +/*************************************************************************** + kxmleditorfactory.cpp - description + ------------------- + begin : Wed Sep 19 2001 + copyright : (C) 2001, 2002, 2003 byThe KXMLEditor Team + email : OleBowle@gmx.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxmleditorfactory.h" +#include "kxmleditorpart.h" +#include "kxmleditorabout.h" +#include "kxeconfiguration.h" +#include "kxedocument.h" + +#include <kinstance.h> +#include <kdebug.h> + +extern "C" +{ + void * init_libkxmleditorpart() + { + return new KXMLEditorFactory; + } +} + +KInstance * KXMLEditorFactory::s_instance = 0L; +KXEConfiguration * KXMLEditorFactory::s_pKXEConfig = 0L; + +KXMLEditorFactory::KXMLEditorFactory( QObject * pParent, const char * pszName ) + : KParts::Factory(pParent,pszName) +{ +} + +KXMLEditorFactory::~KXMLEditorFactory() +{ + if ( s_pKXEConfig ) + delete s_pKXEConfig; + + s_pKXEConfig = 0L; + + if (s_instance) + delete s_instance; + + s_instance = 0L; +} + +KParts::Part * KXMLEditorFactory::createPartObject( QWidget * pParentWidget, const char * pszWidgetName, QObject * pParent, const char * pszName, const char * pszClassName, const QStringList & ) +{ + // eliminating compiler warnings + pParent = pParent; + pszName = pszName; + + KParts::Part * pPart=0L; + KXEDocument* pDocument=0L; + if ( QCString(pszClassName) == "KParts::ReadOnlyPart" ) + { + pDocument = new KXEDocument(); + pPart = new KXMLEditorPart( false, pDocument, pParentWidget, pszWidgetName ); + kdDebug() << "KXMLEditorFactory::createPartObject: read only KXMLEditorPart created" << endl; + } + else if ( (QCString(pszClassName) == "KParts::ReadWritePart") || + (QCString(pszClassName) == "KXMLEditorPart") ) + { + pDocument = new KXEDocument(); + pPart = new KXMLEditorPart( true, pDocument, pParentWidget, pszWidgetName ); + kdDebug() << "KXMLEditorFactory::createPartObject: read/write KXMLEditorPart created" << endl; + } + else + { + kdError() << "KXMLEditorFactory::createPartObject: classname isn't KParts::ReadOnlyPart nor KParts::ReadWritePart." << endl; + return 0L; + } + + + emit objectCreated( pPart ); + + return pPart; +} + +KInstance * KXMLEditorFactory::instance() +{ + if ( ! s_instance ) + { + s_instance = new KInstance( new KXMLEditorAboutData() ); + } + return s_instance; +} + +KXEConfiguration * KXMLEditorFactory::configuration() +{ + if ( ! s_pKXEConfig ) + s_pKXEConfig = new KXEConfiguration(); + + return s_pKXEConfig; +} |