summaryrefslogtreecommitdiff
path: root/src/frontEnd
diff options
context:
space:
mode:
authorAnkushECE2022-10-12 00:56:23 +0530
committerGitHub2022-10-12 00:56:23 +0530
commitfbf6e82dab9c42afcbd722117bcf7ec53333bba2 (patch)
tree3ce1b1194ec1625d848a59b0524870ca49a37f74 /src/frontEnd
parentec998692f698ceef68d8ccdb97c2132bd5bd1021 (diff)
parent7c1f5eacbc233bd365d1fc42c11aa3163f7947e1 (diff)
downloadeSim-fbf6e82dab9c42afcbd722117bcf7ec53333bba2.tar.gz
eSim-fbf6e82dab9c42afcbd722117bcf7ec53333bba2.tar.bz2
eSim-fbf6e82dab9c42afcbd722117bcf7ec53333bba2.zip
Merge branch 'FOSSEE:master' into master
Diffstat (limited to 'src/frontEnd')
-rw-r--r--src/frontEnd/Application.py9
-rwxr-xr-xsrc/frontEnd/ProjectExplorer.py54
2 files changed, 41 insertions, 22 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py
index d3ef020f..7588b1a1 100644
--- a/src/frontEnd/Application.py
+++ b/src/frontEnd/Application.py
@@ -10,11 +10,11 @@
# BUGS: ---
# NOTES: ---
# AUTHOR: Fahim Khan, fahim.elex@gmail.com
-# MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in
+# MAINTAINED: Rahul Paknikar, rahulp@cse.iitb.ac.in
# Sumanto Kar, sumantokar@iitb.ac.in
# ORGANIZATION: eSim Team at FOSSEE, IIT Bombay
# CREATED: Tuesday 24 February 2015
-# REVISION: Monday 31 January 2022
+# REVISION: Tuesday 13 September 2022
# =========================================================================
import os
@@ -949,4 +949,7 @@ def main(args):
# Call main function
if __name__ == '__main__':
# Create and display the splash screen
- main(sys.argv)
+ try:
+ main(sys.argv)
+ except Exception as err:
+ print("Error: ", err)
diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py
index 456276c8..77c9352e 100755
--- a/src/frontEnd/ProjectExplorer.py
+++ b/src/frontEnd/ProjectExplorer.py
@@ -69,13 +69,20 @@ class ProjectExplorer(QtWidgets.QWidget):
parentnode, [files, os.path.join(parents, files)]
)
self.window.addWidget(self.treewidget)
-
+ self.treewidget.expanded.connect(self.refreshInstant)
self.treewidget.doubleClicked.connect(self.openProject)
self.treewidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.treewidget.customContextMenuRequested.connect(self.openMenu)
self.setLayout(self.window)
self.show()
+ def refreshInstant(self):
+ for i in range(self.treewidget.topLevelItemCount()):
+ if(self.treewidget.topLevelItem(i).isExpanded()):
+ index = self.treewidget.indexFromItem(
+ self.treewidget.topLevelItem(i))
+ self.refreshProject(indexItem=index)
+
def addTreeNode(self, parents, children):
os.path.join(parents)
pathlist = parents.split(os.sep)
@@ -125,24 +132,21 @@ class ProjectExplorer(QtWidgets.QWidget):
self.filePath = str(
self.indexItem.sibling(self.indexItem.row(), 1).data()
)
- self.obj_appconfig.print_info(
- 'The current project is ' + self.filePath)
-
- self.textwindow = QtWidgets.QWidget()
- self.textwindow.setMinimumSize(600, 500)
- self.textwindow.setGeometry(QtCore.QRect(400, 150, 400, 400))
- self.textwindow.setWindowTitle(filename)
-
- self.text = QtWidgets.QTextEdit()
- self.save = QtWidgets.QPushButton('Save and Exit')
- self.save.setDisabled(True)
- self.windowgrid = QtWidgets.QGridLayout()
if (os.path.isfile(str(self.filePath))):
self.fopen = open(str(self.filePath), 'r')
lines = self.fopen.read()
- self.text.setText(lines)
+ self.textwindow = QtWidgets.QWidget()
+ self.textwindow.setMinimumSize(600, 500)
+ self.textwindow.setGeometry(QtCore.QRect(400, 150, 400, 400))
+ self.textwindow.setWindowTitle(filename)
+
+ self.text = QtWidgets.QTextEdit()
+ self.save = QtWidgets.QPushButton('Save and Exit')
+ self.save.setDisabled(True)
+
+ self.text.setText(lines)
self.text.textChanged.connect(self.enable_save)
vbox_main = QtWidgets.QVBoxLayout(self.textwindow)
@@ -152,6 +156,12 @@ class ProjectExplorer(QtWidgets.QWidget):
self.textwindow.show()
else:
+ self.refreshProject(self.filePath)
+
+ self.obj_appconfig.print_info(
+ 'The current project is: ' + self.filePath
+ )
+
self.obj_appconfig.current_project["ProjectName"] = str(
self.filePath)
(
@@ -202,25 +212,31 @@ class ProjectExplorer(QtWidgets.QWidget):
json.dump(self.obj_appconfig.project_explorer,
open(self.obj_appconfig.dictPath["path"], 'w'))
- def refreshProject(self, filePath=None):
+ def refreshProject(self, filePath=None, indexItem=None):
"""
This function refresh the project in explorer area by right \
clicking on project and selecting refresh option.
"""
if not filePath or filePath is None:
- self.indexItem = self.treewidget.currentIndex()
+ if indexItem is None:
+ self.indexItem = self.treewidget.currentIndex()
+ else:
+ self.indexItem = indexItem
+
filePath = str(
self.indexItem.sibling(self.indexItem.row(), 1).data()
)
if os.path.exists(filePath):
filelistnew = os.listdir(os.path.join(filePath))
- parentnode = self.treewidget.currentItem()
+ if indexItem is None:
+ parentnode = self.treewidget.currentItem()
+ else:
+ parentnode = self.treewidget.itemFromIndex(self.indexItem)
count = parentnode.childCount()
for i in range(count):
- for items in self.treewidget.selectedItems():
- items.removeChild(items.child(0))
+ parentnode.removeChild(parentnode.child(0))
for files in filelistnew:
QtWidgets.QTreeWidgetItem(
parentnode, [files, os.path.join(filePath, files)]