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
// that the kernel provides it with the necessary
// data.
dialog->RestoreButton();
dialog->slotRestore();
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -45,14 +45,14 @@ void GuiDialog::setButtonsValid(bool valid)
}
void GuiDialog::ApplyButton()
void GuiDialog::slotApply()
{
apply();
bc().apply();
}
void GuiDialog::OKButton()
void GuiDialog::slotOK()
{
is_closing_ = true;
apply();
@ -62,14 +62,14 @@ void GuiDialog::OKButton()
}
void GuiDialog::CancelButton()
void GuiDialog::slotClose()
{
QDialog::hide();
bc().cancel();
}
void GuiDialog::RestoreButton()
void GuiDialog::slotRestore()
{
// 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
@ -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()
{
setUpdatesEnabled(false);

View File

@ -36,28 +36,20 @@ public:
~GuiDialog();
public Q_SLOTS:
// dialog closed from WM
void slotWMHide();
/** \name Buttons
* These methods are publicly accessible because they are invoked
* by the View when the user presses... guess what ;-)
*/
// Restore button clicked
void slotRestore();
// OK button clicked
void slotOK();
// Apply button clicked
void slotApply();
// Close button clicked
// Close button clicked or closed from WindowManager
void slotClose();
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.
*

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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