}
-void BufferView::showErrorList(string const & action) const
-{
- if (getErrorList().size()) {
- string const title = bformat(_("%1$s Errors (%2$s)"),
- action, buffer()->fileName());
- owner()->getDialogs().show("errorlist", title);
- pimpl_->errorlist_.clear();
- }
-}
-
-
-ErrorList const & BufferView::getErrorList() const
-{
- return pimpl_->errorlist_;
-}
-
-
void BufferView::setCursorFromRow(int row)
{
int tmpid = -1;
/// move cursor to the named label
void gotoLabel(std::string const & label);
- /// get the stored error list
- ErrorList const & getErrorList() const;
- /// show the error list to the user
- void showErrorList(std::string const &) const;
/// set the cursor based on the given TeX source row
void setCursorFromRow(int row);
}
-void BufferView::Pimpl::addError(ErrorItem const & ei)
-{
- errorlist_.push_back(ei);
-}
-
-
-void BufferView::Pimpl::showReadonly(bool)
-{
- owner_->updateWindowTitle();
- owner_->getDialogs().updateBufferDependent(false);
-}
-
-
-void BufferView::Pimpl::connectBuffer(Buffer & buf)
-{
- if (errorConnection_.connected())
- disconnectBuffer();
-
- errorConnection_ =
- buf.error.connect(
- boost::bind(&BufferView::Pimpl::addError, this, _1));
-
- messageConnection_ =
- buf.message.connect(
- boost::bind(&LyXView::message, owner_, _1));
-
- busyConnection_ =
- buf.busy.connect(
- boost::bind(&LyXView::busy, owner_, _1));
-
- titleConnection_ =
- buf.updateTitles.connect(
- boost::bind(&LyXView::updateWindowTitle, owner_));
-
- timerConnection_ =
- buf.resetAutosaveTimers.connect(
- boost::bind(&LyXView::resetAutosaveTimer, owner_));
-
- readonlyConnection_ =
- buf.readonly.connect(
- boost::bind(&BufferView::Pimpl::showReadonly, this, _1));
-
- closingConnection_ =
- buf.closing.connect(
- boost::bind(&LyXView::setBuffer, owner_, (Buffer *)0));
-}
-
-
-void BufferView::Pimpl::disconnectBuffer()
-{
- errorConnection_.disconnect();
- messageConnection_.disconnect();
- busyConnection_.disconnect();
- titleConnection_.disconnect();
- timerConnection_.disconnect();
- readonlyConnection_.disconnect();
- closingConnection_.disconnect();
-}
-
-
bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
{
// Get absolute path of file and add ".lyx"
if (found) {
b = bufferlist.newBuffer(s);
- connectBuffer(*b);
if (!::loadLyXFile(b, s)) {
bufferlist.release(b);
return false;
}
setBuffer(b);
- bv_->showErrorList(_("Parse"));
+ owner_->showErrorList(_("Parse"));
// scroll to the position when the file was last closed
if (lyxrc.use_lastfilepos) {
<< "[ b = " << b << "]" << endl;
if (buffer_) {
- disconnectBuffer();
// Save the actual cursor position and anchor inside the
// buffer so that it can be restored in case we rechange
// to this buffer later on.
if (buffer_) {
lyxerr[Debug::INFO] << BOOST_CURRENT_FUNCTION
<< "Buffer addr: " << buffer_ << endl;
- connectBuffer(*buffer_);
cursor_.push(buffer_->inset());
cursor_.resetAnchor();
buffer_->text().init(bv_);
}
-
void BufferView::Pimpl::menuInsertLyXFile(string const & filenm)
{
BOOST_ASSERT(cursor_.inTexted());
string res;
Buffer buf("", false);
- buf.error.connect(boost::bind(&BufferView::Pimpl::addError, this, _1));
+ buf.error.connect(boost::bind(&LyXView::addError, owner_, _1));
if (::loadLyXFile(&buf, makeAbsPath(filename))) {
lyx::cap::pasteParagraphList(cursor_, buf.paragraphs(),
buf.params().textclass);
res = _("Could not insert document %1$s");
owner_->message(bformat(res, disp_fn));
- bv_->showErrorList(_("Document insertion"));
+ owner_->showErrorList(_("Document insertion"));
resizeCurrentBuffer();
}
#include "BufferView.h"
#include "cursor.h"
-#include "errorlist.h"
#include "metricsinfo.h"
#include "frontends/LyXKeySym.h"
#include "support/types.h"
-#include <boost/signals/trackable.hpp>
-
class Change;
class LyXView;
///
-class BufferView::Pimpl : public boost::signals::trackable {
+class BufferView::Pimpl {
public:
///
Pimpl(BufferView & bv, LyXView * owner);
///
ScrollbarParameters scrollbarParameters_;
- /// An error list (replaces the error insets)
- ErrorList errorlist_;
- /// add an error to the list
- void addError(ErrorItem const &);
- /// buffer errors signal connection
- boost::signals::connection errorConnection_;
- /// buffer messages signal connection
- boost::signals::connection messageConnection_;
- /// buffer busy status signal connection
- boost::signals::connection busyConnection_;
- /// buffer title changed signal connection
- boost::signals::connection titleConnection_;
- /// buffer reset timers signal connection
- boost::signals::connection timerConnection_;
- /// buffer readonly status changed signal connection
- boost::signals::connection readonlyConnection_;
- /// buffer closing signal connection
- boost::signals::connection closingConnection_;
- /// connect to signals in the given buffer
- void connectBuffer(Buffer & buf);
- /// disconnect from signals in the given buffer
- void disconnectBuffer();
/// track changes for the document
void trackChanges();
- /// notify readonly status
- void showReadonly(bool);
///
ViewMetricsInfo metrics_info_;
pasteParagraphList(cur, theCuts[sel_index].first,
theCuts[sel_index].second);
- cur.bv().showErrorList(_("Paste"));
+ cur.bv().owner()->showErrorList(_("Paste"));
cur.setSelection();
}
#include "controllers/ControlCommandBuffer.h"
+#include "support/lstrings.h"
#include "support/filetools.h" // OnlyFilename()
#include <boost/bind.hpp>
using lyx::frontend::Gui;
using lyx::frontend::WorkArea;
+using lyx::support::bformat;
using lyx::support::makeDisplayPath;
using lyx::support::onlyFilename;
void LyXView::setBuffer(Buffer * b)
{
+ if (work_area_->bufferView().buffer())
+ disconnectBuffer();
+
work_area_->bufferView().setBuffer(b);
updateMenubar();
updateToolbars();
updateLayoutChoice();
updateWindowTitle();
- if (b)
+ if (b) {
+ connectBuffer(*b);
setLayout(work_area_->bufferView().firstLayout());
+ }
redrawWorkArea();
}
bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
{
+ if (work_area_->bufferView().buffer())
+ disconnectBuffer();
+
bool loaded = work_area_->bufferView().loadLyXFile(filename, tolastfiles);
updateMenubar();
updateToolbars();
updateLayoutChoice();
updateWindowTitle();
- if (loaded)
+ if (loaded) {
+ connectBuffer(*work_area_->bufferView().buffer());
setLayout(work_area_->bufferView().firstLayout());
+ }
redrawWorkArea();
return loaded;
}
+
+void LyXView::connectBuffer(Buffer & buf)
+{
+ if (errorConnection_.connected())
+ disconnectBuffer();
+
+ errorConnection_ =
+ buf.error.connect(
+ boost::bind(&LyXView::addError, this, _1));
+
+ messageConnection_ =
+ buf.message.connect(
+ boost::bind(&LyXView::message, this, _1));
+
+ busyConnection_ =
+ buf.busy.connect(
+ boost::bind(&LyXView::busy, this, _1));
+
+ titleConnection_ =
+ buf.updateTitles.connect(
+ boost::bind(&LyXView::updateWindowTitle, this));
+
+ timerConnection_ =
+ buf.resetAutosaveTimers.connect(
+ boost::bind(&LyXView::resetAutosaveTimer, this));
+
+ readonlyConnection_ =
+ buf.readonly.connect(
+ boost::bind(&LyXView::showReadonly, this, _1));
+
+ closingConnection_ =
+ buf.closing.connect(
+ boost::bind(&LyXView::setBuffer, this, (Buffer *)0));
+}
+
+
+void LyXView::disconnectBuffer()
+{
+ errorConnection_.disconnect();
+ messageConnection_.disconnect();
+ busyConnection_.disconnect();
+ titleConnection_.disconnect();
+ timerConnection_.disconnect();
+ readonlyConnection_.disconnect();
+ closingConnection_.disconnect();
+}
+
+
+void LyXView::addError(ErrorItem const & ei)
+{
+ errorlist_.push_back(ei);
+}
+
+
+void LyXView::showErrorList(string const & action)
+{
+ if (errorlist_.size()) {
+ string const title = bformat(_("%1$s Errors (%2$s)"),
+ action, buffer()->fileName());
+ getDialogs().show("errorlist", title);
+ errorlist_.clear();
+ }
+}
+
+
+ErrorList const & LyXView::getErrorList() const
+{
+ return errorlist_;
+}
+
+
+void LyXView::showReadonly(bool)
+{
+ updateWindowTitle();
+ getDialogs().updateBufferDependent(false);
+}
+
+
BufferView * LyXView::view() const
{
return &work_area_->bufferView();
#ifndef LYXVIEW_H
#define LYXVIEW_H
+#include "errorlist.h"
+
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/signal.hpp>
/// This is needed for the qt3 and gtk frontend.
lyx::frontend::WorkArea * workArea();
+ /// get the stored error list
+ ErrorList const & getErrorList() const;
+ /// show the error list to the user
+ void showErrorList(std::string const &);
+ /// add an error to the list
+ /** FIXME: public method until the signal connection in
+ * BufferView::menuInsertLyXFile() is removed.
+ */
+ void addError(ErrorItem const &);
+
protected:
/// current work area (screen view of a BufferView).
/**
/// dialogs for this view
boost::scoped_ptr<Dialogs> dialogs_;
+ /// An error list (replaces the error insets)
+ ErrorList errorlist_;
+
+ /// buffer errors signal connection
+ boost::signals::connection errorConnection_;
+ /// buffer messages signal connection
+ boost::signals::connection messageConnection_;
+ /// buffer busy status signal connection
+ boost::signals::connection busyConnection_;
+ /// buffer title changed signal connection
+ boost::signals::connection titleConnection_;
+ /// buffer reset timers signal connection
+ boost::signals::connection timerConnection_;
+ /// buffer readonly status changed signal connection
+ boost::signals::connection readonlyConnection_;
+ /// buffer closing signal connection
+ boost::signals::connection closingConnection_;
+ /// connect to signals in the given buffer
+ void connectBuffer(Buffer & buf);
+ /// disconnect from signals in the given buffer
+ void disconnectBuffer();
+ /// notify readonly status
+ void showReadonly(bool);
+
protected:
/// view's command buffer controller
// this has to be declared _after_ lyxfunc_ as its initialization depends
#include <config.h>
#include "ControlErrorList.h"
+#include "frontends/LyXView.h"
#include "buffer.h"
#include "BufferView.h"
#include "debug.h"
bool ControlErrorList::initialiseParams(string const & name)
{
- errorlist_ = kernel().bufferview()->getErrorList();
+ errorlist_ = kernel().lyxview().getErrorList();
name_ = name;
return true;
}
case LFUN_BUFFER_UPDATE:
Exporter::Export(owner->buffer(), argument, true);
- view()->showErrorList(bufferFormat(*owner->buffer()));
+ owner->showErrorList(bufferFormat(*owner->buffer()));
break;
case LFUN_BUFFER_VIEW:
Exporter::preview(owner->buffer(), argument);
- view()->showErrorList(bufferFormat(*owner->buffer()));
+ owner->showErrorList(bufferFormat(*owner->buffer()));
break;
case LFUN_BUILD_PROGRAM:
Exporter::Export(owner->buffer(), "program", true);
- view()->showErrorList(_("Build"));
+ owner->showErrorList(_("Build"));
break;
case LFUN_BUFFER_CHKTEX:
owner->buffer()->runChktex();
- view()->showErrorList(_("ChkTeX"));
+ owner->showErrorList(_("ChkTeX"));
break;
case LFUN_BUFFER_EXPORT:
owner->getDialogs().show("sendto");
else {
Exporter::Export(owner->buffer(), argument, false);
- view()->showErrorList(bufferFormat(*owner->buffer()));
+ owner->showErrorList(bufferFormat(*owner->buffer()));
}
break;
view()->setCursor(backcur.asDocIterator(&(buffer->inset())));
bufferErrors(*buffer, el);
- view()->showErrorList(_("Class switch"));
+ owner->showErrorList(_("Class switch"));
updateLabels(*buffer);
updateforce = true;
break;