]> git.lyx.org Git - features.git/commitdiff
Reinstate the commented out check, now that I've figured out how to do it.
authorRichard Heck <rgheck@comcast.net>
Wed, 16 Jul 2008 16:05:35 +0000 (16:05 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 16 Jul 2008 16:05:35 +0000 (16:05 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25673 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiToolbar.cpp

index 644b1742552cf5f9f37fedc0bc9c1cd900e1efa9..0510f29509181b546c96d4afdf5696d96629c028 100644 (file)
@@ -507,17 +507,20 @@ void GuiLayoutBox::set(docstring const & layout)
                return;
 
        Layout const & lay = (*text_class_)[layout];
-       QString const & name = toqstr(lay.name());
-       // FIXME
-       // 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);
+       QString const newLayout = toqstr(lay.name());
+
+       int const curItem = currentIndex();
+       QModelIndex const mindex = 
+               filterModel_->mapToSource(filterModel_->index(curItem, 1));
+       QString const & currentLayout = model_->itemFromIndex(mindex)->text();
+       if (newLayout == currentLayout) {
+               LYXERR(Debug::GUI, "Already had " << newLayout << " selected.");
+               return;
+       }
+
+       QList<QStandardItem *> r = model_->findItems(newLayout, Qt::MatchExactly, 1);
        if (r.empty()) {
-               LYXERR0("Trying to select non existent layout type " << name);
+               LYXERR0("Trying to select non existent layout type " << newLayout);
                return;
        }