mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 00:23:23 +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:
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue