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

Changes tracking has been fixed

This commit is contained in:
Arin Alexander 2019-02-05 21:51:46 +03:00
parent 2ed1b4b05f
commit 87d0bd5f28
11 changed files with 38 additions and 12 deletions

View File

@ -214,7 +214,7 @@ public:
ReportSettings *reportSettings() const; ReportSettings *reportSettings() const;
void setReportSettings(ReportSettings *reportSettings); void setReportSettings(ReportSettings *reportSettings);
bool isHasChanges(){ return m_hasChanges; } bool hasChanges(){ return m_hasChanges; }
void dropChanges(){ m_hasChanges = false; } void dropChanges(){ m_hasChanges = false; }
signals: signals:
void loadCollectionFinished(const QString& collectionName); void loadCollectionFinished(const QString& collectionName);

View File

@ -284,6 +284,7 @@ void ReportDesignWidget::createTabs(){
} }
m_scriptEditor = new ScriptEditor(this); m_scriptEditor = new ScriptEditor(this);
connect(m_scriptEditor, SIGNAL(textChanged()), this, SLOT(slotScriptTextChanged()));
m_scriptEditor->setReportEngine(m_report); m_scriptEditor->setReportEngine(m_report);
pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script")); pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script"));
m_tabWidget->setTabWhatsThis(pageIndex,"script"); m_tabWidget->setTabWhatsThis(pageIndex,"script");
@ -882,6 +883,11 @@ void ReportDesignWidget::slotReportLoaded()
m_dialogChanged = false; m_dialogChanged = false;
} }
void ReportDesignWidget::slotScriptTextChanged()
{
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
}
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWidget::addNewDialog() void ReportDesignWidget::addNewDialog()

View File

@ -173,6 +173,7 @@ private slots:
void slotSceneRectChanged(QRectF); void slotSceneRectChanged(QRectF);
void slotCurrentTabChanged(int index); void slotCurrentTabChanged(int index);
void slotReportLoaded(); void slotReportLoaded();
void slotScriptTextChanged();
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
void slotDialogChanged(QString); void slotDialogChanged(QString);
void slotDialogNameChanged(QString oldName, QString newName); void slotDialogNameChanged(QString oldName, QString newName);

View File

@ -662,6 +662,8 @@ void ReportDesignWindow::startNewReport()
m_editorTabType = ReportDesignWidget::Page; m_editorTabType = ReportDesignWidget::Page;
showDefaultToolBars(); showDefaultToolBars();
m_reportDesignWidget->report()->dataManager()->dropChanges(); m_reportDesignWidget->report()->dataManager()->dropChanges();
m_reportDesignWidget->report()->scriptContext()->dropChanges();
} }
void ReportDesignWindow::writePosition() void ReportDesignWindow::writePosition()

View File

@ -717,7 +717,7 @@ bool ReportEnginePrivate::slotLoadFromFile(const QString &fileName)
EASY_BLOCK("Connect auto connections") EASY_BLOCK("Connect auto connections")
dataManager()->connectAutoConnections(); dataManager()->connectAutoConnections();
EASY_END_BLOCK; EASY_END_BLOCK;
dataManager()->dropChanges(); dropChanges();
if ( hasActivePreview() ) if ( hasActivePreview() )
{ {
@ -881,7 +881,7 @@ bool ReportEnginePrivate::saveToFile(const QString &fileName)
page->setToSaved(); page->setToSaved();
} }
} }
m_datasources->dropChanges(); dropChanges();
return saved; return saved;
} }
@ -896,7 +896,7 @@ QByteArray ReportEnginePrivate::saveToByteArray()
page->setToSaved(); page->setToSaved();
} }
} }
m_datasources->dropChanges(); dropChanges();
return result; return result;
} }
@ -910,7 +910,7 @@ QString ReportEnginePrivate::saveToString(){
page->setToSaved(); page->setToSaved();
} }
} }
m_datasources->dropChanges(); dropChanges();
return result; return result;
} }
@ -919,9 +919,11 @@ bool ReportEnginePrivate::isNeedToSave()
foreach(PageDesignIntf* page, m_pages){ foreach(PageDesignIntf* page, m_pages){
if (page->isHasChanges()) return true; if (page->isHasChanges()) return true;
} }
if (dataManager()->isHasChanges()){ if (dataManager()->hasChanges()){
return true; return true;
} }
if (scriptContext()->hasChanges())
return true;
return false; return false;
} }

View File

@ -249,6 +249,7 @@ private:
PageItemDesignIntf *createRenderingPage(PageItemDesignIntf *page); PageItemDesignIntf *createRenderingPage(PageItemDesignIntf *page);
void initReport(); void initReport();
void paintByExternalPainter(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem* options); void paintByExternalPainter(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem* options);
void dropChanges(){ m_datasources->dropChanges(); m_scriptEngineContext->dropChanges();}
private: private:
QList<PageDesignIntf*> m_pages; QList<PageDesignIntf*> m_pages;
QList<PageItemDesignIntf*> m_renderingPages; QList<PageItemDesignIntf*> m_renderingPages;

View File

