* src/frontends/qt4/ui/SymbolsUi.ui:

* src/frontends/qt4/GuiSymbols.{cpp,h}:
	- add an option to only display the glyphs of the selected category (= default)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22848 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2008-02-07 17:42:00 +00:00
parent 1cbeb0b244
commit 78760c719f
3 changed files with 53 additions and 8 deletions

View File

@ -235,21 +235,44 @@ void GuiSymbols::on_symbolsLW_itemClicked(QListWidgetItem * item)
void GuiSymbols::on_categoryCO_activated(QString const & text)
{
if (!categoryFilterCB->isChecked())
updateSymbolList();
if (used_blocks.find(text) != used_blocks.end())
symbolsLW->scrollToItem(used_blocks[text]);
symbolsLW->scrollToItem(used_blocks[text],
QAbstractItemView::PositionAtTop);
}
void GuiSymbols::on_categoryFilterCB_toggled(bool)
{
updateSymbolList();
}
void GuiSymbols::updateSymbolList()
{
QString category = categoryCO->currentText();
bool const nocategory = category.isEmpty();
char_type range_start = 0x0000;
char_type range_end = 0x110000;
symbolsLW->clear();
used_blocks.clear();
categoryCO->clear();
bool const show_all = categoryFilterCB->isChecked();
typedef set<char_type> SymbolsList;
Encoding enc = *(encodings.getFromLyXName(encoding_));
SymbolsList symbols = enc.getSymbolsList();
if (!show_all) {
for (int i = 0 ; i < no_blocks; ++i)
if (unicode_blocks[i].name == fromqstr(category)) {
range_start = unicode_blocks[i].start;
range_end = unicode_blocks[i].end;
break;
}
}
SymbolsList::const_iterator const end = symbols.end();
for (SymbolsList::const_iterator it = symbols.begin(); it != end; ++it) {
char_type c = *it;
@ -259,9 +282,13 @@ void GuiSymbols::updateSymbolList()
continue;
QListWidgetItem * lwi = new QListWidgetItem(
QString::fromUcs4((uint const *) &c, 1));
lwi->setTextAlignment(Qt::AlignCenter);
symbolsLW->addItem(lwi);
if (show_all || c > range_start && c < range_end) {
lwi->setTextAlignment(Qt::AlignCenter);
symbolsLW->addItem(lwi);
}
QString block = getBlock(c);
if (category.isEmpty())
category = block;
if (used_blocks.find(block) == used_blocks.end())
used_blocks[block] = lwi;
}
@ -270,6 +297,13 @@ void GuiSymbols::updateSymbolList()
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();
}

View File

@ -45,6 +45,7 @@ public Q_SLOTS:
void on_symbolsLW_itemActivated(QListWidgetItem *);
void on_symbolsLW_itemClicked(QListWidgetItem * item);
void on_categoryCO_activated(QString const & text);
void on_categoryFilterCB_toggled(bool);
void on_chosenLE_returnPressed();
void on_chosenLE_textChanged(QString const &);

View File

@ -58,13 +58,23 @@
</property>
<property name="sizeHint" >
<size>
<width>301</width>
<height>20</height>
<width>81</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2" >
<item row="0" column="2" >
<widget class="QCheckBox" name="categoryFilterCB" >
<property name="toolTip" >
<string>Select this to display all available characters at once</string>
</property>
<property name="text" >
<string>&amp;Display all</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3" >
<widget class="QListWidget" name="symbolsLW" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
@ -104,14 +114,14 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2" >
<item row="2" column="0" colspan="3" >
<widget class="QLineEdit" name="chosenLE" >
<property name="readOnly" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2" >
<item row="3" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<item>
<spacer>