23 #include "kcharselect_p.h" 
   25 #include <QtGui/QActionEvent> 
   26 #include <QtGui/QDoubleSpinBox> 
   27 #include <QtGui/QHeaderView> 
   28 #include <QtGui/QBoxLayout> 
   29 #include <QtGui/QShortcut> 
   30 #include <QtGui/QSplitter> 
   31 #include <QtGui/QPushButton> 
   32 #include <QtGui/QToolButton> 
   46 class KCharSelectTablePrivate
 
   49     KCharSelectTablePrivate(KCharSelectTable *q): q(q), model(0)
 
   55     KCharSelectItemModel *model;
 
   59     void _k_resizeCells();
 
   60     void _k_doubleClicked(
const QModelIndex & index);
 
   61     void _k_slotSelectionChanged(
const QItemSelection & selected, 
const QItemSelection & deselected);
 
   64 class KCharSelect::KCharSelectPrivate
 
   74     enum { MaxHistoryItems = 100 };
 
   80           ,historyEnabled(false)
 
   95     KCharSelectTable *charTable;
 
  105     void historyAdd(
const QChar &c, 
bool fromSearch, 
const QString &searchString);
 
  106     void showFromHistory(
int index);
 
  107     void updateBackForwardButtons();
 
  108     void _k_activateSearchLine();
 
  111     void _k_fontSelected();
 
  112     void _k_updateCurrentChar(
const QChar &c);
 
  113     void _k_slotUpdateUnicode(
const QChar &c);
 
  114     void _k_sectionSelected(
int index);
 
  115     void _k_blockSelected(
int index);
 
  116     void _k_searchEditChanged();
 
  118     void _k_linkClicked(
QUrl url);
 
  125 KCharSelectTable::KCharSelectTable(
QWidget *parent, 
const QFont &_font)
 
  126         : QTableView(parent), d(new KCharSelectTablePrivate(this))
 
  130     setTabKeyNavigation(
false);
 
  131     setSelectionMode(QAbstractItemView::SingleSelection);
 
  133     _palette.setColor(backgroundRole(), palette().color(QPalette::Base));
 
  134     setPalette(_palette);
 
  135     verticalHeader()->setVisible(
false);
 
  136     verticalHeader()->setResizeMode(QHeaderView::Custom);
 
  137     horizontalHeader()->setVisible(
false);
 
  138     horizontalHeader()->setResizeMode(QHeaderView::Custom);
 
  140     setFocusPolicy(Qt::StrongFocus);
 
  141     setDragEnabled(
true);
 
  142     setAcceptDrops(
true);
 
  143     setDropIndicatorShown(
false);
 
  144     setDragDropMode(QAbstractItemView::DragDrop);
 
  146     connect(
this, SIGNAL(doubleClicked(QModelIndex)), 
this, SLOT(_k_doubleClicked(QModelIndex)));
 
  151 KCharSelectTable::~KCharSelectTable()
 
  156 void KCharSelectTable::setFont(
const QFont &_font)
 
  158     QTableView::setFont(_font);
 
  160     if (d->model) d->model->setFont(_font);
 
  164 QChar KCharSelectTable::chr()
 
  169 QFont KCharSelectTable::font()
 const 
  179 void KCharSelectTable::setChar(
const QChar &c)
 
  181     int pos = d->chars.indexOf(c);
 
  183         setCurrentIndex(model()->index(pos / model()->columnCount(), pos % model()->columnCount()));
 
  191     KCharSelectItemModel *m = d->model;
 
  192     d->model = 
new KCharSelectItemModel(chars, d->font, 
this);
 
  196     setSelectionModel(selectionModel);
 
  197     setSelectionBehavior(QAbstractItemView::SelectItems);
 
  198     setSelectionMode(QAbstractItemView::SingleSelection);
 
  199     connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), 
