less functions

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20216 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-09-11 17:06:15 +00:00
parent 63a190ef49
commit 34492a9d03
38 changed files with 74 additions and 116 deletions

View File

@ -184,7 +184,7 @@ void Dialogs::updateBufferDependent(bool switched) const
// A bit clunky, but the dialog will request // A bit clunky, but the dialog will request
// that the kernel provides it with the necessary // that the kernel provides it with the necessary
// data. // data.
dialog->RestoreButton(); dialog->slotRestore();
} }
} }
} }

View File

@ -60,18 +60,18 @@ namespace frontend {
ControlSpellchecker::ControlSpellchecker(Dialog & parent) ControlSpellchecker::ControlSpellchecker(Dialog & parent)
: Controller(parent), exitEarly_(false), : Controller(parent), exitEarly_(false),
oldval_(0), newvalue_(0), count_(0) oldval_(0), newvalue_(0), count_(0), speller_(0)
{ {
} }
ControlSpellchecker::~ControlSpellchecker() ControlSpellchecker::~ControlSpellchecker()
{} {
delete speller_;
}
namespace { static SpellBase * getSpeller(BufferParams const & bp)
SpellBase * getSpeller(BufferParams const & bp)
{ {
string lang = (lyxrc.isp_use_alt_lang) string lang = (lyxrc.isp_use_alt_lang)
? lyxrc.isp_alt_lang ? lyxrc.isp_alt_lang
@ -86,7 +86,7 @@ SpellBase * getSpeller(BufferParams const & bp)
#endif #endif
#if defined(USE_ISPELL) #if defined(USE_ISPELL)
lang = (lyxrc.isp_use_alt_lang) ? lang = lyxrc.isp_use_alt_lang ?
lyxrc.isp_alt_lang : bp.language->lang(); lyxrc.isp_alt_lang : bp.language->lang();
return new ISpell(bp, lang); return new ISpell(bp, lang);
@ -95,15 +95,13 @@ SpellBase * getSpeller(BufferParams const & bp)
#endif #endif
} }
} // namespace anon
bool ControlSpellchecker::initialiseParams(std::string const &) bool ControlSpellchecker::initialiseParams(std::string const &)
{ {
LYXERR(Debug::GUI) << "Spellchecker::initialiseParams" << endl; LYXERR(Debug::GUI) << "Spellchecker::initialiseParams" << endl;
speller_.reset(getSpeller(buffer().params())); speller_ = getSpeller(buffer().params());
if (!speller_.get()) if (!speller_)
return false; return false;
// reset values to initial // reset values to initial
@ -117,7 +115,8 @@ bool ControlSpellchecker::initialiseParams(std::string const &)
Alert::error(_("Spellchecker error"), Alert::error(_("Spellchecker error"),
_("The spellchecker could not be started\n") _("The spellchecker could not be started\n")
+ speller_->error()); + speller_->error());
speller_.reset(0); delete speller_;
speller_ = 0;
} }
return success; return success;
@ -127,26 +126,25 @@ bool ControlSpellchecker::initialiseParams(std::string const &)
void ControlSpellchecker::clearParams() void ControlSpellchecker::clearParams()
{ {
LYXERR(Debug::GUI) << "Spellchecker::clearParams" << endl; LYXERR(Debug::GUI) << "Spellchecker::clearParams" << endl;
speller_.reset(0); delete speller_;
speller_ = 0;
} }
namespace { static bool isLetter(DocIterator const & dit)
bool isLetter(DocIterator const & dit)
{ {
return dit.inTexted() return dit.inTexted()
&& dit.inset().allowSpellCheck() && dit.inset().allowSpellCheck()
&& dit.pos() != dit.lastpos() && dit.pos() != dit.lastpos()
&& (dit.paragraph().isLetter(dit.pos()) && (dit.paragraph().isLetter(dit.pos())
// We want to pass the ' and escape chars to ispell // We want to pass the ' and escape chars to ispell
|| contains(lyx::from_utf8(lyxrc.isp_esc_chars + '\''), || contains(from_utf8(lyxrc.isp_esc_chars + '\''),
dit.paragraph().getChar(dit.pos()))) dit.paragraph().getChar(dit.pos())))
&& !dit.paragraph().isDeleted(dit.pos()); && !dit.paragraph().isDeleted(dit.pos());
} }
WordLangTuple nextWord(Cursor & cur, ptrdiff_t & progress) static WordLangTuple nextWord(Cursor & cur, ptrdiff_t & progress)
{ {
BufferParams const & bp = cur.bv().buffer().params(); BufferParams const & bp = cur.bv().buffer().params();
bool inword = false; bool inword = false;
@ -178,7 +176,7 @@ WordLangTuple nextWord(Cursor & cur, ptrdiff_t & progress)
if (!word.empty() && !ignoreword) { if (!word.empty() && !ignoreword) {
cur.setSelection(); cur.setSelection();
return WordLangTuple(word, lang_code); return WordLangTuple(word, lang_code);
} else }
inword = false; inword = false;
} }
@ -189,9 +187,6 @@ WordLangTuple nextWord(Cursor & cur, ptrdiff_t & progress)
return WordLangTuple(docstring(), string()); return WordLangTuple(docstring(), string());
} }
} // namespace anon
void ControlSpellchecker::check() void ControlSpellchecker::check()
{ {
@ -200,11 +195,11 @@ void ControlSpellchecker::check()
SpellBase::Result res = SpellBase::OK; SpellBase::Result res = SpellBase::OK;
Cursor cur = bufferview()->cursor(); Cursor cur = bufferview()->cursor();
while (cur && cur.pos() && isLetter(cur)) { while (cur && cur.pos() && isLetter(cur))
cur.backwardPos(); cur.backwardPos();
}
ptrdiff_t start = 0, total = 0; ptrdiff_t start = 0;
ptrdiff_t total = 0;
DocIterator it = DocIterator(buffer().inset()); DocIterator it = DocIterator(buffer().inset());
for (start = 0; it != cur; it.forwardPos()) for (start = 0; it != cur; it.forwardPos())
++start; ++start;
@ -278,7 +273,7 @@ bool ControlSpellchecker::checkAlive()
else else
message = _("The spellchecker has failed.\n") + speller_->error(); message = _("The spellchecker has failed.\n") + speller_->error();
dialog().CancelButton(); dialog().slotClose();
Alert::error(_("The spellchecker has failed"), message); Alert::error(_("The spellchecker has failed"), message);
return false; return false;
@ -288,7 +283,7 @@ bool ControlSpellchecker::checkAlive()
void ControlSpellchecker::showSummary() void ControlSpellchecker::showSummary()
{ {
if (!checkAlive() || count_ == 0) { if (!checkAlive() || count_ == 0) {
dialog().CancelButton(); dialog().slotClose();
return; return;
} }
@ -298,7 +293,7 @@ void ControlSpellchecker::showSummary()
else else
message = _("One word checked."); message = _("One word checked.");
dialog().CancelButton(); dialog().slotClose();
Alert::information(_("Spelling check completed"), message); Alert::information(_("Spelling check completed"), message);
} }

View File

@ -14,7 +14,7 @@
#include "Dialog.h" #include "Dialog.h"
#include "WordLangTuple.h" #include "WordLangTuple.h"
#include <boost/scoped_ptr.hpp>
namespace lyx { namespace lyx {
@ -24,7 +24,8 @@ namespace frontend {
/** A controller for Spellchecker dialogs. /** A controller for Spellchecker dialogs.
*/ */
class ControlSpellchecker : public Controller { class ControlSpellchecker : public Controller
{
public: public:
enum State { enum State {
SPELL_PROGRESSED, //< update progress bar SPELL_PROGRESSED, //< update progress bar
@ -94,7 +95,7 @@ private:
int count_; int count_;
/// The actual spellchecker object /// The actual spellchecker object
boost::scoped_ptr<SpellBase> speller_; SpellBase * speller_;
}; };
} // namespace frontend } // namespace frontend

View File

@ -71,10 +71,10 @@ public:
virtual void hide() {} virtual void hide() {}
// Override in GuiDialog // Override in GuiDialog
virtual void OkButton() {} virtual void slotOK() {}
virtual void ApplyButton() {} virtual void slotApply() {}
virtual void CancelButton() {} virtual void slotRestore() {}
virtual void RestoreButton() {} virtual void slotClose() {}
/** This function is called, for example, if the GUI colours /** This function is called, for example, if the GUI colours
* have been changed. * have been changed.

View File

@ -4510,7 +4510,7 @@
No longer passed ControlButtons & or Dialogs &. No longer passed ControlButtons & or Dialogs &.
(bc): new method, enabling the daughter classes to access the (bc): new method, enabling the daughter classes to access the
ButtonController. ButtonController.
(slotWMHide): (slotClose):
(slotApply): (slotApply):
(slotOK): (slotOK):
(slotClose): (slotClose):

View File

@ -60,7 +60,7 @@ void GuiBibitemDialog::change_adaptor()
void GuiBibitemDialog::closeEvent(QCloseEvent *e) void GuiBibitemDialog::closeEvent(QCloseEvent *e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -245,7 +245,7 @@ void GuiBibtexDialog::availableChanged()
void GuiBibtexDialog::closeEvent(QCloseEvent *e) void GuiBibtexDialog::closeEvent(QCloseEvent *e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -120,7 +120,7 @@ ControlBox & GuiBoxDialog::controller() const
void GuiBoxDialog::closeEvent(QCloseEvent * e) void GuiBoxDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -51,7 +51,7 @@ ControlBranch & GuiBranchDialog::controller() const
void GuiBranchDialog::closeEvent(QCloseEvent * e) void GuiBranchDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -54,7 +54,7 @@ ControlChanges & GuiChangesDialog::controller() const
void GuiChangesDialog::closeEvent(QCloseEvent *e) void GuiChangesDialog::closeEvent(QCloseEvent *e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -136,7 +136,7 @@ void GuiCharacterDialog::change_adaptor()
void GuiCharacterDialog::closeEvent(QCloseEvent * e) void GuiCharacterDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -45,14 +45,14 @@ void GuiDialog::setButtonsValid(bool valid)
} }
void GuiDialog::ApplyButton() void GuiDialog::slotApply()
{ {
apply(); apply();
bc().apply(); bc().apply();
} }
void GuiDialog::OKButton() void GuiDialog::slotOK()
{ {
is_closing_ = true; is_closing_ = true;
apply(); apply();
@ -62,14 +62,14 @@ void GuiDialog::OKButton()
} }
void GuiDialog::CancelButton() void GuiDialog::slotClose()
{ {
QDialog::hide(); QDialog::hide();
bc().cancel(); bc().cancel();
} }
void GuiDialog::RestoreButton() void GuiDialog::slotRestore()
{ {
// Tell the controller that a request to refresh the dialog's contents // Tell the controller that a request to refresh the dialog's contents
// has been received. It's up to the controller to supply the necessary // has been received. It's up to the controller to supply the necessary
@ -154,36 +154,6 @@ void GuiDialog::changed()
} }
void GuiDialog::slotWMHide()
{
CancelButton();
}
void GuiDialog::slotApply()
{
ApplyButton();
}
void GuiDialog::slotOK()
{
OKButton();
}
void GuiDialog::slotClose()
{
CancelButton();
}
void GuiDialog::slotRestore()
{
RestoreButton();
}
void GuiDialog::updateView() void GuiDialog::updateView()
{ {
setUpdatesEnabled(false); setUpdatesEnabled(false);

View File

@ -36,28 +36,20 @@ public:
~GuiDialog(); ~GuiDialog();
public Q_SLOTS: public Q_SLOTS:
// dialog closed from WM /** \name Buttons
void slotWMHide(); * These methods are publicly accessible because they are invoked
* by the View when the user presses... guess what ;-)
*/
// Restore button clicked // Restore button clicked
void slotRestore(); void slotRestore();
// OK button clicked // OK button clicked
void slotOK(); void slotOK();
// Apply button clicked // Apply button clicked
void slotApply(); void slotApply();
// Close button clicked // Close button clicked or closed from WindowManager
void slotClose(); void slotClose();
public: public:
/** \name Buttons
* These methods are publicly accessible because they are invoked
* by the View when the user presses... guess what ;-)
*/
//@{
void ApplyButton();
void OKButton();
void CancelButton();
void RestoreButton();
//@}
/** Check whether we may apply our data. /** Check whether we may apply our data.
* *

View File

@ -682,7 +682,7 @@ void GuiDocumentDialog::set_listings_msg()
void GuiDocumentDialog::closeEvent(QCloseEvent * e) void GuiDocumentDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -48,7 +48,7 @@ ControlERT & GuiERTDialog::controller() const
void GuiERTDialog::closeEvent(QCloseEvent * e) void GuiERTDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -57,7 +57,7 @@ void GuiErrorListDialog::select_adaptor(QListWidgetItem * item)
void GuiErrorListDialog::closeEvent(QCloseEvent * e) void GuiErrorListDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -248,7 +248,7 @@ void GuiExternalDialog::change_adaptor()
void GuiExternalDialog::closeEvent(QCloseEvent * e) void GuiExternalDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -68,7 +68,7 @@ void GuiFloatDialog::change_adaptor()
void GuiFloatDialog::closeEvent(QCloseEvent * e) void GuiFloatDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -234,7 +234,7 @@ void GuiGraphicsDialog::change_bb()
void GuiGraphicsDialog::closeEvent(QCloseEvent * e) void GuiGraphicsDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -128,7 +128,7 @@ void GuiIncludeDialog::set_listings_msg()
void GuiIncludeDialog::closeEvent(QCloseEvent * e) void GuiIncludeDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -95,7 +95,7 @@ void GuiIndexDialogBase::reject()
void GuiIndexDialogBase::closeEvent(QCloseEvent * e) void GuiIndexDialogBase::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -253,7 +253,7 @@ ControlListings & GuiListingsDialog::controller() const
void GuiListingsDialog::closeEvent(QCloseEvent * e) void GuiListingsDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -125,7 +125,7 @@ ControlLog & GuiLogDialog::controller() const
void GuiLogDialog::closeEvent(QCloseEvent * e) void GuiLogDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -73,7 +73,7 @@ void GuiNomenclDialog::reject()
void GuiNomenclDialog::closeEvent(QCloseEvent * e) void GuiNomenclDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -50,7 +50,7 @@ ControlNote & GuiNoteDialog::controller() const
void GuiNoteDialog::closeEvent(QCloseEvent * e) void GuiNoteDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -100,7 +100,7 @@ ControlParagraph & GuiParagraphDialog::controller() const
void GuiParagraphDialog::closeEvent(QCloseEvent * e) void GuiParagraphDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -1976,7 +1976,7 @@ void GuiPrefsDialog::add(PrefModule * module)
void GuiPrefsDialog::closeEvent(QCloseEvent * e) void GuiPrefsDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -181,7 +181,7 @@ void GuiRefDialog::reset_dialog()
void GuiRefDialog::closeEvent(QCloseEvent * e) void GuiRefDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
reset_dialog(); reset_dialog();
e->accept(); e->accept();
} }

View File

@ -78,7 +78,7 @@ void GuiSearchDialog::showView()
void GuiSearchDialog::closeEvent(QCloseEvent * e) void GuiSearchDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -69,7 +69,7 @@ void GuiSendtoDialog::changed_adaptor()
void GuiSendtoDialog::closeEvent(QCloseEvent * e) void GuiSendtoDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -45,7 +45,7 @@ ControlShowFile & GuiShowFileDialog::controller() const
void GuiShowFileDialog::closeEvent(QCloseEvent * e) void GuiShowFileDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -119,14 +119,14 @@ void GuiSpellcheckerDialog::replaceChanged(const QString & str)
void GuiSpellcheckerDialog::closeEvent(QCloseEvent * e) void GuiSpellcheckerDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }
void GuiSpellcheckerDialog::reject() void GuiSpellcheckerDialog::reject()
{ {
slotWMHide(); slotClose();
QDialog::reject(); QDialog::reject();
} }

View File

@ -162,7 +162,7 @@ void GuiTabularDialog::change_adaptor()
void GuiTabularDialog::closeEvent(QCloseEvent * e) void GuiTabularDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -74,7 +74,7 @@ void GuiTexinfoDialog::change_adaptor()
void GuiTexinfoDialog::closeEvent(QCloseEvent * e) void GuiTexinfoDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -77,7 +77,7 @@ void GuiThesaurusDialog::change_adaptor()
void GuiThesaurusDialog::closeEvent(QCloseEvent * e) void GuiThesaurusDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -65,7 +65,7 @@ void GuiURLDialog::changed_adaptor()
void GuiURLDialog::closeEvent(QCloseEvent * e) void GuiURLDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -95,7 +95,7 @@ ControlVSpace & GuiVSpaceDialog::controller() const
void GuiVSpaceDialog::closeEvent(QCloseEvent * e) void GuiVSpaceDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }

View File

@ -70,7 +70,7 @@ ControlWrap & GuiWrapDialog::controller() const
void GuiWrapDialog::closeEvent(QCloseEvent * e) void GuiWrapDialog::closeEvent(QCloseEvent * e)
{ {
slotWMHide(); slotClose();
e->accept(); e->accept();
} }