summaryrefslogtreecommitdiffstats
path: root/kchart/kchart_factory.cpp
blob: ff00f20586b284a5ec696e9effb25a5ddce18a7e (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
/**
 * $Id: kchart_factory.cpp 483001 2005-11-24 18:27:18Z dfaure $
 *
 * Kalle Dalheimer <kalle@kde.org>
 */


#include "kchart_factory.h"
#include "kchart_aboutdata.h"
#include "kchart_part.h"
#include <tdelocale.h>
#include <kinstance.h>
#include <kdebug.h>
#include <kiconloader.h>
#include <kstandarddirs.h>

namespace KChart
{

TDEInstance   *KChartFactory::s_global    = 0;
TDEAboutData  *KChartFactory::s_aboutData = 0;


KChartFactory::KChartFactory( TQObject* parent, const char* name )
    : KoFactory( parent, name )
{
    global();
}


KChartFactory::~KChartFactory()
{
    delete s_aboutData;
    s_aboutData = 0;
    delete s_global;
    s_global = 0;
}


KParts::Part* KChartFactory::createPartObject( TQWidget *parentWidget,
					       const char *widgetName,
					       TQObject* parent,
					       const char* name,
					       const char *classname,
					       const TQStringList & )
{
    bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );

    KChartPart *part = new KChartPart( parentWidget, widgetName, parent, name,
				       !bWantKoDocument );

    if ( !bWantKoDocument )
      part->setReadWrite( false );

    return part;
}


TDEAboutData* KChartFactory::aboutData()
{
    if( !s_aboutData )
        s_aboutData = newKChartAboutData();
    return s_aboutData;
}


TDEInstance* KChartFactory::global()
{
    if ( !s_global )
    {
         s_global = new TDEInstance(aboutData());
         s_global->dirs()->addResourceType( "kchart_template",
         TDEStandardDirs::kde_default("data") + "kchart/templates/");
         // Tell the iconloader about share/apps/koffice/icons
         s_global->iconLoader()->addAppDir("koffice");
    }
    return s_global;
}

}  //namespace KChart

#include <kchart_factory.moc>