changeset 247:dd8bbb963458

project remove
author Windel Bouwman
date Fri, 26 Jul 2013 10:44:26 +0200
parents f254b87258e6
children b10d46e5c8dd
files python/codeedit.py python/ide.py python/st-util.py
diffstat 3 files changed, 25 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/python/codeedit.py	Thu Jul 25 08:11:30 2013 +0200
+++ b/python/codeedit.py	Fri Jul 26 10:44:26 2013 +0200
@@ -22,7 +22,7 @@
       # TODO: only beam cursor in text area..
       self.setCursor(Qt.IBeamCursor)
       h = QFontMetrics(self.font()).height()
-      self.errorPixmap = QPixmap('error.png').scaled(h, h)
+      self.errorPixmap = QPixmap('icons/error.png').scaled(h, h)
       self.blinkcursor = False
       self.errorlist = []
       # Initial values:
--- 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)
--- a/python/st-util.py	Thu Jul 25 08:11:30 2013 +0200
+++ b/python/st-util.py	Fri Jul 26 10:44:26 2013 +0200
@@ -68,6 +68,7 @@
          toIndex = self.index(21, 1)
          self.dataChanged.emit(fromIndex, toIndex)
 
+
 class RegisterView(QTableView):
    def __init__(self):
       super().__init__()
@@ -128,8 +129,10 @@
       self.device = dev
       self.Address = 0x8000000
 
+
 class DebugToolbar(QToolBar):
    statusChange = pyqtSignal()
+   codePosition = pyqtSignal(int)
    def __init__(self):
       super().__init__()
       self.device = None
@@ -153,6 +156,10 @@
          self.stepAction.setEnabled(not self.device.Running)
          self.stopAction.setEnabled(self.device.Running)
          self.statusChange.emit()
+         if not self.device.Running:
+            PC = 15
+            v = self.device.iface.read_reg(PC)
+            self.codePosition.emit(v)
       else:
          self.resetAction.setEnabled(False)
          self.enableTraceAction.setEnabled(False)
@@ -178,16 +185,18 @@
       self.device = dev
       self.updateEnables()
 
+
 class FlashTool(QWidget):
    def __init__(self):
       super().__init__()
       # TODO!
 
+
 class DeviceTreeModel(QAbstractItemModel):
    def __init__(self):
       super().__init__()
-      self.chipPixmap = QPixmap('chip.png').scaled(32, 32)
-      self.hardwarePixmap = QPixmap('hardware.png').scaled(32, 32)
+      self.chipPixmap = QPixmap('icons/chip.png').scaled(32, 32)
+      self.hardwarePixmap = QPixmap('icons/hardware.png').scaled(32, 32)
       self.refresh()
    def refresh(self):
       """ Check all usb interfaces for interfaces """