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

Finish addNewTextInPreview

This commit is contained in:
Arin Alexander 2019-03-02 01:18:20 +03:00
commit a2b7de4c10
16 changed files with 303 additions and 51 deletions

View File

@ -15,6 +15,7 @@ class PreviewReportWidget;
class PreviewReportWidgetPrivate;
class ReportEnginePrivate;
class ReportEngine;
class PageDesignIntf;
class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget
{
@ -34,6 +35,11 @@ public:
QColor previewPageBackgroundColor();
QPrinter *defaultPrinter() const;
void setDefaultPrinter(QPrinter *defaultPrinter);
void startInsertTextItem();
void activateItemSelectionMode();
void deleteSelectedItems();
void activateCurrentPage();
public slots:
void refreshPages();
void zoomIn();
@ -57,6 +63,7 @@ signals:
void pageChanged(int page);
void scalePercentChanged(int percent);
void pagesSet(int pageCount);
void itemInserted(LimeReport::PageDesignIntf* report, QPointF pos, const QString& ItemType);
private slots:
void slotSliderMoved(int value);
void reportEngineDestroyed(QObject* object);

View File

@ -775,8 +775,7 @@ BandDesignIntf* BandDesignIntf::findParentBand()
void BandDesignIntf::updateBandMarkerGeometry()
{
if (parentItem() && m_bandMarker){
QPointF sp = parentItem()->mapToScene(pos());
m_bandMarker->setPos((sp.x()-m_bandMarker->boundingRect().width()),sp.y());
m_bandMarker->setPos(pos().x()-m_bandMarker->width(),pos().y());
m_bandMarker->setHeight(rect().height());
}
}

View File

@ -66,11 +66,13 @@ void ItemDesignIntf::setItemLocation(LocationType location)
} else {
if (scene()){
PageItemDesignIntf* page = dynamic_cast<PageDesignIntf*>(scene())->pageItem();
QPointF parentPos = page->mapFromItem(parentItem(),x(),y());
setParentItem(page);
setParent(page);
setPos(parentPos);
emit itemLocationChanged(this, page);
if (page){
QPointF parentPos = page->mapFromItem(parentItem(),x(),y());
setParentItem(page);
setParent(page);
setPos(parentPos);
emit itemLocationChanged(this, page);
}
}
}
notify("locationType",oldValue,location);

View File

