From a48d82c74298b72c62544bf1e4f48d91ce05e311 Mon Sep 17 00:00:00 2001 From: Arin Alex Date: Thu, 5 Oct 2017 01:27:04 +0300 Subject: [PATCH] Script editor fixed --- limereport/scripteditor/lrscripteditor.cpp | 37 +++++++++++++--------- limereport/scripteditor/lrscripteditor.h | 5 +++ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/limereport/scripteditor/lrscripteditor.cpp b/limereport/scripteditor/lrscripteditor.cpp index 263eff3..abb254f 100644 --- a/limereport/scripteditor/lrscripteditor.cpp +++ b/limereport/scripteditor/lrscripteditor.cpp @@ -25,10 +25,8 @@ ScriptEditor::~ScriptEditor() delete ui; } -void ScriptEditor::setReportEngine(ReportEnginePrivate* reportEngine) +void ScriptEditor::initEditor(DataSourceManager* dm) { - m_reportEngine = reportEngine; - DataSourceManager* dm = m_reportEngine->dataManager(); ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance(); se.setDataManager(dm); @@ -41,23 +39,24 @@ void ScriptEditor::setReportEngine(ReportEnginePrivate* reportEngine) ui->twScriptEngine->setModel(se.model()); } + if (ui->twScriptEngine->selectionModel()){ + connect(ui->twScriptEngine->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), + this, SLOT(slotOnCurrentChanged(QModelIndex,QModelIndex))); + } +} + +void ScriptEditor::setReportEngine(ReportEnginePrivate* reportEngine) +{ + m_reportEngine = reportEngine; + DataSourceManager* dm = m_reportEngine->dataManager(); + initEditor(dm); } void ScriptEditor::setReportPage(PageDesignIntf* page) { m_page = page; DataSourceManager* dm = page->datasourceManager(); - ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance(); - se.setDataManager(dm); - - initCompleter(); - - if (dm){ - if (dm->isNeedUpdateDatasourceModel()) - dm->updateDatasourceModel(); - ui->twData->setModel(dm->datasourcesModel()); - ui->twScriptEngine->setModel(se.model()); - } + initEditor(dm); } void ScriptEditor::setPageBand(BandDesignIntf* band) @@ -119,7 +118,7 @@ void ScriptEditor::initCompleter() } } - m_completer->setModel(new QStringListModel(dataWords,m_completer)); + m_completer->setModel(new QStringListModel(dataWords,m_completer)); } QByteArray ScriptEditor::saveState() @@ -196,6 +195,14 @@ void ScriptEditor::on_twScriptEngine_doubleClicked(const QModelIndex &index) ui->textEdit->setFocus(); } +void ScriptEditor::slotOnCurrentChanged(const QModelIndex &to, const QModelIndex &) +{ + LimeReport::ScriptEngineNode* node = static_cast(to.internalPointer()); + if (node->type()==LimeReport::ScriptEngineNode::Function){ + ui->lblDescription->setText(node->description()); + } +} + } // namespace LimeReport diff --git a/limereport/scripteditor/lrscripteditor.h b/limereport/scripteditor/lrscripteditor.h index fc7d7be..b67be79 100644 --- a/limereport/scripteditor/lrscripteditor.h +++ b/limereport/scripteditor/lrscripteditor.h @@ -13,6 +13,7 @@ class ReportEnginePrivate; class BaseDesignIntf; class PageDesignIntf; class BandDesignIntf; +class DataSourceManager; namespace Ui { class ScriptEditor; @@ -36,9 +37,13 @@ public: QString toPlainText(); signals: void splitterMoved(int, int); +protected: + void initEditor(DataSourceManager* dm); + private slots: void on_twData_doubleClicked(const QModelIndex &index); void on_twScriptEngine_doubleClicked(const QModelIndex &index); + void slotOnCurrentChanged(const QModelIndex& to, const QModelIndex&); private: void addItemToCompleater(const QString& pageName, BaseDesignIntf* item, QStringList& dataWords); private: