mirror of
https://github.com/fralx/LimeReport.git
synced 2025-11-25 00:18:06 +03:00
Translation has been updated
This commit is contained in:
@@ -34,22 +34,65 @@ PageTranslation* ReportTranslation::createPageTranslation(PageDesignIntf* page)
|
||||
PageTranslation* pageTranslation = new PageTranslation;
|
||||
pageTranslation->pageName = page->objectName();
|
||||
foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){
|
||||
QMap<QString,QString> 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<QString,QString> 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<QString,QString> 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<PageTranslation*> 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
|
||||
|
||||
Reference in New Issue
Block a user