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 def showMessage(self, title, message):
41 Show an information message box with title and message.
43 QMessageBox.information(self, title, message)
45 ## BProject interaction methods ##
47 def setProjectInfo(self, key, value):
49 Stores the given value in the BProject class associating it with the given
52 QApplication.instance().project.setInfo(key, value)
54 def projectInfo(self, key):
56 Retrieves the information associated with the given key.
58 return QApplication.instance().project.info(key)
62 Returns the BProject instance.
64 return QApplication.instance().project
68 ## QSettings interaction methods ##
70 def settingsStore(self, key, value):
72 Stores the given value in the QSettings associated with the given key.
74 QApplication.instance().settings.setValue(QString(key), value)
76 def settingsRetrieve(self, key):
78 Retrieves the value associated to key in the QSettings. Note that this
79 Value is a QVariant and neet to be converted in a standard type.
81 return QApplication.instance().settings.value(QString(key), QVariant())
85 Returns the version list from the QSettings.
87 return qvariant_converter.getStringList(self.settingsRetrieve("versions"))
89 def setVersions(self, versions):
91 Stores the given versions in the QSettings.
93 self.settingsStore("versions", qvariant_converter.convertStringList(versions))
95 def searchDirList(self):
97 Returns the search dir list from the QSettings.
99 return qvariant_converter.getStringList(self.settingsRetrieve("search_dir_list"))
101 def setSearchDirList(self, search_dir_list):
103 Stores the search dir list in the QSettings.
105 self.settingsStore("search_dir_list", qvariant_converter.convertStringList(search_dir_list))
107 def pathSearch(self):
109 Returns the value of path search from the QSettings.
111 return qvariant_converter.getBool(self.settingsRetrieve("path_search"))
113 def setPathSearch(self, path_search):
115 Stores the path search value in the QSettings.
117 self.settingsStore("path_search", qvariant_converter.convertBool(path_search))
119 def toolchains(self):
121 Returns the toolchains stored in the QSettings.
123 return qvariant_converter.getBoolDict(self.settingsRetrieve("toolchains"))
125 def setToolchains(self, toolchains):
127 Stores the toolchains in the QSettings.
129 self.settingsStore("toolchains", qvariant_converter.convertBoolDict(toolchains))
131 def defaultFolder(self):
133 Returns the default save folder stored in the QSettings.
135 return qvariant_converter.getString(self.settingsRetrieve("folder"))
137 def setDefaultFolder(self, folder):
139 Stores the default save folder in the QSettings.
141 self.settingsStore("folder", qvariant_converter.convertString(folder))
145 ## Methodo to be implemented in child classes when needed ##
147 def reloadData(self):
149 Method called before the page is loaded. The pages that need to use this
150 method have to implement it.
156 Method called automatically during the initialization of the wizard page.
157 It set up the interface. Pages that need to use this method have to
162 def connectSignals(self):
164 Method called automatically during the initialization of the wizard page.
165 It connects the signals and the slots. The pages that need to use this
166 method have to implement it.