KTextEditor

kateglobal.cpp
1 /*
2  SPDX-FileCopyrightText: 2001-2010 Christoph Cullmann <[email protected]>
3  SPDX-FileCopyrightText: 2009 Erlend Hamberg <[email protected]>
4 
5  For the addScrollablePage original
6  SPDX-FileCopyrightText: 2003 Benjamin C Meyer <ben+kdelibs at meyerhome dot net>
7  SPDX-FileCopyrightText: 2003 Waldo Bastian <[email protected]>
8  SPDX-FileCopyrightText: 2004 Michael Brade <[email protected]>
9  SPDX-FileCopyrightText: 2021 Ahmad Samir <[email protected]>
10 
11  SPDX-License-Identifier: LGPL-2.0-or-later
12 */
13 
14 #include "kateglobal.h"
15 #include "config.h"
16 
17 #include <ktexteditor_version.h>
18 
19 #include "katebuffer.h"
20 #include "katecmd.h"
21 #include "katecmds.h"
22 #include "kateconfig.h"
23 #include "katedialogs.h"
24 #include "katedocument.h"
25 #include "katehighlightingcmds.h"
26 #include "katekeywordcompletion.h"
27 #include "katemodemanager.h"
28 #include "katescriptmanager.h"
29 #include "katesedcmd.h"
30 #include "katesyntaxmanager.h"
31 #include "katethemeconfig.h"
32 #include "katevariableexpansionmanager.h"
33 #include "kateview.h"
34 #include "katewordcompletion.h"
35 #include "spellcheck/spellcheck.h"
36 
37 #include "katenormalinputmodefactory.h"
38 #include "kateviinputmodefactory.h"
39 
40 #include <KConfigGroup>
41 #include <KDirWatch>
42 #include <KLocalizedString>
43 #include <KPageDialog>
44 
45 #include <QApplication>
46 #include <QBoxLayout>
47 #include <QClipboard>
48 #include <QFrame>
49 #include <QPushButton>
50 #include <QScreen>
51 #include <QScrollArea>
52 #include <QScrollBar>
53 #include <QStringListModel>
54 #include <QTimer>
55 
56 // BEGIN unit test mode
57 static bool kateUnitTestMode = false;
58 
60 {
61  kateUnitTestMode = true;
62 }
63 
65 {
66  return kateUnitTestMode;
67 }
68 // END unit test mode
69 
70 KTextEditor::EditorPrivate::EditorPrivate(QPointer<KTextEditor::EditorPrivate> &staticInstance)
71  : KTextEditor::Editor(this)
72  , m_aboutData(QStringLiteral("katepart"),
73  i18n("Kate Part"),
74  QStringLiteral(KTEXTEDITOR_VERSION_STRING),
75  i18n("Embeddable editor component"),
76  KAboutLicense::LGPL_V2,
77  i18n("(c) 2000-2022 The Kate Authors"),
78  QString(),
79  QStringLiteral("https://kate-editor.org"))
80  , m_dummyApplication(nullptr)
81  , m_application(&m_dummyApplication)
82  , m_dummyMainWindow(nullptr)
83  , m_searchHistoryModel(nullptr)
84  , m_replaceHistoryModel(nullptr)
85 {
86  // remember this
87  staticInstance = this;
88 
89  // register some datatypes
90  qRegisterMetaType<KTextEditor::Cursor>("KTextEditor::Cursor");
91  qRegisterMetaType<KTextEditor::Document *>("KTextEditor::Document*");
92  qRegisterMetaType<KTextEditor::View *>("KTextEditor::View*");
93 
94  //
95  // fill about data
96  //
97  m_aboutData.addAuthor(i18n("Christoph Cullmann"), i18n("Maintainer"), QStringLiteral("[email protected]"), QStringLiteral("https://cullmann.io"));
98  m_aboutData.addAuthor(i18n("Dominik Haumann"), i18n("Core Developer"), QStringLiteral("[email protected]"));
99  m_aboutData.addAuthor(i18n("Milian Wolff"), i18n("Core Developer"), QStringLiteral("[email protected]"), QStringLiteral("https://milianw.de/"));
100  m_aboutData.addAuthor(i18n("Joseph Wenninger"),
101  i18n("Core Developer"),
102  QStringLiteral("[email protected]"),
103  QStringLiteral("http://stud3.tuwien.ac.at/~e9925371"));
104  m_aboutData.addAuthor(i18n("Erlend Hamberg"), i18n("Vi Input Mode"), QStringLiteral("[email protected]"), QStringLiteral("https://hamberg.no/erlend"));
105  m_aboutData.addAuthor(i18n("Bernhard Beschow"),
106  i18n("Developer"),
107  QStringLiteral("[email protected]"),
108  QStringLiteral("https://user.cs.tu-berlin.de/~bbeschow"));
109  m_aboutData.addAuthor(i18n("Anders Lund"), i18n("Core Developer"), QStringLiteral("[email protected]"), QStringLiteral("https://alweb.dk"));
110  m_aboutData.addAuthor(i18n("Michel Ludwig"), i18n("On-the-fly spell checking"), QStringLiteral("[email protected]"));
111  m_aboutData.addAuthor(i18n("Pascal L├ętourneau"), i18n("Large scale bug fixing"), QStringLiteral("[email protected]"));
112  m_aboutData.addAuthor(i18n("Hamish Rodda"), i18n("Core Developer"), QStringLiteral("[email protected]"));
113  m_aboutData.addAuthor(i18n("Waldo Bastian"), i18n("The cool buffersystem"), QStringLiteral("[email protected]"));
114  m_aboutData.addAuthor(i18n("Charles Samuels"), i18n("The Editing Commands"), QStringLiteral("[email protected]"));
115  m_aboutData.addAuthor(i18n("Matt Newell"), i18n("Testing, ..."), QStringLiteral("[email protected]"));
116  m_aboutData.addAuthor(i18n("Michael Bartl"), i18n("Former Core Developer"), QStringLiteral("[email protected]"));
117  m_aboutData.addAuthor(i18n("Michael McCallum"), i18n("Core Developer"), QStringLiteral("[email protected]"));
118  m_aboutData.addAuthor(i18n("Michael Koch"), i18n("KWrite port to KParts"), QStringLiteral("[email protected]"));
119  m_aboutData.addAuthor(i18n("Christian Gebauer"), QString(), QStringLiteral("[email protected]"));
120  m_aboutData.addAuthor(i18n("Simon Hausmann"), QString(), QStringLiteral("[email protected]"));
121  m_aboutData.addAuthor(i18n("Glen Parker"), i18n("KWrite Undo History, Kspell integration"), QStringLiteral("[email protected]"));
122  m_aboutData.addAuthor(i18n("Scott Manson"), i18n("KWrite XML Syntax highlighting support"), QStringLiteral("[email protected]"));
123  m_aboutData.addAuthor(i18n("John Firebaugh"), i18n("Patches and more"), QStringLiteral("[email protected]"));
124  m_aboutData.addAuthor(i18n("Andreas Kling"), i18n("Developer"), QStringLiteral("[email protected]"));
125  m_aboutData.addAuthor(i18n("Mirko Stocker"), i18n("Various bugfixes"), QStringLiteral("[email protected]"), QStringLiteral("https://misto.ch/"));
126  m_aboutData.addAuthor(i18n("Matthew Woehlke"), i18n("Selection, KColorScheme integration"), QStringLiteral("[email protected]"));
127  m_aboutData.addAuthor(i18n("Sebastian Pipping"),
128  i18n("Search bar back- and front-end"),
129  QStringLiteral("[email protected]"),
130  QStringLiteral("https://hartwork.org/"));
131  m_aboutData.addAuthor(i18n("Jochen Wilhelmy"), i18n("Original KWrite Author"), QStringLiteral("[email protected]"));
132  m_aboutData.addAuthor(i18n("Gerald Senarclens de Grancy"),
133  i18n("QA and Scripting"),
134  QStringLiteral("[email protected]"),
135  QStringLiteral("http://find-santa.eu/"));
136 
137  m_aboutData.addCredit(i18n("Matteo Merli"), i18n("Highlighting for RPM Spec-Files, Perl, Diff and more"), QStringLiteral("[email protected]"));
138  m_aboutData.addCredit(i18n("Rocky Scaletta"), i18n("Highlighting for VHDL"), QStringLiteral("[email protected]"));
139  m_aboutData.addCredit(i18n("Yury Lebedev"), i18n("Highlighting for SQL"), QString());
140  m_aboutData.addCredit(i18n("Chris Ross"), i18n("Highlighting for Ferite"), QString());
141  m_aboutData.addCredit(i18n("Nick Roux"), i18n("Highlighting for ILERPG"), QString());
142  m_aboutData.addCredit(i18n("Carsten Niehaus"), i18n("Highlighting for LaTeX"), QString());
143  m_aboutData.addCredit(i18n("Per Wigren"), i18n("Highlighting for Makefiles, Python"), QString());
144  m_aboutData.addCredit(i18n("Jan Fritz"), i18n("Highlighting for Python"), QString());
145  m_aboutData.addCredit(i18n("Daniel Naber"));
146  m_aboutData.addCredit(i18n("Roland Pabel"), i18n("Highlighting for Scheme"), QString());
147  m_aboutData.addCredit(i18n("Cristi Dumitrescu"), i18n("PHP Keyword/Datatype list"), QString());
148  m_aboutData.addCredit(i18n("Carsten Pfeiffer"), i18n("Very nice help"), QString());
149  m_aboutData.addCredit(i18n("Bruno Massa"), i18n("Highlighting for Lua"), QStringLiteral("[email protected]"));
150 
151  m_aboutData.addCredit(i18n("All people who have contributed and I have forgotten to mention"));
152 
153  m_aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails"));
154 
155  // set proper Kate icon for our about dialog
156  m_aboutData.setProgramLogo(QIcon(QStringLiteral(":/ktexteditor/kate.svg")));
157 
158  //
159  // dir watch
160  //
161  m_dirWatch = new KDirWatch();
162 
163  //
164  // command manager
165  //
166  m_cmdManager = new KateCmd();
167 
168  //
169  // variable expansion manager
170  //
171  m_variableExpansionManager = new KateVariableExpansionManager(this);
172 
173  //
174  // hl manager
175  //
176  m_hlManager = new KateHlManager();
177 
178  //
179  // mode man
180  //
181  m_modeManager = new KateModeManager();
182 
183  //
184  // input mode factories
185  //
186  Q_ASSERT(m_inputModeFactories.size() == KTextEditor::View::ViInputMode + 1);
187  m_inputModeFactories[KTextEditor::View::NormalInputMode].reset(new KateNormalInputModeFactory());
188  m_inputModeFactories[KTextEditor::View::ViInputMode].reset(new KateViInputModeFactory());
189 
190  //
191  // spell check manager
192  //
193  m_spellCheckManager = new KateSpellCheckManager();
194 
195  // config objects
196  m_globalConfig = new KateGlobalConfig();
197  m_documentConfig = new KateDocumentConfig();
198  m_viewConfig = new KateViewConfig();
199  m_rendererConfig = new KateRendererConfig();
200 
201  // create script manager (search scripts)
202  m_scriptManager = KateScriptManager::self();
203 
204  //
205  // init the cmds
206  //
207  m_cmds.push_back(KateCommands::CoreCommands::self());
208  m_cmds.push_back(KateCommands::Character::self());
209  m_cmds.push_back(KateCommands::Date::self());
210  m_cmds.push_back(KateCommands::SedReplace::self());
211  m_cmds.push_back(KateCommands::Highlighting::self());
212 
213  // global word completion model
214  m_wordCompletionModel = new KateWordCompletionModel(this);
215 
216  // global keyword completion model
217  m_keywordCompletionModel = new KateKeywordCompletionModel(this);
218 
219  // tap to QApplication object for color palette changes
220  qApp->installEventFilter(this);
221 }
222 
224 {
225  delete m_globalConfig;
226  delete m_documentConfig;
227  delete m_viewConfig;
228  delete m_rendererConfig;
229 
230  delete m_modeManager;
231 
232  delete m_dirWatch;
233 
234  // cu managers
235  delete m_scriptManager;
236  delete m_hlManager;
237 
238  delete m_spellCheckManager;
239 
240  // cu model
241  delete m_wordCompletionModel;
242 
243  // delete variable expansion manager
244  delete m_variableExpansionManager;
245  m_variableExpansionManager = nullptr;
246 
247  // delete the commands before we delete the cmd manager
248  qDeleteAll(m_cmds);
249  delete m_cmdManager;
250 }
251 
253 {
254  KTextEditor::DocumentPrivate *doc = new KTextEditor::DocumentPrivate(false, false, nullptr, parent);
255 
256  Q_EMIT documentCreated(this, doc);
257 
258  return doc;
259 }
260 
261 // END KTextEditor::Editor config stuff
262 
263 // config dialog with improved sizing and that allows scrolling
264 class KTextEditorConfigDialog : public KPageDialog
265 {
266 public:
268 
269  KTextEditorConfigDialog(KTextEditor::EditorPrivate *editor, QWidget *parent)
270  : KPageDialog(parent)
271  {
272  setWindowTitle(i18n("Configure"));
273  setFaceType(KPageDialog::List);
275 
276  // create pages already in construct to have proper layout for sizeHint
277  editorPages.reserve(editor->configPages());
278  for (int i = 0; i < editor->configPages(); ++i) {
279  KTextEditor::ConfigPage *page = editor->configPage(i, this);
280  KPageWidgetItem *item = addScrollablePage(page, page->name());
281  item->setHeader(page->fullName());
282  item->setIcon(page->icon());
283 
285  editorPages.append(page);
286  }
287  }
288 
289  QSize sizeHint() const override
290  {
291  // start with a bit enlarged default size hint to minimize changes of useless scrollbars
292  QSize size = KPageDialog::sizeHint() * 1.3;
293 
294  // enlarge it to half of the main window size, if that is larger
295  if (parentWidget() && parentWidget()->window()) {
296  size = size.expandedTo(parentWidget()->window()->size() * 0.5);
297  }
298 
299  // return bounded size to available real screen space
300  return size.boundedTo(screen()->availableSize() * 0.9);
301  }
302 
303  KPageWidgetItem *addScrollablePage(QWidget *page, const QString &itemName)
304  {
305  // inspired by KPageWidgetItem *KConfigDialogPrivate::addPageInternal(QWidget *page, const QString &itemName, const QString &pixmapName, const QString
306  // &header)
307  QWidget *frame = new QWidget;
308  QVBoxLayout *boxLayout = new QVBoxLayout(frame);
309  boxLayout->setContentsMargins(0, 0, 0, 0);
310  boxLayout->setContentsMargins(0, 0, 0, 0);
311 
312  QScrollArea *scroll = new QScrollArea;
316  scroll->setWidget(page);
317  scroll->setWidgetResizable(true);
319 
320  if (page->minimumSizeHint().height() > scroll->sizeHint().height() - 2) {
321  if (page->sizeHint().width() < scroll->sizeHint().width() + 2) {
322  // QScrollArea is planning only a vertical scroll bar,
323  // try to avoid the horizontal one by reserving space for the vertical one.
324  // Currently KPageViewPrivate::_k_modelChanged() queries the minimumSizeHint().
325  // We can only set the minimumSize(), so this approach relies on QStackedWidget size calculation.
326  scroll->setMinimumWidth(scroll->sizeHint().width() + qBound(0, scroll->verticalScrollBar()->sizeHint().width(), 200) + 4);
327  }
328  }
329 
330  boxLayout->addWidget(scroll);
331  return addPage(frame, itemName);
332  }
333 };
334 
336 {
337  QPointer<KTextEditorConfigDialog> kd = new KTextEditorConfigDialog(this, parent);
338  if (kd->exec() && kd) {
339  KateGlobalConfig::global()->configStart();
340  KateDocumentConfig::global()->configStart();
341  KateViewConfig::global()->configStart();
342  KateRendererConfig::global()->configStart();
343 
344  for (int i = 0; i < kd->editorPages.count(); ++i) {
345  kd->editorPages.at(i)->apply();
346  }
347 
348  KateGlobalConfig::global()->configEnd();
349  KateDocumentConfig::global()->configEnd();
350  KateViewConfig::global()->configEnd();
351  KateRendererConfig::global()->configEnd();
352  }
353  delete kd;
354 }
355 
357 {
358  return 4;
359 }
360 
362 {
363  switch (number) {
364  case 0:
365  return new KateViewDefaultsConfig(parent);
366 
367  case 1:
368  return new KateThemeConfigPage(parent);
369 
370  case 2:
371  return new KateEditConfigTab(parent);
372 
373  case 3:
374  return new KateSaveConfigTab(parent);
375 
376  default:
377  break;
378  }
379 
380  return nullptr;
381 }
382 
383 /**
384  * Cleanup the KTextEditor::EditorPrivate during QCoreApplication shutdown
385  */
386 static void cleanupGlobal()
387 {
388  // delete if there
390 }
391 
393 {
394  // remember the static instance in a QPointer
395  static bool inited = false;
396  static QPointer<KTextEditor::EditorPrivate> staticInstance;
397 
398  // just return it, if already inited
399  if (inited) {
400  return staticInstance.data();
401  }
402 
403  // start init process
404  inited = true;
405 
406  // now create the object and store it
407  new KTextEditor::EditorPrivate(staticInstance);
408 
409  // register cleanup
410  // let use be deleted during QCoreApplication shutdown
411  qAddPostRoutine(cleanupGlobal);
412 
413  // return instance
414  return staticInstance.data();
415 }
416 
417 void KTextEditor::EditorPrivate::registerDocument(KTextEditor::DocumentPrivate *doc)
418 {
419  Q_ASSERT(!m_documents.contains(doc));
420  m_documents.insert(doc, doc);
421 }
422 
423 void KTextEditor::EditorPrivate::deregisterDocument(KTextEditor::DocumentPrivate *doc)
424 {
425  Q_ASSERT(m_documents.contains(doc));
426  m_documents.remove(doc);
427 }
428 
429 void KTextEditor::EditorPrivate::registerView(KTextEditor::ViewPrivate *view)
430 {
431  Q_ASSERT(!m_views.contains(view));
432  m_views.insert(view);
433 }
434 
435 void KTextEditor::EditorPrivate::deregisterView(KTextEditor::ViewPrivate *view)
436 {
437  Q_ASSERT(m_views.contains(view));
438  m_views.remove(view);
439 }
440 
442 {
443  return m_cmdManager->queryCommand(cmd);
444 }
445 
447 {
448  return m_cmdManager->commands();
449 }
450 
452 {
453  return m_cmdManager->commandList();
454 }
455 
457 {
458  return m_variableExpansionManager;
459 }
460 
461 void KTextEditor::EditorPrivate::updateColorPalette()
462 {
463  // reload the global schema (triggers reload for every view as well)
464  // might trigger selection of better matching theme for new palette
465  m_rendererConfig->reloadSchema();
466 
467  // force full update of all view caches and colors
468  m_rendererConfig->updateConfig();
469 }
470 
472 {
473  // empty => nop
474  if (text.isEmpty()) {
475  return;
476  }
477 
478  // move to clipboard
480 
481  // LRU, kill potential duplicated, move new entry to top
482  // cut after X entries
483  auto entry = ClipboardEntry{text, fileName};
484  m_clipboardHistory.removeOne(entry);
485  m_clipboardHistory.prepend(entry);
486  if (m_clipboardHistory.size() > m_viewConfig->clipboardHistoryEntries()) {
487  m_clipboardHistory.removeLast();
488  }
489 
490  // notify about change
491  Q_EMIT clipboardHistoryChanged();
492 }
493 
494 bool KTextEditor::EditorPrivate::eventFilter(QObject *obj, QEvent *event)
495 {
496  if (obj == qApp && event->type() == QEvent::ApplicationPaletteChange) {
497  // only update the color once for the event that belongs to the qApp
498  updateColorPalette();
499  }
500 
501  return false; // always continue processing
502 }
503 
505 {
506  if (!m_searchHistoryModel) {
507  KConfigGroup cg(KSharedConfig::openConfig(), "KTextEditor::Search");
508  const QStringList history = cg.readEntry(QStringLiteral("Search History"), QStringList());
509  m_searchHistoryModel = new QStringListModel(history, this);
510  }
511  return m_searchHistoryModel;
512 }
513 
515 {
516  if (!m_replaceHistoryModel) {
517  KConfigGroup cg(KSharedConfig::openConfig(), "KTextEditor::Search");
518  const QStringList history = cg.readEntry(QStringLiteral("Replace History"), QStringList());
519  m_replaceHistoryModel = new QStringListModel(history, this);
520  }
521  return m_replaceHistoryModel;
522 }
523 
525 {
526  KConfigGroup cg(KSharedConfig::openConfig(), "KTextEditor::Search");
527  if (m_searchHistoryModel) {
528  cg.writeEntry(QStringLiteral("Search History"), m_searchHistoryModel->stringList());
529  }
530  if (m_replaceHistoryModel) {
531  cg.writeEntry(QStringLiteral("Replace History"), m_replaceHistoryModel->stringList());
532  }
533 }
534 
536 {
537  // use dummy config for unit tests!
539  return KSharedConfig::openConfig(QStringLiteral("katepartrc-unittest"), KConfig::SimpleConfig, QStandardPaths::TempLocation);
540  }
541 
542  // else: use application configuration, but try to transfer global settings on first use
543  auto applicationConfig = KSharedConfig::openConfig();
544  if (!KConfigGroup(applicationConfig, QStringLiteral("KTextEditor Editor")).exists()) {
545  auto globalConfig = KSharedConfig::openConfig(QStringLiteral("katepartrc"));
546  for (const auto &group : {QStringLiteral("Editor"), QStringLiteral("Document"), QStringLiteral("View"), QStringLiteral("Renderer")}) {
547  KConfigGroup origin(globalConfig, group);
548  KConfigGroup destination(applicationConfig, QStringLiteral("KTextEditor ") + group);
549  origin.copyTo(&destination);
550  }
551  }
552  return applicationConfig;
553 }
554 
556 {
557  // trigger delayed emission, will collapse multiple events to one signal emission
558  m_configWasChanged = true;
559  QTimer::singleShot(0, this, &KTextEditor::EditorPrivate::emitConfigChanged);
560 }
561 
562 void KTextEditor::EditorPrivate::emitConfigChanged()
563 {
564  // emit only once, if still needed
565  if (m_configWasChanged) {
566  m_configWasChanged = false;
567  Q_EMIT configChanged(this);
568  }
569 }
570 
571 void KTextEditor::EditorPrivate::copyToMulticursorClipboard(const QStringList &texts)
572 {
573  if (texts.size() == 1) {
574  qWarning() << "Unexpected size 1 of multicursorClipboard. It should either be empty or greater than 1";
575  m_multicursorClipboard = QStringList();
576  Q_ASSERT(false);
577  return;
578  }
579  m_multicursorClipboard = texts;
580 }
581 
582 QStringList KTextEditor::EditorPrivate::multicursorClipboard() const
583 {
584  return m_multicursorClipboard;
585 }
void append(const T &value)
An Editor command line command.
QScrollBar * verticalScrollBar() const const
virtual QString name() const =0
Get a readable name for the config page.
QString readEntry(const char *key, const char *aDefault=nullptr) const
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
ApplicationPaletteChange
void configDialog(QWidget *parent) override
Configuration management.
Definition: kateglobal.cpp:335
void setSizePolicy(QSizePolicy)
virtual QSize sizeHint() const const override
@ ViInputMode
Vi mode.
Definition: view.h:191
void registerView(KTextEditor::ViewPrivate *view)
register view at the factory this allows us to loop over all views for example on config changes
Definition: kateglobal.cpp:429
Highlighting-file based keyword completion for the editor.
void clicked(bool checked)
QString & prepend(QChar ch)
void push_back(const T &value)
ScrollBarAsNeeded
QStringListModel * searchHistoryModel()
Search pattern history shared among simple/power search instances.
Definition: kateglobal.cpp:504
QStringListModel * replaceHistoryModel()
Replace pattern history shared among simple/power search instances.
Definition: kateglobal.cpp:514
~EditorPrivate() override
Destructor.
Definition: kateglobal.cpp:223
int width() const const
void setFrameShape(QFrame::Shape)
QStringList commandList() const override
Get a list of available commandline strings.
Definition: kateglobal.cpp:451
virtual QSize sizeHint() const const override
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
void triggerConfigChanged()
Trigger delayed emission of config changed.
Definition: kateglobal.cpp:555
void saveSearchReplaceHistoryModels()
Call this function to store the history models to the application config.
Definition: kateglobal.cpp:524
QHash::iterator insert(const Key &key, const T &value)
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
virtual QIcon icon() const
Get an icon for the config page.
void reserve(int alloc)
void setIcon(const QIcon &icon)
QClipboard * clipboard()
KAboutData & setProgramLogo(const QVariant &image)
int size() const const
static KSharedConfigPtr config()
The global configuration of katepart, e.g.
Definition: kateglobal.cpp:535
void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy)
QString i18n(const char *text, const TYPE &arg...)
Config page interface for the Editor and Plugins.
Definition: configpage.h:43
A clipboard entry stores the copied text and the filename of the copied text.
Definition: kateglobal.h:355
int height() const const
Manager class for variable expansion.
QList< KTextEditor::Command * > commands() const override
Get a list of all registered commands.
Definition: kateglobal.cpp:446
KTextEditor::ConfigPage * configPage(int number, QWidget *parent) override
returns config page with the given number, config pages from 0 to configPages()-1 are available if co...
Definition: kateglobal.cpp:361
virtual void apply()=0
This slot is called whenever the button Apply or OK was clicked.
bool isEmpty() const const
void deregisterDocument(KTextEditor::DocumentPrivate *doc)
unregister document at the factory
Definition: kateglobal.cpp:423
QSize boundedTo(const QSize &otherSize) const const
KAboutData & setTranslator(const QString &name, const QString &emailAddress)
KTextEditor::Document * createDocument(QObject *parent) override
Create a new document object.
Definition: kateglobal.cpp:252
Accessor interface for the KTextEditor framework.
Definition: editor.h:90
static bool unitTestMode()
Returns true, if the unit test mode was enabled through a call of enableUnitTestMode(),...
Definition: kateglobal.cpp:64
void setText(const QString &text, QClipboard::Mode mode)
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:22
void copyToClipboard(const QString &text, const QString &fileName)
Copy text to clipboard an remember it in the history.
Definition: kateglobal.cpp:471
@ NormalInputMode
Normal Mode.
Definition: view.h:190
static KTextEditor::EditorPrivate * self()
Kate Part Internal stuff ;)
Definition: kateglobal.cpp:392
KateVariableExpansionManager * variableExpansionManager()
Returns the variable expansion manager.
Definition: kateglobal.cpp:456
void setWidgetResizable(bool resizable)
QSize expandedTo(const QSize &otherSize) const const
int remove(const Key &key)
int configPages() const override
Number of available config pages If the editor returns a number < 1, it doesn't support this and the ...
Definition: kateglobal.cpp:356
void copyTo(KConfigBase *other, WriteConfigFlags pFlags=Normal) const
KAboutData & addCredit(const QString &name, const QString &task=QString(), const QString &emailAddress=QString(), const QString &webAddress=QString(), const QString &ocsUsername=QString())
KAboutData & addAuthor(const QString &name, const QString &task=QString(), const QString &emailAddress=QString(), const QString &webAddress=QString(), const QString &ocsUsername=QString())
void setContentsMargins(int left, int top, int right, int bottom)
KTextEditor::EditorPrivate One instance of this class is hold alive during a kate part session,...
Definition: kateglobal.h:63
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void setMinimumWidth(int minw)
void registerDocument(KTextEditor::DocumentPrivate *doc)
register document at the factory this allows us to loop over all docs for example on config changes
Definition: kateglobal.cpp:417
T * data() const const
void deregisterView(KTextEditor::ViewPrivate *view)
unregister view at the factory
Definition: kateglobal.cpp:435
bool contains(const Key &key) const const
KJOBWIDGETS_EXPORT QWidget * window(KJob *job)
void setHeader(const QString &header)
static void enableUnitTestMode()
Calling this function internally sets a flag such that unitTestMode() returns true.
Definition: kateglobal.cpp:59
void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy)
void setWidget(QWidget *widget)
virtual QString fullName() const
Get a readable full name for the config page.
virtual QSize sizeHint() const const override
KTextEditor::Command * queryCommand(const QString &cmd) const override
query for command
Definition: kateglobal.cpp:441
A KParts derived class representing a text document.
Definition: document.h:185
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Wed Sep 28 2022 03:50:45 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.