@ -1390,7 +1390,10 @@ QString ScriptEngineContext::initScript() const
void ScriptEngineContext::setInitScript(const QString& initScript) void ScriptEngineContext::setInitScript(const QString& initScript)
{ {
m_initScript = initScript; if (m_initScript != initScript){
m_initScript = initScript;
m_hasChanges = true;
}
} }
DialogDescriber::Ptr DialogDescriber::create(const QString& name, const QByteArray& desc) { DialogDescriber::Ptr DialogDescriber::create(const QString& name, const QByteArray& desc) {
@ -1884,7 +1887,7 @@ void TableBuilder::buildTable(const QString& datasourceName)
fillInRowData(addRow()); fillInRowData(addRow());
m_dataManager->dataSource(datasourceName)->next(); m_dataManager->dataSource(datasourceName)->next();
} }
m_horizontalLayout->setVisible(false); m_horizontalLayout->setHeight(0);
} }
void TableBuilder::checkBaseLayout() void TableBuilder::checkBaseLayout()

View File

@ -174,7 +174,9 @@ public:
#ifdef HAVE_UI_LOADER #ifdef HAVE_UI_LOADER
typedef QSharedPointer<QDialog> DialogPtr; typedef QSharedPointer<QDialog> DialogPtr;
#endif #endif
explicit ScriptEngineContext(QObject* parent=0):QObject(parent), m_tableOfContents(new TableOfContents(this)){} explicit ScriptEngineContext(QObject* parent=0):
QObject(parent),
m_tableOfContents(new TableOfContents(this)), m_hasChanges(false) {}
#ifdef HAVE_UI_LOADER #ifdef HAVE_UI_LOADER
void addDialog(const QString& name, const QByteArray& description); void addDialog(const QString& name, const QByteArray& description);
bool changeDialog(const QString& name, const QByteArray &description); bool changeDialog(const QString& name, const QByteArray &description);
@ -200,7 +202,8 @@ public:
void setCurrentPage(PageItemDesignIntf* currentPage); void setCurrentPage(PageItemDesignIntf* currentPage);
TableOfContents* tableOfContents() const; TableOfContents* tableOfContents() const;
void setTableOfContents(TableOfContents* tableOfContents); void setTableOfContents(TableOfContents* tableOfContents);
void dropChanges(){ m_hasChanges = false;}
bool hasChanges(){ return m_hasChanges;}
#ifdef HAVE_UI_LOADER #ifdef HAVE_UI_LOADER
signals: signals:
void dialogNameChanged(QString dialogName); void dialogNameChanged(QString dialogName);
@ -227,6 +230,7 @@ private:
BandDesignIntf* m_currentBand; BandDesignIntf* m_currentBand;
PageItemDesignIntf* m_currentPage; PageItemDesignIntf* m_currentPage;
TableOfContents* m_tableOfContents; TableOfContents* m_tableOfContents;
bool m_hasChanges;
}; };
class JSFunctionDesc{ class JSFunctionDesc{

View File

@ -282,8 +282,8 @@ void CodeEditor::insertCompletion(const QString &completion)
return; return;
QTextCursor tc = textCursor(); QTextCursor tc = textCursor();
int extra = completion.length() - m_compleater->completionPrefix().length(); int extra = completion.length() - m_compleater->completionPrefix().length();
tc.movePosition(QTextCursor::Left); //tc.movePosition(QTextCursor::Left);
tc.movePosition(QTextCursor::EndOfWord); //tc.movePosition(QTextCursor::EndOfWord);
tc.insertText(completion.right(extra)); tc.insertText(completion.right(extra));
setTextCursor(tc); setTextCursor(tc);
} }

View File

@ -22,6 +22,7 @@ ScriptEditor::ScriptEditor(QWidget *parent) :
ui->textEdit->setCompleter(m_completer); ui->textEdit->setCompleter(m_completer);
ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().width("0")*m_tabIndention); ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().width("0")*m_tabIndention);
connect(ui->splitter, SIGNAL(splitterMoved(int,int)), this, SIGNAL(splitterMoved(int,int))); connect(ui->splitter, SIGNAL(splitterMoved(int,int)), this, SIGNAL(splitterMoved(int,int)));
connect(ui->textEdit, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
} }
ScriptEditor::~ScriptEditor() ScriptEditor::~ScriptEditor()
@ -361,3 +362,5 @@ void ReportStructureCompleater::addChildItem(BaseDesignIntf *item, const QString

View File

@ -60,8 +60,11 @@ public:
void setEditorFont(QFont font); void setEditorFont(QFont font);
QFont editorFont(); QFont editorFont();
QString toPlainText(); QString toPlainText();
bool hasChanges() const;
void setHasChanges(bool hasChanges);
signals: signals:
void splitterMoved(int, int); void splitterMoved(int, int);
void textChanged();
protected: protected:
void initEditor(DataSourceManager* dm); void initEditor(DataSourceManager* dm);
@ -69,6 +72,7 @@ private slots:
void on_twData_doubleClicked(const QModelIndex &index); void on_twData_doubleClicked(const QModelIndex &index);
void on_twScriptEngine_doubleClicked(const QModelIndex &index); void on_twScriptEngine_doubleClicked(const QModelIndex &index);
void slotOnCurrentChanged(const QModelIndex& to, const QModelIndex&); void slotOnCurrentChanged(const QModelIndex& to, const QModelIndex&);
private: private:
Ui::ScriptEditor *ui; Ui::ScriptEditor *ui;
ReportEnginePrivateInterface* m_reportEngine; ReportEnginePrivateInterface* m_reportEngine;