UI/SymbolsWidget.py

Wed, 02 Jan 2013 10:31:48 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 02 Jan 2013 10:31:48 +0100
changeset 2302
f29e9405c851
parent 2094
88620e11c67c
child 2525
8b507a9a2d40
child 2603
2efe1c237c33
permissions
-rw-r--r--

Updated copyright for 2013.

365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2094
diff changeset
3 # Copyright (c) 2010 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a widget to select a symbol in various formats.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import unicodedata
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import html.entities
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
2094
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1817
diff changeset
13 from PyQt4.QtCore import pyqtSlot, pyqtSignal, QAbstractTableModel, QModelIndex, Qt, \
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1817
diff changeset
14 qVersion
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
15 from PyQt4.QtGui import QWidget, QHeaderView, QAbstractItemView, QColor, \
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
16 QItemSelectionModel
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from .Ui_SymbolsWidget import Ui_SymbolsWidget
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
369
64d423a83450 Added code to set the window icon to the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 367
diff changeset
20 import UI.PixmapCache
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
21 import Preferences
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
22
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
23
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 class SymbolsModel(QAbstractTableModel):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Class implementing the model for the symbols widget.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
28 def __init__(self, parent=None):
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param parent reference to the parent object (QObject)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
34 super().__init__(parent)
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.__headerData = [
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
37 self.trUtf8("Code"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
38 self.trUtf8("Char"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
39 self.trUtf8("Hex"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
40 self.trUtf8("HTML"),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
41 self.trUtf8("Name"),
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 ]
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
44 self.__tables = (
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
45 # first last display name
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
46 (0x0, 0x1f, self.trUtf8("Control Characters")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
47 (0x20, 0x7f, self.trUtf8("Basic Latin")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
48 (0x80, 0x100, self.trUtf8("Latin-1 Supplement")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
49 (0x100, 0x180, self.trUtf8("Latin Extended A")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
50 (0x180, 0x24f, self.trUtf8("Latin Extended B")),
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
51 (0x250, 0x2af, self.trUtf8("IPA Extensions")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
52 (0x2b0, 0x2ff, self.trUtf8("Spacing Modifier Letters")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
53 (0x300, 0x36f, self.trUtf8("Combining Diacritical Marks")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
54 (0x370, 0x3ff, self.trUtf8("Greek and Coptic")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
55 (0x400, 0x4ff, self.trUtf8("Cyrillic")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
56 (0x500, 0x52f, self.trUtf8("Cyrillic Supplement")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
57 (0x530, 0x58f, self.trUtf8("Armenian")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
58 (0x590, 0x5ff, self.trUtf8("Hebrew")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
59 (0x600, 0x6ff, self.trUtf8("Arabic")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
60 (0x700, 0x74f, self.trUtf8("Syriac")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
61 (0x780, 0x7bf, self.trUtf8("Thaana")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
62 (0x900, 0x97f, self.trUtf8("Devanagari")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
63 (0x980, 0x9ff, self.trUtf8("Bengali")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
64 (0xa00, 0xa7f, self.trUtf8("Gurmukhi")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
65 (0xa80, 0xaff, self.trUtf8("Gujarati")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
66 (0xb00, 0xb7f, self.trUtf8("Oriya")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
67 (0xb80, 0xbff, self.trUtf8("Tamil")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
68 (0xc00, 0xc7f, self.trUtf8("Telugu")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
69 (0xc80, 0xcff, self.trUtf8("Kannada")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
70 (0xd00, 0xd7f, self.trUtf8("Malayalam")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
71 (0xd80, 0xdff, self.trUtf8("Sinhala")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
72 (0xe00, 0xe7f, self.trUtf8("Thai")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
73 (0xe80, 0xeff, self.trUtf8("Lao")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
74 (0xf00, 0xfff, self.trUtf8("Tibetan")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
75 (0x1000, 0x109f, self.trUtf8("Myanmar")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
76 (0x10a0, 0x10ff, self.trUtf8("Georgian")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
77 (0x1100, 0x11ff, self.trUtf8("Hangul Jamo")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
78 (0x1200, 0x137f, self.trUtf8("Ethiopic")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
79 (0x13a0, 0x13ff, self.trUtf8("Cherokee")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
80 (0x1400, 0x167f, self.trUtf8("Canadian Aboriginal Syllabics")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
81 (0x1680, 0x169f, self.trUtf8("Ogham")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
82 (0x16a0, 0x16ff, self.trUtf8("Runic")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
83 (0x1700, 0x171f, self.trUtf8("Tagalog")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
84 (0x1720, 0x173f, self.trUtf8("Hanunoo")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
85 (0x1740, 0x175f, self.trUtf8("Buhid")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
86 (0x1760, 0x177f, self.trUtf8("Tagbanwa")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
87 (0x1780, 0x17ff, self.trUtf8("Khmer")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
88 (0x1800, 0x18af, self.trUtf8("Mongolian")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
89 (0x1900, 0x194f, self.trUtf8("Limbu")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
90 (0x1950, 0x197f, self.trUtf8("Tai Le")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
91 (0x19e0, 0x19ff, self.trUtf8("Khmer Symbols")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
92 (0x1d00, 0x1d7f, self.trUtf8("Phonetic Extensions")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
93 (0x1e00, 0x1eff, self.trUtf8("Latin Extended Additional")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
94 (0x1f00, 0x1fff, self.trUtf8("Greek Extended")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
95 (0x2000, 0x206f, self.trUtf8("General Punctuation")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
96 (0x2070, 0x209f, self.trUtf8("Superscripts and Subscripts")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
97 (0x20a0, 0x20cf, self.trUtf8("Currency Symbols")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
98 (0x20d0, 0x20ff, self.trUtf8("Combining Diacritical Marks")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
99 (0x2100, 0x214f, self.trUtf8("Letterlike Symbols")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
100 (0x2150, 0x218f, self.trUtf8("Number Forms")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
101 (0x2190, 0x21ff, self.trUtf8("Arcolumns")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
102 (0x2200, 0x22ff, self.trUtf8("Mathematical Operators")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
103 (0x2300, 0x23ff, self.trUtf8("Miscellaneous Technical")),
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
104 (0x2400, 0x243f, self.trUtf8("Control Pictures")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
105 (0x2440, 0x245f, self.trUtf8("Optical Character Recognition")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
106 (0x2460, 0x24ff, self.trUtf8("Enclosed Alphanumerics")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
107 (0x2500, 0x257f, self.trUtf8("Box Drawing")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
108 (0x2580, 0x259f, self.trUtf8("Block Elements")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
109 (0x25A0, 0x25ff, self.trUtf8("Geometric Shapes")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
110 (0x2600, 0x26ff, self.trUtf8("Miscellaneous Symbols")),
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
111 (0x2700, 0x27bf, self.trUtf8("Dingbats")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
112 (0x27c0, 0x27ef, self.trUtf8("Miscellaneous Mathematical Symbols-A")),
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
113 (0x27f0, 0x27ff, self.trUtf8("Supplement Arcolumns-A")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
114 (0x2800, 0x28ff, self.trUtf8("Braille Patterns")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
115 (0x2900, 0x297f, self.trUtf8("Supplement Arcolumns-B")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
116 (0x2980, 0x29ff, self.trUtf8("Miscellaneous Mathematical Symbols-B")),
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
117 (0x2a00, 0x2aff, self.trUtf8("Supplemental Mathematical Operators")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
118 (0x2b00, 0x2bff, self.trUtf8("Miscellaneous Symbols and Arcolumns")),
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
119 (0x2e80, 0x2eff, self.trUtf8("CJK Radicals Supplement")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
120 (0x2f00, 0x2fdf, self.trUtf8("KangXi Radicals")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
121 (0x2ff0, 0x2fff, self.trUtf8("Ideographic Description Chars")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
122 (0x3000, 0x303f, self.trUtf8("CJK Symbols and Punctuation")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
123 (0x3040, 0x309f, self.trUtf8("Hiragana")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
124 (0x30a0, 0x30ff, self.trUtf8("Katakana")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
125 (0x3100, 0x312f, self.trUtf8("Bopomofo")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
126 (0x3130, 0x318f, self.trUtf8("Hangul Compatibility Jamo")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
127 (0x3190, 0x319f, self.trUtf8("Kanbun")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
128 (0x31a0, 0x31bf, self.trUtf8("Bopomofo Extended")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
129 (0x31f0, 0x31ff, self.trUtf8("Katakana Phonetic Extensions")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
130 (0x3200, 0x32ff, self.trUtf8("Enclosed CJK Letters and Months")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
131 (0x3300, 0x33ff, self.trUtf8("CJK Compatibility")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
132 (0x3400, 0x4db5, self.trUtf8("CJK Unified Ideogr. Ext. A")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
133 (0x4dc0, 0x4dff, self.trUtf8("Yijing Hexagram Symbols")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
134 (0x4e00, 0x9fbb, self.trUtf8("CJK Unified Ideographs")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
135 (0xa000, 0xa48f, self.trUtf8("Yi Syllables")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
136 (0xa490, 0xa4cf, self.trUtf8("Yi Radicals")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
137 (0xac00, 0xd7a3, self.trUtf8("Hangul Syllables")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
138 (0xd800, 0xdb7f, self.trUtf8("High Surrogates")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
139 (0xdb80, 0xdbff, self.trUtf8("High Private Use Surrogates")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
140 (0xdc00, 0xdfff, self.trUtf8("Low Surrogates")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
141 (0xe000, 0xf8ff, self.trUtf8("Private Use")),
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
142 (0xf900, 0xfaff, self.trUtf8("CJK Compatibility Ideographs")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
143 (0xfb00, 0xfb4f, self.trUtf8("Alphabetic Presentation Forms")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
144 (0xfb50, 0xfdff, self.trUtf8("Arabic Presentation Forms-A")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
145 (0xfe00, 0xfe0f, self.trUtf8("Variation Selectors")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
146 (0xfe20, 0xfe2f, self.trUtf8("Combining Half Marks")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
147 (0xfe30, 0xfe4f, self.trUtf8("CJK Compatibility Forms")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
148 (0xfe50, 0xfe6f, self.trUtf8("Small Form Variants")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
149 (0xfe70, 0xfefe, self.trUtf8("Arabic Presentation Forms-B")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
150 (0xfeff, 0xfeff, self.trUtf8("Specials")),
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
151 (0xff00, 0xffef, self.trUtf8("Half- and Fullwidth Forms")),
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
152 (0xfff0, 0xffff, self.trUtf8("Specials")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
153 (0x10300, 0x1032f, self.trUtf8("Old Italic")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
154 (0x10330, 0x1034f, self.trUtf8("Gothic")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
155 (0x10400, 0x1044f, self.trUtf8("Deseret")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
156 (0x1d000, 0x1d0ff, self.trUtf8("Byzantine Musical Symbols")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
157 (0x1d100, 0x1d1ff, self.trUtf8("Musical Symbols")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
158 (0x1d400, 0x1d7ff, self.trUtf8("Mathematical Alphanumeric Symbols")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
159 (0x20000, 0x2a6d6, self.trUtf8("CJK Unified Ideogr. Ext. B")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
160 (0x2f800, 0x2fa1f, self.trUtf8("CJK Compatapility Ideogr. Suppl.")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
161 (0xe0000, 0xe007f, self.trUtf8("Tags")),
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
162 )
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
163 self.__currentTableIndex = 0
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
165 def getTableNames(self):
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 """
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
167 Public method to get a list of table names.
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
168
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
169 @return list of table names (list of strings)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
170 """
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
171 return [table[2] for table in self.__tables]
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
172
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
173 def getTableBoundaries(self, index):
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
174 """
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
175 Public method to get the first and last character position
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
176 of the given table.
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
178 @param index index of the character table (integer)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
179 @return first and last character position (integer, integer)
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 """
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
181 return self.__tables[index][0], self.__tables[index][1]
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
182
367
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
183 def getTableIndex(self):
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
184 """
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
185 Private method to get the current table index.
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
186
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
187 @return current table index (integer)
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
188 """
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
189 return self.__currentTableIndex
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
190
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
191 def selectTable(self, index):
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
192 """
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
193 Public method to select the shown character table.
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
194
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
195 @param index index of the character table (integer)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
196 """
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
197 self.__currentTableIndex = index
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 self.reset()
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
200 def headerData(self, section, orientation, role=Qt.DisplayRole):
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 Public method to get header data from the model.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 @param section section number (integer)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 @param orientation orientation (Qt.Orientation)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 @param role role of the data to retrieve (integer)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 @return requested data
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 if orientation == Qt.Horizontal and role == Qt.DisplayRole:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 return self.__headerData[section]
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 return QAbstractTableModel.headerData(self, section, orientation, role)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
214 def data(self, index, role=Qt.DisplayRole):
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 Public method to get data from the model.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 @param index index to get data for (QModelIndex)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 @param role role of the data to retrieve (integer)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 @return requested data
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 """
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
222 id = self.__tables[self.__currentTableIndex][0] + index.row()
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 if role == Qt.DisplayRole:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 col = index.column()
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 if col == 0:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 return str(id)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 elif col == 1:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 return chr(id)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 elif col == 2:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 return "0x{0:04x}".format(id)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 elif col == 3:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 if id in html.entities.codepoint2name:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 return "&{0};".format(html.entities.codepoint2name[id])
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
235 elif col == 4:
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
236 return unicodedata.name(chr(id), '').title()
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 if role == Qt.BackgroundColorRole:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 if index.column() == 0:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 return QColor(Qt.lightGray)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 if role == Qt.TextColorRole:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 char = chr(id)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 if self.__isDigit(char):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 return QColor(Qt.darkBlue)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 elif self.__isLetter(char):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 return QColor(Qt.darkGreen)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 elif self.__isMark(char):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 return QColor(Qt.darkRed)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 elif self.__isSymbol(char):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 return QColor(Qt.black)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 elif self.__isPunct(char):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 return QColor(Qt.darkMagenta)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 else:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 return QColor(Qt.darkGray)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 if role == Qt.TextAlignmentRole:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 if index.column() in [0, 1, 3]:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 return Qt.AlignHCenter
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 return None
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 def columnCount(self, parent):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 Public method to get the number of columns of the model.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 @param parent parent index (QModelIndex)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 @return number of columns (integer)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 if parent.column() > 0:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 return 0
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 else:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 return len(self.__headerData)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 def rowCount(self, parent):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 Public method to get the number of rows of the model.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 @param parent parent index (QModelIndex)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 @return number of columns (integer)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 if parent.isValid():
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 return 0
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 else:
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
285 first, last = self.__tables[self.__currentTableIndex][:2]
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
286 return last - first + 1
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 def __isDigit(self, char):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 Private method to check, if a character is a digit.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 @param char character to test (one character string)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 @return flag indicating a digit (boolean)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 return unicodedata.category(char) == "Nd"
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 def __isLetter(self, char):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 Private method to check, if a character is a letter.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 @param char character to test (one character string)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 @return flag indicating a letter (boolean)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 return unicodedata.category(char) in ["Lu", "Ll", "Lt", "Lm", "Lo"]
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 def __isMark(self, char):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 Private method to check, if a character is a mark character.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 @param char character to test (one character string)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 @return flag indicating a mark character (boolean)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 return unicodedata.category(char) in ["Mn", "Mc", "Me"]
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 def __isSymbol(self, char):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 Private method to check, if a character is a symbol.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 @param char character to test (one character string)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 @return flag indicating a symbol (boolean)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 return unicodedata.category(char) in ["Sm", "Sc", "Sk", "So"]
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 def __isPunct(self, char):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 Private method to check, if a character is a punctuation character.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 @param char character to test (one character string)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 @return flag indicating a punctuation character (boolean)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 return unicodedata.category(char) in ["Pc", "Pd", "Ps", "Pe", "Pi", "Pf", "Po"]
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
333
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 class SymbolsWidget(QWidget, Ui_SymbolsWidget):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 Class implementing a widget to select a symbol in various formats.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 @signal insertSymbol(str) emitted after the user has selected a symbol
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 insertSymbol = pyqtSignal(str)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
342 def __init__(self, parent=None):
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 Constructor
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 @param parent reference to the parent widget (QWidget)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
348 super().__init__(parent)
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 self.setupUi(self)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350
369
64d423a83450 Added code to set the window icon to the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 367
diff changeset
351 self.setWindowIcon(UI.PixmapCache.getIcon("eric.png"))
64d423a83450 Added code to set the window icon to the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 367
diff changeset
352
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 self.__model = SymbolsModel(self)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 self.symbolsTable.setModel(self.__model)
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
355 self.symbolsTable.selectionModel().currentRowChanged.connect(
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
356 self.__currentRowChanged)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
357
2094
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1817
diff changeset
358 if qVersion() >= "5.0.0":
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1817
diff changeset
359 self.symbolsTable.horizontalHeader().setSectionResizeMode(QHeaderView.Fixed)
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1817
diff changeset
360 else:
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1817
diff changeset
361 self.symbolsTable.horizontalHeader().setResizeMode(QHeaderView.Fixed)
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 fm = self.fontMetrics()
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 em = fm.width("M")
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 self.symbolsTable.horizontalHeader().resizeSection(0, em * 5)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 self.symbolsTable.horizontalHeader().resizeSection(1, em * 5)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 self.symbolsTable.horizontalHeader().resizeSection(2, em * 6)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 self.symbolsTable.horizontalHeader().resizeSection(3, em * 8)
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
368 self.symbolsTable.horizontalHeader().resizeSection(4, em * 85)
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 self.symbolsTable.verticalHeader().setDefaultSectionSize(fm.height() + 4)
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
370
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
371 tableIndex = int(Preferences.Prefs.settings.value("Symbols/CurrentTable", 1))
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
372 self.tableCombo.addItems(self.__model.getTableNames())
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
373 self.tableCombo.setCurrentIndex(tableIndex)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
374
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
375 index = self.__model.index(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
376 int(Preferences.Prefs.settings.value("Symbols/Top", 0)),
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
377 0)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
378 self.symbolsTable.scrollTo(index, QAbstractItemView.PositionAtTop)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
379 self.symbolsTable.selectionModel().setCurrentIndex(index,
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
380 QItemSelectionModel.SelectCurrent | QItemSelectionModel.Rows)
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 @pyqtSlot(QModelIndex)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 def on_symbolsTable_activated(self, index):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 Private slot to signal the selection of a symbol.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 @param index index of the selected symbol (QModelIndex)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 txt = self.__model.data(index)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 if txt:
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 self.insertSymbol.emit(txt)
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 @pyqtSlot()
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 def on_symbolSpinBox_editingFinished(self):
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 Private slot to move the table to the entered symbol id.
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 """
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 id = self.symbolSpinBox.value()
367
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
399 first, last = self.__model.getTableBoundaries(self.__model.getTableIndex())
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
400 row = id - first
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
401 self.symbolsTable.selectRow(row)
365
0686ac00256e Added a symbols viewer with capability to insert the selected symbol by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 self.symbolsTable.scrollTo(
367
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
403 self.__model.index(row, 0), QAbstractItemView.PositionAtCenter)
366
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
404
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
405 @pyqtSlot(int)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
406 def on_tableCombo_currentIndexChanged(self, index):
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
407 """
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
408 Private slot to select the current character table.
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
409
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
410 @param index index of the character table (integer)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
411 """
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
412 self.symbolsTable.setUpdatesEnabled(False)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
413 self.__model.selectTable(index)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
414 self.symbolsTable.setUpdatesEnabled(True)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
415
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
416 first, last = self.__model.getTableBoundaries(index)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
417 self.symbolSpinBox.setMinimum(first)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
418 self.symbolSpinBox.setMaximum(last)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
419
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
420 Preferences.Prefs.settings.setValue("Symbols/CurrentTable", index)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
421
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
422 def __currentRowChanged(self, current, previous):
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
423 """
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
424 Private slot recording the currently selected row.
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
425
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
426 @param current current index (QModelIndex)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
427 @param previous previous current index (QModelIndex)
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
428 """
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
429 Preferences.Prefs.settings.setValue("Symbols/Top", current.row())
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
430 self.symbolSpinBox.setValue(int(
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
431 self.__model.data(self.__model.index(current.row(), 0))))

eric ide

mercurial