'Load the specified file, or the last opened file if None.'

def loadFile(self, filePath=None):

    self.resetState()
    self.canvas.setEnabled(False)
    if (filePath is None):
        filePath = self.settings.get(SETTING_FILENAME)
    unicodeFilePath = ustr(filePath)
    if (unicodeFilePath and (self.fileListWidget.count() > 0)):
        index = self.mImgList.index(unicodeFilePath)
        fileWidgetItem = self.fileListWidget.item(index)
        fileWidgetItem.setSelected(True)
    if (unicodeFilePath and os.path.exists(unicodeFilePath)):
        if LabelFile.isLabelFile(unicodeFilePath):
            try:
                self.labelFile = LabelFile(unicodeFilePath)
            except LabelFileError as e:
                self.errorMessage(u'Error    opening    file', (u'<p><b>%s</b></p><p>Make    sure    <i>%s</i>    is    a    valid    label    file.' % (e, unicodeFilePath)))
                self.status(('Error    reading    %s' % unicodeFilePath))
                return False
            self.imageData = self.labelFile.imageData
            self.lineColor = QColor(*self.labelFile.lineColor)
            self.fillColor = QColor(*self.labelFile.fillColor)
        else:
            self.imageData = read(unicodeFilePath, None)
            self.labelFile = None
        image = QImage.fromData(self.imageData)
        if image.isNull():
            self.errorMessage(u'Error    opening    file', (u'<p>Make    sure    <i>%s</i>    is    a    valid    image    file.' % unicodeFilePath))
            self.status(('Error    reading    %s' % unicodeFilePath))
            return False
        self.status(('Loaded    %s' % os.path.basename(unicodeFilePath)))
        self.image = image
        self.filePath = unicodeFilePath
        self.canvas.loadPixmap(QPixmap.fromImage(image))
        if self.labelFile:
            self.loadLabels(self.labelFile.shapes)
        self.setClean()
        self.canvas.setEnabled(True)
        self.adjustScale(initial=True)
        self.paintCanvas()
        self.addRecentFile(self.filePath)
        self.toggleActions(True)
        if (self.usingPascalVocFormat is True):
            if (self.defaultSaveDir is not None):
                basename = (os.path.basename(os.path.splitext(self.filePath)[0]) + XML_EXT)
                xmlPath = os.path.join(self.defaultSaveDir, basename)
                self.loadPascalXMLByFilename(xmlPath)
            else:
                xmlPath = (os.path.splitext(filePath)[0] + XML_EXT)
                if os.path.isfile(xmlPath):
                    self.loadPascalXMLByFilename(xmlPath)
        self.setWindowTitle(((__appname__ + '    ') + filePath))
        if self.labelList.count():
            self.labelList.setCurrentItem(self.labelList.item((self.labelList.count() - 1)))
            self.labelList.item((self.labelList.count() - 1)).setSelected(True)
        self.canvas.setFocus(True)
        return True
    return False
