]> git.lyx.org Git - lyx.git/commitdiff
Fix a bug involving module conflicts. We need to check not only that we
authorRichard Heck <rgheck@comcast.net>
Thu, 16 Oct 2008 15:04:48 +0000 (15:04 +0000)
committerRichard Heck <rgheck@comcast.net>
Thu, 16 Oct 2008 15:04:48 +0000 (15:04 +0000)
do not exclude some used module, but also that no used module excludes us.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26920 a592a061-630c-0410-9148-cb99ea01b6c8

lib/layouts/g-brief2.layout
src/frontends/qt4/GuiDocument.cpp

index ad42d4f3c8ed1f56c14b327ce93172e13bc476a5..237022d6e4547e0d3bcb222c4fa246bd28ddc962 100644 (file)
@@ -11,7 +11,7 @@ Input stdcounters.inc
 Input stdinsets.inc
 
 # General textclass parameters
-Format 10
+Format 11
 Columns                        1
 Sides                  1
 PageStyle              Empty
index 5d126f5e357002c7acfa6551d778c6b858b815cc..e3132d7bef701f538f5be64b801496b41f0eefa8 100644 (file)
@@ -274,30 +274,33 @@ void ModuleSelectionManager::updateAddPB()
        int const arows = availableModel->rowCount();
        QModelIndexList const availSels = 
                        availableLV->selectionModel()->selectedIndexes();
-       if (arows == 0 || availSels.isEmpty()  || isSelected(availSels.first())) {
+
+       // disable if there aren't any modules (?), if none of them is chosen
+       // in the dialog, or if the chosen one is already selected for use.
+       if (arows == 0 || availSels.isEmpty() || isSelected(availSels.first())) {
                addPB->setEnabled(false);
                return;
        }
-       
+
        QModelIndex const & idx = availableLV->selectionModel()->currentIndex();
        string const modName = getAvailableModel()->getIDString(idx.row());
-       vector<string> const reqs = getRequiredList(modName);
-       vector<string> const excl = getExcludedList(modName);
-       
-       if (reqs.empty() && excl.empty()) {
-               addPB->setEnabled(true);
-               return;
-       }
 
        int const srows = selectedModel->rowCount();
+       // if no modules are yet selected, there is no more to check.
+       if (srows == 0) {
+               addPB->setEnabled(true);
+               return;
+       }
+
        vector<string> selModList;
        for (int i = 0; i < srows; ++i)
                selModList.push_back(getSelectedModel()->getIDString(i));
 
        vector<string>::const_iterator const selModStart = selModList.begin();
        vector<string>::const_iterator const selModEnd   = selModList.end();
-       
+
        // Check whether some required module is available
+       vector<string> const reqs = getRequiredList(modName);
        if (!reqs.empty()) {
                bool foundOne = false;
                vector<string>::const_iterator it = reqs.begin();
@@ -314,7 +317,8 @@ void ModuleSelectionManager::updateAddPB()
                }
        }
        
-       // Check whether any excluded module is being used
+       // Check whether any excluded module is being used...
+       vector<string> const excl = getExcludedList(modName);
        if (!excl.empty()) {
                vector<string>::const_iterator it = excl.begin();
                vector<string>::const_iterator en = excl.end();
@@ -326,6 +330,19 @@ void ModuleSelectionManager::updateAddPB()
                }
        }
 
+       // ...and whether any used module excludes us.
+       vector<string>::const_iterator selModIt = selModStart;
+       for (; selModIt != selModEnd; ++selModIt) {
+               string selMod = *selModIt;
+               vector<string> excMods = getExcludedList(selMod);
+               vector<string>::const_iterator const eit = excMods.begin();
+               vector<string>::const_iterator const een = excMods.end();
+               if (find(eit, een, modName) != een) {
+                       addPB->setEnabled(false);
+                       return;
+               }
+       }
+
        addPB->setEnabled(true);
 }