'Save report'

def save_report(self):

    (filename, _) = QFileDialog.getSaveFileName(self, 'Save    Report', self.save_dir, 'HTML    (*.html);;PDF    (*.pdf);;Report    (*.report)')
    if (not filename):
        return QDialog.Rejected
    self.save_dir = os.path.dirname(filename)
    self.saveSettings()
    (_, extension) = os.path.splitext(filename)
    if (extension == '.pdf'):
        printer = QPrinter()
        printer.setPageSize(QPrinter.A4)
        printer.setOutputFormat(QPrinter.PdfFormat)
        printer.setOutputFileName(filename)
        self.report_view.print_(printer)
    elif (extension == '.report'):
        self.save(filename)
    else:
        def save_html(contents):
            try:
                with open(filename, 'w', encoding='utf-8') as f:
                    f.write(contents)
            except PermissionError:
                self.permission_error(filename)
        save_html(self.report_view.html())
    self.report_changed = False
    return QDialog.Accepted
