#include "BufferView.h"
#include "Color.h"
#include "ColorCache.h"
+#include "Converter.h"
#include "Cursor.h"
#include "Encoding.h"
#include "FloatPlacement.h"
#include "Spacing.h"
#include "TextClass.h"
#include "Undo.h"
+#include "VSpace.h"
#include "insets/InsetListingsParams.h"
#include <QCloseEvent>
#include <QFontDatabase>
#include <QScrollBar>
+#include <QTextBoundaryFinder>
#include <QTextCursor>
#include <sstream>
{
// This is not a memory leak. The object will be destroyed
// with this.
- (void) new LaTeXHighlighter(preambleTE->document());
+ // @ is letter in the LyX user preamble
+ (void) new LaTeXHighlighter(preambleTE->document(), true);
+ preambleTE->setFont(guiApp->typewriterSystemFont());
+ preambleTE->setWordWrapMode(QTextOption::NoWrap);
setFocusProxy(preambleTE);
connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
}
void PreambleModule::apply(BufferParams & params)
{
- params.preamble = fromqstr(preambleTE->document()->toPlainText());
+ params.preamble = qstring_to_ucs4(preambleTE->document()->toPlainText());
}
void LocalLayout::apply(BufferParams & params)
{
- string const layout = fromqstr(locallayoutTE->document()->toPlainText());
+ docstring const layout =
+ qstring_to_ucs4(locallayoutTE->document()->toPlainText());
params.setLocalLayout(layout, false);
}
+void LocalLayout::hideConvert()
+{
+ convertPB->setEnabled(false);
+ convertLB->setText("");
+ convertPB->hide();
+ convertLB->hide();
+}
+
+
void LocalLayout::textChanged()
{
static const QString message =
validated_ = true;
validatePB->setEnabled(false);
validLB->setText("");
- convertPB->hide();
- convertLB->hide();
+ hideConvert();
changed();
} else if (!validatePB->isEnabled()) {
// if that's already enabled, we shouldn't need to do anything.
validated_ = false;
validLB->setText(message);
validatePB->setEnabled(true);
- convertPB->setEnabled(false);
+ hideConvert();
changed();
}
}
string const layout =
fromqstr(locallayoutTE->document()->toPlainText().trimmed());
string const newlayout = TextClass::convert(layout);
- LYXERR0(newlayout);
- if (newlayout.empty()) {
- Alert::error(_("Conversion Failed!"),
- _("Failed to convert local layout to current format."));
- } else {
+ if (!newlayout.empty())
locallayoutTE->setPlainText(toqstr(newlayout));
- }
validate();
}
void LocalLayout::convertPressed() {
convert();
+ hideConvert();
changed();
}
void LocalLayout::validate() {
- static const QString valid = qt_("Layout is valid!");
- static const QString vtext =
- toqstr("<p style=\"font-weight: bold; \">")
- + valid + toqstr("</p>");
- static const QString invalid = qt_("Layout is invalid!");
- static const QString ivtext =
- toqstr("<p style=\"color: #c00000; font-weight: bold; \">")
- + invalid + toqstr("</p>");
-
+ // Bold text
+ static const QString vpar("<p style=\"font-weight: bold;\">%1</p>");
+ // Flashy red bold text
+ static const QString ivpar("<p style=\"color: #c00000; font-weight: bold; \">"
+ "%1</p>");
string const layout =
fromqstr(locallayoutTE->document()->toPlainText().trimmed());
if (!layout.empty()) {
TextClass::ReturnValues const ret = TextClass::validate(layout);
validated_ = (ret == TextClass::OK) || (ret == TextClass::OK_OLDFORMAT);
validatePB->setEnabled(false);
- validLB->setText(validated_ ? vtext : ivtext);
+ validLB->setText(validated_ ? vpar.arg(qt_("Layout is valid!"))
+ : ivpar.arg(qt_("Layout is invalid!")));
if (ret == TextClass::OK_OLDFORMAT) {
convertPB->show();
- convertPB->setEnabled(true);
- convertLB->setText(qt_("Convert to current format"));
+ // Testing conversion to LYXFILE_LAYOUT_FORMAT at this point
+ // already.
+ if (TextClass::convert(layout).empty()) {
+ // Conversion failed. If LAYOUT_FORMAT > LYXFILE_LAYOUT_FORMAT,
+ // then maybe the layout is still valid, but its format is more
+ // recent than LYXFILE_LAYOUT_FORMAT. However, if LAYOUT_FORMAT
+ // == LYXFILE_LAYOUT_FORMAT then something is definitely wrong.
+ convertPB->setEnabled(false);
+ const QString text = (LAYOUT_FORMAT == LYXFILE_LAYOUT_FORMAT)
+ ? ivpar.arg(qt_("Conversion to current format impossible!"))
+ : vpar.arg(qt_("Conversion to current stable format "
+ "impossible."));
+ convertLB->setText(text);
+ } else {
+ convertPB->setEnabled(true);
+ convertLB->setText(qt_("Convert to current format"));
+ }
convertLB->show();
} else {
convertPB->hide();
GuiDocument::GuiDocument(GuiView & lv)
: GuiDialog(lv, "document", qt_("Document Settings")),
- nonModuleChanged_(false)
+ biblioChanged_(false), nonModuleChanged_(false)
{
setupUi(this);
textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
textLayoutModule->lspacingLE));
- textLayoutModule->indentLE->setValidator(unsignedLengthValidator(
+ textLayoutModule->indentLE->setValidator(new LengthValidator(
textLayoutModule->indentLE));
- textLayoutModule->skipLE->setValidator(unsignedGlueLengthValidator(
+ textLayoutModule->skipLE->setValidator(new LengthValidator(
textLayoutModule->skipLE));
textLayoutModule->indentCO->addItem(qt_("Default"));
masterChildModule->childrenTW->resizeColumnToContents(2);
- // output
+ // Formats
outputModule = new UiWidget<Ui::OutputUi>;
connect(outputModule->defaultFormatCO, SIGNAL(activated(int)),
outputModule->synccustomCB->setValidator(new NoNewLineValidator(
outputModule->synccustomCB));
+ connect(outputModule->saveTransientPropertiesCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+
// fonts
- fontModule = new UiWidget<Ui::FontUi>;
+ fontModule = new FontModule;
connect(fontModule->osFontsCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(fontModule->osFontsCB, SIGNAL(toggled(bool)),
this, SLOT(change_adaptor()));
connect(fontModule->cjkFontLE, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
+ connect(fontModule->microtypeCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
this, SLOT(change_adaptor()));
connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
this, SLOT(change_adaptor()));
connect(marginsModule->columnsepUnit, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
- marginsModule->topLE->setValidator(unsignedLengthValidator(
+ marginsModule->topLE->setValidator(new LengthValidator(
marginsModule->topLE));
- marginsModule->bottomLE->setValidator(unsignedLengthValidator(
+ marginsModule->bottomLE->setValidator(new LengthValidator(
marginsModule->bottomLE));
- marginsModule->innerLE->setValidator(unsignedLengthValidator(
+ marginsModule->innerLE->setValidator(new LengthValidator(
marginsModule->innerLE));
- marginsModule->outerLE->setValidator(unsignedLengthValidator(
+ marginsModule->outerLE->setValidator(new LengthValidator(
marginsModule->outerLE));
- marginsModule->headsepLE->setValidator(unsignedLengthValidator(
+ marginsModule->headsepLE->setValidator(new LengthValidator(
marginsModule->headsepLE));
- marginsModule->headheightLE->setValidator(unsignedLengthValidator(
+ marginsModule->headheightLE->setValidator(new LengthValidator(
marginsModule->headheightLE));
- marginsModule->footskipLE->setValidator(unsignedLengthValidator(
+ marginsModule->footskipLE->setValidator(new LengthValidator(
marginsModule->footskipLE));
- marginsModule->columnsepLE->setValidator(unsignedLengthValidator(
+ marginsModule->columnsepLE->setValidator(new LengthValidator(
marginsModule->columnsepLE));
bc().addCheckedLineEdit(marginsModule->topLE,
this, SLOT(change_adaptor()));
connect(langModule->languagePackageCO, SIGNAL(currentIndexChanged(int)),
this, SLOT(languagePackageChanged(int)));
+ connect(langModule->dynamicQuotesCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
langModule->languagePackageLE->setValidator(new NoNewLineValidator(
langModule->languagePackageLE));
encodinglist.sort();
langModule->encodingCO->addItems(encodinglist);
- langModule->quoteStyleCO->addItem(
- qt_("``text''"),InsetQuotes::EnglishQuotes);
- langModule->quoteStyleCO->addItem(
- qt_("''text''"), InsetQuotes::SwedishQuotes);
- langModule->quoteStyleCO->addItem
- (qt_(",,text``"), InsetQuotes::GermanQuotes);
- langModule->quoteStyleCO->addItem(
- qt_(",,text''"), InsetQuotes::PolishQuotes);
- langModule->quoteStyleCO->addItem(
- qt_("<<text>>"), InsetQuotes::FrenchQuotes);
- langModule->quoteStyleCO->addItem(
- qt_(">>text<<"), InsetQuotes::DanishQuotes);
+ for (int i = 0; i < quoteparams.stylescount(); ++i) {
+ InsetQuotesParams::QuoteStyle qs = InsetQuotesParams::QuoteStyle(i);
+ if (qs == InsetQuotesParams::DynamicQuotes)
+ continue;
+ langModule->quoteStyleCO->addItem(toqstr(quoteparams.getGuiLabel(qs)), qs);
+ }
langModule->languagePackageCO->addItem(
qt_("Default"), toqstr("default"));
QString tooltip = toqstr(bformat(_("%1$s [Class '%2$s']"), guiname, from_utf8(tc.latexname())));
if (!available) {
docstring const output_type = (tc.outputType() == lyx::DOCBOOK) ? _("DocBook") : _("LaTeX");
- tooltip += '\n' + toqstr(wrap(bformat(_("Class not found by LyX. "
+ tooltip += '\n' + toqstr(bformat(_("Class not found by LyX. "
"Please check if you have the matching %1$s class "
"and all required packages (%2$s) installed."),
- output_type, from_utf8(tc.prerequisites(", ")))));
+ output_type, from_utf8(tc.prerequisites(", "))));
}
latexModule->classCO->addItemSort(toqstr(tc.name()),
toqstr(guiname),
docPS->addPanel(listingsModule, N_("Listings[[inset]]"));
docPS->addPanel(bulletsModule, N_("Bullets"));
docPS->addPanel(branchesModule, N_("Branches"));
- docPS->addPanel(outputModule, N_("Output"));
+ docPS->addPanel(outputModule, N_("Formats[[output]]"));
docPS->addPanel(preambleModule, N_("LaTeX Preamble"));
docPS->setCurrentPanel("Document Class");
// FIXME: hack to work around resizing bug in Qt >= 4.2
}
+void GuiDocument::onBufferViewChanged()
+{
+ if (isVisibleView())
+ initialiseParams("");
+}
+
+
void GuiDocument::saveDefaultClicked()
{
saveDocDefault();
QString GuiDocument::validateListingsParameters()
{
- // use a cache here to avoid repeated validation
- // of the same parameters
- // FIXME THREAD
- static string param_cache;
- static QString msg_cache;
-
if (listingsModule->bypassCB->isChecked())
return QString();
-
string params = fromqstr(listingsModule->listingsED->toPlainText());
- if (params != param_cache) {
- param_cache = params;
- msg_cache = toqstr(InsetListingsParams(params).validate());
- }
- return msg_cache;
+ return toqstr(InsetListingsParams(params).validate());
}
void GuiDocument::languageChanged(int i)
{
- // some languages only work with polyglossia/XeTeX
+ // some languages only work with polyglossia
Language const * lang = lyx::languages.getLanguage(
fromqstr(langModule->languageCO->itemData(i).toString()));
if (lang->babel().empty() && !lang->polyglossia().empty()) {
void GuiDocument::osFontsChanged(bool nontexfonts)
{
bool const tex_fonts = !nontexfonts;
+ // store current fonts
+ QString const font_roman = fontModule->fontsRomanCO->itemData(
+ fontModule->fontsRomanCO->currentIndex()).toString();
+ QString const font_sans = fontModule->fontsSansCO->itemData(
+ fontModule->fontsSansCO->currentIndex()).toString();
+ QString const font_typewriter = fontModule->fontsTypewriterCO->itemData(
+ fontModule->fontsTypewriterCO->currentIndex()).toString();
+ QString const font_math = fontModule->fontsMathCO->itemData(
+ fontModule->fontsMathCO->currentIndex()).toString();
+ int const font_sf_scale = fontModule->scaleSansSB->value();
+ int const font_tt_scale = fontModule->scaleTypewriterSB->value();
+
updateFontlist();
// store default format
QString const dformat = outputModule->defaultFormatCO->itemData(
if (index == -1)
index = 0;
outputModule->defaultFormatCO->setCurrentIndex(index);
+
+ // try to restore fonts which were selected two toggles ago
+ index = fontModule->fontsRomanCO->findData(fontModule->font_roman);
+ if (index != -1)
+ fontModule->fontsRomanCO->setCurrentIndex(index);
+ index = fontModule->fontsSansCO->findData(fontModule->font_sans);
+ if (index != -1)
+ fontModule->fontsSansCO->setCurrentIndex(index);
+ index = fontModule->fontsTypewriterCO->findData(fontModule->font_typewriter);
+ if (index != -1)
+ fontModule->fontsTypewriterCO->setCurrentIndex(index);
+ index = fontModule->fontsMathCO->findData(fontModule->font_math);
+ if (index != -1)
+ fontModule->fontsMathCO->setCurrentIndex(index);
+ // save fonts for next next toggle
+ fontModule->font_roman = font_roman;
+ fontModule->font_sans = font_sans;
+ fontModule->font_typewriter = font_typewriter;
+ fontModule->font_math = font_math;
+ fontModule->font_sf_scale = font_sf_scale;
+ fontModule->font_tt_scale = font_tt_scale;
+
langModule->encodingCO->setEnabled(tex_fonts &&
!langModule->defaultencodingRB->isChecked());
langModule->defaultencodingRB->setEnabled(tex_fonts);
return (fontModule->fontsSansCO->itemData(
fontModule->fontsSansCO->currentIndex()).toString() == "default"
&& fontModule->fontsSansCO->itemData(
- fontModule->fontsSansCO->currentIndex()).toString() == "default");
+ fontModule->fontsTypewriterCO->currentIndex()).toString() == "default");
}
outputModule->defaultFormatCO->clear();
outputModule->defaultFormatCO->addItem(qt_("Default"),
QVariant(QString("default")));
- typedef vector<Format const *> Formats;
- Formats formats = param_copy.exportableFormats(true);
- sort(formats.begin(), formats.end(), Format::formatSorter);
- Formats::const_iterator cit = formats.begin();
- Formats::const_iterator end = formats.end();
- for (; cit != end; ++cit)
- outputModule->defaultFormatCO->addItem(qt_((*cit)->prettyname()),
- QVariant(toqstr((*cit)->name())));
+ FormatList const & formats =
+ param_copy.exportableFormats(true);
+ for (Format const * f : formats)
+ outputModule->defaultFormatCO->addItem
+ (toqstr(translateIfPossible(f->prettyname())),
+ QVariant(toqstr(f->name())));
outputModule->defaultFormatCO->blockSignals(false);
}
}
}
- bp_.quotes_language = (InsetQuotes::QuoteLanguage) langModule->quoteStyleCO->itemData(
+ bp_.quotes_style = (InsetQuotesParams::QuoteStyle) langModule->quoteStyleCO->itemData(
langModule->quoteStyleCO->currentIndex()).toInt();
+ bp_.dynamic_quotes = langModule->dynamicQuotesCB->isChecked();
QString const langname = langModule->languageCO->itemData(
langModule->languageCO->currentIndex()).toString();
bp_.listings_params =
InsetListingsParams(fromqstr(listingsModule->listingsED->toPlainText())).params();
- // output
+ // Formats
bp_.default_output_format = fromqstr(outputModule->defaultFormatCO->itemData(
outputModule->defaultFormatCO->currentIndex()).toString());
bp_.html_math_img_scale = outputModule->mathimgSB->value();
bp_.display_pixel_ratio = theGuiApp()->pixelRatio();
+ bp_.save_transient_properties =
+ outputModule->saveTransientPropertiesCB->isChecked();
+
// fonts
- bp_.fonts_roman =
+ bp_.fonts_roman[nontexfonts] =
fromqstr(fontModule->fontsRomanCO->
itemData(fontModule->fontsRomanCO->currentIndex()).toString());
+ bp_.fonts_roman[!nontexfonts] = fromqstr(fontModule->font_roman);
- bp_.fonts_sans =
+ bp_.fonts_sans[nontexfonts] =
fromqstr(fontModule->fontsSansCO->
itemData(fontModule->fontsSansCO->currentIndex()).toString());
+ bp_.fonts_sans[!nontexfonts] = fromqstr(fontModule->font_sans);
- bp_.fonts_typewriter =
+ bp_.fonts_typewriter[nontexfonts] =
fromqstr(fontModule->fontsTypewriterCO->
itemData(fontModule->fontsTypewriterCO->currentIndex()).toString());
+ bp_.fonts_typewriter[!nontexfonts] = fromqstr(fontModule->font_typewriter);
- bp_.fonts_math =
+ bp_.fonts_math[nontexfonts] =
fromqstr(fontModule->fontsMathCO->
itemData(fontModule->fontsMathCO->currentIndex()).toString());
+ bp_.fonts_math[!nontexfonts] = fromqstr(fontModule->font_math);
QString const fontenc =
fontModule->fontencCO->itemData(fontModule->fontencCO->currentIndex()).toString();
bp_.fonts_cjk =
fromqstr(fontModule->cjkFontLE->text());
- bp_.fonts_sans_scale = fontModule->scaleSansSB->value();
+ bp_.use_microtype = fontModule->microtypeCB->isChecked();
+
+ bp_.fonts_sans_scale[nontexfonts] = fontModule->scaleSansSB->value();
+ bp_.fonts_sans_scale[!nontexfonts] = fontModule->font_sf_scale;
- bp_.fonts_typewriter_scale = fontModule->scaleTypewriterSB->value();
+ bp_.fonts_typewriter_scale[nontexfonts] = fontModule->scaleTypewriterSB->value();
+ bp_.fonts_typewriter_scale[!nontexfonts] = fontModule->font_tt_scale;
bp_.fonts_expert_sc = fontModule->fontScCB->isChecked();
biblioChanged_ = false;
// indices
- indicesModule->update(bp_);
+ // We may be called when there is no Buffer, e.g., when
+ // the last view has just been closed.
+ bool const isReadOnly = isBufferAvailable() ? buffer().isReadonly() : false;
+ indicesModule->update(bp_, isReadOnly);
// language & quotes
int const pos = langModule->languageCO->findData(toqstr(
langModule->languageCO->setCurrentIndex(pos);
langModule->quoteStyleCO->setCurrentIndex(
- bp_.quotes_language);
+ bp_.quotes_style);
+ langModule->dynamicQuotesCB->setChecked(bp_.dynamic_quotes);
bool default_enc = true;
if (bp_.inputenc != "auto") {
updateFontsize(documentClass().opt_fontsize(),
bp_.fontsize);
- QString font = toqstr(bp_.fonts_roman);
+ QString font = toqstr(bp_.fontsRoman());
int rpos = fontModule->fontsRomanCO->findData(font);
if (rpos == -1) {
rpos = fontModule->fontsRomanCO->count();
fontModule->fontsRomanCO->addItem(font + qt_(" (not installed)"), font);
}
fontModule->fontsRomanCO->setCurrentIndex(rpos);
+ fontModule->font_roman = toqstr(bp_.fonts_roman[!bp_.useNonTeXFonts]);
- font = toqstr(bp_.fonts_sans);
+ font = toqstr(bp_.fontsSans());
int spos = fontModule->fontsSansCO->findData(font);
if (spos == -1) {
spos = fontModule->fontsSansCO->count();
fontModule->fontsSansCO->addItem(font + qt_(" (not installed)"), font);
}
fontModule->fontsSansCO->setCurrentIndex(spos);
+ fontModule->font_sans = toqstr(bp_.fonts_sans[!bp_.useNonTeXFonts]);
- font = toqstr(bp_.fonts_typewriter);
+ font = toqstr(bp_.fontsTypewriter());
int tpos = fontModule->fontsTypewriterCO->findData(font);
if (tpos == -1) {
tpos = fontModule->fontsTypewriterCO->count();
fontModule->fontsTypewriterCO->addItem(font + qt_(" (not installed)"), font);
}
fontModule->fontsTypewriterCO->setCurrentIndex(tpos);
+ fontModule->font_typewriter = toqstr(bp_.fonts_typewriter[!bp_.useNonTeXFonts]);
- font = toqstr(bp_.fonts_math);
+ font = toqstr(bp_.fontsMath());
int mpos = fontModule->fontsMathCO->findData(font);
if (mpos == -1) {
mpos = fontModule->fontsMathCO->count();
fontModule->fontsMathCO->addItem(font + qt_(" (not installed)"), font);
}
fontModule->fontsMathCO->setCurrentIndex(mpos);
+ fontModule->font_math = toqstr(bp_.fonts_math[!bp_.useNonTeXFonts]);
if (bp_.useNonTeXFonts && os_fonts_available) {
fontModule->fontencLA->setEnabled(false);
toqstr(bp_.fonts_cjk));
else
fontModule->cjkFontLE->setText(QString());
+
+ fontModule->microtypeCB->setChecked(bp_.use_microtype);
fontModule->fontScCB->setChecked(bp_.fonts_expert_sc);
fontModule->fontOsfCB->setChecked(bp_.fonts_old_figures);
- fontModule->scaleSansSB->setValue(bp_.fonts_sans_scale);
- fontModule->scaleTypewriterSB->setValue(bp_.fonts_typewriter_scale);
+ fontModule->scaleSansSB->setValue(bp_.fontsSansScale());
+ fontModule->font_sf_scale = bp_.fonts_sans_scale[!bp_.useNonTeXFonts];
+ fontModule->scaleTypewriterSB->setValue(bp_.fontsTypewriterScale());
+ fontModule->font_tt_scale = bp_.fonts_typewriter_scale[!bp_.useNonTeXFonts];
int nn = findToken(GuiDocument::fontfamilies, bp_.fonts_default_family);
if (nn >= 0)
fontModule->fontencLE->setText(toqstr(bp_.fontenc));
}
- // Output
+ // Formats
// This must be set _after_ fonts since updateDefaultFormat()
// checks osFontsCB settings.
// update combobox with formats
outputModule->strictCB->setChecked(bp_.html_be_strict);
outputModule->cssCB->setChecked(bp_.html_css_as_file);
+ outputModule->saveTransientPropertiesCB
+ ->setChecked(bp_.save_transient_properties);
+
// paper
bool const extern_geometry =
documentClass().provides("geometry");
void GuiDocument::updateAvailableModules()
{
modules_av_model_.clear();
- list<modInfoStruct> const & modInfoList = getModuleInfo();
- list<modInfoStruct>::const_iterator mit = modInfoList.begin();
- list<modInfoStruct>::const_iterator men = modInfoList.end();
- for (int i = 0; mit != men; ++mit, ++i)
- modules_av_model_.insertRow(i, mit->name, mit->id,
- mit->description);
+ list<modInfoStruct> modInfoList = getModuleInfo();
+ // Sort names according to the locale
+ modInfoList.sort([](modInfoStruct const & a, modInfoStruct const & b) {
+ return 0 < b.name.localeAwareCompare(a.name);
+ });
+ int i = 0;
+ for (modInfoStruct const & m : modInfoList) {
+ modules_av_model_.insertRow(i, m.name, m.id, m.description);
+ ++i;
+ }
}
{
modules_sel_model_.clear();
list<modInfoStruct> const selModList = getSelectedModules();
- list<modInfoStruct>::const_iterator mit = selModList.begin();
- list<modInfoStruct>::const_iterator men = selModList.end();
- for (int i = 0; mit != men; ++mit, ++i)
- modules_sel_model_.insertRow(i, mit->name, mit->id,
- mit->description);
+ int i = 0;
+ for (modInfoStruct const & m : selModList) {
+ modules_sel_model_.insertRow(i, m.name, m.id, m.description);
+ ++i;
+ }
}
masterChildModule->childrenTW->setEnabled(true);
masterChildModule->maintainAuxCB->setEnabled(true);
}
- QTreeWidgetItem * item = 0;
ListOfBuffers children = buffer().getChildren();
ListOfBuffers::const_iterator it = children.begin();
ListOfBuffers::const_iterator end = children.end();
bool has_unincluded = false;
bool all_unincluded = true;
for (; it != end; ++it) {
- item = new QTreeWidgetItem(masterChildModule->childrenTW);
+ QTreeWidgetItem * item = new QTreeWidgetItem(masterChildModule->childrenTW);
// FIXME Unicode
string const name =
to_utf8(makeRelPath(from_utf8((*it)->fileName().absFileName()),
list<GuiDocument::modInfoStruct> const
- GuiDocument::makeModuleInfo(LayoutModuleList const & mods)
+GuiDocument::makeModuleInfo(LayoutModuleList const & mods)
{
- LayoutModuleList::const_iterator it = mods.begin();
- LayoutModuleList::const_iterator end = mods.end();
list<modInfoStruct> mInfo;
- for (; it != end; ++it) {
+ for (string const & name : mods) {
modInfoStruct m;
- m.id = *it;
- LyXModule const * const mod = theModuleList[*it];
+ LyXModule const * const mod = theModuleList[name];
if (mod)
- // FIXME Unicode
- m.name = toqstr(translateIfPossible(from_utf8(mod->getName())));
- else
- m.name = toqstr(*it) + toqstr(" (") + qt_("Not Found") + toqstr(")");
+ m = modInfo(*mod);
+ else {
+ m.id = name;
+ m.name = toqstr(name + " (") + qt_("Not Found") + toqstr(")");
+ }
mInfo.push_back(m);
}
return mInfo;
}
+//static
+GuiDocument::modInfoStruct GuiDocument::modInfo(LyXModule const & mod)
+{
+ // FIXME Unicode: docstrings would be better for these parameters but this
+ // change requires a lot of others
+ modInfoStruct m;
+ m.id = mod.getID();
+ m.name = toqstr(translateIfPossible(from_utf8(mod.getName())));
+ QString desc = toqstr(translateIfPossible(from_utf8(mod.getDescription())));
+ // Find the first sentence of the description
+ QTextBoundaryFinder bf(QTextBoundaryFinder::Sentence, desc);
+ int pos = bf.toNextBoundary();
+ if (pos > 0)
+ desc.truncate(pos);
+ QString modulename = QString(qt_("(Module name: %1)")).arg(toqstr(m.id));
+ // Tooltip is the desc followed by the module name
+ m.description = QString("%1<i>%2</i>")
+ .arg(desc.isEmpty() ? QString() : QString("<p>%1</p>").arg(desc),
+ modulename);
+ return m;
+}
+
+
void GuiDocument::loadModuleInfo()
{
moduleNames_.clear();
- LyXModuleList::const_iterator it = theModuleList.begin();
- LyXModuleList::const_iterator end = theModuleList.end();
- for (; it != end; ++it) {
- modInfoStruct m;
- m.id = it->getID();
- // FIXME Unicode
- m.name = toqstr(translateIfPossible(from_utf8(it->getName())));
- // this is supposed to give us the first sentence of the description
- // FIXME Unicode
- QString desc =
- toqstr(translateIfPossible(from_utf8(it->getDescription())));
- int const pos = desc.indexOf(".");
- if (pos > 0)
- desc.truncate(pos + 1);
- m.description = desc;
- if (it->category().substr(0, 8) != "Citation")
- moduleNames_.push_back(m);
- }
+ for (LyXModule const & mod : theModuleList)
+ if (mod.category().substr(0, 8) != "Citation")
+ moduleNames_.push_back(modInfo(mod));
}