Skip to content

Commit

Permalink
Added implementation to paging SLOTS. Refs #8230.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawrainey committed Nov 20, 2013
1 parent 7391af8 commit 43ce061
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions Code/Mantid/MantidQt/MantidWidgets/src/CatalogSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ namespace MantidQt
connect(m_icatUiForm.dataFileResultsTbl,SIGNAL(itemClicked(QTableWidgetItem*)),this,SLOT(dataFileCheckboxSelected(QTableWidgetItem*)));
// When several rows are selected we want to check the related checkboxes.
connect(m_icatUiForm.dataFileResultsTbl,SIGNAL(itemSelectionChanged()),this,SLOT(dataFileRowSelected()));
// When the user clicks "< Prev" populate the results table with the previous 100 results.
connect(m_icatUiForm.resPrevious,SIGNAL(clicked()),this,SLOT(prevPageClicked()));
// When the user clicks "Next >" populate the results table with the next 100 results.
connect(m_icatUiForm.resNext,SIGNAL(clicked()),this,SLOT(nextPageClicked()));

// No need for error handling as that's dealt with in the algorithm being used.
populateInstrumentBox();
Expand Down Expand Up @@ -762,15 +766,32 @@ namespace MantidQt
*/
void CatalogSearch::nextPageClicked()
{

int totalNumPages = m_icatUiForm.resPageEndNumTxt->text().toInt();
// Prevent user from pressing "next" when no more investigations exist.
if (m_currentPageNumber >= totalNumPages)
{
m_currentPageNumber = totalNumPages;
return;
}
// Increment here as we need to validate page number above.
m_currentPageNumber++;
// Perform the search, and update the table with the new results using the current page num.
searchClicked();
}

/**
* Populate the result table, and update the page number.
*/
void CatalogSearch::prevPageClicked()
{

m_currentPageNumber--;
// Prevent user from pressing "Previous" when no investigations exist.
if (m_currentPageNumber <= 0)
{
m_currentPageNumber = 1;
return;
}
searchClicked();
}

/**
Expand Down

0 comments on commit 43ce061

Please sign in to comment.