]> git.lyx.org Git - features.git/commitdiff
Fix for bug 5053. There are still some serious problems here, though, as (a) "unknown...
authorRichard Heck <rgheck@comcast.net>
Wed, 16 Jul 2008 15:29:00 +0000 (15:29 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 16 Jul 2008 15:29:00 +0000 (15:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25670 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiToolbar.cpp
src/support/lstrings.cpp
src/support/lstrings.h

index 119ebba01ee14536cac5a82395773f7b9b2ab009..060cd40c7056820fcac3887f7ea74348d8578a26 100644 (file)
@@ -635,9 +635,9 @@ void GuiLayoutBox::selected(int index)
 {
        // 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_) {
@@ -655,7 +655,7 @@ void GuiLayoutBox::selected(int index)
                resetFilter();
                return;
        }
-       LYXERR0("ERROR (layoutSelected): layout not found!");
+       LYXERR0("ERROR (layoutSelected): layout " << layoutName << " not found!");
 }
 
 
index 6792cf6bcd33d8ec512814f8c380d25bee9a822a..2bd5f4ea95c606954ca82639b5a3be6726947906 100644 (file)
@@ -495,7 +495,8 @@ bool prefixIs(docstring const & a, docstring const & pre)
 
 bool suffixIs(string const & a, char c)
 {
-       if (a.empty()) return false;
+       if (a.empty()) 
+               return false;
        return a[a.length() - 1] == c;
 }
 
@@ -516,6 +517,14 @@ bool suffixIs(string const & a, string const & suf)
 }
 
 
+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;
index 3b86053ace1b345d7fa89c7d1b85083335510abb..9130f687c8b1c564faaa38c5d6c7c5eef929fdb0 100644 (file)
@@ -103,8 +103,9 @@ bool prefixIs(docstring const & str, docstring const & pre);
 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)