TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

factory.cpp 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. 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. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #include "factory.h"
  18. #include "part.h"
  19. #include <tqwidget.h>
  20. #include <tdelocale.h>
  21. #include <tdeglobal.h>
  22. #include <kinstance.h>
  23. #include <assert.h>
  24. using namespace KParts;
  25. Factory::Factory( TQObject *parent, const char *name )
  26. : KLibFactory( parent, name )
  27. {
  28. }
  29. Factory::~Factory()
  30. {
  31. }
  32. Part *Factory::createPart( TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const char *classname, const TQStringList &args )
  33. {
  34. Part* part = createPartObject( parentWidget, widgetName, parent, name, classname, args );
  35. if ( part )
  36. emit objectCreated( part );
  37. return part;
  38. }
  39. const TDEInstance *Factory::partInstance()
  40. {
  41. QueryInstanceParams params;
  42. params.instance = 0;
  43. virtual_hook( VIRTUAL_QUERY_INSTANCE_PARAMS, &params );
  44. return params.instance;
  45. }
  46. const TDEInstance *Factory::partInstanceFromLibrary( const TQCString &libraryName )
  47. {
  48. KLibrary *library = KLibLoader::self()->library( libraryName );
  49. if ( !library )
  50. return 0;
  51. KLibFactory *factory = library->factory();
  52. if ( !factory )
  53. return 0;
  54. KParts::Factory *pfactory = tqt_dynamic_cast<KParts::Factory *>( factory );
  55. if ( !pfactory )
  56. return 0;
  57. return pfactory->partInstance();
  58. }
  59. Part *Factory::createPartObject( TQWidget *, const char *, TQObject *, const char *, const char *, const TQStringList & )
  60. {
  61. return 0;
  62. }
  63. TQObject *Factory::createObject( TQObject *parent, const char *name, const char *classname, const TQStringList &args )
  64. {
  65. assert( !parent || parent->isWidgetType() );
  66. return createPart( TQT_TQWIDGET( parent ), name, parent, name, classname, args );
  67. }
  68. #include "factory.moc"