diff --git a/include/lrreportengine.h b/include/lrreportengine.h index e6db8d0..6eed25a 100644 --- a/include/lrreportengine.h +++ b/include/lrreportengine.h @@ -122,6 +122,7 @@ signals: void onLoad(bool& loaded); void onSave(); void saveFinished(); + void loaded(); void getAviableLanguages(QList* languages); void currentDefaulLanguageChanged(QLocale::Language); QLocale::Language getCurrentDefaultLanguage(); diff --git a/limereport/databrowser/lrdatabrowser.cpp b/limereport/databrowser/lrdatabrowser.cpp index 3dcd795..50eaa6a 100644 --- a/limereport/databrowser/lrdatabrowser.cpp +++ b/limereport/databrowser/lrdatabrowser.cpp @@ -96,31 +96,10 @@ void DataBrowser::slotAddConnection() void DataBrowser::slotSQLEditingFinished(SQLEditResult result) { if (result.dialogMode==SQLEditDialog::AddMode) { - switch (result.resultMode) { - case SQLEditResult::Query: - addQuery(result); - break; - case SQLEditResult::SubQuery: - addSubQuery(result); - break; - case SQLEditResult::SubProxy: - addProxy(result); - default: - break; - } + addDatasource(result); } else { - switch(result.resultMode){ - case SQLEditResult::Query: - changeQuery(result); - break; - case SQLEditResult::SubQuery: - changeSubQuery(result); - break; - case SQLEditResult::SubProxy: - changeProxy(result); - } + applyChanges(result); } - updateDataTree(); } @@ -661,6 +640,50 @@ void DataBrowser::changeProxy(SQLEditResult result) } } +SQLEditResult::ResultMode DataBrowser::currentDatasourceType(const QString& datasourceName) +{ + if (m_report->dataManager()->isQuery(datasourceName)) return SQLEditResult::Query; + if (m_report->dataManager()->isSubQuery(datasourceName)) return SQLEditResult::SubQuery; + if (m_report->dataManager()->isProxy(datasourceName)) return SQLEditResult::SubProxy; + return SQLEditResult::Undefined; +} + + +void DataBrowser::applyChanges(SQLEditResult result) +{ + if (result.resultMode == currentDatasourceType(result.datasourceName)){ + switch(result.resultMode){ + case SQLEditResult::Query: + changeQuery(result); + break; + case SQLEditResult::SubQuery: + changeSubQuery(result); + break; + case SQLEditResult::SubProxy: + changeProxy(result); + } + } else { + removeDatasource(result.datasourceName); + addDatasource(result); + } +} + +void DataBrowser::addDatasource(SQLEditResult result) +{ + switch (result.resultMode) { + case SQLEditResult::Query: + addQuery(result); + break; + case SQLEditResult::SubQuery: + addSubQuery(result); + break; + case SQLEditResult::SubProxy: + addProxy(result); + default: + break; + } +} + void DataBrowser::addConnectionDesc(ConnectionDesc *connection) { m_report->dataManager()->addConnectionDesc(connection); diff --git a/limereport/databrowser/lrdatabrowser.h b/limereport/databrowser/lrdatabrowser.h index 7d0a91e..3e4bfd3 100644 --- a/limereport/databrowser/lrdatabrowser.h +++ b/limereport/databrowser/lrdatabrowser.h @@ -106,6 +106,11 @@ private: void addProxy(SQLEditResult result); void changeProxy(SQLEditResult result); + + SQLEditResult::ResultMode currentDatasourceType(const QString& datasourceName); + void applyChanges(SQLEditResult result); + void addDatasource(SQLEditResult result); + void addConnectionDesc(ConnectionDesc *connection); void changeConnectionDesc(ConnectionDesc *connection); bool checkConnectionDesc(ConnectionDesc *connection); diff --git a/limereport/databrowser/lrsqleditdialog.cpp b/limereport/databrowser/lrsqleditdialog.cpp index f74ae6c..ae0d297 100644 --- a/limereport/databrowser/lrsqleditdialog.cpp +++ b/limereport/databrowser/lrsqleditdialog.cpp @@ -179,7 +179,7 @@ void SQLEditDialog::setDataSources(LimeReport::DataSourceManager *dataSources, Q { m_datasources=dataSources; if (!datasourceName.isEmpty()){ - ui->cbSubdetail->setEnabled(false); + ui->cbSubdetail->setEnabled(true); initQueryMode(); m_oldDatasourceName=datasourceName; ui->leDatasourceName->setText(datasourceName); @@ -278,7 +278,6 @@ void SQLEditDialog::initSubQueryMode() ui->leMaster->setVisible(true); ui->leMaster->setEnabled(true); ui->lbMaster->setVisible(true); - } void SQLEditDialog::initProxyMode() diff --git a/limereport/databrowser/lrsqleditdialog.h b/limereport/databrowser/lrsqleditdialog.h index 269f3f4..0f6759a 100644 --- a/limereport/databrowser/lrsqleditdialog.h +++ b/limereport/databrowser/lrsqleditdialog.h @@ -95,7 +95,7 @@ private: }; struct SQLEditResult{ - enum ResultMode{Query,SubQuery,SubProxy}; + enum ResultMode{Query, SubQuery, SubProxy, Undefined}; QString connectionName; QString datasourceName; QString oldDatasourceName;