src/eric7/UI/SymbolsWidget.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
10 import sys 10 import sys
11 import unicodedata 11 import unicodedata
12 import html.entities 12 import html.entities
13 13
14 from PyQt6.QtCore import ( 14 from PyQt6.QtCore import (
15 pyqtSlot, pyqtSignal, QAbstractTableModel, QModelIndex, Qt, 15 pyqtSlot,
16 QItemSelectionModel, QLocale 16 pyqtSignal,
17 QAbstractTableModel,
18 QModelIndex,
19 Qt,
20 QItemSelectionModel,
21 QLocale,
17 ) 22 )
18 from PyQt6.QtGui import QColor 23 from PyQt6.QtGui import QColor
19 from PyQt6.QtWidgets import QWidget, QHeaderView, QAbstractItemView 24 from PyQt6.QtWidgets import QWidget, QHeaderView, QAbstractItemView
20 25
21 from EricWidgets.EricApplication import ericApp 26 from EricWidgets.EricApplication import ericApp
28 33
29 class SymbolsModel(QAbstractTableModel): 34 class SymbolsModel(QAbstractTableModel):
30 """ 35 """
31 Class implementing the model for the symbols widget. 36 Class implementing the model for the symbols widget.
32 """ 37 """
38
33 def __init__(self, parent=None): 39 def __init__(self, parent=None):
34 """ 40 """
35 Constructor 41 Constructor
36 42
37 @param parent reference to the parent object (QObject) 43 @param parent reference to the parent object (QObject)
38 """ 44 """
39 super().__init__(parent) 45 super().__init__(parent)
40 46
41 self.__locale = QLocale() 47 self.__locale = QLocale()
42 48
43 self.__headerData = [ 49 self.__headerData = [
44 self.tr("Code"), 50 self.tr("Code"),
45 self.tr("Char"), 51 self.tr("Char"),
46 self.tr("Hex"), 52 self.tr("Hex"),
47 self.tr("HTML"), 53 self.tr("HTML"),
48 self.tr("Name"), 54 self.tr("Name"),
49 ] 55 ]
50 56
51 self.__isDark = ericApp().usesDarkPalette() 57 self.__isDark = ericApp().usesDarkPalette()
52 58
53 self.__tables = [ 59 self.__tables = [
54 # first last display name 60 # first last display name
55 (0x0, 0x1f, self.tr("Control Characters")), 61 (0x0, 0x1F, self.tr("Control Characters")),
56 (0x20, 0x7f, self.tr("Basic Latin")), 62 (0x20, 0x7F, self.tr("Basic Latin")),
57 (0x80, 0xff, self.tr("Latin-1 Supplement")), 63 (0x80, 0xFF, self.tr("Latin-1 Supplement")),
58 (0x100, 0x17f, self.tr("Latin Extended-A")), 64 (0x100, 0x17F, self.tr("Latin Extended-A")),
59 (0x180, 0x24f, self.tr("Latin Extended-B")), 65 (0x180, 0x24F, self.tr("Latin Extended-B")),
60 (0x250, 0x2af, self.tr("IPA Extensions")), 66 (0x250, 0x2AF, self.tr("IPA Extensions")),
61 (0x2b0, 0x2ff, self.tr("Spacing Modifier Letters")), 67 (0x2B0, 0x2FF, self.tr("Spacing Modifier Letters")),
62 (0x300, 0x36f, self.tr("Combining Diacritical Marks")), 68 (0x300, 0x36F, self.tr("Combining Diacritical Marks")),
63 (0x370, 0x3ff, self.tr("Greek and Coptic")), 69 (0x370, 0x3FF, self.tr("Greek and Coptic")),
64 (0x400, 0x4ff, self.tr("Cyrillic")), 70 (0x400, 0x4FF, self.tr("Cyrillic")),
65 (0x500, 0x52f, self.tr("Cyrillic Supplement")), 71 (0x500, 0x52F, self.tr("Cyrillic Supplement")),
66 (0x530, 0x58f, self.tr("Armenian")), 72 (0x530, 0x58F, self.tr("Armenian")),
67 (0x590, 0x5ff, self.tr("Hebrew")), 73 (0x590, 0x5FF, self.tr("Hebrew")),
68 (0x600, 0x6ff, self.tr("Arabic")), 74 (0x600, 0x6FF, self.tr("Arabic")),
69 (0x700, 0x74f, self.tr("Syriac")), 75 (0x700, 0x74F, self.tr("Syriac")),
70 (0x780, 0x7bf, self.tr("Thaana")), 76 (0x780, 0x7BF, self.tr("Thaana")),
71 (0x7c0, 0x7ff, self.tr("N'Ko")), 77 (0x7C0, 0x7FF, self.tr("N'Ko")),
72 (0x800, 0x83f, self.tr("Samaritan")), 78 (0x800, 0x83F, self.tr("Samaritan")),
73 (0x840, 0x85f, self.tr("Mandaic")), 79 (0x840, 0x85F, self.tr("Mandaic")),
74 (0x8a0, 0x8ff, self.tr("Arabic Extended-A")), 80 (0x8A0, 0x8FF, self.tr("Arabic Extended-A")),
75 (0x900, 0x97f, self.tr("Devanagari")), 81 (0x900, 0x97F, self.tr("Devanagari")),
76 (0x980, 0x9ff, self.tr("Bengali")), 82 (0x980, 0x9FF, self.tr("Bengali")),
77 (0xa00, 0xa7f, self.tr("Gurmukhi")), 83 (0xA00, 0xA7F, self.tr("Gurmukhi")),
78 (0xa80, 0xaff, self.tr("Gujarati")), 84 (0xA80, 0xAFF, self.tr("Gujarati")),
79 (0xb00, 0xb7f, self.tr("Oriya")), 85 (0xB00, 0xB7F, self.tr("Oriya")),
80 (0xb80, 0xbff, self.tr("Tamil")), 86 (0xB80, 0xBFF, self.tr("Tamil")),
81 (0xc00, 0xc7f, self.tr("Telugu")), 87 (0xC00, 0xC7F, self.tr("Telugu")),
82 (0xc80, 0xcff, self.tr("Kannada")), 88 (0xC80, 0xCFF, self.tr("Kannada")),
83 (0xd00, 0xd7f, self.tr("Malayalam")), 89 (0xD00, 0xD7F, self.tr("Malayalam")),
84 (0xd80, 0xdff, self.tr("Sinhala")), 90 (0xD80, 0xDFF, self.tr("Sinhala")),
85 (0xe00, 0xe7f, self.tr("Thai")), 91 (0xE00, 0xE7F, self.tr("Thai")),
86 (0xe80, 0xeff, self.tr("Lao")), 92 (0xE80, 0xEFF, self.tr("Lao")),
87 (0xf00, 0xfff, self.tr("Tibetan")), 93 (0xF00, 0xFFF, self.tr("Tibetan")),
88 (0x1000, 0x109f, self.tr("Myanmar")), 94 (0x1000, 0x109F, self.tr("Myanmar")),
89 (0x10a0, 0x10ff, self.tr("Georgian")), 95 (0x10A0, 0x10FF, self.tr("Georgian")),
90 (0x1100, 0x11ff, self.tr("Hangul Jamo")), 96 (0x1100, 0x11FF, self.tr("Hangul Jamo")),
91 (0x1200, 0x137f, self.tr("Ethiopic")), 97 (0x1200, 0x137F, self.tr("Ethiopic")),
92 (0x1380, 0x139f, self.tr("Ethiopic Supplement")), 98 (0x1380, 0x139F, self.tr("Ethiopic Supplement")),
93 (0x13a0, 0x13ff, self.tr("Cherokee")), 99 (0x13A0, 0x13FF, self.tr("Cherokee")),
94 (0x1400, 0x167f, 100 (0x1400, 0x167F, self.tr("Unified Canadian Aboriginal Syllabics")),
95 self.tr("Unified Canadian Aboriginal Syllabics")), 101 (0x1680, 0x169F, self.tr("Ogham")),
96 (0x1680, 0x169f, self.tr("Ogham")), 102 (0x16A0, 0x16FF, self.tr("Runic")),
97 (0x16a0, 0x16ff, self.tr("Runic")), 103 (0x1700, 0x171F, self.tr("Tagalog")),
98 (0x1700, 0x171f, self.tr("Tagalog")), 104 (0x1720, 0x173F, self.tr("Hanunoo")),
99 (0x1720, 0x173f, self.tr("Hanunoo")), 105 (0x1740, 0x175F, self.tr("Buhid")),
100 (0x1740, 0x175f, self.tr("Buhid")), 106 (0x1760, 0x177F, self.tr("Tagbanwa")),
101 (0x1760, 0x177f, self.tr("Tagbanwa")), 107 (0x1780, 0x17FF, self.tr("Khmer")),
102 (0x1780, 0x17ff, self.tr("Khmer")), 108 (0x1800, 0x18AF, self.tr("Mongolian")),
103 (0x1800, 0x18af, self.tr("Mongolian")), 109 (0x18B0, 0x18FF, self.tr("Unified Canadian Aboriginal Syllabics Extended")),
104 (0x18b0, 0x18ff, 110 (0x1900, 0x194F, self.tr("Limbu")),
105 self.tr("Unified Canadian Aboriginal Syllabics Extended")), 111 (0x1950, 0x197F, self.tr("Tai Le")),
106 (0x1900, 0x194f, self.tr("Limbu")), 112 (0x19E0, 0x19FF, self.tr("Khmer Symbols")),
107 (0x1950, 0x197f, self.tr("Tai Le")), 113 (0x1A00, 0x1A1F, self.tr("Buginese")),
108 (0x19e0, 0x19ff, self.tr("Khmer Symbols")), 114 (0x1A20, 0x1AAF, self.tr("Tai Tham")),
109 (0x1a00, 0x1a1f, self.tr("Buginese")), 115 (0x1B00, 0x1B7F, self.tr("Balinese")),
110 (0x1a20, 0x1aaf, self.tr("Tai Tham")), 116 (0x1B80, 0x1BBF, self.tr("Sundanese")),
111 (0x1b00, 0x1b7f, self.tr("Balinese")), 117 (0x1BC0, 0x1BFF, self.tr("Batak")),
112 (0x1b80, 0x1bbf, self.tr("Sundanese")), 118 (0x1C00, 0x1C4F, self.tr("Lepcha")),
113 (0x1bc0, 0x1bff, self.tr("Batak")), 119 (0x1C50, 0x1C7F, self.tr("Ol Chiki")),
114 (0x1c00, 0x1c4f, self.tr("Lepcha")), 120 (0x1CC0, 0x1CCF, self.tr("Sundanese Supplement")),
115 (0x1c50, 0x1c7f, self.tr("Ol Chiki")), 121 (0x1CD0, 0x1CFF, self.tr("Vedic Extensions")),
116 (0x1cc0, 0x1ccf, self.tr("Sundanese Supplement")), 122 (0x1D00, 0x1D7F, self.tr("Phonetic Extensions")),
117 (0x1cd0, 0x1cff, self.tr("Vedic Extensions")), 123 (0x1D80, 0x1DBF, self.tr("Phonetic Extensions Supplement")),
118 (0x1d00, 0x1d7f, self.tr("Phonetic Extensions")), 124 (0x1DC0, 0x1DFF, self.tr("Combining Diacritical Marks Supplement")),
119 (0x1d80, 0x1dbf, self.tr("Phonetic Extensions Supplement")), 125 (0x1E00, 0x1EFF, self.tr("Latin Extended Additional")),
120 (0x1dc0, 0x1dff, 126 (0x1F00, 0x1FFF, self.tr("Greek Extended")),
121 self.tr("Combining Diacritical Marks Supplement")), 127 (0x2000, 0x206F, self.tr("General Punctuation")),
122 (0x1e00, 0x1eff, self.tr("Latin Extended Additional")), 128 (0x2070, 0x209F, self.tr("Superscripts and Subscripts")),
123 (0x1f00, 0x1fff, self.tr("Greek Extended")), 129 (0x20A0, 0x20CF, self.tr("Currency Symbols")),
124 (0x2000, 0x206f, self.tr("General Punctuation")), 130 (0x20D0, 0x20FF, self.tr("Combining Diacritical Marks")),
125 (0x2070, 0x209f, self.tr("Superscripts and Subscripts")), 131 (0x2100, 0x214F, self.tr("Letterlike Symbols")),
126 (0x20a0, 0x20cf, self.tr("Currency Symbols")), 132 (0x2150, 0x218F, self.tr("Number Forms")),
127 (0x20d0, 0x20ff, self.tr("Combining Diacritical Marks")), 133 (0x2190, 0x21FF, self.tr("Arcolumns")),
128 (0x2100, 0x214f, self.tr("Letterlike Symbols")), 134 (0x2200, 0x22FF, self.tr("Mathematical Operators")),
129 (0x2150, 0x218f, self.tr("Number Forms")), 135 (0x2300, 0x23FF, self.tr("Miscellaneous Technical")),
130 (0x2190, 0x21ff, self.tr("Arcolumns")), 136 (0x2400, 0x243F, self.tr("Control Pictures")),
131 (0x2200, 0x22ff, self.tr("Mathematical Operators")), 137 (0x2440, 0x245F, self.tr("Optical Character Recognition")),
132 (0x2300, 0x23ff, self.tr("Miscellaneous Technical")), 138 (0x2460, 0x24FF, self.tr("Enclosed Alphanumerics")),
133 (0x2400, 0x243f, self.tr("Control Pictures")), 139 (0x2500, 0x257F, self.tr("Box Drawing")),
134 (0x2440, 0x245f, self.tr("Optical Character Recognition")), 140 (0x2580, 0x259F, self.tr("Block Elements")),
135 (0x2460, 0x24ff, self.tr("Enclosed Alphanumerics")), 141 (0x25A0, 0x25FF, self.tr("Geometric Shapes")),
136 (0x2500, 0x257f, self.tr("Box Drawing")), 142 (0x2600, 0x26FF, self.tr("Miscellaneous Symbols")),
137 (0x2580, 0x259f, self.tr("Block Elements")), 143 (0x2700, 0x27BF, self.tr("Dingbats")),
138 (0x25A0, 0x25ff, self.tr("Geometric Shapes")), 144 (0x27C0, 0x27EF, self.tr("Miscellaneous Mathematical Symbols-A")),
139 (0x2600, 0x26ff, self.tr("Miscellaneous Symbols")), 145 (0x27F0, 0x27FF, self.tr("Supplement Arcolumns-A")),
140 (0x2700, 0x27bf, self.tr("Dingbats")), 146 (0x2800, 0x28FF, self.tr("Braille Patterns")),
141 (0x27c0, 0x27ef, 147 (0x2900, 0x297F, self.tr("Supplement Arcolumns-B")),
142 self.tr("Miscellaneous Mathematical Symbols-A")), 148 (0x2980, 0x29FF, self.tr("Miscellaneous Mathematical Symbols-B")),
143 (0x27f0, 0x27ff, self.tr("Supplement Arcolumns-A")), 149 (0x2A00, 0x2AFF, self.tr("Supplemental Mathematical Operators")),
144 (0x2800, 0x28ff, self.tr("Braille Patterns")), 150 (0x2B00, 0x2BFF, self.tr("Miscellaneous Symbols and Arcolumns")),
145 (0x2900, 0x297f, self.tr("Supplement Arcolumns-B")), 151 (0x2C00, 0x2C5F, self.tr("Glagolitic")),
146 (0x2980, 0x29ff, 152 (0x2C60, 0x2C7F, self.tr("Latin Extended-C")),
147 self.tr("Miscellaneous Mathematical Symbols-B")), 153 (0x2C80, 0x2CFF, self.tr("Coptic")),
148 (0x2a00, 0x2aff, 154 (0x2D00, 0x2D2F, self.tr("Georgian Supplement")),
149 self.tr("Supplemental Mathematical Operators")), 155 (0x2D30, 0x2D7F, self.tr("Tifinagh")),
150 (0x2b00, 0x2bff, 156 (0x2D80, 0x2DDF, self.tr("Ethiopic Extended")),
151 self.tr("Miscellaneous Symbols and Arcolumns")), 157 (0x2DE0, 0x2DFF, self.tr("Cyrillic Extended-A")),
152 (0x2c00, 0x2c5f, self.tr("Glagolitic")), 158 (0x2E00, 0x2E7F, self.tr("Supplemental Punctuation")),
153 (0x2c60, 0x2c7f, self.tr("Latin Extended-C")), 159 (0x2E80, 0x2EFF, self.tr("CJK Radicals Supplement")),
154 (0x2c80, 0x2cff, self.tr("Coptic")), 160 (0x2F00, 0x2FDF, self.tr("KangXi Radicals")),
155 (0x2d00, 0x2d2f, self.tr("Georgian Supplement")), 161 (0x2FF0, 0x2FFF, self.tr("Ideographic Description Chars")),
156 (0x2d30, 0x2d7f, self.tr("Tifinagh")), 162 (0x3000, 0x303F, self.tr("CJK Symbols and Punctuation")),
157 (0x2d80, 0x2ddf, self.tr("Ethiopic Extended")), 163 (0x3040, 0x309F, self.tr("Hiragana")),
158 (0x2de0, 0x2dff, self.tr("Cyrillic Extended-A")), 164 (0x30A0, 0x30FF, self.tr("Katakana")),
159 (0x2e00, 0x2e7f, self.tr("Supplemental Punctuation")), 165 (0x3100, 0x312F, self.tr("Bopomofo")),
160 (0x2e80, 0x2eff, self.tr("CJK Radicals Supplement")), 166 (0x3130, 0x318F, self.tr("Hangul Compatibility Jamo")),
161 (0x2f00, 0x2fdf, self.tr("KangXi Radicals")), 167 (0x3190, 0x319F, self.tr("Kanbun")),
162 (0x2ff0, 0x2fff, self.tr("Ideographic Description Chars")), 168 (0x31A0, 0x31BF, self.tr("Bopomofo Extended")),
163 (0x3000, 0x303f, self.tr("CJK Symbols and Punctuation")), 169 (0x31C0, 0x31EF, self.tr("CJK Strokes")),
164 (0x3040, 0x309f, self.tr("Hiragana")), 170 (0x31F0, 0x31FF, self.tr("Katakana Phonetic Extensions")),
165 (0x30a0, 0x30ff, self.tr("Katakana")), 171 (0x3200, 0x32FF, self.tr("Enclosed CJK Letters and Months")),
166 (0x3100, 0x312f, self.tr("Bopomofo")), 172 (0x3300, 0x33FF, self.tr("CJK Compatibility")),
167 (0x3130, 0x318f, self.tr("Hangul Compatibility Jamo")), 173 (0x3400, 0x4DBF, self.tr("CJK Unified Ideogr. Ext. A")),
168 (0x3190, 0x319f, self.tr("Kanbun")), 174 (0x4DC0, 0x4DFF, self.tr("Yijing Hexagram Symbols")),
169 (0x31a0, 0x31bf, self.tr("Bopomofo Extended")), 175 (0x4E00, 0x9FFF, self.tr("CJK Unified Ideographs")),
170 (0x31c0, 0x31ef, self.tr("CJK Strokes")), 176 (0xA000, 0xA48F, self.tr("Yi Syllables")),
171 (0x31f0, 0x31ff, self.tr("Katakana Phonetic Extensions")), 177 (0xA490, 0xA4CF, self.tr("Yi Radicals")),
172 (0x3200, 0x32ff, self.tr("Enclosed CJK Letters and Months")), 178 (0xA4D0, 0xA4FF, self.tr("Lisu")),
173 (0x3300, 0x33ff, self.tr("CJK Compatibility")), 179 (0xA500, 0xA63F, self.tr("Vai")),
174 (0x3400, 0x4dbf, self.tr("CJK Unified Ideogr. Ext. A")), 180 (0xA640, 0xA69F, self.tr("Cyrillic Extended-B")),
175 (0x4dc0, 0x4dff, self.tr("Yijing Hexagram Symbols")), 181 (0xA6A0, 0xA6FF, self.tr("Bamum")),
176 (0x4e00, 0x9fff, self.tr("CJK Unified Ideographs")), 182 (0xA700, 0xA71F, self.tr("Modifier Tone Letters")),
177 (0xa000, 0xa48f, self.tr("Yi Syllables")), 183 (0xA720, 0xA7FF, self.tr("Latin Extended-D")),
178 (0xa490, 0xa4cf, self.tr("Yi Radicals")), 184 (0xA800, 0xA82F, self.tr("Syloti Nagri")),
179 (0xa4d0, 0xa4ff, self.tr("Lisu")), 185 (0xA830, 0xA83F, self.tr("Common Indic Number Forms")),
180 (0xa500, 0xa63f, self.tr("Vai")), 186 (0xA840, 0xA87F, self.tr("Phags-pa")),
181 (0xa640, 0xa69f, self.tr("Cyrillic Extended-B")), 187 (0xA880, 0xA8DF, self.tr("Saurashtra")),
182 (0xa6a0, 0xa6ff, self.tr("Bamum")), 188 (0xA8E0, 0xA8FF, self.tr("Devanagari Extended")),
183 (0xa700, 0xa71f, self.tr("Modifier Tone Letters")), 189 (0xA900, 0xA92F, self.tr("Kayah Li")),
184 (0xa720, 0xa7ff, self.tr("Latin Extended-D")), 190 (0xA930, 0xA95F, self.tr("Rejang")),
185 (0xa800, 0xa82f, self.tr("Syloti Nagri")), 191 (0xA960, 0xA97F, self.tr("Hangul Jamo Extended-A")),
186 (0xa830, 0xa83f, self.tr("Common Indic Number Forms")), 192 (0xA980, 0xA9DF, self.tr("Javanese")),
187 (0xa840, 0xa87f, self.tr("Phags-pa")), 193 (0xAA00, 0xAA5F, self.tr("Cham")),
188 (0xa880, 0xa8df, self.tr("Saurashtra")), 194 (0xAA60, 0xAA7F, self.tr("Myanmar Extended-A")),
189 (0xa8e0, 0xa8ff, self.tr("Devanagari Extended")), 195 (0xAA80, 0xAADF, self.tr("Tai Viet")),
190 (0xa900, 0xa92f, self.tr("Kayah Li")), 196 (0xAAE0, 0xAAFF, self.tr("Meetei Mayek Extensions")),
191 (0xa930, 0xa95f, self.tr("Rejang")), 197 (0xAB00, 0xAB2F, self.tr("Ethiopic Extended-A")),
192 (0xa960, 0xa97f, self.tr("Hangul Jamo Extended-A")), 198 (0xABC0, 0xABFF, self.tr("Meetei Mayek")),
193 (0xa980, 0xa9df, self.tr("Javanese")), 199 (0xAC00, 0xD7AF, self.tr("Hangul Syllables")),
194 (0xaa00, 0xaa5f, self.tr("Cham")), 200 (0xD7B0, 0xD7FF, self.tr("Hangul Jamo Extended-B")),
195 (0xaa60, 0xaa7f, self.tr("Myanmar Extended-A")), 201 (0xD800, 0xDB7F, self.tr("High Surrogates")),
196 (0xaa80, 0xaadf, self.tr("Tai Viet")), 202 (0xDB80, 0xDBFF, self.tr("High Private Use Surrogates")),
197 (0xaae0, 0xaaff, self.tr("Meetei Mayek Extensions")), 203 (0xDC00, 0xDFFF, self.tr("Low Surrogates")),
198 (0xab00, 0xab2f, self.tr("Ethiopic Extended-A")), 204 (0xE000, 0xF8FF, self.tr("Private Use")),
199 (0xabc0, 0xabff, self.tr("Meetei Mayek")), 205 (0xF900, 0xFAFF, self.tr("CJK Compatibility Ideographs")),
200 (0xac00, 0xd7af, self.tr("Hangul Syllables")), 206 (0xFB00, 0xFB4F, self.tr("Alphabetic Presentation Forms")),
201 (0xd7b0, 0xd7ff, self.tr("Hangul Jamo Extended-B")), 207 (0xFB50, 0xFDFF, self.tr("Arabic Presentation Forms-A")),
202 (0xd800, 0xdb7f, self.tr("High Surrogates")), 208 (0xFE00, 0xFE0F, self.tr("Variation Selectors")),
203 (0xdb80, 0xdbff, self.tr("High Private Use Surrogates")), 209 (0xFE10, 0xFE1F, self.tr("Vertical Forms")),
204 (0xdc00, 0xdfff, self.tr("Low Surrogates")), 210 (0xFE20, 0xFE2F, self.tr("Combining Half Marks")),
205 (0xe000, 0xf8ff, self.tr("Private Use")), 211 (0xFE30, 0xFE4F, self.tr("CJK Compatibility Forms")),
206 (0xf900, 0xfaff, self.tr("CJK Compatibility Ideographs")), 212 (0xFE50, 0xFE6F, self.tr("Small Form Variants")),
207 (0xfb00, 0xfb4f, self.tr("Alphabetic Presentation Forms")), 213 (0xFE70, 0xFEFF, self.tr("Arabic Presentation Forms-B")),
208 (0xfb50, 0xfdff, self.tr("Arabic Presentation Forms-A")), 214 (0xFF00, 0xFFEF, self.tr("Half- and Fullwidth Forms")),
209 (0xfe00, 0xfe0f, self.tr("Variation Selectors")), 215 (0xFFF0, 0xFFFF, self.tr("Specials")),
210 (0xfe10, 0xfe1f, self.tr("Vertical Forms")),
211 (0xfe20, 0xfe2f, self.tr("Combining Half Marks")),
212 (0xfe30, 0xfe4f, self.tr("CJK Compatibility Forms")),
213 (0xfe50, 0xfe6f, self.tr("Small Form Variants")),
214 (0xfe70, 0xfeff, self.tr("Arabic Presentation Forms-B")),
215 (0xff00, 0xffef, self.tr("Half- and Fullwidth Forms")),
216 (0xfff0, 0xffff, self.tr("Specials")),
217 ] 216 ]
218 if sys.maxunicode > 0xffff: 217 if sys.maxunicode > 0xFFFF:
219 self.__tables.extend([ 218 self.__tables.extend(
220 (0x10000, 0x1007f, self.tr("Linear B Syllabary")), 219 [
221 (0x10080, 0x100ff, self.tr("Linear B Ideograms")), 220 (0x10000, 0x1007F, self.tr("Linear B Syllabary")),
222 (0x10100, 0x1013f, self.tr("Aegean Numbers")), 221 (0x10080, 0x100FF, self.tr("Linear B Ideograms")),
223 (0x10140, 0x1018f, self.tr("Ancient Greek Numbers")), 222 (0x10100, 0x1013F, self.tr("Aegean Numbers")),
224 (0x10190, 0x101cf, self.tr("Ancient Symbols")), 223 (0x10140, 0x1018F, self.tr("Ancient Greek Numbers")),
225 (0x101d0, 0x101ff, self.tr("Phaistos Disc")), 224 (0x10190, 0x101CF, self.tr("Ancient Symbols")),
226 (0x10280, 0x1029f, self.tr("Lycian")), 225 (0x101D0, 0x101FF, self.tr("Phaistos Disc")),
227 (0x102a0, 0x102df, self.tr("Carian")), 226 (0x10280, 0x1029F, self.tr("Lycian")),
228 (0x10300, 0x1032f, self.tr("Old Italic")), 227 (0x102A0, 0x102DF, self.tr("Carian")),
229 (0x10330, 0x1034f, self.tr("Gothic")), 228 (0x10300, 0x1032F, self.tr("Old Italic")),
230 (0x10380, 0x1039f, self.tr("Ugaritic")), 229 (0x10330, 0x1034F, self.tr("Gothic")),
231 (0x103a0, 0x103df, self.tr("Old Persian")), 230 (0x10380, 0x1039F, self.tr("Ugaritic")),
232 (0x10400, 0x1044f, self.tr("Deseret")), 231 (0x103A0, 0x103DF, self.tr("Old Persian")),
233 (0x10450, 0x1047f, self.tr("Shavian")), 232 (0x10400, 0x1044F, self.tr("Deseret")),
234 (0x10480, 0x104af, self.tr("Osmanya")), 233 (0x10450, 0x1047F, self.tr("Shavian")),
235 (0x10800, 0x1083f, self.tr("Cypriot Syllabary")), 234 (0x10480, 0x104AF, self.tr("Osmanya")),
236 (0x10840, 0x1085f, self.tr("Imperial Aramaic")), 235 (0x10800, 0x1083F, self.tr("Cypriot Syllabary")),
237 (0x10900, 0x1091f, self.tr("Phoenician")), 236 (0x10840, 0x1085F, self.tr("Imperial Aramaic")),
238 (0x10920, 0x1093f, self.tr("Lydian")), 237 (0x10900, 0x1091F, self.tr("Phoenician")),
239 (0x10980, 0x1099f, self.tr("Meroitic Hieroglyphs")), 238 (0x10920, 0x1093F, self.tr("Lydian")),
240 (0x109a0, 0x109ff, self.tr("Meroitic Cursive")), 239 (0x10980, 0x1099F, self.tr("Meroitic Hieroglyphs")),
241 (0x10a00, 0x10a5f, self.tr("Kharoshthi")), 240 (0x109A0, 0x109FF, self.tr("Meroitic Cursive")),
242 (0x10a60, 0x10a7f, self.tr("Old South Arabian")), 241 (0x10A00, 0x10A5F, self.tr("Kharoshthi")),
243 (0x10b00, 0x10b3f, self.tr("Avestan")), 242 (0x10A60, 0x10A7F, self.tr("Old South Arabian")),
244 (0x10b40, 0x10b5f, self.tr("Inscriptional Parthian")), 243 (0x10B00, 0x10B3F, self.tr("Avestan")),
245 (0x10b60, 0x10b7f, self.tr("Inscriptional Pahlavi")), 244 (0x10B40, 0x10B5F, self.tr("Inscriptional Parthian")),
246 (0x10c00, 0x10c4f, self.tr("Old Turkic")), 245 (0x10B60, 0x10B7F, self.tr("Inscriptional Pahlavi")),
247 (0x10e60, 0x10e7f, self.tr("Rumi Numeral Symbols")), 246 (0x10C00, 0x10C4F, self.tr("Old Turkic")),
248 (0x11000, 0x1107f, self.tr("Brahmi")), 247 (0x10E60, 0x10E7F, self.tr("Rumi Numeral Symbols")),
249 (0x11080, 0x110cf, self.tr("Kaithi")), 248 (0x11000, 0x1107F, self.tr("Brahmi")),
250 (0x110d0, 0x110ff, self.tr("Sora Sompeng")), 249 (0x11080, 0x110CF, self.tr("Kaithi")),
251 (0x11100, 0x1114f, self.tr("Chakma")), 250 (0x110D0, 0x110FF, self.tr("Sora Sompeng")),
252 (0x11180, 0x111df, self.tr("Sharada")), 251 (0x11100, 0x1114F, self.tr("Chakma")),
253 (0x11680, 0x116cf, self.tr("Takri")), 252 (0x11180, 0x111DF, self.tr("Sharada")),
254 (0x12000, 0x123ff, self.tr("Cuneiform")), 253 (0x11680, 0x116CF, self.tr("Takri")),
255 (0x12400, 0x1247f, 254 (0x12000, 0x123FF, self.tr("Cuneiform")),
256 self.tr("Cuneiform Numbers and Punctuation")), 255 (0x12400, 0x1247F, self.tr("Cuneiform Numbers and Punctuation")),
257 (0x13000, 0x1342f, self.tr("Egyptian Hieroglyphs")), 256 (0x13000, 0x1342F, self.tr("Egyptian Hieroglyphs")),
258 (0x16800, 0x16a3f, self.tr("Bamum Supplement")), 257 (0x16800, 0x16A3F, self.tr("Bamum Supplement")),
259 (0x16f00, 0x16f9f, self.tr("Miao")), 258 (0x16F00, 0x16F9F, self.tr("Miao")),
260 (0x1b000, 0x1b0ff, self.tr("Kana Supplement")), 259 (0x1B000, 0x1B0FF, self.tr("Kana Supplement")),
261 (0x1d000, 0x1d0ff, self.tr("Byzantine Musical Symbols")), 260 (0x1D000, 0x1D0FF, self.tr("Byzantine Musical Symbols")),
262 (0x1d100, 0x1d1ff, self.tr("Musical Symbols")), 261 (0x1D100, 0x1D1FF, self.tr("Musical Symbols")),
263 (0x1d200, 0x1d24f, 262 (0x1D200, 0x1D24F, self.tr("Ancient Greek Musical Notation")),
264 self.tr("Ancient Greek Musical Notation")), 263 (0x1D300, 0x1D35F, self.tr("Tai Xuan Jing Symbols")),
265 (0x1d300, 0x1d35f, self.tr("Tai Xuan Jing Symbols")), 264 (0x1D360, 0x1D37F, self.tr("Counting Rod Numerals")),
266 (0x1d360, 0x1d37f, 265 (0x1D400, 0x1D7FF, self.tr("Mathematical Alphanumeric Symbols")),
267 self.tr("Counting Rod Numerals")), 266 (
268 (0x1d400, 0x1d7ff, 267 0x1EE00,
269 self.tr("Mathematical Alphanumeric Symbols")), 268 0x1EEFF,
270 (0x1ee00, 0x1eeff, 269 self.tr("Arabic Mathematical Alphabetic Symbols"),
271 self.tr("Arabic Mathematical Alphabetic Symbols")), 270 ),
272 (0x1f000, 0x1f02f, self.tr("Mahjong Tiles")), 271 (0x1F000, 0x1F02F, self.tr("Mahjong Tiles")),
273 (0x1f030, 0x1f09f, self.tr("Domino Tiles")), 272 (0x1F030, 0x1F09F, self.tr("Domino Tiles")),
274 (0x1f0a0, 0x1f0ff, self.tr("Playing Cards")), 273 (0x1F0A0, 0x1F0FF, self.tr("Playing Cards")),
275 (0x1f100, 0x1f1ff, 274 (0x1F100, 0x1F1FF, self.tr("Enclosed Alphanumeric Supplement")),
276 self.tr("Enclosed Alphanumeric Supplement")), 275 (0x1F200, 0x1F2FF, self.tr("Enclosed Ideographic Supplement")),
277 (0x1f200, 0x1f2ff, 276 (
278 self.tr("Enclosed Ideographic Supplement")), 277 0x1F300,
279 (0x1f300, 0x1f5ff, 278 0x1F5FF,
280 self.tr("Miscellaneous Symbols And Pictographs")), 279 self.tr("Miscellaneous Symbols And Pictographs"),
281 (0x1f600, 0x1f64f, self.tr("Emoticons")), 280 ),
282 (0x1f680, 0x1f6ff, self.tr("Transport And Map Symbols")), 281 (0x1F600, 0x1F64F, self.tr("Emoticons")),
283 (0x1f700, 0x1f77f, self.tr("Alchemical Symbols")), 282 (0x1F680, 0x1F6FF, self.tr("Transport And Map Symbols")),
284 (0x20000, 0x2a6df, self.tr("CJK Unified Ideogr. Ext. B")), 283 (0x1F700, 0x1F77F, self.tr("Alchemical Symbols")),
285 (0x2a700, 0x2b73f, 284 (0x20000, 0x2A6DF, self.tr("CJK Unified Ideogr. Ext. B")),
286 self.tr("CJK Unified Ideographs Extension C")), 285 (0x2A700, 0x2B73F, self.tr("CJK Unified Ideographs Extension C")),
287 (0x2b740, 0x2b81f, 286 (0x2B740, 0x2B81F, self.tr("CJK Unified Ideographs Extension D")),
288 self.tr("CJK Unified Ideographs Extension D")), 287 (0x2F800, 0x2FA1F, self.tr("CJK Compatapility Ideogr. Suppl.")),
289 (0x2f800, 0x2fa1f, 288 (0xE0000, 0xE007F, self.tr("Tags")),
290 self.tr("CJK Compatapility Ideogr. Suppl.")), 289 (0xE0100, 0xE01EF, self.tr("Variation Selectors Supplement")),
291 (0xe0000, 0xe007f, self.tr("Tags")), 290 (0xF0000, 0xFFFFF, self.tr("Supplementary Private Use Area-A")),
292 (0xe0100, 0xe01ef, 291 (0x100000, 0x10FFFF, self.tr("Supplementary Private Use Area-B")),
293 self.tr("Variation Selectors Supplement")), 292 ]
294 (0xf0000, 0xfffff, 293 )
295 self.tr("Supplementary Private Use Area-A")),
296 (0x100000, 0x10ffff,
297 self.tr("Supplementary Private Use Area-B")),
298 ])
299 self.__currentTableIndex = 0 294 self.__currentTableIndex = 0
300 295
301 def getTableNames(self): 296 def getTableNames(self):
302 """ 297 """
303 Public method to get a list of table names. 298 Public method to get a list of table names.
304 299
305 @return list of table names (list of strings) 300 @return list of table names (list of strings)
306 """ 301 """
307 return [table[2] for table in self.__tables] 302 return [table[2] for table in self.__tables]
308 303
309 def getTableBoundaries(self, index): 304 def getTableBoundaries(self, index):
310 """ 305 """
311 Public method to get the first and last character position 306 Public method to get the first and last character position
312 of the given table. 307 of the given table.
313 308
314 @param index index of the character table (integer) 309 @param index index of the character table (integer)
315 @return first and last character position (integer, integer) 310 @return first and last character position (integer, integer)
316 """ 311 """
317 return self.__tables[index][0], self.__tables[index][1] 312 return self.__tables[index][0], self.__tables[index][1]
318 313
319 def getTableIndex(self): 314 def getTableIndex(self):
320 """ 315 """
321 Public method to get the current table index. 316 Public method to get the current table index.
322 317
323 @return current table index (integer) 318 @return current table index (integer)
324 """ 319 """
325 return self.__currentTableIndex 320 return self.__currentTableIndex
326 321
327 def selectTable(self, index): 322 def selectTable(self, index):
328 """ 323 """
329 Public method to select the shown character table. 324 Public method to select the shown character table.
330 325
331 @param index index of the character table (integer) 326 @param index index of the character table (integer)
332 """ 327 """
333 self.beginResetModel() 328 self.beginResetModel()
334 self.__currentTableIndex = index 329 self.__currentTableIndex = index
335 self.endResetModel() 330 self.endResetModel()
336 331
337 def headerData(self, section, orientation, 332 def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole):
338 role=Qt.ItemDataRole.DisplayRole):
339 """ 333 """
340 Public method to get header data from the model. 334 Public method to get header data from the model.
341 335
342 @param section section number (integer) 336 @param section section number (integer)
343 @param orientation orientation (Qt.Orientation) 337 @param orientation orientation (Qt.Orientation)
344 @param role role of the data to retrieve (Qt.ItemDataRole) 338 @param role role of the data to retrieve (Qt.ItemDataRole)
345 @return requested data 339 @return requested data
346 """ 340 """
347 if ( 341 if (
348 orientation == Qt.Orientation.Horizontal and 342 orientation == Qt.Orientation.Horizontal
349 role == Qt.ItemDataRole.DisplayRole 343 and role == Qt.ItemDataRole.DisplayRole
350 ): 344 ):
351 return self.__headerData[section] 345 return self.__headerData[section]
352 346
353 return QAbstractTableModel.headerData(self, section, orientation, role) 347 return QAbstractTableModel.headerData(self, section, orientation, role)
354 348
355 def data(self, index, role=Qt.ItemDataRole.DisplayRole): 349 def data(self, index, role=Qt.ItemDataRole.DisplayRole):
356 """ 350 """
357 Public method to get data from the model. 351 Public method to get data from the model.
358 352
359 @param index index to get data for (QModelIndex) 353 @param index index to get data for (QModelIndex)
360 @param role role of the data to retrieve (integer) 354 @param role role of the data to retrieve (integer)
361 @return requested data 355 @return requested data
362 """ 356 """
363 symbolId = self.__tables[self.__currentTableIndex][0] + index.row() 357 symbolId = self.__tables[self.__currentTableIndex][0] + index.row()
364 358
365 if role == Qt.ItemDataRole.DisplayRole: 359 if role == Qt.ItemDataRole.DisplayRole:
366 col = index.column() 360 col = index.column()
367 if col == 0: 361 if col == 0:
368 return self.__locale.toString(symbolId) 362 return self.__locale.toString(symbolId)
369 elif col == 1: 363 elif col == 1:
370 return chr(symbolId) 364 return chr(symbolId)
371 elif col == 2: 365 elif col == 2:
372 return "0x{0:04x}".format(symbolId) 366 return "0x{0:04x}".format(symbolId)
373 elif col == 3: 367 elif col == 3:
374 if symbolId in html.entities.codepoint2name: 368 if symbolId in html.entities.codepoint2name:
375 return "&{0};".format( 369 return "&{0};".format(html.entities.codepoint2name[symbolId])
376 html.entities.codepoint2name[symbolId])
377 elif col == 4: 370 elif col == 4:
378 return unicodedata.name(chr(symbolId), '').title() 371 return unicodedata.name(chr(symbolId), "").title()
379 372
380 if ( 373 if role == Qt.ItemDataRole.BackgroundRole and index.column() == 0:
381 role == Qt.ItemDataRole.BackgroundRole and
382 index.column() == 0
383 ):
384 if self.__isDark: 374 if self.__isDark:
385 return QColor("#4d4d4d") 375 return QColor("#4d4d4d")
386 else: 376 else:
387 return QColor(Qt.GlobalColor.lightGray) 377 return QColor(Qt.GlobalColor.lightGray)
388 378
389 if role == Qt.ItemDataRole.ForegroundRole: 379 if role == Qt.ItemDataRole.ForegroundRole:
390 char = chr(symbolId) 380 char = chr(symbolId)
391 if self.__isDark: 381 if self.__isDark:
392 if self.__isDigit(char): 382 if self.__isDigit(char):
393 return QColor("#8787ff") 383 return QColor("#8787ff")
412 return QColor(Qt.GlobalColor.darkYellow) 402 return QColor(Qt.GlobalColor.darkYellow)
413 elif self.__isPunct(char): 403 elif self.__isPunct(char):
414 return QColor(Qt.GlobalColor.darkMagenta) 404 return QColor(Qt.GlobalColor.darkMagenta)
415 else: 405 else:
416 return QColor(Qt.GlobalColor.darkGray) 406 return QColor(Qt.GlobalColor.darkGray)
417 407
418 if ( 408 if role == Qt.ItemDataRole.TextAlignmentRole and index.column() in [0, 1, 3]:
419 role == Qt.ItemDataRole.TextAlignmentRole and
420 index.column() in [0, 1, 3]
421 ):
422 return Qt.AlignmentFlag.AlignHCenter.value 409 return Qt.AlignmentFlag.AlignHCenter.value
423 410
424 return None 411 return None
425 412
426 def columnCount(self, parent): 413 def columnCount(self, parent):
427 """ 414 """
428 Public method to get the number of columns of the model. 415 Public method to get the number of columns of the model.
429 416
430 @param parent parent index (QModelIndex) 417 @param parent parent index (QModelIndex)
431 @return number of columns (integer) 418 @return number of columns (integer)
432 """ 419 """
433 if parent.column() > 0: 420 if parent.column() > 0:
434 return 0 421 return 0
435 else: 422 else:
436 return len(self.__headerData) 423 return len(self.__headerData)
437 424
438 def rowCount(self, parent): 425 def rowCount(self, parent):
439 """ 426 """
440 Public method to get the number of rows of the model. 427 Public method to get the number of rows of the model.
441 428
442 @param parent parent index (QModelIndex) 429 @param parent parent index (QModelIndex)
443 @return number of columns (integer) 430 @return number of columns (integer)
444 """ 431 """
445 if parent.isValid(): 432 if parent.isValid():
446 return 0 433 return 0
447 else: 434 else:
448 first, last = self.__tables[self.__currentTableIndex][:2] 435 first, last = self.__tables[self.__currentTableIndex][:2]
449 return last - first + 1 436 return last - first + 1
450 437
451 def __isDigit(self, char): 438 def __isDigit(self, char):
452 """ 439 """
453 Private method to check, if a character is a digit. 440 Private method to check, if a character is a digit.
454 441
455 @param char character to test (one character string) 442 @param char character to test (one character string)
456 @return flag indicating a digit (boolean) 443 @return flag indicating a digit (boolean)
457 """ 444 """
458 return unicodedata.category(str(char)) == "Nd" 445 return unicodedata.category(str(char)) == "Nd"
459 446
460 def __isLetter(self, char): 447 def __isLetter(self, char):
461 """ 448 """
462 Private method to check, if a character is a letter. 449 Private method to check, if a character is a letter.
463 450
464 @param char character to test (one character string) 451 @param char character to test (one character string)
465 @return flag indicating a letter (boolean) 452 @return flag indicating a letter (boolean)
466 """ 453 """
467 return unicodedata.category(str(char)) in ["Lu", "Ll", "Lt", "Lm", 454 return unicodedata.category(str(char)) in ["Lu", "Ll", "Lt", "Lm", "Lo"]
468 "Lo"] 455
469
470 def __isMark(self, char): 456 def __isMark(self, char):
471 """ 457 """
472 Private method to check, if a character is a mark character. 458 Private method to check, if a character is a mark character.
473 459
474 @param char character to test (one character string) 460 @param char character to test (one character string)
475 @return flag indicating a mark character (boolean) 461 @return flag indicating a mark character (boolean)
476 """ 462 """
477 return unicodedata.category(str(char)) in ["Mn", "Mc", "Me"] 463 return unicodedata.category(str(char)) in ["Mn", "Mc", "Me"]
478 464
479 def __isSymbol(self, char): 465 def __isSymbol(self, char):
480 """ 466 """
481 Private method to check, if a character is a symbol. 467 Private method to check, if a character is a symbol.
482 468
483 @param char character to test (one character string) 469 @param char character to test (one character string)
484 @return flag indicating a symbol (boolean) 470 @return flag indicating a symbol (boolean)
485 """ 471 """
486 return unicodedata.category(str(char)) in ["Sm", "Sc", "Sk", "So"] 472 return unicodedata.category(str(char)) in ["Sm", "Sc", "Sk", "So"]
487 473
488 def __isPunct(self, char): 474 def __isPunct(self, char):
489 """ 475 """
490 Private method to check, if a character is a punctuation character. 476 Private method to check, if a character is a punctuation character.
491 477
492 @param char character to test (one character string) 478 @param char character to test (one character string)
493 @return flag indicating a punctuation character (boolean) 479 @return flag indicating a punctuation character (boolean)
494 """ 480 """
495 return unicodedata.category(str(char)) in ["Pc", "Pd", "Ps", "Pe", 481 return unicodedata.category(str(char)) in [
496 "Pi", "Pf", "Po"] 482 "Pc",
497 483 "Pd",
484 "Ps",
485 "Pe",
486 "Pi",
487 "Pf",
488 "Po",
489 ]
490
498 def getLocale(self): 491 def getLocale(self):
499 """ 492 """
500 Public method to get the used locale. 493 Public method to get the used locale.
501 494
502 @return used locale 495 @return used locale
503 @rtype QLocale 496 @rtype QLocale
504 """ 497 """
505 return self.__locale 498 return self.__locale
506 499
507 500
508 class SymbolsWidget(QWidget, Ui_SymbolsWidget): 501 class SymbolsWidget(QWidget, Ui_SymbolsWidget):
509 """ 502 """
510 Class implementing a widget to select a symbol in various formats. 503 Class implementing a widget to select a symbol in various formats.
511 504
512 @signal insertSymbol(str) emitted after the user has selected a symbol 505 @signal insertSymbol(str) emitted after the user has selected a symbol
513 """ 506 """
507
514 insertSymbol = pyqtSignal(str) 508 insertSymbol = pyqtSignal(str)
515 509
516 def __init__(self, parent=None): 510 def __init__(self, parent=None):
517 """ 511 """
518 Constructor 512 Constructor
519 513
520 @param parent reference to the parent widget (QWidget) 514 @param parent reference to the parent widget (QWidget)
521 """ 515 """
522 super().__init__(parent) 516 super().__init__(parent)
523 self.setupUi(self) 517 self.setupUi(self)
524 518
525 self.setWindowIcon(UI.PixmapCache.getIcon("eric")) 519 self.setWindowIcon(UI.PixmapCache.getIcon("eric"))
526 520
527 self.__model = SymbolsModel(self) 521 self.__model = SymbolsModel(self)
528 self.symbolsTable.setModel(self.__model) 522 self.symbolsTable.setModel(self.__model)
529 self.symbolsTable.selectionModel().currentRowChanged.connect( 523 self.symbolsTable.selectionModel().currentRowChanged.connect(
530 self.__currentRowChanged) 524 self.__currentRowChanged
531 525 )
526
532 self.symbolsTable.horizontalHeader().setSectionResizeMode( 527 self.symbolsTable.horizontalHeader().setSectionResizeMode(
533 QHeaderView.ResizeMode.Fixed) 528 QHeaderView.ResizeMode.Fixed
529 )
534 fm = self.fontMetrics() 530 fm = self.fontMetrics()
535 try: 531 try:
536 em = fm.horizontalAdvance("M") 532 em = fm.horizontalAdvance("M")
537 except AttributeError: 533 except AttributeError:
538 em = fm.width("M") 534 em = fm.width("M")
539 self.symbolsTable.horizontalHeader().resizeSection(0, em * 5) 535 self.symbolsTable.horizontalHeader().resizeSection(0, em * 5)
540 self.symbolsTable.horizontalHeader().resizeSection(1, em * 5) 536 self.symbolsTable.horizontalHeader().resizeSection(1, em * 5)
541 self.symbolsTable.horizontalHeader().resizeSection(2, em * 6) 537 self.symbolsTable.horizontalHeader().resizeSection(2, em * 6)
542 self.symbolsTable.horizontalHeader().resizeSection(3, em * 8) 538 self.symbolsTable.horizontalHeader().resizeSection(3, em * 8)
543 self.symbolsTable.horizontalHeader().resizeSection(4, em * 85) 539 self.symbolsTable.horizontalHeader().resizeSection(4, em * 85)
544 self.symbolsTable.verticalHeader().setDefaultSectionSize( 540 self.symbolsTable.verticalHeader().setDefaultSectionSize(fm.height() + 4)
545 fm.height() + 4) 541
546 542 tableIndex = int(Preferences.getSettings().value("Symbols/CurrentTable", 1))
547 tableIndex = int(
548 Preferences.getSettings().value("Symbols/CurrentTable", 1))
549 self.tableCombo.addItems(self.__model.getTableNames()) 543 self.tableCombo.addItems(self.__model.getTableNames())
550 self.tableCombo.setCurrentIndex(tableIndex) 544 self.tableCombo.setCurrentIndex(tableIndex)
551 545
552 index = self.__model.index( 546 index = self.__model.index(
553 int(Preferences.getSettings().value("Symbols/Top", 0)), 547 int(Preferences.getSettings().value("Symbols/Top", 0)), 0
554 0) 548 )
555 self.symbolsTable.scrollTo( 549 self.symbolsTable.scrollTo(index, QAbstractItemView.ScrollHint.PositionAtTop)
556 index, QAbstractItemView.ScrollHint.PositionAtTop)
557 self.symbolsTable.selectionModel().setCurrentIndex( 550 self.symbolsTable.selectionModel().setCurrentIndex(
558 index, 551 index,
559 QItemSelectionModel.SelectionFlag.SelectCurrent | 552 QItemSelectionModel.SelectionFlag.SelectCurrent
560 QItemSelectionModel.SelectionFlag.Rows 553 | QItemSelectionModel.SelectionFlag.Rows,
561 ) 554 )
562 555
563 @pyqtSlot(QModelIndex) 556 @pyqtSlot(QModelIndex)
564 def on_symbolsTable_activated(self, index): 557 def on_symbolsTable_activated(self, index):
565 """ 558 """
566 Private slot to signal the selection of a symbol. 559 Private slot to signal the selection of a symbol.
567 560
568 @param index index of the selected symbol (QModelIndex) 561 @param index index of the selected symbol (QModelIndex)
569 """ 562 """
570 txt = self.__model.data(index) 563 txt = self.__model.data(index)
571 if txt: 564 if txt:
572 self.insertSymbol.emit(txt) 565 self.insertSymbol.emit(txt)
573 566
574 @pyqtSlot() 567 @pyqtSlot()
575 def on_symbolSpinBox_editingFinished(self): 568 def on_symbolSpinBox_editingFinished(self):
576 """ 569 """
577 Private slot to move the table to the entered symbol id. 570 Private slot to move the table to the entered symbol id.
578 """ 571 """
579 symbolId = self.symbolSpinBox.value() 572 symbolId = self.symbolSpinBox.value()
580 first, last = self.__model.getTableBoundaries( 573 first, last = self.__model.getTableBoundaries(self.__model.getTableIndex())
581 self.__model.getTableIndex())
582 row = symbolId - first 574 row = symbolId - first
583 self.symbolsTable.selectRow(row) 575 self.symbolsTable.selectRow(row)
584 self.symbolsTable.scrollTo( 576 self.symbolsTable.scrollTo(
585 self.__model.index(row, 0), 577 self.__model.index(row, 0), QAbstractItemView.ScrollHint.PositionAtCenter
586 QAbstractItemView.ScrollHint.PositionAtCenter) 578 )
587 579
588 @pyqtSlot(int) 580 @pyqtSlot(int)
589 def on_tableCombo_currentIndexChanged(self, index): 581 def on_tableCombo_currentIndexChanged(self, index):
590 """ 582 """
591 Private slot to select the current character table. 583 Private slot to select the current character table.
592 584
593 @param index index of the character table (integer) 585 @param index index of the character table (integer)
594 """ 586 """
595 self.symbolsTable.setUpdatesEnabled(False) 587 self.symbolsTable.setUpdatesEnabled(False)
596 self.__model.selectTable(index) 588 self.__model.selectTable(index)
597 self.symbolsTable.setUpdatesEnabled(True) 589 self.symbolsTable.setUpdatesEnabled(True)
598 self.symbolsTable.resizeColumnsToContents() 590 self.symbolsTable.resizeColumnsToContents()
599 591
600 first, last = self.__model.getTableBoundaries(index) 592 first, last = self.__model.getTableBoundaries(index)
601 self.symbolSpinBox.setMinimum(first) 593 self.symbolSpinBox.setMinimum(first)
602 self.symbolSpinBox.setMaximum(last) 594 self.symbolSpinBox.setMaximum(last)
603 595
604 Preferences.getSettings().setValue("Symbols/CurrentTable", index) 596 Preferences.getSettings().setValue("Symbols/CurrentTable", index)
605 597
606 def __currentRowChanged(self, current, previous): 598 def __currentRowChanged(self, current, previous):
607 """ 599 """
608 Private slot recording the currently selected row. 600 Private slot recording the currently selected row.
609 601
610 @param current current index (QModelIndex) 602 @param current current index (QModelIndex)
611 @param previous previous current index (QModelIndex) 603 @param previous previous current index (QModelIndex)
612 """ 604 """
613 Preferences.getSettings().setValue("Symbols/Top", current.row()) 605 Preferences.getSettings().setValue("Symbols/Top", current.row())
614 self.symbolSpinBox.setValue(self.__model.getLocale().toInt( 606 self.symbolSpinBox.setValue(
615 self.__model.data(self.__model.index(current.row(), 0)))[0]) 607 self.__model.getLocale().toInt(
608 self.__model.data(self.__model.index(current.row(), 0))
609 )[0]
610 )

eric ide

mercurial