Add comment for each method and class
[bertos.git] / wizard / BWizardPage.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 #
4 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
5 # All rights reserved.
6 #
7 # $Id:$
8 #
9 # Author: Lorenzo Berni <duplo@develer.com>
10 #
11
12 from PyQt4.QtCore import *
13 from PyQt4.QtGui import *
14 from PyQt4 import uic
15
16 import qvariant_converter
17
18 class BWizardPage(QWizardPage):
19     """
20     Base class for all the wizard pages. It has the utility method used in all
21     the pages. A wizard page class need to extend this class.
22     """
23     
24     def __init__(self, wizardGui, parent = None):
25         QWizardPage.__init__(self, parent)
26         self.pageContent = uic.loadUi(wizardGui, None)
27         layout = QVBoxLayout()
28         layout.addWidget(self.pageContent)
29         self.setLayout(layout)
30     
31     def _exceptionOccurred(self, message):
32         """
33         Simple message box showing method.
34         """
35         QMessageBox.critical(self, self.tr("Error occurred"), message, QMessageBox.Ok, QMessageBox.NoButton)
36     
37     def _settingsStore(self, key, value):
38         """
39         Stores the given value in the QSettings associated with the given key.
40         """
41         QApplication.instance().settings.setValue(QString(key), value)
42     
43     def _settingsRetrieve(self, key):
44         """
45         Retrieves the value associated to key in the QSettings. Note that this
46         Value is a QVariant and neet to be converted in a standard type.
47         """
48         return QApplication.instance().settings.value(QString(key), QVariant())
49     
50     def _projectInfoStore(self, key, value):
51         """
52         Stores the given value in the BProject class associating it with the given
53         key.
54         """
55         QApplication.instance().project.setInfo(key, value)
56     
57     def _projectInfoRetrieve(self, key):
58         """
59         Retrieves the information associated with the given key.
60         """
61         return QApplication.instance().project.info(key)
62     
63     def _project(self):
64         """
65         Returns the BProject instance.
66         """
67         return QApplication.instance().project
68
69     def versions(self):
70         """
71         Returns the version list from the QSettings.
72         """
73         return qvariant_converter.getStringList(self._settingsRetrieve("versions"))
74     
75     def setVersions(self, versions):
76         """
77         Stores the given versions in the QSettings.
78         """
79         self._settingsStore("versions", qvariant_converter.convertStringList(versions))
80         
81     def searchDirList(self):
82         """
83         Returns the search dir list from the QSettings.
84         """
85         return qvariant_converter.getStringList(self._settingsRetrieve("search_dir_list"))
86     
87     def setSearchDirList(self, search_dir_list):
88         """
89         Stores the search dir list in the QSettings.
90         """
91         self._settingsStore("search_dir_list", qvariant_converter.convertStringList(search_dir_list))
92     
93     def pathSearch(self):
94         """
95         Returns the value of path search from the QSettings.
96         """
97         return qvariant_converter.getBool(self._settingsRetrieve("path_search"))
98     
99     def setPathSearch(self, path_search):
100         """
101         Stores the path search value in the QSettings.
102         """
103         self._settingsStore("path_search", qvariant_converter.convertBool(path_search))
104     
105     def toolchains(self):
106         """
107         Returns the toolchains stored in the QSettings.
108         """
109         return qvariant_converter.getBoolDict(self._settingsRetrieve("toolchains"))
110
111     def setToolchains(self, toolchains):
112         """
113         Stores the toolchains in the QSettings.
114         """
115         self._settingsStore("toolchains", qvariant_converter.convertBoolDict(toolchains))
116     
117     def reloadData(self):
118         """
119         Method called before the page is loaded. The pages that need to use this
120         method have to implement it.
121         """
122         pass