0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-25 00:54:39 +03:00

Fix re-enabling subdetail checkbox #109

This commit is contained in:
Arin Alexander 2018-05-21 21:10:16 +03:00
parent 16a5da084a
commit c32281fb79
5 changed files with 54 additions and 26 deletions

View File

@ -122,6 +122,7 @@ signals:
void onLoad(bool& loaded); void onLoad(bool& loaded);
void onSave(); void onSave();
void saveFinished(); void saveFinished();
void loaded();
void getAviableLanguages(QList<QLocale::Language>* languages); void getAviableLanguages(QList<QLocale::Language>* languages);
void currentDefaulLanguageChanged(QLocale::Language); void currentDefaulLanguageChanged(QLocale::Language);
QLocale::Language getCurrentDefaultLanguage(); QLocale::Language getCurrentDefaultLanguage();

View File

@ -96,31 +96,10 @@ void DataBrowser::slotAddConnection()
void DataBrowser::slotSQLEditingFinished(SQLEditResult result) void DataBrowser::slotSQLEditingFinished(SQLEditResult result)
{ {
if (result.dialogMode==SQLEditDialog::AddMode) { if (result.dialogMode==SQLEditDialog::AddMode) {
switch (result.resultMode) { addDatasource(result);
case SQLEditResult::Query:
addQuery(result);
break;
case SQLEditResult::SubQuery:
addSubQuery(result);
break;
case SQLEditResult::SubProxy:
addProxy(result);
default:
break;
}
} else { } else {
switch(result.resultMode){ applyChanges(result);
case SQLEditResult::Query:
changeQuery(result);
break;
case SQLEditResult::SubQuery:
changeSubQuery(result);
break;
case SQLEditResult::SubProxy:
changeProxy(result);
}
} }
updateDataTree(); 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) void DataBrowser::addConnectionDesc(ConnectionDesc *connection)
{ {
m_report->dataManager()->addConnectionDesc(connection); m_report->dataManager()->addConnectionDesc(connection);

View File

@ -106,6 +106,11 @@ private:
void addProxy(SQLEditResult result); void addProxy(SQLEditResult result);
void changeProxy(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 addConnectionDesc(ConnectionDesc *connection);
void changeConnectionDesc(ConnectionDesc *connection); void changeConnectionDesc(ConnectionDesc *connection);
bool checkConnectionDesc(ConnectionDesc *connection); bool checkConnectionDesc(ConnectionDesc *connection);

View File

@ -179,7 +179,7 @@ void SQLEditDialog::setDataSources(LimeReport::DataSourceManager *dataSources, Q
{ {
m_datasources=dataSources; m_datasources=dataSources;
if (!datasourceName.isEmpty()){ if (!datasourceName.isEmpty()){
ui->cbSubdetail->setEnabled(false); ui->cbSubdetail->setEnabled(true);
initQueryMode(); initQueryMode();
m_oldDatasourceName=datasourceName; m_oldDatasourceName=datasourceName;
ui->leDatasourceName->setText(datasourceName); ui->leDatasourceName->setText(datasourceName);
@ -278,7 +278,6 @@ void SQLEditDialog::initSubQueryMode()
ui->leMaster->setVisible(true); ui->leMaster->setVisible(true);
ui->leMaster->setEnabled(true); ui->leMaster->setEnabled(true);
ui->lbMaster->setVisible(true); ui->lbMaster->setVisible(true);
} }
void SQLEditDialog::initProxyMode() void SQLEditDialog::initProxyMode()

View File

@ -95,7 +95,7 @@ private:
}; };
struct SQLEditResult{ struct SQLEditResult{
enum ResultMode{Query,SubQuery,SubProxy}; enum ResultMode{Query, SubQuery, SubProxy, Undefined};
QString connectionName; QString connectionName;
QString datasourceName; QString datasourceName;
QString oldDatasourceName; QString oldDatasourceName;