From: duplo Date: Mon, 15 Dec 2008 14:34:11 +0000 (+0000) Subject: Add the bertos versions in the settings X-Git-Tag: 2.1.0~651 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=aeeabf9cf483f9729f324baa2d50855e54bc0201;p=bertos.git Add the bertos versions in the settings git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2031 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/BVersionPage.py b/wizard/BVersionPage.py index 48bc75bb..752ace0e 100644 --- a/wizard/BVersionPage.py +++ b/wizard/BVersionPage.py @@ -18,6 +18,7 @@ class BVersionPage(BWizardPage): def __init__(self): BWizardPage.__init__(self, "bertos_versions.ui") self._connectSignals() + self._fillVersionList() self._setupUi() self.setTitle(self.tr("Select the beRTOS version needed")) @@ -31,17 +32,42 @@ class BVersionPage(BWizardPage): def _setupUi(self): pass - def addVersion(self): - directory = QFileDialog.getExistingDirectory(self, self.tr("Choose a directory"), QString(), QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks) + def _storeVersion(self, directory): + versions = self._settingsRetrieve("versions").toList() + versions = set([x.toString() for x in versions] + [directory]) + self._settingsStore("versions", list(versions)) + + def _deleteVersion(self, directory): + versions = self._settingsRetrieve(QString("versions")).toList() + versions = [x.toString() for x in versions] + versions.remove(directory) + self._settingsStore("versions", versions) + + def _insertListElement(self, directory): if bertos_utils.isBertosDir(directory): - version = bertos_utils.bertosVersion(directory) - self.pageContent.versionList.addItem(QListWidgetItem(QIcon(":/images/ok.png"), version + " (\"" + directory + "\")")) + item = QListWidgetItem(QIcon(":/images/ok.png"), bertos_utils.bertosVersion(directory) + " (\"" + directory + "\")") + item.setData(Qt.UserRole, QVariant(directory)) + self.pageContent.versionList.addItem(item) elif not directory.isEmpty(): - version = "UNCHECKED" - self.pageContent.versionList.addItem(QListWidgetItem(QIcon(":/images/warning.png"), version + " (\"" + directory + "\")")) + item = QListWidgetItem(QIcon(":/images/warning.png"), "UNKNOWN" + " (\"" + directory + "\")") + item.setData(Qt.UserRole, QVariant(directory)) + self.pageContent.versionList.addItem(item) + + def _fillVersionList(self): + versions = self._settingsRetrieve("versions").toList() + for directory in versions: + self._insertListElement(directory.toString()) + + def addVersion(self): + directory = QFileDialog.getExistingDirectory(self, self.tr("Choose a directory"), "", QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks) + if not directory.isEmpty(): + self._storeVersion(directory) + self.pageContent.versionList.clear() + self._fillVersionList() def removeVersion(self): - self.pageContent.versionList.takeItem(self.pageContent.versionList.currentRow()) + item = self.pageContent.versionList.takeItem(self.pageContent.versionList.currentRow()) + self._deleteVersion(item.data(Qt.UserRole).toString()) def updateClicked(self): print "fake update checking"