mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: remove DiveListView::remember/restoreSelection()
Calls of these functions were removed in the previous commits. Now, remove the functions themselves. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
a83bc5ecdb
commit
364a8270d1
2 changed files with 1 additions and 47 deletions
|
@ -31,7 +31,7 @@
|
||||||
#include "desktop-widgets/mapwidget.h"
|
#include "desktop-widgets/mapwidget.h"
|
||||||
|
|
||||||
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
|
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
|
||||||
currentLayout(DiveTripModelBase::TREE), selectionSaved(false),
|
currentLayout(DiveTripModelBase::TREE),
|
||||||
initialColumnWidths(DiveTripModelBase::COLUMNS, 50) // Set up with default length 50
|
initialColumnWidths(DiveTripModelBase::COLUMNS, 50) // Set up with default length 50
|
||||||
{
|
{
|
||||||
setItemDelegate(new DiveListDelegate(this));
|
setItemDelegate(new DiveListDelegate(this));
|
||||||
|
@ -239,47 +239,6 @@ void DiveListView::rowsInserted(const QModelIndex &parent, int start, int end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this only remembers dives that were selected, not trips
|
|
||||||
void DiveListView::rememberSelection()
|
|
||||||
{
|
|
||||||
selectedDives.clear();
|
|
||||||
QItemSelection selection = selectionModel()->selection();
|
|
||||||
Q_FOREACH (const QModelIndex &index, selection.indexes()) {
|
|
||||||
if (index.column() != 0) // We only care about the dives, so, let's stick to rows and discard columns.
|
|
||||||
continue;
|
|
||||||
struct dive *d = index.data(DiveTripModelBase::DIVE_ROLE).value<struct dive *>();
|
|
||||||
if (d) {
|
|
||||||
selectedDives.insert(d->divetrip, get_divenr(d));
|
|
||||||
} else {
|
|
||||||
struct dive_trip *t = index.data(DiveTripModelBase::TRIP_ROLE).value<dive_trip *>();
|
|
||||||
if (t)
|
|
||||||
selectedDives.insert(t, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
selectionSaved = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiveListView::restoreSelection()
|
|
||||||
{
|
|
||||||
if (!selectionSaved)
|
|
||||||
return;
|
|
||||||
|
|
||||||
selectionSaved = false;
|
|
||||||
QList<int> divesToSelect;
|
|
||||||
Q_FOREACH (dive_trip_t *trip, selectedDives.keys()) {
|
|
||||||
QList<int> divesOnTrip = getDivesInTrip(trip);
|
|
||||||
QList<int> selectedDivesOnTrip = selectedDives.values(trip);
|
|
||||||
|
|
||||||
// Only select trip if all of its dives were selected
|
|
||||||
if(selectedDivesOnTrip.contains(-1)) {
|
|
||||||
selectTrip(trip);
|
|
||||||
selectedDivesOnTrip.removeAll(-1);
|
|
||||||
}
|
|
||||||
divesToSelect += selectedDivesOnTrip;
|
|
||||||
}
|
|
||||||
selectDives(divesToSelect);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is a bit ugly: we hook directly into the tripChanged signal to
|
// 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:
|
// select the trip if it was edited. This feels like a layering violation:
|
||||||
// Shouldn't the core-layer call us?
|
// Shouldn't the core-layer call us?
|
||||||
|
|
|
@ -34,8 +34,6 @@ public:
|
||||||
void selectDive(QModelIndex index, bool scrollto = false, bool toggle = false);
|
void selectDive(QModelIndex index, bool scrollto = false, bool toggle = false);
|
||||||
void selectDive(int dive_table_idx, bool scrollto = false, bool toggle = false);
|
void selectDive(int dive_table_idx, bool scrollto = false, bool toggle = false);
|
||||||
void selectDives(const QList<int> &newDiveSelection);
|
void selectDives(const QList<int> &newDiveSelection);
|
||||||
void rememberSelection();
|
|
||||||
void restoreSelection();
|
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
void contextMenuEvent(QContextMenuEvent *event);
|
||||||
QList<dive_trip *> selectedTrips();
|
QList<dive_trip *> selectedTrips();
|
||||||
static QString lastUsedImageDir();
|
static QString lastUsedImageDir();
|
||||||
|
@ -76,12 +74,9 @@ private:
|
||||||
DiveTripModelBase::Layout currentLayout;
|
DiveTripModelBase::Layout currentLayout;
|
||||||
QModelIndex contextMenuIndex;
|
QModelIndex contextMenuIndex;
|
||||||
bool dontEmitDiveChangedSignal;
|
bool dontEmitDiveChangedSignal;
|
||||||
bool selectionSaved;
|
|
||||||
// Remember the initial column widths, to avoid writing unchanged widths to the settings
|
// Remember the initial column widths, to avoid writing unchanged widths to the settings
|
||||||
QVector<int> initialColumnWidths;
|
QVector<int> initialColumnWidths;
|
||||||
|
|
||||||
/* if dive_trip_t is null, there's no problem. */
|
|
||||||
QMultiHash<dive_trip *, int> selectedDives;
|
|
||||||
void resetModel(); // Call after model changed
|
void resetModel(); // Call after model changed
|
||||||
void merge_trip(const QModelIndex &a, const int offset);
|
void merge_trip(const QModelIndex &a, const int offset);
|
||||||
void setColumnWidths();
|
void setColumnWidths();
|
||||||
|
|
Loading…
Add table
Reference in a new issue