Continued removing the use of QObject.sender().

Tue, 06 Feb 2018 19:18:43 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 06 Feb 2018 19:18:43 +0100
changeset 6118
da9e08920e7c
parent 6117
4cc6c171ecf6
child 6119
18fb5d765f3a

Continued removing the use of QObject.sender().

Helpviewer/AdBlock/AdBlockSubscription.py file | annotate | diff | comparison | revisions
Helpviewer/Bookmarks/BookmarksMenu.py file | annotate | diff | comparison | revisions
Helpviewer/Bookmarks/BookmarksToolBar.py file | annotate | diff | comparison | revisions
Helpviewer/CookieJar/CookiesDialog.py file | annotate | diff | comparison | revisions
Helpviewer/Download/DownloadManager.py file | annotate | diff | comparison | revisions
Helpviewer/Feeds/FeedsDialog.py file | annotate | diff | comparison | revisions
Helpviewer/Feeds/FeedsManager.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
ViewManager/ViewManager.py file | annotate | diff | comparison | revisions
WebBrowser/AdBlock/AdBlockSubscription.py file | annotate | diff | comparison | revisions
WebBrowser/Bookmarks/BookmarksMenu.py file | annotate | diff | comparison | revisions
WebBrowser/Bookmarks/BookmarksToolBar.py file | annotate | diff | comparison | revisions
WebBrowser/Download/DownloadManager.py file | annotate | diff | comparison | revisions
WebBrowser/Feeds/FeedsDialog.py file | annotate | diff | comparison | revisions
WebBrowser/Feeds/FeedsManager.py file | annotate | diff | comparison | revisions
WebBrowser/PersonalInformationManager/PersonalInformationManager.py file | annotate | diff | comparison | revisions
--- a/Helpviewer/AdBlock/AdBlockSubscription.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/Helpviewer/AdBlock/AdBlockSubscription.py	Tue Feb 06 19:18:43 2018 +0100
@@ -394,14 +394,16 @@
         self.__downloading = FollowRedirectReply(
             self.location(),
             Helpviewer.HelpWindow.HelpWindow.networkAccessManager())
-        self.__downloading.finished.connect(self.__rulesDownloaded)
+        self.__downloading.finished.connect(
+            lambda: self.__rulesDownloaded(self.__downloading))
     
-    def __rulesDownloaded(self):
+    def __rulesDownloaded(self, reply):
         """
         Private slot to deal with the downloaded rules.
+        
+        @param reply reference to the network reply
+        @type QNetworkReply
         """
-        reply = self.sender()
-        
         response = reply.readAll()
         reply.close()
         self.__downloading = None
--- a/Helpviewer/Bookmarks/BookmarksMenu.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/Helpviewer/Bookmarks/BookmarksMenu.py	Tue Feb 06 19:18:43 2018 +0100
@@ -96,13 +96,16 @@
         
         self.addSeparator()
         act = self.addAction(self.tr("Open all in Tabs"))
-        act.triggered.connect(self.openAll)
+        act.triggered.connect(lambda: self.openAll(act))
     
-    def openAll(self):
+    def openAll(self, act):
         """
         Public slot to open all the menu's items.
+        
+        @param act reference to the action object
+        @type QAction
         """
-        menu = self.sender().parent()
+        menu = act.parent()
         if menu is None:
             return
         
@@ -139,23 +142,24 @@
             menu = QMenu()
             v = act.data()
             
-            menuAction = menu.addAction(
-                self.tr("&Open"), self.__openBookmark)
-            menuAction.setData(v)
-            menuAction = menu.addAction(
-                self.tr("Open in New &Tab\tCtrl+LMB"),
-                self.__openBookmarkInNewTab)
-            menuAction.setData(v)
+            act2 = menu.addAction(self.tr("Open"))
+            act2.setData(v)
+            act2.triggered.connect(
+                lambda: self.__openBookmark(act2))
+            act2 = menu.addAction(self.tr("Open in New Tab\tCtrl+LMB"))
+            act2.setData(v)
+            act2.triggered.connect(
+                lambda: self.__openBookmarkInNewTab(act2))
             menu.addSeparator()
             
-            menuAction = menu.addAction(
-                self.tr("&Remove"), self.__removeBookmark)
-            menuAction.setData(v)
+            act2 = menu.addAction(self.tr("Remove"))
+            act2.setData(v)
+            act2.triggered.connect(lambda: self.__removeBookmark(act2))
             menu.addSeparator()
             
-            menuAction = menu.addAction(
-                self.tr("&Properties..."), self.__edit)
-            menuAction.setData(v)
+            act2 = menu.addAction(self.tr("Properties..."))
+            act2.setData(v)
+            act2.triggered.connect(lambda: self.__edit(act2))
             
             execAct = menu.exec_(QCursor.pos())
             if execAct is not None:
@@ -165,40 +169,52 @@
                     parent.close()
                     parent = parent.parent()
     
