Always use emitDataChanged() in diveplannermodel.cpp

Use the function in every place instead of once using it and once copying the code again.
No functional change.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
Stefan Fuchs 2017-02-15 23:15:08 +01:00 committed by Dirk Hohndel
parent 83aff9f777
commit 93763f3164

View file

@ -321,7 +321,7 @@ void DivePlannerPointsModel::gaschange(const QModelIndex &index, int newcylinder
int i = index.row(), oldcylinderid = divepoints[i].cylinderid; int i = index.row(), oldcylinderid = divepoints[i].cylinderid;
while (i < rowCount() && oldcylinderid == divepoints[i].cylinderid) while (i < rowCount() && oldcylinderid == divepoints[i].cylinderid)
divepoints[i++].cylinderid = newcylinderid; divepoints[i++].cylinderid = newcylinderid;
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orientation, int role) const QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orientation, int role) const
@ -385,7 +385,7 @@ void DivePlannerPointsModel::setBottomSac(double sac)
diveplan.bottomsac = units_to_sac(sac); diveplan.bottomsac = units_to_sac(sac);
auto planner = SettingsObjectWrapper::instance()->planner_settings; auto planner = SettingsObjectWrapper::instance()->planner_settings;
planner->setBottomSac(diveplan.bottomsac); planner->setBottomSac(diveplan.bottomsac);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setDecoSac(double sac) void DivePlannerPointsModel::setDecoSac(double sac)
@ -393,7 +393,7 @@ void DivePlannerPointsModel::setDecoSac(double sac)
diveplan.decosac = units_to_sac(sac); diveplan.decosac = units_to_sac(sac);
auto planner = SettingsObjectWrapper::instance()->planner_settings; auto planner = SettingsObjectWrapper::instance()->planner_settings;
planner->setDecoSac(diveplan.decosac); planner->setDecoSac(diveplan.decosac);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setGFHigh(const int gfhigh) void DivePlannerPointsModel::setGFHigh(const int gfhigh)
@ -447,13 +447,13 @@ void DivePlannerPointsModel::setVpmbConservatism(int level)
void DivePlannerPointsModel::setSurfacePressure(int pressure) void DivePlannerPointsModel::setSurfacePressure(int pressure)
{ {
diveplan.surface_pressure = pressure; diveplan.surface_pressure = pressure;
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setSalinity(int salinity) void DivePlannerPointsModel::setSalinity(int salinity)
{ {
diveplan.salinity = salinity; diveplan.salinity = salinity;
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
int DivePlannerPointsModel::getSurfacePressure() int DivePlannerPointsModel::getSurfacePressure()
@ -465,35 +465,35 @@ void DivePlannerPointsModel::setLastStop6m(bool value)
{ {
auto planner = SettingsObjectWrapper::instance()->planner_settings; auto planner = SettingsObjectWrapper::instance()->planner_settings;
planner->setLastStop(value); planner->setLastStop(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setVerbatim(bool value) void DivePlannerPointsModel::setVerbatim(bool value)
{ {
auto planner = SettingsObjectWrapper::instance()->planner_settings; auto planner = SettingsObjectWrapper::instance()->planner_settings;
planner->setVerbatimPlan(value); planner->setVerbatimPlan(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setDisplayRuntime(bool value) void DivePlannerPointsModel::setDisplayRuntime(bool value)
{ {
auto planner = SettingsObjectWrapper::instance()->planner_settings; auto planner = SettingsObjectWrapper::instance()->planner_settings;
planner->setDisplayRuntime(value); planner->setDisplayRuntime(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setDisplayDuration(bool value) void DivePlannerPointsModel::setDisplayDuration(bool value)
{ {
auto planner = SettingsObjectWrapper::instance()->planner_settings; auto planner = SettingsObjectWrapper::instance()->planner_settings;
planner->setDisplayDuration(value); planner->setDisplayDuration(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setDisplayTransitions(bool value) void DivePlannerPointsModel::setDisplayTransitions(bool value)
{ {
auto planner = SettingsObjectWrapper::instance()->planner_settings; auto planner = SettingsObjectWrapper::instance()->planner_settings;
planner->setDisplayTransitions(value); planner->setDisplayTransitions(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setDecoMode(int mode) void DivePlannerPointsModel::setDecoMode(int mode)
@ -518,7 +518,7 @@ void DivePlannerPointsModel::setReserveGas(int reserve)
planner->setReserveGas(reserve * 1000); planner->setReserveGas(reserve * 1000);
else else
planner->setReserveGas(psi_to_mbar(reserve)); planner->setReserveGas(psi_to_mbar(reserve));
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setDropStoneMode(bool value) void DivePlannerPointsModel::setDropStoneMode(bool value)
@ -541,21 +541,21 @@ void DivePlannerPointsModel::setDropStoneMode(bool value)
divepoints.push_front(p); divepoints.push_front(p);
endInsertRows(); endInsertRows();
} }
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setSwitchAtReqStop(bool value) void DivePlannerPointsModel::setSwitchAtReqStop(bool value)
{ {
auto planner = SettingsObjectWrapper::instance()->planner_settings; auto planner = SettingsObjectWrapper::instance()->planner_settings;
planner->setSwitchAtRequiredStop(value); planner->setSwitchAtRequiredStop(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setMinSwitchDuration(int duration) void DivePlannerPointsModel::setMinSwitchDuration(int duration)
{ {
auto planner = SettingsObjectWrapper::instance()->planner_settings; auto planner = SettingsObjectWrapper::instance()->planner_settings;
planner->setMinSwitchDuration(duration * 60); planner->setMinSwitchDuration(duration * 60);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setStartDate(const QDate &date) void DivePlannerPointsModel::setStartDate(const QDate &date)
@ -563,7 +563,7 @@ void DivePlannerPointsModel::setStartDate(const QDate &date)
startTime.setDate(date); startTime.setDate(date);
diveplan.when = startTime.toTime_t(); diveplan.when = startTime.toTime_t();
displayed_dive.when = diveplan.when; displayed_dive.when = diveplan.when;
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
void DivePlannerPointsModel::setStartTime(const QTime &t) void DivePlannerPointsModel::setStartTime(const QTime &t)
@ -571,7 +571,7 @@ void DivePlannerPointsModel::setStartTime(const QTime &t)
startTime.setTime(t); startTime.setTime(t);
diveplan.when = startTime.toTime_t(); diveplan.when = startTime.toTime_t();
displayed_dive.when = diveplan.when; displayed_dive.when = diveplan.when;
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
@ -667,7 +667,7 @@ void DivePlannerPointsModel::editStop(int row, divedatapoint newData)
std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan); std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan);
if (updateMaxDepth()) if (updateMaxDepth())
CylindersModel::instance()->updateBestMixes(); CylindersModel::instance()->updateBestMixes();
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emitDataChanged();
} }
int DivePlannerPointsModel::size() int DivePlannerPointsModel::size()