]> git.lyx.org Git - lyx.git/commitdiff
Fix doubling of bibtex and index alternatives everytime preferences are saved.
authorEnrico Forestieri <forenr@lyx.org>
Thu, 28 May 2009 12:49:41 +0000 (12:49 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Thu, 28 May 2009 12:49:41 +0000 (12:49 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29876 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyXRC.cpp
src/LyXRC.h
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiIndices.cpp
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/GuiPrefs.h

index 993fb3889f29dbbc170a1bc49d549592931e795f..b79d4be6e7c1a1b584fa45b8e1c22d9183eac539 100644 (file)
@@ -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<string>::const_iterator it = bibtex_alternatives.begin();
-               vector<string>::const_iterator end = bibtex_alternatives.end();
-               if (ignore_system_lyxrc) {
-                       for ( ; it != end; ++it)
+               set<string>::const_iterator it = bibtex_alternatives.begin();
+               set<string>::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<string>::const_iterator sbeg =
-                               system_lyxrc.bibtex_alternatives.begin();
-                       vector<string>::const_iterator send =
-                               system_lyxrc.bibtex_alternatives.end();
-                       for ( ; it != end; ++it) {
-                               bool found = false;
-                               for (vector<string>::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<string>::const_iterator it = index_alternatives.begin();
-               vector<string>::const_iterator end = index_alternatives.end();
-               if (ignore_system_lyxrc) {
-                       for ( ; it != end; ++it)
+               set<string>::const_iterator it = index_alternatives.begin();
+               set<string>::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<string>::const_iterator sbeg =
-                               system_lyxrc.index_alternatives.begin();
-                       vector<string>::const_iterator send =
-                               system_lyxrc.index_alternatives.end();
-                       for ( ; it != end; ++it) {
-                               bool found = false;
-                               for (vector<string>::const_iterator sit = sbeg;
-                                                       sit != send; ++sit) {
-                                       if (*it == *sit)
-                                               found = true;
-                               }
-                               if (!found)
-                                       os << "\\index_alternatives \""
-                                          << *it << "\"\n";
-                       }
                }
                if (tag != RC_LAST)
                        break;
index 23f1d9ccbbf1e06ff726c6518096b2b35fa565fa..a1004c360e901d9b3c4b51e9562723111b4617a5 100644 (file)
@@ -22,8 +22,8 @@
 
 #include "support/strfwd.h"
 
+#include <set>
 #include <string>
-#include <vector>
 
 
 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<std::string> bibtex_alternatives;
+       std::set<std::string> 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<std::string> index_alternatives;
+       std::set<std::string> index_alternatives;
        /// command to run makeindex incl. options or other index programs
        std::string index_command;
        /// command to run japanese index program incl. options
index ec015597e9f07b87b2b357ed932ba9abeda55330..7521e48332572f727fefd8288a1566e336a2581d 100644 (file)
@@ -871,7 +871,7 @@ GuiDocument::GuiDocument(GuiView & lv)
        biblioModule->bibtexCO->clear();
 
        biblioModule->bibtexCO->addItem(qt_("Default"), QString("default"));
-       for (vector<string>::const_iterator it = lyxrc.bibtex_alternatives.begin();
+       for (set<string>::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);
index 969b86ad5d22b4e5ff58d1556d63696c74823146..5e8c1b3d91aa14adae0f24e32916fe63213c6963 100644 (file)
@@ -54,7 +54,7 @@ GuiIndices::GuiIndices(QWidget * parent)
 
        indexCO->clear();
        indexCO->addItem(qt_("Default"), QString("default"));
-       for (vector<string>::const_iterator it = lyxrc.index_alternatives.begin();
+       for (set<string>::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);
index 818a3e2396aa0ac5243d976b2a40fc41564d02c1..48388bbd2ff9d2fb70668af387759ff4f74f5a77 100644 (file)
@@ -626,7 +626,7 @@ void PrefLatex::on_latexBibtexCO_activated(int n)
                latexBibtexOptionsLA->setText(qt_("C&ommand:"));
                return;
        }
-       for (vector<string>::const_iterator it = bibtex_alternatives.begin();
+       for (set<string>::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<string>::const_iterator it = index_alternatives.begin();
+       for (set<string>::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<string>::const_iterator it = rc.bibtex_alternatives.begin();
+       for (set<string>::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<string>::const_iterator it = rc.index_alternatives.begin();
+       for (set<string>::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);
index c00c88e94d0bda553127368b8ef38489e596ef48..2a82e5a99cff145eee023cb664d1fe6c45908b36 100644 (file)
@@ -232,9 +232,9 @@ private Q_SLOTS:
 
 private:
        ///
-       std::vector<std::string> bibtex_alternatives;
+       std::set<std::string> bibtex_alternatives;
        ///
-       std::vector<std::string> index_alternatives;
+       std::set<std::string> index_alternatives;
 };