merge QSpellChecker and QSpellcheckerDialog

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17953 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-04-24 15:32:14 +00:00
parent 735934a376
commit 2c7f20e2ec
6 changed files with 138 additions and 166 deletions

View File

@ -70,7 +70,6 @@ libqt4_la_SOURCES = \
QRef.C QRef.h \
QSendto.C QSendto.h \
QShowFile.C QShowFile.h \
QSpellchecker.C QSpellchecker.h \
QTabular.C QTabular.h \
QTabularCreate.C QTabularCreate.h \
Qt2BC.C Qt2BC.h \

View File

@ -122,7 +122,7 @@ MOCFILES = \
QSendtoDialog.C QSendtoDialog.h \
qsetborder.C qsetborder.h \
QShowFileDialog.C QShowFileDialog.h \
QSpellcheckerDialog.C QSpellcheckerDialog.h \
QSpellchecker.C QSpellchecker.h \
QDialogView.C QDialogView.h \
QTabularCreateDialog.C QTabularCreateDialog.h \
QTabularDialog.C QTabularDialog.h \

View File

@ -11,7 +11,6 @@
#include <config.h>
#include "QSpellchecker.h"
#include "QSpellcheckerDialog.h"
#include "Qt2BC.h"
#include "qt_helpers.h"
@ -22,16 +21,118 @@
#include <QPushButton>
#include <QListWidget>
#include <QListWidgetItem>
#include <QCloseEvent>
#include <QSyntaxHighlighter>
#include <QTextCharFormat>
#include <QTextDocument>
using std::string;
namespace lyx {
namespace frontend {
typedef QController<ControlSpellchecker, QView<QSpellcheckerDialog> > spellchecker_base_class;
/////////////////////////////////////////////////////////////////////
//
// QSpellCheckerDialog
//
/////////////////////////////////////////////////////////////////////
QSpellcheckerDialog::QSpellcheckerDialog(QSpellchecker * form)
: form_(form)
{
setupUi(this);
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
connect(replaceCO, SIGNAL(highlighted(const QString &)),
this, SLOT(replaceChanged(const QString &)));
connect(replacePB, SIGNAL(clicked()),
this, SLOT(replaceClicked()));
connect(ignorePB, SIGNAL(clicked()),
this, SLOT(ignoreClicked()));
connect(replacePB_3, SIGNAL(clicked()),
this, SLOT(acceptClicked()));
connect(addPB, SIGNAL(clicked()),
this, SLOT(addClicked()));
connect(suggestionsLW, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(replaceClicked() ) );
connect(suggestionsLW, SIGNAL(itemClicked(QListWidgetItem*)),
this, SLOT(suggestionChanged(QListWidgetItem*)));
}
void QSpellcheckerDialog::acceptClicked()
{
form_->accept();
}
void QSpellcheckerDialog::addClicked()
{
form_->add();
}
void QSpellcheckerDialog::replaceClicked()
{
form_->replace();
}
void QSpellcheckerDialog::ignoreClicked()
{
form_->ignore();
}
void QSpellcheckerDialog::suggestionChanged(QListWidgetItem * item)
{
if (replaceCO->count() != 0)
replaceCO->setItemText(0, item->text());
else
replaceCO->addItem(item->text());
replaceCO->setCurrentIndex(0);
}
void QSpellcheckerDialog::replaceChanged(const QString & str)
{
if (suggestionsLW->currentItem()->text() == str)
return;
for (int i = 0; i < suggestionsLW->count(); ++i) {
if (suggestionsLW->item(i)->text() == str) {
suggestionsLW->setCurrentRow(i);
break;
}
}
}
void QSpellcheckerDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
e->accept();
}
void QSpellcheckerDialog::reject()
{
form_->slotWMHide();
QDialog::reject();
}
/////////////////////////////////////////////////////////////////////
//
// QSpellChecker
//
/////////////////////////////////////////////////////////////////////
typedef QController<ControlSpellchecker, QView<QSpellcheckerDialog> >
SpellcheckerBase;
QSpellchecker::QSpellchecker(Dialog & parent)
: spellchecker_base_class(parent, _("Spellchecker"))
: SpellcheckerBase(parent, _("Spellchecker"))
{}
@ -110,3 +211,5 @@ void QSpellchecker::partialUpdate(int s)
} // namespace frontend
} // namespace lyx
#include "QSpellchecker_moc.cpp"

View File

