]> git.lyx.org Git - features.git/commitdiff
This commit continues the drastic diet operated on BufferView. It removes all boost...
authorAbdelrazak Younes <younes@lyx.org>
Fri, 14 Jul 2006 21:47:48 +0000 (21:47 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 14 Jul 2006 21:47:48 +0000 (21:47 +0000)
With this change, the only difference between BufferView.h and BufferView_pimpl.h is "cursor.h" so I think it is time to merge the two classes at last.

BufferView:
* showErrorList(), getErrorList(): transfered to LyXView.

BufferView::pimpl
* addError(), showReadonly(), connectBuffer(), disconnectBuffer(): transfered to LyXView.

CutAndPaste.C: adapted to API changes
frontends/controllers/ControlErrorList.C: ditto
lyxfunc.C: ditto

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14458 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView.h
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/CutAndPaste.C
src/frontends/LyXView.C
src/frontends/LyXView.h
src/frontends/controllers/ControlErrorList.C
src/lyxfunc.C

index 86e17296817ff438e1ac00d93a72fe776756d21f..510e86d3b1d099b09ca4cd6112be63981a214d4b 100644 (file)
@@ -253,23 +253,6 @@ void BufferView::scroll(int lines)
 }
 
 
-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;
index c8f833496b2da879df08529ecf011775e47dadfd..48ca713fde89050cace09ff4eee6e6130b43861c 100644 (file)
@@ -155,10 +155,6 @@ public:
        /// 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);
 
index 43c9c918f20fa553b820b47bede6c67ed15e6c6f..a5f15793be6214d920e4305ea9aed122ce81e12a 100644 (file)
@@ -144,66 +144,6 @@ BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner)
 }
 
 
-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"
@@ -238,7 +178,6 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
 
        if (found) {
                b = bufferlist.newBuffer(s);
-               connectBuffer(*b);
                if (!::loadLyXFile(b, s)) {
                        bufferlist.release(b);
                        return false;
@@ -257,7 +196,7 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
        }
 
        setBuffer(b);
-       bv_->showErrorList(_("Parse"));
+       owner_->showErrorList(_("Parse"));
 
        // scroll to the position when the file was last closed
        if (lyxrc.use_lastfilepos) {
@@ -312,7 +251,6 @@ void BufferView::Pimpl::setBuffer(Buffer * b)
                            << "[ 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.
@@ -349,7 +287,6 @@ void BufferView::Pimpl::setBuffer(Buffer * b)
        if (buffer_) {
                lyxerr[Debug::INFO] << BOOST_CURRENT_FUNCTION
                                    << "Buffer addr: " << buffer_ << endl;
-               connectBuffer(*buffer_);
                cursor_.push(buffer_->inset());
                cursor_.resetAnchor();
                buffer_->text().init(bv_);
@@ -801,7 +738,6 @@ void BufferView::Pimpl::center()
 }
 
 
-
 void BufferView::Pimpl::menuInsertLyXFile(string const & filenm)
 {
        BOOST_ASSERT(cursor_.inTexted());
@@ -851,7 +787,7 @@ void BufferView::Pimpl::menuInsertLyXFile(string const & filenm)
 
        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);
@@ -860,7 +796,7 @@ void BufferView::Pimpl::menuInsertLyXFile(string const & filenm)
                res = _("Could not insert document %1$s");
 
        owner_->message(bformat(res, disp_fn));
-       bv_->showErrorList(_("Document insertion"));
+       owner_->showErrorList(_("Document insertion"));
        resizeCurrentBuffer();
 }
 
index 5d645cf029bfa2a0d1e71608ee07844ccdb66a4a..f90d34b3824aa4dd33f387164b4f615c38117748 100644 (file)
 
 #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;
 
@@ -43,7 +40,7 @@ class Gui;
 
 
 ///
-class BufferView::Pimpl : public boost::signals::trackable {
+class BufferView::Pimpl {
 public:
        ///
        Pimpl(BufferView & bv, LyXView * owner);
@@ -127,32 +124,8 @@ private:
        ///
        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_;
index d88785bb14db1234193a265309107f0abd9134ca..a675c348018810db4c2ad4169fb777a35d80fa97 100644 (file)
@@ -649,7 +649,7 @@ void pasteSelection(LCursor & cur, size_t sel_index)
 
        pasteParagraphList(cur, theCuts[sel_index].first,
                           theCuts[sel_index].second);
-       cur.bv().showErrorList(_("Paste"));
+       cur.bv().owner()->showErrorList(_("Paste"));
        cur.setSelection();
 }
 
index 54dad90f3eaed780cb5069692e5dc6ce49715dca..4fa2308d325a2ba146fc949a71755e7b414e2ec0 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "controllers/ControlCommandBuffer.h"
 
+#include "support/lstrings.h"
 #include "support/filetools.h" // OnlyFilename()
 
 #include <boost/bind.hpp>
@@ -51,6 +52,7 @@
 using lyx::frontend::Gui;
 using lyx::frontend::WorkArea;
 
+using lyx::support::bformat;
 using lyx::support::makeDisplayPath;
 using lyx::support::onlyFilename;
 
@@ -128,30 +130,118 @@ Buffer * LyXView::buffer() const
 
 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();
index 7c9a2a98e2a386bb75e18972c12684592a1040a7..df0440870fc11174fa058490cd541c5ce94712a0 100644 (file)
@@ -13,6 +13,8 @@
 #ifndef LYXVIEW_H
 #define LYXVIEW_H
 
+#include "errorlist.h"
+
 #include <boost/scoped_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/signal.hpp>
@@ -165,6 +167,16 @@ public:
        /// 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).
        /**
@@ -198,6 +210,30 @@ private:
        /// 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
index 175955ae25c628a8cdcf8bfc47722c9cdef18e85..d4a39d6a622a76a1efe381701115b3dbb21e54fb 100644 (file)
@@ -11,6 +11,7 @@
 #include <config.h>
 
 #include "ControlErrorList.h"
+#include "frontends/LyXView.h"
 #include "buffer.h"
 #include "BufferView.h"
 #include "debug.h"
@@ -41,7 +42,7 @@ ErrorList const & ControlErrorList::errorList() const
 
 bool ControlErrorList::initialiseParams(string const & name)
 {
-       errorlist_ = kernel().bufferview()->getErrorList();
+       errorlist_ = kernel().lyxview().getErrorList();
        name_ = name;
        return true;
 }
index 59f6c47fe963228c89fedfe0e629638f1933910c..6cadfff1473460025a1e3b2727509b0e0ce1a9d3 100644 (file)
@@ -837,22 +837,22 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                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:
@@ -860,7 +860,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                owner->getDialogs().show("sendto");
                        else {
                                Exporter::Export(owner->buffer(), argument, false);
-                               view()->showErrorList(bufferFormat(*owner->buffer()));
+                               owner->showErrorList(bufferFormat(*owner->buffer()));
                        }
                        break;
 
@@ -1562,7 +1562,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                        view()->setCursor(backcur.asDocIterator(&(buffer->inset())));
                        bufferErrors(*buffer, el);
-                       view()->showErrorList(_("Class switch"));
+                       owner->showErrorList(_("Class switch"));
                        updateLabels(*buffer);
                        updateforce = true;
                        break;