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)
67 KCharSelectPrivate(KCharSelect *qq)
74 QToolButton *backButton =
nullptr;
75 QToolButton *forwardButton =
nullptr;
76 QLineEdit *searchLine =
nullptr;
77 QFontComboBox *fontCombo =
nullptr;
78 QSpinBox *fontSizeSpinBox =
nullptr;
79 QComboBox *sectionCombo =
nullptr;
80 QComboBox *blockCombo =
nullptr;
81 KCharSelectTable *charTable =
nullptr;
82 QTextBrowser *detailBrowser =
nullptr;
84 bool searchMode =
false;
85 bool historyEnabled =
false;
86 bool allPlanesEnabled =
false;
88 QList<HistoryItem> history;
89 QObject *actionParent =
nullptr;
91 QString createLinks(QString s);
92 void historyAdd(uint c,
bool fromSearch,
const QString &searchString);
93 void showFromHistory(
int index);
94 void updateBackForwardButtons();
95 void activateSearchLine();
99 void charSelected(uint c);
100 void updateCurrentChar(uint c);
101 void slotUpdateUnicode(uint c);
102 void sectionSelected(
int index);
103 void blockSelected(
int index);
104 void searchEditChanged();
106 void linkClicked(QUrl url);
109Q_DECLARE_TYPEINFO(KCharSelectPrivate::HistoryItem, Q_RELOCATABLE_TYPE);
115KCharSelectTable::KCharSelectTable(
QWidget *parent,
const QFont &_font)
117 , d(new KCharSelectTablePrivate(this))
121 setTabKeyNavigation(
false);
127 setPalette(_palette);
128 verticalHeader()->setVisible(
false);
130 horizontalHeader()->setVisible(
false);
134 setDragEnabled(
true);
135 setAcceptDrops(
true);
136 setDropIndicatorShown(
false);
140 connect(
this, &KCharSelectTable::doubleClicked,
this, [
this](
const QModelIndex &index) {
141 d->doubleClicked(index);
147KCharSelectTable::~KCharSelectTable() =
default;
149void KCharSelectTable::setFont(
const QFont &_font)
154 d->model->setFont(_font);
159uint KCharSelectTable::chr()
164QFont KCharSelectTable::font()
const
169QList<uint> KCharSelectTable::displayedChars()
const
174void KCharSelectTable::setChar(uint c)
178 setCurrentIndex(model()->index(pos / model()->columnCount(), pos % model()->columnCount()));
182void KCharSelectTable::setContents(
const QList<uint> &chars)
186 auto oldModel = d->model;
187 d->model =
new KCharSelectItemModel(chars, d->font,
this);
193 d->slotSelectionChanged(selected, deselected);
196 connect(d->model, &KCharSelectItemModel::showCharRequested,
this, &KCharSelectTable::showCharRequested);
201void KCharSelectTable::scrollTo(
const QModelIndex &index, ScrollHint hint)
213 Q_UNUSED(deselected);
214 if (!model || selected.
indexes().isEmpty()) {
217 QVariant temp = model->data(selected.
indexes().at(0), KCharSelectItemModel::CharacterRole);
223 Q_EMIT q->focusItemChanged(c);
238 auto timer =
new QTimer(
this);
239 timer->setSingleShot(
true);
242 timer->deleteLater();
248void KCharSelectTablePrivate::resizeCells()
250 KCharSelectItemModel *model =
static_cast<KCharSelectItemModel *
>(q->model());
255 const int viewportWidth = q->viewport()->size().width();
257 QFontMetrics fontMetrics(font);
262 int maxCharWidth = 0;
263 const QList<uint> chars = model->chars();
264 for (
int i = 0; i < chars.size(); ++i) {
265 char32_t thisChar = chars.at(i);
266 if (s_data()->isPrint(thisChar)) {
267 maxCharWidth = qMax(maxCharWidth, fontMetrics.boundingRect(
QString::fromUcs4(&thisChar, 1)).width());
271 maxCharWidth = qMax(maxCharWidth, 2 * fontMetrics.xHeight());
272 maxCharWidth = qMax(maxCharWidth, fontMetrics.height());
275 maxCharWidth += 2 * textMargin;
277 const int columns = qMax(1, viewportWidth / maxCharWidth);
278 model->setColumnCount(columns);
280 const uint oldChar = q->chr();
282 const int new_w = viewportWidth / columns;
283 const int rows = model->rowCount();
284 q->setUpdatesEnabled(
false);
285 QHeaderView *hHeader = q->horizontalHeader();
287 const int spaceLeft = viewportWidth - new_w * columns;
288 for (
int i = 0; i <= columns; ++i) {
296 QHeaderView *vHeader = q->verticalHeader();
298 int new_h = fontMetrics.lineSpacing() + 1;
300 int new_h = fontMetrics.xHeight() * 3;
302 const int fontHeight = fontMetrics.height();
303 if (new_h < 5 || new_h < 4 + fontHeight) {
304 new_h = qMax(5, 4 + fontHeight);
307 for (
int i = 0; i < rows; ++i) {
311 q->setUpdatesEnabled(
true);
315void KCharSelectTablePrivate::doubleClicked(
const QModelIndex &index)
317 uint c = model->data(index, KCharSelectItemModel::CharacterRole).toUInt();
318 if (s_data()->isPrint(c)) {
319 Q_EMIT q->activated(c);
323void KCharSelectTable::keyPressEvent(
QKeyEvent *e)
332 if (!currentIndex().
isValid()) {
335 uint c = d->model->data(currentIndex(), KCharSelectItemModel::CharacterRole).toUInt();
336 if (s_data()->isPrint(c)) {
354 , d(new KCharSelectPrivate(this))
356 initWidget(controls,
nullptr);
361 , d(new KCharSelectPrivate(this))
363 initWidget(controls, actionParent);
368 if (!action || !actionParent) {
374 if (actionParent->
inherits(
"KActionCollection")) {
382void KCharSelect::initWidget(
const Controls controls,
QObject *actionParent)
384 d->actionParent = actionParent;
386 QVBoxLayout *mainLayout =
new QVBoxLayout(
this);
389 QHBoxLayout *searchLayout =
new QHBoxLayout();
391 d->searchLine =
new QLineEdit(
this);
393 d->searchLine->setPlaceholderText(
tr(
"Enter a search term or character…",
"@info:placeholder"));
394 d->searchLine->setClearButtonEnabled(
true);
395 d->searchLine->setToolTip(
tr(
"Enter a search term or character here",
"@info:tooltip"));
397 QAction *findAction =
new QAction(
this);
399 d->activateSearchLine();
402 findAction->
setText(
tr(
"&Find…",
"@action"));
407 d->searchEditChanged();
415 QFrame *line =
new QFrame(
this);
421 QHBoxLayout *comboLayout =
new QHBoxLayout();
423 d->backButton =
new QToolButton(
this);
425 d->backButton->setEnabled(
false);
426 d->backButton->setText(
tr(
"Previous in History",
"@action:button Goes to previous character"));
428 d->backButton->setToolTip(
tr(
"Go to previous character in history",
"@info:tooltip"));
430 d->forwardButton =
new QToolButton(
this);
431 comboLayout->
addWidget(d->forwardButton);
432 d->forwardButton->setEnabled(
false);
433 d->forwardButton->setText(
tr(
"Next in History",
"@action:button Goes to next character"));
435 d->forwardButton->setToolTip(
tr(
"Go to next character in history",
"info:tooltip"));
437 QAction *backAction =
new QAction(
this);
440 backAction->
setText(
tr(
"&Back",
"@action go back"));
444 QAction *forwardAction =
new QAction(
this);
447 forwardAction->
setText(
tr(
"&Forward",
"@action go forward"));
452 QIcon tmp = backAction->
icon();
464 d->sectionCombo =
new QComboBox(
this);
465 d->sectionCombo->setObjectName(QStringLiteral(
"sectionCombo"));
466 d->sectionCombo->setToolTip(
tr(
"Select a category",
"@info:tooltip"));
468 d->blockCombo =
new QComboBox(
this);
469 d->blockCombo->setObjectName(QStringLiteral(
"blockCombo"));
470 d->blockCombo->setToolTip(
tr(
"Select a block to be displayed",
"@info:tooltip"));
472 comboLayout->
addWidget(d->blockCombo, 1);
473 QStringList sectionList = s_data()->sectionList();
474 d->sectionCombo->addItems(sectionList);
475 d->blockCombo->setMinimumWidth(QFontMetrics(
QWidget::font()).averageCharWidth() * 25);
478 d->sectionSelected(index);
482 d->blockSelected(index);
485 d->fontCombo =
new QFontComboBox(
this);
487 d->fontCombo->setEditable(
true);
488 d->fontCombo->resize(d->fontCombo->sizeHint());
489 d->fontCombo->setToolTip(
tr(
"Set font",
"@info:tooltip"));
491 d->fontSizeSpinBox =
new QSpinBox(
this);
492 comboLayout->
addWidget(d->fontSizeSpinBox);
494 d->fontSizeSpinBox->setRange(1, 400);
495 d->fontSizeSpinBox->setSingleStep(1);
496 d->fontSizeSpinBox->setToolTip(
tr(
"Set font size",
"@info:tooltip"));
509 d->backButton->hide();
510 d->forwardButton->hide();
513 d->fontCombo->hide();
516 d->fontSizeSpinBox->hide();
519 d->sectionCombo->hide();
520 d->blockCombo->hide();
523 QSplitter *splitter =
new QSplitter(
this);
529 d->charTable =
new KCharSelectTable(
this, QFont());
533 d->charTable->hide();
536 const QSize sz(200, 200);
537 d->charTable->resize(sz);
538 d->charTable->setMinimumSize(sz);
544 connect(d->charTable, &KCharSelectTable::focusItemChanged,
this, [
this](uint c) {
545 d->updateCurrentChar(c);
547 connect(d->charTable, &KCharSelectTable::activated,
this, [
this](uint c) {
552 d->detailBrowser =
new QTextBrowser(
this);
556 d->detailBrowser->hide();
558 d->detailBrowser->setOpenLinks(
false);
570 d->sectionSelected(1);
573 d->historyEnabled =
true;
576KCharSelect::~KCharSelect() =
default;
585 d->fontCombo->setCurrentFont(_font);
586 d->fontSizeSpinBox->setValue(_font.
pointSize());
592 d->allPlanesEnabled = all;
595bool KCharSelect::allPlanesEnabled()
const
597 return d->allPlanesEnabled;
600QChar KCharSelect::currentChar()
const
602 if (d->allPlanesEnabled) {
603 qFatal(
"You must use KCharSelect::currentCodePoint instead of KCharSelect::currentChar");
605 return QChar(d->charTable->chr());
608uint KCharSelect::currentCodePoint()
const
610 return d->charTable->chr();
613QFont KCharSelect::currentFont()
const
615 return d->charTable->font();
620 if (d->allPlanesEnabled) {
621 qFatal(
"You must use KCharSelect::displayedCodePoints instead of KCharSelect::displayedChars");
624 const auto displayedChars = d->charTable->displayedChars();
625 result.
reserve(displayedChars.size());
626 for (uint c : displayedChars) {
634 return d->charTable->displayedChars();
639 if (d->allPlanesEnabled) {
640 qCritical(
"You should use KCharSelect::setCurrentCodePoint instead of KCharSelect::setCurrentChar");
648 qCritical(
"You must setAllPlanesEnabled(true) to use non-BMP characters");
652 qCWarning(KWidgetsAddonsLog,
"Code point outside Unicode range");
655 bool oldHistoryEnabled = d->historyEnabled;
656 d->historyEnabled =
false;
657 int block = s_data()->blockIndex(c);
658 int section = s_data()->sectionIndex(block);
659 d->sectionCombo->setCurrentIndex(section);
660 int index = d->blockCombo->findData(block);
662 d->blockCombo->setCurrentIndex(index);
664 d->historyEnabled = oldHistoryEnabled;
665 d->charTable->setChar(c);
668void KCharSelectPrivate::historyAdd(uint c,
bool fromSearch,
const QString &searchString)
672 if (!historyEnabled) {
676 if (!history.isEmpty() && c == history.last().c) {
682 while (!history.isEmpty() && inHistory != history.count() - 1) {
683 history.removeLast();
686 while (history.size() >= MaxHistoryItems) {
687 history.removeFirst();
692 item.fromSearch = fromSearch;
693 item.searchString = searchString;
696 inHistory = history.
count() - 1;
697 updateBackForwardButtons();
700void KCharSelectPrivate::showFromHistory(
int index)
702 Q_ASSERT(index >= 0 && index < history.count());
703 Q_ASSERT(index != inHistory);
706 updateBackForwardButtons();
708 const HistoryItem &item = history[index];
713 bool oldHistoryEnabled = historyEnabled;
714 historyEnabled =
false;
715 if (item.fromSearch) {
716 if (searchLine->text() != item.searchString) {
717 searchLine->setText(item.searchString);
720 charTable->setChar(item.c);
723 q->setCurrentCodePoint(item.c);
725 historyEnabled = oldHistoryEnabled;
728void KCharSelectPrivate::updateBackForwardButtons()
730 backButton->setEnabled(inHistory > 0);
731 forwardButton->setEnabled(inHistory < history.count() - 1);
734void KCharSelectPrivate::activateSearchLine()
736 searchLine->setFocus();
737 searchLine->selectAll();
740void KCharSelectPrivate::back()
742 Q_ASSERT(inHistory > 0);
743 showFromHistory(inHistory - 1);
746void KCharSelectPrivate::forward()
748 Q_ASSERT(inHistory + 1 < history.count());
749 showFromHistory(inHistory + 1);
752void KCharSelectPrivate::fontSelected()
754 QFont font = fontCombo->currentFont();
756 charTable->setFont(font);
757 Q_EMIT q->currentFontChanged(font);
760void KCharSelectPrivate::charSelected(uint c)
762 if (!allPlanesEnabled) {
763 Q_EMIT q->charSelected(QChar(c));
765 Q_EMIT q->codePointSelected(c);
768void KCharSelectPrivate::updateCurrentChar(uint c)
770 if (!allPlanesEnabled) {
771 Q_EMIT q->currentCharChanged(QChar(c));
773 Q_EMIT q->currentCodePointChanged(c);
774 if (searchMode || sectionCombo->currentIndex() == 0) {
778 int block = s_data()->blockIndex(c);
780 int section = s_data()->sectionIndex(block);
781 sectionCombo->setCurrentIndex(section);
783 int index = blockCombo->findData(block);
785 blockCombo->setCurrentIndex(index);
790 historyAdd(c, searchMode, searchLine->text());
793 slotUpdateUnicode(c);
796void KCharSelectPrivate::slotUpdateUnicode(uint c)
798 QString html = QLatin1String(
"<p>") + tr(
"Character:") + QLatin1Char(
' ') + s_data()->display(c, charTable->font()) + QLatin1Char(
' ')
799 + s_data()->formatCode(c) + QLatin1String(
"<br />");
801 QString
name = s_data()->name(c);
806 const QStringList aliases = s_data()->aliases(c);
807 const QStringList notes = s_data()->notes(c);
808 const QList<uint> seeAlso = s_data()->seeAlso(c);
809 const QStringList equivalents = s_data()->equivalents(c);
810 const QStringList approxEquivalents = s_data()->approximateEquivalents(c);
811 const QList<uint> decomposition = s_data()->decomposition(c);
813 html += QLatin1String(
"<p><b>") + tr(
"Annotations and Cross References") + QLatin1String(
"</b></p>");
817 html += QLatin1String(
"<p style=\"margin-bottom: 0px;\">") + tr(
"Alias names:") + QLatin1String(
"</p><ul style=\"margin-top: 0px;\">");
818 for (
const QString &alias : aliases) {
819 html += QLatin1String(
"<li>") + alias.
toHtmlEscaped() + QLatin1String(
"</li>");
821 html += QLatin1String(
"</ul>");
825 html += QLatin1String(
"<p style=\"margin-bottom: 0px;\">") + tr(
"Notes:") + QLatin1String(
"</p><ul style=\"margin-top: 0px;\">");
826 for (
const QString ¬e : notes) {
827 html += QLatin1String(
"<li>") + createLinks(note.toHtmlEscaped()) + QLatin1String(
"</li>");
829 html += QLatin1String(
"</ul>");
833 html += QLatin1String(
"<p style=\"margin-bottom: 0px;\">") + tr(
"See also:") + QLatin1String(
"</p><ul style=\"margin-top: 0px;\">");
834 for (uint c2 : seeAlso) {
838 html += QLatin1String(
"<li><a href=\"") +
QString::number(c2, 16) + QLatin1String(
"\">");
839 if (s_data()->isPrint(c2)) {
840 html += QLatin1String(
"‎&#") +
QString::number(c2) + QLatin1String(
"; ");
842 html += s_data()->formatCode(c2) + QLatin1Char(
' ') + s_data()->name(c2).
toHtmlEscaped() + QLatin1String(
"</a></li>");
844 html += QLatin1String(
"</ul>");
848 html += QLatin1String(
"<p style=\"margin-bottom: 0px;\">") + tr(
"Equivalents:") + QLatin1String(
"</p><ul style=\"margin-top: 0px;\">");
849 for (
const QString &equivalent : equivalents) {
850 html += QLatin1String(
"<li>") + createLinks(equivalent.toHtmlEscaped()) + QLatin1String(
"</li>");
852 html += QLatin1String(
"</ul>");
855 if (!approxEquivalents.
isEmpty()) {
856 html += QLatin1String(
"<p style=\"margin-bottom: 0px;\">") + tr(
"Approximate equivalents:") + QLatin1String(
"</p><ul style=\"margin-top: 0px;\">");
857 for (
const QString &approxEquivalent : approxEquivalents) {
858 html += QLatin1String(
"<li>") + createLinks(approxEquivalent.toHtmlEscaped()) + QLatin1String(
"</li>");
860 html += QLatin1String(
"</ul>");
863 if (!decomposition.
isEmpty()) {
864 html += QLatin1String(
"<p style=\"margin-bottom: 0px;\">") + tr(
"Decomposition:") + QLatin1String(
"</p><ul style=\"margin-top: 0px;\">");
865 for (uint c2 : decomposition) {
869 html += QLatin1String(
"<li>") + createLinks(s_data()->formatCode(c2, 4, QString())) + QLatin1String(
"</li>");
871 html += QLatin1String(
"</ul>");
874 QStringList unihan = s_data()->unihanInfo(c);
875 if (unihan.
count() == 7) {
876 html += QLatin1String(
"<p><b>") + tr(
"CJK Ideograph Information") + QLatin1String(
"</b></p><p>");
878 if (!unihan[0].isEmpty()) {
879 html += tr(
"Definition in English: ") + unihan[0];
882 if (!unihan[2].isEmpty()) {
884 html += QLatin1String(
"<br>");
886 html += tr(
"Mandarin Pronunciation: ") + unihan[2];
889 if (!unihan[1].isEmpty()) {
891 html += QLatin1String(
"<br>");
893 html += tr(
"Cantonese Pronunciation: ") + unihan[1];
896 if (!unihan[6].isEmpty()) {
898 html += QLatin1String(
"<br>");
900 html += tr(
"Japanese On Pronunciation: ") + unihan[6];
903 if (!unihan[5].isEmpty()) {
905 html += QLatin1String(
"<br>");
907 html += tr(
"Japanese Kun Pronunciation: ") + unihan[5];
910 if (!unihan[3].isEmpty()) {
912 html += QLatin1String(
"<br>");
914 html += tr(
"Tang Pronunciation: ") + unihan[3];
917 if (!unihan[4].isEmpty()) {
919 html += QLatin1String(
"<br>");
921 html += tr(
"Korean Pronunciation: ") + unihan[4];
924 html += QLatin1String(
"</p>");
927 html += QLatin1String(
"<p><b>") + tr(
"General Character Properties") + QLatin1String(
"</b><br>");
928 html += tr(
"Block: ") + s_data()->block(c) + QLatin1String(
"<br>");
929 html += tr(
"Unicode category: ") + s_data()->categoryText(s_data()->
category(c)) + QLatin1String(
"</p>");
933 html += QLatin1String(
"<p><b>") + tr(
"Various Useful Representations") + QLatin1String(
"</b><br>");
934 html += tr(
"UTF-8:");
935 for (
unsigned char c : utf8) {
936 html += QLatin1Char(
' ') + s_data()->formatCode(c, 2, QStringLiteral(
"0x"));
938 html += QLatin1String(
"<br>") + tr(
"UTF-16: ");
941 html += QLatin1Char(
' ') + s_data->formatCode(
QChar::lowSurrogate(c), 4, QStringLiteral(
"0x"));
943 html += s_data()->formatCode(c, 4, QStringLiteral(
"0x"));
945 html += QLatin1String(
"<br>") + tr(
"C octal escaped UTF-8: ");
946 for (
unsigned char c : utf8) {
947 html += s_data()->formatCode(c, 3, QStringLiteral(
"\\"), 8);
949 html += QLatin1String(
"<br>") + tr(
"XML decimal entity:") + QLatin1String(
" &#") +
QString::number(c) + QLatin1String(
";</p>");
951 detailBrowser->setHtml(html);
957 QRegularExpressionMatchIterator iter = rx.globalMatch(s);
958 QRegularExpressionMatch
match;
965 for (
const QString &c : std::as_const(chars)) {
966 int unicode = c.toInt(
nullptr, 16);
970 QString
link = QLatin1String(
"<a href=\"") + c + QLatin1String(
"\">");
971 if (s_data()->isPrint(unicode)) {
974 link += QLatin1String(
"U+") + c + QLatin1Char(
' ');
975 link += s_data()->name(unicode).toHtmlEscaped() + QLatin1String(
"</a>");
981void KCharSelectPrivate::sectionSelected(
int index)
985 const QList<int> blocks = s_data()->sectionContents(index);
986 for (
int block : blocks) {
987 if (!allPlanesEnabled) {
988 const QList<uint> contents = s_data()->blockContents(block);
993 blockCombo->addItem(s_data()->blockName(block), QVariant(block));
995 chars << s_data()->blockContents(block);
999 charTable->setContents(chars);
1000 updateCurrentChar(charTable->chr());
1002 blockCombo->setCurrentIndex(0);
1006void KCharSelectPrivate::blockSelected(
int index)
1016 int block = blockCombo->itemData(index).toInt();
1017 if (sectionCombo->currentIndex() == 0 && block == s_data()->blockIndex(charTable->chr())) {
1021 const QList<uint> contents = s_data()->blockContents(block);
1022 if (sectionCombo->currentIndex() > 0) {
1023 charTable->setContents(contents);
1025 Q_EMIT q->displayedCharsChanged();
1026 charTable->setChar(contents[0]);
1029void KCharSelectPrivate::searchEditChanged()
1031 if (searchLine->text().isEmpty()) {
1032 sectionCombo->setEnabled(
true);
1033 blockCombo->setEnabled(
true);
1037 uint c = charTable->chr();
1038 bool oldHistoryEnabled = historyEnabled;
1039 historyEnabled =
false;
1040 blockSelected(blockCombo->currentIndex());
1041 historyEnabled = oldHistoryEnabled;
1042 q->setCurrentCodePoint(c);
1044 sectionCombo->setEnabled(
false);
1045 blockCombo->setEnabled(
false);
1047 int length = searchLine->text().length();
1054void KCharSelectPrivate::search()
1056 if (searchLine->text().isEmpty()) {
1060 QList<uint> contents = s_data()->find(searchLine->text());
1061 if (!allPlanesEnabled) {
1065 charTable->setContents(contents);
1066 Q_EMIT q->displayedCharsChanged();
1068 charTable->setChar(contents[0]);
1072void KCharSelectPrivate::linkClicked(
QUrl url)
1075 if (
hex.size() > 6) {
1078 int unicode =
hex.toInt(
nullptr, 16);
1082 searchLine->clear();
1083 q->setCurrentCodePoint(unicode);
1090 int pos = m_columns * (index.
row()) + index.
column();
1091 if (!index.
isValid() || pos < 0 || pos >= m_chars.size() || index.
row() < 0 || index.
column() < 0) {
1098 char32_t c = m_chars[pos];
1101 + tr(
"Unicode code point:") +
QLatin1Char(
' ') + s_data()->formatCode(c) +
QLatin1String(
"<br />") + tr(
"In decimal",
"Character")
1107 if (s_data()->isPrint(c)) {
1113 if (fm.
inFontUcs4(c) && s_data()->isPrint(c)) {
1120 }
else if (role == CharacterRole) {
1145 Q_EMIT showCharRequested(text.
toUcs4().
at(0));
1149void KCharSelectItemModel::setColumnCount(
int columns)
1151 if (columns == m_columns) {
1154 Q_EMIT layoutAboutToBeChanged();
1155 m_columns = columns;
1156 Q_EMIT layoutChanged();
1159#include "moc_kcharselect.cpp"
1160#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