def _add_file_to_project(self, path): """Add the file for 'path' in the project the user choose here.""" if self._projects_area.count() > 0: pathProject = [self.current_project] addToProject = add_to_project.AddToProject(pathProject, self) addToProject.exec_() if not addToProject.pathSelected: return main_container = IDE.get_service('main_container') if not main_container: return editorWidget = main_container.get_current_editor() if not editorWidget.file_path: name = QInputDialog.getText( None, translations.TR_ADD_FILE_TO_PROJECT, translations.TR_FILENAME + ": ")[0] if not name: QMessageBox.information( self, translations.TR_INVALID_FILENAME, translations.TR_INVALID_FILENAME_ENTER_A_FILENAME) return else: name = file_manager.get_basename(editorWidget.file_path) new_path = file_manager.create_path(addToProject.pathSelected, name) ide_srv = IDE.get_service("ide") old_file = ide_srv.get_or_create_nfile(path) new_file = old_file.save(editorWidget.text(), new_path) #FIXME: Make this file replace the original in the open tab else: pass
def _copy_file(self): path = self.model().filePath(self.currentIndex()) name = file_manager.get_basename(path) global projectsColumn pathProjects = [p.project for p in projectsColumn.projects] add_to_project_dialog = add_to_project.AddToProject(pathProjects, self) add_to_project_dialog.setWindowTitle(translations.TR_COPY_FILE_TO) add_to_project_dialog.exec_() if not add_to_project_dialog.path_selected: return name = QInputDialog.getText(self, translations.TR_COPY_FILE, translations.TR_FILENAME, text=name)[0] if not name: QMessageBox.information( self, translations.TR_INVALID_FILENAME, translations.TR_INVALID_FILENAME_ENTER_A_FILENAME) return new_path = file_manager.create_path(add_to_project_dialog.pathSelected, name) ninjaide = IDE.get_service("ide") current_nfile = ninjaide.get_or_create_nfile(path) # FIXME: Catch willOverWrite and willCopyTo signals current_nfile.copy(new_path)
def _add_file_to_project(self, path): """Add the file for 'path' in the project the user choose here.""" if self._active_project: pathProject = [self._active_project.project] addToProject = add_to_project.AddToProject(pathProject, self) addToProject.exec_() if not addToProject.pathSelected: return main_container = IDE.get_service('main_container') if not main_container: return editorWidget = main_container.get_current_editor() if not editorWidget.file_path: name = QInputDialog.getText(None, self.tr("Add File To Project"), self.tr("File Name:"))[0] if not name: QMessageBox.information( self, self.tr("Invalid Name"), self.tr("The file name is empty, please enter a name")) return else: name = file_manager.get_basename(editorWidget.file_path) new_path = file_manager.create_path(addToProject.pathSelected, name) ide_srv = IDE.get_service("ide") old_file, ide_srv.get_or_create_nfile(path) new_file = old_file.save(editorWidget.get_text(), path) #FIXME: Make this file replace the original in the open tab else: pass
def _move_file(self): path = self.model().filePath(self.currentIndex()) global projectsColumn pathProjects = [p.project for p in projectsColumn.projects] addToProject = add_to_project.AddToProject(pathProjects, self) addToProject.setWindowTitle(translations.TR_COPY_FILE_TO) addToProject.exec_() if not addToProject.pathSelected: return name = file_manager.get_basename(path) new_path = file_manager.create_path(addToProject.pathSelected, name) ide_srv = IDE.get_service("ide") current_nfile = ide_srv.get_or_create_nfile(path) #FIXME: Catch willOverWrite and willMove signals current_nfile.move(new_path)
def _move_file(self): path = self.model().filePath(self.currentIndex()) global projectsColumn path_projects = [p.project for p in projectsColumn.projects] add_to_project_dialog = add_to_project.AddToProject(path_projects) add_to_project_dialog.setWindowTitle(translations.TR_MOVE_FILE) add_to_project_dialog.exec_() if not add_to_project_dialog.path_selected: return name = file_manager.get_basename(path) new_path = file_manager.create_path( add_to_project_dialog.path_selected, name) ninjaide = IDE.get_service("ide") current_nfile = ninjaide.get_or_create_nfile(path) current_nfile.close() # FIXME: Catch willOverWrite and willMove signals current_nfile.move(new_path)
def _copy_file(self): path = self.model().filePath(self.currentIndex()) name = file_manager.get_basename(path) global projectsColumn pathProjects = [p.project for p in projectsColumn.projects] addToProject = add_to_project.AddToProject(pathProjects, self) addToProject.setWindowTitle(self.tr("Copy File to")) addToProject.exec_() if not addToProject.pathSelected: return name = QInputDialog.getText(self, self.tr("Copy File"), self.tr("File Name:"), text=name)[0] if not name: QMessageBox.information( self, self.tr("Invalid Name"), self.tr("The file name is empty, please enter a name")) return new_path = file_manager.create_path(addToProject.pathSelected, name) ide_srv = IDE.get_service("ide") current_nfile = ide_srv.get_or_create_nfile(path) #FIXME: Catch willOverWrite and willCopyTo signals current_nfile.copy(new_path)