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

« back to all changes in this revision

Viewing changes to languages/cpp/app_templates/kateplugin/plugin_app.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%{CPP_TEMPLATE}
2
 
 
3
 
#include "plugin_%{APPNAMELC}.h"
4
 
 
5
 
#include <kaction.h>
6
 
#include <klocale.h>
7
 
#include <kstandarddirs.h>
8
 
 
9
 
class PluginView : public KXMLGUIClient
10
 
{
11
 
  friend class KatePlugin%{APPNAME};
12
 
 
13
 
  public:
14
 
    Kate::MainWindow *win;
15
 
};
16
 
 
17
 
extern "C"
18
 
{
19
 
  void* init_lib%{APPNAMELC}plugin()
20
 
  {
21
 
    KGlobal::locale()->insertCatalogue("kate%{APPNAMELC}");
22
 
    return new KatePluginFactory;
23
 
  }
24
 
}
25
 
 
26
 
KatePluginFactory::KatePluginFactory()
27
 
{
28
 
  s_instance = new KInstance( "kate" );
29
 
}
30
 
 
31
 
KatePluginFactory::~KatePluginFactory()
32
 
{
33
 
  delete s_instance;
34
 
}
35
 
 
36
 
QObject* KatePluginFactory::createObject( QObject* parent, const char* name, const char*, const QStringList & )
37
 
{
38
 
  return new KatePlugin%{APPNAME}( parent, name );
39
 
}
40
 
 
41
 
KInstance* KatePluginFactory::s_instance = 0L;
42
 
 
43
 
KatePlugin%{APPNAME}::KatePlugin%{APPNAME}( QObject* parent, const char* name )
44
 
    : Kate::Plugin ( (Kate::Application*)parent, name )
45
 
{
46
 
}
47
 
 
48
 
KatePlugin%{APPNAME}::~KatePlugin%{APPNAME}()
49
 
{
50
 
}
51
 
 
52
 
void KatePlugin%{APPNAME}::addView(Kate::MainWindow *win)
53
 
{
54
 
    /// @todo doesn't this have to be deleted?
55
 
    PluginView *view = new PluginView ();
56
 
 
57
 
     (void) new KAction ( i18n("Insert Hello World"), 0, this,
58
 
                      SLOT( slotInsertHello() ), view->actionCollection(),
59
 
                      "edit_insert_%{APPNAMELC}" );
60
 
 
61
 
    view->setInstance (new KInstance("kate"));
62
 
    view->setXMLFile("plugins/%{APPNAMELC}/plugin_%{APPNAMELC}.rc");
63
 
    win->guiFactory()->addClient (view);
64
 
    view->win = win;
65
 
 
66
 
   m_views.append (view);
67
 
}
68
 
void KatePlugin%{APPNAME}::removeView(Kate::MainWindow *win)
69
 
{
70
 
  for (uint z=0; z < m_views.count(); z++)
71
 
    if (m_views.at(z)->win == win)
72
 
    {
73
 
      PluginView *view = m_views.at(z);
74
 
      m_views.remove (view);
75
 
      win->guiFactory()->removeClient (view);
76
 
      delete view;
77
 
    }
78
 
}
79
 
 
80
 
void KatePlugin%{APPNAME}::slotInsertHello()
81
 
{
82
 
  Kate::View *kv = application()->activeMainWindow()->viewManager()->activeView();
83
 
 
84
 
  if (kv)
85
 
    kv->insertText ("Hello World");
86
 
}
87
 
 
88
 
#include "plugin_%{APPNAMELC}.moc"
89