def __init__(self, pathProjects, parent=None): QDialog.__init__(self, parent) self.setWindowTitle(self.tr("Add File to Project")) self.pathSelected = '' vbox = QVBoxLayout(self) self._tree = QTreeWidget() self._tree.header().setHidden(True) self._tree.setSelectionMode(QTreeWidget.SingleSelection) self._tree.setAnimated(True) vbox.addWidget(self._tree) hbox = QHBoxLayout() btnAdd = QPushButton(self.tr("Add here!")) btnCancel = QPushButton(self.tr("Cancel")) hbox.addWidget(btnCancel) hbox.addWidget(btnAdd) vbox.addLayout(hbox) #load folders self._root = None if isinstance(pathProjects, list): #pathProject is a list from TreeProjectsWidget._copy_file() for pathProject in pathProjects: folderStructure = file_manager.open_project(pathProject) self._load_project(folderStructure, pathProject) else: #pathProject is a string from anywhere folderStructure = file_manager.open_project(pathProjects) self._load_project(folderStructure, pathProjects) self.connect(btnCancel, SIGNAL("clicked()"), self.close) self.connect(btnAdd, SIGNAL("clicked()"), self._select_path)
def open_project_folder(self, folderName='', notIDEStart=True): if not self._treeProjects and notIDEStart: QMessageBox.information(self, self.tr("Projects Disabled"), self.tr("Project support has been disabled from Preferences")) return if not folderName: if settings.WORKSPACE: directory = settings.WORKSPACE else: directory = self._workingDirectory folderName = unicode(QFileDialog.getExistingDirectory(self, self.tr("Open Project Directory"), directory)) try: if not folderName: return self._workingDirectory = folderName if not self._treeProjects.is_open(folderName): self._treeProjects.load_project( file_manager.open_project(folderName), folderName) self.save_recent_projects(folderName) else: self._treeProjects._set_current_project(folderName) self.emit(SIGNAL("projectOpened(QString)"), folderName) except Exception, reason: logger.error('open_project_folder: %s', reason) if not notIDEStart: QMessageBox.information(self, self.tr("Incorrect Project"), self.tr("The project could not be loaded!"))
def open_project_folder(self, folderName='', notIDEStart=True): if not self._treeProjects and notIDEStart: QMessageBox.information(self, self.tr("Projects Disabled"), self.tr("Project support has been disabled from Preferences")) return if not folderName: if settings.WORKSPACE: directory = settings.WORKSPACE else: directory = self._workingDirectory folderName = unicode(QFileDialog.getExistingDirectory(self, self.tr("Open Project Directory"), directory)) try: if not folderName: return self._workingDirectory = folderName if not self._treeProjects.is_open(folderName): project = json_manager.read_ninja_project(folderName) extensions = project.get('supported-extensions', settings.SUPPORTED_EXTENSIONS) if extensions != settings.SUPPORTED_EXTENSIONS: structure = file_manager.open_project_with_extensions( folderName, extensions) else: structure = file_manager.open_project(folderName) self._treeProjects.load_project(structure, folderName) self.save_recent_projects(folderName) else: self._treeProjects._set_current_project(folderName) self.emit(SIGNAL("projectOpened(QString)"), folderName) except Exception, reason: logger.error('open_project_folder: %s', reason) if not notIDEStart: QMessageBox.information(self, self.tr("Incorrect Project"), self.tr("The project could not be loaded!"))
def __init__(self, pathProjects, parent=None): #pathProjects must be a list QDialog.__init__(self, parent) self.setWindowTitle(self.tr("Add File to Project")) self.pathSelected = '' vbox = QVBoxLayout(self) self._tree = QTreeWidget() self._tree.header().setHidden(True) self._tree.setSelectionMode(QTreeWidget.SingleSelection) self._tree.setAnimated(True) vbox.addWidget(self._tree) hbox = QHBoxLayout() btnAdd = QPushButton(self.tr("Add here!")) btnCancel = QPushButton(self.tr("Cancel")) hbox.addWidget(btnCancel) hbox.addWidget(btnAdd) vbox.addLayout(hbox) #load folders self._root = None for pathProject in pathProjects: folderStructure = file_manager.open_project(pathProject) self._load_project(folderStructure, pathProject) self.connect(btnCancel, SIGNAL("clicked()"), self.close) self.connect(btnAdd, SIGNAL("clicked()"), self._select_path)
def listdir(path): fdict = file_manager.open_project(path) for each_folder in fdict: files, folders = fdict[each_folder] yield each_folder for each_file in files: yield os.path.join(each_folder, each_file)
def _thread_refresh_project(self): if self._extensions != settings.SUPPORTED_EXTENSIONS: folderStructure = file_manager.open_project_with_extensions(self._folder_path, self._extensions) else: folderStructure = file_manager.open_project(self._folder_path) if folderStructure.get(self._folder_path, [None, None])[1] is not None: folderStructure[self._folder_path][1].sort() values = (self._folder_path, self._item, folderStructure) self.emit(SIGNAL("folderDataRefreshed(PyQt_PyObject)"), values)
def _thread_refresh_project(self): if self._extensions != settings.SUPPORTED_EXTENSIONS: folderStructure = file_manager.open_project_with_extensions( self._folder_path, self._extensions) else: folderStructure = file_manager.open_project(self._folder_path) if folderStructure.get(self._folder_path, [None, None])[1] is not None: folderStructure[self._folder_path][1].sort() values = (self._folder_path, self._item, folderStructure) self.emit(SIGNAL("folderDataRefreshed(PyQt_PyObject)"), values)
def _thread_open_project(self): try: project = json_manager.read_ninja_project(self._folder_path) extensions = project.get("supported-extensions", settings.SUPPORTED_EXTENSIONS) if extensions != settings.SUPPORTED_EXTENSIONS: structure = file_manager.open_project_with_extensions(self._folder_path, extensions) else: structure = file_manager.open_project(self._folder_path) self.emit(SIGNAL("folderDataAcquired(PyQt_PyObject)"), (self._folder_path, structure)) except: self.emit(SIGNAL("folderDataAcquired(PyQt_PyObject)"), (self._folder_path, None))
def _thread_refresh_project(self): if self._extensions != settings.SUPPORTED_EXTENSIONS: folderStructure = file_manager.open_project_with_extensions( self._folder_path, self._extensions) else: try: folderStructure = file_manager.open_project(self._folder_path) except NinjaIOException: pass # There is not much we can do at this point if folderStructure and (folderStructure.get(self._folder_path, [None, None])[1] is not None): folderStructure[self._folder_path][1].sort() values = (self._folder_path, self._item, folderStructure) self.emit(SIGNAL("folderDataRefreshed(PyQt_PyObject)"), values)
def _thread_refresh_project(self, path, item, parentItem): if parentItem.extensions != settings.SUPPORTED_EXTENSIONS: folderStructure = file_manager.open_project_with_extensions( path, parentItem.extensions) else: folderStructure = file_manager.open_project(path) if folderStructure.get(path, [None, None])[1] is not None: folderStructure[path][1].sort() values = (folderStructure, path, item) else: values = None self._thread_execution[path].storage_values = values self._thread_execution[path].signal_return = path
def _thread_refresh_project(self): if self._extensions != settings.SUPPORTED_EXTENSIONS: folderStructure = file_manager.open_project_with_extensions( self._folder_path, self._extensions) else: try: folderStructure = file_manager.open_project(self._folder_path) except NinjaIOException: pass # There is not much we can do at this point if folderStructure and (folderStructure.get( self._folder_path, [None, None])[1] is not None): folderStructure[self._folder_path][1].sort() values = (self._folder_path, self._item, folderStructure) self.emit(SIGNAL("folderDataRefreshed(PyQt_PyObject)"), values)
def _thread_open_project(self): try: project = json_manager.read_ninja_project(self._folder_path) extensions = project.get('supported-extensions', settings.SUPPORTED_EXTENSIONS) if extensions != settings.SUPPORTED_EXTENSIONS: structure = file_manager.open_project_with_extensions( self._folder_path, extensions) else: structure = file_manager.open_project(self._folder_path) self.emit(SIGNAL("folderDataAcquired(PyQt_PyObject)"), (self._folder_path, structure)) except: self.emit(SIGNAL("folderDataAcquired(PyQt_PyObject)"), (self._folder_path, None))
def _thread_open_project(self, folderName): self._treeProjects.mute_signals = True try: project = json_manager.read_ninja_project(folderName) extensions = project.get('supported-extensions', settings.SUPPORTED_EXTENSIONS) if extensions != settings.SUPPORTED_EXTENSIONS: structure = file_manager.open_project_with_extensions( folderName, extensions) else: structure = file_manager.open_project(folderName) self._thread_execution[folderName].storage_values = ( structure, folderName) self._thread_execution[folderName].signal_return = folderName except Exception, reason: logger.error('open_project_folder: %s', reason) self._treeProjects.remove_loading_icon(folderName)
def _thread_open_project(self, folderName): self._treeProjects.mute_signals = True try: project = json_manager.read_ninja_project(folderName) extensions = project.get('supported-extensions', settings.SUPPORTED_EXTENSIONS) if extensions != settings.SUPPORTED_EXTENSIONS: structure = file_manager.open_project_with_extensions( folderName, extensions) else: structure = file_manager.open_project(folderName) self._thread_execution[folderName].storage_values = (structure, folderName) self._thread_execution[folderName].signal_return = folderName except Exception, reason: logger.error('open_project_folder: %s', reason) self._treeProjects.remove_loading_icon(folderName)
def open_project_folder(self, folderName='', notIDEStart=True): self._treeProjects.mute_signals = True if not self._treeProjects and notIDEStart: QMessageBox.information(self, self.tr("Projects Disabled"), self.tr("Project support has been disabled from Preferences")) return if not folderName: if settings.WORKSPACE: directory = settings.WORKSPACE else: directory = os.path.expanduser("~") current_project = self.get_actual_project() mainContainer = main_container.MainContainer() editorWidget = mainContainer.get_actual_editor() if current_project is not None: directory = current_project elif editorWidget is not None and editorWidget.ID: directory = file_manager.get_folder(editorWidget.ID) folderName = unicode(QFileDialog.getExistingDirectory(self, self.tr("Open Project Directory"), directory)) try: if not folderName: return if not self._treeProjects.is_open(folderName): project = json_manager.read_ninja_project(folderName) extensions = project.get('supported-extensions', settings.SUPPORTED_EXTENSIONS) if extensions != settings.SUPPORTED_EXTENSIONS: structure = file_manager.open_project_with_extensions( folderName, extensions) else: structure = file_manager.open_project(folderName) self._treeProjects.load_project(structure, folderName) self.save_recent_projects(folderName) else: self._treeProjects._set_current_project(folderName) self.emit(SIGNAL("projectOpened(QString)"), folderName) except Exception, reason: logger.error('open_project_folder: %s', reason) if not notIDEStart: QMessageBox.information(self, self.tr("Incorrect Project"), self.tr("The project could not be loaded!"))
def _refresh_project(self, item=None): if item is None: item = self.currentItem() parentItem = self._get_project_root(item) if parentItem is None: return if item.parent() is None: path = item.path else: path = file_manager.create_path(item.path, unicode(item.text(0))) if parentItem.extensions != settings.SUPPORTED_EXTENSIONS: folderStructure = file_manager.open_project_with_extensions( path, parentItem.extensions) else: folderStructure = file_manager.open_project(path) if folderStructure.get(path, [None, None])[1] is not None: folderStructure[path][1].sort() else: return item.takeChildren() self._load_folder(folderStructure, path, item) item.setExpanded(True)
def _thread_load_projects(self, projects): structures = [] for pathProject in projects: folderStructure = file_manager.open_project(pathProject) structures.append((folderStructure, pathProject)) self._thread_execution.storage_values = structures