diff --git a/common.pri b/common.pri index 2cebc25..69a8d20 100644 --- a/common.pri +++ b/common.pri @@ -119,7 +119,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 4 -LIMEREPORT_VERSION_RELEASE = 121 +LIMEREPORT_VERSION_RELEASE = 122 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrdatasourcemanager.cpp b/limereport/lrdatasourcemanager.cpp index ad1cd58..5e1ee67 100644 --- a/limereport/lrdatasourcemanager.cpp +++ b/limereport/lrdatasourcemanager.cpp @@ -224,7 +224,8 @@ void DataSourceModel::updateModel() } DataSourceManager::DataSourceManager(QObject *parent) : - QObject(parent), m_lastError(""), m_designTime(false), m_needUpdate(false), m_dbCredentialsProvider(0) + QObject(parent), m_lastError(""), m_designTime(false), m_needUpdate(false), + m_dbCredentialsProvider(0), m_hasChanges(false) { m_groupFunctionFactory.registerFunctionCreator(QLatin1String("COUNT"),new ConstructorGroupFunctionCreator); m_groupFunctionFactory.registerFunctionCreator(QLatin1String("SUM"),new ConstructorGroupFunctionCreator); @@ -238,11 +239,11 @@ DataSourceManager::DataSourceManager(QObject *parent) : m_datasourcesModel.setDataSourceManager(this); connect(&m_reportVariables, SIGNAL(variableHasBeenAdded(QString)), - this, SLOT(slotVariableHasBeenAdded(QString)) ); + this, SLOT(slotVariableHasBeenAdded(QString))); connect(&m_reportVariables, SIGNAL(variableHasBeenChanged(QString)), this, SLOT(slotVariableHasBeenChanged(QString))); connect(&m_userVariables, SIGNAL(variableHasBeenAdded(QString)), - this, SLOT(slotVariableHasBeenAdded(QString)) ); + this, SLOT(slotVariableHasBeenAdded(QString))); connect(&m_userVariables, SIGNAL(variableHasBeenChanged(QString)), this, SLOT(slotVariableHasBeenChanged(QString))); @@ -508,6 +509,7 @@ void DataSourceManager::addQuery(const QString &name, const QString &sqlText, co QueryDesc *queryDecs = new QueryDesc(name,sqlText,connectionName); putQueryDesc(queryDecs); putHolder(name,new QueryHolder(sqlText, connectionName, this)); + m_hasChanges = true; emit datasourcesChanged(); } @@ -516,6 +518,7 @@ void DataSourceManager::addSubQuery(const QString &name, const QString &sqlText, SubQueryDesc *subQueryDesc = new SubQueryDesc(name.toLower(),sqlText,connectionName,masterDatasource); putSubQueryDesc(subQueryDesc); putHolder(name,new SubQueryHolder(sqlText, connectionName, masterDatasource, this)); + m_hasChanges = true; emit datasourcesChanged(); } @@ -530,6 +533,7 @@ void DataSourceManager::addProxy(const QString &name, QString master, QString de } putProxyDesc(proxyDesc); putHolder(name,new ProxyHolder(proxyDesc, this)); + m_hasChanges = true; emit datasourcesChanged(); } @@ -652,6 +656,7 @@ void DataSourceManager::removeDatasource(const QString &name) delete m_proxies.at(proxyIndex); m_proxies.removeAt(proxyIndex); } + m_hasChanges = true; emit datasourcesChanged(); } @@ -672,6 +677,7 @@ void DataSourceManager::removeConnection(const QString &connectionName) cit++; } } + m_hasChanges = true; emit datasourcesChanged(); } @@ -680,6 +686,7 @@ void DataSourceManager::addConnectionDesc(ConnectionDesc * connection) if (!isConnection(connection->name())) { connect(connection,SIGNAL(nameChanged(QString,QString)),this,SLOT(slotConnectionRenamed(QString,QString))); m_connections.append(connection); + m_hasChanges = true; if (connection->autoconnect()){ try{ connectConnection(connection); @@ -1034,6 +1041,7 @@ QStringList DataSourceManager::fieldNames(const QString &datasourceName) void DataSourceManager::addConnection(const QString &connectionName) { addConnectionDesc(new ConnectionDesc(QSqlDatabase::database(connectionName))); + m_hasChanges = true; emit datasourcesChanged(); } @@ -1213,8 +1221,10 @@ void DataSourceManager::deleteVariable(const QString& name) m_userVariables.deleteVariable(name); if (m_reportVariables.containsVariable(name)&&m_reportVariables.variableType(name)==VarDesc::Report){ m_reportVariables.deleteVariable(name); - if (designTime()) - emit datasourcesChanged(); + if (designTime()){ + m_hasChanges = true; + emit datasourcesChanged(); + } } } @@ -1291,14 +1301,16 @@ void DataSourceManager::invalidateQueriesContainsVariable(const QString& variabl void DataSourceManager::slotVariableHasBeenAdded(const QString& variableName) { - //qDebug()<< "variable has been added"<< variableName; invalidateQueriesContainsVariable(variableName); + if (variableType(variableName) == VarDesc::Report) + m_hasChanges = true; } void DataSourceManager::slotVariableHasBeenChanged(const QString& variableName) { - //qDebug()<< "variable has been changed"<< variableName; invalidateQueriesContainsVariable(variableName); + if (variableType(variableName) == VarDesc::Report) + m_hasChanges = true; } void DataSourceManager::clear(ClearMethod method) diff --git a/limereport/lrdatasourcemanager.h b/limereport/lrdatasourcemanager.h index 74dfe20..046cd3e 100644 --- a/limereport/lrdatasourcemanager.h +++ b/limereport/lrdatasourcemanager.h @@ -214,6 +214,8 @@ public: ReportSettings *reportSettings() const; void setReportSettings(ReportSettings *reportSettings); + bool isHasChanges(){ return m_hasChanges; } + void dropChanges(){ m_hasChanges = false; } signals: void loadCollectionFinished(const QString& collectionName); void cleared(); @@ -269,6 +271,7 @@ private: QHash m_groupFunctionsExpressionsMap; QVector m_groupFunctionsExpressions; IDbCredentialsProvider* m_dbCredentialsProvider; + bool m_hasChanges; }; } diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 9a6d4d5..1bb5558 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -78,7 +78,7 @@ PageDesignIntf::PageDesignIntf(QObject *parent): m_changePosMode(false), m_changePosOrSizeMode(false), m_executingCommand(false), - m_hasHanges(false), + m_hasChanges(false), m_isLoading(false), m_executingGroupCommand(false), m_settings(0), @@ -604,7 +604,7 @@ bool PageDesignIntf::saveCommand(CommandIf::Ptr command, bool runCommand) m_commandsList.push_back(command); m_currentCommand = m_commandsList.count() - 1; - m_hasHanges = true; + m_hasChanges = true; emit commandHistoryChanged(); return true; } @@ -621,7 +621,7 @@ bool PageDesignIntf::isCanUndo() bool PageDesignIntf::isHasChanges() { - return (m_commandsList.count() > 0) && m_hasHanges; + return (m_commandsList.count() > 0) && m_hasChanges; } bool PageDesignIntf::isItemInsertMode() @@ -1197,7 +1197,7 @@ void PageDesignIntf::undo() m_executingCommand = true; m_commandsList.at(m_currentCommand)->undoIt(); m_currentCommand--; - m_hasHanges = true; + m_hasChanges = true; m_executingCommand = false; } } @@ -1208,7 +1208,7 @@ void PageDesignIntf::redo() m_executingCommand = true; m_currentCommand++; m_commandsList.at(m_currentCommand)->doIt(); - m_hasHanges = true; + m_hasChanges = true; m_executingCommand = false; } } @@ -1318,7 +1318,7 @@ void PageDesignIntf::cut() void PageDesignIntf::setToSaved() { - m_hasHanges = false; + m_hasChanges = false; } void PageDesignIntf::bringToFront() diff --git a/limereport/lrpagedesignintf.h b/limereport/lrpagedesignintf.h index dbf89f7..901ddbc 100644 --- a/limereport/lrpagedesignintf.h +++ b/limereport/lrpagedesignintf.h @@ -153,7 +153,7 @@ namespace LimeReport { void emitItemRemoved(BaseDesignIntf* item); DataSourceManager* datasourceManager(); - bool isSaved(){ return !m_hasHanges;} + bool isSaved(){ return !m_hasChanges;} void changeSelectedGrpoupTextAlignPropperty(const bool& horizontalAlign, Qt::AlignmentFlag flag); int verticalGridStep() const; @@ -293,7 +293,7 @@ namespace LimeReport { bool m_changePosMode; bool m_changePosOrSizeMode; bool m_executingCommand; - bool m_hasHanges; + bool m_hasChanges; bool m_isLoading; bool m_executingGroupCommand; QSettings* m_settings; diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index 416c6c8..685ac93 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -660,8 +660,8 @@ void ReportDesignWindow::startNewReport() m_newReportHeader->setEnabled(true); m_newReportFooter->setEnabled(true); m_editorTabType = ReportDesignWidget::Page; - //showDefaultEditors(); showDefaultToolBars(); + m_reportDesignWidget->report()->dataManager()->dropChanges(); } void ReportDesignWindow::writePosition() diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index dde790f..249c47f 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -711,6 +711,7 @@ bool ReportEnginePrivate::slotLoadFromFile(const QString &fileName) EASY_BLOCK("Connect auto connections") dataManager()->connectAutoConnections(); EASY_END_BLOCK; + dataManager()->dropChanges(); if ( hasActivePreview() ) { @@ -874,6 +875,7 @@ bool ReportEnginePrivate::saveToFile(const QString &fileName) page->setToSaved(); } } + m_datasources->dropChanges(); return saved; } @@ -888,6 +890,7 @@ QByteArray ReportEnginePrivate::saveToByteArray() page->setToSaved(); } } + m_datasources->dropChanges(); return result; } @@ -901,6 +904,7 @@ QString ReportEnginePrivate::saveToString(){ page->setToSaved(); } } + m_datasources->dropChanges(); return result; } @@ -909,6 +913,9 @@ bool ReportEnginePrivate::isNeedToSave() foreach(PageDesignIntf* page, m_pages){ if (page->isHasChanges()) return true; } + if (dataManager()->isHasChanges()){ + return true; + } return false; }