You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kxmleditor/part/kxmleditorfactory.cpp

107 lines
3.1 KiB

/***************************************************************************
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;
}
#include "kxmleditorfactory.moc"