kchart

kchart_factory.cc

00001 
00008 #include "kchart_factory.h"
00009 #include "kchart_aboutdata.h"
00010 #include "kchart_part.h"
00011 #include <klocale.h>
00012 #include <kinstance.h>
00013 #include <kdebug.h>
00014 #include <kiconloader.h>
00015 #include <kstandarddirs.h>
00016 
00017 namespace KChart
00018 {
00019 
00020 KInstance   *KChartFactory::s_global    = 0;
00021 KAboutData  *KChartFactory::s_aboutData = 0;
00022 
00023 
00024 KChartFactory::KChartFactory( QObject* parent, const char* name )
00025     : KoFactory( parent, name )
00026 {
00027     global();
00028 }
00029 
00030 
00031 KChartFactory::~KChartFactory()
00032 {
00033     delete s_aboutData;
00034     s_aboutData = 0;
00035     delete s_global;
00036     s_global = 0;
00037 }
00038 
00039 
00040 KParts::Part* KChartFactory::createPartObject( QWidget *parentWidget,
00041                            const char *widgetName,
00042                            QObject* parent,
00043                            const char* name,
00044                            const char *classname,
00045                            const QStringList & )
00046 {
00047     bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
00048 
00049     KChartPart *part = new KChartPart( parentWidget, widgetName, parent, name,
00050                        !bWantKoDocument );
00051 
00052     if ( !bWantKoDocument )
00053       part->setReadWrite( false );
00054 
00055     return part;
00056 }
00057 
00058 
00059 KAboutData* KChartFactory::aboutData()
00060 {
00061     if( !s_aboutData )
00062         s_aboutData = newKChartAboutData();
00063     return s_aboutData;
00064 }
00065 
00066 
00067 KInstance* KChartFactory::global()
00068 {
00069     if ( !s_global )
00070     {
00071          s_global = new KInstance(aboutData());
00072          s_global->dirs()->addResourceType( "kchart_template",
00073          KStandardDirs::kde_default("data") + "kchart/templates/");
00074          // Tell the iconloader about share/apps/koffice/icons
00075          s_global->iconLoader()->addAppDir("koffice");
00076     }
00077     return s_global;
00078 }
00079 
00080 }  //namespace KChart
00081 
00082 #include <kchart_factory.moc>
KDE Home | KDE Accessibility Home | Description of Access Keys