mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-24 12:34:39 +03:00
All settings are merged in one place
This commit is contained in:
parent
91a1798bf0
commit
b81de4680c
@ -95,6 +95,7 @@ namespace Const{
|
||||
const int SCENE_MARGIN = 50;
|
||||
const QString FUNCTION_MANAGER_NAME = "LimeReport";
|
||||
const QString EOW("~!@#$%^&*()+{}|:\"<>?,/;'[]\\-=");
|
||||
const int DEFAULT_TAB_INDENTION = 4;
|
||||
|
||||
}
|
||||
QString extractClassName(QString className);
|
||||
|
@ -118,8 +118,6 @@ void TextItemEditor::initUI()
|
||||
{
|
||||
QStringList dataWords;
|
||||
|
||||
ui->toolButton->setChecked(false);
|
||||
ui->gbSettings->setVisible(false);
|
||||
LimeReport::DataSourceManager* dm = m_page->datasourceManager();
|
||||
LimeReport::ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance();
|
||||
se.setDataManager(dm);
|
||||
@ -152,13 +150,19 @@ void TextItemEditor::readSetting()
|
||||
if (v.isValid()){
|
||||
ui->codeEditor->restoreState(v.toByteArray());
|
||||
}
|
||||
|
||||
QVariant fontName = settings()->value("FontName");
|
||||
settings()->endGroup();
|
||||
settings()->beginGroup("ScriptEditor");
|
||||
QVariant fontName = settings()->value("DefaultFontName");
|
||||
if (fontName.isValid()){
|
||||
QVariant fontSize = settings()->value("FontSize");
|
||||
QVariant fontSize = settings()->value("DefaultFontSize");
|
||||
ui->codeEditor->setEditorFont(QFont(fontName.toString(),fontSize.toInt()));
|
||||
ui->editorFont->setCurrentFont(ui->codeEditor->editorFont());
|
||||
ui->editorFontSize->setValue(fontSize.toInt());
|
||||
}
|
||||
|
||||
QVariant tabIndention = settings()->value("TabIndention");
|
||||
if (tabIndention.isValid()){
|
||||
ui->codeEditor->setTabIndention(tabIndention.toInt());
|
||||
} else {
|
||||
ui->codeEditor->setTabIndention(LimeReport::Const::DEFAULT_TAB_INDENTION);
|
||||
}
|
||||
settings()->endGroup();
|
||||
|
||||
@ -175,33 +179,6 @@ void TextItemEditor::writeSetting()
|
||||
}
|
||||
}
|
||||
|
||||
void TextItemEditor::on_editorFont_currentFontChanged(const QFont &f)
|
||||
{
|
||||
if (m_isReadingSetting) return;
|
||||
QFont tmp = f;
|
||||
tmp.setPointSize(ui->editorFontSize->value());
|
||||
ui->codeEditor->setEditorFont(tmp);
|
||||
settings()->beginGroup("TextItemEditor");
|
||||
settings()->setValue("FontName",ui->codeEditor->editorFont().family());
|
||||
settings()->setValue("FontSize",ui->editorFontSize->value());
|
||||
settings()->endGroup();
|
||||
}
|
||||
|
||||
void TextItemEditor::on_editorFontSize_valueChanged(int arg1)
|
||||
{
|
||||
if (m_isReadingSetting) return;
|
||||
ui->codeEditor->setEditorFont(QFont(ui->codeEditor->editorFont().family(),arg1));
|
||||
settings()->beginGroup("TextItemEditor");
|
||||
settings()->setValue("FontName",ui->codeEditor->editorFont().family());
|
||||
settings()->setValue("FontSize",ui->editorFontSize->value());
|
||||
settings()->endGroup();
|
||||
}
|
||||
|
||||
void TextItemEditor::on_toolButton_clicked(bool checked)
|
||||
{
|
||||
ui->gbSettings->setVisible(checked);
|
||||
}
|
||||
|
||||
void TextItemEditor::slotSplitterMoved(int, int)
|
||||
{
|
||||
writeSetting();
|
||||
|
@ -78,9 +78,6 @@ protected:
|
||||
private slots:
|
||||
void on_pbOk_clicked();
|
||||
void on_pbCancel_clicked();
|
||||
void on_editorFont_currentFontChanged(const QFont &f);
|
||||
void on_editorFontSize_valueChanged(int arg1);
|
||||
void on_toolButton_clicked(bool checked);
|
||||
void slotSplitterMoved(int, int);
|
||||
private:
|
||||
void initUI();
|
||||
|
@ -17,7 +17,7 @@
|
||||
<string>Text Item Editor</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
<iconset resource="items.qrc">
|
||||
<normaloff>:/items/images/insert-text_3.png</normaloff>:/items/images/insert-text_3.png</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
@ -58,68 +58,8 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbSettings">
|
||||
<property name="title">
|
||||
<string>Editor settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Editor font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFontComboBox" name="editorFont"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="editorFontSize">
|
||||
<property name="value">
|
||||
<number>11</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/items/images/settings.png</normaloff>:/items/images/settings.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
@ -169,6 +109,9 @@
|
||||
<tabstop>pbOk</tabstop>
|
||||
<tabstop>pbCancel</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="items.qrc"/>
|
||||
<include location="items.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -95,6 +95,7 @@ namespace Const{
|
||||
const int SCENE_MARGIN = 50;
|
||||
const QString FUNCTION_MANAGER_NAME = "LimeReport";
|
||||
const QString EOW("~!@#$%^&*()+{}|:\"<>?,/;'[]\\-=");
|
||||
const int DEFAULT_TAB_INDENTION = 4;
|
||||
|
||||
}
|
||||
QString extractClassName(QString className);
|
||||
|
@ -51,12 +51,13 @@ namespace LimeReport {
|
||||
|
||||
// ReportDesignIntf
|
||||
|
||||
ReportDesignWidget::ReportDesignWidget(ReportEnginePrivateInterface* report, QMainWindow *mainWindow, QWidget *parent) :
|
||||
ReportDesignWidget::ReportDesignWidget(ReportEnginePrivateInterface* report, QSettings* settings, QMainWindow *mainWindow, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
||||
m_dialogDesignerManager(new DialogDesignerManager(this)),
|
||||
#endif
|
||||
m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false), m_dialogChanged(false), m_useDarkTheme(false)
|
||||
m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false),
|
||||
m_dialogChanged(false), m_useDarkTheme(false), m_settings(settings)
|
||||
{
|
||||
#ifdef HAVE_QT4
|
||||
m_tabWidget = new LimeReportTabWidget(this);
|
||||
@ -205,41 +206,55 @@ void ReportDesignWidget::applySettings()
|
||||
parentWidget()->setStyleSheet("");
|
||||
m_report->setStyleSheet("");
|
||||
}
|
||||
|
||||
if (m_settings){
|
||||
m_settings->beginGroup("ScriptEditor");
|
||||
QVariant v = m_settings->value("DefaultFontName");
|
||||
if (v.isValid()){
|
||||
QVariant fontSize = m_settings->value("DefaultFontSize");
|
||||
m_scriptEditor->setEditorFont(QFont(v.toString(),fontSize.toInt()));
|
||||
}
|
||||
v = m_settings->value("TabIndention");
|
||||
if (v.isValid()){
|
||||
m_scriptEditor->setTabIndention(v.toInt());
|
||||
}
|
||||
m_settings->endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
void ReportDesignWidget::loadState(QSettings* settings)
|
||||
void ReportDesignWidget::loadState()
|
||||
{
|
||||
settings->beginGroup("DesignerWidget");
|
||||
QVariant v = settings->value("hGridStep");
|
||||
m_settings->beginGroup("DesignerWidget");
|
||||
QVariant v = m_settings->value("hGridStep");
|
||||
if (v.isValid()){
|
||||
m_horizontalGridStep = v.toInt();
|
||||
}
|
||||
|
||||
v = settings->value("vGridStep");
|
||||
v = m_settings->value("vGridStep");
|
||||
if (v.isValid()){
|
||||
m_verticalGridStep = v.toInt();
|
||||
}
|
||||
v = settings->value("defaultFont");
|
||||
v = m_settings->value("defaultFont");
|
||||
if (v.isValid()){
|
||||
m_defaultFont = v.value<QFont>();
|
||||
}
|
||||
|
||||
v = settings->value("useGrid");
|
||||
v = m_settings->value("useGrid");
|
||||
if (v.isValid()){
|
||||
m_useGrid = v.toBool();
|
||||
}
|
||||
|
||||
v = settings->value("useDarkTheme");
|
||||
v = m_settings->value("useDarkTheme");
|
||||
if (v.isValid()){
|
||||
m_useDarkTheme = v.toBool();
|
||||
}
|
||||
|
||||
v = settings->value("ScriptEditorState");
|
||||
v = m_settings->value("ScriptEditorState");
|
||||
if (v.isValid()){
|
||||
m_scriptEditor->restoreState(v.toByteArray());
|
||||
}
|
||||
|
||||
settings->endGroup();
|
||||
m_settings->endGroup();
|
||||
applySettings();
|
||||
}
|
||||
|
||||
@ -720,6 +735,7 @@ void ReportDesignWidget::deleteCurrentPage()
|
||||
void ReportDesignWidget::editSetting()
|
||||
{
|
||||
SettingDialog setting(this);
|
||||
setting.setSettings(m_settings);
|
||||
setting.setVerticalGridStep(m_verticalGridStep);
|
||||
setting.setHorizontalGridStep(m_horizontalGridStep);
|
||||
setting.setDefaultFont(m_defaultFont);
|
||||
|
@ -84,7 +84,8 @@ public:
|
||||
Translations,
|
||||
TabTypeCount
|
||||
};
|
||||
ReportDesignWidget(ReportEnginePrivateInterface* report, QMainWindow *mainWindow, QWidget *parent = 0);
|
||||
ReportDesignWidget(ReportEnginePrivateInterface* report, QSettings* settings,
|
||||
QMainWindow *mainWindow, QWidget *parent = 0);
|
||||
~ReportDesignWidget();
|
||||
void createStartPage();
|
||||
void clear();
|
||||
@ -112,7 +113,7 @@ public:
|
||||
bool emitSaveReportAs();
|
||||
bool emitLoadReport();
|
||||
void saveState(QSettings *settings);
|
||||
void loadState(QSettings *settings);
|
||||
void loadState();
|
||||
void applySettings();
|
||||
void applyUseGrid();
|
||||
bool useGrid(){ return m_useGrid;}
|
||||
@ -227,6 +228,7 @@ private:
|
||||
bool m_useMagnet;
|
||||
bool m_dialogChanged;
|
||||
bool m_useDarkTheme;
|
||||
QSettings* m_settings;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -472,7 +472,7 @@ void ReportDesignWindow::createMainMenu()
|
||||
|
||||
void ReportDesignWindow::initReportEditor(ReportEnginePrivateInterface* report)
|
||||
{
|
||||
m_reportDesignWidget=new ReportDesignWidget(report,this,this);
|
||||
m_reportDesignWidget=new ReportDesignWidget(report, m_settings, this,this);
|
||||
setCentralWidget(m_reportDesignWidget);
|
||||
connect(m_reportDesignWidget,SIGNAL(itemSelected(LimeReport::BaseDesignIntf*)),
|
||||
this,SLOT(slotItemSelected(LimeReport::BaseDesignIntf*)));
|
||||
@ -822,7 +822,7 @@ void ReportDesignWindow::restoreSetting()
|
||||
}
|
||||
settings()->endGroup();
|
||||
|
||||
m_reportDesignWidget->loadState(settings());
|
||||
m_reportDesignWidget->loadState();
|
||||
m_useGridAction->setChecked(m_reportDesignWidget->useGrid());
|
||||
createRecentFilesMenu();
|
||||
}
|
||||
|
@ -252,7 +252,6 @@ void ReportEnginePrivate::clearReport()
|
||||
m_fileName="";
|
||||
m_scriptEngineContext->clear();
|
||||
m_reportSettings.setDefaultValues();
|
||||
|
||||
emit cleared();
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
#include "lrsettingdialog.h"
|
||||
#include "ui_lrsettingdialog.h"
|
||||
#include "lrglobal.h"
|
||||
#include <QFile>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
SettingDialog::SettingDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
QDialog(parent), m_settings(0),
|
||||
ui(new Ui::SettingDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -13,6 +14,7 @@ SettingDialog::SettingDialog(QWidget *parent) :
|
||||
if (!theme.exists()){
|
||||
ui->cbbUseDarkTheme->setVisible(false);
|
||||
}
|
||||
ui->indentSize->setRange(0,10);
|
||||
}
|
||||
|
||||
SettingDialog::~SettingDialog()
|
||||
@ -37,6 +39,18 @@ QFont SettingDialog::defaultFont()
|
||||
return result;
|
||||
}
|
||||
|
||||
QFont SettingDialog::scriptFont()
|
||||
{
|
||||
QFont result = ui->scriptFont->currentFont();
|
||||
result.setPointSize(ui->scriptFontSize->value());
|
||||
return result;
|
||||
}
|
||||
|
||||
int SettingDialog::tabIndention()
|
||||
{
|
||||
return ui->indentSize->value();
|
||||
}
|
||||
|
||||
bool SettingDialog::userDarkTheme()
|
||||
{
|
||||
return ui->cbbUseDarkTheme->isChecked();
|
||||
@ -76,6 +90,17 @@ void SettingDialog::setDefaultFont(const QFont &value)
|
||||
ui->defaultFontSize->setValue(value.pointSize());
|
||||
}
|
||||
|
||||
void SettingDialog::setScriptFont(const QFont& value)
|
||||
{
|
||||
ui->scriptFont->setCurrentFont(value);
|
||||
ui->scriptFontSize->setValue(value.pointSize());
|
||||
}
|
||||
|
||||
void SettingDialog::setScritpTabIndention(int size)
|
||||
{
|
||||
ui->indentSize->setValue(size);
|
||||
}
|
||||
|
||||
void SettingDialog::setUseDarkTheme(bool value)
|
||||
{
|
||||
ui->cbbUseDarkTheme->setChecked(value);
|
||||
@ -103,4 +128,37 @@ void SettingDialog::setDesignerLanguages(QList<QLocale::Language> languages, QLo
|
||||
#endif
|
||||
}
|
||||
|
||||
void SettingDialog::setSettings(QSettings* settings){
|
||||
m_settings = settings;
|
||||
if (m_settings){
|
||||
m_settings->beginGroup("ScriptEditor");
|
||||
QVariant fontName = m_settings->value("DefaultFontName");
|
||||
if (fontName.isValid()){
|
||||
QVariant fontSize = m_settings->value("DefaultFontSize");
|
||||
ui->scriptFont->setCurrentFont(QFont(fontName.toString(),fontSize.toInt()));
|
||||
ui->scriptFontSize->setValue(fontSize.toInt());
|
||||
}
|
||||
QVariant indentSize = m_settings->value("TabIndention");
|
||||
if (indentSize.isValid()){
|
||||
ui->indentSize->setValue(indentSize.toInt());
|
||||
} else {
|
||||
ui->indentSize->setValue(LimeReport::Const::DEFAULT_TAB_INDENTION);
|
||||
}
|
||||
m_settings->endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
void SettingDialog::on_bbOkCancel_accepted()
|
||||
{
|
||||
if (m_settings){
|
||||
m_settings->beginGroup("ScriptEditor");
|
||||
m_settings->setValue("DefaultFontName", ui->scriptFont->currentFont().family());
|
||||
m_settings->setValue("DefaultFontSize", ui->scriptFontSize->value());
|
||||
m_settings->setValue("TabIndention", ui->indentSize->value());
|
||||
m_settings->endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLocale>
|
||||
#include <QSettings>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
@ -20,6 +21,8 @@ public:
|
||||
int verticalGridStep();
|
||||
int horizontalGridStep();
|
||||
QFont defaultFont();
|
||||
QFont scriptFont();
|
||||
int tabIndention();
|
||||
bool userDarkTheme();
|
||||
bool suppressAbsentFieldsAndVarsWarnings();
|
||||
QLocale::Language designerLanguage();
|
||||
@ -27,12 +30,19 @@ public:
|
||||
void setHorizontalGridStep(int value);
|
||||
void setVerticalGridStep(int value);
|
||||
void setDefaultFont(const QFont& value);
|
||||
void setScriptFont(const QFont& value);
|
||||
void setScritpTabIndention(int size);
|
||||
void setUseDarkTheme(bool value);
|
||||
void setDesignerLanguages(QList<QLocale::Language> languages, QLocale::Language currentLanguage);
|
||||
void setSettings(QSettings* settings);
|
||||
private slots:
|
||||
void on_bbOkCancel_accepted();
|
||||
|
||||
private:
|
||||
Ui::SettingDialog *ui;
|
||||
QList<QLocale::Language> m_aviableLanguages;
|
||||
QLocale::Language m_currentLanguage;
|
||||
QSettings* m_settings;
|
||||
};
|
||||
} // namespace LimeReport
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>397</width>
|
||||
<height>345</height>
|
||||
<width>419</width>
|
||||
<height>362</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -19,20 +19,29 @@
|
||||
<property name="windowTitle">
|
||||
<string>Designer setting</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Designer Setting</string>
|
||||
<widget class="QToolBox" name="toolBox">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>401</width>
|
||||
<height>218</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Designer settings</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Default font</string>
|
||||
</property>
|
||||
@ -49,7 +58,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@ -68,11 +77,11 @@
|
||||
<property name="title">
|
||||
<string>Grid</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Vertical grid step</string>
|
||||
</property>
|
||||
@ -86,7 +95,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Horizontal grid step</string>
|
||||
</property>
|
||||
@ -102,7 +111,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@ -118,7 +127,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="hlLanguage">
|
||||
<layout class="QHBoxLayout" name="hlLanguage_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblLanguage">
|
||||
<property name="text">
|
||||
@ -147,23 +156,80 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Report Setting</string>
|
||||
<widget class="QWidget" name="page_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>401</width>
|
||||
<height>218</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<attribute name="label">
|
||||
<string>Script editor settings</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbSuppressWarnings">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Suppress absent fields and variables warning</string>
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFontComboBox" name="scriptFont"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="scriptFontSize">
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Indent size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="indentSize"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
@ -172,11 +238,41 @@
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>4</height>
|
||||
<height>123</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>401</width>
|
||||
<height>218</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Report settings</string>
|
||||
</attribute>
|
||||
<widget class="QCheckBox" name="cbSuppressWarnings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>280</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Suppress absent fields and variables warning</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
|
@ -26,7 +26,6 @@ void ContentEditor::editButtonClicked()
|
||||
dialog->setLayout(new QVBoxLayout());
|
||||
dialog->layout()->setContentsMargins(1,1,1,1);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
//dialog->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, dialog->size(), QApplication::desktop()->availableGeometry()));
|
||||
dialog->setWindowTitle(propertyName());
|
||||
QWidget* editor = dynamic_cast<BaseDesignIntf*>(m_object)->defaultEditor();
|
||||
dialog->layout()->addWidget(editor);
|
||||
|
@ -14,12 +14,13 @@ namespace LimeReport{
|
||||
|
||||
ScriptEditor::ScriptEditor(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ScriptEditor), m_reportEngine(0), m_page(0)
|
||||
ui(new Ui::ScriptEditor), m_reportEngine(0), m_page(0), m_tabIndention(4)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setFocusProxy(ui->textEdit);
|
||||
m_completer = new ReportStructureCompleater(this);
|
||||
ui->textEdit->setCompleter(m_completer);
|
||||
ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().width("0")*m_tabIndention);
|
||||
connect(ui->splitter, SIGNAL(splitterMoved(int,int)), this, SIGNAL(splitterMoved(int,int)));
|
||||
}
|
||||
|
||||
@ -79,58 +80,16 @@ void ScriptEditor::setPageBand(BandDesignIntf* band)
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEditor::setTabIndention(int charCount)
|
||||
{
|
||||
if (m_tabIndention != charCount){
|
||||
ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().width("W")*charCount);
|
||||
m_tabIndention = charCount;
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEditor::initCompleter()
|
||||
{
|
||||
// QStringList dataWords;
|
||||
|
||||
// DataSourceManager* dm = 0;
|
||||
// if (m_reportEngine)
|
||||
// dm = m_reportEngine->dataManager();
|
||||
// if (m_page)
|
||||
// dm = m_page->datasourceManager();
|
||||
|
||||
//#ifdef USE_QJSENGINE
|
||||
// ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance();
|
||||
// QJSValue globalObject = se.scriptEngine()->globalObject();
|
||||
// QJSValueIterator it(globalObject);
|
||||
// while (it.hasNext()){
|
||||
// it.next();
|
||||
// if (it.value().isCallable() ){
|
||||
// dataWords << it.name();
|
||||
// }
|
||||
// }
|
||||
//#endif
|
||||
// foreach(const QString &dsName,dm->dataSourceNames()){
|
||||
// dataWords << dsName;
|
||||
// foreach(const QString &field, dm->fieldNames(dsName)){
|
||||
// dataWords<<dsName+"."+field;
|
||||
// }
|
||||
// }
|
||||
|
||||
// foreach (QString varName, dm->variableNames()) {
|
||||
// dataWords << varName.remove("#");
|
||||
// }
|
||||
|
||||
// if (m_reportEngine){
|
||||
// for ( int i = 0; i < m_reportEngine->pageCount(); ++i){
|
||||
// PageDesignIntf* page = m_reportEngine->pageAt(i);
|
||||
// dataWords << page->pageItem()->objectName();
|
||||
// QMetaObject const * mo = page->pageItem()->metaObject();
|
||||
// for(int i = mo->methodOffset(); i < mo->methodCount(); ++i)
|
||||
// {
|
||||
// if (mo->method(i).methodType() == QMetaMethod::Signal) {
|
||||
// dataWords << page->pageItem()->objectName() +"."+QString::fromLatin1(mo->method(i).name());
|
||||
// }
|
||||
// }
|
||||
// dataWords << page->pageItem()->objectName()+".beforeRender";
|
||||
// dataWords << page->pageItem()->objectName()+".afterRender";
|
||||
// foreach (BaseDesignIntf* item, page->pageItem()->childBaseItems()){
|
||||
// addItemToCompleater(page->pageItem()->objectName(), item, dataWords);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// dataWords.sort();
|
||||
if (m_reportEngine)
|
||||
m_completer->updateCompleaterModel(m_reportEngine);
|
||||
else
|
||||
@ -167,26 +126,26 @@ QString ScriptEditor::toPlainText()
|
||||
return ui->textEdit->toPlainText();
|
||||
}
|
||||
|
||||
void ScriptEditor::addItemToCompleater(const QString& pageName, BaseDesignIntf* item, QStringList& dataWords)
|
||||
{
|
||||
BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(item);
|
||||
if (band){
|
||||
dataWords << band->objectName();
|
||||
dataWords << pageName+"_"+band->objectName();
|
||||
dataWords << pageName+"_"+band->objectName()+".beforeRender";
|
||||
dataWords << pageName+"_"+item->objectName()+".afterData";
|
||||
dataWords << pageName+"_"+band->objectName()+".afterRender";
|
||||
foreach (BaseDesignIntf* child, band->childBaseItems()){
|
||||
addItemToCompleater(pageName, child, dataWords);
|
||||
}
|
||||
} else {
|
||||
dataWords << item->objectName();
|
||||
dataWords << pageName+"_"+item->objectName();
|
||||
dataWords << pageName+"_"+item->objectName()+".beforeRender";
|
||||
dataWords << pageName+"_"+item->objectName()+".afterData";
|
||||
dataWords << pageName+"_"+item->objectName()+".afterRender";
|
||||
}
|
||||
}
|
||||
//void ScriptEditor::addItemToCompleater(const QString& pageName, BaseDesignIntf* item, QStringList& dataWords)
|
||||
//{
|
||||
// BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(item);
|
||||
// if (band){
|
||||
// dataWords << band->objectName();
|
||||
// dataWords << pageName+"_"+band->objectName();
|
||||
// dataWords << pageName+"_"+band->objectName()+".beforeRender";
|
||||
// dataWords << pageName+"_"+item->objectName()+".afterData";
|
||||
// dataWords << pageName+"_"+band->objectName()+".afterRender";
|
||||
// foreach (BaseDesignIntf* child, band->childBaseItems()){
|
||||
// addItemToCompleater(pageName, child, dataWords);
|
||||
// }
|
||||
// } else {
|
||||
// dataWords << item->objectName();
|
||||
// dataWords << pageName+"_"+item->objectName();
|
||||
// dataWords << pageName+"_"+item->objectName()+".beforeRender";
|
||||
// dataWords << pageName+"_"+item->objectName()+".afterData";
|
||||
// dataWords << pageName+"_"+item->objectName()+".afterRender";
|
||||
// }
|
||||
//}
|
||||
|
||||
void ScriptEditor::on_twData_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
void setReportEngine(LimeReport::ReportEnginePrivateInterface* reportEngine);
|
||||
void setReportPage(PageDesignIntf* page);
|
||||
void setPageBand(BandDesignIntf* band);
|
||||
void setTabIndention(int charCount);
|
||||
void initCompleter();
|
||||
QByteArray saveState();
|
||||
void restoreState(QByteArray state);
|
||||
@ -68,13 +69,14 @@ 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:
|
||||
// void addItemToCompleater(const QString& pageName, BaseDesignIntf* item, QStringList& dataWords);
|
||||
private:
|
||||
Ui::ScriptEditor *ui;
|
||||
ReportEnginePrivateInterface* m_reportEngine;
|
||||
PageDesignIntf* m_page;
|
||||
ReportStructureCompleater* m_completer;
|
||||
int m_tabIndention;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
Loading…
Reference in New Issue
Block a user