From 61047f72eb7d61e1c0efd7f22729e16fbfb97505 Mon Sep 17 00:00:00 2001 From: Harishankar Date: Tue, 30 Nov 2010 11:33:36 +0530 Subject: [PATCH] Add/remove files/folders in Site Generate dialog Implemented the add/remove files and folders to destination path in the Generate site dialog --- generate_dialog.py | 52 ++++++++++++++++++++++++++++++++ generate_dialog.ui | 70 +++++++++++++++++++++++++++++++++++++++++++ ui_generate_dialog.py | 6 +++- 3 files changed, 127 insertions(+), 1 deletion(-) diff --git a/generate_dialog.py b/generate_dialog.py index 0d7bbed..eb49933 100644 --- a/generate_dialog.py +++ b/generate_dialog.py @@ -2,6 +2,8 @@ # Generate site dialog import PyQt4 +import os +import os.path import ui_generate_dialog class GenerateDialog (PyQt4.QtGui.QDialog, ui_generate_dialog.Ui_SiteGenerateDialog): @@ -11,3 +13,53 @@ class GenerateDialog (PyQt4.QtGui.QDialog, ui_generate_dialog.Ui_SiteGenerateDia # set the database self.current_db = currentdb + + # when folder add is clicked + def onFolderAdd (self): + folder_to_add = PyQt4.QtGui.QFileDialog.getExistingDirectory (self, + "Folder whose contents to add to destination", os.path.expanduser ("~")) + # if cancelled return + if not folder_to_add: + return + + dest_rel_path, ok = PyQt4.QtGui.QInputDialog.getText (self, "Desination", + "Copy to location (within destination path)") + if not ok: + return + + folderitem = PyQt4.QtGui.QTreeWidgetItem ([folder_to_add, dest_rel_path]) + self.additional_folders.addTopLevelItem (folderitem) + + # when folder remove is clicked + def onFolderRemove (self): + selitem = self.additional_folders.currentItem () + selindex = self.additional_folders.indexOfTopLevelItem (selitem) + # if none selected + if selindex == -1: + return + self.additional_folders.takeTopLevelItem (selindex) + + + # when file add is clicked + def onFileAdd (self): + file_to_add = PyQt4.QtGui.QFileDialog.getOpenFileName (self, "File to add to destination", + os.path.expanduser ("~")) + # if cancelled return + if not file_to_add: + return + dest_rel_path, ok = PyQt4.QtGui.QInputDialog.getText (self, "Destination", + "Copy to location (within destination path)") + if not ok: + return + + fileitem = PyQt4.QtGui.QTreeWidgetItem ([file_to_add, dest_rel_path]) + self.additional_files.addTopLevelItem (fileitem) + + # when file remove is clicked + def onFileRemove (self): + selitem = self.additional_files.currentItem () + selindex = self.additional_files.indexOfTopLevelItem (selitem) + # if none selected + if selindex == -1: + return + self.additional_files.takeTopLevelItem (selindex) \ No newline at end of file diff --git a/generate_dialog.ui b/generate_dialog.ui index 21a3928..2330f19 100644 --- a/generate_dialog.ui +++ b/generate_dialog.ui @@ -213,5 +213,75 @@ p, li { white-space: pre-wrap; } + + addfile + clicked() + SiteGenerateDialog + onFileAdd() + + + 354 + 205 + + + 356 + 433 + + + + + removefile + clicked() + SiteGenerateDialog + onFileRemove() + + + 471 + 207 + + + 492 + 434 + + + + + addfolder + clicked() + SiteGenerateDialog + onFolderAdd() + + + 360 + 203 + + + 420 + 444 + + + + + removefolder + clicked() + SiteGenerateDialog + onFolderRemove() + + + 518 + 206 + + + 563 + 449 + + + + + onFileAdd() + onFileRemove() + onFolderAdd() + onFolderRemove() + diff --git a/ui_generate_dialog.py b/ui_generate_dialog.py index a14ac37..c28205d 100644 --- a/ui_generate_dialog.py +++ b/ui_generate_dialog.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'generate_dialog.ui' # -# Created: Mon Nov 29 22:36:32 2010 +# Created: Tue Nov 30 10:55:19 2010 # by: PyQt4 UI code generator 4.7.4 # # WARNING! All changes made in this file will be lost! @@ -82,6 +82,10 @@ class Ui_SiteGenerateDialog(object): self.retranslateUi(SiteGenerateDialog) self.tabWidget.setCurrentIndex(0) QtCore.QObject.connect(self.close, QtCore.SIGNAL("clicked()"), SiteGenerateDialog.reject) + QtCore.QObject.connect(self.addfile, QtCore.SIGNAL("clicked()"), SiteGenerateDialog.onFileAdd) + QtCore.QObject.connect(self.removefile, QtCore.SIGNAL("clicked()"), SiteGenerateDialog.onFileRemove) + QtCore.QObject.connect(self.addfolder, QtCore.SIGNAL("clicked()"), SiteGenerateDialog.onFolderAdd) + QtCore.QObject.connect(self.removefolder, QtCore.SIGNAL("clicked()"), SiteGenerateDialog.onFolderRemove) QtCore.QMetaObject.connectSlotsByName(SiteGenerateDialog) SiteGenerateDialog.setTabOrder(self.tabWidget, self.addfile) SiteGenerateDialog.setTabOrder(self.addfile, self.removefile) -- 2.20.1