mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-14 15:05:56 +00:00
Dialogs: discourage non const access to buffer() and bufferview().
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26620 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
03e76f0651
commit
53acfb8351
@ -106,25 +106,12 @@ KernelDocType Dialog::docType() const
|
||||
}
|
||||
|
||||
|
||||
BufferView * Dialog::bufferview()
|
||||
{
|
||||
return lyxview_->view();
|
||||
}
|
||||
|
||||
|
||||
BufferView const * Dialog::bufferview() const
|
||||
{
|
||||
return lyxview_->view();
|
||||
}
|
||||
|
||||
|
||||
Buffer & Dialog::buffer()
|
||||
{
|
||||
LASSERT(lyxview_->buffer(), /**/);
|
||||
return *lyxview_->buffer();
|
||||
}
|
||||
|
||||
|
||||
Buffer const & Dialog::buffer() const
|
||||
{
|
||||
LASSERT(lyxview_->buffer(), /**/);
|
||||
|
@ -251,10 +251,8 @@ public:
|
||||
GuiView & lyxview() { return *lyxview_; }
|
||||
GuiView const & lyxview() const { return *lyxview_; }
|
||||
|
||||
Buffer & buffer();
|
||||
Buffer const & buffer() const;
|
||||
|
||||
BufferView * bufferview();
|
||||
BufferView const * bufferview() const;
|
||||
//@}
|
||||
|
||||
|
@ -2216,7 +2216,7 @@ char const * GuiDocument::fontfamilies_gui[5] = {
|
||||
|
||||
bool GuiDocument::initialiseParams(string const &)
|
||||
{
|
||||
BufferView * view = bufferview();
|
||||
BufferView const * view = bufferview();
|
||||
if (!view) {
|
||||
bp_ = BufferParams();
|
||||
paramsToDialog(bp_);
|
||||
@ -2305,7 +2305,7 @@ void GuiDocument::dispatchParams()
|
||||
support::onlyPath(buffer().absFileName()));
|
||||
if (isLyXFilename(master_file.absFilename())) {
|
||||
Buffer * master = checkAndLoadLyXFile(master_file);
|
||||
buffer().setParent(master);
|
||||
const_cast<Buffer &>(buffer()).setParent(master);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2328,7 +2328,8 @@ void GuiDocument::dispatchParams()
|
||||
"assign branch"));
|
||||
}
|
||||
// FIXME: If we used an LFUN, we would not need those two lines:
|
||||
bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
|
||||
BufferView * bv = const_cast<BufferView *>(bufferview());
|
||||
bv->processUpdateFlags(Update::Force | Update::FitCursor);
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,7 +104,7 @@ bool GuiErrorList::goTo(int item)
|
||||
if (err.par_id == -1)
|
||||
return false;
|
||||
|
||||
Buffer & buf = buffer();
|
||||
Buffer const & buf = buffer();
|
||||
DocIterator dit = buf.getParFromID(err.par_id);
|
||||
|
||||
if (dit == doc_iterator_end(buf.inset())) {
|
||||
@ -121,9 +121,10 @@ bool GuiErrorList::goTo(int item)
|
||||
pos_type const start = min(err.pos_start, end);
|
||||
pos_type const range = end - start;
|
||||
dit.pos() = start;
|
||||
bufferview()->putSelectionAt(dit, range, false);
|
||||
BufferView * bv = const_cast<BufferView *>(bufferview());
|
||||
// FIXME: If we used an LFUN, we would not need this line:
|
||||
bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
|
||||
bv->putSelectionAt(dit, range, false);
|
||||
bv->processUpdateFlags(Update::Force | Update::FitCursor);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,10 @@ void GuiInfo::applyView()
|
||||
dispatch(FuncRequest(LFUN_INSET_MODIFY, argument));
|
||||
// FIXME: update the inset contents
|
||||
updateLabels(bufferview()->buffer());
|
||||
bufferview()->updateMetrics();
|
||||
bufferview()->buffer().changed();
|
||||
BufferView * bv = const_cast<BufferView *>(bufferview());
|
||||
bv->updateMetrics();
|
||||
bv->buffer().changed();
|
||||
bv->buffer().markDirty();
|
||||
}
|
||||
|
||||
|
||||
|
@ -372,11 +372,12 @@ void GuiSpellchecker::check()
|
||||
|
||||
int const size = cur.selEnd().pos() - cur.selBegin().pos();
|
||||
cur.pos() -= size;
|
||||
bufferview()->putSelectionAt(cur, size, false);
|
||||
BufferView * bv = const_cast<BufferView *>(bufferview());
|
||||
bv->putSelectionAt(cur, size, false);
|
||||
// FIXME: if we used a lfun like in find/replace, dispatch would do
|
||||
// that for us
|
||||
// FIXME: this Controller is very badly designed...
|
||||
bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
|
||||
bv->processUpdateFlags(Update::Force | Update::FitCursor);
|
||||
|
||||
// set suggestions
|
||||
if (res != SpellBase::OK && res != SpellBase::IGNORED_WORD) {
|
||||
@ -427,10 +428,11 @@ void GuiSpellchecker::replace(docstring const & replacement)
|
||||
{
|
||||
LYXERR(Debug::GUI, "GuiSpellchecker::replace("
|
||||
<< to_utf8(replacement) << ")");
|
||||
cap::replaceSelectionWithString(bufferview()->cursor(), replacement, true);
|
||||
buffer().markDirty();
|
||||
BufferView * bv = const_cast<BufferView *>(bufferview());
|
||||
cap::replaceSelectionWithString(bv->cursor(), replacement, true);
|
||||
bv->buffer().markDirty();
|
||||
// If we used an LFUN, we would not need that
|
||||
bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
|
||||
bv->processUpdateFlags(Update::Force | Update::FitCursor);
|
||||
// fix up the count
|
||||
--count_;
|
||||
check();
|
||||
|
@ -969,7 +969,7 @@ bool GuiTabular::initialiseParams(string const & data)
|
||||
return true;
|
||||
}
|
||||
|
||||
InsetTabular tmp(buffer());
|
||||
InsetTabular tmp(const_cast<Buffer &>(buffer()));
|
||||
InsetTabular::string2params(data, tmp);
|
||||
tabular_ = Tabular(tmp.tabular);
|
||||
return true;
|
||||
@ -978,7 +978,7 @@ bool GuiTabular::initialiseParams(string const & data)
|
||||
|
||||
void GuiTabular::clearParams()
|
||||
{
|
||||
InsetTabular tmp(buffer());
|
||||
InsetTabular tmp(const_cast<Buffer &>(buffer()));
|
||||
tabular_ = tmp.tabular;
|
||||
active_cell_ = Tabular::npos;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ ViewSourceWidget::ViewSourceWidget(GuiViewSource & controller)
|
||||
|
||||
void ViewSourceWidget::updateView()
|
||||
{
|
||||
BufferView * view = controller_.bufferview();
|
||||
BufferView const * view = controller_.bufferview();
|
||||
if (!view) {
|
||||
document_->setPlainText(QString());
|
||||
setEnabled(false);
|
||||
@ -134,7 +134,7 @@ QString GuiViewSource::getContent(bool fullSource)
|
||||
pit_type par_begin;
|
||||
pit_type par_end;
|
||||
|
||||
BufferView * view = bufferview();
|
||||
BufferView const * view = bufferview();
|
||||
if (!view->cursor().selection()) {
|
||||
par_begin = view->cursor().bottom().pit();
|
||||
par_end = par_begin;
|
||||
|
Loading…
Reference in New Issue
Block a user