]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiDocument.cpp
Kill indexing into the list of layouts.
[lyx.git] / src / frontends / qt4 / GuiDocument.cpp
index e2309bfbef992e9f0cb270a2922f6ef46d2bb5d1..9d0633586977bb207b5f8869ff61a420f5d827bd 100644 (file)
@@ -901,9 +901,6 @@ GuiDocument::GuiDocument(GuiView & lv)
                latexModule->psdriverCO->addItem(enc);
        }
        // latex classes
-       //FIXME This seems too involved with the kernel. Some of this
-       //should be moved to the kernel---which should perhaps just
-       //give us a list of entries or something of the sort.
        latexModule->classCO->setModel(&classes_model_);
        BaseClassList const & bcl = BaseClassList::get();
        vector<LayoutFileIndex> classList = bcl.classList();
@@ -916,7 +913,7 @@ GuiDocument::GuiDocument(GuiView & lv)
                docstring item = (tc.isTeXClassAvailable()) ?
                        from_utf8(tc.description()) :
                        bformat(_("Unavailable: %1$s"), from_utf8(tc.description()));
-               classes_model_.insertRow(i, toqstr(item), tc.name());
+               classes_model_.insertRow(i, toqstr(item), *cit);
        }
 
        // branches
@@ -986,22 +983,22 @@ GuiDocument::GuiDocument(GuiView & lv)
        connect(floatModule, SIGNAL(changed()),
                this, SLOT(change_adaptor()));
 
-       docPS->addPanel(latexModule, _("Document Class"));
-       docPS->addPanel(fontModule, _("Fonts"));
-       docPS->addPanel(textLayoutModule, _("Text Layout"));
-       docPS->addPanel(pageLayoutModule, _("Page Layout"));
-       docPS->addPanel(marginsModule, _("Page Margins"));
-       docPS->addPanel(langModule, _("Language"));
-       docPS->addPanel(numberingModule, _("Numbering & TOC"));
-       docPS->addPanel(biblioModule, _("Bibliography"));
-       docPS->addPanel(pdfSupportModule, _("PDF Properties"));
-       docPS->addPanel(mathsModule, _("Math Options"));
-       docPS->addPanel(floatModule, _("Float Placement"));
-       docPS->addPanel(bulletsModule, _("Bullets"));
-       docPS->addPanel(branchesModule, _("Branches"));
-       docPS->addPanel(embeddedFilesModule, _("Embedded Files"));
-       docPS->addPanel(preambleModule, _("LaTeX Preamble"));
-       docPS->setCurrentPanel(_("Document Class"));
+       docPS->addPanel(latexModule, qt_("Document Class"));
+       docPS->addPanel(fontModule, qt_("Fonts"));
+       docPS->addPanel(textLayoutModule, qt_("Text Layout"));
+       docPS->addPanel(pageLayoutModule, qt_("Page Layout"));
+       docPS->addPanel(marginsModule, qt_("Page Margins"));
+       docPS->addPanel(langModule, qt_("Language"));
+       docPS->addPanel(numberingModule, qt_("Numbering & TOC"));
+       docPS->addPanel(biblioModule, qt_("Bibliography"));
+       docPS->addPanel(pdfSupportModule, qt_("PDF Properties"));
+       docPS->addPanel(mathsModule, qt_("Math Options"));
+       docPS->addPanel(floatModule, qt_("Float Placement"));
+       docPS->addPanel(bulletsModule, qt_("Bullets"));
+       docPS->addPanel(branchesModule, qt_("Branches"));
+       docPS->addPanel(embeddedFilesModule, qt_("Embedded Files"));
+       docPS->addPanel(preambleModule, qt_("LaTeX Preamble"));
+       docPS->setCurrentPanel(qt_("Document Class"));
 // FIXME: hack to work around resizing bug in Qt >= 4.2
 // bug verified with Qt 4.2.{0-3} (JSpitzm)
 #if QT_VERSION >= 0x040200
