kplato
kptfactory.cc00001
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 K_EXPORT_COMPONENT_FACTORY( libkplatopart, Factory )
00033
00034 KInstance* Factory::s_global = 0L;
00035 KAboutData* Factory::s_aboutData = 0L;
00036
00037 Factory::Factory( QObject* parent, const char* name )
00038 : KoFactory( parent, name )
00039 {
00040 global();
00041 }
00042
00043 Factory::~Factory()
00044 {
00045 delete s_aboutData;
00046 s_aboutData = 0L;
00047 delete s_global;
00048 s_global = 0L;
00049 }
00050
00051 KParts::Part *Factory::createPartObject(QWidget *parentWidget,
00052 const char *widgetName,
00053 QObject* parent, const char* name,
00054 const char* classname,
00055 const QStringList &)
00056 {
00057
00058
00059
00060 bool bWantKoDocument = (strcmp(classname, "KoDocument") == 0);
00061
00062
00063
00064 Part *part = new Part(parentWidget, widgetName, parent, name,
00065 !bWantKoDocument);
00066
00067 if (!bWantKoDocument)
00068 part->setReadWrite(false);
00069
00070 return part;
00071 }
00072
00073 KAboutData* Factory::aboutData()
00074 {
00075 if ( !s_aboutData )
00076 s_aboutData = newAboutData();
00077 return s_aboutData;
00078 }
00079
00080 KInstance* Factory::global()
00081 {
00082 if ( !s_global )
00083 {
00084 s_global = new KInstance( aboutData() );
00085
00086
00087 s_global->dirs()->addResourceType("kplato_template",
00088 KStandardDirs::kde_default("data") + "kplato/templates/");
00089 s_global->dirs()->addResourceType( "expression", KStandardDirs::kde_default("data") + "kplato/expression/");
00090 s_global->dirs()->addResourceType("toolbar",
00091 KStandardDirs::kde_default("data") + "koffice/toolbar/");
00092
00093
00094 s_global->iconLoader()->addAppDir("koffice");
00095 }
00096 return s_global;
00097 }
00098
00099 }
00100
00101 #include "kptfactory.moc"
|