mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Dive sites: remove internalRowCount from LocationInformationModel
This was redundant. Directly use dive_site_table.nr instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
50e42bffa1
commit
19d651a36b
2 changed files with 3 additions and 7 deletions
|
@ -18,8 +18,7 @@ LocationInformationModel *LocationInformationModel::instance()
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocationInformationModel::LocationInformationModel(QObject *obj) : QAbstractTableModel(obj),
|
LocationInformationModel::LocationInformationModel(QObject *obj) : QAbstractTableModel(obj)
|
||||||
internalRowCount(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ int LocationInformationModel::columnCount(const QModelIndex&) const
|
||||||
|
|
||||||
int LocationInformationModel::rowCount(const QModelIndex&) const
|
int LocationInformationModel::rowCount(const QModelIndex&) const
|
||||||
{
|
{
|
||||||
return internalRowCount;
|
return dive_site_table.nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant LocationInformationModel::data(const QModelIndex &index, int role) const
|
QVariant LocationInformationModel::data(const QModelIndex &index, int role) const
|
||||||
|
@ -74,10 +73,9 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons
|
||||||
void LocationInformationModel::update()
|
void LocationInformationModel::update()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
internalRowCount = dive_site_table.nr;
|
|
||||||
qSort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than);
|
qSort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than);
|
||||||
locationNames.clear();
|
locationNames.clear();
|
||||||
for (int i = 0; i < internalRowCount; i++)
|
for (int i = 0; i < dive_site_table.nr; i++)
|
||||||
locationNames << QString(dive_site_table.dive_sites[i]->name);
|
locationNames << QString(dive_site_table.dive_sites[i]->name);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
@ -96,7 +94,6 @@ bool LocationInformationModel::removeRows(int row, int, const QModelIndex&)
|
||||||
struct dive_site *ds = get_dive_site(row);
|
struct dive_site *ds = get_dive_site(row);
|
||||||
if (ds)
|
if (ds)
|
||||||
delete_dive_site(ds->uuid);
|
delete_dive_site(ds->uuid);
|
||||||
internalRowCount = dive_site_table.nr;
|
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ public slots:
|
||||||
void update();
|
void update();
|
||||||
QStringList allSiteNames() const;
|
QStringList allSiteNames() const;
|
||||||
private:
|
private:
|
||||||
int internalRowCount;
|
|
||||||
QStringList locationNames;
|
QStringList locationNames;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue