mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
The last bit of cleanup: Make checking for exclusions a bit easier.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26924 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
297d5d1f4e
commit
a940cc3f6b
@ -64,6 +64,38 @@ bool LyXModule::isAvailable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LyXModule::isCompatible(string const & modName) const
|
||||||
|
{
|
||||||
|
// do we exclude it?
|
||||||
|
if (find(excludedModules.begin(), excludedModules.end(), modName) !=
|
||||||
|
excludedModules.end())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
LyXModule const * const lm = moduleList[modName];
|
||||||
|
if (!lm)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// does it exclude us?
|
||||||
|
vector<string> const excMods = lm->getExcludedModules();
|
||||||
|
if (find(excMods.begin(), excMods.end(), name) != excMods.end())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LyXModule::areCompatible(string const & mod1, string const & mod2)
|
||||||
|
{
|
||||||
|
LyXModule const * const lm1 = moduleList[mod1];
|
||||||
|
if (lm1)
|
||||||
|
return lm1->isCompatible(mod2);
|
||||||
|
LyXModule const * const lm2 = moduleList[mod2];
|
||||||
|
if (lm2)
|
||||||
|
return lm2->isCompatible(mod1);
|
||||||
|
// Can't check it either way.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// used when sorting the module list.
|
// used when sorting the module list.
|
||||||
class ModuleSorter
|
class ModuleSorter
|
||||||
{
|
{
|
||||||
@ -201,17 +233,6 @@ LyXModuleList::iterator ModuleList::end()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXModule * ModuleList::getModuleByName(string const & str)
|
|
||||||
{
|
|
||||||
LyXModuleList::iterator it = modlist_.begin();
|
|
||||||
for (; it != modlist_.end(); ++it)
|
|
||||||
if (it->getName() == str) {
|
|
||||||
LyXModule & mod = *it;
|
|
||||||
return &mod;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
LyXModule * ModuleList::operator[](string const & str)
|
LyXModule * ModuleList::operator[](string const & str)
|
||||||
{
|
{
|
||||||
LyXModuleList::iterator it = modlist_.begin();
|
LyXModuleList::iterator it = modlist_.begin();
|
||||||
|
@ -24,7 +24,6 @@ namespace lyx {
|
|||||||
* a LaTeX package, where a layout file corresponds to a LaTeX class.
|
* a LaTeX package, where a layout file corresponds to a LaTeX class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//FIXME Give us some access functions here.
|
|
||||||
class LyXModule {
|
class LyXModule {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
@ -51,7 +50,13 @@ public:
|
|||||||
/// Modules this one excludes: the list should be treated disjunctively
|
/// Modules this one excludes: the list should be treated disjunctively
|
||||||
std::vector<std::string> const & getExcludedModules() const
|
std::vector<std::string> const & getExcludedModules() const
|
||||||
{ return excludedModules; }
|
{ return excludedModules; }
|
||||||
|
/// \return true if the module is compatible with this one, i.e.,
|
||||||
|
/// it does not exclude us and we do not exclude it.
|
||||||
|
/// this will also return true if modName is unknown and we do not
|
||||||
|
/// exclude it, since in that case we cannot check its exclusions.
|
||||||
|
bool isCompatible(std::string const & modName) const;
|
||||||
|
///
|
||||||
|
static bool areCompatible(std::string const & mod1, std::string const & mod2);
|
||||||
private:
|
private:
|
||||||
/// what appears in the ui
|
/// what appears in the ui
|
||||||
std::string name;
|
std::string name;
|
||||||
@ -96,13 +101,10 @@ public:
|
|||||||
LyXModuleList::iterator end();
|
LyXModuleList::iterator end();
|
||||||
///
|
///
|
||||||
bool empty() const { return modlist_.empty(); }
|
bool empty() const { return modlist_.empty(); }
|
||||||
/// Returns a pointer to the LyXModule with name str.
|
|
||||||
/// Returns a null pointer if no such module is found.
|
|
||||||
LyXModule * getModuleByName(std::string const & str);
|
|
||||||
/// Returns a pointer to the LyXModule with filename str.
|
/// Returns a pointer to the LyXModule with filename str.
|
||||||
/// Returns a null pointer if no such module is found.
|
/// Returns a null pointer if no such module is found.
|
||||||
LyXModule * operator[](std::string const & str);
|
LyXModule * operator[](std::string const & str);
|
||||||
private:
|
private:
|
||||||
/// noncopyable
|
/// noncopyable
|
||||||
ModuleList(ModuleList const &);
|
ModuleList(ModuleList const &);
|
||||||
///
|
///
|
||||||
|
@ -316,28 +316,11 @@ void ModuleSelectionManager::updateAddPB()
|
|||||||
return;
|
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.
|
// Check for conflicts with used modules
|
||||||
vector<string>::const_iterator selModIt = selModStart;
|
vector<string>::const_iterator selModIt = selModStart;
|
||||||
for (; selModIt != selModEnd; ++selModIt) {
|
for (; selModIt != selModEnd; ++selModIt) {
|
||||||
string selMod = *selModIt;
|
if (!LyXModule::areCompatible(modName, *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);
|
addPB->setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user