diff --git a/limereport/images/addBand1.png b/limereport/images/addBand1.png index d83b77e..d559323 100644 Binary files a/limereport/images/addBand1.png and b/limereport/images/addBand1.png differ diff --git a/limereport/images/addBand2.png b/limereport/images/addBand2.png new file mode 100644 index 0000000..cbaec50 Binary files /dev/null and b/limereport/images/addBand2.png differ diff --git a/limereport/images/delete2.png b/limereport/images/delete2.png new file mode 100644 index 0000000..90d6db0 Binary files /dev/null and b/limereport/images/delete2.png differ diff --git a/limereport/images/edit_control_4_24.png b/limereport/images/edit_control_4_24.png new file mode 100644 index 0000000..1964712 Binary files /dev/null and b/limereport/images/edit_control_4_24.png differ diff --git a/limereport/images/hlayuot_4_24.png b/limereport/images/hlayuot_4_24.png new file mode 100644 index 0000000..6c2a7c3 Binary files /dev/null and b/limereport/images/hlayuot_4_24.png differ diff --git a/limereport/items/images/barcode4.png b/limereport/items/images/barcode4.png new file mode 100644 index 0000000..635b977 Binary files /dev/null and b/limereport/items/images/barcode4.png differ diff --git a/limereport/items/images/barcode5.png b/limereport/items/images/barcode5.png new file mode 100644 index 0000000..5c195c2 Binary files /dev/null and b/limereport/items/images/barcode5.png differ diff --git a/limereport/items/images/imageItem4.png b/limereport/items/images/imageItem4.png new file mode 100644 index 0000000..589cc69 Binary files /dev/null and b/limereport/items/images/imageItem4.png differ diff --git a/limereport/items/images/insert-text_6.png b/limereport/items/images/insert-text_6.png index 0d68f8e..ac5982d 100644 Binary files a/limereport/items/images/insert-text_6.png and b/limereport/items/images/insert-text_6.png differ diff --git a/limereport/items/images/shapes7.png b/limereport/items/images/shapes7.png new file mode 100644 index 0000000..a9920f5 Binary files /dev/null and b/limereport/items/images/shapes7.png differ diff --git a/limereport/items/items.qrc b/limereport/items/items.qrc index aec5e59..8b0a351 100644 --- a/limereport/items/items.qrc +++ b/limereport/items/items.qrc @@ -11,10 +11,10 @@ images/insert-text_5.png images/shape5.png images/imageItem1.png - images/imageItem2.png + images/imageItem2.png images/settings.png images/settings2.png - images/hlayuot_3_24.png + images/hlayuot_3_24.png images/addBand1.png images/DataBand.png images/PageHeader.png @@ -34,8 +34,12 @@ images/GroupHeader16.png images/ReportPage16.png images/insert-text_6.png - images/barcode3.png - images/shape6.png - images/imageItem3.png + images/barcode3.png + images/shape6.png + images/imageItem3.png + images/barcode4.png + images/imageItem4.png + images/shapes7.png + images/barcode5.png diff --git a/limereport/lrdatadesignintf.cpp b/limereport/lrdatadesignintf.cpp index b9a15dd..3b24e66 100644 --- a/limereport/lrdatadesignintf.cpp +++ b/limereport/lrdatadesignintf.cpp @@ -369,6 +369,16 @@ void ConnectionDesc::setName(const QString &value) m_connectionName=value; } +bool ConnectionDesc::isEqual(const QSqlDatabase &db) +{ + return (db.databaseName() == m_databaseName) && + (db.driverName() == m_connectionDriver) && + (db.hostName() == m_connectionHost) && + (db.connectionName() == m_connectionName) && + (db.userName() == m_user) && + (db.password() == m_password); +} + QueryDesc::QueryDesc(QString queryName, QString queryText, QString connection) :m_queryName(queryName), m_queryText(queryText), m_connectionName(connection) {} diff --git a/limereport/lrdatadesignintf.h b/limereport/lrdatadesignintf.h index e53056f..abe26bb 100644 --- a/limereport/lrdatadesignintf.h +++ b/limereport/lrdatadesignintf.h @@ -129,6 +129,7 @@ public: QString password(){return m_password;} void setAutoconnect(bool value){m_autoconnect=value;} bool autoconnect(){return m_autoconnect;} + bool isEqual(const QSqlDatabase& db); signals: void nameChanged(const QString& oldName,const QString& newName); private: diff --git a/limereport/lrdatasourcemanager.cpp b/limereport/lrdatasourcemanager.cpp index b6c25d3..42ec024 100644 --- a/limereport/lrdatasourcemanager.cpp +++ b/limereport/lrdatasourcemanager.cpp @@ -634,6 +634,7 @@ bool DataSourceManager::checkConnectionDesc(ConnectionDesc *connection) QSqlDatabase::removeDatabase(connection->name()); return true; } + QSqlDatabase::removeDatabase(connection->name()); return false; } @@ -672,8 +673,38 @@ void DataSourceManager::putProxyDesc(ProxyDesc *proxyDesc) } else throw ReportError(tr("datasource with name \"%1\" already exists !").arg(proxyDesc->name())); } +bool DataSourceManager::initAndOpenDB(QSqlDatabase& db, ConnectionDesc& connectionDesc){ + + bool connected = false; + db.setHostName(replaceVariables(connectionDesc.host())); + db.setUserName(replaceVariables(connectionDesc.userName())); + db.setPassword(replaceVariables(connectionDesc.password())); + + QString dbName = replaceVariables(connectionDesc.databaseName()); + if (connectionDesc.driver().compare("QSQLITE")==0){ + if (!defaultDatabasePath().isEmpty()){ + dbName = !QFileInfo(dbName).exists() ? + defaultDatabasePath()+QFileInfo(dbName).fileName() : + dbName; + } + if (QFileInfo(dbName).exists()){ + db.setDatabaseName(dbName); + } else { + setLastError(tr("Database \"%1\" not found").arg(dbName)); + return false; + } + } else { + db.setDatabaseName(dbName); + } + + connected=db.open(); + if (!connected) setLastError(db.lastError().text()); + return connected; +} + bool DataSourceManager::connectConnection(ConnectionDesc *connectionDesc) { + bool connected = false; clearErrors(); QString lastError =""; @@ -682,11 +713,31 @@ bool DataSourceManager::connectConnection(ConnectionDesc *connectionDesc) dataSourceHolder(datasourceName)->clearErrors(); } - if (QSqlDatabase::contains(connectionDesc->name())){ + if (!QSqlDatabase::contains(connectionDesc->name())){ + QSqlDatabase db = QSqlDatabase::addDatabase(connectionDesc->driver(),connectionDesc->name()); + connected=initAndOpenDB(db, *connectionDesc); + if (!connected){ + setLastError(db.lastError().text()); + return false; + } + } else { + QSqlDatabase db = QSqlDatabase::database(connectionDesc->name()); + if (!connectionDesc->isEqual(db)){ + db.close(); + connected = initAndOpenDB(db, *connectionDesc); + } else { + connected = db.isOpen(); + } + } + + if (!connected) { + QSqlDatabase::removeDatabase(connectionDesc->name()); + return false; + } else { foreach(QString datasourceName, dataSourceNames()){ if (isQuery(datasourceName)){ QueryHolder* qh = dynamic_cast(dataSourceHolder(datasourceName)); - if (qh && qh->connectionName().compare(connectionDesc->name())==0){ + if (qh){ qh->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE); invalidateChildren(datasourceName); } @@ -700,41 +751,8 @@ bool DataSourceManager::connectConnection(ConnectionDesc *connectionDesc) } } } - - QSqlDatabase::removeDatabase(connectionDesc->name()); + if (designTime()) emit datasourcesChanged(); } - - QSqlDatabase db = QSqlDatabase::addDatabase(connectionDesc->driver(),connectionDesc->name()); - db.setHostName(replaceVariables(connectionDesc->host())); - db.setUserName(replaceVariables(connectionDesc->userName())); - db.setPassword(replaceVariables(connectionDesc->password())); - QString dbName = replaceVariables(connectionDesc->databaseName()); - if (connectionDesc->driver().compare("QSQLITE")==0){ - if (!defaultDatabasePath().isEmpty()){ - dbName = !QFileInfo(dbName).exists() ? - defaultDatabasePath()+QFileInfo(dbName).fileName() : - dbName; - } - if (QFileInfo(dbName).exists()){ - db.setDatabaseName(dbName); - connected=db.open(); - } else { - lastError = tr("Database \"%1\" not found").arg(dbName); - } - } else { - db.setDatabaseName(dbName); - connected=db.open(); - if (!connected) lastError=db.lastError().text(); - } - - if (designTime()) emit datasourcesChanged(); - - if (!connected) { - QSqlDatabase::removeDatabase(connectionDesc->name()); - setLastError(lastError); - return false; - } - return true; } diff --git a/limereport/lrdatasourcemanager.h b/limereport/lrdatasourcemanager.h index 92499c9..a6043f0 100644 --- a/limereport/lrdatasourcemanager.h +++ b/limereport/lrdatasourcemanager.h @@ -220,6 +220,7 @@ private slots: void slotQueryTextChanged(const QString& queryName, const QString& queryText); private: explicit DataSourceManager(QObject *parent = 0); + bool initAndOpenDB(QSqlDatabase &db, ConnectionDesc &connectionDesc); Q_DISABLE_COPY(DataSourceManager) private: QList m_connections; diff --git a/limereport/report.qrc b/limereport/report.qrc index 6dfc6fe..0f74519 100644 --- a/limereport/report.qrc +++ b/limereport/report.qrc @@ -121,11 +121,11 @@ images/text_bold1.png images/text_italic1.png images/text_underline1.png - images/edit_control_3_24.png + images/edit_control_3_24.png images/edit_layout_4_24.png - images/hlayuot_3_24.png - images/addBand1.png - images/delete1.png + images/hlayuot_3_24.png + images/addBand1.png + images/delete1.png images/copy2.png images/new_leaf1.png images/paste1.png @@ -170,5 +170,9 @@ images/toolbar.png images/not_checked.png images/checked.png + images/hlayuot_4_24.png + images/delete2.png + images/addBand2.png + images/edit_control_4_24.png