summaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-02 10:10:55 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-02 10:19:59 -0800
commit768cab66ccdf4e2619b7c143638e85dce43592e1 (patch)
treebb2f38ad5139a9f83c8451a90d6464d85430612a /qt-ui/models.cpp
parent3c064d58578fac536095b68236ae2296935563b4 (diff)
downloadsubsurface-768cab66ccdf4e2619b7c143638e85dce43592e1.tar.gz
Third time's a charm: translating weight system description
Still trying to fix the same issue that I already tried to address in commit e0b70b82cad9 ("Fix translation of weightsystem names") and before in commit dc03b7e7d689 ("We need the correct context to translate event names"). I missed the WeightModel. Hopefully this was indeed the real fix. Fixes #312 (I know, I keep saying that) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r--qt-ui/models.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index d7add1b3f..f53c068e6 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -445,7 +445,7 @@ QVariant WeightModel::data(const QModelIndex& index, int role) const
case Qt::EditRole:
switch(index.column()) {
case TYPE:
- ret = QString(ws->description);
+ ret = gettextFromC::instance()->tr(ws->description);
break;
case WEIGHT:
ret = get_weight_string(ws->weight, TRUE);
@@ -484,10 +484,8 @@ bool WeightModel::setData(const QModelIndex& index, const QVariant& value, int r
switch(index.column()) {
case TYPE:
if (!value.isNull()) {
- QByteArray ba = value.toString().toUtf8();
- const char *text = ba.constData();
- if (!ws->description || strcmp(ws->description, text)) {
- ws->description = strdup(text);
+ if (!ws->description || gettextFromC::instance()->tr(ws->description) != value.toString()) {
+ ws->description = strdup(value.toString().toUtf8().constData());
changed = true;
}
}
@@ -501,7 +499,7 @@ bool WeightModel::setData(const QModelIndex& index, const QVariant& value, int r
// now update the ws_info
changed = true;
WSInfoModel *wsim = WSInfoModel::instance();
- QModelIndexList matches = wsim->match(wsim->index(0,0), Qt::DisplayRole, ws->description);
+ QModelIndexList matches = wsim->match(wsim->index(0,0), Qt::DisplayRole, gettextFromC::instance()->tr(ws->description));
if (!matches.isEmpty())
wsim->setData(wsim->index(matches.first().row(), WSInfoModel::GR), ws->weight.grams);
}
@@ -634,7 +632,7 @@ WSInfoModel::WSInfoModel() : rows(-1)
setHeaderDataStrings( QStringList() << tr("Description") << tr("kg"));
struct ws_info_t *info = ws_info;
for (info = ws_info; info->name; info++, rows++){
- QString wsInfoName(info->name);
+ QString wsInfoName = gettextFromC::instance()->tr(info->name);
if( wsInfoName.count() > biggerEntry.count())
biggerEntry = wsInfoName;
}
@@ -652,7 +650,7 @@ void WSInfoModel::updateInfo()
endRemoveRows();
rows = -1;
for (info = ws_info; info->name; info++, rows++){
- QString wsInfoName(info->name);
+ QString wsInfoName = gettextFromC::instance()->tr(info->name);
if( wsInfoName.count() > biggerEntry.count())
biggerEntry = wsInfoName;
}