mirror of
https://github.com/fralx/LimeReport.git
synced 2025-01-11 17:18:10 +03:00
Script editor fixed
This commit is contained in:
parent
0f915a9581
commit
a48d82c742
@ -25,10 +25,8 @@ ScriptEditor::~ScriptEditor()
|
|||||||
delete ui;
|
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();
|
ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance();
|
||||||
se.setDataManager(dm);
|
se.setDataManager(dm);
|
||||||
|
|
||||||
@ -41,23 +39,24 @@ void ScriptEditor::setReportEngine(ReportEnginePrivate* reportEngine)
|
|||||||
ui->twScriptEngine->setModel(se.model());
|
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)
|
void ScriptEditor::setReportPage(PageDesignIntf* page)
|
||||||
{
|
{
|
||||||
m_page = page;
|
m_page = page;
|
||||||
DataSourceManager* dm = page->datasourceManager();
|
DataSourceManager* dm = page->datasourceManager();
|
||||||
ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance();
|
initEditor(dm);
|
||||||
se.setDataManager(dm);
|
|
||||||
|
|
||||||
initCompleter();
|
|
||||||
|
|
||||||
if (dm){
|
|
||||||
if (dm->isNeedUpdateDatasourceModel())
|
|
||||||
dm->updateDatasourceModel();
|
|
||||||
ui->twData->setModel(dm->datasourcesModel());
|
|
||||||
ui->twScriptEngine->setModel(se.model());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEditor::setPageBand(BandDesignIntf* band)
|
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()
|
QByteArray ScriptEditor::saveState()
|
||||||
@ -196,6 +195,14 @@ void ScriptEditor::on_twScriptEngine_doubleClicked(const QModelIndex &index)
|
|||||||
ui->textEdit->setFocus();
|
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
|
} // namespace LimeReport
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ class ReportEnginePrivate;
|
|||||||
class BaseDesignIntf;
|
class BaseDesignIntf;
|
||||||
class PageDesignIntf;
|
class PageDesignIntf;
|
||||||
class BandDesignIntf;
|
class BandDesignIntf;
|
||||||
|
class DataSourceManager;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ScriptEditor;
|
class ScriptEditor;
|
||||||
@ -36,9 +37,13 @@ public:
|
|||||||
QString toPlainText();
|
QString toPlainText();
|
||||||
signals:
|
signals:
|
||||||
void splitterMoved(int, int);
|
void splitterMoved(int, int);
|
||||||
|
protected:
|
||||||
|
void initEditor(DataSourceManager* dm);
|
||||||
|
|
||||||
private slots:
|
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&);
|
||||||
private:
|
private:
|
||||||
void addItemToCompleater(const QString& pageName, BaseDesignIntf* item, QStringList& dataWords);
|
void addItemToCompleater(const QString& pageName, BaseDesignIntf* item, QStringList& dataWords);
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user