From 97d61335e55d7fd8f5fb096a7e04cb259fd49eb1 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Sat, 19 Aug 2017 01:16:55 +0400 Subject: [PATCH 1/2] Pages reordering has been added --- limereport/lrreportdesignwidget.cpp | 38 +++++++++++++++++++++++++++-- limereport/lrreportdesignwidget.h | 2 ++ limereport/lrreportengine.cpp | 9 +++++++ limereport/lrreportengine_p.h | 2 +- 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index 9e22238..65fef1c 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -53,6 +53,9 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow { m_tabWidget = new QTabWidget(this); m_tabWidget->setTabPosition(QTabWidget::South); + m_tabWidget->setMovable(true); + connect(m_tabWidget->tabBar(), SIGNAL(tabMoved(int,int)), this, SLOT(slotTabMoved(int,int))); + QVBoxLayout* mainLayout = new QVBoxLayout(this); mainLayout->addWidget(m_tabWidget); setLayout(mainLayout); @@ -152,7 +155,9 @@ void ReportDesignWidget::createTabs(){ view->centerOn(0,0); view->scale(0.5,0.5); connectPage(m_report->pageAt(i)); - m_tabWidget->addTab(view,QIcon(),tr("Page")+QString::number(i+1)); + m_tabWidget->addTab(view,QIcon(),m_report->pageAt(i)->pageItem()->objectName()); + connect(m_report->pageAt(i)->pageItem(), SIGNAL(propertyObjectNameChanged(QString,QString)), + this, SLOT(slotPagePropertyObjectNameChanged(QString,QString))); } m_scriptEditor = new QTextEdit(this); m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script")); @@ -476,8 +481,10 @@ void ReportDesignWidget::addPage() 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(),tr("Page")+QString::number(m_report->pageCount())); + 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); view->scale(0.5,0.5); view->centerOn(0,0); @@ -608,6 +615,33 @@ void ReportDesignWidget::slotCurrentTabChanged(int index) emit activePageChanged(); } +void ReportDesignWidget::slotPagePropertyObjectNameChanged(const QString &oldValue, const QString &newValue) +{ + for (int i = 0; i < m_tabWidget->count(); ++i ){ + if (m_tabWidget->tabText(i).compare(oldValue) == 0){ + m_tabWidget->setTabText(i, newValue); + } + } +} + +void ReportDesignWidget::slotTabMoved(int from, int to) +{ + QList pages; + + for ( int i = 0; i < m_tabWidget->tabBar()->count(); ++i){ + QGraphicsView* view = dynamic_cast(m_tabWidget->widget(i)); + if (view){ + PageDesignIntf* page = dynamic_cast(view->scene()); + if (page){ + pages.append(page); + } + } + } + + m_report->reorderPages(pages); + +} + bool ReportDesignWidget::eventFilter(QObject *target, QEvent *event) { if (event->type() == QEvent::Wheel){ diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index 28a1998..0e55b78 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -128,6 +128,8 @@ private slots: void slotDatasourceCollectionLoaded(const QString&); void slotSceneRectChanged(QRectF); void slotCurrentTabChanged(int index); + void slotPagePropertyObjectNameChanged(const QString& oldValue, const QString& newValue); + void slotTabMoved(int from, int to); signals: void insertModeStarted(); void itemInserted(LimeReport::PageDesignIntf*,QPointF,const QString&); diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index b89ee3c..ddb90ac 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -106,6 +106,7 @@ PageDesignIntf *ReportEnginePrivate::createPage(const QString &pageName) { PageDesignIntf* page =new PageDesignIntf(); page->setObjectName(pageName); + page->pageItem()->setObjectName("Report"+pageName); page->setReportEditor(this); page->setReportSettings(&m_reportSettings); return page; @@ -719,6 +720,14 @@ void ReportEnginePrivate::setPassPhrase(const QString &passPhrase) m_passPhrase = passPhrase; } +void ReportEnginePrivate::reorderPages(const QList& reorderedPages) +{ + m_pages.clear(); + foreach(PageDesignIntf* page, reorderedPages){ + m_pages.append(page); + } +} + bool ReportEnginePrivate::resultIsEditable() const { return m_resultIsEditable; diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index ade298e..76987e3 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -128,7 +128,7 @@ public: void setResultEditable(bool value); void setPassPhrase(const QString &passPhrase); - + void reorderPages(const QList &reorderedPages); signals: void pagesLoadFinished(); void datasourceCollectionLoadFinished(const QString& collectionName); From 2b94bad1c02a82a280d11119f17398716795504f Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Sat, 19 Aug 2017 01:18:09 +0400 Subject: [PATCH 2/2] version 1.39 --- common.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.pri b/common.pri index b371859..52d82ec 100644 --- a/common.pri +++ b/common.pri @@ -62,7 +62,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 4 -LIMEREPORT_VERSION_RELEASE = 38 +LIMEREPORT_VERSION_RELEASE = 39 LIMEREPORT_VERSION = '\\"$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}\\"' DEFINES += LIMEREPORT_VERSION_STR=\"$${LIMEREPORT_VERSION}\"