kpresenter

KPrFactory.cpp

00001 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
00002 /* This file is part of the KDE project
00003    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library 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 GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "KPrFactory.h"
00022 #include "KPrDocument.h"
00023 #include "KPrAboutData.h"
00024 
00025 #include <kstandarddirs.h>
00026 #include <kinstance.h>
00027 
00028 
00029 KInstance* KPrFactory::s_global = 0;
00030 KAboutData* KPrFactory::s_aboutData = 0;
00031 
00032 KPrFactory::KPrFactory( QObject* parent, const char* name )
00033     : KoFactory( parent, name )
00034 {
00035     (void)global();
00036 }
00037 
00038 KPrFactory::~KPrFactory()
00039 {
00040     delete s_aboutData;
00041     s_aboutData=0;
00042     delete s_global;
00043     s_global=0;
00044 }
00045 
00046 KParts::Part* KPrFactory::createPartObject( QWidget *parentWidget, const char *widgetName, QObject* parent,
00047                                                    const char* name, const char* classname, const QStringList & )
00048 {
00049     bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
00050 
00051     KPrDocument *doc = new KPrDocument( parentWidget, widgetName, parent, name, !bWantKoDocument );
00052 
00053     if ( !bWantKoDocument )
00054         doc->setReadWrite( false );
00055 
00056     return doc;
00057 }
00058 
00059 KAboutData* KPrFactory::aboutData()
00060 {
00061     if( !s_aboutData )
00062         s_aboutData=newKPresenterAboutData();
00063     return s_aboutData;
00064 }
00065 
00066 KInstance* KPrFactory::global()
00067 {
00068     if ( !s_global )
00069     {
00070         s_global = new KInstance(aboutData());
00071 
00072         s_global->dirs()->addResourceType("kpresenter_template",
00073                                           KStandardDirs::kde_default("data") + "kpresenter/templates/");
00074         s_global->dirs()->addResourceType("autoforms",
00075                                           KStandardDirs::kde_default("data") + "kpresenter/autoforms/");
00076         s_global->dirs()->addResourceType("slideshow",
00077                                           KStandardDirs::kde_default("data") + "kpresenter/slideshow/");
00078         // Tell the iconloader about share/apps/koffice/icons
00079         s_global->iconLoader()->addAppDir("koffice");
00080     }
00081     return s_global;
00082 }
00083 
00084 #include "KPrFactory.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys