diff --git a/src/frontends/qt4/GuiSymbols.cpp b/src/frontends/qt4/GuiSymbols.cpp index 2aadfff79f..cdfedee4e7 100644 --- a/src/frontends/qt4/GuiSymbols.cpp +++ b/src/frontends/qt4/GuiSymbols.cpp @@ -221,9 +221,6 @@ public: if (!index.isValid()) return QVariant(); - static QString const strCharacter = qt_("Character: "); - static QString const strCodePoint = qt_("Code Point: "); - char_type c = symbols_.at(index.row()); switch (role) { @@ -232,10 +229,20 @@ public: case Qt::DisplayRole: return toqstr(c); case Qt::ToolTipRole: { - char codeName[10]; - sprintf(codeName, "0x%04x", c); - return strCharacter + toqstr(c) + '\n' - + strCodePoint + QLatin1String(codeName); + QString latex; + if (encoding_) { + // how is the character output in the current encoding? + docstring const code = encoding_->latexChar(c).first; + // only show it when it is not coded by itself + if (code != docstring(1, c)) + latex = qt_("

LaTeX code: %1

").arg(toqstr(code)); + } + return formatToolTip(QString("

%1" + "
U+%2

%3") + .arg(toqstr(c)) + .arg(QString("%1").arg(c, 0, 16).toUpper()) + .arg(latex)); } case Qt::SizeHintRole: // Fix many symbols not displaying in combination with @@ -246,11 +253,12 @@ public: } } - void setSymbols(QList const & symbols) + void setSymbols(QList const & symbols, Encoding const * encoding) { beginResetModel(); beginInsertRows(QModelIndex(), 0, symbols.size() - 1); symbols_ = symbols; + encoding_ = encoding; endInsertRows(); endResetModel(); } @@ -259,6 +267,7 @@ private: friend class GuiSymbols; QList symbols_; + Encoding const * encoding_; }; @@ -422,8 +431,10 @@ void GuiSymbols::updateSymbolList(bool update_combo) } bool const show_all = categoryFilterCB->isChecked(); + Encoding const * const enc = encodings.fromLyXName(encoding_); + if (symbols_.empty() || update_combo) - symbols_ = encodings.fromLyXName(encoding_)->symbolsList(); + symbols_ = enc->symbolsList(); if (!show_all) { for (int i = 0 ; i < no_blocks; ++i) @@ -455,7 +466,7 @@ void GuiSymbols::updateSymbolList(bool update_combo) used_blocks[block] = numItem; } } - model_->setSymbols(s); + model_->setSymbols(s, enc); if (update_combo) { // update category combo