mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-23 16:22:58 +03:00
Script editor has been finishes
This commit is contained in:
parent
219b4ad678
commit
4764334940
@ -184,6 +184,7 @@ void ReportDesignWidget::saveState(QSettings* settings)
|
||||
settings->setValue("vGridStep",m_verticalGridStep);
|
||||
settings->setValue("defaultFont",m_defaultFont);
|
||||
settings->setValue("useGrid",m_useGrid);
|
||||
settings->setValue("ScriptEditorState", m_scriptEditor->saveState());
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
@ -216,6 +217,12 @@ void ReportDesignWidget::loadState(QSettings* settings)
|
||||
if (v.isValid()){
|
||||
m_useGrid = v.toBool();
|
||||
}
|
||||
|
||||
v = settings->value("ScriptEditorState");
|
||||
if (v.isValid()){
|
||||
m_scriptEditor->restoreState(v.toByteArray());
|
||||
}
|
||||
|
||||
settings->endGroup();
|
||||
applySettings();
|
||||
}
|
||||
@ -242,17 +249,12 @@ void ReportDesignWidget::createTabs(){
|
||||
this, SLOT(slotPagePropertyObjectNameChanged(QString,QString)));
|
||||
}
|
||||
|
||||
m_scriptEditor = new QTextEdit(this);
|
||||
m_scriptEditor = new ScriptEditor(this);
|
||||
m_scriptEditor->setReportEngine(m_report);
|
||||
pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script"));
|
||||
m_tabWidget->setTabWhatsThis(pageIndex,"script");
|
||||
m_tabWidget->setCurrentIndex(0);
|
||||
|
||||
m_newScriptEditor = new ScriptEditor(this);
|
||||
m_newScriptEditor->setReportEngine(m_report);
|
||||
pageIndex = m_tabWidget->addTab(m_newScriptEditor,QIcon(),tr("New Script Editor"));
|
||||
m_tabWidget->setTabWhatsThis(pageIndex,"script");
|
||||
m_tabWidget->setCurrentIndex(0);
|
||||
|
||||
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
||||
QWidget* dialogDesigner;
|
||||
foreach(DialogDescriber::Ptr dialogDesc, m_report->scriptContext()->dialogDescribers()){
|
||||
@ -442,9 +444,11 @@ bool ReportDesignWidget::save()
|
||||
bool ReportDesignWidget::loadFromFile(const QString &fileName)
|
||||
{
|
||||
if (m_report->loadFromFile(fileName,false)){
|
||||
QByteArray editorState = m_scriptEditor->saveState();
|
||||
createTabs();
|
||||
//connectPage(m_report->pageAt(0));
|
||||
m_scriptEditor->setPlainText(m_report->scriptContext()->initScript());
|
||||
m_scriptEditor->restoreState(editorState);
|
||||
emit loaded();
|
||||
m_dialogChanged = false;
|
||||
return true;
|
||||
@ -796,7 +800,8 @@ void ReportDesignWidget::slotCurrentTabChanged(int index)
|
||||
}
|
||||
|
||||
if (activeTabType() == Script){
|
||||
m_newScriptEditor->initCompleter();
|
||||
m_scriptEditor->initCompleter();
|
||||
m_scriptEditor->setFocus();
|
||||
}
|
||||
|
||||
emit activePageChanged();
|
||||
|
@ -191,8 +191,7 @@ private:
|
||||
private:
|
||||
ReportEnginePrivate* m_report;
|
||||
QGraphicsView *m_view;
|
||||
QTextEdit* m_scriptEditor;
|
||||
ScriptEditor* m_newScriptEditor;
|
||||
ScriptEditor* m_scriptEditor;
|
||||
TranslationEditor* m_traslationEditor;
|
||||
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
||||
DialogDesignerManager* m_dialogDesignerManager;
|
||||
|
@ -664,14 +664,21 @@ void ReportDesignWindow::writeState()
|
||||
{
|
||||
settings()->beginGroup("DesignerWindow");
|
||||
switch (m_editorTabType) {
|
||||
case ReportDesignWidget::Page:
|
||||
settings()->setValue("PageEditorsState", saveState());
|
||||
settings()->setValue("DialogEditorsState", m_dialogEditorsState);
|
||||
break;
|
||||
default:
|
||||
settings()->setValue("DialogEditorsState", saveState());
|
||||
settings()->setValue("PageEditorsState", m_pageEditorsState);
|
||||
break;
|
||||
case ReportDesignWidget::Page:
|
||||
settings()->setValue("PageEditorsState", saveState());
|
||||
settings()->setValue("DialogEditorsState", m_dialogEditorsState);
|
||||
settings()->setValue("ScriptEditorsState", m_scriptEditorState);
|
||||
break;
|
||||
case ReportDesignWidget::Script:
|
||||
settings()->setValue("ScriptEditorsState", saveState());
|
||||
settings()->setValue("DialogEditorsState", m_dialogEditorsState);
|
||||
settings()->setValue("PageEditorsState", m_pageEditorsState);
|
||||
break;
|
||||
default:
|
||||
settings()->setValue("DialogEditorsState", saveState());
|
||||
settings()->setValue("PageEditorsState", m_pageEditorsState);
|
||||
settings()->setValue("ScriptEditorsState", m_scriptEditorState);
|
||||
break;
|
||||
}
|
||||
settings()->setValue("InspectorFirsColumnWidth",m_objectInspector->columnWidth(0));
|
||||
settings()->endGroup();
|
||||
@ -775,6 +782,10 @@ void ReportDesignWindow::restoreSetting()
|
||||
if (v.isValid()){
|
||||
m_dialogEditorsState = v.toByteArray();
|
||||
}
|
||||
v = settings()->value("ScriptEditorsState");
|
||||
if (v.isValid()){
|
||||
m_scriptEditorState = v.toByteArray();
|
||||
}
|
||||
v = settings()->value("InspectorFirsColumnWidth");
|
||||
if (v.isValid()){
|
||||
m_objectInspector->setColumnWidth(0,v.toInt());
|
||||
@ -1277,12 +1288,15 @@ void ReportDesignWindow::slotActivePageChanged()
|
||||
updateAvaibleBands();
|
||||
|
||||
switch (m_editorTabType) {
|
||||
case ReportDesignWidget::Dialog:
|
||||
m_dialogEditorsState = saveState();
|
||||
case ReportDesignWidget::Dialog:
|
||||
m_dialogEditorsState = saveState();
|
||||
#ifdef HAVE_UI_LOADER
|
||||
m_scriptBrowser->updateDialogsTree();
|
||||
m_scriptBrowser->updateDialogsTree();
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
case ReportDesignWidget::Script:
|
||||
m_scriptEditorState = saveState();
|
||||
break;
|
||||
default:
|
||||
m_pageEditorsState = saveState();
|
||||
break;
|
||||
@ -1291,20 +1305,30 @@ void ReportDesignWindow::slotActivePageChanged()
|
||||
m_editorTabType = m_reportDesignWidget->activeTabType();
|
||||
|
||||
switch (m_editorTabType) {
|
||||
case ReportDesignWidget::Dialog:
|
||||
if (!m_dialogEditorsState.isEmpty())
|
||||
restoreState(m_dialogEditorsState);
|
||||
else
|
||||
showDefaultEditors();
|
||||
showDefaultToolBars();
|
||||
break;
|
||||
default:
|
||||
if (!m_pageEditors.isEmpty())
|
||||
restoreState(m_pageEditorsState);
|
||||
else
|
||||
showDefaultEditors();
|
||||
showDefaultToolBars();
|
||||
break;
|
||||
case ReportDesignWidget::Dialog:
|
||||
if (!m_dialogEditorsState.isEmpty()){
|
||||
restoreState(m_dialogEditorsState);
|
||||
} else {
|
||||
showDefaultEditors();
|
||||
showDefaultToolBars();
|
||||
}
|
||||
break;
|
||||
case ReportDesignWidget::Script:
|
||||
if (!m_scriptEditorState.isEmpty()){
|
||||
restoreState(m_scriptEditorState);
|
||||
} else {
|
||||
showDefaultEditors();
|
||||
showDefaultToolBars();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!m_pageEditors.isEmpty()){
|
||||
restoreState(m_pageEditorsState);
|
||||
} else {
|
||||
showDefaultEditors();
|
||||
showDefaultToolBars();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -264,6 +264,7 @@ private:
|
||||
ReportDesignWidget::EditorTabType m_editorTabType;
|
||||
QByteArray m_pageEditorsState;
|
||||
QByteArray m_dialogEditorsState;
|
||||
QByteArray m_scriptEditorState;
|
||||
QVector<QToolBar*> m_pageTools;
|
||||
QVector<QToolBar*> m_dialogTools;
|
||||
|
||||
|
@ -14,6 +14,7 @@ ScriptEditor::ScriptEditor(QWidget *parent) :
|
||||
ui(new Ui::ScriptEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setFocusProxy(ui->textEdit);
|
||||
m_completer = new QCompleter(this);
|
||||
ui->textEdit->setCompleter(m_completer);
|
||||
}
|
||||
@ -78,6 +79,26 @@ void ScriptEditor::initCompleter()
|
||||
m_completer->setModel(new QStringListModel(dataWords,m_completer));
|
||||
}
|
||||
|
||||
QByteArray ScriptEditor::saveState()
|
||||
{
|
||||
return ui->splitter->saveState();
|
||||
}
|
||||
|
||||
void ScriptEditor::restoreState(QByteArray state)
|
||||
{
|
||||
ui->splitter->restoreState(state);
|
||||
}
|
||||
|
||||
void ScriptEditor::setPlainText(const QString& text)
|
||||
{
|
||||
ui->textEdit->setPlainText(text);
|
||||
}
|
||||
|
||||
QString ScriptEditor::toPlainText()
|
||||
{
|
||||
return ui->textEdit->toPlainText();
|
||||
}
|
||||
|
||||
void ScriptEditor::addItemToCompleater(const QString& pageName, BaseDesignIntf* item, QStringList& dataWords)
|
||||
{
|
||||
BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(item);
|
||||
@ -99,4 +120,31 @@ void ScriptEditor::addItemToCompleater(const QString& pageName, BaseDesignIntf*
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEditor::on_twData_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid()) return;
|
||||
LimeReport::DataNode* node = static_cast<LimeReport::DataNode*>(index.internalPointer());
|
||||
if (node->type()==LimeReport::DataNode::Field){
|
||||
ui->textEdit->insertPlainText(QString("$D{%1.%2}").arg(node->parent()->name()).arg(node->name()));
|
||||
}
|
||||
if (node->type()==LimeReport::DataNode::Variable){
|
||||
ui->textEdit->insertPlainText(QString("$V{%1}").arg(node->name()));
|
||||
}
|
||||
ui->textEdit->setFocus();
|
||||
}
|
||||
|
||||
void ScriptEditor::on_twScriptEngine_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid()) return;
|
||||
LimeReport::ScriptEngineNode* node = static_cast<LimeReport::ScriptEngineNode*>(index.internalPointer());
|
||||
if (node->type()==LimeReport::ScriptEngineNode::Function){
|
||||
ui->textEdit->insertPlainText(node->name()+"()");
|
||||
}
|
||||
ui->textEdit->setFocus();
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -24,6 +24,15 @@ public:
|
||||
~ScriptEditor();
|
||||
void setReportEngine(ReportEnginePrivate* reportEngine);
|
||||
void initCompleter();
|
||||
QByteArray saveState();
|
||||
void restoreState(QByteArray state);
|
||||
void setPlainText(const QString &text);
|
||||
QString toPlainText();
|
||||
private slots:
|
||||
void on_twData_doubleClicked(const QModelIndex &index);
|
||||
|
||||
void on_twScriptEngine_doubleClicked(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
void addItemToCompleater(const QString& pageName, BaseDesignIntf* item, QStringList& dataWords);
|
||||
private:
|
||||
|
@ -13,116 +13,92 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Content</string>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
<widget class="LimeReport::CodeEditor" name="textEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</widget>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::South</enum>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Data</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="LimeReport::CodeEditor" name="textEdit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::South</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Data</string>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeView" name="twData">
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeView" name="twData">
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Functions</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QTreeView" name="twScriptEngine">
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblDescription">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Functions</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QTreeView" name="twScriptEngine">
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblDescription">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user