From 23c03bea24b2ad59b8abc1394c39985928373598 Mon Sep 17 00:00:00 2001 From: anjalijaiswal08 Date: Sat, 1 Jun 2019 12:18:54 +0530 Subject: Minor changes --- src/frontEnd/ProjectExplorer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/frontEnd/ProjectExplorer.py') diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index d84f41e0..9128370e 100644 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -11,7 +11,7 @@ class ProjectExplorer(QtGui.QWidget): 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) -- cgit From 0b37af40b688ac0f68ab32fdefdf246b61dd1979 Mon Sep 17 00:00:00 2001 From: nilshah98 Date: Fri, 7 Jun 2019 12:40:35 +0530 Subject: treeWidget UI bug fixed --- src/frontEnd/ProjectExplorer.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/frontEnd/ProjectExplorer.py') diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index 9128370e..3a2ed2cc 100644 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -24,20 +24,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 +45,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)]) -- cgit From daffbbb29757deff785c13a429b4c03fe3f25fba Mon Sep 17 00:00:00 2001 From: nilshah98 Date: Fri, 7 Jun 2019 12:48:36 +0530 Subject: Rename feature ported --- src/frontEnd/ProjectExplorer.py | 60 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) (limited to 'src/frontEnd/ProjectExplorer.py') diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index 3a2ed2cc..658ea12e 100644 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -6,7 +6,15 @@ 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): """ @@ -90,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")) @@ -160,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() @@ -168,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( @@ -208,3 +224,43 @@ 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) + # """ -- cgit From 89c637c341a281d31ccd63be65a3504d6db79882 Mon Sep 17 00:00:00 2001 From: nilshah98 Date: Fri, 7 Jun 2019 19:15:54 +0530 Subject: made pep8 compliant using autopep8 tool --- src/frontEnd/ProjectExplorer.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/frontEnd/ProjectExplorer.py') diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index 658ea12e..cac9f986 100644 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -55,7 +55,7 @@ class ProjectExplorer(QtGui.QWidget): pathlist = parents.split(os.sep) parentnode = QtGui.QTreeWidgetItem( self.treewidget, [pathlist[-1], parents] - ) + ) for files in children: QtGui.QTreeWidgetItem( parentnode, [files, os.path.join(parents, files)]) @@ -225,22 +225,24 @@ class ProjectExplorer(QtGui.QWidget): 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) + QtGui.QLineEdit.Normal, baseFileName) if ok and newBaseFileName: newBaseFileName = str(newBaseFileName) - projectPath, projectFiles = list(self.obj_appconfig.project_explorer.items())[indexItem.row()] + 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) + projectFile = projectFile.replace( + baseFileName, newBaseFileName, 1) newFilePath = os.path.join(projectPath, projectFile) print ("Renaming " + oldFilePath + " to " + newFilePath) os.rename(oldFilePath, newFilePath) @@ -248,7 +250,8 @@ class ProjectExplorer(QtGui.QWidget): updatedProjectFiles.append(projectFile) # rename project folder - updatedProjectPath = newBaseFileName.join(projectPath.rsplit(baseFileName, 1)) + updatedProjectPath = newBaseFileName.join( + projectPath.rsplit(baseFileName, 1)) print ("Renaming " + projectPath + " to " + updatedProjectPath) os.rename(projectPath, updatedProjectPath) @@ -257,7 +260,8 @@ class ProjectExplorer(QtGui.QWidget): 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')) + json.dump(self.obj_appconfig.project_explorer, + open(self.obj_appconfig.dictPath, 'w')) # recreate project explorer tree self.treewidget.clear() -- cgit From 8d628dc33e1190dd1f8827bbd26f998d31d0827a Mon Sep 17 00:00:00 2001 From: nilshah98 Date: Fri, 7 Jun 2019 19:25:00 +0530 Subject: projectExplorer made pep8 compliant --- src/frontEnd/ProjectExplorer.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/frontEnd/ProjectExplorer.py') diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index cac9f986..8d0ef4ec 100644 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -73,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. @@ -216,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)]) @@ -229,12 +229,14 @@ class ProjectExplorer(QtGui.QWidget): 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) + 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()] + projectPath, projectFiles = list( + self.obj_appconfig.project_explorer.items())[indexItem.row()] updatedProjectFiles = [] # rename files matching project name @@ -257,7 +259,9 @@ class ProjectExplorer(QtGui.QWidget): # update project_explorer dictionary del self.obj_appconfig.project_explorer[projectPath] - self.obj_appconfig.project_explorer[updatedProjectPath] = updatedProjectFiles + self.obj_appconfig.project_explorer[updatedProjectPath] = ( + updatedProjectFiles + ) # save project_explorer dictionary on disk json.dump(self.obj_appconfig.project_explorer, @@ -265,6 +269,8 @@ class ProjectExplorer(QtGui.QWidget): # recreate project explorer tree self.treewidget.clear() - for parent, children in self.obj_appconfig.project_explorer.items(): + for parent, children in ( + self.obj_appconfig.project_explorer.items() + ): self.addTreeNode(parent, children) # """ -- cgit