]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathRef.cpp
Improve the list of equations
[lyx.git] / src / mathed / InsetMathRef.cpp
index 206a40040e0e4c88d8529d29a50b1c418d4c8bb8..ef08cbcd3d0610d95c8b9446e85b5959261822fe 100644 (file)
@@ -61,11 +61,12 @@ void InsetMathRef::infoize(odocstream & os) const
 
 void InsetMathRef::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
-       switch (cmd.action_) {
+       switch (cmd.action()) {
        case LFUN_INSET_MODIFY:
                if (cmd.getArg(0) == "ref") {
                        MathData ar;
                        if (createInsetMath_fromDialogStr(cmd.argument(), ar)) {
+                               cur.recordUndo();
                                *this = *ar[0].nucleus()->asRefInset();
                                break;
                        }
@@ -74,7 +75,7 @@ void InsetMathRef::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_INSET_DIALOG_UPDATE: {
-               string const data = createDialogStr("ref");
+               string const data = createDialogStr();
                cur.bv().updateDialog("ref", data);
                break;
        }
@@ -88,7 +89,7 @@ void InsetMathRef::doDispatch(Cursor & cur, FuncRequest & cmd)
                }
                if (cmd.button() == mouse_button::button1) {
                        // Eventually trigger dialog with button 3, not 1
-                       string const data = createDialogStr("ref");
+                       string const data = createDialogStr();
                        cur.bv().showDialog("ref", data, this);
                        break;
                }
@@ -110,7 +111,7 @@ void InsetMathRef::doDispatch(Cursor & cur, FuncRequest & cmd)
 bool InsetMathRef::getStatus(Cursor & cur, FuncRequest const & cmd,
                         FuncStatus & status) const
 {
-       switch (cmd.action_) {
+       switch (cmd.action()) {
        // we handle these
        case LFUN_INSET_MODIFY:
        case LFUN_INSET_DIALOG_UPDATE:
@@ -183,17 +184,17 @@ void InsetMathRef::updateBuffer(ParIterator const & it, UpdateType /*utype*/)
                return;
        }
        // register this inset into the buffer reference cache.
-       buffer().references(getTarget()).push_back(make_pair(this, it));
+       buffer().addReference(getTarget(), this, it);
 }
 
 
-string const InsetMathRef::createDialogStr(string const & name) const
+string const InsetMathRef::createDialogStr() const
 {
        InsetCommandParams icp(REF_CODE, to_ascii(commandname()));
        icp["reference"] = asString(cell(0));
        if (!cell(1).empty())
                icp["name"] = asString(cell(1));
-       return InsetCommand::params2string(name, icp);
+       return InsetCommand::params2string(icp);
 }
 
 
@@ -212,9 +213,9 @@ void InsetMathRef::changeTarget(docstring const & target)
        MathData ar;
        Buffer & buf = buffer();
        if (createInsetMath_fromDialogStr(
-           from_utf8(InsetCommand::params2string("ref", icp)), ar)) {
+           from_utf8(InsetCommand::params2string(icp)), ar)) {
                *this = *ar[0].nucleus()->asRefInset();
-               // FIXME audit setBuffer/updateBuffer calls
+               // FIXME audit setBuffer calls
                setBuffer(buf);
        }
 }