Merge branch 'develop' into feature/ds_from_script

This commit is contained in:
Arin Alexander 2019-01-29 23:20:58 +03:00
commit 48c39432ce
25 changed files with 602 additions and 405 deletions

View File

@ -32,13 +32,12 @@ contains(CONFIG, easy_profiler){
!contains(CONFIG, qtscriptengine){ !contains(CONFIG, qtscriptengine){
greaterThan(QT_MAJOR_VERSION, 4){ greaterThan(QT_MAJOR_VERSION, 4){
greaterThan(QT_MINOR_VERSION, 5){
CONFIG *= qjsengine CONFIG *= qjsengine
#greaterThan(QT_MINOR_VERSION, 5){ }
# CONFIG *= qjsengine lessThan(QT_MINOR_VERSION, 6){
#} CONFIG *= qtscriptengine
#lessThan(QT_MINOR_VERSION, 6){ }
# CONFIG *= qtscriptengine
#}
} }
lessThan(QT_MAJOR_VERSION, 5){ lessThan(QT_MAJOR_VERSION, 5){
CONFIG *= qtscriptengine CONFIG *= qtscriptengine

View File

@ -10,17 +10,24 @@ int main(int argc, char *argv[])
DesignerSettingManager manager; DesignerSettingManager manager;
QTranslator limeReportTranslator; QTranslator limeReportTranslator;
QTranslator qtTranslator; QTranslator qtBaseTranslator;
QTranslator qtDesignerTranslator;
QTranslator qtLinguistTranslator;
QString translationPath = QApplication::applicationDirPath(); QString translationPath = QApplication::applicationDirPath();
translationPath.append("/languages"); translationPath.append("/translations");
Qt::LayoutDirection layoutDirection = QLocale::system().textDirection(); Qt::LayoutDirection layoutDirection = QLocale::system().textDirection();
QString designerTranslation = QLocale(manager.getCurrentDefaultLanguage()).name(); QString designerTranslation = QLocale(manager.getCurrentDefaultLanguage()).name();
if (limeReportTranslator.load("limereport_"+designerTranslation, translationPath)){ if (limeReportTranslator.load("limereport_"+designerTranslation, translationPath)){
qtTranslator.load("qt_" + designerTranslation, translationPath); qtBaseTranslator.load("qtbase_" + designerTranslation, translationPath);
a.installTranslator(&qtTranslator); qtDesignerTranslator.load("designer_"+designerTranslation,translationPath);
a.installTranslator(&qtBaseTranslator);
a.installTranslator(&qtDesignerTranslator);
a.installTranslator(&limeReportTranslator); a.installTranslator(&limeReportTranslator);
Qt::LayoutDirection layoutDirection = QLocale(manager.getCurrentDefaultLanguage()).textDirection(); Qt::LayoutDirection layoutDirection = QLocale(manager.getCurrentDefaultLanguage()).textDirection();
a.setLayoutDirection(layoutDirection); a.setLayoutDirection(layoutDirection);
} }

View File

@ -95,6 +95,7 @@ namespace Const{
const int SCENE_MARGIN = 50; const int SCENE_MARGIN = 50;
const QString FUNCTION_MANAGER_NAME = "LimeReport"; const QString FUNCTION_MANAGER_NAME = "LimeReport";
const QString EOW("~!@#$%^&*()+{}|:\"<>?,/;'[]\\-="); const QString EOW("~!@#$%^&*()+{}|:\"<>?,/;'[]\\-=");
const int DEFAULT_TAB_INDENTION = 4;
} }
QString extractClassName(QString className); QString extractClassName(QString className);
@ -157,6 +158,7 @@ namespace Const{
static inline QJSValue getJSValue(QJSEngine &e, T *p) static inline QJSValue getJSValue(QJSEngine &e, T *p)
{ {
QJSValue res = e.newQObject(p); QJSValue res = e.newQObject(p);
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
return res; return res;
} }
#else #else

View File

@ -118,8 +118,6 @@ void TextItemEditor::initUI()
{ {
QStringList dataWords; QStringList dataWords;
ui->toolButton->setChecked(false);
ui->gbSettings->setVisible(false);
LimeReport::DataSourceManager* dm = m_page->datasourceManager(); LimeReport::DataSourceManager* dm = m_page->datasourceManager();
LimeReport::ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance(); LimeReport::ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance();
se.setDataManager(dm); se.setDataManager(dm);
@ -152,13 +150,19 @@ void TextItemEditor::readSetting()
if (v.isValid()){ if (v.isValid()){
ui->codeEditor->restoreState(v.toByteArray()); ui->codeEditor->restoreState(v.toByteArray());
} }
settings()->endGroup();
QVariant fontName = settings()->value("FontName"); settings()->beginGroup("ScriptEditor");
QVariant fontName = settings()->value("DefaultFontName");
if (fontName.isValid()){ if (fontName.isValid()){
QVariant fontSize = settings()->value("FontSize"); QVariant fontSize = settings()->value("DefaultFontSize");
ui->codeEditor->setEditorFont(QFont(fontName.toString(),fontSize.toInt())); 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(); 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) void TextItemEditor::slotSplitterMoved(int, int)
{ {
writeSetting(); writeSetting();

View File

@ -78,9 +78,6 @@ protected:
private slots: private slots:
void on_pbOk_clicked(); void on_pbOk_clicked();
void on_pbCancel_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); void slotSplitterMoved(int, int);
private: private:
void initUI(); void initUI();

View File

@ -17,7 +17,7 @@
<string>Text Item Editor</string> <string>Text Item Editor</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset resource="items.qrc">
<normaloff>:/items/images/insert-text_3.png</normaloff>:/items/images/insert-text_3.png</iconset> <normaloff>:/items/images/insert-text_3.png</normaloff>:/items/images/insert-text_3.png</iconset>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@ -58,68 +58,8 @@
</layout> </layout>
</widget> </widget>
</item> </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> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <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> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
@ -169,6 +109,9 @@
<tabstop>pbOk</tabstop> <tabstop>pbOk</tabstop>
<tabstop>pbCancel</tabstop> <tabstop>pbCancel</tabstop>
</tabstops> </tabstops>
<resources/> <resources>
<include location="items.qrc"/>
<include location="items.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -95,6 +95,7 @@ namespace Const{
const int SCENE_MARGIN = 50; const int SCENE_MARGIN = 50;
const QString FUNCTION_MANAGER_NAME = "LimeReport"; const QString FUNCTION_MANAGER_NAME = "LimeReport";
const QString EOW("~!@#$%^&*()+{}|:\"<>?,/;'[]\\-="); const QString EOW("~!@#$%^&*()+{}|:\"<>?,/;'[]\\-=");
const int DEFAULT_TAB_INDENTION = 4;
} }
QString extractClassName(QString className); QString extractClassName(QString className);
@ -157,6 +158,7 @@ namespace Const{
static inline QJSValue getJSValue(QJSEngine &e, T *p) static inline QJSValue getJSValue(QJSEngine &e, T *p)
{ {
QJSValue res = e.newQObject(p); QJSValue res = e.newQObject(p);
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
return res; return res;
} }
#else #else

View File

@ -210,7 +210,10 @@ namespace LimeReport {
void multiItemsSelected(QList<QObject*>* objectsList); void multiItemsSelected(QList<QObject*>* objectsList);
void miltiItemsSelectionFinished(); void miltiItemsSelectionFinished();
void commandHistoryChanged(); void commandHistoryChanged();
void itemPropertyChanged(const QString& objectName, const QString& propertyName, const QVariant& oldValue, const QVariant& newValue); void itemPropertyChanged(const QString& objectName,
const QString& propertyName,
const QVariant& oldValue,
const QVariant& newValue);
void itemAdded(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item); void itemAdded(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item);
void itemRemoved(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item); void itemRemoved(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item);
void bandAdded(LimeReport::PageDesignIntf* page, LimeReport::BandDesignIntf* band); void bandAdded(LimeReport::PageDesignIntf* page, LimeReport::BandDesignIntf* band);
@ -247,7 +250,9 @@ namespace LimeReport {
void setBorders(const BaseDesignIntf::BorderLines& border); void setBorders(const BaseDesignIntf::BorderLines& border);
private slots: private slots:
void slotPageGeometryChanged(QObject*, QRectF, QRectF ); void slotPageGeometryChanged(QObject*, QRectF, QRectF );
void slotItemPropertyChanged(QString propertyName, const QVariant &oldValue, const QVariant &newValue); void slotItemPropertyChanged(QString propertyName,
const QVariant &oldValue,
const QVariant &newValue);
void slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName); void slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName);
void bandDeleted(QObject* band); void bandDeleted(QObject* band);
void slotPageItemLoaded(QObject *); void slotPageItemLoaded(QObject *);
@ -262,7 +267,10 @@ namespace LimeReport {
void checkSizeOrPosChanges(); void checkSizeOrPosChanges();
CommandIf::Ptr createChangePosCommand(); CommandIf::Ptr createChangePosCommand();
CommandIf::Ptr createChangeSizeCommand(); CommandIf::Ptr createChangeSizeCommand();
void saveChangeProppertyCommand(const QString& objectName, const QString& propertyName, const QVariant& oldPropertyValue, const QVariant& newPropertyValue); void saveChangeProppertyCommand(const QString& objectName,
const QString& propertyName,
const QVariant& oldPropertyValue,
const QVariant& newPropertyValue);
void changeSelectedGroupProperty(const QString& name,const QVariant& value); void changeSelectedGroupProperty(const QString& name,const QVariant& value);
private: private:

View File

@ -203,7 +203,11 @@ void PreviewReportWidget::print()
printer.setPrinterName(pi.defaultPrinter().printerName()); printer.setPrinterName(pi.defaultPrinter().printerName());
#endif #endif
#ifdef HAVE_QT5 #ifdef HAVE_QT5
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
printer.setPrinterName(pi.defaultPrinterName()); printer.setPrinterName(pi.defaultPrinterName());
#else
printer.setPrinterName(pi.defaultPrinter().printerName());
#endif
#endif #endif
QPrintDialog dialog(&printer,QApplication::activeWindow()); QPrintDialog dialog(&printer,QApplication::activeWindow());
if (dialog.exec()==QDialog::Accepted){ if (dialog.exec()==QDialog::Accepted){

View File

@ -51,12 +51,13 @@ namespace LimeReport {
// ReportDesignIntf // ReportDesignIntf
ReportDesignWidget::ReportDesignWidget(ReportEnginePrivateInterface* report, QMainWindow *mainWindow, QWidget *parent) : ReportDesignWidget::ReportDesignWidget(ReportEnginePrivateInterface* report, QSettings* settings, QMainWindow *mainWindow, QWidget *parent) :
QWidget(parent), QWidget(parent),
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
m_dialogDesignerManager(new DialogDesignerManager(this)), m_dialogDesignerManager(new DialogDesignerManager(this)),
#endif #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 #ifdef HAVE_QT4
m_tabWidget = new LimeReportTabWidget(this); m_tabWidget = new LimeReportTabWidget(this);
@ -205,41 +206,55 @@ void ReportDesignWidget::applySettings()
parentWidget()->setStyleSheet(""); parentWidget()->setStyleSheet("");
m_report->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"); m_settings->beginGroup("DesignerWidget");
QVariant v = settings->value("hGridStep"); QVariant v = m_settings->value("hGridStep");
if (v.isValid()){ if (v.isValid()){
m_horizontalGridStep = v.toInt(); m_horizontalGridStep = v.toInt();
} }
v = settings->value("vGridStep"); v = m_settings->value("vGridStep");
if (v.isValid()){ if (v.isValid()){
m_verticalGridStep = v.toInt(); m_verticalGridStep = v.toInt();
} }
v = settings->value("defaultFont"); v = m_settings->value("defaultFont");
if (v.isValid()){ if (v.isValid()){
m_defaultFont = v.value<QFont>(); m_defaultFont = v.value<QFont>();
} }
v = settings->value("useGrid"); v = m_settings->value("useGrid");
if (v.isValid()){ if (v.isValid()){
m_useGrid = v.toBool(); m_useGrid = v.toBool();
} }
v = settings->value("useDarkTheme"); v = m_settings->value("useDarkTheme");
if (v.isValid()){ if (v.isValid()){
m_useDarkTheme = v.toBool(); m_useDarkTheme = v.toBool();
} }
v = settings->value("ScriptEditorState"); v = m_settings->value("ScriptEditorState");
if (v.isValid()){ if (v.isValid()){
m_scriptEditor->restoreState(v.toByteArray()); m_scriptEditor->restoreState(v.toByteArray());
} }
settings->endGroup(); m_settings->endGroup();
applySettings(); applySettings();
} }
@ -720,6 +735,7 @@ void ReportDesignWidget::deleteCurrentPage()
void ReportDesignWidget::editSetting() void ReportDesignWidget::editSetting()
{ {
SettingDialog setting(this); SettingDialog setting(this);
setting.setSettings(m_settings);
setting.setVerticalGridStep(m_verticalGridStep); setting.setVerticalGridStep(m_verticalGridStep);
setting.setHorizontalGridStep(m_horizontalGridStep); setting.setHorizontalGridStep(m_horizontalGridStep);
setting.setDefaultFont(m_defaultFont); setting.setDefaultFont(m_defaultFont);

View File

@ -84,7 +84,8 @@ public:
Translations, Translations,
TabTypeCount TabTypeCount
}; };
ReportDesignWidget(ReportEnginePrivateInterface* report, QMainWindow *mainWindow, QWidget *parent = 0); ReportDesignWidget(ReportEnginePrivateInterface* report, QSettings* settings,
QMainWindow *mainWindow, QWidget *parent = 0);
~ReportDesignWidget(); ~ReportDesignWidget();
void createStartPage(); void createStartPage();
void clear(); void clear();
@ -112,7 +113,7 @@ public:
bool emitSaveReportAs(); bool emitSaveReportAs();
bool emitLoadReport(); bool emitLoadReport();
void saveState(QSettings *settings); void saveState(QSettings *settings);
void loadState(QSettings *settings); void loadState();
void applySettings(); void applySettings();
void applyUseGrid(); void applyUseGrid();
bool useGrid(){ return m_useGrid;} bool useGrid(){ return m_useGrid;}
@ -227,6 +228,7 @@ private:
bool m_useMagnet; bool m_useMagnet;
bool m_dialogChanged; bool m_dialogChanged;
bool m_useDarkTheme; bool m_useDarkTheme;
QSettings* m_settings;
}; };
} // namespace LimeReport } // namespace LimeReport

View File

@ -472,7 +472,7 @@ void ReportDesignWindow::createMainMenu()
void ReportDesignWindow::initReportEditor(ReportEnginePrivateInterface* report) void ReportDesignWindow::initReportEditor(ReportEnginePrivateInterface* report)
{ {
m_reportDesignWidget=new ReportDesignWidget(report,this,this); m_reportDesignWidget=new ReportDesignWidget(report, m_settings, this,this);
setCentralWidget(m_reportDesignWidget); setCentralWidget(m_reportDesignWidget);
connect(m_reportDesignWidget,SIGNAL(itemSelected(LimeReport::BaseDesignIntf*)), connect(m_reportDesignWidget,SIGNAL(itemSelected(LimeReport::BaseDesignIntf*)),
this,SLOT(slotItemSelected(LimeReport::BaseDesignIntf*))); this,SLOT(slotItemSelected(LimeReport::BaseDesignIntf*)));
@ -822,7 +822,7 @@ void ReportDesignWindow::restoreSetting()
} }
settings()->endGroup(); settings()->endGroup();
m_reportDesignWidget->loadState(settings()); m_reportDesignWidget->loadState();
m_useGridAction->setChecked(m_reportDesignWidget->useGrid()); m_useGridAction->setChecked(m_reportDesignWidget->useGrid());
createRecentFilesMenu(); createRecentFilesMenu();
} }

View File

@ -82,7 +82,7 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
m_reportRendering(false), m_resultIsEditable(true), m_passPhrase("HjccbzHjlbyfCkjy"), m_reportRendering(false), m_resultIsEditable(true), m_passPhrase("HjccbzHjlbyfCkjy"),
m_fileWatcher( new QFileSystemWatcher( this ) ), m_reportLanguage(QLocale::AnyLanguage), m_fileWatcher( new QFileSystemWatcher( this ) ), m_reportLanguage(QLocale::AnyLanguage),
m_previewLayoutDirection(Qt::LayoutDirectionAuto), m_designerFactory(0), m_previewLayoutDirection(Qt::LayoutDirectionAuto), m_designerFactory(0),
m_previewScaleType(FitWidth), m_previewScalePercent(0) m_previewScaleType(FitWidth), m_previewScalePercent(0), m_startTOCPage(0)
{ {
#ifdef HAVE_STATIC_BUILD #ifdef HAVE_STATIC_BUILD
initResources(); initResources();
@ -252,7 +252,6 @@ void ReportEnginePrivate::clearReport()
m_fileName=""; m_fileName="";
m_scriptEngineContext->clear(); m_scriptEngineContext->clear();
m_reportSettings.setDefaultValues(); m_reportSettings.setDefaultValues();
emit cleared(); emit cleared();
} }
@ -404,7 +403,11 @@ bool ReportEnginePrivate::printReport(QPrinter* printer)
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName()); m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif #endif
#ifdef HAVE_QT5 #ifdef HAVE_QT5
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
m_printer.data()->setPrinterName(pi.defaultPrinterName()); m_printer.data()->setPrinterName(pi.defaultPrinterName());
#else
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif
#endif #endif
QPrintDialog dialog(m_printer.data(),QApplication::activeWindow()); QPrintDialog dialog(m_printer.data(),QApplication::activeWindow());
m_printerSelected = dialog.exec()!=QDialog::Rejected; m_printerSelected = dialog.exec()!=QDialog::Rejected;
@ -437,7 +440,11 @@ bool ReportEnginePrivate::printPages(ReportPages pages, QPrinter *printer)
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName()); m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif #endif
#ifdef HAVE_QT5 #ifdef HAVE_QT5
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
m_printer.data()->setPrinterName(pi.defaultPrinterName()); m_printer.data()->setPrinterName(pi.defaultPrinterName());
#else
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif
#endif #endif
QPrintDialog dialog(m_printer.data(),QApplication::activeWindow()); QPrintDialog dialog(m_printer.data(),QApplication::activeWindow());
m_printerSelected = dialog.exec()!=QDialog::Rejected; m_printerSelected = dialog.exec()!=QDialog::Rejected;
@ -1140,6 +1147,9 @@ void ReportEnginePrivate::paintByExternalPainter(const QString& objectName, QPai
ReportPages ReportEnginePrivate::renderToPages() ReportPages ReportEnginePrivate::renderToPages()
{ {
int startTOCPage = -1;
int pageAfterTOCIndex = -1;
if (m_reportRendering) return ReportPages(); if (m_reportRendering) return ReportPages();
initReport(); initReport();
m_reportRender = ReportRender::Ptr(new ReportRender); m_reportRender = ReportRender::Ptr(new ReportRender);
@ -1176,10 +1186,15 @@ ReportPages ReportEnginePrivate::renderToPages()
activateLanguage(m_reportLanguage); activateLanguage(m_reportLanguage);
emit renderStarted(); emit renderStarted();
foreach(PageItemDesignIntf* page , m_renderingPages){ for(int i = 0; i < m_renderingPages.count(); ++i){
PageItemDesignIntf* page = m_renderingPages.at(i);
if (!page->isTOC() && page->isPrintable()){ if (!page->isTOC() && page->isPrintable()){
page->setReportSettings(&m_reportSettings); page->setReportSettings(&m_reportSettings);
result.append(m_reportRender->renderPageToPages(page)); result.append(m_reportRender->renderPageToPages(page));
} else {
startTOCPage = result.count();
pageAfterTOCIndex = i+1;
m_reportRender->createTOCMarker(page->resetPageNumber());
} }
} }
@ -1187,16 +1202,17 @@ ReportPages ReportEnginePrivate::renderToPages()
PageItemDesignIntf* page = m_renderingPages.at(i); PageItemDesignIntf* page = m_renderingPages.at(i);
if (page->isTOC()){ if (page->isTOC()){
page->setReportSettings(&m_reportSettings); page->setReportSettings(&m_reportSettings);
if (i==0){ if (i < m_renderingPages.count()){
PageItemDesignIntf* secondPage = 0; PageItemDesignIntf* secondPage = 0;
if (m_pages.count()>1) secondPage = m_renderingPages.at(1); if ( m_renderingPages.count() > (pageAfterTOCIndex))
secondPage = m_renderingPages.at(pageAfterTOCIndex);
ReportPages pages = m_reportRender->renderTOC( ReportPages pages = m_reportRender->renderTOC(
page, page,
true, true,
secondPage && secondPage->resetPageNumber() secondPage && secondPage->resetPageNumber()
); );
for (int j=0; j<pages.count(); ++j){ for (int j=0; j<pages.count(); ++j){
result.insert(j,pages.at(j)); result.insert(startTOCPage+j,pages.at(j));
} }
} else { } else {
@ -1210,9 +1226,9 @@ ReportPages ReportEnginePrivate::renderToPages()
emit renderFinished(); emit renderFinished();
m_reportRender.clear(); m_reportRender.clear();
foreach(PageItemDesignIntf* page, m_renderingPages){ //foreach(PageItemDesignIntf* page, m_renderingPages){
delete page; // delete page;
} //}
m_renderingPages.clear(); m_renderingPages.clear();
} }
m_reportRendering = false; m_reportRendering = false;

View File

@ -283,6 +283,7 @@ private:
QMap<QString, ReportExporterInterface*> exporters; QMap<QString, ReportExporterInterface*> exporters;
ScaleType m_previewScaleType; ScaleType m_previewScaleType;
int m_previewScalePercent; int m_previewScalePercent;
int m_startTOCPage;
}; };
} }

View File

@ -148,7 +148,7 @@ void ReportRender::renameChildItems(BaseDesignIntf *item){
ReportRender::ReportRender(QObject *parent) ReportRender::ReportRender(QObject *parent)
:QObject(parent), m_renderPageItem(0), m_pageCount(0), :QObject(parent), m_renderPageItem(0), m_pageCount(0),
m_lastRenderedHeader(0), m_lastDataBand(0), m_lastRenderedFooter(0), m_currentColumn(0), m_newPageStarted(false), m_renderingFirstTOC(false) m_lastRenderedHeader(0), m_lastDataBand(0), m_lastRenderedFooter(0), m_currentColumn(0), m_newPageStarted(false)
{ {
initColumns(); initColumns();
} }
@ -192,18 +192,13 @@ void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool
{ {
m_currentNameIndex = 0; m_currentNameIndex = 0;
m_patternPageItem = patternPage; m_patternPageItem = patternPage;
m_renderingFirstTOC = isTOC && isFirst;
if (m_patternPageItem->resetPageNumber() && m_pageCount>0 && !isTOC) { if (m_patternPageItem->resetPageNumber() && m_pageCount>0 && !isTOC) {
resetPageNumber(PageReset); resetPageNumber(PageReset);
} }
if (m_renderingFirstTOC && resetPageNumbers){ if (m_patternPageItem->resetPageNumber() && !isTOC && m_pageCount == 0){
PagesRange range; m_pagesRanges.startNewRange();
range.firstPage = 0;
range.lastPage = 0;
m_ranges.insert(0,range);
m_pageCount = 0;
} }
m_renderCanceled = false; m_renderCanceled = false;
@ -248,11 +243,6 @@ void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool
savePage(true); savePage(true);
if (m_renderingFirstTOC && resetPageNumbers && m_ranges.count()>1){
m_ranges[1].firstPage = m_ranges.at(0).lastPage+1;
m_ranges[1].lastPage += m_ranges.at(0).lastPage+1;
}
#ifndef USE_QJSENGINE #ifndef USE_QJSENGINE
ScriptEngineManager::instance().scriptEngine()->popContext(); ScriptEngineManager::instance().scriptEngine()->popContext();
#endif #endif
@ -1138,21 +1128,26 @@ void ReportRender::secondRenderPass(ReportPages renderedPages)
for(int i=0; i<renderedPages.count(); ++i){ for(int i=0; i<renderedPages.count(); ++i){
PageItemDesignIntf::Ptr page = renderedPages.at(i); PageItemDesignIntf::Ptr page = renderedPages.at(i);
foreach(BaseDesignIntf* item, page->childBaseItems()){ foreach(BaseDesignIntf* item, page->childBaseItems()){
updateTOC(item, findPageNumber(i)); updateTOC(item, m_pagesRanges.findPageNumber(i));
} }
} }
} }
for(int i=0; i<renderedPages.count(); ++i){ for(int i=0; i<renderedPages.count(); ++i){
PageItemDesignIntf::Ptr page = renderedPages.at(i); PageItemDesignIntf::Ptr page = renderedPages.at(i);
m_datasources->setReportVariable("#PAGE",findPageNumber(i)); m_datasources->setReportVariable("#PAGE",m_pagesRanges.findPageNumber(i));
m_datasources->setReportVariable("#PAGE_COUNT",findLastPageNumber(i)); m_datasources->setReportVariable("#PAGE_COUNT",m_pagesRanges.findLastPageNumber(i));
foreach(BaseDesignIntf* item, page->childBaseItems()){ foreach(BaseDesignIntf* item, page->childBaseItems()){
item->updateItemSize(m_datasources, SecondPass); item->updateItemSize(m_datasources, SecondPass);
} }
} }
} }
void ReportRender::createTOCMarker(bool startNewRange)
{
m_pagesRanges.addTOCMarker(startNewRange);
}
BandDesignIntf *ReportRender::saveUppperPartReturnBottom(BandDesignIntf *band, int height, BandDesignIntf* patternBand) BandDesignIntf *ReportRender::saveUppperPartReturnBottom(BandDesignIntf *band, int height, BandDesignIntf* patternBand)
{ {
int sliceHeight = height; int sliceHeight = height;
@ -1256,37 +1251,11 @@ void ReportRender::startNewPage(bool isFirst)
void ReportRender::resetPageNumber(ResetPageNuberType resetType) void ReportRender::resetPageNumber(ResetPageNuberType resetType)
{ {
PagesRange range; m_pagesRanges.startNewRange();
if (!m_ranges.isEmpty()){
currentRange().lastPage = (resetType == BandReset)? m_pageCount : m_pageCount-1;
range.firstPage = m_pageCount+((resetType == BandReset)? 1 : 0);
} else {
range.firstPage = m_pageCount;
}
range.lastPage = (resetType == BandReset)? 0 : m_pageCount;
m_ranges.append(range);
if (resetType == PageReset) if (resetType == PageReset)
m_datasources->setReportVariable("#PAGE",1); m_datasources->setReportVariable("#PAGE",1);
} }
int ReportRender::findLastPageNumber(int currentPage)
{
foreach (PagesRange range, m_ranges) {
if ( range.firstPage<= (currentPage) && range.lastPage>= (currentPage) )
return (range.lastPage-(range.firstPage))+1;
}
return 0;
}
int ReportRender::findPageNumber(int currentPage)
{
foreach (PagesRange range, m_ranges) {
if ( range.firstPage<= (currentPage) && range.lastPage>= (currentPage) )
return (currentPage - range.firstPage)+1;
}
return 0;
}
void ReportRender::cutGroups() void ReportRender::cutGroups()
{ {
m_popupedExpression.clear(); m_popupedExpression.clear();
@ -1406,6 +1375,10 @@ void ReportRender::moveTearOffBand(){
void ReportRender::savePage(bool isLast) void ReportRender::savePage(bool isLast)
{ {
if (m_renderPageItem->isTOC())
m_pagesRanges.addTOCPage();
else
m_pagesRanges.addPage();
m_datasources->setReportVariable("#IS_LAST_PAGEFOOTER",isLast); m_datasources->setReportVariable("#IS_LAST_PAGEFOOTER",isLast);
m_datasources->setReportVariable("#IS_FIRST_PAGEFOOTER",m_datasources->variable("#PAGE").toInt()==1); m_datasources->setReportVariable("#IS_FIRST_PAGEFOOTER",m_datasources->variable("#PAGE").toInt()==1);
@ -1427,14 +1400,12 @@ void ReportRender::savePage(bool isLast)
} }
} }
if (currentRange(m_renderingFirstTOC).lastPage==0 && m_ranges.count()>1) { if (m_pagesRanges.currentRange(m_patternPageItem->isTOC()).firstPage == 0) {
m_datasources->setReportVariable("#PAGE",1); m_datasources->setReportVariable("#PAGE",1);
} else { } else {
m_datasources->setReportVariable("#PAGE",m_datasources->variable("#PAGE").toInt()+1); m_datasources->setReportVariable("#PAGE",m_datasources->variable("#PAGE").toInt()+1);
} }
currentRange(m_renderingFirstTOC).lastPage = m_pageCount;
BandDesignIntf* pageFooter = m_renderPageItem->bandByType(BandDesignIntf::PageFooter); BandDesignIntf* pageFooter = m_renderPageItem->bandByType(BandDesignIntf::PageFooter);
if (pageFooter) pageFooter->setBandIndex(++m_currentIndex); if (pageFooter) pageFooter->setBandIndex(++m_currentIndex);
m_renderedPages.append(PageItemDesignIntf::Ptr(m_renderPageItem)); m_renderedPages.append(PageItemDesignIntf::Ptr(m_renderPageItem));
@ -1478,4 +1449,96 @@ void ReportRender::cancelRender(){
m_renderCanceled = true; m_renderCanceled = true;
} }
int PagesRanges::findLastPageNumber(int index)
{
index++;
foreach (PagesRange range, m_ranges) {
if ( range.firstPage <= (index) && range.lastPage>= (index) )
return (range.lastPage-(range.firstPage))+1;
}
return 0;
}
int PagesRanges::findPageNumber(int index)
{
index++;
foreach (PagesRange range, m_ranges) {
if ( range.firstPage <= (index) && range.lastPage >= (index) )
return (index - range.firstPage)+1;
}
return 0;
}
PagesRange&PagesRanges::currentRange(bool isTOC)
{
Q_ASSERT( (isTOC && m_TOCRangeIndex!=-1) || !isTOC);
if (isTOC && m_TOCRangeIndex !=-1) return m_ranges[m_TOCRangeIndex];
return m_ranges.last();
}
void PagesRanges::startNewRange(bool isTOC)
{
PagesRange range;
if (!m_ranges.isEmpty()){
range.firstPage = 0;
range.lastPage = m_ranges.last().lastPage + 1;
} else {
range.firstPage = 0;
range.lastPage = 0;
}
range.isTOC = isTOC;
m_ranges.append(range);
if (isTOC) m_TOCRangeIndex = m_ranges.size()-1;
}
void PagesRanges::addTOCMarker(bool addNewRange)
{
if ( addNewRange || m_ranges.isEmpty()){
startNewRange(true);
} else {
m_TOCRangeIndex = m_ranges.size()-1;
m_ranges.last().isTOC = true;
}
}
void PagesRanges::addPage()
{
if (m_ranges.isEmpty()) startNewRange();
if (m_ranges.last().firstPage == 0){
m_ranges.last().firstPage = m_ranges.last().lastPage == 0 ? 1 : m_ranges.last().lastPage;
m_ranges.last().lastPage = m_ranges.last().lastPage == 0 ? 1 : m_ranges.last().lastPage;
} else {
m_ranges.last().lastPage++;
}
}
void PagesRanges::shiftRangesNextToTOC(){
for(int i = m_TOCRangeIndex+1; i < m_ranges.size(); ++i){
m_ranges[i].firstPage++;
m_ranges[i].lastPage++;
}
}
void PagesRanges::addTOCPage()
{
Q_ASSERT(m_TOCRangeIndex != -1);
if (m_TOCRangeIndex != -1){
PagesRange& tocRange = m_ranges[m_TOCRangeIndex];
if (tocRange.firstPage == 0) {
tocRange.firstPage = tocRange.lastPage == 0 ? 1 : tocRange.lastPage;
tocRange.lastPage = tocRange.lastPage == 0 ? 1 : tocRange.lastPage;
if (tocRange.lastPage == 1 && tocRange.lastPage == 1)
shiftRangesNextToTOC();
} else {
tocRange.lastPage++;
shiftRangesNextToTOC();
}
}
}
void PagesRanges::clear()
{
m_ranges.clear();
}
} // namespace LimeReport } // namespace LimeReport

View File

@ -61,6 +61,25 @@ private:
struct PagesRange{ struct PagesRange{
int firstPage; int firstPage;
int lastPage; int lastPage;
bool isTOC;
};
class PagesRanges{
public:
PagesRanges(): m_TOCRangeIndex(-1) {}
int findLastPageNumber(int index);
int findPageNumber(int index);
PagesRange& currentRange(bool isTOC);
void startNewRange(bool isTOC = false);
void addTOCMarker(bool addNewRange);
void addPage();
void addTOCPage();
void clear();
private:
void shiftRangesNextToTOC();
private:
QVector<PagesRange> m_ranges;
int m_TOCRangeIndex;
}; };
class ReportRender: public QObject class ReportRender: public QObject
@ -84,6 +103,7 @@ public:
ReportPages renderPageToPages(PageItemDesignIntf *patternPage); ReportPages renderPageToPages(PageItemDesignIntf *patternPage);
ReportPages renderTOC(PageItemDesignIntf *patternPage, bool first, bool resetPages); ReportPages renderTOC(PageItemDesignIntf *patternPage, bool first, bool resetPages);
void secondRenderPass(ReportPages renderedPages); void secondRenderPass(ReportPages renderedPages);
void createTOCMarker(bool startNewRange);
signals: signals:
void pageRendered(int renderedPageCount); void pageRendered(int renderedPageCount);
public slots: public slots:
@ -147,8 +167,8 @@ private:
void startNewColumn(); void startNewColumn();
void startNewPage(bool isFirst = false); void startNewPage(bool isFirst = false);
void resetPageNumber(ResetPageNuberType resetType); void resetPageNumber(ResetPageNuberType resetType);
int findLastPageNumber(int currentPage); //int findLastPageNumber(int currentPage);
int findPageNumber(int currentPage); //int findPageNumber(int currentPage);
void savePage(bool isLast = false); void savePage(bool isLast = false);
QString toString(); QString toString();
void initColumns(); void initColumns();
@ -161,7 +181,7 @@ private:
void renameChildItems(BaseDesignIntf *item); void renameChildItems(BaseDesignIntf *item);
void renderGroupFooterByHeader(BandDesignIntf *groupHeader); void renderGroupFooterByHeader(BandDesignIntf *groupHeader);
void updateTOC(BaseDesignIntf* item, int pageNumber); void updateTOC(BaseDesignIntf* item, int pageNumber);
PagesRange& currentRange(bool isTOC = false){ return (isTOC) ? m_ranges.first(): m_ranges.last();} //PagesRange& currentRange(bool isTOC = false){ return (isTOC) ? m_ranges.first(): m_ranges.last();}
void placeBandOnPage(BandDesignIntf *band, int columnIndex); void placeBandOnPage(BandDesignIntf *band, int columnIndex);
private: private:
DataSourceManager* m_datasources; DataSourceManager* m_datasources;
@ -190,11 +210,10 @@ private:
QVector<qreal> m_maxHeightByColumn; QVector<qreal> m_maxHeightByColumn;
QVector<qreal> m_currentStartDataPos; QVector<qreal> m_currentStartDataPos;
int m_currentColumn; int m_currentColumn;
QList<PagesRange> m_ranges; PagesRanges m_pagesRanges;
QVector<BandDesignIntf*> m_columnedBandItems; QVector<BandDesignIntf*> m_columnedBandItems;
unsigned long long m_currentNameIndex; unsigned long long m_currentNameIndex;
bool m_newPageStarted; bool m_newPageStarted;
bool m_renderingFirstTOC;
}; };
} // namespace LimeReport } // namespace LimeReport

View File

@ -1,11 +1,12 @@
#include "lrsettingdialog.h" #include "lrsettingdialog.h"
#include "ui_lrsettingdialog.h" #include "ui_lrsettingdialog.h"
#include "lrglobal.h"
#include <QFile> #include <QFile>
namespace LimeReport{ namespace LimeReport{
SettingDialog::SettingDialog(QWidget *parent) : SettingDialog::SettingDialog(QWidget *parent) :
QDialog(parent), QDialog(parent), m_settings(0),
ui(new Ui::SettingDialog) ui(new Ui::SettingDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -13,6 +14,7 @@ SettingDialog::SettingDialog(QWidget *parent) :
if (!theme.exists()){ if (!theme.exists()){
ui->cbbUseDarkTheme->setVisible(false); ui->cbbUseDarkTheme->setVisible(false);
} }
ui->indentSize->setRange(0,10);
} }
SettingDialog::~SettingDialog() SettingDialog::~SettingDialog()
@ -37,6 +39,18 @@ QFont SettingDialog::defaultFont()
return result; 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() bool SettingDialog::userDarkTheme()
{ {
return ui->cbbUseDarkTheme->isChecked(); return ui->cbbUseDarkTheme->isChecked();
@ -76,6 +90,17 @@ void SettingDialog::setDefaultFont(const QFont &value)
ui->defaultFontSize->setValue(value.pointSize()); 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) void SettingDialog::setUseDarkTheme(bool value)
{ {
ui->cbbUseDarkTheme->setChecked(value); ui->cbbUseDarkTheme->setChecked(value);
@ -103,4 +128,37 @@ void SettingDialog::setDesignerLanguages(QList<QLocale::Language> languages, QLo
#endif #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 } // namespace LimeReport

View File

@ -3,6 +3,7 @@
#include <QDialog> #include <QDialog>
#include <QLocale> #include <QLocale>
#include <QSettings>
namespace LimeReport{ namespace LimeReport{
@ -20,6 +21,8 @@ public:
int verticalGridStep(); int verticalGridStep();
int horizontalGridStep(); int horizontalGridStep();
QFont defaultFont(); QFont defaultFont();
QFont scriptFont();
int tabIndention();
bool userDarkTheme(); bool userDarkTheme();
bool suppressAbsentFieldsAndVarsWarnings(); bool suppressAbsentFieldsAndVarsWarnings();
QLocale::Language designerLanguage(); QLocale::Language designerLanguage();
@ -27,12 +30,19 @@ public:
void setHorizontalGridStep(int value); void setHorizontalGridStep(int value);
void setVerticalGridStep(int value); void setVerticalGridStep(int value);
void setDefaultFont(const QFont& value); void setDefaultFont(const QFont& value);
void setScriptFont(const QFont& value);
void setScritpTabIndention(int size);
void setUseDarkTheme(bool value); void setUseDarkTheme(bool value);
void setDesignerLanguages(QList<QLocale::Language> languages, QLocale::Language currentLanguage); void setDesignerLanguages(QList<QLocale::Language> languages, QLocale::Language currentLanguage);
void setSettings(QSettings* settings);
private slots:
void on_bbOkCancel_accepted();
private: private:
Ui::SettingDialog *ui; Ui::SettingDialog *ui;
QList<QLocale::Language> m_aviableLanguages; QList<QLocale::Language> m_aviableLanguages;
QLocale::Language m_currentLanguage; QLocale::Language m_currentLanguage;
QSettings* m_settings;
}; };
} // namespace LimeReport } // namespace LimeReport

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>397</width> <width>419</width>
<height>345</height> <height>362</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -19,164 +19,260 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Designer setting</string> <string>Designer setting</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item> <item>
<widget class="QGroupBox" name="groupBox_3"> <widget class="QToolBox" name="toolBox">
<property name="title"> <property name="currentIndex">
<string>Designer Setting</string> <number>0</number>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <widget class="QWidget" name="page">
<item> <property name="geometry">
<layout class="QHBoxLayout" name="horizontalLayout"> <rect>
<item> <x>0</x>
<widget class="QLabel" name="label_3"> <y>0</y>
<property name="text"> <width>401</width>
<string>Default font</string> <height>218</height>
</property> </rect>
</widget> </property>
</item> <attribute name="label">
<item> <string>Designer settings</string>
<widget class="QFontComboBox" name="defaultFont"/> </attribute>
</item> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QSpinBox" name="defaultFontSize"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="value">
<number>10</number>
</property>
</widget>
</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>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Grid</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<layout class="QFormLayout" name="formLayout"> <widget class="QLabel" name="label_6">
<item row="0" column="0"> <property name="text">
<widget class="QLabel" name="label"> <string>Default font</string>
<property name="text"> </property>
<string>Vertical grid step</string> </widget>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="verticalGridStep">
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Horizontal grid step</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="horizontalGridStep">
<property name="value">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_3"> <widget class="QFontComboBox" name="defaultFont"/>
</item>
<item>
<widget class="QSpinBox" name="defaultFontSize">
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>73</width> <width>40</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</widget> </item>
</item> <item>
<item> <widget class="QGroupBox" name="groupBox">
<layout class="QHBoxLayout" name="hlLanguage"> <property name="title">
<item> <string>Grid</string>
<widget class="QLabel" name="lblLanguage"> </property>
<property name="text"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<string>Language</string> <item>
</property> <layout class="QFormLayout" name="formLayout_2">
</widget> <item row="0" column="0">
</item> <widget class="QLabel" name="label_4">
<item> <property name="text">
<widget class="QComboBox" name="designerLanguage"> <string>Vertical grid step</string>
<property name="sizePolicy"> </property>
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> </widget>
<horstretch>0</horstretch> </item>
<verstretch>0</verstretch> <item row="0" column="1">
</sizepolicy> <widget class="QSpinBox" name="verticalGridStep">
</property> <property name="value">
</widget> <number>10</number>
</item> </property>
</layout> </widget>
</item> </item>
<item> <item row="1" column="0">
<widget class="QCheckBox" name="cbbUseDarkTheme"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
<string>Use dark theme</string> <string>Horizontal grid step</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="1" column="1">
<widget class="QSpinBox" name="horizontalGridStep">
<property name="value">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>73</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlLanguage_2">
<item>
<widget class="QLabel" name="lblLanguage">
<property name="text">
<string>Language</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="designerLanguage">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="cbbUseDarkTheme">
<property name="text">
<string>Use dark theme</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>401</width>
<height>218</height>
</rect>
</property>
<attribute name="label">
<string>Script editor settings</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<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">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<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> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Report Setting</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="cbSuppressWarnings">
<property name="text">
<string>Suppress absent fields and variables warning</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>4</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>

View File

@ -154,6 +154,7 @@ void QObjectPropertyModel::translatePropertyName()
tr("replaceCRwithBR"); tr("replaceCRwithBR");
tr("hideIfEmpty"); tr("hideIfEmpty");
tr("hideEmptyItems"); tr("hideEmptyItems");
tr("useExternalPainter");
} }
void QObjectPropertyModel::clearObjectsList() void QObjectPropertyModel::clearObjectsList()

View File

@ -26,7 +26,6 @@ void ContentEditor::editButtonClicked()
dialog->setLayout(new QVBoxLayout()); dialog->setLayout(new QVBoxLayout());
dialog->layout()->setContentsMargins(1,1,1,1); dialog->layout()->setContentsMargins(1,1,1,1);
dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setAttribute(Qt::WA_DeleteOnClose);
//dialog->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, dialog->size(), QApplication::desktop()->availableGeometry()));
dialog->setWindowTitle(propertyName()); dialog->setWindowTitle(propertyName());
QWidget* editor = dynamic_cast<BaseDesignIntf*>(m_object)->defaultEditor(); QWidget* editor = dynamic_cast<BaseDesignIntf*>(m_object)->defaultEditor();
dialog->layout()->addWidget(editor); dialog->layout()->addWidget(editor);

View File

@ -14,12 +14,13 @@ namespace LimeReport{
ScriptEditor::ScriptEditor(QWidget *parent) : ScriptEditor::ScriptEditor(QWidget *parent) :
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); ui->setupUi(this);
setFocusProxy(ui->textEdit); setFocusProxy(ui->textEdit);
m_completer = new ReportStructureCompleater(this); m_completer = new ReportStructureCompleater(this);
ui->textEdit->setCompleter(m_completer); 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))); 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() 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) if (m_reportEngine)
m_completer->updateCompleaterModel(m_reportEngine); m_completer->updateCompleaterModel(m_reportEngine);
else else
@ -167,26 +126,26 @@ QString ScriptEditor::toPlainText()
return ui->textEdit->toPlainText(); return ui->textEdit->toPlainText();
} }
void ScriptEditor::addItemToCompleater(const QString& pageName, BaseDesignIntf* item, QStringList& dataWords) //void ScriptEditor::addItemToCompleater(const QString& pageName, BaseDesignIntf* item, QStringList& dataWords)
{ //{
BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(item); // BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(item);
if (band){ // if (band){
dataWords << band->objectName(); // dataWords << band->objectName();
dataWords << pageName+"_"+band->objectName(); // dataWords << pageName+"_"+band->objectName();
dataWords << pageName+"_"+band->objectName()+".beforeRender"; // dataWords << pageName+"_"+band->objectName()+".beforeRender";
dataWords << pageName+"_"+item->objectName()+".afterData"; // dataWords << pageName+"_"+item->objectName()+".afterData";
dataWords << pageName+"_"+band->objectName()+".afterRender"; // dataWords << pageName+"_"+band->objectName()+".afterRender";
foreach (BaseDesignIntf* child, band->childBaseItems()){ // foreach (BaseDesignIntf* child, band->childBaseItems()){
addItemToCompleater(pageName, child, dataWords); // addItemToCompleater(pageName, child, dataWords);
} // }
} else { // } else {
dataWords << item->objectName(); // dataWords << item->objectName();
dataWords << pageName+"_"+item->objectName(); // dataWords << pageName+"_"+item->objectName();
dataWords << pageName+"_"+item->objectName()+".beforeRender"; // dataWords << pageName+"_"+item->objectName()+".beforeRender";
dataWords << pageName+"_"+item->objectName()+".afterData"; // dataWords << pageName+"_"+item->objectName()+".afterData";
dataWords << pageName+"_"+item->objectName()+".afterRender"; // dataWords << pageName+"_"+item->objectName()+".afterRender";
} // }
} //}
void ScriptEditor::on_twData_doubleClicked(const QModelIndex &index) void ScriptEditor::on_twData_doubleClicked(const QModelIndex &index)
{ {

View File

@ -52,6 +52,7 @@ public:
void setReportEngine(LimeReport::ReportEnginePrivateInterface* reportEngine); void setReportEngine(LimeReport::ReportEnginePrivateInterface* reportEngine);
void setReportPage(PageDesignIntf* page); void setReportPage(PageDesignIntf* page);
void setPageBand(BandDesignIntf* band); void setPageBand(BandDesignIntf* band);
void setTabIndention(int charCount);
void initCompleter(); void initCompleter();
QByteArray saveState(); QByteArray saveState();
void restoreState(QByteArray state); void restoreState(QByteArray state);
@ -68,13 +69,14 @@ 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&); 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:
Ui::ScriptEditor *ui; Ui::ScriptEditor *ui;
ReportEnginePrivateInterface* m_reportEngine; ReportEnginePrivateInterface* m_reportEngine;
PageDesignIntf* m_page; PageDesignIntf* m_page;
ReportStructureCompleater* m_completer; ReportStructureCompleater* m_completer;
int m_tabIndention;
}; };
} // namespace LimeReport } // namespace LimeReport

