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