0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-25 00:54:39 +03:00

Finish 1.5.3

This commit is contained in:
Arin Alexander 2019-07-24 03:13:40 +03:00
commit 0864981b48
19 changed files with 1642 additions and 546 deletions

View File

@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 5 LIMEREPORT_VERSION_MINOR = 5
LIMEREPORT_VERSION_RELEASE = 2 LIMEREPORT_VERSION_RELEASE = 3
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"

View File

@ -278,7 +278,8 @@ void SQLEditDialog::initQueryMode()
ui->cbSubdetail->setChecked(false); ui->cbSubdetail->setChecked(false);
ui->leMaster->setVisible(false); ui->leMaster->setVisible(false);
ui->lbMaster->setVisible(false); ui->lbMaster->setVisible(false);
ui->tabWidget->removeTab(1); //ui->tabWidget->removeTab(1);
ui->tabWidget->addTab(ui->csvTab, tr("CSV"));
} }
void SQLEditDialog::initSubQueryMode() void SQLEditDialog::initSubQueryMode()
@ -314,7 +315,7 @@ void SQLEditDialog::initProxyMode()
void SQLEditDialog::initCSVMode() void SQLEditDialog::initCSVMode()
{ {
ui->tabWidget->removeTab(0); ui->tabWidget->setCurrentWidget(ui->csvTab);
} }
void SQLEditDialog::slotPreviewData() void SQLEditDialog::slotPreviewData()

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>422</width> <width>422</width>
<height>622</height> <height>646</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -183,6 +183,15 @@
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="NoBrush">
<color alpha="128">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active> </active>
<inactive> <inactive>
<colorrole role="WindowText"> <colorrole role="WindowText">
@ -320,6 +329,15 @@
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="NoBrush">
<color alpha="128">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive> </inactive>
<disabled> <disabled>
<colorrole role="WindowText"> <colorrole role="WindowText">
@ -457,6 +475,15 @@
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="NoBrush">
<color alpha="128">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</disabled> </disabled>
</palette> </palette>
</property> </property>

View File

@ -500,7 +500,7 @@ void BaseDesignIntf::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
update(); update();
} }
void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent /**event*/)
{ {
m_hovered = true; m_hovered = true;
update(); update();

View File

@ -320,7 +320,7 @@ protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event); void mousePressEvent(QGraphicsSceneMouseEvent* event);
void hoverMoveEvent(QGraphicsSceneHoverEvent* event); void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverEnterEvent(QGraphicsSceneHoverEvent);
void mouseMoveEvent(QGraphicsSceneMouseEvent* event); void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);

View File

@ -176,7 +176,7 @@ public:
bool isOwned() const {return true;} bool isOwned() const {return true;}
bool isEditable() const {return true;} bool isEditable() const {return true;}
bool isRemovable() const {return true;} bool isRemovable() const {return true;}
void invalidate(IDataSource::DatasourceMode mode, bool /*dbWillBeClosed*/){ updateModel();} void invalidate(IDataSource::DatasourceMode /*mode*/, bool /*dbWillBeClosed*/){ updateModel();}
void update(){ updateModel(); } void update(){ updateModel(); }
void clearErrors(){} void clearErrors(){}
private: private:

View File

@ -816,6 +816,7 @@ void PageDesignIntf::slotItemPropertyObjectNameChanged(const QString &oldName, c
if (oldName.compare(newName)!=0 && !m_executingCommand){ if (oldName.compare(newName)!=0 && !m_executingCommand){
CommandIf::Ptr command = PropertyObjectNameChangedCommand::create(this, oldName, newName); CommandIf::Ptr command = PropertyObjectNameChangedCommand::create(this, oldName, newName);
saveCommand(command, false); saveCommand(command, false);
emit itemPropertyObjectNameChanged(oldName, newName);
} }
} }

View File

@ -218,6 +218,7 @@ namespace LimeReport {
const QString& propertyName, const QString& propertyName,
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue); const QVariant& newValue);
void itemPropertyObjectNameChanged(const QString& oldName, const QString& newName);
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);

View File

