diff options
-rw-r--r-- | qt-models/cleanertablemodel.cpp | 11 | ||||
-rw-r--r-- | qt-models/cylindermodel.cpp | 69 | ||||
-rw-r--r-- | qt-models/weightmodel.cpp | 29 |
3 files changed, 41 insertions, 68 deletions
diff --git a/qt-models/cleanertablemodel.cpp b/qt-models/cleanertablemodel.cpp index 36b0f4e76..fc4e93b16 100644 --- a/qt-models/cleanertablemodel.cpp +++ b/qt-models/cleanertablemodel.cpp @@ -31,19 +31,16 @@ int CleanerTableModel::columnCount(const QModelIndex&) const QVariant CleanerTableModel::headerData(int section, Qt::Orientation orientation, int role) const { - QVariant ret; - if (orientation == Qt::Vertical) - return ret; + return QVariant(); switch (role) { case Qt::FontRole: - ret = defaultModelFont(); - break; + return defaultModelFont(); case Qt::DisplayRole: - ret = headers.at(section); + return headers.at(section); } - return ret; + return QVariant(); } void CleanerTableModel::setHeaderDataStrings(const QStringList &newHeaders) diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 52adda753..0e5388818 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -132,10 +132,8 @@ static QVariant percent_string(fraction_t fraction) QVariant CylindersModel::data(const QModelIndex &index, int role) const { - QVariant ret; - if (!index.isValid() || index.row() >= MAX_CYLINDERS) - return ret; + return QVariant(); cylinder_t *cyl = &displayed_dive.cylinder[index.row()]; @@ -151,7 +149,7 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const endp = cyl->end.mbar ? cyl->end : cyl->sample_end; if ((startp.mbar && !endp.mbar) || (endp.mbar && startp.mbar <= endp.mbar)) - ret = REDORANGE1_HIGH_TRANS; + return REDORANGE1_HIGH_TRANS; break; } break; @@ -167,65 +165,57 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const font.setItalic(!cyl->end.mbar); break; } - ret = font; - break; + return font; } case Qt::TextAlignmentRole: - ret = Qt::AlignCenter; - break; + return Qt::AlignCenter; case Qt::DisplayRole: case Qt::EditRole: switch (index.column()) { case TYPE: - ret = QString(cyl->type.description); - break; + return QString(cyl->type.description); case SIZE: if (cyl->type.size.mliter) - ret = get_cylinder_string(cyl); + return get_cylinder_string(cyl); break; case WORKINGPRESS: if (cyl->type.workingpressure.mbar) - ret = get_pressure_string(cyl->type.workingpressure, true); + return get_pressure_string(cyl->type.workingpressure, true); break; case START: if (cyl->start.mbar) - ret = get_pressure_string(cyl->start, true); + return get_pressure_string(cyl->start, true); else if (cyl->sample_start.mbar) - ret = get_pressure_string(cyl->sample_start, true); + return get_pressure_string(cyl->sample_start, true); break; case END: if (cyl->end.mbar) - ret = get_pressure_string(cyl->end, true); + return get_pressure_string(cyl->end, true); else if (cyl->sample_end.mbar) - ret = get_pressure_string(cyl->sample_end, true); + return get_pressure_string(cyl->sample_end, true); break; case O2: - ret = percent_string(cyl->gasmix.o2); - break; + return percent_string(cyl->gasmix.o2); case HE: - ret = percent_string(cyl->gasmix.he); - break; + return percent_string(cyl->gasmix.he); case DEPTH: - ret = get_depth_string(cyl->depth, true); - break; + return get_depth_string(cyl->depth, true); case MOD: if (cyl->bestmix_o2) { - ret = QString("*"); + return QStringLiteral("*"); } else { pressure_t modpO2; modpO2.mbar = prefs.bottompo2; - ret = get_depth_string(gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(1,1)), true); + return get_depth_string(gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(1,1)), true); } - break; case MND: if (cyl->bestmix_he) - ret = QString("*"); + return QStringLiteral("*"); else - ret = get_depth_string(gas_mnd(cyl->gasmix, prefs.bestmixend, &displayed_dive, M_OR_FT(1,1)), true); + return get_depth_string(gas_mnd(cyl->gasmix, prefs.bestmixend, &displayed_dive, M_OR_FT(1,1)), true); break; case USE: - ret = gettextFromC::tr(cylinderuse_text[cyl->cylinder_use]); - break; + return gettextFromC::tr(cylinderuse_text[cyl->cylinder_use]); } break; case Qt::DecorationRole: @@ -233,21 +223,19 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const if (index.column() == REMOVE) { if ((in_planner() && DivePlannerPointsModel::instance()->tankInUse(index.row())) || (!in_planner() && is_cylinder_prot(&displayed_dive, index.row()))) { - ret = trashForbiddenIcon(); + return trashForbiddenIcon(); } - else ret = trashIcon(); + return trashIcon(); } break; - case Qt::ToolTipRole: switch (index.column()) { case REMOVE: if ((in_planner() && DivePlannerPointsModel::instance()->tankInUse(index.row())) || (!in_planner() && is_cylinder_prot(&displayed_dive, index.row()))) { - ret = tr("This gas is in use. Only cylinders that are not used in the dive can be removed."); + return tr("This gas is in use. Only cylinders that are not used in the dive can be removed."); } - else ret = tr("Clicking here will remove this cylinder."); - break; + return tr("Clicking here will remove this cylinder."); case TYPE: case SIZE: return gas_usage_tooltip(cyl); @@ -258,19 +246,16 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const case END: return gas_end_tooltip(cyl); case DEPTH: - ret = tr("Switch depth for deco gas. Calculated using Deco pO₂ preference, unless set manually."); - break; + return tr("Switch depth for deco gas. Calculated using Deco pO₂ preference, unless set manually."); case MOD: - ret = tr("Calculated using Bottom pO₂ preference. Setting MOD adjusts O₂%, set to '*' for best O₂% for max. depth."); - break; + return tr("Calculated using Bottom pO₂ preference. Setting MOD adjusts O₂%, set to '*' for best O₂% for max. depth."); case MND: - ret = tr("Calculated using Best Mix END preference. Setting MND adjusts He%, set to '*' for best He% for max. depth."); - break; + return tr("Calculated using Best Mix END preference. Setting MND adjusts He%, set to '*' for best He% for max. depth."); } break; } - return ret; + return QVariant(); } cylinder_t *CylindersModel::cylinderAt(const QModelIndex &index) diff --git a/qt-models/weightmodel.cpp b/qt-models/weightmodel.cpp index 8f3267359..7285e40cd 100644 --- a/qt-models/weightmodel.cpp +++ b/qt-models/weightmodel.cpp @@ -24,9 +24,8 @@ weightsystem_t *WeightModel::weightSystemAt(const QModelIndex &index) void WeightModel::remove(const QModelIndex &index) { - if (index.column() != REMOVE) { + if (index.column() != REMOVE) return; - } beginRemoveRows(QModelIndex(), index.row(), index.row()); // yah, know, ugly. rows--; remove_weightsystem(&displayed_dive, index.row()); @@ -44,44 +43,36 @@ void WeightModel::clear() QVariant WeightModel::data(const QModelIndex &index, int role) const { - QVariant ret; if (!index.isValid() || index.row() >= MAX_WEIGHTSYSTEMS) - return ret; + return QVariant(); weightsystem_t *ws = &displayed_dive.weightsystem[index.row()]; switch (role) { case Qt::FontRole: - ret = defaultModelFont(); - break; + return defaultModelFont(); case Qt::TextAlignmentRole: - ret = Qt::AlignCenter; - break; + return Qt::AlignCenter; case Qt::DisplayRole: case Qt::EditRole: switch (index.column()) { case TYPE: - ret = gettextFromC::tr(ws->description); - break; + return gettextFromC::tr(ws->description); case WEIGHT: - ret = get_weight_string(ws->weight, true); - break; + return get_weight_string(ws->weight, true); } break; case Qt::DecorationRole: if (index.column() == REMOVE) - ret = trashIcon(); - break; + return trashIcon(); case Qt::SizeHintRole: if (index.column() == REMOVE) - ret = trashIcon().size(); - break; + return trashIcon().size(); case Qt::ToolTipRole: if (index.column() == REMOVE) - ret = tr("Clicking here will remove this weight system."); - break; + return tr("Clicking here will remove this weight system."); } - return ret; + return QVariant(); } // this is our magic 'pass data in' function that allows the delegate to get |