~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to languages/cpp/app_templates/kofficepart/kopart_factory.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* This template is based off of the KOffice example written by Torben Weis <weis@kde.org
 
3
   It was converted to a KDevelop template by Ian Reinhart Geiser <geiseri@yahoo.com>
 
4
*/
 
5
#include <%{APPNAMELC}_factory.h>
 
6
#include <%{APPNAMELC}_part.h>
 
7
#include <%{APPNAMELC}_aboutdata.h>
 
8
#include <kinstance.h>
 
9
#include <kiconloader.h>
 
10
#include <klocale.h>
 
11
#include <kdebug.h>
 
12
#include <kglobal.h>
 
13
 
 
14
extern "C"
 
15
{
 
16
    void* init_lib%{APPNAMELC}part()
 
17
    {
 
18
        KGlobal::locale()->insertCatalogue("%{APPNAMELC}");
 
19
        return new %{APPNAME}Factory;
 
20
    }
 
21
};
 
22
 
 
23
KInstance* %{APPNAME}Factory::s_global = 0L;
 
24
KAboutData* %{APPNAME}Factory::s_aboutData = 0L;
 
25
 
 
26
%{APPNAME}Factory::%{APPNAME}Factory( QObject* parent, const char* name )
 
27
    : KoFactory( parent, name )
 
28
{
 
29
    global();
 
30
}
 
31
 
 
32
%{APPNAME}Factory::~%{APPNAME}Factory()
 
33
{
 
34
    delete s_aboutData;
 
35
    s_aboutData = 0L;
 
36
    delete s_global;
 
37
    s_global = 0L;
 
38
}
 
39
 
 
40
KParts::Part* %{APPNAME}Factory::createPartObject( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name, const char* classname, const QStringList & )
 
41
{
 
42
    // If classname is "KoDocument", our host is a koffice application
 
43
    // otherwise, the host wants us as a simple part, so switch to readonly and single view.
 
44
    bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
 
45
 
 
46
    // parentWidget and widgetName are used by KoDocument for the "readonly+singleView" case.
 
47
    %{APPNAME}Part *part = new %{APPNAME}Part( parentWidget, widgetName, parent, name, !bWantKoDocument );
 
48
 
 
49
    if ( !bWantKoDocument )
 
50
      part->setReadWrite( false );
 
51
 
 
52
    return part;
 
53
}
 
54
 
 
55
KAboutData* %{APPNAME}Factory::aboutData()
 
56
{
 
57
    if ( !s_aboutData )
 
58
        // Change this, of course
 
59
        s_aboutData = new%{APPNAME}AboutData();
 
60
    return s_aboutData;
 
61
}
 
62
 
 
63
KInstance* %{APPNAME}Factory::global()
 
64
{
 
65
    if ( !s_global )
 
66
    {
 
67
        s_global = new KInstance( aboutData() );
 
68
        // Add any application-specific resource directories here
 
69
 
 
70
        // Tell the iconloader about share/apps/koffice/icons
 
71
        s_global->iconLoader()->addAppDir("koffice");
 
72
    }
 
73
    return s_global;
 
74
}
 
75
 
 
76
#include <%{APPNAMELC}_factory.moc>