src/eric7/WebBrowser/PersonalInformationManager/PersonalInformationManager.py

branch
eric7
changeset 10485
287a3ae95e00
parent 10475
ee41fab001f2
child 11090
f5f5f5803935
equal deleted inserted replaced
10484:ad7a6d699a0d 10485:287a3ae95e00
6 """ 6 """
7 Module implementing a personal information manager used to complete form 7 Module implementing a personal information manager used to complete form
8 fields. 8 fields.
9 """ 9 """
10 10
11 import enum
11 import functools 12 import functools
12 13
13 from PyQt6.QtCore import QObject, QPoint, Qt 14 from PyQt6.QtCore import QObject, QPoint, Qt
14 from PyQt6.QtWidgets import QDialog, QMenu 15 from PyQt6.QtWidgets import QDialog, QMenu
15 16
17 from eric7.EricGui import EricPixmapCache 18 from eric7.EricGui import EricPixmapCache
18 19
19 from ..WebBrowserPage import WebBrowserPage 20 from ..WebBrowserPage import WebBrowserPage
20 21
21 22
22 class PersonalInformationManager(QObject): 23 class PersonalInformationType(enum.Enum):
23 """ 24 """
24 Class implementing the personal information manager used to complete form 25 Class defining the personal information types.
25 fields.
26 """ 26 """
27 27
28 # TODO: change this to an enum
29 FullName = 0 28 FullName = 0
30 LastName = 1 29 LastName = 1
31 FirstName = 2 30 FirstName = 2
32 Email = 3 31 Email = 3
33 Mobile = 4 32 Mobile = 4
40 HomePage = 11 39 HomePage = 11
41 Special1 = 12 40 Special1 = 12
42 Special2 = 13 41 Special2 = 13
43 Special3 = 14 42 Special3 = 14
44 Special4 = 15 43 Special4 = 15
44
45 Max = 16 45 Max = 16
46 Invalid = 256 46 Invalid = 256
47
48
49 class PersonalInformationManager(QObject):
50 """
51 Class implementing the personal information manager used to complete form
52 fields.
53 """
47 54
48 def __init__(self, parent=None): 55 def __init__(self, parent=None):
49 """ 56 """
50 Constructor 57 Constructor
51 58
64 71
65 def __loadSettings(self): 72 def __loadSettings(self):
66 """ 73 """
67 Private method to load the settings. 74 Private method to load the settings.
68 """ 75 """
69 self.__allInfo[self.FullName] = Preferences.getWebBrowser("PimFullName") 76 self.__allInfo[PersonalInformationType.FullName] = Preferences.getWebBrowser(
70 self.__allInfo[self.LastName] = Preferences.getWebBrowser("PimLastName") 77 "PimFullName"
71 self.__allInfo[self.FirstName] = Preferences.getWebBrowser("PimFirstName") 78 )
72 self.__allInfo[self.Email] = Preferences.getWebBrowser("PimEmail") 79 self.__allInfo[PersonalInformationType.LastName] = Preferences.getWebBrowser(
73 self.__allInfo[self.Mobile] = Preferences.getWebBrowser("PimMobile") 80 "PimLastName"
74 self.__allInfo[self.Phone] = Preferences.getWebBrowser("PimPhone") 81 )
75 self.__allInfo[self.Address] = Preferences.getWebBrowser("PimAddress") 82 self.__allInfo[PersonalInformationType.FirstName] = Preferences.getWebBrowser(
76 self.__allInfo[self.City] = Preferences.getWebBrowser("PimCity") 83 "PimFirstName"
77 self.__allInfo[self.Zip] = Preferences.getWebBrowser("PimZip") 84 )
78 self.__allInfo[self.State] = Preferences.getWebBrowser("PimState") 85 self.__allInfo[PersonalInformationType.Email] = Preferences.getWebBrowser(
79 self.__allInfo[self.Country] = Preferences.getWebBrowser("PimCountry") 86 "PimEmail"
80 self.__allInfo[self.HomePage] = Preferences.getWebBrowser("PimHomePage") 87 )
81 self.__allInfo[self.Special1] = Preferences.getWebBrowser("PimSpecial1") 88 self.__allInfo[PersonalInformationType.Mobile] = Preferences.getWebBrowser(
82 self.__allInfo[self.Special2] = Preferences.getWebBrowser("PimSpecial2") 89 "PimMobile"
83 self.__allInfo[self.Special3] = Preferences.getWebBrowser("PimSpecial3") 90 )
84 self.__allInfo[self.Special4] = Preferences.getWebBrowser("PimSpecial4") 91 self.__allInfo[PersonalInformationType.Phone] = Preferences.getWebBrowser(
85 92 "PimPhone"
86 self.__translations[self.FullName] = self.tr("Full Name") 93 )
87 self.__translations[self.LastName] = self.tr("Last Name") 94 self.__allInfo[PersonalInformationType.Address] = Preferences.getWebBrowser(
88 self.__translations[self.FirstName] = self.tr("First Name") 95 "PimAddress"
89 self.__translations[self.Email] = self.tr("E-mail") 96 )
90 self.__translations[self.Mobile] = self.tr("Mobile") 97 self.__allInfo[PersonalInformationType.City] = Preferences.getWebBrowser(
91 self.__translations[self.Phone] = self.tr("Phone") 98 "PimCity"
92 self.__translations[self.Address] = self.tr("Address") 99 )
93 self.__translations[self.City] = self.tr("City") 100 self.__allInfo[PersonalInformationType.Zip] = Preferences.getWebBrowser(
94 self.__translations[self.Zip] = self.tr("ZIP Code") 101 "PimZip"
95 self.__translations[self.State] = self.tr("State/Region") 102 )
96 self.__translations[self.Country] = self.tr("Country") 103 self.__allInfo[PersonalInformationType.State] = Preferences.getWebBrowser(
97 self.__translations[self.HomePage] = self.tr("Home Page") 104 "PimState"
98 self.__translations[self.Special1] = self.tr("Custom 1") 105 )
99 self.__translations[self.Special2] = self.tr("Custom 2") 106 self.__allInfo[PersonalInformationType.Country] = Preferences.getWebBrowser(
100 self.__translations[self.Special3] = self.tr("Custom 3") 107 "PimCountry"
101 self.__translations[self.Special4] = self.tr("Custom 4") 108 )
102 109 self.__allInfo[PersonalInformationType.HomePage] = Preferences.getWebBrowser(
103 self.__infoMatches[self.FullName] = ["fullname", "realname"] 110 "PimHomePage"
104 self.__infoMatches[self.LastName] = ["lastname", "surname"] 111 )
105 self.__infoMatches[self.FirstName] = ["firstname", "name"] 112 self.__allInfo[PersonalInformationType.Special1] = Preferences.getWebBrowser(
106 self.__infoMatches[self.Email] = ["email", "e-mail", "mail"] 113 "PimSpecial1"
107 self.__infoMatches[self.Mobile] = ["mobile", "mobilephone"] 114 )
108 self.__infoMatches[self.Phone] = ["phone", "telephone"] 115 self.__allInfo[PersonalInformationType.Special2] = Preferences.getWebBrowser(
109 self.__infoMatches[self.Address] = ["address"] 116 "PimSpecial2"
110 self.__infoMatches[self.City] = ["city"] 117 )
111 self.__infoMatches[self.Zip] = ["zip"] 118 self.__allInfo[PersonalInformationType.Special3] = Preferences.getWebBrowser(
112 self.__infoMatches[self.State] = ["state", "region"] 119 "PimSpecial3"
113 self.__infoMatches[self.Country] = ["country"] 120 )
114 self.__infoMatches[self.HomePage] = ["homepage", "www"] 121 self.__allInfo[PersonalInformationType.Special4] = Preferences.getWebBrowser(
122 "PimSpecial4"
123 )
124
125 self.__translations[PersonalInformationType.FullName] = self.tr("Full Name")
126 self.__translations[PersonalInformationType.LastName] = self.tr("Last Name")
127 self.__translations[PersonalInformationType.FirstName] = self.tr("First Name")
128 self.__translations[PersonalInformationType.Email] = self.tr("E-mail")
129 self.__translations[PersonalInformationType.Mobile] = self.tr("Mobile")
130 self.__translations[PersonalInformationType.Phone] = self.tr("Phone")
131 self.__translations[PersonalInformationType.Address] = self.tr("Address")
132 self.__translations[PersonalInformationType.City] = self.tr("City")
133 self.__translations[PersonalInformationType.Zip] = self.tr("ZIP Code")
134 self.__translations[PersonalInformationType.State] = self.tr("State/Region")
135 self.__translations[PersonalInformationType.Country] = self.tr("Country")
136 self.__translations[PersonalInformationType.HomePage] = self.tr("Home Page")
137 self.__translations[PersonalInformationType.Special1] = self.tr("Custom 1")
138 self.__translations[PersonalInformationType.Special2] = self.tr("Custom 2")
139 self.__translations[PersonalInformationType.Special3] = self.tr("Custom 3")
140 self.__translations[PersonalInformationType.Special4] = self.tr("Custom 4")
141
142 self.__infoMatches[PersonalInformationType.FullName] = ["fullname", "realname"]
143 self.__infoMatches[PersonalInformationType.LastName] = ["lastname", "surname"]
144 self.__infoMatches[PersonalInformationType.FirstName] = ["firstname", "name"]
145 self.__infoMatches[PersonalInformationType.Email] = ["email", "e-mail", "mail"]
146 self.__infoMatches[PersonalInformationType.Mobile] = ["mobile", "mobilephone"]
147 self.__infoMatches[PersonalInformationType.Phone] = ["phone", "telephone"]
148 self.__infoMatches[PersonalInformationType.Address] = ["address"]
149 self.__infoMatches[PersonalInformationType.City] = ["city"]
150 self.__infoMatches[PersonalInformationType.Zip] = ["zip"]
151 self.__infoMatches[PersonalInformationType.State] = ["state", "region"]
152 self.__infoMatches[PersonalInformationType.Country] = ["country"]
153 self.__infoMatches[PersonalInformationType.HomePage] = ["homepage", "www"]
115 154
116 self.__loaded = True 155 self.__loaded = True
117 156
118 def showConfigurationDialog(self, parent=None): 157 def showConfigurationDialog(self, parent=None):
119 """ 158 """

eric ide

mercurial