]> git.lyx.org Git - features.git/commitdiff
This is the continuation of my BufferView/LyXView cleanup. This commit replaces Buffe...
authorAbdelrazak Younes <younes@lyx.org>
Tue, 19 Sep 2006 13:36:20 +0000 (13:36 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 19 Sep 2006 13:36:20 +0000 (13:36 +0000)
The associated WorkArea is then responsible to connect these signals to its LyXView parent.

* BufferView:
  - showDialog, showDialogWithData, showInsetDialog: new boost signals

* LyXView:
  - connectBufferView(), disconnectBufferView(): new method in charge of the connection/disconnection of the above signal to associate private methods (showDialog(), etc).

* WorkArea
  - setBufferView(): will connect/disconnect the BufferView to its LyXView parent.

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

12 files changed:
src/BufferView.C
src/BufferView.h
src/frontends/LyXView.C
src/frontends/LyXView.h
src/frontends/WorkArea.C
src/insets/mailinset.C
src/lyxfunc.h
src/mathed/InsetMathHull.C
src/mathed/InsetMathNest.C
src/mathed/InsetMathRef.C
src/messages.C
src/text3.C

index e16a2da665e60296e04f6a506bbd70a54975d404..6b03a41239dbb131c927a9830283f0e0373aace0 100644 (file)
@@ -858,7 +858,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
 
        case LFUN_CHANGES_MERGE:
                if (lyx::find::findNextChange(this))
-                       owner_->getDialogs().show("changes");
+                       showDialog("changes");
                break;
 
        case LFUN_ALL_CHANGES_ACCEPT: {
@@ -1454,7 +1454,7 @@ void BufferView::trackChanges()
        } else {
                cursor_.setCursor(doc_iterator_begin(buffer_->inset()));
                if (lyx::find::findNextChange(this)) {
-                       owner_->getDialogs().show("changes");
+                       showDialog("changes");
                        return;
                }
 
index 43f197be7af6c2ca43b69da11a0d5c5b9fc240f7..94c1588e8a688ca68f68662b65971fecaf20eafb 100644 (file)
@@ -217,6 +217,22 @@ public:
        /// This signal is emitted when some message shows up.
        boost::signal<void(lyx::docstring)> message;
 
+       /// This signal is emitted when some dialog needs to be shown.
+       boost::signal<void(std::string name)> showDialog;
+
+       /// This signal is emitted when some dialog needs to be shown with
+       /// some data
+       boost::signal<void(std::string name,
+               std::string data)> showDialogWithData;
+
+       /// This signal is emitted when some inset dialogs needs to be shown.
+       boost::signal<void(std::string name, std::string data,
+               InsetBase * inset)> showInsetDialog;
+
+       /// This signal is emitted when some dialogs needs to be updated.
+       boost::signal<void(std::string name,
+               std::string data)> updateDialog;
+
 private:
        ///
        bool multiParSel();
index 7b06cf9684f037b620e220760c07955f1423ff8d..6e08fc4d0c1576b0b336d4ed10700665069eb423 100644 (file)
@@ -83,6 +83,7 @@ LyXView::LyXView(Gui & owner)
        lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
 }
 
+
 LyXView::~LyXView()
 {
 }
@@ -219,6 +220,28 @@ void LyXView::disconnectBuffer()
 }
 
 
+void LyXView::connectBufferView(BufferView & bv)
+{
+       show_dialog_connection_ = bv.showDialog.connect(
+                       boost::bind(&LyXView::showDialog, this, _1));
+       show_dialog_with_data_connection_ = bv.showDialogWithData.connect(
+                       boost::bind(&LyXView::showDialogWithData, this, _1, _2));
+       show_inset_dialog_connection_ = bv.showInsetDialog.connect(
+                       boost::bind(&LyXView::showInsetDialog, this, _1, _2, _3));
+       update_dialog_connection_ = bv.updateDialog.connect(
+                       boost::bind(&LyXView::updateDialog, this, _1, _2));
+}
+
+
+void LyXView::disconnectBufferView()
+{
+       show_dialog_connection_.disconnect();
+       show_dialog_with_data_connection_.disconnect();
+       show_inset_dialog_connection_.disconnect();
+       update_dialog_connection_.disconnect();
+}
+
+
 void LyXView::showErrorList(string const & error_type)
 {
        ErrorList & el = buffer()->errorList(error_type);
@@ -228,6 +251,33 @@ void LyXView::showErrorList(string const & error_type)
 }
 
 
