UI/SymbolsWidget.py

Mon, 25 Mar 2013 10:24:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 25 Mar 2013 10:24:44 +0100
branch
Py2 comp.
changeset 2538
b2642e7a4c18
parent 2526
a91cba8291b9
child 2600
a3feb717c3f0
permissions
-rw-r--r--

Fixed a few PEP-8 related issues.

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
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
10 from __future__ import unicode_literals # __IGNORE_WARNING__
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
11
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
12 import unicodedata
2538
b2642e7a4c18 Fixed a few PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2526
diff changeset
13 try: # Py3
2526
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
14 import html.entities as html_entities
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
15 except (ImportError):
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
16 chr = unichr
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
17 import htmlentitydefs as html_entities # __IGNORE_WARNING__
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
18
2094
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1817
diff changeset
19 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
20 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
21 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
22 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
23
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 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
25
369
64d423a83450 Added code to set the window icon to the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 367
diff changeset
26 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
27 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
28
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
29
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
30 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
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 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
33 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
34 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
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 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
37
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
38 @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
39 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
40 super(SymbolsModel, self).__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
41
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 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
43 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
44 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
45 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
46 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
47 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
48 ]
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
49
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
50 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
51 # 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
52 (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
53 (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
54 (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
55 (0x100, 0x180, self.trUtf8("Latin Extended A")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
56 (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
57 (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
58 (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
59 (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
60 (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
61 (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
62 (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
63 (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
64 (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
65 (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
66 (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
67 (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
68 (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
69 (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
70 (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
71 (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
72 (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
73 (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
74 (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
75 (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
76 (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
77 (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
78 (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
79 (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
80 (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
81 (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
82 (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
83 (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
84 (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
85 (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
86 (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
87 (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
88 (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
89 (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
90 (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
91 (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
92 (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
93 (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
94 (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
95 (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
96 (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
97 (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
98 (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
99 (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
100 (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
101 (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
102 (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
103 (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
104 (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
105 (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
106 (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
107 (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
108 (0x2200, 0x22ff, self.trUtf8("Mathematical Operators")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
109 (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
110 (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
111 (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
112 (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
113 (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
114 (0x2580, 0x259f, self.trUtf8("Block Elements")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
115 (0x25A0, 0x25ff, self.trUtf8("Geometric Shapes")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
116 (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
117 (0x2700, 0x27bf, self.trUtf8("Dingbats")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
118 (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
119 (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
120 (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
121 (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
122 (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
123 (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
124 (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
125 (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
126 (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
127 (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
128 (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
129 (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
130 (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
131 (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
132 (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
133 (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
134 (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
135 (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
136 (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
137 (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
138 (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
139 (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
140 (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
141 (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
142 (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
143 (0xac00, 0xd7a3, self.trUtf8("Hangul Syllables")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
144 (0xd800, 0xdb7f, self.trUtf8("High Surrogates")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
145 (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
146 (0xdc00, 0xdfff, self.trUtf8("Low Surrogates")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
147 (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
148 (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
149 (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
150 (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
151 (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
152 (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
153 (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
154 (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
155 (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
156 (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
157 (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
158 (0xfff0, 0xffff, self.trUtf8("Specials")),
1817
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
159 (0x10300, 0x1032f, self.trUtf8("Old Italic")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
160 (0x10330, 0x1034f, self.trUtf8("Gothic")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
161 (0x10400, 0x1044f, self.trUtf8("Deseret")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
162 (0x1d000, 0x1d0ff, self.trUtf8("Byzantine Musical Symbols")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
163 (0x1d100, 0x1d1ff, self.trUtf8("Musical Symbols")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
164 (0x1d400, 0x1d7ff, self.trUtf8("Mathematical Alphanumeric Symbols")),
cb644326633e Corrected and completed the symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
165 (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
166 (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
167 (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
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 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
170
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
171 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
172 """
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
173 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
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 @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
176 """
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
177 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
178
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 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
180 """
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 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
182 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
183
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
184 @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
185 @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
186 """
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
187 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
188
367
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
189 def getTableIndex(self):
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
190 """
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
191 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
192
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
193 @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
194 """
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
195 return self.__currentTableIndex
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
196
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
197 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
198 """
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
199 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
200
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
201 @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
202 """
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
203 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
204 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
205
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
206 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
207 """
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 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
209
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 @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
211 @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
212 @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
213 @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
214 """
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 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
216 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
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 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
219
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
220 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
221 """
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
222 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
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 @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
225 @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
226 @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
227 """
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
228 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
229
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 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 elif col == 3:
2526
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
239 if id in html_entities.codepoint2name:
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
240 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
241 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
242 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
243
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 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
245 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
246 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
247
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 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260 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
261 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
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 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
264 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
265 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
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 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
268
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 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
270 """
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 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
272
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 @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
274 @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
275 """
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 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
277 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
278 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
279 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
280
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 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
282 """
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 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
284
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
285 @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
286 @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
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 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
289 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
290 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
291 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
292 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
293
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 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
295 """
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 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
297
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 @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
299 @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
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 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
302
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 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
304 """
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 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
306
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 @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
308 @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
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 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
311
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 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
313 """
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 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
315
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 @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
317 @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
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 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
320
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 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
322 """
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 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
324
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 @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
326 @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
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 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
329
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 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
331 """
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 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
333
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 @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
335 @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
336 """
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 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
338
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
339
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
340 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
341 """
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
342 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
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 @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
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 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
347
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
348 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
349 """
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 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
351
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
352 @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
353 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
354 super(SymbolsWidget, self).__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
355 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
356
369
64d423a83450 Added code to set the window icon to the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 367
diff changeset
357 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
358
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
359 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
360 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
361 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
362 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
363
2094
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1817
diff changeset
364 if qVersion() >= "5.0.0":
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1817
diff changeset
365 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
366 else:
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1817
diff changeset
367 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
368 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
369 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
370 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
371 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
372 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
373 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
374 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
375 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
376
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 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
378 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
379 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
380
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
381 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
382 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
383 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
384 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
385 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
386 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
387
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 @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
389 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
390 """
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 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
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 @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
394 """
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 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
396 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
397 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
398
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
399 @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
400 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
401 """
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 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
403 """
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
404 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
405 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
406 row = id - first
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
407 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
408 self.symbolsTable.scrollTo(
367
e66ebdb3b6a2 Corrected a few things in the new symbols widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 366
diff changeset
409 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
410
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 @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
412 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
413 """
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 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
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 @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
417 """
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.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
419 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
420 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
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 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
423 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
424 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
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 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
427
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 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
429 """
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 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
431
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
432 @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
433 @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
434 """
58f2122a5d6a Changed the symbol table to just show characters of a selectable character table.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 365
diff changeset
435 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
436 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
437 self.__model.data(self.__model.index(current.row(), 0))))

eric ide

mercurial