@@ -1012,7 +1009,7 @@ GuiDocument::GuiDocument(GuiView & lv)
 
 void GuiDocument::showPreamble()
 {
-       docPS->setCurrentPanel(_("LaTeX Preamble"));
+       docPS->setCurrentPanel(qt_("LaTeX Preamble"));
 }
 
 
@@ -1245,6 +1242,20 @@ void GuiDocument::classChanged()
        if (idx < 0) 
                return;
        string const classname = classes_model_.getIDString(idx);
+       // check if this is a local layout file
+       if (prefixIs(classname, BaseClassList::localPrefix)) {
+               int const ret = Alert::prompt(_("Local layout file"),
+                               _("The layout file you have selected is a local layout\n"
+                                 "file, not one in the system or user directory. Your\n"
+                                 "document may not work with this layout if you do not\n"
+                                 "keep the layout file in the same directory."),
+                                 1, 1, _("&Set Layout"), _("&Cancel"));
+               if (ret == 1) {
+                       // try to reset the layout combo
+                       setLayoutComboByIDString(bp_.baseClassID());
+                       return;
+               }
+       }
        if (!bp_.setBaseClass(classname)) {
                Alert::error(_("Error"), _("Unable to set document class."));
                return;
@@ -1252,7 +1263,7 @@ void GuiDocument::classChanged()
        if (lyxrc.auto_reset_options) {
                if (applyPB->isEnabled()) {
                        int const ret = Alert::prompt(_("Unapplied changes"),
-                                       _("Some changes in the dialog were not yet applied."
+                                       _("Some changes in the dialog were not yet applied.\n"
                                        "If you do not apply now, they will be lost after this action."),
                                        1, 1, _("&Apply"), _("&Dismiss"));
                        if (ret == 0)
@@ -1399,8 +1410,11 @@ void GuiDocument::updateNumbering()
        QString const no = qt_("No");
        QString const yes = qt_("Yes");
        QTreeWidgetItem * item = 0;
-       for (size_t i = 0; i != tclass.layoutCount(); ++i) {
-               Layout const & lt = *tclass.layout(i);
+
+       DocumentClass::const_iterator lit = tclass.begin();
+       DocumentClass::const_iterator len = tclass.end();
+       for (; lit != len; ++lit) {
+               Layout const & lt = **lit;
                int const toclevel = lt.toclevel;
                if (toclevel != Layout::NOT_IN_TOC && lt.labeltype == LABEL_COUNTER) {
                        item = new QTreeWidgetItem(numberingModule->tocTW);
@@ -1686,7 +1700,8 @@ void GuiDocument::apply(BufferParams & params)
                pdf.pagemode = pdf.pagemode_fullscreen;
        else
                pdf.pagemode.clear();
-       pdf.quoted_options = fromqstr(pdfSupportModule->optionsLE->text());
+       pdf.quoted_options = pdf.quoted_options_check(
+                               fromqstr(pdfSupportModule->optionsLE->text()));
 
        // Embedded files
        // FIXME
@@ -1832,12 +1847,8 @@ void GuiDocument::updateParams(BufferParams const & params)
        }
 
        // text layout
-       string const & classname = params.baseClass()->name();
-       int idx = classes_model_.findIDString(classname);
-       if (idx < 0)
-               lyxerr << "Unable to set layout for classname " << classname << std::endl;
-       else 
-               latexModule->classCO->setCurrentIndex(idx);
+       string const & layoutID = params.baseClassID();
+       setLayoutComboByIDString(layoutID);
 
        updatePagestyle(documentClass().opt_pagestyle(),
                                 params.pagestyle);
@@ -2096,6 +2107,17 @@ void GuiDocument::useClassDefaults()
 }
 
 
+void GuiDocument::setLayoutComboByIDString(std::string const & idString)
+{
+       int idx = classes_model_.findIDString(idString);
+       if (idx < 0)
+               Alert::warning(_("Can't set layout!"), 
+                       bformat(_("Unable to set layout for ID: %1$s"), from_utf8(idString)));
+       else 
+               latexModule->classCO->setCurrentIndex(idx);
+}
+
+
 bool GuiDocument::isValid()
 {
        return (validate_listings_params().empty() &&