]> git.lyx.org Git - features.git/commitdiff
Update GuiDocument when there are changes to loaded modules.
authorRichard Heck <rgheck@comcast.net>
Mon, 20 Oct 2008 19:31:05 +0000 (19:31 +0000)
committerRichard Heck <rgheck@comcast.net>
Mon, 20 Oct 2008 19:31:05 +0000 (19:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26994 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiDocument.h

index 912f98a31aa6f3c3b9b7ff694e9e71aff4819265..715d7da70a8e5502495dd27c3f9585d2055b6637 100644 (file)
@@ -955,7 +955,8 @@ GuiDocument::GuiDocument(GuiView & lv)
                this, SLOT(updateModuleInfo()));
        connect(selectionManager, SIGNAL(updateHook()),
                this, SLOT(change_adaptor()));
-
+       connect(selectionManager, SIGNAL(selectionChanged()),
+               this, SLOT(modulesChanged()));
 
        // PDF support
        pdfSupportModule = new UiWidget<Ui::PDFSupportUi>;
@@ -1424,6 +1425,42 @@ namespace {
 }
 
 
+void GuiDocument::modulesChanged()
+{
+       // update list of loaded modules
+       bp_.clearLayoutModules();
+       int const srows = modules_sel_model_.rowCount();
+       vector<string> selModList;
+       for (int i = 0; i < srows; ++i)
+               bp_.addLayoutModule(modules_sel_model_.getIDString(i));
+
+       // update the list of removed modules
+       bp_.clearRemovedModules();
+       list<string> const & reqmods = bp_.baseClass()->defaultModules();
+       list<string>::const_iterator rit = reqmods.begin();
+       list<string>::const_iterator ren = reqmods.end();
+
+       // check each of the default modules
+       for (; rit != ren; rit++) {
+               list<string>::const_iterator mit = bp_.getModules().begin();
+               list<string>::const_iterator men = bp_.getModules().end();
+               bool found = false;
+               for (; mit != men; mit++) {
+                       if (*rit == *mit) {
+                               found = true;
+                               break;
+                       }
+               }
+               if (!found) {
+                       // the module isn't present so must have been removed by the user
+                       bp_.addRemovedModule(*rit);
+               }
+       }
+       bp_.makeDocumentClass();
+       paramsToDialog();
+}
+
+
 void GuiDocument::updateModuleInfo()
 {
        selectionManager->update();
index 2f3dfc4396fad8d81073c3e982fa3e9f54e13785..6ba761fd74d853345ecc492d665f543e9f5e452b 100644 (file)
@@ -95,6 +95,7 @@ private Q_SLOTS:
        void browseMaster();
        void classChanged();
        void updateModuleInfo();
+       void modulesChanged();
 
 private:
        /// validate listings parameters and return an error message, if any