summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtTextEdit.cpp')
-rw-r--r--Swift/QtUI/QtTextEdit.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp
index 75bc292..513e6fd 100644
--- a/Swift/QtUI/QtTextEdit.cpp
+++ b/Swift/QtUI/QtTextEdit.cpp
@@ -27,7 +27,9 @@ QtTextEdit::QtTextEdit(SettingsProvider* settings, QWidget* parent) : QTextEdit(
connect(this, SIGNAL(textChanged()), this, SLOT(handleTextChanged()));
checker_ = NULL;
settings_ = settings;
+#ifdef HAVE_SPELLCHECKER
setUpSpellChecker();
+#endif
handleTextChanged();
};
@@ -60,9 +62,11 @@ void QtTextEdit::keyPressEvent(QKeyEvent* event) {
}
else {
QTextEdit::keyPressEvent(event);
- if(settings_->getSetting(SettingConstants::SPELL_CHECKER)) {
+#ifdef HAVE_SPELLCHECKER
+ if (settings_->getSetting(SettingConstants::SPELL_CHECKER)) {
underlineMisspells();
}
+#endif
}
}
@@ -82,12 +86,10 @@ void QtTextEdit::underlineMisspells() {
std::string fragment = Q2PSTRING(cursor.selectedText());
checker_->checkFragment(fragment, misspelledPositions_);
for (PositionPairList::iterator it = misspelledPositions_.begin(); it != misspelledPositions_.end(); ++it) {
- if (textCursor().position() > boost::get<1>(*it)) {
- cursor.setPosition(boost::get<0>(*it), QTextCursor::MoveAnchor);
- cursor.setPosition(boost::get<1>(*it), QTextCursor::KeepAnchor);
- cursor.setCharFormat(spellingErrorFormat);
- cursor.clearSelection();
- }
+ cursor.setPosition(boost::get<0>(*it), QTextCursor::MoveAnchor);
+ cursor.setPosition(boost::get<1>(*it), QTextCursor::KeepAnchor);
+ cursor.setCharFormat(spellingErrorFormat);
+ cursor.clearSelection();
cursor.setCharFormat(normalFormat);
}
}
@@ -134,8 +136,8 @@ QSize QtTextEdit::sizeHint() const {
void QtTextEdit::contextMenuEvent(QContextMenuEvent* event) {
QMenu *menu = createStandardContextMenu();
QTextCursor cursor = cursorForPosition(event->pos());
+#ifdef HAVE_SPELLCHECKER
QAction *insertPoint = menu->actions().first();
-
QAction *settingsAction = new QAction(QApplication::translate("QtTextEdit", "Spell Checker Options", 0, QApplication::UnicodeUTF8), menu);
menu->insertAction(insertPoint, settingsAction);
menu->insertAction(insertPoint, menu->addSeparator());
@@ -149,6 +151,9 @@ void QtTextEdit::contextMenuEvent(QContextMenuEvent* event) {
replaceMisspelledWord((*it)->text(), cursor.position());
}
}
+#else
+ menu->exec(event->globalPos());
+#endif
delete menu;
}
@@ -193,6 +198,7 @@ void QtTextEdit::setUpSpellChecker()
std::string affixFile(dictFile);
boost::replace_all(affixFile, ".dic", ".aff");
if ((boost::filesystem::exists(dictPath + dictFile)) && (boost::filesystem::exists(dictPath + affixFile))) {
+ std::cout << dictPath + dictFile << std::endl;
checker_ = checkerFactory->createSpellChecker((dictPath + affixFile).c_str(), (dictPath + dictFile).c_str());
}
else {
@@ -220,8 +226,6 @@ void QtTextEdit::spellCheckerSettingsWindow() {
}
void QtTextEdit::handleModifiedSettings() {
- delete checker_;
- checker_ = NULL;
setUpSpellChecker();
underlineMisspells();
}