Mercurial > lcfOS
diff python/ide.py @ 247:dd8bbb963458
project remove
author | Windel Bouwman |
---|---|
date | Fri, 26 Jul 2013 10:44:26 +0200 |
parents | 6259856841a0 |
children | b10d46e5c8dd |
line wrap: on
line diff
--- a/python/ide.py Thu Jul 25 08:11:30 2013 +0200 +++ b/python/ide.py Fri Jul 26 10:44:26 2013 +0200 @@ -12,7 +12,6 @@ #from codeeditor import CodeEdit from codeedit import CodeEdit stutil = __import__('st-util') -import testc3 import c3 class BuildOutput(QTextEdit): @@ -53,46 +52,6 @@ err = item.data() self.sigErrorSelected.emit(err) -class ProjectView(QWidget): - sigLoadFile = pyqtSignal(str) - def __init__(self, parent=None): - super(ProjectView, self).__init__(parent) - self.treeview = QTreeView(self) - self.treeview.setContextMenuPolicy(Qt.CustomContextMenu) - l = QVBoxLayout(self) - l.addWidget(self.treeview) - self.projectIcon = QIcon('icons/logo.png') - # Connect signals: - self.treeview.activated.connect(self.activate) - self.treeview.customContextMenuRequested.connect(self.contextMenu) - def setProject(self, project): - self.project = project - model = QStandardItemModel() - root = model.invisibleRootItem() - pitem = QStandardItem(self.projectIcon, project.name) - pitem.setEditable(False) - pitem.setData(project) - root.appendRow(pitem) - for el in self.project.elements: - fitem = QStandardItem(el) - pitem.appendRow(fitem) - fitem.setEditable(False) - fitem.setData(el) - self.treeview.setModel(model) - self.treeview.expandAll() - def contextMenu(self, pos): - idx = self.treeview.indexAt(pos) - if not idx.isValid(): - return - item = self.treeview.model().itemFromIndex(idx) - def activate(self, index): - if not index.isValid(): - return - model = self.treeview.model() - item = model.itemFromIndex(index) - fn = item.data() - if type(fn) is str: - self.sigLoadFile.emit(fn) class AboutDialog(QDialog): def __init__(self, parent=None): @@ -113,20 +72,16 @@ but.clicked.connect(self.close) l.addWidget(but) -class ProjectOptions(QDialog): - pass - # TODO: project options in here - class Ide(QMainWindow): def __init__(self, parent=None): super(Ide, self).__init__(parent) self.setWindowTitle('LCFOS IDE') - self.setWindowIcon(QIcon('icons/logo.png')) + icon = QIcon('icons/logo.png') + self.setWindowIcon(icon) # Create menus: mb = self.menuBar() self.fileMenu = mb.addMenu('File') - self.projectMenu = mb.addMenu('Project') self.viewMenu = mb.addMenu('View') self.helpMenu = mb.addMenu('Help') @@ -148,8 +103,6 @@ self.astViewer.sigNodeSelected.connect(self.nodeSelected) self.builderrors = addComponent('Build errors', BuildErrors()) self.builderrors.sigErrorSelected.connect(self.errorSelected) - self.projectview = addComponent('Project explorer', ProjectView()) - self.projectview.sigLoadFile.connect(self.loadFile) self.devxplr = addComponent('Device explorer', stutil.DeviceExplorer()) self.regview = addComponent('Registers', stutil.RegisterView()) self.memview = addComponent('Memory', stutil.MemoryView()) @@ -161,10 +114,11 @@ self.devxplr.deviceSelected.connect(self.memview.setDevice) self.devxplr.deviceSelected.connect(self.ctrlToolbar.setDevice) self.ctrlToolbar.statusChange.connect(self.regview.refresh) + self.ctrlToolbar.codePosition.connect(self.pointCode) # About dialog: self.aboutDialog = AboutDialog() - self.aboutDialog.setWindowIcon(QIcon('icons/logo.png')) + self.aboutDialog.setWindowIcon(icon) # Create actions: def addMenuEntry(name, menu, callback, shortcut=None): a = QAction(name, self) @@ -176,7 +130,7 @@ addMenuEntry("New", self.fileMenu, self.newFile, shortcut=QKeySequence(QKeySequence.New)) addMenuEntry("Open", self.fileMenu, self.openFile, shortcut=QKeySequence(QKeySequence.Open)) addMenuEntry("Save", self.fileMenu, self.saveFile, shortcut=QKeySequence(QKeySequence.Save)) - addMenuEntry("Build", self.fileMenu, self.buildFile, shortcut=QKeySequence("F8")) + addMenuEntry("Build", self.fileMenu, self.buildFile, shortcut=QKeySequence("F7")) self.helpAction = QAction('Help', self) self.helpAction.setShortcut(QKeySequence('F1')) @@ -193,35 +147,27 @@ self.loadSettings() ce = self.newFile() - ce.Source = testc3.testsrc - self.diag = ppci.DiagnosticsManager() self.c3front = c3.Builder(self.diag) # File handling: def newFile(self): ce = CodeEdit() - ce.textChanged.connect(self.buildProject) + ce.textChanged.connect(self.buildFile) w = self.mdiArea.addSubWindow(ce) ce.show() w.resize(500, 700) return ce + def openFile(self): - filename = QFileDialog.getOpenFileName(self, "Open K# file...", "*.ks", "K# source files (*.ks)") + filename = QFileDialog.getOpenFileName(self, "Open C3 file...", "*.c3", "C3 source files (*.ks)") if filename: self.loadFile(filename) + def saveFile(self): ac = self.activeMdiChild() if ac: ac.save() - - def saveProject(self): - self.project.save() - - def closeProject(self): - ac = self.activeMdiChild() - if ac: - self.mdiArea.removeSubWindow(ac) def loadFile(self, filename): # Find existing mdi widget: @@ -245,16 +191,6 @@ 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() @@ -289,8 +225,6 @@ def closeEvent(self, ev): self.settings.setValue('mainwindowstate', self.saveState()) self.settings.setValue('mainwindowgeometry', self.saveGeometry()) - #if self.project: - # self.settings.setValue('openedproject', self.project.filename) # # TODO: ask for save of opened files ac = self.activeMdiChild() if ac: @@ -309,7 +243,7 @@ return if node.loc: row, col = node.loc.row, node.loc.col - ce.setRowCol( row, col ) + ce.setRowCol(row, col) ce.setFocus() else: ce.clearErrors() @@ -321,7 +255,9 @@ ce.setRowCol(err.loc.row, err.loc.col) ce.setFocus() - # Project loading: + def pointCode(self, p): + print('PC', p) + # Build recepy: def buildFile(self): @@ -334,19 +270,6 @@ ast = self.c3front.pkg self.astViewer.setAst(ast) self.buildOutput.append("Done!") - def buildProject(self): - """ Build project """ - self.buildOutput.clear() - self.diag.diags.clear() - self.buildFile() - - self.builderrors.setErrorList(self.diag.diags) - for err in self.diag.diags: - self.buildOutput.append(str(err)) - ce = self.activeMdiChild() - if ce: - ce.setErrors(self.diag.diags) - self.buildOutput.append("Done!") if __name__ == '__main__': app = QApplication(sys.argv)