Translations has been fixed

This commit is contained in:
Arin Alexander 2019-07-24 03:13:23 +03:00
parent c498d96862
commit 1a10fc496e
16 changed files with 140 additions and 42 deletions

View File

@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 5 LIMEREPORT_VERSION_MINOR = 5
LIMEREPORT_VERSION_RELEASE = 2 LIMEREPORT_VERSION_RELEASE = 3
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"

View File

@ -500,7 +500,7 @@ void BaseDesignIntf::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
update(); update();
} }
void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent /**event*/)
{ {
m_hovered = true; m_hovered = true;
update(); update();

View File

@ -320,7 +320,7 @@ protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event); void mousePressEvent(QGraphicsSceneMouseEvent* event);
void hoverMoveEvent(QGraphicsSceneHoverEvent* event); void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverEnterEvent(QGraphicsSceneHoverEvent);
void mouseMoveEvent(QGraphicsSceneMouseEvent* event); void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);

View File

@ -176,7 +176,7 @@ public:
bool isOwned() const {return true;} bool isOwned() const {return true;}
bool isEditable() const {return true;} bool isEditable() const {return true;}
bool isRemovable() 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 update(){ updateModel(); }
void clearErrors(){} void clearErrors(){}
private: private:

View File

@ -816,6 +816,7 @@ void PageDesignIntf::slotItemPropertyObjectNameChanged(const QString &oldName, c
if (oldName.compare(newName)!=0 && !m_executingCommand){ if (oldName.compare(newName)!=0 && !m_executingCommand){
CommandIf::Ptr command = PropertyObjectNameChangedCommand::create(this, oldName, newName); CommandIf::Ptr command = PropertyObjectNameChangedCommand::create(this, oldName, newName);
saveCommand(command, false); saveCommand(command, false);
emit itemPropertyObjectNameChanged(oldName, newName);
} }
} }

View File

@ -218,6 +218,7 @@ namespace LimeReport {
const QString& propertyName, const QString& propertyName,
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue); const QVariant& newValue);
void itemPropertyObjectNameChanged(const QString& oldName, const QString& newName);
void itemAdded(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item); void itemAdded(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item);
void itemRemoved(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item); void itemRemoved(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item);
void bandAdded(LimeReport::PageDesignIntf* page, LimeReport::BandDesignIntf* band); void bandAdded(LimeReport::PageDesignIntf* page, LimeReport::BandDesignIntf* band);

View File

