9#include "kcharselect.h"
10#include "kcharselect_p.h"
12#include "loggingcategory.h"
15#include <QActionEvent>
16#include <QApplication>
20#include <QDoubleSpinBox>
21#include <QFontComboBox>
24#include <QRegularExpression>
26#include <QTextBrowser>
30Q_GLOBAL_STATIC(KCharSelectData, s_data)
32class KCharSelectTablePrivate
35 KCharSelectTablePrivate(KCharSelectTable *qq)
40 KCharSelectTable *
const q;
43 KCharSelectItemModel *model =
nullptr;
48 void doubleClicked(
const QModelIndex &index);
49 void slotSelectionChanged(
const QItemSelection &selected,
const QItemSelection &deselected);
52class KCharSelectPrivate
54 Q_DECLARE_TR_FUNCTIONS(KCharSelect)
63 enum { MaxHistoryItems = 100 };
65 KCharSelectPrivate(KCharSelect *qq)
72 QToolButton *backButton =
nullptr;
73 QToolButton *forwardButton =
nullptr;
74 QLineEdit *searchLine =
nullptr;
75 QFontComboBox *fontCombo =
nullptr;
76 QSpinBox *fontSizeSpinBox =
nullptr;
77 QComboBox *sectionCombo =
nullptr;
78 QComboBox *blockCombo =
nullptr;
79 KCharSelectTable *charTable =
nullptr;
80 QTextBrowser *detailBrowser =
nullptr;
82 bool searchMode =
false;
83 bool historyEnabled =
false;
84 bool allPlanesEnabled =
false;
86 QList<HistoryItem> history;
87 QObject *actionParent =
nullptr;
89 QString createLinks(QString s);
90 void historyAdd(uint c,
bool fromSearch,
const QString &searchString);
91 void showFromHistory(
int index);
92 void updateBackForwardButtons();
93 void activateSearchLine();
97 void charSelected(uint c);
98 void updateCurrentChar(uint c);
99 void slotUpdateUnicode(uint c);
100 void sectionSelected(
int index);
101 void blockSelected(
int index);
102 void searchEditChanged();
104 void linkClicked(QUrl url);
107Q_DECLARE_TYPEINFO(KCharSelectPrivate::HistoryItem, Q_RELOCATABLE_TYPE);
113KCharSelectTable::KCharSelectTable(
QWidget *parent,
const QFont &_font)
115 , d(new KCharSelectTablePrivate(this))
119 setTabKeyNavigation(
false);
125 setPalette(_palette);
126 verticalHeader()->setVisible(
false);
128 horizontalHeader()->setVisible(
false);
132 setDragEnabled(
true);
133 setAcceptDrops(
true);
134 setDropIndicatorShown(
false);
138 connect(
this, &KCharSelectTable::doubleClicked,
this, [
this](
const QModelIndex &index) {
139 d->doubleClicked(index);
145KCharSelectTable::~KCharSelectTable() =
default;
147void KCharSelectTable::setFont(
const QFont &_font)
152 d->model->setFont(_font);
157uint KCharSelectTable::chr()
162QFont KCharSelectTable::font()
const
167QList<uint> KCharSelectTable::displayedChars()
const
172void KCharSelectTable::setChar(uint c)
176 setCurrentIndex(model()->index(pos / model()->columnCount(), pos % model()->columnCount()));
180void KCharSelectTable::setContents(
const QList<uint> &chars)
184 auto oldModel = d->model;
185 d->model =
new KCharSelectItemModel(chars, d->font,
this);
191 d->slotSelectionChanged(selected, deselected);
194 connect(d->model, &KCharSelectItemModel::showCharRequested,
this, &KCharSelectTable::showCharRequested);
199void KCharSelectTable::scrollTo(
const QModelIndex &index, ScrollHint hint)
211 Q_UNUSED(deselected);
212 if (!model || selected.
indexes().isEmpty()) {
215 QVariant temp = model->data(selected.
indexes().at(0), KCharSelectItemModel::CharacterRole);
221 Q_EMIT q->focusItemChanged(c);
236 auto timer =
new QTimer(
this);
237 timer->setSingleShot(
true);
240 timer->deleteLater();
246void KCharSelectTablePrivate::resizeCells()
248 KCharSelectItemModel *model =
static_cast<KCharSelectItemModel *
>(q->model());
253 const int viewportWidth = q->viewport()->size().width();
255 QFontMetrics fontMetrics(font);
260 int maxCharWidth = 0;
261 const QList<uint> chars = model->chars();
262 for (
int i = 0; i < chars.size(); ++i) {
263 char32_t thisChar = chars.at(i);
264 if (s_data()->isPrint(thisChar)) {
265 maxCharWidth = qMax(maxCharWidth, fontMetrics.boundingRect(
QString::fromUcs4(&thisChar, 1)).width());
269 maxCharWidth = qMax(maxCharWidth, 2 * fontMetrics.xHeight());
270 maxCharWidth = qMax(maxCharWidth, fontMetrics.height());
273 maxCharWidth += 2 * textMargin;
275 const int columns = qMax(1, viewportWidth / maxCharWidth);
276 model->setColumnCount(columns);
278 const uint oldChar = q->chr();
280 const int new_w = viewportWidth / columns;
281 const int rows = model->rowCount();
282 q->setUpdatesEnabled(
false);
283 QHeaderView *hHeader = q->horizontalHeader();
285 const int spaceLeft = viewportWidth - new_w * columns;
286 for (
int i = 0; i <= columns; ++i) {
294 QHeaderView *vHeader = q->verticalHeader();
296 int new_h = fontMetrics.lineSpacing() + 1;
298 int new_h = fontMetrics.xHeight() * 3;
300 const int fontHeight = fontMetrics.height();
301 if (new_h < 5 || new_h < 4 + fontHeight) {
302 new_h = qMax(5, 4 + fontHeight);
305 for (
int i = 0; i < rows; ++i) {
309 q->setUpdatesEnabled(
true);
313void KCharSelectTablePrivate::doubleClicked(
const QModelIndex &index)
315 uint c = model->data(index, KCharSelectItemModel::CharacterRole).toUInt();
316 if (s_data()->isPrint(c)) {
317 Q_EMIT q->activated(c);
321void KCharSelectTable::keyPressEvent(
QKeyEvent *e)
330 if (!currentIndex().
isValid()) {
333 uint c = d->model->data(currentIndex(), KCharSelectItemModel::CharacterRole).toUInt();
334 if (s_data()->isPrint(c)) {
352 , d(new KCharSelectPrivate(this))
354 initWidget(controls,
nullptr);
359 , d(new KCharSelectPrivate(this))
361 initWidget(controls, actionParent);
366 if (!action || !actionParent) {
372 if (actionParent->
inherits(
"KActionCollection")) {
380void KCharSelect::initWidget(
const Controls controls,
QObject *actionParent)
382 d->actionParent = actionParent;
384 QVBoxLayout *mainLayout =
new QVBoxLayout(
this);
387 QHBoxLayout *searchLayout =
new QHBoxLayout();
389 d->searchLine =
new QLineEdit(
this);
391 d->searchLine->setPlaceholderText(
tr(
"Enter a search term or character…",
"@info:placeholder"));
392 d->searchLine->setClearButtonEnabled(
true);
393 d->searchLine->setToolTip(
tr(
"Enter a search term or character here",
"@info:tooltip"));
395 QAction *findAction =
new QAction(
this);
397 d->activateSearchLine();
400 findAction->
setText(
tr(
"&Find…",
"@action"));
405 d->searchEditChanged();
413 QFrame *line =
new QFrame(
this);
419 QHBoxLayout *comboLayout =
new QHBoxLayout();
421 d->backButton =
new QToolButton(
this);
423 d->backButton->setEnabled(
false);
424 d->backButton->setText(
tr(
"Previous in History",
"@action:button Goes to previous character"));
426 d->backButton->setToolTip(
tr(
"Go to previous character in history",
"@info:tooltip"));
428 d->forwardButton =
new QToolButton(
this);
429 comboLayout->
addWidget(d->forwardButton);
430 d->forwardButton->setEnabled(
false);
431 d->forwardButton->setText(
tr(
"Next in History",
"@action:button Goes to next character"));
433 d->forwardButton->setToolTip(
tr(
"Go to next character in history",
"info:tooltip"));
435 QAction *backAction =
new QAction(
this);
438 backAction->
setText(
tr(
"&Back",
"@action go back"));
442 QAction *forwardAction =
new QAction(
this);
445 forwardAction->
setText(
tr(
"&Forward",
"@action go forward"));
450 QIcon tmp = backAction->
icon();
462 d->sectionCombo =
new QComboBox(
this);
463 d->sectionCombo->setObjectName(QStringLiteral(
"sectionCombo"));
464 d->sectionCombo->setToolTip(
tr(
"Select a category",
"@info:tooltip"));
466 d->blockCombo =
new QComboBox(
this);
467 d->blockCombo->setObjectName(QStringLiteral(
"blockCombo"));
468 d->blockCombo->setToolTip(
tr(
"Select a block to be displayed",
"@info:tooltip"));
470 comboLayout->
addWidget(d->blockCombo, 1);
471 QStringList sectionList = s_data()->sectionList();
472 d->sectionCombo->addItems(sectionList);
473 d->blockCombo->setMinimumWidth(QFontMetrics(
QWidget::font()).averageCharWidth() * 25);
476 d->sectionSelected(index);
480 d->blockSelected(index);
483 d->fontCombo =
new QFontComboBox(
this);
485 d->fontCombo->setEditable(
true);
486 d->fontCombo->resize(d->fontCombo->sizeHint());
487 d->fontCombo->setToolTip(
tr(
"Set font",
"@info:tooltip"));
489 d->fontSizeSpinBox =
new QSpinBox(
this);
490 comboLayout->
addWidget(d->fontSizeSpinBox);
492 d->fontSizeSpinBox->setRange(1, 400);
493 d->fontSizeSpinBox->setSingleStep(1);
494 d->fontSizeSpinBox->setToolTip(
tr(
"Set font size",
"@info:tooltip"));
507 d->backButton->hide();
508 d->forwardButton->hide();
511 d->fontCombo->hide();
514 d->fontSizeSpinBox->hide();
517 d->sectionCombo->hide();
518 d->blockCombo->hide();
521 QSplitter *splitter =
new QSplitter(
this);
527 d->charTable =
new KCharSelectTable(
this, QFont());
531 d->charTable->hide();
534 const QSize sz(200, 200);
535 d->charTable->resize(sz);
536 d->charTable->setMinimumSize(sz);
542 connect(d->charTable, &KCharSelectTable::focusItemChanged,
this, [
this](uint c) {
543 d->updateCurrentChar(c);
545 connect(d->charTable, &KCharSelectTable::activated,
this, [
this](uint c) {
550 d->detailBrowser =
new QTextBrowser(
this);
554 d->detailBrowser->hide();
556 d->detailBrowser->setOpenLinks(
false);
568 d->sectionSelected(1);
571 d->historyEnabled =
true;
574KCharSelect::~KCharSelect() =
default;
583 d->fontCombo->setCurrentFont(_font);
584 d->fontSizeSpinBox->setValue(_font.
pointSize());
590 d->allPlanesEnabled = all;
593bool KCharSelect::allPlanesEnabled()
const
595 return d->allPlanesEnabled;
598QChar KCharSelect::currentChar()
const
600 if (d->allPlanesEnabled) {
601 qFatal(
"You must use KCharSelect::currentCodePoint instead of KCharSelect::currentChar");
603 return QChar(d->charTable->chr());
606uint KCharSelect::currentCodePoint()
const
608 return d->charTable->chr();
611QFont KCharSelect::currentFont()
const
613 return d->charTable->font();
618 if (d->allPlanesEnabled) {
619 qFatal(
"You must use KCharSelect::displayedCodePoints instead of KCharSelect::displayedChars");
622 const auto displayedChars = d->charTable->displayedChars();
623 result.
reserve(displayedChars.size());
624 for (uint c : displayedChars) {
632 return d->charTable->displayedChars();
637 if (d->allPlanesEnabled) {
638 qCritical(
"You should use KCharSelect::setCurrentCodePoint instead of KCharSelect::setCurrentChar");
646 qCritical(
"You must setAllPlanesEnabled(true) to use non-BMP characters");
650 qCWarning(KWidgetsAddonsLog,
"Code point outside Unicode range");
653 bool oldHistoryEnabled = d->historyEnabled;
654 d->historyEnabled =
false;
655 int block = s_data()->blockIndex(c);
656 int section = s_data()->sectionIndex(block);
657 d->sectionCombo->setCurrentIndex(section);
658 int index = d->blockCombo->findData(block);
660 d->blockCombo->setCurrentIndex(index);
662 d->historyEnabled = oldHistoryEnabled;
663 d->charTable->setChar(c);
666void KCharSelectPrivate::historyAdd(uint c,
bool fromSearch,
const QString &searchString)
670 if (!historyEnabled) {
674 if (!history.isEmpty() && c == history.last().c) {
680 while (!history.isEmpty() && inHistory != history.count() - 1) {
681 history.removeLast();
684 while (history.size() >= MaxHistoryItems) {
685 history.removeFirst();
690 item.fromSearch = fromSearch;
691 item.searchString = searchString;
694 inHistory = history.
count() - 1;
695 updateBackForwardButtons();
698void KCharSelectPrivate::showFromHistory(
int index)
700 Q_ASSERT(index >= 0 && index < history.count());
701 Q_ASSERT(index != inHistory);
704 updateBackForwardButtons();
706 const HistoryItem &item = history[index];
711 bool oldHistoryEnabled = historyEnabled;
712 historyEnabled =
false;
713 if (item.fromSearch) {
714 if (searchLine->text() != item.searchString) {
715 searchLine->setText(item.searchString);
718 charTable->setChar(item.c);
721 q->setCurrentCodePoint(item.c);
723 historyEnabled = oldHistoryEnabled;
726void KCharSelectPrivate::updateBackForwardButtons()
728 backButton->setEnabled(inHistory > 0);
729 forwardButton->setEnabled(inHistory < history.count() - 1);
732void KCharSelectPrivate::activateSearchLine()
734 searchLine->setFocus();
735 searchLine->selectAll();
738void KCharSelectPrivate::back()
740 Q_ASSERT(inHistory > 0);
741 showFromHistory(inHistory - 1);
744void KCharSelectPrivate::forward()
746 Q_ASSERT(inHistory + 1 < history.count());
747 showFromHistory(inHistory + 1);
750void KCharSelectPrivate::fontSelected()
752 QFont font = fontCombo->currentFont();
754 charTable->setFont(font);
755 Q_EMIT q->currentFontChanged(font);
758void KCharSelectPrivate::charSelected(uint c)
760 if (!allPlanesEnabled) {
761 Q_EMIT q->charSelected(QChar(c));
763 Q_EMIT q->codePointSelected(c);
766void KCharSelectPrivate::updateCurrentChar(uint c)
768 if (!allPlanesEnabled) {
769 Q_EMIT q->currentCharChanged(QChar(c));
771 Q_EMIT q->currentCodePointChanged(c);
772 if (searchMode || sectionCombo->currentIndex() == 0) {
776 int block = s_data()->blockIndex(c);
778 int section = s_data()->sectionIndex(block);
779 sectionCombo->setCurrentIndex(section);
781 int index = blockCombo->findData(block);
783 blockCombo->setCurrentIndex(index);
788 historyAdd(c, searchMode, searchLine->text());
791 slotUpdateUnicode(c);
794void KCharSelectPrivate::slotUpdateUnicode(uint c)
796 QString html = QLatin1String(
"<p>") + tr(
"Character:") + QLatin1Char(
' ') + s_data()->display(c, charTable->font()) + QLatin1Char(
' ')
797 + s_data()->formatCode(c) + QLatin1String(
"<br />");
799 QString
name = s_data()->name(c);
804 const QStringList aliases = s_data()->aliases(c);
805 const QStringList notes = s_data()->notes(c);
806 const QList<uint> seeAlso = s_data()->seeAlso(c);
807 const QStringList equivalents = s_data()->equivalents(c);
808 const QStringList approxEquivalents = s_data()->approximateEquivalents(c);
809 const QList<uint> decomposition = s_data()->decomposition(c);
811 html += QLatin1String(
"<p><b>") + tr(
"Annotations and Cross References") + QLatin1String(
"</b></p>");
815 html += QLatin1String(
"<p style=\"margin-bottom: 0px;\">") + tr(
"Alias names:") + QLatin1String(
"</p><ul style=\"margin-top: 0px;\">");
816 for (
const QString &alias : aliases) {
817 html += QLatin1String(
"<li>") + alias.
toHtmlEscaped() + QLatin1String(
"</li>");
819 html += QLatin1String(
"</ul>");
823 html += QLatin1String(
"<p style=\"margin-bottom: 0px;\">") + tr(
"Notes:") + QLatin1String(
"</p><ul style=\"margin-top: 0px;\">");
824 for (
const QString ¬e : notes) {
825 html += QLatin1String(
"<li>") + createLinks(note.toHtmlEscaped()) + QLatin1String(
"</li>");
827 html += QLatin1String(
"</ul>");
831 html += QLatin1String(
"<p style=\"margin-bottom: 0px;\">") + tr(
"See also:") + QLatin1String(
"</p><ul style=\"margin-top: 0px;\">");
832 for (uint c2 : seeAlso) {
836 html += QLatin1String(
"<li><a href=\"") +
QString::number(c2, 16) + QLatin1String(
"\">");
837 if (s_data()->isPrint(c2)) {
838 html += QLatin1String(
"‎&#") +
QString::number(c2) + QLatin1String(
"; ");
840 html += s_data()->formatCode(c2) + QLatin1Char(
' ') + s_data()->name(c2).
toHtmlEscaped() + QLatin1String(
"</a></li>");
842 html += QLatin1String(
"</ul>");
846 html += QLatin1String(
"<p style=\"margin-bottom: 0px;\">") + tr(
"Equivalents:") + QLatin1String(
"</p><ul style=\"margin-top: 0px;\">");
847 for (
const QString &equivalent : equivalents) {
848 html += QLatin1String(
"<li>") + createLinks(equivalent.toHtmlEscaped()) + QLatin1String(
"</li>");
850 html += QLatin1String(
"</ul>");
853 if (!approxEquivalents.
isEmpty()) {
854 html += QLatin1String(
"<p style=\"margin-bottom: 0px;\">") + tr(
"Approximate equivalents:") + QLatin1String(
"</p><ul style=\"margin-top: 0px;\">");
855 for (
const QString &approxEquivalent : approxEquivalents) {
856 html += QLatin1String(
"<li>") + createLinks(approxEquivalent.toHtmlEscaped()) + QLatin1String(
"</li>");
858 html += QLatin1String(
"</ul>");
861 if (!decomposition.
isEmpty()) {
862 html += QLatin1String(
"<p style=\"margin-bottom: 0px;\">") + tr(
"Decomposition:") + QLatin1String(
"</p><ul style=\"margin-top: 0px;\">");
863 for (uint c2 : decomposition) {
867 html += QLatin1String(
"<li>") + createLinks(s_data()->formatCode(c2, 4, QString())) + QLatin1String(
"</li>");
869 html += QLatin1String(
"</ul>");
872 QStringList unihan = s_data()->unihanInfo(c);
873 if (unihan.
count() == 7) {
874 html += QLatin1String(
"<p><b>") + tr(
"CJK Ideograph Information") + QLatin1String(
"</b></p><p>");
876 if (!unihan[0].isEmpty()) {
877 html += tr(
"Definition in English: ") + unihan[0];
880 if (!unihan[2].isEmpty()) {
882 html += QLatin1String(
"<br>");
884 html += tr(
"Mandarin Pronunciation: ") + unihan[2];
887 if (!unihan[1].isEmpty()) {
889 html += QLatin1String(
"<br>");
891 html += tr(
"Cantonese Pronunciation: ") + unihan[1];
894 if (!unihan[6].isEmpty()) {
896 html += QLatin1String(
"<br>");
898 html += tr(
"Japanese On Pronunciation: ") + unihan[6];
901 if (!unihan[5].isEmpty()) {
903 html += QLatin1String(
"<br>");
905 html += tr(
"Japanese Kun Pronunciation: ") + unihan[5];
908 if (!unihan[3].isEmpty()) {
910 html += QLatin1String(
"<br>");
912 html += tr(
"Tang Pronunciation: ") + unihan[3];
915 if (!unihan[4].isEmpty()) {
917 html += QLatin1String(
"<br>");
919 html += tr(
"Korean Pronunciation: ") + unihan[4];
922 html += QLatin1String(
"</p>");
925 html += QLatin1String(
"<p><b>") + tr(
"General Character Properties") + QLatin1String(
"</b><br>");
926 html += tr(
"Block: ") + s_data()->block(c) + QLatin1String(
"<br>");
927 html += tr(
"Unicode category: ") + s_data()->categoryText(s_data()->
category(c)) + QLatin1String(
"</p>");
931 html += QLatin1String(
"<p><b>") + tr(
"Various Useful Representations") + QLatin1String(
"</b><br>");
932 html += tr(
"UTF-8:");
933 for (
unsigned char c : utf8) {
934 html += QLatin1Char(
' ') + s_data()->formatCode(c, 2, QStringLiteral(
"0x"));
936 html += QLatin1String(
"<br>") + tr(
"UTF-16: ");
939 html += QLatin1Char(
' ') + s_data->formatCode(
QChar::lowSurrogate(c), 4, QStringLiteral(
"0x"));
941 html += s_data()->formatCode(c, 4, QStringLiteral(
"0x"));
943 html += QLatin1String(
"<br>") + tr(
"C octal escaped UTF-8: ");
944 for (
unsigned char c : utf8) {
945 html += s_data()->formatCode(c, 3, QStringLiteral(
"\\"), 8);
947 html += QLatin1String(
"<br>") + tr(
"XML decimal entity:") + QLatin1String(
" &#") +
QString::number(c) + QLatin1String(
";</p>");
949 detailBrowser->setHtml(html);
955 QRegularExpressionMatchIterator iter = rx.globalMatch(s);
956 QRegularExpressionMatch
match;
963 for (
const QString &c : std::as_const(chars)) {
964 int unicode = c.toInt(
nullptr, 16);
968 QString
link = QLatin1String(
"<a href=\"") + c + QLatin1String(
"\">");
969 if (s_data()->isPrint(unicode)) {
972 link += QLatin1String(
"U+") + c + QLatin1Char(
' ');
973 link += s_data()->name(unicode).toHtmlEscaped() + QLatin1String(
"</a>");
979void KCharSelectPrivate::sectionSelected(
int index)
983 const QList<int> blocks = s_data()->sectionContents(index);
984 for (
int block : blocks) {
985 if (!allPlanesEnabled) {
986 const QList<uint> contents = s_data()->blockContents(block);
991 blockCombo->addItem(s_data()->blockName(block), QVariant(block));
993 chars << s_data()->blockContents(block);
997 charTable->setContents(chars);
998 updateCurrentChar(charTable->chr());
1000 blockCombo->setCurrentIndex(0);
1004void KCharSelectPrivate::blockSelected(
int index)
1014 int block = blockCombo->itemData(index).toInt();
1015 if (sectionCombo->currentIndex() == 0 && block == s_data()->blockIndex(charTable->chr())) {
1019 const QList<uint> contents = s_data()->blockContents(block);
1020 if (sectionCombo->currentIndex() > 0) {
1021 charTable->setContents(contents);
1023 Q_EMIT q->displayedCharsChanged();
1024 charTable->setChar(contents[0]);
1027void KCharSelectPrivate::searchEditChanged()
1029 if (searchLine->text().isEmpty()) {
1030 sectionCombo->setEnabled(
true);
1031 blockCombo->setEnabled(
true);
1035 uint c = charTable->chr();
1036 bool oldHistoryEnabled = historyEnabled;
1037 historyEnabled =
false;
1038 blockSelected(blockCombo->currentIndex());
1039 historyEnabled = oldHistoryEnabled;
1040 q->setCurrentCodePoint(c);
1042 sectionCombo->setEnabled(
false);
1043 blockCombo->setEnabled(
false);
1045 int length = searchLine->text().length();
1052void KCharSelectPrivate::search()
1054 if (searchLine->text().isEmpty()) {
1058 QList<uint> contents = s_data()->find(searchLine->text());
1059 if (!allPlanesEnabled) {
1063 charTable->setContents(contents);
1064 Q_EMIT q->displayedCharsChanged();
1066 charTable->setChar(contents[0]);
1070void KCharSelectPrivate::linkClicked(
QUrl url)
1073 if (
hex.size() > 6) {
1076 int unicode =
hex.toInt(
nullptr, 16);
1080 searchLine->clear();
1081 q->setCurrentCodePoint(unicode);
1088 int pos = m_columns * (index.
row()) + index.
column();
1089 if (!index.
isValid() || pos < 0 || pos >= m_chars.size() || index.
row() < 0 || index.
column() < 0) {
1096 char32_t c = m_chars[pos];
1099 + tr(
"Unicode code point:") +
QLatin1Char(
' ') + s_data()->formatCode(c) +
QLatin1String(
"<br />") + tr(
"In decimal",
"Character")
1105 if (s_data()->isPrint(c)) {
1111 if (fm.
inFontUcs4(c) && s_data()->isPrint(c)) {
1118 }
else if (role == CharacterRole) {
1143 Q_EMIT showCharRequested(text.
toUcs4().
at(0));
1147void KCharSelectItemModel::setColumnCount(
int columns)
1149 if (columns == m_columns) {
1152 Q_EMIT layoutAboutToBeChanged();
1153 m_columns = columns;
1154 Q_EMIT layoutChanged();
1157#include "moc_kcharselect.cpp"
1158#include "moc_kcharselect_p.cpp"
void setCurrentCodePoint(uint codePoint)
Highlights the character with the specified codePoint.
void setCurrentChar(const QChar &c)
Highlights the character c.
@ CharacterTable
Shows the actual table.
@ HistoryButtons
Shows the Back/Forward buttons.
@ BlockCombos
Shows the category/block selection combo boxes.
@ FontCombo
Shows the font combo box.
@ SearchLine
Shows the search widgets.
@ FontSize
Shows the font size spin box.
@ DetailBrowser
Shows the detail browser.
void setCurrentFont(const QFont &font)
Sets the font which is displayed to font.
void setAllPlanesEnabled(bool all)
Sets the allowed Unicode code planes.
QFlags< Control > Controls
Stores a combination of Control values.
KCharSelect(QWidget *parent, const Controls controls=AllGuiElements)
Constructor.
QSize sizeHint() const override
Reimplemented.
KCOREADDONS_EXPORT Result match(QStringView pattern, QStringView str)
KIOCORE_EXPORT CopyJob * link(const QList< QUrl > &src, const QUrl &destDir, JobFlags flags=DefaultFlags)
bool isValid(QStringView ifopt)
QString name(StandardAction id)
Category category(StandardShortcut id)
virtual void keyPressEvent(QKeyEvent *event) override
virtual void resizeEvent(QResizeEvent *event) override
void setIcon(const QIcon &icon)
void setShortcuts(QKeySequence::StandardKey key)
void setText(const QString &text)
void triggered(bool checked)
void addLayout(QLayout *layout, int stretch)
char16_t highSurrogate(char32_t ucs4)
char16_t lowSurrogate(char32_t ucs4)
bool requiresSurrogates(char32_t ucs4)
void currentIndexChanged(int index)
int pointSize() const const
void setPointSize(int pointSize)
void currentFontChanged(const QFont &font)
bool inFontUcs4(uint ucs4) const const
void setFrameShadow(Shadow)
void setFrameShape(Shape)
QIcon fromTheme(const QString &name)
QModelIndexList indexes() const const
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
QList< QKeySequence > keyBindings(StandardKey key)
void setContentsMargins(const QMargins &margins)
void textChanged(const QString &text)
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
qsizetype count() const const
iterator erase(const_iterator begin, const_iterator end)
qsizetype indexOf(const AT &value, qsizetype from) const const
bool isEmpty() const const
void reserve(qsizetype size)
bool hasText() const const
QString text() const const
bool isValid() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool inherits(const char *className) const const
QObject * parent() const const
void setObjectName(QAnyStringView name)
void setParent(QObject *parent)
QString tr(const char *sourceText, const char *disambiguation, int n)
void setColor(ColorGroup group, ColorRole role, const QColor &color)
UseUnicodePropertiesOption
bool hasNext() const const
QRegularExpressionMatch next()
const QSize & oldSize() const const
const QSize & size() const const
iterator insert(const T &value)
qsizetype count() const const
QString & append(QChar ch)
QString fromUcs4(const char32_t *unicode, qsizetype size)
bool isEmpty() const const
QString number(double n, char format, int precision)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QString toHtmlEscaped() const const
QList< uint > toUcs4() const const
QByteArray toUtf8() const const
QTextStream & hex(QTextStream &stream)
void anchorClicked(const QUrl &link)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QString toString(FormattingOptions options) const const
uint toUInt(bool *ok) const const
int userType() const const