0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-01-12 09:31:04 +03:00

Merge branch '1.4' into 1.4_QJSEngine

This commit is contained in:
Arin Alexander 2016-11-17 00:42:24 +03:00
commit 7986fda128
16 changed files with 83 additions and 45 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 B

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

View File

@ -11,10 +11,10 @@
<file>images/insert-text_5.png</file> <file>images/insert-text_5.png</file>
<file>images/shape5.png</file> <file>images/shape5.png</file>
<file>images/imageItem1.png</file> <file>images/imageItem1.png</file>
<file alias="ImageItem">images/imageItem2.png</file> <file>images/imageItem2.png</file>
<file>images/settings.png</file> <file>images/settings.png</file>
<file>images/settings2.png</file> <file>images/settings2.png</file>
<file alias="HorizontalLayout">images/hlayuot_3_24.png</file> <file>images/hlayuot_3_24.png</file>
<file alias="Band">images/addBand1.png</file> <file alias="Band">images/addBand1.png</file>
<file>images/DataBand.png</file> <file>images/DataBand.png</file>
<file>images/PageHeader.png</file> <file>images/PageHeader.png</file>
@ -34,8 +34,12 @@
<file alias="GroupBandHeader">images/GroupHeader16.png</file> <file alias="GroupBandHeader">images/GroupHeader16.png</file>
<file alias="PageItemDesignIntf">images/ReportPage16.png</file> <file alias="PageItemDesignIntf">images/ReportPage16.png</file>
<file alias="TextItem">images/insert-text_6.png</file> <file alias="TextItem">images/insert-text_6.png</file>
<file alias="BarcodeItem">images/barcode3.png</file> <file>images/barcode3.png</file>
<file alias="ShapeItem">images/shape6.png</file> <file>images/shape6.png</file>
<file alias="ImageItem">images/imageItem3.png</file> <file>images/imageItem3.png</file>
<file>images/barcode4.png</file>
<file alias="ImageItem">images/imageItem4.png</file>
<file alias="ShapeItem">images/shapes7.png</file>
<file alias="BarcodeItem">images/barcode5.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -369,6 +369,16 @@ void ConnectionDesc::setName(const QString &value)
m_connectionName=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) QueryDesc::QueryDesc(QString queryName, QString queryText, QString connection)
:m_queryName(queryName), m_queryText(queryText), m_connectionName(connection) :m_queryName(queryName), m_queryText(queryText), m_connectionName(connection)
{} {}

View File

@ -129,6 +129,7 @@ public:
QString password(){return m_password;} QString password(){return m_password;}
void setAutoconnect(bool value){m_autoconnect=value;} void setAutoconnect(bool value){m_autoconnect=value;}
bool autoconnect(){return m_autoconnect;} bool autoconnect(){return m_autoconnect;}
bool isEqual(const QSqlDatabase& db);
signals: signals:
void nameChanged(const QString& oldName,const QString& newName); void nameChanged(const QString& oldName,const QString& newName);
private: private:

View File

@ -634,6 +634,7 @@ bool DataSourceManager::checkConnectionDesc(ConnectionDesc *connection)
QSqlDatabase::removeDatabase(connection->name()); QSqlDatabase::removeDatabase(connection->name());
return true; return true;
} }
QSqlDatabase::removeDatabase(connection->name());
return false; return false;
} }
@ -672,8 +673,38 @@ void DataSourceManager::putProxyDesc(ProxyDesc *proxyDesc)
} else throw ReportError(tr("datasource with name \"%1\" already exists !").arg(proxyDesc->name())); } 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 DataSourceManager::connectConnection(ConnectionDesc *connectionDesc)
{ {
bool connected = false; bool connected = false;
clearErrors(); clearErrors();
QString lastError =""; QString lastError ="";
@ -682,11 +713,31 @@ bool DataSourceManager::connectConnection(ConnectionDesc *connectionDesc)
dataSourceHolder(datasourceName)->clearErrors(); 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()){ foreach(QString datasourceName, dataSourceNames()){
if (isQuery(datasourceName)){ if (isQuery(datasourceName)){
QueryHolder* qh = dynamic_cast<QueryHolder*>(dataSourceHolder(datasourceName)); QueryHolder* qh = dynamic_cast<QueryHolder*>(dataSourceHolder(datasourceName));
if (qh && qh->connectionName().compare(connectionDesc->name())==0){ if (qh){
qh->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE); qh->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE);
invalidateChildren(datasourceName); invalidateChildren(datasourceName);
} }
@ -700,41 +751,8 @@ bool DataSourceManager::connectConnection(ConnectionDesc *connectionDesc)
} }
} }
} }
if (designTime()) emit datasourcesChanged();
QSqlDatabase::removeDatabase(connectionDesc->name());
} }
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; return true;
} }

View File

@ -220,6 +220,7 @@ private slots:
void slotQueryTextChanged(const QString& queryName, const QString& queryText); void slotQueryTextChanged(const QString& queryName, const QString& queryText);
private: private:
explicit DataSourceManager(QObject *parent = 0); explicit DataSourceManager(QObject *parent = 0);
bool initAndOpenDB(QSqlDatabase &db, ConnectionDesc &connectionDesc);
Q_DISABLE_COPY(DataSourceManager) Q_DISABLE_COPY(DataSourceManager)
private: private:
QList<ConnectionDesc*> m_connections; QList<ConnectionDesc*> m_connections;

View File

@ -121,11 +121,11 @@
<file alias="/images/textBold">images/text_bold1.png</file> <file alias="/images/textBold">images/text_bold1.png</file>
<file alias="/images/textItalic">images/text_italic1.png</file> <file alias="/images/textItalic">images/text_italic1.png</file>
<file alias="/images/textUnderline">images/text_underline1.png</file> <file alias="/images/textUnderline">images/text_underline1.png</file>
<file alias="/images/editMode">images/edit_control_3_24.png</file> <file>images/edit_control_3_24.png</file>
<file alias="/images/editlayout">images/edit_layout_4_24.png</file> <file alias="/images/editlayout">images/edit_layout_4_24.png</file>
<file alias="/images/hlayout">images/hlayuot_3_24.png</file> <file>images/hlayuot_3_24.png</file>
<file alias="/images/addBand">images/addBand1.png</file> <file>images/addBand1.png</file>
<file alias="/images/delete">images/delete1.png</file> <file>images/delete1.png</file>
<file alias="/images/copy">images/copy2.png</file> <file alias="/images/copy">images/copy2.png</file>
<file alias="/images/newReport">images/new_leaf1.png</file> <file alias="/images/newReport">images/new_leaf1.png</file>
<file alias="/images/paste">images/paste1.png</file> <file alias="/images/paste">images/paste1.png</file>
@ -170,5 +170,9 @@
<file alias="/images/toolbar">images/toolbar.png</file> <file alias="/images/toolbar">images/toolbar.png</file>
<file>images/not_checked.png</file> <file>images/not_checked.png</file>
<file>images/checked.png</file> <file>images/checked.png</file>
<file alias="/images/hlayout">images/hlayuot_4_24.png</file>
<file alias="/images/delete">images/delete2.png</file>
<file alias="/images/addBand">images/addBand2.png</file>
<file alias="/images/editMode">images/edit_control_4_24.png</file>
</qresource> </qresource>
</RCC> </RCC>