]> git.lyx.org Git - features.git/commitdiff
Simplify the logic a bit here.
authorRichard Heck <rgheck@comcast.net>
Thu, 6 Mar 2008 05:10:04 +0000 (05:10 +0000)
committerRichard Heck <rgheck@comcast.net>
Thu, 6 Mar 2008 05:10:04 +0000 (05:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23504 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiToolbar.cpp

index 34500bc681fa54946001e43789933b11773b449c..8c59d089e38381bfd410d6772af979c38259eb2a 100644 (file)
@@ -657,7 +657,8 @@ void GuiLayoutBox::selected(int index)
 {
        // get selection
        QModelIndex mindex = filterModel_->mapToSource(filterModel_->index(index, 1));
-       docstring const name = qstring_to_ucs4(model_->itemFromIndex(mindex)->text());
+       docstring const layoutName = 
+               qstring_to_ucs4(model_->itemFromIndex(mindex)->text());
 
        owner_.setFocus();
 
@@ -668,17 +669,13 @@ void GuiLayoutBox::selected(int index)
        }
 
        // find corresponding text class
-       for (size_t i = 0; i != text_class_->layoutCount(); ++i) {
-               docstring const & itname = text_class_->layout(i)->name();
-               if (itname == name) {
-                       FuncRequest const func(LFUN_LAYOUT, itname,
-                                              FuncRequest::TOOLBAR);
-                       theLyXFunc().setLyXView(&owner_);
-                       lyx::dispatch(func);
-                       updateContents(false);
-                       resetFilter();
-                       return;
-               }
+       if (text_class_->hasLayout(layoutName)) {
+               FuncRequest const func(LFUN_LAYOUT, layoutName, FuncRequest::TOOLBAR);
+               theLyXFunc().setLyXView(&owner_);
+               lyx::dispatch(func);
+               updateContents(false);
+               resetFilter();
+               return;
        }
        lyxerr << "ERROR (layoutSelected): layout not found!" << endl;
 }