KParts
factory.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright (C) 1999 Simon Hausmann <hausmann@kde.org> 00003 (C) 1999 David Faure <faure@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include "factory.h" 00022 #include "part.h" 00023 00024 #include <QtGui/QWidget> 00025 00026 #include <kpluginloader.h> 00027 #include <klibrary.h> 00028 #include <klocale.h> 00029 #include <kglobal.h> 00030 #include <kcomponentdata.h> 00031 #include <assert.h> 00032 00033 using namespace KParts; 00034 00035 Factory::Factory( QObject *parent ) 00036 : KLibFactory( 0, 0, parent ) 00037 { 00038 } 00039 00040 Factory::~Factory() 00041 { 00042 } 00043 00044 Part *Factory::createPart( QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args ) 00045 { 00046 Part* part = createPartObject( parentWidget, parent, classname, args ); 00047 if ( part ) 00048 emit objectCreated( part ); 00049 return part; 00050 } 00051 00052 KComponentData Factory::partComponentData() 00053 { 00054 return KComponentData(); 00055 } 00056 00057 KComponentData Factory::partComponentDataFromLibrary( const QString &libraryName ) 00058 { 00059 KPluginLoader loader( libraryName ); 00060 00061 KLibFactory *factory = loader.factory(); 00062 if ( !factory ) 00063 return KComponentData(); 00064 KParts::Factory *pfactory = dynamic_cast<KParts::Factory *>( factory ); 00065 if ( !pfactory ) 00066 return KComponentData(); 00067 return pfactory->partComponentData(); 00068 } 00069 00070 Part *Factory::createPartObject( QWidget *, QObject *, const char *, const QStringList & ) 00071 { 00072 return 0; 00073 } 00074 00075 QObject *Factory::createObject( QObject *parent, const char *classname, const QStringList &args ) 00076 { 00077 assert( !parent || parent->isWidgetType() ); 00078 return createPart( static_cast<QWidget *>( parent ), parent, classname, args ); 00079 } 00080 00081 #include "factory.moc"
KDE 4.6 API Reference