Clean up the unknown layout stuff some more. Please test to make sure this works with translated layout names, especially when one of them is "unknown". The use of "unknown" with RTL is also wrong, probably, as it will appear on the wrong side. But I'm not sure how to fix that.

BTW, to create a file with an "unknown" layout for testing, just take any LyX file, open it with vi, and replace something like:
\begin_layout Section
with
\begin_layout BlubberStuff
That's probably unknown. ;-)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25671 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2008-07-16 15:52:10 +00:00
parent 741bd1221a
commit 97a9667f6e
2 changed files with 14 additions and 10 deletions

View File

@ -507,9 +507,13 @@ void GuiLayoutBox::set(docstring const & layout)
return; return;
Layout const & lay = (*text_class_)[layout]; Layout const & lay = (*text_class_)[layout];
QString const & name = toqstr(lay.name() + (lay.isUnknown() ? " (unknown)" : "")); QString const & name = toqstr(lay.name());
if (name == currentText()) // FIXME
return; // Commenting this out for now. Not sure exactly how to do this test,
// with all the different models that are flying around. As it is, it
// won't work with translated or unknown layouts.
// if (name == currentText())
// return;
QList<QStandardItem *> r = model_->findItems(name, Qt::MatchExactly, 1); QList<QStandardItem *> r = model_->findItems(name, Qt::MatchExactly, 1);
if (r.empty()) { if (r.empty()) {
@ -522,10 +526,12 @@ void GuiLayoutBox::set(docstring const & layout)
void GuiLayoutBox::addItemSort(docstring const & item, docstring const & category, void GuiLayoutBox::addItemSort(docstring const & item, docstring const & category,
bool sorted, bool sortedByCat) bool sorted, bool sortedByCat, bool unknown)
{ {
QString qitem = toqstr(item); QString qitem = toqstr(item);
QString titem = toqstr(translateIfPossible(item)); // FIXME This is wrong for RTL, I'd suppose.
QString titem = toqstr(translateIfPossible(item) +
(unknown ? _(" (unknown)") : from_ascii("")));
QString qcat = toqstr(translateIfPossible(category)); QString qcat = toqstr(translateIfPossible(category));
QList<QStandardItem *> row; QList<QStandardItem *> row;
@ -616,8 +622,8 @@ void GuiLayoutBox::updateContents(bool reset)
// if it doesn't require the empty layout, we skip it // if it doesn't require the empty layout, we skip it
if (name == text_class_->emptyLayoutName() && inset_ && !useEmpty) if (name == text_class_->emptyLayoutName() && inset_ && !useEmpty)
continue; continue;
addItemSort(name + (lit->isUnknown() ? " (unknown)" : ""), addItemSort(name, lit->category(), lyxrc.sort_layouts,
lit->category(), lyxrc.sort_layouts, lyxrc.group_layouts); lyxrc.group_layouts, lit->isUnknown());
} }
set(owner_.view()->cursor().innerParagraph().layout().name()); set(owner_.view()->cursor().innerParagraph().layout().name());
@ -636,8 +642,6 @@ void GuiLayoutBox::selected(int index)
// get selection // get selection
QModelIndex mindex = filterModel_->mapToSource(filterModel_->index(index, 1)); QModelIndex mindex = filterModel_->mapToSource(filterModel_->index(index, 1));
docstring layoutName = qstring_to_ucs4(model_->itemFromIndex(mindex)->text()); docstring layoutName = qstring_to_ucs4(model_->itemFromIndex(mindex)->text());
if (suffixIs(layoutName, from_ascii(" (unknown)")))
layoutName = layoutName.substr(0, layoutName.size() - 10); // = len(" (unknown)")
owner_.setFocus(); owner_.setFocus();
if (!text_class_) { if (!text_class_) {

View File

@ -54,7 +54,7 @@ public:
void updateContents(bool reset); void updateContents(bool reset);
/// Add Item to Layout box according to sorting settings from preferences /// Add Item to Layout box according to sorting settings from preferences
void addItemSort(docstring const & item, docstring const & category, void addItemSort(docstring const & item, docstring const & category,
bool sorted, bool sortedByCat); bool sorted, bool sortedByCat, bool unknown);
/// ///
void showPopup(); void showPopup();