* GuiSymbols.{cpp,h}:

- cache symbols list (speedup).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22866 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2008-02-08 16:43:02 +00:00
parent 3a5fcb9158
commit 369f14fa8e
2 changed files with 13 additions and 7 deletions

View File

@ -287,9 +287,10 @@ void GuiSymbols::updateSymbolList(bool update_combo)
}
bool const show_all = categoryFilterCB->isChecked();
typedef set<char_type> SymbolsList;
Encoding enc = *(encodings.getFromLyXName(encoding_));
SymbolsList symbols = enc.getSymbolsList();
if (symbols_.empty() || update_combo) {
Encoding enc = *(encodings.getFromLyXName(encoding_));
symbols_ = enc.getSymbolsList();
}
if (!show_all) {
for (int i = 0 ; i < no_blocks; ++i)
@ -300,9 +301,11 @@ void GuiSymbols::updateSymbolList(bool update_combo)
}
}
SymbolsList::const_iterator const end = symbols.end();
for (SymbolsList::const_iterator it = symbols.begin(); it != end; ++it) {
SymbolsList::const_iterator const end = symbols_.end();
for (SymbolsList::const_iterator it = symbols_.begin(); it != end; ++it) {
char_type c = *it;
if (!update_combo && !show_all && (c <= range_start || c >= range_end))
continue;
#if QT_VERSION >= 0x040300
QChar::Category const cat = QChar::category(uint(c));
#else
@ -312,8 +315,6 @@ void GuiSymbols::updateSymbolList(bool update_combo)
// we do not want control or space characters
if (cat == QChar::Other_Control || cat == QChar::Separator_Space)
continue;
if (!update_combo && !show_all && (c <= range_start || c >= range_end))
continue;
QListWidgetItem * lwi = new QListWidgetItem(toqstr(c));
if (show_all || c >= range_start && c <= range_end) {
lwi->setTextAlignment(Qt::AlignCenter);

View File

@ -16,6 +16,7 @@
#include "ui_SymbolsUi.h"
#include <map>
#include <set>
class QListWidgetItem;
@ -63,6 +64,10 @@ private:
typedef std::map<QString, QListWidgetItem *> UsedBlocks;
///
UsedBlocks used_blocks;
/// list of all symbols
typedef std::set<char_type> SymbolsList;
///
SymbolsList symbols_;
};
} // namespace frontend