@ -91,7 +91,8 @@ PageDesignIntf::PageDesignIntf(QObject *parent):
m_movedItem(0),
m_joinItem(0),
m_magneticMovement(false),
m_reportSettings(0)
m_reportSettings(0),
m_currentPage(0)
{
m_reportEditor = dynamic_cast<ReportEnginePrivate *>(parent);
updatePageRect();
@ -240,7 +241,9 @@ void PageDesignIntf::startInsertMode(const QString &ItemType)
m_insertItemType = ItemType;
m_itemInsertRect = this->addRect(0, 0, 200, 50);
m_itemInsertRect->setVisible(false);
m_itemInsertRect->setParentItem(pageItem());
PageItemDesignIntf* page = pageItem() ? pageItem() : getCurrentPage();
if (page)
m_itemInsertRect->setParentItem(page);
}
void PageDesignIntf::startEditMode()
@ -253,11 +256,12 @@ void PageDesignIntf::startEditMode()
PageItemDesignIntf *PageDesignIntf::pageItem()
{
return m_pageItem.data();
return m_currentPage ? m_currentPage : m_pageItem.data();
}
void PageDesignIntf::setPageItem(PageItemDesignIntf::Ptr pageItem)
{
if (pageItem.isNull()) return;
if (!m_pageItem.isNull()) {
removeItem(m_pageItem.data());
m_pageItem->setParent(0);
@ -334,10 +338,11 @@ void PageDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
m_selectionRect->setRect(selectionRect);
}
if ((m_insertMode) && (pageItem()->rect().contains(pageItem()->mapFromScene(event->scenePos())))) {
PageItemDesignIntf* page = pageItem() ? pageItem() : getCurrentPage();
if ((m_insertMode) && (page && page->rect().contains(page->mapFromScene(event->scenePos())))) {
if (!m_itemInsertRect->isVisible()) m_itemInsertRect->setVisible(true);
qreal posY = div(pageItem()->mapFromScene(event->scenePos()).y(), verticalGridStep()).quot * verticalGridStep();
qreal posX = div(pageItem()->mapFromScene(event->scenePos()).x(), verticalGridStep()).quot * horizontalGridStep();
qreal posY = div(page->mapFromScene(event->scenePos()).y(), verticalGridStep()).quot * verticalGridStep();
qreal posX = div(page->mapFromScene(event->scenePos()).x(), verticalGridStep()).quot * horizontalGridStep();
m_itemInsertRect->setPos(posX,posY);
if (magneticMovement()){
rectMoved(
@ -348,8 +353,9 @@ void PageDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
)
);
}
} else {
if (m_insertMode) m_itemInsertRect->setVisible(false);
}
else { if (m_insertMode) m_itemInsertRect->setVisible(false); }
QGraphicsScene::mouseMoveEvent(event);
}
@ -490,21 +496,20 @@ BaseDesignIntf *PageDesignIntf::addReportItem(const QString &itemType, QPointF p
BandDesignIntf *band = bandAt(pos);
if (band) {
BaseDesignIntf *reportItem = addReportItem(itemType, band, band);
// QPointF insertPos = band->mapFromScene(pos);
// insertPos = QPointF(div(insertPos.x(), horizontalGridStep()).quot * horizontalGridStep(),
// div(insertPos.y(), verticalGridStep()).quot * verticalGridStep());
reportItem->setPos(placePosOnGrid(band->mapFromScene(pos)));
reportItem->setSize(placeSizeOnGrid(size));
return reportItem;
} else {
BaseDesignIntf *reportItem = addReportItem(itemType, pageItem(), pageItem());
reportItem->setPos(placePosOnGrid(pageItem()->mapFromScene(pos)));
reportItem->setSize(placeSizeOnGrid(size));
ItemDesignIntf* ii = dynamic_cast<ItemDesignIntf*>(reportItem);
if (ii)
ii->setItemLocation(ItemDesignIntf::Page);
return reportItem;
PageItemDesignIntf* page = pageItem() ? pageItem() : m_currentPage;
if (page){
BaseDesignIntf *reportItem = addReportItem(itemType, page, page);
reportItem->setPos(placePosOnGrid(page->mapFromScene(pos)));
reportItem->setSize(placeSizeOnGrid(size));
ItemDesignIntf* ii = dynamic_cast<ItemDesignIntf*>(reportItem);
if (ii)
ii->setItemLocation(ItemDesignIntf::Page);
return reportItem;
}
}
return 0;
@ -1066,6 +1071,22 @@ void PageDesignIntf::changeSelectedGroupProperty(const QString &name, const QVar
}
}
PageItemDesignIntf* PageDesignIntf::getCurrentPage() const
{
return m_currentPage;
}
void PageDesignIntf::setCurrentPage(PageItemDesignIntf* currentPage)
{
if (m_currentPage != currentPage ){
if (m_currentPage) m_currentPage->setItemMode(PreviewMode);
m_currentPage = currentPage;
if (m_itemMode == DesignMode){
m_currentPage->setItemMode(DesignMode);
}
}
}
ReportSettings *PageDesignIntf::getReportSettings() const
{
return m_reportSettings;
@ -1749,13 +1770,14 @@ void PageDesignIntf::removeAllItems()
void PageDesignIntf::setItemMode(BaseDesignIntf::ItemMode state)
{
m_itemMode = state;
foreach(QGraphicsItem * item, items()) {
BaseDesignIntf *reportItem = dynamic_cast<BaseDesignIntf *>(item);
// foreach(QGraphicsItem * item, items()) {
// BaseDesignIntf *reportItem = dynamic_cast<BaseDesignIntf *>(item);
if (reportItem) {
reportItem->setItemMode(itemMode());
}
}
// if (reportItem) {
// reportItem->setItemMode(itemMode());
// }
// }
if (m_currentPage) m_currentPage->setItemMode(state);
}
BaseDesignIntf* PageDesignIntf::reportItemByName(const QString &name)
@ -2490,7 +2512,8 @@ bool BandMoveFromToCommand::doIt()
void BandMoveFromToCommand::undoIt()
{
if (page()) page()->pageItem()->moveBandFromTo(to, from);
if (page() && page()->pageItem())
page()->pageItem()->moveBandFromTo(to, from);
}
}

View File

