mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
next one
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20798 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e093f9212b
commit
bb1c76d479
@ -35,11 +35,6 @@
|
|||||||
#include "TocWidget.h"
|
#include "TocWidget.h"
|
||||||
#include "GuiURL.h"
|
#include "GuiURL.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBAIKSAURUS
|
|
||||||
#include "ControlThesaurus.h"
|
|
||||||
#include "GuiThesaurus.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Uncomment this if you prefer dock widget
|
// Uncomment this if you prefer dock widget
|
||||||
//#define USE_DOCK_WIDGET
|
//#define USE_DOCK_WIDGET
|
||||||
|
|
||||||
@ -220,7 +215,7 @@ Dialog * Dialogs::build(string const & name)
|
|||||||
return createGuiTexInfo(lyxview_);
|
return createGuiTexInfo(lyxview_);
|
||||||
#ifdef HAVE_LIBAIKSAURUS
|
#ifdef HAVE_LIBAIKSAURUS
|
||||||
if (name == "thesaurus")
|
if (name == "thesaurus")
|
||||||
return new GuiThesaurusDialog(lyxview_);
|
return createGuiThesaurus(lyxview_);
|
||||||
#endif
|
#endif
|
||||||
if (name == "toc") {
|
if (name == "toc") {
|
||||||
#ifdef Q_WS_MACX
|
#ifdef Q_WS_MACX
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "GuiThesaurus.h"
|
#include "GuiThesaurus.h"
|
||||||
|
|
||||||
#include "ControlThesaurus.h"
|
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
@ -23,18 +22,21 @@
|
|||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
|
|
||||||
|
#include "lyxfind.h"
|
||||||
|
#include "FuncRequest.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
GuiThesaurusDialog::GuiThesaurusDialog(LyXView & lv)
|
GuiThesaurus::GuiThesaurus(LyXView & lv)
|
||||||
: GuiDialog(lv, "thesaurus")
|
: GuiDialog(lv, "thesaurus"), Controller(this)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setViewTitle(_("Thesaurus"));
|
setViewTitle(_("Thesaurus"));
|
||||||
setController(new ControlThesaurus(*this));
|
setController(this, false);
|
||||||
|
|
||||||
meaningsTV->setColumnCount(1);
|
meaningsTV->setColumnCount(1);
|
||||||
meaningsTV->header()->hide();
|
meaningsTV->header()->hide();
|
||||||
@ -43,8 +45,8 @@ GuiThesaurusDialog::GuiThesaurusDialog(LyXView & lv)
|
|||||||
this, SLOT(slotClose()));
|
this, SLOT(slotClose()));
|
||||||
connect(replaceED, SIGNAL(returnPressed()),
|
connect(replaceED, SIGNAL(returnPressed()),
|
||||||
this, SLOT(replaceClicked()));
|
this, SLOT(replaceClicked()));
|
||||||
connect(replaceED, SIGNAL(textChanged(const QString &)),
|
connect(replaceED, SIGNAL(textChanged(QString)),
|
||||||
this, SLOT(change_adaptor() ) );
|
this, SLOT(change_adaptor()));
|
||||||
connect(entryED, SIGNAL(returnPressed()),
|
connect(entryED, SIGNAL(returnPressed()),
|
||||||
this, SLOT(entryChanged()));
|
this, SLOT(entryChanged()));
|
||||||
connect(replacePB, SIGNAL(clicked()),
|
connect(replacePB, SIGNAL(clicked()),
|
||||||
@ -64,34 +66,29 @@ GuiThesaurusDialog::GuiThesaurusDialog(LyXView & lv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ControlThesaurus & GuiThesaurusDialog::controller()
|
void GuiThesaurus::change_adaptor()
|
||||||
{
|
|
||||||
return static_cast<ControlThesaurus &>(GuiDialog::controller());
|
|
||||||
}
|
|
||||||
|
|
||||||
void GuiThesaurusDialog::change_adaptor()
|
|
||||||
{
|
{
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiThesaurusDialog::closeEvent(QCloseEvent * e)
|
void GuiThesaurus::closeEvent(QCloseEvent * e)
|
||||||
{
|
{
|
||||||
slotClose();
|
slotClose();
|
||||||
GuiDialog::closeEvent(e);
|
GuiDialog::closeEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiThesaurusDialog::entryChanged()
|
void GuiThesaurus::entryChanged()
|
||||||
{
|
{
|
||||||
updateLists();
|
updateLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiThesaurusDialog::selectionChanged()
|
void GuiThesaurus::selectionChanged()
|
||||||
{
|
{
|
||||||
int const col = meaningsTV->currentColumn();
|
int const col = meaningsTV->currentColumn();
|
||||||
if (col < 0 || controller().isBufferReadonly())
|
if (col < 0 || isBufferReadonly())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
replaceED->setText(meaningsTV->currentItem()->text(col));
|
replaceED->setText(meaningsTV->currentItem()->text(col));
|
||||||
@ -100,13 +97,13 @@ void GuiThesaurusDialog::selectionChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiThesaurusDialog::itemClicked(QTreeWidgetItem * /*item*/, int /*col*/)
|
void GuiThesaurus::itemClicked(QTreeWidgetItem * /*item*/, int /*col*/)
|
||||||
{
|
{
|
||||||
selectionChanged();
|
selectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiThesaurusDialog::selectionClicked(QTreeWidgetItem * item, int col)
|
void GuiThesaurus::selectionClicked(QTreeWidgetItem * item, int col)
|
||||||
{
|
{
|
||||||
entryED->setText(item->text(col));
|
entryED->setText(item->text(col));
|
||||||
selectionChanged();
|
selectionChanged();
|
||||||
@ -114,12 +111,12 @@ void GuiThesaurusDialog::selectionClicked(QTreeWidgetItem * item, int col)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiThesaurusDialog::updateLists()
|
void GuiThesaurus::updateLists()
|
||||||
{
|
{
|
||||||
meaningsTV->clear();
|
meaningsTV->clear();
|
||||||
meaningsTV->setUpdatesEnabled(false);
|
meaningsTV->setUpdatesEnabled(false);
|
||||||
|
|
||||||
Thesaurus::Meanings meanings = controller().getMeanings(qstring_to_ucs4(entryED->text()));
|
Thesaurus::Meanings meanings = getMeanings(qstring_to_ucs4(entryED->text()));
|
||||||
|
|
||||||
for (Thesaurus::Meanings::const_iterator cit = meanings.begin();
|
for (Thesaurus::Meanings::const_iterator cit = meanings.begin();
|
||||||
cit != meanings.end(); ++cit) {
|
cit != meanings.end(); ++cit) {
|
||||||
@ -138,19 +135,60 @@ void GuiThesaurusDialog::updateLists()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiThesaurusDialog::updateContents()
|
void GuiThesaurus::updateContents()
|
||||||
{
|
{
|
||||||
entryED->setText(toqstr(controller().text()));
|
entryED->setText(toqstr(text_));
|
||||||
replaceED->setText("");
|
replaceED->setText("");
|
||||||
updateLists();
|
updateLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiThesaurusDialog::replaceClicked()
|
void GuiThesaurus::replaceClicked()
|
||||||
{
|
{
|
||||||
controller().replace(qstring_to_ucs4(replaceED->text()));
|
replace(qstring_to_ucs4(replaceED->text()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GuiThesaurus::initialiseParams(string const & data)
|
||||||
|
{
|
||||||
|
text_ = from_utf8(data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiThesaurus::clearParams()
|
||||||
|
{
|
||||||
|
text_.erase();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiThesaurus::replace(docstring const & newstr)
|
||||||
|
{
|
||||||
|
/* FIXME: this is not suitable ! We need to have a "lock"
|
||||||
|
* on a particular charpos in a paragraph that is broken on
|
||||||
|
* deletion/change !
|
||||||
|
*/
|
||||||
|
docstring const data =
|
||||||
|
replace2string(text_, newstr,
|
||||||
|
true, // case sensitive
|
||||||
|
true, // match word
|
||||||
|
false, // all words
|
||||||
|
true); // forward
|
||||||
|
dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Thesaurus::Meanings const & GuiThesaurus::getMeanings(docstring const & str)
|
||||||
|
{
|
||||||
|
if (str != laststr_)
|
||||||
|
meanings_ = thesaurus.lookup(str);
|
||||||
|
return meanings_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Dialog * createGuiThesaurus(LyXView & lv) { return new GuiThesaurus(lv); }
|
||||||
|
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#define GUITHESAURUS_H
|
#define GUITHESAURUS_H
|
||||||
|
|
||||||
#include "GuiDialog.h"
|
#include "GuiDialog.h"
|
||||||
#include "ControlThesaurus.h"
|
#include "Thesaurus.h"
|
||||||
#include "ui_ThesaurusUi.h"
|
#include "ui_ThesaurusUi.h"
|
||||||
|
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
@ -21,12 +21,12 @@ class QTreeWidgetItem;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
class GuiThesaurusDialog : public GuiDialog, public Ui::ThesaurusUi
|
class GuiThesaurus : public GuiDialog, public Ui::ThesaurusUi, public Controller
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GuiThesaurusDialog(LyXView & lv);
|
GuiThesaurus(LyXView & lv);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void change_adaptor();
|
void change_adaptor();
|
||||||
@ -39,11 +39,38 @@ private Q_SLOTS:
|
|||||||
private:
|
private:
|
||||||
void closeEvent(QCloseEvent * e);
|
void closeEvent(QCloseEvent * e);
|
||||||
/// parent controller
|
/// parent controller
|
||||||
ControlThesaurus & controller();
|
Controller & controller() { return *this; }
|
||||||
/// update
|
/// update
|
||||||
void updateContents();
|
void updateContents();
|
||||||
///
|
///
|
||||||
void updateLists();
|
void updateLists();
|
||||||
|
///
|
||||||
|
bool initialiseParams(std::string const & data);
|
||||||
|
///
|
||||||
|
void clearParams();
|
||||||
|
///
|
||||||
|
void dispatchParams() {}
|
||||||
|
///
|
||||||
|
bool isBufferDependent() const { return true; }
|
||||||
|
|
||||||
|
/// replace the particular string
|
||||||
|
void replace(docstring const & newstr);
|
||||||
|
|
||||||
|
/// get meanings
|
||||||
|
Thesaurus::Meanings const & getMeanings(docstring const & str);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// last string looked up
|
||||||
|
docstring laststr_;
|
||||||
|
|
||||||
|
/// entries for last string
|
||||||
|
Thesaurus::Meanings meanings_;
|
||||||
|
|
||||||
|
/// original string
|
||||||
|
docstring text_;
|
||||||
|
|
||||||
|
/// not needed.
|
||||||
|
void apply() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
Loading…
Reference in New Issue
Block a user