00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kptfactory.h"
00021 #include "kptpart.h"
00022 #include "kptaboutdata.h"
00023 #include <kinstance.h>
00024 #include <kiconloader.h>
00025 #include <klocale.h>
00026 #include <kdebug.h>
00027 #include <kstandarddirs.h>
00028
00029 namespace KPlato
00030 {
00031
00032 KInstance* Factory::s_global = 0L;
00033 KAboutData* Factory::s_aboutData = 0L;
00034
00035 Factory::Factory( QObject* parent, const char* name )
00036 : KoFactory( parent, name )
00037 {
00038 global();
00039 }
00040
00041 Factory::~Factory()
00042 {
00043 delete s_aboutData;
00044 s_aboutData = 0L;
00045 delete s_global;
00046 s_global = 0L;
00047 }
00048
00049 KParts::Part *Factory::createPartObject(QWidget *parentWidget,
00050 QObject* parent,
00051 const char* classname,
00052 const QStringList &)
00053 {
00054
00055
00056
00057 bool bWantKoDocument = (strcmp(classname, "KoDocument") == 0);
00058
00059
00060
00061 Part *part = new Part(parentWidget, parent,
00062 !bWantKoDocument);
00063
00064 if (!bWantKoDocument)
00065 part->setReadWrite(false);
00066
00067 return part;
00068 }
00069
00070 KAboutData* Factory::aboutData()
00071 {
00072 if ( !s_aboutData )
00073 s_aboutData = newAboutData();
00074 return s_aboutData;
00075 }
00076
00077 KInstance* Factory::global()
00078 {
00079 if ( !s_global )
00080 {
00081 s_global = new KInstance( aboutData() );
00082
00083
00084 s_global->dirs()->addResourceType("kplato_template",
00085 KStandardDirs::kde_default("data") + "kplato/templates/");
00086 s_global->dirs()->addResourceType( "expression", KStandardDirs::kde_default("data") + "kplato/expression/");
00087 s_global->dirs()->addResourceType("toolbar",
00088 KStandardDirs::kde_default("data") + "koffice/toolbar/");
00089
00090
00091 s_global->iconLoader()->addAppDir("koffice");
00092 }
00093 return s_global;
00094 }
00095
00096 }
00097
00098 #include "kptfactory.moc"