4 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
9 # Author: Lorenzo Berni <duplo@develer.com>
12 from PyQt4.QtCore import *
13 from PyQt4.QtGui import *
16 import qvariant_converter
18 class BWizardPage(QWizardPage):
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.
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)
33 def exceptionOccurred(self, message):
35 Simple message box showing method.
37 QMessageBox.critical(self, self.tr("Error occurred"), message, QMessageBox.Ok, QMessageBox.NoButton)
39 ## BProject interaction methods ##
41 def setProjectInfo(self, key, value):
43 Stores the given value in the BProject class associating it with the given
46 QApplication.instance().project.setInfo(key, value)
48 def projectInfo(self, key):
50 Retrieves the information associated with the given key.
52 return QApplication.instance().project.info(key)
56 Returns the BProject instance.
58 return QApplication.instance().project
62 ## QSettings interaction methods ##
64 def settingsStore(self, key, value):
66 Stores the given value in the QSettings associated with the given key.
68 QApplication.instance().settings.setValue(QString(key), value)
70 def settingsRetrieve(self, key):
72 Retrieves the value associated to key in the QSettings. Note that this
73 Value is a QVariant and neet to be converted in a standard type.
75 return QApplication.instance().settings.value(QString(key), QVariant())
79 Returns the version list from the QSettings.
81 return qvariant_converter.getStringList(self.settingsRetrieve("versions"))
83 def setVersions(self, versions):
85 Stores the given versions in the QSettings.
87 self.settingsStore("versions", qvariant_converter.convertStringList(versions))
89 def searchDirList(self):
91 Returns the search dir list from the QSettings.
93 return qvariant_converter.getStringList(self.settingsRetrieve("search_dir_list"))
95 def setSearchDirList(self, search_dir_list):
97 Stores the search dir list in the QSettings.
99 self.settingsStore("search_dir_list", qvariant_converter.convertStringList(search_dir_list))
101 def pathSearch(self):
103 Returns the value of path search from the QSettings.
105 return qvariant_converter.getBool(self.settingsRetrieve("path_search"))
107 def setPathSearch(self, path_search):
109 Stores the path search value in the QSettings.
111 self.settingsStore("path_search", qvariant_converter.convertBool(path_search))
113 def toolchains(self):
115 Returns the toolchains stored in the QSettings.
117 return qvariant_converter.getBoolDict(self.settingsRetrieve("toolchains"))
119 def setToolchains(self, toolchains):
121 Stores the toolchains in the QSettings.
123 self.settingsStore("toolchains", qvariant_converter.convertBoolDict(toolchains))
127 ## Methodo to be implemented in child classes when needed ##
129 def reloadData(self):
131 Method called before the page is loaded. The pages that need to use this
132 method have to implement it.
138 Method called automatically during the initialization of the wizard page.
139 It set up the interface. Pages that need to use this method have to
144 def connectSignals(self):
146 Method called automatically during the initialization of the wizard page.
147 It connects the signals and the slots. The pages that need to use this
148 method have to implement it.