Binary file not shown.

View File

@ -384,6 +384,14 @@ p, li { white-space: pre-wrap; }
<source>Print if empty</source> <source>Print if empty</source>
<translation>Печатать, если пустое</translation> <translation>Печатать, если пустое</translation>
</message> </message>
<message>
<source>Cut</source>
<translation>Вырезать</translation>
</message>
<message>
<source>Copy</source>
<translation>Копировать</translation>
</message>
</context> </context>
<context> <context>
<name>LimeReport::BaseDesignIntf</name> <name>LimeReport::BaseDesignIntf</name>
@ -1086,6 +1094,10 @@ p, li { white-space: pre-wrap; }
</context> </context>
<context> <context>
<name>LimeReport::ImageItem</name> <name>LimeReport::ImageItem</name>
<message>
<source>Ext.</source>
<translation>Внешний</translation>
</message>
<message> <message>
<source>Image</source> <source>Image</source>
<translation>Изображение</translation> <translation>Изображение</translation>
@ -1864,6 +1876,10 @@ p, li { white-space: pre-wrap; }
<source>hideEmptyItems</source> <source>hideEmptyItems</source>
<translation>Скрывать пустые элементы</translation> <translation>Скрывать пустые элементы</translation>
</message> </message>
<message>
<source>useExternalPainter</source>
<translation>Использовать внешний отрисовщик</translation>
</message>
</context> </context>
<context> <context>
<name>LimeReport::RectMMPropItem</name> <name>LimeReport::RectMMPropItem</name>