mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 12:32:26 +00:00
* GuiView: get rid of Buffer() and documentBuffer() access.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31290 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b4b19b59a3
commit
184345e4e7
@ -77,15 +77,15 @@ void Dialog::disconnect() const
|
||||
|
||||
bool Dialog::isBufferAvailable() const
|
||||
{
|
||||
return lyxview_->buffer() != 0;
|
||||
return lyxview_->currentBufferView() != 0;
|
||||
}
|
||||
|
||||
|
||||
bool Dialog::isBufferReadonly() const
|
||||
{
|
||||
if (!lyxview_->buffer())
|
||||
if (!lyxview_->documentBufferView())
|
||||
return true;
|
||||
return lyxview_->buffer()->isReadonly();
|
||||
return lyxview_->documentBufferView()->buffer().isReadonly();
|
||||
}
|
||||
|
||||
|
||||
@ -114,8 +114,8 @@ BufferView const * Dialog::bufferview() const
|
||||
|
||||
Buffer const & Dialog::buffer() const
|
||||
{
|
||||
LASSERT(lyxview_->buffer(), /**/);
|
||||
return *lyxview_->buffer();
|
||||
LASSERT(lyxview_->currentBufferView(), /**/);
|
||||
return lyxview_->currentBufferView()->buffer();
|
||||
}
|
||||
|
||||
|
||||
|
@ -877,7 +877,7 @@ bool GuiApplication::dispatch(FuncRequest const & cmd)
|
||||
|
||||
case LFUN_BUFFER_NEW:
|
||||
if (d->views_.empty()
|
||||
|| (!lyxrc.open_buffers_in_tabs && current_view_->buffer() != 0)) {
|
||||
|| (!lyxrc.open_buffers_in_tabs && current_view_->documentBufferView() != 0)) {
|
||||
createView(QString(), false); // keep hidden
|
||||
current_view_->newDocument(to_utf8(cmd.argument()), false);
|
||||
current_view_->show();
|
||||
@ -889,10 +889,10 @@ bool GuiApplication::dispatch(FuncRequest const & cmd)
|
||||
|
||||
case LFUN_BUFFER_NEW_TEMPLATE:
|
||||
if (d->views_.empty()
|
||||
|| (!lyxrc.open_buffers_in_tabs && current_view_->buffer() != 0)) {
|
||||
|| (!lyxrc.open_buffers_in_tabs && current_view_->documentBufferView() != 0)) {
|
||||
createView();
|
||||
current_view_->newDocument(to_utf8(cmd.argument()), true);
|
||||
if (!current_view_->buffer())
|
||||
if (!current_view_->documentBufferView())
|
||||
current_view_->close();
|
||||
} else {
|
||||
current_view_->newDocument(to_utf8(cmd.argument()), true);
|
||||
@ -901,7 +901,7 @@ bool GuiApplication::dispatch(FuncRequest const & cmd)
|
||||
|
||||
case LFUN_FILE_OPEN:
|
||||
if (d->views_.empty()
|
||||
|| (!lyxrc.open_buffers_in_tabs && current_view_->buffer() != 0)) {
|
||||
|| (!lyxrc.open_buffers_in_tabs && current_view_->documentBufferView() != 0)) {
|
||||
string const fname = to_utf8(cmd.argument());
|
||||
// We want the ui session to be saved per document and not per
|
||||
// window number. The filename crc is a good enough identifier.
|
||||
@ -909,7 +909,7 @@ bool GuiApplication::dispatch(FuncRequest const & cmd)
|
||||
crc = for_each(fname.begin(), fname.end(), crc);
|
||||
createView(crc.checksum());
|
||||
current_view_->openDocument(fname);
|
||||
if (current_view_ && !current_view_->buffer())
|
||||
if (current_view_ && !current_view_->documentBufferView())
|
||||
current_view_->close();
|
||||
} else
|
||||
current_view_->openDocument(to_utf8(cmd.argument()));
|
||||
@ -1217,7 +1217,7 @@ void GuiApplication::restoreGuiSession()
|
||||
for (size_t i = 0; i < lastopened.size(); ++i) {
|
||||
FileName const & file_name = lastopened[i].file_name;
|
||||
if (d->views_.empty() || (!lyxrc.open_buffers_in_tabs
|
||||
&& current_view_->buffer() != 0)) {
|
||||
&& current_view_->documentBufferView() != 0)) {
|
||||
boost::crc_32_type crc;
|
||||
string const & fname = file_name.absFilename();
|
||||
crc = for_each(fname.begin(), fname.end(), crc);
|
||||
@ -1318,7 +1318,9 @@ bool GuiApplication::notify(QObject * receiver, QEvent * event)
|
||||
this->exit(1);
|
||||
|
||||
case BufferException: {
|
||||
Buffer * buf = current_view_->buffer();
|
||||
if (current_view_->documentBufferView())
|
||||
return false;
|
||||
Buffer * buf = ¤t_view_->documentBufferView()->buffer();
|
||||
docstring details = e.details_ + '\n';
|
||||
details += buf->emergencyWrite();
|
||||
theBufferList().release(buf);
|
||||
|
@ -42,7 +42,7 @@ namespace frontend {
|
||||
GuiTabular::GuiTabular(GuiView & lv)
|
||||
: GuiDialog(lv, "tabular", qt_("Table Settings")),
|
||||
// tabular_ is initialised at dialog construction in initialiseParams()
|
||||
tabular_(*lv.buffer(), 0, 0)
|
||||
tabular_(lv.currentBufferView()->buffer(), 0, 0)
|
||||
{
|
||||
active_cell_ = Tabular::npos;
|
||||
|
||||
|
@ -1035,40 +1035,6 @@ void GuiView::updateToolbars()
|
||||
}
|
||||
|
||||
|
||||
Buffer * GuiView::buffer()
|
||||
{
|
||||
if (d.current_work_area_)
|
||||
return &d.current_work_area_->bufferView().buffer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Buffer const * GuiView::buffer() const
|
||||
{
|
||||
if (d.current_work_area_)
|
||||
return &d.current_work_area_->bufferView().buffer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Buffer * GuiView::documentBuffer()
|
||||
{
|
||||
TabWorkArea * twa = d.currentTabWorkArea();
|
||||
if (twa && twa->currentWorkArea())
|
||||
return &twa->currentWorkArea()->bufferView().buffer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Buffer const * GuiView::documentBuffer() const
|
||||
{
|
||||
TabWorkArea * twa = d.currentTabWorkArea();
|
||||
if (twa && twa->currentWorkArea())
|
||||
return &twa->currentWorkArea()->bufferView().buffer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void GuiView::setBuffer(Buffer * newBuffer)
|
||||
{
|
||||
LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << std::endl);
|
||||
@ -1120,8 +1086,8 @@ void GuiView::disconnectBufferView()
|
||||
void GuiView::errors(string const & error_type, bool from_master)
|
||||
{
|
||||
ErrorList & el = from_master ?
|
||||
buffer()->masterBuffer()->errorList(error_type)
|
||||
: buffer()->errorList(error_type);
|
||||
documentBufferView()->buffer().masterBuffer()->errorList(error_type)
|
||||
: documentBufferView()->buffer().errorList(error_type);
|
||||
string data = error_type;
|
||||
if (from_master)
|
||||
data = "from_master|" + error_type;
|
||||
@ -1207,7 +1173,8 @@ void GuiView::resetAutosaveTimers()
|
||||
bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
||||
{
|
||||
bool enable = true;
|
||||
Buffer * buf = buffer();
|
||||
Buffer * buf = currentBufferView()
|
||||
? ¤tBufferView()->buffer() : 0;
|
||||
|
||||
if (cmd.origin == FuncRequest::TOC) {
|
||||
GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
|
||||
@ -1418,8 +1385,8 @@ void GuiView::openDocument(string const & fname)
|
||||
{
|
||||
string initpath = lyxrc.document_path;
|
||||
|
||||
if (buffer()) {
|
||||
string const trypath = buffer()->filePath();
|
||||
if (documentBufferView()) {
|
||||
string const trypath = documentBufferView()->buffer().filePath();
|
||||
// If directory is writeable, use this as default.
|
||||
if (FileName(trypath).isDirWritable())
|
||||
initpath = trypath;
|
||||
@ -1563,10 +1530,8 @@ void GuiView::importDocument(string const & argument)
|
||||
// need user interaction
|
||||
if (filename.empty()) {
|
||||
string initpath = lyxrc.document_path;
|
||||
|
||||
Buffer const * buf = buffer();
|
||||
if (buf) {
|
||||
string const trypath = buf->filePath();
|
||||
if (documentBufferView()) {
|
||||
string const trypath = documentBufferView()->buffer().filePath();
|
||||
// If directory is writeable, use this as default.
|
||||
if (FileName(trypath).isDirWritable())
|
||||
initpath = trypath;
|
||||
@ -1648,9 +1613,8 @@ void GuiView::importDocument(string const & argument)
|
||||
void GuiView::newDocument(string const & filename, bool from_template)
|
||||
{
|
||||
FileName initpath(lyxrc.document_path);
|
||||
Buffer * buf = buffer();
|
||||
if (buf) {
|
||||
FileName const trypath(buf->filePath());
|
||||
if (documentBufferView()) {
|
||||
FileName const trypath(documentBufferView()->buffer().filePath());
|
||||
// If directory is writeable, use this as default.
|
||||
if (trypath.isDirWritable())
|
||||
initpath = trypath;
|
||||
@ -2128,7 +2092,8 @@ bool GuiView::inMultiViews(GuiWorkArea * wa)
|
||||
|
||||
void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
|
||||
{
|
||||
Buffer * const curbuf = buffer();
|
||||
Buffer * const curbuf = documentBufferView()
|
||||
? &documentBufferView()->buffer() : 0;
|
||||
Buffer * nextbuf = curbuf;
|
||||
while (true) {
|
||||
if (np == NEXTBUFFER)
|
||||
@ -2294,7 +2259,7 @@ bool GuiView::dispatch(FuncRequest const & cmd)
|
||||
showDialog("character", data);
|
||||
} else if (name == "latexlog") {
|
||||
Buffer::LogType type;
|
||||
string const logfile = buffer()->logName(&type);
|
||||
string const logfile = documentBufferView()->buffer().logName(&type);
|
||||
switch (type) {
|
||||
case Buffer::latexlog:
|
||||
data = "latex ";
|
||||
@ -2307,7 +2272,7 @@ bool GuiView::dispatch(FuncRequest const & cmd)
|
||||
showDialog("log", data);
|
||||
} else if (name == "vclog") {
|
||||
string const data = "vc " +
|
||||
Lexer::quoteString(buffer()->lyxvc().getLogFile());
|
||||
Lexer::quoteString(documentBufferView()->buffer().lyxvc().getLogFile());
|
||||
showDialog("log", data);
|
||||
} else if (name == "symbols") {
|
||||
data = bv->cursor().getEncoding()->name();
|
||||
@ -2352,12 +2317,12 @@ bool GuiView::dispatch(FuncRequest const & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_SPLIT_VIEW:
|
||||
if (Buffer * buf = buffer()) {
|
||||
if (documentBufferView()) {
|
||||
string const orientation = cmd.getArg(0);
|
||||
d.splitter_->setOrientation(orientation == "vertical"
|
||||
? Qt::Vertical : Qt::Horizontal);
|
||||
TabWorkArea * twa = addTabWorkArea();
|
||||
GuiWorkArea * wa = twa->addWorkArea(*buf, *this);
|
||||
GuiWorkArea * wa = twa->addWorkArea(documentBufferView()->buffer(), *this);
|
||||
setCurrentWorkArea(wa);
|
||||
}
|
||||
break;
|
||||
|
@ -70,10 +70,6 @@ public:
|
||||
BufferView const * currentBufferView() const;
|
||||
BufferView * documentBufferView();
|
||||
BufferView const * documentBufferView() const;
|
||||
Buffer * buffer();
|
||||
Buffer const * buffer() const;
|
||||
Buffer * documentBuffer();
|
||||
Buffer const * documentBuffer() const;
|
||||
void setBuffer(Buffer * b);
|
||||
bool closeBuffer();
|
||||
bool closeBufferAll();
|
||||
|
@ -617,15 +617,14 @@ void LayoutBox::updateContents(bool reset)
|
||||
{
|
||||
d->resetFilter();
|
||||
|
||||
Buffer const * buffer = d->owner_.buffer();
|
||||
if (!buffer) {
|
||||
if (!d->owner_.documentBufferView()) {
|
||||
d->model_->clear();
|
||||
setEnabled(false);
|
||||
d->text_class_ = 0;
|
||||
d->inset_ = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Buffer const * buffer = &d->owner_.documentBufferView()->buffer();
|
||||
// we'll only update the layout list if the text class has changed
|
||||
// or we've moved from one inset to another
|
||||
DocumentClass const * text_class = &buffer->params().documentClass();
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "TocModel.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "CutAndPaste.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "FuncStatus.h"
|
||||
@ -440,7 +441,7 @@ void TocWidget::updateView()
|
||||
persistentCB->setEnabled(can_navigate_);
|
||||
|
||||
bool controls_enabled = toc_model && toc_model->rowCount() > 0
|
||||
&& !gui_view_.buffer()->isReadonly();
|
||||
&& !gui_view_.documentBufferView()->buffer().isReadonly();
|
||||
enableControls(controls_enabled);
|
||||
|
||||
depthSL->setMaximum(gui_view_.tocModels().depth(current_type_));
|
||||
|
Loading…
Reference in New Issue
Block a user