Skip to content

Commit

Permalink
BUG: Make sure the delete DICOM object dialog is not too tall
Browse files Browse the repository at this point in the history
When deleting many patients (or studies or series) it can occur that the confirmation dialog that is created with all the deleted object names is taller than the screen height, so the buttons are cut off and not available. This commit ensures that the said dialog cannot be higher than the DICOM browser.

Note that the height of one row is calculated from the first row height in the patients table, which may not be the same as the height of a row in the label that shows the deleted item names. This is implemented like this for simplicity, however, since the table row is typically somewhat higher than a line in the label, it is safe.
  • Loading branch information
cpinter committed Sep 25, 2023
1 parent 5657c58 commit 30d4903
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Libs/DICOM/Widgets/ctkDICOMBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,10 +1092,29 @@ bool ctkDICOMBrowser::confirmDeleteSelectedUIDs(QStringList uids)
ctkMessageBox confirmDeleteDialog;
QString message = tr("Do you want to delete the following selected items?");

// calculate maximum number of rows that fit in the browser widget to have a reasonable limit
// on the items to show in the dialog
int browserHeight = this->geometry().height();
int patientsTableRowHeight = d->dicomTableManager->patientsTable()->tableView()->rowHeight(0);
int maxNumberOfPatientsToShow = browserHeight / patientsTableRowHeight - 3; // subtract 3 due to the checkbox, buttons, and header
if (maxNumberOfPatientsToShow < 3)
{
// make sure there are a meaningful number of items shown
maxNumberOfPatientsToShow = 3;
}

// add the information about the selected UIDs
int numUIDs = uids.size();
for (int i = 0; i < numUIDs; ++i)
{
if (i >= maxNumberOfPatientsToShow && numUIDs > maxNumberOfPatientsToShow + 1)
{
// displayed when there are additional DICOM items to delete that do not fit on screen
// note: do not show this message if there is only one more to show (the message also takes a line)
message += QString("\n") + tr("(and %1 more)").arg(numUIDs - maxNumberOfPatientsToShow);
break;
}

QString uid = uids.at(i);

// try using the given UID to find a descriptive string
Expand Down

0 comments on commit 30d4903

Please sign in to comment.