Distinguish between user and internal divemode names

The former should be translated but not those that
go to xml/git.

... and fix capitalization of pSCR.

Suggested-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
Robert C. Helling 2018-05-17 10:04:41 +02:00
parent 424efb7720
commit 7c6e5ed5db
7 changed files with 27 additions and 12 deletions

View file

@ -35,7 +35,17 @@ static const char *default_tags[] = {
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")
};
const char *divemode_text[] = { "OC", "CCR", "PSCR", "Freedive" };
// For user visible text
const char *divemode_text_ui[] = {
QT_TRANSLATE_NOOP("gettextFromC", "Open circuit"),
QT_TRANSLATE_NOOP("gettextFromC", "CCR"),
QT_TRANSLATE_NOOP("gettextFromC", "pSCR"),
QT_TRANSLATE_NOOP("gettextFromC", "Freedive")
};
// For writing/reading files.
const char *divemode_text[] = {"OC", "CCR", "pSCR", "Freedive"};
/*
* Adding a cylinder pressure sample field is not quite as trivial as it

View file

@ -31,6 +31,7 @@ enum divemode_t {OC, CCR, PSCR, FREEDIVE, NUM_DIVEMODE, UNDEF_COMP_TYPE}; // Fla
enum cylinderuse {OC_GAS, DILUENT, OXYGEN, NOT_USED, NUM_GAS_USE}; // The different uses for cylinders
extern const char *cylinderuse_text[];
extern const char *divemode_text_ui[];
extern const char *divemode_text[];
struct gasmix {

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(translate("gettextFromC","OC"));
stats_by_type[1].location = strdup(divemode_text_ui[OC]);
stats_by_type[1].is_trip = true;
stats_by_type[2].location = strdup(translate("gettextFromC","CCR"));
stats_by_type[2].location = strdup(divemode_text_ui[CCR]);
stats_by_type[2].is_trip = true;
stats_by_type[3].location = strdup(translate("gettextFromC","pSCR"));
stats_by_type[3].location = strdup(divemode_text_ui[PSCR]);
stats_by_type[3].is_trip = true;
stats_by_type[4].location = strdup(translate("gettextFromC","Freedive"));
stats_by_type[4].location = strdup(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

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

View file

@ -109,7 +109,10 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
connect(ui.weights, SIGNAL(addButtonClicked()), this, SLOT(addWeight_clicked()));
// This needs to be the same order as enum dive_comp_type in dive.h!
ui.DiveType->insertItems(0, QStringList() << tr("OC") << tr("CCR") << tr("pSCR") << tr("Freedive"));
QStringList types = QStringList();
for (int i = 0; i < NUM_DIVEMODE; i++)
types.append(QString(divemode_text_ui[i]));
ui.DiveType->insertItems(0, types);
connect(ui.DiveType, SIGNAL(currentIndexChanged(int)), this, SLOT(divetype_Changed(int)));
connect(ui.cylinders->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex)));

View file

@ -194,7 +194,7 @@ void DiveEventItem::setupToolTipString(struct gasmix *lastgasmix)
}
*lastgasmix = *mix;
} else if (same_string(internalEvent->name, "modechange")) {
name += tr(": %1").arg(divemode_text[internalEvent->value]);
name += tr(": %1").arg(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

@ -1433,21 +1433,21 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
QMenu *changeMode = m.addMenu(tr("Change divemode"));
if (divemode != OC) {
QAction *action = new QAction(&m);
action->setText("OC");
action->setText(divemode_text_ui[OC]);
connect(action, SIGNAL(triggered(bool)), this, SLOT(addDivemodeSwith()));
action->setData(event->globalPos());
changeMode->addAction(action);
}
if (divemode != CCR) {
QAction *action = new QAction(&m);
action->setText("CCR");
action->setText(divemode_text_ui[CCR]);
connect(action, SIGNAL(triggered(bool)), this, SLOT(addDivemodeSwith()));
action->setData(event->globalPos());
changeMode->addAction(action);
}
if (divemode != PSCR) {
QAction *action = new QAction(&m);
action->setText("PSCR");
action->setText(divemode_text_ui[PSCR]);
connect(action, SIGNAL(triggered(bool)), this, SLOT(addDivemodeSwith()));
action->setData(event->globalPos());
changeMode->addAction(action);
@ -1619,7 +1619,7 @@ void ProfileWidget2::addDivemodeSwith()
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[i]) == action->text())
if (QString(divemode_text_ui[i]) == action->text())
add_event(current_dc, lrint(timeAxis->valueAt(scenePos)), 8, 0, i, "modechange");
invalidate_dive_cache(current_dive);
mark_divelist_changed(true);