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

Script editor fixed

This commit is contained in:
Arin Alex 2017-10-05 01:27:04 +03:00
parent 0f915a9581
commit a48d82c742
2 changed files with 27 additions and 15 deletions

View File

@ -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<LimeReport::ScriptEngineNode*>(to.internalPointer());
if (node->type()==LimeReport::ScriptEngineNode::Function){
ui->lblDescription->setText(node->description());
}
}
} // namespace LimeReport

View File

@ -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: