{
// get selection
QModelIndex mindex = filterModel_->mapToSource(filterModel_->index(index, 1));
- docstring const layoutName = rtrim(
- qstring_to_ucs4(model_->itemFromIndex(mindex)->text()), " (unknown)");
-
+ 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();
if (!text_class_) {
resetFilter();
return;
}
- LYXERR0("ERROR (layoutSelected): layout not found!");
+ LYXERR0("ERROR (layoutSelected): layout " << layoutName << " not found!");
}
bool suffixIs(string const & a, char c)
{
- if (a.empty()) return false;
+ if (a.empty())
+ return false;
return a[a.length() - 1] == c;
}
}
+bool suffixIs(docstring const & a, docstring const & suf)
+{
+ size_t const suflen = suf.length();
+ size_t const alen = a.length();
+ return suflen <= alen && a.compare(alen - suflen, suflen, suf) == 0;
+}
+
+
bool containsOnly(string const & s, string const & cset)
{
return s.find_first_not_of(cset) == string::npos;
bool suffixIs(std::string const &, char);
bool suffixIs(docstring const &, char_type);
-/// Does the std::string end with this suffix?
+/// Does the string end with this suffix?
bool suffixIs(std::string const &, std::string const &);
+bool suffixIs(docstring const &, docstring const &);
///
inline bool contains(std::string const & a, std::string const & b)