def delete_project(self):
        """
        This method gets the selected project and deletes it form the database.
        :return: none
        """
        if self.project_name != "":
            button_reply = QtWidgets.QMessageBox.question(self.project_tab, 'PyQt5 message',
                                                          "Do you like to erase Project %s ?" % self.project_name,
                                                          QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
                                                          QtWidgets.QMessageBox.No)
            if button_reply == QtWidgets.QMessageBox.Yes:

                DBConnection.drop_db(self.project_name)

                self.project_tab.lineEdit_2.setText("")
                self.project_tab.textEdit_2.setText("")
                self.project_tab.lineEdit_3.setText("")
                self.set_binary_prop()
                self.delete_save_operations(self.project_creation_finished, [self.project_tab.pushButton_7],
                                            [self.project_tab.pushButton_8, self.project_tab.pushButton_10],
                                            self.project_tab.listWidget)

                list_items = self.project_tab.listWidget.selectedItems()
                if not list_items:
                    return
                for item in list_items:
                    self.project_tab.listWidget.takeItem(self.project_tab.listWidget.row(item))
                Singleton.set_project("BEAT")
                Singleton.set_path("")
                self.delete_project_signal.emit()
                self.project_selected_changed()
        else:
            msg = ErrorDialog(self.project_tab, "Please select a project", "Error Deleting Project")
            msg.exec_()
 def project_selected_changed(self):
     """
     This method listens for a change in the current project and updates the singleton and updates the view.
     :return: none
     """
     if self.project_tab.listWidget.count() != 0:
         project = self.project_tab.listWidget.selectedItems()
         project_name = [item.text().encode("ascii") for item in project]
         if project_name:
             self.project_name = str(project_name[0], 'utf-8')
             try:
                 Singleton.set_project(self.project_name)
                 project_db = DBConnection.get_collection(self.project_name)
                 project_info = project_db["projectInfo"]
                 bin_info = project_db["binaryInfo"]
                 cursor = project_info.find()
                 for db in cursor:
                     self.project_tab.textEdit_2.setPlainText(db['ProjectDescription'])
                     self.project_tab.lineEdit_2.setText(db['ProjectName'])
                     self.project_tab.lineEdit_3.setText(db['BnyFilePath'])
                     Singleton.set_path(db['BnyFilePath'])
                 cursor_bin = bin_info.find()
                 for db in cursor_bin:
                     self.set_binary_prop()
                     self.fill_binary_prop(db)
                 self.selected_project_changed.emit()
             except Exception as e:
                 msg = ErrorDialog(self.project_tab, str(e), "Error")
                 msg.exec()
    def save_project(self):
        """
        This method saves the newly created project into the database.
        :return: none
        """
        if self.project_tab.lineEdit_3.text() != "":
            saved = False
            project_db = DBConnection.get_collection(self.project_name)
            project_info = project_db["projectInfo"]
            info = {"ProjectName": self.project_tab.lineEdit_2.text(),
                    "ProjectDescription": self.project_tab.textEdit_2.toPlainText(),
                    "BnyFilePath": self.project_tab.lineEdit_3.text()}
            insert_info = project_info.insert(info, check_keys=False)
            bin_info = project_db["binaryInfo"]
            insert_obj = bin_info.insert(r2_bin_info, check_keys=False)
            msg = QtWidgets.QMessageBox()
            msg.setIcon(QtWidgets.QMessageBox.Information)
            msg.setWindowTitle("Save Project")
            msg.setText("Project Saved")
            msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
            retval = msg.exec_()
            Singleton.set_path(self.project_tab.lineEdit_3.text())
            Singleton.set_project(self.project_name)
            self.project_tab.textEdit_2.setReadOnly(True)
            self.delete_save_operations(self.project_creation_finished, [self.project_tab.pushButton_7],
                                   [self.project_tab.pushButton_8, self.project_tab.pushButton_10],
                                   self.project_tab.listWidget)

        else:
            msg = ErrorDialog(self.project_tab, "Please select a binary file", "Error Saving Project")
            msg.exec_()