+ QString category = categoryCO->currentText();
+ bool const nocategory = category.isEmpty();
+ char_type range_start = 0x0000;
+ char_type range_end = 0x110000;
+ QList<char_type> s;
+ if (update_combo) {
+ used_blocks.clear();
+ categoryCO->clear();
+ }
+ bool const show_all = categoryFilterCB->isChecked();
+
+ if (symbols_.empty() || update_combo)
+ symbols_ = encodings.fromLyXName(encoding_)->symbolsList();
+
+ if (!show_all) {
+ for (int i = 0 ; i < no_blocks; ++i)
+ if (qt_(unicode_blocks[i].name) == category) {
+ range_start = unicode_blocks[i].start;
+ range_end = unicode_blocks[i].end;
+ break;
+ }
+ }
+
+ SymbolsList::const_iterator const end = symbols_.end();
+ int numItem = 0;
+ 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
+ QChar::Category const cat = QChar(uint(c)).category();
+#endif
+ // we do not want control or space characters
+ if (cat == QChar::Other_Control || cat == QChar::Separator_Space)
+ continue;
+ ++numItem;
+ if (show_all || (c >= range_start && c <= range_end))
+ s.append(c);
+ if (update_combo) {
+ QString block = getBlock(c);
+ if (category.isEmpty())
+ category = block;
+ if (used_blocks.find(block) == used_blocks.end())
+ used_blocks[block] = numItem;
+ }
+ }
+ model_->setSymbols(s);
+
+ if (update_combo) {
+ // update category combo
+ for (UsedBlocks::iterator it = used_blocks.begin();
+ it != used_blocks.end(); ++it) {
+ categoryCO->addItem(it->first);
+ }
+ }
+
+ int old = categoryCO->findText(category);
+ if (old != -1)
+ categoryCO->setCurrentIndex(old);
+ // update again in case the combo has not yet been filled
+ // on first cycle (at dialog initialization)
+ if (nocategory && !category.isEmpty())
+ updateSymbolList();