summaryrefslogtreecommitdiff
path: root/src/frontEnd
diff options
context:
space:
mode:
authorkomalsheth2362015-05-13 13:36:24 +0530
committerkomalsheth2362015-05-13 13:36:24 +0530
commit3e134d4e2826699656d7b7b4c8edb1f7ba89aed9 (patch)
treed73631831d3b030deee868b6100400c9b3104b5d /src/frontEnd
parent6a69cbdbb54b99e1b4e27fac4635f8169b6db463 (diff)
downloadeSim-3e134d4e2826699656d7b7b4c8edb1f7ba89aed9.tar.gz
eSim-3e134d4e2826699656d7b7b4c8edb1f7ba89aed9.tar.bz2
eSim-3e134d4e2826699656d7b7b4c8edb1f7ba89aed9.zip
Project Explorer Compeleted
Diffstat (limited to 'src/frontEnd')
-rwxr-xr-xsrc/frontEnd/Application.py25
-rw-r--r--src/frontEnd/ProjectExplorer.py275
-rw-r--r--src/frontEnd/ProjectExplorer.pycbin10311 -> 5058 bytes
-rw-r--r--src/frontEnd/ViewManagement.pycbin2841 -> 2847 bytes
-rw-r--r--src/frontEnd/Workspace.pycbin3526 -> 3533 bytes
-rw-r--r--src/frontEnd/__init__.pycbin138 -> 139 bytes
6 files changed, 15 insertions, 285 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py
index a1560c9b..dd2e2264 100755
--- a/src/frontEnd/Application.py
+++ b/src/frontEnd/Application.py
@@ -29,9 +29,8 @@ import Workspace
import sys
import time
import subprocess
-from frontEnd import ProjectExplorer
import DockArea
-
+from frontEnd import ProjectExplorer
class Application(QtGui.QMainWindow):
"""
@@ -69,6 +68,7 @@ class Application(QtGui.QMainWindow):
self.newproj = QtGui.QAction(QtGui.QIcon('../images/newProject.png'),'<b>New Project</b>',self)
self.newproj.setShortcut('Ctrl+N')
self.newproj.triggered.connect(self.new_project)
+
#self.newproj.connect(self.newproj,QtCore.SIGNAL('triggered()'),self,QtCore.SLOT(self.new_project()))
self.openproj = QtGui.QAction(QtGui.QIcon('../images/openProject.png'),'<b>Open Project</b>',self)
@@ -129,8 +129,10 @@ class Application(QtGui.QMainWindow):
if ok:
self.projname = (str(text))
self.project = NewProjectInfo()
- self.project.createProject(self.projname)
- #self.setCentralWidget(self.obj_Mainview)
+ directory, filelist =self.project.createProject(self.projname)
+
+ self.obj_Mainview.obj_projectExplorer.addTreeNode(directory, filelist)
+ #self.setCentralWidget(self.obj_Mainview.obj_projectExplorer)
else:
print "No project created"
@@ -141,8 +143,12 @@ class Application(QtGui.QMainWindow):
"""
print "Open Project called"
self.project = OpenProjectInfo()
- self.project.body()
- print "init main view in open proj"
+
+ try:
+ directory, filelist = self.project.body()
+ self.obj_Mainview.obj_projectExplorer.addTreeNode(directory, filelist)
+ except:
+ pass
#self.setCentralWidget(self.obj_Mainview)
@@ -167,7 +173,6 @@ class Application(QtGui.QMainWindow):
self.obj_Mainview.obj_dockarea.createTestEditor()
-
def testing(self):
print "Success hit kicad button"
@@ -189,7 +194,7 @@ class MainView(QtGui.QWidget):
self.noteArea = QtGui.QTextEdit()
self.obj_dockarea = DockArea.DockArea()
self.obj_projectExplorer = ProjectExplorer.ProjectExplorer()
- self.projectExplorer = self.obj_projectExplorer.maketree()
+
#Adding content to vertical middle Split.
self.middleSplit.setOrientation(QtCore.Qt.Vertical)
@@ -201,9 +206,9 @@ class MainView(QtGui.QWidget):
self.middleContainer.setLayout(self.middleContainerLayout)
#Adding content of left split
- self.leftSplit.addWidget(self.projectExplorer)
+ self.leftSplit.addWidget(self.obj_projectExplorer)
self.leftSplit.addWidget(self.middleContainer)
-
+
#Adding to main Layout
self.mainLayout.addWidget(self.leftSplit)
diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py
deleted file mode 100644
index 282133cb..00000000
--- a/src/frontEnd/ProjectExplorer.py
+++ /dev/null
@@ -1,275 +0,0 @@
-from PyQt4 import QtCore, QtGui
-from configuration.Appconfig import Appconfig
-import os
-import json
-
-class Node(object):
-
- def __init__(self, name, parent=None):
-
- self._name = name
- self._children = []
- self._parent = parent
-
- if parent is not None:
- parent.addChild(self)
-
- def typeInfo(self):
- return self._typeInfo
-
- def settypeInfo(self,typeInfo):
- self._typeInfo = typeInfo
-
- def addChild(self, child):
- self._children.append(child)
-
- def name(self):
- return self._name
-
- def setName(self, name):
- self._name = name
-
- def child(self, row):
- return self._children[row]
-
- def childCount(self):
- return len(self._children)
-
- def parent(self):
- return self._parent
-
- def row(self):
- if self._parent is not None:
- return self._parent._children.index(self)
-
-
-class SceneGraphModel(QtCore.QAbstractItemModel):
-
- """INPUTS: Node, QObject"""
- def __init__(self, root, parent=None):
- super(SceneGraphModel, self).__init__(parent)
- self._rootNode = root
-
- """INPUTS: QModelIndex"""
- """OUTPUT: int"""
- def rowCount(self, parent):
- if not parent.isValid():
- parentNode = self._rootNode
- else:
- parentNode = parent.internalPointer()
-
- return parentNode.childCount()
-
- """INPUTS: QModelIndex"""
- """OUTPUT: int"""
- def columnCount(self, parent):
- return 1
-
- """INPUTS: QModelIndex, int"""
- """OUTPUT: QVariant, strings are cast to QString which is a QVariant"""
- def data(self, index, role):
-
- if not index.isValid():
- return None
-
- node = index.internalPointer()
-
- if role == QtCore.Qt.DisplayRole or role == QtCore.Qt.EditRole:
- if index.column() == 0:
- return node.name()
- else:
- return node.typeInfo()
-
-
-
- """INPUTS: QModelIndex, QVariant, int (flag)"""
- def setData(self, index, value, role=QtCore.Qt.EditRole):
-
- if index.isValid():
-
- if role == QtCore.Qt.EditRole:
-
- node = index.internalPointer()
- node.setName(value)
-
- return True
- return False
-
-
- """INPUTS: int, Qt::Orientation, int"""
- """OUTPUT: QVariant, strings are cast to QString which is a QVariant"""
- def headerData(self, section, orientation, role):
- if role == QtCore.Qt.DisplayRole:
- if section == 0:
- return "Project Explorer"
- else:
- return "FilePath"
-
- """INPUTS: QModelIndex"""
- """OUTPUT: int (flag)"""
- def flags(self, index):
- return QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable
-
- """INPUTS: QModelIndex"""
- """OUTPUT: QModelIndex"""
- """Should return the parent of the node with the given QModelIndex"""
- def parent(self, index):
-
- node = self.getNode(index)
- parentNode = node.parent()
-
- if parentNode == self._rootNode:
- return QtCore.QModelIndex()
-
- return self.createIndex(parentNode.row(), 0, parentNode)
-
- """INPUTS: int, int, QModelIndex"""
- """OUTPUT: QModelIndex"""
- """Should return a QModelIndex that corresponds to the given row, column and parent node"""
- def index(self, row, column, parent):
-
- parentNode = self.getNode(parent)
-
- childItem = parentNode.child(row)
-
-
- if childItem:
- return self.createIndex(row, column, childItem)
- else:
- return QtCore.QModelIndex()
-
-
- """CUSTOM"""
- """INPUTS: QModelIndex"""
- def getNode(self, index):
- if index.isValid():
- node = index.internalPointer()
- if node:
- return node
-
- return self._rootNode
-
-
-
-class ProjectExplorer(QtGui.QWidget):
- def __init__(self,parent=None):
- QtGui.QWidget.__init__(self)
-
- returnwidget = self.maketree()
- returnwidget.setStyleSheet("""
- .QWidget {
- border: 3px solid gray;
- border-radius: 40px;
- background-color:white;
- }
- """)
-
- def maketree(self):
- self.obj_appconfig = Appconfig()
- self.root = Node("Projects")
- currentpath= self.obj_appconfig.current_project["ProjectName"]
- if currentpath == None:
- pass
- else:
- self.children =[]
- for dirct, subdir, files in os.walk(currentpath):
- dirlist = dirct.split(os.sep)
- self.parentof = dirlist[-1]
- self.obj_appconfig.project_explorer[dirct]= files
- json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w'))
-
- for item, value in self.obj_appconfig.project_explorer.items():
- os.path.join(item)
- pathlist= item.split(os.sep)
- parentnode = Node(pathlist[-1], self.root)
- parentnode.settypeInfo(item)
- for projFiles in value:
- childnode = Node(projFiles, parentnode)
- childnode.settypeInfo (item+ '/' + projFiles)
-
- self.model = SceneGraphModel(self.root)
-
- self.treeView = QtGui.QTreeView()
- self.treeView.doubleClicked.connect(self.openProject)
-
- self.treeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
- self.treeView.customContextMenuRequested.connect(self.openMenu)
- self.treeView.show()
-
- self.treeView.setModel(self.model)
- self.treeView.setStyleSheet("""
- .QWidget {
- border: 3px solid gray;
- border-radius: 40px;
- background-color:white;
- }
- """)
- return self.treeView
-
- def openMenu(self, position):
-
- indexes = self.treeView.selectedIndexes()
- if len(indexes) > 0:
-
- level = 0
- index = indexes[0]
- while index.parent().isValid():
- index = index.parent()
- level += 1
-
- menu = QtGui.QMenu()
- if level == 0:
- deleteproject = menu.addAction(self.tr("Remove Project"))
- deleteproject.triggered.connect(self.removeProject)
- elif level == 1:
- openfile = menu.addAction(self.tr("Open"))
- openfile.triggered.connect(self.openProject)
-
- menu.exec_(self.treeView.viewport().mapToGlobal(position))
-
- def openProject(self):
- self.indexItem =self.treeView.currentIndex()
- filename= self.indexItem.data().toString()
- self.filePath= self.indexItem.sibling(self.indexItem.row(), 1).data().toString()
-
- self.textwindow = QtGui.QWidget()
- self.textwindow.setMinimumSize(600, 500)
- self.textwindow.setWindowTitle(filename)
- self.text = QtGui.QTextEdit()
- #self.text.setMaximumSize(580, 450)
- self.save = QtGui.QPushButton('Save and Exit')
- self.save.setDisabled(True)
- self.windowgrid = QtGui.QGridLayout()
- if (os.path.isfile(str(self.filePath)))== True:
- self.fopen = open(str(self.filePath), 'r')
- lines = self.fopen.readlines()
- for line in lines:
- self.text.append(line)
-
- QtCore.QObject.connect(self.text,QtCore.SIGNAL("textChanged()"), self.enable_save)
-
- vbox_main = QtGui.QVBoxLayout(self.textwindow)
- vbox_main.addWidget(self.text)
- vbox_main.addWidget(self.save)
- self.save.clicked.connect(self.save_data)
- #self.connect(exit,QtCore.SIGNAL('close()'), self.onQuit)
-
- self.textwindow.show()
- else:
- pass
-
- def enable_save(self):
- self.save.setEnabled(True)
-
- def save_data(self):
- self.fopen=open(self.filePath, 'w')
- self.fopen.write(self.text.toPlainText())
- self.fopen.close()
- self.textwindow.close()
-
- def removeProject(self):
- self.indexItem =self.treeView.currentIndex()
- filename= self.indexItem.data().toString()
- self.filePath= self.indexItem.sibling(self.indexItem.row(), 1).data().toString()
- del self.obj_appconfig.project_explorer[str(self.filePath)]
- json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w'))
diff --git a/src/frontEnd/ProjectExplorer.pyc b/src/frontEnd/ProjectExplorer.pyc
index da647370..7906f8b0 100644
--- a/src/frontEnd/ProjectExplorer.pyc
+++ b/src/frontEnd/ProjectExplorer.pyc
Binary files differ
diff --git a/src/frontEnd/ViewManagement.pyc b/src/frontEnd/ViewManagement.pyc
index 3a562d99..eeef23a3 100644
--- a/src/frontEnd/ViewManagement.pyc
+++ b/src/frontEnd/ViewManagement.pyc
Binary files differ
diff --git a/src/frontEnd/Workspace.pyc b/src/frontEnd/Workspace.pyc
index 935ed8d5..7a5776b8 100644
--- a/src/frontEnd/Workspace.pyc
+++ b/src/frontEnd/Workspace.pyc
Binary files differ
diff --git a/src/frontEnd/__init__.pyc b/src/frontEnd/__init__.pyc
index 107c0b45..5ea864ab 100644
--- a/src/frontEnd/__init__.pyc
+++ b/src/frontEnd/__init__.pyc
Binary files differ