mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Third time's a charm: translating weight system description
Still trying to fix the same issue that I already tried to address in commite0b70b82ca
("Fix translation of weightsystem names") and before in commitdc03b7e7d6
("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>
This commit is contained in:
parent
3c064d5857
commit
768cab66cc
1 changed files with 6 additions and 8 deletions
|
@ -445,7 +445,7 @@ QVariant WeightModel::data(const QModelIndex& index, int role) const
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
switch(index.column()) {
|
switch(index.column()) {
|
||||||
case TYPE:
|
case TYPE:
|
||||||
ret = QString(ws->description);
|
ret = gettextFromC::instance()->tr(ws->description);
|
||||||
break;
|
break;
|
||||||
case WEIGHT:
|
case WEIGHT:
|
||||||
ret = get_weight_string(ws->weight, TRUE);
|
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()) {
|
switch(index.column()) {
|
||||||
case TYPE:
|
case TYPE:
|
||||||
if (!value.isNull()) {
|
if (!value.isNull()) {
|
||||||
QByteArray ba = value.toString().toUtf8();
|
if (!ws->description || gettextFromC::instance()->tr(ws->description) != value.toString()) {
|
||||||
const char *text = ba.constData();
|
ws->description = strdup(value.toString().toUtf8().constData());
|
||||||
if (!ws->description || strcmp(ws->description, text)) {
|
|
||||||
ws->description = strdup(text);
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -501,7 +499,7 @@ bool WeightModel::setData(const QModelIndex& index, const QVariant& value, int r
|
||||||
// now update the ws_info
|
// now update the ws_info
|
||||||
changed = true;
|
changed = true;
|
||||||
WSInfoModel *wsim = WSInfoModel::instance();
|
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())
|
if (!matches.isEmpty())
|
||||||
wsim->setData(wsim->index(matches.first().row(), WSInfoModel::GR), ws->weight.grams);
|
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"));
|
setHeaderDataStrings( QStringList() << tr("Description") << tr("kg"));
|
||||||
struct ws_info_t *info = ws_info;
|
struct ws_info_t *info = ws_info;
|
||||||
for (info = ws_info; info->name; info++, rows++){
|
for (info = ws_info; info->name; info++, rows++){
|
||||||
QString wsInfoName(info->name);
|
QString wsInfoName = gettextFromC::instance()->tr(info->name);
|
||||||
if( wsInfoName.count() > biggerEntry.count())
|
if( wsInfoName.count() > biggerEntry.count())
|
||||||
biggerEntry = wsInfoName;
|
biggerEntry = wsInfoName;
|
||||||
}
|
}
|
||||||
|
@ -652,7 +650,7 @@ void WSInfoModel::updateInfo()
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
rows = -1;
|
rows = -1;
|
||||||
for (info = ws_info; info->name; info++, rows++){
|
for (info = ws_info; info->name; info++, rows++){
|
||||||
QString wsInfoName(info->name);
|
QString wsInfoName = gettextFromC::instance()->tr(info->name);
|
||||||
if( wsInfoName.count() > biggerEntry.count())
|
if( wsInfoName.count() > biggerEntry.count())
|
||||||
biggerEntry = wsInfoName;
|
biggerEntry = wsInfoName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue