summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/configuration/Appconfig.py7
-rw-r--r--src/configuration/Appconfig.pycbin1391 -> 1557 bytes
-rw-r--r--src/configuration/__init__.pycbin144 -> 144 bytes
-rwxr-xr-xsrc/frontEnd/Application.py22
-rw-r--r--[-rwxr-xr-x]src/frontEnd/ProjectExplorer.py304
-rw-r--r--src/frontEnd/ProjectExplorer.pycbin3015 -> 10541 bytes
-rw-r--r--src/frontEnd/ViewManagement.pycbin2875 -> 2875 bytes
-rw-r--r--src/frontEnd/Workspace.pycbin3533 -> 3533 bytes
-rw-r--r--src/frontEnd/__init__.pycbin138 -> 139 bytes
-rw-r--r--src/projManagement/Kicad.pycbin4309 -> 4309 bytes
-rw-r--r--src/projManagement/Validation.pycbin2404 -> 2404 bytes
-rw-r--r--src/projManagement/Worker.pycbin1507 -> 1507 bytes
-rw-r--r--src/projManagement/__init__.pycbin145 -> 145 bytes
-rw-r--r--src/projManagement/newProject.py44
-rw-r--r--src/projManagement/newProject.pycbin3749 -> 2971 bytes
-rw-r--r--src/projManagement/openProject.pycbin1771 -> 1771 bytes
16 files changed, 291 insertions, 86 deletions
diff --git a/src/configuration/Appconfig.py b/src/configuration/Appconfig.py
index 84502e5d..f00ac984 100644
--- a/src/configuration/Appconfig.py
+++ b/src/configuration/Appconfig.py
@@ -19,6 +19,7 @@
from PyQt4 import QtGui
import os
+import json
class Appconfig(QtGui.QWidget):
@@ -35,7 +36,11 @@ class Appconfig(QtGui.QWidget):
#Workspace detail
workspace_text = '''eSim stores your project in a folder called a eSim-Workspace. You can choose a different workspace folder to use for this session.'''
procThread_list = []
-
+ dictPath = os.path.join(home, ".text.txt")
+ try:
+ project_explorer = json.load(open(dictPath))
+ except:
+ project_explorer= {}
def __init__(self):
super(Appconfig, self).__init__()
diff --git a/src/configuration/Appconfig.pyc b/src/configuration/Appconfig.pyc
index 9e78df71..e08ffda4 100644
--- a/src/configuration/Appconfig.pyc
+++ b/src/configuration/Appconfig.pyc
Binary files differ
diff --git a/src/configuration/__init__.pyc b/src/configuration/__init__.pyc
index 5d054b24..58bf9549 100644
--- a/src/configuration/__init__.pyc
+++ b/src/configuration/__init__.pyc
Binary files differ
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py
index 9c845ed4..56e3276b 100755
--- a/src/frontEnd/Application.py
+++ b/src/frontEnd/Application.py
@@ -29,6 +29,8 @@ import Workspace
import sys
import time
import subprocess
+from frontEnd import ProjectExplorer
+
class Application(QtGui.QMainWindow):
@@ -72,7 +74,7 @@ class Application(QtGui.QMainWindow):
self.middleSplit = QtGui.QSplitter()
self.rightSplit = QtGui.QSplitter() #Will be use in future for Browser
- self.projectExplorer = QtGui.QTextEdit()
+ self.projectExplorer = ProjectExplorer.ProjectExplorer()
self.mainArea = QtGui.QTextEdit()
self.noteArea = QtGui.QTextEdit()
self.browserArea = QtGui.QTextEdit()
@@ -92,7 +94,7 @@ class Application(QtGui.QMainWindow):
self.middleContainer.setLayout(self.middleContainerLayout)
#Adding content ot left split
- self.leftSplit.addWidget(self.projectExplorer)
+ self.leftSplit.addWidget(self.projectExplorer.maketree())
self.leftSplit.addWidget(self.middleContainer)
@@ -166,9 +168,14 @@ class Application(QtGui.QMainWindow):
This function call New Project Info class.
"""
print "New Project called"
+ text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog',
+ 'Enter Project Name:')
+ if ok:
+ self.projname = (str(text))
+
self.project = NewProjectInfo()
- self.project.body()
-
+ self.project.createProject(self.projname)
+ self.setCentralWidget(self.initMainView())
def open_project(self):
"""
@@ -177,6 +184,10 @@ class Application(QtGui.QMainWindow):
print "Open Project called"
self.project = OpenProjectInfo()
self.project.body()
+ print "init main view in open proj"
+
+ self.setCentralWidget(self.initMainView())
+
def exit_project(self):
print "Exit Project called"
@@ -195,8 +206,7 @@ class Application(QtGui.QMainWindow):
def help_project(self):
print "Help is called"
- print "Current Project : ",self.obj_appconfig.current_project
-
+ print "Current Project : ",self.obj_appconfig.current_project
def testing(self):
print "Success hit kicad button"
diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py
index 82c740fa..a95986b1 100755..100644
--- a/src/frontEnd/ProjectExplorer.py
+++ b/src/frontEnd/ProjectExplorer.py
@@ -1,68 +1,271 @@
-import sys
-from PyQt4 import QtGui,QtCore
+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()
+
+ if role == QtCore.Qt.DecorationRole:
+ if index.column() == 0:
+ typeInfo = node.typeInfo()
+
+ if typeInfo == "DIRECTORY":
+ return QtGui.QIcon(QtGui.QPixmap("../images/default.png"))
+
+ if typeInfo == "FILE":
+ return QtGui.QIcon(QtGui.QPixmap("../images/default.png"))
+
+
+ """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):
- """
- This Class create the project explorer windows of eSim-Workspace
- """
def __init__(self,parent=None):
QtGui.QWidget.__init__(self)
- #Creating object of AppConfig
+
+ 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'))
- self.startpath = self.obj_appconfig.default_workspace["workspace"]
+ 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.view = QtGui.QTreeView()
-
- self.grid= QtGui.QGridLayout()
- self.model = QtGui.QFileSystemModel()
+ self.model = SceneGraphModel(self.root)
- self.view.setModel(self.model)
- self.view.setRootIndex(self.model.setRootPath(self.startpath))
- self.view.setHeaderHidden(True)
- self.view.hideColumn(1)
- self.view.hideColumn(2)
- self.view.hideColumn(3)
-
- self.view.doubleClicked.connect(self.on_clicked)
- self.grid.addWidget(self.view)
+ 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
- self.setLayout(self.grid)
- self.show()
+ 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)
- def on_clicked(self,index):
-
- self.indexItem = self.model.index(index.row(), 0, index.parent())
+ 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.text = QtGui.QTextEdit()
+ #self.text.setMaximumSize(580, 450)
self.save = QtGui.QPushButton('Save and Exit')
self.save.setDisabled(True)
self.windowgrid = QtGui.QGridLayout()
-
- self.filePath = self.model.filePath(self.indexItem)
-
-
- self.fopen = open(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)
- splitter_filelist = QtGui.QSplitter()
- splitter_filelist.setOrientation(QtCore.Qt.Vertical)
-
- vbox_main = QtGui.QVBoxLayout(self.textwindow)
- vbox_main.addWidget(splitter_filelist)
- 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()
+ 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)
@@ -70,4 +273,11 @@ class ProjectExplorer(QtGui.QWidget):
self.fopen=open(self.filePath, 'w')
self.fopen.write(self.text.toPlainText())
self.fopen.close()
- self.textwindow.close() \ No newline at end of file
+ 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 392fa27b..e87d977d 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 6511e9ea..93901e11 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 576e6ba1..a60ebd37 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..d878c583 100644
--- a/src/frontEnd/__init__.pyc
+++ b/src/frontEnd/__init__.pyc
Binary files differ
diff --git a/src/projManagement/Kicad.pyc b/src/projManagement/Kicad.pyc
index 7f977180..1a1c7183 100644
--- a/src/projManagement/Kicad.pyc
+++ b/src/projManagement/Kicad.pyc
Binary files differ
diff --git a/src/projManagement/Validation.pyc b/src/projManagement/Validation.pyc
index 54ae7db1..b66bd3af 100644
--- a/src/projManagement/Validation.pyc
+++ b/src/projManagement/Validation.pyc
Binary files differ
diff --git a/src/projManagement/Worker.pyc b/src/projManagement/Worker.pyc
index b8f921e3..28b7afff 100644
--- a/src/projManagement/Worker.pyc
+++ b/src/projManagement/Worker.pyc
Binary files differ
diff --git a/src/projManagement/__init__.pyc b/src/projManagement/__init__.pyc
index a5c33b52..87910074 100644
--- a/src/projManagement/__init__.pyc
+++ b/src/projManagement/__init__.pyc
Binary files differ
diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py
index d6045fd3..77c583d3 100644
--- a/src/projManagement/newProject.py
+++ b/src/projManagement/newProject.py
@@ -20,6 +20,7 @@ from PyQt4 import QtGui,QtCore
from Validation import Validation
from configuration.Appconfig import Appconfig
import os
+import json
class NewProjectInfo(QtGui.QWidget):
"""
@@ -30,44 +31,16 @@ class NewProjectInfo(QtGui.QWidget):
super(NewProjectInfo, self).__init__()
self.obj_validation = Validation()
self.obj_appconfig = Appconfig()
+
-
- def body(self):
- """
- This function create gui for New Project Info
- """
- #print "Calling NewProjectInfo"
- self.projLabel = QtGui.QLabel("Enter Project Name :")
- self.projEdit = QtGui.QLineEdit()
-
- self.okbtn = QtGui.QPushButton("OK")
- self.okbtn.clicked.connect(self.createProject)
-
- self.cancelbtn = QtGui.QPushButton("Cancel")
- self.cancelbtn.clicked.connect(self.cancelProject)
-
-
- #Layout
- self.grid = QtGui.QGridLayout()
- self.grid.addWidget(self.projLabel,2,0)
- self.grid.addWidget(self.projEdit, 2,1,1,5)
- self.grid.addWidget(self.okbtn,3,1)
- self.grid.addWidget(self.cancelbtn,3,2)
- self.setLayout(self.grid)
-
- self.setGeometry(QtCore.QRect(80,80,80,80))
- self.setWindowTitle("New Project")
- self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
- self.show()
-
-
- def createProject(self):
+ def createProject(self,projName):
"""
This function create Project related directories and files
"""
#print "Create Project Called"
+ self.projName= projName
self.workspace = self.obj_appconfig.default_workspace['workspace']
- self.projName = self.projEdit.text()
+ #self.projName = self.projEdit.text()
self.projName = str(self.projName).rstrip().lstrip() #Remove leading and trailing space
self.projDir = os.path.join(self.workspace,str(self.projName))
@@ -97,7 +70,14 @@ class NewProjectInfo(QtGui.QWidget):
f.close()
#Now Change the current working project
+ newprojlist = []
+ #self.obj_appconfig = Appconfig()
self.obj_appconfig.current_project['ProjectName'] = self.projDir
+ newprojlist.append(self.projName+'.proj')
+ self.obj_appconfig.project_explorer[self.projDir] = newprojlist
+
+ json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w'))
+
elif self.reply == "CHECKEXIST":
#print "Project already exist"
diff --git a/src/projManagement/newProject.pyc b/src/projManagement/newProject.pyc
index 9a413352..ad569488 100644
--- a/src/projManagement/newProject.pyc
+++ b/src/projManagement/newProject.pyc
Binary files differ
diff --git a/src/projManagement/openProject.pyc b/src/projManagement/openProject.pyc
index c4b544ae..d9c25b77 100644
--- a/src/projManagement/openProject.pyc
+++ b/src/projManagement/openProject.pyc
Binary files differ