Next step: LayoutModuleList is now a thin wrapper around a list<string>.

It'll get its own methods later.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28468 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-02-12 15:07:22 +00:00
parent 4ae0333a99
commit 08d7f7885a
5 changed files with 56 additions and 20 deletions

View File

@ -13,6 +13,7 @@
#ifndef BASECLASSLIST_H #ifndef BASECLASSLIST_H
#define BASECLASSLIST_H #define BASECLASSLIST_H
#include "LayoutModuleList.h"
#include "TextClass.h" #include "TextClass.h"
#include "support/strfwd.h" #include "support/strfwd.h"
@ -65,13 +66,13 @@ public:
/// check whether the TeX class is available /// check whether the TeX class is available
bool isTeXClassAvailable() const { return texClassAvail_; } bool isTeXClassAvailable() const { return texClassAvail_; }
/// ///
std::list<std::string> const & defaultModules() const LayoutModuleList const & defaultModules() const
{ return default_modules_; } { return default_modules_; }
/// ///
std::list<std::string> const & providedModules() const LayoutModuleList const & providedModules() const
{ return provided_modules_; } { return provided_modules_; }
/// ///
std::list<std::string> const & excludedModules() const LayoutModuleList const & excludedModules() const
{ return excluded_modules_; } { return excluded_modules_; }
private: private:
/// Construct a layout with default values. Actual values loaded later. /// Construct a layout with default values. Actual values loaded later.

View File

@ -16,7 +16,39 @@
#include <string> #include <string>
namespace lyx { namespace lyx {
class LayoutModuleList {
public:
/// ///
typedef std::list<std::string> LayoutModuleList; typedef std::list<std::string>::const_iterator const_iterator;
///
typedef std::list<std::string>::iterator iterator;
///
iterator begin() { return lml_.begin(); }
///
iterator end() { return lml_.end(); }
///
const_iterator begin() const { return lml_.begin(); }
///
const_iterator end() const { return lml_.end(); }
///
void clear() { lml_.clear(); }
///
bool empty() const { return lml_.empty(); }
///
iterator erase(iterator pos) { return lml_.erase(pos); }
///
iterator insert(iterator pos, std::string const & str)
{ return lml_.insert(pos, str); }
///
void push_back(std::string const & str) { lml_.push_back(str); }
///
size_t size() const { return lml_.size(); }
/// This is needed in GuiDocument. It seems better than an
/// implicit conversion.
std::list<std::string> const & list() const { return lml_; }
private:
std::list<std::string> lml_;
};
} }
#endif #endif

View File

