GuiDelimiter: store delimiter name in UserRole

This commit is contained in:
Juergen Spitzmueller 2021-02-06 15:33:13 +01:00
parent 1fe75ae72c
commit 7c33e2fc08

View File

@ -169,13 +169,13 @@ string const & texName(char_type math_symbol)
void setDelimiterName(QListWidgetItem * lwi, string const & name) void setDelimiterName(QListWidgetItem * lwi, string const & name)
{ {
lwi->setToolTip(toqstr(name)); lwi->setData(Qt::UserRole, toqstr(name));
} }
string getDelimiterName(QListWidgetItem const * lwi) string getDelimiterName(QListWidgetItem const * lwi)
{ {
return fromqstr(lwi->data(Qt::ToolTipRole).toString()); return fromqstr(lwi->data(Qt::UserRole).toString());
} }
@ -219,6 +219,7 @@ GuiDelimiter::GuiDelimiter(GuiView & lv)
QListWidgetItem * lwi = new QListWidgetItem(QIcon(pixmap), QString()); QListWidgetItem * lwi = new QListWidgetItem(QIcon(pixmap), QString());
setDelimiterName(lwi, delim); setDelimiterName(lwi, delim);
left_list_items_[ms.unicode] = lwi; left_list_items_[ms.unicode] = lwi;
lwi->setToolTip(toqstr(delim));
lwi->setSizeHint(icon_size); lwi->setSizeHint(icon_size);
leftLW->addItem(lwi); leftLW->addItem(lwi);
} }
@ -232,10 +233,10 @@ GuiDelimiter::GuiDelimiter(GuiView & lv)
// The last element is the empty one. // The last element is the empty one.
QListWidgetItem * lwi = new QListWidgetItem(qt_("(None)")); QListWidgetItem * lwi = new QListWidgetItem(qt_("(None)"));
lwi->setToolTip(qt_("(No Delimiter)")); lwi->setToolTip(qt_("No Delimiter"));
left_list_items_['?'] = lwi; left_list_items_['?'] = lwi;
QListWidgetItem * rwi = new QListWidgetItem(qt_("(None)")); QListWidgetItem * rwi = new QListWidgetItem(qt_("(None)"));
rwi->setToolTip(qt_("(No Delimiter)")); rwi->setToolTip(qt_("No Delimiter"));
right_list_items_['?'] = rwi; right_list_items_['?'] = rwi;
leftLW->addItem(lwi); leftLW->addItem(lwi);
rightLW->addItem(rwi); rightLW->addItem(rwi);