Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Make sure the delete DICOM object dialog is not too tall #1140

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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