+void LyXView::showDialog(string const & name)
+{
+       getDialogs().show(name);
+}
+
+
+void LyXView::showDialogWithData(string const & name,
+                                                                string const & data)
+{
+       getDialogs().show(name, data);
+}
+
+
+void LyXView::showInsetDialog(string const & name, string const & data,
+                                                         InsetBase * inset)
+{
+       getDialogs().show(name, data, 0);
+}
+
+
+void LyXView::updateDialog(string const & name, string const & data)
+{
+       if (getDialogs().visible(name))
+               getDialogs().update(name, data);
+}
+
+
 void LyXView::showReadonly(bool)
 {
        updateWindowTitle();
index b353571f03c4c16d7385373bedab188068fd60ac..13776f252978dd2def4d0ecbebb9a4f799be995d 100644 (file)
@@ -165,6 +165,11 @@ public:
        /// show the error list to the user
        void showErrorList(std::string const &);
 
+       /// connect to signals in the given BufferView
+       void connectBufferView(BufferView & bv);
+       /// disconnect from signals in the given BufferView
+       void disconnectBufferView();
+
 protected:
        /// current work area (screen view of a BufferView).
        /**
@@ -214,6 +219,27 @@ private:
        void connectBuffer(Buffer & buf);
        /// disconnect from signals in the given buffer
        void disconnectBuffer();
+
+       /// BufferView messages signal connection
+       //@{
+       boost::signals::connection message_connection_;
+       boost::signals::connection show_dialog_connection_;
+       boost::signals::connection show_dialog_with_data_connection_;
+       boost::signals::connection show_inset_dialog_connection_;
+       boost::signals::connection update_dialog_connection_;
+       //@}
+
+       /// Bind methods for BufferView messages signal connection
+       //@{
+       void showDialog(std::string const & name);
+       void showDialogWithData(std::string const & name,
+               std::string const & data);
+       void showInsetDialog(std::string const & name,
+               std::string const & data, InsetBase * inset);
+       void updateDialog(std::string const & name,
+               std::string const & data);
+       //@}
+
        /// notify readonly status
        void showReadonly(bool);
 
index 41c7c62e6ba52e85d2a0c60448d98211f85c6623..21005c4f504ef5fe7984384b67cdb399d2527b4d 100644 (file)
@@ -159,8 +159,10 @@ WorkArea::WorkArea(LyXView & lyx_view)
 
 void WorkArea::setBufferView(BufferView * buffer_view)
 {
-       if (buffer_view_)
+       if (buffer_view_) {
                message_connection_.disconnect();
+               lyx_view_.disconnectBufferView();
+       }
 
        hideCursor();
        buffer_view_ = buffer_view;
@@ -168,6 +170,8 @@ void WorkArea::setBufferView(BufferView * buffer_view)
 
        message_connection_ = buffer_view_->message.connect(
                        boost::bind(&WorkArea::displayMessage, this, _1));
+
+       lyx_view_.connectBufferView(*buffer_view);
 }
 
 
index 6c63619af52f51b1e16eec042263f3d715268c1d..c059200b2035424491fedaab5e4697c9036896de 100644 (file)
@@ -24,7 +24,7 @@ using std::string;
 void MailInset::showDialog(BufferView * bv) const
 {
        BOOST_ASSERT(bv);
-       bv->owner()->getDialogs().show(name(), inset2string(*bv->buffer()),
+       bv->showInsetDialog(name(), inset2string(*bv->buffer()),
                                       &inset());
 }
 
@@ -32,9 +32,7 @@ void MailInset::showDialog(BufferView * bv) const
 void MailInset::updateDialog(BufferView * bv) const
 {
        BOOST_ASSERT(bv);
-       if (bv->owner()->getDialogs().visible(name()))
-               bv->owner()->getDialogs().update(name(),
-                                                inset2string(*bv->buffer()));
+       bv->updateDialog(name(), inset2string(*bv->buffer()));
 }
 
 
index 92ec7f6de989ae5abbadf76d0ba4a06b2b9e5650..47c0108eed94332831af80a2da00457ffaeecdfe 100644 (file)
@@ -41,7 +41,7 @@ class LyXView;
 class LyXFunc : public boost::signals::trackable {
 public:
        ///
-       explicit LyXFunc(LyXView *);
+       explicit LyXFunc(LyXView * lv = 0);
 
        /// LyX dispatcher, executes lyx actions.
        void dispatch(FuncRequest const &);
index 08d9d147a06f5246ab40e2b88e570f43db63de5e..0054d6f46151c2f00017116eaf7637560af823c5 100644 (file)
@@ -1081,7 +1081,7 @@ void InsetMathHull::doDispatch(LCursor & cur, FuncRequest & cmd)
                string const data = InsetCommandMailer::params2string("label", p);
 
                if (cmd.argument().empty())
-                       cur.bv().owner()->getDialogs().show("label", data, 0);
+                       cur.bv().showInsetDialog("label", data, 0);
                else {
                        FuncRequest fr(LFUN_INSET_INSERT, data);
                        dispatch(cur, fr);
index 787b0b11a53c9b25a5cd1a5c683b3cd5b58742a8..775543a63cfcad743c5d303958cb30b62121a62b 100644 (file)
@@ -939,7 +939,7 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
                        RefInset tmp(name);
                        data = tmp.createDialogStr(name);
                }
-               cur.bv().owner()->getDialogs().show(name, data, 0);
+               cur.bv().showInsetDialog(name, data, 0);
                break;
        }
 
@@ -1126,7 +1126,7 @@ void InsetMathNest::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
 
        if (cmd.button() == mouse_button::button3) {
                // try to dispatch to enclosed insets first
-               cur.bv().owner()->getDialogs().show("mathpanel");
+               cur.bv().showDialog("mathpanel");
                return;
        }
 
index 606a1f5c799e9525d4d4371b17e5a163368f36bc..4fbe793883e3b075606d8b9165d01cf07d78e215 100644 (file)
@@ -73,8 +73,7 @@ void RefInset::doDispatch(LCursor & cur, FuncRequest & cmd)
 
        case LFUN_INSET_DIALOG_UPDATE: {
                string const data = createDialogStr("ref");
-               if (cur.bv().owner()->getDialogs().visible("ref"))
-                       cur.bv().owner()->getDialogs().update("ref", data);
+               cur.bv().updateDialog("ref", data);
                break;
        }
 
@@ -87,7 +86,7 @@ void RefInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                if (cmd.button() == mouse_button::button1) {
                        // Eventually trigger dialog with button 3, not 1
                        string const data = createDialogStr("ref");
-                       cur.bv().owner()->getDialogs().show("ref", data, this);
+                       cur.bv().showInsetDialog("ref", data, this);
                        break;
                }
                cur.undispatched();
index 1f192e9fc75729b68a5ed6426e990b28d285e147..82f86c684db9507574a35f0281f5d2bbd8827901 100644 (file)
@@ -196,7 +196,7 @@ public:
                        lyxerr << "Undefined result from gettext" << endl;
                        translated = from_ascii(tmp);
                } else if (msg == tmp) {
-                       lyxerr << "Same as entered returned" << endl;
+                       //lyxerr << "Same as entered returned" << endl;
                        translated = from_ascii(tmp);
                } else {
                        lyxerr << "We got a translation" << endl;
index 7f0e8465726625e9381ab528e8290b07c0e51a14..f5142a1c76d1e0089c2e766d4e0c4697189e67d0 100644 (file)
@@ -1091,14 +1091,14 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_URL_INSERT: {
                InsetCommandParams p("url");
                string const data = InsetCommandMailer::params2string("url", p);
-               bv->owner()->getDialogs().show("url", data, 0);
+               bv->showInsetDialog("url", data, 0);
                break;
        }
 
        case LFUN_HTML_INSERT: {
                InsetCommandParams p("htmlurl");
                string const data = InsetCommandMailer::params2string("url", p);
-               bv->owner()->getDialogs().show("url", data, 0);
+               bv->showInsetDialog("url", data, 0);
                break;
        }
 
@@ -1111,7 +1111,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                string const data = InsetCommandMailer::params2string("label", p);
 
                if (cmd.argument().empty()) {
-                       bv->owner()->getDialogs().show("label", data, 0);
+                       bv->showInsetDialog("label", data, 0);
                } else {
                        FuncRequest fr(LFUN_INSET_INSERT, data);
                        dispatch(cur, fr);
@@ -1146,7 +1146,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                if (doInsertInset(cur, this, cmd, false, true))
                        cur.posRight();
                else
-                       bv->owner()->getDialogs().show("tabularcreate");
+                       bv->showDialog("tabularcreate");
 
                break;
 
@@ -1351,13 +1351,11 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                string data;
                params2string(cur.paragraph(), data);
                data = "show\n" + data;
-               bv->owner()->getDialogs().show("paragraph", data);
+               bv->showDialogWithData("paragraph", data);
                break;
        }
 
        case LFUN_PARAGRAPH_UPDATE: {
-               if (!bv->owner()->getDialogs().visible("paragraph"))
-                       break;
                string data;
                params2string(cur.paragraph(), data);
 
@@ -1365,7 +1363,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
 
                data = "update " + convert<string>(accept) + '\n' + data;
-               bv->owner()->getDialogs().update("paragraph", data);
+               bv->updateDialog("paragraph", data);
                break;
        }
 
@@ -1438,7 +1436,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                                arg = cur.selectionAsString(false);
                        }
                }
-               bv->owner()->getDialogs().show("thesaurus", lyx::to_utf8(arg));
+               bv->showDialogWithData("thesaurus", lyx::to_utf8(arg));
                break;
        }