mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Undo: switch to edited trip
If fields in a trip are edited, select that trip, which will display the trip in the notes-box. This is realized by hooking into the tripChanged signal in the dive-list. A layering-violation, perhaps? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
91c33b475c
commit
7924c7dafb
2 changed files with 22 additions and 2 deletions
|
@ -24,7 +24,6 @@
|
||||||
#include "desktop-widgets/divelistview.h"
|
#include "desktop-widgets/divelistview.h"
|
||||||
#include "qt-models/divepicturemodel.h"
|
#include "qt-models/divepicturemodel.h"
|
||||||
#include "core/metrics.h"
|
#include "core/metrics.h"
|
||||||
#include "core/subsurface-qt/DiveListNotifier.h"
|
|
||||||
#include "desktop-widgets/simplewidgets.h"
|
#include "desktop-widgets/simplewidgets.h"
|
||||||
|
|
||||||
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
|
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
|
||||||
|
@ -46,6 +45,8 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec
|
||||||
// Update selection if all selected dives were hidden by filter
|
// Update selection if all selected dives were hidden by filter
|
||||||
connect(MultiFilterSortModel::instance(), &MultiFilterSortModel::filterFinished, this, &DiveListView::filterFinished);
|
connect(MultiFilterSortModel::instance(), &MultiFilterSortModel::filterFinished, this, &DiveListView::filterFinished);
|
||||||
|
|
||||||
|
connect(&diveListNotifier, &DiveListNotifier::tripChanged, this, &DiveListView::tripChanged);
|
||||||
|
|
||||||
header()->setStretchLastSection(true);
|
header()->setStretchLastSection(true);
|
||||||
header()->setSortIndicatorShown(true);
|
header()->setSortIndicatorShown(true);
|
||||||
header()->setSectionsClickable(true);
|
header()->setSectionsClickable(true);
|
||||||
|
@ -292,6 +293,23 @@ void DiveListView::restoreSelection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is a bit ugly: we hook directly into the tripChanged signal to
|
||||||
|
// select the trip if it was edited. This feels like a layering violation:
|
||||||
|
// Shouldn't the core-layer call us?
|
||||||
|
void DiveListView::tripChanged(dive_trip *trip, TripField)
|
||||||
|
{
|
||||||
|
// First check if the trip is already selected (and only
|
||||||
|
// this trip, as only then is it displayed). Is so, then do nothing.
|
||||||
|
QList<dive_trip *> selected = selectedTrips();
|
||||||
|
if (selected.size() == 1 && selected[0] == trip)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dontEmitDiveChangedSignal = true;
|
||||||
|
unselectDives();
|
||||||
|
dontEmitDiveChangedSignal = false;
|
||||||
|
selectTrip(trip);
|
||||||
|
}
|
||||||
|
|
||||||
void DiveListView::selectTrip(dive_trip_t *trip)
|
void DiveListView::selectTrip(dive_trip_t *trip)
|
||||||
{
|
{
|
||||||
if (!trip)
|
if (!trip)
|
||||||
|
@ -318,7 +336,7 @@ void DiveListView::selectTrip(dive_trip_t *trip)
|
||||||
void DiveListView::clearTripSelection()
|
void DiveListView::clearTripSelection()
|
||||||
{
|
{
|
||||||
// This marks the selection change as being internal - ie. we don't process it further.
|
// This marks the selection change as being internal - ie. we don't process it further.
|
||||||
// TODO: This should probably be sold differently.
|
// TODO: This should probably be done differently.
|
||||||
auto marker = diveListNotifier.enterCommand();
|
auto marker = diveListNotifier.enterCommand();
|
||||||
|
|
||||||
// we want to make sure no trips are selected
|
// we want to make sure no trips are selected
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include "qt-models/divetripmodel.h"
|
#include "qt-models/divetripmodel.h"
|
||||||
|
#include "core/subsurface-qt/DiveListNotifier.h"
|
||||||
|
|
||||||
class DiveListView : public QTreeView {
|
class DiveListView : public QTreeView {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -65,6 +66,7 @@ slots:
|
||||||
void diveSelectionChanged(const QVector<QModelIndex> &indexes, bool select);
|
void diveSelectionChanged(const QVector<QModelIndex> &indexes, bool select);
|
||||||
void currentDiveChanged(QModelIndex index);
|
void currentDiveChanged(QModelIndex index);
|
||||||
void filterFinished();
|
void filterFinished();
|
||||||
|
void tripChanged(dive_trip *trip, TripField);
|
||||||
private:
|
private:
|
||||||
bool mouseClickSelection;
|
bool mouseClickSelection;
|
||||||
QList<int> expandedRows;
|
QList<int> expandedRows;
|
||||||
|
|
Loading…
Add table
Reference in a new issue