cleanup: invert control-flow when resetting the core structures

To reset the core data structures, the mobile and desktop UIs
were calling into the dive-list models, which then reset the
core data structures, themselves and the unrelated
locationinformation model. The UI code then reset various other
things, such as the TankInformation model or the map. . This was
unsatisfying from a control-flow perspective, as the models should
display the core data, not act on it. Moreover, this meant lots
of intricate intermodule-dependencies.

Thus, straighten up the control flow: give the C core the
possibility to send a "all data reset" event. And do that
in those functions that reset the core data structures.
Let each module react to this event by itself. This removes
inter-module dependencies. For example, the MainWindow now
doesn't have to reset the TankInfoModel or the MapWidget.

Then, to reset the core data structures, let the UI code
simply directly call the respective core functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-05-05 00:12:36 +02:00 committed by Dirk Hohndel
parent aeee2a0802
commit fb6210a99a
18 changed files with 70 additions and 49 deletions

View file

@ -835,6 +835,9 @@ void process_loaded_dives()
autogroup_dives(&dive_table, &trip_table); autogroup_dives(&dive_table, &trip_table);
fulltext_populate(); fulltext_populate();
/* Inform frontend of reset data. This should reset all the models. */
emit_reset_signal();
} }
/* /*
@ -1045,6 +1048,9 @@ void add_imported_dives(struct dive_table *import_table, struct trip_table *impo
* Choose the newest dive as selected (if any) */ * Choose the newest dive as selected (if any) */
current_dive = dive_table.nr > 0 ? dive_table.dives[dive_table.nr - 1] : NULL; current_dive = dive_table.nr > 0 ? dive_table.dives[dive_table.nr - 1] : NULL;
mark_divelist_changed(true); mark_divelist_changed(true);
/* Inform frontend of reset data. This should reset all the models. */
emit_reset_signal();
} }
/* Helper function for process_imported_dives(): /* Helper function for process_imported_dives():
@ -1373,6 +1379,9 @@ void clear_dive_file_data()
reset_min_datafile_version(); reset_min_datafile_version();
clear_git_id(); clear_git_id();
/* Inform frontend of reset data. This should reset all the models. */
emit_reset_signal();
} }
bool dive_less_than(const struct dive *a, const struct dive *b) bool dive_less_than(const struct dive *a, const struct dive *b)

View file

@ -3,6 +3,7 @@
#include "dive.h" #include "dive.h"
#include "core/settings/qPrefLanguage.h" #include "core/settings/qPrefLanguage.h"
#include "core/settings/qPrefUpdateManager.h" #include "core/settings/qPrefUpdateManager.h"
#include "core/subsurface-qt/divelistnotifier.h"
#include "subsurface-string.h" #include "subsurface-string.h"
#include "subsurface-string.h" #include "subsurface-string.h"
#include "gettextfromc.h" #include "gettextfromc.h"
@ -1675,3 +1676,8 @@ std::vector<int> get_cylinder_map_for_add(int count, int n)
std::iota(mapping.begin() + n, mapping.end(), n + 1); std::iota(mapping.begin() + n, mapping.end(), n + 1);
return mapping; return mapping;
} }
extern "C" void emit_reset_signal()
{
emit diveListNotifier.dataReset();
}

View file

