kivio_factory.cpp
1/*
2 * Kivio - Visual Modelling and Flowcharting
3 * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19#include "kivio_factory.h"
20#include "kivio_doc.h"
21#include "kivio_aboutdata.h"
22
23#include <tdelocale.h>
24#include <tdeinstance.h>
25#include <kstandarddirs.h>
26#include <kiconloader.h>
27
28
29TDEInstance* KivioFactory::s_global = 0;
30TDEAboutData* KivioFactory::s_aboutData = 0;
31
32KivioFactory::KivioFactory( TQObject* parent, const char* name )
33: KoFactory( parent, name )
34{
35 global();
36}
37
38KivioFactory::~KivioFactory()
39{
40 delete s_aboutData;
41 s_aboutData=0;
42 delete s_global;
43 s_global = 0L;
44}
45
46KParts::Part* KivioFactory::createPartObject( TQWidget *parentWidget, const char *widgetName, TQObject* parent, const char* name, const char* classname, const TQStringList & )
47{
48 bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
49
50 KivioDoc *doc = new KivioDoc( parentWidget, widgetName, parent, name, !bWantKoDocument );
51
52 if ( !bWantKoDocument )
53 doc->setReadWrite( false );
54
55 return doc;
56}
57
58TDEAboutData* KivioFactory::aboutData()
59{
60 if( !s_aboutData )
61 s_aboutData = newKivioAboutData();
62 return s_aboutData;
63}
64
65TDEInstance* KivioFactory::global()
66{
67 if ( !s_global )
68 {
69 s_global = new TDEInstance(aboutData());
70 s_global->dirs()->addResourceType( "kivio_template", TDEStandardDirs::kde_default("data") + "kivio/templates/" );
71 s_global->dirs()->addResourceType( "toolbar", TDEStandardDirs::kde_default("data") + "koffice/toolbar/");
72 s_global->iconLoader()->addAppDir("koffice");
73 }
74
75 return s_global;
76}
77
78#include "kivio_factory.moc"