Jürgen Spitzmüller wrote:
> > And switching from one category to another takes
> > 10 seconds each time ("Display all" is unchecked).
>
> Better with the attached?

The attached patch is significantly faster on switching.

Furthermore, I tend to disable "display all" for utf8.

Jürgen
Index: src/frontends/qt4/GuiSymbols.cpp
===================================================================
--- src/frontends/qt4/GuiSymbols.cpp	(Revision 22860)
+++ src/frontends/qt4/GuiSymbols.cpp	(Arbeitskopie)
@@ -287,9 +287,10 @@
 	}
 	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,16 @@
 			}
 	}
 
-	SymbolsList::const_iterator const end = symbols.end();
-	for (SymbolsList::const_iterator it = symbols.begin(); it != end; ++it) {
+	SymbolsList::iterator begin = symbols_.begin();
+	SymbolsList::iterator end = symbols_.end();
+	if (!update_combo) {
+		begin = symbols_.find(range_start);
+		end = symbols_.find(range_end);
+	}
+	for (SymbolsList::iterator it = 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 +320,6 @@
 		// 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);
Index: src/frontends/qt4/GuiSymbols.h
===================================================================
--- src/frontends/qt4/GuiSymbols.h	(Revision 22859)
+++ src/frontends/qt4/GuiSymbols.h	(Arbeitskopie)
@@ -16,6 +16,7 @@
 #include "ui_SymbolsUi.h"
 
 #include <map>
+#include <set>
 
 class QListWidgetItem;
 
@@ -63,6 +64,10 @@
 	typedef std::map<QString, QListWidgetItem *> UsedBlocks;
 	///
 	UsedBlocks used_blocks;
+	/// list of all symbols
+	typedef std::set<char_type> SymbolsList;
+	///
+	SymbolsList symbols_;
 };
 
 } // namespace frontend

Reply via email to