diff --git a/common.pri b/common.pri
index e6a988c..751d0e8 100644
--- a/common.pri
+++ b/common.pri
@@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 5
-LIMEREPORT_VERSION_RELEASE = 2
+LIMEREPORT_VERSION_RELEASE = 3
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"
diff --git a/limereport/databrowser/lrsqleditdialog.cpp b/limereport/databrowser/lrsqleditdialog.cpp
index d53bc3d..8f613b5 100644
--- a/limereport/databrowser/lrsqleditdialog.cpp
+++ b/limereport/databrowser/lrsqleditdialog.cpp
@@ -278,7 +278,8 @@ void SQLEditDialog::initQueryMode()
ui->cbSubdetail->setChecked(false);
ui->leMaster->setVisible(false);
ui->lbMaster->setVisible(false);
- ui->tabWidget->removeTab(1);
+ //ui->tabWidget->removeTab(1);
+ ui->tabWidget->addTab(ui->csvTab, tr("CSV"));
}
void SQLEditDialog::initSubQueryMode()
@@ -314,7 +315,7 @@ void SQLEditDialog::initProxyMode()
void SQLEditDialog::initCSVMode()
{
- ui->tabWidget->removeTab(0);
+ ui->tabWidget->setCurrentWidget(ui->csvTab);
}
void SQLEditDialog::slotPreviewData()
diff --git a/limereport/databrowser/lrsqleditdialog.ui b/limereport/databrowser/lrsqleditdialog.ui
index f0abfbe..177343d 100644
--- a/limereport/databrowser/lrsqleditdialog.ui
+++ b/limereport/databrowser/lrsqleditdialog.ui
@@ -7,7 +7,7 @@
0
0
422
- 622
+ 646
@@ -183,6 +183,15 @@
+
+
+
+ 0
+ 0
+ 0
+
+
+
@@ -320,6 +329,15 @@
+
+
+
+ 0
+ 0
+ 0
+
+
+
@@ -457,6 +475,15 @@
+
+
+
+ 0
+ 0
+ 0
+
+
+
diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp
index d76f341..71f2f94 100644
--- a/limereport/lrbasedesignintf.cpp
+++ b/limereport/lrbasedesignintf.cpp
@@ -500,7 +500,7 @@ void BaseDesignIntf::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
update();
}
-void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
+void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent /**event*/)
{
m_hovered = true;
update();
diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h
index 462791f..40c4761 100644
--- a/limereport/lrbasedesignintf.h
+++ b/limereport/lrbasedesignintf.h
@@ -320,7 +320,7 @@ protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event);
void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
- void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
+ void hoverEnterEvent(QGraphicsSceneHoverEvent);
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
diff --git a/limereport/lrdatadesignintf.h b/limereport/lrdatadesignintf.h
index 38b9207..c682fc4 100644
--- a/limereport/lrdatadesignintf.h
+++ b/limereport/lrdatadesignintf.h
@@ -176,7 +176,7 @@ public:
bool isOwned() const {return true;}
bool isEditable() const {return true;}
bool isRemovable() const {return true;}
- void invalidate(IDataSource::DatasourceMode mode, bool /*dbWillBeClosed*/){ updateModel();}
+ void invalidate(IDataSource::DatasourceMode /*mode*/, bool /*dbWillBeClosed*/){ updateModel();}
void update(){ updateModel(); }
void clearErrors(){}
private:
diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp
index 720d7bb..bc81b94 100644
--- a/limereport/lrpagedesignintf.cpp
+++ b/limereport/lrpagedesignintf.cpp
@@ -816,6 +816,7 @@ void PageDesignIntf::slotItemPropertyObjectNameChanged(const QString &oldName, c
if (oldName.compare(newName)!=0 && !m_executingCommand){
CommandIf::Ptr command = PropertyObjectNameChangedCommand::create(this, oldName, newName);
saveCommand(command, false);
+ emit itemPropertyObjectNameChanged(oldName, newName);
}
}
diff --git a/limereport/lrpagedesignintf.h b/limereport/lrpagedesignintf.h
index 2ed583c..d94abfe 100644
--- a/limereport/lrpagedesignintf.h
+++ b/limereport/lrpagedesignintf.h
@@ -218,6 +218,7 @@ namespace LimeReport {
const QString& propertyName,
const QVariant& oldValue,
const QVariant& newValue);
+ void itemPropertyObjectNameChanged(const QString& oldName, const QString& newName);
void itemAdded(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item);
void itemRemoved(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item);
void bandAdded(LimeReport::PageDesignIntf* page, LimeReport::BandDesignIntf* band);
diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp
index 12d4116..c7f965e 100644
--- a/limereport/lrreportdesignwidget.cpp
+++ b/limereport/lrreportdesignwidget.cpp
@@ -287,30 +287,31 @@ void ReportDesignWidget::loadState()
applySettings();
}
+PageView* ReportDesignWidget::createPageView(PageDesignIntf* page){
+ PageView* view = new PageView(this);
+ view->setBackgroundBrush(QBrush(Qt::gray));
+ view->setFrameShape(QFrame::NoFrame);
+ view->setScene(page);
+ view->setPageItem(page->pageItem());
+ view->scale(0.5, 0.5);
+ view->centerOn(0, 0);
+ return view;
+}
void ReportDesignWidget::createTabs(){
m_tabWidget->clear();
int pageIndex = -1;
+
for (int i = 0; i < m_report->pageCount(); ++i){
- PageView* view = new PageView(qobject_cast(this));
- view->setBackgroundBrush(QBrush(Qt::gray));
- view->setFrameShape(QFrame::NoFrame);
- view->setScene(m_report->pageAt(i));
- view->setPageItem(m_report->pageAt(i)->pageItem());
-
- m_report->pageAt(i)->clearSelection();
-
- view->centerOn(0,0);
- view->scale(0.5,0.5);
- connectPage(m_report->pageAt(i));
- pageIndex = m_tabWidget->addTab(view,QIcon(),m_report->pageAt(i)->pageItem()->objectName());
+ PageDesignIntf* page = m_report->pageAt(i);
+ page->clearSelection();
+ connectPage(page);
+ PageView* view = createPageView(page);
+ int pageIndex = m_tabWidget->addTab(view, QIcon(), page->pageItem()->objectName());
m_tabWidget->setTabWhatsThis(pageIndex, "page");
- connect(m_report->pageAt(i)->pageItem(), SIGNAL(propertyObjectNameChanged(QString,QString)),
- this, SLOT(slotPagePropertyObjectNameChanged(QString,QString)));
}
m_scriptEditor = new ScriptEditor(this);
-
connect(m_scriptEditor, SIGNAL(textChanged()), this, SLOT(slotScriptTextChanged()));
m_scriptEditor->setReportEngine(m_report);
pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script"));
@@ -359,25 +360,29 @@ QGraphicsView* ReportDesignWidget::activeView(){
void ReportDesignWidget::connectPage(PageDesignIntf *page)
{
- connect(page,SIGNAL(itemInserted(LimeReport::PageDesignIntf*,QPointF,QString)),this,SIGNAL(itemInserted(LimeReport::PageDesignIntf*,QPointF,QString)));
- connect(page,SIGNAL(itemInsertCanceled(QString)),this,SIGNAL(itemInsertCanceled(QString)));
- connect(page,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)),this,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)));
- connect(page,SIGNAL(selectionChanged()),this,SLOT(slotSelectionChanged()));
- connect(page,SIGNAL(insertModeStarted()),this,SIGNAL(insertModeStarted()));
- connect(page,SIGNAL(commandHistoryChanged()),this,SIGNAL(commandHistoryChanged()));
- connect(page,SIGNAL(sceneRectChanged(QRectF)),this,SLOT(slotSceneRectChanged(QRectF)));
-
- connect(page,SIGNAL(itemAdded(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)),
- this, SIGNAL(itemAdded(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)));
- connect(page,SIGNAL(itemRemoved(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)),
- this,SIGNAL(itemDeleted(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)));
- connect(page,SIGNAL(bandAdded(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)),
- this, SIGNAL(bandAdded(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)));
- connect(page, SIGNAL(bandRemoved(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)),
- this, SIGNAL(bandDeleted(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)));
+ connect(page, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)),
+ this, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)));
+ connect(page, SIGNAL(itemInsertCanceled(QString)),this,SIGNAL(itemInsertCanceled(QString)));
+ connect(page, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)),
+ this, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)));
+ connect(page, SIGNAL(itemPropertyObjectNameChanged(QString, QString)),
+ this, SLOT(slotItemPropertyObjectNameChanged(QString, QString)));
+ connect(page, SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()));
+ connect(page, SIGNAL(insertModeStarted()), this, SIGNAL(insertModeStarted()));
+ connect(page, SIGNAL(commandHistoryChanged()), this, SIGNAL(commandHistoryChanged()));
+ connect(page, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(slotSceneRectChanged(QRectF)));
+ connect(page, SIGNAL(itemAdded(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)),
+ this, SIGNAL(itemAdded(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)));
+ connect(page, SIGNAL(itemRemoved(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)),
+ this, SIGNAL(itemDeleted(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)));
+ connect(page, SIGNAL(bandAdded(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)),
+ this, SIGNAL(bandAdded(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)));
+ connect(page, SIGNAL(bandRemoved(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)),
+ this, SIGNAL(bandDeleted(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)));
connect(page, SIGNAL(pageUpdateFinished(LimeReport::PageDesignIntf*)),
this, SIGNAL(activePageUpdated(LimeReport::PageDesignIntf*)));
-
+ connect(page->pageItem(), SIGNAL(propertyObjectNameChanged(QString, QString)),
+ this, SLOT(slotPagePropertyObjectNameChanged(QString, QString)));
emit activePageChanged();
}
@@ -737,19 +742,13 @@ void ReportDesignWidget::printReport()
void ReportDesignWidget::addPage()
{
- QGraphicsView* view = new QGraphicsView(qobject_cast(this));
- view->setBackgroundBrush(QBrush(Qt::gray));
- view->setFrameShape(QFrame::NoFrame);
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(),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);
+ PageView* view = createPageView(page);
+ int index = m_report->pageCount()-1;
+ m_tabWidget->insertTab(index, view, QIcon(), page->pageItem()->objectName());
+ m_tabWidget->setTabWhatsThis(index, "page");
+ m_tabWidget->setCurrentIndex(index);
applyUseGrid();
emit pageAdded(page);
}
@@ -821,9 +820,9 @@ void ReportDesignWidget::editSetting()
void ReportDesignWidget::applyUseGrid()
{
- int hGridStep = m_useGrid?m_horizontalGridStep:2;
- int vGridStep = m_useGrid?m_verticalGridStep:2;
- for(int i=0;ipageCount();++i){
+ int hGridStep = m_useGrid ? m_horizontalGridStep : 2;
+ int vGridStep = m_useGrid ? m_verticalGridStep : 2;
+ for(int i = 0; i < m_report->pageCount(); ++i){
m_report->pageAt(i)->setVerticalGridStep(hGridStep);
m_report->pageAt(i)->setHorizontalGridStep(vGridStep);
}
@@ -968,6 +967,18 @@ void ReportDesignWidget::slotScriptTextChanged()
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
}
+void ReportDesignWidget::slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName)
+{
+ PageDesignIntf* page = qobject_cast(sender());
+ if (page){
+ ITranslationContainer* tc = dynamic_cast(report());
+ for (int i = 0; i < tc->translations()->values().count(); ++i){
+ PageTranslation* pt = tc->translations()->values().at(i)->findPageTranslation(page->pageItem()->objectName());
+ if (pt) pt->renameItem(oldName, newName);
+ }
+ }
+}
+
#ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWidget::addNewDialog()
@@ -999,6 +1010,11 @@ void ReportDesignWidget::slotDialogNameChanged(QString oldName, QString newName)
void ReportDesignWidget::slotPagePropertyObjectNameChanged(const QString &oldValue, const QString &newValue)
{
+ ITranslationContainer* tc = dynamic_cast(report());
+ foreach(ReportTranslation* translation, tc->translations()->values()){
+ translation->renamePage(oldValue, newValue);
+ }
+
for (int i = 0; i < m_tabWidget->count(); ++i ){
if (m_tabWidget->tabText(i).compare(oldValue) == 0){
QGraphicsView* view = dynamic_cast(m_tabWidget->widget(i));
@@ -1071,14 +1087,16 @@ bool PageView::viewportEvent(QEvent *event)
{
switch (event->type()) {
case QEvent::MouseMove:
- m_horizontalRuller->setMousePos(dynamic_cast(event)->pos());
- m_verticalRuller->setMousePos(dynamic_cast(event)->pos());
- m_horizontalRuller->update();
- m_verticalRuller->update();
+ if (m_horizontalRuller && m_verticalRuller){
+ m_horizontalRuller->setMousePos(dynamic_cast(event)->pos());
+ m_verticalRuller->setMousePos(dynamic_cast(event)->pos());
+ m_horizontalRuller->update();
+ m_verticalRuller->update();
+ }
break;
//case QEvent::Resize:
case QEvent::Paint:
- if (m_horizontalRuller){
+ if (m_horizontalRuller && m_verticalRuller){
int x = mapFromScene(m_pageItem->boundingRect().x(),m_pageItem->boundingRect().y()).x();
int y = mapFromScene(m_pageItem->boundingRect().x(),m_pageItem->boundingRect().y()).y();
int width = mapFromScene(m_pageItem->boundingRect().bottomRight().x(),m_pageItem->boundingRect().bottomRight().y()).x();
diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h
index f48879c..4b7248e 100644
--- a/limereport/lrreportdesignwidget.h
+++ b/limereport/lrreportdesignwidget.h
@@ -216,6 +216,7 @@ private slots:
void slotCurrentTabChanged(int index);
void slotReportLoaded();
void slotScriptTextChanged();
+ void slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName);
#ifdef HAVE_QTDESIGNER_INTEGRATION
void slotDialogChanged(QString);
void slotDialogNameChanged(QString oldName, QString newName);
@@ -241,6 +242,7 @@ signals:
void pageAdded(PageDesignIntf* page);
void pageDeleted();
protected:
+ PageView *createPageView(PageDesignIntf *page);
#ifdef HAVE_QTDESIGNER_INTEGRATION
void createNewDialogTab(const QString& dialogName,const QByteArray& description);
#endif
@@ -275,6 +277,7 @@ private:
QMap m_themes;
QMap m_localToEng;
BaseDesignIntf::UnitType m_defaultUnits;
+
};
} // namespace LimeReport
diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp
index 8006745..c07cff4 100644
--- a/limereport/lrreportengine.cpp
+++ b/limereport/lrreportengine.cpp
@@ -224,9 +224,11 @@ void ReportEnginePrivate::showError(QString message)
void ReportEnginePrivate::updateTranslations()
{
foreach(ReportTranslation* translation, m_translations.values()){
+ translation->invalidatePages();
foreach(PageDesignIntf* page, m_pages){
translation->updatePageTranslation(page);
}
+ translation->clearInvalidPages();
}
}
@@ -500,7 +502,7 @@ bool ReportEnginePrivate::exportReport(QString exporterName, const QString &file
return false;
}
-bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints)
+bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter* printer)
{
if (pages.count()>0){
Q_Q(ReportEngine);
@@ -515,6 +517,7 @@ bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hint
w->setPages(pages);
w->setLayoutDirection(m_previewLayoutDirection);
w->setStyleSheet(styleSheet());
+// w->setDefaultPrinter()
if (!dataManager()->errorsList().isEmpty()){
w->setErrorMessages(dataManager()->errorsList());
@@ -550,14 +553,13 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
previewReport(0, hints);
}
-void ReportEnginePrivate::previewReport(QPrinter *printer, PreviewHints hints)
+void ReportEnginePrivate::previewReport(QPrinter* printer, PreviewHints hints)
{
- // QTime start = QTime::currentTime();
try{
dataManager()->setDesignTime(false);
ReportPages pages = renderToPages();
dataManager()->setDesignTime(true);
- showPreviewWindow(pages, hints);
+ showPreviewWindow(pages, hints, printer);
} catch (ReportError &exception){
saveError(exception.what());
showError(exception.what());
@@ -980,7 +982,12 @@ IPreparedPages *ReportEnginePrivate::preparedPages(){
bool ReportEnginePrivate::showPreparedPages(PreviewHints hints)
{
- return showPreviewWindow(m_preparedPages, hints);
+ return showPreparedPages(0, hints);
+}
+
+bool ReportEnginePrivate::showPreparedPages(QPrinter* defaultPrinter, PreviewHints hints)
+{
+ return showPreviewWindow(m_preparedPages, hints, defaultPrinter);
}
bool ReportEnginePrivate::prepareReportPages()
diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h
index 3ffec70..6bdefe6 100644
--- a/limereport/lrreportengine_p.h
+++ b/limereport/lrreportengine_p.h
@@ -246,6 +246,7 @@ public:
void clearWatermarks();
IPreparedPages* preparedPages();
bool showPreparedPages(PreviewHints hints);
+ bool showPreparedPages(QPrinter *defaultPrinter, PreviewHints hints);
bool prepareReportPages();
bool printPreparedPages();
signals:
@@ -273,7 +274,7 @@ public slots:
void cancelRender();
protected:
PageDesignIntf* createPage(const QString& pageName="", bool preview = false);
- bool showPreviewWindow(ReportPages pages, PreviewHints hints);
+ bool showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter *printer);
protected slots:
void slotDataSourceCollectionLoaded(const QString& collectionName);
private slots:
diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp
index ec608fd..f4c7944 100644
--- a/limereport/lrreportrender.cpp
+++ b/limereport/lrreportrender.cpp
@@ -189,7 +189,7 @@ void ReportRender::initDatasource(const QString& name){
}
}
-void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool isFirst, bool resetPageNumbers)
+void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool /*isFirst*/, bool /*resetPageNumbers*/)
{
m_currentNameIndex = 0;
m_patternPageItem = patternPage;
diff --git a/limereport/lrreportrender.h b/limereport/lrreportrender.h
index d31efce..dabaa79 100644
--- a/limereport/lrreportrender.h
+++ b/limereport/lrreportrender.h
@@ -116,7 +116,7 @@ private:
void initGroups();
void clearPageMap();
- void renderPage(PageItemDesignIntf *patternPage, bool isTOC = false, bool isFirst = false, bool resetPageNumbers = false);
+ void renderPage(PageItemDesignIntf *patternPage, bool isTOC = false, bool isFirst = false, bool = false);
BandDesignIntf* renderBand(BandDesignIntf *patternBand, BandDesignIntf *bandData, DataRenderMode mode = NotStartNewPage, bool isLast = false);
void renderDataBand(BandDesignIntf* dataBand);
void renderPageHeader(PageItemDesignIntf* patternPage);
diff --git a/limereport/lrreporttranslation.cpp b/limereport/lrreporttranslation.cpp
index aa6cfdd..d25b0d5 100644
--- a/limereport/lrreporttranslation.cpp
+++ b/limereport/lrreporttranslation.cpp
@@ -32,6 +32,7 @@ ReportTranslation::~ReportTranslation()
PageTranslation* ReportTranslation::createPageTranslation(PageDesignIntf* page)
{
PageTranslation* pageTranslation = new PageTranslation;
+ pageTranslation->checked = true;
pageTranslation->pageName = page->pageItem()->objectName();
foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){
createItemTranslation(item, pageTranslation);
@@ -43,6 +44,7 @@ void ReportTranslation::createItemTranslation(BaseDesignIntf* item, PageTranslat
QMap stringsForTranslation = item->getStringForTranslation();
if (!stringsForTranslation.isEmpty()){
ItemTranslation* itemTranslation = new ItemTranslation;
+ itemTranslation->checked = true;
itemTranslation->itemName = item->objectName();
foreach(QString propertyName, stringsForTranslation.keys()){
PropertyTranslation* propertyTranslation = new PropertyTranslation;
@@ -57,16 +59,42 @@ void ReportTranslation::createItemTranslation(BaseDesignIntf* item, PageTranslat
}
}
-PageTranslation* ReportTranslation::findPageTranslation(const QString& page_name)
+PageTranslation* ReportTranslation::findPageTranslation(const QString& pageName)
{
foreach(PageTranslation* page, m_pagesTranslation){
- if (page->pageName.compare(page_name) == 0){
+ if (page->pageName.compare(pageName) == 0){
return page;
}
}
return 0;
}
+void ReportTranslation::renamePage(const QString &oldName, const QString &newName)
+{
+ PageTranslation* page = findPageTranslation(oldName);
+ if (page){
+ page->pageName = newName;
+ }
+}
+
+void ReportTranslation::invalidatePages()
+{
+ foreach(PageTranslation* page, m_pagesTranslation){
+ page->checked = false;
+ }
+}
+
+void ReportTranslation::clearInvalidPages()
+{
+ QList::Iterator it = m_pagesTranslation.begin();
+ while (it != m_pagesTranslation.end()){
+ if (!(*it)->checked){
+ delete *it;
+ it = m_pagesTranslation.erase(it);
+ } else ++it;
+ }
+}
+
void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
{
PageTranslation* pageTranslation = findPageTranslation(page->pageItem()->objectName());
@@ -75,6 +103,10 @@ void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
m_pagesTranslation.append(pageTranslation);
}
if (pageTranslation){
+ pageTranslation->checked = true;
+ foreach(ItemTranslation* item, pageTranslation->itemsTranslation){
+ item->checked = false;
+ }
foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){
QMap stringsForTranslation = item->getStringForTranslation();
if (!stringsForTranslation.isEmpty()){
@@ -90,15 +122,23 @@ void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
propertyTranslation->sourceValue = stringsForTranslation.value(propertyName);
if (!translated) propertyTranslation->value = propertyTranslation->sourceValue;
}
+ itemTranslation->checked = true;
} else {
createItemTranslation(item, pageTranslation);
}
}
}
+ QHash::Iterator it = pageTranslation->itemsTranslation.begin();
+ while( it != pageTranslation->itemsTranslation.end()){
+ if (!it.value()->checked) {
+ delete it.value();
+ it = pageTranslation->itemsTranslation.erase(it);
+ } else ++it;
+ }
}
}
-QList ReportTranslation::pagesTranslation() const
+QList& ReportTranslation::pagesTranslation()
{
return m_pagesTranslation;
}
@@ -139,4 +179,14 @@ PageTranslation::~PageTranslation()
}
}
+void PageTranslation::renameItem(const QString &oldName, const QString &newName)
+{
+ ItemTranslation* item = itemsTranslation.value(oldName);
+ if (item){
+ itemsTranslation.remove(oldName);
+ item->itemName = newName;
+ itemsTranslation[newName] = item;
+ }
+}
+
} //namespace LimeReport
diff --git a/limereport/lrreporttranslation.h b/limereport/lrreporttranslation.h
index 3c7b376..c9b82a2 100644
--- a/limereport/lrreporttranslation.h
+++ b/limereport/lrreporttranslation.h
@@ -31,6 +31,7 @@ struct PropertyTranslation{
struct ItemTranslation{
QString itemName;
+ bool checked;
PropertyTranslation* findProperty(const QString& propertyName);
~ItemTranslation();
QList propertyesTranslation;
@@ -38,8 +39,10 @@ struct ItemTranslation{
struct PageTranslation{
QString pageName;
+ bool checked;
~PageTranslation();
- QHash itemsTranslation;
+ void renameItem(const QString& oldName, const QString& newName);
+ QHash itemsTranslation;
};
class ReportTranslation{
@@ -49,12 +52,15 @@ public:
ReportTranslation(const ReportTranslation& reportTranslation);
~ReportTranslation();
QLocale::Language language() const;
- QList pagesTranslation() const;
+ QList &pagesTranslation();
PageTranslation* createEmptyPageTranslation();
void updatePageTranslation(PageDesignIntf* page);
- PageTranslation* findPageTranslation(const QString& page_name);
- void createItemTranslation(BaseDesignIntf* item, PageTranslation* pageTranslation);
+ PageTranslation* findPageTranslation(const QString& pageName);
+ void renamePage(const QString& oldName, const QString& newName);
+ void invalidatePages();
+ void clearInvalidPages();
private:
+ void createItemTranslation(BaseDesignIntf* item, PageTranslation* pageTranslation);
PageTranslation* createPageTranslation(PageDesignIntf* page);
private:
QLocale::Language m_language;
diff --git a/limereport/translationeditor/translationeditor.cpp b/limereport/translationeditor/translationeditor.cpp
index d792d67..c686258 100644
--- a/limereport/translationeditor/translationeditor.cpp
+++ b/limereport/translationeditor/translationeditor.cpp
@@ -11,7 +11,8 @@ namespace LimeReport {
TranslationEditor::TranslationEditor(QWidget *parent) :
QWidget(parent),
ui(new Ui::TranslationEditor), m_translationContainer(0),
- m_currentReportTranslation(0), m_currentPageTranslation(0), m_currentPropertyTranslation(0)
+ m_currentReportTranslation(0), m_currentPageTranslation(0),
+ m_currentPropertyTranslation(0), m_translationChanging(false)
{
ui->setupUi(this);
ui->splitter_3->setStretchFactor(1,10);
@@ -78,11 +79,10 @@ void TranslationEditor::updateUi()
ui->lvLanguages->addItem(QLocale::languageToString(language));
}
if (!translations->keys().isEmpty()){
- if (ui->lvLanguages->count()!=0){
+ if (ui->lvLanguages->count() != 0){
ui->lvLanguages->item(0)->setSelected(true);
activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text()));
} else {
- //activateLanguage(QLocale::AnyLanguage);
ui->twPages->clear();
ui->tbStrings->setRowCount(0);
}
@@ -93,7 +93,9 @@ void TranslationEditor::updateUi()
void TranslationEditor::activateLanguage(QLocale::Language language)
{
+ m_translationChanging = true;
ui->teTranslation->setEnabled(false);
+ ui->teTranslation->setPlainText("");
ui->cbChecked->setEnabled(false);
ui->twPages->clear();
Translations* translations = m_translationContainer->translations();
@@ -113,6 +115,7 @@ void TranslationEditor::activateLanguage(QLocale::Language language)
activatePage(m_currentReportTranslation->findPageTranslation(ui->twPages->topLevelItem(0)->text(0)));
}
}
+ m_translationChanging = false;
}
void TranslationEditor::activatePage(PageTranslation* pageTranslation)
@@ -171,13 +174,13 @@ void TranslationEditor::activateTranslation(const QString& itemName, const QStri
void TranslationEditor::on_tbStrings_itemSelectionChanged()
{
- if (m_currentPageTranslation)
+ if (m_currentPageTranslation && !m_translationChanging)
activateTranslation(ui->tbStrings->item(ui->tbStrings->currentRow(),1)->text(), ui->tbStrings->item(ui->tbStrings->currentRow(),2)->text());
}
void TranslationEditor::on_teTranslation_textChanged()
{
- if (m_currentPropertyTranslation)
+ if (m_currentPropertyTranslation && !m_translationChanging)
m_currentPropertyTranslation->value = ui->teTranslation->toPlainText();
}
@@ -200,16 +203,23 @@ void TranslationEditor::on_tbAddLanguage_clicked()
{
LanguageSelectDialog dialog;
if (dialog.exec()){
+ m_translationChanging = true;
m_translationContainer->addTranslationLanguage(dialog.getSelectedLanguage());
updateUi();
activateLanguage(dialog.getSelectedLanguage());
+ foreach (QListWidgetItem* item, ui->lvLanguages->findItems(QLocale::languageToString(dialog.getSelectedLanguage()), Qt::MatchExactly)){
+ item->setSelected(true);
+ }
+ m_translationChanging = false;
}
}
void TranslationEditor::on_tbDeleteLanguage_clicked()
{
+ m_translationChanging = true;
m_translationContainer->removeTranslationLanguage(m_currentReportTranslation->language());
updateUi();
+ m_translationChanging = false;
}
void TranslationEditor::slotItemChecked()
diff --git a/limereport/translationeditor/translationeditor.h b/limereport/translationeditor/translationeditor.h
index a270eb4..48fbb0b 100644
--- a/limereport/translationeditor/translationeditor.h
+++ b/limereport/translationeditor/translationeditor.h
@@ -45,6 +45,7 @@ private:
ReportTranslation* m_currentReportTranslation;
PageTranslation* m_currentPageTranslation;
PropertyTranslation* m_currentPropertyTranslation;
+ bool m_translationChanging;
};
} //namespace LimeReport