@ -14,11 +14,41 @@
#define QSPELLCHECKER_H
#include "QDialogView.h"
#include "QSpellcheckerDialog.h"
#include "ui/SpellcheckerUi.h"
#include <QDialog>
#include <QCloseEvent>
class QListWidgetItem;
namespace lyx {
namespace frontend {
class QSpellchecker;
class QSpellcheckerDialog: public QDialog, public Ui::QSpellcheckerUi {
Q_OBJECT
public:
QSpellcheckerDialog(QSpellchecker * form);
public Q_SLOTS:
virtual void suggestionChanged(QListWidgetItem *);
protected Q_SLOTS:
virtual void acceptClicked();
virtual void addClicked();
virtual void replaceClicked();
virtual void ignoreClicked();
virtual void replaceChanged(const QString &);
virtual void reject();
protected:
virtual void closeEvent(QCloseEvent * e);
private:
QSpellchecker * form_;
};
class ControlSpellchecker;
class QSpellchecker

View File

@ -1,108 +0,0 @@
/**
* \file QSpellcheckerDialog.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author John Levon
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "QSpellcheckerDialog.h"
#include "QSpellchecker.h"
#include <QListWidget>
#include <QPushButton>
#include <QCloseEvent>
namespace lyx {
namespace frontend {
QSpellcheckerDialog::QSpellcheckerDialog(QSpellchecker * form)
: form_(form)
{
setupUi(this);
connect(closePB, SIGNAL(clicked()),
form, SLOT(slotClose()));
connect( replaceCO, SIGNAL( highlighted(const QString&) ),
this, SLOT( replaceChanged(const QString &) ) );
connect( replacePB, SIGNAL( clicked() ),
this, SLOT( replaceClicked() ) );
connect( ignorePB, SIGNAL( clicked() ),
this, SLOT( ignoreClicked() ) );
connect( replacePB_3, SIGNAL( clicked() ),
this, SLOT( acceptClicked() ) );
connect( addPB, SIGNAL( clicked() ),
this, SLOT( addClicked() ) );
connect( suggestionsLW, SIGNAL( itemDoubleClicked(QListWidgetItem*) ),
this, SLOT( replaceClicked() ) );
connect( suggestionsLW, SIGNAL( itemClicked(QListWidgetItem*) ),
this, SLOT( suggestionChanged(QListWidgetItem*) ) );
}
void QSpellcheckerDialog::acceptClicked()
{
form_->accept();
}
void QSpellcheckerDialog::addClicked()
{
form_->add();
}
void QSpellcheckerDialog::replaceClicked()
{
form_->replace();
}
void QSpellcheckerDialog::ignoreClicked()
{
form_->ignore();
}
void QSpellcheckerDialog::suggestionChanged(QListWidgetItem * item)
{
if (replaceCO->count() != 0)
replaceCO->setItemText(0, item->text());
else
replaceCO->addItem(item->text());
replaceCO->setCurrentIndex(0);
}
void QSpellcheckerDialog::replaceChanged(const QString & str)
{
if (suggestionsLW->currentItem()->text() == str)
return;
for (int i = 0; i < suggestionsLW->count(); ++i) {
if (suggestionsLW->item(i)->text() == str) {
suggestionsLW->setCurrentRow(i);
break;
}
}
}
void QSpellcheckerDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
e->accept();
}
void QSpellcheckerDialog::reject()
{
form_->slotWMHide();
QDialog::reject();
}
} // namespace frontend
} // namespace lyx
#include "QSpellcheckerDialog_moc.cpp"

View File

@ -1,52 +0,0 @@
// -*- C++ -*-
/**
* \file QSpellcheckerDialog.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author John Levon
*
* Full author contact details are available in file CREDITS.
*/
#ifndef QSPELLCHECKERDIALOG_H
#define QSPELLCHECKERDIALOG_H
#include "ui/SpellcheckerUi.h"
#include <QDialog>
#include <QCloseEvent>
class QListWidgetItem;
namespace lyx {
namespace frontend {
class QSpellchecker;
class QSpellcheckerDialog: public QDialog, public Ui::QSpellcheckerUi {
Q_OBJECT
public:
QSpellcheckerDialog(QSpellchecker * form);
public Q_SLOTS:
virtual void suggestionChanged(QListWidgetItem *);
protected Q_SLOTS:
virtual void acceptClicked();
virtual void addClicked();
virtual void replaceClicked();
virtual void ignoreClicked();
virtual void replaceChanged(const QString &);
virtual void reject();
protected:
virtual void closeEvent(QCloseEvent * e);
private:
QSpellchecker * form_;
};
} // namespace frontend
} // namespace lyx
#endif // QSPELLCHECKERDIALOG_H