]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiDocument.cpp
Rationalize the handling of makeTextClass().
[lyx.git] / src / frontends / qt4 / GuiDocument.cpp
index d884e9b9f6bee74dfd9f7c522ffa5ff36b8ca946..19212fa525d37e1d83add8eb38153da2d0e9e9a4 100644 (file)
@@ -913,7 +913,7 @@ void GuiDocument::updatePagestyle(string const & items, string const & sel)
 void GuiDocument::classChanged()
 {
        textclass_type const tc = latexModule->classCO->currentIndex();
-       bp_.setJustBaseClass(tc);
+       bp_.setBaseClass(tc);
        if (lyxrc.auto_reset_options)
                bp_.useClassDefaults();
        updateContents();
@@ -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));
        }
 }
@@ -1089,13 +1097,15 @@ void GuiDocument::apply(BufferParams & params)
        params.graphicsDriver =
                tex_graphics[latexModule->psdriverCO->currentIndex()];
        
+       // text layout
+       params.setBaseClass(latexModule->classCO->currentIndex());
+
        // Modules
        params.clearLayoutModules();
        QStringList const selMods = selectedModel()->stringList();
        for (int i = 0; i != selMods.size(); ++i)
                params.addLayoutModule(lyx::fromqstr(selMods[i]));
 
-
        if (mathsModule->amsautoCB->isChecked()) {
                params.use_amsmath = BufferParams::package_auto;
        } else {
@@ -1114,9 +1124,6 @@ void GuiDocument::apply(BufferParams & params)
                        params.use_esint = BufferParams::package_off;
        }
 
-       // text layout
-       params.setJustBaseClass(latexModule->classCO->currentIndex());
-
        if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
                params.pagestyle = "default";
        else {
@@ -1631,7 +1638,7 @@ void GuiDocument::updateContents()
 
 void GuiDocument::useClassDefaults()
 {
-       bp_.setJustBaseClass(latexModule->classCO->currentIndex());
+       bp_.setBaseClass(latexModule->classCO->currentIndex());
        bp_.useClassDefaults();
        updateContents();
 }
@@ -1689,13 +1696,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<string>
-GuiDocument::getPackageList(string const & modName) const
+vector<string> GuiDocument::getPackageList(string const & modName) const
 {
        LyXModule const * const mod = moduleList[modName];
        if (!mod)
@@ -1704,6 +1710,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()];
@@ -1728,8 +1741,6 @@ void GuiDocument::dispatchParams()
 
        // Apply the BufferParams. Note that this will set the base class
        // and then update the buffer's layout.
-       //FIXME Could this be done last? Then, I think, we'd get the automatic
-       //update mentioned in the next FIXME...
        dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY);
 
        // Generate the colours requested by each new branch.