@ -287,30 +287,31 @@ void ReportDesignWidget::loadState()
applySettings(); applySettings();
} }
PageView* ReportDesignWidget::createPageView(PageDesignIntf* page){
PageView* view = new PageView(this);
view->setBackgroundBrush(QBrush(Qt::gray));
view->setFrameShape(QFrame::NoFrame);
view->setScene(page);
view->setPageItem(page->pageItem());
view->scale(0.5, 0.5);
view->centerOn(0, 0);
return view;
}
void ReportDesignWidget::createTabs(){ void ReportDesignWidget::createTabs(){
m_tabWidget->clear(); m_tabWidget->clear();
int pageIndex = -1; int pageIndex = -1;
for (int i = 0; i < m_report->pageCount(); ++i){ for (int i = 0; i < m_report->pageCount(); ++i){
PageView* view = new PageView(qobject_cast<QWidget*>(this)); PageDesignIntf* page = m_report->pageAt(i);
view->setBackgroundBrush(QBrush(Qt::gray)); page->clearSelection();
view->setFrameShape(QFrame::NoFrame); connectPage(page);
view->setScene(m_report->pageAt(i)); PageView* view = createPageView(page);
view->setPageItem(m_report->pageAt(i)->pageItem()); int pageIndex = m_tabWidget->addTab(view, QIcon(), page->pageItem()->objectName());
m_report->pageAt(i)->clearSelection();
view->centerOn(0,0);
view->scale(0.5,0.5);
connectPage(m_report->pageAt(i));
pageIndex = m_tabWidget->addTab(view,QIcon(),m_report->pageAt(i)->pageItem()->objectName());
m_tabWidget->setTabWhatsThis(pageIndex, "page"); m_tabWidget->setTabWhatsThis(pageIndex, "page");
connect(m_report->pageAt(i)->pageItem(), SIGNAL(propertyObjectNameChanged(QString,QString)),
this, SLOT(slotPagePropertyObjectNameChanged(QString,QString)));
} }
m_scriptEditor = new ScriptEditor(this); m_scriptEditor = new ScriptEditor(this);
connect(m_scriptEditor, SIGNAL(textChanged()), this, SLOT(slotScriptTextChanged())); connect(m_scriptEditor, SIGNAL(textChanged()), this, SLOT(slotScriptTextChanged()));
m_scriptEditor->setReportEngine(m_report); m_scriptEditor->setReportEngine(m_report);
pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script")); pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script"));
@ -359,25 +360,29 @@ QGraphicsView* ReportDesignWidget::activeView(){
void ReportDesignWidget::connectPage(PageDesignIntf *page) void ReportDesignWidget::connectPage(PageDesignIntf *page)
{ {
connect(page,SIGNAL(itemInserted(LimeReport::PageDesignIntf*,QPointF,QString)),this,SIGNAL(itemInserted(LimeReport::PageDesignIntf*,QPointF,QString))); connect(page, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)),
connect(page,SIGNAL(itemInsertCanceled(QString)),this,SIGNAL(itemInsertCanceled(QString))); this, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)));
connect(page,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)),this,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant))); connect(page, SIGNAL(itemInsertCanceled(QString)),this,SIGNAL(itemInsertCanceled(QString)));
connect(page,SIGNAL(selectionChanged()),this,SLOT(slotSelectionChanged())); connect(page, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)),
connect(page,SIGNAL(insertModeStarted()),this,SIGNAL(insertModeStarted())); this, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)));
connect(page,SIGNAL(commandHistoryChanged()),this,SIGNAL(commandHistoryChanged())); connect(page, SIGNAL(itemPropertyObjectNameChanged(QString, QString)),
connect(page,SIGNAL(sceneRectChanged(QRectF)),this,SLOT(slotSceneRectChanged(QRectF))); this, SLOT(slotItemPropertyObjectNameChanged(QString, QString)));
connect(page, SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()));
connect(page,SIGNAL(itemAdded(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)), connect(page, SIGNAL(insertModeStarted()), this, SIGNAL(insertModeStarted()));
this, SIGNAL(itemAdded(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*))); connect(page, SIGNAL(commandHistoryChanged()), this, SIGNAL(commandHistoryChanged()));
connect(page,SIGNAL(itemRemoved(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)), connect(page, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(slotSceneRectChanged(QRectF)));
this,SIGNAL(itemDeleted(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*))); connect(page, SIGNAL(itemAdded(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)),
connect(page,SIGNAL(bandAdded(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)), this, SIGNAL(itemAdded(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)));
this, SIGNAL(bandAdded(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*))); connect(page, SIGNAL(itemRemoved(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)),
connect(page, SIGNAL(bandRemoved(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)), this, SIGNAL(itemDeleted(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)));
this, SIGNAL(bandDeleted(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*))); connect(page, SIGNAL(bandAdded(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)),
this, SIGNAL(bandAdded(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)));
connect(page, SIGNAL(bandRemoved(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)),
this, SIGNAL(bandDeleted(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)));
connect(page, SIGNAL(pageUpdateFinished(LimeReport::PageDesignIntf*)), connect(page, SIGNAL(pageUpdateFinished(LimeReport::PageDesignIntf*)),
this, SIGNAL(activePageUpdated(LimeReport::PageDesignIntf*))); this, SIGNAL(activePageUpdated(LimeReport::PageDesignIntf*)));
connect(page->pageItem(), SIGNAL(propertyObjectNameChanged(QString, QString)),
this, SLOT(slotPagePropertyObjectNameChanged(QString, QString)));
emit activePageChanged(); emit activePageChanged();
} }
@ -737,19 +742,13 @@ void ReportDesignWidget::printReport()
void ReportDesignWidget::addPage() void ReportDesignWidget::addPage()
{ {
QGraphicsView* view = new QGraphicsView(qobject_cast<QWidget*>(this));
view->setBackgroundBrush(QBrush(Qt::gray));
view->setFrameShape(QFrame::NoFrame);
PageDesignIntf* page = m_report->appendPage("page"+QString::number(m_report->pageCount()+1)); PageDesignIntf* page = m_report->appendPage("page"+QString::number(m_report->pageCount()+1));
view->setScene(page);
int index = m_report->pageCount()-1;
m_tabWidget->insertTab(index,view,QIcon(),page->pageItem()->objectName());
m_tabWidget->setCurrentIndex(index);
connect(page->pageItem(), SIGNAL(propertyObjectNameChanged(QString,QString)),
this, SLOT(slotPagePropertyObjectNameChanged(QString,QString)));
connectPage(page); connectPage(page);
view->scale(0.5,0.5); PageView* view = createPageView(page);
view->centerOn(0,0); int index = m_report->pageCount()-1;
m_tabWidget->insertTab(index, view, QIcon(), page->pageItem()->objectName());
m_tabWidget->setTabWhatsThis(index, "page");
m_tabWidget->setCurrentIndex(index);
applyUseGrid(); applyUseGrid();
emit pageAdded(page); emit pageAdded(page);
} }
@ -821,9 +820,9 @@ void ReportDesignWidget::editSetting()
void ReportDesignWidget::applyUseGrid() void ReportDesignWidget::applyUseGrid()
{ {
int hGridStep = m_useGrid?m_horizontalGridStep:2; int hGridStep = m_useGrid ? m_horizontalGridStep : 2;
int vGridStep = m_useGrid?m_verticalGridStep:2; int vGridStep = m_useGrid ? m_verticalGridStep : 2;
for(int i=0;i<m_report->pageCount();++i){ for(int i = 0; i < m_report->pageCount(); ++i){
m_report->pageAt(i)->setVerticalGridStep(hGridStep); m_report->pageAt(i)->setVerticalGridStep(hGridStep);
m_report->pageAt(i)->setHorizontalGridStep(vGridStep); m_report->pageAt(i)->setHorizontalGridStep(vGridStep);
} }
@ -968,6 +967,18 @@ void ReportDesignWidget::slotScriptTextChanged()
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
} }
void ReportDesignWidget::slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName)
{
PageDesignIntf* page = qobject_cast<PageDesignIntf*>(sender());
if (page){
ITranslationContainer* tc = dynamic_cast<ITranslationContainer*>(report());
for (int i = 0; i < tc->translations()->values().count(); ++i){
PageTranslation* pt = tc->translations()->values().at(i)->findPageTranslation(page->pageItem()->objectName());
if (pt) pt->renameItem(oldName, newName);
}
}
}
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWidget::addNewDialog() void ReportDesignWidget::addNewDialog()
@ -999,6 +1010,11 @@ void ReportDesignWidget::slotDialogNameChanged(QString oldName, QString newName)
void ReportDesignWidget::slotPagePropertyObjectNameChanged(const QString &oldValue, const QString &newValue) void ReportDesignWidget::slotPagePropertyObjectNameChanged(const QString &oldValue, const QString &newValue)
{ {
ITranslationContainer* tc = dynamic_cast<ITranslationContainer*>(report());
foreach(ReportTranslation* translation, tc->translations()->values()){
translation->renamePage(oldValue, newValue);
}
for (int i = 0; i < m_tabWidget->count(); ++i ){ for (int i = 0; i < m_tabWidget->count(); ++i ){
if (m_tabWidget->tabText(i).compare(oldValue) == 0){ if (m_tabWidget->tabText(i).compare(oldValue) == 0){
QGraphicsView* view = dynamic_cast<QGraphicsView*>(m_tabWidget->widget(i)); QGraphicsView* view = dynamic_cast<QGraphicsView*>(m_tabWidget->widget(i));
@ -1071,14 +1087,16 @@ bool PageView::viewportEvent(QEvent *event)
{ {
switch (event->type()) { switch (event->type()) {
case QEvent::MouseMove: case QEvent::MouseMove:
m_horizontalRuller->setMousePos(dynamic_cast<QMouseEvent*>(event)->pos()); if (m_horizontalRuller && m_verticalRuller){
m_verticalRuller->setMousePos(dynamic_cast<QMouseEvent*>(event)->pos()); m_horizontalRuller->setMousePos(dynamic_cast<QMouseEvent*>(event)->pos());
m_horizontalRuller->update(); m_verticalRuller->setMousePos(dynamic_cast<QMouseEvent*>(event)->pos());
m_verticalRuller->update(); m_horizontalRuller->update();
m_verticalRuller->update();
}
break; break;
//case QEvent::Resize: //case QEvent::Resize:
case QEvent::Paint: case QEvent::Paint:
if (m_horizontalRuller){ if (m_horizontalRuller && m_verticalRuller){
int x = mapFromScene(m_pageItem->boundingRect().x(),m_pageItem->boundingRect().y()).x(); int x = mapFromScene(m_pageItem->boundingRect().x(),m_pageItem->boundingRect().y()).x();
int y = mapFromScene(m_pageItem->boundingRect().x(),m_pageItem->boundingRect().y()).y(); int y = mapFromScene(m_pageItem->boundingRect().x(),m_pageItem->boundingRect().y()).y();
int width = mapFromScene(m_pageItem->boundingRect().bottomRight().x(),m_pageItem->boundingRect().bottomRight().y()).x(); int width = mapFromScene(m_pageItem->boundingRect().bottomRight().x(),m_pageItem->boundingRect().bottomRight().y()).x();

View File

@ -216,6 +216,7 @@ private slots:
void slotCurrentTabChanged(int index); void slotCurrentTabChanged(int index);
void slotReportLoaded(); void slotReportLoaded();
void slotScriptTextChanged(); void slotScriptTextChanged();
void slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName);
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
void slotDialogChanged(QString); void slotDialogChanged(QString);
void slotDialogNameChanged(QString oldName, QString newName); void slotDialogNameChanged(QString oldName, QString newName);
@ -241,6 +242,7 @@ signals:
void pageAdded(PageDesignIntf* page); void pageAdded(PageDesignIntf* page);
void pageDeleted(); void pageDeleted();
protected: protected:
PageView *createPageView(PageDesignIntf *page);
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
void createNewDialogTab(const QString& dialogName,const QByteArray& description); void createNewDialogTab(const QString& dialogName,const QByteArray& description);
#endif #endif
@ -275,6 +277,7 @@ private:
QMap<QString, QString> m_themes; QMap<QString, QString> m_themes;
QMap<QString, QString> m_localToEng; QMap<QString, QString> m_localToEng;
BaseDesignIntf::UnitType m_defaultUnits; BaseDesignIntf::UnitType m_defaultUnits;
}; };
} // namespace LimeReport } // namespace LimeReport

View File

@ -224,9 +224,11 @@ void ReportEnginePrivate::showError(QString message)
void ReportEnginePrivate::updateTranslations() void ReportEnginePrivate::updateTranslations()
{ {
foreach(ReportTranslation* translation, m_translations.values()){ foreach(ReportTranslation* translation, m_translations.values()){
translation->invalidatePages();
foreach(PageDesignIntf* page, m_pages){ foreach(PageDesignIntf* page, m_pages){
translation->updatePageTranslation(page); translation->updatePageTranslation(page);
} }
translation->clearInvalidPages();
} }
} }
@ -500,7 +502,7 @@ bool ReportEnginePrivate::exportReport(QString exporterName, const QString &file
return false; return false;
} }
bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints) bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter* printer)
{ {
if (pages.count()>0){ if (pages.count()>0){
Q_Q(ReportEngine); Q_Q(ReportEngine);
@ -515,6 +517,7 @@ bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hint
w->setPages(pages); w->setPages(pages);
w->setLayoutDirection(m_previewLayoutDirection); w->setLayoutDirection(m_previewLayoutDirection);
w->setStyleSheet(styleSheet()); w->setStyleSheet(styleSheet());
// w->setDefaultPrinter()
if (!dataManager()->errorsList().isEmpty()){ if (!dataManager()->errorsList().isEmpty()){
w->setErrorMessages(dataManager()->errorsList()); w->setErrorMessages(dataManager()->errorsList());
@ -550,14 +553,13 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
previewReport(0, hints); previewReport(0, hints);
} }
void ReportEnginePrivate::previewReport(QPrinter *printer, PreviewHints hints) void ReportEnginePrivate::previewReport(QPrinter* printer, PreviewHints hints)
{ {
// QTime start = QTime::currentTime();
try{ try{
dataManager()->setDesignTime(false); dataManager()->setDesignTime(false);
ReportPages pages = renderToPages(); ReportPages pages = renderToPages();
dataManager()->setDesignTime(true); dataManager()->setDesignTime(true);
showPreviewWindow(pages, hints); showPreviewWindow(pages, hints, printer);
} catch (ReportError &exception){ } catch (ReportError &exception){
saveError(exception.what()); saveError(exception.what());
showError(exception.what()); showError(exception.what());
@ -980,7 +982,12 @@ IPreparedPages *ReportEnginePrivate::preparedPages(){
bool ReportEnginePrivate::showPreparedPages(PreviewHints hints) bool ReportEnginePrivate::showPreparedPages(PreviewHints hints)
{ {
return showPreviewWindow(m_preparedPages, hints); return showPreparedPages(0, hints);
}
bool ReportEnginePrivate::showPreparedPages(QPrinter* defaultPrinter, PreviewHints hints)
{
return showPreviewWindow(m_preparedPages, hints, defaultPrinter);
} }
bool ReportEnginePrivate::prepareReportPages() bool ReportEnginePrivate::prepareReportPages()

View File

@ -246,6 +246,7 @@ public:
void clearWatermarks(); void clearWatermarks();
IPreparedPages* preparedPages(); IPreparedPages* preparedPages();
bool showPreparedPages(PreviewHints hints); bool showPreparedPages(PreviewHints hints);
bool showPreparedPages(QPrinter *defaultPrinter, PreviewHints hints);
bool prepareReportPages(); bool prepareReportPages();
bool printPreparedPages(); bool printPreparedPages();
signals: signals:
@ -273,7 +274,7 @@ public slots:
void cancelRender(); void cancelRender();
protected: protected:
PageDesignIntf* createPage(const QString& pageName="", bool preview = false); PageDesignIntf* createPage(const QString& pageName="", bool preview = false);
bool showPreviewWindow(ReportPages pages, PreviewHints hints); bool showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter *printer);
protected slots: protected slots:
void slotDataSourceCollectionLoaded(const QString& collectionName); void slotDataSourceCollectionLoaded(const QString& collectionName);
private slots: private slots:

View File

@ -189,7 +189,7 @@ void ReportRender::initDatasource(const QString& name){
} }
} }
void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool isFirst, bool resetPageNumbers) void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool /*isFirst*/, bool /*resetPageNumbers*/)
{ {
m_currentNameIndex = 0; m_currentNameIndex = 0;
m_patternPageItem = patternPage; m_patternPageItem = patternPage;

View File

@ -116,7 +116,7 @@ private:
void initGroups(); void initGroups();
void clearPageMap(); void clearPageMap();
void renderPage(PageItemDesignIntf *patternPage, bool isTOC = false, bool isFirst = false, bool resetPageNumbers = false); void renderPage(PageItemDesignIntf *patternPage, bool isTOC = false, bool isFirst = false, bool = false);
BandDesignIntf* renderBand(BandDesignIntf *patternBand, BandDesignIntf *bandData, DataRenderMode mode = NotStartNewPage, bool isLast = false); BandDesignIntf* renderBand(BandDesignIntf *patternBand, BandDesignIntf *bandData, DataRenderMode mode = NotStartNewPage, bool isLast = false);
void renderDataBand(BandDesignIntf* dataBand); void renderDataBand(BandDesignIntf* dataBand);
void renderPageHeader(PageItemDesignIntf* patternPage); void renderPageHeader(PageItemDesignIntf* patternPage);

View File

@ -32,6 +32,7 @@ ReportTranslation::~ReportTranslation()
PageTranslation* ReportTranslation::createPageTranslation(PageDesignIntf* page) PageTranslation* ReportTranslation::createPageTranslation(PageDesignIntf* page)
{ {
PageTranslation* pageTranslation = new PageTranslation; PageTranslation* pageTranslation = new PageTranslation;
pageTranslation->checked = true;
pageTranslation->pageName = page->pageItem()->objectName(); pageTranslation->pageName = page->pageItem()->objectName();
foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){ foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){
createItemTranslation(item, pageTranslation); createItemTranslation(item, pageTranslation);
@ -43,6 +44,7 @@ void ReportTranslation::createItemTranslation(BaseDesignIntf* item, PageTranslat
QMap<QString,QString> stringsForTranslation = item->getStringForTranslation(); QMap<QString,QString> stringsForTranslation = item->getStringForTranslation();
if (!stringsForTranslation.isEmpty()){ if (!stringsForTranslation.isEmpty()){
ItemTranslation* itemTranslation = new ItemTranslation; ItemTranslation* itemTranslation = new ItemTranslation;
itemTranslation->checked = true;
itemTranslation->itemName = item->objectName(); itemTranslation->itemName = item->objectName();
foreach(QString propertyName, stringsForTranslation.keys()){ foreach(QString propertyName, stringsForTranslation.keys()){
PropertyTranslation* propertyTranslation = new PropertyTranslation; PropertyTranslation* propertyTranslation = new PropertyTranslation;
@ -57,16 +59,42 @@ void ReportTranslation::createItemTranslation(BaseDesignIntf* item, PageTranslat
} }
} }
PageTranslation* ReportTranslation::findPageTranslation(const QString& page_name) PageTranslation* ReportTranslation::findPageTranslation(const QString& pageName)
{ {
foreach(PageTranslation* page, m_pagesTranslation){ foreach(PageTranslation* page, m_pagesTranslation){
if (page->pageName.compare(page_name) == 0){ if (page->pageName.compare(pageName) == 0){
return page; return page;
} }
} }
return 0; return 0;
} }
void ReportTranslation::renamePage(const QString &oldName, const QString &newName)
{
PageTranslation* page = findPageTranslation(oldName);
if (page){
page->pageName = newName;
}
}
void ReportTranslation::invalidatePages()
{
foreach(PageTranslation* page, m_pagesTranslation){
page->checked = false;
}
}
void ReportTranslation::clearInvalidPages()
{
QList<PageTranslation*>::Iterator it = m_pagesTranslation.begin();
while (it != m_pagesTranslation.end()){
if (!(*it)->checked){
delete *it;
it = m_pagesTranslation.erase(it);
} else ++it;
}
}
void ReportTranslation::updatePageTranslation(PageDesignIntf* page) void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
{ {
PageTranslation* pageTranslation = findPageTranslation(page->pageItem()->objectName()); PageTranslation* pageTranslation = findPageTranslation(page->pageItem()->objectName());
@ -75,6 +103,10 @@ void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
m_pagesTranslation.append(pageTranslation); m_pagesTranslation.append(pageTranslation);
} }
if (pageTranslation){ if (pageTranslation){
pageTranslation->checked = true;
foreach(ItemTranslation* item, pageTranslation->itemsTranslation){
item->checked = false;
}
foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){ foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){
QMap<QString,QString> stringsForTranslation = item->getStringForTranslation(); QMap<QString,QString> stringsForTranslation = item->getStringForTranslation();
if (!stringsForTranslation.isEmpty()){ if (!stringsForTranslation.isEmpty()){
@ -90,15 +122,23 @@ void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
propertyTranslation->sourceValue = stringsForTranslation.value(propertyName); propertyTranslation->sourceValue = stringsForTranslation.value(propertyName);
if (!translated) propertyTranslation->value = propertyTranslation->sourceValue; if (!translated) propertyTranslation->value = propertyTranslation->sourceValue;
} }
itemTranslation->checked = true;
} else { } else {
createItemTranslation(item, pageTranslation); createItemTranslation(item, pageTranslation);
} }
} }
} }
QHash<QString, ItemTranslation*>::Iterator it = pageTranslation->itemsTranslation.begin();
while( it != pageTranslation->itemsTranslation.end()){
if (!it.value()->checked) {
delete it.value();
it = pageTranslation->itemsTranslation.erase(it);
} else ++it;
}
} }
} }
QList<PageTranslation*> ReportTranslation::pagesTranslation() const QList<PageTranslation*>& ReportTranslation::pagesTranslation()
{ {
return m_pagesTranslation; return m_pagesTranslation;
} }
@ -139,4 +179,14 @@ PageTranslation::~PageTranslation()
} }
} }
void PageTranslation::renameItem(const QString &oldName, const QString &newName)
{
ItemTranslation* item = itemsTranslation.value(oldName);
if (item){
itemsTranslation.remove(oldName);
item->itemName = newName;
itemsTranslation[newName] = item;
}
}
} //namespace LimeReport } //namespace LimeReport

View File

@ -31,6 +31,7 @@ struct PropertyTranslation{
struct ItemTranslation{ struct ItemTranslation{
QString itemName; QString itemName;
bool checked;
PropertyTranslation* findProperty(const QString& propertyName); PropertyTranslation* findProperty(const QString& propertyName);
~ItemTranslation(); ~ItemTranslation();
QList<PropertyTranslation*> propertyesTranslation; QList<PropertyTranslation*> propertyesTranslation;
@ -38,8 +39,10 @@ struct ItemTranslation{
struct PageTranslation{ struct PageTranslation{
QString pageName; QString pageName;
bool checked;
~PageTranslation(); ~PageTranslation();
QHash<QString,ItemTranslation*> itemsTranslation; void renameItem(const QString& oldName, const QString& newName);
QHash<QString, ItemTranslation*> itemsTranslation;
}; };
class ReportTranslation{ class ReportTranslation{
@ -49,12 +52,15 @@ public:
ReportTranslation(const ReportTranslation& reportTranslation); ReportTranslation(const ReportTranslation& reportTranslation);
~ReportTranslation(); ~ReportTranslation();
QLocale::Language language() const; QLocale::Language language() const;
QList<PageTranslation*> pagesTranslation() const; QList<PageTranslation *> &pagesTranslation();
PageTranslation* createEmptyPageTranslation(); PageTranslation* createEmptyPageTranslation();
void updatePageTranslation(PageDesignIntf* page); void updatePageTranslation(PageDesignIntf* page);
PageTranslation* findPageTranslation(const QString& page_name); PageTranslation* findPageTranslation(const QString& pageName);
void createItemTranslation(BaseDesignIntf* item, PageTranslation* pageTranslation); void renamePage(const QString& oldName, const QString& newName);
void invalidatePages();
void clearInvalidPages();
private: private:
void createItemTranslation(BaseDesignIntf* item, PageTranslation* pageTranslation);
PageTranslation* createPageTranslation(PageDesignIntf* page); PageTranslation* createPageTranslation(PageDesignIntf* page);
private: private:
QLocale::Language m_language; QLocale::Language m_language;

View File

@ -11,7 +11,8 @@ namespace LimeReport {
TranslationEditor::TranslationEditor(QWidget *parent) : TranslationEditor::TranslationEditor(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::TranslationEditor), m_translationContainer(0), ui(new Ui::TranslationEditor), m_translationContainer(0),
m_currentReportTranslation(0), m_currentPageTranslation(0), m_currentPropertyTranslation(0) m_currentReportTranslation(0), m_currentPageTranslation(0),
m_currentPropertyTranslation(0), m_translationChanging(false)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->splitter_3->setStretchFactor(1,10); ui->splitter_3->setStretchFactor(1,10);
@ -78,11 +79,10 @@ void TranslationEditor::updateUi()
ui->lvLanguages->addItem(QLocale::languageToString(language)); ui->lvLanguages->addItem(QLocale::languageToString(language));
} }
if (!translations->keys().isEmpty()){ if (!translations->keys().isEmpty()){
if (ui->lvLanguages->count()!=0){ if (ui->lvLanguages->count() != 0){
ui->lvLanguages->item(0)->setSelected(true); ui->lvLanguages->item(0)->setSelected(true);
activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text())); activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text()));
} else { } else {
//activateLanguage(QLocale::AnyLanguage);
ui->twPages->clear(); ui->twPages->clear();
ui->tbStrings->setRowCount(0); ui->tbStrings->setRowCount(0);
} }
@ -93,7 +93,9 @@ void TranslationEditor::updateUi()
void TranslationEditor::activateLanguage(QLocale::Language language) void TranslationEditor::activateLanguage(QLocale::Language language)
{ {
m_translationChanging = true;
ui->teTranslation->setEnabled(false); ui->teTranslation->setEnabled(false);
ui->teTranslation->setPlainText("");
ui->cbChecked->setEnabled(false); ui->cbChecked->setEnabled(false);
ui->twPages->clear(); ui->twPages->clear();
Translations* translations = m_translationContainer->translations(); Translations* translations = m_translationContainer->translations();
@ -113,6 +115,7 @@ void TranslationEditor::activateLanguage(QLocale::Language language)
activatePage(m_currentReportTranslation->findPageTranslation(ui->twPages->topLevelItem(0)->text(0))); activatePage(m_currentReportTranslation->findPageTranslation(ui->twPages->topLevelItem(0)->text(0)));
} }
} }
m_translationChanging = false;
} }
void TranslationEditor::activatePage(PageTranslation* pageTranslation) void TranslationEditor::activatePage(PageTranslation* pageTranslation)
@ -171,13 +174,13 @@ void TranslationEditor::activateTranslation(const QString& itemName, const QStri
void TranslationEditor::on_tbStrings_itemSelectionChanged() void TranslationEditor::on_tbStrings_itemSelectionChanged()
{ {
if (m_currentPageTranslation) if (m_currentPageTranslation && !m_translationChanging)
activateTranslation(ui->tbStrings->item(ui->tbStrings->currentRow(),1)->text(), ui->tbStrings->item(ui->tbStrings->currentRow(),2)->text()); activateTranslation(ui->tbStrings->item(ui->tbStrings->currentRow(),1)->text(), ui->tbStrings->item(ui->tbStrings->currentRow(),2)->text());
} }
void TranslationEditor::on_teTranslation_textChanged() void TranslationEditor::on_teTranslation_textChanged()
{ {
if (m_currentPropertyTranslation) if (m_currentPropertyTranslation && !m_translationChanging)
m_currentPropertyTranslation->value = ui->teTranslation->toPlainText(); m_currentPropertyTranslation->value = ui->teTranslation->toPlainText();
} }
@ -200,16 +203,23 @@ void TranslationEditor::on_tbAddLanguage_clicked()
{ {
LanguageSelectDialog dialog; LanguageSelectDialog dialog;
if (dialog.exec()){ if (dialog.exec()){
m_translationChanging = true;
m_translationContainer->addTranslationLanguage(dialog.getSelectedLanguage()); m_translationContainer->addTranslationLanguage(dialog.getSelectedLanguage());
updateUi(); updateUi();
activateLanguage(dialog.getSelectedLanguage()); activateLanguage(dialog.getSelectedLanguage());
foreach (QListWidgetItem* item, ui->lvLanguages->findItems(QLocale::languageToString(dialog.getSelectedLanguage()), Qt::MatchExactly)){
item->setSelected(true);
}
m_translationChanging = false;
} }
} }
void TranslationEditor::on_tbDeleteLanguage_clicked() void TranslationEditor::on_tbDeleteLanguage_clicked()
{ {
m_translationChanging = true;
m_translationContainer->removeTranslationLanguage(m_currentReportTranslation->language()); m_translationContainer->removeTranslationLanguage(m_currentReportTranslation->language());
updateUi(); updateUi();
m_translationChanging = false;
} }
void TranslationEditor::slotItemChecked() void TranslationEditor::slotItemChecked()

View File

@ -45,6 +45,7 @@ private:
ReportTranslation* m_currentReportTranslation; ReportTranslation* m_currentReportTranslation;
PageTranslation* m_currentPageTranslation; PageTranslation* m_currentPageTranslation;
PropertyTranslation* m_currentPropertyTranslation; PropertyTranslation* m_currentPropertyTranslation;
bool m_translationChanging;
}; };
} //namespace LimeReport } //namespace LimeReport

File diff suppressed because it is too large Load Diff