diff --git a/include/lrpreviewreportwidget.h b/include/lrpreviewreportwidget.h index faa26c7..e7ff76e 100644 --- a/include/lrpreviewreportwidget.h +++ b/include/lrpreviewreportwidget.h @@ -15,6 +15,7 @@ class PreviewReportWidget; class PreviewReportWidgetPrivate; class ReportEnginePrivate; class ReportEngine; +class PageDesignIntf; class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget { @@ -35,6 +36,10 @@ public: QPrinter *defaultPrinter() const; void setDefaultPrinter(QPrinter *defaultPrinter); void startInsertTextItem(); + void activateItemSelectionMode(); + void deleteSelectedItems(); + void activateCurrentPage(); + public slots: void refreshPages(); void zoomIn(); @@ -58,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); diff --git a/limereport/lrpreviewreportwidget.cpp b/limereport/lrpreviewreportwidget.cpp index 0ba6426..328eb1f 100644 --- a/limereport/lrpreviewreportwidget.cpp +++ b/limereport/lrpreviewreportwidget.cpp @@ -53,6 +53,7 @@ void PreviewReportWidgetPrivate::setPages(ReportPages pages) m_changingPage = false; q_ptr->initPreview(); q_ptr->emitPageSet(); + q_ptr->activateCurrentPage(); } } @@ -73,6 +74,16 @@ 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)), @@ -135,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(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) @@ -342,6 +357,16 @@ 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; @@ -380,8 +405,16 @@ void PreviewReportWidget::refreshPages() } } +void PreviewReportWidget::activateCurrentPage() +{ + PageDesignIntf* page = dynamic_cast(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){ @@ -396,14 +429,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; + } - PageDesignIntf* page = dynamic_cast(ui->graphicsView->scene()); - if (page) - page->setCurrentPage(d_ptr->currentPage().data()); - - d_ptr->m_changingPage = false; d_ptr->m_priorScrolValue = value; } diff --git a/limereport/lrpreviewreportwidget.h b/limereport/lrpreviewreportwidget.h index faa26c7..e7ff76e 100644 --- a/limereport/lrpreviewreportwidget.h +++ b/limereport/lrpreviewreportwidget.h @@ -15,6 +15,7 @@ class PreviewReportWidget; class PreviewReportWidgetPrivate; class ReportEnginePrivate; class ReportEngine; +class PageDesignIntf; class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget { @@ -35,6 +36,10 @@ public: QPrinter *defaultPrinter() const; void setDefaultPrinter(QPrinter *defaultPrinter); void startInsertTextItem(); + void activateItemSelectionMode(); + void deleteSelectedItems(); + void activateCurrentPage(); + public slots: void refreshPages(); void zoomIn(); @@ -58,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); diff --git a/limereport/lrpreviewreportwidget_p.h b/limereport/lrpreviewreportwidget_p.h index dba8bd8..d7dc719 100644 --- a/limereport/lrpreviewreportwidget_p.h +++ b/limereport/lrpreviewreportwidget_p.h @@ -22,6 +22,8 @@ public: PageItemDesignIntf::Ptr currentPage(); QList aviableExporters(); void startInsertTextItem(); + void activateItemSelectionMode(); + void deleteSelectedItems(); public: PageDesignIntf* m_previewPage; ReportPages m_reportPages; diff --git a/limereport/lrpreviewreportwindow.cpp b/limereport/lrpreviewreportwindow.cpp index 0e6c4cc..7d01c0c 100644 --- a/limereport/lrpreviewreportwindow.cpp +++ b/limereport/lrpreviewreportwindow.cpp @@ -82,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(); } @@ -110,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(screenWidth*0.1); + int y = static_cast(screenHeight*0.1); - resize(screenWidth*0.8, screenHeight*0.8); + resize( + static_cast(screenWidth*0.8), + static_cast(screenHeight*0.8) + ); move(x, y); } v = settings()->value("State"); @@ -410,6 +416,19 @@ void PreviewReportWindow::slotPageChanged(int 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() @@ -457,5 +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 diff --git a/limereport/lrpreviewreportwindow.h b/limereport/lrpreviewreportwindow.h index 2104669..992a34d 100644 --- a/limereport/lrpreviewreportwindow.h +++ b/limereport/lrpreviewreportwindow.h @@ -101,6 +101,8 @@ public slots: 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(); @@ -109,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(); diff --git a/limereport/lrpreviewreportwindow.ui b/limereport/lrpreviewreportwindow.ui index 23550ec..8ce8873 100644 --- a/limereport/lrpreviewreportwindow.ui +++ b/limereport/lrpreviewreportwindow.ui @@ -35,7 +35,7 @@ 0 0 800 - 22 + 20 @@ -106,7 +106,10 @@ false + + + @@ -295,6 +298,9 @@ + + true + :/items/TextItem:/items/TextItem @@ -306,6 +312,33 @@ Add new TextItem + + + true + + + true + + + + :/report/images/editMode:/report/images/editMode + + + Selection Mode + + + + + + :/report/images/delete:/report/images/delete + + + Delete Item + + + Del + + @@ -476,6 +509,38 @@ + + actionSelection_Mode + triggered() + LimeReport::PreviewReportWindow + slotActivateItemSelectionMode() + + + -1 + -1 + + + 399 + 299 + + + + + actionDelete_Item + triggered() + LimeReport::PreviewReportWindow + slotDeleteSelectedItems() + + + -1 + -1 + + + 399 + 299 + + + slotNextPage() @@ -487,5 +552,7 @@ slotLastPage() slotPrintToPDF() slotInsertNewTextItem() + slotActivateItemSelectionMode() + slotDeleteSelectedItems()