QmuParser library now have similar class for translation. Better delete

VTranslation and use QmuTranslation instead.

--HG--
branch : develop
This commit is contained in:
dismine 2014-12-04 19:55:49 +02:00
parent 91bc32b71f
commit 952d5e7a26
5 changed files with 683 additions and 850 deletions

View File

@ -3,12 +3,10 @@
HEADERS += \
$$PWD/vapplication.h \
$$PWD/vtranslation.h \
$$PWD/undoevent.h \
$$PWD/vsettings.h
SOURCES += \
$$PWD/vapplication.cpp \
$$PWD/vtranslation.cpp \
$$PWD/undoevent.cpp \
$$PWD/vsettings.cpp

File diff suppressed because it is too large Load Diff

View File

@ -31,8 +31,8 @@
#include <QApplication>
#include "../options.h"
#include "vtranslation.h"
#include "../widgets/vmaingraphicsview.h"
#include "../../libs/qmuparser/qmutranslation.h"
class VApplication;// used in define
class QUndoStack;
@ -128,13 +128,13 @@ private:
MeasurementsType _patternType;
qreal _widthMainLine;
qreal _widthHairLine;
QMap<QString, VTranslation> measurements;
QMap<QString, VTranslation> guiTexts;
QMap<QString, VTranslation> descriptions;
QMap<QString, VTranslation> variables;
QMap<QString, VTranslation> functions;
QMap<QString, VTranslation> postfixOperators;
QMap<QString, VTranslation> stDescriptions;
QMap<QString, qmu::QmuTranslation> measurements;
QMap<QString, qmu::QmuTranslation> guiTexts;
QMap<QString, qmu::QmuTranslation> descriptions;
QMap<QString, qmu::QmuTranslation> variables;
QMap<QString, qmu::QmuTranslation> functions;
QMap<QString, qmu::QmuTranslation> postfixOperators;
QMap<QString, qmu::QmuTranslation> stDescriptions;
QUndoStack *undoStack;
VMainGraphicsView *sceneView;
VMainGraphicsScene *currentScene;
@ -173,8 +173,8 @@ private:
void CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens,
QMap<int, QString> &numbers);
void BiasTokens(int position, int bias, QMap<int, QString> &tokens) const;
void InitMeasurement(const QString &name, const VTranslation &m, const VTranslation &g,
const VTranslation &d);
void InitMeasurement(const QString &name, const qmu::QmuTranslation &m, const qmu::QmuTranslation &g,
const qmu::QmuTranslation &d);
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
static const QString GistFileName;

View File

@ -1,79 +0,0 @@
/************************************************************************
**
** @file vtranslation.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 5, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2014 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vtranslation.h"
#include <QCoreApplication>
//---------------------------------------------------------------------------------------------------------------------
VTranslation VTranslation::translate(const QString &context, const QString &sourceText, const QString &disambiguation,
int n)
{
if (n < 0)
{
n = -1;
}
VTranslation t(context, sourceText, disambiguation, n);
return t;
}
//---------------------------------------------------------------------------------------------------------------------
VTranslation::VTranslation()
:mcontext(QString()), msourceText(QString()), mdisambiguation(QString()), mn(-1)
{}
//---------------------------------------------------------------------------------------------------------------------
VTranslation::VTranslation(const QString &context, const QString &sourceText, const QString &disambiguation, int n)
:mcontext(context), msourceText(sourceText), mdisambiguation(disambiguation), mn(n)
{}
//---------------------------------------------------------------------------------------------------------------------
VTranslation &VTranslation::operator=(const VTranslation &tr)
{
if ( &tr == this )
{
return *this;
}
this->mcontext = tr.getMcontext();
this->msourceText = tr.getMsourceText();
this->mdisambiguation = tr.getMdisambiguation();
this->mn = tr.getN();
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VTranslation::VTranslation(const VTranslation &tr)
:mcontext(tr.getMcontext()), msourceText(tr.getMsourceText()), mdisambiguation(tr.getMdisambiguation()),
mn(tr.getN())
{}
//---------------------------------------------------------------------------------------------------------------------
QString VTranslation::translate() const
{
return QCoreApplication::translate(mcontext.toUtf8().constData(), msourceText.toUtf8().constData(),
mdisambiguation.toUtf8().constData(), mn);
}

View File

@ -1,95 +0,0 @@
/************************************************************************
**
** @file vtranslation.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 5, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2014 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VTRANSLATION_H
#define VTRANSLATION_H
#include <QString>
/**
* @file
* @brief The VTranslation class help store string for translation.
*
* I took idea from this article http://ololoepepe.blogspot.com/2013/08/qt.html.
* As you know, if wrap string to a function translate, it will be marked for translation. No matter what namespace
* contains this function. In class Translation used this circumstance.
* This mean never change name of method translate!!!!!.
* Instead of using QT_TRANSLATE_NOOP3 macros we can store strings in QMap.
* Example:
* create map and fill up its
* QMap<QString, VTranslation> map;
* map.insert("head_girth", VTranslation::translate("Measurements", "head_girth", "Around fullest part of Head."));
* get translated string
* map.value(measurement).translate();
*/
class VTranslation
{
public:
VTranslation();
VTranslation(const QString &context, const QString &sourceText, const QString &disambiguation = 0, int n = -1);
VTranslation &operator=(const VTranslation &tr);
VTranslation(const VTranslation &tr);
QString translate() const;
static VTranslation translate(const QString &context, const QString &sourceText, const QString &disambiguation = 0,
int n = -1);
QString getMcontext() const;
QString getMsourceText() const;
QString getMdisambiguation() const;
int getN() const;
private:
QString mcontext;
QString msourceText;
QString mdisambiguation;
int mn;
};
//---------------------------------------------------------------------------------------------------------------------
inline QString VTranslation::getMcontext() const
{
return mcontext;
}
//---------------------------------------------------------------------------------------------------------------------
inline QString VTranslation::getMsourceText() const
{
return msourceText;
}
//---------------------------------------------------------------------------------------------------------------------
inline QString VTranslation::getMdisambiguation() const
{
return mdisambiguation;
}
//---------------------------------------------------------------------------------------------------------------------
inline int VTranslation::getN() const
{
return mn;
}
#endif // VTRANSLATION_H