0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-23 16:22:58 +03:00

Finish 1.7.13

This commit is contained in:
Arin Alex 2024-07-25 21:44:18 +03:00
commit a1937e6101
5 changed files with 26 additions and 3 deletions

View File

@ -177,6 +177,7 @@ public:
QString saveToString(); QString saveToString();
QString lastError(); QString lastError();
void setCurrentReportsDir(const QString& dirName); void setCurrentReportsDir(const QString& dirName);
bool setDefaultExportDir(const QString& dirName);
void setReportName(const QString& name); void setReportName(const QString& name);
QString reportName(); QString reportName();
PreviewReportWidget *createPreviewWidget(QWidget *parent = 0); PreviewReportWidget *createPreviewWidget(QWidget *parent = 0);

View File

@ -125,7 +125,7 @@ bool PreviewReportWidget::exportReport(QString exporterName, const QMap<QString,
if (ExportersFactory::instance().map().contains(exporterName)){ if (ExportersFactory::instance().map().contains(exporterName)){
ReportExporterInterface* e = ExportersFactory::instance().objectCreator(exporterName)(d_ptr->m_report); ReportExporterInterface* e = ExportersFactory::instance().objectCreator(exporterName)(d_ptr->m_report);
QString defaultFileName = d_ptr->m_report->reportName().split(".")[0]; QString defaultFileName = d_ptr->m_report->defaultExportDir() + d_ptr->m_report->reportName().split(".")[0];
QString filter = QString("%1 (*.%2)").arg(e->exporterName()).arg(e->exporterFileExt()); QString filter = QString("%1 (*.%2)").arg(e->exporterName()).arg(e->exporterFileExt());
QString fileName = QFileDialog::getSaveFileName(this,tr("%1 file name").arg(e->exporterName()), defaultFileName, filter); QString fileName = QFileDialog::getSaveFileName(this,tr("%1 file name").arg(e->exporterName()), defaultFileName, filter);
if (!fileName.isEmpty()){ if (!fileName.isEmpty()){
@ -286,7 +286,7 @@ void PreviewReportWidget::saveToFile()
PreparedPages pagesManager = PreparedPages(&d_ptr->m_reportPages); PreparedPages pagesManager = PreparedPages(&d_ptr->m_reportPages);
emit onSave(saved, &pagesManager); emit onSave(saved, &pagesManager);
if (!saved){ if (!saved){
QString fileName = QFileDialog::getSaveFileName(this,tr("Report file name")); QString fileName = QFileDialog::getSaveFileName(this,tr("Report file name"), d_ptr->m_report->defaultExportDir());
if (!fileName.isEmpty()){ if (!fileName.isEmpty()){
QScopedPointer< ItemsWriterIntf > writer(new XMLWriter()); QScopedPointer< ItemsWriterIntf > writer(new XMLWriter());
foreach (PageItemDesignIntf::Ptr page, d_ptr->m_reportPages){ foreach (PageItemDesignIntf::Ptr page, d_ptr->m_reportPages){

View File

@ -474,7 +474,8 @@ bool ReportEnginePrivate::exportReport(QString exporterName, const QString &file
QFileInfo fi(fn); QFileInfo fi(fn);
if (fi.suffix().isEmpty()) if (fi.suffix().isEmpty())
fn += QString(".%1").arg(e->exporterFileExt()); fn += QString(".%1").arg(e->exporterFileExt());
if (fi.absolutePath().compare(QDir::currentPath())==0)
fn = defaultExportDir() + fn;
bool designTime = dataManager()->designTime(); bool designTime = dataManager()->designTime();
dataManager()->setDesignTime(false); dataManager()->setDesignTime(false);
ReportPages pages = renderToPages(); ReportPages pages = renderToPages();
@ -657,6 +658,15 @@ void ReportEnginePrivate::setCurrentReportsDir(const QString &dirName)
m_reportsDir = dirName; m_reportsDir = dirName;
} }
bool ReportEnginePrivate::setDefaultExportDir(const QString &dirName)
{
if (QDir(dirName).exists()){
m_exportDir = dirName;
return true;
}
return false;
}
bool ReportEnginePrivate::slotLoadFromFile(const QString &fileName) bool ReportEnginePrivate::slotLoadFromFile(const QString &fileName)
{ {
EASY_BLOCK("ReportEnginePrivate::slotLoadFromFile") EASY_BLOCK("ReportEnginePrivate::slotLoadFromFile")
@ -1770,6 +1780,12 @@ void ReportEngine::setCurrentReportsDir(const QString &dirName)
return d->setCurrentReportsDir(dirName); return d->setCurrentReportsDir(dirName);
} }
bool ReportEngine::setDefaultExportDir(const QString &dirName)
{
Q_D(ReportEngine);
return d->setDefaultExportDir(dirName);
}
void ReportEngine::setReportName(const QString &name) void ReportEngine::setReportName(const QString &name)
{ {
Q_D(ReportEngine); Q_D(ReportEngine);

View File

@ -177,6 +177,7 @@ public:
QString saveToString(); QString saveToString();
QString lastError(); QString lastError();
void setCurrentReportsDir(const QString& dirName); void setCurrentReportsDir(const QString& dirName);
bool setDefaultExportDir(const QString& dirName);
void setReportName(const QString& name); void setReportName(const QString& name);
QString reportName(); QString reportName();
PreviewReportWidget *createPreviewWidget(QWidget *parent = 0); PreviewReportWidget *createPreviewWidget(QWidget *parent = 0);

View File

@ -103,6 +103,8 @@ public:
virtual void previewReport(PreviewHints hints = PreviewBarsUserSetting) = 0; virtual void previewReport(PreviewHints hints = PreviewBarsUserSetting) = 0;
virtual void setCurrentReportsDir(const QString& dirName) = 0; virtual void setCurrentReportsDir(const QString& dirName) = 0;
virtual QString currentReportsDir() = 0; virtual QString currentReportsDir() = 0;
virtual bool setDefaultExportDir(const QString& dirName) = 0;
virtual QString defaultExportDir() = 0;
virtual bool suppressFieldAndVarError() const = 0; virtual bool suppressFieldAndVarError() const = 0;
virtual void setSuppressFieldAndVarError(bool suppressFieldAndVarError) = 0; virtual void setSuppressFieldAndVarError(bool suppressFieldAndVarError) = 0;
virtual void setStyleSheet(const QString& styleSheet) = 0; virtual void setStyleSheet(const QString& styleSheet) = 0;
@ -210,6 +212,8 @@ public:
bool isSaved(); bool isSaved();
void setCurrentReportsDir(const QString& dirName); void setCurrentReportsDir(const QString& dirName);
QString currentReportsDir(){ return m_reportsDir;} QString currentReportsDir(){ return m_reportsDir;}
bool setDefaultExportDir(const QString& dirname);
QString defaultExportDir(){ return m_exportDir;}
void setReportName(const QString& reportName){ m_reportName=reportName;} void setReportName(const QString& reportName){ m_reportName=reportName;}
QString reportName(){ return m_reportName;} QString reportName(){ return m_reportName;}
bool hasActivePreview(){return m_activePreview;} bool hasActivePreview(){return m_activePreview;}
@ -336,6 +340,7 @@ private:
bool m_printerSelected; bool m_printerSelected;
bool m_showProgressDialog; bool m_showProgressDialog;
QString m_reportsDir; QString m_reportsDir;
QString m_exportDir;
QString m_reportName; QString m_reportName;
QMainWindow* m_activePreview; QMainWindow* m_activePreview;
QIcon m_previewWindowIcon; QIcon m_previewWindowIcon;