Helpviewer/PersonalInformationManager/PersonalInformationManager.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2525
8b507a9a2d40
parent 3002
6ffc581f00f1
child 3145
a9de05d4a22f
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
2 2
3 # Copyright (c) 2012 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2012 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a personal information manager used to complete form fields. 7 Module implementing a personal information manager used to complete form
8 fields.
8 """ 9 """
9 10
10 from __future__ import unicode_literals # __IGNORE_WARNING__ 11 from __future__ import unicode_literals # __IGNORE_WARNING__
11 12
12 from PyQt4.QtCore import Qt, QObject 13 from PyQt4.QtCore import Qt, QObject
16 import UI.PixmapCache 17 import UI.PixmapCache
17 18
18 19
19 class PersonalInformationManager(QObject): 20 class PersonalInformationManager(QObject):
20 """ 21 """
21 Class implementing the personal information manager used to complete form fields. 22 Class implementing the personal information manager used to complete form
23 fields.
22 """ 24 """
23 FullName = 0 25 FullName = 0
24 LastName = 1 26 LastName = 1
25 FirstName = 2 27 FirstName = 2
26 Email = 3 28 Email = 3
122 """ 124 """
123 Public method to create the personal information sub-menu. 125 Public method to create the personal information sub-menu.
124 126
125 @param menu reference to the main menu (QMenu) 127 @param menu reference to the main menu (QMenu)
126 @param view reference to the view (HelpBrowser) 128 @param view reference to the view (HelpBrowser)
127 @param hitTestResult reference to the hit test result (QWebHitTestResult) 129 @param hitTestResult reference to the hit test result
130 (QWebHitTestResult)
128 """ 131 """
129 self.__view = view 132 self.__view = view
130 self.__element = hitTestResult.element() 133 self.__element = hitTestResult.element()
131 134
132 if not hitTestResult.isContentEditable(): 135 if not hitTestResult.isContentEditable():
138 submenu = QMenu(self.trUtf8("Insert Personal Information"), menu) 141 submenu = QMenu(self.trUtf8("Insert Personal Information"), menu)
139 submenu.setIcon(UI.PixmapCache.getIcon("pim.png")) 142 submenu.setIcon(UI.PixmapCache.getIcon("pim.png"))
140 143
141 for key, info in sorted(self.__allInfo.items()): 144 for key, info in sorted(self.__allInfo.items()):
142 if info: 145 if info:
143 act = submenu.addAction(self.__translations[key], self.__insertData) 146 act = submenu.addAction(
147 self.__translations[key], self.__insertData)
144 act.setData(info) 148 act.setData(info)
145 149
146 submenu.addSeparator() 150 submenu.addSeparator()
147 submenu.addAction(self.trUtf8("Edit Personal Information"), 151 submenu.addAction(self.trUtf8("Edit Personal Information"),
148 self.showConfigurationDialog) 152 self.showConfigurationDialog)
159 return 163 return
160 164
161 info = act.data() 165 info = act.data()
162 info = info.replace('"', '\\"') 166 info = info.replace('"', '\\"')
163 self.__element.evaluateJavaScript( 167 self.__element.evaluateJavaScript(
164 'var newVal = this.value.substring(0, this.selectionStart) + "{0}" +' 168 'var newVal = this.value.substring(0, this.selectionStart) +'
165 ' this.value.substring(this.selectionEnd); this.value = newVal;'.format(info)) 169 ' "{0}" + this.value.substring(this.selectionEnd); this.value ='
170 ' newVal;'.format(info))
166 171
167 def viewKeyPressEvent(self, view, evt): 172 def viewKeyPressEvent(self, view, evt):
168 """ 173 """
169 Public method to handle key press events we are interested in. 174 Public method to handle key press events we are interested in.
170 175
212 217
213 return self.Invalid 218 return self.Invalid
214 219
215 def connectPage(self, page): 220 def connectPage(self, page):
216 """ 221 """
217 Public method to allow the personal information manager to connect to the page. 222 Public method to allow the personal information manager to connect to
223 the page.
218 224
219 @param page reference to the web page (HelpWebPage) 225 @param page reference to the web page (HelpWebPage)
220 """ 226 """
221 page.loadFinished.connect(self.__pageLoadFinished) 227 page.loadFinished.connect(self.__pageLoadFinished)
222 228

eric ide

mercurial