Skip to content

Commit

Permalink
Prevent invalid page number. Refs #8230.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawrainey committed Nov 20, 2013
1 parent 36c4cf5 commit eb84922
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
</property>
<property name="maximumSize">
<size>
<width>40</width>
<width>35</width>
<height>16777215</height>
</size>
</property>
Expand All @@ -140,7 +140,7 @@
<set>Qt::ImhDigitsOnly</set>
</property>
<property name="maxLength">
<number>4</number>
<number>3</number>
</property>
</widget>
</item>
Expand Down
12 changes: 11 additions & 1 deletion Code/Mantid/MantidQt/MantidWidgets/src/CatalogSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ namespace MantidQt
// Limit input to: A number, 1 hyphen or colon followed by another number. E.g. 444-444, -444, 444-
QRegExp re("[0-9]*(-|:){1}[0-9]*");
m_icatUiForm.RunRange->setValidator(new QRegExpValidator(re, this));
// Limit the page number input field to only digits.
m_icatUiForm.pageStartNum->setValidator(new QIntValidator(0,999,this));

// Resize to minimum width/height to improve UX.
this->resize(minimumSizeHint());
Expand Down Expand Up @@ -779,7 +781,15 @@ namespace MantidQt
*/
void CatalogSearch::goToInputPage()
{
m_currentPageNumber = m_icatUiForm.pageStartNum->text().toInt();
int pageNum = m_icatUiForm.pageStartNum->text().toInt();
// If the user inputs a page number larger than the total
// amount of page numbers we do not want to do anything.
if (pageNum > m_icatUiForm.resPageEndNumTxt->text().toInt())
{
m_icatUiForm.pageStartNum->setText(QString::number(m_currentPageNumber));
return;
}
m_currentPageNumber = pageNum;
searchClicked();
}

Expand Down

0 comments on commit eb84922

Please sign in to comment.