@ -155,6 +155,8 @@ pressure_t string_to_pressure(const char *str);
volume_t string_to_volume(const char *str, pressure_t workp); volume_t string_to_volume(const char *str, pressure_t workp);
fraction_t string_to_fraction(const char *str); fraction_t string_to_fraction(const char *str);
char *get_changes_made(); char *get_changes_made();
void emit_reset_signal();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -78,6 +78,9 @@ struct TripField {
class DiveListNotifier : public QObject { class DiveListNotifier : public QObject {
Q_OBJECT Q_OBJECT
signals: signals:
// The core structures were completely reset. Repopulate all models.
void dataReset();
// Note that there are no signals for trips being added and created // Note that there are no signals for trips being added and created
// because these events never happen without a dive being added, removed or moved. // because these events never happen without a dive being added, removed or moved.
// The dives are always sorted according to the dives_less_than() function of the core. // The dives are always sorted according to the dives_less_than() function of the core.

View file

@ -408,15 +408,12 @@ MainWindow *MainWindow::instance()
void MainWindow::refreshDisplay(bool doRecreateDiveList) void MainWindow::refreshDisplay(bool doRecreateDiveList)
{ {
mainTab->reload(); mainTab->reload();
TankInfoModel::instance()->update();
if (doRecreateDiveList) if (doRecreateDiveList)
diveList->reload(); diveList->reload();
MapWidget::instance()->reload();
setApplicationState(ApplicationState::Default); setApplicationState(ApplicationState::Default);
diveList->setEnabled(true); diveList->setEnabled(true);
diveList->setFocus(); diveList->setFocus();
WSInfoModel::instance()->update();
ui.actionAutoGroup->setChecked(autogroup); ui.actionAutoGroup->setChecked(autogroup);
} }
@ -647,7 +644,7 @@ void MainWindow::closeCurrentFile()
{ {
/* free the dives and trips */ /* free the dives and trips */
clear_git_id(); clear_git_id();
MultiFilterSortModel::instance()->clear(); // this clears all the core data structures clear_dive_file_data(); // this clears all the core data structures and resets the models
setCurrentFile(nullptr); setCurrentFile(nullptr);
diveList->setSortOrder(DiveTripModelBase::NR, Qt::DescendingOrder); diveList->setSortOrder(DiveTripModelBase::NR, Qt::DescendingOrder);
MapWidget::instance()->reload(); MapWidget::instance()->reload();

View file

@ -28,6 +28,7 @@ MapWidget::MapWidget(QWidget *parent) : QQuickWidget(parent)
setResizeMode(QQuickWidget::SizeRootObjectToView); setResizeMode(QQuickWidget::SizeRootObjectToView);
connect(this, &QQuickWidget::statusChanged, this, &MapWidget::doneLoading); connect(this, &QQuickWidget::statusChanged, this, &MapWidget::doneLoading);
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &MapWidget::divesChanged); connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &MapWidget::divesChanged);
connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &MapWidget::reload);
setSource(urlMapWidget); setSource(urlMapWidget);
} }

View file

