summaryrefslogtreecommitdiff
path: root/src/frontEnd
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontEnd')
-rw-r--r--src/frontEnd/DockArea.py55
-rw-r--r--src/frontEnd/ProjectExplorer.py111
-rw-r--r--src/frontEnd/Workspace.py2
-rw-r--r--src/frontEnd/pathmagic.py2
4 files changed, 122 insertions, 48 deletions
diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py
index 2c605272..8b8e975b 100644
--- a/src/frontEnd/DockArea.py
+++ b/src/frontEnd/DockArea.py
@@ -11,16 +11,19 @@ from ngspicetoModelica.ModelicaUI import OpenModelicaEditor
import os
dockList = ['Welcome']
-count = 1
+count = 1
dock = {}
+
#
class DockArea(QtGui.QMainWindow):
- """ """
+ """Sdf."""
+
def __init__(self):
+ """Sdf."""
QtGui.QMainWindow.__init__(self)
self.obj_appconfig = Appconfig()
-
+
for dockName in dockList:
dock[dockName] = QtGui.QDockWidget(dockName)
self.welcomeWidget = QtGui.QWidget()
@@ -42,9 +45,8 @@ class DockArea(QtGui.QMainWindow):
# This function create widget for Library Editor
def createTestEditor(self):
- """ """
+ """Sdf."""
global count
-
self.testWidget = QtGui.QWidget()
self.testArea = QtGui.QTextEdit()
self.testLayout = QtGui.QVBoxLayout()
@@ -71,14 +73,14 @@ class DockArea(QtGui.QMainWindow):
# This function create widget for interactive PythonPlotting
def plottingEditor(self):
- """ """
+ """Sdf."""
self.projDir = self.obj_appconfig.current_project["ProjectName"]
self.projName = os.path.basename(self.projDir)
# self.project = os.path.join(self.projDir,self.projName)
global count
self.plottingWidget = QtGui.QWidget()
-
+
self.plottingLayout = QtGui.QVBoxLayout()
self.plottingLayout.addWidget(plotWindow(self.projDir, self.projName))
@@ -100,9 +102,9 @@ class DockArea(QtGui.QMainWindow):
dock['Plotting-' + str(count)])
count = count + 1
+ # This function creates widget for NgSpice window.
def ngspiceEditor(self, projDir):
- """This function creates widget for NgSpice window."""
-
+ """Sdf."""
self.projDir = projDir
self.projName = os.path.basename(self.projDir)
self.ngspiceNetlist = os.path.join(
@@ -110,7 +112,7 @@ class DockArea(QtGui.QMainWindow):
global count
self.ngspiceWidget = QtGui.QWidget()
-
+
self.ngspiceLayout = QtGui.QVBoxLayout()
self.ngspiceLayout.addWidget(
NgspiceWidget(
@@ -140,7 +142,9 @@ class DockArea(QtGui.QMainWindow):
dock['NgSpice-' + str(count)])
count = count + 1
+ # This function defines UI for model editor.
def modelEditor(self):
+ """Sdf."""
print("in model editor")
global count
self.modelwidget = QtGui.QWidget()
@@ -174,7 +178,9 @@ class DockArea(QtGui.QMainWindow):
dock['Model Editor-' + str(count)])
count = count + 1
+ # This function is creating Editor UI for Kicad to Ngspice conversion.
def kicadToNgspiceEditor(self, clarg1, clarg2=None):
+ """Sdf."""
global count
self.kicadToNgspiceWidget = QtGui.QWidget()
self.kicadToNgspiceLayout = QtGui.QVBoxLayout()
@@ -204,16 +210,15 @@ class DockArea(QtGui.QMainWindow):
self.obj_appconfig.dock_dict[temp].append(
dock['kicadToNgspice-' + str(count)])
count = count + 1
+
+ # This function creates a widget for different subcircuit options.
def subcircuiteditor(self):
- """
- This function creates a widget for different subcircuit options
- """
-
+ """Sdf."""
global count
self.subcktWidget = QtGui.QWidget()
self.subcktLayout = QtGui.QVBoxLayout()
self.subcktLayout.addWidget(Subcircuit(self))
-
+
self.subcktWidget.setLayout(self.subcktLayout)
dock['Subcircuit-' +
str(count)] = QtGui.QDockWidget('Subcircuit-' + str(count))
@@ -237,17 +242,15 @@ class DockArea(QtGui.QMainWindow):
self.obj_appconfig.dock_dict[temp].append(
dock['Subcircuit-' + str(count)])
count = count + 1
-
+
+ # This function creates a widget for different subcircuit options.
def usermanual(self):
- """
- This function creates a widget for different subcircuit options
- """
-
+ """Sdf."""
global count
self.usermanualWidget = QtGui.QWidget()
self.usermanualLayout = QtGui.QVBoxLayout()
self.usermanualLayout.addWidget(UserManual())
-
+
self.usermanualWidget.setLayout(self.usermanualLayout)
dock['User Manual-' +
str(count)] = QtGui.QDockWidget('User Manual-' + str(count))
@@ -269,9 +272,9 @@ class DockArea(QtGui.QMainWindow):
count = count + 1
+ # This function sets up the UI for ngspice to modelica conversion.
def modelicaEditor(self, projDir):
- """This function sets up the UI for ngspice to modelica conversion."""
-
+ """Dfg."""
global count
self.modelicaWidget = QtGui.QWidget()
self.modelicaLayout = QtGui.QVBoxLayout()
@@ -300,7 +303,9 @@ class DockArea(QtGui.QMainWindow):
count = count + 1
+ # This function when called closes the opened file.
def closeDock(self):
- temp = self.obj_appconfig.current_project['ProjectName']
- for dockwidget in self.obj_appconfig.dock_dict[temp]:
+ """Sdf."""
+ self.temp = self.obj_appconfig.current_project['ProjectName']
+ for dockwidget in self.obj_appconfig.dock_dict[self.temp]:
dockwidget.close()
diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py
index d84f41e0..8d0ef4ec 100644
--- a/src/frontEnd/ProjectExplorer.py
+++ b/src/frontEnd/ProjectExplorer.py
@@ -6,12 +6,20 @@ from configuration.Appconfig import Appconfig
# This is main class for Project Explorer Area.
class ProjectExplorer(QtGui.QWidget):
- """ """
+ """
+ This class contains function:
+ a)One work as a constructor(__init__).
+ b)For saving data.
+ c)for renaming project.
+ d)for refreshing project.
+ e)for removing project.
+ f) for saving data.
+ """
def __init__(self):
"""
This method is doing following tasks:
- a)initializing objects used in full program.
+ a)Working as a constructor for class ProjectExplorer.
b)view of project explorer area.
"""
QtGui.QWidget.__init__(self)
@@ -24,20 +32,20 @@ class ProjectExplorer(QtGui.QWidget):
# CSS
self.treewidget.setStyleSheet(" \
- QTreeView { border-radius: 15px; border: 1px solid gray; padding: \
- 5px; width: 200px; height: 150px; } \
- QTreeView::branch:has-siblings:!adjoins-item { border-image:\
- url(../../images/vline.png) 0; } \
- QTreeView::branch:has-siblings:adjoins-item { border-image:\
- url(../../images/branch-more.png) 0; } \
- QTreeView::branch:!has-children:!has-siblings:\
- adjoins-item { border-image: url(../../images/branch-end.png) 0; } \
- QTreeView::branch:has-children:!has-siblings:closed, \
- QTreeView::branch:closed:has-children:has-siblings { border-image:\
- none; image: url(../../images/branch-closed.png); } \
- QTreeView::branch:open:has-children:!has-siblings, \
- QTreeView::branch:open:has-children:has-siblings { border-image: \
- none; image: url(../../images/branch-open.png); } \
+ QTreeView::branch:has-siblings:!adjoins-item { \
+ border-image: url(../../images/vline.png) 0;} \
+ QTreeView::branch:has-siblings:adjoins-item { \
+ border-image: url(../../images/branch-more.png) 0; } \
+ QTreeView::branch:!has-children:!has-siblings:adjoins-item { \
+ border-image: url(../../images/branch-end.png) 0; } \
+ QTreeView::branch:has-children:!has-siblings:closed, \
+ QTreeView::branch:closed:has-children:has-siblings { \
+ border-image: none; \
+ image: url(../../images/branch-closed.png); } \
+ QTreeView::branch:open:has-children:!has-siblings, \
+ QTreeView::branch:open:has-children:has-siblings { \
+ border-image: none; \
+ image: url(../../images/branch-open.png); } \
")
for parents, children in list(
@@ -45,8 +53,9 @@ class ProjectExplorer(QtGui.QWidget):
os.path.join(parents)
if os.path.exists(parents):
pathlist = parents.split(os.sep)
- parentnode = QtGui.QTreeWidgetItem(self.treewidget,
- [pathlist[-1], parents])
+ parentnode = QtGui.QTreeWidgetItem(
+ self.treewidget, [pathlist[-1], parents]
+ )
for files in children:
QtGui.QTreeWidgetItem(
parentnode, [files, os.path.join(parents, files)])
@@ -64,9 +73,9 @@ class ProjectExplorer(QtGui.QWidget):
parentnode = QtGui.QTreeWidgetItem(
self.treewidget, [pathlist[-1], parents])
for files in children:
- QtGui.QTreeWidgetItem(
+ QtGui.QTreeWidgetItem(
parentnode, [files, os.path.join(parents, files)]
- )
+ )
(
self.obj_appconfig.
@@ -89,6 +98,8 @@ class ProjectExplorer(QtGui.QWidget):
menu = QtGui.QMenu()
if level == 0:
+ renameProject = menu.addAction(self.tr("Rename Project"))
+ renameProject.triggered.connect(self.renameProject)
deleteproject = menu.addAction(self.tr("Remove Project"))
deleteproject.triggered.connect(self.removeProject)
refreshproject = menu.addAction(self.tr("Refresh"))
@@ -159,6 +170,10 @@ class ProjectExplorer(QtGui.QWidget):
# This function is saving data before it closes the given file.
def save_data(self):
+ """
+ This function first opens file in write-mode, when write
+ operation is performed it closes that file and then window.
+ """
self.fopen = open(self.filePath, 'w')
self.fopen.write(self.text.toPlainText())
self.fopen.close()
@@ -167,7 +182,9 @@ class ProjectExplorer(QtGui.QWidget):
# This function removes the project in explorer area by right
# clicking on project and selecting remove option.
def removeProject(self):
- """ """
+ """
+
+ """
self.indexItem = self.treewidget.currentIndex()
self.filePath = str(
self.indexItem.sibling(
@@ -199,7 +216,7 @@ class ProjectExplorer(QtGui.QWidget):
for items in self.treewidget.selectedItems():
items.removeChild(items.child(0))
for files in filelistnew:
- QtGui.QTreeWidgetItem(
+ QtGui.QTreeWidgetItem(
parentnode, [
files, os.path.join(
self.filePath, files)])
@@ -207,3 +224,53 @@ class ProjectExplorer(QtGui.QWidget):
self.obj_appconfig.project_explorer[self.filePath] = filelistnew
json.dump(self.obj_appconfig.project_explorer,
open(self.obj_appconfig.dictPath, 'w'))
+
+ # """
+ def renameProject(self):
+ indexItem = self.treewidget.currentIndex()
+ baseFileName = str(indexItem.data())
+ newBaseFileName, ok = QtGui.QInputDialog.getText(
+ self, 'Rename Project', 'Project Name:',
+ QtGui.QLineEdit.Normal, baseFileName
+ )
+ if ok and newBaseFileName:
+ newBaseFileName = str(newBaseFileName)
+ projectPath, projectFiles = list(
+ self.obj_appconfig.project_explorer.items())[indexItem.row()]
+ updatedProjectFiles = []
+
+ # rename files matching project name
+ for projectFile in projectFiles:
+ if baseFileName in projectFile:
+ oldFilePath = os.path.join(projectPath, projectFile)
+ projectFile = projectFile.replace(
+ baseFileName, newBaseFileName, 1)
+ newFilePath = os.path.join(projectPath, projectFile)
+ print ("Renaming " + oldFilePath + " to " + newFilePath)
+ os.rename(oldFilePath, newFilePath)
+
+ updatedProjectFiles.append(projectFile)
+
+ # rename project folder
+ updatedProjectPath = newBaseFileName.join(
+ projectPath.rsplit(baseFileName, 1))
+ print ("Renaming " + projectPath + " to " + updatedProjectPath)
+ os.rename(projectPath, updatedProjectPath)
+
+ # update project_explorer dictionary
+ del self.obj_appconfig.project_explorer[projectPath]
+ self.obj_appconfig.project_explorer[updatedProjectPath] = (
+ updatedProjectFiles
+ )
+
+ # save project_explorer dictionary on disk
+ json.dump(self.obj_appconfig.project_explorer,
+ open(self.obj_appconfig.dictPath, 'w'))
+
+ # recreate project explorer tree
+ self.treewidget.clear()
+ for parent, children in (
+ self.obj_appconfig.project_explorer.items()
+ ):
+ self.addTreeNode(parent, children)
+ # """
diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py
index 62833064..30d0607b 100644
--- a/src/frontEnd/Workspace.py
+++ b/src/frontEnd/Workspace.py
@@ -21,6 +21,8 @@ import time
import os
# This class creates Workspace GUI.
+
+
class Workspace(QtGui.QWidget):
"""
diff --git a/src/frontEnd/pathmagic.py b/src/frontEnd/pathmagic.py
index 92a5e6e2..49c4932d 100644
--- a/src/frontEnd/pathmagic.py
+++ b/src/frontEnd/pathmagic.py
@@ -3,4 +3,4 @@ import sys
# Setting PYTHONPATH
cwd = os.getcwd()
(setPath, fronEnd) = os.path.split(cwd)
-sys.path.append(setPath) \ No newline at end of file
+sys.path.append(setPath)