Skip to content

Commit b97e7f5

Browse files
committed
ENH: Update search/category UI
- Move search bar to main layout - Add clear option to search bar - Set up auto-complete on category selector
1 parent d829b95 commit b97e7f5

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

IDCBrowser/IDCBrowser.py

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,23 @@ def setup(self):
251251
# Browser Widget Layout within the collapsible button
252252
browserWidgetLayout = qt.QVBoxLayout(self.browserWidget)
253253

254+
# add unified search field
255+
searchWidget = qt.QWidget()
256+
searchWidgetLayout = qt.QGridLayout(searchWidget)
257+
browserWidgetLayout.addWidget(searchWidget)
258+
259+
label = qt.QLabel('Search:')
260+
self.unifiedSearchSelector = ctk.ctkSearchBox()
261+
self.unifiedSearchSelector.setPlaceholderText('Enter Collection ID, Patient ID, Study UID, or Series UID')
262+
searchWidgetLayout.addWidget(label, 0, 0)
263+
searchWidgetLayout.addWidget(self.unifiedSearchSelector, 0, 1)
264+
265+
# add warning label for no matches
266+
self.searchWarningLabel = qt.QLabel('')
267+
self.searchWarningLabel.setStyleSheet("QLabel { color: red; font-weight: bold; }")
268+
self.searchWarningLabel.hide()
269+
searchWidgetLayout.addWidget(self.searchWarningLabel, 1, 0, 1, 2)
270+
254271
self.collectionsCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox()
255272
self.collectionsCollapsibleGroupBox.setTitle('Collections')
256273
browserWidgetLayout.addWidget(self.collectionsCollapsibleGroupBox) #
@@ -284,19 +301,6 @@ def setup(self):
284301
#downloaderLayout.addWidget(self.downloadFromManifestButton, 1, 2)
285302
#downloaderLayout.addWidget(self.downloadAndIndexFromManifestButton, 1, 3)
286303

287-
# add unified search field
288-
label = qt.QLabel('Search:')
289-
self.unifiedSearchSelector = qt.QLineEdit()
290-
self.unifiedSearchSelector.setPlaceholderText('Enter Collection ID, Patient ID, Study UID, or Series UID')
291-
downloaderLayout.addWidget(label, 2, 0)
292-
downloaderLayout.addWidget(self.unifiedSearchSelector, 2, 1)
293-
294-
# add warning label for no matches
295-
self.searchWarningLabel = qt.QLabel('')
296-
self.searchWarningLabel.setStyleSheet("QLabel { color: red; font-weight: bold; }")
297-
self.searchWarningLabel.hide()
298-
downloaderLayout.addWidget(self.searchWarningLabel, 3, 0, 1, 2)
299-
300304
# add output directory selector
301305
label = qt.QLabel('Download directory:')
302306
self.downloadDestinationSelector = ctk.ctkDirectoryButton()
@@ -314,8 +318,17 @@ def setup(self):
314318
# Selector ComboBox
315319
self.collectionSelector = qt.QComboBox()
316320
self.collectionSelector.setMinimumWidth(200)
321+
self.collectionSelector.setEditable(True)
322+
self.collectionSelector.setInsertPolicy(qt.QComboBox.NoInsert)
317323
collectionsFormLayout.addWidget(self.collectionSelector)
318324

325+
# Set up QCompleter for auto-completion
326+
self.collectionCompleter = qt.QCompleter()
327+
self.collectionCompleter.setCaseSensitivity(qt.Qt.CaseInsensitive)
328+
self.collectionCompleter.setCompletionMode(qt.QCompleter.PopupCompletion)
329+
self.collectionCompleter.setFilterMode(qt.Qt.MatchContains)
330+
self.collectionSelector.setCompleter(self.collectionCompleter)
331+
319332
collectionsFormLayout.addStretch(4)
320333
logoLabelText = "IDC release "+self.logic.idc_version
321334
self.logoLabel = qt.QLabel(logoLabelText)
@@ -1482,14 +1495,11 @@ def getSeriesSize(self, seriesInstanceUID):
14821495
def populateCollectionsTreeView(self, responseString):
14831496
collectionNames = sorted(responseString)
14841497

1485-
self.collectionSelector.disconnect('currentIndexChanged(QString)')
14861498
self.collectionSelector.clear()
1487-
self.collectionSelector.connect('currentIndexChanged(QString)', self.collectionSelected)
1488-
1489-
n = 0 # If you intend to use the 'n' variable for a specific purpose, it's kept here.
1499+
self.collectionSelector.addItems(collectionNames)
14901500

1491-
for name in collectionNames:
1492-
self.collectionSelector.addItem(name)
1501+
# Set up the completer with the same items
1502+
self.collectionCompleter.setModel(self.collectionSelector.model())
14931503

14941504

14951505
def populatePatientsTableWidget(self, responseString):

0 commit comments

Comments
 (0)