@ -176,6 +176,8 @@ namespace LimeReport {
void setPropertyToSelectedItems(const char *name, const QVariant &value);
PageItemDesignIntf* getCurrentPage() const;
void setCurrentPage(PageItemDesignIntf* currentPage);
protected:
@ -314,7 +316,7 @@ namespace LimeReport {
JoinType m_joinType;
bool m_magneticMovement;
ReportSettings* m_reportSettings;
PageItemDesignIntf* m_currentPage;
};
class AbstractPageCommand : public CommandIf{

View File

@ -479,7 +479,7 @@ void PageItemDesignIntf::relocateBands()
{
if (isLoading()) return;
int bandSpace = (itemMode() & DesignMode)?0:0;
int bandSpace = 0;
QVector<qreal> posByColumn;

View File

@ -53,6 +53,7 @@ void PreviewReportWidgetPrivate::setPages(ReportPages pages)
m_changingPage = false;
q_ptr->initPreview();
q_ptr->emitPageSet();
q_ptr->activateCurrentPage();
}
}
@ -68,6 +69,21 @@ QList<QString> PreviewReportWidgetPrivate::aviableExporters()
return ExportersFactory::instance().map().keys();
}
void PreviewReportWidgetPrivate::startInsertTextItem()
{
m_previewPage->startInsertMode("TextItem");
}
void PreviewReportWidgetPrivate::activateItemSelectionMode()
{
m_previewPage->startEditMode();
}
void PreviewReportWidgetPrivate::deleteSelectedItems()
{
m_previewPage->deleteSelected();
}
PreviewReportWidget::PreviewReportWidget(ReportEngine *report, QWidget *parent) :
QWidget(parent),
ui(new Ui::PreviewReportWidget), d_ptr(new PreviewReportWidgetPrivate(this)),
@ -130,6 +146,10 @@ void PreviewReportWidget::initPreview()
ui->graphicsView->centerOn(0, 0);
ui->graphicsView->scene()->setBackgroundBrush(QColor(m_previewPageBackgroundColor));
setScalePercent(d_ptr->m_scalePercent);
PageDesignIntf* page = dynamic_cast<PageDesignIntf*>(ui->graphicsView->scene());
if (page)
connect(page, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)),
this, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)));
}
void PreviewReportWidget::setErrorsMesagesVisible(bool visible)
@ -157,6 +177,7 @@ void PreviewReportWidget::firstPage()
d_ptr->m_currentPage=1;
ui->graphicsView->ensureVisible(d_ptr->calcPageShift(), 0, 0);
emit pageChanged(d_ptr->m_currentPage);
activateCurrentPage();
}
d_ptr->m_changingPage=false;
}
@ -168,6 +189,7 @@ void PreviewReportWidget::priorPage()
d_ptr->m_currentPage--;
ui->graphicsView->ensureVisible(d_ptr->calcPageShift(), 0, 0);
emit pageChanged(d_ptr->m_currentPage);
activateCurrentPage();
}
d_ptr->m_changingPage=false;
}
@ -179,6 +201,7 @@ void PreviewReportWidget::nextPage()
d_ptr->m_currentPage++;
ui->graphicsView->ensureVisible(d_ptr->calcPageShift(), 0, 0);
emit pageChanged(d_ptr->m_currentPage);
activateCurrentPage();
}
d_ptr->m_changingPage=false;
}
@ -190,6 +213,7 @@ void PreviewReportWidget::lastPage()
d_ptr->m_currentPage=d_ptr->m_reportPages.count();
ui->graphicsView->ensureVisible(d_ptr->calcPageShift(), 0, 0);
emit pageChanged(d_ptr->m_currentPage);
activateCurrentPage();
}
d_ptr->m_changingPage=false;
}
@ -249,6 +273,7 @@ void PreviewReportWidget::pageNavigatorChanged(int value)
d_ptr->m_changingPage = true;
if ((!d_ptr->m_reportPages.isEmpty())&&(d_ptr->m_reportPages.count() >= value) && value>0){
d_ptr->m_currentPage = value;
activateCurrentPage();
ui->graphicsView->ensureVisible(d_ptr->calcPageShift(), 0, 0);
}
d_ptr->m_changingPage=false;
@ -332,6 +357,21 @@ ScaleType PreviewReportWidget::scaleType() const
return m_scaleType;
}
void PreviewReportWidget::startInsertTextItem()
{
d_ptr->startInsertTextItem();
}
void PreviewReportWidget::activateItemSelectionMode()
{
d_ptr->activateItemSelectionMode();
}
void PreviewReportWidget::deleteSelectedItems()
{
d_ptr->deleteSelectedItems();
}
int PreviewReportWidget::scalePercent() const
{
return m_scalePercent;
@ -370,8 +410,16 @@ void PreviewReportWidget::refreshPages()
}
}
void PreviewReportWidget::activateCurrentPage()
{
PageDesignIntf* page = dynamic_cast<PageDesignIntf*>(ui->graphicsView->scene());
if (page)
page->setCurrentPage(d_ptr->currentPage().data());
}
void PreviewReportWidget::slotSliderMoved(int value)
{
int curPage = d_ptr->m_currentPage;
if (ui->graphicsView->verticalScrollBar()->minimum()==value){
d_ptr->m_currentPage = 1;
} else if (ui->graphicsView->verticalScrollBar()->maximum()==value){
@ -386,10 +434,13 @@ void PreviewReportWidget::slotSliderMoved(int value)
}
}
d_ptr->m_changingPage = true;
emit pageChanged(d_ptr->m_currentPage);
if (curPage != d_ptr->m_currentPage){
d_ptr->m_changingPage = true;
emit pageChanged(d_ptr->m_currentPage);
activateCurrentPage();
d_ptr->m_changingPage = false;
}
d_ptr->m_changingPage = false;
d_ptr->m_priorScrolValue = value;
}

