Beispiel #1
0
def scan_delete_files(dirs_to_del,parent_window=None):
	if parent_window!=None:
		progress_window=progress_class()
		progress_window.show()
		progress_window.start()

		process_events()
	
	for i in range(0, len(dirs_to_del)):
		gpvdm_delete_file(dirs_to_del[i])
		if parent_window!=None:
			progress_window.set_fraction(float(i)/float(len(dirs_to_del)))
			progress_window.set_text("Deleting"+dirs_to_del[i])
			process_events()

	if parent_window!=None:
		progress_window.stop()
Beispiel #2
0
 def callback_clear_cache(self):
     path = os.path.join(get_user_settings_dir(), "cache")
     gpvdm_delete_file(path)
     self.close()
Beispiel #3
0
	def callback_menu(self,event):
		if self.enable_menu==False:
			return
		menu = QMenu(self)
		newmaterialAction=False
		newspectraAction=False
		newdirAction = menu.addAction(_("New directory"))
		if self.menu_new_material_enabled==True:
			newmaterialAction = menu.addAction(_("New material"))

		if self.menu_new_spectra_enabled==True:
			newspectraAction = menu.addAction(_("New spectra"))

		deleteAction = menu.addAction(_("Delete file"))
		renameAction = menu.addAction(_("Rename"))
		renameAction.setEnabled(False)
		deleteAction.setEnabled(False)
		if len(self.selectedItems())==1:
			renameAction.setEnabled(True)

		if len(self.selectedItems())>0:
			deleteAction.setEnabled(True)

		action = menu.exec_(self.mapToGlobal(event))

		if action == newdirAction:
			new_sim_name=dlg_get_text( _("New directory name:"), _("New directory"),"document-new")
			new_sim_name=new_sim_name.ret

			if new_sim_name!=None:
				name=os.path.join(self.path,new_sim_name)
				os.mkdir(name)
		elif action == newmaterialAction:
			new_sim_name=dlg_get_text( _("New material name:"), _("New material name"),"organic_material")
			new_sim_name=new_sim_name.ret
			if new_sim_name!=None:
				new_material=os.path.join(self.path,new_sim_name)
				clone_material(new_material,os.path.join(get_base_material_path(),"generic","generic_organic"))
		elif action == newspectraAction:
			new_sim_name=dlg_get_text( _("New spectra name:"), _("New spectra name"),"spectra_file")
			new_sim_name=new_sim_name.ret
			if new_sim_name!=None:
				new_material=os.path.join(self.path,new_sim_name)
				clone_spectra(new_material,get_base_spectra_path())
		elif action == deleteAction:
			files=""
			for i in self.selectedItems():
				files=files+os.path.join(self.path,i.text())+"\n"
			ret=yes_no_dlg(self,_("Are you sure you want to delete the files ?")+"\n\n"+files)
			if ret==True:
				for i in self.selectedItems():
					file_to_remove=os.path.join(self.path,i.text())
					gpvdm_delete_file(file_to_remove)
		elif action == renameAction:
			old_name=self.currentItem().text()
			new_sim_name=dlg_get_text( _("Rename:"), self.currentItem().text(),"rename")
			new_sim_name=new_sim_name.ret

			if new_sim_name!=None:
				new_name=os.path.join(self.path,new_sim_name)
				old_name=os.path.join(self.path,old_name)
				#print(old_name, new_name)
				os.rename(old_name, new_name)

		self.fill_store()
Beispiel #4
0
def scan_delete_files(dirs_to_del):
	for i in range(0, len(dirs_to_del)):
		gpvdm_delete_file(dirs_to_del[i])