1 | /* This file is part of the KDE project |
2 | Copyright (C) 1999 Simon Hausmann <hausmann@kde.org> |
3 | (C) 1999 David Faure <faure@kde.org> |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library 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 GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include "factory.h" |
22 | #include "part.h" |
23 | |
24 | #include <QtGui/QWidget> |
25 | |
26 | #include <kpluginloader.h> |
27 | #include <klibrary.h> |
28 | #include <klocale.h> |
29 | #include <kglobal.h> |
30 | #include <kcomponentdata.h> |
31 | #include <assert.h> |
32 | |
33 | using namespace KParts; |
34 | |
35 | Factory::Factory( QObject *parent ) |
36 | : KLibFactory( 0, 0, parent ) |
37 | { |
38 | } |
39 | |
40 | Factory::~Factory() |
41 | { |
42 | } |
43 | |
44 | Part *Factory::createPart( QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args ) |
45 | { |
46 | Part* part = createPartObject( parentWidget, parent, classname, args ); |
47 | if ( part ) |
48 | emit objectCreated( part ); |
49 | return part; |
50 | } |
51 | |
52 | KComponentData Factory::partComponentData() |
53 | { |
54 | return KComponentData(); |
55 | } |
56 | |
57 | KComponentData Factory::partComponentDataFromLibrary( const QString &libraryName ) |
58 | { |
59 | KPluginLoader loader( libraryName ); |
60 | |
61 | KLibFactory *factory = loader.factory(); |
62 | if ( !factory ) |
63 | return KComponentData(); |
64 | KParts::Factory *pfactory = dynamic_cast<KParts::Factory *>( factory ); |
65 | if ( !pfactory ) |
66 | return KComponentData(); |
67 | return pfactory->partComponentData(); |
68 | } |
69 | |
70 | Part *Factory::createPartObject( QWidget *, QObject *, const char *, const QStringList & ) |
71 | { |
72 | return 0; |
73 | } |
74 | |
75 | QObject *Factory::createObject( QObject *parent, const char *classname, const QStringList &args ) |
76 | { |
77 | assert( !parent || parent->isWidgetType() ); |
78 | return createPart( static_cast<QWidget *>( parent ), parent, classname, args ); |
79 | } |
80 | |
81 | #include "factory.moc" |
82 | |