Add the toolchain search function
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 23 Dec 2008 08:56:56 +0000 (08:56 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 23 Dec 2008 08:56:56 +0000 (08:56 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2123 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BToolchainPage.py
wizard/toolchain_select.ui

index e052db273d062e24a4f80abb95869d8547ebc7ce..4b2b4c5e21f1063833c0456d9402556eebd87e2a 100644 (file)
@@ -10,6 +10,7 @@
 #
 
 from BWizardPage import *
+import bertos_utils
 
 class BToolchainPage(BWizardPage):
     
@@ -17,6 +18,7 @@ class BToolchainPage(BWizardPage):
         BWizardPage.__init__(self, "toolchain_select.ui")
         self.setTitle(self.tr("Select toolchain"))
         self._setupUi()
+        self._populateDirList()
         self._connectSignals()
     
     def _setupUi(self):
@@ -41,6 +43,13 @@ class BToolchainPage(BWizardPage):
             self.pageContent.doSearchButton.setEnabled(True)
         else:
             self.pageContent.doSearchButton.setEnabled(False)
+    
+    def _populateDirList(self):
+        search_dir_list = self._settingsRetrieve("search_dir_list").toList()
+        for element in search_dir_list:
+            item = QListWidgetItem(element.toString())
+            item.setData(Qt.UserRole, element)
+            self.pageContent.customDirList.addItem(item)
         
     def _disableCustomDir(self):
         self.pageContent.customDirList.setEnabled(False)
@@ -52,14 +61,50 @@ class BToolchainPage(BWizardPage):
         self.pageContent.addDirButton.setEnabled(True)
         self.pageContent.removeDirButton.setEnabled(True)
     
-    def _toSearchSubpage(self):
-        self.pageContent.pageSelector.setCurrentIndex(1)
-    
-    def _toSelectionSubpage(self):
-        self.pageContent.pageSelector.setCurrentIndex(0)
+    def _clearList(self):
+        self.pageContent.toolchainList.clear()
     
     def _connectSignals(self):
         self.connect(self.pageContent.pathBox, SIGNAL("clicked()"), self._updateUi)
         self.connect(self.pageContent.customDirBox, SIGNAL("clicked()"), self._updateUi)
-        self.connect(self.pageContent.searchButton, SIGNAL("clicked()"), self._toSearchSubpage)
-        self.connect(self.pageContent.cancelButton, SIGNAL("clicked()"), self._toSelectionSubpage)
\ No newline at end of file
+        self.connect(self.pageContent.searchButton, SIGNAL("clicked()"), self.toSearchSubpage)
+        self.connect(self.pageContent.cancelButton, SIGNAL("clicked()"), self.toSelectionSubpage)
+        self.connect(self.pageContent.doSearchButton, SIGNAL("clicked()"), self.doSearch)
+        self.connect(self.pageContent.addDirButton, SIGNAL("clicked()"), self.addDir)
+        self.connect(self.pageContent.removeDirButton, SIGNAL("clicked()"), self.removeDir)
+    
+    def toSearchSubpage(self):
+        self.pageContent.pageSelector.setCurrentIndex(1)
+
+    def toSelectionSubpage(self):
+        self.pageContent.pageSelector.setCurrentIndex(0)    
+
+    def doSearch(self):
+        path = []
+        if self.pageContent.pathBox.isChecked():
+            path += bertos_utils.getSystemPath()
+        if self.pageContent.customDirBox.isChecked():
+            for element in range(self.pageContent.customDirList.count()):
+                path += [unicode(self.pageContent.customDirList.item(element).data(Qt.UserRole).toString())]
+        toolchains = bertos_utils.findToolchains(path)
+        self._clearList()
+        for toolchain in toolchains:
+            self.pageContent.toolchainList.addItem(QListWidgetItem(toolchain))
+        self.toSelectionSubpage()
+    
+    def addDir(self):
+        directory = QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "", QFileDialog.ShowDirsOnly)
+        if not directory.isEmpty():
+            item = QListWidgetItem(directory)
+            item.setData(Qt.UserRole, QVariant(directory))
+            self.pageContent.customDirList.addItem(item)
+            search_dir_list = self._settingsRetrieve("search_dir_list").toList()
+            search_dir_list = set([d.toString() for d in search_dir_list] + [directory])
+            self._settingsStore("search_dir_list", list(search_dir_list))
+    
+    def removeDir(self):
+        item = self.pageContent.customDirList.takeItem(self.pageContent.customDirList.currentRow())
+        search_dir_list = self._settingsRetrieve("search_dir_list").toList()
+        search_dir_list = set([d.toString() for d in search_dir_list])
+        search_dir_list.remove(item.data(Qt.UserRole).toString())
+        self._settingsStore("search_dir_list", list(search_dir_list))
\ No newline at end of file
index 79a64b27ac57d40e8f29f0d52e3b054dfd0b341c..8694e623f0ebc91d6dbd868a30ab8c00ed8fbf6f 100644 (file)
@@ -28,7 +28,7 @@
       </sizepolicy>
      </property>
      <property name="currentIndex" >
-      <number>0</number>
+      <number>1</number>
      </property>
      <widget class="QWidget" name="page" >
       <layout class="QVBoxLayout" name="verticalLayout_6" >