Fix an error around translation of dive modes in the UI

This fixes an mistake introduced in
3d1072f886

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
Stefan Fuchs 2018-06-16 16:30:03 +02:00 committed by Dirk Hohndel
parent 4ccc4d7329
commit 0bc9edf855
8 changed files with 14 additions and 14 deletions

View file

@ -36,7 +36,7 @@ const char *cylinderuse_text[] = {
QT_TRANSLATE_NOOP("gettextFromC", "OC-gas"), QT_TRANSLATE_NOOP("gettextFromC", "diluent"), QT_TRANSLATE_NOOP("gettextFromC", "oxygen"), QT_TRANSLATE_NOOP("gettextFromC", "not used")
};
// For user visible text
// For user visible text but still not translated
const char *divemode_text_ui[] = {
QT_TRANSLATE_NOOP("gettextFromC", "Open circuit"),
QT_TRANSLATE_NOOP("gettextFromC", "CCR"),

View file

@ -140,13 +140,13 @@ void process_all_dives(struct dive *dive, struct dive **prev_dive)
* field in the statistics window */
stats_by_type[0].location = strdup(translate("gettextFromC", "All (by type stats)"));
stats_by_type[0].is_trip = true;
stats_by_type[1].location = strdup(divemode_text_ui[OC]);
stats_by_type[1].location = strdup(translate("gettextFromC", divemode_text_ui[OC]));
stats_by_type[1].is_trip = true;
stats_by_type[2].location = strdup(divemode_text_ui[CCR]);
stats_by_type[2].location = strdup(translate("gettextFromC", divemode_text_ui[CCR]));
stats_by_type[2].is_trip = true;
stats_by_type[3].location = strdup(divemode_text_ui[PSCR]);
stats_by_type[3].location = strdup(translate("gettextFromC", divemode_text_ui[PSCR]));
stats_by_type[3].is_trip = true;
stats_by_type[4].location = strdup(divemode_text_ui[FREEDIVE]);
stats_by_type[4].location = strdup(translate("gettextFromC", divemode_text_ui[FREEDIVE]));
stats_by_type[4].is_trip = true;
/* this relies on the fact that the dives in the dive_table

View file

@ -448,7 +448,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
// should be the same order as in dive_comp_type!
for (int i=0; i < FREEDIVE; i++)
rebreather_modes.append(QString(divemode_text_ui[i]));
rebreather_modes.append(QString(tr(divemode_text_ui[i])));
ui.rebreathermode->insertItems(0, rebreather_modes);
modeMapper = new QSignalMapper(this);

View file

@ -111,7 +111,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
// This needs to be the same order as enum dive_comp_type in dive.h!
QStringList types = QStringList();
for (int i = 0; i < NUM_DIVEMODE; i++)
types.append(QString(divemode_text_ui[i]));
types.append(QString(tr(divemode_text_ui[i])));
ui.DiveType->insertItems(0, types);
connect(ui.DiveType, SIGNAL(currentIndexChanged(int)), this, SLOT(divetype_Changed(int)));

View file

@ -194,7 +194,7 @@ void DiveEventItem::setupToolTipString(struct gasmix *lastgasmix)
}
*lastgasmix = *mix;
} else if (same_string(internalEvent->name, "modechange")) {
name += QString(": %1").arg(divemode_text_ui[internalEvent->value]);
name += QString(": %1").arg(tr(divemode_text_ui[internalEvent->value]));
} else if (value) {
if (type == SAMPLE_EVENT_PO2 && same_string(internalEvent->name, "SP change")) {
name += QString(": %1bar").arg((double)value / 1000, 0, 'f', 1);

View file

@ -1436,21 +1436,21 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
QMenu *changeMode = m.addMenu(tr("Change divemode"));
if (divemode != OC) {
QAction *action = new QAction(&m);
action->setText(divemode_text_ui[OC]);
action->setText(tr(divemode_text_ui[OC]));
connect(action, SIGNAL(triggered(bool)), this, SLOT(addDivemodeSwitch()));
action->setData(event->globalPos());
changeMode->addAction(action);
}
if (divemode != CCR) {
QAction *action = new QAction(&m);
action->setText(divemode_text_ui[CCR]);
action->setText(tr(divemode_text_ui[CCR]));
connect(action, SIGNAL(triggered(bool)), this, SLOT(addDivemodeSwitch()));
action->setData(event->globalPos());
changeMode->addAction(action);
}
if (divemode != PSCR) {
QAction *action = new QAction(&m);
action->setText(divemode_text_ui[PSCR]);
action->setText(tr(divemode_text_ui[PSCR]));
connect(action, SIGNAL(triggered(bool)), this, SLOT(addDivemodeSwitch()));
action->setData(event->globalPos());
changeMode->addAction(action);
@ -1622,7 +1622,7 @@ void ProfileWidget2::addDivemodeSwitch()
QAction *action = qobject_cast<QAction *>(sender());
QPointF scenePos = mapToScene(mapFromGlobal(action->data().toPoint()));
for (i = 0; i < UNDEF_COMP_TYPE; i++)
if (QString(divemode_text_ui[i]) == action->text())
if (QString(tr(divemode_text_ui[i])) == action->text())
add_event(current_dc, lrint(timeAxis->valueAt(scenePos)), 8, 0, i,
QT_TRANSLATE_NOOP("gettextFromC", "modechange"));
invalidate_dive_cache(current_dive);

View file

@ -252,7 +252,7 @@ QVariant DivePlannerPointsModel::data(const QModelIndex &index, int role) const
else
return p.time / 60;
case DIVEMODE:
return QString(divemode_text[p.divemode]);
return QString(tr(divemode_text_ui[p.divemode]));
case GAS:
/* Check if we have the same gasmix two or more times
* If yes return more verbose string */

View file

@ -83,7 +83,7 @@ void DiveTypeSelectionModel::repopulate()
{
QStringList modes = QStringList();
for (int i = 0; i < FREEDIVE; i++)
modes.append(QString(divemode_text[i]));
modes.append(QString(tr(divemode_text_ui[i])));
setStringList(modes);
}