26#include <QApplication>
33#include <QTextDocumentFragment>
34#include <QDBusInterface>
35#include <QDBusConnection>
36#include <QDBusConnectionInterface>
59class KTextEdit::Private
64 customPalette( false ),
65 checkSpellingEnabled( false ),
66 findReplaceEnabled(true),
68 showAutoCorrectionButton(false),
69 highlighter( 0 ), findDlg(0),find(0),repDlg(0),replace(0), findIndex(0), repIndex(0),
70 lastReplacedPosition(-1)
73 KConfig sonnetKConfig(
"sonnetrc");
75 checkSpellingEnabled =
group.readEntry(
"checkerEnabledByDefault",
false);
82 QString metaMsg =
i18nc(
"Italic placeholder text in line edits: 0 no, 1 yes",
"1");
83 italicizePlaceholder = (metaMsg.trimmed() != QString(
'0'));
100 bool overrideShortcut(
const QKeyEvent* e);
104 bool handleShortcut(
const QKeyEvent* e);
106 void spellCheckerMisspelling(
const QString &text,
int pos );
107 void spellCheckerCorrected(
const QString &,
int,
const QString &);
108 void spellCheckerAutoCorrect(
const QString&,
const QString&);
109 void spellCheckerCanceled();
110 void spellCheckerFinished();
111 void toggleAutoSpellCheck();
113 void slotFindHighlight(
const QString& text,
int matchingIndex,
int matchingLength);
114 void slotReplaceText(
const QString &text,
int replacementIndex,
int ,
int matchedLength);
120 void undoableClear();
123 void menuActivated(
QAction* action );
125 QRect clickMessageRect()
const;
135 QString clickMessage;
136 bool italicizePlaceholder : 1;
137 bool customPalette : 1;
139 bool checkSpellingEnabled : 1;
140 bool findReplaceEnabled: 1;
141 bool showTabAction: 1;
142 bool showAutoCorrectionButton: 1;
143 QTextDocumentFragment originalDoc;
144 QString spellCheckingConfigFileName;
145 QString spellCheckingLanguage;
151 int findIndex, repIndex;
152 int lastReplacedPosition;
156void KTextEdit::Private::checkSpelling(
bool force)
158 if(parent->document()->isEmpty())
167 if(!spellCheckingLanguage.isEmpty())
170 backgroundSpellCheck, force ? parent : 0);
171 backgroundSpellCheck->setParent(spellDialog);
172 spellDialog->setAttribute(Qt::WA_DeleteOnClose,
true);
174 connect(spellDialog, SIGNAL(replace(QString,
int,QString)),
175 parent, SLOT(spellCheckerCorrected(QString,
int,QString)));
176 connect(spellDialog, SIGNAL(misspelling(QString,
int)),
177 parent, SLOT(spellCheckerMisspelling(QString,
int)));
178 connect(spellDialog, SIGNAL(autoCorrect(QString,QString)),
179 parent, SLOT(spellCheckerAutoCorrect(QString,QString)));
180 connect(spellDialog, SIGNAL(done(QString)),
181 parent, SLOT(spellCheckerFinished()));
182 connect(spellDialog, SIGNAL(
cancel()),
183 parent, SLOT(spellCheckerCanceled()));
199 originalDoc = QTextDocumentFragment(parent->document());
200 spellDialog->
setBuffer(parent->toPlainText());
205void KTextEdit::Private::spellCheckerCanceled()
207 QTextDocument *doc = parent->document();
209 QTextCursor cursor(doc);
210 cursor.insertFragment(originalDoc);
211 spellCheckerFinished();
214void KTextEdit::Private::spellCheckerAutoCorrect(
const QString& currentWord,
const QString& autoCorrectWord)
216 emit parent->spellCheckerAutoCorrect(currentWord, autoCorrectWord);
219void KTextEdit::Private::spellCheckerMisspelling(
const QString &text,
int pos )
222 parent->highlightWord( text.length(), pos );
225void KTextEdit::Private::spellCheckerCorrected(
const QString& oldWord,
int pos,
const QString& newWord)
228 if (oldWord != newWord ) {
229 QTextCursor cursor(parent->document());
230 cursor.setPosition(pos);
231 cursor.setPosition(pos+oldWord.length(),QTextCursor::KeepAnchor);
232 cursor.insertText(newWord);
236void KTextEdit::Private::spellCheckerFinished()
238 QTextCursor cursor(parent->document());
239 cursor.clearSelection();
240 parent->setTextCursor(cursor);
241 if (parent->highlighter())
242 parent->highlighter()->rehighlight();
245void KTextEdit::Private::toggleAutoSpellCheck()
247 parent->setCheckSpellingEnabled( !parent->checkSpellingEnabled() );
250void KTextEdit::Private::undoableClear()
252 QTextCursor cursor = parent->textCursor();
253 cursor.beginEditBlock();
254 cursor.movePosition(QTextCursor::Start);
255 cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
256 cursor.removeSelectedText();
257 cursor.endEditBlock();
260void KTextEdit::Private::slotAllowTab()
262 parent->setTabChangesFocus( !parent->tabChangesFocus() );
265void KTextEdit::Private::menuActivated(
QAction* action )
267 if ( action == spellCheckAction )
268 parent->checkSpelling();
269 else if ( action == autoSpellCheckAction )
270 toggleAutoSpellCheck();
271 else if ( action == allowTab )
276void KTextEdit::Private::slotFindHighlight(
const QString& text,
int matchingIndex,
int matchingLength)
280 QTextCursor tc = parent->textCursor();
281 tc.setPosition(matchingIndex);
282 tc.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, matchingLength);
283 parent->setTextCursor(tc);
284 parent->ensureCursorVisible();
288void KTextEdit::Private::slotReplaceText(
const QString &text,
int replacementIndex,
int replacedLength,
int matchedLength) {
290 QTextCursor tc = parent->textCursor();
291 tc.setPosition(replacementIndex);
292 tc.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, matchedLength);
293 tc.removeSelectedText();
294 tc.insertText(text.mid(replacementIndex, replacedLength));
296 parent->setTextCursor(tc);
297 parent->ensureCursorVisible();
299 lastReplacedPosition = replacementIndex;
302QRect KTextEdit::Private::clickMessageRect()
const
304 int margin = int(parent->document()->documentMargin());
305 QRect rect = parent->viewport()->rect().adjusted(margin, margin, -margin, -margin);
306 return parent->fontMetrics().boundingRect(rect, Qt::AlignTop | Qt::TextWordWrap, clickMessage);
309void KTextEdit::Private::init()
318 :
QTextEdit( text, parent ), d( new Private( this ) )
324 :
QTextEdit( parent ), d( new Private( this ) )
336 d->spellCheckingConfigFileName = _fileName;
341 return d->spellCheckingLanguage;
351 if (_language != d->spellCheckingLanguage) {
352 d->spellCheckingLanguage = _language;
358 const QString &windowIcon)
360 KConfig config(configFileName);
362 if (!d->spellCheckingLanguage.isEmpty())
364 if (!windowIcon.isEmpty())
365 dialog.setWindowIcon(
KIcon(windowIcon));
373 if (ev->type() == QEvent::ShortcutOverride) {
374 QKeyEvent *e =
static_cast<QKeyEvent *
>( ev );
375 if (d->overrideShortcut(e)) {
380 return QTextEdit::event(ev);
383bool KTextEdit::Private::handleShortcut(
const QKeyEvent* event)
385 const int key =
event->key() |
event->modifiers();
397 if(!parent->isReadOnly())
401 if(!parent->isReadOnly())
405 if (!parent->isReadOnly())
409 if (!parent->isReadOnly())
413 QTextCursor cursor = parent->textCursor();
414 cursor.movePosition( QTextCursor::PreviousWord );
415 parent->setTextCursor( cursor );
418 QTextCursor cursor = parent->textCursor();
419 cursor.movePosition( QTextCursor::NextWord );
420 parent->setTextCursor( cursor );
423 QTextCursor cursor = parent->textCursor();
425 qreal lastY = parent->cursorRect(cursor).bottom();
428 qreal y = parent->cursorRect(cursor).bottom();
429 distance += qAbs(y - lastY);
431 moved = cursor.movePosition(QTextCursor::Down);
432 }
while (moved && distance < parent->viewport()->height());
435 cursor.movePosition(QTextCursor::Up);
436 parent->verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
438 parent->setTextCursor(cursor);
441 QTextCursor cursor = parent->textCursor();
443 qreal lastY = parent->cursorRect(cursor).bottom();
446 qreal y = parent->cursorRect(cursor).bottom();
447 distance += qAbs(y - lastY);
449 moved = cursor.movePosition(QTextCursor::Up);
450 }
while (moved && distance < parent->viewport()->height());
453 cursor.movePosition(QTextCursor::Down);
454 parent->verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
456 parent->setTextCursor(cursor);
459 QTextCursor cursor = parent->textCursor();
460 cursor.movePosition( QTextCursor::Start );
461 parent->setTextCursor( cursor );
464 QTextCursor cursor = parent->textCursor();
465 cursor.movePosition( QTextCursor::End );
466 parent->setTextCursor( cursor );
469 QTextCursor cursor = parent->textCursor();
470 cursor.movePosition( QTextCursor::StartOfLine );
471 parent->setTextCursor( cursor );
474 QTextCursor cursor = parent->textCursor();
475 cursor.movePosition( QTextCursor::EndOfLine );
476 parent->setTextCursor( cursor );
488 if (!parent->isReadOnly())
492 QString text = QApplication::clipboard()->text( QClipboard::Selection );
493 if ( !text.isEmpty() )
494 parent->insertPlainText( text );
500static void deleteWord(QTextCursor cursor, QTextCursor::MoveOperation op)
502 cursor.clearSelection();
503 cursor.movePosition( op, QTextCursor::KeepAnchor );
504 cursor.removeSelectedText();
509 deleteWord(textCursor(), QTextCursor::PreviousWord);
514 deleteWord(textCursor(), QTextCursor::WordRight);
519 QMenu *popup = createStandardContextMenu();
520 if (!popup)
return 0;
521 connect( popup, SIGNAL(triggered(
QAction*)),
522 this, SLOT(menuActivated(
QAction*)) );
524 const bool emptyDocument = document()->isEmpty();
528 enum { UndoAct, RedoAct, CutAct, CopyAct, PasteAct, ClearAct, SelectAllAct, NCountActs };
530 int idx = actionList.indexOf( actionList[SelectAllAct] ) + 1;
531 if ( idx < actionList.count() )
532 separatorAction = actionList.at( idx );
533 if ( separatorAction )
537 clearAllAction->setEnabled(
false );
538 popup->insertAction( separatorAction, clearAllAction );
547 popup->addSeparator();
548 d->spellCheckAction = popup->addAction(
KIcon(
"tools-check-spelling" ),
549 i18n(
"Check Spelling..." ) );
551 d->spellCheckAction->setEnabled(
false );
552 d->autoSpellCheckAction = popup->addAction(
i18n(
"Auto Spell Check" ) );
553 d->autoSpellCheckAction->setCheckable(
true );
555 popup->addSeparator();
556 if (d->showTabAction) {
557 d->allowTab = popup->addAction(
i18n(
"Allow Tabulations") );
558 d->allowTab->setCheckable(
true );
559 d->allowTab->setChecked( !tabChangesFocus() );
563 if (d->findReplaceEnabled) {
568 findAction->setEnabled(
false);
569 findNextAction->setEnabled(
false);
570 findPrevAction->setEnabled(
false);
572 findNextAction->setEnabled(d->find != 0);
573 findPrevAction->setEnabled(d->find != 0);
575 popup->addSeparator();
576 popup->addAction(findAction);
577 popup->addAction(findNextAction);
578 popup->addAction(findPrevAction);
583 replaceAction->setEnabled(
false);
585 popup->addAction(replaceAction);
588 popup->addSeparator();
589 QAction *speakAction = popup->addAction(
i18n(
"Speak Text"));
590 speakAction->setIcon(
KIcon(
"preferences-desktop-text-to-speech"));
591 speakAction->setEnabled(!emptyDocument );
592 connect( speakAction, SIGNAL(triggered(
bool)),
this, SLOT(
slotSpeakText()) );
599 if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(
"org.kde.kttsd"))
608 QDBusInterface ktts(
"org.kde.kttsd",
"/KSpeech",
"org.kde.KSpeech");
610 if(textCursor().hasSelection())
611 text = textCursor().selectedText();
613 text = toPlainText();
614 ktts.asyncCall(
"say", text, 0);
620 QTextCursor cursorAtMouse = cursorForPosition(event->pos());
621 const int mousePos = cursorAtMouse.position();
622 QTextCursor cursor = textCursor();
625 const bool selectedWordClicked = cursor.hasSelection() &&
626 mousePos >= cursor.selectionStart() &&
627 mousePos <= cursor.selectionEnd();
631 QTextCursor wordSelectCursor(cursorAtMouse);
632 wordSelectCursor.clearSelection();
633 wordSelectCursor.select(QTextCursor::WordUnderCursor);
634 QString selectedWord = wordSelectCursor.selectedText();
636 bool isMouseCursorInsideWord =
true;
637 if ((mousePos < wordSelectCursor.selectionStart() ||
638 mousePos >= wordSelectCursor.selectionEnd())
639 && (selectedWord.length() > 1)) {
640 isMouseCursorInsideWord =
false;
644 wordSelectCursor.setPosition(wordSelectCursor.position()-selectedWord.size());
645 if (selectedWord.startsWith(
'\'') || selectedWord.startsWith(
'\"')) {
646 selectedWord = selectedWord.right(selectedWord.size() - 1);
647 wordSelectCursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor);
649 if (selectedWord.endsWith(
'\'') || selectedWord.endsWith(
'\"'))
650 selectedWord.chop(1);
652 wordSelectCursor.movePosition(QTextCursor::NextCharacter,
653 QTextCursor::KeepAnchor, selectedWord.size());
655 const bool wordIsMisspelled = isMouseCursorInsideWord &&
657 !selectedWord.isEmpty() &&
665 bool inQuote =
false;
666 if (d->spellInterface &&
669 if (!selectedWordClicked) {
670 if (wordIsMisspelled && !inQuote)
671 setTextCursor(wordSelectCursor);
673 setTextCursor(cursorAtMouse);
674 cursor = textCursor();
679 if (!wordIsMisspelled || selectedWordClicked || inQuote) {
680 QMetaObject::invokeMethod(
this,
"mousePopupMenuImplementation", Q_ARG(QPoint, event->globalPos()));
687 if (reps.isEmpty()) {
688 QAction *suggestionsAction = menu.addAction(
i18n(
"No suggestions for %1", selectedWord));
689 suggestionsAction->setEnabled(
false);
692 QStringList::const_iterator end(reps.constEnd());
693 for (QStringList::const_iterator it = reps.constBegin(); it != end; ++it) {
700 QAction *ignoreAction = menu.addAction(
i18n(
"Ignore"));
701 QAction *addToDictAction = menu.addAction(
i18n(
"Add to Dictionary"));
703 const QAction *selectedAction = menu.exec(event->globalPos());
705 if (selectedAction) {
706 Q_ASSERT(cursor.selectedText() == selectedWord);
708 if (selectedAction == ignoreAction) {
712 else if (selectedAction == addToDictAction) {
719 const QString replacement = selectedAction->text();
720 Q_ASSERT(reps.contains(replacement));
721 cursor.insertText(replacement);
722 setTextCursor(cursor);
731 QTextEdit::wheelEvent( event );
733 QAbstractScrollArea::wheelEvent( event );
743 return d->highlighter;
748 delete d->highlighter;
749 d->highlighter = _highLighter;
754 if (d->spellInterface)
763 if ( check == d->checkSpellingEnabled )
770 d->checkSpellingEnabled = check;
781 delete d->highlighter;
788 if ( d->checkSpellingEnabled && !isReadOnly() && !d->highlighter )
791 QTextEdit::focusInEvent( event );
796 if (d->spellInterface)
804 return d->checkSpellingEnabled;
809 if ( !readOnly && hasFocus() && d->checkSpellingEnabled && !d->highlighter )
812 if ( readOnly == isReadOnly() )
816 delete d->highlighter;
819 d->customPalette = testAttribute( Qt::WA_SetPalette );
820 QPalette p = palette();
821 QColor color = p.color( QPalette::Disabled, QPalette::Background );
822 p.setColor( QPalette::Base, color );
823 p.setColor( QPalette::Background, color );
826 if ( d->customPalette && testAttribute( Qt::WA_SetPalette ) ) {
827 QPalette p = palette();
828 QColor color = p.color( QPalette::Normal, QPalette::Base );
829 p.setColor( QPalette::Base, color );
830 p.setColor( QPalette::Background, color );
833 setPalette( QPalette() );
836 QTextEdit::setReadOnly( readOnly );
841 d->checkSpelling(
false);
846 d->checkSpelling(
true);
851 QTextCursor cursor(document());
852 cursor.setPosition(pos);
853 cursor.setPosition(pos+length,QTextCursor::KeepAnchor);
854 setTextCursor (cursor);
855 ensureCursorVisible();
860 if ( document()->isEmpty() )
867 QStringList(), QStringList(),
false);
868 connect( d->repDlg, SIGNAL(okClicked()),
this, SLOT(
slotDoReplace()) );
880 if(d->repDlg->
pattern().isEmpty()) {
883 ensureCursorVisible();
891 d->repIndex = textCursor().anchor();
896 connect(d->replace, SIGNAL(highlight(QString,
int,
int)),
897 this, SLOT(slotFindHighlight(QString,
int,
int)));
898 connect(d->replace, SIGNAL(findNext()),
this, SLOT(
slotReplaceNext()));
899 connect(d->replace, SIGNAL(
replace(QString,
int,
int,
int)),
900 this, SLOT(slotReplaceText(QString,
int,
int,
int)));
912 d->lastReplacedPosition = -1;
914 textCursor().beginEditBlock();
915 viewport()->setUpdatesEnabled(
false);
921 d->replace->
setData(toPlainText(), d->repIndex);
924 textCursor().endEditBlock();
925 if (d->lastReplacedPosition >= 0) {
926 QTextCursor tc = textCursor();
927 tc.setPosition(d->lastReplacedPosition);
929 ensureCursorVisible();
932 viewport()->setUpdatesEnabled(
true);
933 viewport()->update();
938 d->replace->disconnect(
this);
939 d->replace->deleteLater();
941 ensureCursorVisible();
955 if( d->findDlg->
pattern().isEmpty())
965 d->findIndex = textCursor().anchor();
970 connect(d->find, SIGNAL(highlight(QString,
int,
int)),
971 this, SLOT(slotFindHighlight(QString,
int,
int)));
972 connect(d->find, SIGNAL(findNext()),
this, SLOT(
slotFindNext()));
984 const long oldOptions = d->find->
options();
996 if(document()->isEmpty())
998 d->find->disconnect(
this);
999 d->find->deleteLater();
1006 d->find->
setData(toPlainText(), d->findIndex);
1007 res = d->find->
find();
1011 d->find->disconnect(
this);
1012 d->find->deleteLater();
1023 if ( document()->isEmpty() )
1030 connect( d->findDlg, SIGNAL(okClicked()),
this, SLOT(
slotDoFind()) );
1038 if ( document()->isEmpty() )
1045 QStringList(), QStringList(),
false);
1046 connect( d->repDlg, SIGNAL(okClicked()),
this, SLOT(
slotDoReplace()) );
1053 d->findReplaceEnabled = enabled;
1058 d->showTabAction = show;
1063 d->spellInterface = spellInterface;
1066bool KTextEdit::Private::overrideShortcut(
const QKeyEvent* event)
1068 const int key =
event->key() |
event->modifiers();
1110 }
else if (event->matches(QKeySequence::SelectAll)) {
1112 }
else if (event->modifiers() == Qt::ControlModifier &&
1113 (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) &&
1114 qobject_cast<KDialog*>(parent->window()) ) {
1123 if (d->handleShortcut(event)) {
1125 }
else if (event->modifiers() == Qt::ControlModifier &&
1126 (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) &&
1127 qobject_cast<KDialog*>(window()) ) {
1130 QTextEdit::keyPressEvent(event);
1136 if (msg != d->clickMessage) {
1137 if (!d->clickMessage.isEmpty()) {
1138 viewport()->update(d->clickMessageRect());
1140 d->clickMessage = msg;
1141 if (!d->clickMessage.isEmpty()) {
1142 viewport()->update(d->clickMessageRect());
1149 return d->clickMessage;
1154 QTextEdit::paintEvent(ev);
1156 if (!d->clickMessage.isEmpty() && document()->isEmpty()) {
1157 QPainter p(viewport());
1160 f.setItalic(d->italicizePlaceholder);
1163 QColor color(palette().color(viewport()->foregroundRole()));
1164 color.setAlphaF(0.5);
1167 QRect cr = d->clickMessageRect();
1168 p.drawText(cr, Qt::AlignTop | Qt::TextWordWrap, d->clickMessage);
1174 QTextEdit::focusOutEvent(ev);
1179 d->showAutoCorrectionButton = show;
1192#include "ktextedit.moc"
Class to encapsulate user-driven action or event.
static void setAutoHideCursor(QWidget *w, bool enable, bool customEventFilter=false)
Sets auto-hiding the cursor for widget w.
QString pattern() const
Returns the pattern to find.
long options() const
Returns the state of the options.
A generic implementation of the "find" function.
void closeFindNextDialog()
Close the "find next?" dialog.
virtual void setOptions(long options)
Set new options.
@ FromCursor
Start from current cursor position.
@ FindBackwards
Go backwards.
void setData(const QString &data, int startPos=-1)
Call this when needData returns true, before calling find().
virtual void displayFinalDialog() const
Displays the final dialog saying "no match was found", if that was the case.
Result find()
Walk the text fragment (e.g.
long options() const
Return the current options.
static bool wheelMouseZooms()
Typically, QScrollView derived classes can be scrolled fast by holding down the Ctrl-button during wh...
static void assignIconsToContextMenu(ContextMenus type, QList< QAction * > actions)
Assigns standard icons to the various standard text edit context menus.
A wrapper around QIcon that provides KDE icon features.
static void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
Display an "Error" dialog.
static void information(QWidget *parent, const QString &text, const QString &caption=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
Display an "Information" dialog.
A generic "replace" dialog.
long options() const
Returns the state of the options.
QString replacement() const
Returns the replacement string.
A generic implementation of the "replace" function.
virtual void displayFinalDialog() const
Displays the final dialog telling the user how many replacements were made.
Result replace()
Walk the text fragment (e.g.
This interface is a workaround to keep binary compatibility in KDE4, because adding the virtual keywo...
virtual bool shouldBlockBeSpellChecked(const QString &block) const =0
Returns true if the given paragraph or block should be spellcheck.
virtual void setSpellCheckingEnabled(bool enable)=0
Sets whether to enable spellchecking for the KTextEdit.
virtual bool isSpellCheckingEnabled() const =0
void forceSpellChecking()
virtual void focusOutEvent(QFocusEvent *)
virtual void paintEvent(QPaintEvent *)
Reimplemented to paint clickMessage.
bool checkSpellingEnabled
void setSpellCheckingLanguage(const QString &language)
Set the spell check language which will be used for highlighting spelling mistakes and for the spellc...
void setSpellCheckingConfigFileName(const QString &fileName)
Allows to override the config file where the settings for spell checking, like the current language o...
void checkSpelling()
Show a dialog to check the spelling.
void setCheckSpellingEnabled(bool check)
Turns background spell checking for this text edit on or off.
virtual void createHighlighter()
Allows to create a specific highlighter if reimplemented.
KTextEdit(const QString &text, QWidget *parent=0)
Constructs a KTextEdit object.
virtual void keyPressEvent(QKeyEvent *)
Reimplemented for internal reasons.
void spellCheckingCanceled()
signal spellCheckingCanceled is sent when we cancel spell checking.
virtual void wheelEvent(QWheelEvent *)
Reimplemented to allow fast-wheelscrolling with Ctrl-Wheel or zoom.
void mousePopupMenuImplementation(const QPoint &pos)
void highlightWord(int length, int pos)
Selects the characters at the specified position.
virtual void setReadOnly(bool readOnly)
Reimplemented to set a proper "deactivated" background color.
QString spellCheckingLanguage
void replace()
Create replace dialogbox.
void showSpellConfigDialog(const QString &configFileName, const QString &windowIcon=QString())
Opens a Sonnet::ConfigDialog for this text edit.
virtual void deleteWordBack()
Deletes a word backwards from the current cursor position, if available.
void enableFindReplace(bool enabled)
Enable find replace action.
void showAutoCorrectButton(bool show)
virtual void focusInEvent(QFocusEvent *)
Reimplemented to instantiate a KDictSpellingHighlighter, if spellchecking is enabled.
void spellCheckingFinished()
signal spellCheckingFinished is sent when we finish spell check or we click on "Terminate" button in ...
void setClickMessage(const QString &msg)
This makes the text edit display a grayed-out hinting text as long as the user didn't enter any text.
~KTextEdit()
Destroys the KTextEdit object.
QMenu * mousePopupMenu()
Return standard KTextEdit popupMenu.
bool checkSpellingEnabledInternal() const
Checks whether spellchecking is enabled or disabled.
void showTabAction(bool show)
virtual bool event(QEvent *)
Reimplemented to catch "delete word" shortcut events.
void setHighlighter(Sonnet::Highlighter *_highLighter)
Sets a custom backgound spell highlighter for this text edit.
void setCheckSpellingEnabledInternal(bool check)
Enable or disable the spellchecking.
void setSpellInterface(KTextEditSpellInterface *spellInterface)
Sets the spell interface, which is used to delegate certain function calls to the interface.
void checkSpellingChanged(bool)
emit signal when we activate or not autospellchecking
void spellCheckStatus(const QString &)
Signal sends when spell checking is finished/stopped/completed.
void aboutToShowContextMenu(QMenu *menu)
Emitted before the context menu is displayed.
Sonnet::Highlighter * highlighter() const
Returns the current highlighter, which is 0 if spell checking is disabled.
void languageChanged(const QString &language)
Emitted when the user changes the language in the spellcheck dialog shown by checkSpelling() or when ...
virtual void deleteWordForward()
Deletes a word forwards from the current cursor position, if available.
virtual void contextMenuEvent(QContextMenuEvent *)
Reimplemented from QTextEdit to add spelling related items when appropriate.
static void activateWindow(WId win, long time=0)
Requests that window win is activated.
void changeLanguage(const QString &lang)
QString language() const
return selected language
void setLanguage(const QString &language)
Sets the language/dictionary that will be selected by default in this config dialog.
void setBuffer(const QString &)
void activeAutoCorrect(bool _active)
void addWordToDictionary(const QString &word)
Adds the given word permanently to the dictionary.
void ignoreWord(const QString &word)
Ignores the given word.
bool isWordMisspelled(const QString &word)
Checks if a given word is marked as misspelled by the highlighter.
QStringList suggestionsForWord(const QString &word, int max=10)
Returns a list of suggested replacements for the given misspelled word.
void setCurrentLanguage(const QString &lang)
QString i18n(const char *text)
QString i18nc(const char *ctxt, const char *text)
static void deleteWord(QTextCursor cursor, QTextCursor::MoveOperation op)
KAction * replace(const QObject *recvr, const char *slot, QObject *parent)
Find and replace matches.
KAction * findPrev(const QObject *recvr, const char *slot, QObject *parent)
Find a previous instance of a stored 'find'.
KAction * findNext(const QObject *recvr, const char *slot, QObject *parent)
Find the next instance of a stored 'find'.
KAction * find(const QObject *recvr, const char *slot, QObject *parent)
Initiate a 'find' request in the current document.
KAction * clear(const QObject *recvr, const char *slot, QObject *parent)
Clear the content of the focus widget.
KGuiItem cancel()
Returns the 'Cancel' gui item.
const KShortcut & findPrev()
Find/search previous.
const KShortcut & prior()
Scroll up one page.
const KShortcut & find()
Find, search.
const KShortcut & undo()
Undo last operation.
const KShortcut & forwardWord()
ForwardWord.
const KShortcut & deleteWordBack()
Delete a word back from mouse/cursor position.
const KShortcut & endOfLine()
Goto end of current line.
const KShortcut & beginningOfLine()
Goto beginning of current line.
const KShortcut & backwardWord()
BackwardWord.
const KShortcut & begin()
Goto beginning of the document.
const KShortcut & end()
Goto end of the document.
const KShortcut & cut()
Cut selected area and store it in the clipboard.
const KShortcut & paste()
Paste contents of clipboard at mouse/cursor position.
const KShortcut & deleteWordForward()
Delete a word forward from mouse/cursor position.
const KShortcut & copy()
Copy selected area into the clipboard.
const KShortcut & replace()
Find and replace matches.
const KShortcut & findNext()
Find/search next.
const KShortcut & redo()
Redo.
const KShortcut & next()
Scroll down one page.
const KShortcut & pasteSelection()
Paste the selection at mouse/cursor position.