• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Kate

kateglobal.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2001-2005 Christoph Cullmann <cullmann@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #include "kateglobal.h"
00020 #include "kateglobal.moc"
00021 
00022 #include "katedocument.h"
00023 #include "kateview.h"
00024 #include "katerenderer.h"
00025 #include "katecmds.h"
00026 #include "katemodemanager.h"
00027 #include "kateschema.h"
00028 #include "kateconfig.h"
00029 #include "katescriptmanager.h"
00030 #include "katecmd.h"
00031 #include "katebuffer.h"
00032 #include "katepartpluginmanager.h"
00033 
00034 #include <klocale.h>
00035 #include <kservicetypetrader.h>
00036 #include <kdirwatch.h>
00037 #include <kdebug.h>
00038 #include <kpagedialog.h>
00039 #include <kpagewidgetmodel.h>
00040 #include <kiconloader.h>
00041 
00042 #include <QtGui/QBoxLayout>
00043 
00044 KateGlobal *KateGlobal::s_self = 0;
00045 
00046 int KateGlobal::s_ref = 0;
00047 
00048 KateGlobal::KateGlobal ()
00049  : KTextEditor::Editor (0)
00050  , m_aboutData ("katepart", 0, ki18n("Kate Part"), KATEPART_VERSION,
00051              ki18n( "Embeddable editor component" ), KAboutData::License_LGPL_V2,
00052              ki18n( "(c) 2000-2007 The Kate Authors" ), KLocalizedString(), "http://www.kate-editor.org")
00053  , m_componentData (&m_aboutData)
00054 {
00055   // set s_self
00056   s_self = this;
00057 
00058   //
00059   // fill about data
00060   //
00061   m_aboutData.setProgramIconName("preferences-plugin");
00062   m_aboutData.addAuthor (ki18n("Christoph Cullmann"), ki18n("Maintainer"), "cullmann@kde.org", "http://www.babylon2k.de");
00063   m_aboutData.addAuthor (ki18n("Anders Lund"), ki18n("Core Developer"), "anders@alweb.dk", "http://www.alweb.dk");
00064   m_aboutData.addAuthor (ki18n("Joseph Wenninger"), ki18n("Core Developer"), "jowenn@kde.org","http://stud3.tuwien.ac.at/~e9925371");
00065   m_aboutData.addAuthor (ki18n("Hamish Rodda"), ki18n("Core Developer"), "rodda@kde.org");
00066   m_aboutData.addAuthor (ki18n("Dominik Haumann"), ki18n("Developer & Highlight wizard"), "dhdev@gmx.de");
00067   m_aboutData.addAuthor (ki18n("Waldo Bastian"), ki18n( "The cool buffersystem" ), "bastian@kde.org" );
00068   m_aboutData.addAuthor (ki18n("Charles Samuels"), ki18n("The Editing Commands"), "charles@kde.org");
00069   m_aboutData.addAuthor (ki18n("Matt Newell"), ki18n("Testing, ..."), "newellm@proaxis.com");
00070   m_aboutData.addAuthor (ki18n("Michael Bartl"), ki18n("Former Core Developer"), "michael.bartl1@chello.at");
00071   m_aboutData.addAuthor (ki18n("Michael McCallum"), ki18n("Core Developer"), "gholam@xtra.co.nz");
00072   m_aboutData.addAuthor (ki18n("Jochen Wilhemly"), ki18n( "KWrite Author" ), "digisnap@cs.tu-berlin.de" );
00073   m_aboutData.addAuthor (ki18n("Michael Koch"), ki18n("KWrite port to KParts"), "koch@kde.org");
00074   m_aboutData.addAuthor (ki18n("Christian Gebauer"), KLocalizedString(), "gebauer@kde.org" );
00075   m_aboutData.addAuthor (ki18n("Simon Hausmann"), KLocalizedString(), "hausmann@kde.org" );
00076   m_aboutData.addAuthor (ki18n("Glen Parker"), ki18n("KWrite Undo History, Kspell integration"), "glenebob@nwlink.com");
00077   m_aboutData.addAuthor (ki18n("Scott Manson"), ki18n("KWrite XML Syntax highlighting support"), "sdmanson@alltel.net");
00078   m_aboutData.addAuthor (ki18n("John Firebaugh"), ki18n("Patches and more"), "jfirebaugh@kde.org");
00079   m_aboutData.addAuthor (ki18n("Andreas Kling"), ki18n("Developer"), "kling@impul.se");
00080   m_aboutData.addAuthor (ki18n("Mirko Stocker"), ki18n("Various bugfixes"), "me@misto.ch", "http://misto.ch/");
00081   m_aboutData.addAuthor (ki18n("Matthew Woehlke"), ki18n("Selection, KColorScheme integration"), "mw_triad@users.sourceforge.net");
00082   m_aboutData.addAuthor (ki18n("Sebastian Pipping"), ki18n("Search bar back- and front-end"), "webmaster@hartwork.org", "http://www.hartwork.org/");
00083 
00084   m_aboutData.addCredit (ki18n("Matteo Merli"), ki18n("Highlighting for RPM Spec-Files, Perl, Diff and more"), "merlim@libero.it");
00085   m_aboutData.addCredit (ki18n("Rocky Scaletta"), ki18n("Highlighting for VHDL"), "rocky@purdue.edu");
00086   m_aboutData.addCredit (ki18n("Yury Lebedev"), ki18n("Highlighting for SQL"),"");
00087   m_aboutData.addCredit (ki18n("Chris Ross"), ki18n("Highlighting for Ferite"),"");
00088   m_aboutData.addCredit (ki18n("Nick Roux"), ki18n("Highlighting for ILERPG"),"");
00089   m_aboutData.addCredit (ki18n("Carsten Niehaus"), ki18n("Highlighting for LaTeX"),"");
00090   m_aboutData.addCredit (ki18n("Per Wigren"), ki18n("Highlighting for Makefiles, Python"),"");
00091   m_aboutData.addCredit (ki18n("Jan Fritz"), ki18n("Highlighting for Python"),"");
00092   m_aboutData.addCredit (ki18n("Daniel Naber"));
00093   m_aboutData.addCredit (ki18n("Roland Pabel"), ki18n("Highlighting for Scheme"),"");
00094   m_aboutData.addCredit (ki18n("Cristi Dumitrescu"), ki18n("PHP Keyword/Datatype list"),"");
00095   m_aboutData.addCredit (ki18n("Carsten Pfeiffer"), ki18n("Very nice help"), "");
00096   m_aboutData.addCredit (ki18n("Bruno Massa"), ki18n("Highlighting for Lua"), "brmassa@gmail.com");
00097 
00098   m_aboutData.addCredit (ki18n("All people who have contributed and I have forgotten to mention"));
00099 
00100   m_aboutData.setTranslator(ki18nc("NAME OF TRANSLATORS","Your names"), ki18nc("EMAIL OF TRANSLATORS","Your emails"));
00101 
00102   //
00103   // dir watch
00104   //
00105   m_dirWatch = new KDirWatch ();
00106 
00107   //
00108   // command manager
00109   //
00110   m_cmdManager = new KateCmd ();
00111 
00112   //
00113   // hl manager
00114   //
00115   m_hlManager = new KateHlManager ();
00116 
00117   //
00118   // mode man
00119   //
00120   m_modeManager = new KateModeManager ();
00121 
00122   //
00123   // schema man
00124   //
00125   m_schemaManager = new KateSchemaManager ();
00126 
00127   // config objects
00128   m_documentConfig = new KateDocumentConfig ();
00129   m_viewConfig = new KateViewConfig ();
00130   m_rendererConfig = new KateRendererConfig ();
00131 
00132   // create script manager (search scripts) + register commands
00133   m_scriptManager = new KateScriptManager ();
00134   KateCmd::self()->registerCommand (m_scriptManager);
00135 
00136   //
00137   // plugin manager
00138   //
00139   m_pluginManager = new KatePartPluginManager ();
00140 
00141   //
00142   // init the cmds
00143   //
00144   m_cmds.push_back (new KateCommands::CoreCommands());
00145   m_cmds.push_back (new KateCommands::SedReplace ());
00146   m_cmds.push_back (new KateCommands::Character ());
00147   m_cmds.push_back (new KateCommands::Date ());
00148 
00149   for ( QList<KTextEditor::Command *>::iterator it = m_cmds.begin(); it != m_cmds.end(); ++it )
00150     m_cmdManager->registerCommand (*it);
00151 }
00152 
00153 KateGlobal::~KateGlobal()
00154 {
00155   delete m_pluginManager;
00156 
00157   delete m_documentConfig;
00158   delete m_viewConfig;
00159   delete m_rendererConfig;
00160 
00161   delete m_modeManager;
00162   delete m_schemaManager;
00163 
00164   delete m_dirWatch;
00165 
00166   // you too
00167   qDeleteAll (m_cmds);
00168 
00169   // cu managers
00170   delete m_scriptManager;
00171   delete m_hlManager;
00172   delete m_cmdManager;
00173 
00174   s_self = 0;
00175 }
00176 
00177 KTextEditor::Document *KateGlobal::createDocument ( QObject *parent )
00178 {
00179   KateDocument *doc = new KateDocument (false, false, false, 0, parent);
00180 
00181   emit documentCreated (this, doc);
00182 
00183   return doc;
00184 }
00185 
00186 const QList<KTextEditor::Document*> &KateGlobal::documents ()
00187 {
00188   return m_docs;
00189 }
00190 
00191 //BEGIN KTextEditor::Editor config stuff
00192 void KateGlobal::readConfig(KConfig *config)
00193 {
00194   if( !config )
00195     config = KGlobal::config().data();
00196 
00197   KateDocumentConfig::global()->readConfig (KConfigGroup(config, "Kate Document Defaults"));
00198 
00199   KateViewConfig::global()->readConfig (KConfigGroup(config, "Kate View Defaults"));
00200 
00201   KateRendererConfig::global()->readConfig (KConfigGroup(config, "Kate Renderer Defaults"));
00202 }
00203 
00204 void KateGlobal::writeConfig(KConfig *config)
00205 {
00206   if( !config )
00207     config = KGlobal::config().data();
00208 
00209   KConfigGroup cg(config, "Kate Document Defaults");
00210   KateDocumentConfig::global()->writeConfig (cg);
00211 
00212   KConfigGroup cgDefault(config, "Kate View Defaults");
00213   KateViewConfig::global()->writeConfig (cgDefault);
00214 
00215   KConfigGroup cgRenderer(config, "Kate Renderer Defaults");
00216   KateRendererConfig::global()->writeConfig (cgRenderer);
00217 
00218   config->sync();
00219 }
00220 //END KTextEditor::Editor config stuff
00221 
00222 bool KateGlobal::configDialogSupported () const
00223 {
00224   return true;
00225 }
00226 
00227 void KateGlobal::configDialog(QWidget *parent)
00228 {
00229   KPageDialog *kd = new KPageDialog(parent);
00230   kd->setCaption( i18n("Configure") );
00231   kd->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Help );
00232   kd->setFaceType( KPageDialog::List );
00233 
00234   QList<KTextEditor::ConfigPage*> editorPages;
00235 
00236   for (int i = 0; i < configPages (); ++i)
00237   {
00238     const QString name = configPageName (i);
00239 
00240     QFrame *page = new QFrame();
00241 
00242     KPageWidgetItem *item = kd->addPage( page, name );
00243     item->setHeader( configPageFullName (i) );
00244     item->setIcon( configPageIcon(i) );
00245 
00246     QVBoxLayout *topLayout = new QVBoxLayout( page );
00247     topLayout->setMargin( 0 );
00248     topLayout->setSpacing( KDialog::spacingHint() );
00249 
00250     KTextEditor::ConfigPage *cp = configPage(i, page);
00251     topLayout->addWidget( cp);
00252     editorPages.append (cp);
00253   }
00254 
00255   if (kd->exec())
00256   {
00257     KateDocumentConfig::global()->configStart ();
00258     KateViewConfig::global()->configStart ();
00259     KateRendererConfig::global()->configStart ();
00260 
00261     for (int i=0; i < editorPages.count(); ++i)
00262     {
00263       editorPages.at(i)->apply();
00264     }
00265 
00266     KateDocumentConfig::global()->configEnd ();
00267     KateViewConfig::global()->configEnd ();
00268     KateRendererConfig::global()->configEnd ();
00269 
00270     writeConfig ();
00271   }
00272 
00273   delete kd;
00274 }
00275 
00276 int KateGlobal::configPages () const
00277 {
00278   return 6;
00279 }
00280 
00281 KTextEditor::ConfigPage *KateGlobal::configPage (int number, QWidget *parent)
00282 {
00283   switch( number )
00284   {
00285     case 0:
00286       return new KateViewDefaultsConfig (parent);
00287 
00288     case 1:
00289       return new KateSchemaConfigPage (parent, 0);
00290 
00291     case 2:
00292       return new KateEditConfigTab (parent);
00293 
00294     case 3:
00295       return new KateSaveConfigTab (parent);
00296 
00297     case 4:
00298       return new KateEditKeyConfiguration (parent);
00299 
00300     case 5:
00301       return new KatePartPluginConfigPage (parent);
00302 
00303     default:
00304       return 0;
00305   }
00306 
00307   return 0;
00308 }
00309 
00310 QString KateGlobal::configPageName (int number) const
00311 {
00312   switch( number )
00313   {
00314     case 0:
00315       return i18n ("Appearance");
00316 
00317     case 1:
00318       return i18n ("Fonts & Colors");
00319 
00320     case 2:
00321       return i18n ("Editing");
00322 
00323     case 3:
00324       return i18n("Open/Save");
00325 
00326     case 4:
00327       return i18n ("Shortcuts");
00328 
00329     case 5:
00330       return i18n ("Extensions");
00331 
00332     default:
00333       return QString ("");
00334   }
00335 
00336   return QString ("");
00337 }
00338 
00339 QString KateGlobal::configPageFullName (int number) const
00340 {
00341   switch( number )
00342   {
00343     case 0:
00344       return i18n("Appearance");
00345 
00346     case 1:
00347       return i18n ("Font & Color Schemas");
00348 
00349     case 2:
00350       return i18n ("Editing Options");
00351 
00352     case 3:
00353       return i18n("File Opening & Saving");
00354 
00355     case 4:
00356       return i18n ("Shortcuts Configuration");
00357 
00358     case 5:
00359       return i18n ("Extensions Manager");
00360 
00361     default:
00362       return QString ("");
00363   }
00364 
00365   return QString ("");
00366 }
00367 
00368 KIcon KateGlobal::configPageIcon (int number) const
00369 {
00370   switch( number )
00371   {
00372     case 0:
00373       return KIcon("preferences-desktop-theme");
00374 
00375     case 1:
00376       return KIcon("preferences-desktop-color");
00377 
00378     case 2:
00379       return KIcon("accessories-text-editor");
00380 
00381     case 3:
00382       return KIcon("document-save");
00383 
00384     case 4:
00385       return KIcon("configure-shortcuts");
00386 
00387     case 5:
00388       return KIcon("preferences-plugin");
00389 
00390     default:
00391       return KIcon("document-properties");
00392   }
00393 
00394   return KIcon("document-properties");
00395 }
00396 
00397 KateGlobal *KateGlobal::self ()
00398 {
00399   if (!s_self) {
00400     new KateGlobal ();
00401   }
00402 
00403   return s_self;
00404 }
00405 
00406 void KateGlobal::registerDocument ( KateDocument *doc )
00407 {
00408   KateGlobal::incRef ();
00409   m_documents.append( doc );
00410   m_docs.append (doc);
00411 }
00412 
00413 void KateGlobal::deregisterDocument ( KateDocument *doc )
00414 {
00415   m_docs.removeAll (doc);
00416   m_documents.removeAll( doc );
00417   KateGlobal::decRef ();
00418 }
00419 
00420 void KateGlobal::registerView ( KateView *view )
00421 {
00422   KateGlobal::incRef ();
00423   m_views.append( view );
00424 }
00425 
00426 void KateGlobal::deregisterView ( KateView *view )
00427 {
00428   m_views.removeAll( view );
00429   KateGlobal::decRef ();
00430 }
00431 
00432 //BEGIN command interface
00433 bool KateGlobal::registerCommand (KTextEditor::Command *cmd)
00434 {return m_cmdManager->registerCommand(cmd);}
00435 
00436 bool KateGlobal::unregisterCommand (KTextEditor::Command *cmd)
00437 {return m_cmdManager->unregisterCommand(cmd);}
00438 
00439 KTextEditor::Command *KateGlobal::queryCommand (const QString &cmd) const
00440 {return m_cmdManager->queryCommand(cmd);}
00441 
00442 QList<KTextEditor::Command*> KateGlobal::commands() const
00443 {return m_cmdManager->commands();}
00444 
00445 QStringList KateGlobal::commandList() const
00446 {return m_cmdManager->commandList();}
00447 //END command interface
00448 
00449 
00450 // kate: space-indent on; indent-width 2; replace-tabs on;

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal