From: John Levon Date: Mon, 27 Aug 2001 02:54:27 +0000 (+0000) Subject: Thesaurus dialog. Untested, as it won't build for me. I get undefined X-Git-Tag: 1.6.10~20750 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ec417b6f3da2a90407fac07cdce1558ac4faa55c;p=features.git Thesaurus dialog. Untested, as it won't build for me. I get undefined vtable errors, which make no sense :( git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2595 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 7f88ac9715..480cf2e00c 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,11 @@ +2001-08-27 John Levon + + * Dialogs.C: + * Makefile.dialogs: + * QThesaurus.[Ch]: + * QThesaurusDialog.[Ch]: + * ui/QThesaurusDialog.ui: add thesaurus dialog + 2001-08-27 John Levon * Dialogs.C: diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index 96611ea716..2fd5c55191 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -22,6 +22,7 @@ #include "QExternalDialog.h" #include "QIndexDialog.h" #include "QRefDialog.h" +#include "QThesaurusDialog.h" #include "QURLDialog.h" #include "QAbout.h" @@ -39,6 +40,7 @@ #include "QSearch.h" #include "QSplash.h" #include "QTabularCreate.h" +#include "QThesaurus.h" #include "QURL.h" #include "QtLyXView.h" @@ -59,6 +61,7 @@ #include "controllers/ControlIndex.h" #include "controllers/ControlRef.h" #include "controllers/ControlSplash.h" +#include "controllers/ControlThesaurus.h" #include "controllers/ControlUrl.h" #if 0 #include "controllers/ControlButtons.h" @@ -75,7 +78,6 @@ #include "controllers/ControlSearch.h" #include "controllers/ControlSpellchecker.h" #include "controllers/ControlTabularCreate.h" -#include "controllers/ControlThesaurus.h" #include "controllers/ControlToc.h" #include "controllers/ControlVCLog.h" #endif @@ -101,6 +103,7 @@ Dialogs::Dialogs(LyXView * lv) add(new GUIExternal(*lv, *this)); add(new GUIIndex(*lv, *this)); add(new GUIRef(*lv, *this)); + add(new GUIThesaurus(*lv, *this)); add(new GUIUrl(*lv, *this)); // reduce the number of connections needed in diff --git a/src/frontends/qt2/Makefile.dialogs b/src/frontends/qt2/Makefile.dialogs index 0e169fd214..334860fd0e 100644 --- a/src/frontends/qt2/Makefile.dialogs +++ b/src/frontends/qt2/Makefile.dialogs @@ -17,6 +17,7 @@ DIALOGS = \ QSearch \ QSplash \ QTabularCreate \ + QThesaurus \ QToc \ QURL @@ -53,6 +54,8 @@ DIALOGSOURCES = \ QSplash.C QSplashDialog.C \ QTabularCreate.h QTabularCreateDialog.h \ QTabularCreate.C QTabularCreateDialog.C \ + QThesaurus.h QThesaurusDialog.h \ + QThesaurus.C QThesaurusDialog.C \ QToc.h QTocDialog.h \ QToc.C QTocDialog.C \ QURL.h QURLDialog.h \ @@ -75,6 +78,7 @@ MOCDIALOGS = \ QSearchDialog_moc.C \ QSplashDialog_moc.C \ QTabularCreateDialog_moc.C \ + QThesaurusDialog_moc.C \ QTocDialog_moc.C \ QURLDialog_moc.C @@ -109,6 +113,8 @@ UIDIALOGS = \ QSearchDialogBase.C \ QTabularCreateDialogBase.h \ QTabularCreateDialogBase.C \ + QThesaurusDialogBase.h \ + QThesaurusDialogBase.C \ QTocDialogBase.h \ QTocDialogBase.C \ QURLDialogBase.h \ @@ -130,5 +136,6 @@ UIMOCDIALOGS = \ QRefDialogBase_moc.C \ QSearchDialogBase_moc.C \ QTabularCreateDialogBase_moc.C \ + QThesaurusDialogBase_moc.C \ QTocDialogBase_moc.C \ QURLDialogBase_moc.C diff --git a/src/frontends/qt2/QThesaurus.C b/src/frontends/qt2/QThesaurus.C new file mode 100644 index 0000000000..bb3a980a9b --- /dev/null +++ b/src/frontends/qt2/QThesaurus.C @@ -0,0 +1,49 @@ +/** + * \file QThesaurus.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include + +#include "ControlThesaurus.h" +#include "QThesaurusDialog.h" +#include "QThesaurus.h" +#include "Qt2BC.h" +#include "gettext.h" + +#include +#include +#include + +typedef Qt2CB > base_class; + +QThesaurus::QThesaurus(ControlThesaurus & c) + : base_class(c, _("Thesaurus")) +{ +} + + +void QThesaurus::build_dialog() +{ + dialog_.reset(new QThesaurusDialog(this)); + + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->replaceED); + bc().addReadOnly(dialog_->replacePB); +} + + +void QThesaurus::update_contents() +{ + dialog_->entryED->setText(controller().text().c_str()); + dialog_->updateLists(); +} + + +void QThesaurus::replace() +{ + controller().replace(dialog_->replaceED->text().latin1()); +} diff --git a/src/frontends/qt2/QThesaurus.h b/src/frontends/qt2/QThesaurus.h new file mode 100644 index 0000000000..e47a5f5530 --- /dev/null +++ b/src/frontends/qt2/QThesaurus.h @@ -0,0 +1,38 @@ +// -*- C++ -*- +/** + * \file QThesaurus.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#ifndef QTHESAURUS_H +#define QTHESAURUS_H + +#include "Qt2Base.h" + +class ControlThesaurus; +class QThesaurusDialog; + +class QThesaurus : + public Qt2CB > +{ + friend class QThesaurusDialog; + +public: + QThesaurus(ControlThesaurus &); + +private: + /// Apply changes + virtual void apply(); + /// update + virtual void update_contents(); + /// build the dialog + virtual void build_dialog(); + + /// replace the word + void replace(); +}; + +#endif // QTHESAURUS_H diff --git a/src/frontends/qt2/QThesaurusDialog.C b/src/frontends/qt2/QThesaurusDialog.C new file mode 100644 index 0000000000..1e182f8805 --- /dev/null +++ b/src/frontends/qt2/QThesaurusDialog.C @@ -0,0 +1,93 @@ +/** + * \file QThesaurusDialog.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include +#include + +#include "LString.h" + +#include "ControlThesaurus.h" +#include "QThesaurusDialog.h" +#include "Dialogs.h" +#include "QThesaurus.h" + +#include +#include +#include +#include + +QThesaurusDialog::QThesaurusDialog(QThesaurus * form) + : QThesaurusDialogBase(0, 0, false, 0), + form_(form) +{ + connect(closePB, SIGNAL(clicked()), + form, SLOT(slotClose())); +} + + +void QThesaurusDialog::change_adaptor() +{ + form_->changed(); +} + + +void QThesaurusDialog::closeEvent(QCloseEvent * e) +{ + form_->slotWMHide(); + e->accept(); +} + + +void QThesaurusDialog::entryChanged() +{ + updateLists(); +} + + +void QThesaurusDialog::replaceClicked() +{ + form_->replace(); +} + + +void QThesaurusDialog::selectionChanged(const QString & str) +{ + string const entry(str.latin1()); + entryED->setText(entry.c_str()); + updateLists(); +} + + +void QThesaurusDialog::updateLists() +{ + ControlThesaurus & control(form_->controller()); + string const entry(entryED->text().latin1()); + + std::vector matches; + + matches = control.getNouns(entry); + for (std::vector::const_iterator cit = matches.begin(); + cit != matches.end(); ++cit) + nounsLB->insertItem(cit->c_str()); + matches = control.getVerbs(entry); + for (std::vector::const_iterator cit = matches.begin(); + cit != matches.end(); ++cit) + verbsLB->insertItem(cit->c_str()); + matches = control.getAdjectives(entry); + for (std::vector::const_iterator cit = matches.begin(); + cit != matches.end(); ++cit) + adjectivesLB->insertItem(cit->c_str()); + matches = control.getAdverbs(entry); + for (std::vector::const_iterator cit = matches.begin(); + cit != matches.end(); ++cit) + adverbsLB->insertItem(cit->c_str()); + matches = control.getOthers(entry); + for (std::vector::const_iterator cit = matches.begin(); + cit != matches.end(); ++cit) + otherLB->insertItem(cit->c_str()); +} diff --git a/src/frontends/qt2/QThesaurusDialog.h b/src/frontends/qt2/QThesaurusDialog.h new file mode 100644 index 0000000000..db6d7a7d0f --- /dev/null +++ b/src/frontends/qt2/QThesaurusDialog.h @@ -0,0 +1,39 @@ +/** + * \file QThesaurusDialog.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#ifndef QTHESAURUSDIALOG_H +#define QTHESAURUSDIALOG_H + +#include + +#include "ui/QThesaurusDialogBase.h" + +class QThesaurus; + +class QThesaurusDialog : public QThesaurusDialogBase +{ Q_OBJECT + +public: + QThesaurusDialog(QThesaurus * form); + + void updateLists(); + +protected slots: + virtual void change_adaptor(); + virtual void entryChanged(); + virtual void replaceClicked(); + virtual void selectionChanged(const QString &); + +protected: + virtual void closeEvent(QCloseEvent * e); + +private: + QThesaurus * form_; +}; + +#endif // QTHESAURUSDIALOG_H diff --git a/src/frontends/qt2/ui/QThesaurusDialog.ui b/src/frontends/qt2/ui/QThesaurusDialog.ui new file mode 100644 index 0000000000..0418b042b9 --- /dev/null +++ b/src/frontends/qt2/ui/QThesaurusDialog.ui @@ -0,0 +1,479 @@ + +QThesaurusDialogBase + + QDialog + + name + QThesaurusDialogBase + + + geometry + + 0 + 0 + 490 + 442 + + + + caption + Thesaurus + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout4 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + entryLA + + + text + &Keyword + + + buddy + entryED + + + toolTip + Index entry + + + + QLineEdit + + name + entryED + + + toolTip + Entry + + + + + name + Spacer2 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QTabWidget + + name + TabWidget2 + + + QWidget + + name + tab + + + title + &Nouns + + + + margin + 11 + + + spacing + 6 + + + QListBox + + name + nounsLB + + + columnMode + FitToHeight + + + toolTip + Matching nouns + + + + + + QWidget + + name + tab + + + title + &Verbs + + + + margin + 11 + + + spacing + 6 + + + QListBox + + + text + New Item + + + + name + verbsLB + + + columnMode + FitToHeight + + + + + + QWidget + + name + tab + + + title + &Adjectives + + + + margin + 11 + + + spacing + 6 + + + QListBox + + + text + New Item + + + + name + adjectivesLB + + + columnMode + FitToHeight + + + + + + QWidget + + name + tab + + + title + A&dverbs + + + + margin + 11 + + + spacing + 6 + + + QListBox + + + text + New Item + + + + name + adverbsLB + + + columnMode + FitToHeight + + + + + + QWidget + + name + tab + + + title + &Other + + + + margin + 11 + + + spacing + 6 + + + QListBox + + + text + New Item + + + + name + otherLB + + + columnMode + FitToHeight + + + + + + + QLayoutWidget + + name + Layout5 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + selectionLA + + + text + &Selection + + + buddy + selectionED + + + toolTip + The selected entry + + + + QLineEdit + + name + replaceED + + + toolTip + The selected entry + + + + QPushButton + + name + replacePB + + + text + &Replace + + + toolTip + Replace the entry with the selection + + + + + + QLayoutWidget + + name + Layout27 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer3 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + closePB + + + text + &Close + + + + + + + + + replaceED + returnPressed() + QThesaurusDialogBase + replaceClicked() + + + replaceED + textChanged(const QString&) + QThesaurusDialogBase + change_adaptor() + + + nounsLB + selected(const QString&) + QThesaurusDialogBase + selectionChanged(const QString &) + + + verbsLB + selected(const QString&) + QThesaurusDialogBase + selectionChanged(const QString &) + + + adjectivesLB + selected(const QString&) + QThesaurusDialogBase + selectionChanged(const QString &) + + + adverbsLB + selected(const QString&) + QThesaurusDialogBase + selectionChanged(const QString &) + + + otherLB + selected(const QString&) + QThesaurusDialogBase + selectionChanged(const QString &) + + + entryED + returnPressed() + QThesaurusDialogBase + entryChanged() + + + replacePB + clicked() + QThesaurusDialogBase + replaceClicked() + + change_adaptor() + entryChanged() + replaceClicked() + selectionChanged(const QString &) + + + TabWidget2 + entryED + nounsLB + verbsLB + adjectivesLB + adverbsLB + otherLB + replaceED + replacePB + closePB + +