@ -34,6 +34,7 @@
#include "Language.h" #include "Language.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "Layout.h" #include "Layout.h"
#include "LayoutModuleList.h"
#include "LyXRC.h" #include "LyXRC.h"
#include "ModuleList.h" #include "ModuleList.h"
#include "OutputParams.h" #include "OutputParams.h"
@ -252,11 +253,11 @@ public:
upPB, downPB, availableModel, selectedModel), container_(container) upPB, downPB, availableModel, selectedModel), container_(container)
{} {}
/// ///
void updateProvidedModules(std::list<std::string> const & pm) void updateProvidedModules(LayoutModuleList const & pm)
{ provided_modules_ = pm; } { provided_modules_ = pm.list(); }
/// ///
void updateExcludedModules(std::list<std::string> const & em) void updateExcludedModules(LayoutModuleList const & em)
{ excluded_modules_ = em; } { excluded_modules_ = em.list(); }
private: private:
/// ///
virtual void updateAddPB(); virtual void updateAddPB();
@ -1409,7 +1410,7 @@ void GuiDocument::modulesToParams(BufferParams & bp)
// update the list of removed modules // update the list of removed modules
bp.clearRemovedModules(); bp.clearRemovedModules();
list<string> const & reqmods = bp.baseClass()->defaultModules(); LayoutModuleList const & reqmods = bp.baseClass()->defaultModules();
list<string>::const_iterator rit = reqmods.begin(); list<string>::const_iterator rit = reqmods.begin();
list<string>::const_iterator ren = reqmods.end(); list<string>::const_iterator ren = reqmods.end();
@ -1457,7 +1458,7 @@ void GuiDocument::updateModuleInfo()
string const modName = id_model.getIDString(idx.row()); string const modName = id_model.getIDString(idx.row());
docstring desc = getModuleDescription(modName); docstring desc = getModuleDescription(modName);
list<string> const & provmods = bp_.baseClass()->providedModules(); LayoutModuleList const & provmods = bp_.baseClass()->providedModules();
if (std::find(provmods.begin(), provmods.end(), modName) != provmods.end()) { if (std::find(provmods.begin(), provmods.end(), modName) != provmods.end()) {
if (!desc.empty()) if (!desc.empty())
desc += "\n"; desc += "\n";
@ -2282,10 +2283,10 @@ list<GuiDocument::modInfoStruct> const & GuiDocument::getModuleInfo()
list<GuiDocument::modInfoStruct> const list<GuiDocument::modInfoStruct> const
GuiDocument::makeModuleInfo(list<string> const & mods) GuiDocument::makeModuleInfo(LayoutModuleList const & mods)
{ {
list<string>::const_iterator it = mods.begin(); LayoutModuleList::const_iterator it = mods.begin();
list<string>::const_iterator end = mods.end(); LayoutModuleList::const_iterator end = mods.end();
list<modInfoStruct> mInfo; list<modInfoStruct> mInfo;
for (; it != end; ++it) { for (; it != end; ++it) {
modInfoStruct m; modInfoStruct m;

View File

@ -41,6 +41,7 @@ namespace lyx {
class BufferParams; class BufferParams;
class FloatPlacement; class FloatPlacement;
class LayoutModuleList;
class TextClass; class TextClass;
namespace frontend { namespace frontend {
@ -188,7 +189,7 @@ private:
std::list<modInfoStruct> const getProvidedModules(); std::list<modInfoStruct> const getProvidedModules();
/// ///
std::list<modInfoStruct> const std::list<modInfoStruct> const
makeModuleInfo(std::list<std::string> const & mods); makeModuleInfo(LayoutModuleList const & mods);
/// ///
void setLanguage() const; void setLanguage() const;
/// ///

View File

@ -27,6 +27,7 @@
#include "FuncStatus.h" #include "FuncStatus.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "LayoutFile.h" #include "LayoutFile.h"
#include "LayoutModuleList.h"
#include "LyX.h" #include "LyX.h"
#include "LyXFunc.h" #include "LyXFunc.h"
#include "LyXRC.h" #include "LyXRC.h"
@ -499,13 +500,13 @@ int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const
// Make sure modules used in child are all included in master // Make sure modules used in child are all included in master
//FIXME It might be worth loading the children's modules into the master //FIXME It might be worth loading the children's modules into the master
//over in BufferParams rather than doing this check. //over in BufferParams rather than doing this check.
list<string> const masterModules = masterBuffer->params().getModules(); LayoutModuleList const masterModules = masterBuffer->params().getModules();
list<string> const childModules = tmp->params().getModules(); LayoutModuleList const childModules = tmp->params().getModules();
list<string>::const_iterator it = childModules.begin(); LayoutModuleList::const_iterator it = childModules.begin();
list<string>::const_iterator end = childModules.end(); LayoutModuleList::const_iterator end = childModules.end();
for (; it != end; ++it) { for (; it != end; ++it) {
string const module = *it; string const module = *it;
list<string>::const_iterator found = LayoutModuleList::const_iterator found =
find(masterModules.begin(), masterModules.end(), module); find(masterModules.begin(), masterModules.end(), module);
if (found == masterModules.end()) { if (found == masterModules.end()) {
docstring text = bformat(_("Included file `%1$s'\n" docstring text = bformat(_("Included file `%1$s'\n"