View File

@ -15,6 +15,7 @@ class PreviewReportWidget;
class PreviewReportWidgetPrivate;
class ReportEnginePrivate;
class ReportEngine;
class PageDesignIntf;
class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget
{
@ -34,6 +35,11 @@ public:
QColor previewPageBackgroundColor();
QPrinter *defaultPrinter() const;
void setDefaultPrinter(QPrinter *defaultPrinter);
void startInsertTextItem();
void activateItemSelectionMode();
void deleteSelectedItems();
void activateCurrentPage();
public slots:
void refreshPages();
void zoomIn();
@ -57,6 +63,7 @@ signals:
void pageChanged(int page);
void scalePercentChanged(int percent);
void pagesSet(int pageCount);
void itemInserted(LimeReport::PageDesignIntf* report, QPointF pos, const QString& ItemType);
private slots:
void slotSliderMoved(int value);
void reportEngineDestroyed(QObject* object);

View File

@ -21,6 +21,9 @@ public:
void setPages( ReportPages pages);
PageItemDesignIntf::Ptr currentPage();
QList<QString> aviableExporters();
void startInsertTextItem();
void activateItemSelectionMode();
void deleteSelectedItems();
public:
PageDesignIntf* m_previewPage;
ReportPages m_reportPages;

View File

@ -57,6 +57,7 @@ PreviewReportWindow::PreviewReportWindow(ReportEngine *report, QWidget *parent,
m_pagesNavigator->setPrefix(tr("Page: "));
m_pagesNavigator->setMinimumWidth(120);
ui->toolBar->insertWidget(ui->actionNextPage,m_pagesNavigator);
ui->editModeTools->hide();
ui->actionShowMessages->setVisible(false);
connect(m_pagesNavigator,SIGNAL(valueChanged(int)),this,SLOT(slotPageNavigatorChanged(int)));
@ -81,10 +82,13 @@ PreviewReportWindow::PreviewReportWindow(ReportEngine *report, QWidget *parent,
ui->toolBar->insertWidget(ui->actionZoomOut, m_scalePercent);
initPercentCombobox();
// connect(ui->graphicsView->verticalScrollBar(),SIGNAL(valueChanged(int)), this, SLOT(slotSliderMoved(int)));
connect(ui->actionShowMessages, SIGNAL(triggered()), this, SLOT(slotShowErrors()));
connect(m_previewReportWidget, SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int)));
connect(m_scalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString)));
connect(m_previewReportWidget, SIGNAL(pageChanged(int)), this, SLOT(slotCurrentPageChanged(int)));
connect(m_previewReportWidget, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)),
this, SLOT(slotItemInserted(LimeReport::PageDesignIntf*, QPointF, QString)));
restoreSetting();
selectStateIcon();
}
@ -109,10 +113,13 @@ void PreviewReportWindow::restoreSetting()
int screenWidth = desktop->screenGeometry().width();
int screenHeight = desktop->screenGeometry().height();
int x = screenWidth*0.1;
int y = screenHeight*0.1;
int x = static_cast<int>(screenWidth*0.1);
int y = static_cast<int>(screenHeight*0.1);
resize(screenWidth*0.8, screenHeight*0.8);
resize(
static_cast<int>(screenWidth*0.8),
static_cast<int>(screenHeight*0.8)
);
move(x, y);
}
v = settings()->value("State");
@ -260,6 +267,7 @@ void PreviewReportWindow::moveEvent(QMoveEvent* e)
void PreviewReportWindow::showEvent(QShowEvent *)
{
m_fontEditor->setVisible(ui->actionEdit_Mode->isChecked());
ui->editModeTools->setVisible(false);
m_textAlignmentEditor->setVisible(ui->actionEdit_Mode->isChecked());
switch (m_previewScaleType) {
case FitWidth:
@ -326,7 +334,9 @@ void PreviewReportWindow::on_actionEdit_Mode_triggered(bool checked)
m_previewReportWidget->d_ptr->m_previewPage->setItemMode((checked)?ItemModes(DesignMode):PreviewMode);
m_textAlignmentEditor->setVisible(checked);
m_fontEditor->setVisible(checked);
//m_reportPages.at(m_currentPage)->setItemMode((checked)?DesignMode:PreviewMode);
if (checked)
ui->editModeTools->show();
else ui->editModeTools->hide();
}
void PreviewReportWindow::slotSelectionChanged()
@ -403,6 +413,24 @@ void PreviewReportWindow::slotPageChanged(int pageIndex)
m_pagesNavigator->setValue(pageIndex);
}
void PreviewReportWindow::slotInsertNewTextItem()
{
m_previewReportWidget->startInsertTextItem();
ui->actionSelection_Mode->setChecked(false);
}
void PreviewReportWindow::slotActivateItemSelectionMode()
{
m_previewReportWidget->activateItemSelectionMode();
ui->actionSelection_Mode->setChecked(true);
ui->actionInsertTextItem->setChecked(false);
}
void PreviewReportWindow::slotDeleteSelectedItems()
{
m_previewReportWidget->deleteSelectedItems();
}
void PreviewReportWindow::on_actionFit_page_width_triggered()
{
m_previewReportWidget->fitWidth();
@ -439,6 +467,7 @@ void PreviewReportWindow::slotScalePercentChanged(int percent)
void PreviewReportWindow::on_actionShowMessages_toggled(bool value)
{
m_previewReportWidget->setErrorsMesagesVisible(value);
m_previewReportWidget->startInsertTextItem();
}
void PreviewReportWindow::on_actionShow_Toolbar_triggered()
@ -447,7 +476,15 @@ void PreviewReportWindow::on_actionShow_Toolbar_triggered()
writeSetting();
}
void PreviewReportWindow::slotCurrentPageChanged(int page)
{
slotActivateItemSelectionMode();
}
void PreviewReportWindow::slotItemInserted(PageDesignIntf *, QPointF, const QString&)
{
slotActivateItemSelectionMode();
}
}// namespace LimeReport

