kchart

kchart_factory.cpp
1
6
7
8#include "kchart_factory.h"
9#include "kchart_aboutdata.h"
10#include "kchart_part.h"
11#include <tdelocale.h>
12#include <tdeinstance.h>
13#include <kdebug.h>
14#include <kiconloader.h>
15#include <kstandarddirs.h>
16
17namespace KChart
18{
19
20TDEInstance *KChartFactory::s_global = 0;
21TDEAboutData *KChartFactory::s_aboutData = 0;
22
23
24KChartFactory::KChartFactory( TQObject* parent, const char* name )
25 : KoFactory( parent, name )
26{
27 global();
28}
29
30
31KChartFactory::~KChartFactory()
32{
33 delete s_aboutData;
34 s_aboutData = 0;
35 delete s_global;
36 s_global = 0;
37}
38
39
40KParts::Part* KChartFactory::createPartObject( TQWidget *parentWidget,
41 const char *widgetName,
42 TQObject* parent,
43 const char* name,
44 const char *classname,
45 const TQStringList & )
46{
47 bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
48
49 KChartPart *part = new KChartPart( parentWidget, widgetName, parent, name,
50 !bWantKoDocument );
51
52 if ( !bWantKoDocument )
53 part->setReadWrite( false );
54
55 return part;
56}
57
58
59TDEAboutData* KChartFactory::aboutData()
60{
61 if( !s_aboutData )
62 s_aboutData = newKChartAboutData();
63 return s_aboutData;
64}
65
66
67TDEInstance* KChartFactory::global()
68{
69 if ( !s_global )
70 {
71 s_global = new TDEInstance(aboutData());
72 s_global->dirs()->addResourceType( "kchart_template",
73 TDEStandardDirs::kde_default("data") + "kchart/templates/");
74 // Tell the iconloader about share/apps/koffice/icons
75 s_global->iconLoader()->addAppDir("koffice");
76 }
77 return s_global;
78}
79
80} //namespace KChart
81
82#include <kchart_factory.moc>