예제 #1
0
 def saveImage(self):
     filters = (self.tr("Images (*.jpg *.jpeg *.bmp *.png *.tiff *.gif)"),
                self.tr("All files (*.*)"))
     # TODO: Set default name to coin title + field name
     fileName, _selectedFilter = getSaveFileName(
         self, 'save_image', self.name, OpenNumismat.IMAGE_PATH, filters)
     if fileName:
         self.image.save(fileName)
예제 #2
0
    def save(self):
        defaultFileName = "%s_%s" % (self.chartSelector.currentText(),
                                     QDateTime.currentDateTime().toString('yyyyMMdd'))

        fileName, selectedFilter = getSaveFileName(
            self, 'export_statistics', defaultFileName,
            OpenNumismat.HOME_PATH, self.chart.filters)
        if fileName:
            self.chart.save(fileName, selectedFilter)
    def save(self):
        defaultFileName = "%s_%s" % (self.chartSelector.currentText(),
                                     QDateTime.currentDateTime().toString('yyyyMMdd'))

        fileName, selectedFilter = getSaveFileName(
            self, 'export_statistics', defaultFileName,
            OpenNumismat.HOME_PATH, self.chart.filters)
        if fileName:
            self.chart.save(fileName, selectedFilter)
예제 #4
0
 def _q_export(self, action):
     if exportToWordAvailable and action == self.wordAction:
         fileName, _selectedFilter = getSaveFileName(
             self, 'export', '', OpenNumismat.HOME_PATH,
             self.tr("Word documents (*.doc)"))
         if fileName:
             self.__exportToWord(self.fileName, fileName)
     elif action == self.htmlAction:
         fileName, _selectedFilter = getSaveFileName(
             self, 'export', '', OpenNumismat.HOME_PATH,
             self.tr("Web page (*.htm *.html)"))
         if fileName:
             self.__exportToHtml(fileName)
     elif action == self.pdfAction:
         fileName, _selectedFilter = getSaveFileName(
             self, 'export', '', OpenNumismat.HOME_PATH,
             self.tr("PDF file (*.pdf)"))
         if fileName:
             self.__exportToPdf(fileName)
예제 #5
0
 def _q_export(self, action):
     if exportToWordAvailable and action == self.wordAction:
         fileName, _selectedFilter = getSaveFileName(
             self, 'export', '',
             OpenNumismat.HOME_PATH, self.tr("Word documents (*.doc)"))
         if fileName:
             self.__exportToWord(self.fileName, fileName)
     elif action == self.htmlAction:
         fileName, _selectedFilter = getSaveFileName(
             self, 'export', '',
             OpenNumismat.HOME_PATH, self.tr("Web page (*.htm *.html)"))
         if fileName:
             self.__exportToHtml(fileName)
     elif action == self.pdfAction:
         fileName, _selectedFilter = getSaveFileName(
             self, 'export', '',
             OpenNumismat.HOME_PATH, self.tr("PDF file (*.pdf)"))
         if fileName:
             self.__exportToPdf(fileName)
예제 #6
0
    def saveTable(self):
        filters = (self.tr("Excel document (*.xls)"),
                   self.tr("Web page (*.htm *.html)"),
                   self.tr("Text file (*.csv)"),
                   self.tr("Text file UTF-8 (*.csv)"))
        if not ExportToExcel.isAvailable():
            filters = filters[1:]

        defaultFileName = self.listParam.page.title
        fileName, selectedFilter = getSaveFileName(
            self, 'export_table', defaultFileName,
            OpenNumismat.HOME_PATH, filters)
        if fileName:
            model = self.model()
            progressDlg = Gui.ProgressDialog(self.tr("Saving list"),
                                    self.tr("Cancel"), model.rowCount(), self)

            if filters.index(selectedFilter) == 0:  # Excel documents
                export = ExportToExcel(fileName, self.listParam.page.title)
            elif filters.index(selectedFilter) == 1:  # Web page
                export = ExportToHtml(fileName, self.listParam.page.title)
            elif filters.index(selectedFilter) == 2:  # Text file
                export = ExportToCsv(fileName, self.listParam.page.title)
            elif filters.index(selectedFilter) == 3:  # Text file UTF-8
                export = ExportToCsvUtf8(fileName, self.listParam.page.title)
            else:
                raise

            export.open()

            parts = []
            for param in self.listParam.columns:
                if not param.enabled:
                    continue

                field = model.fields.field(param.fieldid)
                if field.type in Type.ImageTypes:
                    continue

                parts.append(field.title)

            export.writeHeader(parts)

            for i in range(model.rowCount()):
                progressDlg.step()
                if progressDlg.wasCanceled():
                    break

                index = self.__mapToSource(self.proxyModel.index(i, 0))
                record = model.record(index.row())
                parts = []
                for param in self.listParam.columns:
                    field = model.fields.field(param.fieldid)
                    if field.type in Type.ImageTypes:
                        continue

                    if not param.enabled:
                        continue

                    if record.isNull(param.fieldid):
                        parts.append('')
                    else:
                        parts.append(record.value(param.fieldid))

                export.writeRow(parts)

            export.close()

            progressDlg.reset()