From 5c4758357f2c4e6c800b4284fe90155e9ce67b01 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Sat, 11 Jul 2009 09:37:28 +0000 Subject: [PATCH] * GuiDocument.{cpp,h}: - do not rename branches in the document unless the dialog was applied. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30466 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiDocument.cpp | 26 ++++++++++++++++++++++++-- src/frontends/qt4/GuiDocument.h | 4 ++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index a77a32cb92..671a1dc5d8 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -2561,6 +2561,7 @@ bool GuiDocument::initialiseParams(string const &) //selected, and that we don't have conflicts. If so, we could //at least pop up a warning. paramsToDialog(); + changedBranches_.clear(); return true; } @@ -2639,6 +2640,9 @@ void GuiDocument::dispatchParams() // This must come first so that a language change is correctly noticed setLanguage(); + // rename branches in the document + executeBranchRenaming(); + // Apply the BufferParams. Note that this will set the base class // and then update the buffer's layout. dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY); @@ -2816,8 +2820,26 @@ void GuiDocument::updateUnknownBranches() void GuiDocument::branchesRename(docstring const & oldname, docstring const & newname) { - docstring const arg = '"' + oldname + '"' + " " + '"' + newname + '"'; - dispatch(FuncRequest(LFUN_BRANCHES_RENAME, arg)); + map::iterator it = changedBranches_.begin(); + for (; it != changedBranches_.end() ; ++it) { + if (it->second == oldname) { + // branch has already been renamed + it->second = newname; + return; + } + } + // store new name + changedBranches_[oldname] = newname; +} + + +void GuiDocument::executeBranchRenaming() const +{ + map::const_iterator it = changedBranches_.begin(); + for (; it != changedBranches_.end() ; ++it) { + docstring const arg = '"' + it->first + '"' + " " + '"' + it->second + '"'; + dispatch(FuncRequest(LFUN_BRANCHES_RENAME, arg)); + } } diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h index af26f40b1b..b485a6061c 100644 --- a/src/frontends/qt4/GuiDocument.h +++ b/src/frontends/qt4/GuiDocument.h @@ -212,6 +212,8 @@ private: bool providesSC(std::string const & font) const; /// does this font provide size adjustment? bool providesScale(std::string const & font) const; + /// + void executeBranchRenaming() const; private: /// void loadModuleInfo(); @@ -221,6 +223,8 @@ private: BufferParams bp_; /// List of names of available modules std::list moduleNames_; + /// + std::map changedBranches_; }; -- 2.39.5