]> git.lyx.org Git - lyx.git/commitdiff
* GuiSymbols.{cpp,h}:
authorJürgen Spitzmüller <spitz@lyx.org>
Fri, 8 Feb 2008 16:43:02 +0000 (16:43 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Fri, 8 Feb 2008 16:43:02 +0000 (16:43 +0000)
- cache symbols list (speedup).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22866 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiSymbols.cpp
src/frontends/qt4/GuiSymbols.h

index 82c88b101f9231032b16cab4a0e7e70abcba1cbd..87ebbaea4b765cc34bd5966b951c7396eaaf9b37 100644 (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);
index 55c99c74a23a45477db75915a7782f976d7881b2..ba35527420114292bb58f45cd9979b0a7debefff 100644 (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