@ -360,26 +360,29 @@ QGraphicsView* ReportDesignWidget::activeView(){
void ReportDesignWidget::connectPage(PageDesignIntf *page) void ReportDesignWidget::connectPage(PageDesignIntf *page)
{ {
connect(page,SIGNAL(itemInserted(LimeReport::PageDesignIntf*,QPointF,QString)),this,SIGNAL(itemInserted(LimeReport::PageDesignIntf*,QPointF,QString))); connect(page, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)),
connect(page,SIGNAL(itemInsertCanceled(QString)),this,SIGNAL(itemInsertCanceled(QString))); this, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)));
connect(page,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)),this,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant))); connect(page, SIGNAL(itemInsertCanceled(QString)),this,SIGNAL(itemInsertCanceled(QString)));
connect(page,SIGNAL(selectionChanged()),this,SLOT(slotSelectionChanged())); connect(page, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)),
connect(page,SIGNAL(insertModeStarted()),this,SIGNAL(insertModeStarted())); this, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)));
connect(page,SIGNAL(commandHistoryChanged()),this,SIGNAL(commandHistoryChanged())); connect(page, SIGNAL(itemPropertyObjectNameChanged(QString, QString)),
connect(page,SIGNAL(sceneRectChanged(QRectF)),this,SLOT(slotSceneRectChanged(QRectF))); this, SLOT(slotItemPropertyObjectNameChanged(QString, QString)));
connect(page, SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()));
connect(page,SIGNAL(itemAdded(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)), connect(page, SIGNAL(insertModeStarted()), this, SIGNAL(insertModeStarted()));
this, SIGNAL(itemAdded(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*))); connect(page, SIGNAL(commandHistoryChanged()), this, SIGNAL(commandHistoryChanged()));
connect(page,SIGNAL(itemRemoved(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)), connect(page, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(slotSceneRectChanged(QRectF)));
this,SIGNAL(itemDeleted(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*))); connect(page, SIGNAL(itemAdded(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)),
connect(page,SIGNAL(bandAdded(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)), this, SIGNAL(itemAdded(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)));
this, SIGNAL(bandAdded(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*))); connect(page, SIGNAL(itemRemoved(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)),
connect(page, SIGNAL(bandRemoved(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)), this, SIGNAL(itemDeleted(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)));
this, SIGNAL(bandDeleted(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*))); 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*)), connect(page, SIGNAL(pageUpdateFinished(LimeReport::PageDesignIntf*)),
this, SIGNAL(activePageUpdated(LimeReport::PageDesignIntf*))); this, SIGNAL(activePageUpdated(LimeReport::PageDesignIntf*)));
connect(page->pageItem(), SIGNAL(propertyObjectNameChanged(QString,QString)), connect(page->pageItem(), SIGNAL(propertyObjectNameChanged(QString, QString)),
this, SLOT(slotPagePropertyObjectNameChanged(QString,QString))); this, SLOT(slotPagePropertyObjectNameChanged(QString, QString)));
emit activePageChanged(); emit activePageChanged();
} }
@ -964,6 +967,18 @@ void ReportDesignWidget::slotScriptTextChanged()
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
} }
void ReportDesignWidget::slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName)
{
PageDesignIntf* page = qobject_cast<PageDesignIntf*>(sender());
if (page){
ITranslationContainer* tc = dynamic_cast<ITranslationContainer*>(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 #ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWidget::addNewDialog() void ReportDesignWidget::addNewDialog()
@ -995,6 +1010,11 @@ void ReportDesignWidget::slotDialogNameChanged(QString oldName, QString newName)
void ReportDesignWidget::slotPagePropertyObjectNameChanged(const QString &oldValue, const QString &newValue) void ReportDesignWidget::slotPagePropertyObjectNameChanged(const QString &oldValue, const QString &newValue)
{ {
ITranslationContainer* tc = dynamic_cast<ITranslationContainer*>(report());
foreach(ReportTranslation* translation, tc->translations()->values()){
translation->renamePage(oldValue, newValue);
}
for (int i = 0; i < m_tabWidget->count(); ++i ){ for (int i = 0; i < m_tabWidget->count(); ++i ){
if (m_tabWidget->tabText(i).compare(oldValue) == 0){ if (m_tabWidget->tabText(i).compare(oldValue) == 0){
QGraphicsView* view = dynamic_cast<QGraphicsView*>(m_tabWidget->widget(i)); QGraphicsView* view = dynamic_cast<QGraphicsView*>(m_tabWidget->widget(i));

View File

@ -216,6 +216,7 @@ private slots:
void slotCurrentTabChanged(int index); void slotCurrentTabChanged(int index);
void slotReportLoaded(); void slotReportLoaded();
void slotScriptTextChanged(); void slotScriptTextChanged();
void slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName);
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
void slotDialogChanged(QString); void slotDialogChanged(QString);
void slotDialogNameChanged(QString oldName, QString newName); void slotDialogNameChanged(QString oldName, QString newName);

View File

@ -224,9 +224,11 @@ void ReportEnginePrivate::showError(QString message)
void ReportEnginePrivate::updateTranslations() void ReportEnginePrivate::updateTranslations()
{ {
foreach(ReportTranslation* translation, m_translations.values()){ foreach(ReportTranslation* translation, m_translations.values()){
translation->invalidatePages();
foreach(PageDesignIntf* page, m_pages){ foreach(PageDesignIntf* page, m_pages){
translation->updatePageTranslation(page); translation->updatePageTranslation(page);
} }
translation->clearInvalidPages();
} }
} }
@ -500,7 +502,7 @@ bool ReportEnginePrivate::exportReport(QString exporterName, const QString &file
return false; return false;
} }
bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints) bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter* printer)
{ {
if (pages.count()>0){ if (pages.count()>0){
Q_Q(ReportEngine); Q_Q(ReportEngine);
@ -515,6 +517,7 @@ bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hint
w->setPages(pages); w->setPages(pages);
w->setLayoutDirection(m_previewLayoutDirection); w->setLayoutDirection(m_previewLayoutDirection);
w->setStyleSheet(styleSheet()); w->setStyleSheet(styleSheet());
// w->setDefaultPrinter()
if (!dataManager()->errorsList().isEmpty()){ if (!dataManager()->errorsList().isEmpty()){
w->setErrorMessages(dataManager()->errorsList()); w->setErrorMessages(dataManager()->errorsList());
@ -550,14 +553,13 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
previewReport(0, hints); previewReport(0, hints);
} }
void ReportEnginePrivate::previewReport(QPrinter *printer, PreviewHints hints) void ReportEnginePrivate::previewReport(QPrinter* printer, PreviewHints hints)
{ {
// QTime start = QTime::currentTime();
try{ try{
dataManager()->setDesignTime(false); dataManager()->setDesignTime(false);
ReportPages pages = renderToPages(); ReportPages pages = renderToPages();
dataManager()->setDesignTime(true); dataManager()->setDesignTime(true);
showPreviewWindow(pages, hints); showPreviewWindow(pages, hints, printer);
} catch (ReportError &exception){ } catch (ReportError &exception){
saveError(exception.what()); saveError(exception.what());
showError(exception.what()); showError(exception.what());
@ -980,7 +982,12 @@ IPreparedPages *ReportEnginePrivate::preparedPages(){
bool ReportEnginePrivate::showPreparedPages(PreviewHints hints) 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() bool ReportEnginePrivate::prepareReportPages()

View File

@ -246,6 +246,7 @@ public:
void clearWatermarks(); void clearWatermarks();
IPreparedPages* preparedPages(); IPreparedPages* preparedPages();
bool showPreparedPages(PreviewHints hints); bool showPreparedPages(PreviewHints hints);
bool showPreparedPages(QPrinter *defaultPrinter, PreviewHints hints);
bool prepareReportPages(); bool prepareReportPages();
bool printPreparedPages(); bool printPreparedPages();
signals: signals:
@ -273,7 +274,7 @@ public slots:
void cancelRender(); void cancelRender();
protected: protected:
PageDesignIntf* createPage(const QString& pageName="", bool preview = false); PageDesignIntf* createPage(const QString& pageName="", bool preview = false);
bool showPreviewWindow(ReportPages pages, PreviewHints hints); bool showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter *printer);
protected slots: protected slots:
void slotDataSourceCollectionLoaded(const QString& collectionName); void slotDataSourceCollectionLoaded(const QString& collectionName);
private slots: private slots:

View File

@ -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_currentNameIndex = 0;
m_patternPageItem = patternPage; m_patternPageItem = patternPage;

View File

@ -116,7 +116,7 @@ private:
void initGroups(); void initGroups();
void clearPageMap(); 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); BandDesignIntf* renderBand(BandDesignIntf *patternBand, BandDesignIntf *bandData, DataRenderMode mode = NotStartNewPage, bool isLast = false);
void renderDataBand(BandDesignIntf* dataBand); void renderDataBand(BandDesignIntf* dataBand);
void renderPageHeader(PageItemDesignIntf* patternPage); void renderPageHeader(PageItemDesignIntf* patternPage);

View File

@ -32,6 +32,7 @@ ReportTranslation::~ReportTranslation()
PageTranslation* ReportTranslation::createPageTranslation(PageDesignIntf* page) PageTranslation* ReportTranslation::createPageTranslation(PageDesignIntf* page)
{ {
PageTranslation* pageTranslation = new PageTranslation; PageTranslation* pageTranslation = new PageTranslation;
pageTranslation->checked = true;
pageTranslation->pageName = page->pageItem()->objectName(); pageTranslation->pageName = page->pageItem()->objectName();
foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){ foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){
createItemTranslation(item, pageTranslation); createItemTranslation(item, pageTranslation);
@ -43,6 +44,7 @@ void ReportTranslation::createItemTranslation(BaseDesignIntf* item, PageTranslat
QMap<QString,QString> stringsForTranslation = item->getStringForTranslation(); QMap<QString,QString> stringsForTranslation = item->getStringForTranslation();
if (!stringsForTranslation.isEmpty()){ if (!stringsForTranslation.isEmpty()){
ItemTranslation* itemTranslation = new ItemTranslation; ItemTranslation* itemTranslation = new ItemTranslation;
itemTranslation->checked = true;
itemTranslation->itemName = item->objectName(); itemTranslation->itemName = item->objectName();
foreach(QString propertyName, stringsForTranslation.keys()){ foreach(QString propertyName, stringsForTranslation.keys()){
PropertyTranslation* propertyTranslation = new PropertyTranslation; 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){ foreach(PageTranslation* page, m_pagesTranslation){
if (page->pageName.compare(page_name) == 0){ if (page->pageName.compare(pageName) == 0){
return page; return page;
} }
} }
return 0; 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<PageTranslation*>::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) void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
{ {
PageTranslation* pageTranslation = findPageTranslation(page->pageItem()->objectName()); PageTranslation* pageTranslation = findPageTranslation(page->pageItem()->objectName());
@ -75,6 +103,10 @@ void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
m_pagesTranslation.append(pageTranslation); m_pagesTranslation.append(pageTranslation);
} }
if (pageTranslation){ if (pageTranslation){
pageTranslation->checked = true;
foreach(ItemTranslation* item, pageTranslation->itemsTranslation){
item->checked = false;
}
foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){ foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){
QMap<QString,QString> stringsForTranslation = item->getStringForTranslation(); QMap<QString,QString> stringsForTranslation = item->getStringForTranslation();
if (!stringsForTranslation.isEmpty()){ if (!stringsForTranslation.isEmpty()){
@ -90,15 +122,23 @@ void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
propertyTranslation->sourceValue = stringsForTranslation.value(propertyName); propertyTranslation->sourceValue = stringsForTranslation.value(propertyName);
if (!translated) propertyTranslation->value = propertyTranslation->sourceValue; if (!translated) propertyTranslation->value = propertyTranslation->sourceValue;
} }
itemTranslation->checked = true;
} else { } else {
createItemTranslation(item, pageTranslation); createItemTranslation(item, pageTranslation);
} }
} }
} }
QHash<QString, ItemTranslation*>::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<PageTranslation*> ReportTranslation::pagesTranslation() const QList<PageTranslation*>& ReportTranslation::pagesTranslation()
{ {
return m_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 } //namespace LimeReport

View File

@ -31,6 +31,7 @@ struct PropertyTranslation{
struct ItemTranslation{ struct ItemTranslation{
QString itemName; QString itemName;
bool checked;
PropertyTranslation* findProperty(const QString& propertyName); PropertyTranslation* findProperty(const QString& propertyName);
~ItemTranslation(); ~ItemTranslation();
QList<PropertyTranslation*> propertyesTranslation; QList<PropertyTranslation*> propertyesTranslation;
@ -38,8 +39,10 @@ struct ItemTranslation{
struct PageTranslation{ struct PageTranslation{
QString pageName; QString pageName;
bool checked;
~PageTranslation(); ~PageTranslation();
QHash<QString,ItemTranslation*> itemsTranslation; void renameItem(const QString& oldName, const QString& newName);
QHash<QString, ItemTranslation*> itemsTranslation;
}; };
class ReportTranslation{ class ReportTranslation{
@ -49,12 +52,15 @@ public:
ReportTranslation(const ReportTranslation& reportTranslation); ReportTranslation(const ReportTranslation& reportTranslation);
~ReportTranslation(); ~ReportTranslation();
QLocale::Language language() const; QLocale::Language language() const;
QList<PageTranslation*> pagesTranslation() const; QList<PageTranslation *> &pagesTranslation();
PageTranslation* createEmptyPageTranslation(); PageTranslation* createEmptyPageTranslation();
void updatePageTranslation(PageDesignIntf* page); void updatePageTranslation(PageDesignIntf* page);
PageTranslation* findPageTranslation(const QString& page_name); PageTranslation* findPageTranslation(const QString& pageName);
void createItemTranslation(BaseDesignIntf* item, PageTranslation* pageTranslation); void renamePage(const QString& oldName, const QString& newName);
void invalidatePages();
void clearInvalidPages();
private: private:
void createItemTranslation(BaseDesignIntf* item, PageTranslation* pageTranslation);
PageTranslation* createPageTranslation(PageDesignIntf* page); PageTranslation* createPageTranslation(PageDesignIntf* page);
private: private:
QLocale::Language m_language; QLocale::Language m_language;

View File

@ -11,7 +11,8 @@ namespace LimeReport {
TranslationEditor::TranslationEditor(QWidget *parent) : TranslationEditor::TranslationEditor(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::TranslationEditor), m_translationContainer(0), 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->setupUi(this);
ui->splitter_3->setStretchFactor(1,10); ui->splitter_3->setStretchFactor(1,10);
@ -78,11 +79,10 @@ void TranslationEditor::updateUi()
ui->lvLanguages->addItem(QLocale::languageToString(language)); ui->lvLanguages->addItem(QLocale::languageToString(language));
} }
if (!translations->keys().isEmpty()){ if (!translations->keys().isEmpty()){
if (ui->lvLanguages->count()!=0){ if (ui->lvLanguages->count() != 0){
ui->lvLanguages->item(0)->setSelected(true); ui->lvLanguages->item(0)->setSelected(true);
activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text())); activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text()));
} else { } else {
//activateLanguage(QLocale::AnyLanguage);
ui->twPages->clear(); ui->twPages->clear();
ui->tbStrings->setRowCount(0); ui->tbStrings->setRowCount(0);
} }
@ -93,7 +93,9 @@ void TranslationEditor::updateUi()
void TranslationEditor::activateLanguage(QLocale::Language language) void TranslationEditor::activateLanguage(QLocale::Language language)
{ {
m_translationChanging = true;
ui->teTranslation->setEnabled(false); ui->teTranslation->setEnabled(false);
ui->teTranslation->setPlainText("");
ui->cbChecked->setEnabled(false); ui->cbChecked->setEnabled(false);
ui->twPages->clear(); ui->twPages->clear();
Translations* translations = m_translationContainer->translations(); 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))); activatePage(m_currentReportTranslation->findPageTranslation(ui->twPages->topLevelItem(0)->text(0)));
} }
} }
m_translationChanging = false;
} }
void TranslationEditor::activatePage(PageTranslation* pageTranslation) void TranslationEditor::activatePage(PageTranslation* pageTranslation)
@ -171,13 +174,13 @@ void TranslationEditor::activateTranslation(const QString& itemName, const QStri
void TranslationEditor::on_tbStrings_itemSelectionChanged() 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()); activateTranslation(ui->tbStrings->item(ui->tbStrings->currentRow(),1)->text(), ui->tbStrings->item(ui->tbStrings->currentRow(),2)->text());
} }
void TranslationEditor::on_teTranslation_textChanged() void TranslationEditor::on_teTranslation_textChanged()
{ {
if (m_currentPropertyTranslation) if (m_currentPropertyTranslation && !m_translationChanging)
m_currentPropertyTranslation->value = ui->teTranslation->toPlainText(); m_currentPropertyTranslation->value = ui->teTranslation->toPlainText();
} }
@ -200,16 +203,23 @@ void TranslationEditor::on_tbAddLanguage_clicked()
{ {
LanguageSelectDialog dialog; LanguageSelectDialog dialog;
if (dialog.exec()){ if (dialog.exec()){
m_translationChanging = true;
m_translationContainer->addTranslationLanguage(dialog.getSelectedLanguage()); m_translationContainer->addTranslationLanguage(dialog.getSelectedLanguage());
updateUi(); updateUi();
activateLanguage(dialog.getSelectedLanguage()); 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() void TranslationEditor::on_tbDeleteLanguage_clicked()
{ {
m_translationChanging = true;
m_translationContainer->removeTranslationLanguage(m_currentReportTranslation->language()); m_translationContainer->removeTranslationLanguage(m_currentReportTranslation->language());
updateUi(); updateUi();
m_translationChanging = false;
} }
void TranslationEditor::slotItemChecked() void TranslationEditor::slotItemChecked()

View File

@ -45,6 +45,7 @@ private:
ReportTranslation* m_currentReportTranslation; ReportTranslation* m_currentReportTranslation;
PageTranslation* m_currentPageTranslation; PageTranslation* m_currentPageTranslation;
PropertyTranslation* m_currentPropertyTranslation; PropertyTranslation* m_currentPropertyTranslation;
bool m_translationChanging;
}; };
} //namespace LimeReport } //namespace LimeReport