From 80e98c5b715f7f239d67dc8d96f4db311c5c0fd3 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sat, 5 Jan 2008 16:56:30 +0000 Subject: [PATCH] Implement checks for available modules both in BufferParams and in the gui. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22387 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferParams.cpp | 7 +++++++ src/frontends/qt4/GuiDocument.cpp | 24 +++++++++++++++++++----- src/frontends/qt4/GuiDocument.h | 2 ++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 11145b8189..dc2823911d 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1413,6 +1413,13 @@ void BufferParams::makeTextClass() endl; continue; } + if (!lm->isAvailable()) { + docstring const msg = + bformat(_("The module %1$s requires a package that is\n" + "not available in your LaTeX installation. LaTeX output\n" + "may not be possible.\n"), from_utf8(modName)); + frontend::Alert::warning(_("Package not available"), msg); + } FileName layout_file = libFileSearch("layouts", lm->filename); textClass_->read(layout_file, TextClass::MODULE); } diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index d884e9b9f6..7063e9e0e2 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -951,8 +951,16 @@ void GuiDocument::updateModuleInfo() } pkgdesc += pkgList[i]; } - if (!pkgdesc.empty()) - desc += " Requires " + pkgdesc + "."; + if (!pkgdesc.empty()) { + if (!desc.empty()) + desc += " "; + desc += ("Requires " + pkgdesc + "."); + } + if (!isModuleAvailable(modName)) { + if (!desc.empty()) + desc += "\n"; + desc += "WARNING: Some packages are unavailable!"; + } latexModule->infoML->document()->setPlainText(toqstr(desc)); } } @@ -1689,13 +1697,12 @@ string GuiDocument::getModuleDescription(string const & modName) const { LyXModule const * const mod = moduleList[modName]; if (!mod) - return string("Module unavailable!"); + return string("Module not found!"); return mod->description; } -vector -GuiDocument::getPackageList(string const & modName) const +vector GuiDocument::getPackageList(string const & modName) const { LyXModule const * const mod = moduleList[modName]; if (!mod) @@ -1704,6 +1711,13 @@ GuiDocument::getPackageList(string const & modName) const } +bool GuiDocument::isModuleAvailable(string const & modName) const +{ + LyXModule * mod = moduleList[modName]; + return mod->isAvailable(); +} + + TextClass const & GuiDocument::textClass() const { return textclasslist[bp_.getBaseClass()]; diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h index 5fb2e30828..90a93f8314 100644 --- a/src/frontends/qt4/GuiDocument.h +++ b/src/frontends/qt4/GuiDocument.h @@ -186,6 +186,8 @@ protected: /// std::vector getPackageList(std::string const & modName) const; /// + bool isModuleAvailable(std::string const & modName) const; + /// void setLanguage() const; /// void saveAsDefault() const; -- 2.39.2