View File

@ -100,6 +100,9 @@ public slots:
void slotLastPage();
void slotPrintToPDF();
void slotPageChanged(int pageIndex);
void slotInsertNewTextItem();
void slotActivateItemSelectionMode();
void slotDeleteSelectedItems();
private slots:
void on_actionFit_page_width_triggered();
void on_actionFit_page_triggered();
@ -108,6 +111,8 @@ private slots:
void slotScalePercentChanged(int percent);
void on_actionShowMessages_toggled(bool value);
void on_actionShow_Toolbar_triggered();
void slotCurrentPageChanged(int page);
void slotItemInserted(LimeReport::PageDesignIntf* report, QPointF pos, const QString& ItemType);
private:
ItemsReaderIntf* reader();
void initPercentCombobox();

View File

@ -93,6 +93,24 @@
<addaction name="actionClosePreview"/>
<addaction name="actionShowMessages"/>
</widget>
<widget class="QToolBar" name="editModeTools">
<property name="enabled">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>toolBar_2</string>
</property>
<attribute name="toolBarArea">
<enum>LeftToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionSelection_Mode"/>
<addaction name="actionInsertTextItem"/>
<addaction name="separator"/>
<addaction name="actionDelete_Item"/>
</widget>
<action name="actionPrint">
<property name="icon">
<iconset resource="report.qrc">
@ -279,11 +297,55 @@
<string>Show toolbar</string>
</property>
</action>
<action name="actionInsertTextItem">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="items/items.qrc">
<normaloff>:/items/TextItem</normaloff>:/items/TextItem</iconset>
</property>
<property name="text">
<string>InsertTextItem</string>
</property>
<property name="toolTip">
<string>Add new TextItem</string>
</property>
</action>
<action name="actionSelection_Mode">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="report.qrc">
<normaloff>:/report/images/editMode</normaloff>:/report/images/editMode</iconset>
</property>
<property name="text">
<string>Selection Mode</string>
</property>
</action>
<action name="actionDelete_Item">
<property name="icon">
<iconset resource="report.qrc">
<normaloff>:/report/images/delete</normaloff>:/report/images/delete</iconset>
</property>
<property name="text">
<string>Delete Item</string>
</property>
<property name="shortcut">
<string>Del</string>
</property>
</action>
</widget>
<resources>
<include location="report.qrc"/>
<include location="items/items.qrc"/>
<include location="databrowser/lrdatabrowser.qrc"/>
<include location="report.qrc"/>
<include location="items/items.qrc"/>
<include location="databrowser/lrdatabrowser.qrc"/>
</resources>
<connections>
@ -431,6 +493,54 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionInsertTextItem</sender>
<signal>triggered()</signal>
<receiver>LimeReport::PreviewReportWindow</receiver>
<slot>slotInsertNewTextItem()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionSelection_Mode</sender>
<signal>triggered()</signal>
<receiver>LimeReport::PreviewReportWindow</receiver>
<slot>slotActivateItemSelectionMode()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionDelete_Item</sender>
<signal>triggered()</signal>
<receiver>LimeReport::PreviewReportWindow</receiver>
<slot>slotDeleteSelectedItems()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slotNextPage()</slot>
@ -441,5 +551,8 @@
<slot>slotFirstPage()</slot>
<slot>slotLastPage()</slot>
<slot>slotPrintToPDF()</slot>
<slot>slotInsertNewTextItem()</slot>
<slot>slotActivateItemSelectionMode()</slot>
<slot>slotDeleteSelectedItems()</slot>
</slots>
</ui>

