refreshes the table after deleting the file

This commit is contained in:
VanillaHellen 2021-01-11 16:22:46 +01:00
parent 5cceb7c77f
commit 47a0a52475

View File

@ -41,7 +41,7 @@ class deletePopup(QMessageBox):
class LibraryTableButtons(QWidget):
def __init__(self, file, parent=None):
def __init__(self, file, table, type, parent=None):
super(LibraryTableButtons,self).__init__(parent)
def viewFile():
@ -49,10 +49,10 @@ class LibraryTableButtons(QWidget):
def deleteFile():
self.exPopup = deletePopup()
# self.exPopup.setGeometry(100, 200, 100, 100)
ret = self.exPopup.exec()
if ret == self.exPopup.Yes:
os.remove(file)
table.fillTable(type)
layout = QHBoxLayout()
layout.setContentsMargins(0,0,0,0)
@ -73,6 +73,9 @@ class LibraryTable(QTableWidget):
def __init__(self, type, parent=None):
QTableWidget.__init__(self)
self.fillTable(type)
def fillTable(self, type):
self.setColumnCount(3)
if type == LIB_RAW:
@ -81,6 +84,7 @@ class LibraryTable(QTableWidget):
else:
self.setHorizontalHeaderLabels(['Creation date', 'Filename', 'Options'])
filePath = outputFilePath
self.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
self.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
self.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeToContents)
@ -96,7 +100,7 @@ class LibraryTable(QTableWidget):
for index, date in enumerate(dates):
self.setItem(index,0,date)
self.setItem(index,1,names[index])
self.setCellWidget(index,2,LibraryTableButtons(filePath + '\\' + names[index].text()))
self.setCellWidget(index,2,LibraryTableButtons(filePath + '\\' + names[index].text(), self, type))
class formatHelp(QLabel):
@ -152,13 +156,13 @@ class MainWindow(QMainWindow):
# Show raw uploaded files
def showInputLibrary(self):
libTable = LibraryTable(LIB_RAW)
self.setCentralWidget(libTable)
self.libTable = LibraryTable(LIB_RAW)
self.setCentralWidget(self.libTable)
# Show visualisations
def showVisualisationsLibrary(self):
libTable = LibraryTable(LIB_VIS)
self.setCentralWidget(libTable)
self.libTable = LibraryTable(LIB_VIS)
self.setCentralWidget(self.libTable)
def showUploadFile(self):
dialog = QFileDialog(self)