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
This commit is contained in:
John Levon 2001-08-27 02:54:27 +00:00
parent 58dcb8523c
commit ec417b6f3d
8 changed files with 717 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2001-08-27 John Levon <moz@compsoc.man.ac.uk>
* Dialogs.C:
* Makefile.dialogs:
* QThesaurus.[Ch]:
* QThesaurusDialog.[Ch]:
* ui/QThesaurusDialog.ui: add thesaurus dialog
2001-08-27 John Levon <moz@compsoc.man.ac.uk> 2001-08-27 John Levon <moz@compsoc.man.ac.uk>
* Dialogs.C: * Dialogs.C:

View File

@ -22,6 +22,7 @@
#include "QExternalDialog.h" #include "QExternalDialog.h"
#include "QIndexDialog.h" #include "QIndexDialog.h"
#include "QRefDialog.h" #include "QRefDialog.h"
#include "QThesaurusDialog.h"
#include "QURLDialog.h" #include "QURLDialog.h"
#include "QAbout.h" #include "QAbout.h"
@ -39,6 +40,7 @@
#include "QSearch.h" #include "QSearch.h"
#include "QSplash.h" #include "QSplash.h"
#include "QTabularCreate.h" #include "QTabularCreate.h"
#include "QThesaurus.h"
#include "QURL.h" #include "QURL.h"
#include "QtLyXView.h" #include "QtLyXView.h"
@ -59,6 +61,7 @@
#include "controllers/ControlIndex.h" #include "controllers/ControlIndex.h"
#include "controllers/ControlRef.h" #include "controllers/ControlRef.h"
#include "controllers/ControlSplash.h" #include "controllers/ControlSplash.h"
#include "controllers/ControlThesaurus.h"
#include "controllers/ControlUrl.h" #include "controllers/ControlUrl.h"
#if 0 #if 0
#include "controllers/ControlButtons.h" #include "controllers/ControlButtons.h"
@ -75,7 +78,6 @@
#include "controllers/ControlSearch.h" #include "controllers/ControlSearch.h"
#include "controllers/ControlSpellchecker.h" #include "controllers/ControlSpellchecker.h"
#include "controllers/ControlTabularCreate.h" #include "controllers/ControlTabularCreate.h"
#include "controllers/ControlThesaurus.h"
#include "controllers/ControlToc.h" #include "controllers/ControlToc.h"
#include "controllers/ControlVCLog.h" #include "controllers/ControlVCLog.h"
#endif #endif
@ -101,6 +103,7 @@ Dialogs::Dialogs(LyXView * lv)
add(new GUIExternal<QExternal, Qt2BC>(*lv, *this)); add(new GUIExternal<QExternal, Qt2BC>(*lv, *this));
add(new GUIIndex<QIndex, Qt2BC>(*lv, *this)); add(new GUIIndex<QIndex, Qt2BC>(*lv, *this));
add(new GUIRef<QRef, Qt2BC>(*lv, *this)); add(new GUIRef<QRef, Qt2BC>(*lv, *this));
add(new GUIThesaurus<QThesaurus, Qt2BC>(*lv, *this));
add(new GUIUrl<QURL, Qt2BC>(*lv, *this)); add(new GUIUrl<QURL, Qt2BC>(*lv, *this));
// reduce the number of connections needed in // reduce the number of connections needed in

View File

@ -17,6 +17,7 @@ DIALOGS = \
QSearch \ QSearch \
QSplash \ QSplash \
QTabularCreate \ QTabularCreate \
QThesaurus \
QToc \ QToc \
QURL QURL
@ -53,6 +54,8 @@ DIALOGSOURCES = \
QSplash.C QSplashDialog.C \ QSplash.C QSplashDialog.C \
QTabularCreate.h QTabularCreateDialog.h \ QTabularCreate.h QTabularCreateDialog.h \
QTabularCreate.C QTabularCreateDialog.C \ QTabularCreate.C QTabularCreateDialog.C \
QThesaurus.h QThesaurusDialog.h \
QThesaurus.C QThesaurusDialog.C \
QToc.h QTocDialog.h \ QToc.h QTocDialog.h \
QToc.C QTocDialog.C \ QToc.C QTocDialog.C \
QURL.h QURLDialog.h \ QURL.h QURLDialog.h \
@ -75,6 +78,7 @@ MOCDIALOGS = \
QSearchDialog_moc.C \ QSearchDialog_moc.C \
QSplashDialog_moc.C \ QSplashDialog_moc.C \
QTabularCreateDialog_moc.C \ QTabularCreateDialog_moc.C \
QThesaurusDialog_moc.C \
QTocDialog_moc.C \ QTocDialog_moc.C \
QURLDialog_moc.C QURLDialog_moc.C
@ -109,6 +113,8 @@ UIDIALOGS = \
QSearchDialogBase.C \ QSearchDialogBase.C \
QTabularCreateDialogBase.h \ QTabularCreateDialogBase.h \
QTabularCreateDialogBase.C \ QTabularCreateDialogBase.C \
QThesaurusDialogBase.h \
QThesaurusDialogBase.C \
QTocDialogBase.h \ QTocDialogBase.h \
QTocDialogBase.C \ QTocDialogBase.C \
QURLDialogBase.h \ QURLDialogBase.h \
@ -130,5 +136,6 @@ UIMOCDIALOGS = \
QRefDialogBase_moc.C \ QRefDialogBase_moc.C \
QSearchDialogBase_moc.C \ QSearchDialogBase_moc.C \
QTabularCreateDialogBase_moc.C \ QTabularCreateDialogBase_moc.C \
QThesaurusDialogBase_moc.C \
QTocDialogBase_moc.C \ QTocDialogBase_moc.C \
QURLDialogBase_moc.C QURLDialogBase_moc.C

