From: Enrico Forestieri Date: Thu, 28 May 2009 12:49:41 +0000 (+0000) Subject: Fix doubling of bibtex and index alternatives everytime preferences are saved. X-Git-Tag: 2.0.0~6424 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=3e18652f8e2ed4777de927f0442068e1827e8acf;p=lyx.git Fix doubling of bibtex and index alternatives everytime preferences are saved. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29876 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 993fb3889f..b79d4be6e7 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -598,7 +598,7 @@ int LyXRC::read(Lexer & lexrc) case RC_BIBTEX_ALTERNATIVES: if (lexrc.next(true)) { - bibtex_alternatives.push_back(lexrc.getString()); + bibtex_alternatives.insert(lexrc.getString()); } break; @@ -616,7 +616,7 @@ int LyXRC::read(Lexer & lexrc) case RC_INDEX_ALTERNATIVES: if (lexrc.next(true)) { - index_alternatives.push_back(lexrc.getString()); + index_alternatives.insert(lexrc.getString()); } break; @@ -1371,28 +1371,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c if (tag != RC_LAST) break; case RC_BIBTEX_ALTERNATIVES: { - vector::const_iterator it = bibtex_alternatives.begin(); - vector::const_iterator end = bibtex_alternatives.end(); - if (ignore_system_lyxrc) { - for ( ; it != end; ++it) + set::const_iterator it = bibtex_alternatives.begin(); + set::const_iterator end = bibtex_alternatives.end(); + for ( ; it != end; ++it) { + if (ignore_system_lyxrc + || !system_lyxrc.bibtex_alternatives.count(*it)) os << "\\bibtex_alternatives \"" << *it << "\"\n"; - } else { - vector::const_iterator sbeg = - system_lyxrc.bibtex_alternatives.begin(); - vector::const_iterator send = - system_lyxrc.bibtex_alternatives.end(); - for ( ; it != end; ++it) { - bool found = false; - for (vector::const_iterator sit = sbeg; - sit != send; ++sit) { - if (*it == *sit) - found = true; - } - if (!found) - os << "\\bibtex_alternatives \"" - << *it << "\"\n"; - } } if (tag != RC_LAST) break; @@ -1412,28 +1397,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c if (tag != RC_LAST) break; case RC_INDEX_ALTERNATIVES: { - vector::const_iterator it = index_alternatives.begin(); - vector::const_iterator end = index_alternatives.end(); - if (ignore_system_lyxrc) { - for ( ; it != end; ++it) + set::const_iterator it = index_alternatives.begin(); + set::const_iterator end = index_alternatives.end(); + for ( ; it != end; ++it) { + if (ignore_system_lyxrc + || !system_lyxrc.index_alternatives.count(*it)) os << "\\index_alternatives \"" << *it << "\"\n"; - } else { - vector::const_iterator sbeg = - system_lyxrc.index_alternatives.begin(); - vector::const_iterator send = - system_lyxrc.index_alternatives.end(); - for ( ; it != end; ++it) { - bool found = false; - for (vector::const_iterator sit = sbeg; - sit != send; ++sit) { - if (*it == *sit) - found = true; - } - if (!found) - os << "\\index_alternatives \"" - << *it << "\"\n"; - } } if (tag != RC_LAST) break; diff --git a/src/LyXRC.h b/src/LyXRC.h index 23f1d9ccbb..a1004c360e 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -22,8 +22,8 @@ #include "support/strfwd.h" +#include #include -#include namespace lyx { @@ -250,13 +250,13 @@ public: /// command to run chktex incl. options std::string chktex_command; /// all available commands to run bibtex incl. options - std::vector bibtex_alternatives; + std::set bibtex_alternatives; /// command to run bibtex incl. options std::string bibtex_command; /// command to run japanese bibtex incl. options std::string jbibtex_command; /// all available index commands incl. options - std::vector index_alternatives; + std::set index_alternatives; /// command to run makeindex incl. options or other index programs std::string index_command; /// command to run japanese index program incl. options diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index ec015597e9..7521e48332 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -871,7 +871,7 @@ GuiDocument::GuiDocument(GuiView & lv) biblioModule->bibtexCO->clear(); biblioModule->bibtexCO->addItem(qt_("Default"), QString("default")); - for (vector::const_iterator it = lyxrc.bibtex_alternatives.begin(); + for (set::const_iterator it = lyxrc.bibtex_alternatives.begin(); it != lyxrc.bibtex_alternatives.end(); ++it) { QString const command = toqstr(*it).left(toqstr(*it).indexOf(" ")); biblioModule->bibtexCO->addItem(command, command); diff --git a/src/frontends/qt4/GuiIndices.cpp b/src/frontends/qt4/GuiIndices.cpp index 969b86ad5d..5e8c1b3d91 100644 --- a/src/frontends/qt4/GuiIndices.cpp +++ b/src/frontends/qt4/GuiIndices.cpp @@ -54,7 +54,7 @@ GuiIndices::GuiIndices(QWidget * parent) indexCO->clear(); indexCO->addItem(qt_("Default"), QString("default")); - for (vector::const_iterator it = lyxrc.index_alternatives.begin(); + for (set::const_iterator it = lyxrc.index_alternatives.begin(); it != lyxrc.index_alternatives.end(); ++it) { QString const command = toqstr(*it).left(toqstr(*it).indexOf(" ")); indexCO->addItem(command, command); diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 818a3e2396..48388bbd2f 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -626,7 +626,7 @@ void PrefLatex::on_latexBibtexCO_activated(int n) latexBibtexOptionsLA->setText(qt_("C&ommand:")); return; } - for (vector::const_iterator it = bibtex_alternatives.begin(); + for (set::const_iterator it = bibtex_alternatives.begin(); it != bibtex_alternatives.end(); ++it) { QString const bib = toqstr(*it); int ind = bib.indexOf(" "); @@ -651,7 +651,7 @@ void PrefLatex::on_latexIndexCO_activated(int n) latexIndexOptionsLA->setText(qt_("Co&mmand:")); return; } - for (vector::const_iterator it = index_alternatives.begin(); + for (set::const_iterator it = index_alternatives.begin(); it != index_alternatives.end(); ++it) { QString const idx = toqstr(*it); int ind = idx.indexOf(" "); @@ -714,7 +714,7 @@ void PrefLatex::update(LyXRC const & rc) latexBibtexCO->clear(); latexBibtexCO->addItem(qt_("Custom"), QString()); - for (vector::const_iterator it = rc.bibtex_alternatives.begin(); + for (set::const_iterator it = rc.bibtex_alternatives.begin(); it != rc.bibtex_alternatives.end(); ++it) { QString const command = toqstr(*it).left(toqstr(*it).indexOf(" ")); latexBibtexCO->addItem(command, command); @@ -741,7 +741,7 @@ void PrefLatex::update(LyXRC const & rc) latexIndexCO->clear(); latexIndexCO->addItem(qt_("Custom"), QString()); - for (vector::const_iterator it = rc.index_alternatives.begin(); + for (set::const_iterator it = rc.index_alternatives.begin(); it != rc.index_alternatives.end(); ++it) { QString const command = toqstr(*it).left(toqstr(*it).indexOf(" ")); latexIndexCO->addItem(command, command); diff --git a/src/frontends/qt4/GuiPrefs.h b/src/frontends/qt4/GuiPrefs.h index c00c88e94d..2a82e5a99c 100644 --- a/src/frontends/qt4/GuiPrefs.h +++ b/src/frontends/qt4/GuiPrefs.h @@ -232,9 +232,9 @@ private Q_SLOTS: private: /// - std::vector bibtex_alternatives; + std::set bibtex_alternatives; /// - std::vector index_alternatives; + std::set index_alternatives; };