@ -339,7 +339,7 @@ void QMLManager::applicationStateChanged(Qt::ApplicationState state)
void QMLManager::openLocalThenRemote(QString url) void QMLManager::openLocalThenRemote(QString url)
{ {
// clear out the models and the fulltext index // clear out the models and the fulltext index
MobileModels::instance()->clear(); clear_dive_file_data();
setDiveListProcessing(true); setDiveListProcessing(true);
setNotificationText(tr("Open local dive data file")); setNotificationText(tr("Open local dive data file"));
appendTextToLog(QString("Open dive data file %1 - git_local only is %2").arg(url).arg(git_local_only)); appendTextToLog(QString("Open dive data file %1 - git_local only is %2").arg(url).arg(git_local_only));
@ -383,7 +383,6 @@ void QMLManager::openLocalThenRemote(QString url)
// the following steps can take a long time, so provide updates // the following steps can take a long time, so provide updates
setNotificationText(tr("Processing %1 dives").arg(dive_table.nr)); setNotificationText(tr("Processing %1 dives").arg(dive_table.nr));
process_loaded_dives(); process_loaded_dives();
MobileModels::instance()->reset();
setNotificationText(tr("%1 dives loaded from local dive data file").arg(dive_table.nr)); setNotificationText(tr("%1 dives loaded from local dive data file").arg(dive_table.nr));
} }
if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_NEED_TO_VERIFY) { if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_NEED_TO_VERIFY) {
@ -612,8 +611,7 @@ void QMLManager::saveCloudCredentials(const QString &newEmail, const QString &ne
syncLoadFromCloud(); syncLoadFromCloud();
manager()->clearAccessCache(); // remove any chached credentials manager()->clearAccessCache(); // remove any chached credentials
clear_git_id(); // invalidate our remembered GIT SHA clear_git_id(); // invalidate our remembered GIT SHA
MobileModels::instance()->clear(); clear_dive_file_data();
GpsListModel::instance()->clear();
setStartPageText(tr("Attempting to open cloud storage with new credentials")); setStartPageText(tr("Attempting to open cloud storage with new credentials"));
// since we changed credentials, we need to try to connect to the cloud, regardless // since we changed credentials, we need to try to connect to the cloud, regardless
// of whether we're in offline mode or not, to make sure the repository is synced // of whether we're in offline mode or not, to make sure the repository is synced
@ -687,7 +685,7 @@ void QMLManager::loadDivesWithValidCredentials()
// if we aren't switching from no-cloud mode, let's clear the dive data // if we aren't switching from no-cloud mode, let's clear the dive data
if (!noCloudToCloud) { if (!noCloudToCloud) {
appendTextToLog("Clear out in memory dive data"); appendTextToLog("Clear out in memory dive data");
MobileModels::instance()->clear(); clear_dive_file_data();
} else { } else {
appendTextToLog("Switching from no cloud mode; keep in memory dive data"); appendTextToLog("Switching from no cloud mode; keep in memory dive data");
} }
@ -717,7 +715,6 @@ void QMLManager::loadDivesWithValidCredentials()
if (noCloudToCloud) { if (noCloudToCloud) {
git_storage_update_progress(qPrintable(tr("Loading dives from local storage ('no cloud' mode)"))); git_storage_update_progress(qPrintable(tr("Loading dives from local storage ('no cloud' mode)")));
mergeLocalRepo(); mergeLocalRepo();
MobileModels::instance()->reset();
appendTextToLog(QStringLiteral("%1 dives loaded after importing nocloud local storage").arg(dive_table.nr)); appendTextToLog(QStringLiteral("%1 dives loaded after importing nocloud local storage").arg(dive_table.nr));
noCloudToCloud = false; noCloudToCloud = false;
mark_divelist_changed(true); mark_divelist_changed(true);
@ -779,7 +776,6 @@ void QMLManager::consumeFinishedLoad()
prefs.show_ccr_sensors = git_prefs.show_ccr_sensors; prefs.show_ccr_sensors = git_prefs.show_ccr_sensors;
prefs.pp_graphs.po2 = git_prefs.pp_graphs.po2; prefs.pp_graphs.po2 = git_prefs.pp_graphs.po2;
process_loaded_dives(); process_loaded_dives();
MobileModels::instance()->reset();
appendTextToLog(QStringLiteral("%1 dives loaded").arg(dive_table.nr)); appendTextToLog(QStringLiteral("%1 dives loaded").arg(dive_table.nr));
if (dive_table.nr == 0) if (dive_table.nr == 0)
setStartPageText(tr("Cloud storage open successfully. No dives in dive list.")); setStartPageText(tr("Cloud storage open successfully. No dives in dive list."));
@ -787,7 +783,7 @@ void QMLManager::consumeFinishedLoad()
void QMLManager::refreshDiveList() void QMLManager::refreshDiveList()
{ {
MobileModels::instance()->reset(); MobileModels::instance()->invalidate();
} }
// Ouch. Editing a dive might create a dive site or change an existing dive site. // Ouch. Editing a dive might create a dive site or change an existing dive site.

View file

@ -26,6 +26,7 @@ LocationInformationModel::LocationInformationModel(QObject *obj) : QAbstractTabl
connect(&diveListNotifier, &DiveListNotifier::diveSiteDeleted, this, &LocationInformationModel::diveSiteDeleted); connect(&diveListNotifier, &DiveListNotifier::diveSiteDeleted, this, &LocationInformationModel::diveSiteDeleted);
connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &LocationInformationModel::diveSiteChanged); connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &LocationInformationModel::diveSiteChanged);
connect(&diveListNotifier, &DiveListNotifier::diveSiteDivesChanged, this, &LocationInformationModel::diveSiteDivesChanged); connect(&diveListNotifier, &DiveListNotifier::diveSiteDivesChanged, this, &LocationInformationModel::diveSiteDivesChanged);
connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &LocationInformationModel::update);
} }
int LocationInformationModel::columnCount(const QModelIndex &) const int LocationInformationModel::columnCount(const QModelIndex &) const

