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
|
// Copyright (c) 2000 Phil Thompson <phil@river-bank.demon.co.uk>
//
// This file contains the implementation of the Kugar KPart.
#include <klocale.h>
#include <kstandarddirs.h>
#include <kinstance.h>
#include <kaboutdata.h>
#include <kglobal.h>
#include <kiconloader.h>
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include "kugar_factory.h"
#include "kugar_part.h"
#include "kugar_about.h"
KInstance *KugarFactory::s_instance = 0L;
KAboutData *KugarFactory::s_aboutdata = 0L;
// The part's entry point.
K_EXPORT_COMPONENT_FACTORY( libkugarpart, KugarFactory )
// The factory ctor.
KugarFactory::KugarFactory( TQObject *tqparent, const char* name ) : KoFactory( tqparent, name )
{
global();
}
KInstance* KugarFactory::global()
{
if ( !s_instance )
{
s_instance = new KInstance( aboutData() );
s_instance->iconLoader() ->addAppDir( "koffice" );
s_instance->iconLoader() ->addAppDir( "kugar" );
}
return s_instance;
}
// The factory dtor.
KugarFactory::~KugarFactory()
{
delete s_instance;
s_instance = 0;
delete s_aboutdata;
s_aboutdata = 0;
}
KAboutData *KugarFactory::aboutData()
{
if ( !s_aboutdata )
s_aboutdata = newKugarAboutData();
return s_aboutdata;
}
// Create a new part.
KParts::Part* KugarFactory::createPartObject( TQWidget *parentWidget, const char *widgetName,
TQObject* tqparent, const char* name, const char* classname, const TQStringList & data )
{
TQString forcedUserTemplate;
for ( TQStringList::const_iterator it = data.begin();it != data.end();++it )
{
TQString tmp = ( *it );
if ( tmp.startsWith( "template=" ) )
forcedUserTemplate = tmp.right( tmp.length() - 9 );
}
bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
// parentWidget and widgetName are used by KoDocument for the "readonly+singleView" case.
KugarPart *part = new KugarPart( parentWidget, widgetName, tqparent, name, !bWantKoDocument );
// if ( !bWantKoDocument )
part->setReadWrite( false );
part->setForcedUserTemplate( forcedUserTemplate );
return part;
//return ( new KugarPart(parentWidget,name,forcedUserTemplate));
}
#include "kugar_factory.moc"
|