F:/KPlato/koffice/kplato/kptfactory.cc

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
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     // If classname is "KoDocument", our host is a koffice application
00055     // otherwise, the host wants us as a simple part, so switch to readonly
00056     // and single view.
00057     bool bWantKoDocument = (strcmp(classname, "KoDocument") == 0);
00058 
00059     // parentWidget and widgetName are used by KoDocument for the
00060     // "readonly+singleView" case.
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         // Add any application-specific resource directories here
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         // Tell the iconloader about share/apps/koffice/icons
00091         s_global->iconLoader()->addAppDir("koffice");
00092     }
00093     return s_global;
00094 }
00095 
00096 } // KPlato namespace
00097 
00098 #include "kptfactory.moc"

Généré le Wed Nov 22 23:40:56 2006 pour KPlato par  doxygen 1.5.1-p1