--- /dev/null
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# Copyright 2009 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# $Id:$
+#
+# Author: Lorenzo Berni <duplo@develer.com>
+#
+
+import os
+import pickle
+
+from PyQt4.QtGui import *
+from PyQt4.QtCore import *
+
+from BWizardPage import *
+import bertos_utils
+
+from const import *
+
+class BOpenPage(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 + "/project_select.ui")
+ self.setTitle(self.tr("Open an existing BeRTOS project"))
+
+ ## Overloaded BWizardPage methods ##
+
+ def reloadData(self):
+ project = unicode(QFileDialog.getOpenFileName(self, self.tr("Open project file"), os.path.expanduser("~"), self.tr("Project file (project.bertos)")))
+ if project == "":
+ QApplication.instance().quit()
+ else:
+ QApplication.instance().project = pickle.loads(open(project, "r").read())
+ self.pageContent.nameLabel.setText(os.path.basename(project.replace(os.sep + "project.bertos", "")))
+ self.pageContent.dirLabel.setText(project)
+
+ ####
+
## Overloaded BWizardPage methods ##
- def setupUi(self):
- """
- Overload of the BWizardPage setupUi method.
- """
- self.fillVersionList()
- self.pageContent.versionList.setCurrentRow(-1)
-
def connectSignals(self):
"""
Overload of the BWizardPage connectSignals method.
# Fake signal connection for the update button
self.connect(self.pageContent.updateButton, SIGNAL("clicked()"), self.updateClicked)
+ def reloadData(self):
+ """
+ Overload of the BWizardPage reloadData method.
+ """
+ self.pageContent.versionList.setCurrentRow(-1)
+ self.fillVersionList()
+
####
## Slots ##
def insertListElement(self, directory):
"""
- Inserts the given directory in the version list.
+ Inserts the given directory in the version list and returns the
+ inserted item.
"""
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))
self.pageContent.versionList.addItem(item)
+ return item
elif len(directory) > 0:
item = QListWidgetItem(QIcon(":/images/warning.png"), "UNKNOWN" + " (\"" + os.path.normpath(directory) + "\")")
item.setData(Qt.UserRole, qvariant_converter.convertString(directory))
self.pageContent.versionList.addItem(item)
+ return item
def fillVersionList(self):
"""
Fills the version list with all the BeRTOS versions founded in the QSettings.
"""
versions = self.versions()
+ selected = self.projectInfo("SOURCES_PATH")
for directory in versions:
- self.insertListElement(directory)
\ No newline at end of file
+ item = self.insertListElement(directory)
+ if not selected is None and selected == directory:
+ self.setCurrentItem(item)
+
+ def setCurrentItem(self, item):
+ """
+ Select the given item in the version list.
+ """
+ self.pageContent.versionList.setCurrentItem(item)
\ No newline at end of file
import BWizard
from BFolderPage import BFolderPage
+from BOpenPage import BOpenPage
from BVersionPage import BVersionPage
from BCpuPage import BCpuPage
from BToolchainPage import BToolchainPage
wizard.exec_()
def editProject():
- page_list = [BVersionPage, BCpuPage, BToolchainPage, BModulePage, BOutputPage, BCreationPage, BFinalPage]
+ page_list = [BOpenPage, BVersionPage, BCpuPage, BToolchainPage, BModulePage, BOutputPage, BCreationPage, BFinalPage]
wizard = BWizard.BWizard(page_list)
wizard.show()
wizard.exec_()
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>397</width>
+ <height>143</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetDefaultConstraint</enum>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Project name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Project folder:</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="nameLabel">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="dirLabel">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>