diff --git a/common.pri b/common.pri index ebe5250..1e0d2bd 100644 --- a/common.pri +++ b/common.pri @@ -69,7 +69,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}\" diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index ce6a6fa..738dedc 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -59,6 +59,9 @@ ReportDesignWidget::ReportDesignWidget(ReportEngine *report, QMainWindow *mainWi { 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); @@ -631,8 +634,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); @@ -811,6 +816,33 @@ void ReportDesignWidget::slotDialogNameChanged(QString oldName, QString newName) #endif +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 9ae27ed..4d3b25d 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -159,6 +159,8 @@ private slots: void slotDialogChanged(QString); void slotDialogNameChanged(QString oldName, QString newName); #endif + 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 50d1d48..5fb5de5 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -112,6 +112,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; @@ -765,6 +766,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::addTranslationLanguage(QLocale::Language language) { if (!m_translations.keys().contains(language)){ diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index c8d6307..52c3aa1 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -136,6 +136,7 @@ public: bool setReportLanguage(QLocale::Language language); QList aviableLanguages(); ReportTranslation* reportTranslation(QLocale::Language language); + void reorderPages(const QList &reorderedPages); signals: void pagesLoadFinished(); void datasourceCollectionLoadFinished(const QString& collectionName);