2 * \file qt4/GuiToolbar.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
9 * \author Angus Leeming
10 * \author Abdelrazak Younes
12 * Full author contact details are available in file CREDITS.
18 #include "GuiCommandBuffer.h"
19 #include "GuiToolbar.h"
20 #include "LyXAction.h"
22 #include "qt_helpers.h"
23 #include "InsertTableWidget.h"
26 #include "BufferParams.h"
27 #include "BufferView.h"
29 #include "FuncRequest.h"
30 #include "FuncStatus.h"
31 #include "IconPalette.h"
35 #include "Paragraph.h"
36 #include "TextClass.h"
37 #include "ToolbarBackend.h"
39 #include "support/debug.h"
40 #include "support/filetools.h"
41 #include "support/gettext.h"
42 #include "support/lstrings.h"
43 #include "support/lyxalgo.h" // sorted
45 #include <QAbstractItemDelegate>
46 #include <QAbstractTextDocumentLayout>
47 #include <QApplication>
49 #include <QHeaderView>
54 #include <QSortFilterProxyModel>
55 #include <QStandardItem>
56 #include <QStandardItemModel>
57 #include <QTextDocument>
59 #include <QToolButton>
62 #include <boost/assert.hpp>
65 using namespace lyx::support;
67 static void initializeResources()
69 static bool initialized = false;
71 Q_INIT_RESOURCE(Resources);
88 bool operator<(PngMap const & lhs, PngMap const & rhs)
90 return lhs.key < rhs.key;
96 CompareKey(QString const & name) : name_(name) {}
97 bool operator()(PngMap const & other) const { return other.key == name_; }
103 PngMap sorted_png_map[] = {
104 { "Bumpeq", "bumpeq2" },
107 { "Delta", "delta2" },
108 { "Downarrow", "downarrow2" },
109 { "Gamma", "gamma2" },
110 { "Lambda", "lambda2" },
111 { "Leftarrow", "leftarrow2" },
112 { "Leftrightarrow", "leftrightarrow2" },
113 { "Longleftarrow", "longleftarrow2" },
114 { "Longleftrightarrow", "longleftrightarrow2" },
115 { "Longrightarrow", "longrightarrow2" },
116 { "Omega", "omega2" },
120 { "Rightarrow", "rightarrow2" },
121 { "Sigma", "sigma2" },
122 { "Subset", "subset2" },
123 { "Supset", "supset2" },
124 { "Theta", "theta2" },
125 { "Uparrow", "uparrow2" },
126 { "Updownarrow", "updownarrow2" },
127 { "Upsilon", "upsilon2" },
128 { "Vdash", "vdash3" },
130 { "nLeftarrow", "nleftarrow2" },
131 { "nLeftrightarrow", "nleftrightarrow2" },
132 { "nRightarrow", "nrightarrow2" },
133 { "nVDash", "nvdash3" },
134 { "nvDash", "nvdash2" },
135 { "textrm \\AA", "textrm_AA"},
136 { "textrm \\O", "textrm_O"},
137 { "vDash", "vdash2" }
140 size_t const nr_sorted_png_map = sizeof(sorted_png_map) / sizeof(PngMap);
143 QString findPng(QString const & name)
145 PngMap const * const begin = sorted_png_map;
146 PngMap const * const end = begin + nr_sorted_png_map;
147 BOOST_ASSERT(sorted(begin, end));
149 PngMap const * const it = find_if(begin, end, CompareKey(name));
153 png_name = it->value;
156 png_name.replace('_', "underscore");
157 png_name.replace(' ', '_');
159 // This way we can have "math-delim { }" on the toolbar.
160 png_name.replace('(', "lparen");
161 png_name.replace(')', "rparen");
162 png_name.replace('[', "lbracket");
163 png_name.replace(']', "rbracket");
164 png_name.replace('{', "lbrace");
165 png_name.replace('}', "rbrace");
166 png_name.replace('|', "bars");
167 png_name.replace(',', "thinspace");
168 png_name.replace(':', "mediumspace");
169 png_name.replace(';', "thickspace");
170 png_name.replace('!', "negthinspace");
173 LYXERR(Debug::GUI, "findPng(" << fromqstr(name) << ")\n"
174 << "Looking for math PNG called \"" << fromqstr(png_name) << '"');
181 /// return a icon for the given action
182 static QIcon getIcon(FuncRequest const & f, bool unknown)
184 initializeResources();
190 case LFUN_MATH_INSERT:
191 if (!f.argument().empty()) {
193 name1 = findPng(toqstr(f.argument()).mid(1));
196 case LFUN_MATH_DELIM:
197 case LFUN_MATH_BIGDELIM:
199 name1 = findPng(toqstr(f.argument()));
203 name1 = toqstr(f.argument());
206 name2 = toqstr(lyxaction.getActionName(f.action));
209 if (!f.argument().empty()) {
210 name1 = name2 + ' ' + toqstr(f.argument());
211 name1.replace(' ', '_');
215 string fullname = libFileSearch("images/" + path, name1, "png").absFilename();
216 if (pm.load(toqstr(fullname)))
219 fullname = libFileSearch("images/" + path, name2, "png").absFilename();
220 if (pm.load(toqstr(fullname)))
223 if (pm.load(":/images/" + path + name1 + ".png"))
226 if (pm.load(":/images/" + path + name2 + ".png"))
229 LYXERR(Debug::GUI, "Cannot find icon for command \""
230 << lyxaction.getActionName(f.action)
231 << '(' << to_utf8(f.argument()) << ")\"");
233 pm.load(":/images/unknown.png");
239 /////////////////////////////////////////////////////////////////////
243 /////////////////////////////////////////////////////////////////////
245 class FilterItemDelegate : public QAbstractItemDelegate {
248 explicit FilterItemDelegate(QObject * parent = 0)
249 : QAbstractItemDelegate(parent)
253 void paint(QPainter * painter, QStyleOptionViewItem const & option,
254 QModelIndex const & index) const
256 QComboBox * combo = static_cast<QComboBox *>(parent());
257 QStyleOptionMenuItem opt = getStyleOption(option, index);
259 // draw line with small text string for separator
260 if (opt.text.left(2) == "--") {
263 // set options for the separator, the first 8/18 of the vertical space
264 QStyleOptionMenuItem sopt = opt;
265 sopt.state = QStyle::State_Active | QStyle::State_Enabled;
266 sopt.checked = false;
267 sopt.text = QString();
268 sopt.rect.setHeight(sopt.rect.height() * 8 / 18);
269 sopt.menuRect.setHeight(sopt.menuRect.height() * 8 / 18);
271 // use the style with an empty text to paint the background
272 painter->eraseRect(sopt.rect);
273 combo->style()->drawControl(QStyle::CE_MenuItem, &sopt, painter, combo->view());
275 // draw the centered text, small and bold
278 pen.setColor(sopt.palette.text().color());
279 painter->setPen(pen);
280 QFont font = sopt.font;
282 font.setWeight(QFont::Black);
283 font.setPointSize(sopt.font.pointSize() * 8 / 10);
284 painter->setFont(font);
286 painter->drawText(sopt.rect, Qt::AlignCenter, "Modules", &brect);
288 // draw the horizontal line
289 QColor lcol = sopt.palette.text().color();
291 painter->setPen(lcol);
292 painter->drawLine(sopt.rect.x(), sopt.rect.y() + sopt.rect.height() / 2 ,
293 brect.left() - 1, sopt.rect.y() + sopt.rect.height() / 2);
294 painter->drawLine(brect.right() + 1, sopt.rect.y() + sopt.rect.height() / 2,
295 sopt.rect.right(), sopt.rect.y() + sopt.rect.height() / 2);
299 // move rect down 8/20 of the original height
300 opt.rect.setTop(sopt.rect.y() + sopt.rect.height());
301 opt.menuRect = opt.rect;
304 // Draw using the menu item style (this is how QComboBox does it).
305 // But for the rich text drawing below we will call it with an
306 // empty string, and later then draw over it the real string.
308 QString text = underlineFilter(opt.text);
309 opt.text = QString();
310 painter->eraseRect(opt.rect);
311 combo->style()->drawControl(QStyle::CE_MenuItem, &opt, painter, combo->view());
314 // Draw the rich text.
316 QColor col = opt.palette.text().color();
317 if (opt.state & QStyle::State_Selected)
318 col = opt.palette.highlightedText().color();
319 QAbstractTextDocumentLayout::PaintContext context;
320 context.palette.setColor(QPalette::Text, col);
323 doc.setDefaultFont(opt.font);
325 painter->translate(opt.rect.x() + 20, opt.rect.y());
326 doc.documentLayout()->draw(painter, context);
331 QSize sizeHint(QStyleOptionViewItem const & option,
332 QModelIndex const & index) const
334 QComboBox * combo = static_cast<QComboBox *>(parent());
336 QStyleOptionMenuItem opt = getStyleOption(option, index);
337 QSize size = combo->style()->sizeFromContents(
338 QStyle::CT_MenuItem, &opt, option.rect.size(), combo);
339 if (opt.text.left(2) == "--")
340 size.setHeight(size.height() * 18 / 10);
346 QString underlineFilter(QString const & s) const
349 GuiLayoutBox * p = static_cast<GuiLayoutBox *>(parent());
350 QString const & f = p->filter();
354 // step through data item and put "(x)" for every matching character
358 for (int i = 0; i < f.length(); ++i) {
359 int p = s.indexOf(f[i], lastp + 1, Qt::CaseInsensitive);
360 BOOST_ASSERT(p != -1);
361 if (lastp == p - 1 && lastp != -1) {
362 // remove ")" and append "x)"
363 r = r.left(r.length() - 4) + s[p] + "</u>";
366 r += s.mid(lastp + 1, p - lastp - 1);
367 r += QString("<u>") + s[p] + "</u>";
371 r += s.mid(lastp + 1);
376 QStyleOptionMenuItem getStyleOption(QStyleOptionViewItem const & option,
377 QModelIndex const & index) const
379 QComboBox * combo = static_cast<QComboBox *>(parent());
381 // create the options for a menu item
382 QStyleOptionMenuItem menuOption;
383 menuOption.palette = QApplication::palette("QMenu");
384 menuOption.checkType = QStyleOptionMenuItem::NonExclusive;
385 menuOption.state = QStyle::State_Active | QStyle::State_Enabled;
386 menuOption.menuRect = option.rect;
387 menuOption.rect = option.rect;
388 menuOption.font = combo->font();
389 menuOption.fontMetrics = QFontMetrics(menuOption.font);
390 menuOption.tabWidth = 0;
391 menuOption.text = index.model()->data(index, Qt::DisplayRole).toString()
392 .replace(QLatin1Char('&'), QLatin1String("&&"));
393 menuOption.menuItemType = QStyleOptionMenuItem::Normal;
394 if (option.state & QStyle::State_Selected)
395 menuOption.state |= QStyle::State_Selected;
396 menuOption.checked = combo->currentIndex() == index.row();
403 class GuiFilterProxyModel : public QSortFilterProxyModel
407 GuiFilterProxyModel(QObject * parent)
408 : QSortFilterProxyModel(parent) {}
411 void setCharFilter(QString const & f)
413 setFilterRegExp(charFilterRegExp(f));
414 dataChanged(index(0, 0), index(rowCount() - 1, 1));
419 QString charFilterRegExp(QString const & filter)
422 for (int i = 0; i < filter.length(); ++i)
423 re += ".*" + QRegExp::escape(filter[i]);
429 GuiLayoutBox::GuiLayoutBox(GuiView & owner)
430 : owner_(owner), filterItemDelegate_(new FilterItemDelegate(this))
432 setSizeAdjustPolicy(QComboBox::AdjustToContents);
433 setFocusPolicy(Qt::ClickFocus);
434 setMinimumWidth(sizeHint().width());
435 setMaxVisibleItems(100);
437 // set the layout model with two columns
438 // 1st: translated layout names
439 // 2nd: raw layout names
440 model_ = new QStandardItemModel(0, 2, this);
441 filterModel_ = new GuiFilterProxyModel(this);
442 filterModel_->setSourceModel(model_);
443 filterModel_->setDynamicSortFilter(true);
444 filterModel_->setFilterCaseSensitivity(Qt::CaseInsensitive);
445 setModel(filterModel_);
447 // for the filtering we have to intercept characters
448 view()->installEventFilter(this);
449 view()->setItemDelegateForColumn(0, filterItemDelegate_);
451 QObject::connect(this, SIGNAL(activated(int)),
452 this, SLOT(selected(int)));
453 owner_.setLayoutDialog(this);
454 updateContents(true);
458 void GuiLayoutBox::setFilter(QString const & s)
460 // remember old selection
461 int sel = currentIndex();
463 lastSel_ = filterModel_->mapToSource(filterModel_->index(sel, 0)).row();
466 filterModel_->setCharFilter(s);
468 // restore old selection
469 if (lastSel_ != -1) {
470 QModelIndex i = filterModel_->mapFromSource(model_->index(lastSel_, 0));
472 setCurrentIndex(i.row());
475 // Workaround to resize to content size
476 // FIXME: There must be a better way. The QComboBox::AdjustToContents)
478 if (view()->isVisible())
479 QComboBox::showPopup();
483 void GuiLayoutBox::resetFilter()
485 setFilter(QString());
489 void GuiLayoutBox::showPopup()
492 owner_.message(_("Enter characters to filter the layout list."));
493 QComboBox::showPopup();
497 bool GuiLayoutBox::eventFilter(QObject * o, QEvent * e)
499 if (e->type() != QEvent::KeyPress)
500 return QComboBox::eventFilter(o, e);
502 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
503 bool modified = (ke->modifiers() == Qt::ControlModifier)
504 || (ke->modifiers() == Qt::AltModifier)
505 || (ke->modifiers() == Qt::MetaModifier);
509 if (!modified && !filter_.isEmpty()) {
514 case Qt::Key_Backspace:
516 // cut off one character
517 setFilter(filter_.left(filter_.length() - 1));
521 if (modified || ke->text().isEmpty())
523 // find chars for the filter string
525 for (int i = 0; i < ke->text().length(); ++i) {
526 QChar c = ke->text()[i];
527 if (c.isLetterOrNumber()
530 || c.category() == QChar::Separator_Space) {
535 // append new chars to the filter string
536 setFilter(filter_ + s);
542 return QComboBox::eventFilter(o, e);
546 void GuiLayoutBox::set(docstring const & layout)
553 QString const & name = toqstr((*text_class_)[layout].name());
554 if (name == currentText())
557 QList<QStandardItem *> r = model_->findItems(name, Qt::MatchExactly, 1);
559 lyxerr << "Trying to select non existent layout type "
560 << fromqstr(name) << endl;
564 setCurrentIndex(filterModel_->mapFromSource(r.first()->index()).row());
568 void GuiLayoutBox::addItemSort(docstring const & item, bool sorted)
570 QString qitem = toqstr(item);
571 QString titem = toqstr(translateIfPossible(item));
573 QList<QStandardItem *> row;
574 row.append(new QStandardItem(titem));
575 row.append(new QStandardItem(qitem));
577 // the simple unsorted case
578 int const end = model_->rowCount();
579 if (!sorted || end < 2 || qitem[0].category() != QChar::Letter_Uppercase) {
580 model_->appendRow(row);
584 // find row to insert the item, after the separator if it exists
585 int i = 1; // skip the Standard layout
587 QList<QStandardItem *> sep = model_->findItems("--", Qt::MatchStartsWith);
589 i = sep.first()->index().row() + 1;
590 if (i < model_->rowCount()) {
591 // find alphabetic position
592 QString is = model_->item(i, 0)->text();
593 while (is.compare(titem) < 0) {
594 // e.g. --Separator--
595 if (is.at(0).category() != QChar::Letter_Uppercase)
600 is = model_->item(i, 0)->text();
604 model_->insertRow(i, row);
608 void GuiLayoutBox::updateContents(bool reset)
612 Buffer const * buffer = owner_.buffer();
621 // we'll only update the layout list if the text class has changed
622 // or we've moved from one inset to another
623 DocumentClass const * text_class = &buffer->params().documentClass();
624 Inset const * inset =
625 owner_.view()->cursor().innerParagraph().inInset();
626 if (!reset && text_class_ == text_class && inset_ == inset) {
627 set(owner_.view()->cursor().innerParagraph().layout().name());
632 text_class_ = text_class;
635 DocumentClass::const_iterator lit = text_class_->begin();
636 DocumentClass::const_iterator len = text_class_->end();
637 for (; lit != len; ++lit) {
638 docstring const & name = lit->name();
639 // if this inset requires the empty layout, we skip the default
641 if (name == text_class_->defaultLayoutName() && inset &&
642 (inset->forceEmptyLayout() || inset->useEmptyLayout()))
644 // if it doesn't require the empty layout, we skip it
645 if (name == text_class_->emptyLayoutName() && inset &&
646 !inset->forceEmptyLayout() && !inset->useEmptyLayout())
648 addItemSort(name, lyxrc.sort_layouts);
651 set(owner_.view()->cursor().innerParagraph().layout().name());
653 // needed to recalculate size hint
655 setMinimumWidth(sizeHint().width());
656 setEnabled(!buffer->isReadonly());
661 void GuiLayoutBox::selected(int index)
664 QModelIndex mindex = filterModel_->mapToSource(filterModel_->index(index, 1));
665 docstring const layoutName =
666 qstring_to_ucs4(model_->itemFromIndex(mindex)->text());
671 updateContents(false);
676 // find corresponding text class
677 if (text_class_->hasLayout(layoutName)) {
678 FuncRequest const func(LFUN_LAYOUT, layoutName, FuncRequest::TOOLBAR);
679 theLyXFunc().setLyXView(&owner_);
681 updateContents(false);
685 lyxerr << "ERROR (layoutSelected): layout not found!" << endl;
690 /////////////////////////////////////////////////////////////////////
694 /////////////////////////////////////////////////////////////////////
697 GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
698 : QToolBar(qt_(tbinfo.gui_name), &owner), owner_(owner),
699 layout_(0), command_buffer_(0)
701 // give visual separation between adjacent toolbars
704 // TODO: save toolbar position
707 ToolbarInfo::item_iterator it = tbinfo.items.begin();
708 ToolbarInfo::item_iterator end = tbinfo.items.end();
709 for (; it != end; ++it)
714 Action * GuiToolbar::addItem(ToolbarItem const & item)
716 Action * act = new Action(owner_,
717 getIcon(item.func_, false),
718 toqstr(item.label_), item.func_, toqstr(item.label_));
719 actions_.append(act);
725 class PaletteButton : public QToolButton
729 ToolbarItem const & tbitem_;
732 PaletteButton(GuiToolbar * bar, ToolbarItem const & item)
733 : QToolButton(bar), bar_(bar), tbitem_(item), initialized_(false)
735 QString const label = qt_(to_ascii(tbitem_.label_));
739 connect(bar_, SIGNAL(iconSizeChanged(QSize)),
740 this, SLOT(setIconSize(QSize)));
742 ToolbarInfo const * tbinfo =
743 toolbarbackend.getDefinedToolbarInfo(tbitem_.name_);
745 // use the icon of first action for the toolbar button
746 setIcon(getIcon(tbinfo->items.begin()->func_, true));
749 void mousePressEvent(QMouseEvent * e)
752 QToolButton::mousePressEvent(e);
758 ToolbarInfo const * tbinfo =
759 toolbarbackend.getDefinedToolbarInfo(tbitem_.name_);
761 lyxerr << "Unknown toolbar " << tbitem_.name_ << endl;
764 IconPalette * panel = new IconPalette(this);
765 QString const label = qt_(to_ascii(tbitem_.label_));
766 panel->setWindowTitle(label);
767 connect(this, SIGNAL(clicked(bool)), panel, SLOT(setVisible(bool)));
768 connect(panel, SIGNAL(visible(bool)), this, SLOT(setChecked(bool)));
769 ToolbarInfo::item_iterator it = tbinfo->items.begin();
770 ToolbarInfo::item_iterator const end = tbinfo->items.end();
771 for (; it != end; ++it)
772 if (!getStatus(it->func_).unknown())
773 panel->addButton(bar_->addItem(*it));
775 QToolButton::mousePressEvent(e);
779 class MenuButton : public QToolButton
783 ToolbarItem const & tbitem_;
786 MenuButton(GuiToolbar * bar, ToolbarItem const & item)
787 : QToolButton(bar), bar_(bar), tbitem_(item), initialized_(false)
789 setPopupMode(QToolButton::InstantPopup);
790 QString const label = qt_(to_ascii(tbitem_.label_));
794 setIcon(QPixmap(":images/math/" + toqstr(tbitem_.name_) + ".png"));
795 connect(bar, SIGNAL(iconSizeChanged(QSize)),
796 this, SLOT(setIconSize(QSize)));
799 void mousePressEvent(QMouseEvent * e)
802 QToolButton::mousePressEvent(e);
808 QString const label = qt_(to_ascii(tbitem_.label_));
809 ButtonMenu * m = new ButtonMenu(label, this);
810 m->setWindowTitle(label);
811 m->setTearOffEnabled(true);
812 connect(bar_, SIGNAL(updated()), m, SLOT(updateParent()));
813 ToolbarInfo const * tbinfo =
814 toolbarbackend.getDefinedToolbarInfo(tbitem_.name_);
816 lyxerr << "Unknown toolbar " << tbitem_.name_ << endl;
819 ToolbarInfo::item_iterator it = tbinfo->items.begin();
820 ToolbarInfo::item_iterator const end = tbinfo->items.end();
821 for (; it != end; ++it)
822 if (!getStatus(it->func_).unknown())
823 m->add(bar_->addItem(*it));
826 QToolButton::mousePressEvent(e);
833 void GuiToolbar::add(ToolbarItem const & item)
835 switch (item.type_) {
836 case ToolbarItem::SEPARATOR:
839 case ToolbarItem::LAYOUTS:
840 layout_ = new GuiLayoutBox(owner_);
843 case ToolbarItem::MINIBUFFER:
844 command_buffer_ = new GuiCommandBuffer(&owner_);
845 addWidget(command_buffer_);
846 /// \todo find a Qt4 equivalent to setHorizontalStretchable(true);
847 //setHorizontalStretchable(true);
849 case ToolbarItem::TABLEINSERT: {
850 QToolButton * tb = new QToolButton;
851 tb->setCheckable(true);
852 tb->setIcon(getIcon(FuncRequest(LFUN_TABULAR_INSERT), true));
853 QString const label = qt_(to_ascii(item.label_));
854 tb->setToolTip(label);
855 tb->setStatusTip(label);
857 InsertTableWidget * iv = new InsertTableWidget(owner_, tb);
858 connect(tb, SIGNAL(clicked(bool)), iv, SLOT(show(bool)));
859 connect(iv, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool)));
860 connect(this, SIGNAL(updated()), iv, SLOT(updateParent()));
864 case ToolbarItem::ICONPALETTE:
865 addWidget(new PaletteButton(this, item));
868 case ToolbarItem::POPUPMENU: {
869 addWidget(new MenuButton(this, item));
872 case ToolbarItem::COMMAND: {
873 if (!getStatus(item.func_).unknown())
874 addAction(addItem(item));
883 void GuiToolbar::saveInfo(ToolbarSection::ToolbarInfo & tbinfo)
885 // if tbinfo.state == auto *do not* set on/off
886 if (tbinfo.state != ToolbarSection::ToolbarInfo::AUTO) {
887 if (GuiToolbar::isVisible())
888 tbinfo.state = ToolbarSection::ToolbarInfo::ON;
890 tbinfo.state = ToolbarSection::ToolbarInfo::OFF;
893 // no need to save it here.
894 Qt::ToolBarArea loc = owner_.toolBarArea(this);
896 if (loc == Qt::TopToolBarArea)
897 tbinfo.location = ToolbarSection::ToolbarInfo::TOP;
898 else if (loc == Qt::BottomToolBarArea)
899 tbinfo.location = ToolbarSection::ToolbarInfo::BOTTOM;
900 else if (loc == Qt::RightToolBarArea)
901 tbinfo.location = ToolbarSection::ToolbarInfo::RIGHT;
902 else if (loc == Qt::LeftToolBarArea)
903 tbinfo.location = ToolbarSection::ToolbarInfo::LEFT;
905 tbinfo.location = ToolbarSection::ToolbarInfo::NOTSET;
907 // save toolbar position. They are not used to restore toolbar position
908 // now because move(x,y) does not work for toolbar.
909 tbinfo.posx = pos().x();
910 tbinfo.posy = pos().y();
914 void GuiToolbar::updateContents()
916 // update visible toolbars only
919 // This is a speed bottleneck because this is called on every keypress
920 // and update calls getStatus, which copies the cursor at least two times
921 for (int i = 0; i < actions_.size(); ++i)
922 actions_[i]->update();
925 layout_->setEnabled(lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled());
932 } // namespace frontend
935 #include "GuiToolbar_moc.cpp"