mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Inform LocationFilterModel of added dive site name
If the user implicitly adds a dive site by editing a dive, and a location filter is active, check the new dive site in the location filter. This is done by informing the LocationFilterModel of the new dive site name prior to repopulation. The LocationFilterModel then adds a corresponding entry and marks it as checked. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f4bcdf46aa
commit
24c72cb359
4 changed files with 22 additions and 1 deletions
|
@ -21,8 +21,10 @@
|
|||
#include "qt-models/weightmodel.h"
|
||||
#include "qt-models/divecomputerextradatamodel.h"
|
||||
#include "qt-models/divelocationmodel.h"
|
||||
#include "qt-models/filtermodels.h"
|
||||
#include "core/divesite.h"
|
||||
#include "desktop-widgets/locationinformation.h"
|
||||
#include "desktop-widgets/locationinformation.h"
|
||||
|
||||
#include "TabDiveExtraInfo.h"
|
||||
#include "TabDiveInformation.h"
|
||||
|
@ -201,6 +203,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
|||
|
||||
connect(ui.diveNotesMessage, &KMessageWidget::showAnimationFinished,
|
||||
ui.location, &DiveLocationLineEdit::fixPopupPosition);
|
||||
connect(this, SIGNAL(diveSiteAdded(const QString &)), LocationFilterModel::instance(), SLOT(addName(const QString &)));
|
||||
|
||||
// enable URL clickability in notes:
|
||||
new TextHyperlinkEventFilter(ui.notes);//destroyed when ui.notes is destroyed
|
||||
|
@ -703,8 +706,10 @@ uint32_t MainTab::updateDiveSite(uint32_t pickedUuid, int divenr)
|
|||
return origUuid;
|
||||
|
||||
if (pickedUuid == RECENTLY_ADDED_DIVESITE) {
|
||||
pickedUuid = create_dive_site(ui.location->text().isEmpty() ? qPrintable(tr("New dive site")) : qPrintable(ui.location->text()), displayed_dive.when);
|
||||
QString name = ui.location->text().isEmpty() ? tr("New dive site") : ui.location->text();
|
||||
pickedUuid = create_dive_site(qPrintable(name), displayed_dive.when);
|
||||
createdNewDive = true;
|
||||
emit diveSiteAdded(name);
|
||||
}
|
||||
|
||||
newDs = get_dive_site_by_uuid(pickedUuid);
|
||||
|
|
|
@ -60,6 +60,7 @@ signals:
|
|||
void addDiveFinished();
|
||||
void dateTimeChanged();
|
||||
void diveSiteChanged(struct dive_site * ds);
|
||||
void diveSiteAdded(const QString &);
|
||||
public
|
||||
slots:
|
||||
void addCylinder_clicked();
|
||||
|
|
|
@ -333,6 +333,20 @@ void LocationFilterModel::changeName(const QString &oldName, const QString &newN
|
|||
checkState[newIndex] = true;
|
||||
}
|
||||
|
||||
void LocationFilterModel::addName(const QString &newName)
|
||||
{
|
||||
// If any item is checked and a new location is added, add the name
|
||||
// of the new location in front of the list and mark it as checked.
|
||||
// Thus, on subsequent repopulation of the list, the new entry will
|
||||
// be registered as already checked.
|
||||
QStringList list = stringList();
|
||||
if (!anyChecked || newName.isEmpty() || list.indexOf(newName) >= 0)
|
||||
return;
|
||||
list.prepend(newName);
|
||||
setStringList(list);
|
||||
checkState.insert(checkState.begin(), true);
|
||||
}
|
||||
|
||||
MultiFilterSortModel::MultiFilterSortModel(QObject *parent) :
|
||||
QSortFilterProxyModel(parent),
|
||||
divesDisplayed(0),
|
||||
|
|
|
@ -69,6 +69,7 @@ public
|
|||
slots:
|
||||
void repopulate();
|
||||
void changeName(const QString &oldName, const QString &newName);
|
||||
void addName(const QString &newName);
|
||||
|
||||
private:
|
||||
explicit LocationFilterModel(QObject *parent = 0);
|
||||
|
|
Loading…
Reference in a new issue