Searching through files can now loop back to first file again
This commit is contained in:
+5
-3
@@ -1168,15 +1168,17 @@ class GuiDocEditor(QTextEdit):
|
|||||||
searchFor = self.docSearch.getSearchText()
|
searchFor = self.docSearch.getSearchText()
|
||||||
wasFound = self.find(searchFor, findOpt)
|
wasFound = self.find(searchFor, findOpt)
|
||||||
if not wasFound:
|
if not wasFound:
|
||||||
if self.docSearch.doLoop:
|
if self.docSearch.doNextFile and not isBackward:
|
||||||
|
self.theParent.openNextDocument(
|
||||||
|
self.theHandle, wrapAround=self.docSearch.doLoop
|
||||||
|
)
|
||||||
|
elif self.docSearch.doLoop:
|
||||||
theCursor = self.textCursor()
|
theCursor = self.textCursor()
|
||||||
theCursor.movePosition(
|
theCursor.movePosition(
|
||||||
QTextCursor.End if isBackward else QTextCursor.Start
|
QTextCursor.End if isBackward else QTextCursor.Start
|
||||||
)
|
)
|
||||||
self.setTextCursor(theCursor)
|
self.setTextCursor(theCursor)
|
||||||
self.find(searchFor, findOpt)
|
self.find(searchFor, findOpt)
|
||||||
elif self.docSearch.doNextFile:
|
|
||||||
self.theParent.openNextDocument(self.theHandle)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
+11
-5
@@ -476,28 +476,34 @@ class GuiMain(QMainWindow):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def openNextDocument(self, tHandle):
|
def openNextDocument(self, tHandle, wrapAround=False):
|
||||||
"""Opens the next document in the project tree, following the
|
"""Opens the next document in the project tree, following the
|
||||||
document with the given handle. Stops when reaching the end.
|
document with the given handle. Stops when reaching the end.
|
||||||
"""
|
"""
|
||||||
if self.hasProject:
|
if self.hasProject:
|
||||||
self.treeView.flushTreeOrder()
|
self.treeView.flushTreeOrder()
|
||||||
nHandle = None
|
nHandle = None # The next handle after tHandle
|
||||||
goNext = False
|
fHandle = None # The first file handle we encounter
|
||||||
|
foundIt = False # We've found tHandle, pick the next we see
|
||||||
for tItem in self.theProject.projTree:
|
for tItem in self.theProject.projTree:
|
||||||
if tItem is None:
|
if tItem is None:
|
||||||
continue
|
continue
|
||||||
if tItem.itemType != nwItemType.FILE:
|
if tItem.itemType != nwItemType.FILE:
|
||||||
continue
|
continue
|
||||||
|
if fHandle is None:
|
||||||
|
fHandle = tItem.itemHandle
|
||||||
if tItem.itemHandle == tHandle:
|
if tItem.itemHandle == tHandle:
|
||||||
goNext = True
|
foundIt = True
|
||||||
elif goNext:
|
elif foundIt:
|
||||||
nHandle = tItem.itemHandle
|
nHandle = tItem.itemHandle
|
||||||
break
|
break
|
||||||
|
|
||||||
if nHandle is not None:
|
if nHandle is not None:
|
||||||
self.openDocument(nHandle, tLine=0)
|
self.openDocument(nHandle, tLine=0)
|
||||||
return True
|
return True
|
||||||
|
elif wrapAround:
|
||||||
|
self.openDocument(fHandle, tLine=0)
|
||||||
|
return False
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user