// Ordering criteria:
// 1. Availability of text class
// 2. Description (lexicographic)
- TextClass const & tc1 = BaseClassList::get()[lhs];
- TextClass const & tc2 = BaseClassList::get()[rhs];
+ LayoutFile const & tc1 = BaseClassList::get()[lhs];
+ LayoutFile const & tc2 = BaseClassList::get()[rhs];
return (tc1.isTeXClassAvailable() && !tc2.isTeXClassAvailable()) ||
(tc1.isTeXClassAvailable() == tc2.isTeXClassAvailable() &&
_(tc1.description()) < _(tc2.description()));
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<BaseClassIndex> classList = bcl.classList();
+ vector<LayoutFileIndex> classList = bcl.classList();
sort(classList.begin(), classList.end(), less_textclass_avail_desc());
- vector<BaseClassIndex>::const_iterator cit = classList.begin();
- vector<BaseClassIndex>::const_iterator cen = classList.end();
+ vector<LayoutFileIndex>::const_iterator cit = classList.begin();
+ vector<LayoutFileIndex>::const_iterator cen = classList.end();
for (int i = 0; cit != cen; ++cit, ++i) {
- TextClass const & tc = bcl[*cit];
+ LayoutFile const & tc = bcl[*cit];
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
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;
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)
}
// 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);
}
+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() &&