View File

@ -155,12 +155,13 @@ QObject *ReportEnginePrivate::elementAt(const QString &, int index)
return pageAt(index);
}
PageDesignIntf *ReportEnginePrivate::createPage(const QString &pageName)
PageDesignIntf *ReportEnginePrivate::createPage(const QString &pageName, bool preview)
{
PageDesignIntf* page =new PageDesignIntf();
page->setObjectName(pageName);
page->pageItem()->setObjectName("Report"+pageName);
page->setReportEditor(this);
if (!preview)
page->setReportEditor(this);
page->setReportSettings(&m_reportSettings);
return page;
}
@ -185,7 +186,7 @@ bool ReportEnginePrivate::deletePage(PageDesignIntf *page){
PageDesignIntf *ReportEnginePrivate::createPreviewPage()
{
return createPage();
return createPage("preview",true);
}
int ReportEnginePrivate::elementsCount(const QString &)

View File

@ -240,7 +240,7 @@ public slots:
bool slotLoadFromFile(const QString& fileName);
void cancelRender();
protected:
PageDesignIntf* createPage(const QString& pageName="");
PageDesignIntf* createPage(const QString& pageName="", bool preview = false);
protected slots:
void slotDataSourceCollectionLoaded(const QString& collectionName);
private slots:

View File

@ -336,7 +336,7 @@ QStringList ScriptEngineManager::functionsNames()
}
void ScriptEngineManager::setDataManager(DataSourceManager *dataManager){
if (m_dataManager != dataManager){
if (dataManager && m_dataManager != dataManager){
m_dataManager = dataManager;
if (m_dataManager){
foreach(QString func, m_dataManager->groupFunctionNames()){

View File

@ -54,14 +54,16 @@ void ScriptEditor::setReportEngine(ReportEnginePrivateInterface* reportEngine)
{
m_reportEngine = reportEngine;
DataSourceManager* dm = m_reportEngine->dataManager();
initEditor(dm);
if (dm) initEditor(dm);
else ui->tabWidget->setVisible(false);
}
void ScriptEditor::setReportPage(PageDesignIntf* page)
{
m_page = page;
DataSourceManager* dm = page->datasourceManager();
initEditor(dm);
if (dm) initEditor(dm);
else ui->tabWidget->setVisible(false);
}
void ScriptEditor::setPageBand(BandDesignIntf* band)