From 8c5a9fcd918a0a7d083a826f608f8b69fa487ed2 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Sat, 5 Aug 2017 01:38:19 +0300 Subject: [PATCH] Translation has been updated --- include/lrreportengine.h | 1 + limereport/limereport.pri | 11 +- limereport/limereport.pro | 1 - limereport/lrreportdesignwidget.cpp | 10 +- limereport/lrreportdesignwidget.h | 5 +- limereport/lrreportengine.cpp | 17 +- limereport/lrreportengine.h | 1 + limereport/lrreportengine_p.h | 2 +- limereport/lrreporttranslation.cpp | 91 +++++++- limereport/lrreporttranslation.h | 14 +- limereport/serializators/lrxmlreader.cpp | 16 +- limereport/serializators/lrxmlwriter.cpp | 12 +- limereport/translationeditor/images/add.png | Bin 0 -> 655 bytes .../translationeditor/images/checked.png | Bin 0 -> 265 bytes .../translationeditor/images/green_check.png | Bin 0 -> 1347 bytes .../translationeditor/images/question.png | Bin 0 -> 542 bytes .../translationeditor/images/remove.png | Bin 0 -> 867 bytes .../translationeditor/translationeditor.cpp | 165 ++++++++++++++ .../translationeditor/translationeditor.h | 45 ++++ .../translationeditor/translationeditor.qrc | 8 + .../translationeditor/translationeditor.ui | 214 ++++++++++++++++++ 21 files changed, 575 insertions(+), 38 deletions(-) create mode 100644 limereport/translationeditor/images/add.png create mode 100644 limereport/translationeditor/images/checked.png create mode 100644 limereport/translationeditor/images/green_check.png create mode 100644 limereport/translationeditor/images/question.png create mode 100644 limereport/translationeditor/images/remove.png create mode 100644 limereport/translationeditor/translationeditor.cpp create mode 100644 limereport/translationeditor/translationeditor.h create mode 100644 limereport/translationeditor/translationeditor.qrc create mode 100644 limereport/translationeditor/translationeditor.ui diff --git a/include/lrreportengine.h b/include/lrreportengine.h index 64f01bb..f785713 100644 --- a/include/lrreportengine.h +++ b/include/lrreportengine.h @@ -72,6 +72,7 @@ class LIMEREPORT_EXPORT ReportEngine : public QObject{ Q_OBJECT friend class ReportDesignWidget; friend class PreviewReportWidget; + friend class TranslationEditor; public: static void setSettings(QSettings *value){m_settings=value;} public: diff --git a/limereport/limereport.pri b/limereport/limereport.pri index cf5c18e..2f91286 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -72,6 +72,7 @@ SOURCES += \ $$REPORT_PATH/items/lrtextitemeditor.cpp \ $$REPORT_PATH/items/lrshapeitem.cpp \ $$REPORT_PATH/items/lrtextitem.cpp \ + $$REPORT_PATH/translationeditor/translationeditor.cpp \ $$REPORT_PATH/lrbanddesignintf.cpp \ $$REPORT_PATH/lrpageitemdesignintf.cpp \ $$REPORT_PATH/lrpagedesignintf.cpp \ @@ -172,6 +173,7 @@ HEADERS += \ $$REPORT_PATH/items/lrshapeitem.h \ $$REPORT_PATH/items/lrimageitem.h \ $$REPORT_PATH/items/lrsimpletagparser.h \ + $$REPORT_PATH/translationeditor/translationeditor.h \ $$REPORT_PATH/lrfactoryinitializer.h \ $$REPORT_PATH/lrbanddesignintf.h \ $$REPORT_PATH/lrpageitemdesignintf.h \ @@ -204,7 +206,7 @@ HEADERS += \ $$REPORT_PATH/lrsettingdialog.h \ $$REPORT_PATH/lrpreviewreportwidget_p.h \ $$REPORT_PATH/lritemscontainerdesignitf.h \ - $$REPORT_PATH/lrcolorindicator.h \ + $$REPORT_PATH/lrcolorindicator.h \ $$REPORT_PATH/items/lrchartitem.h \ $$REPORT_PATH/items/lrchartitemeditor.h \ $$REPORT_PATH/lrreporttranslation.h @@ -229,12 +231,13 @@ FORMS += \ $$REPORT_PATH/lraboutdialog.ui \ $$REPORT_PATH/lrsettingdialog.ui \ $$REPORT_PATH/scriptbrowser/lrscriptbrowser.ui \ - $$REPORT_PATH/items/lrchartitemeditor.ui + $$REPORT_PATH/items/lrchartitemeditor.ui \ + $$REPORT_PATH/translationeditor/translationeditor.ui RESOURCES += \ $$REPORT_PATH/objectinspector/lobjectinspector.qrc \ $$REPORT_PATH/databrowser/lrdatabrowser.qrc \ $$REPORT_PATH/report.qrc \ $$REPORT_PATH/items/items.qrc \ - $$REPORT_PATH/scriptbrowser/lrscriptbrowser.qrc - + $$REPORT_PATH/scriptbrowser/lrscriptbrowser.qrc \ + $$REPORT_PATH/translationeditor/translationeditor.qrc diff --git a/limereport/limereport.pro b/limereport/limereport.pro index 6f4e488..7d45253 100644 --- a/limereport/limereport.pro +++ b/limereport/limereport.pro @@ -86,7 +86,6 @@ contains(CONFIG,zint){ } } -####### ####Automatically build required translation files (*.qm) contains(CONFIG,build_translations){ diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index b082273..ce6a6fa 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -34,6 +34,7 @@ #include "lrbasedesignintf.h" #include "lrsettingdialog.h" #include "dialogdesigner/lrdialogdesigner.h" +#include "translationeditor/translationeditor.h" #include #include @@ -137,6 +138,7 @@ ReportDesignWidget::EditorTabType ReportDesignWidget::activeTabType() QString tabType = m_tabWidget->tabWhatsThis(m_tabWidget->currentIndex()); if ( tabType.compare("dialog") == 0) return Dialog; if ( tabType.compare("script") == 0) return Script; + if ( tabType.compare("translations") == 0) return Translations; return Page; } @@ -245,10 +247,13 @@ void ReportDesignWidget::createTabs(){ dialogDesigner = m_dialogDesignerManager->createFormEditor(dialogDesc->description()); pageIndex = m_tabWidget->addTab(dialogDesigner,QIcon(),dialogDesc->name()); m_tabWidget->setTabWhatsThis(pageIndex,"dialog"); - } #endif + m_traslationEditor = new TranslationEditor(this); + pageIndex = m_tabWidget->addTab(m_traslationEditor,QIcon(),tr("Translations")); + m_tabWidget->setTabWhatsThis(pageIndex,"translations"); + } #ifdef HAVE_QTDESIGNER_INTEGRATION @@ -771,6 +776,9 @@ void ReportDesignWidget::slotCurrentTabChanged(int index) } updateDialogs(); #endif + if (activeTabType() == Translations){ + m_traslationEditor->setReportEngine(report()); + } emit activePageChanged(); } diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index 82717af..9ae27ed 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -50,6 +50,7 @@ class DataBrowser; class ReportDesignWindow; class DialogDesignerManager; class DialogDesigner; +class TranslationEditor; class ReportDesignWidget : public QWidget { @@ -67,7 +68,8 @@ public: enum EditorTabType{ Page, Dialog, - Script + Script, + Translations }; ReportDesignWidget(ReportEngine* report, QMainWindow *mainWindow, QWidget *parent = 0); ~ReportDesignWidget(); @@ -186,6 +188,7 @@ private: ReportEnginePrivate* m_report; QGraphicsView *m_view; QTextEdit* m_scriptEditor; + TranslationEditor* m_traslationEditor; #ifdef HAVE_QTDESIGNER_INTEGRATION DialogDesignerManager* m_dialogDesignerManager; #endif diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 18af591..33fec2a 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -167,6 +167,15 @@ void ReportEnginePrivate::showError(QString message) QMessageBox::critical(0,tr("Error"),message); } +void ReportEnginePrivate::updateTranslations() +{ + foreach(ReportTranslation* translation, m_translations.values()){ + foreach(PageDesignIntf* page, m_pages){ + translation->updatePageTranslation(page); + } + } +} + void ReportEnginePrivate::slotDataSourceCollectionLoaded(const QString &collectionName) { emit datasourceCollectionLoadFinished(collectionName); @@ -775,11 +784,11 @@ bool ReportEnginePrivate::setReportLanguage(QLocale::Language language){ foreach(PageTranslation* pageTranslation, translation->pagesTranslation()){ PageDesignIntf* page = getPageByName(pageTranslation->pageName); if (page){ - foreach(ItemTranslation itemTranslation, pageTranslation->itemsTranslation){ - BaseDesignIntf* item = page->pageItem()->childByName(itemTranslation.itemName); + foreach(ItemTranslation* itemTranslation, pageTranslation->itemsTranslation){ + BaseDesignIntf* item = page->pageItem()->childByName(itemTranslation->itemName); if (item) { - foreach(PropertyTranslation propertyTranslation, itemTranslation.propertyesTranslation){ - item->setProperty(propertyTranslation.propertyName.toLatin1(),propertyTranslation.value); + foreach(PropertyTranslation* propertyTranslation, itemTranslation->propertyesTranslation){ + item->setProperty(propertyTranslation->propertyName.toLatin1(), propertyTranslation->value); } } } diff --git a/limereport/lrreportengine.h b/limereport/lrreportengine.h index 64f01bb..f785713 100644 --- a/limereport/lrreportengine.h +++ b/limereport/lrreportengine.h @@ -72,6 +72,7 @@ class LIMEREPORT_EXPORT ReportEngine : public QObject{ Q_OBJECT friend class ReportDesignWidget; friend class PreviewReportWidget; + friend class TranslationEditor; public: static void setSettings(QSettings *value){m_settings=value;} public: diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index c31e019..23c53cc 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -135,7 +135,6 @@ public: bool setReportLanguage(QLocale::Language language); QList aviableLanguages(); ReportTranslation* reportTranslation(QLocale::Language language); - signals: void pagesLoadFinished(); void datasourceCollectionLoadFinished(const QString& collectionName); @@ -166,6 +165,7 @@ private: //ICollectionContainer //ITranslationContainer Translations* translations(){ return &m_translations;} + void updateTranslations(); //ITranslationContainer ReportPages renderToPages(); QString renderToString(); diff --git a/limereport/lrreporttranslation.cpp b/limereport/lrreporttranslation.cpp index bc8717a..2df00eb 100644 --- a/limereport/lrreporttranslation.cpp +++ b/limereport/lrreporttranslation.cpp @@ -34,22 +34,65 @@ PageTranslation* ReportTranslation::createPageTranslation(PageDesignIntf* page) PageTranslation* pageTranslation = new PageTranslation; pageTranslation->pageName = page->objectName(); foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){ - QMap stringsForTranslation = item->getStringForTranslation(); - if (!stringsForTranslation.isEmpty()){ - ItemTranslation itemTranslation; - itemTranslation.itemName = item->objectName(); - foreach(QString propertyName, stringsForTranslation.keys()){ - PropertyTranslation propertyTranslation; - propertyTranslation.propertyName = propertyName; - propertyTranslation.value = stringsForTranslation.value(propertyName); - itemTranslation.propertyesTranslation.append(propertyTranslation); - } - pageTranslation->itemsTranslation.append(itemTranslation); - } + createItemTranslation(item, pageTranslation); } return pageTranslation; } +void ReportTranslation::createItemTranslation(BaseDesignIntf* item, PageTranslation* pageTranslation){ + QMap stringsForTranslation = item->getStringForTranslation(); + if (!stringsForTranslation.isEmpty()){ + ItemTranslation* itemTranslation = new ItemTranslation; + itemTranslation->itemName = item->objectName(); + foreach(QString propertyName, stringsForTranslation.keys()){ + PropertyTranslation* propertyTranslation = new PropertyTranslation; + propertyTranslation->propertyName = propertyName; + propertyTranslation->value = stringsForTranslation.value(propertyName); + propertyTranslation->sourceValue = stringsForTranslation.value(propertyName); + propertyTranslation->checked = false; + propertyTranslation->sourceHasBeenChanged = false; + itemTranslation->propertyesTranslation.append(propertyTranslation); + } + pageTranslation->itemsTranslation.insert(itemTranslation->itemName, itemTranslation); + } +} + +PageTranslation* ReportTranslation::findPageTranslation(const QString& page_name) +{ + foreach(PageTranslation* page, m_pagesTranslation){ + if (page->pageName.compare(page_name) == 0){ + return page; + } + } + return 0; +} + +void ReportTranslation::updatePageTranslation(PageDesignIntf* page) +{ + PageTranslation* pageTranslation = findPageTranslation(page->objectName()); + if (!pageTranslation){ + pageTranslation = createPageTranslation(page); + m_pagesTranslation.append(pageTranslation); + } + if (pageTranslation){ + foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){ + QMap stringsForTranslation = item->getStringForTranslation(); + if (!stringsForTranslation.isEmpty()){ + ItemTranslation* itemTranslation = pageTranslation->itemsTranslation.value(item->objectName()); + if (itemTranslation){ + foreach(QString propertyName, stringsForTranslation.keys()){ + PropertyTranslation* propertyTranslation = itemTranslation->findProperty(propertyName); + propertyTranslation->sourceValue = stringsForTranslation.value(propertyName); + propertyTranslation->sourceHasBeenChanged = propertyTranslation->value != propertyTranslation->sourceValue; + } + } else { + createItemTranslation(item, pageTranslation); + } + } + } + } +} + QList ReportTranslation::pagesTranslation() const { return m_pagesTranslation; @@ -67,4 +110,28 @@ QLocale::Language ReportTranslation::language() const return m_language; } +PropertyTranslation* ItemTranslation::findProperty(const QString& propertyName) +{ + foreach(PropertyTranslation* propertyTranslation, propertyesTranslation){ + if (propertyTranslation->propertyName.compare(propertyName) == 0){ + return propertyTranslation; + } + } + return 0; +} + +ItemTranslation::~ItemTranslation() +{ + foreach(PropertyTranslation* property, propertyesTranslation){ + delete property; + } +} + +PageTranslation::~PageTranslation() +{ + foreach(ItemTranslation* item, itemsTranslation){ + delete item; + } +} + } //namespace LimeReport diff --git a/limereport/lrreporttranslation.h b/limereport/lrreporttranslation.h index 8af2de7..cae7622 100644 --- a/limereport/lrreporttranslation.h +++ b/limereport/lrreporttranslation.h @@ -24,16 +24,22 @@ namespace LimeReport{ struct PropertyTranslation{ QString propertyName; QString value; + QString sourceValue; + bool checked; + bool sourceHasBeenChanged; }; struct ItemTranslation{ QString itemName; - QList propertyesTranslation; + PropertyTranslation* findProperty(const QString& propertyName); + ~ItemTranslation(); + QList propertyesTranslation; }; struct PageTranslation{ QString pageName; - QList itemsTranslation; + ~PageTranslation(); + QHash itemsTranslation; }; class ReportTranslation{ @@ -45,6 +51,9 @@ public: QLocale::Language language() const; QList pagesTranslation() const; PageTranslation* createEmptyPageTranslation(); + void updatePageTranslation(PageDesignIntf* page); + PageTranslation* findPageTranslation(const QString& page_name); + void createItemTranslation(BaseDesignIntf* item, PageTranslation* pageTranslation); private: PageTranslation* createPageTranslation(PageDesignIntf* page); private: @@ -58,6 +67,7 @@ typedef QMap Translations; class ITranslationContainer{ public: virtual Translations* translations() = 0; + virtual void updateTranslations() = 0; }; } // namespace LimeReport diff --git a/limereport/serializators/lrxmlreader.cpp b/limereport/serializators/lrxmlreader.cpp index 3cf11ad..9b15b30 100644 --- a/limereport/serializators/lrxmlreader.cpp +++ b/limereport/serializators/lrxmlreader.cpp @@ -217,16 +217,18 @@ void XMLReader::readTranslation(QObject* item, QDomElement* node) pageTranslation->pageName = pageNode.nodeName(); for (int itemIndex = 0; itemIndex < pageNode.childNodes().count(); ++itemIndex){ QDomElement itemNode = pageNode.childNodes().at(itemIndex).toElement(); - ItemTranslation itemTranslation; - itemTranslation.itemName = itemNode.nodeName(); + ItemTranslation* itemTranslation = new ItemTranslation(); + itemTranslation->itemName = itemNode.nodeName(); for (int propertyIndex = 0; propertyIndex < itemNode.childNodes().count(); ++propertyIndex){ QDomElement propertyNode = itemNode.childNodes().at(propertyIndex).toElement(); - PropertyTranslation propertyTranslation; - propertyTranslation.propertyName = propertyNode.nodeName(); - propertyTranslation.value = propertyNode.attribute("Value"); - itemTranslation.propertyesTranslation.append(propertyTranslation); + PropertyTranslation* propertyTranslation = new PropertyTranslation; + propertyTranslation->propertyName = propertyNode.nodeName(); + propertyTranslation->value = propertyNode.attribute("Value"); + propertyTranslation->sourceValue = propertyNode.attribute("SourceValue"); + propertyTranslation->checked = propertyNode.attribute("Checked").compare("Y") == 0; + itemTranslation->propertyesTranslation.append(propertyTranslation); } - pageTranslation->itemsTranslation.append(itemTranslation); + pageTranslation->itemsTranslation.insert(itemTranslation->itemName, itemTranslation); } } translations->insert(curTranslation->language(),curTranslation); diff --git a/limereport/serializators/lrxmlwriter.cpp b/limereport/serializators/lrxmlwriter.cpp index b0f0bee..2f77dd1 100644 --- a/limereport/serializators/lrxmlwriter.cpp +++ b/limereport/serializators/lrxmlwriter.cpp @@ -230,12 +230,14 @@ void XMLWriter::saveTranslation(QString propertyName, QObject* item, QDomElement foreach(PageTranslation* page, curTranslation->pagesTranslation()){ QDomElement pageNode = m_doc->createElement(page->pageName); languageNode.appendChild(pageNode); - foreach(ItemTranslation item, page->itemsTranslation){ - QDomElement itemNode = m_doc->createElement(item.itemName); + foreach(ItemTranslation* item, page->itemsTranslation){ + QDomElement itemNode = m_doc->createElement(item->itemName); pageNode.appendChild(itemNode); - foreach(PropertyTranslation property, item.propertyesTranslation){ - QDomElement propertyNode = m_doc->createElement(property.propertyName); - propertyNode.setAttribute("Value",property.value); + foreach(PropertyTranslation* property, item->propertyesTranslation){ + QDomElement propertyNode = m_doc->createElement(property->propertyName); + propertyNode.setAttribute("Value",property->value); + propertyNode.setAttribute("SourceValue", property->sourceValue); + propertyNode.setAttribute("Checked", property->checked ? "Y":"N"); itemNode.appendChild(propertyNode); } } diff --git a/limereport/translationeditor/images/add.png b/limereport/translationeditor/images/add.png new file mode 100644 index 0000000000000000000000000000000000000000..b5671255c10af83f7c735089053e072312309f46 GIT binary patch literal 655 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl45bDP46hOx7_4S6Fo+k-*%fF5lvo|$6XN>+|Nqe4p+P%> zI^K2oZSiY;-RimCv+;SO^GfHMM>Wcw%8ADlWt(MV4#h~+Nkr_65UCOoEEfc7v0ZGd z*{=y<ee8#eZZdZXqvpiiKLnJPz_PYx;F$k~-0>MO;$dew^e*B+rdHST*uS>zT(rq^j z6+$kDY;QauckuG2c`0Iz){M6cbBx*#%x`>MsW;PIK<@xQ(|jF;jP>ObM?HnyAO2pd zxJ2y4CmZGE97mt`Gdb$7-j%s~UGA$@R|Jn}zu13&o{o}-xk1lkhiL*&tY9`zxOX7Iu0%`U735TH+c}l9E`GYL#4+3Zxi}3=GY54GnY+ z%|eWftPISpj7+o*jI9g|>RwiDMA49&pOTqYiCY8zmP5Qi4U!-mg7ec#$`gxH85~pc glTsBta}(23gHjVyDhp4hf>H^Cr>mdKI;Vst08H=T#{d8T literal 0 HcmV?d00001 diff --git a/limereport/translationeditor/images/checked.png b/limereport/translationeditor/images/checked.png new file mode 100644 index 0000000000000000000000000000000000000000..8149629267018c615fe9e4833a4adc7deb884c31 GIT binary patch literal 265 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPt2Ma$3qg0IZCZLdHiEBiObAE1aYF-J0b5UwyNotBh zd1gt5g1e`0KzJjcI8afcr;B5V#p$b)Hu5$Y@UZ0ftvTp1ag%>rf|AQ&Hl7K;GB})? zj;%Z}RrPmV-R%#nJv2EvDxMYYh+2BFHR;0}9i?oC2aNiR+=@HQzdsU~bN2hP3pdg> zA1%tYc=B^szVnfjnKg+fDg1}{C+2>*eQ({zzZMKgTe~DWM4f D#8X|= literal 0 HcmV?d00001 diff --git a/limereport/translationeditor/images/green_check.png b/limereport/translationeditor/images/green_check.png new file mode 100644 index 0000000000000000000000000000000000000000..ada2461a8c8ca04fe43fb09e9b61be5028dc2ed5 GIT binary patch literal 1347 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gjk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m@_g%B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxSU1_g&``n5OwZ87 z)XdCKN5ROz&`93^h|F{iO{`4Ktc=VRpg;*|TTx1yRgjAt)Gi>;Rw<*Tq`*pFzr4I$ zuiRKKzbIYb(9+TpWQLKEE>MMTab;dfVufyAu`kBtHuNWFoz#!AFNG#Ad)HBe}%?0@jth%@)C>7xhtg4GcDhpEegHnt0 zON)|$@sXws(+mtd{1$-}0$pR}Uz7=ql*AmD{N&Qy)VvZ;7h5Huj9yA+ij{$(1uzuN zO$^M949qMH4K0j}94#zNTuhu@O`VKQondBR(`)JIW?|rD>1=B0Vq|FOYGi3_;^yq? z>S}20Wa#E(?grEAnO9trn3tRivo{lHFI2A+UcFY%MX8A;`9&f5`8lu@5Rj2yl3$#W zU!dR|Y^I>$o0y!L2NKW(MG(ZlE~!PCWvMA{Mftf3;1IUT#Nq;=cM13$qBn({P}2uG zMjwHrA^SF|DpLDW0lk+&v2)dh(oLek3MSWZkes>@JhKf*sqD%bgokI6KrIOt{T| z-p0nd@u6Mmd{U?Z@b`J?-nMUU)FI`lpBPL}(yJ3cG_blyz!}brfy8W0pnhM-MoY={4(q5D}aX04?J%>ND0usyFvre)K zeL5h!;-P-0u5UcUMq87af=vAj+Uym#?qHkRGVemian^Yb%6}Ahem&@)5jDTbm2Zkf z%)*1tfvum#XYI;bpxMhPHE}`0PRFxSydgo$m_Ax7d}DZYddmu<=S&-I1m-L66qEY2 dmaBn*nc;MTXZV%(`#C|yny0Iu%Q~loCIFE|$T0u_ literal 0 HcmV?d00001 diff --git a/limereport/translationeditor/images/question.png b/limereport/translationeditor/images/question.png new file mode 100644 index 0000000000000000000000000000000000000000..badcba0370684a7f24dabbe20055263908f98998 GIT binary patch literal 542 zcmV+(0^$9MP)02y>e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00D+cL_t(I%e9k1NRx3G#(%nj zj`+lq2hmQ0 zposbo2_{9GG&2WI2TunPGMsG(pWFNLzR&yeJnswVfiMhZtrZ|Z)>?&OsMBhD|4n2v z8O3N&oGqY@J7{B);`9MK)pumGS)DmKpU=y`JfNSSXViR)UKUZbg7p51DoZGlNSsaJ z`@Zhqy`a5SG=z`j z(>(md*B@}n@9$hpV~k!seIQl(^l%y(WAtAUkKvrtL}8Gzp(j-d)qNt}Mf?BP{#LW@Lh8rAKw`uG_d96lQ8Z^H@X7eM|cVXvum(LUg!LjFp gBmaXS(7Al>A1pSRrYECP9RL6T07*qoM6N<$f?7K1tpET3 literal 0 HcmV?d00001 diff --git a/limereport/translationeditor/images/remove.png b/limereport/translationeditor/images/remove.png new file mode 100644 index 0000000000000000000000000000000000000000..8a974cfac9fb94cf56b6fbb3c0a41b2a51a0c489 GIT binary patch literal 867 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFf4Ghh64GnY+%|eWftPISpj7+o*jI9g|>RwiD zMA49&pOTqYiCY8zmP5Qi4Kg4bg7ec#$`gxH85~pclTsDjGK*5n^NX^J6`X^OXIygw z#s%Zjs*s412wxwo>o&VLD%pv!KEDqCnPJ9xT8_)M#KFn9D&Ot1$xG*O?ww(L&$1$4@h~zp zZ8~w`{l6BUR}-VA-Y*aHEw@iE+CI&*QSMXRt&i(gX+LEtx$0)V=kx@PGckqr_u37c zn2)SA{<33#!}OEJJw2fU?Isgcx)kMFa!yQo_&{#ip@aMj8+jWAADJK1d}`P_dEuVt z->-;q|I7YUvg+ktp0#sUTOP~3-IgmNwfl⪻v|Cn$Cxg1(lcmN*eRt^?Ba=+!Lyt z8@c;Z#*N=edE4}ySFnqhW%*rs?zD@OzqjpD$c^{}DWRHkd;H%u*Q87>ICie*=9A;! z=6kJpgMVVIKPowh8I!Yi|tM zaqYCof8KxJYmcvx=eD2r!)E%=tDEgk@2i<;e@OYak(m4MdBBKe@O1TaS?83{1OO%i BO0WO` literal 0 HcmV?d00001 diff --git a/limereport/translationeditor/translationeditor.cpp b/limereport/translationeditor/translationeditor.cpp new file mode 100644 index 0000000..6576702 --- /dev/null +++ b/limereport/translationeditor/translationeditor.cpp @@ -0,0 +1,165 @@ +#include "translationeditor.h" +#include "ui_translationeditor.h" +#include "lrreportengine.h" +#include "lrreportengine_p.h" +#include "lrreporttranslation.h" + +namespace LimeReport { + +TranslationEditor::TranslationEditor(QWidget *parent) : + QWidget(parent), + ui(new Ui::TranslationEditor), m_translationContainer(0) +{ + ui->setupUi(this); + ui->splitter_3->setStretchFactor(1,10); + ui->splitter_3->setStretchFactor(0,2); + ui->splitter_2->setStretchFactor(1,2); + ui->splitter->setStretchFactor(0,2); + QTableWidgetItem* item = new QTableWidgetItem(); + item->setIcon(QIcon(":/translationeditor/images/checked.png")); + ui->tbStrings->setColumnCount(4); + ui->tbStrings->setColumnWidth(0,30); + ui->tbStrings->setColumnWidth(1,100); + ui->tbStrings->setColumnWidth(2,100); + ui->tbStrings->setHorizontalHeaderItem(0,item); + ui->tbStrings->setHorizontalHeaderItem(1,new QTableWidgetItem(tr("Report Item"))); + ui->tbStrings->setHorizontalHeaderItem(2,new QTableWidgetItem(tr("Property"))); + ui->tbStrings->setHorizontalHeaderItem(3,new QTableWidgetItem(tr("Source text"))); + //ui->tbStrings->setSortingEnabled(true); + +} + +void TranslationEditor::setReportEngine(ITranslationContainer* translationContainer) +{ + m_translationContainer = translationContainer; + if (m_translationContainer){ + m_translationContainer->updateTranslations(); + updateUi(); + } +} + +TranslationEditor::~TranslationEditor() +{ + delete ui; +} + + +void TranslationEditor::updateUi() +{ + ui->lvLanguages->clear(); + + Q_ASSERT(m_translationContainer != 0); + if (m_translationContainer){ + Translations* translations = m_translationContainer->translations(); + Q_ASSERT(translations != 0); + if (translations){ + foreach(QLocale::Language language, translations->keys()){ + ui->lvLanguages->addItem(QLocale::languageToString(language)); + } + if (!translations->keys().isEmpty()){ + ui->lvLanguages->item(0)->setSelected(true); + activateLanguage(translations->keys().at(0)); + } + } + } +} + +void TranslationEditor::activateLanguage(QLocale::Language language) +{ + ui->teTranslation->setEnabled(false); + ui->cbChecked->setEnabled(false); + ui->twPages->clear(); + Translations* translations = m_translationContainer->translations(); + Q_ASSERT(translations != 0); + if (translations){ + m_currentReportTranslation = translations->value(language); + Q_ASSERT(m_currentReportTranslation != 0); + if (m_currentReportTranslation){ + foreach(PageTranslation* pageTranslation, m_currentReportTranslation->pagesTranslation()){ + QTreeWidgetItem* pageItem = new QTreeWidgetItem(); + pageItem->setText(0,pageTranslation->pageName); + ui->twPages->addTopLevelItem(pageItem); + } + } + if (ui->twPages->topLevelItem(0)){ + ui->twPages->topLevelItem(0)->setSelected(true); + activatePage(m_currentReportTranslation->findPageTranslation(ui->twPages->topLevelItem(0)->text(0))); + } + } +} + +void TranslationEditor::activatePage(PageTranslation* pageTranslation) +{ + ui->teTranslation->setEnabled(false); + ui->cbChecked->setEnabled(false); + Q_ASSERT(pageTranslation != 0); + if(pageTranslation){ + ui->tbStrings->clearContents(); + ui->tbStrings->setRowCount(0); + m_currentPageTranslation = pageTranslation; + QStringList items = pageTranslation->itemsTranslation.keys(); + items.sort(); + foreach(QString itemName, items){ + ItemTranslation* itemTranslation = pageTranslation->itemsTranslation.value(itemName); + int rowIndex = ui->tbStrings->rowCount(); + ui->tbStrings->setRowCount(rowIndex+1); + foreach(PropertyTranslation* propertyTranslation, itemTranslation->propertyesTranslation){ + QTableWidgetItem* checkItem = new QTableWidgetItem(); + if (propertyTranslation->checked) + checkItem->setIcon(QIcon(":/translationeditor/images/checked.png")); + ui->tbStrings->setItem(rowIndex,0,checkItem); + ui->tbStrings->setItem(rowIndex,1,new QTableWidgetItem(itemTranslation->itemName)); + ui->tbStrings->setItem(rowIndex,2,new QTableWidgetItem(propertyTranslation->propertyName)); + ui->tbStrings->setItem(rowIndex,3,new QTableWidgetItem(propertyTranslation->sourceValue)); + } + } + } + +} + +void TranslationEditor::activateTranslation(const QString& itemName, const QString& propertyName) +{ + Q_ASSERT(m_currentPageTranslation != 0); + if (m_currentPageTranslation){ + ItemTranslation* itemTranslation = m_currentPageTranslation->itemsTranslation.value(itemName); + Q_ASSERT(itemTranslation !=0 ); + if (itemTranslation){ + m_currentPropertyTranslation = m_currentPageTranslation->itemsTranslation.value(itemName)->findProperty(propertyName); + Q_ASSERT(m_currentPropertyTranslation != 0); + if (m_currentPropertyTranslation){ + ui->teTranslation->setEnabled(true); + ui->cbChecked->setEnabled(true); + ui->teTranslation->setText(m_currentPropertyTranslation->value); + ui->cbChecked->setChecked(m_currentPropertyTranslation->checked); + } + } + } +} + +void TranslationEditor::on_tbStrings_itemSelectionChanged() +{ + activateTranslation(ui->tbStrings->item(ui->tbStrings->currentRow(),1)->text(), ui->tbStrings->item(ui->tbStrings->currentRow(),2)->text()); +} + +void TranslationEditor::on_teTranslation_textChanged() +{ + m_currentPropertyTranslation->value = ui->teTranslation->toPlainText(); +} + +void TranslationEditor::on_cbChecked_toggled(bool checked) +{ + m_currentPropertyTranslation->checked = checked; + ui->tbStrings->item(ui->tbStrings->currentRow(),0)->setIcon(checked ? QIcon(":/translationeditor/images/checked.png"):QIcon()); +} + +void TranslationEditor::on_twPages_itemSelectionChanged() +{ + if (!ui->twPages->selectedItems().isEmpty()){ + activatePage(m_currentReportTranslation->findPageTranslation(ui->twPages->selectedItems().at(0)->text(0))); + } +} + +} //namespace LimeReport + + + diff --git a/limereport/translationeditor/translationeditor.h b/limereport/translationeditor/translationeditor.h new file mode 100644 index 0000000..ca153c3 --- /dev/null +++ b/limereport/translationeditor/translationeditor.h @@ -0,0 +1,45 @@ +#ifndef TRANSLATIONEDITOR_H +#define TRANSLATIONEDITOR_H + +#include +#include +#include +#include "lrreporttranslation.h" + +namespace LimeReport { + +namespace Ui { +class TranslationEditor; +} + + +class TranslationEditor : public QWidget +{ + Q_OBJECT + +public: + explicit TranslationEditor(QWidget *parent = 0); + void setReportEngine(ITranslationContainer* translationContainer); + ~TranslationEditor(); + void updateUi(); + void activateLanguage(QLocale::Language language); + void activatePage(PageTranslation* pageTranslation); + void activateTranslation(const QString& itemName, const QString& propertyName); +private slots: + void on_tbStrings_itemSelectionChanged(); + void on_teTranslation_textChanged(); + void on_cbChecked_toggled(bool checked); + void on_twPages_itemSelectionChanged(); +private: + Ui::TranslationEditor *ui; + ITranslationContainer* m_translationContainer; + QMap m_reportTranslations; + QMap m_pageTranslations; + ReportTranslation* m_currentReportTranslation; + PageTranslation* m_currentPageTranslation; + PropertyTranslation* m_currentPropertyTranslation; +}; + +} //namespace LimeReport + +#endif // TRANSLATIONEDITOR_H diff --git a/limereport/translationeditor/translationeditor.qrc b/limereport/translationeditor/translationeditor.qrc new file mode 100644 index 0000000..706f7af --- /dev/null +++ b/limereport/translationeditor/translationeditor.qrc @@ -0,0 +1,8 @@ + + + images/add.png + images/remove.png + images/checked.png + images/question.png + + diff --git a/limereport/translationeditor/translationeditor.ui b/limereport/translationeditor/translationeditor.ui new file mode 100644 index 0000000..aac3734 --- /dev/null +++ b/limereport/translationeditor/translationeditor.ui @@ -0,0 +1,214 @@ + + + LimeReport::TranslationEditor + + + + 0 + 0 + 873 + 525 + + + + Form + + + + + + Qt::Horizontal + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + + + Qt::Vertical + + + + Languages + + + true + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ... + + + + :/translationeditor/images/add.png:/translationeditor/images/add.png + + + + + + + ... + + + + :/translationeditor/images/remove.png:/translationeditor/images/remove.png + + + + + + + + + + + + + Pages + + + true + + + + + + false + + + false + + + + 1 + + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + + + Qt::Vertical + + + + Strings + + + true + + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + 2 + + + true + + + + + + + + + Source Text + + + + + + + + + Translation + + + true + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Checked + + + + + + + + + + + + + + + + + + + +