eric6/Preferences/ProgramsDialog.py

changeset 7426
dc171b1d8261
parent 7425
bd0eff406c6b
child 7451
f04328aef87a
equal deleted inserted replaced
7425:bd0eff406c6b 7426:dc171b1d8261
50 50
51 self.searchButton = self.buttonBox.addButton( 51 self.searchButton = self.buttonBox.addButton(
52 self.tr("Search"), QDialogButtonBox.ActionRole) 52 self.tr("Search"), QDialogButtonBox.ActionRole)
53 self.searchButton.setToolTip( 53 self.searchButton.setToolTip(
54 self.tr("Press to search for programs")) 54 self.tr("Press to search for programs"))
55
56 self.showComboBox.addItems([
57 self.tr("All Supported Tools"),
58 self.tr("Available Tools Only"),
59 self.tr("Unavailable Tools Only"),
60 ])
55 61
56 def show(self): 62 def show(self):
57 """ 63 """
58 Public slot to show the dialog. 64 Public slot to show the dialog.
59 """ 65 """
334 info["text"], 340 info["text"],
335 info["version"] 341 info["version"]
336 ) 342 )
337 343
338 self.programsList.sortByColumn(0, Qt.AscendingOrder) 344 self.programsList.sortByColumn(0, Qt.AscendingOrder)
339 self.on_showUnavailableCheckBox_toggled( 345 self.on_showComboBox_currentIndexChanged(
340 self.showUnavailableCheckBox.isChecked()) 346 self.showComboBox.currentIndex())
341 QApplication.restoreOverrideCursor() 347 QApplication.restoreOverrideCursor()
342 348
343 self.__hasSearched = True 349 self.__hasSearched = True
344 350
345 def __createProgramEntry(self, description, exe, 351 def __createProgramEntry(self, description, exe,
376 itm = QTreeWidgetItem(self.programsList, [description]) 382 itm = QTreeWidgetItem(self.programsList, [description])
377 font = itm.font(0) 383 font = itm.font(0)
378 font.setBold(True) 384 font.setBold(True)
379 itm.setFont(0, font) 385 itm.setFont(0, font)
380 rememberedExe = exe 386 rememberedExe = exe
381 available = True
382 if not exe: 387 if not exe:
383 itm.setText(1, self.tr("(not configured)")) 388 itm.setText(1, self.tr("(not configured)"))
384 else: 389 else:
385 if os.path.isabs(exe): 390 if os.path.isabs(exe):
386 if not Utilities.isExecutable(exe): 391 if not Utilities.isExecutable(exe):
387 exe = "" 392 exe = ""
388 else: 393 else:
389 exe = Utilities.getExecutablePath(exe) 394 exe = Utilities.getExecutablePath(exe)
390 if exe: 395 if exe:
396 available = True
391 if ( 397 if (
392 versionCommand and 398 versionCommand and
393 (versionStartsWith != "" or 399 (versionStartsWith != "" or
394 (versionRe is not None and versionRe != "")) and 400 (versionRe is not None and versionRe != "")) and
395 versionPosition 401 versionPosition
438 available = False 444 available = False
439 else: 445 else:
440 version = self.tr("(not executable)") 446 version = self.tr("(not executable)")
441 available = False 447 available = False
442 if exeModule: 448 if exeModule:
443 QTreeWidgetItem(itm, [ 449 citm = QTreeWidgetItem(itm, [
444 "{0} {1}".format(exe, " ".join(exeModule)), 450 "{0} {1}".format(exe, " ".join(exeModule)),
445 version]) 451 version])
446 else: 452 else:
447 QTreeWidgetItem(itm, [exe, version]) 453 citm = QTreeWidgetItem(itm, [exe, version])
454 citm.setData(0, self.ToolAvailableRole, available)
448 itm.setExpanded(True) 455 itm.setExpanded(True)
449 else: 456 else:
450 if itm.childCount() == 0: 457 if itm.childCount() == 0:
451 itm.setText(1, self.tr("(not found)")) 458 itm.setText(1, self.tr("(not found)"))
452 else: 459 else:
453 QTreeWidgetItem(itm, [rememberedExe, 460 citm = QTreeWidgetItem(
454 self.tr("(not found)")]) 461 itm, [rememberedExe, self.tr("(not found)")])
462 citm.setData(0, self.ToolAvailableRole, False)
455 itm.setExpanded(True) 463 itm.setExpanded(True)
456 available = False
457 itm.setData(0, self.ToolAvailableRole, available)
458 QApplication.processEvents() 464 QApplication.processEvents()
459 self.programsList.header().resizeSections(QHeaderView.ResizeToContents) 465 self.programsList.header().resizeSections(QHeaderView.ResizeToContents)
460 self.programsList.header().setStretchLastSection(True) 466 self.programsList.header().setStretchLastSection(True)
461 return version 467 return version
462 468
470 """ 476 """
471 itm = QTreeWidgetItem(self.programsList, [description]) 477 itm = QTreeWidgetItem(self.programsList, [description])
472 font = itm.font(0) 478 font = itm.font(0)
473 font.setBold(True) 479 font.setBold(True)
474 itm.setFont(0, font) 480 itm.setFont(0, font)
475 available = True
476 481
477 if len(entryVersion): 482 if len(entryVersion):
478 QTreeWidgetItem(itm, [entryText, entryVersion]) 483 citm = QTreeWidgetItem(itm, [entryText, entryVersion])
479 itm.setExpanded(True) 484 itm.setExpanded(True)
480 if entryVersion.startswith("("): 485 citm.setData(0, self.ToolAvailableRole,
481 # assume version starting with '(' is an unavailability 486 not entryVersion.startswith("("))
482 # indicator 487 # assume version starting with '(' is an unavailability
483 available = False
484 else: 488 else:
485 itm.setText(1, self.tr("(not found)")) 489 itm.setText(1, self.tr("(not found)"))
486 available = False
487 itm.setData(0, self.ToolAvailableRole, available)
488 QApplication.processEvents() 490 QApplication.processEvents()
489 self.programsList.header().resizeSections(QHeaderView.ResizeToContents) 491 self.programsList.header().resizeSections(QHeaderView.ResizeToContents)
490 self.programsList.header().setStretchLastSection(True) 492 self.programsList.header().setStretchLastSection(True)
491 493
492 @pyqtSlot(bool) 494 @pyqtSlot(int)
493 def on_showUnavailableCheckBox_toggled(self, checked): 495 def on_showComboBox_currentIndexChanged(self, index):
494 """ 496 """
495 Private slot show or hide entries belonging to unavailable but 497 Private slot to apply the selected show criteria.
496 supported tools. 498
497 499 @param index index of the show criterium
498 @param checked state of the check box 500 @type int
499 @type bool 501 """
500 """ 502 if index == 0:
501 for index in range(self.programsList.topLevelItemCount()): 503 # All Supported Tools
502 itm = self.programsList.topLevelItem(index) 504 for topIndex in range(self.programsList.topLevelItemCount()):
503 itm.setHidden(not checked and 505 topItem = self.programsList.topLevelItem(topIndex)
504 not itm.data(0, self.ToolAvailableRole)) 506 for childIndex in range(topItem.childCount()):
505 # TODO: change filter to a selection combo with 507 topItem.child(childIndex).setHidden(False)
506 # All Supported Tools 508 topItem.setHidden(False)
507 # Found Tools Only 509 else:
508 # Unavailable Tools Only 510 # 1 = Available Tools Only
509 # TODO: add available flag to each child item and derive parent status from 511 # 2 = Unavailable Tools Only
510 # them 512 for topIndex in range(self.programsList.topLevelItemCount()):
513 topItem = self.programsList.topLevelItem(topIndex)
514 if topItem.childCount() == 0:
515 topItem.setHidden(index == 1)
516 else:
517 availabilityList = []
518 for childIndex in range(topItem.childCount()):
519 childItem = topItem.child(childIndex)
520 available = childItem.data(0, self.ToolAvailableRole)
521 if index == 1:
522 childItem.setHidden(not available)
523 else:
524 childItem.setHidden(available)
525 availabilityList.append(available)
526 if index == 1:
527 topItem.setHidden(not any(availabilityList))
528 else:
529 topItem.setHidden(all(availabilityList))

eric ide

mercurial