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. Also, the height calculation does not include the window header and the buttons.
  • Loading branch information
cpinter committed Sep 18, 2023
1 parent 5657c58 commit b1a938b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Libs/DICOM/Widgets/ctkDICOMBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,10 +1092,22 @@ 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 - 1; // Subtract 1 due to the do not show checkbox

// add the information about the selected UIDs
int numUIDs = uids.size();
for (int i = 0; i < numUIDs; ++i)
{
if (i >= maxNumberOfPatientsToShow)
{
message += QString("\n(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 b1a938b

Please sign in to comment.