Esempio n. 1
0
    def openButton_clicked(self):
        self.fileNameTuple = QtGui.QFileDialog.getOpenFileName(self,
            "Open VitalView data file (.asc)", "", "ASCII Files (*.asc);;All Files (*.*)")
        
        if self.fileNameTuple[0] != '':
            rwparser = RwParser() # create rwparser class object
            
            # Get filename and Path information
            self.fullFilePath, self.dirName, self.fullFileName, \
                self.fileNameNoExt = rwparser.getFileNamesAndDir(self.fileNameTuple)
            
            # Check the header, if its correct...
            isCorrectHeader = rwparser.checkFileHeader(self.fullFilePath, MAIN_HEADER)
            if isCorrectHeader:
                # Create a new folder to house the parsed data and get path
                self.newFolderPath = rwparser.mkParsedFolder(self.dirName, self.fileNameNoExt)
                
                # Begin first pass - gets all time variables, parses first 3 files
                self.uniqueDates, self.startTime, self.endTime, self.distCsvName = \
                    rwparser.firstPass(self.fullFilePath, self.fileNameNoExt, self.newFolderPath)
                
                # Fill out the combo boxes
                self.startDateCombo.addItems(self.uniqueDates)
                self.endDateCombo.addItems(self.uniqueDates)
                
                # set the start and endDate combos to the first and last unique date
                self.startDateCombo.setCurrentIndex(1)
                self.endDateCombo.setCurrentIndex(len(self.uniqueDates)- 1)
                
                # Turn time strings into QTime obj and fill out time edits
                self.qtEndTime = QtCore.QTime.fromString(self.endTime, 'hh:mm:ss')
                self.qtStartTime = QtCore.QTime.fromString(self.startTime, 'hh:mm:ss')
                self.startTimeEdit.setTime(self.qtStartTime)
                self.endTimeEdit.setTime(self.qtEndTime)              
                               
                # Update all current QDateTime objects
                self.updateQtDateTimes()
                self.limitTimeEdit()
                  
                # Allow user to access filters and buttons
                self.enableButtons()

                # Change label to give user feedback
                self.changableLabel.setText(self.fullFileName + ' successfully loaded.')
            
            else:
                self.changableLabel.setText(self.fullFileName + ' is not a VitalView file')