mirror of
				https://github.com/fralx/LimeReport.git
				synced 2025-11-04 15:11:26 +03:00 
			
		
		
		
	Translation has been finished
This commit is contained in:
		@@ -109,9 +109,7 @@ public:
 | 
				
			|||||||
    bool isBusy();
 | 
					    bool isBusy();
 | 
				
			||||||
    void setPassPharse(QString& passPharse);
 | 
					    void setPassPharse(QString& passPharse);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    QList<QLocale::Language> aviableLanguages();
 | 
					    QList<QLocale::Language> aviableLanguages();
 | 
				
			||||||
    bool addTranslationLanguage(QLocale::Language language);
 | 
					 | 
				
			||||||
    bool setReportLanguage(QLocale::Language language);
 | 
					    bool setReportLanguage(QLocale::Language language);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
signals:
 | 
					signals:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -96,10 +96,11 @@ SOURCES += \
 | 
				
			|||||||
    $$REPORT_PATH/lraboutdialog.cpp \
 | 
					    $$REPORT_PATH/lraboutdialog.cpp \
 | 
				
			||||||
    $$REPORT_PATH/lrsettingdialog.cpp \
 | 
					    $$REPORT_PATH/lrsettingdialog.cpp \
 | 
				
			||||||
    $$REPORT_PATH/lritemscontainerdesignitf.cpp \
 | 
					    $$REPORT_PATH/lritemscontainerdesignitf.cpp \
 | 
				
			||||||
	$$REPORT_PATH/lrcolorindicator.cpp \
 | 
					    $$REPORT_PATH/lrcolorindicator.cpp \
 | 
				
			||||||
    $$REPORT_PATH/items/lrchartitem.cpp \
 | 
					    $$REPORT_PATH/items/lrchartitem.cpp \
 | 
				
			||||||
    $$REPORT_PATH/items/lrchartitemeditor.cpp \
 | 
					    $$REPORT_PATH/items/lrchartitemeditor.cpp \
 | 
				
			||||||
    $$REPORT_PATH/lrreporttranslation.cpp
 | 
					    $$REPORT_PATH/lrreporttranslation.cpp \
 | 
				
			||||||
 | 
					    $$REPORT_PATH/translationeditor/languageselectdialog.cpp
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
contains(CONFIG, staticlib){
 | 
					contains(CONFIG, staticlib){
 | 
				
			||||||
    SOURCES += $$REPORT_PATH/lrfactoryinitializer.cpp
 | 
					    SOURCES += $$REPORT_PATH/lrfactoryinitializer.cpp
 | 
				
			||||||
@@ -209,7 +210,8 @@ HEADERS += \
 | 
				
			|||||||
    $$REPORT_PATH/lrcolorindicator.h \
 | 
					    $$REPORT_PATH/lrcolorindicator.h \
 | 
				
			||||||
    $$REPORT_PATH/items/lrchartitem.h \
 | 
					    $$REPORT_PATH/items/lrchartitem.h \
 | 
				
			||||||
    $$REPORT_PATH/items/lrchartitemeditor.h \
 | 
					    $$REPORT_PATH/items/lrchartitemeditor.h \
 | 
				
			||||||
    $$REPORT_PATH/lrreporttranslation.h
 | 
					    $$REPORT_PATH/lrreporttranslation.h \
 | 
				
			||||||
 | 
					    $$REPORT_PATH/translationeditor/languageselectdialog.h
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
contains(CONFIG, staticlib){
 | 
					contains(CONFIG, staticlib){
 | 
				
			||||||
    HEADERS += $$REPORT_PATH/lrfactoryinitializer.h
 | 
					    HEADERS += $$REPORT_PATH/lrfactoryinitializer.h
 | 
				
			||||||
@@ -232,7 +234,8 @@ FORMS += \
 | 
				
			|||||||
    $$REPORT_PATH/lrsettingdialog.ui \
 | 
					    $$REPORT_PATH/lrsettingdialog.ui \
 | 
				
			||||||
    $$REPORT_PATH/scriptbrowser/lrscriptbrowser.ui \
 | 
					    $$REPORT_PATH/scriptbrowser/lrscriptbrowser.ui \
 | 
				
			||||||
    $$REPORT_PATH/items/lrchartitemeditor.ui \
 | 
					    $$REPORT_PATH/items/lrchartitemeditor.ui \
 | 
				
			||||||
    $$REPORT_PATH/translationeditor/translationeditor.ui
 | 
					    $$REPORT_PATH/translationeditor/translationeditor.ui \
 | 
				
			||||||
 | 
					    $$PWD/translationeditor/languageselectdialog.ui
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RESOURCES += \
 | 
					RESOURCES += \
 | 
				
			||||||
    $$REPORT_PATH/objectinspector/lobjectinspector.qrc \
 | 
					    $$REPORT_PATH/objectinspector/lobjectinspector.qrc \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -64,7 +64,7 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
 | 
				
			|||||||
    m_showProgressDialog(true), m_reportName(""), m_activePreview(0),
 | 
					    m_showProgressDialog(true), m_reportName(""), m_activePreview(0),
 | 
				
			||||||
    m_previewWindowIcon(":/report/images/logo32"), m_previewWindowTitle(tr("Preview")),
 | 
					    m_previewWindowIcon(":/report/images/logo32"), m_previewWindowTitle(tr("Preview")),
 | 
				
			||||||
    m_reportRendering(false), m_resultIsEditable(true), m_passPhrase("HjccbzHjlbyfCkjy"),
 | 
					    m_reportRendering(false), m_resultIsEditable(true), m_passPhrase("HjccbzHjlbyfCkjy"),
 | 
				
			||||||
    m_fileWatcher( new QFileSystemWatcher( this ) )
 | 
					    m_fileWatcher( new QFileSystemWatcher( this ) ), m_reportLanguage(QLocale::AnyLanguage)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
#ifdef HAVE_STATIC_BUILD
 | 
					#ifdef HAVE_STATIC_BUILD
 | 
				
			||||||
    initResources();
 | 
					    initResources();
 | 
				
			||||||
@@ -768,7 +768,12 @@ void ReportEnginePrivate::setPassPhrase(const QString &passPhrase)
 | 
				
			|||||||
bool ReportEnginePrivate::addTranslationLanguage(QLocale::Language language)
 | 
					bool ReportEnginePrivate::addTranslationLanguage(QLocale::Language language)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (!m_translations.keys().contains(language)){
 | 
					    if (!m_translations.keys().contains(language)){
 | 
				
			||||||
        ReportTranslation* translation = new ReportTranslation(language,m_pages);
 | 
					        ReportTranslation* translation = 0;
 | 
				
			||||||
 | 
					        if (!m_translations.contains(QLocale::AnyLanguage)){
 | 
				
			||||||
 | 
					            translation = new ReportTranslation(QLocale::AnyLanguage,m_pages);
 | 
				
			||||||
 | 
					            m_translations.insert(QLocale::AnyLanguage,translation);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        translation = new ReportTranslation(language,m_pages);
 | 
				
			||||||
        m_translations.insert(language, translation);
 | 
					        m_translations.insert(language, translation);
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
@@ -777,8 +782,14 @@ bool ReportEnginePrivate::addTranslationLanguage(QLocale::Language language)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool ReportEnginePrivate::setReportLanguage(QLocale::Language language){
 | 
					bool ReportEnginePrivate::removeTranslationLanguage(QLocale::Language language)
 | 
				
			||||||
    if (!m_translations.keys().contains(language)) return false;
 | 
					{
 | 
				
			||||||
 | 
					    return m_translations.remove(language) != 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void ReportEnginePrivate::activateLanguage(QLocale::Language language)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (!m_translations.keys().contains(language)) return;
 | 
				
			||||||
    ReportTranslation* translation = m_translations.value(language);
 | 
					    ReportTranslation* translation = m_translations.value(language);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    foreach(PageTranslation* pageTranslation, translation->pagesTranslation()){
 | 
					    foreach(PageTranslation* pageTranslation, translation->pagesTranslation()){
 | 
				
			||||||
@@ -794,6 +805,12 @@ bool ReportEnginePrivate::setReportLanguage(QLocale::Language language){
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool ReportEnginePrivate::setReportLanguage(QLocale::Language language){
 | 
				
			||||||
 | 
					    m_reportLanguage = language;
 | 
				
			||||||
 | 
					    if (!m_translations.keys().contains(language)) return false;
 | 
				
			||||||
 | 
					//    activateLanguage(language);
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -861,7 +878,7 @@ ReportPages ReportEnginePrivate::renderToPages()
 | 
				
			|||||||
    dataManager()->connectAllDatabases();
 | 
					    dataManager()->connectAllDatabases();
 | 
				
			||||||
    dataManager()->setDesignTime(false);
 | 
					    dataManager()->setDesignTime(false);
 | 
				
			||||||
    dataManager()->updateDatasourceModel();
 | 
					    dataManager()->updateDatasourceModel();
 | 
				
			||||||
 | 
					    activateLanguage(m_reportLanguage);
 | 
				
			||||||
    connect(m_reportRender.data(),SIGNAL(pageRendered(int)),
 | 
					    connect(m_reportRender.data(),SIGNAL(pageRendered(int)),
 | 
				
			||||||
            this, SIGNAL(renderPageFinished(int)));
 | 
					            this, SIGNAL(renderPageFinished(int)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -892,6 +909,7 @@ ReportPages ReportEnginePrivate::renderToPages()
 | 
				
			|||||||
            m_reportRender.clear();
 | 
					            m_reportRender.clear();
 | 
				
			||||||
            m_reportRendering = false;
 | 
					            m_reportRendering = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        activateLanguage(QLocale::AnyLanguage);
 | 
				
			||||||
        return result;
 | 
					        return result;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        return ReportPages();
 | 
					        return ReportPages();
 | 
				
			||||||
@@ -1009,12 +1027,6 @@ QList<QLocale::Language> ReportEngine::aviableLanguages()
 | 
				
			|||||||
    return d->aviableLanguages();
 | 
					    return d->aviableLanguages();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool ReportEngine::addTranslationLanguage(QLocale::Language language)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    Q_D(ReportEngine);
 | 
					 | 
				
			||||||
    return d->addTranslationLanguage(language);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
bool ReportEngine::setReportLanguage(QLocale::Language language)
 | 
					bool ReportEngine::setReportLanguage(QLocale::Language language)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Q_D(ReportEngine);
 | 
					    Q_D(ReportEngine);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -109,9 +109,7 @@ public:
 | 
				
			|||||||
    bool isBusy();
 | 
					    bool isBusy();
 | 
				
			||||||
    void setPassPharse(QString& passPharse);
 | 
					    void setPassPharse(QString& passPharse);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    QList<QLocale::Language> aviableLanguages();
 | 
					    QList<QLocale::Language> aviableLanguages();
 | 
				
			||||||
    bool addTranslationLanguage(QLocale::Language language);
 | 
					 | 
				
			||||||
    bool setReportLanguage(QLocale::Language language);
 | 
					    bool setReportLanguage(QLocale::Language language);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
signals:
 | 
					signals:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -132,6 +132,7 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    void setPassPhrase(const QString &passPhrase);
 | 
					    void setPassPhrase(const QString &passPhrase);
 | 
				
			||||||
    bool addTranslationLanguage(QLocale::Language language);
 | 
					    bool addTranslationLanguage(QLocale::Language language);
 | 
				
			||||||
 | 
					    bool removeTranslationLanguage(QLocale::Language language);
 | 
				
			||||||
    bool setReportLanguage(QLocale::Language language);
 | 
					    bool setReportLanguage(QLocale::Language language);
 | 
				
			||||||
    QList<QLocale::Language> aviableLanguages();
 | 
					    QList<QLocale::Language> aviableLanguages();
 | 
				
			||||||
    ReportTranslation* reportTranslation(QLocale::Language language);
 | 
					    ReportTranslation* reportTranslation(QLocale::Language language);
 | 
				
			||||||
@@ -195,6 +196,8 @@ private:
 | 
				
			|||||||
    QString m_passPhrase;
 | 
					    QString m_passPhrase;
 | 
				
			||||||
    QFileSystemWatcher  *m_fileWatcher;
 | 
					    QFileSystemWatcher  *m_fileWatcher;
 | 
				
			||||||
    Translations m_translations;
 | 
					    Translations m_translations;
 | 
				
			||||||
 | 
					    QLocale::Language m_reportLanguage;
 | 
				
			||||||
 | 
					    void activateLanguage(QLocale::Language language);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -66,8 +66,12 @@ typedef QMap<QLocale::Language, ReportTranslation*> Translations;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class ITranslationContainer{
 | 
					class ITranslationContainer{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					    virtual ~ITranslationContainer(){}
 | 
				
			||||||
    virtual Translations* translations() = 0;
 | 
					    virtual Translations* translations() = 0;
 | 
				
			||||||
    virtual void updateTranslations() = 0;
 | 
					    virtual void updateTranslations() = 0;
 | 
				
			||||||
 | 
					    virtual bool addTranslationLanguage(QLocale::Language language) = 0;
 | 
				
			||||||
 | 
					    virtual bool removeTranslationLanguage(QLocale::Language language) = 0;
 | 
				
			||||||
 | 
					    virtual QList<QLocale::Language> aviableLanguages() = 0;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace LimeReport
 | 
					} // namespace LimeReport
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										26
									
								
								limereport/translationeditor/languageselectdialog.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								limereport/translationeditor/languageselectdialog.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
				
			|||||||
 | 
					#include "languageselectdialog.h"
 | 
				
			||||||
 | 
					#include "ui_languageselectdialog.h"
 | 
				
			||||||
 | 
					#include <QLocale>
 | 
				
			||||||
 | 
					#include <QSet>
 | 
				
			||||||
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					LanguageSelectDialog::LanguageSelectDialog(QWidget *parent) :
 | 
				
			||||||
 | 
					    QDialog(parent),
 | 
				
			||||||
 | 
					    ui(new Ui::LanguageSelectDialog)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    ui->setupUi(this);
 | 
				
			||||||
 | 
					    for (int i = 2; i<QLocale::LastLanguage; ++i){
 | 
				
			||||||
 | 
					        ui->comboBox->addItem(QLocale::languageToString(static_cast<QLocale::Language>(i)),static_cast<QLocale::Language>(i));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    ui->comboBox->setCurrentText("");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					LanguageSelectDialog::~LanguageSelectDialog()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    delete ui;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QLocale::Language LanguageSelectDialog::getSelectedLanguage()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return ui->comboBox->itemData(ui->comboBox->currentIndex()).value<QLocale::Language>();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										23
									
								
								limereport/translationeditor/languageselectdialog.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								limereport/translationeditor/languageselectdialog.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					#ifndef LANGUAGESELECTDIALOG_H
 | 
				
			||||||
 | 
					#define LANGUAGESELECTDIALOG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QDialog>
 | 
				
			||||||
 | 
					#include <QLocale>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Ui {
 | 
				
			||||||
 | 
					class LanguageSelectDialog;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class LanguageSelectDialog : public QDialog
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    explicit LanguageSelectDialog(QWidget *parent = 0);
 | 
				
			||||||
 | 
					    ~LanguageSelectDialog();
 | 
				
			||||||
 | 
					    QLocale::Language getSelectedLanguage();
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    Ui::LanguageSelectDialog *ui;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // LANGUAGESELECTDIALOG_H
 | 
				
			||||||
							
								
								
									
										88
									
								
								limereport/translationeditor/languageselectdialog.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								limereport/translationeditor/languageselectdialog.ui
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,88 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<ui version="4.0">
 | 
				
			||||||
 | 
					 <class>LanguageSelectDialog</class>
 | 
				
			||||||
 | 
					 <widget class="QDialog" name="LanguageSelectDialog">
 | 
				
			||||||
 | 
					  <property name="geometry">
 | 
				
			||||||
 | 
					   <rect>
 | 
				
			||||||
 | 
					    <x>0</x>
 | 
				
			||||||
 | 
					    <y>0</y>
 | 
				
			||||||
 | 
					    <width>336</width>
 | 
				
			||||||
 | 
					    <height>109</height>
 | 
				
			||||||
 | 
					   </rect>
 | 
				
			||||||
 | 
					  </property>
 | 
				
			||||||
 | 
					  <property name="windowTitle">
 | 
				
			||||||
 | 
					   <string>Dialog</string>
 | 
				
			||||||
 | 
					  </property>
 | 
				
			||||||
 | 
					  <layout class="QVBoxLayout" name="verticalLayout">
 | 
				
			||||||
 | 
					   <item>
 | 
				
			||||||
 | 
					    <layout class="QHBoxLayout" name="horizontalLayout">
 | 
				
			||||||
 | 
					     <item>
 | 
				
			||||||
 | 
					      <widget class="QLabel" name="label">
 | 
				
			||||||
 | 
					       <property name="sizePolicy">
 | 
				
			||||||
 | 
					        <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
 | 
				
			||||||
 | 
					         <horstretch>0</horstretch>
 | 
				
			||||||
 | 
					         <verstretch>0</verstretch>
 | 
				
			||||||
 | 
					        </sizepolicy>
 | 
				
			||||||
 | 
					       </property>
 | 
				
			||||||
 | 
					       <property name="text">
 | 
				
			||||||
 | 
					        <string>Language</string>
 | 
				
			||||||
 | 
					       </property>
 | 
				
			||||||
 | 
					      </widget>
 | 
				
			||||||
 | 
					     </item>
 | 
				
			||||||
 | 
					     <item>
 | 
				
			||||||
 | 
					      <widget class="QComboBox" name="comboBox">
 | 
				
			||||||
 | 
					       <property name="editable">
 | 
				
			||||||
 | 
					        <bool>true</bool>
 | 
				
			||||||
 | 
					       </property>
 | 
				
			||||||
 | 
					      </widget>
 | 
				
			||||||
 | 
					     </item>
 | 
				
			||||||
 | 
					    </layout>
 | 
				
			||||||
 | 
					   </item>
 | 
				
			||||||
 | 
					   <item>
 | 
				
			||||||
 | 
					    <widget class="QDialogButtonBox" name="buttonBox">
 | 
				
			||||||
 | 
					     <property name="orientation">
 | 
				
			||||||
 | 
					      <enum>Qt::Horizontal</enum>
 | 
				
			||||||
 | 
					     </property>
 | 
				
			||||||
 | 
					     <property name="standardButtons">
 | 
				
			||||||
 | 
					      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
 | 
				
			||||||
 | 
					     </property>
 | 
				
			||||||
 | 
					    </widget>
 | 
				
			||||||
 | 
					   </item>
 | 
				
			||||||
 | 
					  </layout>
 | 
				
			||||||
 | 
					 </widget>
 | 
				
			||||||
 | 
					 <resources/>
 | 
				
			||||||
 | 
					 <connections>
 | 
				
			||||||
 | 
					  <connection>
 | 
				
			||||||
 | 
					   <sender>buttonBox</sender>
 | 
				
			||||||
 | 
					   <signal>accepted()</signal>
 | 
				
			||||||
 | 
					   <receiver>LanguageSelectDialog</receiver>
 | 
				
			||||||
 | 
					   <slot>accept()</slot>
 | 
				
			||||||
 | 
					   <hints>
 | 
				
			||||||
 | 
					    <hint type="sourcelabel">
 | 
				
			||||||
 | 
					     <x>248</x>
 | 
				
			||||||
 | 
					     <y>254</y>
 | 
				
			||||||
 | 
					    </hint>
 | 
				
			||||||
 | 
					    <hint type="destinationlabel">
 | 
				
			||||||
 | 
					     <x>157</x>
 | 
				
			||||||
 | 
					     <y>274</y>
 | 
				
			||||||
 | 
					    </hint>
 | 
				
			||||||
 | 
					   </hints>
 | 
				
			||||||
 | 
					  </connection>
 | 
				
			||||||
 | 
					  <connection>
 | 
				
			||||||
 | 
					   <sender>buttonBox</sender>
 | 
				
			||||||
 | 
					   <signal>rejected()</signal>
 | 
				
			||||||
 | 
					   <receiver>LanguageSelectDialog</receiver>
 | 
				
			||||||
 | 
					   <slot>reject()</slot>
 | 
				
			||||||
 | 
					   <hints>
 | 
				
			||||||
 | 
					    <hint type="sourcelabel">
 | 
				
			||||||
 | 
					     <x>316</x>
 | 
				
			||||||
 | 
					     <y>260</y>
 | 
				
			||||||
 | 
					    </hint>
 | 
				
			||||||
 | 
					    <hint type="destinationlabel">
 | 
				
			||||||
 | 
					     <x>286</x>
 | 
				
			||||||
 | 
					     <y>274</y>
 | 
				
			||||||
 | 
					    </hint>
 | 
				
			||||||
 | 
					   </hints>
 | 
				
			||||||
 | 
					  </connection>
 | 
				
			||||||
 | 
					 </connections>
 | 
				
			||||||
 | 
					</ui>
 | 
				
			||||||
@@ -3,12 +3,15 @@
 | 
				
			|||||||
#include "lrreportengine.h"
 | 
					#include "lrreportengine.h"
 | 
				
			||||||
#include "lrreportengine_p.h"
 | 
					#include "lrreportengine_p.h"
 | 
				
			||||||
#include "lrreporttranslation.h"
 | 
					#include "lrreporttranslation.h"
 | 
				
			||||||
 | 
					#include "languageselectdialog.h"
 | 
				
			||||||
 | 
					#include <QShortcut>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace LimeReport {
 | 
					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)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ui->setupUi(this);
 | 
					    ui->setupUi(this);
 | 
				
			||||||
    ui->splitter_3->setStretchFactor(1,10);
 | 
					    ui->splitter_3->setStretchFactor(1,10);
 | 
				
			||||||
@@ -25,6 +28,7 @@ TranslationEditor::TranslationEditor(QWidget *parent) :
 | 
				
			|||||||
    ui->tbStrings->setHorizontalHeaderItem(1,new QTableWidgetItem(tr("Report Item")));
 | 
					    ui->tbStrings->setHorizontalHeaderItem(1,new QTableWidgetItem(tr("Report Item")));
 | 
				
			||||||
    ui->tbStrings->setHorizontalHeaderItem(2,new QTableWidgetItem(tr("Property")));
 | 
					    ui->tbStrings->setHorizontalHeaderItem(2,new QTableWidgetItem(tr("Property")));
 | 
				
			||||||
    ui->tbStrings->setHorizontalHeaderItem(3,new QTableWidgetItem(tr("Source text")));
 | 
					    ui->tbStrings->setHorizontalHeaderItem(3,new QTableWidgetItem(tr("Source text")));
 | 
				
			||||||
 | 
					    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return), this, SLOT(slotItemChecked()));
 | 
				
			||||||
    //ui->tbStrings->setSortingEnabled(true);
 | 
					    //ui->tbStrings->setSortingEnabled(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -32,6 +36,10 @@ TranslationEditor::TranslationEditor(QWidget *parent) :
 | 
				
			|||||||
void TranslationEditor::setReportEngine(ITranslationContainer* translationContainer)
 | 
					void TranslationEditor::setReportEngine(ITranslationContainer* translationContainer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_translationContainer = translationContainer;
 | 
					    m_translationContainer = translationContainer;
 | 
				
			||||||
 | 
					    m_currentReportTranslation = 0;
 | 
				
			||||||
 | 
					    m_currentPageTranslation = 0;
 | 
				
			||||||
 | 
					    m_currentPropertyTranslation = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (m_translationContainer){
 | 
					    if (m_translationContainer){
 | 
				
			||||||
        m_translationContainer->updateTranslations();
 | 
					        m_translationContainer->updateTranslations();
 | 
				
			||||||
        updateUi();
 | 
					        updateUi();
 | 
				
			||||||
@@ -43,10 +51,22 @@ TranslationEditor::~TranslationEditor()
 | 
				
			|||||||
    delete ui;
 | 
					    delete ui;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QLocale::Language TranslationEditor::getLanguageByName(const QString& languageName){
 | 
				
			||||||
 | 
					   foreach(QLocale::Language language, m_translationContainer->translations()->keys()){
 | 
				
			||||||
 | 
					       if (QLocale::languageToString(language).compare(languageName) == 0){
 | 
				
			||||||
 | 
					           return language;
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					   return QLocale::AnyLanguage;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TranslationEditor::updateUi()
 | 
					void TranslationEditor::updateUi()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ui->lvLanguages->clear();
 | 
					    ui->lvLanguages->clear();
 | 
				
			||||||
 | 
					    ui->twPages->clear();
 | 
				
			||||||
 | 
					    ui->tbStrings->clearContents();
 | 
				
			||||||
 | 
					    ui->teTranslation->setPlainText("");
 | 
				
			||||||
 | 
					    ui->cbChecked->setEnabled(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_ASSERT(m_translationContainer != 0);
 | 
					    Q_ASSERT(m_translationContainer != 0);
 | 
				
			||||||
    if (m_translationContainer){
 | 
					    if (m_translationContainer){
 | 
				
			||||||
@@ -54,11 +74,12 @@ void TranslationEditor::updateUi()
 | 
				
			|||||||
        Q_ASSERT(translations != 0);
 | 
					        Q_ASSERT(translations != 0);
 | 
				
			||||||
        if (translations){
 | 
					        if (translations){
 | 
				
			||||||
            foreach(QLocale::Language language, translations->keys()){
 | 
					            foreach(QLocale::Language language, translations->keys()){
 | 
				
			||||||
                ui->lvLanguages->addItem(QLocale::languageToString(language));
 | 
					                if (language != QLocale::AnyLanguage)
 | 
				
			||||||
 | 
					                    ui->lvLanguages->addItem(QLocale::languageToString(language));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (!translations->keys().isEmpty()){
 | 
					            if (!translations->keys().isEmpty()){
 | 
				
			||||||
                ui->lvLanguages->item(0)->setSelected(true);
 | 
					                ui->lvLanguages->item(0)->setSelected(true);
 | 
				
			||||||
                activateLanguage(translations->keys().at(0));
 | 
					                activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text()));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -138,18 +159,22 @@ void TranslationEditor::activateTranslation(const QString& itemName, const QStri
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void TranslationEditor::on_tbStrings_itemSelectionChanged()
 | 
					void TranslationEditor::on_tbStrings_itemSelectionChanged()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    activateTranslation(ui->tbStrings->item(ui->tbStrings->currentRow(),1)->text(), ui->tbStrings->item(ui->tbStrings->currentRow(),2)->text());
 | 
					    if (m_currentPageTranslation)
 | 
				
			||||||
 | 
					        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()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_currentPropertyTranslation->value = ui->teTranslation->toPlainText();
 | 
					    if (m_currentPropertyTranslation)
 | 
				
			||||||
 | 
					        m_currentPropertyTranslation->value = ui->teTranslation->toPlainText();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TranslationEditor::on_cbChecked_toggled(bool checked)
 | 
					void TranslationEditor::on_cbChecked_toggled(bool checked)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_currentPropertyTranslation->checked = checked;
 | 
					    if (m_currentPropertyTranslation){
 | 
				
			||||||
    ui->tbStrings->item(ui->tbStrings->currentRow(),0)->setIcon(checked ? QIcon(":/translationeditor/images/checked.png"):QIcon());
 | 
					        m_currentPropertyTranslation->checked = checked;
 | 
				
			||||||
 | 
					        ui->tbStrings->item(ui->tbStrings->currentRow(),0)->setIcon(checked ? QIcon(":/translationeditor/images/checked.png"):QIcon());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TranslationEditor::on_twPages_itemSelectionChanged()
 | 
					void TranslationEditor::on_twPages_itemSelectionChanged()
 | 
				
			||||||
@@ -159,7 +184,42 @@ void TranslationEditor::on_twPages_itemSelectionChanged()
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TranslationEditor::on_tbAddLanguage_clicked()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    LanguageSelectDialog dialog;
 | 
				
			||||||
 | 
					    if (dialog.exec()){
 | 
				
			||||||
 | 
					        m_translationContainer->addTranslationLanguage(dialog.getSelectedLanguage());
 | 
				
			||||||
 | 
					        updateUi();
 | 
				
			||||||
 | 
					        activateLanguage(dialog.getSelectedLanguage());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TranslationEditor::on_tbDeleteLanguage_clicked()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    m_translationContainer->removeTranslationLanguage(m_currentReportTranslation->language());
 | 
				
			||||||
 | 
					    updateUi();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TranslationEditor::slotItemChecked()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (ui->tbStrings->currentRow()<ui->tbStrings->rowCount()){
 | 
				
			||||||
 | 
					        ui->cbChecked->setChecked(true);
 | 
				
			||||||
 | 
					        ui->tbStrings->selectRow(ui->tbStrings->currentRow()+1);
 | 
				
			||||||
 | 
					        ui->teTranslation->setFocus();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TranslationEditor::on_lvLanguages_itemSelectionChanged()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (ui->lvLanguages->currentItem() && m_currentReportTranslation){
 | 
				
			||||||
 | 
					        activateLanguage(getLanguageByName(ui->lvLanguages->currentItem()->text()));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} //namespace LimeReport
 | 
					} //namespace LimeReport
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,14 @@ private slots:
 | 
				
			|||||||
    void on_tbStrings_itemSelectionChanged();
 | 
					    void on_tbStrings_itemSelectionChanged();
 | 
				
			||||||
    void on_teTranslation_textChanged();
 | 
					    void on_teTranslation_textChanged();
 | 
				
			||||||
    void on_cbChecked_toggled(bool checked);
 | 
					    void on_cbChecked_toggled(bool checked);
 | 
				
			||||||
    void on_twPages_itemSelectionChanged();
 | 
					    void on_twPages_itemSelectionChanged();   
 | 
				
			||||||
 | 
					    void on_tbAddLanguage_clicked();
 | 
				
			||||||
 | 
					    void on_tbDeleteLanguage_clicked();
 | 
				
			||||||
 | 
					    void slotItemChecked();
 | 
				
			||||||
 | 
					    void on_lvLanguages_itemSelectionChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    QLocale::Language getLanguageByName(const QString& languageName);
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    Ui::TranslationEditor *ui;
 | 
					    Ui::TranslationEditor *ui;
 | 
				
			||||||
    ITranslationContainer* m_translationContainer;
 | 
					    ITranslationContainer* m_translationContainer;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,7 +56,7 @@
 | 
				
			|||||||
              </spacer>
 | 
					              </spacer>
 | 
				
			||||||
             </item>
 | 
					             </item>
 | 
				
			||||||
             <item>
 | 
					             <item>
 | 
				
			||||||
              <widget class="QToolButton" name="toolButton">
 | 
					              <widget class="QToolButton" name="tbAddLanguage">
 | 
				
			||||||
               <property name="text">
 | 
					               <property name="text">
 | 
				
			||||||
                <string>...</string>
 | 
					                <string>...</string>
 | 
				
			||||||
               </property>
 | 
					               </property>
 | 
				
			||||||
@@ -64,10 +64,13 @@
 | 
				
			|||||||
                <iconset resource="translationeditor.qrc">
 | 
					                <iconset resource="translationeditor.qrc">
 | 
				
			||||||
                 <normaloff>:/translationeditor/images/add.png</normaloff>:/translationeditor/images/add.png</iconset>
 | 
					                 <normaloff>:/translationeditor/images/add.png</normaloff>:/translationeditor/images/add.png</iconset>
 | 
				
			||||||
               </property>
 | 
					               </property>
 | 
				
			||||||
 | 
					               <property name="autoRaise">
 | 
				
			||||||
 | 
					                <bool>true</bool>
 | 
				
			||||||
 | 
					               </property>
 | 
				
			||||||
              </widget>
 | 
					              </widget>
 | 
				
			||||||
             </item>
 | 
					             </item>
 | 
				
			||||||
             <item>
 | 
					             <item>
 | 
				
			||||||
              <widget class="QToolButton" name="toolButton_2">
 | 
					              <widget class="QToolButton" name="tbDeleteLanguage">
 | 
				
			||||||
               <property name="text">
 | 
					               <property name="text">
 | 
				
			||||||
                <string>...</string>
 | 
					                <string>...</string>
 | 
				
			||||||
               </property>
 | 
					               </property>
 | 
				
			||||||
@@ -75,6 +78,9 @@
 | 
				
			|||||||
                <iconset resource="translationeditor.qrc">
 | 
					                <iconset resource="translationeditor.qrc">
 | 
				
			||||||
                 <normaloff>:/translationeditor/images/remove.png</normaloff>:/translationeditor/images/remove.png</iconset>
 | 
					                 <normaloff>:/translationeditor/images/remove.png</normaloff>:/translationeditor/images/remove.png</iconset>
 | 
				
			||||||
               </property>
 | 
					               </property>
 | 
				
			||||||
 | 
					               <property name="autoRaise">
 | 
				
			||||||
 | 
					                <bool>true</bool>
 | 
				
			||||||
 | 
					               </property>
 | 
				
			||||||
              </widget>
 | 
					              </widget>
 | 
				
			||||||
             </item>
 | 
					             </item>
 | 
				
			||||||
            </layout>
 | 
					            </layout>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user