View file

@ -31,6 +31,7 @@ public:
public slots: public slots:
void update(); void update();
private slots:
void diveSiteDiveCountChanged(struct dive_site *ds); void diveSiteDiveCountChanged(struct dive_site *ds);
void diveSiteAdded(struct dive_site *ds, int idx); void diveSiteAdded(struct dive_site *ds, int idx);
void diveSiteDeleted(struct dive_site *ds, int idx); void diveSiteDeleted(struct dive_site *ds, int idx);

View file

@ -476,27 +476,13 @@ void DiveTripModelBase::initSelection()
select_newest_visible_dive(); select_newest_visible_dive();
} }
void DiveTripModelBase::clear()
{
Command::clear(); // If we clear the dive list, all undo-information becomes stalte.
beginResetModel();
clear_dive_file_data();
clearData();
LocationInformationModel::instance()->update();
oldCurrent = nullptr;
emit diveListNotifier.divesSelected({}); // Inform profile, etc of changed selection
endResetModel();
emit diveListNotifier.numShownChanged();
}
// Currently only used by the mobile models // Currently only used by the mobile models
void DiveTripModelBase::reset() void DiveTripModelBase::reset()
{ {
beginResetModel(); beginResetModel();
oldCurrent = nullptr;
clearData(); clearData();
populate(); populate();
uiNotification(tr("setting up dive sites"));
LocationInformationModel::instance()->update();
uiNotification(tr("finish populating data store")); uiNotification(tr("finish populating data store"));
endResetModel(); endResetModel();
uiNotification(tr("setting up internal data structures")); uiNotification(tr("setting up internal data structures"));
@ -721,6 +707,7 @@ DiveTripModelTree::DiveTripModelTree(QObject *parent) : DiveTripModelBase(parent
connect(&diveListNotifier, &DiveListNotifier::pictureOffsetChanged, this, &DiveTripModelTree::diveChanged); connect(&diveListNotifier, &DiveListNotifier::pictureOffsetChanged, this, &DiveTripModelTree::diveChanged);
connect(&diveListNotifier, &DiveListNotifier::picturesRemoved, this, &DiveTripModelTree::diveChanged); connect(&diveListNotifier, &DiveListNotifier::picturesRemoved, this, &DiveTripModelTree::diveChanged);
connect(&diveListNotifier, &DiveListNotifier::picturesAdded, this, &DiveTripModelTree::diveChanged); connect(&diveListNotifier, &DiveListNotifier::picturesAdded, this, &DiveTripModelTree::diveChanged);
connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &DiveTripModelTree::reset);
populate(); populate();
} }
@ -1485,6 +1472,7 @@ DiveTripModelList::DiveTripModelList(QObject *parent) : DiveTripModelBase(parent
connect(&diveListNotifier, &DiveListNotifier::pictureOffsetChanged, this, &DiveTripModelList::diveChanged); connect(&diveListNotifier, &DiveListNotifier::pictureOffsetChanged, this, &DiveTripModelList::diveChanged);
connect(&diveListNotifier, &DiveListNotifier::picturesRemoved, this, &DiveTripModelList::diveChanged); connect(&diveListNotifier, &DiveListNotifier::picturesRemoved, this, &DiveTripModelList::diveChanged);
connect(&diveListNotifier, &DiveListNotifier::picturesAdded, this, &DiveTripModelList::diveChanged); connect(&diveListNotifier, &DiveListNotifier::picturesAdded, this, &DiveTripModelList::diveChanged);
connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &DiveTripModelList::reset);
populate(); populate();
} }

View file

@ -64,12 +64,6 @@ public:
// Call after having set the model to be informed of the current selection. // Call after having set the model to be informed of the current selection.
void initSelection(); void initSelection();
// Clear all dives
void clear();
// Reload data
void reset();
Qt::ItemFlags flags(const QModelIndex &index) const; Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
DiveTripModelBase(QObject *parent = 0); DiveTripModelBase(QObject *parent = 0);
@ -78,6 +72,8 @@ public:
// Used for sorting. This is a bit of a layering violation, as sorting should be performed // Used for sorting. This is a bit of a layering violation, as sorting should be performed
// by the higher-up QSortFilterProxyModel, but it makes things so much easier! // by the higher-up QSortFilterProxyModel, but it makes things so much easier!
virtual bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const = 0; virtual bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const = 0;
protected slots:
void reset();
signals: signals:
// The propagation of selection changes is complex. // The propagation of selection changes is complex.
// The control flow of dive-selection goes: // The control flow of dive-selection goes:

View file

@ -33,11 +33,6 @@ void MultiFilterSortModel::resetModel(DiveTripModelBase::Layout layout)
LocationInformationModel::instance()->update(); LocationInformationModel::instance()->update();
} }
void MultiFilterSortModel::clear()
{
model->clear();
}
// Translate selection into local indices and re-emit signal // Translate selection into local indices and re-emit signal
void MultiFilterSortModel::selectionChangedSlot(const QVector<QModelIndex> &indices) void MultiFilterSortModel::selectionChangedSlot(const QVector<QModelIndex> &indices)
{ {

View file

@ -17,7 +17,6 @@ public:
bool lessThan(const QModelIndex &, const QModelIndex &) const override; bool lessThan(const QModelIndex &, const QModelIndex &) const override;
void resetModel(DiveTripModelBase::Layout layout); void resetModel(DiveTripModelBase::Layout layout);
void clear();
signals: signals:
void selectionChanged(const QVector<QModelIndex> &indices); void selectionChanged(const QVector<QModelIndex> &indices);
void currentDiveChanged(QModelIndex index); void currentDiveChanged(QModelIndex index);

View file

@ -1,10 +1,12 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "qt-models/gpslistmodel.h" #include "qt-models/gpslistmodel.h"
#include "core/subsurface-qt/divelistnotifier.h"
#include "core/qthelper.h" #include "core/qthelper.h"
#include <QVector> #include <QVector>
GpsListModel::GpsListModel() GpsListModel::GpsListModel()
{ {
connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &GpsListModel::update);
} }
void GpsListModel::update() void GpsListModel::update()

View file

@ -507,6 +507,18 @@ void MobileListModel::changed(const QModelIndex &topLeft, const QModelIndex &bot
} }
} }
void MobileListModel::invalidate()
{
// Qt's model/view API can't handle empty ranges and we have to subtract one from the last item,
// because ranges are given as [first,last] (i.e. last inclusive).
int rows = rowCount(QModelIndex());
if (rows <= 0)
return;
QModelIndex fromIdx = createIndex(0, 0);
QModelIndex toIdx = createIndex(rows - 1, 0);
dataChanged(fromIdx, toIdx);
}
void MobileListModel::unexpand() void MobileListModel::unexpand()
{ {
if (expandedRow < 0) if (expandedRow < 0)
@ -903,6 +915,18 @@ void MobileSwipeModel::changed(const QModelIndex &topLeft, const QModelIndex &bo
emit currentDiveChanged(fromIdx); emit currentDiveChanged(fromIdx);
} }
void MobileSwipeModel::invalidate()
{
// Qt's model/view API can't handle empty ranges and we have to subtract one from the last item,
// because ranges are given as [first,last] (i.e. last inclusive).
int rows = rowCount(QModelIndex());
if (rows <= 0)
return;
QModelIndex fromIdx = createIndex(0, 0);
QModelIndex toIdx = createIndex(rows - 1, 0);
dataChanged(fromIdx, toIdx);
}
QVariant MobileSwipeModel::data(const QModelIndex &index, int role) const QVariant MobileSwipeModel::data(const QModelIndex &index, int role) const
{ {
return source->data(mapToSource(index), role); return source->data(mapToSource(index), role);
@ -925,7 +949,6 @@ MobileModels::MobileModels() :
lm(&source), lm(&source),
sm(&source) sm(&source)
{ {
reset();
} }
MobileListModel *MobileModels::listModel() MobileListModel *MobileModels::listModel()
@ -938,12 +961,9 @@ MobileSwipeModel *MobileModels::swipeModel()
return &sm; return &sm;
} }
void MobileModels::clear() // This is called when the settings changed. Instead of rebuilding the model, send a changed signal on all entries.
void MobileModels::invalidate()
{ {
source.clear(); sm.invalidate();
} sm.invalidate();
void MobileModels::reset()
{
source.reset();
} }

View file

@ -77,6 +77,7 @@ public:
MobileListModel(DiveTripModelBase *source); MobileListModel(DiveTripModelBase *source);
void expand(int row); void expand(int row);
void unexpand(); void unexpand();
void invalidate();
Q_INVOKABLE void toggle(int row); Q_INVOKABLE void toggle(int row);
Q_PROPERTY(int shown READ shown NOTIFY shownChanged); Q_PROPERTY(int shown READ shown NOTIFY shownChanged);
signals: signals:
@ -121,6 +122,7 @@ public:
MobileSwipeModel(DiveTripModelBase *source); MobileSwipeModel(DiveTripModelBase *source);
static MobileSwipeModel *instance(); static MobileSwipeModel *instance();
void resetModel(DiveTripModelBase::Layout layout); // Switch between tree and list view void resetModel(DiveTripModelBase::Layout layout); // Switch between tree and list view
void invalidate();
private: private:
struct IndexRange { struct IndexRange {
int first, last; int first, last;
@ -175,8 +177,7 @@ public:
static MobileModels *instance(); static MobileModels *instance();
MobileListModel *listModel(); MobileListModel *listModel();
MobileSwipeModel *swipeModel(); MobileSwipeModel *swipeModel();
void clear(); // Clear all dive data void invalidate(); // Invalidate all entries to force a re-render.
void reset(); // Reset model after having reloaded the core data
private: private:
MobileModels(); MobileModels();
DiveTripModelTree source; DiveTripModelTree source;

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "qt-models/tankinfomodel.h" #include "qt-models/tankinfomodel.h"
#include "core/dive.h" #include "core/dive.h"
#include "core/subsurface-qt/divelistnotifier.h"
#include "core/gettextfromc.h" #include "core/gettextfromc.h"
#include "core/metrics.h" #include "core/metrics.h"
@ -85,6 +86,7 @@ int TankInfoModel::rowCount(const QModelIndex&) const
TankInfoModel::TankInfoModel() TankInfoModel::TankInfoModel()
{ {
setHeaderDataStrings(QStringList() << tr("Description") << tr("ml") << tr("bar")); setHeaderDataStrings(QStringList() << tr("Description") << tr("ml") << tr("bar"));
connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &TankInfoModel::update);
update(); update();
} }

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "qt-models/weightsysteminfomodel.h" #include "qt-models/weightsysteminfomodel.h"
#include "core/subsurface-qt/divelistnotifier.h"
#include "core/dive.h" #include "core/dive.h"
#include "core/metrics.h" #include "core/metrics.h"
#include "core/gettextfromc.h" #include "core/gettextfromc.h"
@ -74,6 +75,7 @@ int WSInfoModel::rowCount(const QModelIndex&) const
WSInfoModel::WSInfoModel() WSInfoModel::WSInfoModel()
{ {
setHeaderDataStrings(QStringList() << tr("Description") << tr("kg")); setHeaderDataStrings(QStringList() << tr("Description") << tr("kg"));
connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &WSInfoModel::update);
update(); update();
} }