@@ -62,6 +62,8 @@ def __init__(self, algType, alg):
6262 super (ScriptEditorDialog , self ).__init__ (None )
6363 self .setupUi (self )
6464
65+ self .searchWidget .setVisible (False )
66+
6567 self .setWindowFlags (Qt .WindowMinimizeButtonHint |
6668 Qt .WindowMaximizeButtonHint |
6769 Qt .WindowCloseButtonHint )
@@ -76,6 +78,8 @@ def __init__(self, algType, alg):
7678 QIcon (os .path .join (pluginPath , 'images' , 'edithelp.png' )))
7779 self .btnRun .setIcon (
7880 QIcon (os .path .join (pluginPath , 'images' , 'runalgorithm.png' )))
81+ self .btnSearch .setIcon (
82+ QIcon (os .path .join (pluginPath , 'images' , 'search.png' )))
7983 self .btnCut .setIcon (QgsApplication .getThemeIcon ('/mActionEditCut.svg' ))
8084 self .btnCopy .setIcon (
8185 QgsApplication .getThemeIcon ('/mActionEditCopy.svg' ))
@@ -97,10 +101,15 @@ def __init__(self, algType, alg):
97101 self .btnPaste .clicked .connect (self .editor .paste )
98102 self .btnUndo .clicked .connect (self .editor .undo )
99103 self .btnRedo .clicked .connect (self .editor .redo )
104+ self .btnSearch .clicked .connect (self .toggleSearchBox )
100105 self .btnIncreaseFont .clicked .connect (self .editor .zoomIn )
101106 self .btnDecreaseFont .clicked .connect (self .editor .zoomOut )
107+ self .btnFind .clicked .connect (self .find )
108+ self .btnReplace .clicked .connect (self .replace )
102109 self .editor .textChanged .connect (lambda : self .setHasChanged (True ))
103110
111+ self .lastSearch = None
112+
104113 self .alg = alg
105114 self .algType = algType
106115
@@ -138,6 +147,22 @@ def __init__(self, algType, alg):
138147
139148 self .editor .setLexerType (self .algType )
140149
150+ def find (self ):
151+ txt = self .findBox .text ()
152+ cs = self .chkCaseSensitive .isChecked ()
153+ wo = self .chkWholeWord .isChecked ()
154+ if self .lastSearch is None or txt != self .lastSearch :
155+ self .editor .findFirst (txt , False , cs , wo , True )
156+ else :
157+ self .editor .findNext ()
158+
159+ def replace (self ):
160+ txt = self .replaceBox .text ()
161+ self .editor .replaceSelectedText (txt )
162+
163+ def toggleSearchBox (self ):
164+ self .searchWidget .setVisible (not self .searchWidget .isVisible ())
165+
141166 def showSnippets (self , evt ):
142167 popupmenu = QMenu ()
143168 for name , snippet in self .snippets .iteritems ():
0 commit comments