-    def __openBookmark(self):
+    def __openBookmark(self, act):
         """
         Private slot to open a bookmark in the current browser tab.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         
         self.openUrl.emit(
             idx.data(BookmarksModel.UrlRole),
             idx.data(Qt.DisplayRole))
     
-    def __openBookmarkInNewTab(self):
+    def __openBookmarkInNewTab(self, act):
         """
         Private slot to open a bookmark in a new browser tab.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         
         self.newUrl.emit(
             idx.data(BookmarksModel.UrlRole),
             idx.data(Qt.DisplayRole))
     
-    def __removeBookmark(self):
+    def __removeBookmark(self, act):
         """
         Private slot to remove a bookmark.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         self.removeEntry(idx)
     
-    def __edit(self):
+    def __edit(self, act):
         """
         Private slot to edit a bookmarks properties.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
         from .BookmarkPropertiesDialog import BookmarkPropertiesDialog
         
-        idx = self.index(self.sender())
+        idx = self.index(act)
         node = self.model().node(idx)
         dlg = BookmarkPropertiesDialog(node)
         dlg.exec_()
@@ -279,13 +295,15 @@
         self.addSeparator()
         act = self.addAction(self.tr("Default Home Page"))
         act.setData("eric:home")
-        act.triggered.connect(self.__defaultBookmarkTriggered)
+        act.triggered.connect(
+            lambda: self.__defaultBookmarkTriggered(act))
         act = self.addAction(self.tr("Speed Dial"))
         act.setData("eric:speeddial")
-        act.triggered.connect(self.__defaultBookmarkTriggered)
+        act.triggered.connect(
+            lambda: self.__defaultBookmarkTriggered(act))
         self.addSeparator()
         act = self.addAction(self.tr("Open all in Tabs"))
-        act.triggered.connect(self.openAll)
+        act.triggered.connect(lambda: self.openAll(act))
     
     def setInitialActions(self, actions):
         """
@@ -298,11 +316,13 @@
         for act in self.__initialActions:
             self.addAction(act)
     
-    def __defaultBookmarkTriggered(self):
+    def __defaultBookmarkTriggered(self, act):
         """
         Private slot handling the default bookmark menu entries.
+        
+        @param act reference to the action object
+        @type QAction
         """
-        act = self.sender()
         urlStr = act.data()
         if urlStr.startswith("eric:"):
             self.openUrl.emit(QUrl(urlStr), "")
--- a/Helpviewer/Bookmarks/BookmarksToolBar.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/Helpviewer/Bookmarks/BookmarksToolBar.py	Tue Feb 06 19:18:43 2018 +0100
@@ -87,23 +87,24 @@
             v = act.data()
             
             if act.menu() is None:
-                menuAction = menu.addAction(
-                    self.tr("&Open"), self.__openBookmark)
-                menuAction.setData(v)
-                menuAction = menu.addAction(
-                    self.tr("Open in New &Tab\tCtrl+LMB"),
-                    self.__openBookmarkInNewTab)
-                menuAction.setData(v)
+                act2 = menu.addAction(self.tr("Open"))
+                act2.setData(v)
+                act2.triggered.connect(
+                    lambda: self.__openBookmark(act2))
+                act2 = menu.addAction(self.tr("Open in New Tab\tCtrl+LMB"))
+                act2.setData(v)
+                act2.triggered.connect(
+                    lambda: self.__openBookmarkInNewTab(act2))
                 menu.addSeparator()
             
-            menuAction = menu.addAction(
-                self.tr("&Remove"), self.__removeBookmark)
-            menuAction.setData(v)
+            act2 = menu.addAction(self.tr("Remove"))
+            act2.setData(v)
+            act2.triggered.connect(lambda: self.__removeBookmark(act2))
             menu.addSeparator()
             
-            menuAction = menu.addAction(
-                self.tr("&Properties..."), self.__edit)
-            menuAction.setData(v)
+            act2 = menu.addAction(self.tr("Properties..."))
+            act2.setData(v)
+            act2.triggered.connect(lambda: self.__edit(act2))
             menu.addSeparator()
         
         menu.addAction(self.tr("Add &Bookmark..."), self.__newBookmark)
@@ -133,47 +134,40 @@
                     idx.data(BookmarksModel.UrlRole),
                     idx.data(Qt.DisplayRole))
     
-    def __openToolBarBookmark(self):
+    def __openBookmark(self, act):
         """
         Private slot to open a bookmark in the current browser tab.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
-        
-        if self._keyboardModifiers & Qt.ControlModifier:
-            self.newUrl.emit(
-                idx.data(BookmarksModel.UrlRole),
-                idx.data(Qt.DisplayRole))
-        else:
-            self.openUrl.emit(
-                idx.data(BookmarksModel.UrlRole),
-                idx.data(Qt.DisplayRole))
-        self.resetFlags()
-    
-    def __openBookmark(self):
-        """
-        Private slot to open a bookmark in the current browser tab.
-        """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         
         self.openUrl.emit(
             idx.data(BookmarksModel.UrlRole),
             idx.data(Qt.DisplayRole))
     
-    def __openBookmarkInNewTab(self):
+    def __openBookmarkInNewTab(self, act):
         """
         Private slot to open a bookmark in a new browser tab.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         
         self.newUrl.emit(
             idx.data(BookmarksModel.UrlRole),
             idx.data(Qt.DisplayRole))
     
-    def __removeBookmark(self):
+    def __removeBookmark(self, act):
         """
         Private slot to remove a bookmark.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         
         self.__bookmarksModel.removeRow(idx.row(), self.rootIndex())
     
@@ -208,12 +202,15 @@
         menu.newUrl.connect(self.newUrl)
         return menu
     
-    def __edit(self):
+    def __edit(self, act):
         """
         Private slot to edit a bookmarks properties.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
         from .BookmarkPropertiesDialog import BookmarkPropertiesDialog
-        idx = self.index(self.sender())
+        idx = self.index(act)
         node = self.__bookmarksModel.node(idx)
         dlg = BookmarkPropertiesDialog(node)
         dlg.exec_()
--- a/Helpviewer/CookieJar/CookiesDialog.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/Helpviewer/CookieJar/CookiesDialog.py	Tue Feb 06 19:18:43 2018 +0100
@@ -85,11 +85,7 @@
         if not index.isValid():
             return
         
-        cookiesTable = self.sender()
-        if cookiesTable is None:
-            return
-        
-        model = cookiesTable.model()
+        model = self.cookiesTable.model()
         row = index.row()
         
         domain = model.data(model.index(row, 0))
--- a/Helpviewer/Download/DownloadManager.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/Helpviewer/Download/DownloadManager.py	Tue Feb 06 19:18:43 2018 +0100
@@ -231,7 +231,7 @@
         @param append flag indicating to append the item
         @type bool
         """
-        itm.statusChanged.connect(self.__updateRow)
+        itm.statusChanged.connect(lambda: self.__updateRow(itm))
         itm.downloadFinished.connect(self.__finished)
         
         # insert at top of window
@@ -256,15 +256,13 @@
         self.changeOccurred()
         self.__updateActiveItemCount()
     
-    def __updateRow(self, itm=None):
+    def __updateRow(self, itm):
         """
         Private slot to update a download item.
         
-        @param itm reference to the download item (DownloadItem)
+        @param itm reference to the download item
+        @type DownloadItem
         """
-        if itm is None:
-            itm = self.sender()
-        
         if itm not in self.__downloads:
             return
         
--- a/Helpviewer/Feeds/FeedsDialog.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/Helpviewer/Feeds/FeedsDialog.py	Tue Feb 06 19:18:43 2018 +0100
@@ -49,16 +49,18 @@
             label.setText(feed[0])
             self.feedsLayout.addWidget(label, row, 0)
             self.feedsLayout.addWidget(button, row, 1)
-            button.clicked.connect(self.__addFeed)
+            button.clicked.connect(lambda: self.__addFeed(button))
         
         msh = self.minimumSizeHint()
         self.resize(max(self.width(), msh.width()), msh.height())
     
-    def __addFeed(self):
+    def __addFeed(self, button):
         """
         Private slot to add a RSS feed.
+        
+        @param button reference to the feed button
+        @type QPushButton
         """
-        button = self.sender()
         urlString = button.feed[1]
         url = QUrl(urlString)
         if not url.host():
--- a/Helpviewer/Feeds/FeedsManager.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/Helpviewer/Feeds/FeedsManager.py	Tue Feb 06 19:18:43 2018 +0100
@@ -264,14 +264,16 @@
         request = QNetworkRequest(QUrl(urlString))
         reply = Helpviewer.HelpWindow.HelpWindow.networkAccessManager()\
             .get(request)
-        reply.finished.connect(self.__feedLoaded)
+        reply.finished.connect(lambda: self.__feedLoaded(reply))
         self.__replies[id(reply)] = (reply, itm)
     
-    def __feedLoaded(self):
+    def __feedLoaded(self, reply):
         """
         Private slot to extract the loaded feed data.
+        
+        @param reply reference to the network reply
+        @type QNetworkReply
         """
-        reply = self.sender()
         if id(reply) not in self.__replies:
             return
         
--- a/UI/UserInterface.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/UI/UserInterface.py	Tue Feb 06 19:18:43 2018 +0100
@@ -485,7 +485,8 @@
         self.viewmanager.editorRenamed.connect(self.__writeCrashSession)
         self.viewmanager.editorChanged.connect(self.__writeCrashSession)
         
-        self.shell.zoomValueChanged.connect(self.viewmanager.zoomValueChanged)
+        self.shell.zoomValueChanged.connect(
+            lambda v: self.viewmanager.zoomValueChanged(v, self.shell))
         
         self.cooperation.shareEditor.connect(self.viewmanager.shareEditor)
         self.cooperation.startEdit.connect(self.viewmanager.startSharedEdit)
@@ -3021,7 +3022,8 @@
                                   tool['menutext'], self)
                     act.setObjectName("{0}@@{1}".format(toolGroup[0],
                                       tool['menutext']))
-                    act.triggered.connect(self.__toolActionTriggered)
+                    act.triggered.connect(
+                        lambda: self.__toolActionTriggered(act))
                     self.toolGroupActions[act.objectName()] = act
                     
                     self.toolbarManager.addAction(act, category)
@@ -3049,8 +3051,7 @@
         for key in groupActionKeys:
             if key not in ckeys:
                 self.toolbarManager.removeAction(self.toolGroupActions[key])
-                self.toolGroupActions[key].triggered.disconnect(
-                    self.__toolActionTriggered)
+                self.toolGroupActions[key].triggered.disconnect()
                 del self.toolGroupActions[key]
         
         # step 4: add all newly configured tools
@@ -3062,7 +3063,8 @@
                     act = QAction(UI.PixmapCache.getIcon(tool['icon']),
                                   tool['menutext'], self)
                     act.setObjectName(key)
-                    act.triggered.connect(self.__toolActionTriggered)
+                    act.triggered.connect(
+                        lambda: self.__toolActionTriggered(act))
                     self.toolGroupActions[key] = act
                     
                     self.toolbarManager.addAction(act, category)
@@ -4822,11 +4824,13 @@
                     'Ensure that it is available as <b>{0}</b>.</p>'
                 ).format(snap))
         
-    def __toolActionTriggered(self):
+    def __toolActionTriggered(self, act):
         """
         Private slot called by external tools toolbar actions.
-        """
-        act = self.sender()
+        
+        @param act reference to the action that triggered the slot
+        @type QAction
+        """
         toolGroupName, toolMenuText = act.objectName().split('@@', 1)
         for toolGroup in self.toolGroups:
             if toolGroup[0] == toolGroupName:
@@ -6463,7 +6467,7 @@
             request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
                                  QNetworkRequest.AlwaysNetwork)
             reply = self.__networkManager.get(request)
-            reply.finished.connect(self.__versionsDownloadDone)
+            reply.finished.connect(lambda: self.__versionsDownloadDone(reply))
             self.__replies.append(reply)
         else:
             if manual:
@@ -6475,10 +6479,13 @@
                             """ Please go online and try again."""))
         
     @pyqtSlot()
-    def __versionsDownloadDone(self):
+    def __versionsDownloadDone(self, reply):
         """
         Private slot called, after the versions file has been downloaded
         from the internet.
+        
+        @param reply reference to the network reply
+        @type QNetworkReply
         """
         if self.__versionCheckCanceled:
             self.__inVersionCheck = False
@@ -6487,14 +6494,6 @@
                 self.__versionCheckProgress = None
             return
         
-        reply = self.sender()
-        
-        # This is a hack because sometimes reply is not a QNetworkReply
-        if not isinstance(reply, QNetworkReply):
-            if reply in self.__replies:
-                self.__replies.remove(reply)
-            return
-        
         reply.deleteLater()
         if reply in self.__replies:
             self.__replies.remove(reply)
--- a/ViewManager/ViewManager.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/ViewManager/ViewManager.py	Tue Feb 06 19:18:43 2018 +0100
@@ -4642,22 +4642,28 @@
         """
         editor.modificationStatusChanged.connect(
             self._modificationStatusChanged)
-        editor.cursorChanged.connect(self.__cursorChanged)
-        editor.editorSaved.connect(self.__editorSaved)
-        editor.editorRenamed.connect(self.__editorRenamed)
+        editor.cursorChanged.connect(
+            lambda f, l, p: self.__cursorChanged(f, l, p, editor))
+        editor.editorSaved.connect(
+            lambda fn: self.__editorSaved(fn, editor))
+        editor.editorRenamed.connect(
+            lambda fn: self.__editorRenamed(fn, editor))
         editor.breakpointToggled.connect(self.__breakpointToggled)
         editor.bookmarkToggled.connect(self.__bookmarkToggled)
         editor.syntaxerrorToggled.connect(self._syntaxErrorToggled)
         editor.coverageMarkersShown.connect(self.__coverageMarkersShown)
         editor.autoCompletionAPIsAvailable.connect(
-            self.__editorAutoCompletionAPIsAvailable)
+            lambda a: self.__editorAutoCompletionAPIsAvailable(a, editor))
         editor.undoAvailable.connect(self.undoAct.setEnabled)
         editor.redoAvailable.connect(self.redoAct.setEnabled)
         editor.taskMarkersUpdated.connect(self.__taskMarkersUpdated)
         editor.changeMarkersUpdated.connect(self.__changeMarkersUpdated)
-        editor.languageChanged.connect(self.__editorConfigChanged)
-        editor.eolChanged.connect(self.__editorConfigChanged)
-        editor.encodingChanged.connect(self.__editorConfigChanged)
+        editor.languageChanged.connect(
+            lambda: self.__editorConfigChanged(editor))
+        editor.eolChanged.connect(
+            lambda: self.__editorConfigChanged(editor))
+        editor.encodingChanged.connect(
+            lambda: self.__editorConfigChanged(editor))
         editor.selectionChanged.connect(
             lambda: self.__searchWidget.selectionChanged(editor))
         editor.selectionChanged.connect(
@@ -4666,7 +4672,8 @@
             lambda: self.__editorSelectionChanged(editor))
         editor.lastEditPositionAvailable.connect(
             self.__lastEditPositionAvailable)
-        editor.zoomValueChanged.connect(self.zoomValueChanged)
+        editor.zoomValueChanged.connect(
+            lambda v: self.zoomValueChanged(v, editor))
         
         editor.languageChanged.connect(
             lambda: self.editorLanguageChanged.emit(editor))
@@ -5527,14 +5534,16 @@
         """
         self.activeWindow().autoCompleteFromAll()
         
-    def __editorAutoCompletionAPIsAvailable(self, available):
+    def __editorAutoCompletionAPIsAvailable(self, available, editor):
         """
         Private method to handle the availability of API autocompletion signal.
         
         @param available flag indicating the availability of API
-        autocompletion (boolean)
-        """
-        editor = self.sender()
+            autocompletion
+        @type bool
+        @param editor reference to the editor
+        @type Editor
+        """
         self.autoCompleteAct.setEnabled(
             editor.canProvideDynamicAutoCompletion())
         self.autoCompleteFromAPIsAct.setEnabled(available)
@@ -5985,17 +5994,20 @@
             aw.zoomTo(value)
             self.sbZoom.setValue(aw.getZoom())
         
-    def zoomValueChanged(self, value):
+    def zoomValueChanged(self, value, zoomingWidget):
         """
         Public slot to handle changes of the zoom value.
         
-        @param value new zoom value (integer)
+        @param value new zoom value
+        @type int
+        @param zoomingWidget reference to the widget triggering the slot
+        @type Editor or Shell
         """
         if QApplication.focusWidget() == e5App().getObject("Shell"):
             aw = e5App().getObject("Shell")
         else:
             aw = self.activeWindow()
-        if aw and aw == self.sender():
+        if aw and aw == zoomingWidget:
             self.sbZoom.setValue(value)
     
     def __clearAllFolds(self):
@@ -6770,54 +6782,52 @@
         
         self.__enableSpellingActions()
         
-    def __editorSaved(self, fn):
+    def __editorSaved(self, fn, editor):
         """
         Private slot to handle the editorSaved signal.
         
-        It simply reemits the signal.
-        
-        @param fn filename of the saved editor (string)
+        It simply re-emits the signal.
+        
+        @param fn filename of the saved editor
+        @type str
+        @param editor reference to the editor
+        @type Editor
         """
         self.editorSaved.emit(fn)
-        editor = self.sender()
-        if editor:
-            self.editorSavedEd.emit(editor)
-        
-    def __editorRenamed(self, fn):
+        self.editorSavedEd.emit(editor)
+        
+    def __editorRenamed(self, fn, editor):
         """
         Private slot to handle the editorRenamed signal.
         
-        It simply reemits the signal.
-        
-        @param fn filename of the renamed editor (string)
+        It simply re-emits the signal.
+        
+        @param fn filename of the renamed editor
+        @type str
+        @param editor reference to the editor
+        @type Editor
         """
         self.editorRenamed.emit(fn)
-        editor = self.sender()
-        if editor:
-            self.editorRenamedEd.emit(editor)
-        
-    def __cursorChanged(self, fn, line, pos):
+        self.editorRenamedEd.emit(editor)
+        
+    def __cursorChanged(self, fn, line, pos, editor):
         """
         Private slot to handle the cursorChanged signal.
         
         It emits the signal cursorChanged with parameter editor.
         
-        @param fn filename (string)
-        @param line line number of the cursor (int)
-        @param pos position in line of the cursor (int)
-        """
-        editor = self.getOpenEditor(fn)
-        if editor is None:
-            editor = self.sender()
-        
-        if editor is not None:
-            enc = editor.getEncoding()
-            lang = editor.getLanguage()
-            eol = editor.getEolIndicator()
-        else:
-            enc = None
-            lang = None
-            eol = None
+        @param fn filename
+        @type str
+        @param line line number of the cursor
+        @type int
+        @param pos position in line of the cursor
+        @type int
+        @param editor reference to the editor
+        @type Editor
+        """
+        enc = editor.getEncoding()
+        lang = editor.getLanguage()
+        eol = editor.getEolIndicator()
         self.__setSbFile(fn, line, pos, enc, lang, eol)
         self.cursorChanged.emit(editor)
         
@@ -6875,11 +6885,13 @@
             if aw:
                 aw.newLineBelow()
         
-    def __editorConfigChanged(self):
+    def __editorConfigChanged(self, editor):
         """
         Private slot to handle changes of an editor's configuration.
-        """
-        editor = self.sender()
+        
+        @param editor reference to the editor
+        @type Editor
+        """
         fn = editor.getFileName()
         line, pos = editor.getCursorPosition()
         enc = editor.getEncoding()
--- a/WebBrowser/AdBlock/AdBlockSubscription.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/WebBrowser/AdBlock/AdBlockSubscription.py	Tue Feb 06 19:18:43 2018 +0100
@@ -370,14 +370,16 @@
         from WebBrowser.WebBrowserWindow import WebBrowserWindow
         self.__downloading = WebBrowserWindow.networkManager().get(
             QNetworkRequest(self.location()))
-        self.__downloading.finished.connect(self.__rulesDownloaded)
+        self.__downloading.finished.connect(
+            lambda: self.__rulesDownloaded(self.__downloading))
     
-    def __rulesDownloaded(self):
+    def __rulesDownloaded(self, reply):
         """
         Private slot to deal with the downloaded rules.
+        
+        @param reply reference to the network reply
+        @type QNetworkReply
         """
-        reply = self.sender()
-        
         response = reply.readAll()
         reply.close()
         self.__downloading = None
--- a/WebBrowser/Bookmarks/BookmarksMenu.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/WebBrowser/Bookmarks/BookmarksMenu.py	Tue Feb 06 19:18:43 2018 +0100
@@ -116,13 +116,16 @@
         
         self.addSeparator()
         act = self.addAction(self.tr("Open all in Tabs"))
-        act.triggered.connect(self.openAll)
+        act.triggered.connect(lambda: self.openAll(act))
     
-    def openAll(self):
+    def openAll(self, act):
         """
         Public slot to open all the menu's items.
+        
+        @param act reference to the action object
+        @type QAction
         """
-        menu = self.sender().parent()
+        menu = act.parent()
         if menu is None:
             return
         
@@ -160,28 +163,32 @@
             menu = QMenu()
             v = act.data()
             
-            menu.addAction(
-                self.tr("Open"),
-                self.__openBookmark).setData(v)
-            menu.addAction(
-                self.tr("Open in New Tab\tCtrl+LMB"),
-                self.__openBookmarkInNewTab).setData(v)
-            menu.addAction(
-                self.tr("Open in New Window"),
-                self.__openBookmarkInNewWindow).setData(v)
-            menu.addAction(
-                self.tr("Open in New Private Window"),
-                self.__openBookmarkInPrivateWindow).setData(v)
+            act2 = menu.addAction(self.tr("Open"))
+            act2.setData(v)
+            act2.triggered.connect(
+                lambda: self.__openBookmark(act2))
+            act2 = menu.addAction(self.tr("Open in New Tab\tCtrl+LMB"))
+            act2.setData(v)
+            act2.triggered.connect(
+                lambda: self.__openBookmarkInNewTab(act2))
+            act2 = menu.addAction(self.tr("Open in New Window"))
+            act2.setData(v)
+            act2.triggered.connect(
+                lambda: self.__openBookmarkInNewWindow(act2))
+            act2 = menu.addAction(self.tr("Open in New Private Window"))
+            act2.setData(v)
+            act2.triggered.connect(
+                lambda: self.__openBookmarkInPrivateWindow(act2))
             menu.addSeparator()
             
-            menu.addAction(
-                self.tr("Remove"),
-                self.__removeBookmark).setData(v)
+            act2 = menu.addAction(self.tr("Remove"))
+            act2.setData(v)
+            act2.triggered.connect(lambda: self.__removeBookmark(act2))
             menu.addSeparator()
             
-            menu.addAction(
-                self.tr("Properties..."),
-                self.__edit).setData(v)
+            act2 = menu.addAction(self.tr("Properties..."))
+            act2.setData(v)
+            act2.triggered.connect(lambda: self.__edit(act2))
             
             execAct = menu.exec_(QCursor.pos())
             if execAct is not None:
@@ -191,64 +198,82 @@
                     parent.close()
                     parent = parent.parent()
     
-    def __openBookmark(self):
+    def __openBookmark(self, act):
         """
         Private slot to open a bookmark in the current browser tab.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         
         self.openUrl.emit(
             idx.data(BookmarksModel.UrlRole),
             idx.data(Qt.DisplayRole))
         self.__updateVisitCount(idx)
     
-    def __openBookmarkInNewTab(self):
+    def __openBookmarkInNewTab(self, act):
         """
         Private slot to open a bookmark in a new browser tab.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         
         self.newTab.emit(
             idx.data(BookmarksModel.UrlRole),
             idx.data(Qt.DisplayRole))
         self.__updateVisitCount(idx)
     
-    def __openBookmarkInNewWindow(self):
+    def __openBookmarkInNewWindow(self, act):
         """
         Private slot to open a bookmark in a new window.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         url = idx.data(BookmarksModel.UrlRole)
         
         from WebBrowser.WebBrowserWindow import WebBrowserWindow
         WebBrowserWindow.mainWindow().newWindow(url)
         self.__updateVisitCount(idx)
     
-    def __openBookmarkInPrivateWindow(self):
+    def __openBookmarkInPrivateWindow(self, act):
         """
         Private slot to open a bookmark in a new private window.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         url = idx.data(BookmarksModel.UrlRole)
         
         from WebBrowser.WebBrowserWindow import WebBrowserWindow
         WebBrowserWindow.mainWindow().newPrivateWindow(url)
         self.__updateVisitCount(idx)
     
-    def __removeBookmark(self):
+    def __removeBookmark(self, act):
         """
         Private slot to remove a bookmark.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         self.removeEntry(idx)
     
-    def __edit(self):
+    def __edit(self, act):
         """
         Private slot to edit a bookmarks properties.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
         from .BookmarkPropertiesDialog import BookmarkPropertiesDialog
         
-        idx = self.index(self.sender())
+        idx = self.index(act)
         node = self.model().node(idx)
         dlg = BookmarkPropertiesDialog(node)
         dlg.exec_()
@@ -325,13 +350,15 @@
         self.addSeparator()
         act = self.addAction(self.tr("Default Home Page"))
         act.setData("eric:home")
-        act.triggered.connect(self.__defaultBookmarkTriggered)
+        act.triggered.connect(
+            lambda: self.__defaultBookmarkTriggered(act))
         act = self.addAction(self.tr("Speed Dial"))
         act.setData("eric:speeddial")
-        act.triggered.connect(self.__defaultBookmarkTriggered)
+        act.triggered.connect(
+            lambda: self.__defaultBookmarkTriggered(act))
         self.addSeparator()
         act = self.addAction(self.tr("Open all in Tabs"))
-        act.triggered.connect(self.openAll)
+        act.triggered.connect(lambda: self.openAll(act))
     
     def setInitialActions(self, actions):
         """
@@ -344,11 +371,13 @@
         for act in self.__initialActions:
             self.addAction(act)
     
-    def __defaultBookmarkTriggered(self):
+    def __defaultBookmarkTriggered(self, act):
         """
         Private slot handling the default bookmark menu entries.
+        
+        @param act reference to the action object
+        @type QAction
         """
-        act = self.sender()
         urlStr = act.data()
         if urlStr.startswith("eric:"):
             self.openUrl.emit(QUrl(urlStr), "")
--- a/WebBrowser/Bookmarks/BookmarksToolBar.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/WebBrowser/Bookmarks/BookmarksToolBar.py	Tue Feb 06 19:18:43 2018 +0100
@@ -84,28 +84,32 @@
             v = act.data()
             
             if act.menu() is None:
-                menu.addAction(
-                    self.tr("Open"),
-                    self.__openBookmark).setData(v)
-                menu.addAction(
-                    self.tr("Open in New Tab\tCtrl+LMB"),
-                    self.__openBookmarkInNewTab).setData(v)
-                menu.addAction(
-                    self.tr("Open in New Window"),
-                    self.__openBookmarkInNewWindow).setData(v)
-                menu.addAction(
-                    self.tr("Open in New Private Window"),
-                    self.__openBookmarkInPrivateWindow).setData(v)
+                act2 = menu.addAction(self.tr("Open"))
+                act2.setData(v)
+                act2.triggered.connect(
+                    lambda: self.__openBookmark(act2))
+                act2 = menu.addAction(self.tr("Open in New Tab\tCtrl+LMB"))
+                act2.setData(v)
+                act2.triggered.connect(
+                    lambda: self.__openBookmarkInNewTab(act2))
+                act2 = menu.addAction(self.tr("Open in New Window"))
+                act2.setData(v)
+                act2.triggered.connect(
+                    lambda: self.__openBookmarkInNewWindow(act2))
+                act2 = menu.addAction(self.tr("Open in New Private Window"))
+                act2.setData(v)
+                act2.triggered.connect(
+                    lambda: self.__openBookmarkInPrivateWindow(act2))
                 menu.addSeparator()
             
-            menu.addAction(
-                self.tr("Remove"),
-                self.__removeBookmark).setData(v)
+            act2 = menu.addAction(self.tr("Remove"))
+            act2.setData(v)
+            act2.triggered.connect(lambda: self.__removeBookmark(act2))
             menu.addSeparator()
             
-            menu.addAction(
-                self.tr("Properties..."),
-                self.__edit).setData(v)
+            act2 = menu.addAction(self.tr("Properties..."))
+            act2.setData(v)
+            act2.triggered.connect(lambda: self.__edit(act2))
             menu.addSeparator()
         
         menu.addAction(self.tr("Add Bookmark..."), self.__newBookmark)
@@ -153,55 +157,70 @@
                     idx.data(Qt.DisplayRole))
             self.__updateVisitCount(idx)
     
-    def __openBookmark(self):
+    def __openBookmark(self, act):
         """
         Private slot to open a bookmark in the current browser tab.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         
         self.openUrl.emit(
             idx.data(BookmarksModel.UrlRole),
             idx.data(Qt.DisplayRole))
         self.__updateVisitCount(idx)
     
-    def __openBookmarkInNewTab(self):
+    def __openBookmarkInNewTab(self, act):
         """
         Private slot to open a bookmark in a new browser tab.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         
         self.newTab.emit(
             idx.data(BookmarksModel.UrlRole),
             idx.data(Qt.DisplayRole))
         self.__updateVisitCount(idx)
     
-    def __openBookmarkInNewWindow(self):
+    def __openBookmarkInNewWindow(self, act):
         """
         Private slot to open a bookmark in a new window.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         
         self.newWindow.emit(
             idx.data(BookmarksModel.UrlRole),
             idx.data(Qt.DisplayRole))
         self.__updateVisitCount(idx)
     
-    def __openBookmarkInPrivateWindow(self):
+    def __openBookmarkInPrivateWindow(self, act):
         """
         Private slot to open a bookmark in a new private window.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         url = idx.data(BookmarksModel.UrlRole)
         
         from WebBrowser.WebBrowserWindow import WebBrowserWindow
         WebBrowserWindow.mainWindow().newPrivateWindow(url)
         self.__updateVisitCount(idx)
     
-    def __removeBookmark(self):
+    def __removeBookmark(self, act):
         """
         Private slot to remove a bookmark.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
-        idx = self.index(self.sender())
+        idx = self.index(act)
         
         self.__bookmarksModel.removeRow(idx.row(), self.rootIndex())
     
@@ -237,12 +256,15 @@
         menu.newWindow.connect(self.newWindow)
         return menu
     
-    def __edit(self):
+    def __edit(self, act):
         """
         Private slot to edit a bookmarks properties.
+        
+        @param act reference to the triggering action
+        @type QAction
         """
         from .BookmarkPropertiesDialog import BookmarkPropertiesDialog
-        idx = self.index(self.sender())
+        idx = self.index(act)
         node = self.__bookmarksModel.node(idx)
         dlg = BookmarkPropertiesDialog(node)
         dlg.exec_()
--- a/WebBrowser/Download/DownloadManager.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/WebBrowser/Download/DownloadManager.py	Tue Feb 06 19:18:43 2018 +0100
@@ -216,7 +216,7 @@
         @param append flag indicating to append the item
         @type bool
         """
-        itm.statusChanged.connect(self.__updateRow)
+        itm.statusChanged.connect(lambda: self.__updateRow(itm))
         itm.downloadFinished.connect(self.__finished)
         
         # insert at top of window
@@ -241,15 +241,13 @@
         self.changeOccurred()
         self.__updateActiveItemCount()
     
-    def __updateRow(self, itm=None):
+    def __updateRow(self, itm):
         """
         Private slot to update a download item.
         
-        @param itm reference to the download item (DownloadItem)
+        @param itm reference to the download item
+        @type DownloadItem
         """
-        if itm is None:
-            itm = self.sender()
-        
         if itm not in self.__downloads:
             return
         
--- a/WebBrowser/Feeds/FeedsDialog.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/WebBrowser/Feeds/FeedsDialog.py	Tue Feb 06 19:18:43 2018 +0100
@@ -49,16 +49,18 @@
             label.setText(feed[0])
             self.feedsLayout.addWidget(label, row, 0)
             self.feedsLayout.addWidget(button, row, 1)
-            button.clicked.connect(self.__addFeed)
+            button.clicked.connect(lambda: self.__addFeed(button))
         
         msh = self.minimumSizeHint()
         self.resize(max(self.width(), msh.width()), msh.height())
     
-    def __addFeed(self):
+    def __addFeed(self, button):
         """
         Private slot to add a RSS feed.
+        
+        @param button reference to the feed button
+        @type QPushButton
         """
-        button = self.sender()
         urlString = button.feed[1]
         url = QUrl(urlString)
         if url.isRelative():
--- a/WebBrowser/Feeds/FeedsManager.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/WebBrowser/Feeds/FeedsManager.py	Tue Feb 06 19:18:43 2018 +0100
@@ -268,14 +268,16 @@
         from WebBrowser.WebBrowserWindow import WebBrowserWindow
         request = QNetworkRequest(QUrl(urlString))
         reply = WebBrowserWindow.networkManager().get(request)
-        reply.finished.connect(self.__feedLoaded)
+        reply.finished.connect(lambda: self.__feedLoaded(reply))
         self.__replies[id(reply)] = (reply, itm)
     
-    def __feedLoaded(self):
+    def __feedLoaded(self, reply):
         """
         Private slot to extract the loaded feed data.
+        
+        @param reply reference to the network reply
+        @type QNetworkReply
         """
-        reply = self.sender()
         if id(reply) not in self.__replies:
             return
         
--- a/WebBrowser/PersonalInformationManager/PersonalInformationManager.py	Tue Feb 06 19:18:24 2018 +0100
+++ b/WebBrowser/PersonalInformationManager/PersonalInformationManager.py	Tue Feb 06 19:18:43 2018 +0100
@@ -234,7 +234,7 @@
         @param page reference to the web page
         @type WebBrowserPage
         """
-        page.loadFinished.connect(lambda ok:self.__pageLoadFinished(ok, page))
+        page.loadFinished.connect(lambda ok: self.__pageLoadFinished(ok, page))
     
     def __pageLoadFinished(self, ok, page):
         """

eric ide

mercurial