Organize the dive_sites alphabetically
run std::sort on the dive_site list inside of the model. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
committed by
Dirk Hohndel
parent
7129cef66f
commit
6d9206150a
@@ -1,6 +1,11 @@
|
||||
#include "divelocationmodel.h"
|
||||
#include "dive.h"
|
||||
|
||||
bool dive_site_less_then(dive_site *a, dive_site *b)
|
||||
{
|
||||
return QString(a->name) <= QString(b->name);
|
||||
}
|
||||
|
||||
LocationInformationModel *LocationInformationModel::instance()
|
||||
{
|
||||
static LocationInformationModel *self = new LocationInformationModel();
|
||||
@@ -33,7 +38,6 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons
|
||||
|
||||
void LocationInformationModel::update()
|
||||
{
|
||||
|
||||
if (rowCount()) {
|
||||
beginRemoveRows(QModelIndex(), 0, rowCount()-1);
|
||||
endRemoveRows();
|
||||
@@ -41,6 +45,7 @@ void LocationInformationModel::update()
|
||||
if (dive_site_table.nr) {
|
||||
beginInsertRows(QModelIndex(), 0, dive_site_table.nr);
|
||||
internalRowCount = dive_site_table.nr;
|
||||
std::sort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr - 1, dive_site_less_then);
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user