def deleteFile(self): """ Delete file from database and update model and widget """ x = self.tableWidget_files.currentRow() fileId = self.sourcetext[x]['id'] #print("Delete row: " + str(x)) Dialog_confirmDelete = QtGui.QDialog() ui = Ui_Dialog_confirmDelete(self.sourcetext[x]['name']) ui.setupUi(Dialog_confirmDelete) ok = Dialog_confirmDelete.exec_() if ok: cur = self.settings['conn'].cursor() cur.execute("delete from source where id = ?", [fileId]) cur.execute("delete from coding where fid = ?", [fileId]) cur.execute("delete from coding2 where fid = ?", [fileId]) cur.execute("delete from annotation where fid = ?", [fileId]) cur.execute("delete from caselinkage where fid = ?", [fileId]) cur.execute("delete from fileAttr where fileID = ?", [fileId]) self.settings['conn'].commit() for item in self.sourcetext: if item['id'] == fileId: self.log += item['name'] + " deleted.\n" self.sourcetext.remove(item) self.tableWidget_files.removeRow(x)
def deleteAttribute(self): """ When delete button pressed, attribute is deleted from model and database """ tableRowsToDelete = [] # for table widget ids namesToDelete = [] for itemWidget in self.tableWidget.selectedItems(): tableRowsToDelete.append(int(itemWidget.row())) namesToDelete.append(str(self.tableWidget.item(itemWidget.row(),0).text())) #print("X:"+ str(itemWidget.row()) + " y:"+str(itemWidget.column()) +" "+itemWidget.text() +" id:"+str(self.tableWidget_codes.item(itemWidget.row(),3).text())) tableRowsToDelete.sort(reverse=True) if len(namesToDelete) == 0: return Dialog_confirmDelete = QtGui.QDialog() ui = Ui_Dialog_confirmDelete("\n".join(namesToDelete)) ui.setupUi(Dialog_confirmDelete) ok = Dialog_confirmDelete.exec_() if ok: for r in tableRowsToDelete: self.tableWidget.removeRow(r) for name in namesToDelete: for attr in self.attributes: if attr['name'] == name: self.attributes.remove(attr) cur = self.settings['conn'].cursor() cur.execute("delete from attributes where name = ?", (name,)) cur.execute("delete from caseAttr where variable = ?", (name,)) cur.execute("delete from fileAttr where variable = ?", (name,)) self.settings['conn'].commit()
def deleteCase(self): """ When delete button pressed, case is deleted from model and database """ tableRowsToDelete = [] # for table widget ids caseNamesToDelete = "" # for confirmDelete Dialog idsToDelete = [] # for ids for cases and db for itemWidget in self.tableWidget_cases.selectedItems(): tableRowsToDelete.append(int(itemWidget.row())) idsToDelete.append(int(self.tableWidget_cases.item(itemWidget.row(), self.ID_COLUMN).text())) caseNamesToDelete = caseNamesToDelete+"\n" + str(self.tableWidget_cases.item(itemWidget.row(),self.NAME_COLUMN).text()) #print("X:"+ str(itemWidget.row()) + " y:"+str(itemWidget.column()) +" "+itemWidget.text() +" id:"+str(self.tableWidget_codes.item(itemWidget.row(),3).text())) tableRowsToDelete.sort(reverse=True) if len(caseNamesToDelete) == 0: return Dialog_confirmDelete = QtGui.QDialog() ui = Ui_Dialog_confirmDelete(caseNamesToDelete) ui.setupUi(Dialog_confirmDelete) ok = Dialog_confirmDelete.exec_() if ok: for r in tableRowsToDelete: self.tableWidget_cases.removeRow(r) for id in idsToDelete: for c in self.cases: if c['id'] == id: self.cases.remove(c) cur = self.settings['conn'].cursor() #print(str(id) + " "+ str(type(id))) cur.execute("delete from cases where id = ?", [id]) cur.execute("delete from caselinkage where caseid = ?", [id]) cur.execute("delete from caseAttr where caseid = ?", [id]) self.settings['conn'].commit()
def deleteCat(self): """ When category highlighted and Delete button pressed. Delete category from model and database """ tableRowsToDelete = [] # for table widget ids idsToDelete = [] # for ids for cats and db catNamesToDelete = "" # for confirmDelete Dialog for itemWidget in self.tableWidget_cats.selectedItems(): tableRowsToDelete.append(int(itemWidget.row())) idsToDelete.append( int( self.tableWidget_cats.item(itemWidget.row(), self.CAT_ID_COLUMN).text())) catNamesToDelete = catNamesToDelete + "\n" + str( self.tableWidget_cats.item(itemWidget.row(), self.CAT_NAME_COLUMN).text()) #print("X:"+ str(itemWidget.row()) + " y:"+str(itemWidget.column()) +" "+itemWidget.text() +" id:"+str(self.tableWidget_codes.item(itemWidget.row(),3).text())) if catNamesToDelete == "": return tableRowsToDelete.sort(reverse=True) Dialog_confirmDelete = QtGui.QDialog() ui = Ui_Dialog_confirmDelete(catNamesToDelete) ui.setupUi(Dialog_confirmDelete) ok = Dialog_confirmDelete.exec_() if ok: for r in tableRowsToDelete: self.tableWidget_cats.removeRow(r) if self.selectedCategoryId != -1: # show all other categories and codes again self.selectedCategoryId = -1 for (row, item) in enumerate(self.cats): self.tableWidget_cats.showRow(row) for (row, item) in enumerate(self.freecode): self.tableWidget_codes.showRow(row) for catid in idsToDelete: for item in self.cats: if item['catid'] == catid: self.cats.remove(item) cur = self.settings['conn'].cursor() #print(str(id) + " "+ str(type(id))) cur.execute("delete from treecode where catid = ?", [catid]) cur.execute("delete from codecat where catid = ?", [catid]) self.settings['conn'].commit()
def deleteCode(self): """ When delete button pressed, code is deleted from model and database """ tableRowsToDelete = [] # for table widget ids codeNamesToDelete = "" # for confirmDelete Dialog idsToDelete = [] # for ids for freecode and db for itemWidget in self.tableWidget_codes.selectedItems(): tableRowsToDelete.append(int(itemWidget.row())) idsToDelete.append( int( self.tableWidget_codes.item(itemWidget.row(), self.ID_COLUMN).text())) codeNamesToDelete = codeNamesToDelete + "\n" + str( self.tableWidget_codes.item(itemWidget.row(), self.NAME_COLUMN).text().toUtf8()) codeNamesToDelete = codeNamesToDelete.decode("utf-8") #print("X:"+ str(itemWidget.row()) + " y:"+str(itemWidget.column()) +" "+itemWidget.text() +" id:"+str(self.tableWidget_codes.item(itemWidget.row(),3).text())) tableRowsToDelete.sort(reverse=True) if len(codeNamesToDelete) == 0: return Dialog_confirmDelete = QtGui.QDialog() ui = Ui_Dialog_confirmDelete(codeNamesToDelete) ui.setupUi(Dialog_confirmDelete) ok = Dialog_confirmDelete.exec_() if ok: for r in tableRowsToDelete: self.tableWidget_codes.removeRow(r) for id in idsToDelete: for code in self.freecode: if code['id'] == id: self.freecode.remove(code) cur = self.settings['conn'].cursor() #print(str(id) + " "+ str(type(id))) cur.execute("delete from coding where cid = ?", [id]) cur.execute("delete from coding2 where cid = ?", [id]) cur.execute("delete from freecode where id = ?", [id]) cur.execute("delete from treecode where cid=?", [id]) self.settings['conn'].commit() # update filter for tooltip and text edit self.eventFilter.setCodes(self.coding, self.freecode) self.unlight() self.highlight()
def deleteCode(self): """ When delete button pressed, code is deleted from model and database """ tableRowsToDelete = [] # for table widget ids codeNamesToDelete = "" # for confirmDelete Dialog idsToDelete = [] # for ids for freecode and db for itemWidget in self.tableWidget_codes.selectedItems(): tableRowsToDelete.append(int(itemWidget.row())) idsToDelete.append(int(self.tableWidget_codes.item(itemWidget.row(), self.ID_COLUMN).text())) codeNamesToDelete = ( codeNamesToDelete + "\n" + str(self.tableWidget_codes.item(itemWidget.row(), self.NAME_COLUMN).text().toUtf8()) ) codeNamesToDelete = codeNamesToDelete.decode("utf-8") # print("X:"+ str(itemWidget.row()) + " y:"+str(itemWidget.column()) +" "+itemWidget.text() +" id:"+str(self.tableWidget_codes.item(itemWidget.row(),3).text())) tableRowsToDelete.sort(reverse=True) if len(codeNamesToDelete) == 0: return Dialog_confirmDelete = QtGui.QDialog() ui = Ui_Dialog_confirmDelete(codeNamesToDelete) ui.setupUi(Dialog_confirmDelete) ok = Dialog_confirmDelete.exec_() if ok: for r in tableRowsToDelete: self.tableWidget_codes.removeRow(r) for id in idsToDelete: for code in self.freecode: if code["id"] == id: self.freecode.remove(code) cur = self.settings["conn"].cursor() # print(str(id) + " "+ str(type(id))) cur.execute("delete from coding where cid = ?", [id]) cur.execute("delete from coding2 where cid = ?", [id]) cur.execute("delete from freecode where id = ?", [id]) cur.execute("delete from treecode where cid=?", [id]) self.settings["conn"].commit() # update filter for tooltip and text edit self.eventFilter.setCodes(self.coding, self.freecode) self.unlight() self.highlight()
def deleteCase(self): """ When delete button pressed, case is deleted from model and database """ tableRowsToDelete = [] # for table widget ids caseNamesToDelete = "" # for confirmDelete Dialog idsToDelete = [] # for ids for cases and db for itemWidget in self.tableWidget_cases.selectedItems(): tableRowsToDelete.append(int(itemWidget.row())) idsToDelete.append( int( self.tableWidget_cases.item(itemWidget.row(), self.ID_COLUMN).text())) caseNamesToDelete = caseNamesToDelete + "\n" + str( self.tableWidget_cases.item(itemWidget.row(), self.NAME_COLUMN).text()) #print("X:"+ str(itemWidget.row()) + " y:"+str(itemWidget.column()) +" "+itemWidget.text() +" id:"+str(self.tableWidget_codes.item(itemWidget.row(),3).text())) tableRowsToDelete.sort(reverse=True) if len(caseNamesToDelete) == 0: return Dialog_confirmDelete = QtGui.QDialog() ui = Ui_Dialog_confirmDelete(caseNamesToDelete) ui.setupUi(Dialog_confirmDelete) ok = Dialog_confirmDelete.exec_() if ok: for r in tableRowsToDelete: self.tableWidget_cases.removeRow(r) for id in idsToDelete: for c in self.cases: if c['id'] == id: self.cases.remove(c) cur = self.settings['conn'].cursor() #print(str(id) + " "+ str(type(id))) cur.execute("delete from cases where id = ?", [id]) cur.execute("delete from caselinkage where caseid = ?", [id]) cur.execute("delete from caseAttr where caseid = ?", [id]) self.settings['conn'].commit()
def deleteJournal(self): """ Delete journal from database and update model and widget """ x = self.tableWidget_journals.currentRow() journalName = self.journals[x]['name'] #print(("Delete row: " + str(x))) Dialog_confirmDelete = QtGui.QDialog() ui = Ui_Dialog_confirmDelete(self.journals[x]['name']) ui.setupUi(Dialog_confirmDelete) ok = Dialog_confirmDelete.exec_() if ok: cur = self.settings['conn'].cursor() cur.execute("delete from journal where name = ?", [journalName]) self.settings['conn'].commit() for item in self.journals: if item['name'] == journalName: self.journals.remove(item) self.tableWidget_journals.removeRow(x) self.log += "Journal " + journalName + " deleted\n"
def deleteCat(self): """ When category highlighted and Delete button pressed. Delete category from model and database """ tableRowsToDelete = [] # for table widget ids idsToDelete = [] # for ids for cats and db catNamesToDelete = "" # for confirmDelete Dialog for itemWidget in self.tableWidget_cats.selectedItems(): tableRowsToDelete.append(int(itemWidget.row())) idsToDelete.append(int(self.tableWidget_cats.item(itemWidget.row(), self.CAT_ID_COLUMN).text())) catNamesToDelete = catNamesToDelete+"\n" + str(self.tableWidget_cats.item(itemWidget.row(), self.CAT_NAME_COLUMN).text()) #print("X:"+ str(itemWidget.row()) + " y:"+str(itemWidget.column()) +" "+itemWidget.text() +" id:"+str(self.tableWidget_codes.item(itemWidget.row(),3).text())) if catNamesToDelete == "": return tableRowsToDelete.sort(reverse=True) Dialog_confirmDelete = QtGui.QDialog() ui = Ui_Dialog_confirmDelete(catNamesToDelete) ui.setupUi(Dialog_confirmDelete) ok = Dialog_confirmDelete.exec_() if ok: for r in tableRowsToDelete: self.tableWidget_cats.removeRow(r) if self.selectedCategoryId != -1: # show all other categories and codes again self.selectedCategoryId = -1 for (row, item) in enumerate(self.cats): self.tableWidget_cats.showRow(row) for(row, item) in enumerate(self.freecode): self.tableWidget_codes.showRow(row) for catid in idsToDelete: for item in self.cats: if item['catid'] == catid: self.cats.remove(item) cur = self.settings['conn'].cursor() #print(str(id) + " "+ str(type(id))) cur.execute("delete from treecode where catid = ?", [catid]) cur.execute("delete from codecat where catid = ?", [catid]) self.settings['conn'].commit()