def initialize_ui(self): routes = Configuration.routes() self.ui.routes_list.clear() for route in routes: self.ui.routes_list.addItem(route) if len(routes) > 0: self.ui.remove_route.setEnabled(True) else: self.ui.remove_route.setDisabled(True)
def remove_route(self): self.ui.routes_list.blockSignals(True) # fix it!!! current_row = self.ui.routes_list.currentRow() current_path = self.ui.routes_list.currentItem().text() self.ui.routes_list.takeItem(current_row) self.ui.routes_list.blockSignals(False) # update configuration routes = Configuration.routes() routes.remove(current_path) Configuration.set_routes(routes=routes)
def search_documents(self): """ search valid documents in config routes :return: document_added, documents deleted """ self.documents_added = [] self.documents_deleted = [] routes = Configuration.routes() for route in routes: document_finder = DocumentFinder(path=route) added, deleted = document_finder.find_documents() self.documents_added += added self.documents_deleted += deleted return len(self.documents_added), len(self.documents_deleted)
def add_route(self): path = QtGui.QFileDialog.getExistingDirectory( self, 'Seleccionar ruta', QtCore.QDir.homePath() ) if path != '': for index in xrange(self.ui.routes_list.count()): if self.ui.routes_list.item(index).text() == path: QtGui.QMessageBox.information( self, _from_Utf8('Añadir ruta'), 'La ruta seleccionada ya existe' ) return path_dir = QtCore.QDir(path) if not path_dir.isReadable: QtGui.QMessageBox.critical( self, _from_Utf8('Añadir ruta'), 'El directorio seleccionado no tiene permiso de lectura' ) return # update ui self.ui.routes_list.addItem(path) # update configuration routes = Configuration.routes() routes.append(path) Configuration.set_routes(routes=routes)