def add(self): """ Agrega un nuevo animal """ common = self.ui.common_name.toPlainText() if common == "": self.ui.msgBox = QtGui.QMessageBox.information(self, u'Error', u"Debe ingresar al menos el nombre común") else: cientific = self.ui.cientific_name.toPlainText() other = self.ui.data.toPlainText() tipo = self.ui.typeBox.currentText() id_type = controller_form.get_id_type(tipo) result = controller_form.add_animal(common, cientific, other, id_type) path = self.ui.image.toPlainText() if path != "": id_animal = controller_form.get_id_animal(common) shutil.copy(path,(self.directory.currentPath()+"/images/")) Ifile = QFileInfo(path) controller_form.add_image_dir(id_animal,Ifile.fileName()) else: noimage = controller_form.no_image() item = QGraphicsPixmapItem(noimage.scaled(100,100)) self.scene = QGraphicsScene() self.ui.graphicsView.setSceneRect(0,0,100,100) self.ui.graphicsView.setScene(self.scene) self.scene.addItem(item) if result: self.reject() else: self.ui.msgBox = QtGui.QMessageBox.information(self, u'Error', u"Hubo un problema al intentar agregar el animal")
def setTitle(self,fullPath): traceLogger.debug("fullPath=%s" % fullPath) if fullPath is '': self.setWindowTitle("[*]" + self.tr("Untitled")) else: info = QFileInfo(fullPath) self.setWindowFilePath(info.absolutePath()) self.setWindowTitle("[*]" + info.fileName())
def edit(self): """ Modifica un animal que se encuentre en la base de datos """ id_animal = controller_form.get_id_animal(self.common) common = self.ui.common_name.toPlainText() if common == "": self.ui.msgBox = QtGui.QMessageBox.information(self, u'Error', u"El nombre común no puede estar en blanco") else: cientific = self.ui.cientific_name.toPlainText() other = self.ui.data.toPlainText() tipo = self.ui.typeBox.currentText() id_type = controller_form.get_id_type(tipo) path = self.ui.image.toPlainText() result = controller_form.edit_animal(id_animal,common,cientific,other,id_type) if path != "": pixImage = controller_form.get_root_image(path) item = QGraphicsPixmapItem(pixImage.scaled(100,100)) scene = QGraphicsScene() scene.addItem(item) self.display.setScene(scene) self.ui.image.setPlainText(path) Ifile = QFileInfo(path) if controller_form.search_image(id_animal,Ifile.fileName()): controller_form.add_image_dir(id_animal,Ifile.fileName()) result = True else: result = False else: noimage = controller_form.no_image() item = QGraphicsPixmapItem(noimage.scaled(100,100)) scene = QGraphicsScene() scene.addItem(item) self.display.setScene(scene) self.ui.image.setPlainText(path) if result: self.reject() else: self.ui.msgBox = QtGui.QMessageBox.information(self, u'Error', u"Hubo un problema al intentar editar el animal, intentelo de nuevo")
def delete(self): """ Borra la imagen del animal cuando se preciona quitar """ path = self.ui.image.toPlainText() Ifile = QFileInfo(path) success = controller_form.del_image(Ifile.fileName()) if not success: self.ui.errorMessageDialog = QtGui.QMessageBox.information(self, 'Error', u"Dirección incorrecta", QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok) self.ui.image.setPlainText("")