Changeset c1dc0c9 in subsurface


Ignore:
Timestamp:
Jan 23, 2017, 10:11:51 PM (2 months ago)
Author:
Subsurface <dirk@…>
Branches:
master
Children:
c49f0446
Parents:
79bba04f
git-author:
Robert C. Helling <helling@…> (01/23/17 08:35:27)
git-committer:
Subsurface <dirk@…> (01/23/17 22:11:51)
Message:

Allow user to disable a cylinder in planner

In the cylinder table, the last column ("use") always showed
OC-GAS. Editing was enabled, but the user had to guess to enter
a small integer meaning dilluent or CCR oxygen cylingder. I guess,
nobody has ever done that.

This patch makes this column clickable. A click toggles if the cylinder
is used for planning or not. This wait it is much easier to investigate
the consequences of gas loss on a plan.

Signed-off-by: Robert C. Helling <helling@…>

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • core/dive.c

    r638e7fb rc1dc0c9  
    3131
    3232const char *cylinderuse_text[] = {
    33         QT_TRANSLATE_NOOP("gettextFromC", "OC-gas"), QT_TRANSLATE_NOOP("gettextFromC", "diluent"), QT_TRANSLATE_NOOP("gettextFromC", "oxygen")
     33        QT_TRANSLATE_NOOP("gettextFromC", "OC-gas"), QT_TRANSLATE_NOOP("gettextFromC", "diluent"), QT_TRANSLATE_NOOP("gettextFromC", "oxygen"), QT_TRANSLATE_NOOP("gettextFromC", "not used")
    3434};
    3535const char *divemode_text[] = { "OC", "CCR", "PSCR", "Freedive" };
  • core/dive.h

    r7725842 rc1dc0c9  
    5757
    5858enum dive_comp_type {OC, CCR, PSCR, FREEDIVE, NUM_DC_TYPE};     // Flags (Open-circuit and Closed-circuit-rebreather) for setting dive computer type
    59 enum cylinderuse {OC_GAS, DILUENT, OXYGEN, NUM_GAS_USE}; // The different uses for cylinders
     59enum cylinderuse {OC_GAS, DILUENT, OXYGEN, NOT_USED, NUM_GAS_USE}; // The different uses for cylinders
    6060
    6161extern const char *cylinderuse_text[];
  • qt-models/cylindermodel.cpp

    r7f7c008 rc1dc0c9  
    481481Qt::ItemFlags CylindersModel::flags(const QModelIndex &index) const
    482482{
    483         if (index.column() == REMOVE)
     483        if (index.column() == REMOVE || index.column() == USE)
    484484                return Qt::ItemIsEnabled;
    485485        return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
     
    489489{
    490490        int mapping[MAX_CYLINDERS];
     491
     492        if (index.column() == USE) {
     493                cylinder_t *cyl = cylinderAt(index);
     494                if (cyl->cylinder_use == OC_GAS)
     495                        cyl->cylinder_use = NOT_USED;
     496                else if (cyl->cylinder_use == NOT_USED)
     497                        cyl->cylinder_use = OC_GAS;
     498                changed = true;
     499                dataChanged(index, index);
     500                return;
     501        }
    491502        if (index.column() != REMOVE) {
    492503                return;
  • qt-models/diveplannermodel.cpp

    r79bba04f rc1dc0c9  
    799799        for (int i = 0; i < MAX_CYLINDERS; i++) {
    800800                cylinder_t *cyl = &displayed_dive.cylinder[i];
    801                 if (cyl->depth.mm) {
     801                if (cyl->depth.mm && cyl->cylinder_use != NOT_USED) {
    802802                        dp = create_dp(0, cyl->depth.mm, i, 0);
    803803                        if (diveplan.dp) {
Note: See TracChangeset for help on using the changeset viewer.