Mercurial > lcfOS
diff python/apps/ide.py @ 67:99bf4f7d47f4
Changed project storage
author | windel |
---|---|
date | Fri, 12 Oct 2012 16:11:31 +0200 |
parents | bcd55a341512 |
children | 654c5ac4f2c5 |
line wrap: on
line diff
--- a/python/apps/ide.py Sun Oct 07 17:27:09 2012 +0200 +++ b/python/apps/ide.py Fri Oct 12 16:11:31 2012 +0200 @@ -68,11 +68,11 @@ pitem.setEditable(False) pitem.setData(project) root.appendRow(pitem) - for f in self.project.files: - fitem = QStandardItem(f) + for el in self.project.elements: + fitem = QStandardItem(el) pitem.appendRow(fitem) fitem.setEditable(False) - fitem.setData(f) + fitem.setData(el) self.treeview.setModel(model) self.treeview.expandAll() def contextMenu(self, pos): @@ -121,9 +121,8 @@ self.setWindowIcon(QIcon(icon)) # Create menus: - self.fileMenu = self.menuBar().addMenu('File') + self.projectMenu = self.menuBar().addMenu('Project') self.viewMenu = self.menuBar().addMenu('View') - self.projectMenu = self.menuBar().addMenu('Project') self.helpMenu = self.menuBar().addMenu('Help') # Create mdi area: @@ -143,20 +142,32 @@ self.builderrors.sigErrorSelected.connect(self.errorSelected) self.projectview = ProjectView() - self.addComponent('Project', self.projectview) + self.addComponent('Project explorer', self.projectview) self.projectview.sigLoadFile.connect(self.loadFile) # About dialog: self.aboutDialog = AboutDialog() self.aboutDialog.setWindowIcon(QIcon(icon)) # Create actions: - self.buildAction = QAction('Build!', self) + self.newFileAction = QAction("New", self) + self.projectMenu.addAction(self.newFileAction) + self.newFileAction.triggered.connect(self.newProject) + + self.openAction = QAction("Open", self) + self.openAction.triggered.connect(self.openProject) + self.projectMenu.addAction(self.openAction) + + self.saveAction = QAction("Save", self) + self.projectMenu.addAction(self.saveAction) + self.saveAction.triggered.connect(self.saveProject) + self.closeAction = QAction("Close", self) + self.projectMenu.addAction(self.closeAction) + self.closeAction.triggered.connect(self.closeProject) + self.buildAction = QAction('Build', self) self.buildAction.setShortcut(QKeySequence('F7')) self.projectMenu.addAction(self.buildAction) - self.buildAction.triggered.connect(self.buildFile) - self.openProjectAction = QAction("Open project", self) - self.openProjectAction.triggered.connect(self.openProject) - self.projectMenu.addAction(self.openProjectAction) + self.buildAction.triggered.connect(self.buildProject) + self.helpAction = QAction('Help', self) self.helpAction.setShortcut(QKeySequence('F1')) self.helpMenu.addAction(self.helpAction) @@ -164,15 +175,6 @@ self.helpMenu.addAction(self.aboutAction) self.aboutAction.triggered.connect(self.aboutDialog.open) - self.newFileAction = QAction("New File", self) - self.fileMenu.addAction(self.newFileAction) - self.newFileAction.triggered.connect(self.newFile) - self.saveFileAction = QAction("Save File", self) - self.fileMenu.addAction(self.saveFileAction) - self.saveFileAction.triggered.connect(self.saveFile) - self.closeFileAction = QAction("Close File", self) - self.fileMenu.addAction(self.closeFileAction) - self.closeFileAction.triggered.connect(self.closeFile) cascadeAction = QAction("Cascade windows", self) cascadeAction.triggered.connect(self.mdiArea.cascadeSubWindows) @@ -193,24 +195,18 @@ self.viewMenu.addAction(dw.toggleViewAction()) # File handling: - def newFile(self): - ce = CodeEdit() - w = self.mdiArea.addSubWindow(ce) - ce.show() + def newProject(self): + filename = QFileDialog.getSaveFileName(self, \ + "Select new projectfile", "", "lcfos Project files (*.lcp2)") + if filename: + self.project = Project() + self.project.filename = filename + self.project.save() - def saveFile(self): - ac = self.activeMdiChild() - if ac: - ac.saveFile() + def saveProject(self): + self.project.save() - def saveAll(self): - pass - - def openFile(self): - # TODO - pass - - def closeFile(self): + def closeProject(self): ac = self.activeMdiChild() if ac: self.mdiArea.removeSubWindow(ac) @@ -230,6 +226,16 @@ ce.show() return ce + def loadProject(self, filename): + self.project = Project(filename) + self.projectview.setProject(self.project) + + def openProject(self): + filename = QFileDialog.getOpenFileName(self, \ + "Choose project file", "", "lcfos Project files (*.lcp2)") + if filename: + self.loadProject(filename) + # MDI: def activeMdiChild(self): aw = self.mdiArea.activeSubWindow() @@ -260,7 +266,7 @@ self.restoreGeometry(self.settings.value('mainwindowgeometry')) if self.settings.contains('openedproject'): projectfile = self.settings.value('openedproject') - self.loadProject(projectfile) + #self.loadProject(projectfile) def closeEvent(self, ev): self.settings.setValue('mainwindowstate', self.saveState()) @@ -289,18 +295,9 @@ ce.highlightErrorLocation(row, col) # Project loading: - def loadProject(self, filename): - self.project = Project(filename) - self.projectview.setProject(self.project) - - def openProject(self): - filename = QFileDialog.getOpenFileName(self, \ - "Choose project file", "", "lcfos Project files (*.lcp)") - if filename: - self.loadProject(filename) # Build recepy: - def buildFile(self): + def buildProject(self): """ Build project """ self.saveAll() self.buildOutput.clear()