From: John Levon Date: Sat, 1 Sep 2001 03:52:21 +0000 (+0000) Subject: add qt2 spellchecker X-Git-Tag: 1.6.10~20698 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7c9de3222e9a48e69fc3322027287fb4b4803edf;p=features.git add qt2 spellchecker git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2648 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 8d46a427c4..c2c0a0b451 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,11 @@ +2001-09-01 John Levon + + * Makefile.dialogs: + * Dialogs.C: + * QSpellchecker.[Ch]: + * QSpellcheckerDialog.[Ch]: + * ui/QSpellcheckerDialog.ui: add spellchecker dialog + 2001-08-31 Edwin Leuven * ui/QMinipageDialog.ui: layout tweak again (but it's getting better) diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index c9a015b527..84615efeee 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -29,6 +29,7 @@ #include "QPrintDialog.h" #include "QRefDialog.h" #include "QSearchDialog.h" +#include "QSpellcheckerDialog.h" #include "QTabularCreateDialog.h" #include "QThesaurusDialog.h" #include "QURLDialog.h" @@ -52,6 +53,7 @@ #include "QPrint.h" #include "QRef.h" #include "QSearch.h" +#include "QSpellchecker.h" #include "QSplash.h" #include "QTabularCreate.h" #include "QThesaurus.h" @@ -82,18 +84,16 @@ #include "controllers/ControlPrint.h" #include "controllers/ControlRef.h" #include "controllers/ControlSearch.h" +#include "controllers/ControlSpellchecker.h" #include "controllers/ControlSplash.h" #include "controllers/ControlTabularCreate.h" #include "controllers/ControlThesaurus.h" #include "controllers/ControlUrl.h" #include "controllers/ControlVCLog.h" #if 0 -#include "controllers/ControlButtons.h" #include "controllers/ControlCitation.h" #include "controllers/ControlFloat.h" -#include "controllers/ControlLabel.h" #include "controllers/ControlRef.h" -#include "controllers/ControlSpellchecker.h" #include "controllers/ControlToc.h" #endif @@ -125,6 +125,7 @@ Dialogs::Dialogs(LyXView * lv) add(new GUIPrint(*lv, *this)); add(new GUIRef(*lv, *this)); add(new GUISearch(*lv, *this)); + add(new GUISpellchecker(*lv, *this)); add(new GUITabularCreate(*lv, *this)); add(new GUIThesaurus(*lv, *this)); add(new GUIUrl(*lv, *this)); diff --git a/src/frontends/qt2/Makefile.dialogs b/src/frontends/qt2/Makefile.dialogs index 132c6bc4d0..c6e2f1ab1f 100644 --- a/src/frontends/qt2/Makefile.dialogs +++ b/src/frontends/qt2/Makefile.dialogs @@ -20,6 +20,7 @@ DIALOGS = \ QPrint \ QRef \ QSearch \ + QSpellchecker \ QSplash \ QTabularCreate \ QThesaurus \ @@ -66,6 +67,8 @@ DIALOGSOURCES = \ QRef.C QRefDialog.C \ QSearch.h QSearchDialog.h \ QSearch.C QSearchDialog.C \ + QSpellchecker.h QSpellcheckerDialog.h \ + QSpellchecker.C QSpellcheckerDialog.C \ QSplash.h QSplashDialog.h \ QSplash.C QSplashDialog.C \ QTabularCreate.h QTabularCreateDialog.h \ @@ -99,6 +102,7 @@ MOCDIALOGS = \ QPrintDialog_moc.C \ QRefDialog_moc.C \ QSearchDialog_moc.C \ + QSpellcheckerDialog_moc.C \ QSplashDialog_moc.C \ QTabularCreateDialog_moc.C \ QThesaurusDialog_moc.C \ @@ -145,6 +149,8 @@ UIDIALOGS = \ QRefDialogBase.C \ QSearchDialogBase.h \ QSearchDialogBase.C \ + QSpellcheckerDialogBase.h \ + QSpellcheckerDialogBase.C \ QTabularCreateDialogBase.h \ QTabularCreateDialogBase.C \ QThesaurusDialogBase.h \ @@ -176,6 +182,7 @@ UIMOCDIALOGS = \ QPrintDialogBase_moc.C \ QRefDialogBase_moc.C \ QSearchDialogBase_moc.C \ + QSpellcheckerDialogBase_moc.C \ QTabularCreateDialogBase_moc.C \ QThesaurusDialogBase_moc.C \ QTocDialogBase_moc.C \ diff --git a/src/frontends/qt2/QSpellchecker.C b/src/frontends/qt2/QSpellchecker.C new file mode 100644 index 0000000000..d463f4cb5a --- /dev/null +++ b/src/frontends/qt2/QSpellchecker.C @@ -0,0 +1,117 @@ +/** + * \file QSpellchecker.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include + +#include "ControlSpellchecker.h" +#include "QSpellcheckerDialog.h" +#include "QSpellchecker.h" +#include "Qt2BC.h" +#include "gettext.h" + +#include +#include +#include +#include +#include +#include + +typedef Qt2CB > base_class; + +QSpellchecker::QSpellchecker(ControlSpellchecker & c) + : base_class(c, _("Spellchecker")) +{ +} + + +void QSpellchecker::build_dialog() +{ + dialog_.reset(new QSpellcheckerDialog(this)); + + bc().setCancel(dialog_->closePB); + dialog_->wordED->setReadOnly(true); +} + + +void QSpellchecker::update_contents() +{ + dialog_->wordED->setText(""); + dialog_->replaceCO->clear(); + dialog_->suggestionsLB->clear(); +} + + +void QSpellchecker::accept() +{ + controller().ignoreAll(); +} + + +void QSpellchecker::add() +{ + controller().insert(); +} + + +void QSpellchecker::ignore() +{ + controller().check(); +} + + +void QSpellchecker::replace() +{ + controller().replace(dialog_->replaceCO->currentText().latin1()); +} + + +void QSpellchecker::options() +{ + controller().options(); +} + + +void QSpellchecker::spellcheck() +{ + controller().check(); + dialog_->spellcheckPB->setEnabled(false); +} + + +void QSpellchecker::stop() +{ + controller().stop(); + dialog_->spellcheckPB->setEnabled(true); + hide(); +} + + +void QSpellchecker::partialUpdate(int id) +{ + switch (id) { + case 0: + dialog_->spellcheckPR->setProgress(controller().getProgress()); + break; + case 1: + { + dialog_->wordED->setText(controller().getWord().c_str()); + dialog_->suggestionsLB->clear(); + + string w; + while (!(w = controller().getSuggestion()).empty()) { + dialog_->suggestionsLB->insertItem(w.c_str()); + } + } + break; + case 2: + dialog_->spellcheckPB->setEnabled(true); + hide(); + QMessageBox::information(0, _("Spellcheck complete"), controller().getMessage().c_str() , _("OK")); + break; + } +} diff --git a/src/frontends/qt2/QSpellchecker.h b/src/frontends/qt2/QSpellchecker.h new file mode 100644 index 0000000000..4deed6bb81 --- /dev/null +++ b/src/frontends/qt2/QSpellchecker.h @@ -0,0 +1,48 @@ +// -*- C++ -*- +/** + * \file QSpellchecker.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + * \author Kalle Dalheimer + */ + +#ifndef QSPELLCHECKER_H +#define QSPELLCHECKER_H + +#include "Qt2Base.h" + + +class ControlSpellchecker; +class QSpellcheckerDialog; + +class QSpellchecker : + public Qt2CB > +{ + friend class QSpellcheckerDialog; + +public: + QSpellchecker(ControlSpellchecker &); + + /// update from controller + void partialUpdate(int id); + +private: + void stop(); + void accept(); + void add(); + void ignore(); + void replace(); + void options(); + void spellcheck(); + + /// Apply changes + virtual void apply() {}; + /// update + virtual void update_contents(); + /// build the dialog + virtual void build_dialog(); +}; + +#endif // QSPELLCHECKER_H diff --git a/src/frontends/qt2/QSpellcheckerDialog.C b/src/frontends/qt2/QSpellcheckerDialog.C new file mode 100644 index 0000000000..a07c842d5f --- /dev/null +++ b/src/frontends/qt2/QSpellcheckerDialog.C @@ -0,0 +1,61 @@ +/** + * \file QSpellcheckerDialog.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include + +#include "QSpellcheckerDialog.h" +#include "Dialogs.h" +#include "QSpellchecker.h" +#include "gettext.h" + +#include +#include +#include +#include + +QSpellcheckerDialog::QSpellcheckerDialog(QSpellchecker * form) + : QSpellcheckerDialogBase(0, 0, false, 0), + form_(form) +{ + connect(closePB, SIGNAL(clicked()), + this, SLOT(stop())); +} + + +void QSpellcheckerDialog:: suggestionChanged(const QString & str) +{ + if (replaceCO->count() != 0) + replaceCO->changeItem(str, 0); + else + replaceCO->insertItem(str); + + replaceCO->setCurrentItem(0); +} + + +void QSpellcheckerDialog:: replaceChanged(const QString & str) +{ + if (suggestionsLB->currentText() == str) + return; + + int i = 0; + for (; i < suggestionsLB->count(); ++i) { + if (suggestionsLB->text(i) == str) + break; + } + + if (i != suggestionsLB->count()) + suggestionsLB->setCurrentItem(i); +} + + +void QSpellcheckerDialog::closeEvent(QCloseEvent * e) +{ + form_->slotWMHide(); + e->accept(); +} diff --git a/src/frontends/qt2/QSpellcheckerDialog.h b/src/frontends/qt2/QSpellcheckerDialog.h new file mode 100644 index 0000000000..89d0db01d6 --- /dev/null +++ b/src/frontends/qt2/QSpellcheckerDialog.h @@ -0,0 +1,57 @@ +/** + * \file QSpellcheckerDialog.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#ifndef QSPELLCHECKERDIALOG_H +#define QSPELLCHECKERDIALOG_H + +#include + +#include "ui/QSpellcheckerDialogBase.h" + +#include "QSpellchecker.h" + +class QSpellcheckerDialog : public QSpellcheckerDialogBase +{ Q_OBJECT + +public: + QSpellcheckerDialog(QSpellchecker * form); + +protected slots: + virtual void stop() { + form_->stop(); + } + + virtual void acceptClicked() { + form_->accept(); + } + virtual void spellcheckClicked() { + form_->spellcheck(); + } + virtual void addClicked() { + form_->add(); + } + virtual void replaceClicked() { + form_->replace(); + } + virtual void ignoreClicked() { + form_->ignore(); + } + virtual void optionsClicked() { + form_->options(); + } + virtual void suggestionChanged(const QString &); + virtual void replaceChanged(const QString &); + +protected: + virtual void closeEvent(QCloseEvent * e); + +private: + QSpellchecker * form_; +}; + +#endif // QSPELLCHECKERDIALOG_H diff --git a/src/frontends/qt2/ui/QSpellcheckerDialog.ui b/src/frontends/qt2/ui/QSpellcheckerDialog.ui new file mode 100644 index 0000000000..207f4be45c --- /dev/null +++ b/src/frontends/qt2/ui/QSpellcheckerDialog.ui @@ -0,0 +1,443 @@ + +QSpellcheckerDialogBase +config.h +gettext.h + + QDialog + + name + QSpellcheckerDialogBase + + + geometry + + 0 + 0 + 434 + 282 + + + + caption + Spellchecker + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout8 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout7 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout10 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout9 + + + + margin + 0 + + + spacing + 6 + + + QLineEdit + + name + wordED + + + toolTip + Current word + + + + QComboBox + + name + replaceCO + + + focusPolicy + StrongFocus + + + editable + true + + + insertionPolicy + AtTop + + + autoCompletion + true + + + duplicatesEnabled + false + + + sizePolicy + + 3 + 0 + + + + toolTip + Replace with selected word + + + + + + + name + Spacer11 + + + orientation + Horizontal + + + sizeType + MinimumExpanding + + + sizeHint + + 20 + 20 + + + + + + + QListBox + + name + suggestionsLB + + + toolTip + Suggestions + + + + QProgressBar + + name + spellcheckPR + + + toolTip + How far spellchecking has got + + + + + + QLayoutWidget + + name + Layout5 + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + replacePB + + + text + &Replace + + + toolTip + Replace word with current choice + + + + QPushButton + + name + ignorePB + + + text + &Ignore + + + toolTip + Ignore this word + + + + QPushButton + + name + replacePB_3 + + + text + &Accept + + + toolTip + Accept word for this session + + + + QPushButton + + name + addPB + + + text + &Add to dictionary + + + toolTip + Add the word to your personal dictionary + + + + + name + Spacer10 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + + QLayoutWidget + + name + Layout1 + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + spellcheckPB + + + text + &Spellcheck ... + + + + + name + Spacer6 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + optionsPB + + + text + &Options ... + + + + + name + Spacer5 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + closePB + + + text + &Close + + + + + + + + + suggestionsLB + highlighted(const QString&) + QSpellcheckerDialogBase + suggestionChanged(const QString &) + + + replaceCO + highlighted(const QString&) + QSpellcheckerDialogBase + replaceChanged(const QString &) + + + replacePB + clicked() + QSpellcheckerDialogBase + replaceClicked() + + + ignorePB + clicked() + QSpellcheckerDialogBase + ignoreClicked() + + + replacePB_3 + clicked() + QSpellcheckerDialogBase + acceptClicked() + + + addPB + clicked() + QSpellcheckerDialogBase + addClicked() + + + optionsPB + clicked() + QSpellcheckerDialogBase + optionsClicked() + + + spellcheckPB + clicked() + QSpellcheckerDialogBase + spellcheckClicked() + + acceptClicked() + addClicked() + ignoreClicked() + optionsClicked() + replaceChanged(const QString &) + replaceClicked() + spellcheckClicked() + suggestionChanged(const QString &) + +