diff --git a/limereport/databrowser/lrdatabrowser.cpp b/limereport/databrowser/lrdatabrowser.cpp index ba89566..b6db492 100644 --- a/limereport/databrowser/lrdatabrowser.cpp +++ b/limereport/databrowser/lrdatabrowser.cpp @@ -426,18 +426,58 @@ void DataBrowser::initConnections() { ui->dataTree->clear(); QListitems; - foreach(QString connectionName,m_report->dataManager()->connectionNames()){ + + QStringList connections = QSqlDatabase::connectionNames(); + foreach(QString connectionName, m_report->dataManager()->connectionNames()){ + if (!connections.contains(connectionName,Qt::CaseInsensitive)){ + connections.append(connectionName); + } + } + qSort(connections); + foreach (QString connectionName, connections) { QTreeWidgetItem *item=new QTreeWidgetItem( ui->dataTree, QStringList(ConnectionDesc::connectionNameForUser(connectionName)), DataBrowserTree::Connection ); - if (m_report->dataManager()->isConnectionConnected(connectionName)) + if (!m_report->dataManager()->connectionNames().contains(ConnectionDesc::connectionNameForReport(connectionName), Qt::CaseInsensitive)) + { item->setIcon(0,QIcon(":/databrowser/images/database_connected")); - else - item->setIcon(0,QIcon(":/databrowser/images/database_disconnected")); + } else { + if (m_report->dataManager()->isConnectionConnected(connectionName)) + item->setIcon(0,QIcon(":/databrowser/images/database_connected")); + else + item->setIcon(0,QIcon(":/databrowser/images/database_disconnected")); + } items.append(item); } + + +// foreach (QString connectionName, connections) { +// QTreeWidgetItem *item=new QTreeWidgetItem( +// ui->dataTree, +// QStringList(ConnectionDesc::connectionNameForUser(connectionName)), +// DataBrowserTree::Connection +// ); +// item->setIcon(0,QIcon(":/databrowser/images/database_connected")); +// } + +// connections = m_report->dataManager()->connectionNames(); +// qSort(connections); +// foreach(QString connectionName,connectionName){ +// if (!QSqlDatabase::contains(connectionName)){ +// QTreeWidgetItem *item=new QTreeWidgetItem( +// ui->dataTree, +// QStringList(ConnectionDesc::connectionNameForUser(connectionName)), +// DataBrowserTree::Connection +// ); +// if (m_report->dataManager()->isConnectionConnected(connectionName)) +// item->setIcon(0,QIcon(":/databrowser/images/database_connected")); +// else +// item->setIcon(0,QIcon(":/databrowser/images/database_disconnected")); +// items.append(item); +// } +// } ui->dataTree->insertTopLevelItems(0,items); } @@ -642,7 +682,8 @@ bool DataBrowser::checkConnectionDesc(ConnectionDesc *connection) bool DataBrowser::containsDefaultConnection() { - bool result = m_report->dataManager()->connectionByName(QSqlDatabase::defaultConnection); + bool result = m_report->dataManager()->connectionByName(QSqlDatabase::defaultConnection) || + QSqlDatabase::contains(QSqlDatabase::defaultConnection); return result; } @@ -660,7 +701,7 @@ void DataBrowser::on_dataTree_currentItemChanged(QTreeWidgetItem *current, QTree { Q_UNUSED(previous) if (current&&(current->type() == DataBrowserTree::Connection)) { - ui->pbConnect->setEnabled(true); + bool internalConnection = m_report->dataManager()->connectionByName(ConnectionDesc::connectionNameForReport(current->text(0))); if (m_report->dataManager()->isConnectionConnected(current->text(0))){ ui->pbConnect->setIcon(QIcon(":/databrowser/images/plug-connect.png")); } else { @@ -668,9 +709,10 @@ void DataBrowser::on_dataTree_currentItemChanged(QTreeWidgetItem *current, QTree } ui->editDataSource->setEnabled(false); ui->deleteDataSource->setEnabled(false); - ui->viewDataSource->setEnabled(false); - ui->changeConnection->setEnabled(true); - ui->deleteConection->setEnabled(true); + ui->viewDataSource->setEnabled(false); + ui->pbConnect->setEnabled(internalConnection); + ui->changeConnection->setEnabled(internalConnection); + ui->deleteConection->setEnabled(internalConnection); ui->errorMessage->setDisabled(true); } else { ui->changeConnection->setEnabled(false); diff --git a/limereport/lrdatasourcemanager.cpp b/limereport/lrdatasourcemanager.cpp index 74dd69e..f0a9bf2 100644 --- a/limereport/lrdatasourcemanager.cpp +++ b/limereport/lrdatasourcemanager.cpp @@ -667,8 +667,10 @@ void DataSourceManager::addConnectionDesc(ConnectionDesc * connection) bool DataSourceManager::checkConnectionDesc(ConnectionDesc *connection) { if (connectConnection(connection)){ - if (connection->isInternal()) + if (connection->isInternal()){ QSqlDatabase::removeDatabase(connection->name()); + if (designTime()) emit datasourcesChanged(); + } return true; } if (connection->isInternal()) diff --git a/limereport/lrpreviewreportwindow.h b/limereport/lrpreviewreportwindow.h index bc942be..92b2829 100644 --- a/limereport/lrpreviewreportwindow.h +++ b/limereport/lrpreviewreportwindow.h @@ -98,7 +98,6 @@ private slots: void slotScalePercentChanged(int percent); void on_actionShowMessages_toggled(bool value); void on_actionShow_Toolbar_triggered(); - private: ItemsReaderIntf* reader(); void initPercentCombobox(); diff --git a/limereport/lrpreviewreportwindow.ui b/limereport/lrpreviewreportwindow.ui index bca9861..50487cb 100644 --- a/limereport/lrpreviewreportwindow.ui +++ b/limereport/lrpreviewreportwindow.ui @@ -35,7 +35,7 @@ 0 0 800 - 20 + 19 @@ -158,6 +158,9 @@ Close Preview + + Esc + diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index 5455529..358aa6b 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -539,6 +539,7 @@ void ReportDesignWindow::startNewReport() m_reportDesignWidget->createStartPage(); m_lblReportName->setText(""); updateRedoUndo(); + m_reportDesignWidget->slotPagesLoadFinished(); m_newPageHeader->setEnabled(true); m_newPageFooter->setEnabled(true); m_newReportHeader->setEnabled(true); diff --git a/limereport/scriptbrowser/lrscriptbrowser.cpp b/limereport/scriptbrowser/lrscriptbrowser.cpp index 8719229..8e6dcc3 100644 --- a/limereport/scriptbrowser/lrscriptbrowser.cpp +++ b/limereport/scriptbrowser/lrscriptbrowser.cpp @@ -64,6 +64,7 @@ void ScriptBrowser::setReportEditor(ReportDesignWidget* report) void ScriptBrowser::updateFunctionTree() { + ui->twFunctions->clear(); ScriptEngineManager* sm = reportEditor()->scriptManager(); QMap categ; foreach(ScriptFunctionDesc fd, sm->functionsDescribers()){