ProgramsDialog: implemented interims filter solution to hide unavailable tools.

Tue, 18 Feb 2020 19:38:58 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 18 Feb 2020 19:38:58 +0100
changeset 7425
bd0eff406c6b
parent 7423
9758025d7225
child 7426
dc171b1d8261

ProgramsDialog: implemented interims filter solution to hide unavailable tools.

eric6/Preferences/ProgramsDialog.py file | annotate | diff | comparison | revisions
eric6/Preferences/ProgramsDialog.ui file | annotate | diff | comparison | revisions
--- a/eric6/Preferences/ProgramsDialog.py	Mon Feb 17 19:20:43 2020 +0100
+++ b/eric6/Preferences/ProgramsDialog.py	Tue Feb 18 19:38:58 2020 +0100
@@ -30,6 +30,8 @@
     """
     Class implementing the Programs page.
     """
+    ToolAvailableRole = Qt.UserRole + 1
+    
     def __init__(self, parent=None):
         """
         Constructor
@@ -334,6 +336,8 @@
                 )
         
         self.programsList.sortByColumn(0, Qt.AscendingOrder)
+        self.on_showUnavailableCheckBox_toggled(
+            self.showUnavailableCheckBox.isChecked())
         QApplication.restoreOverrideCursor()
         
         self.__hasSearched = True
@@ -374,6 +378,7 @@
         font.setBold(True)
         itm.setFont(0, font)
         rememberedExe = exe
+        available = True
         if not exe:
             itm.setText(1, self.tr("(not configured)"))
         else:
@@ -409,6 +414,7 @@
                              proc.exitCode() != 0)
                         ):
                             version = self.tr("(module not found)")
+                            available = False
                         else:
                             if versionRe is None:
                                 versionRe = "^{0}".format(
@@ -426,10 +432,13 @@
                                         break
                                     except IndexError:
                                         version = self.tr("(unknown)")
+                                        available = False
                             else:
                                 version = self.tr("(unknown)")
+                                available = False
                     else:
                         version = self.tr("(not executable)")
+                        available = False
                 if exeModule:
                     QTreeWidgetItem(itm, [
                         "{0} {1}".format(exe, " ".join(exeModule)),
@@ -444,6 +453,8 @@
                     QTreeWidgetItem(itm, [rememberedExe,
                                           self.tr("(not found)")])
                     itm.setExpanded(True)
+                available = False
+        itm.setData(0, self.ToolAvailableRole, available)
         QApplication.processEvents()
         self.programsList.header().resizeSections(QHeaderView.ResizeToContents)
         self.programsList.header().setStretchLastSection(True)
@@ -461,12 +472,39 @@
         font = itm.font(0)
         font.setBold(True)
         itm.setFont(0, font)
+        available = True
         
         if len(entryVersion):
             QTreeWidgetItem(itm, [entryText, entryVersion])
             itm.setExpanded(True)
+            if entryVersion.startswith("("):
+                # assume version starting with '(' is an unavailability
+                # indicator
+                available = False
         else:
             itm.setText(1, self.tr("(not found)"))
+            available =  False
+        itm.setData(0, self.ToolAvailableRole, available)
         QApplication.processEvents()
         self.programsList.header().resizeSections(QHeaderView.ResizeToContents)
         self.programsList.header().setStretchLastSection(True)
+    
+    @pyqtSlot(bool)
+    def on_showUnavailableCheckBox_toggled(self, checked):
+        """
+        Private slot show or hide entries belonging to unavailable but
+        supported tools.
+        
+        @param checked state of the check box
+        @type bool
+        """
+        for index in range(self.programsList.topLevelItemCount()):
+            itm = self.programsList.topLevelItem(index)
+            itm.setHidden(not checked and
+                          not itm.data(0, self.ToolAvailableRole))
+# TODO: change filter to a selection combo with
+#       All Supported Tools
+#       Found Tools Only
+#       Unavailable Tools Only
+# TODO: add available flag to each child item and derive parent status from
+#       them
--- a/eric6/Preferences/ProgramsDialog.ui	Mon Feb 17 19:20:43 2020 +0100
+++ b/eric6/Preferences/ProgramsDialog.ui	Tue Feb 18 19:38:58 2020 +0100
@@ -13,7 +13,7 @@
   <property name="windowTitle">
    <string>External Tools</string>
   </property>
-  <layout class="QVBoxLayout">
+  <layout class="QVBoxLayout" name="verticalLayout">
    <item>
     <widget class="QTreeWidget" name="programsList">
      <property name="rootIsDecorated">
@@ -35,14 +35,31 @@
     </widget>
    </item>
    <item>
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Close</set>
-     </property>
-    </widget>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QCheckBox" name="showUnavailableCheckBox">
+       <property name="toolTip">
+        <string>Select to show unavailable but supported tools as well</string>
+       </property>
+       <property name="text">
+        <string>Show unavailable tools</string>
+       </property>
+       <property name="checked">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons">
+        <set>QDialogButtonBox::Close</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
    </item>
   </layout>
  </widget>

eric ide

mercurial