mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-23 20:22:58 +03:00
Finished add new text item in preview mode
This commit is contained in:
parent
a84d1e0f36
commit
c6c5e2b206
@ -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);
|
||||
|
@ -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<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)
|
||||
@ -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<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){
|
||||
@ -396,14 +429,13 @@ void PreviewReportWidget::slotSliderMoved(int value)
|
||||
}
|
||||
}
|
||||
|
||||
if (curPage != d_ptr->m_currentPage){
|
||||
d_ptr->m_changingPage = true;
|
||||
emit pageChanged(d_ptr->m_currentPage);
|
||||
|
||||
PageDesignIntf* page = dynamic_cast<PageDesignIntf*>(ui->graphicsView->scene());
|
||||
if (page)
|
||||
page->setCurrentPage(d_ptr->currentPage().data());
|
||||
|
||||
activateCurrentPage();
|
||||
d_ptr->m_changingPage = false;
|
||||
}
|
||||
|
||||
d_ptr->m_priorScrolValue = value;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -22,6 +22,8 @@ public:
|
||||
PageItemDesignIntf::Ptr currentPage();
|
||||
QList<QString> aviableExporters();
|
||||
void startInsertTextItem();
|
||||
void activateItemSelectionMode();
|
||||
void deleteSelectedItems();
|
||||
public:
|
||||
PageDesignIntf* m_previewPage;
|
||||
ReportPages m_reportPages;
|
||||
|
@ -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<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");
|
||||
@ -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
|
||||
|
||||
|
@ -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();
|
||||
|
@ -35,7 +35,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>22</height>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuView">
|
||||
@ -106,7 +106,10 @@
|
||||
<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">
|
||||
@ -295,6 +298,9 @@
|
||||
</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>
|
||||
@ -306,6 +312,33 @@
|
||||
<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"/>
|
||||
@ -476,6 +509,38 @@
|
||||
</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>
|
||||
@ -487,5 +552,7 @@
|
||||
<slot>slotLastPage()</slot>
|
||||
<slot>slotPrintToPDF()</slot>
|
||||
<slot>slotInsertNewTextItem()</slot>
|
||||
<slot>slotActivateItemSelectionMode()</slot>
|
||||
<slot>slotDeleteSelectedItems()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user