kivio

kivio_factory.cpp

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 #include "kivio_factory.h"
00020 #include "kivio_doc.h"
00021 #include "kivio_aboutdata.h"
00022 
00023 #include <klocale.h>
00024 #include <kinstance.h>
00025 #include <kstandarddirs.h>
00026 #include <kiconloader.h>
00027 
00028 
00029 KInstance* KivioFactory::s_global = 0;
00030 KAboutData* KivioFactory::s_aboutData = 0;
00031 
00032 KivioFactory::KivioFactory( QObject* parent, const char* name )
00033 : KoFactory( parent, name )
00034 {
00035   global();
00036 }
00037 
00038 KivioFactory::~KivioFactory()
00039 {
00040   delete s_aboutData;
00041   s_aboutData=0;
00042   delete s_global;
00043   s_global = 0L;
00044 }
00045 
00046 KParts::Part* KivioFactory::createPartObject( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name, const char* classname, const QStringList & )
00047 {
00048   bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
00049 
00050   KivioDoc *doc = new KivioDoc( parentWidget, widgetName, parent, name, !bWantKoDocument );
00051 
00052   if ( !bWantKoDocument )
00053     doc->setReadWrite( false );
00054 
00055   return doc;
00056 }
00057 
00058 KAboutData* KivioFactory::aboutData()
00059 {
00060   if( !s_aboutData )
00061     s_aboutData = newKivioAboutData();
00062   return s_aboutData;
00063 }
00064 
00065 KInstance* KivioFactory::global()
00066 {
00067   if ( !s_global )
00068   {
00069     s_global = new KInstance(aboutData());
00070     s_global->dirs()->addResourceType( "kivio_template", KStandardDirs::kde_default("data") + "kivio/templates/" );
00071     s_global->dirs()->addResourceType( "toolbar", KStandardDirs::kde_default("data") + "koffice/toolbar/");
00072     s_global->iconLoader()->addAppDir("koffice");
00073   }
00074 
00075   return s_global;
00076 }
00077 
00078 #include "kivio_factory.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys