26 #include <QApplication>
32 #include <QTextCursor>
33 #include <QTextDocumentFragment>
34 #include <QDBusInterface>
35 #include <QDBusConnection>
36 #include <QDBusConnectionInterface>
59 class KTextEdit::Private
64 customPalette( false ),
66 findReplaceEnabled(true),
68 showAutoCorrectionButton(false),
70 lastReplacedPosition(-1)
73 KConfig sonnetKConfig(
"sonnetrc");
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 &);
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;
136 bool italicizePlaceholder : 1;
137 bool customPalette : 1;
140 bool findReplaceEnabled: 1;
142 bool showAutoCorrectionButton: 1;
143 QTextDocumentFragment originalDoc;
144 QString spellCheckingConfigFileName;
151 int findIndex, repIndex;
152 int lastReplacedPosition;
156 void KTextEdit::Private::checkSpelling(
bool force)
158 if(parent->document()->isEmpty())
162 emit parent->spellCheckingFinished();
167 if(!spellCheckingLanguage.isEmpty())
170 backgroundSpellCheck, force ? parent : 0);
171 backgroundSpellCheck->setParent(spellDialog);
172 spellDialog->setAttribute(Qt::WA_DeleteOnClose,
true);
176 connect(spellDialog, SIGNAL(misspelling(
QString,
int)),
177 parent, SLOT(spellCheckerMisspelling(
QString,
int)));
180 connect(spellDialog, SIGNAL(done(
QString)),
181 parent, SLOT(spellCheckerFinished()));
182 connect(spellDialog, SIGNAL(
cancel()),
183 parent, SLOT(spellCheckerCanceled()));
189 connect(spellDialog, SIGNAL(spellCheckStatus(
QString)),
190 parent, SIGNAL(spellCheckStatus(
QString)));
191 connect(spellDialog, SIGNAL(languageChanged(
QString)),
192 parent, SIGNAL(languageChanged(
QString)));
194 connect(spellDialog, SIGNAL(done(
QString)),parent, SIGNAL(spellCheckingFinished()));
195 connect(spellDialog, SIGNAL(
cancel()), parent, SIGNAL(spellCheckingCanceled()));
199 originalDoc = QTextDocumentFragment(parent->document());
200 spellDialog->
setBuffer(parent->toPlainText());
205 void KTextEdit::Private::spellCheckerCanceled()
207 QTextDocument *doc = parent->document();
209 QTextCursor cursor(doc);
210 cursor.insertFragment(originalDoc);
211 spellCheckerFinished();
214 void KTextEdit::Private::spellCheckerAutoCorrect(
const QString& currentWord,
const QString& autoCorrectWord)
216 emit parent->spellCheckerAutoCorrect(currentWord, autoCorrectWord);
219 void KTextEdit::Private::spellCheckerMisspelling(
const QString &text,
int pos )
222 parent->highlightWord( text.length(), pos );
225 void 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);
236 void KTextEdit::Private::spellCheckerFinished()
238 QTextCursor cursor(parent->document());
239 cursor.clearSelection();
240 parent->setTextCursor(cursor);
241 if (parent->highlighter())
242 parent->highlighter()->rehighlight();
245 void KTextEdit::Private::toggleAutoSpellCheck()
247 parent->setCheckSpellingEnabled( !parent->checkSpellingEnabled() );
250 void KTextEdit::Private::undoableClear()
252 QTextCursor cursor = parent->textCursor();
253 cursor.beginEditBlock();
254 cursor.movePosition(QTextCursor::Start);
256 cursor.removeSelectedText();
257 cursor.endEditBlock();
260 void KTextEdit::Private::slotAllowTab()
262 parent->setTabChangesFocus( !parent->tabChangesFocus() );
265 void KTextEdit::Private::menuActivated(
QAction* action )
267 if ( action == spellCheckAction )
268 parent->checkSpelling();
269 else if ( action == autoSpellCheckAction )
270 toggleAutoSpellCheck();
271 else if ( action == allowTab )
276 void 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();
288 void 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;
302 QRect 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);
309 void KTextEdit::Private::init()
313 parent->connect(parent, SIGNAL(languageChanged(
QString)),
314 parent, SLOT(setSpellCheckingLanguage(
QString)));
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;
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);
383 bool KTextEdit::Private::handleShortcut(
const QKeyEvent* event)
385 const int key =
event->key() |
event->modifiers();
397 if(!parent->isReadOnly())
401 if(!parent->isReadOnly())
405 parent->deleteWordBack();
408 parent->deleteWordForward();
411 QTextCursor cursor = parent->textCursor();
412 cursor.movePosition( QTextCursor::PreviousWord );
413 parent->setTextCursor( cursor );
416 QTextCursor cursor = parent->textCursor();
417 cursor.movePosition( QTextCursor::NextWord );
418 parent->setTextCursor( cursor );
421 QTextCursor cursor = parent->textCursor();
423 qreal lastY = parent->cursorRect(cursor).bottom();
426 qreal y = parent->cursorRect(cursor).bottom();
427 distance += qAbs(y - lastY);
429 moved = cursor.movePosition(QTextCursor::Down);
430 }
while (moved && distance < parent->viewport()->height());
434 parent->verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
436 parent->setTextCursor(cursor);
439 QTextCursor cursor = parent->textCursor();
441 qreal lastY = parent->cursorRect(cursor).bottom();
444 qreal y = parent->cursorRect(cursor).bottom();
445 distance += qAbs(y - lastY);
448 }
while (moved && distance < parent->viewport()->height());
451 cursor.movePosition(QTextCursor::Down);
452 parent->verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
454 parent->setTextCursor(cursor);
457 QTextCursor cursor = parent->textCursor();
458 cursor.movePosition( QTextCursor::Start );
459 parent->setTextCursor( cursor );
462 QTextCursor cursor = parent->textCursor();
464 parent->setTextCursor( cursor );
467 QTextCursor cursor = parent->textCursor();
468 cursor.movePosition( QTextCursor::StartOfLine );
469 parent->setTextCursor( cursor );
472 QTextCursor cursor = parent->textCursor();
474 parent->setTextCursor( cursor );
480 parent->slotFindNext();
483 if (!parent->isReadOnly())
484 parent->slotReplace();
487 QString text = QApplication::clipboard()->text( QClipboard::Selection );
488 if ( !text.isEmpty() )
489 parent->insertPlainText( text );
495 static void deleteWord(QTextCursor cursor, QTextCursor::MoveOperation op)
497 cursor.clearSelection();
498 cursor.movePosition( op, QTextCursor::KeepAnchor );
499 cursor.removeSelectedText();
504 deleteWord(textCursor(), QTextCursor::PreviousWord);
509 deleteWord(textCursor(), QTextCursor::WordRight);
514 QMenu *popup = createStandardContextMenu();
515 if (!popup)
return 0;
516 connect( popup, SIGNAL(triggered(
QAction*)),
517 this, SLOT(menuActivated(
QAction*)) );
519 const bool emptyDocument = document()->isEmpty();
523 enum { UndoAct, RedoAct, CutAct, CopyAct, PasteAct, ClearAct, SelectAllAct, NCountActs };
525 int idx = actionList.indexOf( actionList[SelectAllAct] ) + 1;
526 if ( idx < actionList.count() )
527 separatorAction = actionList.at( idx );
528 if ( separatorAction )
532 clearAllAction->setEnabled(
false );
533 popup->insertAction( separatorAction, clearAllAction );
542 popup->addSeparator();
543 d->spellCheckAction = popup->addAction(
KIcon(
"tools-check-spelling" ),
544 i18n(
"Check Spelling..." ) );
546 d->spellCheckAction->setEnabled(
false );
547 d->autoSpellCheckAction = popup->addAction(
i18n(
"Auto Spell Check" ) );
548 d->autoSpellCheckAction->setCheckable(
true );
550 popup->addSeparator();
551 if (d->showTabAction) {
552 d->allowTab = popup->addAction(
i18n(
"Allow Tabulations") );
553 d->allowTab->setCheckable(
true );
554 d->allowTab->setChecked( !tabChangesFocus() );
558 if (d->findReplaceEnabled) {
562 findAction->setEnabled(
false);
563 findNextAction->setEnabled(
false);
565 findNextAction->setEnabled(d->find != 0);
567 popup->addSeparator();
568 popup->addAction(findAction);
569 popup->addAction(findNextAction);
574 replaceAction->setEnabled(
false);
576 popup->addAction(replaceAction);
579 popup->addSeparator();
580 QAction *speakAction = popup->addAction(
i18n(
"Speak Text"));
581 speakAction->setIcon(
KIcon(
"preferences-desktop-text-to-speech"));
582 speakAction->setEnabled(!emptyDocument );
583 connect( speakAction, SIGNAL(triggered(
bool)),
this, SLOT(
slotSpeakText()) );
590 if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(
"org.kde.kttsd"))
599 QDBusInterface ktts(
"org.kde.kttsd",
"/KSpeech",
"org.kde.KSpeech");
601 if(textCursor().hasSelection())
602 text = textCursor().selectedText();
604 text = toPlainText();
605 ktts.asyncCall(
"say", text, 0);
611 QTextCursor cursorAtMouse = cursorForPosition(event->pos());
612 const int mousePos = cursorAtMouse.position();
613 QTextCursor cursor = textCursor();
616 const bool selectedWordClicked = cursor.hasSelection() &&
617 mousePos >= cursor.selectionStart() &&
618 mousePos <= cursor.selectionEnd();
622 QTextCursor wordSelectCursor(cursorAtMouse);
623 wordSelectCursor.clearSelection();
624 wordSelectCursor.select(QTextCursor::WordUnderCursor);
625 QString selectedWord = wordSelectCursor.selectedText();
627 bool isMouseCursorInsideWord =
true;
628 if ((mousePos < wordSelectCursor.selectionStart() ||
629 mousePos >= wordSelectCursor.selectionEnd())
630 && (selectedWord.length() > 1)) {
631 isMouseCursorInsideWord =
false;
635 wordSelectCursor.setPosition(wordSelectCursor.position()-selectedWord.size());
636 if (selectedWord.startsWith(
'\'') || selectedWord.startsWith(
'\"')) {
637 selectedWord = selectedWord.right(selectedWord.size() - 1);
638 wordSelectCursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor);
640 if (selectedWord.endsWith(
'\'') || selectedWord.endsWith(
'\"'))
641 selectedWord.chop(1);
643 wordSelectCursor.movePosition(QTextCursor::NextCharacter,
644 QTextCursor::KeepAnchor, selectedWord.size());
646 const bool wordIsMisspelled = isMouseCursorInsideWord &&
648 !selectedWord.isEmpty() &&
656 bool inQuote =
false;
657 if (d->spellInterface &&
658 !d->spellInterface->shouldBlockBeSpellChecked(cursorAtMouse.block().text()))
660 if (!selectedWordClicked) {
661 if (wordIsMisspelled && !inQuote)
662 setTextCursor(wordSelectCursor);
664 setTextCursor(cursorAtMouse);
665 cursor = textCursor();
670 if (!wordIsMisspelled || selectedWordClicked || inQuote) {
671 QMetaObject::invokeMethod(
this,
"mousePopupMenuImplementation", Q_ARG(
QPoint, event->globalPos()));
678 if (reps.isEmpty()) {
679 QAction *suggestionsAction = menu.addAction(
i18n(
"No suggestions for %1", selectedWord));
680 suggestionsAction->setEnabled(
false);
683 QStringList::const_iterator
end(reps.constEnd());
684 for (QStringList::const_iterator it = reps.constBegin(); it !=
end; ++it) {
691 QAction *ignoreAction = menu.addAction(
i18n(
"Ignore"));
692 QAction *addToDictAction = menu.addAction(
i18n(
"Add to Dictionary"));
694 const QAction *selectedAction = menu.exec(event->globalPos());
696 if (selectedAction) {
697 Q_ASSERT(cursor.selectedText() == selectedWord);
699 if (selectedAction == ignoreAction) {
703 else if (selectedAction == addToDictAction) {
710 const QString replacement = selectedAction->text();
711 Q_ASSERT(reps.contains(replacement));
712 cursor.insertText(replacement);
713 setTextCursor(cursor);
722 QTextEdit::wheelEvent( event );
724 QAbstractScrollArea::wheelEvent( event );
734 return d->highlighter;
739 delete d->highlighter;
740 d->highlighter = _highLighter;
745 if (d->spellInterface)
746 d->spellInterface->setSpellCheckingEnabled(check);
754 if ( check == d->checkSpellingEnabled )
761 d->checkSpellingEnabled = check;
772 delete d->highlighter;
779 if ( d->checkSpellingEnabled && !isReadOnly() && !d->highlighter )
782 QTextEdit::focusInEvent( event );
787 if (d->spellInterface)
788 return d->spellInterface->isSpellCheckingEnabled();
795 return d->checkSpellingEnabled;
800 if ( !readOnly && hasFocus() && d->checkSpellingEnabled && !d->highlighter )
803 if ( readOnly == isReadOnly() )
807 delete d->highlighter;
810 d->customPalette = testAttribute( Qt::WA_SetPalette );
811 QPalette p = palette();
812 QColor color = p.color( QPalette::Disabled, QPalette::Background );
813 p.setColor( QPalette::Base, color );
814 p.setColor( QPalette::Background, color );
817 if ( d->customPalette && testAttribute( Qt::WA_SetPalette ) ) {
818 QPalette p = palette();
819 QColor color = p.color( QPalette::Normal, QPalette::Base );
820 p.setColor( QPalette::Base, color );
821 p.setColor( QPalette::Background, color );
824 setPalette( QPalette() );
827 QTextEdit::setReadOnly( readOnly );
832 d->checkSpelling(
false);
837 d->checkSpelling(
true);
842 QTextCursor cursor(document());
843 cursor.setPosition(pos);
844 cursor.setPosition(pos+length,QTextCursor::KeepAnchor);
845 setTextCursor (cursor);
846 ensureCursorVisible();
851 if ( document()->isEmpty() )
859 connect( d->repDlg, SIGNAL(okClicked()),
this, SLOT(
slotDoReplace()) );
871 if(d->repDlg->pattern().isEmpty()) {
874 ensureCursorVisible();
879 d->replace =
new KReplace(d->repDlg->pattern(), d->repDlg->replacement(), d->repDlg->options(),
this);
882 d->repIndex = textCursor().anchor();
887 connect(d->replace, SIGNAL(highlight(
QString,
int,
int)),
888 this, SLOT(slotFindHighlight(
QString,
int,
int)));
891 this, SLOT(slotReplaceText(
QString,
int,
int,
int)));
903 d->lastReplacedPosition = -1;
905 textCursor().beginEditBlock();
906 viewport()->setUpdatesEnabled(
false);
911 if (d->replace->needData())
912 d->replace->setData(toPlainText(), d->repIndex);
913 res = d->replace->replace();
915 textCursor().endEditBlock();
916 if (d->lastReplacedPosition >= 0) {
917 QTextCursor tc = textCursor();
918 tc.setPosition(d->lastReplacedPosition);
920 ensureCursorVisible();
923 viewport()->setUpdatesEnabled(
true);
924 viewport()->update();
928 d->replace->displayFinalDialog();
929 d->replace->disconnect(
this);
930 d->replace->deleteLater();
932 ensureCursorVisible();
946 if( d->findDlg->pattern().isEmpty())
953 d->find =
new KFind(d->findDlg->pattern(), d->findDlg->options(),
this);
956 d->findIndex = textCursor().anchor();
961 connect(d->find, SIGNAL(highlight(
QString,
int,
int)),
962 this, SLOT(slotFindHighlight(
QString,
int,
int)));
966 d->find->closeFindNextDialog();
975 if(document()->isEmpty())
977 d->find->disconnect(
this);
978 d->find->deleteLater();
984 if (d->find->needData())
985 d->find->setData(toPlainText(), d->findIndex);
986 res = d->find->find();
989 d->find->displayFinalDialog();
990 d->find->disconnect(
this);
991 d->find->deleteLater();
1002 if ( document()->isEmpty() )
1009 connect( d->findDlg, SIGNAL(okClicked()),
this, SLOT(
slotDoFind()) );
1017 if ( document()->isEmpty() )
1025 connect( d->repDlg, SIGNAL(okClicked()),
this, SLOT(
slotDoReplace()) );
1032 d->findReplaceEnabled = enabled;
1037 d->showTabAction = show;
1042 d->spellInterface = spellInterface;
1045 bool KTextEdit::Private::overrideShortcut(
const QKeyEvent* event)
1047 const int key =
event->key() |
event->modifiers();
1089 }
else if (event->modifiers() == Qt::ControlModifier &&
1090 (
event->key() == Qt::Key_Return ||
event->key() == Qt::Key_Enter) &&
1091 qobject_cast<KDialog*>(parent->window()) ) {
1100 if (d->handleShortcut(event)) {
1102 }
else if (event->modifiers() == Qt::ControlModifier &&
1103 (
event->key() == Qt::Key_Return ||
event->key() == Qt::Key_Enter) &&
1104 qobject_cast<KDialog*>(window()) ) {
1107 QTextEdit::keyPressEvent(event);
1113 if (msg != d->clickMessage) {
1114 if (!d->clickMessage.isEmpty()) {
1115 viewport()->update(d->clickMessageRect());
1117 d->clickMessage = msg;
1118 if (!d->clickMessage.isEmpty()) {
1119 viewport()->update(d->clickMessageRect());
1126 return d->clickMessage;
1131 QTextEdit::paintEvent(ev);
1133 if (!d->clickMessage.isEmpty() && document()->isEmpty()) {
1134 QPainter p(viewport());
1137 f.setItalic(d->italicizePlaceholder);
1140 QColor color(palette().color(viewport()->foregroundRole()));
1141 color.setAlphaF(0.5);
1144 QRect cr = d->clickMessageRect();
1145 p.drawText(cr, Qt::AlignTop | Qt::TextWordWrap, d->clickMessage);
1151 QTextEdit::focusOutEvent(ev);
1156 d->showAutoCorrectionButton = show;
1169 #include "ktextedit.moc"
KGuiItem cancel()
Returns the 'Cancel' gui item.
void setCheckSpellingEnabled(bool check)
Turns background spell checking for this text edit on or off.
QString i18n(const char *text)
const KShortcut & findNext()
Find/search next.
void showAutoCorrectButton(bool show)
const KShortcut & deleteWordForward()
Delete a word forward from mouse/cursor position.
void checkSpellingChanged(bool)
emit signal when we activate or not autospellchecking
const KShortcut & next()
Scroll down one page.
virtual void deleteWordForward()
Deletes a word forwards from the current cursor position, if available.
void enableFindReplace(bool enabled)
Enable find replace action.
const KShortcut & forwardWord()
ForwardWord.
const KShortcut & redo()
Redo.
StandardShortcut find(const QKeySequence &seq)
Return the StandardShortcut id of the standard accel action which uses this key sequence, or AccelNone if none of them do.
bool checkSpellingEnabled() const
Returns true if background spell checking is enabled for this text edit.
void showTabAction(bool show)
static void information(QWidget *parent, const QString &text, const QString &caption=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
Display an "Information" dialog.
QMenu * mousePopupMenu()
Return standard KTextEdit popupMenu.
const KShortcut & undo()
Undo last operation.
This interface is a workaround to keep binary compatibility in KDE4, because adding the virtual keywo...
Sonnet::Highlighter * highlighter() const
Returns the current highlighter, which is 0 if spell checking is disabled.
static void deleteWord(QTextCursor cursor, QTextCursor::MoveOperation op)
void ignoreWord(const QString &word)
Ignores the given word.
void replace()
Create replace dialogbox.
void setBuffer(const QString &)
KAction * find(const QObject *recvr, const char *slot, QObject *parent)
Initiate a 'find' request in the current document.
QString clickMessage() const
KAction * findNext(const QObject *recvr, const char *slot, QObject *parent)
Find the next instance of a stored 'find'.
QString i18nc(const char *ctxt, const char *text)
KSharedConfigPtr config()
void setSpellCheckingConfigFileName(const QString &fileName)
Allows to override the config file where the settings for spell checking, like the current language o...
A generic "replace" dialog.
void languageChanged(const QString &language)
Emitted when the user changes the language in the spellcheck dialog shown by checkSpelling() or when ...
void highlightWord(int length, int pos)
Selects the characters at the specified position.
void forceSpellChecking()
void mousePopupMenuImplementation(const QPoint &pos)
static void activateWindow(WId win, long time=0)
Requests that window win is activated.
void setSpellInterface(KTextEditSpellInterface *spellInterface)
Sets the spell interface, which is used to delegate certain function calls to the interface...
Start from current cursor position.
void changeLanguage(const QString &lang)
virtual void setReadOnly(bool readOnly)
Reimplemented to set a proper "deactivated" background color.
A generic implementation of the "replace" function.
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...
virtual void paintEvent(QPaintEvent *)
Reimplemented to paint clickMessage.
void setHighlighter(Sonnet::Highlighter *_highLighter)
Sets a custom backgound spell highlighter for this text edit.
const KShortcut & endOfLine()
Goto end of current line.
static bool wheelMouseZooms()
Typically, QScrollView derived classes can be scrolled fast by holding down the Ctrl-button during wh...
virtual void wheelEvent(QWheelEvent *)
Reimplemented to allow fast-wheelscrolling with Ctrl-Wheel or zoom.
const KShortcut & backwardWord()
BackwardWord.
A wrapper around QIcon that provides KDE icon features.
const KShortcut & beginningOfLine()
Goto beginning of current line.
KAction * clear(const QObject *recvr, const char *slot, QObject *parent)
Clear the content of the focus widget.
const KShortcut & replace()
Find and replace matches.
virtual void createHighlighter()
Allows to create a specific highlighter if reimplemented.
~KTextEdit()
Destroys the KTextEdit object.
void addWordToDictionary(const QString &word)
Adds the given word permanently to the dictionary.
QString language() const
return selected language
void activeAutoCorrect(bool _active)
const KShortcut & copy()
Copy selected area into the clipboard.
KTextEdit(const QString &text, QWidget *parent=0)
Constructs a KTextEdit object.
const QString & spellCheckingLanguage() const
void setCurrentLanguage(const QString &lang)
virtual void deleteWordBack()
Deletes a word backwards from the current cursor position, if available.
bool isWordMisspelled(const QString &word)
Checks if a given word is marked as misspelled by the highlighter.
static void setAutoHideCursor(QWidget *w, bool enable, bool customEventFilter=false)
Sets auto-hiding the cursor for widget w.
A generic implementation of the "find" function.
const KShortcut & cut()
Cut selected area and store it in the clipboard.
QStringList suggestionsForWord(const QString &word, int max=10)
Returns a list of suggested replacements for the given misspelled word.
virtual void contextMenuEvent(QContextMenuEvent *)
Reimplemented from QTextEdit to add spelling related items when appropriate.
KAction * replace(const QObject *recvr, const char *slot, QObject *parent)
Find and replace matches.
const KShortcut & deleteWordBack()
Delete a word back from mouse/cursor position.
virtual void focusInEvent(QFocusEvent *)
Reimplemented to instantiate a KDictSpellingHighlighter, if spellchecking is enabled.
const KShortcut & prior()
Scroll up one page.
const KShortcut & pasteSelection()
Paste the selection at mouse/cursor position.
Class to encapsulate user-driven action or event.
void showSpellConfigDialog(const QString &configFileName, const QString &windowIcon=QString())
Opens a Sonnet::ConfigDialog for this text edit.
void spellCheckerAutoCorrect(const QString ¤tWord, const QString &autoCorrectWord)
void setCheckSpellingEnabledInternal(bool check)
Enable or disable the spellchecking.
void setLanguage(const QString &language)
Sets the language/dictionary that will be selected by default in this config dialog.
bool checkSpellingEnabledInternal() const
Checks whether spellchecking is enabled or disabled.
virtual void keyPressEvent(QKeyEvent *)
Reimplemented for internal reasons.
void checkSpelling()
Show a dialog to check the spelling.
static void assignIconsToContextMenu(ContextMenus type, QList< QAction * > actions)
Assigns standard icons to the various standard text edit context menus.
void setSpellCheckingLanguage(const QString &language)
Set the spell check language which will be used for highlighting spelling mistakes and for the spellc...
virtual void focusOutEvent(QFocusEvent *)
const KShortcut & end()
Goto end of the document.
virtual bool event(QEvent *)
Reimplemented to catch "delete word" shortcut events.
void aboutToShowContextMenu(QMenu *menu)
Emitted before the context menu is displayed.
static void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
Display an "Error" dialog.
const KShortcut & paste()
Paste contents of clipboard at mouse/cursor position.
const KShortcut & begin()
Goto beginning of the document.