GUI manage json files

master
Salvo 'LtWorf' Tomaselli 2020-08-24 18:55:51 +07:00
parent 5a271dce1d
commit a110f3f2c5
No known key found for this signature in database
GPG Key ID: B3A7CF0C801886CF
2 changed files with 7 additions and 4 deletions

@ -107,7 +107,10 @@ class UserInterface:
def store(self, filename: str, name: str) -> None:
'''Stores a relation to file.'''
raise Exception('Not implemented')
if filename.endswith('.csv'):
self.relations[name].save_csv(filename)
else:
self.relations[name].save(filename)
def session_dump(self, filename: Optional[str] = None) -> Optional[str]:
'''

@ -292,13 +292,13 @@ class relForm(QtWidgets.QMainWindow):
filename = QtWidgets.QFileDialog.getSaveFileName(
self, QtWidgets.QApplication.translate("Form", "Save Relation"),
"",
QtWidgets.QApplication.translate("Form", "Relations (*.csv)")
QtWidgets.QApplication.translate("Form", "Json relations (*.json);;CSV relations (*.csv)")
)[0]
if (len(filename) == 0): # Returns if no file was selected
return
relname = self.ui.lstRelations.selectedItems()[0].text()
self.user_interface.relations[relname].save(filename)
self.user_interface.store(filename, relname)
def unloadRelation(self):
for i in self.ui.lstRelations.selectedItems():
@ -422,7 +422,7 @@ class relForm(QtWidgets.QMainWindow):
"",
QtWidgets.QApplication.translate(
"Form",
"Relations (*.csv);;Text Files (*.txt);;All Files (*)"
"Relations (*.json *.csv);;Text Files (*.txt);;All Files (*)"
)
)
filenames = f[0]