Skip to content

Commit

Permalink
[MetaSearch] Fix navigation through the results pages
Browse files Browse the repository at this point in the history
(cherry picked from commit 1559908)
  • Loading branch information
agiudiceandrea authored and nyalldawson committed Jan 15, 2021
1 parent 7da798a commit d91ed2d
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions python/plugins/MetaSearch/dialogs/maindialog.py
Expand Up @@ -98,7 +98,7 @@ def __init__(self, iface):
self.rubber_band.setWidth(5)

# form inputs
self.startfrom = 0
self.startfrom = 1
self.maxrecords = 10
self.timeout = 10
self.disable_ssl_verification = False
Expand Down Expand Up @@ -450,7 +450,7 @@ def search(self):
self.catalog_password = self.settings.value('%s/password' % key)

# start position and number of records to return
self.startfrom = 0
self.startfrom = 1
self.maxrecords = self.spnRecords.value()

# set timeout
Expand Down Expand Up @@ -511,10 +511,10 @@ def display_results(self):

self.treeRecords.clear()

position = self.catalog.results['returned'] + self.startfrom
position = self.catalog.results['returned'] + self.startfrom - 1

msg = self.tr('Showing {0} - {1} of %n result(s)', 'number of results',
self.catalog.results['matches']).format(self.startfrom + 1,
self.catalog.results['matches']).format(self.startfrom,
position)

self.lblResults.setText(msg)
Expand Down Expand Up @@ -651,34 +651,38 @@ def navigate(self):
caller = self.sender().objectName()

if caller == 'btnFirst':
self.startfrom = 0
self.startfrom = 1
elif caller == 'btnLast':
self.startfrom = self.catalog.results['matches'] - self.maxrecords
self.startfrom = self.catalog.results['matches'] - self.maxrecords + 1
elif caller == 'btnNext':
self.startfrom += self.maxrecords
if self.startfrom >= self.catalog.results["matches"]:
if self.startfrom > self.catalog.results["matches"] - self.maxrecords:
msg = self.tr('End of results. Go to start?')
res = QMessageBox.information(self, self.tr('Navigation'),
msg,
(QMessageBox.Ok |
QMessageBox.Cancel))
if res == QMessageBox.Ok:
self.startfrom = 0
self.startfrom = 1
else:
return
else:
self.startfrom += self.maxrecords
elif caller == "btnPrev":
self.startfrom -= self.maxrecords
if self.startfrom <= 0:
if self.startfrom == 1:
msg = self.tr('Start of results. Go to end?')
res = QMessageBox.information(self, self.tr('Navigation'),
msg,
(QMessageBox.Ok |
QMessageBox.Cancel))
if res == QMessageBox.Ok:
self.startfrom = (self.catalog.results['matches'] -
self.maxrecords)
self.maxrecords + 1)
else:
return
elif self.startfrom <= self.maxrecords:
self.startfrom = 1
else:
self.startfrom -= self.maxrecords

try:
with OverrideCursor(Qt.WaitCursor):
Expand Down

0 comments on commit d91ed2d

Please sign in to comment.