1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "kptfactory.h"
21#include "kptmaindocument.h"
22#include "kptpart.h"
23#include "kptaboutdata.h"
24#include <kcomponentdata.h>
25#include <kiconloader.h>
26#include <klocale.h>
27#include <kdebug.h>
28#include <kstandarddirs.h>
29
30namespace KPlato
31{
32
33KComponentData* Factory::s_global = 0L;
34KAboutData* Factory::s_aboutData = 0L;
35
36Factory::Factory( QObject* parent )
37 : KPluginFactory( *aboutData(), parent )
38{
39 global();
40}
41
42Factory::~Factory()
43{
44 delete s_aboutData;
45 s_aboutData = 0L;
46 delete s_global;
47 s_global = 0L;
48}
49
50QObject* Factory::create( const char* /*iface*/, QWidget* /*parentWidget*/, QObject *parent,
51 const QVariantList& args, const QString& keyword )
52{
53 Q_UNUSED( args );
54 Q_UNUSED( keyword );
55
56 Part *part = new Part(parent);
57 MainDocument *doc = new MainDocument(part);
58 part->setDocument(doc);
59
60 return part;
61}
62
63KAboutData* Factory::aboutData()
64{
65 if ( !s_aboutData )
66 s_aboutData = newAboutData();
67 return s_aboutData;
68}
69
70const KComponentData &Factory::global()
71{
72 if ( !s_global )
73 {
74 s_global = new KComponentData( aboutData() );
75
76 // Add any application-specific resource directories here
77 s_global->dirs()->addResourceType("plan_template", "data", "plan/templates/");
78 s_global->dirs()->addResourceType("plan_taskmodules", "data", "plan/taskmodules/");
79 s_global->dirs()->addResourceType("toolbar", "data", "calligra/toolbar/");
80
81 // Tell the iconloader about share/apps/calligra/icons
82 KIconLoader::global()->addAppDir("calligra");
83 }
84 return *s_global;
85}
86
87} // KPlato namespace
88
89#include "kptfactory.moc"
90