Skip to content
Snippets Groups Projects
Commit 38bb0cac authored by Garrett Bates's avatar Garrett Bates
Browse files

Implemented listing of files and folders in selected data directory.

parent 0edd3e16
No related branches found
No related tags found
1 merge request!3Main UI and miscellaneous associated widgets
......@@ -16,12 +16,14 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
Qt Designer.
"""
currentDirectoryChanged = QtCore.Signal(str)
def __init__(self, parent=None):
super().__init__(parent)
self.setupUi(self)
cwd = os.path.dirname(pathlib.Path().absolute())
self.currentDirectoryChanged.emit(cwd)
self.setCurrentDirectory(cwd)
# File menu
self.deleteSetup.triggered.connect(self.deleteSetupFile)
......@@ -58,12 +60,18 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self.dateGroup.addAction(self.showYYYYMMMDDDates)
self.showYYYYDOYDates.setChecked(True)
self.showYYYYDOYDates.triggered.connect(lambda: self.setDateFormat('yyyy:D'))
self.showYYYY_MM_DDDates.triggered.connect(lambda: self.setDateFormat('yyyy-MM-dd'))
self.showYYYYMMMDDDates.triggered.connect(lambda: self.setDateFormat('yyyyMMMdd'))
self.timeToDateEdit.setCalendarWidget(CalendarWidget(self))
self.timeToDateEdit.setDate(QtCore.QDate.currentDate())
self.timeFromDateEdit.setCalendarWidget(CalendarWidget(self))
self.timeFromDateEdit.setDate(QtCore.QDate.currentDate())
self.showYYYYDOYDates.triggered.emit()
@QtCore.Slot()
def deleteSetupFile(self):
print('Deleting setup file.')
......@@ -116,17 +124,24 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def reloadFile(self):
print('Reloading last file.')
@QtCore.Slot()
def setDateFormat(self, displayFormat):
self.timeToDateEdit.setDisplayFormat(displayFormat)
self.timeFromDateEdit.setDisplayFormat(displayFormat)
def setCurrentDirectory(self, path=''):
self.currentDirectoryChanged.emit(path)
self.openFilesList.addItems([dent.name for dent in pathlib.Path(path).iterdir()])
@QtCore.Slot(str)
def changeCurrentDirectory(self, path=''):
fd = QtWidgets.QFileDialog(self)
fd.setFileMode(QtWidgets.QFileDialog.Directory)
fd.exec_()
new_path = fd.selectedFiles()[0]
self.currentDirectoryChanged.emit(new_path)
currentDirectoryChanged = QtCore.Signal(str)
self.setCurrentDirectory(new_path)
@QtCore.Slot()
@QtCore.Slot(str)
def openCalendarWidget(self):
calendar = CalendarDialog(self)
calendar.show()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment