From 30d4903bf22b96b20891adda192ab66d8f2a45d1 Mon Sep 17 00:00:00 2001 From: Csaba Pinter Date: Mon, 18 Sep 2023 20:46:00 +0100 Subject: [PATCH] BUG: Make sure the delete DICOM object dialog is not too tall 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. --- Libs/DICOM/Widgets/ctkDICOMBrowser.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Libs/DICOM/Widgets/ctkDICOMBrowser.cpp b/Libs/DICOM/Widgets/ctkDICOMBrowser.cpp index 344810e1f7..22dda34897 100644 --- a/Libs/DICOM/Widgets/ctkDICOMBrowser.cpp +++ b/Libs/DICOM/Widgets/ctkDICOMBrowser.cpp @@ -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