diff options
author | Tomaz Canabrava <tomaz.canabrava@gmail.com> | 2015-05-31 17:56:53 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-05-31 16:02:35 -0700 |
commit | 6d9206150a9d0d9496542ab6c4a12d8a41a8f596 (patch) | |
tree | b086c3ca500b54a8fe164cc5a6ba2c4ba7c2be28 /qt-models/divelocationmodel.cpp | |
parent | 7129cef66fa4d335d70e6d64ce9cb03f89b3610f (diff) | |
download | subsurface-6d9206150a9d0d9496542ab6c4a12d8a41a8f596.tar.gz |
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>
Diffstat (limited to 'qt-models/divelocationmodel.cpp')
-rw-r--r-- | qt-models/divelocationmodel.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index 21c3127ca..c335f7039 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -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(); } } |