View File

@ -0,0 +1,49 @@
/**
* \file QThesaurus.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#include "ControlThesaurus.h"
#include "QThesaurusDialog.h"
#include "QThesaurus.h"
#include "Qt2BC.h"
#include "gettext.h"
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlistbox.h>
typedef Qt2CB<ControlThesaurus, Qt2DB<QThesaurusDialog> > 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());
}

View File

@ -0,0 +1,38 @@
// -*- C++ -*-
/**
* \file QThesaurus.h
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QTHESAURUS_H
#define QTHESAURUS_H
#include "Qt2Base.h"
class ControlThesaurus;
class QThesaurusDialog;
class QThesaurus :
public Qt2CB<ControlThesaurus, Qt2DB<QThesaurusDialog> >
{
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

View File

@ -0,0 +1,93 @@
/**
* \file QThesaurusDialog.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#include <vector>
#include "LString.h"
#include "ControlThesaurus.h"
#include "QThesaurusDialog.h"
#include "Dialogs.h"
#include "QThesaurus.h"
#include <qwidget.h>
#include <qpushbutton.h>
#include <qlistbox.h>
#include <qlineedit.h>
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<string> matches;
matches = control.getNouns(entry);
for (std::vector<string>::const_iterator cit = matches.begin();
cit != matches.end(); ++cit)
nounsLB->insertItem(cit->c_str());
matches = control.getVerbs(entry);
for (std::vector<string>::const_iterator cit = matches.begin();
cit != matches.end(); ++cit)
verbsLB->insertItem(cit->c_str());
matches = control.getAdjectives(entry);
for (std::vector<string>::const_iterator cit = matches.begin();
cit != matches.end(); ++cit)
adjectivesLB->insertItem(cit->c_str());
matches = control.getAdverbs(entry);
for (std::vector<string>::const_iterator cit = matches.begin();
cit != matches.end(); ++cit)
adverbsLB->insertItem(cit->c_str());
matches = control.getOthers(entry);
for (std::vector<string>::const_iterator cit = matches.begin();
cit != matches.end(); ++cit)
otherLB->insertItem(cit->c_str());
}

View File

@ -0,0 +1,39 @@
/**
* \file QThesaurusDialog.h
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QTHESAURUSDIALOG_H
#define QTHESAURUSDIALOG_H
#include <config.h>
#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

View File

@ -0,0 +1,479 @@
<!DOCTYPE UI><UI>
<class>QThesaurusDialogBase</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>QThesaurusDialogBase</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
<width>490</width>
<height>442</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Thesaurus</string>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout4</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>entryLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Keyword</string>
</property>
<property>
<name>buddy</name>
<cstring>entryED</cstring>
</property>
<property>
<name>toolTip</name>
<string>Index entry</string>
</property>
</widget>
<widget>
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>entryED</cstring>
</property>
<property>
<name>toolTip</name>
<string>Entry</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer2</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<widget>
<class>QTabWidget</class>
<property stdset="1">
<name>name</name>
<cstring>TabWidget2</cstring>
</property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>&amp;Nouns</string>
</attribute>
<hbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QListBox</class>
<property stdset="1">
<name>name</name>
<cstring>nounsLB</cstring>
</property>
<property stdset="1">
<name>columnMode</name>
<enum>FitToHeight</enum>
</property>
<property>
<name>toolTip</name>
<string>Matching nouns</string>
</property>
</widget>
</hbox>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>&amp;Verbs</string>
</attribute>
<hbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QListBox</class>
<item>
<property>
<name>text</name>
<string>New Item</string>
</property>
</item>
<property stdset="1">
<name>name</name>
<cstring>verbsLB</cstring>
</property>
<property stdset="1">
<name>columnMode</name>
<enum>FitToHeight</enum>
</property>
</widget>
</hbox>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>&amp;Adjectives</string>
</attribute>
<hbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QListBox</class>
<item>
<property>
<name>text</name>
<string>New Item</string>
</property>
</item>
<property stdset="1">
<name>name</name>
<cstring>adjectivesLB</cstring>
</property>
<property stdset="1">
<name>columnMode</name>
<enum>FitToHeight</enum>
</property>
</widget>
</hbox>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>A&amp;dverbs</string>
</attribute>
<hbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QListBox</class>
<item>
<property>
<name>text</name>
<string>New Item</string>
</property>
</item>
<property stdset="1">
<name>name</name>
<cstring>adverbsLB</cstring>
</property>
<property stdset="1">
<name>columnMode</name>
<enum>FitToHeight</enum>
</property>
</widget>
</hbox>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>&amp;Other</string>
</attribute>
<hbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QListBox</class>
<item>
<property>
<name>text</name>
<string>New Item</string>
</property>
</item>
<property stdset="1">
<name>name</name>
<cstring>otherLB</cstring>
</property>
<property stdset="1">
<name>columnMode</name>
<enum>FitToHeight</enum>
</property>
</widget>
</hbox>
</widget>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout5</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>selectionLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Selection</string>
</property>
<property>
<name>buddy</name>
<cstring>selectionED</cstring>
</property>
<property>
<name>toolTip</name>
<string>The selected entry</string>
</property>
</widget>
<widget>
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>replaceED</cstring>
</property>
<property>
<name>toolTip</name>
<string>The selected entry</string>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>replacePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Replace</string>
</property>
<property>
<name>toolTip</name>
<string>Replace the entry with the selection</string>
</property>
</widget>
</hbox>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout27</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<spacer>
<property>
<name>name</name>
<cstring>Spacer3</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>closePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Close</string>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
<connections>
<connection>
<sender>replaceED</sender>
<signal>returnPressed()</signal>
<receiver>QThesaurusDialogBase</receiver>
<slot>replaceClicked()</slot>
</connection>
<connection>
<sender>replaceED</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>QThesaurusDialogBase</receiver>
<slot>change_adaptor()</slot>
</connection>
<connection>
<sender>nounsLB</sender>
<signal>selected(const QString&amp;)</signal>
<receiver>QThesaurusDialogBase</receiver>
<slot>selectionChanged(const QString &amp;)</slot>
</connection>
<connection>
<sender>verbsLB</sender>
<signal>selected(const QString&amp;)</signal>
<receiver>QThesaurusDialogBase</receiver>
<slot>selectionChanged(const QString &amp;)</slot>
</connection>
<connection>
<sender>adjectivesLB</sender>
<signal>selected(const QString&amp;)</signal>
<receiver>QThesaurusDialogBase</receiver>
<slot>selectionChanged(const QString &amp;)</slot>
</connection>
<connection>
<sender>adverbsLB</sender>
<signal>selected(const QString&amp;)</signal>
<receiver>QThesaurusDialogBase</receiver>
<slot>selectionChanged(const QString &amp;)</slot>
</connection>
<connection>
<sender>otherLB</sender>
<signal>selected(const QString&amp;)</signal>
<receiver>QThesaurusDialogBase</receiver>
<slot>selectionChanged(const QString &amp;)</slot>
</connection>
<connection>
<sender>entryED</sender>
<signal>returnPressed()</signal>
<receiver>QThesaurusDialogBase</receiver>
<slot>entryChanged()</slot>
</connection>
<connection>
<sender>replacePB</sender>
<signal>clicked()</signal>
<receiver>QThesaurusDialogBase</receiver>
<slot>replaceClicked()</slot>
</connection>
<slot access="public">change_adaptor()</slot>
<slot access="public">entryChanged()</slot>
<slot access="public">replaceClicked()</slot>
<slot access="public">selectionChanged(const QString &amp;)</slot>
</connections>
<tabstops>
<tabstop>TabWidget2</tabstop>
<tabstop>entryED</tabstop>
<tabstop>nounsLB</tabstop>
<tabstop>verbsLB</tabstop>
<tabstop>adjectivesLB</tabstop>
<tabstop>adverbsLB</tabstop>
<tabstop>otherLB</tabstop>
<tabstop>replaceED</tabstop>
<tabstop>replacePB</tabstop>
<tabstop>closePB</tabstop>
</tabstops>
</UI>