this, SLOT(_k_slotSelectionChanged(QItemSelection,QItemSelection)));
 
  200     connect(d->model, SIGNAL(showCharRequested(QChar)), 
this, SIGNAL(showCharRequested(QChar)));
 
  204 void KCharSelectTable::scrollTo(
const QModelIndex & index, ScrollHint hint)
 
  207     if (index.isValid() && index.column() != 0) {
 
  208         QTableView::scrollTo(d->model->index(index.row(), 0), hint);
 
  210         QTableView::scrollTo(index, hint);
 
  214 void KCharSelectTablePrivate::_k_slotSelectionChanged(
const QItemSelection & selected, 
const QItemSelection & deselected)
 
  216     Q_UNUSED(deselected);
 
  217     if (!model || selected.indexes().isEmpty())
 
  219     QVariant temp = model->data(selected.indexes().at(0), KCharSelectItemModel::CharacterRole);
 
  220     if (temp.type() != QVariant::Char)
 
  222     QChar c = temp.toChar();
 
  224     emit q->focusItemChanged(c);
 
  227 void KCharSelectTable::resizeEvent(QResizeEvent * e)
 
  229     QTableView::resizeEvent(e);
 
  230     if (e->size().width() != e->oldSize().width()) {
 
  235 void KCharSelectTablePrivate::_k_resizeCells()
 
  237     if (!q->model()) 
return;
 
  238     static_cast<KCharSelectItemModel*
>(q->model())->updateColumnCount(q->viewport()->size().width());
 
  240     QChar oldChar = q->chr();
 
  242     const int new_w   = q->viewport()->size().width() / q->model()->columnCount(QModelIndex());
 
  243     const int columns = q->model()->columnCount(QModelIndex());
 
  244     const int rows = q->model()->rowCount(QModelIndex());
 
  245     q->setUpdatesEnabled(
false);
 
  246     QHeaderView* hv = q->horizontalHeader();
 
  247     int spaceLeft = q->viewport()->size().width() % new_w + 1;
 
  248     for (
int i = 0;i <= columns;i++) {
 
  250             hv->resizeSection(i, new_w + 1);
 
  252             hv->resizeSection(i, new_w);
 
  256     hv = q->verticalHeader();
 
  258     int new_h = QFontMetrics(font).lineSpacing() + 1;
 
  260     int new_h = QFontMetrics(font).xHeight() * 3;
 
  262     if (new_h < 5 || new_h < 4 + QFontMetrics(font).height()) {
 
  263         new_h = qMax(5, 4 + QFontMetrics(font).height());
 
  265     for (
int i = 0;i < rows;i++) {
 
  266         hv->resizeSection(i, new_h);
 
  269     q->setUpdatesEnabled(
true);
 
  273 void KCharSelectTablePrivate::_k_doubleClicked(
const QModelIndex & index)
 
  275     QChar c = model->data(index, KCharSelectItemModel::CharacterRole).toChar();
 
  276     if (s_data->isPrint(c)) {
 
  277         emit q->activated(c);
 
  281 void KCharSelectTable::keyPressEvent(QKeyEvent *e)
 
  289     case Qt::Key_Enter: 
case Qt::Key_Return: {
 
  290             if (!currentIndex().isValid()) 
return;
 
  291             QChar c = d->model->data(currentIndex(), KCharSelectItemModel::CharacterRole).toChar();
 
  292             if (s_data->isPrint(c)) {
 
  299     QTableView::keyPressEvent(e);
 
  307 #ifndef KDE_NO_DEPRECATED 
  309         : 
QWidget(parent), d(new KCharSelectPrivate(this))
 
  311     init(controls, NULL);
 
  318         ,
const Controls controls)
 
  319     : 
QWidget(parent), d(new KCharSelectPrivate(this))
 
  321     init(controls, collection);
 
  326     if (collection==NULL) {
 
  328         d->actions->addAssociatedWidget(
this);
 
  330         d->actions = collection;
 
  333     QVBoxLayout *mainLayout = 
new QVBoxLayout(
this);
 
  334     mainLayout->setMargin(0);
 
  336         QHBoxLayout *searchLayout = 
new QHBoxLayout();
 
  337         mainLayout->addLayout(searchLayout);
 
  339         searchLayout->addWidget(d->searchLine);
 
  340         d->searchLine->setClickMessage(
i18n(
"Enter a search term or character here"));
 
  341         d->searchLine->setClearButtonShown(
true);
 
  342         d->searchLine->setToolTip(
i18n(
"Enter a search term or character here"));
 
  344         connect(d->searchLine, SIGNAL(textChanged(
QString)), 
this, SLOT(_k_searchEditChanged()));
 
  345         connect(d->searchLine, SIGNAL(returnPressed()), 
this, SLOT(_k_search()));
 
  350         line->setFrameShape(QFrame::HLine);
 
  351         line->setFrameShadow(QFrame::Sunken);
 
  352         mainLayout->addWidget(line);
 
  355     QHBoxLayout *comboLayout = 
new QHBoxLayout();
 
  358     comboLayout->addWidget(d->backButton);
 
  359     d->backButton->setEnabled(
false);
 
  360     d->backButton->setText(
i18nc(
"Goes to previous character", 
"Previous in History"));
 
  361     d->backButton->setIcon(
KIcon(
"go-previous"));
 
  362     d->backButton->setToolTip(
i18n(
"Previous Character in History"));
 
  365     comboLayout->addWidget(d->forwardButton);
 
  366     d->forwardButton->setEnabled(
false);
 
  367     d->forwardButton->setText(
i18nc(
"Goes to next character", 
"Next in History"));
 
  368     d->forwardButton->setIcon(
KIcon(
"go-next"));
 
  369     d->forwardButton->setToolTip(
i18n(
"Next Character in History"));
 
  373     connect(d->backButton, SIGNAL(clicked()), 
this, SLOT(_k_back()));
 
  374     connect(d->forwardButton, SIGNAL(clicked()), 
this, SLOT(_k_forward()));
 
  377     d->sectionCombo->setToolTip(
i18n(
"Select a category"));
 
  378     comboLayout->addWidget(d->sectionCombo);
 
  380     d->blockCombo->setToolTip(
i18n(
"Select a block to be displayed"));
 
  381     d->blockCombo->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
 
  382     comboLayout->addWidget(d->blockCombo, 1);
 
  383     d->sectionCombo->addItems(s_data->sectionList());
 
  384     d->blockCombo->setMinimumWidth(QFontMetrics(QWidget::font()).averageCharWidth() * 25);
 
  386     connect(d->sectionCombo, SIGNAL(currentIndexChanged(
int)), 
this, SLOT(_k_sectionSelected(
int)));
 
  387     connect(d->blockCombo, SIGNAL(currentIndexChanged(
int)), 
this, SLOT(_k_blockSelected(
int)));
 
  390     comboLayout->addWidget(d->fontCombo);
 
  391     d->fontCombo->setEditable(
true);
 
  392     d->fontCombo->resize(d->fontCombo->sizeHint());
 
  393     d->fontCombo->setToolTip(
i18n(
"Set font"));
 
  395     d->fontSizeSpinBox = 
new QSpinBox(
this);
 
  396     comboLayout->addWidget(d->fontSizeSpinBox);
 
  397     d->fontSizeSpinBox->setValue(QWidget::font().pointSize());
 
  398     d->fontSizeSpinBox->setRange(1, 400);
 
  399     d->fontSizeSpinBox->setSingleStep(1);
 
  400     d->fontSizeSpinBox->setToolTip(
i18n(
"Set font size"));
 
  402     connect(d->fontCombo, SIGNAL(currentIndexChanged(
QString)), 
this, SLOT(_k_fontSelected()));
 
  403     connect(d->fontSizeSpinBox, SIGNAL(valueChanged(
int)), 
this, SLOT(_k_fontSelected()));
 
  406         mainLayout->addLayout(comboLayout);
 
  409         d->backButton->hide();
 
  410         d->forwardButton->hide();
 
  413         d->fontCombo->hide();
 
  416         d->fontSizeSpinBox->hide();
 
  419         d->sectionCombo->hide();
 
  420         d->blockCombo->hide();
 
  423     QSplitter *splitter = 
new QSplitter(
this);
 
  425         mainLayout->addWidget(splitter);
 
  429     d->charTable = 
new KCharSelectTable(
this, 
QFont());
 
  431         splitter->addWidget(d->charTable);
 
  432         d->charTable->setFocus(Qt::OtherFocusReason);
 
  434         d->charTable->hide();
 
  437     const QSize sz(200, 200);
 
  438     d->charTable->resize(sz);
 
  439     d->charTable->setMinimumSize(sz);
 
  441     d->charTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
  445     connect(d->charTable, SIGNAL(focusItemChanged(QChar)), 
this, SLOT(_k_updateCurrentChar(QChar)));
 
  446     connect(d->charTable, SIGNAL(activated(QChar)), 
this, SIGNAL(
charSelected(QChar)));
 
  447     connect(d->charTable, SIGNAL(focusItemChanged(QChar)),
 
  450     connect(d->charTable, SIGNAL(showCharRequested(QChar)), 
this, SLOT(
setCurrentChar(QChar)));
 
  454         splitter->addWidget(d->detailBrowser);
 
  456         d->detailBrowser->hide();
 
  458     d->detailBrowser->setOpenLinks(
false);
 
  459     connect(d->detailBrowser, SIGNAL(anchorClicked(
QUrl)), 
this, SLOT(_k_linkClicked(
QUrl)));
 
  461     setFocusPolicy(Qt::StrongFocus);
 
  462     setFocusProxy(d->charTable);
 
  463     d->_k_sectionSelected(0);
 
  464     d->_k_blockSelected(0);
 
  467     d->historyEnabled = 
true;
 
  477     return QWidget::sizeHint();
 
  482     d->fontCombo->setCurrentFont(_font);
 
  483     d->fontSizeSpinBox->setValue(_font.pointSize());
 
  484     d->_k_fontSelected();
 
  489     return d->charTable->chr();
 
  494     return d->charTable->font();
 
  499     return d->charTable->displayedChars();
 
  504     bool oldHistoryEnabled = d->historyEnabled;
 
  505     d->historyEnabled = 
false;
 
  506     int block = s_data->blockIndex(c);
 
  507     int section = s_data->sectionIndex(block);
 
  508     d->sectionCombo->setCurrentIndex(section);
 
  509     int index = d->blockCombo->findData(block);
 
  511         d->blockCombo->setCurrentIndex(index);
 
  513     d->historyEnabled = oldHistoryEnabled;
 
  514     d->charTable->setChar(c);
 
  517 void KCharSelect::KCharSelectPrivate::historyAdd(
const QChar &c, 
bool fromSearch, 
const QString &searchString)
 
  521     if (!historyEnabled) {
 
  525     if (!history.isEmpty() && c == history.last().c) {
 
  531     while (!history.isEmpty() && inHistory != history.count() - 1) {
 
  532         history.removeLast();
 
  535     while (history.size() >= MaxHistoryItems) {
 
  536         history.removeFirst();
 
  541     item.fromSearch = fromSearch;
 
  542     item.searchString = searchString;
 
  543     history.append(item);
 
  545     inHistory = history.count() - 1;
 
  546     updateBackForwardButtons();
 
  549 void KCharSelect::KCharSelectPrivate::showFromHistory(
int index)
 
  551     Q_ASSERT(index >= 0 && index < history.count());
 
  552     Q_ASSERT(index != inHistory);
 
  555     updateBackForwardButtons();
 
  557     const HistoryItem &item = history[index];
 
  562     bool oldHistoryEnabled = historyEnabled;
 
  563     historyEnabled = 
false;
 
  564     if (item.fromSearch) {
 
  565         if (searchLine->text() != item.searchString) {
 
  566             searchLine->setText(item.searchString);
 
  569         charTable->setChar(item.c);
 
  572         q->setCurrentChar(item.c);
 
  574     historyEnabled = oldHistoryEnabled;
 
  577 void KCharSelect::KCharSelectPrivate::updateBackForwardButtons()
 
  579     backButton->setEnabled(inHistory > 0);
 
  580     forwardButton->setEnabled(inHistory < history.count() - 1);
 
  583 void KCharSelect::KCharSelectPrivate::_k_activateSearchLine()
 
  585     searchLine->setFocus();
 
  586     searchLine->selectAll();
 
  589 void KCharSelect::KCharSelectPrivate::_k_back()
 
  591     Q_ASSERT(inHistory > 0);
 
  592     showFromHistory(inHistory - 1);
 
  595 void KCharSelect::KCharSelectPrivate::_k_forward()
 
  597     Q_ASSERT(inHistory + 1 < history.count());
 
  598     showFromHistory(inHistory + 1);
 
  601 void KCharSelect::KCharSelectPrivate::_k_fontSelected()
 
  603     QFont font = fontCombo->currentFont();
 
  604     font.setPointSize(fontSizeSpinBox->value());
 
  605     charTable->setFont(font);
 
  606     emit q->currentFontChanged(font);
 
  609 void KCharSelect::KCharSelectPrivate::_k_updateCurrentChar(
const QChar &c)
 
  614         int block = s_data->blockIndex(c);
 
  615         int section = s_data->sectionIndex(block);
 
  616         sectionCombo->setCurrentIndex(section);
 
  617         int index = blockCombo->findData(block);
 
  619             blockCombo->setCurrentIndex(index);
 
  624        historyAdd(c, searchMode, searchLine->text());
 
  626     _k_slotUpdateUnicode(c);
 
  629 void KCharSelect::KCharSelectPrivate::_k_slotUpdateUnicode(
const QChar &c)
 
  631     QString html = 
"<p>" + 
i18n(
"Character:") + 
' ' + s_data->display(c, charTable->font()) + 
' ' +
 
  632                    s_data->formatCode(c.unicode())  + 
"<br />";
 
  635     if (!name.isEmpty()) {
 
  637         html += 
i18n(
"Name: ") + Qt::escape(name) + 
"</p>";
 
  643     QStringList approxEquivalents = s_data->approximateEquivalents(c);
 
  644     if (!(aliases.isEmpty() && notes.isEmpty() && seeAlso.isEmpty() && equivalents.isEmpty() && approxEquivalents.isEmpty())) {
 
  645         html += 
"<p><b>" + 
i18n(
"Annotations and Cross References") + 
"</b></p>";
 
  648     if (!aliases.isEmpty()) {
 
  649         html += 
"<p style=\"margin-bottom: 0px;\">" + 
i18n(
"Alias names:") + 
"</p><ul style=\"margin-top: 0px;\">";
 
  650         foreach(
const QString &alias, aliases) {
 
  651             html += 
"<li>" + Qt::escape(alias) + 
"</li>";
 
  656     if (!notes.isEmpty()) {
 
  657         html += 
"<p style=\"margin-bottom: 0px;\">" + 
i18n(
"Notes:") + 
"</p><ul style=\"margin-top: 0px;\">";
 
  658         foreach(
const QString ¬e, notes) {
 
  659             html += 
"<li>" + createLinks(Qt::escape(note)) + 
"</li>";
 
  664     if (!seeAlso.isEmpty()) {
 
  665         html += 
"<p style=\"margin-bottom: 0px;\">" + 
i18n(
"See also:") + 
"</p><ul style=\"margin-top: 0px;\">";
 
  666         foreach(
const QChar &c2, seeAlso) {
 
  667             html += 
"<li><a href=\"" + QString::number(c2.unicode(), 16) + 
"\">";
 
  668             if (s_data->isPrint(c2)) {
 
  669                 html += 
"&#" + QString::number(c2.unicode()) + 
"; ";
 
  671             html += s_data->formatCode(c2.unicode()) + 
' ' + Qt::escape(s_data->name(c2)) + 
"</a></li>";
 
  676     if (!equivalents.isEmpty()) {
 
  677         html += 
"<p style=\"margin-bottom: 0px;\">" + 
i18n(
"Equivalents:") + 
"</p><ul style=\"margin-top: 0px;\">";
 
  678         foreach(
const QString &equivalent, equivalents) {
 
  679             html += 
"<li>" + createLinks(Qt::escape(equivalent)) + 
"</li>";
 
  684     if (!approxEquivalents.isEmpty()) {
 
  685         html += 
"<p style=\"margin-bottom: 0px;\">" + 
i18n(
"Approximate equivalents:") + 
"</p><ul style=\"margin-top: 0px;\">";
 
  686         foreach(
const QString &approxEquivalent, approxEquivalents) {
 
  687             html += 
"<li>" + createLinks(Qt::escape(approxEquivalent)) + 
"</li>";
 
  693     if (unihan.count() == 7) {
 
  694         html += 
"<p><b>" + 
i18n(
"CJK Ideograph Information") + 
"</b></p><p>";
 
  696         if (!unihan[0].isEmpty()) {
 
  697             html += 
i18n(
"Definition in English: ") + unihan[0];
 
  700         if (!unihan[2].isEmpty()) {
 
  701             if (!newline) html += 
"<br>";
 
  702             html += 
i18n(
"Mandarin Pronunciation: ") + unihan[2];
 
  705         if (!unihan[1].isEmpty()) {
 
  706             if (!newline) html += 
"<br>";
 
  707             html += 
i18n(
"Cantonese Pronunciation: ") + unihan[1];
 
  710         if (!unihan[6].isEmpty()) {
 
  711             if (!newline) html += 
"<br>";
 
  712             html += 
i18n(
"Japanese On Pronunciation: ") + unihan[6];
 
  715         if (!unihan[5].isEmpty()) {
 
  716             if (!newline) html += 
"<br>";
 
  717             html += 
i18n(
"Japanese Kun Pronunciation: ") + unihan[5];
 
  720         if (!unihan[3].isEmpty()) {
 
  721             if (!newline) html += 
"<br>";
 
  722             html += 
i18n(
"Tang Pronunciation: ") + unihan[3];
 
  725         if (!unihan[4].isEmpty()) {
 
  726             if (!newline) html += 
"<br>";
 
  727             html += 
i18n(
"Korean Pronunciation: ") + unihan[4];
 
  733     html += 
"<p><b>" + 
i18n(
"General Character Properties") + 
"</b><br>";
 
  734     html += 
i18n(
"Block: ") + s_data->block(c) + 
"<br>";
 
  735     html += 
i18n(
"Unicode category: ") + s_data->categoryText(s_data->category(c)) + 
"</p>";
 
  737     QByteArray utf8 = 
QString(c).toUtf8();
 
  739     html += 
"<p><b>" + 
i18n(
"Various Useful Representations") + 
"</b><br>";
 
  740     html += 
i18n(
"UTF-8:");
 
  741     foreach(
unsigned char c, utf8)
 
  742     html += 
' ' + s_data->formatCode(c, 2, 
"0x");
 
  743     html += 
"<br>" + 
i18n(
"UTF-16: ") + s_data->formatCode(c.unicode(), 4, 
"0x") + 
"<br>";
 
  744     html += 
i18n(
"C octal escaped UTF-8: ");
 
  745     foreach(
unsigned char c, utf8)
 
  746     html += s_data->formatCode(c, 3, 
"\\", 8);
 
  747     html += 
"<br>" + 
i18n(
"XML decimal entity:") + 
" &#" + QString::number(c.unicode()) + 
";</p>";
 
  749     detailBrowser->setHtml(html);
 
  754     QRegExp rx(
"\\b([\\dABCDEF]{4})\\b");
 
  759     while ((pos = rx.indexIn(s, pos)) != -1) {
 
  761         pos += rx.matchedLength();
 
  765     foreach(
const QString &c, chars2) {
 
  766         int unicode = c.toInt(0, 16);
 
  767         QString link = 
"<a href=\"" + c + 
"\">";
 
  768         if (s_data->isPrint(QChar(unicode))) {
 
  769             link += 
"&#" + QString::number(unicode) + 
"; ";
 
  771         link += 
"U+" + c + 
' ';
 
  772         link += Qt::escape(s_data->name(QChar(unicode))) + 
"</a>";
 
  778 void KCharSelect::KCharSelectPrivate::_k_sectionSelected(
int index)
 
  781     QList<int> blocks = s_data->sectionContents(index);
 
  782     foreach(
int block, blocks) {
 
  783         blockCombo->addItem(s_data->blockName(block), 
QVariant(block));
 
  785     blockCombo->setCurrentIndex(0);
 
  788 void KCharSelect::KCharSelectPrivate::_k_blockSelected(
int index)
 
  799     int block = blockCombo->itemData(index).toInt();
 
  800     const QList<QChar> contents = s_data->blockContents(block);
 
  801     if(contents.count() <= index) {
 
  804     charTable->setContents(contents);
 
  805     emit q->displayedCharsChanged();
 
  806     charTable->setChar(contents[0]);
 
  809 void KCharSelect::KCharSelectPrivate::_k_searchEditChanged()
 
  811     if (searchLine->text().isEmpty()) {
 
  812         sectionCombo->setEnabled(
true);
 
  813         blockCombo->setEnabled(
true);
 
  817         QChar c = charTable->chr();
 
  818         bool oldHistoryEnabled = historyEnabled;
 
  819         historyEnabled = 
false;
 
  820         _k_blockSelected(blockCombo->currentIndex());
 
  821         historyEnabled = oldHistoryEnabled;
 
  822         q->setCurrentChar(c);
 
  824         sectionCombo->setEnabled(
false);
 
  825         blockCombo->setEnabled(
false);
 
  827         int length = searchLine->text().length();
 
  834 void KCharSelect::KCharSelectPrivate::_k_search()
 
  836     if (searchLine->text().isEmpty()) {
 
  840     const QList<QChar> contents = s_data->find(searchLine->text());
 
  841     charTable->setContents(contents);
 
  842     emit q->displayedCharsChanged();
 
  843     if (!contents.isEmpty()) {
 
  844         charTable->setChar(contents[0]);
 
  848 void  KCharSelect::KCharSelectPrivate::_k_linkClicked(
QUrl url)
 
  851     if (hex.size() > 4) {
 
  854     int unicode = hex.toInt(0, 16);
 
  856     q->setCurrentChar(QChar(unicode));
 
  861 QVariant KCharSelectItemModel::data(
const QModelIndex &index, 
int role)
 const 
  863     int pos = m_columns * (index.row()) + index.column();
 
  864     if (!index.isValid() || pos < 0 || pos >= m_chars.size()
 
  865             || index.row() < 0 || index.column() < 0) {
 
  866         if (role == Qt::BackgroundColorRole) {
 
  867             return QVariant(qApp->palette().color(QPalette::Button));
 
  872     QChar c = m_chars[pos];
 
  873     if (role == Qt::ToolTipRole) {
 
  874         QString result = s_data->display(c, m_font) + 
"<br />" + Qt::escape(s_data->name(c)) + 
"<br />" +
 
  875                          i18n(
"Unicode code point:") + 
' ' + s_data->formatCode(c.unicode()) + 
"<br />" +
 
  876                          i18nc(
"Character", 
"In decimal:") + 
' ' + QString::number(c.unicode());
 
  878     } 
else if (role == Qt::TextAlignmentRole)
 
  879         return QVariant(Qt::AlignHCenter | Qt::AlignVCenter);
 
  880     else if (role == Qt::DisplayRole) {
 
  881         if (s_data->isPrint(c))
 
  884     } 
else if (role == Qt::BackgroundColorRole) {
 
  885         QFontMetrics fm = QFontMetrics(m_font);
 
  886         if (fm.inFont(c) && s_data->isPrint(c))
 
  887             return QVariant(qApp->palette().color(QPalette::Base));
 
  889             return QVariant(qApp->palette().color(QPalette::Button));
 
  890     } 
else if (role == Qt::FontRole)
 
  892     else if (role == CharacterRole) {
 
  898 #include "kcharselect.moc" 
  899 #include "kcharselect_p.moc" 
QString i18n(const char *text)
A container for a set of QAction objects. 
KAction * back(const QObject *recvr, const char *slot, QObject *parent)
Move back (web style menu). 
A lightweight font selection widget. 
#define K_GLOBAL_STATIC(TYPE, NAME)
Shows the font size spin box. 
const char * name(StandardAction id)
This will return the internal name of a given standard action. 
Shows the search widgets. 
KAction * find(const QObject *recvr, const char *slot, QObject *parent)
Initiate a 'find' request in the current document. 
Shows the detail browser. 
QString i18nc(const char *ctxt, const char *text)
Shows the category/block selection combo boxes. 
QChar currentChar() const 
Returns the currently selected character. 
void charSelected(const QChar &c)
A character is selected to be inserted somewhere. 
Shows the Back/Forward buttons. 
QList< QChar > displayedChars() const 
Returns a list of currently displayed characters. 
A wrapper around QIcon that provides KDE icon features. 
void setCurrentChar(const QChar &c)
Highlights the character c. 
Shows the font combo box. 
void currentCharChanged(const QChar &c)
The current character is changed. 
void setCurrentFont(const QFont &font)
Sets the font which is displayed to font. 
KAction * forward(const QObject *recvr, const char *slot, QObject *parent)
Move forward (web style menu). 
Character selection widget. 
An enhanced QLineEdit widget for inputting text. 
KCharSelect(QWidget *parent, KActionCollection *collection, const Controls controls=AllGuiElements)
Constructor. 
QFont currentFont() const 
Returns the currently displayed font. 
virtual QSize sizeHint() const 
Reimplemented.