00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
#include "katefactory.h"
00020
00021
#include "katedocument.h"
00022
#include "kateview.h"
00023
#include "katerenderer.h"
00024
#include "katecmds.h"
00025
#include "katefiletype.h"
00026
#include "kateschema.h"
00027
#include "katesearch.h"
00028
#include "kateconfig.h"
00029
#include <kvmallocator.h>
00030
00031
#include "../interfaces/katecmd.h"
00032
00033
#include <klocale.h>
00034
#include <kdirwatch.h>
00035
#include <kstaticdeleter.h>
00036
#include <qapplication.h>
00037
00041
class KateFactoryPublic :
public KParts::Factory
00042 {
00043
public:
00053
KParts::Part *createPartObject (
QWidget *parentWidget,
const char *widgetName,
QObject *parent,
const char *name,
const char *classname,
const QStringList &args )
00054 {
00055
return KateFactory::self()->createPartObject (parentWidget, widgetName, parent, name, classname, args);
00056 }
00057 };
00058
00059 K_EXPORT_COMPONENT_FACTORY( libkatepart, KateFactoryPublic )
00060
00061 KateFactory *KateFactory::s_self = 0;
00062
00063 KateFactory::KateFactory ()
00064 : m_aboutData ("katepart", I18N_NOOP("Kate Part"), KATEPART_VERSION,
00065 I18N_NOOP( "Embeddable editor component" ),
KAboutData::License_LGPL_V2,
00066 I18N_NOOP( "(c) 2000-2004 The Kate Authors" ), 0, "http:
00067 , m_instance (&m_aboutData)
00068 , m_plugins (KTrader::self()->query("KTextEditor/Plugin"))
00069 {
00070
00071 s_self =
this;
00072
00073
00074
00075
00076 m_aboutData.addAuthor (
"Christoph Cullmann",
I18N_NOOP(
"Maintainer"),
"cullmann@kde.org",
"http://www.babylon2k.de");
00077 m_aboutData.addAuthor (
"Anders Lund",
I18N_NOOP(
"Core Developer"),
"anders@alweb.dk",
"http://www.alweb.dk");
00078 m_aboutData.addAuthor (
"Joseph Wenninger",
I18N_NOOP(
"Core Developer"),
"jowenn@kde.org",
"http://stud3.tuwien.ac.at/~e9925371");
00079 m_aboutData.addAuthor (
"Hamish Rodda",
I18N_NOOP(
"Core Developer"),
"rodda@kde.org");
00080 m_aboutData.addAuthor (
"Waldo Bastian",
I18N_NOOP(
"The cool buffersystem" ),
"bastian@kde.org" );
00081 m_aboutData.addAuthor (
"Charles Samuels",
I18N_NOOP(
"The Editing Commands"),
"charles@kde.org");
00082 m_aboutData.addAuthor (
"Matt Newell",
I18N_NOOP(
"Testing, ..."),
"newellm@proaxis.com");
00083 m_aboutData.addAuthor (
"Michael Bartl",
I18N_NOOP(
"Former Core Developer"),
"michael.bartl1@chello.at");
00084 m_aboutData.addAuthor (
"Michael McCallum",
I18N_NOOP(
"Core Developer"),
"gholam@xtra.co.nz");
00085 m_aboutData.addAuthor (
"Jochen Wilhemly",
I18N_NOOP(
"KWrite Author" ),
"digisnap@cs.tu-berlin.de" );
00086 m_aboutData.addAuthor (
"Michael Koch",
I18N_NOOP(
"KWrite port to KParts"),
"koch@kde.org");
00087 m_aboutData.addAuthor (
"Christian Gebauer", 0,
"gebauer@kde.org" );
00088 m_aboutData.addAuthor (
"Simon Hausmann", 0,
"hausmann@kde.org" );
00089 m_aboutData.addAuthor (
"Glen Parker",
I18N_NOOP(
"KWrite Undo History, Kspell integration"),
"glenebob@nwlink.com");
00090 m_aboutData.addAuthor (
"Scott Manson",
I18N_NOOP(
"KWrite XML Syntax highlighting support"),
"sdmanson@alltel.net");
00091 m_aboutData.addAuthor (
"John Firebaugh",
I18N_NOOP(
"Patches and more"),
"jfirebaugh@kde.org");
00092 m_aboutData.addAuthor (
"Dominik Haumann",
I18N_NOOP(
"Developer & Highlight wizard"),
"dhdev@gmx.de");
00093
00094 m_aboutData.addCredit (
"Matteo Merli",
I18N_NOOP(
"Highlighting for RPM Spec-Files, Perl, Diff and more"),
"merlim@libero.it");
00095 m_aboutData.addCredit (
"Rocky Scaletta",
I18N_NOOP(
"Highlighting for VHDL"),
"rocky@purdue.edu");
00096 m_aboutData.addCredit (
"Yury Lebedev",
I18N_NOOP(
"Highlighting for SQL"),
"");
00097 m_aboutData.addCredit (
"Chris Ross",
I18N_NOOP(
"Highlighting for Ferite"),
"");
00098 m_aboutData.addCredit (
"Nick Roux",
I18N_NOOP(
"Highlighting for ILERPG"),
"");
00099 m_aboutData.addCredit (
"Carsten Niehaus",
I18N_NOOP(
"Highlighting for LaTeX"),
"");
00100 m_aboutData.addCredit (
"Per Wigren",
I18N_NOOP(
"Highlighting for Makefiles, Python"),
"");
00101 m_aboutData.addCredit (
"Jan Fritz",
I18N_NOOP(
"Highlighting for Python"),
"");
00102 m_aboutData.addCredit (
"Daniel Naber",
"",
"");
00103 m_aboutData.addCredit (
"Roland Pabel",
I18N_NOOP(
"Highlighting for Scheme"),
"");
00104 m_aboutData.addCredit (
"Cristi Dumitrescu",
I18N_NOOP(
"PHP Keyword/Datatype list"),
"");
00105 m_aboutData.addCredit (
"Carsten Pfeiffer",
I18N_NOOP(
"Very nice help"),
"");
00106 m_aboutData.addCredit (
I18N_NOOP(
"All people who have contributed and I have forgotten to mention"),
"",
"");
00107
00108 m_aboutData.setTranslator(
I18N_NOOP(
"_: NAME OF TRANSLATORS\nYour names"),
I18N_NOOP(
"_: EMAIL OF TRANSLATORS\nYour emails"));
00109
00110
00111
00112
00113 m_dirWatch =
new KDirWatch ();
00114
00115
00116
00117
00118 m_fileTypeManager =
new KateFileTypeManager ();
00119
00120
00121
00122
00123 m_schemaManager =
new KateSchemaManager ();
00124
00125
00126 m_documentConfig =
new KateDocumentConfig ();
00127 m_viewConfig =
new KateViewConfig ();
00128 m_rendererConfig =
new KateRendererConfig ();
00129
00130
00131 m_vm =
new KVMAllocator ();
00132
00133
00134
00135
00136 m_cmds.push_back (
new KateCommands::CoreCommands());
00137 m_cmds.push_back (
new KateCommands::SedReplace ());
00138 m_cmds.push_back (
new KateCommands::Character ());
00139 m_cmds.push_back (
new KateCommands::Date ());
00140 m_cmds.push_back (
new SearchCommand());
00141
00142
for (
QValueList<Kate::Command *>::iterator it = m_cmds.begin(); it != m_cmds.end(); ++it )
00143 KateCmd::self()->registerCommand (*it);
00144 }
00145
00146 KateFactory::~KateFactory()
00147 {
00148
00149
00150
00151
while (KateDocument *doc=m_documents.first()) {
00152 s_self=
this;
00153
00154
delete doc;
00155 s_self=0;
00156 }
00157
00158
00159
00160
delete m_documentConfig;
00161
delete m_viewConfig;
00162
delete m_rendererConfig;
00163
00164
delete m_fileTypeManager;
00165
delete m_schemaManager;
00166
00167
delete m_dirWatch;
00168
00169
delete m_vm;
00170
00171
for (
QValueList<Kate::Command *>::iterator it = m_cmds.begin(); it != m_cmds.end(); ++it )
00172
delete *it;
00173 }
00174
00175
static KStaticDeleter<KateFactory> sdFactory;
00176
00177 KateFactory *KateFactory::self ()
00178 {
00179
if (!s_self) {
00180 sdFactory.setObject(s_self,
new KateFactory ());
00181 }
00182
return s_self;
00183 }
00184
00185
KParts::Part *KateFactory::createPartObject (
QWidget *parentWidget,
const char *widgetName,
QObject *parent,
const char *name,
const char *_classname,
const QStringList & )
00186 {
00187
QCString classname( _classname );
00188
bool bWantSingleView = ( classname !=
"KTextEditor::Document" && classname !=
"Kate::Document" );
00189
bool bWantBrowserView = ( classname ==
"Browser/View" );
00190
bool bWantReadOnly = (bWantBrowserView || ( classname ==
"KParts::ReadOnlyPart" ));
00191
00192
KParts::ReadWritePart *part =
new KateDocument (bWantSingleView, bWantBrowserView, bWantReadOnly, parentWidget, widgetName, parent, name);
00193 part->
setReadWrite( !bWantReadOnly );
00194
00195
return part;
00196 }
00197
00198
void KateFactory::registerDocument ( KateDocument *doc )
00199 {
00200 m_documents.append( doc );
00201 }
00202
00203
void KateFactory::deregisterDocument ( KateDocument *doc )
00204 {
00205 m_documents.removeRef( doc );
00206 }
00207
00208
void KateFactory::registerView ( KateView *view )
00209 {
00210 m_views.append( view );
00211 }
00212
00213
void KateFactory::deregisterView ( KateView *view )
00214 {
00215 m_views.removeRef( view );
00216 }
00217
00218
void KateFactory::registerRenderer (
KateRenderer *renderer )
00219 {
00220 m_renderers.append( renderer );
00221 }
00222
00223
void KateFactory::deregisterRenderer (
KateRenderer *renderer )
00224 {
00225 m_renderers.removeRef( renderer );
00226 }
00227
00228