- 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();
- vector<string>::const_iterator en = reqs.end();
- for (; it != en; ++it) {
- if (find(selModStart, selModEnd, *it) != selModEnd) {
- foundOne = true;
- break;
- }
- }
- if (!foundOne) {
- addPB->setEnabled(false);
- return;
- }
- }
-
- // 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();
- for (; it != en; ++it) {
- if (find(selModStart, selModEnd, *it) != selModEnd) {
- addPB->setEnabled(false);
- return;
- }
- }
- }
-
- // ...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);