]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetlabel.C
The speed patch: redraw only rows that have changed
[lyx.git] / src / insets / insetlabel.C
index 7e19d69bd22c4286dc8295eb69d9ece91a9f1add..9d1264dbe0b955da8f64f76fad7a334c9805317a 100644 (file)
@@ -58,41 +58,7 @@ string const InsetLabel::getScreenLabel(Buffer const &) const
 }
 
 
-namespace {
-
-void changeRefsIfUnique(BufferView & bv, string const & from, string const & to)
-{
-       // Check if the label 'from' appears more than once
-       vector<string> labels;
-       bv.buffer()->getLabelList(labels);
-
-       if (lyx::count(labels.begin(), labels.end(), from) > 1)
-               return;
-
-       InsetBase::Code code = InsetBase::REF_CODE;
-
-       ParIterator it = bv.buffer()->par_iterator_begin();
-       ParIterator end = bv.buffer()->par_iterator_end();
-       for ( ; it != end; ++it) {
-               bool changed_inset = false;
-               for (InsetList::iterator it2 = it->insetlist.begin();
-                    it2 != it->insetlist.end(); ++it2) {
-                       if (it2->inset->lyxCode() == code) {
-                               InsetCommand * inset = static_cast<InsetCommand *>(it2->inset);
-                               if (inset->getContents() == from) {
-                                       inset->setContents(to);
-                                       //inset->setButtonLabel();
-                                       changed_inset = true;
-                               }
-                       }
-               }
-       }
-}
-
-} // namespace anon
-
-
-void InsetLabel::priv_dispatch(LCursor & cur, FuncRequest & cmd)
+void InsetLabel::doDispatch(LCursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
 
@@ -100,18 +66,18 @@ void InsetLabel::priv_dispatch(LCursor & cur, FuncRequest & cmd)
                InsetCommandParams p;
                InsetCommandMailer::string2params("label", cmd.argument, p);
                if (p.getCmdName().empty()) {
-                       cur.undispatched();
+                       cur.noUpdate();
                        break;
                }
                if (p.getContents() != params().getContents())
-                       changeRefsIfUnique(cur.bv(), params().getContents(),
+                       cur.bv().buffer()->changeRefsIfUnique(params().getContents(),
                                                       p.getContents());
                setParams(p);
                break;
        }
 
        default:
-               InsetCommand::priv_dispatch(cur, cmd);
+               InsetCommand::doDispatch(cur, cmd);
                break;
        }
 }