mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: implement proper Qt-model semantics in DivePlotData model
User beginResetModel()/endResetModel() pairs to reset the model. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
77e5dbac73
commit
3025e0630d
1 changed files with 11 additions and 15 deletions
|
@ -164,29 +164,25 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
|
||||||
|
|
||||||
void DivePlotDataModel::clear()
|
void DivePlotDataModel::clear()
|
||||||
{
|
{
|
||||||
if (rowCount() != 0) {
|
beginResetModel();
|
||||||
beginRemoveRows(QModelIndex(), 0, rowCount() - 1);
|
|
||||||
pInfo.nr = 0;
|
pInfo.nr = 0;
|
||||||
free(pInfo.entry);
|
free(pInfo.entry);
|
||||||
pInfo.entry = 0;
|
pInfo.entry = 0;
|
||||||
diveId = -1;
|
diveId = -1;
|
||||||
dcNr = -1;
|
dcNr = -1;
|
||||||
endRemoveRows();
|
endResetModel();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlotDataModel::setDive(dive *d, const plot_info &info)
|
void DivePlotDataModel::setDive(dive *d, const plot_info &info)
|
||||||
{
|
{
|
||||||
clear();
|
beginResetModel();
|
||||||
Q_ASSERT(d != NULL);
|
|
||||||
diveId = d->id;
|
diveId = d->id;
|
||||||
dcNr = dc_number;
|
dcNr = dc_number;
|
||||||
free(pInfo.entry);
|
free(pInfo.entry);
|
||||||
pInfo = info;
|
pInfo = info;
|
||||||
pInfo.entry = (struct plot_data *)malloc(sizeof(struct plot_data) * pInfo.nr);
|
pInfo.entry = (struct plot_data *)malloc(sizeof(struct plot_data) * pInfo.nr);
|
||||||
memcpy(pInfo.entry, info.entry, sizeof(plot_data) * pInfo.nr);
|
memcpy(pInfo.entry, info.entry, sizeof(plot_data) * pInfo.nr);
|
||||||
beginInsertRows(QModelIndex(), 0, pInfo.nr - 1);
|
endResetModel();
|
||||||
endInsertRows();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int DivePlotDataModel::dcShown() const
|
unsigned int DivePlotDataModel::dcShown() const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue