ViewManager/ViewManager.py

changeset 5742
dc9cd8059221
parent 5726
e1dbd217214a
child 5900
cd90bfdc1247
child 5948
6f958d5765f4
diff -r ece3c72a24c3 -r dc9cd8059221 ViewManager/ViewManager.py
--- a/ViewManager/ViewManager.py	Sat May 20 14:33:00 2017 +0200
+++ b/ViewManager/ViewManager.py	Sat May 20 16:13:23 2017 +0200
@@ -2831,7 +2831,7 @@
             """ dialog is shown to enter the searchtext and options"""
             """ for the search.</p>"""
         ))
-        self.searchAct.triggered.connect(self.__search)
+        self.searchAct.triggered.connect(self.showSearchWidget)
         self.searchActions.append(self.searchAct)
         
         self.searchNextAct = E5Action(
@@ -2852,7 +2852,7 @@
             """ editor. The previously entered searchtext and options are"""
             """ reused.</p>"""
         ))
-        self.searchNextAct.triggered.connect(self.__searchWidget.findNext)
+        self.searchNextAct.triggered.connect(self.__searchNext)
         self.searchActions.append(self.searchNextAct)
         
         self.searchPrevAct = E5Action(
@@ -2872,7 +2872,7 @@
             """ editor. The previously entered searchtext and options are"""
             """ reused.</p>"""
         ))
-        self.searchPrevAct.triggered.connect(self.__searchWidget.findPrev)
+        self.searchPrevAct.triggered.connect(self.__searchPrev)
         self.searchActions.append(self.searchPrevAct)
         
         self.searchClearMarkersAct = E5Action(
@@ -2956,9 +2956,77 @@
             """ A dialog is shown to enter the searchtext, the replacement"""
             """ text and options for the search and replace.</p>"""
         ))
-        self.replaceAct.triggered.connect(self.__replace)
+        self.replaceAct.triggered.connect(self.showReplaceWidget)
         self.searchActions.append(self.replaceAct)
         
+        self.replaceAndSearchAct = E5Action(
+            QCoreApplication.translate(
+                'ViewManager', 'Replace and Search'),
+            UI.PixmapCache.getIcon("editReplaceSearch.png"),
+            QCoreApplication.translate(
+                'ViewManager', 'Replace and Search'),
+            QKeySequence(QCoreApplication.translate(
+                'ViewManager', "Meta+R", "Search|Replace and Search")),
+            0,
+            self.searchActGrp, 'vm_replace_search')
+        self.replaceAndSearchAct.setStatusTip(QCoreApplication.translate(
+            'ViewManager',
+            'Replace the found text and search the next occurrence'))
+        self.replaceAndSearchAct.setWhatsThis(QCoreApplication.translate(
+            'ViewManager',
+            """<b>Replace and Search</b>"""
+            """<p>Replace the found occurrence of text in the current"""
+            """ editor and search for the next one. The previously entered"""
+            """ search text and options are reused.</p>"""
+        ))
+        self.replaceAndSearchAct.triggered.connect(
+            self.__replaceWidget.replaceSearch)
+        self.searchActions.append(self.replaceAndSearchAct)
+        
+        self.replaceSelectionAct = E5Action(
+            QCoreApplication.translate(
+                'ViewManager', 'Replace Occurrence'),
+            UI.PixmapCache.getIcon("editReplace.png"),
+            QCoreApplication.translate(
+                'ViewManager', 'Replace Occurrence'),
+            QKeySequence(QCoreApplication.translate(
+                'ViewManager', "Ctrl+Meta+R", "Search|Replace Occurrence")),
+            0,
+            self.searchActGrp, 'vm_replace_occurrence')
+        self.replaceSelectionAct.setStatusTip(QCoreApplication.translate(
+            'ViewManager', 'Replace the found text'))
+        self.replaceSelectionAct.setWhatsThis(QCoreApplication.translate(
+            'ViewManager',
+            """<b>Replace Occurrence</b>"""
+            """<p>Replace the found occurrence of the search text in the"""
+            """ current editor.</p>"""
+        ))
+        self.replaceSelectionAct.triggered.connect(
+            self.__replaceWidget.replace)
+        self.searchActions.append(self.replaceSelectionAct)
+        
+        self.replaceAllAct = E5Action(
+            QCoreApplication.translate(
+                'ViewManager', 'Replace All'),
+            UI.PixmapCache.getIcon("editReplaceAll.png"),
+            QCoreApplication.translate(
+                'ViewManager', 'Replace All'),
+            QKeySequence(QCoreApplication.translate(
+                'ViewManager', "Shift+Meta+R", "Search|Replace All")),
+            0,
+            self.searchActGrp, 'vm_replace_all')
+        self.replaceAllAct.setStatusTip(QCoreApplication.translate(
+            'ViewManager', 'Replace search text occurrences'))
+        self.replaceAllAct.setWhatsThis(QCoreApplication.translate(
+            'ViewManager',
+            """<b>Replace All</b>"""
+            """<p>Replace all occurrences of the search text in the current"""
+            """ editor.</p>"""
+        ))
+        self.replaceAllAct.triggered.connect(
+            self.__replaceWidget.replaceAll)
+        self.searchActions.append(self.replaceAllAct)
+        
         self.quickSearchAct = E5Action(
             QCoreApplication.translate('ViewManager', 'Quicksearch'),
             UI.PixmapCache.getIcon("quickFindNext.png"),
@@ -3310,6 +3378,9 @@
         toolbarManager.addToolBar(tb, tb.windowTitle())
         toolbarManager.addAction(self.gotoAct, tb.windowTitle())
         toolbarManager.addAction(self.gotoBraceAct, tb.windowTitle())
+        toolbarManager.addAction(self.replaceSelectionAct, tb.windowTitle())
+        toolbarManager.addAction(self.replaceAllAct, tb.windowTitle())
+        toolbarManager.addAction(self.replaceAndSearchAct, tb.windowTitle())
         
         return tb, qtb
     
@@ -5603,17 +5674,35 @@
             txt += ext
             self.quickFindtextCombo.lineEdit().setText(txt)
         
-    def __search(self):
-        """
-        Private method to handle the search action.
+    def showSearchWidget(self):
+        """
+        Public method to show the search widget.
         """
         self.__replaceWidget.hide()
         self.__searchWidget.show()
         self.__searchWidget.show(self.textForFind())
-        
-    def __replace(self):
-        """
-        Private method to handle the replace action.
+    
+    def __searchNext(self):
+        """
+        Private slot to handle the search next action.
+        """
+        if self.__replaceWidget.isVisible():
+            self.__replaceWidget.findNext()
+        else:
+            self.__searchWidget.findNext()
+    
+    def __searchPrev(self):
+        """
+        Private slot to handle the search previous action.
+        """
+        if self.__replaceWidget.isVisible():
+            self.__replaceWidget.findPrev()
+        else:
+            self.__searchWidget.findPrev()
+    
+    def showReplaceWidget(self):
+        """
+        Public method to show the replace widget.
         """
         self.__searchWidget.hide()
         self.__replaceWidget.show(self.textForFind())

eric ide

mercurial