konqfactory.h 3.1 KB
Newer Older
1 2 3 4
/*  This file is part of the KDE project
    Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
    Copyright (C) 1999 David Faure <faure@kde.org>
    Copyright (C) 1999 Torben Weis <weis@kde.org>
Torben Weis's avatar
Torben Weis committed
5

6 7 8 9
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
Torben Weis's avatar
Torben Weis committed
10

11 12 13 14
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
Torben Weis's avatar
Torben Weis committed
15

16 17
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
Dirk Mueller's avatar
Dirk Mueller committed
18
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Torben Weis's avatar
Torben Weis committed
19 20

*/
21 22

#ifndef __konq_factory_h__
Frans Englich's avatar
 
Frans Englich committed
23
#define __konq_factory_h__
24

25
#include "konqprivate_export.h"
Laurent Montel's avatar
Laurent Montel committed
26

Dirk Mueller's avatar
Dirk Mueller committed
27
#include <QtCore/QStringList>
28

Aaron J. Seigo's avatar
Aaron J. Seigo committed
29
#include <kservice.h>
30

31
class KAboutData;
David Faure's avatar
David Faure committed
32 33
class KLibFactory;
namespace KParts { class ReadOnlyPart; }
34

35
class KonqViewFactory // TODO rename to KonqPartFactory? confusing though due to KParts::PartFactory (in the part itself)
36 37
{
public:
David Faure's avatar
David Faure committed
38
  KonqViewFactory() : m_factory( 0 ), m_createBrowser( false ) {}
39

40
  KonqViewFactory( KLibFactory *factory, const QStringList &args, bool createBrowser );
41

42
  KonqViewFactory( const KonqViewFactory &factory )
Simon Hausmann's avatar
Simon Hausmann committed
43 44 45 46 47 48 49 50 51
  { (*this) = factory; }

  KonqViewFactory &operator=( const KonqViewFactory &other )
  {
    m_factory = other.m_factory;
    m_args = other.m_args;
    m_createBrowser = other.m_createBrowser;
    return *this;
  }
52

Aaron J. Seigo's avatar
Aaron J. Seigo committed
53
  KParts::ReadOnlyPart *create( QWidget *parentWidget, QObject *parent );
54 55

  bool isNull() const { return m_factory ? false : true; }
56 57 58 59

private:
  KLibFactory *m_factory;
  QStringList m_args;
Simon Hausmann's avatar
Simon Hausmann committed
60
  bool m_createBrowser;
61 62
};

David Faure's avatar
David Faure committed
63 64 65
/**
 * Factory for creating (loading) parts when creating a view.
 */
66
class KONQ_TESTS_EXPORT KonqFactory
67 68
{
public:
David Faure's avatar
David Faure committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
    /**
     * Return the factory that can be used to actually create the part inside a view.
     *
     * The implementation locates the part module (library), using the trader
     * and opens it (using klibfactory), which gives us a factory that can be used to
     * actually create the part (later on, when the KonqView exists).
     *
     * Not a static method so that we can define an abstract base class
     * with another implementation, for unit tests, if wanted.
     */
    KonqViewFactory createView( const QString &serviceType,
                                const QString &serviceName = QString(),
                                KService::Ptr *serviceImpl = 0,
                                KService::List *partServiceOffers = 0,
                                KService::List *appServiceOffers = 0,
                                bool forceAutoEmbed = false );

    static void getOffers( const QString & serviceType,
                           KService::List *partServiceOffers = 0,
                           KService::List *appServiceOffers = 0);

    static const KAboutData* aboutData();
91 92 93
};

#endif