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 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)