diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index 2da64da..b5585d8 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -72,20 +72,15 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivateInterface* report, QMa mainLayout->addWidget(m_tabWidget); setLayout(mainLayout); -// if (!report) { -// m_report=new ReportEnginePrivate(this); -// m_report->setObjectName("report"); -// m_report->appendPage("page1"); -// } -// else { - m_report=report;//report->d_ptr; - if (!m_report->pageCount()) m_report->appendPage("page1"); -// } + m_report=report; + if (!m_report->pageCount()) m_report->appendPage("page1"); createTabs(); connect(dynamic_cast(m_report), SIGNAL(pagesLoadFinished()),this,SLOT(slotPagesLoadFinished())); - connect(dynamic_cast(m_report), SIGNAL(cleared()),this,SIGNAL(cleared())); + connect(dynamic_cast(m_report), SIGNAL(cleared()), this, SIGNAL(cleared())); + connect(dynamic_cast(m_report), SIGNAL(loaded()), this, SLOT(slotReportLoaded())); + connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentTabChanged(int))); #ifdef HAVE_UI_LOADER connect(m_report->scriptContext(), SIGNAL(dialogDeleted(QString)), this, SLOT(slotDialogDeleted(QString))); @@ -250,6 +245,7 @@ void ReportDesignWidget::loadState(QSettings* settings) void ReportDesignWidget::createTabs(){ + m_tabWidget->clear(); int pageIndex = -1; for (int i = 0; ipageCount();++i){ QGraphicsView* view = new QGraphicsView(qobject_cast(this)); @@ -465,14 +461,13 @@ bool ReportDesignWidget::save() bool ReportDesignWidget::loadFromFile(const QString &fileName) { if (m_report->loadFromFile(fileName,false)){ - QByteArray editorState = m_scriptEditor->saveState(); - createTabs(); - //connectPage(m_report->pageAt(0)); - m_scriptEditor->setPlainText(m_report->scriptContext()->initScript()); - m_scriptEditor->restoreState(editorState); - emit loaded(); - m_dialogChanged = false; - return true; +// QByteArray editorState = m_scriptEditor->saveState(); +// createTabs(); +// m_scriptEditor->setPlainText(m_report->scriptContext()->initScript()); +// m_scriptEditor->restoreState(editorState); +// emit loaded(); +// m_dialogChanged = false; +// return true; } else { QMessageBox::critical(this,tr("Error"),tr("Wrong file format")); return false; @@ -839,6 +834,16 @@ void ReportDesignWidget::slotCurrentTabChanged(int index) if (view) view->centerOn(0,0); } +void ReportDesignWidget::slotReportLoaded() +{ + QByteArray editorState = m_scriptEditor->saveState(); + createTabs(); + m_scriptEditor->setPlainText(m_report->scriptContext()->initScript()); + m_scriptEditor->restoreState(editorState); + emit loaded(); + m_dialogChanged = false; +} + #ifdef HAVE_QTDESIGNER_INTEGRATION void ReportDesignWidget::addNewDialog() diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index 2887621..8e812dc 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -168,6 +168,7 @@ private slots: void slotDatasourceCollectionLoaded(const QString&); void slotSceneRectChanged(QRectF); void slotCurrentTabChanged(int index); + void slotReportLoaded(); #ifdef HAVE_QTDESIGNER_INTEGRATION void slotDialogChanged(QString); void slotDialogNameChanged(QString oldName, QString newName); diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index b54e13e..e699459 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -67,6 +67,7 @@ #ifdef HAVE_STATIC_BUILD #include "lrfactoryinitializer.h" #endif + namespace LimeReport{ QSettings* ReportEngine::m_settings = 0; @@ -740,7 +741,11 @@ bool ReportEnginePrivate::loadFromFile(const QString &fileName, bool autoLoadPre m_fileWatcher->addPath( fileName ); } - return slotLoadFromFile( fileName ); + bool result = slotLoadFromFile( fileName ); + if (result) { + emit loaded(); + } + return result; } bool ReportEnginePrivate::loadFromByteArray(QByteArray* data, const QString &name){ @@ -752,6 +757,7 @@ bool ReportEnginePrivate::loadFromByteArray(QByteArray* data, const QString &nam if (reader->readItem(this)){ m_fileName = ""; m_reportName = name; + emit loaded(); return true; }; } @@ -768,6 +774,7 @@ bool ReportEnginePrivate::loadFromString(const QString &report, const QString &n if (reader->readItem(this)){ m_fileName = ""; m_reportName = name; + emit loaded(); return true; }; } @@ -1131,6 +1138,7 @@ ReportEngine::ReportEngine(QObject *parent) connect(d, SIGNAL(onSave()), this, SIGNAL(onSave())); connect(d, SIGNAL(onLoad(bool&)), this, SIGNAL(onLoad(bool&))); connect(d, SIGNAL(saveFinished()), this, SIGNAL(saveFinished())); + connect(d, SIGNAL(loaded()), this, SIGNAL(loaded())); } ReportEngine::~ReportEngine() @@ -1177,7 +1185,7 @@ void ReportEngine::designReport() d->designReport(); } -ReportDesignWindowInterface*ReportEngine::getDesignerWindow() +ReportDesignWindowInterface* ReportEngine::getDesignerWindow() { Q_D(ReportEngine); return d->getDesignerWindow(); diff --git a/limereport/lrreportengine.h b/limereport/lrreportengine.h index 589e359..bed2d88 100644 --- a/limereport/lrreportengine.h +++ b/limereport/lrreportengine.h @@ -120,6 +120,7 @@ signals: void onLoad(bool& loaded); void onSave(); void saveFinished(); + void loaded(); public slots: void cancelRender(); protected: diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index 95ed764..d0bc16f 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -189,6 +189,7 @@ signals: void onLoad(bool& loaded); void onSave(); void saveFinished(); + void loaded(); public slots: bool slotLoadFromFile(const QString& fileName); void cancelRender();