mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
7129cef66f
commit
6d9206150a
2 changed files with 8 additions and 7 deletions
|
@ -1,6 +1,11 @@
|
||||||
#include "divelocationmodel.h"
|
#include "divelocationmodel.h"
|
||||||
#include "dive.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()
|
LocationInformationModel *LocationInformationModel::instance()
|
||||||
{
|
{
|
||||||
static LocationInformationModel *self = new LocationInformationModel();
|
static LocationInformationModel *self = new LocationInformationModel();
|
||||||
|
@ -33,7 +38,6 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons
|
||||||
|
|
||||||
void LocationInformationModel::update()
|
void LocationInformationModel::update()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (rowCount()) {
|
if (rowCount()) {
|
||||||
beginRemoveRows(QModelIndex(), 0, rowCount()-1);
|
beginRemoveRows(QModelIndex(), 0, rowCount()-1);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
@ -41,6 +45,7 @@ void LocationInformationModel::update()
|
||||||
if (dive_site_table.nr) {
|
if (dive_site_table.nr) {
|
||||||
beginInsertRows(QModelIndex(), 0, dive_site_table.nr);
|
beginInsertRows(QModelIndex(), 0, dive_site_table.nr);
|
||||||
internalRowCount = 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();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,11 +45,6 @@ void LocationInformationWidget::setCurrentDiveSite(int dive_nr)
|
||||||
|
|
||||||
void LocationInformationWidget::setLocationId(uint32_t uuid)
|
void LocationInformationWidget::setLocationId(uint32_t uuid)
|
||||||
{
|
{
|
||||||
LocationInformationModel *m = (LocationInformationModel*) ui.currentLocation->model();
|
|
||||||
if (m->rowCount() == 0) {
|
|
||||||
m->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
currentDs = get_dive_site_by_uuid(uuid);
|
currentDs = get_dive_site_by_uuid(uuid);
|
||||||
if(!currentDs)
|
if(!currentDs)
|
||||||
return;
|
return;
|
||||||
|
@ -138,7 +133,8 @@ void LocationInformationWidget::rejectChanges()
|
||||||
|
|
||||||
void LocationInformationWidget::showEvent(QShowEvent *ev)
|
void LocationInformationWidget::showEvent(QShowEvent *ev)
|
||||||
{
|
{
|
||||||
emit startFilterDiveSite(displayed_dive_site.uuid);
|
if (displayed_dive_site.uuid)
|
||||||
|
emit startFilterDiveSite(displayed_dive_site.uuid);
|
||||||
ui.diveSiteMessage->setCloseButtonVisible(false);
|
ui.diveSiteMessage->setCloseButtonVisible(false);
|
||||||
QGroupBox::showEvent(ev);
|
QGroupBox::showEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue