fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / kparts / factory.cpp
blob2e863dd4c5521a1774cc4ec799dfc25ae3cbbf2c
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>
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.
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.
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.
21 #include "factory.h"
22 #include "part.h"
24 #include <QtGui/QWidget>
26 #include <klocale.h>
27 #include <kglobal.h>
28 #include <kcomponentdata.h>
29 #include <assert.h>
31 using namespace KParts;
33 Factory::Factory( QObject *parent )
34 : KLibFactory( parent )
38 Factory::~Factory()
42 Part *Factory::createPart( QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args )
44 Part* part = createPartObject( parentWidget, parent, classname, args );
45 if ( part )
46 emit objectCreated( part );
47 return part;
50 KComponentData Factory::partComponentData()
52 return KComponentData();
55 KComponentData Factory::partComponentDataFromLibrary( const QString &libraryName )
57 KLibrary *library = KLibLoader::self()->library( libraryName );
58 if ( !library )
59 return KComponentData();
60 KLibFactory *factory = library->factory();
61 if ( !factory )
62 return KComponentData();
63 KParts::Factory *pfactory = dynamic_cast<KParts::Factory *>( factory );
64 if ( !pfactory )
65 return KComponentData();
66 return pfactory->partComponentData();
69 Part *Factory::createPartObject( QWidget *, QObject *, const char *, const QStringList & )
71 return 0;
74 QObject *Factory::createObject( QObject *parent, const char *classname, const QStringList &args )
76 assert( !parent || parent->isWidgetType() );
77 return createPart( static_cast<QWidget *>( parent ), parent, classname, args );
80 #include "factory.moc"