From ca1a17d62748010cd95a0012f67a9e80c6565d73 Mon Sep 17 00:00:00 2001 From: duplo Date: Tue, 31 Mar 2009 15:04:55 +0000 Subject: [PATCH] Add comment for each method and class git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2452 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BCpuPage.py | 24 +++++++++ wizard/BFinalPage.py | 6 +++ wizard/BFolderPage.py | 28 ++++++++++ wizard/BModulePage.py | 103 ++++++++++++++++++++++++++++++++++++- wizard/BOutputPage.py | 9 ++++ wizard/BProject.py | 9 ++++ wizard/BToolchainPage.py | 58 +++++++++++++++++++-- wizard/BToolchainSearch.py | 27 ++++++++++ wizard/BVersionPage.py | 42 +++++++++++++-- wizard/BWizard.py | 16 ++++++ wizard/BWizardPage.py | 55 ++++++++++++++++++-- 11 files changed, 366 insertions(+), 11 deletions(-) diff --git a/wizard/BCpuPage.py b/wizard/BCpuPage.py index abf0251f..702248a8 100644 --- a/wizard/BCpuPage.py +++ b/wizard/BCpuPage.py @@ -17,6 +17,9 @@ import qvariant_converter from const import * class BCpuPage(BWizardPage): + """ + Page of the wizard that permits to choose the cpu from the supported ones. + """ def __init__(self): BWizardPage.__init__(self, UI_LOCATION + "/cpu_select.ui") @@ -25,6 +28,9 @@ class BCpuPage(BWizardPage): self._setupUi() def _populateCpuList(self): + """ + Fills the cpu list. + """ self.pageContent.cpuList.clear() self.pageContent.cpuList.setCurrentItem(None) infos = bertos_utils.loadCpuInfos(self._project()) @@ -34,19 +40,31 @@ class BCpuPage(BWizardPage): self.pageContent.cpuList.addItem(item) def _connectSignals(self): + """ + Connects the signals with the related slots. + """ self.connect(self.pageContent.cpuList, SIGNAL("itemSelectionChanged()"), self.rowChanged) def _selectItem(self, cpu): + """ + Selects the given cpu from the list. + """ elements = self.pageContent.cpuList.findItems(cpu, Qt.MatchCaseSensitive) if len(elements) == 1: self.pageContent.cpuList.setCurrentItem(elements[0]) def _setupUi(self): + """ + Sets up the user interface. + """ self.pageContent.cpuList.setSortingEnabled(True) self.pageContent.descriptionLabel.setVisible(False) self.pageContent.descriptionLabel.setText("") def reloadData(self): + """ + Overload of the BWizardPage reloadData method. + """ QApplication.instance().setOverrideCursor(Qt.WaitCursor) bertos_utils.loadSourceTree(self._project()) self._populateCpuList() @@ -58,6 +76,9 @@ class BCpuPage(BWizardPage): self.emit(SIGNAL("completeChanged()")) def isComplete(self): + """ + Overload of the QWizardPage isComplete method. + """ if self.pageContent.cpuList.currentRow() != -1: infos = qvariant_converter.getDict(self.pageContent.cpuList.currentItem().data(Qt.UserRole)) for key, value in infos.items(): @@ -72,6 +93,9 @@ class BCpuPage(BWizardPage): return False def rowChanged(self): + """ + Slot called when the user select an entry from the cpu list. + """ description = qvariant_converter.getDict(self.pageContent.cpuList.currentItem().data(Qt.UserRole))["CPU_DESC"] description = qvariant_converter.getStringList(description) self.pageContent.descriptionLabel.setText("
".join(description)) diff --git a/wizard/BFinalPage.py b/wizard/BFinalPage.py index 04b1f507..af690eeb 100644 --- a/wizard/BFinalPage.py +++ b/wizard/BFinalPage.py @@ -19,12 +19,18 @@ import bertos_utils from const import * class BFinalPage(BWizardPage): + """ + Last page of the wizard. It creates the project and show a success message. + """ def __init__(self): BWizardPage.__init__(self, UI_LOCATION + "/final_page.ui") self.setTitle(self.tr("Project created successfully")) def reloadData(self): + """ + Overload of the BWizardPage reloadData method. + """ QApplication.instance().setOverrideCursor(Qt.WaitCursor) bertos_utils.createBertosProject(self.wizard().project()) QApplication.instance().restoreOverrideCursor() \ No newline at end of file diff --git a/wizard/BFolderPage.py b/wizard/BFolderPage.py index 7de7fc73..a6fdc7a1 100644 --- a/wizard/BFolderPage.py +++ b/wizard/BFolderPage.py @@ -18,6 +18,10 @@ import bertos_utils from const import * class BFolderPage(BWizardPage): + """ + Initial page of the wizard. Permit to select the project name and the directory + where the project will be created. + """ def __init__(self): BWizardPage.__init__(self, UI_LOCATION + "/dir_select.ui") @@ -27,27 +31,45 @@ class BFolderPage(BWizardPage): self._connectSignals() def _setupUi(self): + """ + Sets up the user interface. + """ self.pageContent.warningLabel.setVisible(False) def _initializeAttributes(self): + """ + Initializes the page attributes to the default values. + """ self._project_name = "" self._destination_folder = os.path.expanduser("~") self.pageContent.directoryEdit.setText(self._destination_folder) def _connectSignals(self): + """ + Connects the signals to the related slots. + """ self.connect(self.pageContent.nameEdit, SIGNAL("textChanged(const QString)"), self._nameChanged) self.connect(self.pageContent.directoryEdit, SIGNAL("textChanged(const QString)"), self._directoryChanged) self.connect(self.pageContent.directoryButton, SIGNAL("clicked()"), self._selectDirectory) def _nameChanged(self, name): + """ + Slot called when the project name is changed manually by the user. + """ self._project_name = str(name).replace(" ", "_") self._setProjectPath() def _directoryChanged(self, directory): + """ + Slot called when the project folder is changed manually by the user. + """ self._destination_folder = str(QDir.toNativeSeparators(directory)) self._setProjectPath() def _setProjectPath(self): + """ + Analyzes the page attributes and generates the path string. + """ if self._destination_folder != "" and self._project_name <> "": if not self._destination_folder.endswith(os.sep): self._destination_folder += "/" @@ -66,11 +88,17 @@ class BFolderPage(BWizardPage): self.emit(SIGNAL("completeChanged()")) def _selectDirectory(self): + """ + Slot called when the project folder is changed using the file dialog. + """ directory = unicode(QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "", QFileDialog.ShowDirsOnly)) if len(directory) > 0: self.pageContent.directoryEdit.setText(directory) def isComplete(self): + """ + Overload of the QWizardPage isComplete method. + """ if self.pageContent.projectPath.text() != "None": self._projectInfoStore("PROJECT_PATH", unicode(self.pageContent.projectPath.text())) return True diff --git a/wizard/BModulePage.py b/wizard/BModulePage.py index 5fd3abc8..2a5e0a42 100644 --- a/wizard/BModulePage.py +++ b/wizard/BModulePage.py @@ -19,6 +19,9 @@ from DefineException import * from const import * class BModulePage(BWizardPage): + """ + Page of the wizard that permits to select and configurate the BeRTOS modules. + """ def __init__(self): BWizardPage.__init__(self, UI_LOCATION + "/module_select.ui") @@ -27,6 +30,9 @@ class BModulePage(BWizardPage): self._connectSignals() def reloadData(self): + """ + Overload of the BWizardPage reloadData method. + """ QApplication.instance().setOverrideCursor(Qt.WaitCursor) self._setupUi() self._loadModuleData() @@ -34,11 +40,17 @@ class BModulePage(BWizardPage): QApplication.instance().restoreOverrideCursor() def _setupButtonGroup(self): + """ + Sets up the button group. + """ self._button_group = QButtonGroup() self._button_group.setExclusive(False) self.connect(self._button_group, SIGNAL("buttonClicked(int)"), self._moduleSelectionChanged) def _loadModuleData(self): + """ + Loads the module data. + """ ## Load the module data only if it isn't already loaded if self._projectInfoRetrieve("MODULES") == None \ and self._projectInfoRetrieve("LISTS") == None \ @@ -53,6 +65,9 @@ class BModulePage(BWizardPage): self._exceptionOccurred(self.tr("Error parsing line '%2' in file %1").arg(e.path).arg(e.line)) def _fillModuleTree(self): + """ + Fills the module tree with the module entries separated in categories. + """ modules = self._projectInfoRetrieve("MODULES") if modules is None: return @@ -75,6 +90,11 @@ class BModulePage(BWizardPage): def _fillPropertyTable(self): + """ + Slot called when the user selects a module from the module tree. + Fills the property table using the configuration parameters defined in + the source tree. + """ module = self._currentModule() if module is not None: self._control_group.clear() @@ -114,7 +134,10 @@ class BModulePage(BWizardPage): self.pageContent.moduleLabel.setText(module_label) def _insertCheckBox(self, index, value): - ## boolean property + """ + Inserts in the table at index a checkbox for a boolean property setted + to value. + """ check_box = QCheckBox() self.pageContent.propertyTable.setCellWidget(index, 1, check_box) if value == "1": @@ -124,7 +147,10 @@ class BModulePage(BWizardPage): self._control_group.addControl(index, check_box) def _insertComboBox(self, index, value, value_list): - ## enum property + """ + Inserts in the table at index a combobox for an enum property setted + to value. + """ try: enum = self._projectInfoRetrieve("LISTS")[value_list] combo_box = QComboBox() @@ -139,6 +165,10 @@ class BModulePage(BWizardPage): self.pageContent.propertyTable.setItem(index, 1, QTableWidgetItem(value)) def _insertSpinBox(self, index, value, informations): + """ + Inserts in the table at index a spinbox for an int, a long or an unsigned + long property setted to value. + """ ## int, long or undefined type property spin_box = None if bertos_utils.isLong(informations) or bertos_utils.isUnsignedLong(informations): @@ -173,6 +203,9 @@ class BModulePage(BWizardPage): def _currentModule(self): + """ + Retuns the current module name. + """ current_module = self.pageContent.moduleTree.currentItem() # return only the child items if current_module is not None and current_module.parent() is not None: @@ -181,15 +214,27 @@ class BModulePage(BWizardPage): return None def _currentModuleConfigurations(self): + """ + Returns the current module configuration. + """ return self._configurations(self._currentModule()) def _currentProperty(self): + """ + Rerturns the current property from the property table. + """ return qvariant_converter.getString(self.pageContent.propertyTable.item(self.pageContent.propertyTable.currentRow(), 0).data(Qt.UserRole)) def _currentPropertyItem(self): + """ + Returns the QTableWidgetItem of the current property. + """ return self.pageContent.propertyTable.item(self.pageContent.propertyTable.currentRow(), 0) def _configurations(self, module): + """ + Returns the configuration for the selected module. + """ configuration = self._projectInfoRetrieve("MODULES")[module]["configuration"] if len(configuration) > 0: return self._projectInfoRetrieve("CONFIGURATIONS")[configuration] @@ -197,6 +242,9 @@ class BModulePage(BWizardPage): return {} def _resetPropertyDescription(self): + """ + Resets the label for each property table entry. + """ for index in range(self.pageContent.propertyTable.rowCount()): property_name = qvariant_converter.getString(self.pageContent.propertyTable.item(index, 0).data(Qt.UserRole)) # Awful solution! Needed because if the user change the module, the selection changed... @@ -205,6 +253,10 @@ class BModulePage(BWizardPage): self.pageContent.propertyTable.item(index, 0).setText(self._currentModuleConfigurations()[property_name]['brief']) def _showPropertyDescription(self): + """ + Slot called when the property selection changes. Shows the description + of the selected property. + """ self._resetPropertyDescription() configurations = self._currentModuleConfigurations() if self._currentProperty() in configurations.keys(): @@ -213,6 +265,9 @@ class BModulePage(BWizardPage): self._currentPropertyItem().setText(description + "\n" + name) def _setupUi(self): + """ + Set up the user interface. + """ self.pageContent.moduleTree.clear() self.pageContent.moduleTree.setHeaderHidden(True) self.pageContent.propertyTable.horizontalHeader().setResizeMode(QHeaderView.Stretch) @@ -224,12 +279,18 @@ class BModulePage(BWizardPage): self.pageContent.moduleLabel.setVisible(False) def _connectSignals(self): + """ + Connect the signals with the related slots. + """ self.connect(self.pageContent.moduleTree, SIGNAL("itemPressed(QTreeWidgetItem*, int)"), self._fillPropertyTable) self.connect(self.pageContent.moduleTree, SIGNAL("itemChanged(QTreeWidgetItem*, int)"), self._dependencyCheck) self.connect(self.pageContent.propertyTable, SIGNAL("itemSelectionChanged()"), self._showPropertyDescription) self.connect(self._control_group, SIGNAL("stateChanged"), self._saveValue) def _saveValue(self, index): + """ + Slot called when the user modifies one of the configuration parameters. + It stores the new value.""" property = qvariant_converter.getString(self.pageContent.propertyTable.item(index, 0).data(Qt.UserRole)) configuration = self._projectInfoRetrieve("MODULES")[self._currentModule()]["configuration"] configurations = self._projectInfoRetrieve("CONFIGURATIONS") @@ -245,6 +306,10 @@ class BModulePage(BWizardPage): self._projectInfoStore("CONFIGURATIONS", configurations) def _moduleSelectionChanged(self, index): + """ + Slot called when the user selects or unselects a module from the module + tree. + """ module = unicode(self.pageContent.moduleTable.item(index, 1).text()) if self._button_group.button(index).isChecked(): self._moduleSelected(module) @@ -252,6 +317,9 @@ class BModulePage(BWizardPage): self._moduleUnselected(module) def _dependencyCheck(self, item): + """ + Checks the dependencies of the module associated with the given item. + """ checked = False module = unicode(item.text(0)) if item.checkState(0) == Qt.Checked: @@ -261,6 +329,9 @@ class BModulePage(BWizardPage): self.removeFileDependencies(module) def _moduleSelected(self, selectedModule): + """ + Resolves the selection dependencies. + """ modules = self._projectInfoRetrieve("MODULES") modules[selectedModule]["enabled"] = True self._projectInfoStore("MODULES", modules) @@ -279,6 +350,9 @@ class BModulePage(BWizardPage): item.child(child).setCheckState(0, Qt.Checked) def _moduleUnselected(self, unselectedModule): + """ + Resolves the unselection dependencies. + """ modules = self._projectInfoRetrieve("MODULES") modules[unselectedModule]["enabled"] = False self._projectInfoStore("MODULES", modules) @@ -300,6 +374,9 @@ class BModulePage(BWizardPage): item.child(child).setCheckState(0, Qt.Unchecked) def selectDependencyCheck(self, module): + """ + Returns the list of unsatisfied dependencies after a selection. + """ unsatisfied = set() modules = self._projectInfoRetrieve("MODULES") files = self._projectInfoRetrieve("FILES") @@ -317,6 +394,9 @@ class BModulePage(BWizardPage): return unsatisfied def unselectDependencyCheck(self, dependency): + """ + Returns the list of unsatisfied dependencies after an unselection. + """ unsatisfied = set() modules = self._projectInfoRetrieve("MODULES") for module, informations in modules.items(): @@ -327,6 +407,9 @@ class BModulePage(BWizardPage): return unsatisfied def removeFileDependencies(self, module): + """ + Removes the files dependencies of the given module. + """ modules = self._projectInfoRetrieve("MODULES") files = self._projectInfoRetrieve("FILES") dependencies = modules[module]["depends"] @@ -338,11 +421,20 @@ class BModulePage(BWizardPage): self._projectInfoStore("FILES", files) class QControlGroup(QObject): + """ + Simple class that permit to connect different signals of different widgets + with a slot that emit a signal. Permits to group widget and to understand which of + them has sent the signal. + """ + def __init__(self): QObject.__init__(self) self._controls = {} def addControl(self, id, control): + """ + Add a control. + """ self._controls[id] = control if type(control) == QCheckBox: self.connect(control, SIGNAL("stateChanged(int)"), lambda: self._stateChanged(id)) @@ -354,7 +446,14 @@ class QControlGroup(QObject): self.connect(control, SIGNAL("valueChanged(double)"), lambda: self._stateChanged(id)) def clear(self): + """ + Remove all the controls. + """ self._controls = {} def _stateChanged(self, id): + """ + Slot called when the value of one of the stored widget changes. It emits + another signal. + """ self.emit(SIGNAL("stateChanged"), id) \ No newline at end of file diff --git a/wizard/BOutputPage.py b/wizard/BOutputPage.py index c8e22c9f..fb7eaade 100644 --- a/wizard/BOutputPage.py +++ b/wizard/BOutputPage.py @@ -18,6 +18,9 @@ import bertos_utils from const import * class BOutputPage(BWizardPage): + """ + Page of the wizard that show a little summary of the previous decisions. + """ def __init__(self): BWizardPage.__init__(self, UI_LOCATION + "/output_select.ui") @@ -26,11 +29,17 @@ class BOutputPage(BWizardPage): self._projectInfoStore("OUTPUT", []) def _connectSignals(self): + """ + Connects the signals with the related slots. + """ self.connect(self.pageContent.eclipseCheckBox, SIGNAL("stateChanged(int)"), lambda checked: self._modeChecked(checked, "eclipse")) self.connect(self.pageContent.xcodeCheckBox, SIGNAL("stateChanged(int)"), lambda checked: self._modeChecked(checked, "xcode")) self.connect(self.pageContent.codeliteCheckBox, SIGNAL("stateChanged(int)"), lambda checked: self._modeChecked(checked, "codelite")) def _modeChecked(self, checked, value): + """ + Slot called when one of the mode checkbox is checked. It stores it. + """ output_list = self._projectInfoRetrieve("OUTPUT") if checked == Qt.Checked: output_list.append(value) diff --git a/wizard/BProject.py b/wizard/BProject.py index 08bac0f0..54db258a 100644 --- a/wizard/BProject.py +++ b/wizard/BProject.py @@ -10,14 +10,23 @@ # class BProject(object): + """ + Simple class for store and retrieve project informations. + """ def __init__(self): self.infos = {} def setInfo(self, key, value): + """ + Store the given value with the name key. + """ self.infos[key] = value def info(self, key): + """ + Retrieve the value associated with the name key. + """ if key in self.infos.keys(): return self.infos[key] return None diff --git a/wizard/BToolchainPage.py b/wizard/BToolchainPage.py index 7cd722a1..0736a99a 100644 --- a/wizard/BToolchainPage.py +++ b/wizard/BToolchainPage.py @@ -20,19 +20,29 @@ import qvariant_converter from const import * class BToolchainPage(BWizardPage): + """ + Page of the wizard that permits to choose the toolchain to use for the + project. + """ def __init__(self): BWizardPage.__init__(self, UI_LOCATION + "/toolchain_select.ui") self.setTitle(self.tr("Select toolchain")) self._validation_process = None - self._updateUi() + self._setupUi() #self._populateToolchainList() self._connectSignals() - def _updateUi(self): + def _setupUi(self): + """ + Sets up the user interface. + """ self.pageContent.infoLabel.setVisible(False) def _populateToolchainList(self): + """ + Fills the toolchain list with the toolchains stored in the QSettings. + """ toolchains = self.toolchains() sel_toolchain = self._projectInfoRetrieve("TOOLCHAIN") for key, value in toolchains.items(): @@ -45,9 +55,15 @@ class BToolchainPage(BWizardPage): self.validateToolchain(self.pageContent.toolchainList.row(item)) def _clearList(self): + """ + Removes all the toolchain from the list. + """ self.pageContent.toolchainList.clear() def _selectionChanged(self): + """ + Slot called when the user click on an entry of the toolchain list. + """ if self.pageContent.toolchainList.currentRow() != -1: infos = collections.defaultdict(lambda: unicode("not defined")) infos.update(qvariant_converter.getStringDict(self.pageContent.toolchainList.currentItem().data(Qt.UserRole))) @@ -56,6 +72,10 @@ class BToolchainPage(BWizardPage): self.emit(SIGNAL("completeChanged()")) def _search(self): + """ + Searches for toolchains in the stored directories, and stores them in the + QSettings. + """ dir_list = self.searchDirList() if self.pathSearch(): dir_list += [element for element in bertos_utils.getSystemPath()] @@ -70,6 +90,9 @@ class BToolchainPage(BWizardPage): self.setToolchains(stored_toolchains) def _connectSignals(self): + """ + Connects the signals with the related slots. + """ self.connect(self.pageContent.toolchainList, SIGNAL("itemSelectionChanged()"), self._selectionChanged) self.connect(self.pageContent.addButton, SIGNAL("clicked()"), self.addToolchain) self.connect(self.pageContent.removeButton, SIGNAL("clicked()"), self.removeToolchain) @@ -77,6 +100,9 @@ class BToolchainPage(BWizardPage): self.connect(self.pageContent.checkButton, SIGNAL("clicked()"), self.validateAllToolchains) def _validItem(self, index, infos): + """ + Sets the item at index as a valid item and associates the given info to it. + """ item = self.pageContent.toolchainList.item(index) new_data = qvariant_converter.getStringDict(self.pageContent.toolchainList.item(index).data(Qt.UserRole)) new_data.update(infos) @@ -90,10 +116,16 @@ class BToolchainPage(BWizardPage): item.setText("GCC " + infos["version"] + " - " + infos["target"]) def _invalidItem(self, index): + """ + Sets the item at index as an invalid item. + """ item = self.pageContent.toolchainList.item(index) item.setIcon(QIcon(":/images/error.png")) def addToolchain(self): + """ + Slot called when the user adds manually a toolchain. + """ sel_toolchain = QFileDialog.getOpenFileName(self, self.tr("Choose the toolchain"), "") if not sel_toolchain.isEmpty(): item = QListWidgetItem(sel_toolchain) @@ -104,6 +136,9 @@ class BToolchainPage(BWizardPage): self.setToolchains(toolchains) def removeToolchain(self): + """ + Slot called when the user removes manually a toolchain. + """ if self.pageContent.toolchainList.currentRow() != -1: item = self.pageContent.toolchainList.takeItem(self.pageContent.toolchainList.currentRow()) toolchain = qvariant_converter.getStringDict(item.data(Qt.UserRole))["path"] @@ -112,17 +147,28 @@ class BToolchainPage(BWizardPage): self.setToolchains(toolchains) def searchToolchain(self): + """ + Slot called when the user clicks on the 'search' button. It opens the + toolchain search dialog. + """ search = BToolchainSearch.BToolchainSearch() self.connect(search, SIGNAL("accepted()"), self._search) search.exec_() def validateAllToolchains(self): + """ + Slot called when the user clicks on the validate button. It starts the + toolchain validation procedure for all the toolchains. + """ QApplication.instance().setOverrideCursor(Qt.WaitCursor) for i in range(self.pageContent.toolchainList.count()): self.validateToolchain(i) QApplication.instance().restoreOverrideCursor() def validateToolchain(self, i): + """ + Toolchain validation procedure. + """ filename = qvariant_converter.getStringDict(self.pageContent.toolchainList.item(i).data(Qt.UserRole))["path"] valid = False info = {} @@ -155,6 +201,9 @@ class BToolchainPage(BWizardPage): self.setToolchains(toolchains) def isComplete(self): + """ + Overload of the QWizard isComplete method. + """ if self.pageContent.toolchainList.currentRow() != -1: self._projectInfoStore("TOOLCHAIN", qvariant_converter.getStringDict(self.pageContent.toolchainList.currentItem().data(Qt.UserRole))) @@ -163,6 +212,9 @@ class BToolchainPage(BWizardPage): return False def reloadData(self): + """ + Overload of the BWizard reloadData method. + """ self._clearList() - self._updateUi() + self._setupUi() self._populateToolchainList() \ No newline at end of file diff --git a/wizard/BToolchainSearch.py b/wizard/BToolchainSearch.py index 0290c0ea..ddebf7ce 100644 --- a/wizard/BToolchainSearch.py +++ b/wizard/BToolchainSearch.py @@ -18,6 +18,9 @@ import qvariant_converter from const import * class BToolchainSearch(QDialog): + """ + Dialog that permits to choice the settings for the toolchain search procedure. + """ def __init__(self): QDialog.__init__(self) @@ -26,6 +29,9 @@ class BToolchainSearch(QDialog): self.setWindowTitle(self.tr("Toolchain search page")) def _setupUi(self): + """ + Sets up the user interface. + """ self.content = uic.loadUi(UI_LOCATION + "/toolchain_search.ui", None) layout = QVBoxLayout() layout.addWidget(self.content) @@ -35,6 +41,9 @@ class BToolchainSearch(QDialog): self._setSearchButton() def _connectSignals(self): + """ + Connects the signals with the related slots. + """ self.connect(self.content.pathBox, SIGNAL("stateChanged(int)"), self._stateChanged) self.connect(self.content.addButton, SIGNAL("clicked()"), self._addDir) self.connect(self.content.removeButton, SIGNAL("clicked()"), self._removeDir) @@ -42,24 +51,39 @@ class BToolchainSearch(QDialog): self.connect(self.content.searchButton, SIGNAL("clicked()"), self.accept) def _setSearchButton(self): + """ + Toggles the 'searchButton' evaluating the settings. + """ self.content.searchButton.setDefault(True) self.content.searchButton.setEnabled(self.content.pathBox.isChecked() or self.content.customDirList.count() != 0) def _populateDirList(self): + """ + Fills the dir list with the directories stored in the QSettings. + """ search_dir_list = qvariant_converter.getStringList(QApplication.instance().settings.value("search_dir_list")) for element in search_dir_list: item = QListWidgetItem(element) self.content.customDirList.addItem(item) def _setPathSearch(self): + """ + Sets the path search checkbox to the stored value. + """ pathSearch = qvariant_converter.getBool(QApplication.instance().settings.value(QString("path_search"))) self.content.pathBox.setChecked(pathSearch) def _stateChanged(self, state): + """ + Slot called when the path search checkbox state changes. Stores the value in the QSettings. + """ QApplication.instance().settings.setValue(QString("path_search"), QVariant(state != 0)) self._setSearchButton() def _addDir(self): + """ + Slot called when the user adds a dir. + """ directory = QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "", QFileDialog.ShowDirsOnly) if not directory.isEmpty(): directory = unicode(directory) @@ -71,6 +95,9 @@ class BToolchainSearch(QDialog): self._setSearchButton() def _removeDir(self): + """ + Slot called when the user removes a dir. + """ if self.content.customDirList.currentRow() != -1: item = self.content.customDirList.takeItem(self.content.customDirList.currentRow()) search_dir_list = qvariant_converter.getStringList(QApplication.instance().settings.value(QString("search_dir_list"))) diff --git a/wizard/BVersionPage.py b/wizard/BVersionPage.py index bd78fe01..d9097a32 100644 --- a/wizard/BVersionPage.py +++ b/wizard/BVersionPage.py @@ -19,6 +19,10 @@ import qvariant_converter from const import * class BVersionPage(BWizardPage): + """ + Page of the wizard that permits to choose which BeRTOS version the user wants + to use. This page show some pieces of information about the version. + """ def __init__(self): BWizardPage.__init__(self, UI_LOCATION + "/bertos_versions.ui") @@ -28,6 +32,9 @@ class BVersionPage(BWizardPage): self.setTitle(self.tr("Select the BeRTOS version needed")) def _connectSignals(self): + """ + Connects the signals to the related slots. + """ self.connect(self.pageContent.versionList, SIGNAL("itemSelectionChanged()"), self.rowChanged) self.connect(self.pageContent.addButton, SIGNAL("clicked()"), self.addVersion) self.connect(self.pageContent.removeButton, SIGNAL("clicked()"), self.removeVersion) @@ -35,19 +42,31 @@ class BVersionPage(BWizardPage): self.connect(self.pageContent.updateButton, SIGNAL("clicked()"), self.updateClicked) def _setupUi(self): + """ + Sets up the user interface. + """ self.pageContent.versionList.setCurrentRow(-1) def _storeVersion(self, directory): + """ + Stores the directory selected by the user in the QSettings. + """ versions = self.versions() versions = set(versions + [directory]) self.setVersions(list(versions)) def _deleteVersion(self, directory): + """ + Removes the given directory from the QSettings. + """ versions = self.versions() versions.remove(directory) self.setVersions(versions) def _insertListElement(self, directory): + """ + Inserts the given directory in the version list. + """ if bertos_utils.isBertosDir(directory): item = QListWidgetItem(QIcon(":/images/ok.png"), bertos_utils.bertosVersion(directory) + " (\"" + os.path.normpath(directory) + "\")") item.setData(Qt.UserRole, qvariant_converter.convertString(directory)) @@ -58,11 +77,17 @@ class BVersionPage(BWizardPage): self.pageContent.versionList.addItem(item) def _fillVersionList(self): + """ + Fills the version list with all the BeRTOS versions founded in the QSettings. + """ versions = self.versions() for directory in versions: self._insertListElement(directory) def isComplete(self): + """ + Overload of the QWizardPage isComplete method. + """ if self.pageContent.versionList.currentRow() != -1: # Remove trailing slash sources_path = qvariant_converter.getString(self.pageContent.versionList.currentItem().data(Qt.UserRole)) @@ -74,6 +99,9 @@ class BVersionPage(BWizardPage): return False def addVersion(self): + """ + Slot called when the user add a BeRTOS version. + """ directory = QFileDialog.getExistingDirectory(self, self.tr("Choose a directory"), "", QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks) if not directory.isEmpty(): self._storeVersion(unicode(directory)) @@ -82,13 +110,21 @@ class BVersionPage(BWizardPage): self.emit(SIGNAL("completeChanged()")) def removeVersion(self): + """ + Slot called when the user remove a BeRTOS version. + """ item = self.pageContent.versionList.takeItem(self.pageContent.versionList.currentRow()) self._deleteVersion(qvariant_converter.getString(item.data(Qt.UserRole))) self.emit(SIGNAL("completeChanged()")) def updateClicked(self): - print "fake update checking" + """ + Checks for update (TO BE IMPLEMENTED). + """ + pass def rowChanged(self): - self.emit(SIGNAL("completeChanged()")) - + """ + Slot called when the user select an entry from the version list. + """ + self.emit(SIGNAL("completeChanged()")) \ No newline at end of file diff --git a/wizard/BWizard.py b/wizard/BWizard.py index a4309528..004fdf3e 100644 --- a/wizard/BWizard.py +++ b/wizard/BWizard.py @@ -24,6 +24,9 @@ import BCreationPage import BFinalPage class BWizard(QWizard): + """ + Main class of the wizard. It adds the pages automatically. + """ def __init__(self): QWizard.__init__(self) @@ -33,6 +36,9 @@ class BWizard(QWizard): self._connectSignals() def _addPages(self): + """ + Method used by the constructor in order to add the pages in the wizard. + """ self.addPage(BFolderPage.BFolderPage()) self.addPage(BVersionPage.BVersionPage()) self.addPage(BCpuPage.BCpuPage()) @@ -43,12 +49,22 @@ class BWizard(QWizard): self.addPage(BFinalPage.BFinalPage()) def _connectSignals(self): + """ + Connects the signals with the related slots. + """ self.connect(self, SIGNAL("currentIdChanged(int)"), self._pageChanged) def _pageChanged(self, pageId): + """ + Slot called when the user change the current page. It calls the reloadData + method of the next page. + """ page = self.page(pageId) if page is not None: page.reloadData() def project(self): + """ + Returns the BProject associated with the wizard. + """ return copy.deepcopy(QApplication.instance().project) diff --git a/wizard/BWizardPage.py b/wizard/BWizardPage.py index 81737e34..e1a815d1 100644 --- a/wizard/BWizardPage.py +++ b/wizard/BWizardPage.py @@ -16,6 +16,10 @@ from PyQt4 import uic import qvariant_converter class BWizardPage(QWizardPage): + """ + Base class for all the wizard pages. It has the utility method used in all + the pages. A wizard page class need to extend this class. + """ def __init__(self, wizardGui, parent = None): QWizardPage.__init__(self, parent) @@ -25,49 +29,94 @@ class BWizardPage(QWizardPage): self.setLayout(layout) def _exceptionOccurred(self, message): + """ + Simple message box showing method. + """ QMessageBox.critical(self, self.tr("Error occurred"), message, QMessageBox.Ok, QMessageBox.NoButton) def _settingsStore(self, key, value): + """ + Stores the given value in the QSettings associated with the given key. + """ QApplication.instance().settings.setValue(QString(key), value) def _settingsRetrieve(self, key): + """ + Retrieves the value associated to key in the QSettings. Note that this + Value is a QVariant and neet to be converted in a standard type. + """ return QApplication.instance().settings.value(QString(key), QVariant()) def _projectInfoStore(self, key, value): + """ + Stores the given value in the BProject class associating it with the given + key. + """ QApplication.instance().project.setInfo(key, value) def _projectInfoRetrieve(self, key): + """ + Retrieves the information associated with the given key. + """ return QApplication.instance().project.info(key) def _project(self): + """ + Returns the BProject instance. + """ return QApplication.instance().project def versions(self): + """ + Returns the version list from the QSettings. + """ return qvariant_converter.getStringList(self._settingsRetrieve("versions")) def setVersions(self, versions): + """ + Stores the given versions in the QSettings. + """ self._settingsStore("versions", qvariant_converter.convertStringList(versions)) def searchDirList(self): + """ + Returns the search dir list from the QSettings. + """ return qvariant_converter.getStringList(self._settingsRetrieve("search_dir_list")) def setSearchDirList(self, search_dir_list): + """ + Stores the search dir list in the QSettings. + """ self._settingsStore("search_dir_list", qvariant_converter.convertStringList(search_dir_list)) def pathSearch(self): + """ + Returns the value of path search from the QSettings. + """ return qvariant_converter.getBool(self._settingsRetrieve("path_search")) def setPathSearch(self, path_search): + """ + Stores the path search value in the QSettings. + """ self._settingsStore("path_search", qvariant_converter.convertBool(path_search)) def toolchains(self): + """ + Returns the toolchains stored in the QSettings. + """ return qvariant_converter.getBoolDict(self._settingsRetrieve("toolchains")) def setToolchains(self, toolchains): + """ + Stores the toolchains in the QSettings. + """ self._settingsStore("toolchains", qvariant_converter.convertBoolDict(toolchains)) def reloadData(self): + """ + Method called before the page is loaded. The pages that need to use this + method have to implement it. + """ pass - - def saveData(self): - pass \ No newline at end of file -- 2.25.1