summaryrefslogtreecommitdiffstats
path: root/part/kxmleditorfactory.cpp
blob: 0db94559011a9e4886dce3ed9ec0012f97662652 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/***************************************************************************
                          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 "config.h"

#include "kxmleditorfactory.h"
#include "kxmleditorpart.h"
#include "kxmleditorabout.h"
#include "kxeconfiguration.h"
#include "kxedocument.h"

#include <kinstance.h>
#include <kdebug.h>

extern "C"
{
	KDE_EXPORT void * init_libkxmleditorpart()
	{
		return new KXMLEditorFactory;
	}
} 

TDEInstance * KXMLEditorFactory::s_instance = 0L;
KXEConfiguration * KXMLEditorFactory::s_pKXEConfig = 0L;

KXMLEditorFactory::KXMLEditorFactory( TQObject * 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( TQWidget * pParentWidget, const char * pszWidgetName, TQObject * pParent, const char * pszName, const char * pszClassName, const TQStringList & )
{
	// eliminating compiler warnings
	pParent = pParent;
	pszName = pszName;

	KParts::Part * pPart=0L;
	KXEDocument* pDocument=0L;
	if ( TQCString(pszClassName) == "KParts::ReadOnlyPart" )
	{
		pDocument = new KXEDocument();
		pPart = new KXMLEditorPart( false, pDocument, pParentWidget, pszWidgetName );
		kdDebug() << "KXMLEditorFactory::createPartObject: read only KXMLEditorPart created" << endl;
	}
	else if ( (TQCString(pszClassName) == "KParts::ReadWritePart") ||
	          (TQCString(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;
}

TDEInstance * KXMLEditorFactory::instance()
{
	if ( ! s_instance )
	{
		s_instance = new TDEInstance( new KXMLEditorAboutData() );
	}
	return s_instance;
}

KXEConfiguration * KXMLEditorFactory::configuration()
{
	if ( ! s_pKXEConfig )
		s_pKXEConfig = new KXEConfiguration();

	return s_pKXEConfig;
}

#include "kxmleditorfactory.moc"