1 # BiaWeb Website content manager (c) 2010 V.Harishankar
7 import ui_generate_dialog
9 class GenerateDialog (PyQt4
.QtGui
.QDialog
, ui_generate_dialog
.Ui_SiteGenerateDialog
):
10 def __init__ (self
, master
, currentdb
):
11 PyQt4
.QtGui
.QDialog
.__init
__ (self
, master
)
15 self
.current_db
= currentdb
17 # to return the list of items from a tree widget
18 def get_list_from_tree (self
, treewidget
):
20 iter = PyQt4
.QtGui
.QTreeWidgetItemIterator (treewidget
)
22 # iterate through the list of files
24 # while there is still a valid item
26 # get the text in columns 0 and 1
27 src
= str (item
.text (0))
28 dst
= str (item
.text (1))
30 lstfiles
.append ( (src
, dst
) )
31 # increase iterator by 1
37 # when site generate button is clicked
38 def onSiteGenerate (self
):
39 files_list
= self
.get_list_from_tree (self
.additional_files
)
40 folder_list
= self
.get_list_from_tree (self
.additional_folders
)
42 # when folder add is clicked
43 def onFolderAdd (self
):
44 folder_to_add
= PyQt4
.QtGui
.QFileDialog
.getExistingDirectory (self
,
45 "Folder whose contents to add to destination", os
.path
.expanduser ("~"))
50 dest_rel_path
, ok
= PyQt4
.QtGui
.QInputDialog
.getText (self
, "Desination",
51 "Copy to location (within destination path)")
55 folderitem
= PyQt4
.QtGui
.QTreeWidgetItem ([folder_to_add
, dest_rel_path
])
56 self
.additional_folders
.addTopLevelItem (folderitem
)
58 # when folder remove is clicked
59 def onFolderRemove (self
):
60 selitem
= self
.additional_folders
.currentItem ()
61 selindex
= self
.additional_folders
.indexOfTopLevelItem (selitem
)
65 self
.additional_folders
.takeTopLevelItem (selindex
)
68 # when file add is clicked
70 file_to_add
= PyQt4
.QtGui
.QFileDialog
.getOpenFileName (self
, "File to add to destination",
71 os
.path
.expanduser ("~"))
75 dest_rel_path
, ok
= PyQt4
.QtGui
.QInputDialog
.getText (self
, "Destination",
76 "Copy to location (within destination path)")
80 fileitem
= PyQt4
.QtGui
.QTreeWidgetItem ([file_to_add
, dest_rel_path
])
81 self
.additional_files
.addTopLevelItem (fileitem
)
83 # when file remove is clicked
84 def onFileRemove (self
):
85 selitem
= self
.additional_files
.currentItem ()
86 selindex
= self
.additional_files
.indexOfTopLevelItem (selitem
)
90 self
.additional_files
.takeTopLevelItem (selindex
)