File indexing completed on 2024-04-28 03:59:01

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2007 Daniel Laidig <d.laidig@gmx.de>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KCHARSELECTDATA_H
0009 #define KCHARSELECTDATA_H
0010 
0011 #include <QChar>
0012 #include <QFont>
0013 #include <QFuture>
0014 #include <QList>
0015 #include <QString>
0016 #include <QStringList>
0017 
0018 // Internal class used by KCharSelect
0019 
0020 typedef QMap<QString, QList<quint16>> Index;
0021 
0022 class KCharSelectData
0023 {
0024 public:
0025     QString formatCode(uint code, int length = 4, const QString &prefix = QStringLiteral("U+"), int base = 16);
0026 
0027     QList<uint> blockContents(int block);
0028     QList<int> sectionContents(int section);
0029 
0030     QStringList sectionList();
0031 
0032     QString block(uint c);
0033     QString section(uint c);
0034     QString name(uint c);
0035 
0036     int blockIndex(uint c);
0037     int sectionIndex(int block);
0038 
0039     QString blockName(int index);
0040     QString sectionName(int index);
0041 
0042     QStringList aliases(uint c);
0043     QStringList notes(uint c);
0044     QList<uint> seeAlso(uint c);
0045     QStringList equivalents(uint c);
0046     QStringList approximateEquivalents(uint c);
0047     QList<uint> decomposition(uint c);
0048 
0049     QStringList unihanInfo(uint c);
0050 
0051     QChar::Category category(uint c);
0052     bool isPrint(uint c);
0053     bool isDisplayable(uint c);
0054     bool isIgnorable(uint c);
0055     bool isCombining(uint c);
0056     QString display(uint c, const QFont &font);
0057     QString displayCombining(uint c);
0058 
0059     QString categoryText(QChar::Category category);
0060 
0061     QList<uint> find(const QString &s);
0062 
0063 private:
0064     bool openDataFile();
0065     quint32 getDetailIndex(uint c) const;
0066     QSet<uint> getMatchingChars(const QString &s);
0067 
0068     QStringList splitString(const QString &s);
0069     void appendToIndex(Index *index, quint16 unicode, const QString &s);
0070     Index createIndex(const QByteArray &dataFile);
0071 
0072     quint16 mapCodePointToDataBase(uint code) const;
0073     uint mapDataBaseToCodePoint(quint16 code) const;
0074 
0075     QByteArray dataFile;
0076     QFuture<Index> futureIndex;
0077     int remapType;
0078     friend class RunIndexCreation;
0079 };
0080 
0081 #endif /* #ifndef KCHARSELECTDATA_H */